@fluidframework/fluid-static 2.50.0 → 2.51.0-347100

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.
Files changed (52) hide show
  1. package/api-report/fluid-static.alpha.api.md +17 -0
  2. package/dist/fluidContainer.d.ts +1 -1
  3. package/dist/fluidContainer.d.ts.map +1 -1
  4. package/dist/fluidContainer.js.map +1 -1
  5. package/dist/index.d.ts +3 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +5 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/rootDataObject.d.ts +6 -3
  10. package/dist/rootDataObject.d.ts.map +1 -1
  11. package/dist/rootDataObject.js +27 -44
  12. package/dist/rootDataObject.js.map +1 -1
  13. package/dist/treeRootDataObject.d.ts +47 -0
  14. package/dist/treeRootDataObject.d.ts.map +1 -0
  15. package/dist/treeRootDataObject.js +157 -0
  16. package/dist/treeRootDataObject.js.map +1 -0
  17. package/dist/types.d.ts +23 -8
  18. package/dist/types.d.ts.map +1 -1
  19. package/dist/types.js.map +1 -1
  20. package/dist/utils.d.ts +29 -4
  21. package/dist/utils.d.ts.map +1 -1
  22. package/dist/utils.js +62 -3
  23. package/dist/utils.js.map +1 -1
  24. package/lib/fluidContainer.d.ts +1 -1
  25. package/lib/fluidContainer.d.ts.map +1 -1
  26. package/lib/fluidContainer.js.map +1 -1
  27. package/lib/index.d.ts +3 -1
  28. package/lib/index.d.ts.map +1 -1
  29. package/lib/index.js +2 -0
  30. package/lib/index.js.map +1 -1
  31. package/lib/rootDataObject.d.ts +6 -3
  32. package/lib/rootDataObject.d.ts.map +1 -1
  33. package/lib/rootDataObject.js +25 -42
  34. package/lib/rootDataObject.js.map +1 -1
  35. package/lib/treeRootDataObject.d.ts +47 -0
  36. package/lib/treeRootDataObject.d.ts.map +1 -0
  37. package/lib/treeRootDataObject.js +153 -0
  38. package/lib/treeRootDataObject.js.map +1 -0
  39. package/lib/types.d.ts +23 -8
  40. package/lib/types.d.ts.map +1 -1
  41. package/lib/types.js.map +1 -1
  42. package/lib/utils.d.ts +29 -4
  43. package/lib/utils.d.ts.map +1 -1
  44. package/lib/utils.js +55 -0
  45. package/lib/utils.js.map +1 -1
  46. package/package.json +21 -20
  47. package/src/fluidContainer.ts +1 -1
  48. package/src/index.ts +3 -0
  49. package/src/rootDataObject.ts +46 -69
  50. package/src/treeRootDataObject.ts +249 -0
  51. package/src/types.ts +30 -9
  52. package/src/utils.ts +90 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/fluid-static",
3
- "version": "2.50.0",
3
+ "version": "2.51.0-347100",
4
4
  "description": "A tool to enable consumption of Fluid Data Objects without requiring custom container code.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -59,33 +59,34 @@
59
59
  "temp-directory": "nyc/.nyc_output"
60
60
  },
