Skip to content

Commit d7ede75

Browse files
Merge remote-tracking branch 'origin' into directory-oracle
2 parents b68355b + bc5a930 commit d7ede75

File tree

773 files changed

+20881
-3803
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

773 files changed

+20881
-3803
lines changed

.changeset/angry-wings-battle.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
"@fluidframework/tree": minor
3+
"fluid-framework": minor
4+
"__section": tree
5+
---
6+
Schema snapshot compatibility checker
7+
8+
This change adds alpha APIs for creating snapshots of view schema and testing their compatibility for the purposes
9+
of schema migrations.
10+
11+
New APIs:
12+
13+
- `checkCompatibility` - Checks the compatibility of the view schema which created the document against the view schema
14+
being used to open it.
15+
- `importCompatibilitySchemaSnapshot` - Parse a JSON representation of a tree schema into a concrete schema.
16+
- `exportCompatibilitySchemaSnapshot` - Returns a JSON representation of the tree schema for snapshot compatibility checking.
17+
18+
#### Example: Current view schema vs. historical view schema
19+
20+
An application author is developing an app that has a schema for storing 2D Points.
21+
They wish to maintain backwards compatibility in future versions and avoid changing their view schema in a way that breaks
22+
this behavior.
23+
When introducing a new initial schema, they persists a snapshot using `exportCompatibilitySchemaSnapshot`:
24+
25+
```ts
26+
const factory = new SchemaFactory("test");
27+
28+
// The past view schema, for the purposes of illustration. This wouldn't normally appear as a concrete schema in the test
29+
// checking compatibility, but rather would be loaded from a snapshot.
30+
class Point2D extends factory.object("Point", {
31+
x: factory.number,
32+
y: factory.number,
33+
}) {}
34+
const viewSchema = new TreeViewConfiguration({ schema: Point2D });
35+
const encodedSchema = JSON.stringify(exportCompatibilitySchemaSnapshot(viewSchema));
36+
fs.writeFileSync("PointSchema.json", encodedSchema);
37+
```
38+
39+
Next they create a regression test to ensure that the current view schema can read content written by the original view
40+
schema (`SchemaCompatibilityStatus.canUpgrade`). Initially `currentViewSchema === Point2D`:
41+
42+
```ts
43+
const encodedSchema = JSON.parse(fs.readFileSync("PointSchema.json", "utf8"));
44+
const oldViewSchema = importCompatibilitySchemaSnapshot(encodedSchema);
45+
46+
// Check to see if the document created by the historical view schema can be opened with the current view schema
47+
const compatibilityStatus = checkCompatibility(oldViewSchema, currentViewSchema);
48+
49+
// Check to see if the document created by the historical view schema can be opened with the current view schema
50+
const backwardsCompatibilityStatus = checkCompatibility(oldViewSchema, currentViewSchema);
51+
52+
// z is not present in Point2D, so the schema must be upgraded
53+
assert.equal(backwardsCompatibilityStatus.canView, false);
54+
55+
// The schema can be upgraded to add the new optional field
56+
assert.equal(backwardsCompatibilityStatus.canUpgrade, true);
57+
```
58+
59+
Additionally, they a regression test to ensure that older view schemas can read content written by the current view
60+
schema (`SchemaCompatibilityStatus.canView`):
61+
62+
```ts
63+
// Test what the old version of the application would do with a tree using the new schema:
64+
const forwardsCompatibilityStatus = checkCompatibility(currentViewSchema, oldViewSchema);
65+
66+
// If the old schema set allowUnknownOptionalFields, this would be true, but since it did not,
67+
// this assert will fail, detecting the forwards compatibility break:
68+
// this means these two versions of the application cannot collaborate on content using these schema.
69+
assert.equal(forwardsCompatibilityStatus.canView, true);
70+
```
71+
72+
Later in the application development cycle, the application author decides they want to change their Point2D to
73+
a Point3D, adding an extra field:
74+
75+
```ts
76+
// Build the current view schema
77+
const schemaFactory = new SchemaFactory("test");
78+
class Point3D extends schemaFactory.object("Point", {
79+
x: factory.number,
80+
y: factory.number,
81+
82+
// The current schema has a new optional field that was not present on Point2D
83+
z: factory.optional(factory.number),
84+
}) {}
85+
```
86+
87+
The test first compatibility test will pass as the Point2D schema is upgradeable to a Point3D schema.
88+
However, the second compatibility test fill fail as an application using the Point2D view schema cannot collaborate on
89+
content authored using the Point3D schema.

