fluid-framework 2.10.0 → 2.11.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,58 @@
1
1
  # fluid-framework
2
2
 
3
+ ## 2.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Revertible objects can now be cloned using `RevertibleAlpha.clone()` ([#23044](https://github.com/microsoft/FluidFramework/pull/23044)) [5abfa015af](https://github.com/microsoft/FluidFramework/commit/5abfa015aff9d639d82830f3ad828324d5680bd7)
8
+
9
+ The `DisposableRevertible` interface has been replaced with `RevertibleAlpha`. The new `RevertibleAlpha` interface extends `Revertible` and includes a `clone(branch: TreeBranch)` method to facilitate cloning a Revertible to a specified target branch. The source branch where the `RevertibleAlpha` was created must share revision logs with the target branch where the `RevertibleAlpha` is being cloned. If this condition is not met, the operation will throw an error.
10
+
11
+ - Providing unused properties in object literals for building empty ObjectNodes no longer compiles ([#23162](https://github.com/microsoft/FluidFramework/pull/23162)) [dc3c30019e](https://github.com/microsoft/FluidFramework/commit/dc3c30019ef869b27b9468bff59f10434d3c5c68)
12
+
13
+ ObjectNodes with no fields will now emit a compiler error if constructed from an object literal with fields.
14
+ This matches the behavior of non-empty ObjectNodes which already gave errors when unexpected properties were provided.
15
+
16
+ ```typescript
17
+ class A extends schemaFactory.object("A", {}) {}
18
+ const a = new A({ thisDoesNotExist: 5 }); // This now errors.
19
+ ```
20
+
21
+ - ✨ New! Alpha APIs for indexing ([#22491](https://github.com/microsoft/FluidFramework/pull/22491)) [cd95357ba8](https://github.com/microsoft/FluidFramework/commit/cd95357ba8f8cea6615f4fb0e9a62743770dce83)
22
+
23
+ SharedTree now supports indexing via two new APIs, `createSimpleTreeIndex` and `createIdentifierIndex`.
24
+
25
+ `createSimpleTreeIndex` is used to create a `SimpleTreeIndex` which indexes nodes based on their schema.
26
+ Depending on the schema, the user specifies which field to key the node on.
27
+
28
+ The following example indexes `IndexableParent`s and `IndexableChild`s and returns the first node of a particular key:
29
+
30
+ ```typescript
31
+ function isStringKey(key: TreeIndexKey): key is string {
32
+ return typeof key === "string";
33
+ }
34
+
35
+ const index = createSimpleTreeIndex(
36
+ view,
37
+ new Map([
38
+ [IndexableParent, parentKey],
39
+ [IndexableChild, childKey],
40
+ ]),
41
+ (nodes) => nodes[0],
42
+ isStringKey,
43
+ [IndexableParent, IndexableChild],
44
+ );
45
+ ```
46
+
47
+ `createIdentifierIndex` is used to create an `IdentifierIndex` which provides an efficient way to retrieve nodes using the node identifier.
48
+
49
+ Example:
50
+
51
+ ```typescript
52
+ const identifierIndex = createIdentifierIndex(view);
53
+ const node = identifierIndex.get("node12345");
54
+ ```
55
+
3
56
  ## 2.10.0
4
57
 
5
58
  ### Minor Changes
@@ -103,6 +103,21 @@ export interface ContainerSchema {
103
103
  readonly initialObjects: Record<string, SharedObjectKind>;
104
104
  }
105
105
 
106
+ // @alpha
107
+ export function createIdentifierIndex<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): IdentifierIndex;
108
+
109
+ // @alpha
110
+ export function createSimpleTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue>(view: TreeView<TFieldSchema>, indexer: (schema: TreeNodeSchema) => string | undefined, getValue: (nodes: TreeIndexNodes<TreeNode>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey): SimpleTreeIndex<TKey, TValue>;
111
+
112
+ // @alpha
113
+ export function createSimpleTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue, TSchema extends TreeNodeSchema>(view: TreeView<TFieldSchema>, indexer: (schema: TSchema) => string | undefined, getValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey, indexableSchema: readonly TSchema[]): SimpleTreeIndex<TKey, TValue>;
114
+
115
+ // @alpha
116
+ export function createSimpleTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue>(view: TreeView<TFieldSchema>, indexer: Map<TreeNodeSchema, string>, getValue: (nodes: TreeIndexNodes<TreeNode>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey): SimpleTreeIndex<TKey, TValue>;
117
+
118
+ // @alpha
119
+ export function createSimpleTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue, TSchema extends TreeNodeSchema>(view: TreeView<TFieldSchema>, indexer: Map<TreeNodeSchema, string>, getValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey, indexableSchema: readonly TSchema[]): SimpleTreeIndex<TKey, TValue>;
120
+
106
121
  // @public @sealed
107
122
  interface DefaultProvider extends ErasedType<"@fluidframework/tree.FieldProvider"> {
108
123
  }
@@ -253,6 +268,9 @@ export interface IConnection {
253
268
  // @public
254
269
  export type ICriticalContainerError = IErrorBase;
255
270
 
271
+ // @alpha
272
+ export type IdentifierIndex = SimpleTreeIndex<string, TreeNode>;
273
+
256
274
  // @public @sealed
257
275
  export interface IDisposable {
258
276
  dispose(error?: Error): void;
@@ -534,7 +552,7 @@ TSchema
534
552
  ] extends [ImplicitFieldSchema] ? InsertableTreeFieldFromImplicitField<TSchema> : [TSchema] extends [UnsafeUnknownSchema] ? InsertableContent | undefined : never;
535
553
 
536
554
  // @public
537
- type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = FlattenKeys<{
555
+ type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = Record<string, never> extends T ? Record<string, never> : FlattenKeys<{
538
556
  readonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<T[Property & string]>;
539
557
  } & {
540
558
  readonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false ? Property : never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;
@@ -892,6 +910,14 @@ export interface Revertible {
892
910
  readonly status: RevertibleStatus;
893
911
  }
894
912
 
913
+ // @alpha @sealed
914
+ export interface RevertibleAlpha extends Revertible {
915
+ clone: (branch: TreeBranch) => RevertibleAlpha;
916
+ }
917
+
918
+ // @alpha @sealed
919
+ export type RevertibleAlphaFactory = (onRevertibleDisposed?: (revertible: RevertibleAlpha) => void) => RevertibleAlpha;
920
+
895
921
  // @public @sealed
896
922
  export type RevertibleFactory = (onRevertibleDisposed?: (revertible: Revertible) => void) => Revertible;
897
923
 
@@ -998,6 +1024,9 @@ export type SharedTreeFormatVersion = typeof SharedTreeFormatVersion;
998
1024
  // @alpha
999
1025
  export type SharedTreeOptions = Partial<ICodecOptions> & Partial<SharedTreeFormatOptions> & ForestOptions;
1000
1026
 
1027
+ // @alpha
1028
+ export type SimpleTreeIndex<TKey extends TreeIndexKey, TValue> = TreeIndex<TKey, TValue>;
1029
+
1001
1030
  // @alpha
1002
1031
  export function singletonSchema<TScope extends string, TName extends string | number>(factory: SchemaFactory<TScope, TName>, name: TName): TreeNodeSchemaClass<ScopedSchemaName<TScope, TName>, NodeKind.Object, TreeNode & {
1003
1032
  readonly value: TName;
@@ -1098,8 +1127,8 @@ export interface TreeBranch extends IDisposable {
1098
1127
 
1099
1128
  // @alpha @sealed
1100
1129
  export interface TreeBranchEvents {
1101
- changed(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
1102
- commitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
1130
+ changed(data: CommitMetadata, getRevertible?: RevertibleAlphaFactory): void;
1131
+ commitApplied(data: CommitMetadata, getRevertible?: RevertibleAlphaFactory): void;
1103
1132
  schemaChanged(): void;
1104
1133
  }
1105
1134
 
@@ -1131,6 +1160,17 @@ export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = Fie
1131
1160
  // @public
1132
1161
  type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
1133
1162
 
1163
+ // @alpha
1164
+ export interface TreeIndex<TKey extends TreeIndexKey, TValue> extends ReadonlyMap<TKey, TValue> {
1165
+ dispose(): void;
1166
+ }
1167
+
1168
+ // @alpha
1169
+ export type TreeIndexKey = number | string | boolean | IFluidHandle | null;
1170
+
1171
+ // @alpha
1172
+ export type TreeIndexNodes<TNode> = readonly [first: TNode, ...rest: TNode[]];
1173
+
1134
1174
  // @public
1135
1175
  export type TreeLeafValue = number | string | boolean | IFluidHandle | null;
1136
1176
 
@@ -417,7 +417,7 @@ type _InlineTrick = 0;
417
417
  export type Input<T extends never> = T;
418
418
 
419
419
  // @public
420
- type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = FlattenKeys<{
420
+ type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = Record<string, never> extends T ? Record<string, never> : FlattenKeys<{
421
421
  readonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<T[Property & string]>;
422
422
  } & {
423
423
  readonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false ? Property : never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;
@@ -517,7 +517,7 @@ type _InlineTrick = 0;
517
517
  export type Input<T extends never> = T;
518
518
 
519
519
  // @public
520
- type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = FlattenKeys<{
520
+ type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = Record<string, never> extends T ? Record<string, never> : FlattenKeys<{
521
521
  readonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<T[Property & string]>;
522
522
  } & {
523
523
  readonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false ? Property : never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;
@@ -445,7 +445,7 @@ type _InlineTrick = 0;
445
445
  export type Input<T extends never> = T;
446
446
 
447
447
  // @public
448
- type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = FlattenKeys<{
448
+ type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = Record<string, never> extends T ? Record<string, never> : FlattenKeys<{
449
449
  readonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<T[Property & string]>;
450
450
  } & {
451
451
  readonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false ? Property : never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;
@@ -417,7 +417,7 @@ type _InlineTrick = 0;
417
417
  export type Input<T extends never> = T;
418
418
 
419
419
  // @public
420
- type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = FlattenKeys<{
420
+ type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = Record<string, never> extends T ? Record<string, never> : FlattenKeys<{
421
421
  readonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<T[Property & string]>;
422
422
  } & {
423
423
  readonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false ? Property : never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;
package/dist/alpha.d.ts CHANGED
@@ -148,6 +148,7 @@ export {
148
148
  ForestOptions,
149
149
  ForestType,
150
150
  ICodecOptions,
151
+ IdentifierIndex,
151
152
  Insertable,
152
153
  InsertableContent,
153
154
  InsertableField,
@@ -172,15 +173,21 @@ export {
172
173
  PopUnion,
173
174
  ReadSchema,
174
175
  ReadableField,
176
+ RevertibleAlpha,
177
+ RevertibleAlphaFactory,
175
178
  SchemaValidationFunction,
176
179
  SharedTreeFormatOptions,
177
180
  SharedTreeFormatVersion,
178
181
  SharedTreeOptions,
182
+ SimpleTreeIndex,
179
183
  TreeAlpha,
180
184
  TreeBranch,
181
185
  TreeBranchEvents,
182
186
  TreeBranchFork,
183
187
  TreeCompressionStrategy,
188
+ TreeIndex,
189
+ TreeIndexKey,
190
+ TreeIndexNodes,
184
191
  TreeViewAlpha,
185
192
  UnionToTuple,
186
193
  UnsafeUnknownSchema,
@@ -191,6 +198,8 @@ export {
191
198
  asTreeViewAlpha,
192
199
  comparePersistedSchema,
193
200
  configuredSharedTree,
201
+ createIdentifierIndex,
202
+ createSimpleTreeIndex,
194
203
  enumFromStrings,
195
204
  extractPersistedSchema,
196
205
  getBranch,
package/lib/alpha.d.ts CHANGED
@@ -148,6 +148,7 @@ export {
148
148
  ForestOptions,
149
149
  ForestType,
150
150
  ICodecOptions,
151
+ IdentifierIndex,
151
152
  Insertable,
152
153
  InsertableContent,
153
154
  InsertableField,
@@ -172,15 +173,21 @@ export {
172
173
  PopUnion,
173
174
  ReadSchema,
174
175
  ReadableField,
176
+ RevertibleAlpha,
177
+ RevertibleAlphaFactory,
175
178
  SchemaValidationFunction,
176
179
  SharedTreeFormatOptions,
177
180
  SharedTreeFormatVersion,
178
181
  SharedTreeOptions,
182
+ SimpleTreeIndex,
179
183
  TreeAlpha,
180
184
  TreeBranch,
181
185
  TreeBranchEvents,
182
186
  TreeBranchFork,
183
187
  TreeCompressionStrategy,
188
+ TreeIndex,
189
+ TreeIndexKey,
190
+ TreeIndexNodes,
184
191
  TreeViewAlpha,
185
192
  UnionToTuple,
186
193
  UnsafeUnknownSchema,
@@ -191,6 +198,8 @@ export {
191
198
  asTreeViewAlpha,
192
199
  comparePersistedSchema,
193
200
  configuredSharedTree,
201
+ createIdentifierIndex,
202
+ createSimpleTreeIndex,
194
203
  enumFromStrings,
195
204
  extractPersistedSchema,
196
205
  getBranch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluid-framework",
3
- "version": "2.10.0",
3
+ "version": "2.11.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.10.0",
61
- "@fluidframework/container-loader": "~2.10.0",
62
- "@fluidframework/core-interfaces": "~2.10.0",
63
- "@fluidframework/driver-definitions": "~2.10.0",
64
- "@fluidframework/fluid-static": "~2.10.0",
65
- "@fluidframework/map": "~2.10.0",
66
- "@fluidframework/runtime-utils": "~2.10.0",
67
- "@fluidframework/sequence": "~2.10.0",
68
- "@fluidframework/shared-object-base": "~2.10.0",
69
- "@fluidframework/tree": "~2.10.0"
60
+ "@fluidframework/container-definitions": "~2.11.0",
61
+ "@fluidframework/container-loader": "~2.11.0",
62
+ "@fluidframework/core-interfaces": "~2.11.0",
63
+ "@fluidframework/driver-definitions": "~2.11.0",
64
+ "@fluidframework/fluid-static": "~2.11.0",
65
+ "@fluidframework/map": "~2.11.0",
66
+ "@fluidframework/runtime-utils": "~2.11.0",
67
+ "@fluidframework/sequence": "~2.11.0",
68
+ "@fluidframework/shared-object-base": "~2.11.0",
69
+ "@fluidframework/tree": "~2.11.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@arethetypeswrong/cli": "^0.16.4",
@@ -74,7 +74,7 @@
74
74
  "@fluid-tools/build-cli": "^0.51.0",
75
75
  "@fluidframework/build-common": "^2.0.3",
76
76
  "@fluidframework/build-tools": "^0.51.0",
77
- "@fluidframework/eslint-config-fluid": "^5.4.0",
77
+ "@fluidframework/eslint-config-fluid": "^5.6.0",
78
78
  "@microsoft/api-extractor": "7.47.8",
79
79
  "@types/node": "^18.19.0",
80
80
  "concurrently": "^8.2.1",