Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add initial change set docs #3185

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/lix-sdk/docs/20-concepts/20-change.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Purpose

Store information of what changed in a [file](./10-file.md).
Stores a change for an [entity](./21-entity.md) along with a [snapshot](./22-snapshot.md).

## Description

Expand Down
25 changes: 25 additions & 0 deletions packages/lix-sdk/docs/20-concepts/21-entity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Entity

## Purpose

Defines what is being changed.

## Description

An entity is the subject of a change. It can be a file, a database table, a configuration, or any other data structure.

## Examples

### CSV File Format

An examplary csv plugin tracks changes for the rows in a csv file. Hence, the entities are `row`.

### Inlang File Format

An examplary inlang plugin tracks changes for bundles, messages and variants. Hence, the entities are `bundle`, `message`, `variant`.

### Markdown File Format

An examplary markdown plugin tracks changes for the lines in a markdown file. Hence, the entities are `line`.


44 changes: 44 additions & 0 deletions packages/lix-sdk/docs/20-concepts/22-snapshot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Snapshot

## Purpose

Stores the state of a [change](./20-change.md).

## Description

The snapshot is used to re-apply changes, revert changes, compare changes, and more.

## Technical Details

- Snapshot's are [content adressable](https://en.wikipedia.org/wiki/Content-addressable_storage) to save storage.

- IDs are generated by hashing the content of the snapshot.

- If a snapshot is empty (e.g., a file is empty), the snapshot is has a special ID `empty-content`.

## Examples

### CSV File Format

An examplary csv plugin tracks changes in rows. Hence, the snapshot is a row.

Suppose the following table is a CSV file:

| id | name | age |
|----|------|-----|
| 1 | John | 25 |

The snapshot of the row with `id=1` is:

`1, John, 25`

Someone updates John's age from 25 to 26.

| id | name | age |
|----|------|-----|
| 1 | John | 26 |

The snapshot of the row with `id=1` after the change is:

`1, John, 26`

79 changes: 79 additions & 0 deletions packages/lix-sdk/docs/20-concepts/50-change-set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Change Set

## Purpose

Group related changes.

## Description

Changes in a set are treated as a single unit. They are merged, applied, described (commentied) and undone together.

## Graph

Changes D and B are in a set.

```mermaid
graph TB
subgraph Set
direction TB
D["Change D"]
B["Change B"]
end

E["Change E"]
X["Change X"]
A["Change A"]
F["Change F"]

X --> D
B --> A
F --> B
D --> E
```

## Examples

### Discussions/Commenting

A [discussion](./90-discussion.md) points to a change set. A change set can contain 1 or many changes.

### Inventory of a deparment store

A department store sells three types of shoes: **Shoe A**, **Shoe B**, and **Shoe C**. After each day, the inventory manager updates the stock levels and re-stocking dates in a CSV file.

#### Initial Table

| Product | In Stock | Price |
|----------|----------|-------------------------------|
| Shoe A | 120 | $89 |
| Shoe B | 150 | $124 |
| Shoe C | 200 | $78 |

#### Changes

1. Change H - Update stock of **Shoe A** from 120 to 80 units.

2. Change L - Update stock of **Shoe B** from 150 to 100 units.

3. Change R - Update price of **Shoe C** from $78 to $89.

#### Change Sets

Both inventory stock changes are related because they reflect the stock level after 2022-09-01. If someone looks at the stock levels on 2022-09-01, they should see both changes.

However, the price change the manager made right after updating the stock levels is an independent change, and therefore, the store manager decided to not group it with the stock changes.

```plaintext
Change Set 1

- Comment: Update Stock Levels - date 2022-09-01
- Changes: [Change H, Change L]
```

```plaintext
Change Set 2

- Comment: Increased the price due to high demand
- Changes: [Change R]
```

Loading