@fluidframework/aqueduct 2.33.2 → 2.40.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 +4 -0
- package/README.md +10 -12
- package/api-report/aqueduct.legacy.alpha.api.md +16 -3
- package/dist/container-runtime-factories/baseContainerRuntimeFactory.d.ts +7 -1
- package/dist/container-runtime-factories/baseContainerRuntimeFactory.d.ts.map +1 -1
- package/dist/container-runtime-factories/baseContainerRuntimeFactory.js +2 -0
- package/dist/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
- package/dist/data-object-factories/dataObjectFactory.d.ts +9 -3
- package/dist/data-object-factories/dataObjectFactory.d.ts.map +1 -1
- package/dist/data-object-factories/dataObjectFactory.js +20 -10
- package/dist/data-object-factories/dataObjectFactory.js.map +1 -1
- package/dist/data-object-factories/index.d.ts +1 -1
- package/dist/data-object-factories/index.d.ts.map +1 -1
- package/dist/data-object-factories/index.js.map +1 -1
- package/dist/data-object-factories/pureDataObjectFactory.d.ts +48 -9
- package/dist/data-object-factories/pureDataObjectFactory.d.ts.map +1 -1
- package/dist/data-object-factories/pureDataObjectFactory.js +45 -22
- package/dist/data-object-factories/pureDataObjectFactory.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +1 -0
- package/lib/container-runtime-factories/baseContainerRuntimeFactory.d.ts +7 -1
- package/lib/container-runtime-factories/baseContainerRuntimeFactory.d.ts.map +1 -1
- package/lib/container-runtime-factories/baseContainerRuntimeFactory.js +2 -0
- package/lib/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
- package/lib/data-object-factories/dataObjectFactory.d.ts +9 -3
- package/lib/data-object-factories/dataObjectFactory.d.ts.map +1 -1
- package/lib/data-object-factories/dataObjectFactory.js +18 -8
- package/lib/data-object-factories/dataObjectFactory.js.map +1 -1
- package/lib/data-object-factories/index.d.ts +1 -1
- package/lib/data-object-factories/index.d.ts.map +1 -1
- package/lib/data-object-factories/index.js +1 -1
- package/lib/data-object-factories/index.js.map +1 -1
- package/lib/data-object-factories/pureDataObjectFactory.d.ts +48 -9
- package/lib/data-object-factories/pureDataObjectFactory.d.ts.map +1 -1
- package/lib/data-object-factories/pureDataObjectFactory.js +45 -22
- package/lib/data-object-factories/pureDataObjectFactory.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +1 -0
- package/package.json +18 -18
- package/src/container-runtime-factories/baseContainerRuntimeFactory.ts +9 -0
- package/src/data-object-factories/dataObjectFactory.ts +40 -10
- package/src/data-object-factories/index.ts +4 -1
- package/src/data-object-factories/pureDataObjectFactory.ts +139 -51
- package/src/index.ts +1 -0
|
@@ -23,6 +23,7 @@ import type {
|
|
|
23
23
|
IFluidDataStoreContext,
|
|
24
24
|
IFluidDataStoreContextDetached,
|
|
25
25
|
IFluidDataStoreFactory,
|
|
26
|
+
IFluidDataStorePolicies,
|
|
26
27
|
IFluidDataStoreRegistry,
|
|
27
28
|
IProvideFluidDataStoreRegistry,
|
|
28
29
|
NamedFluidDataStoreRegistryEntries,
|
|
@@ -40,6 +41,16 @@ import type {
|
|
|
40
41
|
PureDataObject,
|
|
41
42
|
} from "../data-objects/index.js";
|
|
42
43
|
|
|
44
|
+
interface CreateDataObjectProps<TObj extends PureDataObject, I extends DataObjectTypes> {
|
|
45
|
+
ctor: new (props: IDataObjectProps<I>) => TObj;
|
|
46
|
+
context: IFluidDataStoreContext;
|
|
47
|
+
sharedObjectRegistry: ISharedObjectRegistry;
|
|
48
|
+
optionalProviders: FluidObjectSymbolProvider<I["OptionalProviders"]>;
|
|
49
|
+
runtimeClassArg: typeof FluidDataStoreRuntime;
|
|
50
|
+
existing: boolean;
|
|
51
|
+
initialState?: I["InitialState"];
|
|
52
|
+
policies?: Partial<IFluidDataStorePolicies>;
|
|
53
|
+
}
|
|
43
54
|
/**
|
|
44
55
|
* Proxy over PureDataObject
|
|
45
56
|
* Does delayed creation & initialization of PureDataObject
|
|
@@ -47,15 +58,16 @@ import type {
|
|
|
47
58
|
async function createDataObject<
|
|
48
59
|
TObj extends PureDataObject,
|
|
49
60
|
I extends DataObjectTypes = DataObjectTypes,
|
|
50
|
-
>(
|
|
51
|
-
ctor
|
|
52
|
-
context
|
|
53
|
-
sharedObjectRegistry
|
|
54
|
-
optionalProviders
|
|
55
|
-
runtimeClassArg
|
|
56
|
-
existing
|
|
57
|
-
initProps
|
|
58
|
-
|
|
61
|
+
>({
|
|
62
|
+
ctor,
|
|
63
|
+
context,
|
|
64
|
+
sharedObjectRegistry,
|
|
65
|
+
optionalProviders,
|
|
66
|
+
runtimeClassArg,
|
|
67
|
+
existing,
|
|
68
|
+
initialState: initProps,
|
|
69
|
+
policies,
|
|
70
|
+
}: CreateDataObjectProps<TObj, I>): Promise<{
|
|
59
71
|
instance: TObj;
|
|
60
72
|
runtime: FluidDataStoreRuntime;
|
|
61
73
|
}> {
|
|
@@ -92,6 +104,7 @@ async function createDataObject<
|
|
|
92
104
|
await instance.finishInitialization(true);
|
|
93
105
|
return instance;
|
|
94
106
|
} /* provideEntryPoint */,
|
|
107
|
+
policies,
|
|
95
108
|
);
|
|
96
109
|
|
|
97
110
|
// Create object right away.
|
|
@@ -126,6 +139,58 @@ async function createDataObject<
|
|
|
126
139
|
return { instance, runtime };
|
|
127
140
|
}
|
|
128
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Represents the properties required to create a DataObjectFactory.
|
|
144
|
+
* This includes the type identifier, constructor, shared objects, optional providers,
|
|
145
|
+
* registry entries, and the runtime class to use for the data object.
|
|
146
|
+
* @typeParam TObj - DataObject (concrete type)
|
|
147
|
+
* @typeParam I - The input types for the DataObject
|
|
148
|
+
* @legacy
|
|
149
|
+
* @alpha
|
|
150
|
+
*/
|
|
151
|
+
export interface DataObjectFactoryProps<
|
|
152
|
+
TObj extends PureDataObject<I>,
|
|
153
|
+
I extends DataObjectTypes = DataObjectTypes,
|
|
154
|
+
> {
|
|
155
|
+
/**
|
|
156
|
+
* The type identifier for the data object factory.
|
|
157
|
+
*/
|
|
158
|
+
readonly type: string;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The constructor for the data object.
|
|
162
|
+
*/
|
|
163
|
+
readonly ctor: new (
|
|
164
|
+
props: IDataObjectProps<I>,
|
|
165
|
+
) => TObj;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The shared objects (DDSes) to be registered with the data object.
|
|
169
|
+
*/
|
|
170
|
+
readonly sharedObjects?: readonly IChannelFactory[];
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Optional providers for dependency injection.
|
|
174
|
+
*/
|
|
175
|
+
readonly optionalProviders?: FluidObjectSymbolProvider<I["OptionalProviders"]>;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Registry entries for named data stores.
|
|
179
|
+
*/
|
|
180
|
+
readonly registryEntries?: NamedFluidDataStoreRegistryEntries;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* The runtime class to use for the data object.
|
|
184
|
+
*/
|
|
185
|
+
readonly runtimeClass?: typeof FluidDataStoreRuntime;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Optional policies that can be applied to the DataObject.
|
|
189
|
+
* These policies define specific behaviors or constraints for the data object.
|
|
190
|
+
*/
|
|
191
|
+
readonly policies?: Partial<IFluidDataStorePolicies>;
|
|
192
|
+
}
|
|
193
|
+
|
|
129
194
|
/**
|
|
130
195
|
* PureDataObjectFactory is a bare-bones IFluidDataStoreFactory for use with PureDataObject.
|
|
131
196
|
* Consumers should typically use DataObjectFactory instead unless creating
|
|
@@ -141,27 +206,66 @@ export class PureDataObjectFactory<
|
|
|
141
206
|
I extends DataObjectTypes = DataObjectTypes,
|
|
142
207
|
> implements IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry>
|
|
143
208
|
{
|
|
144
|
-
private readonly sharedObjectRegistry: ISharedObjectRegistry;
|
|
145
209
|
private readonly registry: IFluidDataStoreRegistry | undefined;
|
|
210
|
+
private readonly createProps: Omit<CreateDataObjectProps<TObj, I>, "existing" | "context">;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory."type"}
|
|
214
|
+
*/
|
|
215
|
+
public readonly type: string;
|
|
146
216
|
|
|
217
|
+
/**
|
|
218
|
+
* @remarks Use the props object based constructor instead.
|
|
219
|
+
* No new features will be added to this constructor,
|
|
220
|
+
* and it will eventually be deprecated and removed.
|
|
221
|
+
*/
|
|
147
222
|
public constructor(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
private readonly ctor: new (props: IDataObjectProps<I>) => TObj,
|
|
153
|
-
sharedObjects: readonly IChannelFactory[],
|
|
154
|
-
private readonly optionalProviders: FluidObjectSymbolProvider<I["OptionalProviders"]>,
|
|
223
|
+
type: string,
|
|
224
|
+
ctor: new (props: IDataObjectProps<I>) => TObj,
|
|
225
|
+
sharedObjects?: readonly IChannelFactory[],
|
|
226
|
+
optionalProviders?: FluidObjectSymbolProvider<I["OptionalProviders"]>,
|
|
155
227
|
registryEntries?: NamedFluidDataStoreRegistryEntries,
|
|
156
|
-
|
|
228
|
+
runtimeClass?: typeof FluidDataStoreRuntime,
|
|
229
|
+
);
|
|
230
|
+
public constructor(props: DataObjectFactoryProps<TObj, I>);
|
|
231
|
+
public constructor(
|
|
232
|
+
propsOrType: DataObjectFactoryProps<TObj, I> | string,
|
|
233
|
+
maybeCtor?: new (doProps: IDataObjectProps<I>) => TObj,
|
|
234
|
+
maybeSharedObjects?: readonly IChannelFactory[],
|
|
235
|
+
maybeOptionalProviders?: FluidObjectSymbolProvider<I["OptionalProviders"]>,
|
|
236
|
+
maybeRegistryEntries?: NamedFluidDataStoreRegistryEntries,
|
|
237
|
+
maybeRuntimeFactory?: typeof FluidDataStoreRuntime,
|
|
157
238
|
) {
|
|
158
|
-
|
|
239
|
+
const newProps =
|
|
240
|
+
typeof propsOrType === "string"
|
|
241
|
+
? {
|
|
242
|
+
type: propsOrType,
|
|
243
|
+
// both the arg and props base constructor require this param
|
|
244
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
245
|
+
ctor: maybeCtor!,
|
|
246
|
+
sharedObjects: maybeSharedObjects,
|
|
247
|
+
optionalProviders: maybeOptionalProviders,
|
|
248
|
+
registryEntries: maybeRegistryEntries,
|
|
249
|
+
runtimeClass: maybeRuntimeFactory,
|
|
250
|
+
}
|
|
251
|
+
: propsOrType;
|
|
252
|
+
|
|
253
|
+
if (newProps.type === "") {
|
|
159
254
|
throw new Error("undefined type member");
|
|
160
255
|
}
|
|
161
|
-
|
|
162
|
-
|
|
256
|
+
this.type = newProps.type;
|
|
257
|
+
|
|
258
|
+
this.createProps = {
|
|
259
|
+
ctor: newProps.ctor,
|
|
260
|
+
optionalProviders: newProps.optionalProviders ?? {},
|
|
261
|
+
sharedObjectRegistry: new Map(newProps.sharedObjects?.map((ext) => [ext.type, ext])),
|
|
262
|
+
runtimeClassArg: newProps.runtimeClass ?? FluidDataStoreRuntime,
|
|
263
|
+
policies: newProps.policies,
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
if (newProps.registryEntries !== undefined) {
|
|
267
|
+
this.registry = new FluidDataStoreRegistry(newProps.registryEntries);
|
|
163
268
|
}
|
|
164
|
-
this.sharedObjectRegistry = new Map(sharedObjects.map((ext) => [ext.type, ext]));
|
|
165
269
|
}
|
|
166
270
|
|
|
167
271
|
/**
|
|
@@ -195,14 +299,7 @@ export class PureDataObjectFactory<
|
|
|
195
299
|
context: IFluidDataStoreContext,
|
|
196
300
|
existing: boolean,
|
|
197
301
|
): Promise<IFluidDataStoreChannel> {
|
|
198
|
-
const { runtime } = await createDataObject(
|
|
199
|
-
this.ctor,
|
|
200
|
-
context,
|
|
201
|
-
this.sharedObjectRegistry,
|
|
202
|
-
this.optionalProviders,
|
|
203
|
-
this.runtimeClass,
|
|
204
|
-
existing,
|
|
205
|
-
);
|
|
302
|
+
const { runtime } = await createDataObject({ ...this.createProps, context, existing });
|
|
206
303
|
|
|
207
304
|
return runtime;
|
|
208
305
|
}
|
|
@@ -297,15 +394,12 @@ export class PureDataObjectFactory<
|
|
|
297
394
|
packagePath ?? [this.type],
|
|
298
395
|
loadingGroupId,
|
|
299
396
|
);
|
|
300
|
-
const { instance, runtime } = await createDataObject(
|
|
301
|
-
this.
|
|
397
|
+
const { instance, runtime } = await createDataObject({
|
|
398
|
+
...this.createProps,
|
|
302
399
|
context,
|
|
303
|
-
|
|
304
|
-
this.optionalProviders,
|
|
305
|
-
this.runtimeClass,
|
|
306
|
-
false, // existing
|
|
400
|
+
existing: false,
|
|
307
401
|
initialState,
|
|
308
|
-
);
|
|
402
|
+
});
|
|
309
403
|
const dataStore = await context.attachRuntime(this, runtime);
|
|
310
404
|
|
|
311
405
|
return [instance, dataStore];
|
|
@@ -330,15 +424,12 @@ export class PureDataObjectFactory<
|
|
|
330
424
|
initialState?: I["InitialState"],
|
|
331
425
|
): Promise<TObj> {
|
|
332
426
|
const context = runtime.createDetachedDataStore([this.type]);
|
|
333
|
-
const { instance, runtime: dataStoreRuntime } = await createDataObject(
|
|
334
|
-
this.
|
|
427
|
+
const { instance, runtime: dataStoreRuntime } = await createDataObject({
|
|
428
|
+
...this.createProps,
|
|
335
429
|
context,
|
|
336
|
-
|
|
337
|
-
this.optionalProviders,
|
|
338
|
-
this.runtimeClass,
|
|
339
|
-
false, // existing
|
|
430
|
+
existing: false,
|
|
340
431
|
initialState,
|
|
341
|
-
);
|
|
432
|
+
});
|
|
342
433
|
const dataStore = await context.attachRuntime(this, dataStoreRuntime);
|
|
343
434
|
const result = await dataStore.trySetAlias(rootDataStoreId);
|
|
344
435
|
if (result !== "Success") {
|
|
@@ -363,15 +454,12 @@ export class PureDataObjectFactory<
|
|
|
363
454
|
context: IFluidDataStoreContextDetached,
|
|
364
455
|
initialState?: I["InitialState"],
|
|
365
456
|
): Promise<TObj> {
|
|
366
|
-
const { instance, runtime } = await createDataObject(
|
|
367
|
-
this.
|
|
457
|
+
const { instance, runtime } = await createDataObject({
|
|
458
|
+
...this.createProps,
|
|
368
459
|
context,
|
|
369
|
-
|
|
370
|
-
this.optionalProviders,
|
|
371
|
-
this.runtimeClass,
|
|
372
|
-
false, // existing
|
|
460
|
+
existing: false,
|
|
373
461
|
initialState,
|
|
374
|
-
);
|
|
462
|
+
});
|
|
375
463
|
|
|
376
464
|
await context.attachRuntime(this, runtime);
|
|
377
465
|
|