@fluidframework/test-utils 2.0.0-rc.1.0.4 → 2.0.0-rc.2.0.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/{.eslintrc.js → .eslintrc.cjs} +4 -1
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +34 -0
- package/README.md +1 -1
- package/api-extractor-cjs.json +8 -0
- package/api-extractor-lint.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/test-utils.api.md +27 -9
- package/dist/DriverWrappers.d.ts +3 -0
- package/dist/DriverWrappers.d.ts.map +1 -1
- package/dist/DriverWrappers.js +3 -0
- package/dist/DriverWrappers.js.map +1 -1
- package/dist/TestConfigs.d.ts +14 -1
- package/dist/TestConfigs.d.ts.map +1 -1
- package/dist/TestConfigs.js +14 -3
- package/dist/TestConfigs.js.map +1 -1
- package/dist/TestSummaryUtils.d.ts +7 -2
- package/dist/TestSummaryUtils.d.ts.map +1 -1
- package/dist/TestSummaryUtils.js +39 -14
- package/dist/TestSummaryUtils.js.map +1 -1
- package/dist/containerUtils.d.ts +1 -1
- package/dist/containerUtils.d.ts.map +1 -1
- package/dist/containerUtils.js +2 -2
- package/dist/containerUtils.js.map +1 -1
- package/dist/debug.js +2 -2
- package/dist/debug.js.map +1 -1
- package/dist/index.d.ts +14 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -43
- package/dist/index.js.map +1 -1
- package/dist/loaderContainerTracker.d.ts +1 -1
- package/dist/loaderContainerTracker.d.ts.map +1 -1
- package/dist/loaderContainerTracker.js +11 -11
- package/dist/loaderContainerTracker.js.map +1 -1
- package/dist/localLoader.d.ts +1 -1
- package/dist/localLoader.d.ts.map +1 -1
- package/dist/localLoader.js +2 -2
- package/dist/localLoader.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/test-utils-alpha.d.ts +7 -3
- package/dist/test-utils-beta.d.ts +9 -3
- package/dist/test-utils-public.d.ts +9 -3
- package/dist/test-utils-untrimmed.d.ts +59 -14
- package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
- package/dist/testContainerRuntimeFactory.js +9 -2
- package/dist/testContainerRuntimeFactory.js.map +1 -1
- package/dist/testFluidObject.d.ts +1 -1
- package/dist/testFluidObject.d.ts.map +1 -1
- package/dist/testFluidObject.js.map +1 -1
- package/dist/testObjectProvider.d.ts +34 -11
- package/dist/testObjectProvider.d.ts.map +1 -1
- package/dist/testObjectProvider.js +71 -38
- package/dist/testObjectProvider.js.map +1 -1
- package/dist/timeoutUtils.d.ts.map +1 -1
- package/dist/timeoutUtils.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/DriverWrappers.d.ts +35 -0
- package/lib/DriverWrappers.d.ts.map +1 -0
- package/lib/DriverWrappers.js +54 -0
- package/lib/DriverWrappers.js.map +1 -0
- package/lib/TestConfigs.d.ts +23 -0
- package/lib/TestConfigs.d.ts.map +1 -0
- package/lib/TestConfigs.js +24 -0
- package/lib/TestConfigs.js.map +1 -0
- package/lib/TestSummaryUtils.d.ts +66 -0
- package/lib/TestSummaryUtils.d.ts.map +1 -0
- package/lib/TestSummaryUtils.js +153 -0
- package/lib/TestSummaryUtils.js.map +1 -0
- package/lib/containerUtils.d.ts +46 -0
- package/lib/containerUtils.d.ts.map +1 -0
- package/lib/containerUtils.js +79 -0
- package/lib/containerUtils.js.map +1 -0
- package/lib/debug.d.ts +7 -0
- package/lib/debug.d.ts.map +1 -0
- package/lib/debug.js +9 -0
- package/lib/debug.js.map +1 -0
- package/lib/index.d.ts +19 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces.d.ts +25 -0
- package/lib/interfaces.d.ts.map +1 -0
- package/lib/interfaces.js +6 -0
- package/lib/interfaces.js.map +1 -0
- package/lib/loaderContainerTracker.d.ts +144 -0
- package/lib/loaderContainerTracker.d.ts.map +1 -0
- package/lib/loaderContainerTracker.js +631 -0
- package/lib/loaderContainerTracker.js.map +1 -0
- package/lib/localCodeLoader.d.ts +31 -0
- package/lib/localCodeLoader.d.ts.map +1 -0
- package/lib/localCodeLoader.js +73 -0
- package/lib/localCodeLoader.js.map +1 -0
- package/lib/localLoader.d.ts +26 -0
- package/lib/localLoader.d.ts.map +1 -0
- package/lib/localLoader.js +37 -0
- package/lib/localLoader.js.map +1 -0
- package/lib/packageVersion.d.ts +9 -0
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/packageVersion.js +9 -0
- package/lib/packageVersion.js.map +1 -0
- package/lib/retry.d.ts +18 -0
- package/lib/retry.d.ts.map +1 -0
- package/lib/retry.js +37 -0
- package/lib/retry.js.map +1 -0
- package/lib/test/timeoutUtils.spec.js +165 -0
- package/lib/test/timeoutUtils.spec.js.map +1 -0
- package/lib/test/types/validateTestUtilsPrevious.generated.js +90 -0
- package/lib/test/types/validateTestUtilsPrevious.generated.js.map +1 -0
- package/lib/test-utils-alpha.d.ts +309 -0
- package/lib/test-utils-beta.d.ts +208 -0
- package/lib/test-utils-public.d.ts +208 -0
- package/lib/test-utils-untrimmed.d.ts +1046 -0
- package/lib/testContainerRuntimeFactory.d.ts +46 -0
- package/lib/testContainerRuntimeFactory.d.ts.map +1 -0
- package/lib/testContainerRuntimeFactory.js +113 -0
- package/lib/testContainerRuntimeFactory.js.map +1 -0
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +23 -0
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -0
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js +28 -0
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -0
- package/lib/testFluidObject.d.ts +92 -0
- package/lib/testFluidObject.d.ts.map +1 -0
- package/lib/testFluidObject.js +159 -0
- package/lib/testFluidObject.js.map +1 -0
- package/lib/testObjectProvider.d.ts +435 -0
- package/lib/testObjectProvider.d.ts.map +1 -0
- package/lib/testObjectProvider.js +636 -0
- package/lib/testObjectProvider.js.map +1 -0
- package/lib/timeoutUtils.d.ts +60 -0
- package/lib/timeoutUtils.d.ts.map +1 -0
- package/lib/timeoutUtils.js +164 -0
- package/lib/timeoutUtils.js.map +1 -0
- package/package.json +105 -38
- package/src/DriverWrappers.ts +3 -0
- package/src/TestConfigs.ts +25 -3
- package/src/TestSummaryUtils.ts +36 -12
- package/src/containerUtils.ts +1 -1
- package/src/debug.ts +1 -1
- package/src/index.ts +19 -14
- package/src/loaderContainerTracker.ts +5 -5
- package/src/localLoader.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/testContainerRuntimeFactory.ts +12 -2
- package/src/testFluidObject.ts +1 -1
- package/src/testObjectProvider.ts +99 -34
- package/src/timeoutUtils.ts +1 -0
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +3 -4
package/dist/localLoader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localLoader.js","sourceRoot":"","sources":["../src/localLoader.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,uEAA0D;AAG1D,
|
|
1
|
+
{"version":3,"file":"localLoader.js","sourceRoot":"","sources":["../src/localLoader.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,uEAA0D;AAG1D,6DAAwE;AAExE;;;;;;;GAOG;AACH,SAAgB,YAAY,CAC3B,cAA8D,EAC9D,sBAA+C,EAC/C,WAAyB,EACzB,MAA6B,EAC7B,OAAwB;IAExB,MAAM,UAAU,GAAuB,IAAI,oCAAe,CAAC,cAAc,CAAC,CAAC;IAE3E,OAAO,IAAI,yBAAM,CAAC;QACjB,WAAW;QACX,sBAAsB;QACtB,UAAU;QACV,MAAM;QACN,OAAO;KACP,CAAC,CAAC;AACJ,CAAC;AAhBD,oCAgBC;AAED;;;;;;GAMG;AAEI,KAAK,UAAU,wBAAwB,CAC7C,MAAyB,EACzB,MAAmB,EACnB,aAAuB;IAEvB,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAC/D,MAAM,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAEtC,OAAO,SAAS,CAAC;AAClB,CAAC;AATD,4DASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tICodeDetailsLoader,\n\tIContainer,\n\tIHostLoader,\n\tILoaderOptions,\n\tIFluidCodeDetails,\n} from \"@fluidframework/container-definitions\";\nimport { Loader } from \"@fluidframework/container-loader\";\nimport { ITelemetryBaseLogger, IRequest } from \"@fluidframework/core-interfaces\";\nimport { IDocumentServiceFactory, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { fluidEntryPoint, LocalCodeLoader } from \"./localCodeLoader.js\";\n\n/**\n * Creates a loader with the given package entries and driver.\n * @param packageEntries - A list of code details to Fluid entry points.\n * @param documentServiceFactory - the driver factory to use\n * @param urlResolver - the url resolver to use\n * @param options - loader options\n * @internal\n */\nexport function createLoader(\n\tpackageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,\n\tdocumentServiceFactory: IDocumentServiceFactory,\n\turlResolver: IUrlResolver,\n\tlogger?: ITelemetryBaseLogger,\n\toptions?: ILoaderOptions,\n): IHostLoader {\n\tconst codeLoader: ICodeDetailsLoader = new LocalCodeLoader(packageEntries);\n\n\treturn new Loader({\n\t\turlResolver,\n\t\tdocumentServiceFactory,\n\t\tcodeLoader,\n\t\tlogger,\n\t\toptions,\n\t});\n}\n\n/**\n * Creates a detached Container and attaches it.\n * @param source - The code details used to create the Container.\n * @param loader - The loader to use to initialize the container.\n * @param attachRequest - The request to create new from.\n * @alpha\n */\n\nexport async function createAndAttachContainer(\n\tsource: IFluidCodeDetails,\n\tloader: IHostLoader,\n\tattachRequest: IRequest,\n): Promise<IContainer> {\n\tconst container = await loader.createDetachedContainer(source);\n\tawait container.attach(attachRequest);\n\n\treturn container;\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/test-utils";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-rc.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-rc.2.0.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/test-utils";
|
|
11
|
-
exports.pkgVersion = "2.0.0-rc.
|
|
11
|
+
exports.pkgVersion = "2.0.0-rc.2.0.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,4BAA4B,CAAC;AACvC,QAAA,UAAU,GAAG,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/test-utils\";\nexport const pkgVersion = \"2.0.0-rc.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,4BAA4B,CAAC;AACvC,QAAA,UAAU,GAAG,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/test-utils\";\nexport const pkgVersion = \"2.0.0-rc.2.0.0\";\n"]}
|
|
@@ -42,7 +42,7 @@ import { ISummaryContext } from '@fluidframework/driver-definitions';
|
|
|
42
42
|
import { ISummaryTree } from '@fluidframework/protocol-definitions';
|
|
43
43
|
import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
|
|
44
44
|
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
45
|
-
import {
|
|
45
|
+
import { ITelemetryGenericEventExt } from '@fluidframework/telemetry-utils';
|
|
46
46
|
import { ITestDriver } from '@fluidframework/test-driver-definitions';
|
|
47
47
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
48
48
|
import { Loader } from '@fluidframework/container-loader';
|
|
@@ -68,8 +68,12 @@ export declare function createAndAttachContainer(source: IFluidCodeDetails, load
|
|
|
68
68
|
|
|
69
69
|
/* Excluded from this release type: createSummarizer */
|
|
70
70
|
|
|
71
|
+
/* Excluded from this release type: createSummarizerCore */
|
|
72
|
+
|
|
71
73
|
/* Excluded from this release type: createSummarizerFromFactory */
|
|
72
74
|
|
|
75
|
+
/* Excluded from this release type: createTestConfigProvider */
|
|
76
|
+
|
|
73
77
|
/* Excluded from this release type: createTestContainerRuntimeFactory */
|
|
74
78
|
|
|
75
79
|
/* Excluded from this release type: DataObjectFactoryType */
|
|
@@ -105,6 +109,8 @@ export declare interface IProvideTestFluidObject {
|
|
|
105
109
|
readonly ITestFluidObject: ITestFluidObject;
|
|
106
110
|
}
|
|
107
111
|
|
|
112
|
+
/* Excluded from this release type: ITestConfigProvider */
|
|
113
|
+
|
|
108
114
|
/* Excluded from this release type: ITestContainerConfig */
|
|
109
115
|
|
|
110
116
|
/* Excluded from this release type: ITestDriver */
|
|
@@ -266,8 +272,6 @@ export declare class LoaderContainerTracker implements IOpProcessingController {
|
|
|
266
272
|
|
|
267
273
|
/* Excluded from this release type: LocalCodeLoader */
|
|
268
274
|
|
|
269
|
-
/* Excluded from this release type: mockConfigProvider */
|
|
270
|
-
|
|
271
275
|
/* Excluded from this release type: retryWithEventualValue */
|
|
272
276
|
|
|
273
277
|
/* Excluded from this release type: summarizeNow */
|
|
@@ -42,7 +42,7 @@ import { ISummaryContext } from '@fluidframework/driver-definitions';
|
|
|
42
42
|
import { ISummaryTree } from '@fluidframework/protocol-definitions';
|
|
43
43
|
import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
|
|
44
44
|
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
45
|
-
import {
|
|
45
|
+
import { ITelemetryGenericEventExt } from '@fluidframework/telemetry-utils';
|
|
46
46
|
import { ITestDriver } from '@fluidframework/test-driver-definitions';
|
|
47
47
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
48
48
|
import { Loader } from '@fluidframework/container-loader';
|
|
@@ -65,8 +65,12 @@ import { RuntimeRequestHandler } from '@fluidframework/request-handler';
|
|
|
65
65
|
|
|
66
66
|
/* Excluded from this release type: createSummarizer */
|
|
67
67
|
|
|
68
|
+
/* Excluded from this release type: createSummarizerCore */
|
|
69
|
+
|
|
68
70
|
/* Excluded from this release type: createSummarizerFromFactory */
|
|
69
71
|
|
|
72
|
+
/* Excluded from this release type: createTestConfigProvider */
|
|
73
|
+
|
|
70
74
|
/* Excluded from this release type: createTestContainerRuntimeFactory */
|
|
71
75
|
|
|
72
76
|
/* Excluded from this release type: DataObjectFactoryType */
|
|
@@ -119,6 +123,8 @@ import { RuntimeRequestHandler } from '@fluidframework/request-handler';
|
|
|
119
123
|
|
|
120
124
|
/* Excluded from this release type: IHostLoader */
|
|
121
125
|
|
|
126
|
+
/* Excluded from this release type: ILoaderOptions */
|
|
127
|
+
|
|
122
128
|
/* Excluded from this release type: ILoaderProps */
|
|
123
129
|
|
|
124
130
|
/* Excluded from this release type: IOnDemandSummarizeOptions */
|
|
@@ -143,6 +149,8 @@ import { RuntimeRequestHandler } from '@fluidframework/request-handler';
|
|
|
143
149
|
|
|
144
150
|
/* Excluded from this release type: ISummaryContext */
|
|
145
151
|
|
|
152
|
+
/* Excluded from this release type: ITestConfigProvider */
|
|
153
|
+
|
|
146
154
|
/* Excluded from this release type: ITestContainerConfig */
|
|
147
155
|
|
|
148
156
|
/* Excluded from this release type: ITestDriver */
|
|
@@ -159,8 +167,6 @@ import { RuntimeRequestHandler } from '@fluidframework/request-handler';
|
|
|
159
167
|
|
|
160
168
|
/* Excluded from this release type: LocalCodeLoader */
|
|
161
169
|
|
|
162
|
-
/* Excluded from this release type: mockConfigProvider */
|
|
163
|
-
|
|
164
170
|
/* Excluded from this release type: NamedFluidDataStoreRegistryEntries */
|
|
165
171
|
|
|
166
172
|
/* Excluded from this release type: retryWithEventualValue */
|
|
@@ -42,7 +42,7 @@ import { ISummaryContext } from '@fluidframework/driver-definitions';
|
|
|
42
42
|
import { ISummaryTree } from '@fluidframework/protocol-definitions';
|
|
43
43
|
import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
|
|
44
44
|
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
45
|
-
import {
|
|
45
|
+
import { ITelemetryGenericEventExt } from '@fluidframework/telemetry-utils';
|
|
46
46
|
import { ITestDriver } from '@fluidframework/test-driver-definitions';
|
|
47
47
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
48
48
|
import { Loader } from '@fluidframework/container-loader';
|
|
@@ -65,8 +65,12 @@ import { RuntimeRequestHandler } from '@fluidframework/request-handler';
|
|
|
65
65
|
|
|
66
66
|
/* Excluded from this release type: createSummarizer */
|
|
67
67
|
|
|
68
|
+
/* Excluded from this release type: createSummarizerCore */
|
|
69
|
+
|
|
68
70
|
/* Excluded from this release type: createSummarizerFromFactory */
|
|
69
71
|
|
|
72
|
+
/* Excluded from this release type: createTestConfigProvider */
|
|
73
|
+
|
|
70
74
|
/* Excluded from this release type: createTestContainerRuntimeFactory */
|
|
71
75
|
|
|
72
76
|
/* Excluded from this release type: DataObjectFactoryType */
|
|
@@ -119,6 +123,8 @@ import { RuntimeRequestHandler } from '@fluidframework/request-handler';
|
|
|
119
123
|
|
|
120
124
|
/* Excluded from this release type: IHostLoader */
|
|
121
125
|
|
|
126
|
+
/* Excluded from this release type: ILoaderOptions */
|
|
127
|
+
|
|
122
128
|
/* Excluded from this release type: ILoaderProps */
|
|
123
129
|
|
|
124
130
|
/* Excluded from this release type: IOnDemandSummarizeOptions */
|
|
@@ -143,6 +149,8 @@ import { RuntimeRequestHandler } from '@fluidframework/request-handler';
|
|
|
143
149
|
|
|
144
150
|
/* Excluded from this release type: ISummaryContext */
|
|
145
151
|
|
|
152
|
+
/* Excluded from this release type: ITestConfigProvider */
|
|
153
|
+
|
|
146
154
|
/* Excluded from this release type: ITestContainerConfig */
|
|
147
155
|
|
|
148
156
|
/* Excluded from this release type: ITestDriver */
|
|
@@ -159,8 +167,6 @@ import { RuntimeRequestHandler } from '@fluidframework/request-handler';
|
|
|
159
167
|
|
|
160
168
|
/* Excluded from this release type: LocalCodeLoader */
|
|
161
169
|
|
|
162
|
-
/* Excluded from this release type: mockConfigProvider */
|
|
163
|
-
|
|
164
170
|
/* Excluded from this release type: NamedFluidDataStoreRegistryEntries */
|
|
165
171
|
|
|
166
172
|
/* Excluded from this release type: retryWithEventualValue */
|
|
@@ -42,7 +42,7 @@ import { ISummaryContext } from '@fluidframework/driver-definitions';
|
|
|
42
42
|
import { ISummaryTree } from '@fluidframework/protocol-definitions';
|
|
43
43
|
import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
|
|
44
44
|
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
45
|
-
import {
|
|
45
|
+
import { ITelemetryGenericEventExt } from '@fluidframework/telemetry-utils';
|
|
46
46
|
import { ITestDriver } from '@fluidframework/test-driver-definitions';
|
|
47
47
|
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
48
48
|
import { Loader } from '@fluidframework/container-loader';
|
|
@@ -103,6 +103,12 @@ export declare function createSummarizer(provider: ITestObjectProvider, containe
|
|
|
103
103
|
summarizer: ISummarizer;
|
|
104
104
|
}>;
|
|
105
105
|
|
|
106
|
+
/** @internal */
|
|
107
|
+
export declare function createSummarizerCore(container: IContainer, loader: IHostLoader, summaryVersion?: string): Promise<{
|
|
108
|
+
container: IContainer;
|
|
109
|
+
summarizer: ISummarizer;
|
|
110
|
+
}>;
|
|
111
|
+
|
|
106
112
|
/**
|
|
107
113
|
* Creates a summarizer client from the given container and data store factory, and returns the summarizer client's
|
|
108
114
|
* IContainer and ISummarizer.
|
|
@@ -114,6 +120,12 @@ export declare function createSummarizerFromFactory(provider: ITestObjectProvide
|
|
|
114
120
|
summarizer: ISummarizer;
|
|
115
121
|
}>;
|
|
116
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Creates a test config provider with the ability to set configs values and clear all config values.
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
export declare const createTestConfigProvider: () => ITestConfigProvider;
|
|
128
|
+
|
|
117
129
|
/**
|
|
118
130
|
* Create a container runtime factory class that allows you to set runtime options
|
|
119
131
|
* @internal
|
|
@@ -163,12 +175,12 @@ export declare class EventAndErrorTrackingLogger implements ITelemetryBaseLogger
|
|
|
163
175
|
constructor(baseLogger: ITelemetryBaseLogger);
|
|
164
176
|
private readonly expectedEvents;
|
|
165
177
|
private readonly unexpectedErrors;
|
|
166
|
-
registerExpectedEvent(...orderedExpectedEvents:
|
|
178
|
+
registerExpectedEvent(...orderedExpectedEvents: ITelemetryGenericEventExt[]): void;
|
|
167
179
|
send(event: ITelemetryBaseEvent): void;
|
|
168
180
|
reportAndClearTrackedEvents(): {
|
|
169
181
|
expectedNotFound: ({
|
|
170
182
|
index: number;
|
|
171
|
-
event:
|
|
183
|
+
event: ITelemetryGenericEventExt | undefined;
|
|
172
184
|
} | undefined)[];
|
|
173
185
|
unexpectedErrors: ITelemetryBaseEvent[];
|
|
174
186
|
};
|
|
@@ -238,6 +250,19 @@ export declare interface IProvideTestFluidObject {
|
|
|
238
250
|
readonly ITestFluidObject: ITestFluidObject;
|
|
239
251
|
}
|
|
240
252
|
|
|
253
|
+
/**
|
|
254
|
+
* Extension of IConfigProviderBase that supports setting a config value and clearing all
|
|
255
|
+
* config values for testing.
|
|
256
|
+
*
|
|
257
|
+
* @internal
|
|
258
|
+
*/
|
|
259
|
+
export declare interface ITestConfigProvider extends IConfigProviderBase {
|
|
260
|
+
/** Set a config value */
|
|
261
|
+
set: (key: string, value: ConfigTypes) => void;
|
|
262
|
+
/** Clear all config values */
|
|
263
|
+
clear: () => void;
|
|
264
|
+
}
|
|
265
|
+
|
|
241
266
|
/**
|
|
242
267
|
* @internal
|
|
243
268
|
*/
|
|
@@ -324,6 +349,14 @@ export declare interface ITestObjectProvider {
|
|
|
324
349
|
* @param packageEntries - list of code details and fluidEntryPoint pairs.
|
|
325
350
|
*/
|
|
326
351
|
createContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>): Promise<IContainer>;
|
|
352
|
+
/**
|
|
353
|
+
* Create a detached container much like createContainer, but without attaching it to the document service.
|
|
354
|
+
*/
|
|
355
|
+
createDetachedContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>): Promise<IContainer>;
|
|
356
|
+
/**
|
|
357
|
+
* Attaches a detached container to the document service.
|
|
358
|
+
*/
|
|
359
|
+
attachDetachedContainer(container: IContainer): Promise<void>;
|
|
327
360
|
/**
|
|
328
361
|
* Loads a container using the default document id
|
|
329
362
|
*/
|
|
@@ -523,11 +556,6 @@ export declare class LocalCodeLoader implements ICodeDetailsLoader {
|
|
|
523
556
|
load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;
|
|
524
557
|
}
|
|
525
558
|
|
|
526
|
-
/**
|
|
527
|
-
* @internal
|
|
528
|
-
*/
|
|
529
|
-
export declare const mockConfigProvider: (settings?: Record<string, ConfigTypes>) => IConfigProviderBase;
|
|
530
|
-
|
|
531
559
|
/**
|
|
532
560
|
* Simple retry mechanism with linear back off to call
|
|
533
561
|
* a function which may eventually return an accepted value.
|
|
@@ -746,6 +774,14 @@ export declare class TestObjectProvider implements ITestObjectProvider {
|
|
|
746
774
|
* {@inheritDoc ITestObjectProvider.createContainer}
|
|
747
775
|
*/
|
|
748
776
|
createContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>): Promise<IContainer>;
|
|
777
|
+
/**
|
|
778
|
+
* {@inheritdoc ITestObjectProvider.createDetachedContainer}
|
|
779
|
+
*/
|
|
780
|
+
createDetachedContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps> | undefined): Promise<IContainer>;
|
|
781
|
+
/**
|
|
782
|
+
* {@inheritdoc ITestObjectProvider.attachDetachedContainer}
|
|
783
|
+
*/
|
|
784
|
+
attachDetachedContainer(container: IContainer): Promise<void>;
|
|
749
785
|
/**
|
|
750
786
|
* {@inheritDoc ITestObjectProvider.loadContainer}
|
|
751
787
|
*/
|
|
@@ -805,13 +841,12 @@ export declare class TestObjectProviderWithVersionedLoad implements ITestObjectP
|
|
|
805
841
|
private _urlResolver;
|
|
806
842
|
private _documentCreated;
|
|
807
843
|
/**
|
|
808
|
-
*
|
|
809
|
-
* loadCount is even then we will load with the "create" version, and if odd we load with the "load" version.
|
|
810
|
-
* After each test we will reset loadCount to 0 to ensure we always create the first container with the create version.
|
|
844
|
+
* Used to determine which APIs to use when creating a loader.
|
|
811
845
|
*
|
|
812
|
-
*
|
|
846
|
+
* The first load will always use the create APIs, and then useCreateApi will be set to false to ensure all
|
|
847
|
+
* subsequent loads use the load APIs.
|
|
813
848
|
*/
|
|
814
|
-
private
|
|
849
|
+
private useCreateApi;
|
|
815
850
|
constructor(LoaderConstructorForCreating: typeof Loader, LoaderConstructorForLoading: typeof Loader, driverForCreating: ITestDriver, driverForLoading: ITestDriver, createFluidEntryPointForCreating: (testContainerConfig?: ITestContainerConfig) => fluidEntryPoint, createFluidEntryPointForLoading: (testContainerConfig?: ITestContainerConfig) => fluidEntryPoint);
|
|
816
851
|
/**
|
|
817
852
|
* {@inheritDoc ITestObjectProvider.logger}
|
|
@@ -855,6 +890,14 @@ export declare class TestObjectProviderWithVersionedLoad implements ITestObjectP
|
|
|
855
890
|
* {@inheritDoc ITestObjectProvider.createContainer}
|
|
856
891
|
*/
|
|
857
892
|
createContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>): Promise<IContainer>;
|
|
893
|
+
/**
|
|
894
|
+
* {@inheritdoc ITestObjectProvider.createDetachedContainer}
|
|
895
|
+
*/
|
|
896
|
+
createDetachedContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps> | undefined): Promise<IContainer>;
|
|
897
|
+
/**
|
|
898
|
+
* {@inheritdoc ITestObjectProvider.attachDetachedContainer}
|
|
899
|
+
*/
|
|
900
|
+
attachDetachedContainer(container: IContainer): Promise<void>;
|
|
858
901
|
/**
|
|
859
902
|
* {@inheritDoc ITestObjectProvider.loadContainer}
|
|
860
903
|
*/
|
|
@@ -889,7 +932,6 @@ export declare class TestObjectProviderWithVersionedLoad implements ITestObjectP
|
|
|
889
932
|
* {@inheritDoc ITestObjectProvider.resetLoaderContainerTracker}
|
|
890
933
|
*/
|
|
891
934
|
resetLoaderContainerTracker(syncSummarizerClients?: boolean): void;
|
|
892
|
-
private nextLoaderShouldCreate;
|
|
893
935
|
}
|
|
894
936
|
|
|
895
937
|
/**
|
|
@@ -971,6 +1013,7 @@ export declare interface TimeoutWithValue<T = void> {
|
|
|
971
1013
|
export declare function waitForContainerConnection(container: IContainer, failOnContainerClose?: boolean, timeoutOptions?: TimeoutWithError): Promise<void>;
|
|
972
1014
|
|
|
973
1015
|
/**
|
|
1016
|
+
* @deprecated - unused
|
|
974
1017
|
* Wraps the given IDocumentService to override the `connectToStorage` method. The intent is to plumb the
|
|
975
1018
|
* `uploadSummaryCb` to the IDocumentStorageService so that it is called whenever a summary is uploaded by
|
|
976
1019
|
* the client.
|
|
@@ -981,6 +1024,7 @@ export declare function waitForContainerConnection(container: IContainer, failOn
|
|
|
981
1024
|
export declare function wrapDocumentService(innerDocService: IDocumentService, uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext): IDocumentService;
|
|
982
1025
|
|
|
983
1026
|
/**
|
|
1027
|
+
* @deprecated - unused
|
|
984
1028
|
* Wraps the given IDocumentServiceFactory to override the `createDocumentService` method. The intent is to plumb
|
|
985
1029
|
* the `uploadSummaryCb` all the way to the IDocumentStorageService so that it is called whenever a summary is
|
|
986
1030
|
* uploaded by the client.
|
|
@@ -991,6 +1035,7 @@ export declare function wrapDocumentService(innerDocService: IDocumentService, u
|
|
|
991
1035
|
export declare function wrapDocumentServiceFactory(innerDocServiceFactory: IDocumentServiceFactory, uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext): IDocumentServiceFactory;
|
|
992
1036
|
|
|
993
1037
|
/**
|
|
1038
|
+
* @deprecated - unused
|
|
994
1039
|
* Wraps the given IDocumentStorageService to override the `uploadSummaryWithContext` method. It calls the
|
|
995
1040
|
* `uploadSummaryCb` whenever a summary is uploaded by the client. The summary context can be updated in the
|
|
996
1041
|
* callback before it is uploaded to the server.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testContainerRuntimeFactory.d.ts","sourceRoot":"","sources":["../src/testContainerRuntimeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"testContainerRuntimeFactory.d.ts","sourceRoot":"","sources":["../src/testContainerRuntimeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EAExB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAQlF,OAAO,EAA8B,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EACN,sBAAsB,EAEtB,MAAM,qCAAqC,CAAC;AAmC7C;;;GAGG;AACH,eAAO,MAAM,iCAAiC,yBACvB,uBAAuB;eAI9B,MAAM,oBACM,sBAAsB,mBACxB,wBAAwB,oBAUvB,qBAAqB,EAAE;cAZlC,MAAM;0BACM,sBAAsB;wBACxB,wBAAwB;yBAUvB,qBAAqB,EAAE;sCAKL,gBAAgB,GAAG,QAAQ,IAAI,CAAC;yCAkB7B,gBAAgB,GAAG,QAAQ,IAAI,CAAC;+BAiBpE,iBAAiB,YAChB,OAAO,GACf,QAAQ,QAAQ,GAAG,iBAAiB,CAAC;;;;;CAwDzC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,2BAA2B;eApHxB,MAAM,oBACM,sBAAsB,mBACxB,wBAAwB,oBAUvB,qBAAqB,EAAE;cAZlC,MAAM;0BACM,sBAAsB;wBACxB,wBAAwB;yBAUvB,qBAAqB,EAAE;sCAKL,gBAAgB,GAAG,QAAQ,IAAI,CAAC;yCAkB7B,gBAAgB,GAAG,QAAQ,IAAI,CAAC;+BAiBpE,iBAAiB,YAChB,OAAO,GACf,QAAQ,QAAQ,GAAG,iBAAiB,CAAC;;;;;CA8DoD,CAAC"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.TestContainerRuntimeFactory = exports.createTestContainerRuntimeFactory = void 0;
|
|
8
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
8
9
|
const container_runtime_1 = require("@fluidframework/container-runtime");
|
|
9
10
|
// eslint-disable-next-line import/no-deprecated
|
|
10
11
|
const request_handler_1 = require("@fluidframework/request-handler");
|
|
@@ -44,10 +45,16 @@ const createTestContainerRuntimeFactory = (containerRuntimeCtor) => {
|
|
|
44
45
|
this.requestHandlers = requestHandlers;
|
|
45
46
|
}
|
|
46
47
|
async instantiateFirstTime(runtime) {
|
|
47
|
-
|
|
48
|
+
// Back-compat - old code does not return IDataStore for rootContext.attachRuntime() call!
|
|
49
|
+
// Thus need to leverage old API createDetachedRootDataStore() that is gone in latest releases.
|
|
50
|
+
const rootContext = "createDetachedRootDataStore" in runtime
|
|
51
|
+
? runtime.createDetachedRootDataStore([this.type], "default")
|
|
52
|
+
: runtime.createDetachedDataStore([this.type], "default");
|
|
48
53
|
const rootRuntime = await this.dataStoreFactory.instantiateDataStore(rootContext,
|
|
49
54
|
/* existing */ false);
|
|
50
|
-
await rootContext.attachRuntime(this.dataStoreFactory, rootRuntime);
|
|
55
|
+
const dataStore = await rootContext.attachRuntime(this.dataStoreFactory, rootRuntime);
|
|
56
|
+
const result = await dataStore?.trySetAlias("default");
|
|
57
|
+
(0, core_utils_1.assert)(result === "Success" || result === undefined, "success");
|
|
51
58
|
}
|
|
52
59
|
async instantiateFromExisting(runtime) {
|
|
53
60
|
// Validate we can load root data stores.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testContainerRuntimeFactory.js","sourceRoot":"","sources":["../src/testContainerRuntimeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yEAI2C;AAQ3C,gDAAgD;AAChD,qEAAoG;AAKpG,iEAAoF;AAOpF,MAAM,qCAAqC,GAAG,CAAC,aAAqB,EAAE,EAAE;IACvE,OAAO,KAAK,EAAE,OAAiB,EAAE,OAA0B,EAAE,EAAE;QAC9D,MAAM,MAAM,GAAG,6BAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YAClC,OACC,OACA,CAAC,mBAAmB,CAAC,aAAa,CAAC;gBACnC,GAAG,EAAE,IAAI,aAAa,GAAG,MAAM,CAAC,KAAK,EAAE;gBACvC,OAAO,EAAE,OAAO,CAAC,OAAO;aACxB,CAAC,CAAC;SACH;QACD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C,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;oBACnD,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;iBACnD;gBACD,cAAc,EAAE,IAAA,4CAA0B,EACzC,gBAAgB,EAChB,GAAG,IAAI,CAAC,eAAe,CACvB;gBACD,iBAAiB;gBACjB,gFAAgF;gBAChF,oBAAoB,EAAE,iBAAiB;gBACvC,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,cAAc,EAAE,OAAO,CAAC,KAAK;gBAC7B,QAAQ;aACD,CAAC,CAAC;QACX,CAAC;KACD,CAAC;AACH,CAAC,CAAC;AA1GW,QAAA,iCAAiC,qCA0G5C;AAEF;;;GAGG;AACU,QAAA,2BAA2B,GAAG,IAAA,yCAAiC,EAAC,oCAAgB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IContainerContext, IRuntime } from \"@fluidframework/container-definitions\";\nimport {\n\tContainerRuntime,\n\tIContainerRuntimeOptions,\n\tDefaultSummaryConfiguration,\n} from \"@fluidframework/container-runtime\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport {\n\tFluidObject,\n\tIFluidHandleContext,\n\tIRequest,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\n// eslint-disable-next-line import/no-deprecated\nimport { buildRuntimeRequestHandler, RuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\nimport { RequestParser, RuntimeFactoryHelper } from \"@fluidframework/runtime-utils\";\n\ninterface backCompat_IFluidRouter {\n\tIFluidRouter?: backCompat_IFluidRouter;\n\trequest(request: IRequest): Promise<IResponse>;\n}\n\nconst backCompat_DefaultRouteRequestHandler = (defaultRootId: string) => {\n\treturn async (request: IRequest, runtime: IContainerRuntime) => {\n\t\tconst parser = RequestParser.create(request);\n\t\tif (parser.pathParts.length === 0) {\n\t\t\treturn (\n\t\t\t\truntime as any as Required<FluidObject<IFluidHandleContext>>\n\t\t\t).IFluidHandleContext.resolveHandle({\n\t\t\t\turl: `/${defaultRootId}${parser.query}`,\n\t\t\t\theaders: request.headers,\n\t\t\t});\n\t\t}\n\t\treturn undefined; // continue search\n\t};\n};\n\ninterface backCompat_ContainerRuntime {\n\tload(\n\t\tcontext: IContainerContext,\n\t\tregistryEntries: NamedFluidDataStoreRegistryEntries,\n\t\trequestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>,\n\t\truntimeOptions?: IContainerRuntimeOptions,\n\t\tcontainerScope?: FluidObject,\n\t\texisting?: boolean,\n\t\tcontainerRuntimeCtor?: typeof ContainerRuntime,\n\t): Promise<ContainerRuntime>;\n}\n\n/**\n * Create a container runtime factory class that allows you to set runtime options\n * @internal\n */\nexport const createTestContainerRuntimeFactory = (\n\tcontainerRuntimeCtor: typeof ContainerRuntime,\n) => {\n\treturn class extends RuntimeFactoryHelper {\n\t\tconstructor(\n\t\t\tpublic type: string,\n\t\t\tpublic dataStoreFactory: IFluidDataStoreFactory,\n\t\t\tpublic runtimeOptions: IContainerRuntimeOptions = {\n\t\t\t\tsummaryOptions: {\n\t\t\t\t\tsummaryConfigOverrides: {\n\t\t\t\t\t\t...DefaultSummaryConfiguration,\n\t\t\t\t\t\t...{\n\t\t\t\t\t\t\tinitialSummarizerDelayMs: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tpublic requestHandlers: RuntimeRequestHandler[] = [],\n\t\t) {\n\t\t\tsuper();\n\t\t}\n\n\t\tpublic async instantiateFirstTime(runtime: ContainerRuntime): Promise<void> {\n\t\t\tconst rootContext = runtime.createDetachedRootDataStore([this.type], \"default\");\n\t\t\tconst rootRuntime = await this.dataStoreFactory.instantiateDataStore(\n\t\t\t\trootContext,\n\t\t\t\t/* existing */ false,\n\t\t\t);\n\t\t\tawait rootContext.attachRuntime(this.dataStoreFactory, rootRuntime);\n\t\t}\n\n\t\tpublic async instantiateFromExisting(runtime: ContainerRuntime): Promise<void> {\n\t\t\t// Validate we can load root data stores.\n\t\t\t// We should be able to load any data store that was created in initializeFirstTime!\n\t\t\t// Note: We use the deprecated `getRootDataStore` from v1.X here to allow for cross-major version compat\n\t\t\t// testing. Can be removed when we no longer support v1.X.\n\t\t\tawait (runtime.getAliasedDataStoreEntryPoint?.(\"default\") ??\n\t\t\t\t(\n\t\t\t\t\truntime as any as {\n\t\t\t\t\t\tgetRootDataStore(\n\t\t\t\t\t\t\tid: string,\n\t\t\t\t\t\t\twait?: boolean,\n\t\t\t\t\t\t): Promise<backCompat_IFluidRouter>;\n\t\t\t\t\t}\n\t\t\t\t).getRootDataStore(\"default\"));\n\t\t}\n\n\t\tasync preInitialize(\n\t\t\tcontext: IContainerContext,\n\t\t\texisting: boolean,\n\t\t): Promise<IRuntime & IContainerRuntime> {\n\t\t\tif (containerRuntimeCtor.loadRuntime === undefined) {\n\t\t\t\t// Note: We use the deprecated `load` from v1.X here to allow for cross-major version compat testing.\n\t\t\t\t// Can be removed when we no longer support v1.X.\n\t\t\t\treturn (containerRuntimeCtor as any as backCompat_ContainerRuntime).load(\n\t\t\t\t\tcontext,\n\t\t\t\t\t[\n\t\t\t\t\t\t[\"default\", Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t\t\t[this.type, Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t\t],\n\t\t\t\t\tbuildRuntimeRequestHandler(\n\t\t\t\t\t\tbackCompat_DefaultRouteRequestHandler(\"default\"),\n\t\t\t\t\t\t...this.requestHandlers,\n\t\t\t\t\t),\n\t\t\t\t\tthis.runtimeOptions,\n\t\t\t\t\tcontext.scope,\n\t\t\t\t\texisting,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst provideEntryPoint = async (runtime: IContainerRuntime) => {\n\t\t\t\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(\"default\");\n\t\t\t\tif (entryPoint === undefined) {\n\t\t\t\t\tthrow new Error(\"default dataStore must exist\");\n\t\t\t\t}\n\t\t\t\treturn entryPoint.get();\n\t\t\t};\n\t\t\tconst getDefaultObject = async (request: IRequest, runtime: IContainerRuntime) => {\n\t\t\t\tconst parser = RequestParser.create(request);\n\t\t\t\tif (parser.pathParts.length === 0) {\n\t\t\t\t\t// This cast is safe as ContainerRuntime.loadRuntime is called below\n\t\t\t\t\treturn (runtime as ContainerRuntime).resolveHandle({\n\t\t\t\t\t\turl: `/default${parser.query}`,\n\t\t\t\t\t\theaders: request.headers,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn undefined; // continue search\n\t\t\t};\n\t\t\treturn containerRuntimeCtor.loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistryEntries: [\n\t\t\t\t\t[\"default\", Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t\t[this.type, Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t],\n\t\t\t\trequestHandler: buildRuntimeRequestHandler(\n\t\t\t\t\tgetDefaultObject,\n\t\t\t\t\t...this.requestHandlers,\n\t\t\t\t),\n\t\t\t\tprovideEntryPoint,\n\t\t\t\t// ! This prop is needed for back-compat. Can be removed in 2.0.0-internal.8.0.0\n\t\t\t\tinitializeEntryPoint: provideEntryPoint,\n\t\t\t\truntimeOptions: this.runtimeOptions,\n\t\t\t\tcontainerScope: context.scope,\n\t\t\t\texisting,\n\t\t\t} as any);\n\t\t}\n\t};\n};\n\n/**\n * A container runtime factory that allows you to set runtime options\n * @internal\n */\nexport const TestContainerRuntimeFactory = createTestContainerRuntimeFactory(ContainerRuntime);\n"]}
|
|
1
|
+
{"version":3,"file":"testContainerRuntimeFactory.js","sourceRoot":"","sources":["../src/testContainerRuntimeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AAEpD,yEAI2C;AA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AAC,CAAC;AAnHW,QAAA,iCAAiC,qCAmH5C;AAEF;;;GAGG;AACU,QAAA,2BAA2B,GAAG,IAAA,yCAAiC,EAAC,oCAAgB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IContainerContext, IRuntime } from \"@fluidframework/container-definitions\";\nimport {\n\tContainerRuntime,\n\tIContainerRuntimeOptions,\n\tDefaultSummaryConfiguration,\n} from \"@fluidframework/container-runtime\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport {\n\tFluidObject,\n\tIFluidHandleContext,\n\tIRequest,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\n// eslint-disable-next-line import/no-deprecated\nimport { buildRuntimeRequestHandler, RuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\nimport { RequestParser, RuntimeFactoryHelper } from \"@fluidframework/runtime-utils\";\n\ninterface backCompat_IFluidRouter {\n\tIFluidRouter?: backCompat_IFluidRouter;\n\trequest(request: IRequest): Promise<IResponse>;\n}\n\nconst backCompat_DefaultRouteRequestHandler = (defaultRootId: string) => {\n\treturn async (request: IRequest, runtime: IContainerRuntime) => {\n\t\tconst parser = RequestParser.create(request);\n\t\tif (parser.pathParts.length === 0) {\n\t\t\treturn (\n\t\t\t\truntime as any as Required<FluidObject<IFluidHandleContext>>\n\t\t\t).IFluidHandleContext.resolveHandle({\n\t\t\t\turl: `/${defaultRootId}${parser.query}`,\n\t\t\t\theaders: request.headers,\n\t\t\t});\n\t\t}\n\t\treturn undefined; // continue search\n\t};\n};\n\ninterface backCompat_ContainerRuntime {\n\tload(\n\t\tcontext: IContainerContext,\n\t\tregistryEntries: NamedFluidDataStoreRegistryEntries,\n\t\trequestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>,\n\t\truntimeOptions?: IContainerRuntimeOptions,\n\t\tcontainerScope?: FluidObject,\n\t\texisting?: boolean,\n\t\tcontainerRuntimeCtor?: typeof ContainerRuntime,\n\t): Promise<ContainerRuntime>;\n}\n\n/**\n * Create a container runtime factory class that allows you to set runtime options\n * @internal\n */\nexport const createTestContainerRuntimeFactory = (\n\tcontainerRuntimeCtor: typeof ContainerRuntime,\n) => {\n\treturn class extends RuntimeFactoryHelper {\n\t\tconstructor(\n\t\t\tpublic type: string,\n\t\t\tpublic dataStoreFactory: IFluidDataStoreFactory,\n\t\t\tpublic runtimeOptions: IContainerRuntimeOptions = {\n\t\t\t\tsummaryOptions: {\n\t\t\t\t\tsummaryConfigOverrides: {\n\t\t\t\t\t\t...DefaultSummaryConfiguration,\n\t\t\t\t\t\t...{\n\t\t\t\t\t\t\tinitialSummarizerDelayMs: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tpublic requestHandlers: RuntimeRequestHandler[] = [],\n\t\t) {\n\t\t\tsuper();\n\t\t}\n\n\t\tpublic async instantiateFirstTime(runtime: ContainerRuntime): Promise<void> {\n\t\t\t// Back-compat - old code does not return IDataStore for rootContext.attachRuntime() call!\n\t\t\t// Thus need to leverage old API createDetachedRootDataStore() that is gone in latest releases.\n\t\t\tconst rootContext =\n\t\t\t\t\"createDetachedRootDataStore\" in runtime\n\t\t\t\t\t? (runtime as any).createDetachedRootDataStore([this.type], \"default\")\n\t\t\t\t\t: runtime.createDetachedDataStore([this.type], \"default\");\n\n\t\t\tconst rootRuntime = await this.dataStoreFactory.instantiateDataStore(\n\t\t\t\trootContext,\n\t\t\t\t/* existing */ false,\n\t\t\t);\n\t\t\tconst dataStore = await rootContext.attachRuntime(this.dataStoreFactory, rootRuntime);\n\n\t\t\tconst result = await dataStore?.trySetAlias(\"default\");\n\t\t\tassert(result === \"Success\" || result === undefined, \"success\");\n\t\t}\n\n\t\tpublic async instantiateFromExisting(runtime: ContainerRuntime): Promise<void> {\n\t\t\t// Validate we can load root data stores.\n\t\t\t// We should be able to load any data store that was created in initializeFirstTime!\n\t\t\t// Note: We use the deprecated `getRootDataStore` from v1.X here to allow for cross-major version compat\n\t\t\t// testing. Can be removed when we no longer support v1.X.\n\t\t\tawait (runtime.getAliasedDataStoreEntryPoint?.(\"default\") ??\n\t\t\t\t(\n\t\t\t\t\truntime as any as {\n\t\t\t\t\t\tgetRootDataStore(\n\t\t\t\t\t\t\tid: string,\n\t\t\t\t\t\t\twait?: boolean,\n\t\t\t\t\t\t): Promise<backCompat_IFluidRouter>;\n\t\t\t\t\t}\n\t\t\t\t).getRootDataStore(\"default\"));\n\t\t}\n\n\t\tasync preInitialize(\n\t\t\tcontext: IContainerContext,\n\t\t\texisting: boolean,\n\t\t): Promise<IRuntime & IContainerRuntime> {\n\t\t\tif (containerRuntimeCtor.loadRuntime === undefined) {\n\t\t\t\t// Note: We use the deprecated `load` from v1.X here to allow for cross-major version compat testing.\n\t\t\t\t// Can be removed when we no longer support v1.X.\n\t\t\t\treturn (containerRuntimeCtor as any as backCompat_ContainerRuntime).load(\n\t\t\t\t\tcontext,\n\t\t\t\t\t[\n\t\t\t\t\t\t[\"default\", Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t\t\t[this.type, Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t\t],\n\t\t\t\t\tbuildRuntimeRequestHandler(\n\t\t\t\t\t\tbackCompat_DefaultRouteRequestHandler(\"default\"),\n\t\t\t\t\t\t...this.requestHandlers,\n\t\t\t\t\t),\n\t\t\t\t\tthis.runtimeOptions,\n\t\t\t\t\tcontext.scope,\n\t\t\t\t\texisting,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst provideEntryPoint = async (runtime: IContainerRuntime) => {\n\t\t\t\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(\"default\");\n\t\t\t\tif (entryPoint === undefined) {\n\t\t\t\t\tthrow new Error(\"default dataStore must exist\");\n\t\t\t\t}\n\t\t\t\treturn entryPoint.get();\n\t\t\t};\n\t\t\tconst getDefaultObject = async (request: IRequest, runtime: IContainerRuntime) => {\n\t\t\t\tconst parser = RequestParser.create(request);\n\t\t\t\tif (parser.pathParts.length === 0) {\n\t\t\t\t\t// This cast is safe as ContainerRuntime.loadRuntime is called below\n\t\t\t\t\treturn (runtime as ContainerRuntime).resolveHandle({\n\t\t\t\t\t\turl: `/default${parser.query}`,\n\t\t\t\t\t\theaders: request.headers,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn undefined; // continue search\n\t\t\t};\n\t\t\treturn containerRuntimeCtor.loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistryEntries: [\n\t\t\t\t\t[\"default\", Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t\t[this.type, Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t],\n\t\t\t\trequestHandler: buildRuntimeRequestHandler(\n\t\t\t\t\tgetDefaultObject,\n\t\t\t\t\t...this.requestHandlers,\n\t\t\t\t),\n\t\t\t\tprovideEntryPoint,\n\t\t\t\t// ! This prop is needed for back-compat. Can be removed in 2.0.0-internal.8.0.0\n\t\t\t\tinitializeEntryPoint: provideEntryPoint,\n\t\t\t\truntimeOptions: this.runtimeOptions,\n\t\t\t\tcontainerScope: context.scope,\n\t\t\t\texisting,\n\t\t\t} as any);\n\t\t}\n\t};\n};\n\n/**\n * A container runtime factory that allows you to set runtime options\n * @internal\n */\nexport const TestContainerRuntimeFactory = createTestContainerRuntimeFactory(ContainerRuntime);\n"]}
|
|
@@ -7,7 +7,7 @@ import { FluidDataStoreRuntime } from "@fluidframework/datastore";
|
|
|
7
7
|
import { ISharedMap } from "@fluidframework/map";
|
|
8
8
|
import { IFluidDataStoreContext, IFluidDataStoreFactory, IFluidDataStoreChannel } from "@fluidframework/runtime-definitions";
|
|
9
9
|
import { IFluidDataStoreRuntime, IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
10
|
-
import { ITestFluidObject } from "./interfaces";
|
|
10
|
+
import { ITestFluidObject } from "./interfaces.js";
|
|
11
11
|
/**
|
|
12
12
|
* A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load.
|
|
13
13
|
* The shared objects can be retrieved by passing the key of the entry to getSharedObject.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testFluidObject.d.ts","sourceRoot":"","sources":["../src/testFluidObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAEN,qBAAqB,EAErB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAa,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAGhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"testFluidObject.d.ts","sourceRoot":"","sources":["../src/testFluidObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAEN,qBAAqB,EAErB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAa,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAGhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;;GAKG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;aAyBtC,OAAO,EAAE,sBAAsB;aAC/B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CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO,QAAQ,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAoB,IAAI,eAAe,CACpD,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,UAAU;QACnB,OAAO,EACP,0BAA0B,CAC1B,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE;YACd,MAAM,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SACjC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACD;AAtED,wDAsEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest, IResponse, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tFluidObjectHandle,\n\tFluidDataStoreRuntime,\n\tmixinRequestHandler,\n} from \"@fluidframework/datastore\";\nimport { SharedMap, ISharedMap } from \"@fluidframework/map\";\nimport {\n\tIFluidDataStoreContext,\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreChannel,\n} from \"@fluidframework/runtime-definitions\";\nimport { IFluidDataStoreRuntime, IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { create404Response } from \"@fluidframework/runtime-utils\";\nimport { ITestFluidObject } from \"./interfaces\";\n\n/**\n * A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load.\n * The shared objects can be retrieved by passing the key of the entry to getSharedObject.\n * It exposes the IFluidDataStoreContext and IFluidDataStoreRuntime.\n * @internal\n */\nexport class TestFluidObject implements ITestFluidObject {\n\tpublic get ITestFluidObject() {\n\t\treturn this;\n\t}\n\n\tpublic get IFluidLoadable() {\n\t\treturn this;\n\t}\n\n\tpublic get handle(): IFluidHandle<this> {\n\t\treturn this.innerHandle;\n\t}\n\n\tpublic root!: ISharedMap;\n\tprivate readonly innerHandle: IFluidHandle<this>;\n\tprivate initializeP: Promise<void> | undefined;\n\n\t/**\n\t * Creates a new TestFluidObject.\n\t * @param runtime - The data store runtime.\n\t * @param context - The data store context.\n\t * @param factoryEntries - A list of id to IChannelFactory mapping. For each item in the list,\n\t * a shared object is created which can be retrieved by calling getSharedObject() with the id;\n\t */\n\tconstructor(\n\t\tpublic readonly runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly channel: IFluidDataStoreChannel,\n\t\tpublic readonly context: IFluidDataStoreContext,\n\t\tprivate readonly factoryEntriesMap: Map<string, IChannelFactory>,\n\t) {\n\t\tthis.innerHandle = new FluidObjectHandle(this, \"\", runtime.objectsRoutingContext);\n\t}\n\n\t/**\n\t * Retrieves a shared object with the given id.\n\t * @param id - The id of the shared object to retrieve.\n\t */\n\tpublic async getSharedObject<T = any>(id: string): Promise<T> {\n\t\tif (this.factoryEntriesMap === undefined) {\n\t\t\tthrow new Error(\"Shared objects were not provided during creation.\");\n\t\t}\n\n\t\tfor (const key of this.factoryEntriesMap.keys()) {\n\t\t\tif (key === id) {\n\t\t\t\tconst handle = this.root.get<IFluidHandle>(id);\n\t\t\t\treturn handle?.get() as unknown as T;\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(`Shared object with id ${id} not found.`);\n\t}\n\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\treturn request.url === \"\" || request.url === \"/\" || request.url.startsWith(\"/?\")\n\t\t\t? { mimeType: \"fluid/object\", status: 200, value: this }\n\t\t\t: create404Response(request);\n\t}\n\n\tpublic async initialize(existing: boolean) {\n\t\tconst doInitialization = async () => {\n\t\t\tif (!existing) {\n\t\t\t\tthis.root = SharedMap.create(this.runtime, \"root\");\n\n\t\t\t\tthis.factoryEntriesMap.forEach(\n\t\t\t\t\t(sharedObjectFactory: IChannelFactory, key: string) => {\n\t\t\t\t\t\tconst sharedObject = this.runtime.createChannel(\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tsharedObjectFactory.type,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.root.set(key, sharedObject.handle);\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tthis.root.bindToContext();\n\t\t\t}\n\n\t\t\tthis.root = (await this.runtime.getChannel(\"root\")) as ISharedMap;\n\t\t};\n\n\t\tif (this.initializeP === undefined) {\n\t\t\tthis.initializeP = doInitialization();\n\t\t}\n\n\t\treturn this.initializeP;\n\t}\n}\n\n/**\n * @internal\n */\nexport type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFactory]>;\n\n/**\n * Creates a factory for a TestFluidObject with the given object factory entries. It creates a data store runtime\n * with the object factories in the entry list. All the entries with an id other than undefined are passed to the\n * Fluid object so that it can create a shared object for each.\n *\n * @example\n *\n * The following will create a Fluid object that creates and loads a SharedString and SharedDirectory.\n * It will add SparseMatrix to the data store's factory so that it can be created later.\n *\n * ```typescript\n * new TestFluidObjectFactory([\n * [ \"sharedString\", SharedString.getFactory() ],\n * [ \"sharedDirectory\", SharedDirectory.getFactory() ],\n * [ undefined, SparseMatrix.getFactory() ],\n * ]);\n * ```\n *\n * The SharedString and SharedDirectory can be retrieved via getSharedObject() on the TestFluidObject as follows:\n *\n * ```typescript\n * sharedString = testFluidObject.getSharedObject<SharedString>(\"sharedString\");\n * sharedDir = testFluidObject.getSharedObject<SharedDirectory>(\"sharedDirectory\");\n * ```\n *\n * @privateRemarks Beware that using this class generally forfeits some compatibility coverage\n * `describeCompat` aims to provide:\n * `SharedMap`s always reference the current version of SharedMap.\n * AB#4670 tracks improving this situation.\n * @internal\n */\nexport class TestFluidObjectFactory implements IFluidDataStoreFactory {\n\tpublic get IFluidDataStoreFactory() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates a new TestFluidObjectFactory.\n\t * @param factoryEntries - A list of id to IChannelFactory mapping. It creates a data store runtime with each\n\t * IChannelFactory. Entries with string ids are passed to the Fluid object so that it can create a shared object\n\t * for it.\n\t */\n\tconstructor(\n\t\tprivate readonly factoryEntries: ChannelFactoryRegistry,\n\t\tpublic readonly type = \"TestFluidObjectFactory\",\n\t) {}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<FluidDataStoreRuntime> {\n\t\tconst dataTypes = new Map<string, IChannelFactory>();\n\n\t\t// Add SharedMap's factory which will be used to create the root map.\n\t\tconst sharedMapFactory = SharedMap.getFactory();\n\t\tdataTypes.set(sharedMapFactory.type, sharedMapFactory);\n\n\t\t// Add the object factories to the list to be sent to data store runtime.\n\t\tfor (const [, factory] of this.factoryEntries) {\n\t\t\tdataTypes.set(factory.type, factory);\n\t\t}\n\n\t\t// Create a map from the factory entries with entries that don't have the id as undefined. This will be\n\t\t// passed to the Fluid object.\n\t\tconst factoryEntriesMapForObject = new Map<string, IChannelFactory>();\n\t\tfor (const [id, factory] of this.factoryEntries) {\n\t\t\tif (id !== undefined) {\n\t\t\t\tfactoryEntriesMapForObject.set(id, factory);\n\t\t\t}\n\t\t}\n\n\t\tconst runtimeClass = mixinRequestHandler(\n\t\t\tasync (request: IRequest, rt: FluidDataStoreRuntime) => {\n\t\t\t\t// The provideEntryPoint callback below always returns FluidDataStoreRuntime, so this cast is safe\n\t\t\t\tconst dataObject = (await rt.entryPoint.get()) as FluidDataStoreRuntime;\n\t\t\t\tassert(\n\t\t\t\t\tdataObject.request !== undefined,\n\t\t\t\t\t\"entryPoint should have been initialized by now\",\n\t\t\t\t);\n\t\t\t\treturn dataObject.request(request);\n\t\t\t},\n\t\t);\n\n\t\tconst runtime = new runtimeClass(context, dataTypes, existing, async () => {\n\t\t\tawait instance.initialize(true);\n\t\t\treturn instance;\n\t\t});\n\n\t\tconst instance: TestFluidObject = new TestFluidObject(\n\t\t\truntime, // runtime\n\t\t\truntime, // channel\n\t\t\tcontext,\n\t\t\tfactoryEntriesMapForObject,\n\t\t);\n\n\t\tif (!existing) {\n\t\t\tawait instance.initialize(false);\n\t\t}\n\n\t\treturn runtime;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"testFluidObject.js","sourceRoot":"","sources":["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,IAAI,EAAE;YACzE,MAAM,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO,QAAQ,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAoB,IAAI,eAAe,CACpD,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,UAAU;QACnB,OAAO,EACP,0BAA0B,CAC1B,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE;YACd,MAAM,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SACjC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACD;AAtED,wDAsEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest, IResponse, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tFluidObjectHandle,\n\tFluidDataStoreRuntime,\n\tmixinRequestHandler,\n} from \"@fluidframework/datastore\";\nimport { SharedMap, ISharedMap } from \"@fluidframework/map\";\nimport {\n\tIFluidDataStoreContext,\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreChannel,\n} from \"@fluidframework/runtime-definitions\";\nimport { IFluidDataStoreRuntime, IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { create404Response } from \"@fluidframework/runtime-utils\";\nimport { ITestFluidObject } from \"./interfaces.js\";\n\n/**\n * A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load.\n * The shared objects can be retrieved by passing the key of the entry to getSharedObject.\n * It exposes the IFluidDataStoreContext and IFluidDataStoreRuntime.\n * @internal\n */\nexport class TestFluidObject implements ITestFluidObject {\n\tpublic get ITestFluidObject() {\n\t\treturn this;\n\t}\n\n\tpublic get IFluidLoadable() {\n\t\treturn this;\n\t}\n\n\tpublic get handle(): IFluidHandle<this> {\n\t\treturn this.innerHandle;\n\t}\n\n\tpublic root!: ISharedMap;\n\tprivate readonly innerHandle: IFluidHandle<this>;\n\tprivate initializeP: Promise<void> | undefined;\n\n\t/**\n\t * Creates a new TestFluidObject.\n\t * @param runtime - The data store runtime.\n\t * @param context - The data store context.\n\t * @param factoryEntries - A list of id to IChannelFactory mapping. For each item in the list,\n\t * a shared object is created which can be retrieved by calling getSharedObject() with the id;\n\t */\n\tconstructor(\n\t\tpublic readonly runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly channel: IFluidDataStoreChannel,\n\t\tpublic readonly context: IFluidDataStoreContext,\n\t\tprivate readonly factoryEntriesMap: Map<string, IChannelFactory>,\n\t) {\n\t\tthis.innerHandle = new FluidObjectHandle(this, \"\", runtime.objectsRoutingContext);\n\t}\n\n\t/**\n\t * Retrieves a shared object with the given id.\n\t * @param id - The id of the shared object to retrieve.\n\t */\n\tpublic async getSharedObject<T = any>(id: string): Promise<T> {\n\t\tif (this.factoryEntriesMap === undefined) {\n\t\t\tthrow new Error(\"Shared objects were not provided during creation.\");\n\t\t}\n\n\t\tfor (const key of this.factoryEntriesMap.keys()) {\n\t\t\tif (key === id) {\n\t\t\t\tconst handle = this.root.get<IFluidHandle>(id);\n\t\t\t\treturn handle?.get() as unknown as T;\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(`Shared object with id ${id} not found.`);\n\t}\n\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\treturn request.url === \"\" || request.url === \"/\" || request.url.startsWith(\"/?\")\n\t\t\t? { mimeType: \"fluid/object\", status: 200, value: this }\n\t\t\t: create404Response(request);\n\t}\n\n\tpublic async initialize(existing: boolean) {\n\t\tconst doInitialization = async () => {\n\t\t\tif (!existing) {\n\t\t\t\tthis.root = SharedMap.create(this.runtime, \"root\");\n\n\t\t\t\tthis.factoryEntriesMap.forEach(\n\t\t\t\t\t(sharedObjectFactory: IChannelFactory, key: string) => {\n\t\t\t\t\t\tconst sharedObject = this.runtime.createChannel(\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tsharedObjectFactory.type,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.root.set(key, sharedObject.handle);\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tthis.root.bindToContext();\n\t\t\t}\n\n\t\t\tthis.root = (await this.runtime.getChannel(\"root\")) as ISharedMap;\n\t\t};\n\n\t\tif (this.initializeP === undefined) {\n\t\t\tthis.initializeP = doInitialization();\n\t\t}\n\n\t\treturn this.initializeP;\n\t}\n}\n\n/**\n * @internal\n */\nexport type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFactory]>;\n\n/**\n * Creates a factory for a TestFluidObject with the given object factory entries. It creates a data store runtime\n * with the object factories in the entry list. All the entries with an id other than undefined are passed to the\n * Fluid object so that it can create a shared object for each.\n *\n * @example\n *\n * The following will create a Fluid object that creates and loads a SharedString and SharedDirectory.\n * It will add SparseMatrix to the data store's factory so that it can be created later.\n *\n * ```typescript\n * new TestFluidObjectFactory([\n * [ \"sharedString\", SharedString.getFactory() ],\n * [ \"sharedDirectory\", SharedDirectory.getFactory() ],\n * [ undefined, SparseMatrix.getFactory() ],\n * ]);\n * ```\n *\n * The SharedString and SharedDirectory can be retrieved via getSharedObject() on the TestFluidObject as follows:\n *\n * ```typescript\n * sharedString = testFluidObject.getSharedObject<SharedString>(\"sharedString\");\n * sharedDir = testFluidObject.getSharedObject<SharedDirectory>(\"sharedDirectory\");\n * ```\n *\n * @privateRemarks Beware that using this class generally forfeits some compatibility coverage\n * `describeCompat` aims to provide:\n * `SharedMap`s always reference the current version of SharedMap.\n * AB#4670 tracks improving this situation.\n * @internal\n */\nexport class TestFluidObjectFactory implements IFluidDataStoreFactory {\n\tpublic get IFluidDataStoreFactory() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates a new TestFluidObjectFactory.\n\t * @param factoryEntries - A list of id to IChannelFactory mapping. It creates a data store runtime with each\n\t * IChannelFactory. Entries with string ids are passed to the Fluid object so that it can create a shared object\n\t * for it.\n\t */\n\tconstructor(\n\t\tprivate readonly factoryEntries: ChannelFactoryRegistry,\n\t\tpublic readonly type = \"TestFluidObjectFactory\",\n\t) {}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<FluidDataStoreRuntime> {\n\t\tconst dataTypes = new Map<string, IChannelFactory>();\n\n\t\t// Add SharedMap's factory which will be used to create the root map.\n\t\tconst sharedMapFactory = SharedMap.getFactory();\n\t\tdataTypes.set(sharedMapFactory.type, sharedMapFactory);\n\n\t\t// Add the object factories to the list to be sent to data store runtime.\n\t\tfor (const [, factory] of this.factoryEntries) {\n\t\t\tdataTypes.set(factory.type, factory);\n\t\t}\n\n\t\t// Create a map from the factory entries with entries that don't have the id as undefined. This will be\n\t\t// passed to the Fluid object.\n\t\tconst factoryEntriesMapForObject = new Map<string, IChannelFactory>();\n\t\tfor (const [id, factory] of this.factoryEntries) {\n\t\t\tif (id !== undefined) {\n\t\t\t\tfactoryEntriesMapForObject.set(id, factory);\n\t\t\t}\n\t\t}\n\n\t\tconst runtimeClass = mixinRequestHandler(\n\t\t\tasync (request: IRequest, rt: FluidDataStoreRuntime) => {\n\t\t\t\t// The provideEntryPoint callback below always returns FluidDataStoreRuntime, so this cast is safe\n\t\t\t\tconst dataObject = (await rt.entryPoint.get()) as FluidDataStoreRuntime;\n\t\t\t\tassert(\n\t\t\t\t\tdataObject.request !== undefined,\n\t\t\t\t\t\"entryPoint should have been initialized by now\",\n\t\t\t\t);\n\t\t\t\treturn dataObject.request(request);\n\t\t\t},\n\t\t);\n\n\t\tconst runtime = new runtimeClass(context, dataTypes, existing, async () => {\n\t\t\tawait instance.initialize(true);\n\t\t\treturn instance;\n\t\t});\n\n\t\tconst instance: TestFluidObject = new TestFluidObject(\n\t\t\truntime, // runtime\n\t\t\truntime, // channel\n\t\t\tcontext,\n\t\t\tfactoryEntriesMapForObject,\n\t\t);\n\n\t\tif (!existing) {\n\t\t\tawait instance.initialize(false);\n\t\t}\n\n\t\treturn runtime;\n\t}\n}\n"]}
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
import { IContainer, IHostLoader, IFluidCodeDetails } from "@fluidframework/container-definitions";
|
|
6
6
|
import { ILoaderProps, Loader } from "@fluidframework/container-loader";
|
|
7
7
|
import { IContainerRuntimeOptions } from "@fluidframework/container-runtime";
|
|
8
|
-
import {
|
|
8
|
+
import { ITelemetryBaseLogger, ITelemetryBaseEvent, IRequestHeader } from "@fluidframework/core-interfaces";
|
|
9
9
|
import { IDocumentServiceFactory, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
10
10
|
import { ITestDriver } from "@fluidframework/test-driver-definitions";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { type ITelemetryGenericEventExt } from "@fluidframework/telemetry-utils";
|
|
12
|
+
import { fluidEntryPoint } from "./localCodeLoader.js";
|
|
13
|
+
import { ChannelFactoryRegistry } from "./testFluidObject.js";
|
|
13
14
|
/**
|
|
14
15
|
* @alpha
|
|
15
16
|
*/
|
|
@@ -78,6 +79,14 @@ export interface ITestObjectProvider {
|
|
|
78
79
|
* @param packageEntries - list of code details and fluidEntryPoint pairs.
|
|
79
80
|
*/
|
|
80
81
|
createContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>): Promise<IContainer>;
|
|
82
|
+
/**
|
|
83
|
+
* Create a detached container much like createContainer, but without attaching it to the document service.
|
|
84
|
+
*/
|
|
85
|
+
createDetachedContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>): Promise<IContainer>;
|
|
86
|
+
/**
|
|
87
|
+
* Attaches a detached container to the document service.
|
|
88
|
+
*/
|
|
89
|
+
attachDetachedContainer(container: IContainer): Promise<void>;
|
|
81
90
|
/**
|
|
82
91
|
* Loads a container using the default document id
|
|
83
92
|
*/
|
|
@@ -180,12 +189,12 @@ export declare class EventAndErrorTrackingLogger implements ITelemetryBaseLogger
|
|
|
180
189
|
constructor(baseLogger: ITelemetryBaseLogger);
|
|
181
190
|
private readonly expectedEvents;
|
|
182
191
|
private readonly unexpectedErrors;
|
|
183
|
-
registerExpectedEvent(...orderedExpectedEvents:
|
|
192
|
+
registerExpectedEvent(...orderedExpectedEvents: ITelemetryGenericEventExt[]): void;
|
|
184
193
|
send(event: ITelemetryBaseEvent): void;
|
|
185
194
|
reportAndClearTrackedEvents(): {
|
|
186
195
|
expectedNotFound: ({
|
|
187
196
|
index: number;
|
|
188
|
-
event:
|
|
197
|
+
event: ITelemetryGenericEventExt | undefined;
|
|
189
198
|
} | undefined)[];
|
|
190
199
|
unexpectedErrors: ITelemetryBaseEvent[];
|
|
191
200
|
};
|
|
@@ -261,6 +270,14 @@ export declare class TestObjectProvider implements ITestObjectProvider {
|
|
|
261
270
|
* {@inheritDoc ITestObjectProvider.createContainer}
|
|
262
271
|
*/
|
|
263
272
|
createContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>): Promise<IContainer>;
|
|
273
|
+
/**
|
|
274
|
+
* {@inheritdoc ITestObjectProvider.createDetachedContainer}
|
|
275
|
+
*/
|
|
276
|
+
createDetachedContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps> | undefined): Promise<IContainer>;
|
|
277
|
+
/**
|
|
278
|
+
* {@inheritdoc ITestObjectProvider.attachDetachedContainer}
|
|
279
|
+
*/
|
|
280
|
+
attachDetachedContainer(container: IContainer): Promise<void>;
|
|
264
281
|
/**
|
|
265
282
|
* {@inheritDoc ITestObjectProvider.loadContainer}
|
|
266
283
|
*/
|
|
@@ -319,13 +336,12 @@ export declare class TestObjectProviderWithVersionedLoad implements ITestObjectP
|
|
|
319
336
|
private _urlResolver;
|
|
320
337
|
private _documentCreated;
|
|
321
338
|
/**
|
|
322
|
-
*
|
|
323
|
-
* loadCount is even then we will load with the "create" version, and if odd we load with the "load" version.
|
|
324
|
-
* After each test we will reset loadCount to 0 to ensure we always create the first container with the create version.
|
|
339
|
+
* Used to determine which APIs to use when creating a loader.
|
|
325
340
|
*
|
|
326
|
-
*
|
|
341
|
+
* The first load will always use the create APIs, and then useCreateApi will be set to false to ensure all
|
|
342
|
+
* subsequent loads use the load APIs.
|
|
327
343
|
*/
|
|
328
|
-
private
|
|
344
|
+
private useCreateApi;
|
|
329
345
|
constructor(LoaderConstructorForCreating: typeof Loader, LoaderConstructorForLoading: typeof Loader, driverForCreating: ITestDriver, driverForLoading: ITestDriver, createFluidEntryPointForCreating: (testContainerConfig?: ITestContainerConfig) => fluidEntryPoint, createFluidEntryPointForLoading: (testContainerConfig?: ITestContainerConfig) => fluidEntryPoint);
|
|
330
346
|
/**
|
|
331
347
|
* {@inheritDoc ITestObjectProvider.logger}
|
|
@@ -369,6 +385,14 @@ export declare class TestObjectProviderWithVersionedLoad implements ITestObjectP
|
|
|
369
385
|
* {@inheritDoc ITestObjectProvider.createContainer}
|
|
370
386
|
*/
|
|
371
387
|
createContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>): Promise<IContainer>;
|
|
388
|
+
/**
|
|
389
|
+
* {@inheritdoc ITestObjectProvider.createDetachedContainer}
|
|
390
|
+
*/
|
|
391
|
+
createDetachedContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps> | undefined): Promise<IContainer>;
|
|
392
|
+
/**
|
|
393
|
+
* {@inheritdoc ITestObjectProvider.attachDetachedContainer}
|
|
394
|
+
*/
|
|
395
|
+
attachDetachedContainer(container: IContainer): Promise<void>;
|
|
372
396
|
/**
|
|
373
397
|
* {@inheritDoc ITestObjectProvider.loadContainer}
|
|
374
398
|
*/
|
|
@@ -403,7 +427,6 @@ export declare class TestObjectProviderWithVersionedLoad implements ITestObjectP
|
|
|
403
427
|
* {@inheritDoc ITestObjectProvider.resetLoaderContainerTracker}
|
|
404
428
|
*/
|
|
405
429
|
resetLoaderContainerTracker(syncSummarizerClients?: boolean): void;
|
|
406
|
-
private nextLoaderShouldCreate;
|
|
407
430
|
}
|
|
408
431
|
/**
|
|
409
432
|
* @internal
|