@fluidframework/fluid-static 2.0.0-dev-rc.4.0.0.261659 → 2.0.0-dev-rc.5.0.0.265721

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 (45) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/api-report/fluid-static.api.md +6 -19
  3. package/dist/fluidContainer.d.ts +4 -3
  4. package/dist/fluidContainer.d.ts.map +1 -1
  5. package/dist/fluidContainer.js.map +1 -1
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/public.d.ts +0 -3
  10. package/dist/rootDataObject.d.ts +1 -1
  11. package/dist/rootDataObject.d.ts.map +1 -1
  12. package/dist/rootDataObject.js +8 -5
  13. package/dist/rootDataObject.js.map +1 -1
  14. package/dist/serviceAudience.js.map +1 -1
  15. package/dist/types.d.ts +13 -20
  16. package/dist/types.d.ts.map +1 -1
  17. package/dist/types.js.map +1 -1
  18. package/dist/utils.d.ts +5 -12
  19. package/dist/utils.d.ts.map +1 -1
  20. package/dist/utils.js.map +1 -1
  21. package/lib/fluidContainer.d.ts +4 -3
  22. package/lib/fluidContainer.d.ts.map +1 -1
  23. package/lib/fluidContainer.js.map +1 -1
  24. package/lib/index.d.ts +1 -1
  25. package/lib/index.d.ts.map +1 -1
  26. package/lib/index.js.map +1 -1
  27. package/lib/public.d.ts +0 -3
  28. package/lib/rootDataObject.d.ts +1 -1
  29. package/lib/rootDataObject.d.ts.map +1 -1
  30. package/lib/rootDataObject.js +8 -5
  31. package/lib/rootDataObject.js.map +1 -1
  32. package/lib/serviceAudience.js.map +1 -1
  33. package/lib/tsdoc-metadata.json +1 -1
  34. package/lib/types.d.ts +13 -20
  35. package/lib/types.d.ts.map +1 -1
  36. package/lib/types.js.map +1 -1
  37. package/lib/utils.d.ts +5 -12
  38. package/lib/utils.d.ts.map +1 -1
  39. package/lib/utils.js.map +1 -1
  40. package/package.json +37 -24
  41. package/src/fluidContainer.ts +5 -9
  42. package/src/index.ts +0 -3
  43. package/src/rootDataObject.ts +18 -12
  44. package/src/types.ts +13 -18
  45. package/src/utils.ts +8 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/fluid-static",
3
- "version": "2.0.0-dev-rc.4.0.0.261659",
3
+ "version": "2.0.0-dev-rc.5.0.0.265721",
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": {
@@ -57,33 +57,33 @@
57
57
  "temp-directory": "nyc/.nyc_output"
58
58
  },
