@fluidframework/fluid-static 2.0.0-internal.6.4.0 → 2.0.0-internal.7.1.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.
@@ -0,0 +1,557 @@
1
+ /**
2
+ * Provides a simple and powerful way to consume collaborative Fluid data.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ import { AttachState } from '@fluidframework/container-definitions';
8
+ import { BaseContainerRuntimeFactory } from '@fluidframework/aqueduct';
9
+ import { ConnectionState } from '@fluidframework/container-definitions';
10
+ import { IAudience } from '@fluidframework/container-definitions';
11
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
12
+ import { IClient } from '@fluidframework/protocol-definitions';
13
+ import { IContainer } from '@fluidframework/container-definitions';
14
+ import { IContainerRuntime } from '@fluidframework/container-runtime-definitions';
15
+ import { ICriticalContainerError } from '@fluidframework/container-definitions';
16
+ import { IEvent } from '@fluidframework/core-interfaces';
17
+ import { IEventProvider } from '@fluidframework/core-interfaces';
18
+ import { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
19
+ import { IFluidLoadable } from '@fluidframework/core-interfaces';
20
+ import { TypedEventEmitter } from '@fluid-internal/client-utils';
21
+
22
+ /**
23
+ * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
24
+ *
25
+ * @remarks
26
+ *
27
+ * It includes both the instances of objects that are initially available upon `Container` creation, as well
28
+ * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.
29
+ */
30
+ export declare interface ContainerSchema {
31
+ /**
32
+ * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.
33
+ *
34
+ * @remarks It uses the key as the id and the value as the loadable object to create.
35
+ *
36
+ * @example
37
+ *
38
+ * In the example below two objects will be created when the `Container` is first
39
+ * created. One with id "map1" that will return a `SharedMap` and the other with
40
+ * id "pair1" that will return a `KeyValueDataObject`.
41
+ *
42
+ * ```typescript
43
+ * {
44
+ * map1: SharedMap,
45
+ * pair1: KeyValueDataObject,
46
+ * }
47
+ * ```
48
+ */
49
+ initialObjects: LoadableObjectClassRecord;
50
+ /**
51
+ * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
52
+ *
53
+ * @remarks
54
+ *
55
+ * Types defined in `initialObjects` will always be available and are not required to be provided here.
56
+ *
57
+ * For best practice it's recommended to define all the dynamic types you create even if they are
58
+ * included via initialObjects.
59
+ */
60
+ dynamicObjectTypes?: LoadableObjectClass<any>[];
61
+ }
62
+
63
+ /**
64
+ * A class that has a factory that can create a `DataObject` and a
65
+ * constructor that will return the type of the `DataObject`.
66
+ *
67
+ * @typeParam T - The class of the `DataObject`.
68
+ */
69
+ export declare type DataObjectClass<T extends IFluidLoadable> = {
70
+ readonly factory: IFluidDataStoreFactory;
71
+ } & LoadableObjectCtor<T>;
72
+
73
+ /**
74
+ * Container code that provides a single {@link IRootDataObject}.
75
+ *
76
+ * @remarks
77
+ *
78
+ * This data object is dynamically customized (registry and initial objects) based on the schema provided.
79
+ * to the container runtime factory.
80
+ */
81
+ export declare class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
82
+ private readonly rootDataObjectFactory;
83
+ private readonly initialObjects;
84
+ constructor(schema: ContainerSchema);
85
+ /**
86
+ * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}
87
+ */
88
+ protected containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void>;
89
+ }
90
+
91
+ /**
92
+ * Base {@link IFluidContainer} implementation.
93
+ *
94
+ * @remarks
95
+ *
96
+ * Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
97
+ * will need to utilize or provide a service-specific implementation of this type that implements that method.
98
+ */
99
+ export declare class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {
100
+ private readonly container;
101
+ private readonly rootDataObject;
102
+ private readonly connectedHandler;
103
+ private readonly disconnectedHandler;
104
+ private readonly disposedHandler;
105
+ private readonly savedHandler;
106
+ private readonly dirtyHandler;
107
+ constructor(container: IContainer, rootDataObject: IRootDataObject);
108
+ /**
109
+ * {@inheritDoc IFluidContainer.isDirty}
110
+ */
111
+ get isDirty(): boolean;
112
+ /**
113
+ * {@inheritDoc IFluidContainer.attachState}
114
+ */
115
+ get attachState(): AttachState;
116
+ /**
117
+ * {@inheritDoc IFluidContainer.disposed}
118
+ */
119
+ get disposed(): boolean;
120
+ /**
121
+ * {@inheritDoc IFluidContainer.connectionState}
122
+ */
123
+ get connectionState(): ConnectionState;
124
+ /**
125
+ * {@inheritDoc IFluidContainer.initialObjects}
126
+ */
127
+ get initialObjects(): LoadableObjectRecord;
128
+ /**
129
+ * Incomplete base implementation of {@link IFluidContainer.attach}.
130
+ *
131
+ * @remarks
132
+ *
133
+ * Note: this implementation will unconditionally throw.
134
+ * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type
135
+ * that provides an implementation of this method.
136
+ *
137
+ * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,
138
+ * but internally this separation is not there.
139
+ */
140
+ attach(): Promise<string>;
141
+ /**
142
+ * {@inheritDoc IFluidContainer.connect}
143
+ */
144
+ connect(): Promise<void>;
145
+ /**
146
+ * {@inheritDoc IFluidContainer.connect}
147
+ */
148
+ disconnect(): Promise<void>;
149
+ /**
150
+ * {@inheritDoc IFluidContainer.create}
151
+ */
152
+ create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
153
+ /**
154
+ * {@inheritDoc IFluidContainer.dispose}
155
+ */
156
+ dispose(): void;
157
+ /**
158
+ * FOR INTERNAL USE ONLY. NOT FOR EXTERNAL USE.
159
+ * We make no stability guarantees here whatsoever.
160
+ *
161
+ * Gets the underlying {@link @fluidframework/container-definitions#IContainer}.
162
+ *
163
+ * @remarks Used to power debug tooling.
164
+ *
165
+ * @internal
166
+ */
167
+ readonly INTERNAL_CONTAINER_DO_NOT_USE?: () => IContainer;
168
+ }
169
+
170
+ /**
171
+ * Base interface for information for each connection made to the Fluid session.
172
+ *
173
+ * @remarks This interface can be extended to provide additional information specific to each service.
174
+ */
175
+ export declare interface IConnection {
176
+ /**
177
+ * A unique ID for the connection. A single user may have multiple connections, each with a different ID.
178
+ */
179
+ id: string;
180
+ /**
181
+ * Whether the connection is in read or read/write mode.
182
+ */
183
+ mode: "write" | "read";
184
+ }
185
+
186
+ /**
187
+ * Provides an entrypoint into the client side of collaborative Fluid data.
188
+ * Provides access to the data as well as status on the collaboration session.
189
+ *
190
+ * @remarks Note: external implementations of this interface are not supported.
191
+ */
192
+ export declare interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
193
+ /**
194
+ * Provides the current connected state of the container
195
+ */
196
+ readonly connectionState: ConnectionState;
197
+ /**
198
+ * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.
199
+ *
200
+ * @remarks
201
+ *
202
+ * You should always check the `isDirty` flag before closing the container or navigating away from the page.
203
+ * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been
204
+ * acknowledged by the service.
205
+ *
206
+ * A container is considered dirty in the following cases:
207
+ *
208
+ * 1. The container has been created in the detached state, and either it has not been attached yet or it is
209
+ * in the process of being attached (container is in `attaching` state). If container is closed prior to being
210
+ * attached, host may never know if the file was created or not.
211
+ *
212
+ * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.
213
+ * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the
214
+ * service. In some cases this can be due to lack of network connection. If the network connection is down,
215
+ * it needs to be restored for the pending changes to be acknowledged.
216
+ */
217
+ readonly isDirty: boolean;
218
+ /**
219
+ * Whether or not the container is disposed, which permanently disables it.
220
+ */
221
+ readonly disposed: boolean;
222
+ /**
223
+ * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.
224
+ *
225
+ * @remarks These data objects and DDSes exist for the lifetime of the container.
226
+ */
227
+ readonly initialObjects: LoadableObjectRecord;
228
+ /**
229
+ * The current attachment state of the container.
230
+ *
231
+ * @remarks
232
+ *
233
+ * Once a container has been attached, it remains attached.
234
+ * When loading an existing container, it will already be attached.
235
+ */
236
+ readonly attachState: AttachState;
237
+ /**
238
+ * A newly created container starts detached from the collaborative service.
239
+ * Calling `attach()` uploads the new container to the service and connects to the collaborative service.
240
+ *
241
+ * @remarks
242
+ *
243
+ * This should only be called when the container is in the
244
+ * {@link @fluidframework/container-definitions#AttachState.Detatched} state.
245
+ *
246
+ * This can be determined by observing {@link IFluidContainer.attachState}.
247
+ *
248
+ * @returns A promise which resolves when the attach is complete, with the string identifier of the container.
249
+ */
250
+ attach(): Promise<string>;
251
+ /**
252
+ * Attempts to connect the container to the delta stream and process operations.
253
+ *
254
+ * @throws Will throw an error if connection is unsuccessful.
255
+ *
256
+ * @remarks
257
+ *
258
+ * This should only be called when the container is in the
259
+ * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
260
+ *
261
+ * This can be determined by observing {@link IFluidContainer.connectionState}.
262
+ */
263
+ connect(): void;
264
+ /**
265
+ * Disconnects the container from the delta stream and stops processing operations.
266
+ *
267
+ * @remarks
268
+ *
269
+ * This should only be called when the container is in the
270
+ * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
271
+ *
272
+ * This can be determined by observing {@link IFluidContainer.connectionState}.
273
+ */
274
+ disconnect(): void;
275
+ /**
276
+ * Create a new data object or Distributed Data Store (DDS) of the specified type.
277
+ *
278
+ * @remarks
279
+ *
280
+ * In order to share the data object or DDS with other
281
+ * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
282
+ * initialObjects.
283
+ *
284
+ * @param objectClass - The class of the `DataObject` or `SharedObject` to create.
285
+ *
286
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
287
+ */
288
+ create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
289
+ /**
290
+ * Dispose of the container instance, permanently disabling it.
291
+ */
292
+ dispose(): void;
293
+ }
294
+
295
+ /**
296
+ * Events emitted from {@link IFluidContainer}.
297
+ */
298
+ export declare interface IFluidContainerEvents extends IEvent {
299
+ /**
300
+ * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.
301
+ *
302
+ * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
303
+ *
304
+ * @see
305
+ *
306
+ * - {@link IFluidContainer.connectionState}
307
+ *
308
+ * - {@link IFluidContainer.connect}
309
+ */
310
+ (event: "connected", listener: () => void): void;
311
+ /**
312
+ * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.
313
+ *
314
+ * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
315
+ *
316
+ * @see
317
+ *
318
+ * - {@link IFluidContainer.connectionState}
319
+ *
320
+ * - {@link IFluidContainer.disconnect}
321
+ */
322
+ (event: "disconnected", listener: () => void): void;
323
+ /**
324
+ * Emitted when all local changes/edits have been acknowledged by the service.
325
+ *
326
+ * @remarks "dirty" event will be emitted when the next local change has been made.
327
+ *
328
+ * @see {@link IFluidContainer.isDirty}
329
+ */
330
+ (event: "saved", listener: () => void): void;
331
+ /**
332
+ * Emitted when the first local change has been made, following a "saved" event.
333
+ *
334
+ * @remarks "saved" event will be emitted once all local changes have been acknowledged by the service.
335
+ *
336
+ * @see {@link IFluidContainer.isDirty}
337
+ */
338
+ (event: "dirty", listener: () => void): void;
339
+ /**
340
+ * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.
341
+ *
342
+ * @remarks Listener parameters:
343
+ *
344
+ * - `error`: If the container was closed due to error (as opposed to an explicit call to
345
+ * {@link IFluidContainer.dispose}), this will contain details about the error that caused it.
346
+ */
347
+ (event: "disposed", listener: (error?: ICriticalContainerError) => void): any;
348
+ }
349
+
350
+ /**
351
+ * Base interface to be implemented to fetch each service's member.
352
+ *
353
+ * @remarks This interface can be extended by each service to provide additional service-specific user metadata.
354
+ */
355
+ export declare interface IMember {
356
+ /**
357
+ * An ID for the user, unique among each individual user connecting to the session.
358
+ */
359
+ userId: string;
360
+ /**
361
+ * The set of connections the user has made, e.g. from multiple tabs or devices.
362
+ */
363
+ connections: IConnection[];
364
+ }
365
+
366
+ /**
367
+ * Holds the collection of objects that the container was initially created with, as well as provides the ability
368
+ * to dynamically create further objects during usage.
369
+ */
370
+ export declare interface IRootDataObject {
371
+ /**
372
+ * Provides a record of the initial objects defined on creation.
373
+ */
374
+ readonly initialObjects: LoadableObjectRecord;
375
+ /**
376
+ * Dynamically creates a new detached collaborative object (DDS/DataObject).
377
+ *
378
+ * @param objectClass - Type of the collaborative object to be created.
379
+ *
380
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
381
+ */
382
+ create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
383
+ }
384
+
385
+ /**
386
+ * Base interface to be implemented to fetch each service's audience.
387
+ *
388
+ * @remarks
389
+ *
390
+ * The type parameter `M` allows consumers to further extend the client object with service-specific
391
+ * details about the connecting client, such as device information, environment, or a username.
392
+ *
393
+ * @typeParam M - A service-specific {@link IMember} type.
394
+ */
395
+ export declare interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
396
+ /**
397
+ * Returns an map of all users currently in the Fluid session where key is the userId and the value is the
398
+ * member object. The implementation may choose to exclude certain connections from the returned map.
399
+ * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.
400
+ */
401
+ getMembers(): Map<string, M>;
402
+ /**
403
+ * Returns the current active user on this client once they are connected. Otherwise, returns undefined.
404
+ */
405
+ getMyself(): Myself<M> | undefined;
406
+ }
407
+
408
+ /**
409
+ * Events that trigger when the roster of members in the Fluid session change.
410
+ *
411
+ * @remarks
412
+ *
413
+ * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s
414
+ * {@link IServiceAudience.getMembers} method will emit events.
415
+ *
416
+ * @typeParam M - A service-specific {@link IMember} implementation.
417
+ */
418
+ export declare interface IServiceAudienceEvents<M extends IMember> extends IEvent {
419
+ /**
420
+ * Emitted when a {@link IMember | member}(s) are either added or removed.
421
+ *
422
+ * @eventProperty
423
+ */
424
+ (event: "membersChanged", listener: () => void): void;
425
+ /**
426
+ * Emitted when a {@link IMember | member} joins the audience.
427
+ *
428
+ * @eventProperty
429
+ */
430
+ (event: "memberAdded", listener: MemberChangedListener<M>): void;
431
+ /**
432
+ * Emitted when a {@link IMember | member} leaves the audience.
433
+ *
434
+ * @eventProperty
435
+ */
436
+ (event: "memberRemoved", listener: MemberChangedListener<M>): void;
437
+ }
438
+
439
+ /**
440
+ * A class object of `DataObject` or `SharedObject`.
441
+ *
442
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
443
+ */
444
+ export declare type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> | SharedObjectClass<T>;
445
+
446
+ /**
447
+ * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
448
+ * or `SharedObject` in a {@link LoadableObjectRecord}.
449
+ */
450
+ export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
451
+
452
+ /**
453
+ * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
454
+ *
455
+ * @typeParam T - The class of the loadable object.
456
+ */
457
+ export declare type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
458
+
459
+ /**
460
+ * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
461
+ */
462
+ export declare type LoadableObjectRecord = Record<string, IFluidLoadable>;
463
+
464
+ /**
465
+ * Signature for {@link IMember} change events.
466
+ *
467
+ * @param clientId - A unique identifier for the client.
468
+ * @param member - The service-specific member object for the client.
469
+ *
470
+ * @see See {@link IServiceAudienceEvents} for usage details.
471
+ */
472
+ export declare type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;
473
+
474
+ /**
475
+ * An extended member object that includes currentConnection
476
+ */
477
+ export declare type Myself<M extends IMember = IMember> = M & {
478
+ currentConnection: string;
479
+ };
480
+
481
+ /**
482
+ * Base class for providing audience information for sessions interacting with {@link IFluidContainer}
483
+ *
484
+ * @remarks
485
+ *
486
+ * This can be extended by different service-specific client packages to additional parameters to
487
+ * the user and client details returned in {@link IMember}.
488
+ *
489
+ * @typeParam M - A service-specific {@link IMember} implementation.
490
+ */
491
+ export declare abstract class ServiceAudience<M extends IMember = IMember> extends TypedEventEmitter<IServiceAudienceEvents<M>> implements IServiceAudience<M> {
492
+ /**
493
+ * Fluid Container to read the audience from.
494
+ */
495
+ protected readonly container: IContainer;
496
+ /**
497
+ * Audience object which includes all the existing members of the {@link IFluidContainer | container}.
498
+ */
499
+ protected readonly audience: IAudience;
500
+ /**
501
+ * Retain the most recent member list.
502
+ *
503
+ * @remarks
504
+ *
505
+ * This is so we have more information about a member leaving the audience in the `removeMember` event.
506
+ *
507
+ * It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this
508
+ * class exposes (and would actually produce a change in what `getMembers` returns).
509
+ *
510
+ * It also allows us to provide the client details in the event which makes it easier to find that client connection
511
+ * in a map keyed on the `userId` and not `clientId`.
512
+ *
513
+ * This map will always be up-to-date in a `removeMember` event because it is set once at construction and in
514
+ * every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}
515
+ * events provide.
516
+ */
517
+ protected lastMembers: Map<string, M>;
518
+ constructor(
519
+ /**
520
+ * Fluid Container to read the audience from.
521
+ */
522
+ container: IContainer);
523
+ /**
524
+ * Provides ability for inheriting class to modify/extend the audience object.
525
+ *
526
+ * @param audienceMember - Record of a specific audience member.
527
+ */
528
+ protected abstract createServiceMember(audienceMember: IClient): M;
529
+ /**
530
+ * {@inheritDoc IServiceAudience.getMembers}
531
+ */
532
+ getMembers(): Map<string, M>;
533
+ /**
534
+ * {@inheritDoc IServiceAudience.getMyself}
535
+ */
536
+ getMyself(): Myself<M> | undefined;
537
+ private getMember;
538
+ /**
539
+ * Provides ability for the inheriting class to include/omit specific members.
540
+ * An example use case is omitting the summarizer client.
541
+ *
542
+ * @param member - Member to be included/omitted.
543
+ */
544
+ protected shouldIncludeAsMember(member: IClient): boolean;
545
+ }
546
+
547
+ /**
548
+ * A class that has a factory that can create a DDSes (`SharedObject`s) and a
549
+ * constructor that will return the type of the `DataObject`.
550
+ *
551
+ * @typeParam T - The class of the `SharedObject`.
552
+ */
553
+ export declare type SharedObjectClass<T extends IFluidLoadable> = {
554
+ readonly getFactory: () => IChannelFactory;
555
+ } & LoadableObjectCtor<T>;
556
+
557
+ export { }
@@ -1 +1 @@
1
- {"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,2BAA2B,EAC3B,UAAU,EAGV,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EACN,eAAe,EAEf,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EAEpB,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,cAAc,EAAE,yBAAyB,CAAC;CAC1C;AAED;;;GAGG;AACH,qBAAa,cACZ,SAAQ,UAAU,CAAC;IAAE,YAAY,EAAE,mBAAmB,CAAA;CAAE,CACxD,YAAW,eAAe;IAE1B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAyB;IAC9D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA4B;IAE5D,OAAO,KAAK,iBAAiB,GAM5B;IAED;;;;;OAKG;cACa,qBAAqB,CAAC,KAAK,EAAE,mBAAmB;IAgBhE;;;;;OAKG;cACa,cAAc;IAc9B;;OAEG;IACH,IAAW,cAAc,IAAI,oBAAoB,CAKhD;IAED;;OAEG;IACU,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,WAAW,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;YAShF,gBAAgB;IAU9B,OAAO,CAAC,kBAAkB;CAO1B;AAID;;;;;;;GAOG;AACH,qBAAa,iCAAkC,SAAQ,2BAA2B;IACj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B;IACjF,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAKpC;IAEF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA4B;gBAE/C,MAAM,EAAE,eAAe;IA6BnC;;OAEG;cACa,8BAA8B,CAAC,OAAO,EAAE,iBAAiB;CAMzE"}
@@ -87,7 +87,7 @@ class RootDataObject extends aqueduct_1.DataObject {
87
87
  const factory = dataObjectClass.factory;
88
88
  const packagePath = [...this.context.packagePath, factory.type];
89
89
  const dataStore = await this.context.containerRuntime.createDataStore(packagePath);
90
- const entryPoint = await dataStore.entryPoint?.get();
90
+ const entryPoint = await dataStore.entryPoint.get();
91
91
  return entryPoint;
92
92
  }
