fluid-framework 2.43.0-343119 → 2.43.0

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,194 @@
1
1
  # fluid-framework
2
2
 
3
+ ## 2.43.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Tree's enum schema utility are now beta ([#24749](https://github.com/microsoft/FluidFramework/pull/24749)) [a23bc9e4d02](https://github.com/microsoft/FluidFramework/commit/a23bc9e4d025f0925d09daadc2952bf0bfacc06b)
8
+
9
+ The functions [singletonSchema](https://fluidframework.com/docs/api/tree/#singletonschema-function), [adaptEnum](https://fluidframework.com/docs/api/tree/#adaptenum-function) and [enumFromStrings](https://fluidframework.com/docs/api/tree/#enumfromstrings-function) are now `@beta` instead of `@alpha`.
10
+
11
+ - Add TreeAlpha.child and TreeAlpha.children APIs for generic tree traversal ([#24723](https://github.com/microsoft/FluidFramework/pull/24723)) [87941b7fa05](https://github.com/microsoft/FluidFramework/commit/87941b7fa0575e030344079a25f65d25d8457367)
12
+
13
+ #### TreeAlpha.child
14
+
15
+ Access a child node or value of a `TreeNode` by its property key.
16
+
17
+ ```typescript
18
+ class MyObject extends schemaFactory.object("MyObject", {
19
+ foo: schemaFactory.string;
20
+ bar: schemaFactory.optional(schemaFactory.string);
21
+ }) {}
22
+
23
+ const myObject = new MyObject({
24
+ foo: "Hello world!"
25
+ });
26
+
27
+ const foo = TreeAlpha.child(myObject, "foo"); // "Hello world!"
28
+ const bar = TreeAlpha.child(myObject, "bar"); // undefined
29
+ const baz = TreeAlpha.child(myObject, "baz"); // undefined
30
+ ```
31
+
32
+ ```typescript
33
+ class MyArray extends schemaFactory.array("MyArray", schemaFactory.string) {}
34
+
35
+ const myArray = new MyArray("Hello", "World");
36
+
37
+ const child0 = TreeAlpha.child(myArray, 0); // "Hello"
38
+ const child1 = TreeAlpha.child(myArray, 1); // "World
39
+ const child2 = TreeAlpha.child(myArray, 2); // undefined
40
+ ```
41
+
42
+ #### TreeAlpha.children
43
+
44
+ Get all child nodes / values of a `TreeNode`, keyed by their property keys.
45
+
46
+ ```typescript
47
+ class MyObject extends schemaFactory.object("MyObject", {
48
+ foo: schemaFactory.string;
49
+ bar: schemaFactory.optional(schemaFactory.string);
50
+ baz: schemaFactory.optional(schemaFactory.number);
51
+ }) {}
52
+
53
+ const myObject = new MyObject({
54
+ foo: "Hello world!",
55
+ baz: 42,
56
+ });
57
+
58
+ const children = TreeAlpha.children(myObject); // [["foo", "Hello world!"], ["baz", 42]]
59
+ ```
60
+
61
+ ```typescript
62
+ class MyArray extends schemaFactory.array("MyArray", schemaFactory.string) {}
63
+
64
+ const myArray = new MyArray("Hello", "World");
65
+
66
+ const children = TreeAlpha.children(myObject); // [[0, "Hello"], [1, "World"]]
67
+ ```
68
+
69
+ - Rename and change type of annotatedAllowedTypeSet on FieldSchemaAlpha to more closely align with allowedTypesSet ([#24820](https://github.com/microsoft/FluidFramework/pull/24820)) [f4e8dc8cd09](https://github.com/microsoft/FluidFramework/commit/f4e8dc8cd09f052f21e436e2c0584a1a34d2be77)
70
+
71
+ This changes the `annotatedAllowedTypeSet` property on [`FieldSchemaAlpha`](https://fluidframework.com/docs/api/fluid-framework/fieldschemaalpha-class).
72
+ It is now called `annotatedAllowedTypesNormalized` and stores evaluated schemas along with their annotations in a list of objects rather than as a mapping from the schemas to their annotations. This makes the API easier to use and better aligns with the current public APIs.
73
+
74
+ - Persisted metadata for Shared Tree schemas (Alpha) ([#24812](https://github.com/microsoft/FluidFramework/pull/24812)) [3f81ab52ff7](https://github.com/microsoft/FluidFramework/commit/3f81ab52ff7265a8533c0e192c8b77d298b70eea)
75
+
76
+ The persisted metadata feature for Shared Tree allows an application author to write document-persisted metadata along with the schema. This feature is supported for both node and field schemas.
77
+
78
+ #### Using the persisted metadata feature
79
+
80
+ As of now, persisted metadata support is available via the SchemaFactoryAlpha API:
81
+
82
+ ```ts
83
+ // Construct a schema factory with alpha APIs
84
+ const schemaFactory = new SchemaFactoryAlpha("com.example");
85
+ ```
86
+
87
+ Persisted metadata can take the shape of any JSON-serializable object, e.g.:
88
+
89
+ ```ts
90
+ const persistedMetadata = { a: 2 };
91
+ ```
92
+
93
+ #### Feature flag
94
+
95
+ To enable persisted metadata, use `configuredSharedTree` to specify the format version. The tree that is returned can be substituted in place of the default `SharedTree` object exported by the Fluid Framework. For example:
96
+
97
+ ```ts
98
+ const tree = configuredSharedTree({
99
+ formatVersion: SharedTreeFormatVersion.v5,
100
+ }).create(runtime);
101
+
102
+ export const MyContainerSchema = {
103
+ initialObjects: {
104
+ appData: tree,
105
+ },
106
+ } satisfies ContainerSchema;
107
+ ```
108
+
109
+ #### Examples
110
+
111
+ ##### Field schemas with persisted metadata
112
+
113
+ ```ts
114
+ // Construct a schema factory with alpha APIs
115
+ const schemaFactory = new SchemaFactoryAlpha("com.example");
116
+
117
+ // Define metadata. This can take the shape of any JSON-serializable object.
118
+ const persistedMetadata = { a: 2 };
119
+
120
+ // Foo is an object type with metadata
121
+ class Foo extends schemaFactory.objectAlpha(
122
+ "Foo",
123
+ {
124
+ // Metadata for a required number field
125
+ bar: schemaFactory.required(schemaFactory.number, { persistedMetadata }),
126
+
127
+ // Metadata for an optional string field
128
+ baz: schemaFactory.optional(schemaFactory.string, { persistedMetadata }),
129
+ // Metadata for the object type Foo
130
+ },
131
+ { persistedMetadata },
132
+ ) {}
133
+ ```
134
+
135
+ ##### Recursive field schemas
136
+
137
+ ```ts
138
+ // Construct a schema factory with alpha APIs
139
+ const schemaFactory = new SchemaFactoryAlpha("com.example");
140
+
141
+ // Define metadata. This can take the shape of any JSON-serializable object.
142
+ const persistedMetadata = { a: 2 };
143
+
144
+ // Recursive object schema with persisted metadata
145
+ class RecursiveObject extends schemaFactory.objectRecursive(
146
+ "RecursiveObject",
147
+ {
148
+ x: [() => RecursiveObject, schemaFactory.number],
149
+ },
150
+ { persistedMetadata },
151
+ ) {}
152
+
153
+ // Recursive field schema with metadata
154
+ const recursiveField = schemaFactory.optionalRecursive(
155
+ [() => RecursiveObject, schemaFactory.number],
156
+ { persistedMetadata },
157
+ );
158
+ ```
159
+
160
+ ##### Recursive object schemas
161
+
162
+ ```ts
163
+ // Construct a schema factory with alpha APIs
164
+ const schemaFactory = new SchemaFactoryAlpha("com.example");
165
+
166
+ // Define metadata. This can take the shape of any JSON-serializable object.
167
+ const persistedMetadata = { a: 2 };
168
+
169
+ // Recursive array schema
170
+ class Foos extends schemaFactory.arrayRecursive("FooList", [() => Foo], {
171
+ persistedMetadata,
172
+ }) {}
173
+
174
+ // Recursive object schema
175
+ class Foo extends schemaFactory.objectRecursive(
176
+ "Foo",
177
+ { fooList: Foos },
178
+ { persistedMetadata },
179
+ ) {}
180
+
181
+ // Recursive map schema
182
+ class FooMap extends schemaFactory.mapRecursive("FooMap", [() => Foo], {
183
+ persistedMetadata,
184
+ }) {}
185
+ ```
186
+
187
+ - Improved Schema Validation ([#24866](https://github.com/microsoft/FluidFramework/pull/24866)) [caae4ae15ed](https://github.com/microsoft/FluidFramework/commit/caae4ae15edeb8aeae33b0520b18dbb1993965f6)
188
+
189
+ When constructing a [`TreeViewConfiguration`](https://fluidframework.com/docs/api/fluid-framework/treeviewconfiguration-class), the same schema listed more than once in a given [`AllowedTypes`](https://fluidframework.com/docs/api/fluid-framework/allowedtypes-typealias) is now an error even when [`preventAmbiguity`](https://fluidframework.com/docs/api/fluid-framework/treeviewconfiguration-class#preventambiguity-property) is false.
190
+ Previously a bug resulted in this only being rejected when `preventAmbiguity` was true.
191
+
3
192
  ## 2.42.0
4
193
 
5
194
  ### Minor Changes
@@ -32,9 +32,9 @@ export interface AllowedTypesMetadata {
32
32
  export function allowUnused<T>(t?: T): void;
33
33
 
34
34
  // @alpha
35
- export interface AnnotatedAllowedType<T extends TreeNodeSchema = TreeNodeSchema> {
35
+ export interface AnnotatedAllowedType<T = LazyItem<TreeNodeSchema>> {
36
36
  readonly metadata: AllowedTypeMetadata;
37
- readonly type: LazyItem<T>;
37
+ readonly type: T;
38
38
  }
39
39
 
40
40
  // @alpha
@@ -258,7 +258,7 @@ export class FieldSchemaAlpha<Kind extends FieldKind = FieldKind, Types extends
258
258
  readonly allowedTypesMetadata: AllowedTypesMetadata;
259
259
  // (undocumented)
260
260
  readonly annotatedAllowedTypes: ImplicitAnnotatedAllowedTypes;
261
- get annotatedAllowedTypeSet(): ReadonlyMap<TreeNodeSchema, AllowedTypeMetadata>;
261
+ get annotatedAllowedTypesNormalized(): NormalizedAnnotatedAllowedTypes;
262
262
  get persistedMetadata(): JsonCompatibleReadOnlyObject | undefined;
263
263
  }
264
264
 
@@ -970,6 +970,12 @@ export interface NodeSchemaOptionsAlpha<out TCustomMetadata = unknown> extends N
970
970
  // @alpha
971
971
  export const noopValidator: JsonValidator;
972
972
 
973
+ // @alpha
974
+ export interface NormalizedAnnotatedAllowedTypes {
975
+ readonly metadata: AllowedTypesMetadata;
976
+ readonly types: readonly AnnotatedAllowedType<TreeNodeSchema>[];
977
+ }
978
+
973
979
  // @public @system
974
980
  export type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = RestrictiveStringRecord<ImplicitFieldSchema> extends T ? {} : {
975
981
  -readonly [Property in keyof T]: Property extends string ? TreeFieldFromImplicitField<T[Property]> : unknown;
@@ -1598,6 +1604,8 @@ export const Tree: Tree;
1598
1604
  // @alpha @sealed @system
1599
1605
  export interface TreeAlpha {
1600
1606
  branch(node: TreeNode): TreeBranch | undefined;
1607
+ child(node: TreeNode, key: string | number): TreeNode | TreeLeafValue | undefined;
1608
+ children(node: TreeNode): Iterable<[propertyKey: string | number, child: TreeNode | TreeLeafValue]>;
1601
1609
  create<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(schema: UnsafeUnknownSchema extends TSchema ? ImplicitFieldSchema : TSchema & ImplicitFieldSchema, data: InsertableField<TSchema>): Unhydrated<TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeNode | TreeLeafValue | undefined>;
1602
1610
  exportCompressed(tree: TreeNode | TreeLeafValue, options: {
1603
1611
  idCompressor?: IIdCompressor;
@@ -1835,6 +1843,7 @@ export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | Unsa
1835
1843
  // @public @sealed
1836
1844
  export class TreeViewConfiguration<const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> implements Required<ITreeViewConfiguration<TSchema>> {
1837
1845
  constructor(props: ITreeViewConfiguration<TSchema>);
1846
+ protected readonly definitionsInternal: ReadonlyMap<string, TreeNodeSchema>;
1838
1847
  readonly enableSchemaValidation: boolean;
1839
1848
  readonly preventAmbiguity: boolean;
1840
1849
  readonly schema: TSchema;
@@ -1845,7 +1854,7 @@ export class TreeViewConfiguration<const TSchema extends ImplicitFieldSchema = I
1845
1854
  // @alpha @sealed
1846
1855
  export class TreeViewConfigurationAlpha<const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> extends TreeViewConfiguration<TSchema> implements TreeSchema {
1847
1856
  constructor(props: ITreeViewConfiguration<TSchema>);
1848
- readonly definitions: ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;
1857
+ get definitions(): ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;
1849
1858
  readonly root: FieldSchemaAlpha;
1850
1859
  }
1851
1860
 
@@ -1018,6 +1018,7 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
1018
1018
  // @public @sealed
1019
1019
  export class TreeViewConfiguration<const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> implements Required<ITreeViewConfiguration<TSchema>> {
1020
1020
  constructor(props: ITreeViewConfiguration<TSchema>);
1021
+ protected readonly definitionsInternal: ReadonlyMap<string, TreeNodeSchema>;
1021
1022
  readonly enableSchemaValidation: boolean;
1022
1023
  readonly preventAmbiguity: boolean;
1023
1024
  readonly schema: TSchema;
@@ -431,7 +431,7 @@ export interface IInterval {
431
431
  compareEnd(b: IInterval): number;
432
432
  compareStart(b: IInterval): number;
433
433
  // @deprecated
434
- modify(label: string, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number, useNewSlidingBehavior?: boolean): IInterval | undefined;
434
+ modify(label: string, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number, canSlideToEndpoint?: boolean): IInterval | undefined;
435
435
  // (undocumented)
436
436
  overlaps(b: IInterval): boolean;
437
437
  // @deprecated
@@ -1047,7 +1047,7 @@ export interface SequenceInterval extends ISerializableInterval {
1047
1047
  // (undocumented)
1048
1048
  readonly intervalType: IntervalType;
1049
1049
  // @deprecated
1050
- modify(label: string, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number, useNewSlidingBehavior?: boolean): SequenceInterval | undefined;
1050
+ modify(label: string, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number, canSlideToEndpoint?: boolean): SequenceInterval | undefined;
1051
1051
  // (undocumented)
1052
1052
  overlaps(b: SequenceInterval): boolean;
1053
1053
  // (undocumented)
@@ -1351,6 +1351,7 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
1351
1351
  // @public @sealed
1352
1352
  export class TreeViewConfiguration<const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> implements Required<ITreeViewConfiguration<TSchema>> {
1353
1353
  constructor(props: ITreeViewConfiguration<TSchema>);
1354
+ protected readonly definitionsInternal: ReadonlyMap<string, TreeNodeSchema>;
1354
1355
  readonly enableSchemaValidation: boolean;
1355
1356
  readonly preventAmbiguity: boolean;
1356
1357
  readonly schema: TSchema;
@@ -1003,6 +1003,7 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
1003
1003
  // @public @sealed
1004
1004
  export class TreeViewConfiguration<const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> implements Required<ITreeViewConfiguration<TSchema>> {
1005
1005
  constructor(props: ITreeViewConfiguration<TSchema>);
1006
+ protected readonly definitionsInternal: ReadonlyMap<string, TreeNodeSchema>;
1006
1007
  readonly enableSchemaValidation: boolean;
1007
1008
  readonly preventAmbiguity: boolean;
1008
1009
  readonly schema: TSchema;
@@ -969,6 +969,7 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
969
969
  // @public @sealed
970
970
  export class TreeViewConfiguration<const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> implements Required<ITreeViewConfiguration<TSchema>> {
971
971
  constructor(props: ITreeViewConfiguration<TSchema>);
972
+ protected readonly definitionsInternal: ReadonlyMap<string, TreeNodeSchema>;
972
973
  readonly enableSchemaValidation: boolean;
973
974
  readonly preventAmbiguity: boolean;
974
975
  readonly schema: TSchema;
package/dist/alpha.d.ts CHANGED
@@ -200,6 +200,7 @@ export {
200
200
  MapNodePojoEmulationSchema,
201
201
  MapNodeSchema,
202
202
  NodeSchemaOptionsAlpha,
203
+ NormalizedAnnotatedAllowedTypes,
203
204
  ObjectNodeSchema,
204
205
  ReadSchema,
205
206
  ReadableField,
package/lib/alpha.d.ts CHANGED
@@ -200,6 +200,7 @@ export {
200
200
  MapNodePojoEmulationSchema,
201
201
  MapNodeSchema,
202
202
  NodeSchemaOptionsAlpha,
203
+ NormalizedAnnotatedAllowedTypes,
203
204
  ObjectNodeSchema,
204
205
  ReadSchema,
205
206
  ReadableField,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluid-framework",
3
- "version": "2.43.0-343119",
3
+ "version": "2.43.0",
4
4
  "description": "The main entry point into Fluid Framework public packages",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -57,24 +57,24 @@
57
57
  "main": "lib/index.js",
58
58
  "types": "lib/public.d.ts",
59
59
  "dependencies": {
60
- "@fluidframework/container-definitions": "2.43.0-343119",
61
- "@fluidframework/container-loader": "2.43.0-343119",
62
- "@fluidframework/core-interfaces": "2.43.0-343119",
63
- "@fluidframework/core-utils": "2.43.0-343119",
64
- "@fluidframework/driver-definitions": "2.43.0-343119",
65
- "@fluidframework/fluid-static": "2.43.0-343119",
66
- "@fluidframework/map": "2.43.0-343119",
67
- "@fluidframework/runtime-utils": "2.43.0-343119",
68
- "@fluidframework/sequence": "2.43.0-343119",
69
- "@fluidframework/shared-object-base": "2.43.0-343119",
70
- "@fluidframework/tree": "2.43.0-343119"
60
+ "@fluidframework/container-definitions": "~2.43.0",
61
+ "@fluidframework/container-loader": "~2.43.0",
62
+ "@fluidframework/core-interfaces": "~2.43.0",
63
+ "@fluidframework/core-utils": "~2.43.0",
64
+ "@fluidframework/driver-definitions": "~2.43.0",
65
+ "@fluidframework/fluid-static": "~2.43.0",
66
+ "@fluidframework/map": "~2.43.0",
67
+ "@fluidframework/runtime-utils": "~2.43.0",
68
+ "@fluidframework/sequence": "~2.43.0",
69
+ "@fluidframework/shared-object-base": "~2.43.0",
70
+ "@fluidframework/tree": "~2.43.0"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@arethetypeswrong/cli": "^0.17.1",
74
74
  "@biomejs/biome": "~1.9.3",
75
- "@fluid-tools/build-cli": "^0.55.0",
75
+ "@fluid-tools/build-cli": "^0.56.0",
76
76
  "@fluidframework/build-common": "^2.0.3",
77
- "@fluidframework/build-tools": "^0.55.0",
77
+ "@fluidframework/build-tools": "^0.56.0",
78
78
  "@fluidframework/eslint-config-fluid": "^5.7.4",
79
79
  "@microsoft/api-extractor": "7.52.8",
80
80
  "@types/node": "^18.19.0",