fluid-framework 2.23.0 → 2.30.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,43 @@
1
1
  # fluid-framework
2
2
 
3
+ ## 2.30.0
4
+
5
+ ### Minor Changes
6
+
7
+ - New SchemaFactoryAlpha.scopedFactory method ([#23987](https://github.com/microsoft/FluidFramework/pull/23987)) [cddd5139c3](https://github.com/microsoft/FluidFramework/commit/cddd5139c3e070ef26db55331528435a99c0a1b1)
8
+
9
+ The [`SchemaFactoryAlpha.scopedFactory`](https://fluidframework.com/docs/api/fluid-framework/schemafactoryalpha-class)
10
+ method has been added, providing an easy way to create a new `SchemaFactory` with a nested scope string.
11
+
12
+ - TreeBranchEvents now exposes the rootChanged event ([#24014](https://github.com/microsoft/FluidFramework/pull/24014)) [702a08af83](https://github.com/microsoft/FluidFramework/commit/702a08af83206c21e1016ca47051052fa8554aa5)
13
+
14
+ `TreeBranchEvents` now includes the `rootChanged` event from `TreeViewEvents`.
15
+
16
+ - Alpha APIs for replacing handles in export formats have been redesigned ([#24061](https://github.com/microsoft/FluidFramework/pull/24061)) [34b319cae7](https://github.com/microsoft/FluidFramework/commit/34b319cae7a78db5530dc898689e2eb846f1419f)
17
+
18
+ The various import and export [`VerboseTree`](https://fluidframework.com/docs/api/fluid-framework/verbosetree-typealias) and [`ConciseTree`](https://fluidframework.com/docs/api/fluid-framework/concisetree-typealias) APIs no longer include `valueConverter` options.
19
+ Instead the resulting tree can be further processed to do any desired replacements.
20
+ The following `@alpha` APIs have been added to assist with this:
21
+
22
+ 1. `cloneWithReplacements`
23
+ 2. `replaceHandles`
24
+ 3. `replaceConciseTreeHandles`
25
+ 4. `replaceVerboseTreeHandles`
26
+
27
+ - Rules regarding how and when lazy schema references are resolved have been clarified ([#24030](https://github.com/microsoft/FluidFramework/pull/24030)) [23f32794db](https://github.com/microsoft/FluidFramework/commit/23f32794dbd3672dcc18e2a9ba2f16f4bf1241f0)
28
+
29
+ A lazy schema reference is a [LazyItem](https://fluidframework.com/docs/api/fluid-framework/lazyitem-typealias) referencing a [TreeNodeSchema](https://fluidframework.com/docs/api/fluid-framework/treenodeschema-typealias).
30
+ They typically look like `() => MySchema` and are used when a [forward reference](https://en.wikipedia.org/wiki/Forward_declaration#Forward_reference) from one schema to another is required (including but not limited to recursive and co-recursive schema).
31
+
32
+ [TreeViewConfiguration](https://fluidframework.com/docs/api/fluid-framework/treeviewconfiguration-class#_constructor_-constructor) now documents its significance with respect to lazy schema references.
33
+ Additionally some implicit assumptions like no modifications of [AllowedTypes](https://fluidframework.com/docs/api/fluid-framework/allowedtypes-typealias)
34
+ after resolving of lazy schema references have been enforced (such modifications would previously cause undefined behavior in the future, and now an error is thrown when trying to modify them).
35
+
36
+ `evaluateLazySchema` has been added as an `@alpha` API that is now consistently used by all internal code when evaluating lazy schema references.
37
+ This ensures consistent behavior and error reporting, but also adds caching.
38
+ Therefore it is now supported for applications to have lazy schema references which compute the schema when invoked,
39
+ without having to implement their own caching as long as those applications use `evaluateLazySchema` anytime they need to evaluate a lazy schema reference.
40
+
3
41
  ## 2.23.0
4
42
 
5
43
  ### Minor Changes
@@ -51,6 +51,12 @@ export interface BranchableTree extends ViewableTree {
51
51
  rebase(branch: TreeBranchFork): void;
52
52
  }
53
53
 
54
+ // @alpha
55
+ export function cloneWithReplacements(root: unknown, rootKey: string, replacer: (key: string, value: unknown) => {
56
+ clone: boolean;
57
+ value: unknown;
58
+ }): unknown;
59
+
54
60
  // @public
55
61
  export enum CommitKind {
56
62
  Default = 0,
@@ -123,9 +129,8 @@ interface DefaultProvider extends ErasedType<"@fluidframework/tree.FieldProvider
123
129
  }
124
130
 
125
131
  // @alpha
126
- export interface EncodeOptions<TCustom> {
132
+ export interface EncodeOptions {
127
133
  readonly useStoredKeys?: boolean;
128
- valueConverter(data: IFluidHandle): TCustom;
129
134
  }
130
135
 
131
136
  // @alpha
@@ -145,6 +150,9 @@ export abstract class ErasedType<out Name = unknown> {
145
150
  protected abstract brand(dummy: never): Name;
146
151
  }
147
152
 
153
+ // @alpha
154
+ export function evaluateLazySchema<T extends TreeNodeSchema>(value: LazyItem<T>): T;
155
+
148
156
  // @public
149
157
  type ExtractItemType<Item extends LazyItem> = Item extends () => infer Result ? Result : Item;
150
158
 
@@ -260,6 +268,9 @@ export function getBranch<T extends ImplicitFieldSchema | UnsafeUnknownSchema>(v
260
268
  // @alpha
261
269
  export function getJsonSchema(schema: ImplicitFieldSchema): JsonTreeSchema;
262
270
 
271
+ // @alpha
272
+ export type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;
273
+
263
274
  // @alpha
264
275
  export interface ICodecOptions {
265
276
  readonly jsonValidator: JsonValidator;
@@ -898,9 +909,8 @@ type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveStringRecord<I
898
909
  export type Off = () => void;
899
910
 
900
911
  // @alpha
901
- export interface ParseOptions<TCustom> {
912
+ export interface ParseOptions {
902
913
  readonly useStoredKeys?: boolean;
903
- valueConverter(data: VerboseTree<TCustom>): TreeLeafValue | VerboseTreeNode<TCustom>;
904
914
  }
905
915
 
906
916
  // @alpha
@@ -934,11 +944,20 @@ export type ReadSchema<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema
934
944
  TSchema
935
945
  ] extends [ImplicitFieldSchema] ? TSchema : ImplicitFieldSchema;
936
946
 
947
+ // @alpha
948
+ export function replaceConciseTreeHandles<T>(tree: ConciseTree, replacer: HandleConverter<T>): ConciseTree<T>;
949
+
950
+ // @alpha
951
+ export function replaceHandles<T>(tree: unknown, replacer: HandleConverter<T>): unknown;
952
+
937
953
  // @public
938
954
  export type ReplaceIEventThisPlaceHolder<L extends any[], TThis> = L extends any[] ? {
939
955
  [K in keyof L]: L[K] extends IEventThisPlaceHolder ? TThis : L[K];
940
956
  } : L;
941
957
 
958
+ // @alpha
959
+ export function replaceVerboseTreeHandles<T>(tree: VerboseTree, replacer: HandleConverter<T>): VerboseTree<T>;
960
+
942
961
  // @public @deprecated
943
962
  export type RestrictiveReadonlyRecord<K extends symbol | string, T> = {
944
963
  readonly [P in symbol | string]: P extends K ? T : never;
@@ -1071,6 +1090,7 @@ export class SchemaFactoryAlpha<out TScope extends string | undefined = string |
1071
1090
  }, false, T, undefined, TCustomMetadata>;
1072
1091
  object<const Name extends TName, const T extends RestrictiveStringRecord<ImplicitFieldSchema>, const TCustomMetadata = unknown>(name: Name, fields: T, options?: SchemaFactoryObjectOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNode<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecord<T>, true, T, never, TCustomMetadata>;
1073
1092
  objectRecursive<const Name extends TName, const T extends Unenforced<RestrictiveStringRecord<ImplicitFieldSchema>>, const TCustomMetadata = unknown>(name: Name, t: T, options?: SchemaFactoryObjectOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecordUnsafe<T>, false, T, never, TCustomMetadata>;
1093
+ scopedFactory<const T extends TName, TNameInner extends number | string = string>(name: T): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner>;
1074
1094
  }
1075
1095
 
1076
1096
  // @alpha
@@ -1189,12 +1209,9 @@ export const TreeAlpha: {
1189
1209
  branch(node: TreeNode): TreeBranch | undefined;
1190
1210
  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>;
1191
1211
  importConcise<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(schema: UnsafeUnknownSchema extends TSchema ? ImplicitFieldSchema : TSchema & ImplicitFieldSchema, data: ConciseTree | undefined): Unhydrated<TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeNode | TreeLeafValue | undefined>;
1192
- importVerbose<const TSchema extends ImplicitFieldSchema>(schema: TSchema, data: VerboseTree | undefined, options?: Partial<ParseOptions<IFluidHandle>>): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
1193
- importVerbose<const TSchema extends ImplicitFieldSchema, THandle>(schema: TSchema, data: VerboseTree<THandle> | undefined, options: ParseOptions<THandle>): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
1194
- exportConcise(node: TreeNode | TreeLeafValue, options?: Partial<EncodeOptions<IFluidHandle>>): ConciseTree;
1195
- exportConcise<THandle>(node: TreeNode | TreeLeafValue, options: EncodeOptions<THandle>): ConciseTree<THandle>;
1196
- exportVerbose(node: TreeNode | TreeLeafValue, options?: Partial<EncodeOptions<IFluidHandle>>): VerboseTree;
1197
- exportVerbose<T>(node: TreeNode | TreeLeafValue, options: EncodeOptions<T>): VerboseTree<T>;
1212
+ importVerbose<const TSchema extends ImplicitFieldSchema>(schema: TSchema, data: VerboseTree | undefined, options?: Partial<ParseOptions>): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
1213
+ exportConcise(node: TreeNode | TreeLeafValue, options?: EncodeOptions): ConciseTree;
1214
+ exportVerbose(node: TreeNode | TreeLeafValue, options?: EncodeOptions): VerboseTree;
1198
1215
  exportCompressed(tree: TreeNode | TreeLeafValue, options: {
1199
1216
  oldestCompatibleClient: FluidClientVersion;
1200
1217
  idCompressor?: IIdCompressor;
@@ -1258,10 +1275,9 @@ export interface TreeBranch extends IDisposable {
1258
1275
  }
1259
1276
 
1260
1277
  // @alpha @sealed
1261
- export interface TreeBranchEvents {
1278
+ export interface TreeBranchEvents extends Omit<TreeViewEvents, "commitApplied"> {
1262
1279
  changed(data: CommitMetadata, getRevertible?: RevertibleAlphaFactory): void;
1263
1280
  commitApplied(data: CommitMetadata, getRevertible?: RevertibleAlphaFactory): void;
1264
- schemaChanged(): void;
1265
1281
  }
1266
1282
 
1267
1283
  // @alpha @sealed
package/dist/alpha.d.ts CHANGED
@@ -153,6 +153,7 @@ export {
153
153
  ForestTypeExpensiveDebug,
154
154
  ForestTypeOptimized,
155
155
  ForestTypeReference,
156
+ HandleConverter,
156
157
  ICodecOptions,
157
158
  IdentifierIndex,
158
159
  Insertable,
@@ -212,17 +213,22 @@ export {
212
213
  VoidTransactionCallbackStatus,
213
214
  adaptEnum,
214
215
  asTreeViewAlpha,
216
+ cloneWithReplacements,
215
217
  comparePersistedSchema,
216
218
  configuredSharedTree,
217
219
  createIdentifierIndex,
218
220
  createSimpleTreeIndex,
219
221
  enumFromStrings,
222
+ evaluateLazySchema,
220
223
  extractPersistedSchema,
221
224
  getBranch,
222
225
  getJsonSchema,
223
226
  independentInitializedView,
224
227
  independentView,
225
228
  noopValidator,
229
+ replaceConciseTreeHandles,
230
+ replaceHandles,
231
+ replaceVerboseTreeHandles,
226
232
  singletonSchema,
227
233
  typeboxValidator
228
234
  } from "./index.js";
package/lib/alpha.d.ts CHANGED
@@ -153,6 +153,7 @@ export {
153
153
  ForestTypeExpensiveDebug,
154
154
  ForestTypeOptimized,
155
155
  ForestTypeReference,
156
+ HandleConverter,
156
157
  ICodecOptions,
157
158
  IdentifierIndex,
158
159
  Insertable,
@@ -212,17 +213,22 @@ export {
212
213
  VoidTransactionCallbackStatus,
213
214
  adaptEnum,
214
215
  asTreeViewAlpha,
216
+ cloneWithReplacements,
215
217
  comparePersistedSchema,
216
218
  configuredSharedTree,
217
219
  createIdentifierIndex,
218
220
  createSimpleTreeIndex,
219
221
  enumFromStrings,
222
+ evaluateLazySchema,
220
223
  extractPersistedSchema,
221
224
  getBranch,
222
225
  getJsonSchema,
223
226
  independentInitializedView,
224
227
  independentView,
225
228
  noopValidator,
229
+ replaceConciseTreeHandles,
230
+ replaceHandles,
231
+ replaceVerboseTreeHandles,
226
232
  singletonSchema,
227
233
  typeboxValidator
228
234
  } from "./index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluid-framework",
3
- "version": "2.23.0",
3
+ "version": "2.30.0",
4
4
  "description": "The main entry point into Fluid Framework public packages",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -57,16 +57,16 @@
57
57
  "main": "lib/index.js",
58
58
  "types": "lib/public.d.ts",
59
59
  "dependencies": {
60
- "@fluidframework/container-definitions": "~2.23.0",
61
- "@fluidframework/container-loader": "~2.23.0",
62
- "@fluidframework/core-interfaces": "~2.23.0",
63
- "@fluidframework/driver-definitions": "~2.23.0",
64
- "@fluidframework/fluid-static": "~2.23.0",
65
- "@fluidframework/map": "~2.23.0",
66
- "@fluidframework/runtime-utils": "~2.23.0",
67
- "@fluidframework/sequence": "~2.23.0",
68
- "@fluidframework/shared-object-base": "~2.23.0",
69
- "@fluidframework/tree": "~2.23.0"
60
+ "@fluidframework/container-definitions": "~2.30.0",
61
+ "@fluidframework/container-loader": "~2.30.0",
62
+ "@fluidframework/core-interfaces": "~2.30.0",
63
+ "@fluidframework/driver-definitions": "~2.30.0",
64
+ "@fluidframework/fluid-static": "~2.30.0",
65
+ "@fluidframework/map": "~2.30.0",
66
+ "@fluidframework/runtime-utils": "~2.30.0",
67
+ "@fluidframework/sequence": "~2.30.0",
68
+ "@fluidframework/shared-object-base": "~2.30.0",
69
+ "@fluidframework/tree": "~2.30.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@arethetypeswrong/cli": "^0.17.1",