fluid-framework 2.117.0 → 2.118.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,91 @@
1
1
  # fluid-framework
2
2
 
3
+ ## 2.118.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Preserve enabled staged schema upgrades by default ([#28155](https://github.com/microsoft/FluidFramework/pull/28155)) [9b61289e943](https://github.com/microsoft/FluidFramework/commit/9b61289e9432a4e84e18d834b76d1d6818a3a6a7)
8
+
9
+ [`TreeView.upgradeSchema()`](https://fluidframework.com/docs/api/tree/treeview-interface#upgradeschema-method) now includes staged schema upgrades that are already enabled in the document, even when the view's staged upgrade policy does not select them.
10
+ This prevents a schema upgrade from accidentally attempting to narrow stored schema enabled by another client.
11
+
12
+ Set [`includeAlreadyEnabledUpgrades`](https://fluidframework.com/docs/api/tree/stagedschemaupgradepolicy-interface#includealreadyenabledupgrades-property) to `false` when creating the staged upgrade policy to require upgrades to be selected explicitly:
13
+
14
+ ```typescript
15
+ const config = new TreeViewConfigurationAlpha({
16
+ schema: AppSchema,
17
+ stagedUpgradePolicy: {
18
+ includeAlreadyEnabledUpgrades: false,
19
+ ...StagedSchemaUpgradePolicy.enabledStagedUpgrades(myUpgrade),
20
+ },
21
+ });
22
+ ```
23
+
24
+ - Expose schema incompatibility details on TreeViewBeta ([#28155](https://github.com/microsoft/FluidFramework/pull/28155)) [9b61289e943](https://github.com/microsoft/FluidFramework/commit/9b61289e9432a4e84e18d834b76d1d6818a3a6a7)
25
+
26
+ `TreeViewBeta.compatibility.discrepancies` now provides typed `SchemaDiscrepancy` objects when a view cannot access a tree because its view schema is incompatible with the stored schema.
27
+ The readonly array may include application-defined schema identifiers and field keys.
28
+ Each entry includes a `mismatch` discriminator so consumers can distinguish allowed-type, field-kind, value-schema, and node-kind differences.
29
+ Allowed-type discrepancies include staged types that are absent from the stored schema in `stagedView`, while discrepancies on staged optional fields include `viewIsStagedOptional: true`.
30
+ Staged-only differences remain compatible and do not produce discrepancies by themselves.
31
+
32
+ ```typescript
33
+ const sf = new SchemaFactory("com.example");
34
+ class Todo extends sf.object("Todo", {
35
+ title: sf.number,
36
+ }) {}
37
+
38
+ const view = asBeta(
39
+ tree.viewWith(new TreeViewConfiguration({ schema: Todo })),
40
+ );
41
+ if (!view.compatibility.canView) {
42
+ console.error(view.compatibility.discrepancies);
43
+ }
44
+ ```
45
+
46
+ If the stored schema allows `string` for `Todo.title`, the output is:
47
+
48
+ ```json
49
+ [
50
+ {
51
+ "mismatch": "allowedTypes",
52
+ "location": { "nodeType": "com.example.Todo", "fieldKey": "title" },
53
+ "view": ["com.fluidframework.leaf.number"],
54
+ "stored": ["com.fluidframework.leaf.string"]
55
+ }
56
+ ]
57
+ ```
58
+
59
+ Applications can see from `mismatch: "allowedTypes"` that the schemas differ in their allowed types, compare `view` with `stored` to determine which types each schema permits, and use `location` to find the field where the mismatch occurs.
60
+
61
+ - SharedTree schema errors now explain the mismatch ([#28153](https://github.com/microsoft/FluidFramework/pull/28153)) [850aa1f1c47](https://github.com/microsoft/FluidFramework/commit/850aa1f1c47ea737b0c8a34e826f8caac97f0a7b)
62
+
63
+ Schema validation errors now report the mismatch category and attach relevant diagnostic context. Depending on the mismatch, tagged telemetry properties identify the node type, field kind, child count, expected leaf value type, actual value type, unexpected fields, or path, making invalid content easier to diagnose while allowing consumers to filter potentially sensitive user data.
64
+
65
+ When a view schema cannot access a document's stored schema, the error now reports the first schema mismatch and explains whether to initialize the document, upgrade its stored schema, use a compatible view schema, or explicitly migrate the document.
66
+
67
+ - TreeViewAlpha can now query whether a staged schema upgrade has been applied ([#28154](https://github.com/microsoft/FluidFramework/pull/28154)) [0ea7aa88589](https://github.com/microsoft/FluidFramework/commit/0ea7aa885896ba58fb063fdbc3ee1c66dbd6b8e1)
68
+
69
+ A new [`isStagedUpgradeEnabled`](https://fluidframework.com/docs/api/tree/treeviewalpha-interface#isstagedupgradeenabled-methodsignature) method on [`TreeViewAlpha`](https://fluidframework.com/docs/api/tree/treeviewalpha-interface) checks whether a given [`SchemaUpgrade`](https://fluidframework.com/docs/api/tree/schemaupgrade-typealias) token has already been applied to a document's stored schema.
70
+
71
+ This is useful when gradually rolling out a staged schema upgrade via feature flags — for example, to conditionally include the upgrade token in the view configuration after a flag rollback, or to show UI that depends on the upgraded schema.
72
+
73
+ ```typescript
74
+ const view = tree.viewWith(
75
+ new TreeViewConfigurationAlpha({
76
+ schema: mySchema,
77
+ stagedUpgradePolicy: featureFlag.isEnabled
78
+ ? StagedSchemaUpgradePolicy.enabledStagedUpgrades(myUpgrade)
79
+ : StagedSchemaUpgradePolicy.restrictive,
80
+ }),
81
+ );
82
+
83
+ // Show a "create poll" button only if the document supports the new poll schema
84
+ if (view.isStagedUpgradeEnabled(myUpgrade)) {
85
+ showCreatePollButton();
86
+ }
87
+ ```
88
+
3
89
  ## 2.117.0
4
90
 
5
91
  ### Minor Changes
@@ -1269,7 +1269,7 @@ export interface ITreeViewConfiguration<TSchema extends ImplicitFieldSchema = Im
1269
1269
  readonly schema: TSchema;
1270
1270
  }
1271
1271
 
1272
- // @alpha
1272
+ // @alpha @input
1273
1273
  export interface ITreeViewConfigurationAlpha<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> extends ITreeViewConfiguration<TSchema> {
1274
1274
  readonly stagedUpgradePolicy?: StagedSchemaUpgradePolicy;
1275
1275
  }
@@ -1813,6 +1813,43 @@ export interface SchemaCompatibilityStatus {
1813
1813
  readonly isEquivalent: boolean;
1814
1814
  }
1815
1815
 
1816
+ // @beta @sealed
1817
+ export interface SchemaCompatibilityStatusBeta extends SchemaCompatibilityStatus {
1818
+ readonly discrepancies: readonly SchemaDiscrepancy[] | undefined;
1819
+ }
1820
+
1821
+ // @beta @sealed
1822
+ export type SchemaDiscrepancy = {
1823
+ readonly mismatch: "allowedTypes";
1824
+ readonly location: "root" | {
1825
+ readonly nodeType: string;
1826
+ readonly fieldKey: string | undefined;
1827
+ };
1828
+ readonly view: readonly string[];
1829
+ readonly stagedView?: readonly string[];
1830
+ readonly stored: readonly string[];
1831
+ readonly viewIsStagedOptional?: true;
1832
+ } | {
1833
+ readonly mismatch: "fieldKind";
1834
+ readonly location: "root" | {
1835
+ readonly nodeType: string;
1836
+ readonly fieldKey: string | undefined;
1837
+ };
1838
+ readonly view: string;
1839
+ readonly stored: string;
1840
+ readonly viewIsStagedOptional?: true;
1841
+ } | {
1842
+ readonly mismatch: "valueSchema";
1843
+ readonly nodeType: string;
1844
+ readonly view: string | undefined;
1845
+ readonly stored: string | undefined;
1846
+ } | {
1847
+ readonly mismatch: "nodeKind";
1848
+ readonly nodeType: string;
1849
+ readonly view: string;
1850
+ readonly stored: string;
1851
+ };
1852
+
1816
1853
  // @public @sealed
1817
1854
  export class SchemaFactory<out TScope extends string | undefined = string | undefined, TName extends number | string = string> extends SchemaFactory_base {
1818
1855
  constructor(
@@ -2136,6 +2173,7 @@ export interface SnapshotSchemaCompatibilityOptions {
2136
2173
 
2137
2174
  // @alpha @input
2138
2175
  export interface StagedSchemaUpgradePolicy {
2176
+ readonly includeAlreadyEnabledUpgrades?: boolean;
2139
2177
  includeStaged(upgrade: SchemaUpgrade): boolean;
2140
2178
  includeStagedOptional(upgrade: SchemaUpgrade): boolean;
2141
2179
  }
@@ -2150,6 +2188,9 @@ export interface StagedSchemaUpgradePolicyFactory {
2150
2188
  readonly restrictive: StagedSchemaUpgradePolicy;
2151
2189
  }
2152
2190
 
2191
+ // @alpha
2192
+ export type StagedUpgradeStatus = "disabled" | "partial" | "enabled";
2193
+
2153
2194
  // @alpha @sealed @system
2154
2195
  export type StringSchema = LeafSchema<"string", string> & SimpleLeafNodeSchema;
2155
2196
 
@@ -2766,6 +2807,7 @@ export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | Unsa
2766
2807
  // (undocumented)
2767
2808
  fork(): ReturnType<UntypedTreeView["fork"]> & TreeViewAlpha<TSchema>;
2768
2809
  initialize(content: InsertableField<TSchema>): void;
2810
+ isStagedUpgradeEnabled(upgrade: SchemaUpgrade): StagedUpgradeStatus;
2769
2811
  // (undocumented)
2770
2812
  get root(): ReadableField<TSchema>;
2771
2813
  set root(newRoot: InsertableField<TSchema>);
@@ -2773,6 +2815,7 @@ export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | Unsa
2773
2815
 
2774
2816
  // @beta @sealed
2775
2817
  export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, UntypedTreeView {
2818
+ readonly compatibility: SchemaCompatibilityStatusBeta;
2776
2819
  // (undocumented)
2777
2820
  fork(): ReturnType<UntypedTreeView["fork"]> & TreeViewBeta<TSchema>;
2778
2821
  runTransaction<TOut extends TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void>(transaction: () => TOut, params?: RunTransactionParamsBeta): TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult;
@@ -994,6 +994,43 @@ export interface SchemaCompatibilityStatus {
994
994
  readonly isEquivalent: boolean;
995
995
  }
996
996
 
997
+ // @beta @sealed
998
+ export interface SchemaCompatibilityStatusBeta extends SchemaCompatibilityStatus {
999
+ readonly discrepancies: readonly SchemaDiscrepancy[] | undefined;
1000
+ }
1001
+
1002
+ // @beta @sealed
1003
+ export type SchemaDiscrepancy = {
1004
+ readonly mismatch: "allowedTypes";
1005
+ readonly location: "root" | {
1006
+ readonly nodeType: string;
1007
+ readonly fieldKey: string | undefined;
1008
+ };
1009
+ readonly view: readonly string[];
1010
+ readonly stagedView?: readonly string[];
1011
+ readonly stored: readonly string[];
1012
+ readonly viewIsStagedOptional?: true;
1013
+ } | {
1014
+ readonly mismatch: "fieldKind";
1015
+ readonly location: "root" | {
1016
+ readonly nodeType: string;
1017
+ readonly fieldKey: string | undefined;
1018
+ };
1019
+ readonly view: string;
1020
+ readonly stored: string;
1021
+ readonly viewIsStagedOptional?: true;
1022
+ } | {
1023
+ readonly mismatch: "valueSchema";
1024
+ readonly nodeType: string;
1025
+ readonly view: string | undefined;
1026
+ readonly stored: string | undefined;
1027
+ } | {
1028
+ readonly mismatch: "nodeKind";
1029
+ readonly nodeType: string;
1030
+ readonly view: string;
1031
+ readonly stored: string;
1032
+ };
1033
+
997
1034
  // @public @sealed
998
1035
  export class SchemaFactory<out TScope extends string | undefined = string | undefined, TName extends number | string = string> extends SchemaFactory_base {
999
1036
  constructor(
@@ -1598,6 +1635,7 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
1598
1635
 
1599
1636
  // @beta @sealed
1600
1637
  export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, UntypedTreeView {
1638
+ readonly compatibility: SchemaCompatibilityStatusBeta;
1601
1639
  // (undocumented)
1602
1640
  fork(): ReturnType<UntypedTreeView["fork"]> & TreeViewBeta<TSchema>;
1603
1641
  runTransaction<TOut extends TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void>(transaction: () => TOut, params?: RunTransactionParamsBeta): TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult;
@@ -1280,6 +1280,43 @@ export interface SchemaCompatibilityStatus {
1280
1280
  readonly isEquivalent: boolean;
1281
1281
  }
1282
1282
 
1283
+ // @beta @sealed
1284
+ export interface SchemaCompatibilityStatusBeta extends SchemaCompatibilityStatus {
1285
+ readonly discrepancies: readonly SchemaDiscrepancy[] | undefined;
1286
+ }
1287
+
1288
+ // @beta @sealed
1289
+ export type SchemaDiscrepancy = {
1290
+ readonly mismatch: "allowedTypes";
1291
+ readonly location: "root" | {
1292
+ readonly nodeType: string;
1293
+ readonly fieldKey: string | undefined;
1294
+ };
1295
+ readonly view: readonly string[];
1296
+ readonly stagedView?: readonly string[];
1297
+ readonly stored: readonly string[];
1298
+ readonly viewIsStagedOptional?: true;
1299
+ } | {
1300
+ readonly mismatch: "fieldKind";
1301
+ readonly location: "root" | {
1302
+ readonly nodeType: string;
1303
+ readonly fieldKey: string | undefined;
1304
+ };
1305
+ readonly view: string;
1306
+ readonly stored: string;
1307
+ readonly viewIsStagedOptional?: true;
1308
+ } | {
1309
+ readonly mismatch: "valueSchema";
1310
+ readonly nodeType: string;
1311
+ readonly view: string | undefined;
1312
+ readonly stored: string | undefined;
1313
+ } | {
1314
+ readonly mismatch: "nodeKind";
1315
+ readonly nodeType: string;
1316
+ readonly view: string;
1317
+ readonly stored: string;
1318
+ };
1319
+
1283
1320
  // @public @sealed
1284
1321
  export class SchemaFactory<out TScope extends string | undefined = string | undefined, TName extends number | string = string> extends SchemaFactory_base {
1285
1322
  constructor(
@@ -1964,6 +2001,7 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
1964
2001
 
1965
2002
  // @beta @sealed
1966
2003
  export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, UntypedTreeView {
2004
+ readonly compatibility: SchemaCompatibilityStatusBeta;
1967
2005
  // (undocumented)
1968
2006
  fork(): ReturnType<UntypedTreeView["fork"]> & TreeViewBeta<TSchema>;
1969
2007
  runTransaction<TOut extends TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void>(transaction: () => TOut, params?: RunTransactionParamsBeta): TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult;
package/dist/alpha.d.ts CHANGED
@@ -179,6 +179,8 @@ export {
179
179
  PopUnion,
180
180
  RecordNodeInsertableData,
181
181
  RunTransactionParamsBeta,
182
+ SchemaCompatibilityStatusBeta,
183
+ SchemaDiscrepancy,
182
184
  SchemaFactoryBeta,
183
185
  SchemaStaticsBeta,
184
186
  SchemaUpgrade,
@@ -358,6 +360,7 @@ export {
358
360
  SimpleTreeSchema,
359
361
  StagedSchemaUpgradePolicy,
360
362
  StagedSchemaUpgradePolicyFactory,
363
+ StagedUpgradeStatus,
361
364
  StringSchema,
362
365
  TransactionCallbackStatusAlpha,
363
366
  TransactionConstraintAlpha,
package/dist/beta.d.ts CHANGED
@@ -179,6 +179,8 @@ export {
179
179
  PopUnion,
180
180
  RecordNodeInsertableData,
181
181
  RunTransactionParamsBeta,
182
+ SchemaCompatibilityStatusBeta,
183
+ SchemaDiscrepancy,
182
184
  SchemaFactoryBeta,
183
185
  SchemaStaticsBeta,
184
186
  SchemaUpgrade,
package/dist/legacy.d.ts CHANGED
@@ -186,6 +186,8 @@ export {
186
186
  PopUnion,
187
187
  RecordNodeInsertableData,
188
188
  RunTransactionParamsBeta,
189
+ SchemaCompatibilityStatusBeta,
190
+ SchemaDiscrepancy,
189
191
  SchemaFactoryBeta,
190
192
  SchemaStaticsBeta,
191
193
  SchemaUpgrade,
package/lib/alpha.d.ts CHANGED
@@ -179,6 +179,8 @@ export {
179
179
  PopUnion,
180
180
  RecordNodeInsertableData,
181
181
  RunTransactionParamsBeta,
182
+ SchemaCompatibilityStatusBeta,
183
+ SchemaDiscrepancy,
182
184
  SchemaFactoryBeta,
183
185
  SchemaStaticsBeta,
184
186
  SchemaUpgrade,
@@ -358,6 +360,7 @@ export {
358
360
  SimpleTreeSchema,
359
361
  StagedSchemaUpgradePolicy,
360
362
  StagedSchemaUpgradePolicyFactory,
363
+ StagedUpgradeStatus,
361
364
  StringSchema,
362
365
  TransactionCallbackStatusAlpha,
363
366
  TransactionConstraintAlpha,
package/lib/beta.d.ts CHANGED
@@ -179,6 +179,8 @@ export {
179
179
  PopUnion,
180
180
  RecordNodeInsertableData,
181
181
  RunTransactionParamsBeta,
182
+ SchemaCompatibilityStatusBeta,
183
+ SchemaDiscrepancy,
182
184
  SchemaFactoryBeta,
183
185
  SchemaStaticsBeta,
184
186
  SchemaUpgrade,
package/lib/legacy.d.ts CHANGED
@@ -186,6 +186,8 @@ export {
186
186
  PopUnion,
187
187
  RecordNodeInsertableData,
188
188
  RunTransactionParamsBeta,
189
+ SchemaCompatibilityStatusBeta,
190
+ SchemaDiscrepancy,
189
191
  SchemaFactoryBeta,
190
192
  SchemaStaticsBeta,
191
193
  SchemaUpgrade,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluid-framework",
3
- "version": "2.117.0",
3
+ "version": "2.118.1",
4
4
  "description": "The main entry point into Fluid Framework public packages",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -57,17 +57,17 @@
57
57
  "main": "lib/index.js",
58
58
  "types": "lib/public.d.ts",
59
59
  "dependencies": {
60
- "@fluidframework/container-definitions": "~2.117.0",
61
- "@fluidframework/container-loader": "~2.117.0",
62
- "@fluidframework/core-interfaces": "~2.117.0",
63
- "@fluidframework/core-utils": "~2.117.0",
64
- "@fluidframework/driver-definitions": "~2.117.0",
65
- "@fluidframework/fluid-static": "~2.117.0",
66
- "@fluidframework/map": "~2.117.0",
67
- "@fluidframework/runtime-utils": "~2.117.0",
68
- "@fluidframework/sequence": "~2.117.0",
69
- "@fluidframework/shared-object-base": "~2.117.0",
70
- "@fluidframework/tree": "~2.117.0"
60
+ "@fluidframework/container-definitions": "~2.118.1",
61
+ "@fluidframework/container-loader": "~2.118.1",
62
+ "@fluidframework/core-interfaces": "~2.118.1",
63
+ "@fluidframework/core-utils": "~2.118.1",
64
+ "@fluidframework/driver-definitions": "~2.118.1",
65
+ "@fluidframework/fluid-static": "~2.118.1",
66
+ "@fluidframework/map": "~2.118.1",
67
+ "@fluidframework/runtime-utils": "~2.118.1",
68
+ "@fluidframework/sequence": "~2.118.1",
69
+ "@fluidframework/shared-object-base": "~2.118.1",
70
+ "@fluidframework/tree": "~2.118.1"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@arethetypeswrong/cli": "^0.18.5",