59
59
  "dependencies": {
60
- "@fluid-internal/client-utils": "2.0.0-dev-rc.4.0.0.261659",
61
- "@fluidframework/aqueduct": "2.0.0-dev-rc.4.0.0.261659",
62
- "@fluidframework/container-definitions": "2.0.0-dev-rc.4.0.0.261659",
63
- "@fluidframework/container-loader": "2.0.0-dev-rc.4.0.0.261659",
64
- "@fluidframework/container-runtime": "2.0.0-dev-rc.4.0.0.261659",
65
- "@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.4.0.0.261659",
66
- "@fluidframework/core-interfaces": "2.0.0-dev-rc.4.0.0.261659",
67
- "@fluidframework/datastore-definitions": "2.0.0-dev-rc.4.0.0.261659",
60
+ "@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.265721",
61
+ "@fluidframework/aqueduct": "2.0.0-dev-rc.5.0.0.265721",
62
+ "@fluidframework/container-definitions": "2.0.0-dev-rc.5.0.0.265721",
63
+ "@fluidframework/container-loader": "2.0.0-dev-rc.5.0.0.265721",
64
+ "@fluidframework/container-runtime": "2.0.0-dev-rc.5.0.0.265721",
65
+ "@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.5.0.0.265721",
66
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.5.0.0.265721",
67
+ "@fluidframework/datastore-definitions": "2.0.0-dev-rc.5.0.0.265721",
68
68
  "@fluidframework/protocol-definitions": "^3.2.0",
69
- "@fluidframework/request-handler": "2.0.0-dev-rc.4.0.0.261659",
70
- "@fluidframework/runtime-definitions": "2.0.0-dev-rc.4.0.0.261659",
71
- "@fluidframework/runtime-utils": "2.0.0-dev-rc.4.0.0.261659",
72
- "@fluidframework/shared-object-base": "2.0.0-dev-rc.4.0.0.261659",
73
- "@fluidframework/telemetry-utils": "2.0.0-dev-rc.4.0.0.261659"
69
+ "@fluidframework/request-handler": "2.0.0-dev-rc.5.0.0.265721",
70
+ "@fluidframework/runtime-definitions": "2.0.0-dev-rc.5.0.0.265721",
71
+ "@fluidframework/runtime-utils": "2.0.0-dev-rc.5.0.0.265721",
72
+ "@fluidframework/shared-object-base": "2.0.0-dev-rc.5.0.0.265721",
73
+ "@fluidframework/telemetry-utils": "2.0.0-dev-rc.5.0.0.265721"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@arethetypeswrong/cli": "^0.15.2",
77
77
  "@biomejs/biome": "^1.6.2",
78
- "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.4.0.0.261659",
79
- "@fluid-tools/build-cli": "0.38.0-259537",
78
+ "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.5.0.0.265721",
79
+ "@fluid-tools/build-cli": "^0.39.0-264124",
80
80
  "@fluidframework/build-common": "^2.0.3",
81
- "@fluidframework/build-tools": "0.38.0-259537",
81
+ "@fluidframework/build-tools": "^0.39.0-264124",
82
82
  "@fluidframework/eslint-config-fluid": "^5.1.0",
83
- "@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-rc.3.0.0",
84
- "@fluidframework/map": "2.0.0-dev-rc.4.0.0.261659",
85
- "@fluidframework/sequence": "2.0.0-dev-rc.4.0.0.261659",
86
- "@microsoft/api-extractor": "^7.42.3",
83
+ "@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-rc.4.0.0",
84
+ "@fluidframework/map": "2.0.0-dev-rc.5.0.0.265721",
85
+ "@fluidframework/sequence": "2.0.0-dev-rc.5.0.0.265721",
86
+ "@microsoft/api-extractor": "^7.43.1",
87
87
  "@types/mocha": "^9.1.1",
88
88
  "@types/node": "^18.19.0",
89
89
  "c8": "^8.0.1",
@@ -96,17 +96,30 @@
96
96
  "moment": "^2.21.0",
97
97
  "prettier": "~3.0.3",
98
98
  "rimraf": "^4.4.0",
99
- "typescript": "~5.1.6"
99
+ "typescript": "~5.3.3"
100
100
  },