93
93
  createSharedObject(sharedObjectClass) {
@@ -110,10 +110,21 @@ class DOProviderContainerRuntimeFactory extends aqueduct_1.BaseContainerRuntimeF
110
110
  constructor(schema) {
111
111
  const [registryEntries, sharedObjects] = (0, utils_1.parseDataObjectsFromSharedObjects)(schema);
112
112
  const rootDataObjectFactory = new aqueduct_1.DataObjectFactory("rootDO", RootDataObject, sharedObjects, {}, registryEntries);
113
- super([rootDataObjectFactory.registryEntry], undefined, [(0, aqueduct_1.defaultRouteRequestHandler)(rootDataStoreId)],
114
- // temporary workaround to disable message batching until the message batch size issue is resolved
115
- // resolution progress is tracked by the Feature 465 work item in AzDO
116
- { flushMode: runtime_definitions_1.FlushMode.Immediate });
113
+ super({
114
+ registryEntries: [rootDataObjectFactory.registryEntry],
115
+ // eslint-disable-next-line import/no-deprecated
116
+ requestHandlers: [(0, aqueduct_1.defaultRouteRequestHandler)(rootDataStoreId)],
117
+ // temporary workaround to disable message batching until the message batch size issue is resolved
118
+ // resolution progress is tracked by the Feature 465 work item in AzDO
119
+ runtimeOptions: { flushMode: runtime_definitions_1.FlushMode.Immediate },
120
+ provideEntryPoint: async (containerRuntime) => {
121
+ const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
122
+ if (entryPoint === undefined) {
123
+ throw new Error(`default dataStore [${rootDataStoreId}] must exist`);
124
+ }
125
+ return entryPoint.get();
126
+ },
127
+ });
117
128
  this.rootDataObjectFactory = rootDataObjectFactory;
118
129
  this.initialObjects = schema.initialObjects;
119
130
  }
@@ -1 +1 @@
1
- {"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uDAKkC;AAGlC,6EAAgE;AAUhE,mCAAoG;AAcpG;;;GAGG;AACH,MAAa,cACZ,SAAQ,qBAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IA2F7D,CAAC;IAzFA,IAAY,iBAAiB;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACpE;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAA0B;QAC/D,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAExD,mDAAmD;QACnD,MAAM,eAAe,GAAoB,EAAE,CAAC;QAC5C,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,WAAW,CAAC,EAAE,EAAE;YAClE,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;gBAC/B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;gBAC3C,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;YAC5C,CAAC,CAAC;YACF,eAAe,CAAC,IAAI,CAAC,YAAY,EAAE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AAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAC7C,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,8BAA8B,CAAC,OAA0B;QACxE,sEAAsE;QACtE,MAAM,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,eAAe,EAAE,OAAO,EAAE;YAC7E,cAAc,EAAE,IAAI,CAAC,cAAc;SACnC,CAAC,CAAC;IACJ,CAAC;CACD;AAxCD,8EAwCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\tDataObjectFactory,\n\tdefaultRouteRequestHandler,\n} from \"@fluidframework/aqueduct\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions\";\nimport {\n\tContainerSchema,\n\tDataObjectClass,\n\tIRootDataObject,\n\tLoadableObjectClass,\n\tLoadableObjectClassRecord,\n\tLoadableObjectRecord,\n\tSharedObjectClass,\n} from \"./types\";\nimport { isDataObjectClass, isSharedObjectClass, parseDataObjectsFromSharedObjects } from \"./utils\";\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\nexport interface RootDataObjectProps {\n\t/**\n\t * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n\t *\n\t * @see {@link RootDataObject.initializingFirstTime}\n\t */\n\tinitialObjects: LoadableObjectClassRecord;\n}\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nexport class RootDataObject\n\textends DataObject<{ InitialState: RootDataObjectProps }>\n\timplements IRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\n\tprivate get initialObjectsDir() {\n\t\tconst dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n\t\tif (dir === undefined) {\n\t\t\tthrow new Error(\"InitialObjects sub-directory was not initialized\");\n\t\t}\n\t\treturn dir;\n\t}\n\n\t/**\n\t * The first time this object is initialized, creates each object identified in\n\t * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n\t */\n\tprotected async initializingFirstTime(props: RootDataObjectProps) {\n\t\tthis.root.createSubDirectory(this.initialObjectsDirKey);\n\n\t\t// Create initial objects provided by the developer\n\t\tconst initialObjectsP: Promise<void>[] = [];\n\t\tObject.entries(props.initialObjects).forEach(([id, objectClass]) => {\n\t\t\tconst createObject = async () => {\n\t\t\t\tconst obj = await this.create(objectClass);\n\t\t\t\tthis.initialObjectsDir.set(id, obj.handle);\n\t\t\t};\n\t\t\tinitialObjectsP.push(createObject());\n\t\t});\n\n\t\tawait Promise.all(initialObjectsP);\n\t}\n\n\t/**\n\t * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n\t * accessed immediately.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n\t */\n\tprotected async hasInitialized() {\n\t\t// We will always load the initial objects so they are available to the developer\n\t\tconst loadInitialObjectsP: Promise<void>[] = [];\n\t\tfor (const [key, value] of Array.from(this.initialObjectsDir.entries())) {\n\t\t\tconst loadDir = async () => {\n\t\t\t\tconst obj = await value.get();\n\t\t\t\tObject.assign(this._initialObjects, { [key]: obj });\n\t\t\t};\n\t\t\tloadInitialObjectsP.push(loadDir());\n\t\t}\n\n\t\tawait Promise.all(loadInitialObjectsP);\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.initialObjects}\n\t */\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\tif (Object.keys(this._initialObjects).length === 0) {\n\t\t\tthrow new Error(\"Initial Objects were not correctly initialized\");\n\t\t}\n\t\treturn this._initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.create}\n\t */\n\tpublic async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {\n\t\tif (isDataObjectClass(objectClass)) {\n\t\t\treturn this.createDataObject<T>(objectClass);\n\t\t} else if (isSharedObjectClass(objectClass)) {\n\t\t\treturn this.createSharedObject<T>(objectClass);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tprivate async createDataObject<T extends IFluidLoadable>(\n\t\tdataObjectClass: DataObjectClass<T>,\n\t): Promise<T> {\n\t\tconst factory = dataObjectClass.factory;\n\t\tconst packagePath = [...this.context.packagePath, factory.type];\n\t\tconst dataStore = await this.context.containerRuntime.createDataStore(packagePath);\n\t\tconst entryPoint = await dataStore.entryPoint?.get();\n\t\treturn entryPoint as unknown as T;\n\t}\n\n\tprivate createSharedObject<T extends IFluidLoadable>(\n\t\tsharedObjectClass: SharedObjectClass<T>,\n\t): T {\n\t\tconst factory = sharedObjectClass.getFactory();\n\t\tconst obj = this.runtime.createChannel(undefined, factory.type);\n\t\treturn obj as unknown as T;\n\t}\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * Container code that provides a single {@link IRootDataObject}.\n *\n * @remarks\n *\n * This data object is dynamically customized (registry and initial objects) based on the schema provided.\n * to the container runtime factory.\n */\nexport class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\tprivate readonly rootDataObjectFactory: DataObjectFactory<\n\t\tRootDataObject,\n\t\t{\n\t\t\tInitialState: RootDataObjectProps;\n\t\t}\n\t>;\n\n\tprivate readonly initialObjects: LoadableObjectClassRecord;\n\n\tconstructor(schema: ContainerSchema) {\n\t\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n\t\tconst rootDataObjectFactory = new DataObjectFactory(\n\t\t\t\"rootDO\",\n\t\t\tRootDataObject,\n\t\t\tsharedObjects,\n\t\t\t{},\n\t\t\tregistryEntries,\n\t\t);\n\t\tsuper(\n\t\t\t[rootDataObjectFactory.registryEntry],\n\t\t\tundefined,\n\t\t\t[defaultRouteRequestHandler(rootDataStoreId)],\n\t\t\t// temporary workaround to disable message batching until the message batch size issue is resolved\n\t\t\t// resolution progress is tracked by the Feature 465 work item in AzDO\n\t\t\t{ flushMode: FlushMode.Immediate },\n\t\t);\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}\n\t */\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime) {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uDAMkC;AAGlC,6EAAgE;AAUhE,mCAAoG;AAcpG;;;GAGG;AACH,MAAa,cACZ,SAAQ,qBAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IA2F7D,CAAC;IAzFA,IAAY,iBAAiB;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACpE;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAA0B;QAC/D,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAExD,mDAAmD;QACnD,MAAM,eAAe,GAAoB,EAAE,CAAC;QAC5C,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AM,CAAC,CAAC;QACnF,MAAM,qBAAqB,GAAG,IAAI,4BAAiB,CAClD,QAAQ,EACR,cAAc,EACd,aAAa,EACb,EAAE,EACF,eAAe,CACf,CAAC;QACF,KAAK,CAAC;YACL,eAAe,EAAE,CAAC,qBAAqB,CAAC,aAAa,CAAC;YACtD,gDAAgD;YAChD,eAAe,EAAE,CAAC,IAAA,qCAA0B,EAAC,eAAe,CAAC,CAAC;YAC9D,kGAAkG;YAClG,sEAAsE;YACtE,cAAc,EAAE,EAAE,SAAS,EAAE,+BAAS,CAAC,SAAS,EAAE;YAClD,iBAAiB,EAAE,KAAK,EAAE,gBAAmC,EAAE,EAAE;gBAChE,MAAM,UAAU,GACf,MAAM,gBAAgB,CAAC,6BAA6B,CAAC,eAAe,CAAC,CAAC;gBACvE,IAAI,UAAU,KAAK,SAAS,EAAE;oBAC7B,MAAM,IAAI,KAAK,CAAC,sBAAsB,eAAe,cAAc,CAAC,CAAC;iBACrE;gBACD,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC;YACzB,CAAC;SACD,CAAC,CAAC;QACH,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAC7C,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,8BAA8B,CAAC,OAA0B;QACxE,sEAAsE;QACtE,MAAM,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,eAAe,EAAE,OAAO,EAAE;YAC7E,cAAc,EAAE,IAAI,CAAC,cAAc;SACnC,CAAC,CAAC;IACJ,CAAC;CACD;AAhDD,8EAgDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\tDataObjectFactory,\n\t// eslint-disable-next-line import/no-deprecated\n\tdefaultRouteRequestHandler,\n} from \"@fluidframework/aqueduct\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions\";\nimport {\n\tContainerSchema,\n\tDataObjectClass,\n\tIRootDataObject,\n\tLoadableObjectClass,\n\tLoadableObjectClassRecord,\n\tLoadableObjectRecord,\n\tSharedObjectClass,\n} from \"./types\";\nimport { isDataObjectClass, isSharedObjectClass, parseDataObjectsFromSharedObjects } from \"./utils\";\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\nexport interface RootDataObjectProps {\n\t/**\n\t * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n\t *\n\t * @see {@link RootDataObject.initializingFirstTime}\n\t */\n\tinitialObjects: LoadableObjectClassRecord;\n}\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nexport class RootDataObject\n\textends DataObject<{ InitialState: RootDataObjectProps }>\n\timplements IRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\n\tprivate get initialObjectsDir() {\n\t\tconst dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n\t\tif (dir === undefined) {\n\t\t\tthrow new Error(\"InitialObjects sub-directory was not initialized\");\n\t\t}\n\t\treturn dir;\n\t}\n\n\t/**\n\t * The first time this object is initialized, creates each object identified in\n\t * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n\t */\n\tprotected async initializingFirstTime(props: RootDataObjectProps) {\n\t\tthis.root.createSubDirectory(this.initialObjectsDirKey);\n\n\t\t// Create initial objects provided by the developer\n\t\tconst initialObjectsP: Promise<void>[] = [];\n\t\tObject.entries(props.initialObjects).forEach(([id, objectClass]) => {\n\t\t\tconst createObject = async () => {\n\t\t\t\tconst obj = await this.create(objectClass);\n\t\t\t\tthis.initialObjectsDir.set(id, obj.handle);\n\t\t\t};\n\t\t\tinitialObjectsP.push(createObject());\n\t\t});\n\n\t\tawait Promise.all(initialObjectsP);\n\t}\n\n\t/**\n\t * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n\t * accessed immediately.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n\t */\n\tprotected async hasInitialized() {\n\t\t// We will always load the initial objects so they are available to the developer\n\t\tconst loadInitialObjectsP: Promise<void>[] = [];\n\t\tfor (const [key, value] of Array.from(this.initialObjectsDir.entries())) {\n\t\t\tconst loadDir = async () => {\n\t\t\t\tconst obj = await value.get();\n\t\t\t\tObject.assign(this._initialObjects, { [key]: obj });\n\t\t\t};\n\t\t\tloadInitialObjectsP.push(loadDir());\n\t\t}\n\n\t\tawait Promise.all(loadInitialObjectsP);\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.initialObjects}\n\t */\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\tif (Object.keys(this._initialObjects).length === 0) {\n\t\t\tthrow new Error(\"Initial Objects were not correctly initialized\");\n\t\t}\n\t\treturn this._initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.create}\n\t */\n\tpublic async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {\n\t\tif (isDataObjectClass(objectClass)) {\n\t\t\treturn this.createDataObject<T>(objectClass);\n\t\t} else if (isSharedObjectClass(objectClass)) {\n\t\t\treturn this.createSharedObject<T>(objectClass);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tprivate async createDataObject<T extends IFluidLoadable>(\n\t\tdataObjectClass: DataObjectClass<T>,\n\t): Promise<T> {\n\t\tconst factory = dataObjectClass.factory;\n\t\tconst packagePath = [...this.context.packagePath, factory.type];\n\t\tconst dataStore = await this.context.containerRuntime.createDataStore(packagePath);\n\t\tconst entryPoint = await dataStore.entryPoint.get();\n\t\treturn entryPoint as unknown as T;\n\t}\n\n\tprivate createSharedObject<T extends IFluidLoadable>(\n\t\tsharedObjectClass: SharedObjectClass<T>,\n\t): T {\n\t\tconst factory = sharedObjectClass.getFactory();\n\t\tconst obj = this.runtime.createChannel(undefined, factory.type);\n\t\treturn obj as unknown as T;\n\t}\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * Container code that provides a single {@link IRootDataObject}.\n *\n * @remarks\n *\n * This data object is dynamically customized (registry and initial objects) based on the schema provided.\n * to the container runtime factory.\n */\nexport class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\tprivate readonly rootDataObjectFactory: DataObjectFactory<\n\t\tRootDataObject,\n\t\t{\n\t\t\tInitialState: RootDataObjectProps;\n\t\t}\n\t>;\n\n\tprivate readonly initialObjects: LoadableObjectClassRecord;\n\n\tconstructor(schema: ContainerSchema) {\n\t\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n\t\tconst rootDataObjectFactory = new DataObjectFactory(\n\t\t\t\"rootDO\",\n\t\t\tRootDataObject,\n\t\t\tsharedObjects,\n\t\t\t{},\n\t\t\tregistryEntries,\n\t\t);\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\trequestHandlers: [defaultRouteRequestHandler(rootDataStoreId)],\n\t\t\t// temporary workaround to disable message batching until the message batch size issue is resolved\n\t\t\t// resolution progress is tracked by the Feature 465 work item in AzDO\n\t\t\truntimeOptions: { flushMode: FlushMode.Immediate },\n\t\t\tprovideEntryPoint: async (containerRuntime: IContainerRuntime) => {\n\t\t\t\tconst entryPoint =\n\t\t\t\t\tawait containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\t\tif (entryPoint === undefined) {\n\t\t\t\t\tthrow new Error(`default dataStore [${rootDataStoreId}] must exist`);\n\t\t\t\t}\n\t\t\t\treturn entryPoint.get();\n\t\t\t},\n\t\t});\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}\n\t */\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime) {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.34.9"
8
+ "packageVersion": "7.38.0"
9
9
  }
10
10
  ]
11
11
  }