61
61
  "dependencies": {
62
- "@fluid-internal/client-utils": "~2.50.0",
63
- "@fluidframework/aqueduct": "~2.50.0",
64
- "@fluidframework/container-definitions": "~2.50.0",
65
- "@fluidframework/container-loader": "~2.50.0",
66
- "@fluidframework/container-runtime": "~2.50.0",
67
- "@fluidframework/container-runtime-definitions": "~2.50.0",
68
- "@fluidframework/core-interfaces": "~2.50.0",
69
- "@fluidframework/core-utils": "~2.50.0",
70
- "@fluidframework/datastore-definitions": "~2.50.0",
71
- "@fluidframework/driver-definitions": "~2.50.0",
72
- "@fluidframework/request-handler": "~2.50.0",
73
- "@fluidframework/runtime-definitions": "~2.50.0",
74
- "@fluidframework/runtime-utils": "~2.50.0",
75
- "@fluidframework/shared-object-base": "~2.50.0",
76
- "@fluidframework/telemetry-utils": "~2.50.0"
62
+ "@fluid-internal/client-utils": "2.51.0-347100",
63
+ "@fluidframework/aqueduct": "2.51.0-347100",
64
+ "@fluidframework/container-definitions": "2.51.0-347100",
65
+ "@fluidframework/container-loader": "2.51.0-347100",
66
+ "@fluidframework/container-runtime": "2.51.0-347100",
67
+ "@fluidframework/container-runtime-definitions": "2.51.0-347100",
68
+ "@fluidframework/core-interfaces": "2.51.0-347100",
69
+ "@fluidframework/core-utils": "2.51.0-347100",
70
+ "@fluidframework/datastore-definitions": "2.51.0-347100",
71
+ "@fluidframework/driver-definitions": "2.51.0-347100",
72
+ "@fluidframework/request-handler": "2.51.0-347100",
73
+ "@fluidframework/runtime-definitions": "2.51.0-347100",
74
+ "@fluidframework/runtime-utils": "2.51.0-347100",
75
+ "@fluidframework/shared-object-base": "2.51.0-347100",
76
+ "@fluidframework/telemetry-utils": "2.51.0-347100",
77
+ "@fluidframework/tree": "2.51.0-347100"
77
78
  },
