@fluidframework/test-utils 2.0.0-internal.7.4.0 → 2.0.0-internal.8.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/CHANGELOG.md +18 -0
- package/README.md +3 -3
- package/api-report/test-utils.api.md +1 -3
- package/dist/TestSummaryUtils.d.ts.map +1 -1
- package/dist/TestSummaryUtils.js +0 -2
- package/dist/TestSummaryUtils.js.map +1 -1
- package/dist/localCodeLoader.d.ts.map +1 -1
- package/dist/localCodeLoader.js +0 -2
- package/dist/localCodeLoader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/test-utils-untrimmed.d.ts +0 -7
- package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
- package/dist/testContainerRuntimeFactory.js +26 -3
- package/dist/testContainerRuntimeFactory.js.map +1 -1
- package/dist/testFluidObject.d.ts +0 -7
- package/dist/testFluidObject.d.ts.map +1 -1
- package/dist/testFluidObject.js +4 -13
- package/dist/testFluidObject.js.map +1 -1
- package/lib/test-utils-untrimmed.d.ts +0 -7
- package/package.json +25 -22
- package/src/TestSummaryUtils.ts +0 -4
- package/src/localCodeLoader.ts +0 -7
- package/src/packageVersion.ts +1 -1
- package/src/testContainerRuntimeFactory.ts +66 -7
- package/src/testFluidObject.ts +4 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @fluidframework/test-utils
|
|
2
2
|
|
|
3
|
+
## 2.0.0-internal.8.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- data-object-base: Removed IFluidRouter from DataObject interfaces and classes [9a451d4946](https://github.com/microsoft/FluidFramework/commits/9a451d4946b5c51a52e4d1ab5bf51e7b285b0d74)
|
|
8
|
+
|
|
9
|
+
The `IFluidRouter` property has been removed from a number of DataObject related classes:
|
|
10
|
+
|
|
11
|
+
- `PureDataObject`
|
|
12
|
+
- `LazyLoadedDataObject`
|
|
13
|
+
- `TestFluidObject`
|
|
14
|
+
|
|
15
|
+
Please migrate to the new `entryPoint` pattern or use the relevant `request` method as necessary.
|
|
16
|
+
|
|
17
|
+
See
|
|
18
|
+
[Removing-IFluidRouter.md](https://github.com/microsoft/FluidFramework/blob/main/packages/common/core-interfaces/Removing-IFluidRouter.md)
|
|
19
|
+
for more details.
|
|
20
|
+
|
|
3
21
|
## 2.0.0-internal.7.4.0
|
|
4
22
|
|
|
5
23
|
Dependency updates only.
|
package/README.md
CHANGED
|
@@ -145,10 +145,10 @@ The typical usage for testing a Fluid object is as follows:
|
|
|
145
145
|
|
|
146
146
|
> We used the same `IFluidCodeDetails` that was used to create the `Loader` in step 3.
|
|
147
147
|
|
|
148
|
-
6. Get the `Fluid object (TestFluidObject)` by using `
|
|
148
|
+
6. Get the `Fluid object (TestFluidObject)` by using `getEntryPoint()` API on `IContainer`. Then get the `DDS` to test:
|
|
149
149
|
|
|
150
150
|
```typescript
|
|
151
|
-
const fluidObject = await
|
|
151
|
+
const fluidObject = await container.getEntryPoint();
|
|
152
152
|
const sharedString = await fluidObject.getSharedObject<SharedString>("sharedString");
|
|
153
153
|
```
|
|
154
154
|
|
|
@@ -163,7 +163,7 @@ The typical usage for testing a Fluid object is as follows:
|
|
|
163
163
|
urlResolver,
|
|
164
164
|
);
|
|
165
165
|
const container2 = await loader2.resolver({ url: documentUrl });
|
|
166
|
-
const fluidObject = await
|
|
166
|
+
const fluidObject = await container2.getEntryPoint();
|
|
167
167
|
const sharedString2 = await fluidObject2.getSharedObject<SharedString>("sharedString");
|
|
168
168
|
```
|
|
169
169
|
> It is important to use the same `ILocalDeltaConnectionServer` to create the `Loader` and the same `documentId` to load the `Container`. This will make sure that we load the `Container` that was created earlier and do not create a new one.
|
|
@@ -278,13 +278,11 @@ export class TestFluidObject implements ITestFluidObject {
|
|
|
278
278
|
get handle(): IFluidHandle<this>;
|
|
279
279
|
// (undocumented)
|
|
280
280
|
get IFluidLoadable(): this;
|
|
281
|
-
// @deprecated (undocumented)
|
|
282
|
-
get IFluidRouter(): this;
|
|
283
281
|
// (undocumented)
|
|
284
282
|
initialize(existing: boolean): Promise<void>;
|
|
285
283
|
// (undocumented)
|
|
286
284
|
get ITestFluidObject(): this;
|
|
287
|
-
//
|
|
285
|
+
// (undocumented)
|
|
288
286
|
request(request: IRequest): Promise<IResponse>;
|
|
289
287
|
// (undocumented)
|
|
290
288
|
root: ISharedMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestSummaryUtils.d.ts","sourceRoot":"","sources":["../src/TestSummaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2CAA2C,EAAE,MAAM,0BAA0B,CAAC;AAEvF,OAAO,EAAE,UAAU,EAA6B,MAAM,uCAAuC,CAAC;AAC9F,OAAO,EACN,yBAAyB,EACzB,WAAW,EAEX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACN,oBAAoB,EAGpB,mBAAmB,EACnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,
|
|
1
|
+
{"version":3,"file":"TestSummaryUtils.d.ts","sourceRoot":"","sources":["../src/TestSummaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2CAA2C,EAAE,MAAM,0BAA0B,CAAC;AAEvF,OAAO,EAAE,UAAU,EAA6B,MAAM,uCAAuC,CAAC;AAC9F,OAAO,EACN,yBAAyB,EACzB,WAAW,EAEX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACN,oBAAoB,EAGpB,mBAAmB,EACnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACN,sBAAsB,EACtB,kCAAkC,EAClC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAsDjF;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAChD,QAAQ,EAAE,mBAAmB,EAC7B,SAAS,EAAE,UAAU,EACrB,gBAAgB,EAAE,sBAAsB,EACxC,cAAc,CAAC,EAAE,MAAM,EACvB,2BAA2B,qDAA8C,EACzE,eAAe,CAAC,EAAE,kCAAkC,EACpD,MAAM,CAAC,EAAE,oBAAoB,EAC7B,cAAc,GAAE,mBAA0C,GACxD,OAAO,CAAC;IAAE,SAAS,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,WAAW,CAAA;CAAE,CAAC,CAiB7D;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACrC,QAAQ,EAAE,mBAAmB,EAC7B,SAAS,EAAE,UAAU,EACrB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,cAAc,CAAC,EAAE,MAAM,EACvB,MAAM,CAAC,EAAE,oBAAoB,GAC3B,OAAO,CAAC;IAAE,SAAS,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,WAAW,CAAA;CAAE,CAAC,CAe7D;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CACjC,UAAU,EAAE,WAAW,EACvB,MAAM,GAAE,MAAM,GAAG,yBAA6C;;;;GAoC9D"}
|
package/dist/TestSummaryUtils.js
CHANGED
|
@@ -57,13 +57,11 @@ const defaultSummaryOptions = {
|
|
|
57
57
|
* @internal
|
|
58
58
|
*/
|
|
59
59
|
async function createSummarizerFromFactory(provider, container, dataStoreFactory, summaryVersion, containerRuntimeFactoryType = aqueduct_1.ContainerRuntimeFactoryWithDefaultDataStore, registryEntries, logger, configProvider = (0, TestConfigs_1.mockConfigProvider)()) {
|
|
60
|
-
const innerRequestHandler = async (request, runtime) => runtime.IFluidHandleContext.resolveHandle(request);
|
|
61
60
|
const runtimeFactory = (0, testContainerRuntimeFactoryWithDefaultDataStore_1.createContainerRuntimeFactoryWithDefaultDataStore)(containerRuntimeFactoryType, {
|
|
62
61
|
defaultFactory: dataStoreFactory,
|
|
63
62
|
registryEntries: registryEntries ?? [
|
|
64
63
|
[dataStoreFactory.type, Promise.resolve(dataStoreFactory)],
|
|
65
64
|
],
|
|
66
|
-
requestHandlers: [innerRequestHandler],
|
|
67
65
|
runtimeOptions: { summaryOptions: defaultSummaryOptions },
|
|
68
66
|
});
|
|
69
67
|
const loader = provider.createLoader([[provider.defaultCodeDetails, runtimeFactory]], {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestSummaryUtils.js","sourceRoot":"","sources":["../src/TestSummaryUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAAuF;AACvF,2DAAoD;AACpD,iFAA8F;AAY9F,2EAAkE;AAOlE,+CAAmD;AACnD,qDAA8D;AAC9D,iDAA8C;AAC9C,uHAAsH;AAEtH,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C,KAAK,UAAU,oBAAoB,CAClC,SAAqB,EACrB,MAAmB,EACnB,cAAuB;IAEvB,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IACvD,IAAI,WAAW,KAAK,SAAS,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;KAC7C;IAED,MAAM,OAAO,GAAa;QACzB,OAAO,EAAE;YACR,CAAC,oCAAY,CAAC,KAAK,CAAC,EAAE,KAAK;YAC3B,CAAC,oCAAY,CAAC,aAAa,CAAC,EAAE;gBAC7B,YAAY,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;gBACpC,IAAI,EAAE,oBAAoB;aAC1B;YACD,CAAC,iCAAY,CAAC,iBAAiB,CAAC,EAAE,IAAI;YACtC,CAAC,oCAAY,CAAC,OAAO,CAAC,EAAE,cAAc;SACtC;QACD,GAAG,EAAE,WAAW;KAChB,CAAC;IACF,MAAM,mBAAmB,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,IAAA,2CAA0B,EAAC,mBAAmB,CAAC,CAAC;IAEtD,MAAM,WAAW,GAChB,MAAM,m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M,EACL,YAAY,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,EACpC,yDAAyD,CACzD,CAAC;IACF,IAAA,mBAAM,EAAC,YAAY,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,2BAA2B,CAAC,CAAC;IAEjF,MAAM,eAAe,GAAG,MAAM,IAAA,2BAAY,EAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACxE,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE;QAC7B,MAAM,eAAe,CAAC,KAAK,CAAC;KAC5B;IAED,MAAM,aAAa,GAAG,MAAM,IAAA,2BAAY,EAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAC1E,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;QAC3B,MAAM,aAAa,CAAC,KAAK,CAAC;KAC1B;IAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAE1D,OAAO;QACN,WAAW,EAAE,YAAY,CAAC,IAAI,CAAC,WAAW;QAC1C,cAAc,EAAE,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM;QAC/D,aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,uBAAuB;KACxD,CAAC;AACH,CAAC;AAtCD,oCAsCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ContainerRuntimeFactoryWithDefaultDataStore } from \"@fluidframework/aqueduct\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IContainer, IHostLoader, LoaderHeader } from \"@fluidframework/container-definitions\";\nimport {\n\tIOnDemandSummarizeOptions,\n\tISummarizer,\n\tISummaryRuntimeOptions,\n} from \"@fluidframework/container-runtime\";\nimport {\n\tITelemetryBaseLogger,\n\tFluidObject,\n\tIRequest,\n\tIConfigProviderBase,\n} from \"@fluidframework/core-interfaces\";\nimport { DriverHeader } from \"@fluidframework/driver-definitions\";\nimport {\n\tIContainerRuntimeBase,\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\nimport { ITestContainerConfig, ITestObjectProvider } from \"./testObjectProvider\";\nimport { mockConfigProvider } from \"./TestConfigs\";\nimport { waitForContainerConnection } from \"./containerUtils\";\nimport { timeoutAwait } from \"./timeoutUtils\";\nimport { createContainerRuntimeFactoryWithDefaultDataStore } from \"./testContainerRuntimeFactoryWithDefaultDataStore\";\n\nconst summarizerClientType = \"summarizer\";\n\nasync function createSummarizerCore(\n\tcontainer: IContainer,\n\tloader: IHostLoader,\n\tsummaryVersion?: string,\n) {\n\tconst absoluteUrl = await container.getAbsoluteUrl(\"\");\n\tif (absoluteUrl === undefined) {\n\t\tthrow new Error(\"URL could not be resolved\");\n\t}\n\n\tconst request: IRequest = {\n\t\theaders: {\n\t\t\t[LoaderHeader.cache]: false,\n\t\t\t[LoaderHeader.clientDetails]: {\n\t\t\t\tcapabilities: { interactive: false },\n\t\t\t\ttype: summarizerClientType,\n\t\t\t},\n\t\t\t[DriverHeader.summarizingClient]: true,\n\t\t\t[LoaderHeader.version]: summaryVersion,\n\t\t},\n\t\turl: absoluteUrl,\n\t};\n\tconst summarizerContainer = await loader.resolve(request);\n\tawait waitForContainerConnection(summarizerContainer);\n\n\tconst fluidObject: FluidObject<ISummarizer> | undefined =\n\t\tawait summarizerContainer.getEntryPoint();\n\tif (fluidObject?.ISummarizer === undefined) {\n\t\tthrow new Error(\"Fluid object does not implement ISummarizer\");\n\t}\n\n\treturn {\n\t\tcontainer: summarizerContainer,\n\t\tsummarizer: fluidObject.ISummarizer,\n\t};\n}\n\nconst defaultSummaryOptions: ISummaryRuntimeOptions = {\n\tsummaryConfigOverrides: {\n\t\tstate: \"disableHeuristics\",\n\t\tmaxAckWaitTime: 20000, // Some of the AFR tests take a long time to ack.\n\t\tmaxOpsSinceLastSummary: 7000,\n\t\tinitialSummarizerDelayMs: 0,\n\t},\n};\n\n/**\n * Creates a summarizer client from the given container and data store factory, and returns the summarizer client's\n * IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n * @internal\n */\nexport async function createSummarizerFromFactory(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tdataStoreFactory: IFluidDataStoreFactory,\n\tsummaryVersion?: string,\n\tcontainerRuntimeFactoryType = ContainerRuntimeFactoryWithDefaultDataStore,\n\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\tlogger?: ITelemetryBaseLogger,\n\tconfigProvider: IConfigProviderBase = mockConfigProvider(),\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst innerRequestHandler = async (request: IRequest, runtime: IContainerRuntimeBase) =>\n\t\truntime.IFluidHandleContext.resolveHandle(request);\n\tconst runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(\n\t\tcontainerRuntimeFactoryType,\n\t\t{\n\t\t\tdefaultFactory: dataStoreFactory,\n\t\t\tregistryEntries: registryEntries ?? [\n\t\t\t\t[dataStoreFactory.type, Promise.resolve(dataStoreFactory)],\n\t\t\t],\n\t\t\trequestHandlers: [innerRequestHandler],\n\t\t\truntimeOptions: { summaryOptions: defaultSummaryOptions },\n\t\t},\n\t);\n\n\tconst loader = provider.createLoader([[provider.defaultCodeDetails, runtimeFactory]], {\n\t\tconfigProvider,\n\t\tlogger,\n\t});\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Creates a summarizer client from the given container and returns the summarizer client's IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n *\n * Can pass in a test config provider to enable/disable features.\n * @internal\n */\nexport async function createSummarizer(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tconfig?: ITestContainerConfig,\n\tsummaryVersion?: string,\n\tlogger?: ITelemetryBaseLogger,\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst testContainerConfig: ITestContainerConfig = {\n\t\t...config,\n\t\truntimeOptions: {\n\t\t\t...config?.runtimeOptions,\n\t\t\tsummaryOptions: config?.runtimeOptions?.summaryOptions ?? defaultSummaryOptions,\n\t\t},\n\t\tloaderProps: {\n\t\t\t...config?.loaderProps,\n\t\t\tconfigProvider: config?.loaderProps?.configProvider ?? mockConfigProvider(),\n\t\t\tlogger,\n\t\t},\n\t};\n\tconst loader = provider.makeTestLoader(testContainerConfig);\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Summarizes on demand and returns the summary tree, the version number and the reference sequence number of the\n * submitted summary.\n *\n * @param summarizer - The ISummarizer to use to summarize on demand\n * @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.\n * Defaults to the reason \"end-to-end test\".\n * @internal\n */\nexport async function summarizeNow(\n\tsummarizer: ISummarizer,\n\tinputs: string | IOnDemandSummarizeOptions = \"end-to-end test\",\n) {\n\tconst options: IOnDemandSummarizeOptions =\n\t\ttypeof inputs === \"string\" ? { reason: inputs } : inputs;\n\tconst result = summarizer.summarizeOnDemand(options);\n\n\tconst submitResult = await timeoutAwait(result.summarySubmitted);\n\tif (!submitResult.success) {\n\t\tif (typeof submitResult.error !== \"string\") {\n\t\t\tsubmitResult.error.data = submitResult.data;\n\t\t}\n\t\tthrow submitResult.error;\n\t}\n\tassert(\n\t\tsubmitResult.data.stage === \"submit\",\n\t\t\"on-demand summary submitted data stage should be submit\",\n\t);\n\tassert(submitResult.data.summaryTree !== undefined, \"summary tree should exist\");\n\n\tconst broadcastResult = await timeoutAwait(result.summaryOpBroadcasted);\n\tif (!broadcastResult.success) {\n\t\tthrow broadcastResult.error;\n\t}\n\n\tconst ackNackResult = await timeoutAwait(result.receivedSummaryAckOrNack);\n\tif (!ackNackResult.success) {\n\t\tthrow ackNackResult.error;\n\t}\n\n\tawait new Promise((resolve) => process.nextTick(resolve));\n\n\treturn {\n\t\tsummaryTree: submitResult.data.summaryTree,\n\t\tsummaryVersion: ackNackResult.data.summaryAckOp.contents.handle,\n\t\tsummaryRefSeq: submitResult.data.referenceSequenceNumber,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TestSummaryUtils.js","sourceRoot":"","sources":["../src/TestSummaryUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAAuF;AACvF,2DAAoD;AACpD,iFAA8F;AAY9F,2EAAkE;AAMlE,+CAAmD;AACnD,qDAA8D;AAC9D,iDAA8C;AAC9C,uHAAsH;AAEtH,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C,KAAK,UAAU,oBAAoB,CAClC,SAAqB,EACrB,MAAmB,EACnB,cAAuB;IAEvB,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IACvD,IAAI,WAAW,KAAK,SAAS,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;KAC7C;IAED,MAAM,OAAO,GAAa;QACzB,OAAO,EAAE;YACR,CAAC,oCAAY,CAAC,KAAK,CAAC,EAAE,KAAK;YAC3B,CAAC,oCAAY,CAAC,aAAa,CAAC,EAAE;gBAC7B,YAAY,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;gBACpC,IAAI,EAAE,oBAAoB;aAC1B;YACD,CAAC,iCAAY,CAAC,iBAAiB,CAAC,EAAE,IAAI;YACtC,CAAC,oCAAY,CAAC,OAAO,CAAC,EAAE,cAAc;SACtC;QACD,GAAG,EAAE,WAAW;KAChB,CAAC;IACF,MAAM,mBAAmB,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,IAAA,2CAA0B,EAAC,mBAAmB,CAAC,CAAC;IAEtD,MAAM,WAAW,GAChB,MAAM,mBAAmB,CAAC,aAAa,EAAE,CAAC;IAC3C,IAAI,WAAW,EAAE,WAAW,KAAK,SAAS,EAAE;QAC3C,MAAM,IAAI,KAAK,CAAC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OAAO,EAAE;QAC7B,MAAM,eAAe,CAAC,KAAK,CAAC;KAC5B;IAED,MAAM,aAAa,GAAG,MAAM,IAAA,2BAAY,EAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAC1E,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;QAC3B,MAAM,aAAa,CAAC,KAAK,CAAC;KAC1B;IAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAE1D,OAAO;QACN,WAAW,EAAE,YAAY,CAAC,IAAI,CAAC,WAAW;QAC1C,cAAc,EAAE,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM;QAC/D,aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,uBAAuB;KACxD,CAAC;AACH,CAAC;AAtCD,oCAsCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ContainerRuntimeFactoryWithDefaultDataStore } from \"@fluidframework/aqueduct\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IContainer, IHostLoader, LoaderHeader } from \"@fluidframework/container-definitions\";\nimport {\n\tIOnDemandSummarizeOptions,\n\tISummarizer,\n\tISummaryRuntimeOptions,\n} from \"@fluidframework/container-runtime\";\nimport {\n\tITelemetryBaseLogger,\n\tFluidObject,\n\tIRequest,\n\tIConfigProviderBase,\n} from \"@fluidframework/core-interfaces\";\nimport { DriverHeader } from \"@fluidframework/driver-definitions\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\nimport { ITestContainerConfig, ITestObjectProvider } from \"./testObjectProvider\";\nimport { mockConfigProvider } from \"./TestConfigs\";\nimport { waitForContainerConnection } from \"./containerUtils\";\nimport { timeoutAwait } from \"./timeoutUtils\";\nimport { createContainerRuntimeFactoryWithDefaultDataStore } from \"./testContainerRuntimeFactoryWithDefaultDataStore\";\n\nconst summarizerClientType = \"summarizer\";\n\nasync function createSummarizerCore(\n\tcontainer: IContainer,\n\tloader: IHostLoader,\n\tsummaryVersion?: string,\n) {\n\tconst absoluteUrl = await container.getAbsoluteUrl(\"\");\n\tif (absoluteUrl === undefined) {\n\t\tthrow new Error(\"URL could not be resolved\");\n\t}\n\n\tconst request: IRequest = {\n\t\theaders: {\n\t\t\t[LoaderHeader.cache]: false,\n\t\t\t[LoaderHeader.clientDetails]: {\n\t\t\t\tcapabilities: { interactive: false },\n\t\t\t\ttype: summarizerClientType,\n\t\t\t},\n\t\t\t[DriverHeader.summarizingClient]: true,\n\t\t\t[LoaderHeader.version]: summaryVersion,\n\t\t},\n\t\turl: absoluteUrl,\n\t};\n\tconst summarizerContainer = await loader.resolve(request);\n\tawait waitForContainerConnection(summarizerContainer);\n\n\tconst fluidObject: FluidObject<ISummarizer> | undefined =\n\t\tawait summarizerContainer.getEntryPoint();\n\tif (fluidObject?.ISummarizer === undefined) {\n\t\tthrow new Error(\"Fluid object does not implement ISummarizer\");\n\t}\n\n\treturn {\n\t\tcontainer: summarizerContainer,\n\t\tsummarizer: fluidObject.ISummarizer,\n\t};\n}\n\nconst defaultSummaryOptions: ISummaryRuntimeOptions = {\n\tsummaryConfigOverrides: {\n\t\tstate: \"disableHeuristics\",\n\t\tmaxAckWaitTime: 20000, // Some of the AFR tests take a long time to ack.\n\t\tmaxOpsSinceLastSummary: 7000,\n\t\tinitialSummarizerDelayMs: 0,\n\t},\n};\n\n/**\n * Creates a summarizer client from the given container and data store factory, and returns the summarizer client's\n * IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n * @internal\n */\nexport async function createSummarizerFromFactory(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tdataStoreFactory: IFluidDataStoreFactory,\n\tsummaryVersion?: string,\n\tcontainerRuntimeFactoryType = ContainerRuntimeFactoryWithDefaultDataStore,\n\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\tlogger?: ITelemetryBaseLogger,\n\tconfigProvider: IConfigProviderBase = mockConfigProvider(),\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(\n\t\tcontainerRuntimeFactoryType,\n\t\t{\n\t\t\tdefaultFactory: dataStoreFactory,\n\t\t\tregistryEntries: registryEntries ?? [\n\t\t\t\t[dataStoreFactory.type, Promise.resolve(dataStoreFactory)],\n\t\t\t],\n\t\t\truntimeOptions: { summaryOptions: defaultSummaryOptions },\n\t\t},\n\t);\n\n\tconst loader = provider.createLoader([[provider.defaultCodeDetails, runtimeFactory]], {\n\t\tconfigProvider,\n\t\tlogger,\n\t});\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Creates a summarizer client from the given container and returns the summarizer client's IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n *\n * Can pass in a test config provider to enable/disable features.\n * @internal\n */\nexport async function createSummarizer(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tconfig?: ITestContainerConfig,\n\tsummaryVersion?: string,\n\tlogger?: ITelemetryBaseLogger,\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst testContainerConfig: ITestContainerConfig = {\n\t\t...config,\n\t\truntimeOptions: {\n\t\t\t...config?.runtimeOptions,\n\t\t\tsummaryOptions: config?.runtimeOptions?.summaryOptions ?? defaultSummaryOptions,\n\t\t},\n\t\tloaderProps: {\n\t\t\t...config?.loaderProps,\n\t\t\tconfigProvider: config?.loaderProps?.configProvider ?? mockConfigProvider(),\n\t\t\tlogger,\n\t\t},\n\t};\n\tconst loader = provider.makeTestLoader(testContainerConfig);\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Summarizes on demand and returns the summary tree, the version number and the reference sequence number of the\n * submitted summary.\n *\n * @param summarizer - The ISummarizer to use to summarize on demand\n * @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.\n * Defaults to the reason \"end-to-end test\".\n * @internal\n */\nexport async function summarizeNow(\n\tsummarizer: ISummarizer,\n\tinputs: string | IOnDemandSummarizeOptions = \"end-to-end test\",\n) {\n\tconst options: IOnDemandSummarizeOptions =\n\t\ttypeof inputs === \"string\" ? { reason: inputs } : inputs;\n\tconst result = summarizer.summarizeOnDemand(options);\n\n\tconst submitResult = await timeoutAwait(result.summarySubmitted);\n\tif (!submitResult.success) {\n\t\tif (typeof submitResult.error !== \"string\") {\n\t\t\tsubmitResult.error.data = submitResult.data;\n\t\t}\n\t\tthrow submitResult.error;\n\t}\n\tassert(\n\t\tsubmitResult.data.stage === \"submit\",\n\t\t\"on-demand summary submitted data stage should be submit\",\n\t);\n\tassert(submitResult.data.summaryTree !== undefined, \"summary tree should exist\");\n\n\tconst broadcastResult = await timeoutAwait(result.summaryOpBroadcasted);\n\tif (!broadcastResult.success) {\n\t\tthrow broadcastResult.error;\n\t}\n\n\tconst ackNackResult = await timeoutAwait(result.receivedSummaryAckOrNack);\n\tif (!ackNackResult.success) {\n\t\tthrow ackNackResult.error;\n\t}\n\n\tawait new Promise((resolve) => process.nextTick(resolve));\n\n\treturn {\n\t\tsummaryTree: submitResult.data.summaryTree,\n\t\tsummaryVersion: ackNackResult.data.summaryAckOp.contents.handle,\n\t\tsummaryRefSeq: submitResult.data.referenceSequenceNumber,\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localCodeLoader.d.ts","sourceRoot":"","sources":["../src/localCodeLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,sBAAsB,EACtB,YAAY,EACZ,gCAAgC,EAChC,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"localCodeLoader.d.ts","sourceRoot":"","sources":["../src/localCodeLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,sBAAsB,EACtB,YAAY,EACZ,gCAAgC,EAChC,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,6BAA6B,EAC7B,8BAA8B,EAC9B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAC9C,sBAAsB,GACrB,6BAA6B,GAC7B,8BAA8B,GAC9B,gCAAgC,CACjC,CAAC;AAGF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,yBAAyB,GAAG,YAAY,CAAC;AAEvE;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,kBAAkB;IACzD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA8C;gBAG/E,cAAc,EAAE,QAAQ,CAAC,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC,EAC9D,cAAc,CAAC,EAAE,wBAAwB;IA+C1C;;;;OAIG;IACU,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAe9E"}
|
package/dist/localCodeLoader.js
CHANGED
|
@@ -36,7 +36,6 @@ class LocalCodeLoader {
|
|
|
36
36
|
else {
|
|
37
37
|
(0, assert_1.default)(maybeExport.IFluidDataStoreFactory !== undefined);
|
|
38
38
|
const defaultFactory = (0, runtime_utils_1.createDataStoreFactory)("default", maybeExport.IFluidDataStoreFactory);
|
|
39
|
-
const innerRequestHandler = async (request, runtime) => runtime.IFluidHandleContext.resolveHandle(request);
|
|
40
39
|
fluidModule = {
|
|
41
40
|
fluidExport: {
|
|
42
41
|
...maybeExport,
|
|
@@ -45,7 +44,6 @@ class LocalCodeLoader {
|
|
|
45
44
|
registryEntries: [
|
|
46
45
|
[defaultFactory.type, Promise.resolve(defaultFactory)],
|
|
47
46
|
],
|
|
48
|
-
requestHandlers: [innerRequestHandler],
|
|
49
47
|
runtimeOptions,
|
|
50
48
|
}),
|
|
51
49
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localCodeLoader.js","sourceRoot":"","sources":["../src/localCodeLoader.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,oDAA4B;AAC5B,uDAAuF;
|
|
1
|
+
{"version":3,"file":"localCodeLoader.js","sourceRoot":"","sources":["../src/localCodeLoader.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,oDAA4B;AAC5B,uDAAuF;AAavF,iEAAuE;AAmBvE;;;;GAIG;AACH,MAAa,eAAe;IAG3B,YACC,cAA8D,EAC9D,cAAyC;QAJzB,sBAAiB,GAAG,IAAI,GAAG,EAAmC,CAAC;QAM/E,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE;YACnC,sEAAsE;YACtE,8EAA8E;YAC9E,qGAAqG;YACrG,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACxB,MAAM,KAAK,GACV,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;gBACjC,CAAC,CAAC,MAAM,CAAC,OAAO;gBAChB,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACvD,IAAI,WAAW,GAAG,KAAK,CAAC,CAAC,CAAiB,CAAC;YAC3C,IAAI,WAAW,EAAE,WAAW,KAAK,SAAS,EAAE;gBAC3C,MAAM,WAAW,GAAG,WAAwC,CAAC;gBAE7D,IAAI,WAAW,CAAC,eAAe,KAAK,SAAS,EAAE;oBAC9C,WAAW,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;iBAC3C;qBAAM;oBACN,IAAA,gBAAM,EAAC,WAAW,CAAC,sBAAsB,KAAK,SAAS,CAAC,CAAC;oBACzD,MAAM,cAAc,GAAG,IAAA,sCAAsB,EAC5C,SAAS,EACT,WAAW,CAAC,sBAAsB,CAClC,CAAC;oBACF,WAAW,GAAG;wBACb,WAAW,EAAE;4BACZ,GAAG,WAAW;4BACd,eAAe,EAAE,IAAI,sDAA2C,CAAC;gCAChE,cAAc;gCACd,eAAe,EAAE;oCAChB,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;iCACtD;gCACD,cAAc;6BACd,CAAC;yBACF;qBACD,CAAC;iBACF;aACD;YAED,MAAM,cAAc,GAAG;gBACtB,MAAM,EAAE,WAAW;gBACnB,OAAO,EAAE,MAAM;aACf,CAAC;YAEF,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;SAClD;IACF,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CAAC,MAAyB;QAC1C,iFAAiF;QACjF,8EAA8E;QAC9E,qGAAqG;QACrG,MAAM,KAAK,GACV,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;YACjC,CAAC,CAAC,MAAM,CAAC,OAAO;YAChB,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAEvD,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACrD,IAAI,UAAU,KAAK,SAAS,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAC;SAChD;QACD,OAAO,UAAU,CAAC;IACnB,CAAC;CACD;AAxED,0CAwEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport assert from \"assert\";\nimport { ContainerRuntimeFactoryWithDefaultDataStore } from \"@fluidframework/aqueduct\";\nimport {\n\tIProvideRuntimeFactory,\n\tIFluidModule,\n\tIProvideFluidCodeDetailsComparer,\n\tIFluidCodeDetails,\n\tICodeDetailsLoader,\n\tIFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tIProvideFluidDataStoreFactory,\n\tIProvideFluidDataStoreRegistry,\n} from \"@fluidframework/runtime-definitions\";\nimport { createDataStoreFactory } from \"@fluidframework/runtime-utils\";\nimport { IContainerRuntimeOptions } from \"@fluidframework/container-runtime\";\n\n/**\n * @internal\n */\nexport type SupportedExportInterfaces = Partial<\n\tIProvideRuntimeFactory &\n\t\tIProvideFluidDataStoreFactory &\n\t\tIProvideFluidDataStoreRegistry &\n\t\tIProvideFluidCodeDetailsComparer\n>;\n\n// Represents the entry point for a Fluid container.\n/**\n * @internal\n */\nexport type fluidEntryPoint = SupportedExportInterfaces | IFluidModule;\n\n/**\n * A simple code loader that caches a mapping of package name to a Fluid entry point.\n * On load, it retrieves the entry point matching the package name in the given code details.\n * @internal\n */\nexport class LocalCodeLoader implements ICodeDetailsLoader {\n\tprivate readonly fluidPackageCache = new Map<string, IFluidModuleWithDetails>();\n\n\tconstructor(\n\t\tpackageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,\n\t\truntimeOptions?: IContainerRuntimeOptions,\n\t) {\n\t\tfor (const entry of packageEntries) {\n\t\t\t// Store the entry point against a unique id in the fluidPackageCache.\n\t\t\t// For code details containing a package name, use the package name as the id.\n\t\t\t// For code details containing a Fluid package, create a unique id from the package name and version.\n\t\t\tconst source = entry[0];\n\t\t\tconst pkgId =\n\t\t\t\ttypeof source.package === \"string\"\n\t\t\t\t\t? source.package\n\t\t\t\t\t: `${source.package.name}@${source.package.version}`;\n\t\t\tlet fluidModule = entry[1] as IFluidModule;\n\t\t\tif (fluidModule?.fluidExport === undefined) {\n\t\t\t\tconst maybeExport = fluidModule as SupportedExportInterfaces;\n\n\t\t\t\tif (maybeExport.IRuntimeFactory !== undefined) {\n\t\t\t\t\tfluidModule = { fluidExport: maybeExport };\n\t\t\t\t} else {\n\t\t\t\t\tassert(maybeExport.IFluidDataStoreFactory !== undefined);\n\t\t\t\t\tconst defaultFactory = createDataStoreFactory(\n\t\t\t\t\t\t\"default\",\n\t\t\t\t\t\tmaybeExport.IFluidDataStoreFactory,\n\t\t\t\t\t);\n\t\t\t\t\tfluidModule = {\n\t\t\t\t\t\tfluidExport: {\n\t\t\t\t\t\t\t...maybeExport,\n\t\t\t\t\t\t\tIRuntimeFactory: new ContainerRuntimeFactoryWithDefaultDataStore({\n\t\t\t\t\t\t\t\tdefaultFactory,\n\t\t\t\t\t\t\t\tregistryEntries: [\n\t\t\t\t\t\t\t\t\t[defaultFactory.type, Promise.resolve(defaultFactory)],\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\truntimeOptions,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst runtimeFactory = {\n\t\t\t\tmodule: fluidModule,\n\t\t\t\tdetails: source,\n\t\t\t};\n\n\t\t\tthis.fluidPackageCache.set(pkgId, runtimeFactory);\n\t\t}\n\t}\n\n\t/**\n\t * It finds the entry point for the package name in the given source and return it\n\t * as a Fluid module.\n\t * @param source - Details of where to find chaincode\n\t */\n\tpublic async load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails> {\n\t\t// Get the entry point for from the fluidPackageCache for the given code details.\n\t\t// For code details containing a package name, use the package name as the id.\n\t\t// For code details containing a Fluid package, create a unique id from the package name and version.\n\t\tconst pkdId =\n\t\t\ttypeof source.package === \"string\"\n\t\t\t\t? source.package\n\t\t\t\t: `${source.package.name}@${source.package.version}`;\n\n\t\tconst entryPoint = this.fluidPackageCache.get(pkdId);\n\t\tif (entryPoint === undefined) {\n\t\t\tthrow new Error(`Cannot find package ${pkdId}`);\n\t\t}\n\t\treturn entryPoint;\n\t}\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-internal.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.8.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-internal.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.8.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,sBAAsB,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-internal.
|
|
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,sBAAsB,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-internal.8.0.0\";\n"]}
|
|
@@ -594,10 +594,6 @@ export declare class TestFluidObject implements ITestFluidObject {
|
|
|
594
594
|
private readonly factoryEntriesMap;
|
|
595
595
|
get ITestFluidObject(): this;
|
|
596
596
|
get IFluidLoadable(): this;
|
|
597
|
-
/**
|
|
598
|
-
* @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
599
|
-
*/
|
|
600
|
-
get IFluidRouter(): this;
|
|
601
597
|
get handle(): IFluidHandle<this>;
|
|
602
598
|
root: ISharedMap;
|
|
603
599
|
private readonly innerHandle;
|
|
@@ -615,9 +611,6 @@ export declare class TestFluidObject implements ITestFluidObject {
|
|
|
615
611
|
* @param id - The id of the shared object to retrieve.
|
|
616
612
|
*/
|
|
617
613
|
getSharedObject<T = any>(id: string): Promise<T>;
|
|
618
|
-
/**
|
|
619
|
-
* @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
620
|
-
*/
|
|
621
614
|
request(request: IRequest): Promise<IResponse>;
|
|
622
615
|
initialize(existing: boolean): Promise<void>;
|
|
623
616
|
}
|
|
@@ -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;AAEH,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;yCAS7B,gBAAgB,GAAG,QAAQ,IAAI,CAAC;+BAiBpE,iBAAiB,YAChB,OAAO,GACf,QAAQ,QAAQ,GAAG,iBAAiB,CAAC;;;;;CAwDzC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,2BAA2B;eA3GxB,MAAM,oBACM,sBAAsB,mBACxB,wBAAwB,oBAUvB,qBAAqB,EAAE;cAZlC,MAAM;0BACM,sBAAsB;wBACxB,wBAAwB;yBAUvB,qBAAqB,EAAE;sCAKL,gBAAgB,GAAG,QAAQ,IAAI,CAAC;yCAS7B,gBAAgB,GAAG,QAAQ,IAAI,CAAC;+BAiBpE,iBAAiB,YAChB,OAAO,GACf,QAAQ,QAAQ,GAAG,iBAAiB,CAAC;;;;;CA8DoD,CAAC"}
|
|
@@ -5,10 +5,22 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.TestContainerRuntimeFactory = exports.createTestContainerRuntimeFactory = void 0;
|
|
8
|
-
const aqueduct_1 = require("@fluidframework/aqueduct");
|
|
9
8
|
const container_runtime_1 = require("@fluidframework/container-runtime");
|
|
9
|
+
// eslint-disable-next-line import/no-deprecated
|
|
10
10
|
const request_handler_1 = require("@fluidframework/request-handler");
|
|
11
11
|
const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
12
|
+
const backCompat_DefaultRouteRequestHandler = (defaultRootId) => {
|
|
13
|
+
return async (request, runtime) => {
|
|
14
|
+
const parser = runtime_utils_1.RequestParser.create(request);
|
|
15
|
+
if (parser.pathParts.length === 0) {
|
|
16
|
+
return runtime.IFluidHandleContext.resolveHandle({
|
|
17
|
+
url: `/${defaultRootId}${parser.query}`,
|
|
18
|
+
headers: request.headers,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return undefined; // continue search
|
|
22
|
+
};
|
|
23
|
+
};
|
|
12
24
|
/**
|
|
13
25
|
* Create a container runtime factory class that allows you to set runtime options
|
|
14
26
|
* @internal
|
|
@@ -52,7 +64,7 @@ const createTestContainerRuntimeFactory = (containerRuntimeCtor) => {
|
|
|
52
64
|
return containerRuntimeCtor.load(context, [
|
|
53
65
|
["default", Promise.resolve(this.dataStoreFactory)],
|
|
54
66
|
[this.type, Promise.resolve(this.dataStoreFactory)],
|
|
55
|
-
], (0, request_handler_1.buildRuntimeRequestHandler)((
|
|
67
|
+
], (0, request_handler_1.buildRuntimeRequestHandler)(backCompat_DefaultRouteRequestHandler("default"), ...this.requestHandlers), this.runtimeOptions, context.scope, existing);
|
|
56
68
|
}
|
|
57
69
|
const provideEntryPoint = async (runtime) => {
|
|
58
70
|
const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
|
|
@@ -61,13 +73,24 @@ const createTestContainerRuntimeFactory = (containerRuntimeCtor) => {
|
|
|
61
73
|
}
|
|
62
74
|
return entryPoint.get();
|
|
63
75
|
};
|
|
76
|
+
const getDefaultObject = async (request, runtime) => {
|
|
77
|
+
const parser = runtime_utils_1.RequestParser.create(request);
|
|
78
|
+
if (parser.pathParts.length === 0) {
|
|
79
|
+
// This cast is safe as ContainerRuntime.loadRuntime is called below
|
|
80
|
+
return runtime.resolveHandle({
|
|
81
|
+
url: `/default${parser.query}`,
|
|
82
|
+
headers: request.headers,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return undefined; // continue search
|
|
86
|
+
};
|
|
64
87
|
return containerRuntimeCtor.loadRuntime({
|
|
65
88
|
context,
|
|
66
89
|
registryEntries: [
|
|
67
90
|
["default", Promise.resolve(this.dataStoreFactory)],
|
|
68
91
|
[this.type, Promise.resolve(this.dataStoreFactory)],
|
|
69
92
|
],
|
|
70
|
-
requestHandler: (0, request_handler_1.buildRuntimeRequestHandler)(
|
|
93
|
+
requestHandler: (0, request_handler_1.buildRuntimeRequestHandler)(getDefaultObject, ...this.requestHandlers),
|
|
71
94
|
provideEntryPoint,
|
|
72
95
|
// ! This prop is needed for back-compat. Can be removed in 2.0.0-internal.8.0.0
|
|
73
96
|
initializeEntryPoint: provideEntryPoint,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testContainerRuntimeFactory.js","sourceRoot":"","sources":["../src/testContainerRuntimeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
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,OAAO,SAAS,CAAC,CAAC,kBAAkB;IACrC,CAAC,CAAC;AACH,CAAC,CAAC;AAcF;;;GAGG;AACI,MAAM,iCAAiC,GAAG,CAChD,oBAA6C,EAC5C,EAAE;IACH,OAAO,KAAM,SAAQ,oCAAoB;QACxC,YACQ,IAAY,EACZ,gB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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"]}
|
|
@@ -21,10 +21,6 @@ export declare class TestFluidObject implements ITestFluidObject {
|
|
|
21
21
|
private readonly factoryEntriesMap;
|
|
22
22
|
get ITestFluidObject(): this;
|
|
23
23
|
get IFluidLoadable(): this;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
26
|
-
*/
|
|
27
|
-
get IFluidRouter(): this;
|
|
28
24
|
get handle(): IFluidHandle<this>;
|
|
29
25
|
root: ISharedMap;
|
|
30
26
|
private readonly innerHandle;
|
|
@@ -42,9 +38,6 @@ export declare class TestFluidObject implements ITestFluidObject {
|
|
|
42
38
|
* @param id - The id of the shared object to retrieve.
|
|
43
39
|
*/
|
|
44
40
|
getSharedObject<T = any>(id: string): Promise<T>;
|
|
45
|
-
/**
|
|
46
|
-
* @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
47
|
-
*/
|
|
48
41
|
request(request: IRequest): Promise<IResponse>;
|
|
49
42
|
initialize(existing: boolean): Promise<void>;
|
|
50
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testFluidObject.d.ts","sourceRoot":"","sources":["../src/testFluidObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
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,cAAc,CAAC;AAEhD;;;;;GAKG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;aAyBtC,OAAO,EAAE,sBAAsB;aAC/B,OAAO,EAAE,sBAAsB;aAC/B,OAAO,EAAE,sBAAsB;IAC/C,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IA3BnC,IAAW,gBAAgB,SAE1B;IAED,IAAW,cAAc,SAExB;IAED,IAAW,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAEtC;IAEM,IAAI,EAAG,UAAU,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,WAAW,CAA4B;IAE/C;;;;;;OAMG;gBAEc,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,sBAAsB,EAC9B,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC;IAKjE;;;OAGG;IACU,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAehD,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAM9C,UAAU,CAAC,QAAQ,EAAE,OAAO;CA2BzC;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC,CAAC,MAAM,GAAG,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,sBAAuB,YAAW,sBAAsB;IAYnE,OAAO,CAAC,QAAQ,CAAC,cAAc;aACf,IAAI;IAZrB,IAAW,sBAAsB,SAEhC;IAED;;;;;OAKG;gBAEe,cAAc,EAAE,sBAAsB,EACvC,IAAI,SAA2B;IAGnC,oBAAoB,CAChC,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,OAAO,GACf,OAAO,CAAC,qBAAqB,CAAC;CAmDjC"}
|
package/dist/testFluidObject.js
CHANGED
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.TestFluidObjectFactory = exports.TestFluidObject = void 0;
|
|
8
|
-
// eslint-disable-next-line import/no-deprecated
|
|
9
|
-
const aqueduct_1 = require("@fluidframework/aqueduct");
|
|
10
8
|
const datastore_1 = require("@fluidframework/datastore");
|
|
11
9
|
const map_1 = require("@fluidframework/map");
|
|
12
10
|
const core_utils_1 = require("@fluidframework/core-utils");
|
|
11
|
+
const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
13
12
|
/**
|
|
14
13
|
* A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load.
|
|
15
14
|
* The shared objects can be retrieved by passing the key of the entry to getSharedObject.
|
|
@@ -23,12 +22,6 @@ class TestFluidObject {
|
|
|
23
22
|
get IFluidLoadable() {
|
|
24
23
|
return this;
|
|
25
24
|
}
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
28
|
-
*/
|
|
29
|
-
get IFluidRouter() {
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
25
|
get handle() {
|
|
33
26
|
return this.innerHandle;
|
|
34
27
|
}
|
|
@@ -62,12 +55,10 @@ class TestFluidObject {
|
|
|
62
55
|
}
|
|
63
56
|
throw new Error(`Shared object with id ${id} not found.`);
|
|
64
57
|
}
|
|
65
|
-
/**
|
|
66
|
-
* @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
67
|
-
*/
|
|
68
58
|
async request(request) {
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
return request.url === "" || request.url === "/" || request.url.startsWith("/?")
|
|
60
|
+
? { mimeType: "fluid/object", status: 200, value: this }
|
|
61
|
+
: (0, runtime_utils_1.create404Response)(request);
|
|
71
62
|
}
|
|
72
63
|
async initialize(existing) {
|
|
73
64
|
const doInitialization = async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testFluidObject.js","sourceRoot":"","sources":["../src/testFluidObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gDAAgD;AAChD,uDAA4E;AAE5E,yDAImC;AACnC,6CAA4D;AAO5D,2DAAoD;AAGpD;;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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\n// eslint-disable-next-line import/no-deprecated\nimport { defaultFluidObjectRequestHandler } from \"@fluidframework/aqueduct\";\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 { 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\t/**\n\t * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\tpublic get IFluidRouter() {\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\t/**\n\t * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\treturn defaultFluidObjectRequestHandler(this, 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":"","s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AAK,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\";\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"]}
|
|
@@ -594,10 +594,6 @@ export declare class TestFluidObject implements ITestFluidObject {
|
|
|
594
594
|
private readonly factoryEntriesMap;
|
|
595
595
|
get ITestFluidObject(): this;
|
|
596
596
|
get IFluidLoadable(): this;
|
|
597
|
-
/**
|
|
598
|
-
* @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
599
|
-
*/
|
|
600
|
-
get IFluidRouter(): this;
|
|
601
597
|
get handle(): IFluidHandle<this>;
|
|
602
598
|
root: ISharedMap;
|
|
603
599
|
private readonly innerHandle;
|
|
@@ -615,9 +611,6 @@ export declare class TestFluidObject implements ITestFluidObject {
|
|
|
615
611
|
* @param id - The id of the shared object to retrieve.
|
|
616
612
|
*/
|
|
617
613
|
getSharedObject<T = any>(id: string): Promise<T>;
|
|
618
|
-
/**
|
|
619
|
-
* @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
620
|
-
*/
|
|
621
614
|
request(request: IRequest): Promise<IResponse>;
|
|
622
615
|
initialize(existing: boolean): Promise<void>;
|
|
623
616
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/test-utils",
|
|
3
|
-
"version": "2.0.0-internal.
|
|
3
|
+
"version": "2.0.0-internal.8.0.0",
|
|
4
4
|
"description": "Utilities for Fluid tests",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -34,27 +34,27 @@
|
|
|
34
34
|
"temp-directory": "nyc/.nyc_output"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@fluidframework/aqueduct": ">=2.0.0-internal.
|
|
38
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.
|
|
39
|
-
"@fluidframework/container-loader": ">=2.0.0-internal.
|
|
40
|
-
"@fluidframework/container-runtime": ">=2.0.0-internal.
|
|
41
|
-
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.
|
|
42
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.
|
|
43
|
-
"@fluidframework/core-utils": ">=2.0.0-internal.
|
|
44
|
-
"@fluidframework/datastore": ">=2.0.0-internal.
|
|
45
|
-
"@fluidframework/datastore-definitions": ">=2.0.0-internal.
|
|
46
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.
|
|
47
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.
|
|
48
|
-
"@fluidframework/local-driver": ">=2.0.0-internal.
|
|
49
|
-
"@fluidframework/map": ">=2.0.0-internal.
|
|
37
|
+
"@fluidframework/aqueduct": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
38
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
39
|
+
"@fluidframework/container-loader": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
40
|
+
"@fluidframework/container-runtime": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
41
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
42
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
43
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
44
|
+
"@fluidframework/datastore": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
45
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
46
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
47
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
48
|
+
"@fluidframework/local-driver": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
49
|
+
"@fluidframework/map": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
50
50
|
"@fluidframework/protocol-definitions": "^3.0.0",
|
|
51
|
-
"@fluidframework/request-handler": ">=2.0.0-internal.
|
|
52
|
-
"@fluidframework/routerlicious-driver": ">=2.0.0-internal.
|
|
53
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-internal.
|
|
54
|
-
"@fluidframework/runtime-utils": ">=2.0.0-internal.
|
|
55
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-internal.
|
|
56
|
-
"@fluidframework/test-driver-definitions": ">=2.0.0-internal.
|
|
57
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.
|
|
51
|
+
"@fluidframework/request-handler": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
52
|
+
"@fluidframework/routerlicious-driver": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
53
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
54
|
+
"@fluidframework/runtime-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
55
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
56
|
+
"@fluidframework/test-driver-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
57
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
58
58
|
"best-random": "^1.0.0",
|
|
59
59
|
"debug": "^4.3.4",
|
|
60
60
|
"uuid": "^9.0.0"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@fluidframework/build-common": "^2.0.3",
|
|
66
66
|
"@fluidframework/build-tools": "^0.28.0",
|
|
67
67
|
"@fluidframework/eslint-config-fluid": "^3.1.0",
|
|
68
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.
|
|
68
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
69
69
|
"@fluidframework/test-utils-previous": "npm:@fluidframework/test-utils@2.0.0-internal.7.2.0",
|
|
70
70
|
"@microsoft/api-extractor": "^7.38.3",
|
|
71
71
|
"@types/debug": "^4.1.5",
|
|
@@ -100,6 +100,9 @@
|
|
|
100
100
|
},
|
|
101
101
|
"typeValidation": {
|
|
102
102
|
"broken": {
|
|
103
|
+
"ClassDeclaration_TestFluidObject": {
|
|
104
|
+
"backCompat": false
|
|
105
|
+
},
|
|
103
106
|
"InterfaceDeclaration_ITestObjectProvider": {
|
|
104
107
|
"backCompat": false,
|
|
105
108
|
"forwardCompat": false
|
package/src/TestSummaryUtils.ts
CHANGED
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
} from "@fluidframework/core-interfaces";
|
|
20
20
|
import { DriverHeader } from "@fluidframework/driver-definitions";
|
|
21
21
|
import {
|
|
22
|
-
IContainerRuntimeBase,
|
|
23
22
|
IFluidDataStoreFactory,
|
|
24
23
|
NamedFluidDataStoreRegistryEntries,
|
|
25
24
|
} from "@fluidframework/runtime-definitions";
|
|
@@ -93,8 +92,6 @@ export async function createSummarizerFromFactory(
|
|
|
93
92
|
logger?: ITelemetryBaseLogger,
|
|
94
93
|
configProvider: IConfigProviderBase = mockConfigProvider(),
|
|
95
94
|
): Promise<{ container: IContainer; summarizer: ISummarizer }> {
|
|
96
|
-
const innerRequestHandler = async (request: IRequest, runtime: IContainerRuntimeBase) =>
|
|
97
|
-
runtime.IFluidHandleContext.resolveHandle(request);
|
|
98
95
|
const runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(
|
|
99
96
|
containerRuntimeFactoryType,
|
|
100
97
|
{
|
|
@@ -102,7 +99,6 @@ export async function createSummarizerFromFactory(
|
|
|
102
99
|
registryEntries: registryEntries ?? [
|
|
103
100
|
[dataStoreFactory.type, Promise.resolve(dataStoreFactory)],
|
|
104
101
|
],
|
|
105
|
-
requestHandlers: [innerRequestHandler],
|
|
106
102
|
runtimeOptions: { summaryOptions: defaultSummaryOptions },
|
|
107
103
|
},
|
|
108
104
|
);
|
package/src/localCodeLoader.ts
CHANGED
|
@@ -13,9 +13,7 @@ import {
|
|
|
13
13
|
ICodeDetailsLoader,
|
|
14
14
|
IFluidModuleWithDetails,
|
|
15
15
|
} from "@fluidframework/container-definitions";
|
|
16
|
-
import { IRequest } from "@fluidframework/core-interfaces";
|
|
17
16
|
import {
|
|
18
|
-
IContainerRuntimeBase,
|
|
19
17
|
IProvideFluidDataStoreFactory,
|
|
20
18
|
IProvideFluidDataStoreRegistry,
|
|
21
19
|
} from "@fluidframework/runtime-definitions";
|
|
@@ -71,10 +69,6 @@ export class LocalCodeLoader implements ICodeDetailsLoader {
|
|
|
71
69
|
"default",
|
|
72
70
|
maybeExport.IFluidDataStoreFactory,
|
|
73
71
|
);
|
|
74
|
-
const innerRequestHandler = async (
|
|
75
|
-
request: IRequest,
|
|
76
|
-
runtime: IContainerRuntimeBase,
|
|
77
|
-
) => runtime.IFluidHandleContext.resolveHandle(request);
|
|
78
72
|
fluidModule = {
|
|
79
73
|
fluidExport: {
|
|
80
74
|
...maybeExport,
|
|
@@ -83,7 +77,6 @@ export class LocalCodeLoader implements ICodeDetailsLoader {
|
|
|
83
77
|
registryEntries: [
|
|
84
78
|
[defaultFactory.type, Promise.resolve(defaultFactory)],
|
|
85
79
|
],
|
|
86
|
-
requestHandlers: [innerRequestHandler],
|
|
87
80
|
runtimeOptions,
|
|
88
81
|
}),
|
|
89
82
|
},
|
package/src/packageVersion.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { defaultRouteRequestHandler } from "@fluidframework/aqueduct";
|
|
7
6
|
import { IContainerContext, IRuntime } from "@fluidframework/container-definitions";
|
|
8
7
|
import {
|
|
9
8
|
ContainerRuntime,
|
|
@@ -11,9 +10,51 @@ import {
|
|
|
11
10
|
DefaultSummaryConfiguration,
|
|
12
11
|
} from "@fluidframework/container-runtime";
|
|
13
12
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
13
|
+
import {
|
|
14
|
+
FluidObject,
|
|
15
|
+
IFluidHandleContext,
|
|
16
|
+
IRequest,
|
|
17
|
+
IResponse,
|
|
18
|
+
} from "@fluidframework/core-interfaces";
|
|
19
|
+
// eslint-disable-next-line import/no-deprecated
|
|
14
20
|
import { buildRuntimeRequestHandler, RuntimeRequestHandler } from "@fluidframework/request-handler";
|
|
15
|
-
import {
|
|
16
|
-
|
|
21
|
+
import {
|
|
22
|
+
IFluidDataStoreFactory,
|
|
23
|
+
NamedFluidDataStoreRegistryEntries,
|
|
24
|
+
} from "@fluidframework/runtime-definitions";
|
|
25
|
+
import { RequestParser, RuntimeFactoryHelper } from "@fluidframework/runtime-utils";
|
|
26
|
+
|
|
27
|
+
interface backCompat_IFluidRouter {
|
|
28
|
+
IFluidRouter?: backCompat_IFluidRouter;
|
|
29
|
+
request(request: IRequest): Promise<IResponse>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const backCompat_DefaultRouteRequestHandler = (defaultRootId: string) => {
|
|
33
|
+
return async (request: IRequest, runtime: IContainerRuntime) => {
|
|
34
|
+
const parser = RequestParser.create(request);
|
|
35
|
+
if (parser.pathParts.length === 0) {
|
|
36
|
+
return (
|
|
37
|
+
runtime as any as Required<FluidObject<IFluidHandleContext>>
|
|
38
|
+
).IFluidHandleContext.resolveHandle({
|
|
39
|
+
url: `/${defaultRootId}${parser.query}`,
|
|
40
|
+
headers: request.headers,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return undefined; // continue search
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
interface backCompat_ContainerRuntime {
|
|
48
|
+
load(
|
|
49
|
+
context: IContainerContext,
|
|
50
|
+
registryEntries: NamedFluidDataStoreRegistryEntries,
|
|
51
|
+
requestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>,
|
|
52
|
+
runtimeOptions?: IContainerRuntimeOptions,
|
|
53
|
+
containerScope?: FluidObject,
|
|
54
|
+
existing?: boolean,
|
|
55
|
+
containerRuntimeCtor?: typeof ContainerRuntime,
|
|
56
|
+
): Promise<ContainerRuntime>;
|
|
57
|
+
}
|
|
17
58
|
|
|
18
59
|
/**
|
|
19
60
|
* Create a container runtime factory class that allows you to set runtime options
|
|
@@ -56,7 +97,14 @@ export const createTestContainerRuntimeFactory = (
|
|
|
56
97
|
// Note: We use the deprecated `getRootDataStore` from v1.X here to allow for cross-major version compat
|
|
57
98
|
// testing. Can be removed when we no longer support v1.X.
|
|
58
99
|
await (runtime.getAliasedDataStoreEntryPoint?.("default") ??
|
|
59
|
-
|
|
100
|
+
(
|
|
101
|
+
runtime as any as {
|
|
102
|
+
getRootDataStore(
|
|
103
|
+
id: string,
|
|
104
|
+
wait?: boolean,
|
|
105
|
+
): Promise<backCompat_IFluidRouter>;
|
|
106
|
+
}
|
|
107
|
+
).getRootDataStore("default"));
|
|
60
108
|
}
|
|
61
109
|
|
|
62
110
|
async preInitialize(
|
|
@@ -66,14 +114,14 @@ export const createTestContainerRuntimeFactory = (
|
|
|
66
114
|
if (containerRuntimeCtor.loadRuntime === undefined) {
|
|
67
115
|
// Note: We use the deprecated `load` from v1.X here to allow for cross-major version compat testing.
|
|
68
116
|
// Can be removed when we no longer support v1.X.
|
|
69
|
-
return containerRuntimeCtor.load(
|
|
117
|
+
return (containerRuntimeCtor as any as backCompat_ContainerRuntime).load(
|
|
70
118
|
context,
|
|
71
119
|
[
|
|
72
120
|
["default", Promise.resolve(this.dataStoreFactory)],
|
|
73
121
|
[this.type, Promise.resolve(this.dataStoreFactory)],
|
|
74
122
|
],
|
|
75
123
|
buildRuntimeRequestHandler(
|
|
76
|
-
|
|
124
|
+
backCompat_DefaultRouteRequestHandler("default"),
|
|
77
125
|
...this.requestHandlers,
|
|
78
126
|
),
|
|
79
127
|
this.runtimeOptions,
|
|
@@ -88,6 +136,17 @@ export const createTestContainerRuntimeFactory = (
|
|
|
88
136
|
}
|
|
89
137
|
return entryPoint.get();
|
|
90
138
|
};
|
|
139
|
+
const getDefaultObject = async (request: IRequest, runtime: IContainerRuntime) => {
|
|
140
|
+
const parser = RequestParser.create(request);
|
|
141
|
+
if (parser.pathParts.length === 0) {
|
|
142
|
+
// This cast is safe as ContainerRuntime.loadRuntime is called below
|
|
143
|
+
return (runtime as ContainerRuntime).resolveHandle({
|
|
144
|
+
url: `/default${parser.query}`,
|
|
145
|
+
headers: request.headers,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return undefined; // continue search
|
|
149
|
+
};
|
|
91
150
|
return containerRuntimeCtor.loadRuntime({
|
|
92
151
|
context,
|
|
93
152
|
registryEntries: [
|
|
@@ -95,7 +154,7 @@ export const createTestContainerRuntimeFactory = (
|
|
|
95
154
|
[this.type, Promise.resolve(this.dataStoreFactory)],
|
|
96
155
|
],
|
|
97
156
|
requestHandler: buildRuntimeRequestHandler(
|
|
98
|
-
|
|
157
|
+
getDefaultObject,
|
|
99
158
|
...this.requestHandlers,
|
|
100
159
|
),
|
|
101
160
|
provideEntryPoint,
|
package/src/testFluidObject.ts
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
// eslint-disable-next-line import/no-deprecated
|
|
7
|
-
import { defaultFluidObjectRequestHandler } from "@fluidframework/aqueduct";
|
|
8
6
|
import { IRequest, IResponse, IFluidHandle } from "@fluidframework/core-interfaces";
|
|
9
7
|
import {
|
|
10
8
|
FluidObjectHandle,
|
|
@@ -19,6 +17,7 @@ import {
|
|
|
19
17
|
} from "@fluidframework/runtime-definitions";
|
|
20
18
|
import { IFluidDataStoreRuntime, IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
21
19
|
import { assert } from "@fluidframework/core-utils";
|
|
20
|
+
import { create404Response } from "@fluidframework/runtime-utils";
|
|
22
21
|
import { ITestFluidObject } from "./interfaces";
|
|
23
22
|
|
|
24
23
|
/**
|
|
@@ -36,13 +35,6 @@ export class TestFluidObject implements ITestFluidObject {
|
|
|
36
35
|
return this;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
41
|
-
*/
|
|
42
|
-
public get IFluidRouter() {
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
38
|
public get handle(): IFluidHandle<this> {
|
|
47
39
|
return this.innerHandle;
|
|
48
40
|
}
|
|
@@ -86,12 +78,10 @@ export class TestFluidObject implements ITestFluidObject {
|
|
|
86
78
|
throw new Error(`Shared object with id ${id} not found.`);
|
|
87
79
|
}
|
|
88
80
|
|
|
89
|
-
/**
|
|
90
|
-
* @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
91
|
-
*/
|
|
92
81
|
public async request(request: IRequest): Promise<IResponse> {
|
|
93
|
-
|
|
94
|
-
|
|
82
|
+
return request.url === "" || request.url === "/" || request.url.startsWith("/?")
|
|
83
|
+
? { mimeType: "fluid/object", status: 200, value: this }
|
|
84
|
+
: create404Response(request);
|
|
95
85
|
}
|
|
96
86
|
|
|
97
87
|
public async initialize(existing: boolean) {
|