@fluidframework/test-utils 2.0.0-internal.7.0.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,675 @@
1
+ import { ConfigTypes } from '@fluidframework/telemetry-utils';
2
+ import { ContainerRuntime } from '@fluidframework/container-runtime';
3
+ import { ContainerRuntimeFactoryWithDefaultDataStore } from '@fluidframework/aqueduct';
4
+ import { FluidDataStoreRuntime } from '@fluidframework/datastore';
5
+ import { FluidObject } from '@fluidframework/core-interfaces';
6
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
7
+ import { ICodeDetailsLoader } from '@fluidframework/container-definitions';
8
+ import { IConfigProviderBase } from '@fluidframework/telemetry-utils';
9
+ import { IContainer } from '@fluidframework/container-definitions';
10
+ import { IContainerContext } from '@fluidframework/container-definitions';
11
+ import { IContainerRuntime } from '@fluidframework/container-runtime-definitions';
12
+ import { IContainerRuntimeOptions } from '@fluidframework/container-runtime';
13
+ import { IDocumentService } from '@fluidframework/driver-definitions';
14
+ import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
15
+ import { IDocumentStorageService } from '@fluidframework/driver-definitions';
16
+ import { IFluidCodeDetails } from '@fluidframework/container-definitions';
17
+ import { IFluidDataStoreChannel } from '@fluidframework/runtime-definitions';
18
+ import { IFluidDataStoreContext } from '@fluidframework/runtime-definitions';
19
+ import { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
20
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
21
+ import { IFluidHandle } from '@fluidframework/core-interfaces';
22
+ import { IFluidLoadable } from '@fluidframework/core-interfaces';
23
+ import { IFluidModule } from '@fluidframework/container-definitions';
24
+ import { IFluidModuleWithDetails } from '@fluidframework/container-definitions';
25
+ import { IHostLoader } from '@fluidframework/container-definitions';
26
+ import { ILoaderOptions } from '@fluidframework/container-definitions';
27
+ import { ILoaderProps } from '@fluidframework/container-loader';
28
+ import { IOnDemandSummarizeOptions } from '@fluidframework/container-runtime';
29
+ import { IProvideFluidCodeDetailsComparer } from '@fluidframework/container-definitions';
30
+ import { IProvideFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
31
+ import { IProvideFluidDataStoreRegistry } from '@fluidframework/runtime-definitions';
32
+ import { IProvideRuntimeFactory } from '@fluidframework/container-definitions';
33
+ import { IRequest } from '@fluidframework/core-interfaces';
34
+ import { IRequestHeader } from '@fluidframework/core-interfaces';
35
+ import { IResolvedUrl } from '@fluidframework/driver-definitions';
36
+ import { IResponse } from '@fluidframework/core-interfaces';
37
+ import { IRuntime } from '@fluidframework/container-definitions';
38
+ import { ISharedMap } from '@fluidframework/map';
39
+ import { ISummarizer } from '@fluidframework/container-runtime';
40
+ import { ISummaryContext } from '@fluidframework/driver-definitions';
41
+ import { ISummaryTree } from '@fluidframework/protocol-definitions';
42
+ import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
43
+ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
44
+ import { ITelemetryGenericEvent } from '@fluidframework/core-interfaces';
45
+ import { ITestDriver } from '@fluidframework/test-driver-definitions';
46
+ import { IUrlResolver } from '@fluidframework/driver-definitions';
47
+ import { Loader } from '@fluidframework/container-loader';
48
+ import { NamedFluidDataStoreRegistryEntries } from '@fluidframework/runtime-definitions';
49
+ import { RuntimeRequestHandler } from '@fluidframework/request-handler';
50
+
51
+ export declare type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFactory]>;
52
+
53
+ /**
54
+ * Creates a detached Container and attaches it.
55
+ * @param source - The code details used to create the Container.
56
+ * @param loader - The loader to use to initialize the container.
57
+ * @param attachRequest - The request to create new from.
58
+ */
59
+ export declare function createAndAttachContainer(source: IFluidCodeDetails, loader: IHostLoader, attachRequest: IRequest): Promise<IContainer>;
60
+
61
+ /**
62
+ * ! Note: This function is purely needed for back-compat as the constructor argument structure was changed
63
+ */
64
+ export declare const createContainerRuntimeFactoryWithDefaultDataStore: (Base: typeof ContainerRuntimeFactoryWithDefaultDataStore | undefined, ctorArgs: {
65
+ defaultFactory: IFluidDataStoreFactory;
66
+ registryEntries: NamedFluidDataStoreRegistryEntries;
67
+ dependencyContainer?: any;
68
+ requestHandlers?: RuntimeRequestHandler[] | undefined;
69
+ runtimeOptions?: IContainerRuntimeOptions | undefined;
70
+ provideEntryPoint?: ((runtime: IContainerRuntime) => Promise<FluidObject>) | undefined;
71
+ }) => ContainerRuntimeFactoryWithDefaultDataStore;
72
+
73
+ export declare const createDocumentId: () => string;
74
+
75
+ /**
76
+ * Creates a loader with the given package entries and driver.
77
+ * @param packageEntries - A list of code details to Fluid entry points.
78
+ * @param documentServiceFactory - the driver factory to use
79
+ * @param urlResolver - the url resolver to use
80
+ * @param options - loader options
81
+ */
82
+ export declare function createLoader(packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>, documentServiceFactory: IDocumentServiceFactory, urlResolver: IUrlResolver, logger?: ITelemetryBaseLogger, options?: ILoaderOptions): IHostLoader;
83
+
84
+ /**
85
+ * Creates a summarizer client from the given container and returns the summarizer client's IContainer and ISummarizer.
86
+ * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.
87
+ *
88
+ * Can pass in a test config provider to enable/disable features.
89
+ */
90
+ export declare function createSummarizer(provider: ITestObjectProvider, container: IContainer, config?: ITestContainerConfig, summaryVersion?: string, logger?: ITelemetryBaseLogger): Promise<{
91
+ container: IContainer;
92
+ summarizer: ISummarizer;
93
+ }>;
94
+
95
+ /**
96
+ * Creates a summarizer client from the given container and data store factory, and returns the summarizer client's
97
+ * IContainer and ISummarizer.
98
+ * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.
99
+ */
100
+ export declare function createSummarizerFromFactory(provider: ITestObjectProvider, container: IContainer, dataStoreFactory: IFluidDataStoreFactory, summaryVersion?: string, containerRuntimeFactoryType?: typeof ContainerRuntimeFactoryWithDefaultDataStore, registryEntries?: NamedFluidDataStoreRegistryEntries, logger?: ITelemetryBaseLogger, configProvider?: IConfigProviderBase): Promise<{
101
+ container: IContainer;
102
+ summarizer: ISummarizer;
103
+ }>;
104
+
105
+ /**
106
+ * Create a container runtime factory class that allows you to set runtime options
107
+ */
108
+ export declare const createTestContainerRuntimeFactory: (containerRuntimeCtor: typeof ContainerRuntime) => {
109
+ new (type: string, dataStoreFactory: IFluidDataStoreFactory, runtimeOptions?: IContainerRuntimeOptions, requestHandlers?: RuntimeRequestHandler[]): {
110
+ type: string;
111
+ dataStoreFactory: IFluidDataStoreFactory;
112
+ runtimeOptions: IContainerRuntimeOptions;
113
+ requestHandlers: RuntimeRequestHandler[];
114
+ instantiateFirstTime(runtime: ContainerRuntime): Promise<void>;
115
+ instantiateFromExisting(runtime: ContainerRuntime): Promise<void>;
116
+ preInitialize(context: IContainerContext, existing: boolean): Promise<IRuntime & IContainerRuntime>;
117
+ readonly IRuntimeFactory: any;
118
+ instantiateRuntime(context: IContainerContext, existing: boolean): Promise<IRuntime>;
119
+ hasInitialized(_runtime: IContainerRuntime): Promise<void>;
120
+ };
121
+ };
122
+
123
+ export declare enum DataObjectFactoryType {
124
+ Primed = 0,
125
+ Test = 1
126
+ }
127
+
128
+ export declare const defaultTimeoutDurationMs = 250;
129
+
130
+ /**
131
+ * This class tracks events. It allows specifying expected events, which will be looked for in order.
132
+ * It also tracks all unexpected errors.
133
+ * At any point you call reportAndClearTrackedEvents which will provide all unexpected errors, and
134
+ * any expected events that have not occurred.
135
+ */
136
+ export declare class EventAndErrorTrackingLogger implements ITelemetryBaseLogger {
137
+ private readonly baseLogger;
138
+ /**
139
+ * Even if these error events are logged, tests should still be allowed to pass
140
+ * Additionally, if downgrade is true, then log as generic (e.g. to avoid polluting the e2e test logs)
141
+ */
142
+ private readonly allowedErrors;
143
+ constructor(baseLogger: ITelemetryBaseLogger);
144
+ private readonly expectedEvents;
145
+ private readonly unexpectedErrors;
146
+ registerExpectedEvent(...orderedExpectedEvents: ITelemetryGenericEvent[]): void;
147
+ send(event: ITelemetryBaseEvent): void;
148
+ reportAndClearTrackedEvents(): {
149
+ expectedNotFound: ({
150
+ index: number;
151
+ event: ITelemetryGenericEvent | undefined;
152
+ } | undefined)[];
153
+ unexpectedErrors: ITelemetryBaseEvent[];
154
+ };
155
+ }
156
+
157
+ export declare type fluidEntryPoint = SupportedExportInterfaces | IFluidModule;
158
+
159
+ export declare function getUnexpectedLogErrorException(logger: EventAndErrorTrackingLogger | undefined, prefix?: string): Error | undefined;
160
+
161
+ export declare interface IOpProcessingController {
162
+ processIncoming(...containers: IContainer[]): Promise<void>;
163
+ processOutgoing(...containers: IContainer[]): Promise<void>;
164
+ pauseProcessing(...containers: IContainer[]): Promise<void>;
165
+ resumeProcessing(...containers: IContainer[]): void;
166
+ }
167
+
168
+ export declare interface IProvideTestFluidObject {
169
+ readonly ITestFluidObject: ITestFluidObject;
170
+ }
171
+
172
+ export declare interface ITestContainerConfig {
173
+ /** TestFluidDataObject instead of PrimedDataStore */
174
+ fluidDataObjectType?: DataObjectFactoryType;
175
+ /** An array of channel name and DDS factory pair to create on container creation time */
176
+ registry?: ChannelFactoryRegistry;
177
+ /** Container runtime options for the container instance */
178
+ runtimeOptions?: IContainerRuntimeOptions;
179
+ /** Whether this runtime should be instantiated using a mixed-in attributor class */
180
+ enableAttribution?: boolean;
181
+ /** Loader options for the loader used to create containers */
182
+ loaderProps?: Partial<ILoaderProps>;
183
+ }
184
+
185
+ export declare interface ITestFluidObject extends IProvideTestFluidObject, IFluidLoadable {
186
+ root: ISharedMap;
187
+ readonly runtime: IFluidDataStoreRuntime;
188
+ readonly channel: IFluidDataStoreChannel;
189
+ readonly context: IFluidDataStoreContext;
190
+ getSharedObject<T = any>(id: string): Promise<T>;
191
+ }
192
+
193
+ export declare interface ITestObjectProvider {
194
+ createFluidEntryPoint: (testContainerConfig?: ITestContainerConfig) => fluidEntryPoint;
195
+ createLoader(packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>, loaderProps?: Partial<ILoaderProps>): IHostLoader;
196
+ createContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>): Promise<IContainer>;
197
+ loadContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>, requestHeader?: IRequestHeader): Promise<IContainer>;
198
+ /**
199
+ * Used to create a test Container. The Loader/ContainerRuntime/DataRuntime might be different versioned.
200
+ * In generateLocalCompatTest(), this Container and its runtime will be arbitrarily-versioned.
201
+ */
202
+ makeTestLoader(testContainerConfig?: ITestContainerConfig): IHostLoader;
203
+ makeTestContainer(testContainerConfig?: ITestContainerConfig): Promise<IContainer>;
204
+ loadTestContainer(testContainerConfig?: ITestContainerConfig, requestHeader?: IRequestHeader): Promise<IContainer>;
205
+ /**
206
+ *
207
+ * @param url - Resolved container URL
208
+ */
209
+ updateDocumentId(url: IResolvedUrl | undefined): void;
210
+ logger: ITelemetryBaseLogger;
211
+ documentServiceFactory: IDocumentServiceFactory;
212
+ urlResolver: IUrlResolver;
213
+ defaultCodeDetails: IFluidCodeDetails;
214
+ opProcessingController: IOpProcessingController;
215
+ ensureSynchronized(timeoutDuration?: number): Promise<void>;
216
+ reset(): void;
217
+ documentId: string;
218
+ driver: ITestDriver;
219
+ }
220
+
221
+ export declare class LoaderContainerTracker implements IOpProcessingController {
222
+ private readonly syncSummarizerClients;
223
+ private readonly containers;
224
+ private lastProposalSeqNum;
225
+ constructor(syncSummarizerClients?: boolean);
226
+ /**
227
+ * Add a loader to start to track any container created from them
228
+ * @param loader - loader to start tracking any container created.
229
+ */
230
+ add<LoaderType extends IHostLoader>(loader: LoaderType): void;
231
+ /**
232
+ * Utility function to add container to be tracked.
233
+ *
234
+ * @param container - container to add
235
+ */
236
+ private addContainer;
237
+ /**
238
+ * Keep track of the trailing NoOp that was sent so we can discount them in the clientSequenceNumber tracking.
239
+ * The server might coalesce them with other ops, or a single NoOp, or delay it if it don't think it is necessary.
240
+ *
241
+ * @param container - the container to track
242
+ * @param record - the record to update the trailing op information
243
+ */
244
+ private trackTrailingNoOps;
245
+ private trackLastProposal;
246
+ /**
247
+ * Reset the tracker, closing all containers and stop tracking them.
248
+ */
249
+ reset(): void;
250
+ /**
251
+ * Make sure all the tracked containers are synchronized.
252
+ *
253
+ * No isDirty (non-readonly) containers
254
+ * No extra clientId in quorum of any container that is not tracked and still opened.
255
+ * - i.e. no pending Join/Leave message.
256
+ * No unresolved proposal (minSeqNum \>= lastProposalSeqNum)
257
+ * lastSequenceNumber of all container is the same
258
+ * clientSequenceNumberObserved is the same as clientSequenceNumber sent
259
+ * - this overlaps with !isDirty, but include task scheduler ops.
260
+ * - Trailing NoOp is tracked and don't count as pending ops.
261
+ *
262
+ * Containers that are already pause will resume process and paused again once
263
+ * everything is synchronized. Containers that aren't paused will remain unpaused when this
264
+ * function returns.
265
+ */
266
+ ensureSynchronized(...containers: IContainer[]): Promise<void>;
267
+ /**
268
+ * Utility to calculate the set of clientId per container in quorum that is NOT associated with
269
+ * any container we tracked, indicating there is a pending join or leave op that we need to wait.
270
+ *
271
+ * @param containersToApply - the set of containers to check
272
+ */
273
+ private getPendingClients;
274
+ /**
275
+ * Utility to check synchronization based on sequence number
276
+ * See ensureSynchronized for more detail
277
+ *
278
+ * @param containersToApply - the set of containers to check
279
+ */
280
+ private needSequenceNumberSynchronize;
281
+ private containerIndexStrings;
282
+ /**
283
+ * Utility to wait for any clientId in quorum that is NOT associated with any container we
284
+ * tracked, indicating there is a pending join or leave op that we need to wait.
285
+ *
286
+ * Note that this function doesn't account for container that got added after we started waiting
287
+ *
288
+ * @param containersToApply - the set of containers to wait for any inbound ops for
289
+ */
290
+ private waitForPendingClients;
291
+ /**
292
+ * Utility to wait for any inbound ops from a set of containers
293
+ * @param containersToApply - the set of containers to wait for any inbound ops for
294
+ */
295
+ private waitForAnyInboundOps;
296
+ /**
297
+ * Resume all queue activities on all paused tracked containers and return them
298
+ */
299
+ resumeProcessing(...containers: IContainer[]): IContainer[];
300
+ /**
301
+ * Pause all queue activities on the containers given, or all tracked containers
302
+ * Any containers given that is not tracked will be ignored.
303
+ *
304
+ * When a container is paused, it is assumed that we want fine grain control over op
305
+ * sequencing. This function will prepare the container and force it into write mode to
306
+ * avoid missing join messages or change the sequence of event when switching from read to
307
+ * write mode.
308
+ */
309
+ pauseProcessing(...containers: IContainer[]): Promise<void>;
310
+ /**
311
+ * When a container is paused, it is assumed that we want fine grain control over op
312
+ * sequencing. This function will prepare the container and force it into write mode to
313
+ * avoid missing join messages or change the sequence of event when switching from read to
314
+ * write mode.
315
+ *
316
+ * @param container - the container to pause
317
+ * @param record - the record for the container
318
+ */
319
+ private pauseContainer;
320
+ /**
321
+ * Pause all queue activities on all tracked containers, and resume only
322
+ * inbound to process ops until it is idle. All queues are left in the paused state
323
+ * after the function.
324
+ *
325
+ * Pausing will switch the container to write mode. See `pauseProcessing`
326
+ */
327
+ processIncoming(...containers: IContainer[]): Promise<void>;
328
+ /**
329
+ * Pause all queue activities on all tracked containers, and resume only
330
+ * outbound to process ops until it is idle. All queues are left in the paused state
331
+ * after the function.
332
+ *
333
+ * Pausing will switch the container to write mode. See `pauseProcessing`
334
+ */
335
+ processOutgoing(...containers: IContainer[]): Promise<void>;
336
+ /**
337
+ * Implementation of processIncoming and processOutgoing
338
+ */
339
+ private processQueue;
340
+ /**
341
+ * Utility to set up listener to track the outbound ops until it round trip back
342
+ * Returns a function to remove the handler after it is done.
343
+ *
344
+ * @param container - the container to setup
345
+ * @param inflightTracker - a map to track the clientSequenceNumber per container it expect to get ops back
346
+ */
347
+ private setupInOutTracker;
348
+ /**
349
+ * Setup debug traces for connection and ops
350
+ */
351
+ private setupTrace;
352
+ /**
353
+ * Filter out the opened containers based on param.
354
+ * @param containers - The container to filter to. If the array is empty, it means don't filter and return
355
+ * all open containers.
356
+ */
357
+ private getContainers;
358
+ }
359
+
360
+ /**
361
+ * A simple code loader that caches a mapping of package name to a Fluid entry point.
362
+ * On load, it retrieves the entry point matching the package name in the given code details.
363
+ */
364
+ export declare class LocalCodeLoader implements ICodeDetailsLoader {
365
+ private readonly fluidPackageCache;
366
+ constructor(packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>, runtimeOptions?: IContainerRuntimeOptions);
367
+ /**
368
+ * It finds the entry point for the package name in the given source and return it
369
+ * as a Fluid module.
370
+ * @param source - Details of where to find chaincode
371
+ */
372
+ load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;
373
+ }
374
+
375
+ export declare const mockConfigProvider: (settings?: Record<string, ConfigTypes>) => IConfigProviderBase;
376
+
377
+ /**
378
+ * Simple retry mechanism with linear back off to call
379
+ * a function which may eventually return an accepted value.
380
+ *
381
+ * @param callback - the function to execute
382
+ * @param check - the function to check if the value is acceptable
383
+ * @param defaultValue - the default value
384
+ * @param maxTries - maximum number of attempts
385
+ * @param backOffMs - back off between attempts in milliseconds
386
+ * @returns the actual value from the callback when successful or the default value otherwise
387
+ */
388
+ export declare const retryWithEventualValue: <T>(callback: () => Promise<T>, check: (value: T) => boolean, defaultValue: T, maxTries?: number, backOffMs?: number) => Promise<T>;
389
+
390
+ /**
391
+ * Summarizes on demand and returns the summary tree, the version number and the reference sequence number of the
392
+ * submitted summary.
393
+ *
394
+ * @param summarizer - The ISummarizer to use to summarize on demand
395
+ * @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.
396
+ * Defaults to the reason "end-to-end test".
397
+ */
398
+ export declare function summarizeNow(summarizer: ISummarizer, inputs?: string | IOnDemandSummarizeOptions): Promise<{
399
+ summaryTree: ISummaryTree;
400
+ summaryVersion: string;
401
+ summaryRefSeq: number;
402
+ }>;
403
+
404
+ export declare type SupportedExportInterfaces = Partial<IProvideRuntimeFactory & IProvideFluidDataStoreFactory & IProvideFluidDataStoreRegistry & IProvideFluidCodeDetailsComparer>;
405
+
406
+ /**
407
+ * A container runtime factory that allows you to set runtime options
408
+ */
409
+ export declare const TestContainerRuntimeFactory: {
410
+ new (type: string, dataStoreFactory: IFluidDataStoreFactory, runtimeOptions?: IContainerRuntimeOptions, requestHandlers?: RuntimeRequestHandler[]): {
411
+ type: string;
412
+ dataStoreFactory: IFluidDataStoreFactory;
413
+ runtimeOptions: IContainerRuntimeOptions;
414
+ requestHandlers: RuntimeRequestHandler[];
415
+ instantiateFirstTime(runtime: ContainerRuntime): Promise<void>;
416
+ instantiateFromExisting(runtime: ContainerRuntime): Promise<void>;
417
+ preInitialize(context: IContainerContext, existing: boolean): Promise<IRuntime & IContainerRuntime>;
418
+ readonly IRuntimeFactory: any;
419
+ instantiateRuntime(context: IContainerContext, existing: boolean): Promise<IRuntime>;
420
+ hasInitialized(_runtime: IContainerRuntime): Promise<void>;
421
+ };
422
+ };
423
+
424
+ /**
425
+ * A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load.
426
+ * The shared objects can be retrieved by passing the key of the entry to getSharedObject.
427
+ * It exposes the IFluidDataStoreContext and IFluidDataStoreRuntime.
428
+ */
429
+ export declare class TestFluidObject implements ITestFluidObject {
430
+ readonly runtime: IFluidDataStoreRuntime;
431
+ readonly channel: IFluidDataStoreChannel;
432
+ readonly context: IFluidDataStoreContext;
433
+ private readonly factoryEntriesMap;
434
+ get ITestFluidObject(): this;
435
+ get IFluidLoadable(): this;
436
+ /**
437
+ * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
438
+ */
439
+ get IFluidRouter(): this;
440
+ get handle(): IFluidHandle<this>;
441
+ root: ISharedMap;
442
+ private readonly innerHandle;
443
+ private initializeP;
444
+ /**
445
+ * Creates a new TestFluidObject.
446
+ * @param runtime - The data store runtime.
447
+ * @param context - The data store context.
448
+ * @param factoryEntries - A list of id to IChannelFactory mapping. For each item in the list,
449
+ * a shared object is created which can be retrieved by calling getSharedObject() with the id;
450
+ */
451
+ constructor(runtime: IFluidDataStoreRuntime, channel: IFluidDataStoreChannel, context: IFluidDataStoreContext, factoryEntriesMap: Map<string, IChannelFactory>);
452
+ /**
453
+ * Retrieves a shared object with the given id.
454
+ * @param id - The id of the shared object to retrieve.
455
+ */
456
+ getSharedObject<T = any>(id: string): Promise<T>;
457
+ /**
458
+ * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
459
+ */
460
+ request(request: IRequest): Promise<IResponse>;
461
+ initialize(existing: boolean): Promise<void>;
462
+ }
463
+
464
+ /**
465
+ * Creates a factory for a TestFluidObject with the given object factory entries. It creates a data store runtime
466
+ * with the object factories in the entry list. All the entries with an id other than undefined are passed to the
467
+ * Fluid object so that it can create a shared object for each.
468
+ *
469
+ * @example
470
+ *
471
+ * The following will create a Fluid object that creates and loads a SharedString and SharedDirectory.
472
+ * It will add SparseMatrix to the data store's factory so that it can be created later.
473
+ *
474
+ * ```typescript
475
+ * new TestFluidObjectFactory([
476
+ * [ "sharedString", SharedString.getFactory() ],
477
+ * [ "sharedDirectory", SharedDirectory.getFactory() ],
478
+ * [ undefined, SparseMatrix.getFactory() ],
479
+ * ]);
480
+ * ```
481
+ *
482
+ * The SharedString and SharedDirectory can be retrieved via getSharedObject() on the TestFluidObject as follows:
483
+ *
484
+ * ```typescript
485
+ * sharedString = testFluidObject.getSharedObject<SharedString>("sharedString");
486
+ * sharedDir = testFluidObject.getSharedObject<SharedDirectory>("sharedDirectory");
487
+ * ```
488
+ *
489
+ * @privateRemarks Beware that using this class generally forfeits some compatibility coverage
490
+ * `describeCompat` aims to provide:
491
+ * `SharedMap`s always reference the current version of SharedMap.
492
+ * AB#4670 tracks improving this situation.
493
+ */
494
+ export declare class TestFluidObjectFactory implements IFluidDataStoreFactory {
495
+ private readonly factoryEntries;
496
+ readonly type: string;
497
+ get IFluidDataStoreFactory(): this;
498
+ /**
499
+ * Creates a new TestFluidObjectFactory.
500
+ * @param factoryEntries - A list of id to IChannelFactory mapping. It creates a data store runtime with each
501
+ * IChannelFactory. Entries with string ids are passed to the Fluid object so that it can create a shared object
502
+ * for it.
503
+ */
504
+ constructor(factoryEntries: ChannelFactoryRegistry, type?: string);
505
+ instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<FluidDataStoreRuntime>;
506
+ }
507
+
508
+ /**
509
+ * Shared base class for test object provider. Contain code for loader and container creation and loading
510
+ */
511
+ export declare class TestObjectProvider implements ITestObjectProvider {
512
+ readonly LoaderConstructor: typeof Loader;
513
+ readonly driver: ITestDriver;
514
+ readonly createFluidEntryPoint: (testContainerConfig?: ITestContainerConfig) => fluidEntryPoint;
515
+ private _loaderContainerTracker;
516
+ private _documentServiceFactory;
517
+ private _urlResolver;
518
+ private _logger;
519
+ private readonly _documentIdStrategy;
520
+ private _documentCreated;
521
+ /**
522
+ * Manage objects for loading and creating container, including the driver, loader, and OpProcessingController
523
+ * @param createFluidEntryPoint - callback to create a fluidEntryPoint, with an optional set of channel name
524
+ * and factory for TestFluidObject
525
+ */
526
+ constructor(LoaderConstructor: typeof Loader, driver: ITestDriver, createFluidEntryPoint: (testContainerConfig?: ITestContainerConfig) => fluidEntryPoint);
527
+ get logger(): EventAndErrorTrackingLogger;
528
+ set logger(logger: EventAndErrorTrackingLogger);
529
+ get documentServiceFactory(): IDocumentServiceFactory;
530
+ get urlResolver(): IUrlResolver;
531
+ get documentId(): string;
532
+ get defaultCodeDetails(): IFluidCodeDetails;
533
+ get opProcessingController(): IOpProcessingController;
534
+ /**
535
+ * Create a loader. Containers created/loaded through this loader will be added to the OpProcessingController.
536
+ *
537
+ * Only the version of the loader will vary based on compat config. The version of
538
+ * containerRuntime/dataRuntime used in fluidEntryPoint will be used as is from what is passed in.
539
+ *
540
+ * @param packageEntries - list of code details and fluidEntryPoint pairs.
541
+ */
542
+ createLoader(packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>, loaderProps?: Partial<ILoaderProps>): Loader;
543
+ /**
544
+ * Create a container using a default document id and code details.
545
+ * Container created is automatically added to the OpProcessingController to manage op flow
546
+ *
547
+ * Only the version of the loader will vary based on compat config. The version of
548
+ * containerRuntime/dataRuntime used in fluidEntryPoint will be used as is from what is passed in.
549
+ *
550
+ * @param packageEntries - list of code details and fluidEntryPoint pairs.
551
+ */
552
+ createContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>): Promise<IContainer>;
553
+ loadContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>, requestHeader?: IRequestHeader): Promise<IContainer>;
554
+ private resolveContainer;
555
+ /**
556
+ * Make a test loader. Containers created/loaded through this loader will be added to the OpProcessingController.
557
+ * The version of the loader/containerRuntime/dataRuntime may vary based on compat config of the current run
558
+ * @param testContainerConfig - optional configuring the test Container
559
+ */
560
+ makeTestLoader(testContainerConfig?: ITestContainerConfig): Loader;
561
+ /**
562
+ * Make a container using a default document id and code details
563
+ * Container loaded is automatically added to the OpProcessingController to manage op flow
564
+ * @param testContainerConfig - optional configuring the test Container
565
+ */
566
+ makeTestContainer(testContainerConfig?: ITestContainerConfig): Promise<IContainer>;
567
+ /**
568
+ * Load a container using a default document id and code details.
569
+ * IContainer loaded is automatically added to the OpProcessingController to manage op flow
570
+ * @param testContainerConfig - optional configuring the test Container
571
+ * @param requestHeader - optional headers to be supplied to the loader
572
+ */
573
+ loadTestContainer(testContainerConfig?: ITestContainerConfig, requestHeader?: IRequestHeader): Promise<IContainer>;
574
+ reset(): void;
575
+ ensureSynchronized(): Promise<void>;
576
+ waitContainerToCatchUp(container: IContainer): Promise<boolean>;
577
+ updateDocumentId(resolvedUrl: IResolvedUrl | undefined): void;
578
+ resetLoaderContainerTracker(syncSummarizerClients?: boolean): void;
579
+ }
580
+
581
+ /**
582
+ * Wraps the given promise around with promise that will complete after a specific timeout if the original promise does
583
+ * not resolve by then. By default, it uses the mocha test timeout and complete the promise just before that so that
584
+ * tests don't time out because of unpredictable awaits.
585
+ * The timeout can be overridden via timeoutOptions but it's recommended to use the default value.
586
+ * @param promise - The promise to be awaited.
587
+ * @param timeoutOptions - Options that can be used to override the timeout and / or define the behavior
588
+ * when the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a
589
+ * specific value.
590
+ * @returns A new promise that will complete when the given promise resolves or the timeout expires.
591
+ */
592
+ export declare function timeoutAwait<T = void>(promise: PromiseLike<T>, timeoutOptions?: TimeoutWithError | TimeoutWithValue<T>): Promise<T>;
593
+
594
+ /**
595
+ * Creates a promise from the given executor that will complete after a specific timeout. By default, it uses the mocha
596
+ * test timeout and complete the promise just before that so that tests don't time out because of unpredictable awaits.
597
+ * The timeout can be overridden via timeoutOptions but it's recommended to use the default value.
598
+ * @param executor - The executor for the promise.
599
+ * @param timeoutOptions - Options that can be used to override the timeout and / or define the behavior when
600
+ * the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a specific value.
601
+ * @returns A new promise that will complete when the given executor resolves or the timeout expires.
602
+ */
603
+ export declare function timeoutPromise<T = void>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void, timeoutOptions?: TimeoutWithError | TimeoutWithValue<T>): Promise<T>;
604
+
605
+ export declare interface TimeoutWithError {
606
+ /**
607
+ * Timeout duration in milliseconds, if it is great than 0 and not Infinity
608
+ * If it is undefined, then it will use test timeout if we are in side the test function
609
+ * Otherwise, there is no timeout
610
+ */
611
+ durationMs?: number;
612
+ reject?: true;
613
+ errorMsg?: string;
614
+ }
615
+
616
+ export declare interface TimeoutWithValue<T = void> {
617
+ /**
618
+ * Timeout duration in milliseconds, if it is great than 0 and not Infinity
619
+ * If it is undefined, then it will use test timeout if we are in side the test function
620
+ * Otherwise, there is no timeout
621
+ */
622
+ durationMs?: number;
623
+ reject: false;
624
+ value: T;
625
+ }
626
+
627
+ /**
628
+ * Utility function to wait for the specified Container to be in Connected state.
629
+ * If the Container is already connected, the Promise returns immediately; otherwise it resolves when the Container emits
630
+ * its 'connected' event.
631
+ * If failOnContainerClose === true, the returned Promise will be rejected if the container emits a 'closed' event
632
+ * before a 'connected' event.
633
+ * @param container - The container to wait for.
634
+ * @param failOnContainerClose - If true, the returned Promise will be rejected if the container emits a 'closed' event
635
+ * before a 'connected' event.
636
+ * Defaults to true.
637
+ * @param timeoutOptions - Options related to the behavior of the timeout.
638
+ * If provided, the returned Promise will reject if the container hasn't emitted relevant events in timeoutOptions.durationMs.
639
+ * If not provided, the Promise will wait indefinitely for the Container to emit its 'connected' (or 'closed', if
640
+ * failOnContainerClose === true) event.
641
+ *
642
+ * @returns A Promise that either:
643
+ * - Resolves when the specified container emits a 'connected' event (or immediately if the Container is already connected).
644
+ * - Rejects if failOnContainerClose === true and the container emits a 'closed' event before a 'connected' event.
645
+ * - Rejects after timeoutOptions.durationMs if timeoutOptions !== undefined and the container does not emit relevant
646
+ * events, within that timeframe.
647
+ */
648
+ export declare function waitForContainerConnection(container: IContainer, failOnContainerClose?: boolean, timeoutOptions?: TimeoutWithError): Promise<void>;
649
+
650
+ /**
651
+ * Wraps the given IDocumentService to override the `connectToStorage` method. The intent is to plumb the
652
+ * `uploadSummaryCb` to the IDocumentStorageService so that it is called whenever a summary is uploaded by
653
+ * the client.
654
+ * The document storage service that is created in `connectToStorage` is wrapped by calling `wrapDocumentStorageService`
655
+ * to pass in the `uploadSummaryCb`.
656
+ */
657
+ export declare function wrapDocumentService(innerDocService: IDocumentService, uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext): IDocumentService;
658
+
659
+ /**
660
+ * Wraps the given IDocumentServiceFactory to override the `createDocumentService` method. The intent is to plumb
661
+ * the `uploadSummaryCb` all the way to the IDocumentStorageService so that it is called whenever a summary is
662
+ * uploaded by the client.
663
+ * The document service that is created in `createDocumentService` is wrapped by calling `wrapDocumentService` to
664
+ * pass in the `uploadSummaryCb`.
665
+ */
666
+ export declare function wrapDocumentServiceFactory(innerDocServiceFactory: IDocumentServiceFactory, uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext): IDocumentServiceFactory;
667
+
668
+ /**
669
+ * Wraps the given IDocumentStorageService to override the `uploadSummaryWithContext` method. It calls the
670
+ * `uploadSummaryCb` whenever a summary is uploaded by the client. The summary context can be updated in the
671
+ * callback before it is uploaded to the server.
672
+ */
673
+ export declare function wrapDocumentStorageService(innerDocStorageService: IDocumentStorageService, uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext): IDocumentStorageService;
674
+
675
+ export { }