@fluidframework/fluid-static 2.0.0-dev-rc.5.0.0.263932 → 2.0.0-dev-rc.5.0.0.267932

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 (58) hide show
  1. package/api-report/fluid-static.api.md +11 -20
  2. package/dist/compatibilityConfiguration.d.ts +12 -0
  3. package/dist/compatibilityConfiguration.d.ts.map +1 -0
  4. package/dist/compatibilityConfiguration.js +38 -0
  5. package/dist/compatibilityConfiguration.js.map +1 -0
  6. package/dist/fluidContainer.d.ts +4 -3
  7. package/dist/fluidContainer.d.ts.map +1 -1
  8. package/dist/fluidContainer.js.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/public.d.ts +1 -3
  13. package/dist/rootDataObject.d.ts +3 -2
  14. package/dist/rootDataObject.d.ts.map +1 -1
  15. package/dist/rootDataObject.js +11 -18
  16. package/dist/rootDataObject.js.map +1 -1
  17. package/dist/serviceAudience.d.ts +1 -1
  18. package/dist/serviceAudience.d.ts.map +1 -1
  19. package/dist/serviceAudience.js.map +1 -1
  20. package/dist/types.d.ts +18 -20
  21. package/dist/types.d.ts.map +1 -1
  22. package/dist/types.js.map +1 -1
  23. package/dist/utils.d.ts +5 -12
  24. package/dist/utils.d.ts.map +1 -1
  25. package/dist/utils.js.map +1 -1
  26. package/lib/compatibilityConfiguration.d.ts +12 -0
  27. package/lib/compatibilityConfiguration.d.ts.map +1 -0
  28. package/lib/compatibilityConfiguration.js +35 -0
  29. package/lib/compatibilityConfiguration.js.map +1 -0
  30. package/lib/fluidContainer.d.ts +4 -3
  31. package/lib/fluidContainer.d.ts.map +1 -1
  32. package/lib/fluidContainer.js.map +1 -1
  33. package/lib/index.d.ts +1 -1
  34. package/lib/index.d.ts.map +1 -1
  35. package/lib/index.js.map +1 -1
  36. package/lib/public.d.ts +1 -3
  37. package/lib/rootDataObject.d.ts +3 -2
  38. package/lib/rootDataObject.d.ts.map +1 -1
  39. package/lib/rootDataObject.js +9 -16
  40. package/lib/rootDataObject.js.map +1 -1
  41. package/lib/serviceAudience.d.ts +1 -1
  42. package/lib/serviceAudience.d.ts.map +1 -1
  43. package/lib/serviceAudience.js.map +1 -1
  44. package/lib/tsdoc-metadata.json +1 -1
  45. package/lib/types.d.ts +18 -20
  46. package/lib/types.d.ts.map +1 -1
  47. package/lib/types.js.map +1 -1
  48. package/lib/utils.d.ts +5 -12
  49. package/lib/utils.d.ts.map +1 -1
  50. package/lib/utils.js.map +1 -1
  51. package/package.json +38 -25
  52. package/src/compatibilityConfiguration.ts +42 -0
  53. package/src/fluidContainer.ts +5 -9
  54. package/src/index.ts +13 -15
  55. package/src/rootDataObject.ts +29 -31
  56. package/src/serviceAudience.ts +1 -1
  57. package/src/types.ts +19 -18
  58. package/src/utils.ts +8 -22
@@ -9,7 +9,7 @@ import {
9
9
  DataObjectFactory,
10
10
  } from "@fluidframework/aqueduct/internal";
11
11
  import { type IRuntimeFactory } from "@fluidframework/container-definitions/internal";