101
101
  "typeValidation": {
102
102
  "broken": {
103
- "InterfaceDeclaration_IMember": {
103
+ "RemovedTypeAliasDeclaration_DataObjectClass": {
104
104
  "forwardCompat": false,
105
105
  "backCompat": false
106
106
  },
107
- "TypeAliasDeclaration_Myself": {
107
+ "InterfaceDeclaration_IFluidContainer": {
108
+ "backCompat": false
109
+ },
110
+ "TypeAliasDeclaration_InitialObjects": {
111
+ "backCompat": false
112
+ },
113
+ "RemovedTypeAliasDeclaration_LoadableObjectClass": {
108
114
  "forwardCompat": false,
109
115
  "backCompat": false
116
+ },
117
+ "RemovedTypeAliasDeclaration_LoadableObjectClassRecord": {
118
+ "forwardCompat": false,
119
+ "backCompat": false
120
+ },
121
+ "InterfaceDeclaration_ContainerSchema": {
122
+ "backCompat": false
110
123
  }
111
124
  }
112
125
  },
@@ -15,13 +15,9 @@ import {
15
15
  type IEventProvider,
16
16
  type IFluidLoadable,
17
17
  } from "@fluidframework/core-interfaces";
18
+ import type { SharedObjectKind } from "@fluidframework/shared-object-base";
18
19
 
19
- import type {
20
- ContainerAttachProps,
21
- ContainerSchema,
22
- IRootDataObject,
23
- LoadableObjectClass,
24
- } from "./types.js";
20
+ import type { ContainerAttachProps, ContainerSchema, IRootDataObject } from "./types.js";
25
21
 
26
22
  /**
27
23
  * Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
@@ -33,7 +29,7 @@ export type InitialObjects<T extends ContainerSchema> = {
33
29
  //
34
30
  // The '? TChannel : never' is required because infer can only be used in
35
31
  // a conditional 'extends' expression.
36
- [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends LoadableObjectClass<
32
+ [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends SharedObjectKind<
37
33
  infer TChannel
38
34
  >
39
35
  ? TChannel
@@ -219,7 +215,7 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
219
215
  *
220
216
  * @typeParam T - The class of the `DataObject` or `SharedObject`.
221
217
  */
222
- create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
218
+ create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T>;
223
219
 
224
220
  /**
225
221
  * Dispose of the container instance, permanently disabling it.
@@ -347,7 +343,7 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
347
343
  /**
348
344
  * {@inheritDoc IFluidContainer.create}
349
345
  */
350
- public async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {
346
+ public async create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T> {
351
347
  return this.rootDataObject.create(objectClass);
352
348
  }
353
349
 
package/src/index.ts CHANGED
@@ -20,14 +20,11 @@ export { createServiceAudience } from "./serviceAudience.js";
20
20
  export {
21
21
  type ContainerSchema,
22
22
  type ContainerAttachProps,
23
- type DataObjectClass,
24
23
  type IConnection,
25
24
  type IMember,
26
25
  type IRootDataObject,
27
26
  type IServiceAudience,
28
27
  type IServiceAudienceEvents,
29
- type LoadableObjectClass,
30
- type LoadableObjectClassRecord,
31
28
  type LoadableObjectRecord,
32
29
  type MemberChangedListener,
33
30
  type Myself,
@@ -20,9 +20,11 @@ import {
20
20
  import { type IDirectory } from "@fluidframework/map/internal";
21
21
  import { FlushMode } from "@fluidframework/runtime-definitions/internal";
22
22
  import { RequestParser } from "@fluidframework/runtime-utils/internal";
23
- import type { ISharedObjectKind } from "@fluidframework/shared-object-base";
23
+ import type { SharedObjectKind } from "@fluidframework/shared-object-base";
24
+ import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
24
25
 
25
26
  import {
27
+ type DataObjectClass,
26
28
  type ContainerSchema,
27
29
  type IRootDataObject,
28
30
  type LoadableObjectClass,
@@ -30,7 +32,6 @@ import {
30
32
  type LoadableObjectRecord,
31
33
  } from "./types.js";
32
34
  import {
33
- type InternalDataObjectClass,
34
35
  isDataObjectClass,
35
36
  isSharedObjectKind,
36
37
  parseDataObjectsFromSharedObjects,
@@ -45,7 +46,7 @@ export interface RootDataObjectProps {
45
46
  *
46
47
  * @see {@link RootDataObject.initializingFirstTime}
47
48
  */
48
- initialObjects: LoadableObjectClassRecord;
49
+ readonly initialObjects: LoadableObjectClassRecord;
49
50
  }
50
51
 
51
52
  /**
@@ -84,7 +85,9 @@ class RootDataObject
84
85
  const initialObjectsP: Promise<void>[] = [];
85
86
  for (const [id, objectClass] of Object.entries(props.initialObjects)) {
86
87
  const createObject = async (): Promise<void> => {
87
- const obj = await this.create<IFluidLoadable>(objectClass);
88
+ const obj = await this.create<IFluidLoadable>(
89
+ objectClass as SharedObjectKind<IFluidLoadable>,
90
+ );
88
91
  this.initialObjectsDir.set(id, obj.handle);
89
92
  };
90
93
  initialObjectsP.push(createObject());
@@ -127,23 +130,24 @@ class RootDataObject
127
130
  /**
128
131
  * {@inheritDoc IRootDataObject.create}
129
132
  */
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);
133
+ public async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {
134
+ const internal = objectClass as unknown as LoadableObjectClass<T & IFluidLoadable>;
135
+ if (isDataObjectClass(internal)) {
136
+ return this.createDataObject(internal);
137
+ } else if (isSharedObjectKind(internal)) {
138
+ return this.createSharedObject(internal);
135
139
  }
136
140
  throw new Error("Could not create new Fluid object because an unknown object was passed");
137
141
  }
138
142
 
139
143
  private async createDataObject<T extends IFluidLoadable>(
140
- dataObjectClass: InternalDataObjectClass<T>,
144
+ dataObjectClass: DataObjectClass<T>,
141
145
  ): Promise<T> {
142
146
  const factory = dataObjectClass.factory;
143
147
  const packagePath = [...this.context.packagePath, factory.type];
144
148
  const dataStore = await this.context.containerRuntime.createDataStore(packagePath);
145
149
  const entryPoint = await dataStore.entryPoint.get();
146
- return entryPoint as unknown as T;
150
+ return entryPoint as T;
147
151
  }
148
152
 
149
153
  private createSharedObject<T extends IFluidLoadable>(
@@ -234,7 +238,9 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
234
238
  flushMode: FlushMode.Immediate,
235
239
  // The runtime compressor is required to be on to use @fluidframework/tree.
236
240
  enableRuntimeIdCompressor: "on",
237
- explicitSchemaControl: true,
241
+ // For now this was set to false to allow 1.x/2.x testing with AzureClient.
242
+ // Long term, this config will be set dynamically. See https://github.com/microsoft/FluidFramework/pull/20997.
243
+ explicitSchemaControl: false,
238
244
  },
239
245
  provideEntryPoint,
240
246
  });
package/src/types.ts CHANGED
@@ -8,7 +8,9 @@ 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";
12
14
 
13
15
  /**
14
16
  * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
@@ -19,15 +21,13 @@ export type LoadableObjectRecord = Record<string, IFluidLoadable>;
19
21
  /**
20
22
  * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
21
23
  * or `SharedObject`.
22
- * @public
23
24
  */
24
- export type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
25
+ export type LoadableObjectClassRecord = Record<string, SharedObjectKind>;
25
26
 
26
27
  /**
27
28
  * A class object of `DataObject` or `SharedObject`.
28
29
  *
29
30
  * @typeParam T - The class of the `DataObject` or `SharedObject`.
30
- * @public
31
31
  *
32
32
  * @privateRemarks
33
33
  * There are some edge cases in TypeScript where the order of the members in a union matter.
@@ -46,19 +46,14 @@ export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> =
46
46
  *
47
47
  * @typeParam T - The class of the `DataObject`.
48
48
  * @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
49
+ * Having both `factory` and constructor is redundant.
50
+ * TODO: It appears the factory is what's used, so the constructor should be removed once factory provides strong typing.
52
51
  */
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"] };
52
+ export interface DataObjectClass<T extends IFluidLoadable> {
53
+ readonly factory: IFluidDataStoreFactory;
60
54
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- } & (new (...args: any[]) => T);
55
+ new (...args: any[]): T;
56
+ }
62
57
 
63
58
  /**
64
59
  * Represents properties that can be attached to a container.
@@ -94,7 +89,7 @@ export interface ContainerSchema {
94
89
  * }
95
90
  * ```
96
91
  */
97
- readonly initialObjects: LoadableObjectClassRecord;
92
+ readonly initialObjects: Record<string, SharedObjectKind>;
98
93
 
99
94
  /**
100
95
  * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
@@ -106,7 +101,7 @@ export interface ContainerSchema {
106
101
  * For best practice it's recommended to define all the dynamic types you create even if they are
107
102
  * included via initialObjects.
108
103
  */
109
- readonly dynamicObjectTypes?: readonly LoadableObjectClass[];
104
+ readonly dynamicObjectTypes?: readonly SharedObjectKind[];
110
105
  }
111
106
 
112
107
  /**
@@ -134,7 +129,7 @@ export interface IRootDataObject extends IProvideRootDataObject {
134
129
  *
135
130
  * @typeParam T - The class of the `DataObject` or `SharedObject`.
136
131
  */
137
- create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
132
+ create<T>(objectClass: SharedObjectKind<T>): Promise<T>;
138
133
  }
139
134
 
140
135
  /**
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) {