78
79
  "devDependencies": {
79
80
  "@arethetypeswrong/cli": "^0.17.1",
80
81
  "@biomejs/biome": "~1.9.3",
81
- "@fluid-internal/mocha-test-setup": "~2.50.0",
82
+ "@fluid-internal/mocha-test-setup": "2.51.0-347100",
82
83
  "@fluid-tools/build-cli": "^0.56.0",
83
84
  "@fluidframework/build-common": "^2.0.3",
84
85
  "@fluidframework/build-tools": "^0.56.0",
85
86
  "@fluidframework/eslint-config-fluid": "^5.7.4",
86
- "@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.43.0",
87
- "@fluidframework/map": "~2.50.0",
88
- "@fluidframework/sequence": "~2.50.0",
87
+ "@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.50.0",
88
+ "@fluidframework/map": "2.51.0-347100",
89
+ "@fluidframework/sequence": "2.51.0-347100",
89
90
  "@microsoft/api-extractor": "7.52.8",
90
91
  "@types/mocha": "^10.0.10",
91
92
  "@types/node": "^18.19.0",
@@ -19,7 +19,7 @@ import type {
19
19
  IFluidLoadable,
20
20
  } from "@fluidframework/core-interfaces";
21
21
  import { assert } from "@fluidframework/core-utils/internal";
22
- import type { SharedObjectKind } from "@fluidframework/shared-object-base";
22
+ import type { SharedObjectKind } from "@fluidframework/shared-object-base/internal";
23
23
 
24
24
  import type {
25
25
  ContainerAttachProps,
package/src/index.ts CHANGED
@@ -19,6 +19,7 @@ export {
19
19
  } from "./fluidContainer.js";
20
20
  export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
21
21
  export { createServiceAudience } from "./serviceAudience.js";
22
+ export { createTreeContainerRuntimeFactory } from "./treeRootDataObject.js";
22
23
  export type {
23
24
  CompatibilityMode,
24
25
  ContainerSchema,
@@ -29,4 +30,6 @@ export type {
29
30
  IServiceAudienceEvents,
30
31
  MemberChangedListener,
31
32
  Myself,
33
+ TreeContainerSchema,
32
34
  } from "./types.js";
35
+ export { isTreeContainerSchema } from "./utils.js";
@@ -6,7 +6,6 @@
6
6
  import {
7
7
  BaseContainerRuntimeFactory,
8
8
  DataObject,
9
- type DataObjectKind,
10
9
  DataObjectFactory,
11
10
  } from "@fluidframework/aqueduct/internal";
12
11
  import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
@@ -21,7 +20,6 @@ import type {
21
20
  } from "@fluidframework/container-runtime-definitions/internal";
22
21
  import type {
23
22
  FluidObject,
24
- FluidObjectKeys,
25
23
  IFluidHandle,
26
24
  IFluidLoadable,
27
25
  } from "@fluidframework/core-interfaces";
@@ -29,10 +27,7 @@ import { assert } from "@fluidframework/core-utils/internal";
29
27
  import type { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
30
28
  import type { IDirectory } from "@fluidframework/map/internal";
31
29
  import type { IFluidDataStoreRegistry } from "@fluidframework/runtime-definitions/internal";
32
- import type {
33
- ISharedObjectKind,
34
- SharedObjectKind,
35
- } from "@fluidframework/shared-object-base/internal";
30
+ import type { SharedObjectKind } from "@fluidframework/shared-object-base/internal";
36
31
 
37
32
  import { compatibilityModeRuntimeOptions } from "./compatibilityConfiguration.js";
38
33
  import type {
@@ -45,19 +40,15 @@ import type {
45
40
  LoadableObjectRecord,
46
41
  } from "./types.js";
47
42
  import {
43
+ compatibilityModeToMinVersionForCollab,
44
+ createDataObject,
45
+ createSharedObject,
48
46
  isDataObjectKind,
49
47
  isSharedObjectKind,
48
+ makeFluidObject,
50
49
  parseDataObjectsFromSharedObjects,
51
50
  } from "./utils.js";
52
51
 
53
- /**
54
- * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.
55
- */
56
- const compatibilityModeToMinVersionForCollab = {
57
- "1": "1.0.0",
58
- "2": "2.0.0",
59
- } as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;
60
-
61
52
  /**
62
53
  * Input props for {@link RootDataObject.initializingFirstTime}.
63
54
  */
@@ -152,9 +143,9 @@ class RootDataObject
152
143
  public async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {
153
144
  const internal = objectClass as unknown as LoadableObjectKind<T & IFluidLoadable>;
154
145
  if (isDataObjectKind(internal)) {
155
- return this.createDataObject(internal);
146
+ return createDataObject(internal, this.context);
156
147
  } else if (isSharedObjectKind(internal)) {
157
- return this.createSharedObject(internal);
148
+ return createSharedObject(internal, this.runtime);
158
149
  }
159
150
  throw new Error("Could not create new Fluid object because an unknown object was passed");
160
151
  }
@@ -162,32 +153,37 @@ class RootDataObject
162
153
  public async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {
163
154
  return this.runtime.uploadBlob(blob);
164
155
  }
156
+ }
165
157
 
166
- private async createDataObject<T extends IFluidLoadable>(
167
- dataObjectClass: DataObjectKind<T>,
168
- ): Promise<T> {
169
- const factory = dataObjectClass.factory;
170
- const packagePath = [...this.context.packagePath, factory.type];
171
- const dataStore = await this.context.containerRuntime.createDataStore(packagePath);
172
- const entryPoint = await dataStore.entryPoint.get();
173
- return entryPoint as T;
174
- }
158
+ const rootDataStoreId = "rootDOId";
159
+ const rootDataObjectType = "rootDO";
175
160
 
176
- private createSharedObject<T extends IFluidLoadable>(
177
- sharedObjectClass: ISharedObjectKind<T>,
178
- ): T {
179
- const factory = sharedObjectClass.getFactory();
180
- const obj = this.runtime.createChannel(undefined, factory.type);
181
- return obj as unknown as T;
161
+ async function provideEntryPoint(
162
+ containerRuntime: IContainerRuntime,
163
+ ): Promise<IStaticEntryPoint> {
164
+ const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
165
+ if (entryPoint === undefined) {
166
+ throw new Error(`default dataStore [${rootDataStoreId}] must exist`);
182
167
  }
168
+ const rootDataObject = ((await entryPoint.get()) as FluidObject<RootDataObject>)
169
+ .RootDataObject;
170
+ assert(rootDataObject !== undefined, 0xb9f /* entryPoint must be of type RootDataObject */);
171
+ return makeFluidObject<IStaticEntryPoint>(
172
+ {
173
+ rootDataObject,
174
+ extensionStore: containerRuntime as IContainerRuntimeInternal,
175
+ },
176
+ "IStaticEntryPoint",
177
+ );
183
178
  }
184
179
 
185
- const rootDataStoreId = "rootDOId";
186
-
187
180
  /**
188
- * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers
189
- * with an entry point containing single IRootDataObject (entry point is opaque to caller),
190
- * where the root data object's registry and initial objects are configured based on the provided
181
+ * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
182
+ * with an entry point containing single directory-based root data object.
183
+ *
184
+ * @remarks
185
+ * The entry point is opaque to caller.
186
+ * The root data object's registry and initial objects are configured based on the provided
191
187
  * schema (and optionally, data store registry).
192
188
  *
193
189
  * @internal
@@ -219,46 +215,27 @@ export function createDOProviderContainerRuntimeFactory(props: {
219
215
  */
220
216
  minVersionForCollabOverride?: MinimumVersionForCollab;
221
217
  }): IRuntimeFactory {
222
- const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(props.schema);
223
- const registry = props.rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);
218
+ const {
219
+ compatibilityMode,
220
+ minVersionForCollabOverride,
221
+ rootDataStoreRegistry,
222
+ runtimeOptionOverrides,
223
+ schema,
224
+ } = props;
225
+ const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);
226
+ const registry = rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);
224
227
 
225
228
  return new DOProviderContainerRuntimeFactory(
226
- props.schema,
227
- props.compatibilityMode,
229
+ schema,
230
+ compatibilityMode,
228
231
  new RootDataObjectFactory(sharedObjects, registry),
229
232
  {
230
- runtimeOptions: props.runtimeOptionOverrides,
231
- minVersionForCollab: props.minVersionForCollabOverride,
233
+ runtimeOptions: runtimeOptionOverrides,
234
+ minVersionForCollab: minVersionForCollabOverride,
232
235
  },
233
236
  );
234
237
  }