.changeset/big-items-stop.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

.changeset/metal-games-love.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

.changeset/sweet-groups-love.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/changeset-reporter.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ jobs:
2020
pull-requests: write # for marocchino/sticky-pull-request-comment to create or update PR comment
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # ratchet:actions/checkout@v3
23+
# release notes: https://github.com/actions/checkout/releases/tag/v5.0.0
24+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # ratchet:actions/checkout@v5
2425
with:
2526
persist-credentials: false
2627

.github/workflows/pr-changeset-review.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626
name: vale
2727
runs-on: ubuntu-latest
2828
steps:
29-
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # ratchet:actions/checkout@v3
29+
# release notes: https://github.com/actions/checkout/releases/tag/v5.0.0
30+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # ratchet:actions/checkout@v5
3031
with:
3132
persist-credentials: false
3233
- uses: errata-ai/vale-action@d89dee975228ae261d22c15adcd03578634d429c # ratchet:errata-ai/vale-action@v2.1.1

.github/workflows/pr-check-changeset.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,19 @@ jobs:
2222
runs-on: ubuntu-latest
2323
if: contains(github.event.pull_request.labels.*.name, 'changeset-required')
2424
steps:
25-
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # ratchet:actions/checkout@v3
25+
# release notes: https://github.com/actions/checkout/releases/tag/v5.0.0
26+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # ratchet:actions/checkout@v5
2627
with:
2728
fetch-depth: "0" # all history
2829
persist-credentials: false
2930
ref: ${{ github.event.pull_request.head.sha }} # Check out the head commit, not the merge commit
3031

3132
# install and configure node, pnpm and the changeset tools
32-
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # ratchet:pnpm/action-setup@v4
33-
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # ratchet:actions/setup-node@v3
33+
# release notes: https://github.com/pnpm/action-setup/releases/tag/v4.2.0
34+
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # ratchet:pnpm/action-setup@v4
35+
36+
# release notes: https://github.com/actions/setup-node/releases/tag/v6.0.0
37+
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # ratchet:actions/setup-node@v6
3438
with:
3539
node-version-file: .nvmrc
3640
cache: "pnpm"

.github/workflows/pr-release-branch-warning.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ jobs:
2121
pull-requests: write # for marocchino/sticky-pull-request-comment to create or update PR comment
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # ratchet:actions/checkout@v4
24+
# release notes: https://github.com/actions/checkout/releases/tag/v5.0.0
25+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # ratchet:actions/checkout@v5
2526
with:
2627
persist-credentials: false
2728
submodules: false

.github/workflows/pr-validation.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ jobs:
1919
name: Validate CODEOWNERS
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # ratchet:actions/checkout@v3
22+
# release notes: https://github.com/actions/checkout/releases/tag/v5.0.0
23+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # ratchet:actions/checkout@v5
2324
with:
2425
persist-credentials: false
2526
- uses: mszostok/codeowners-validator@7f3f5e28c6d7b8dfae5731e54ce2272ca384592f # ratchet:mszostok/codeowners-validator@v0.7.4

.github/workflows/push-tag-create-release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ jobs:
3535
fetch-depth: "0" # all history, including tags
3636
persist-credentials: false
3737

38-
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # ratchet:pnpm/action-setup@v4
39-
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # ratchet:actions/setup-node@v3
38+
# release notes: https://github.com/pnpm/action-setup/releases/tag/v4.2.0
39+
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # ratchet:pnpm/action-setup@v4
40+
41+
# release notes: https://github.com/actions/setup-node/releases/tag/v6.0.0
42+
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # ratchet:actions/setup-node@v6
4043
with:
4144
node-version-file: .nvmrc
4245
cache: "pnpm"

0 commit comments

Comments
 (0)