12
- import { type ContainerRuntime } from "@fluidframework/container-runtime/internal";
12
+ import type { ContainerRuntime } from "@fluidframework/container-runtime/internal";
13
13
  import { type IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
14
14
  import {
15
15
  type FluidObject,
@@ -18,19 +18,21 @@ import {
18
18
  type IResponse,
19
19
  } from "@fluidframework/core-interfaces";
20
20
  import { type IDirectory } from "@fluidframework/map/internal";
21
- import { FlushMode } from "@fluidframework/runtime-definitions/internal";
22
21
  import { RequestParser } from "@fluidframework/runtime-utils/internal";
23
- import type { ISharedObjectKind } from "@fluidframework/shared-object-base";
24
-
25
- import {
26
- type ContainerSchema,
27
- type IRootDataObject,
28
- type LoadableObjectClass,
29
- type LoadableObjectClassRecord,
30
- type LoadableObjectRecord,
22
+ import type { SharedObjectKind } from "@fluidframework/shared-object-base";
23
+ import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
24
+
25
+ import { compatibilityModeRuntimeOptions } from "./compatibilityConfiguration.js";
26
+ import type {
27
+ CompatibilityMode,
28
+ ContainerSchema,
29
+ DataObjectClass,
30
+ IRootDataObject,
31
+ LoadableObjectClass,
32
+ LoadableObjectClassRecord,
33
+ LoadableObjectRecord,
31
34
  } from "./types.js";
32
35
  import {
33
- type InternalDataObjectClass,
34
36
  isDataObjectClass,
35
37
  isSharedObjectKind,
36
38
  parseDataObjectsFromSharedObjects,
@@ -45,7 +47,7 @@ export interface RootDataObjectProps {
45
47
  *
46
48
  * @see {@link RootDataObject.initializingFirstTime}
47
49
  */
48
- initialObjects: LoadableObjectClassRecord;
50
+ readonly initialObjects: LoadableObjectClassRecord;
49
51
  }
50
52
 
51
53
  /**
@@ -84,7 +86,9 @@ class RootDataObject
84
86
  const initialObjectsP: Promise<void>[] = [];
85
87
  for (const [id, objectClass] of Object.entries(props.initialObjects)) {
86
88
  const createObject = async (): Promise<void> => {
87
- const obj = await this.create<IFluidLoadable>(objectClass);
89
+ const obj = await this.create<IFluidLoadable>(
90
+ objectClass as SharedObjectKind<IFluidLoadable>,
91
+ );
88
92
  this.initialObjectsDir.set(id, obj.handle);
89
93
  };
90
94
  initialObjectsP.push(createObject());
@@ -127,23 +131,24 @@ class RootDataObject
127
131
  /**
128
132
  * {@inheritDoc IRootDataObject.create}
129
133
  */
130
- public async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {
131
- if (isDataObjectClass(objectClass)) {
132
- return this.createDataObject(objectClass);
133
- } else if (isSharedObjectKind(objectClass)) {
134
- return this.createSharedObject(objectClass);
134
+ public async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {
135
+ const internal = objectClass as unknown as LoadableObjectClass<T & IFluidLoadable>;
136
+ if (isDataObjectClass(internal)) {
137
+ return this.createDataObject(internal);
138
+ } else if (isSharedObjectKind(internal)) {
139
+ return this.createSharedObject(internal);
135
140
  }
136
141
  throw new Error("Could not create new Fluid object because an unknown object was passed");
137
142
  }
138
143
 
139
144
  private async createDataObject<T extends IFluidLoadable>(
140
- dataObjectClass: InternalDataObjectClass<T>,
145
+ dataObjectClass: DataObjectClass<T>,
141
146
  ): Promise<T> {
142
147
  const factory = dataObjectClass.factory;
143
148
  const packagePath = [...this.context.packagePath, factory.type];
144
149
  const dataStore = await this.context.containerRuntime.createDataStore(packagePath);
145
150
  const entryPoint = await dataStore.entryPoint.get();
146
- return entryPoint as unknown as T;
151
+ return entryPoint as T;
147
152
  }
148
153
 
149
154
  private createSharedObject<T extends IFluidLoadable>(
@@ -165,8 +170,9 @@ const rootDataStoreId = "rootDOId";
165
170
  */
166
171
  export function createDOProviderContainerRuntimeFactory(props: {
167
172
  schema: ContainerSchema;
173
+ compatibilityMode: CompatibilityMode;
168
174
  }): IRuntimeFactory {
169
- return new DOProviderContainerRuntimeFactory(props.schema);
175
+ return new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode);
170
176
  }
171
177
 
172
178
  /**
@@ -189,7 +195,7 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
189
195
 
190
196
  private readonly initialObjects: LoadableObjectClassRecord;
191
197
 
192
- public constructor(schema: ContainerSchema) {
198
+ public constructor(schema: ContainerSchema, compatibilityMode: CompatibilityMode) {
193
199
  const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);
194
200
  const rootDataObjectFactory = new DataObjectFactory(
195
201
  "rootDO",
@@ -227,15 +233,7 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
227
233
  super({
228
234
  registryEntries: [rootDataObjectFactory.registryEntry],
229
235
  requestHandlers: [getDefaultObject],
230
- // WARNING: These settigs are not compatible with FF 1.3 clients!
231
- runtimeOptions: {
232
- // temporary workaround to disable message batching until the message batch size issue is resolved
233
- // resolution progress is tracked by the Feature 465 work item in AzDO
234
- flushMode: FlushMode.Immediate,
235
- // The runtime compressor is required to be on to use @fluidframework/tree.
236
- enableRuntimeIdCompressor: "on",
237
- explicitSchemaControl: true,
238
- },
236
+ runtimeOptions: compatibilityModeRuntimeOptions[compatibilityMode],
239
237
  provideEntryPoint,
240
238
  });
241
239
  this.rootDataObjectFactory = rootDataObjectFactory;
@@ -6,7 +6,7 @@
6
6
  import { TypedEventEmitter } from "@fluid-internal/client-utils";
7
7
  import { type IAudience } from "@fluidframework/container-definitions";
8
8
  import { type IContainer } from "@fluidframework/container-definitions/internal";
9
- import { type IClient } from "@fluidframework/protocol-definitions";
9
+ import { type IClient } from "@fluidframework/driver-definitions";
10
10
 
11
11
  import {
12
12
  type IMember,
package/src/types.ts CHANGED
@@ -8,7 +8,15 @@ import {
8
8
  type IEventProvider,
9
9
  type IFluidLoadable,
10
10
  } from "@fluidframework/core-interfaces";
11
- import { type ISharedObjectKind } from "@fluidframework/shared-object-base";
11
+ import type { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions/internal";
12
+ import { type SharedObjectKind } from "@fluidframework/shared-object-base";
13
+ import { type ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
14
+
15
+ /**
16
+ * Valid compatibility modes that may be specified when creating a DOProviderContainerRuntimeFactory.
17
+ * @public
18
+ */
19
+ export type CompatibilityMode = "1" | "2";
12
20
 
13
21
  /**
14
22
  * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
@@ -19,15 +27,13 @@ export type LoadableObjectRecord = Record<string, IFluidLoadable>;
19
27
  /**
20
28
  * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
21
29
  * or `SharedObject`.
22
- * @public
23
30
  */
24
- export type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
31
+ export type LoadableObjectClassRecord = Record<string, SharedObjectKind>;
25
32
 
26
33
  /**
27
34
  * A class object of `DataObject` or `SharedObject`.
28
35
  *
29
36
  * @typeParam T - The class of the `DataObject` or `SharedObject`.
30
- * @public
31
37
  *
32
38
  * @privateRemarks
33
39
  * There are some edge cases in TypeScript where the order of the members in a union matter.
@@ -46,19 +52,14 @@ export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> =
46
52
  *
47
53
  * @typeParam T - The class of the `DataObject`.
48
54
  * @privateRemarks
49
- * Having both `factory` and `LoadableObjectCtor` is redundant.
50
- * TODO: It appears the factory is what's used, so the constructor should be removed.
51
- * @public
55
+ * Having both `factory` and constructor is redundant.
56
+ * TODO: It appears the factory is what's used, so the constructor should be removed once factory provides strong typing.
52
57
  */
53
- export type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {
54
- /**
55
- * @privateRemarks
56
- * This has to implement {@link @fluidframework/runtime-definitions#IFluidDataStoreFactory}.
57
- * TODO: Gain type safety for this without leaking IFluidDataStoreFactory as public using type erasure.
58
- */
59
- readonly factory: { readonly IFluidDataStoreFactory: DataObjectClass<T>["factory"] };
58
+ export interface DataObjectClass<T extends IFluidLoadable> {
59
+ readonly factory: IFluidDataStoreFactory;
60
60
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- } & (new (...args: any[]) => T);
61
+ new (...args: any[]): T;
62
+ }
62
63
 
63
64
  /**
64
65
  * Represents properties that can be attached to a container.
@@ -94,7 +95,7 @@ export interface ContainerSchema {
94
95
  * }
95
96
  * ```
96
97
  */
97
- readonly initialObjects: LoadableObjectClassRecord;
98
+ readonly initialObjects: Record<string, SharedObjectKind>;
98
99
 
99
100
  /**
100
101
  * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
@@ -106,7 +107,7 @@ export interface ContainerSchema {
106
107
  * For best practice it's recommended to define all the dynamic types you create even if they are
107
108
  * included via initialObjects.
108
109
  */
109
- readonly dynamicObjectTypes?: readonly LoadableObjectClass[];
110
+ readonly dynamicObjectTypes?: readonly SharedObjectKind[];
110
111
  }
111
112
 
112
113
  /**
@@ -134,7 +135,7 @@ export interface IRootDataObject extends IProvideRootDataObject {
134
135
  *
135
136
  * @typeParam T - The class of the `DataObject` or `SharedObject`.
136
137
  */
137
- create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
138
+ create<T>(objectClass: SharedObjectKind<T>): Promise<T>;
138
139
  }
139
140
 
140
141
  /**
package/src/utils.ts CHANGED
@@ -4,46 +4,32 @@
4
4
  */
5
5
 
6
6
  import { type IFluidLoadable } from "@fluidframework/core-interfaces";
7
- import { type IChannelFactory } from "@fluidframework/datastore-definitions";
8
- import {
9
- type IFluidDataStoreFactory,
10
- type NamedFluidDataStoreRegistryEntry,
11
- } from "@fluidframework/runtime-definitions/internal";
12
- import type { ISharedObjectKind } from "@fluidframework/shared-object-base";
7
+ import { type IChannelFactory } from "@fluidframework/datastore-definitions/internal";
8
+ import { type NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions/internal";
9
+ import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
13
10
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
14
11
 
15
12
  import { type ContainerSchema, type DataObjectClass, type LoadableObjectClass } from "./types.js";
16
13
 
17
- /**
18
- * An internal type used by the internal type guard isDataObjectClass to cast a
19
- * DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.
20
- * Unlike the external and exported type DataObjectClass which is
21
- * weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.
22
- */
23
- export type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> &
24
- Record<"factory", IFluidDataStoreFactory>;
25
-
26
14
  /**
27
15
  * Runtime check to determine if a class is a DataObject type.
28
16
  */
29
17
  export function isDataObjectClass<T extends IFluidLoadable>(
30
18
  obj: LoadableObjectClass<T>,
31
- ): obj is InternalDataObjectClass<T>;
19
+ ): obj is DataObjectClass<T>;
32
20
 
33
21
  /**
34
22
  * Runtime check to determine if a class is a DataObject type.
35
23
  */
36
- export function isDataObjectClass(
37
- obj: LoadableObjectClass,
38
- ): obj is InternalDataObjectClass<IFluidLoadable>;
24
+ export function isDataObjectClass(obj: LoadableObjectClass): obj is DataObjectClass<IFluidLoadable>;
39
25
 
40
26
  /**
41
27
  * Runtime check to determine if a class is a DataObject type.
42
28
  */
43
29
  export function isDataObjectClass(
44
30
  obj: LoadableObjectClass,
45
- ): obj is InternalDataObjectClass<IFluidLoadable> {
46
- const maybe = obj as Partial<InternalDataObjectClass<IFluidLoadable>> | undefined;
31
+ ): obj is DataObjectClass<IFluidLoadable> {
32
+ const maybe = obj as Partial<DataObjectClass<IFluidLoadable>> | undefined;
47
33
  const isDataObject =
48
34
  maybe?.factory?.IFluidDataStoreFactory !== undefined &&
49
35
  maybe.factory.IFluidDataStoreFactory === maybe.factory;
@@ -96,7 +82,7 @@ export const parseDataObjectsFromSharedObjects = (
96
82
  ...(schema.dynamicObjectTypes ?? []),
97
83
  ]);
98
84
  for (const obj of dedupedObjects) {
99
- tryAddObject(obj);
85
+ tryAddObject(obj as unknown as LoadableObjectClass);
100
86
  }
101
87
 
102
88
  if (registryEntries.size === 0 && sharedObjects.size === 0) {