235
238
 
236
- function makeFluidObject<T extends object, K extends FluidObjectKeys<T> = FluidObjectKeys<T>>(
237
- object: Omit<T, K>,
238
- providerKey: K,
239
- ): T {
240
- return Object.defineProperty(object, providerKey, { value: object }) as T;
241
- }
242
-
243
- async function provideEntryPoint(
244
- containerRuntime: IContainerRuntime,
245
- ): Promise<IStaticEntryPoint> {
246
- const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
247
- if (entryPoint === undefined) {
248
- throw new Error(`default dataStore [${rootDataStoreId}] must exist`);
249
- }
250
- const rootDataObject = ((await entryPoint.get()) as FluidObject<RootDataObject>)
251
- .RootDataObject;
252
- assert(rootDataObject !== undefined, 0xb9f /* entryPoint must be of type RootDataObject */);
253
- return makeFluidObject<IStaticEntryPoint>(
254
- {
255
- rootDataObject,
256
- extensionStore: containerRuntime as IContainerRuntimeInternal,
257
- },
258
- "IStaticEntryPoint",
259
- );
260
- }
261
-
262
239
  /**
263
240
  * Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}
264
241
  * (containing single {@link IRootDataObject}) as their entry point.
@@ -336,7 +313,7 @@ class RootDataObjectFactory extends DataObjectFactory<
336
313
  // Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,
337
314
  // and instead we override the necessary methods in this class to use the registry received in the constructor.
338
315
  super({
339
- type: "rootDO",
316
+ type: rootDataObjectType,
340
317
  ctor: RootDataObject,
341
318
  sharedObjects,
342
319
  });
@@ -0,0 +1,249 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import {
7
+ BaseContainerRuntimeFactory,
8
+ TreeDataObject,
9
+ TreeDataObjectFactory,
10
+ } from "@fluidframework/aqueduct/internal";
11
+ import type { IDataObjectProps } from "@fluidframework/aqueduct/internal";
12
+ import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
13
+ import {
14
+ FluidDataStoreRegistry,
15
+ type IContainerRuntimeOptions,
16
+ type MinimumVersionForCollab,
17
+ } from "@fluidframework/container-runtime/internal";
18
+ import type {
19
+ IContainerRuntime,
20
+ IContainerRuntimeInternal,
21
+ } from "@fluidframework/container-runtime-definitions/internal";
22
+ import type {
23
+ FluidObject,
24
+ IFluidHandle,
25
+ IFluidLoadable,
26
+ } from "@fluidframework/core-interfaces";
27
+ import { assert } from "@fluidframework/core-utils/internal";
28
+ import type { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
29
+ import type { IFluidDataStoreRegistry } from "@fluidframework/runtime-definitions/internal";
30
+ import type { SharedObjectKind } from "@fluidframework/shared-object-base/internal";
31
+
32
+ import { compatibilityModeRuntimeOptions } from "./compatibilityConfiguration.js";
33
+ import type {
34
+ CompatibilityMode,
35
+ IRootDataObject,
36
+ IStaticEntryPoint,
37
+ LoadableObjectKind,
38
+ LoadableObjectRecord,
39
+ TreeContainerSchema,
40
+ } from "./types.js";
41
+ import {
42
+ compatibilityModeToMinVersionForCollab,
43
+ createDataObject,
44
+ createSharedObject,
45
+ isDataObjectKind,
46
+ isSharedObjectKind,
47
+ makeFluidObject,
48
+ parseDataObjectsFromSharedObjects,
49
+ } from "./utils.js";
50
+
51
+ /**
52
+ * This module contains types and factories for creating tree-based root data objects.
53
+ * They exist as an alternative to the APIs in `rootDataObject.ts`.
54
+ *
55
+ * These APIs are currently shaped to parallel `RootDataObject`, but this is not intended as the long-term design.
56
+ * The current shape is a short-term solution to allow for easier migration from the old APIs.
57
+ */
58
+
59
+ /**
60
+ * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
61
+ *
62
+ * @remarks
63
+ * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
64
+ */
65
+ class TreeRootDataObject extends TreeDataObject implements IRootDataObject {
66
+ public constructor(props: IDataObjectProps) {
67
+ super(props);
68
+ }
69
+
70
+ public get TreeRootDataObject(): TreeRootDataObject {
71
+ return this;
72
+ }
73
+
74
+ // TODO: longer term, it would be better to not have to fit into the `initialObjects` model for tree-based containers.
75
+ // But in the short term, fitting into this model makes migration easier.
76
+ public get initialObjects(): LoadableObjectRecord {
77
+ return {
78
+ tree: this.tree,
79
+ };
80
+ }
81
+
82
+ public async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {
83
+ const internal = objectClass as unknown as LoadableObjectKind<T & IFluidLoadable>;
84
+ if (isDataObjectKind(internal)) {
85
+ return createDataObject(internal, this.context);
86
+ } else if (isSharedObjectKind(internal)) {
87
+ return createSharedObject(internal, this.runtime);
88
+ }
89
+ throw new Error("Could not create new Fluid object because an unknown object was passed");
90
+ }
91
+
92
+ public async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {
93
+ return this.runtime.uploadBlob(blob);
94
+ }
95
+ }
96
+
97
+ const treeRootDataStoreId = "treeRootDOId";
98
+
99
+ /**
100
+ * Type of the {@link TreeRootDataObject}.
101
+ * @remarks Used in the PureDataObjectFactory to create the root data object.
102
+ */
103
+ const treeRootDataObjectType = "treeRootDO";
104
+
105
+ async function provideEntryPoint(
106
+ containerRuntime: IContainerRuntime,
107
+ ): Promise<IStaticEntryPoint> {
108
+ const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(treeRootDataStoreId);
109
+ if (entryPoint === undefined) {
110
+ throw new Error(`default dataStore [${treeRootDataStoreId}] must exist`);
111
+ }
112
+ const treeRootDataObject = ((await entryPoint.get()) as FluidObject<TreeRootDataObject>)
113
+ .TreeRootDataObject;
114
+ assert(treeRootDataObject !== undefined, "entryPoint must be of type TreeRootDataObject");
115
+ return makeFluidObject<IStaticEntryPoint>(
116
+ {
117
+ rootDataObject: treeRootDataObject,
118
+ extensionStore: containerRuntime as IContainerRuntimeInternal,
119
+ },
120
+ "IStaticEntryPoint",
121
+ );
122
+ }
123
+
124
+ /**
125
+ * Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}
126
+ * (containing single {@link IRootDataObject}) as their entry point.
127
+ */
128
+ class TreeContainerRuntimeFactory extends BaseContainerRuntimeFactory {
129
+ // TODO: use for runtime factory.
130
+ readonly #treeRootDataObjectFactory: TreeDataObjectFactory<TreeRootDataObject>;
131
+
132
+ public constructor(
133
+ compatibilityMode: CompatibilityMode,
134
+ treeRootDataObjectFactory: TreeDataObjectFactory<TreeRootDataObject>,
135
+ overrides?: Partial<{
136
+ runtimeOptions: Partial<IContainerRuntimeOptions>;
137
+ minVersionForCollab: MinimumVersionForCollab;
138
+ }>,
139
+ ) {
140
+ super({
141
+ registryEntries: [treeRootDataObjectFactory.registryEntry],
142
+ runtimeOptions: {
143
+ ...compatibilityModeRuntimeOptions[compatibilityMode],
144
+ ...overrides?.runtimeOptions,
145
+ },
146
+ provideEntryPoint,
147
+ minVersionForCollab:
148
+ overrides?.minVersionForCollab ??
149
+ compatibilityModeToMinVersionForCollab[compatibilityMode],
150
+ });
151
+ this.#treeRootDataObjectFactory = treeRootDataObjectFactory;
152
+ }
153
+
154
+ protected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {
155
+ // The first time we create the container we create the RootDataObject
156
+ await this.#treeRootDataObjectFactory.createRootInstance(treeRootDataStoreId, runtime);
157
+ }
158
+ }
159
+
160
+ /**
161
+ * Factory that creates instances of a tree-based root data object.
162
+ */
163
+ class TreeRootDataObjectFactory extends TreeDataObjectFactory<TreeRootDataObject> {
164
+ public constructor(
165
+ sharedObjects: readonly IChannelFactory[] = [],
166
+ private readonly dataStoreRegistry: IFluidDataStoreRegistry,
167
+ ) {
168
+ type Ctor = new (props: IDataObjectProps) => TreeRootDataObject;
169
+ const ctor: Ctor = function (_props) {
170
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
171
+ return new TreeRootDataObject({
172
+ ..._props,
173
+ // Add any additional injected properties here
174
+ });
175
+ } as unknown as Ctor;
176
+
177
+ // Note: we're not specifying registry entries to the base class, so it won't create a registry itself,
178
+ // and instead we override the necessary methods in this class to use the registry received in the constructor.
179
+ super({
180
+ type: treeRootDataObjectType,
181
+ ctor,
182
+ sharedObjects,
183
+ });
184
+ }
185
+
186
+ public get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {
187
+ return this.dataStoreRegistry;
188
+ }
189
+ }
190
+
191
+ /**
192
+ * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
193
+ * with an entry point containing single tree-based root data object.
194
+ *
195
+ * @remarks
196
+ * The entry point is opaque to caller.
197
+ * The root data object's registry and shared objects are configured based on the provided
198
+ * SharedTree and optionally data store registry.
199
+ *
200
+ * @legacy @alpha
201
+ */
202
+ export function createTreeContainerRuntimeFactory(props: {
203
+ /**
204
+ * The schema for the container.
205
+ */
206
+ readonly schema: TreeContainerSchema;
207
+
208
+ /**
209
+ * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.
210
+ */
211
+ readonly compatibilityMode: CompatibilityMode;
212
+ /**
213
+ * Optional registry of data stores to pass to the DataObject factory.
214
+ * If not provided, one will be created based on the schema.
215
+ */
216
+ readonly rootDataStoreRegistry?: IFluidDataStoreRegistry;
217
+ /**
218
+ * Optional overrides for the container runtime options.
219
+ * If not provided, only the default options for the given compatibilityMode will be used.
220
+ */
221
+ readonly runtimeOptionOverrides?: Partial<IContainerRuntimeOptions>;
222
+ /**
223
+ * Optional override for minimum version for collab.
224
+ * If not provided, the default for the given compatibilityMode will be used.
225
+ * @remarks
226
+ * This is useful when runtime options are overridden and change the minimum version for collab.
227
+ */
228
+ readonly minVersionForCollabOverride?: MinimumVersionForCollab;
229
+ }): IRuntimeFactory {
230
+ const {
231
+ compatibilityMode,
232
+ minVersionForCollabOverride,
233
+ rootDataStoreRegistry,
234
+ runtimeOptionOverrides,
235
+ schema,
236
+ } = props;
237
+
238
+ const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);
239
+ const registry = rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);
240
+
241
+ return new TreeContainerRuntimeFactory(
242
+ compatibilityMode,
243
+ new TreeRootDataObjectFactory(sharedObjects, registry),
244
+ {
245
+ runtimeOptions: runtimeOptionOverrides,
246
+ minVersionForCollab: minVersionForCollabOverride,
247
+ },
248
+ );
249
+ }
package/src/types.ts CHANGED
@@ -11,8 +11,11 @@ import type {
11
11
  IFluidHandle,
12
12
  IFluidLoadable,
13
13
  } from "@fluidframework/core-interfaces";
14
- import type { SharedObjectKind } from "@fluidframework/shared-object-base";
15
- import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
14
+ import type {
15
+ ISharedObjectKind,
16
+ SharedObjectKind,
17
+ } from "@fluidframework/shared-object-base/internal";
18
+ import type { ITree } from "@fluidframework/tree";
16
19
 
17
20
  /**
18
21
  * Determines the set of runtime options that Fluid Framework will use when running.
@@ -100,15 +103,28 @@ export interface ContainerSchema {
100
103
  }
101
104
 
102
105
  /**
103
- * Holds the collection of objects that the container was initially created with, as well as provides the ability
104
- * to dynamically create further objects during usage.
106
+ * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
107
+ *
108
+ * @remarks
109
+ *
110
+ * It includes both the kind of `SharedTree` that will be initially available upon `Container` creation, as well
111
+ * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.
112
+ *
113
+ * @legacy @alpha
105
114
  */
106
- export interface IRootDataObject {
107
- /**
108
- * Provides a record of the initial objects defined on creation.
109
- */
110
- readonly initialObjects: LoadableObjectRecord;
115
+ export interface TreeContainerSchema extends ContainerSchema {
116
+ // TODO: longer term, it would be better to not have to fit into the `initialObjects` model for tree-based containers.
117
+ // But in the short term, fitting into this model makes migration easier.
118
+ readonly initialObjects: {
119
+ readonly tree: SharedObjectKind<ITree>;
120
+ };
121
+ }
111
122
 
123
+ /**
124
+ * Holds the collection of objects that the container was initially created with.
125
+ * Additionally provides the ability to dynamically create further objects during usage.
126
+ */
127
+ export interface IRootDataObject {
112
128
  /**
113
129
  * Dynamically creates a new detached collaborative object (DDS/DataObject).
114
130
  *
@@ -127,6 +143,11 @@ export interface IRootDataObject {
127
143
  * @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).
128
144
  */
129
145
  uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;
146
+
147
+ /**
148
+ * Provides a record of the initial objects defined on creation.
149
+ */
150
+ readonly initialObjects: LoadableObjectRecord;
130
151
  }
131
152
 
132
153
  interface IProvideStaticEntryPoint {