@fluidframework/test-utils 2.23.0-323641 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/TestSummaryUtils.d.ts +2 -2
- package/dist/TestSummaryUtils.d.ts.map +1 -1
- package/dist/TestSummaryUtils.js +17 -17
- package/dist/TestSummaryUtils.js.map +1 -1
- package/dist/containerRuntimeFactories.d.ts +80 -0
- package/dist/containerRuntimeFactories.d.ts.map +1 -0
- package/dist/containerRuntimeFactories.js +94 -0
- package/dist/containerRuntimeFactories.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/localCodeLoader.d.ts.map +1 -1
- package/dist/localCodeLoader.js +6 -4
- package/dist/localCodeLoader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +42 -10
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js +9 -7
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
- package/lib/TestSummaryUtils.d.ts +2 -2
- package/lib/TestSummaryUtils.d.ts.map +1 -1
- package/lib/TestSummaryUtils.js +8 -8
- package/lib/TestSummaryUtils.js.map +1 -1
- package/lib/containerRuntimeFactories.d.ts +80 -0
- package/lib/containerRuntimeFactories.d.ts.map +1 -0
- package/lib/containerRuntimeFactories.js +92 -0
- package/lib/containerRuntimeFactories.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/localCodeLoader.d.ts.map +1 -1
- package/lib/localCodeLoader.js +3 -1
- package/lib/localCodeLoader.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +42 -10
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js +9 -7
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
- package/package.json +23 -24
- package/src/TestSummaryUtils.ts +9 -6
- package/src/containerRuntimeFactories.ts +183 -0
- package/src/index.ts +5 -1
- package/src/localCodeLoader.ts +4 -1
- package/src/packageVersion.ts +1 -1
- package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +57 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testContainerRuntimeFactoryWithDefaultDataStore.d.ts","sourceRoot":"","sources":["../src/testContainerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"testContainerRuntimeFactoryWithDefaultDataStore.d.ts","sourceRoot":"","sources":["../src/testContainerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EACN,sBAAsB,EACtB,kCAAkC,EAClC,MAAM,8CAA8C,CAAC;AAUtD;;;;GAIG;AACH,MAAM,WAAW,gDAAgD;IAChE,QAAQ,CAAC,cAAc,EAAE,sBAAsB,CAAC;IAChD;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,kCAAkC,CAAC;IAE7D;;OAEG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,KAAK,CAAC;IAErC;;;OAGG;IAEH,QAAQ,CAAC,eAAe,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAEnD;;OAEG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAEnD;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CAClF;AAED;;;;GAIG;AACH,MAAM,MAAM,sDAAsD,GAAG,KACpE,KAAK,EAAE,gDAAgD,KACnD,eAAe,CAAC;AAErB;;;;;;GAMG;AACH,eAAO,MAAM,iDAAiD,SACvD,sDAAsD,aACjD,gDAAgD,KACzD,eAuBF,CAAC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ContainerRuntimeFactoryWithDefaultDataStore } from "@fluidframework/aqueduct/internal";
|
|
6
5
|
const getDefaultFluidObject = async (runtime) => {
|
|
7
6
|
const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
|
|
8
7
|
if (entryPoint === undefined) {
|
|
@@ -11,18 +10,21 @@ const getDefaultFluidObject = async (runtime) => {
|
|
|
11
10
|
return entryPoint.get();
|
|
12
11
|
};
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* This function is purely needed for back-compat as the constructor argument structure of
|
|
15
|
+
* `ContainerRuntimeFactoryWithDefaultDataStore` was changed.
|
|
16
|
+
*
|
|
15
17
|
* @internal
|
|
16
18
|
*/
|
|
17
|
-
export const createContainerRuntimeFactoryWithDefaultDataStore = (
|
|
19
|
+
export const createContainerRuntimeFactoryWithDefaultDataStore = (ctor, ctorProps) => {
|
|
18
20
|
try {
|
|
19
|
-
return new
|
|
21
|
+
return new ctor(ctorProps);
|
|
20
22
|
}
|
|
21
23
|
catch (err) {
|
|
22
|
-
// IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older ContainerRuntimeFactoryWithDefaultDataStore
|
|
23
|
-
const { defaultFactory, registryEntries, dependencyContainer, requestHandlers, runtimeOptions, provideEntryPoint, } =
|
|
24
|
+
// IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older `ContainerRuntimeFactoryWithDefaultDataStore`s
|
|
25
|
+
const { defaultFactory, registryEntries, dependencyContainer, requestHandlers, runtimeOptions, provideEntryPoint, } = ctorProps;
|
|
24
26
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
25
|
-
return new
|
|
27
|
+
return new ctor(defaultFactory, registryEntries, dependencyContainer, requestHandlers, runtimeOptions, provideEntryPoint ?? getDefaultFluidObject);
|
|
26
28
|
}
|
|
27
29
|
};
|
|
28
30
|
//# sourceMappingURL=testContainerRuntimeFactoryWithDefaultDataStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testContainerRuntimeFactoryWithDefaultDataStore.js","sourceRoot":"","sources":["../src/testContainerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"testContainerRuntimeFactoryWithDefaultDataStore.js","sourceRoot":"","sources":["../src/testContainerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,MAAM,qBAAqB,GAAG,KAAK,EAAE,OAA0B,EAAE,EAAE;IAClE,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC;IAC1E,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC;AACzB,CAAC,CAAC;AA+CF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iDAAiD,GAAG,CAChE,IAA4D,EAC5D,SAA2D,EACzC,EAAE;IACpB,IAAI,CAAC;QACJ,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,sJAAsJ;QACtJ,MAAM,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,iBAAiB,GACjB,GAAG,SAAS,CAAC;QACd,+DAA+D;QAC/D,OAAO,IAAK,IAAY,CACvB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,iBAAiB,IAAI,qBAAqB,CAC1C,CAAC;IACH,CAAC;AACF,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport { IContainerRuntimeOptions } from \"@fluidframework/container-runtime/internal\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\n// eslint-disable-next-line import/no-deprecated\nimport { RuntimeRequestHandler } from \"@fluidframework/request-handler/internal\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nconst getDefaultFluidObject = async (runtime: IContainerRuntime) => {\n\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(\"default\");\n\tif (entryPoint === undefined) {\n\t\tthrow new Error(\"default dataStore must exist\");\n\t}\n\treturn entryPoint.get();\n};\n\n/**\n * {@link ContainerRuntimeFactoryWithDefaultDataStoreConstructor} input properties.\n *\n * @internal\n */\nexport interface ContainerRuntimeFactoryWithDefaultDataStoreProps {\n\treadonly defaultFactory: IFluidDataStoreFactory;\n\t/**\n\t * The data store registry for containers produced.\n\t */\n\treadonly registryEntries: NamedFluidDataStoreRegistryEntries;\n\n\t/**\n\t * @deprecated Do not use. This strictly exists for backwards compatibility.\n\t */\n\treadonly dependencyContainer?: never;\n\n\t/**\n\t * Request handlers for containers produced.\n\t * @deprecated Will be removed once Loader LTS version is \"2.0.0-internal.7.0.0\". Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\treadonly requestHandlers?: RuntimeRequestHandler[];\n\n\t/**\n\t * The runtime options passed to the IContainerRuntime when instantiating it\n\t */\n\treadonly runtimeOptions?: IContainerRuntimeOptions;\n\n\t/**\n\t * Function that will initialize the entryPoint of the IContainerRuntime instances\n\t * created with this factory\n\t */\n\treadonly provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;\n}\n\n/**\n * {@link @fluidframework/container-definitions#IRuntimeFactory} construct signature.\n *\n * @internal\n */\nexport type ContainerRuntimeFactoryWithDefaultDataStoreConstructor = new (\n\tprops: ContainerRuntimeFactoryWithDefaultDataStoreProps,\n) => IRuntimeFactory;\n\n/**\n * @remarks\n * This function is purely needed for back-compat as the constructor argument structure of\n * `ContainerRuntimeFactoryWithDefaultDataStore` was changed.\n *\n * @internal\n */\nexport const createContainerRuntimeFactoryWithDefaultDataStore = (\n\tctor: ContainerRuntimeFactoryWithDefaultDataStoreConstructor,\n\tctorProps: ContainerRuntimeFactoryWithDefaultDataStoreProps,\n): IRuntimeFactory => {\n\ttry {\n\t\treturn new ctor(ctorProps);\n\t} catch (err) {\n\t\t// IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older `ContainerRuntimeFactoryWithDefaultDataStore`s\n\t\tconst {\n\t\t\tdefaultFactory,\n\t\t\tregistryEntries,\n\t\t\tdependencyContainer,\n\t\t\trequestHandlers,\n\t\t\truntimeOptions,\n\t\t\tprovideEntryPoint,\n\t\t} = ctorProps;\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn new (ctor as any)(\n\t\t\tdefaultFactory,\n\t\t\tregistryEntries,\n\t\t\tdependencyContainer,\n\t\t\trequestHandlers,\n\t\t\truntimeOptions,\n\t\t\tprovideEntryPoint ?? getDefaultFluidObject,\n\t\t);\n\t}\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/test-utils",
|
|
3
|
-
"version": "2.23.0
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"description": "Utilities for Fluid tests",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -67,26 +67,25 @@
|
|
|
67
67
|
"temp-directory": "nyc/.nyc_output"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@fluid-internal/test-driver-definitions": "2.23.0
|
|
71
|
-
"@fluidframework/
|
|
72
|
-
"@fluidframework/container-
|
|
73
|
-
"@fluidframework/container-
|
|
74
|
-
"@fluidframework/container-runtime": "2.23.0
|
|
75
|
-
"@fluidframework/
|
|
76
|
-
"@fluidframework/core-
|
|
77
|
-
"@fluidframework/
|
|
78
|
-
"@fluidframework/datastore": "2.23.0
|
|
79
|
-
"@fluidframework/
|
|
80
|
-
"@fluidframework/driver-
|
|
81
|
-
"@fluidframework/driver
|
|
82
|
-
"@fluidframework/
|
|
83
|
-
"@fluidframework/
|
|
84
|
-
"@fluidframework/
|
|
85
|
-
"@fluidframework/
|
|
86
|
-
"@fluidframework/
|
|
87
|
-
"@fluidframework/runtime-
|
|
88
|
-
"@fluidframework/
|
|
89
|
-
"@fluidframework/telemetry-utils": "2.23.0-323641",
|
|
70
|
+
"@fluid-internal/test-driver-definitions": "~2.23.0",
|
|
71
|
+
"@fluidframework/container-definitions": "~2.23.0",
|
|
72
|
+
"@fluidframework/container-loader": "~2.23.0",
|
|
73
|
+
"@fluidframework/container-runtime": "~2.23.0",
|
|
74
|
+
"@fluidframework/container-runtime-definitions": "~2.23.0",
|
|
75
|
+
"@fluidframework/core-interfaces": "~2.23.0",
|
|
76
|
+
"@fluidframework/core-utils": "~2.23.0",
|
|
77
|
+
"@fluidframework/datastore": "~2.23.0",
|
|
78
|
+
"@fluidframework/datastore-definitions": "~2.23.0",
|
|
79
|
+
"@fluidframework/driver-definitions": "~2.23.0",
|
|
80
|
+
"@fluidframework/driver-utils": "~2.23.0",
|
|
81
|
+
"@fluidframework/local-driver": "~2.23.0",
|
|
82
|
+
"@fluidframework/map": "~2.23.0",
|
|
83
|
+
"@fluidframework/odsp-driver": "~2.23.0",
|
|
84
|
+
"@fluidframework/request-handler": "~2.23.0",
|
|
85
|
+
"@fluidframework/routerlicious-driver": "~2.23.0",
|
|
86
|
+
"@fluidframework/runtime-definitions": "~2.23.0",
|
|
87
|
+
"@fluidframework/runtime-utils": "~2.23.0",
|
|
88
|
+
"@fluidframework/telemetry-utils": "~2.23.0",
|
|
90
89
|
"best-random": "^1.0.0",
|
|
91
90
|
"debug": "^4.3.4",
|
|
92
91
|
"mocha": "^10.2.0",
|
|
@@ -95,10 +94,10 @@
|
|
|
95
94
|
"devDependencies": {
|
|
96
95
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
97
96
|
"@biomejs/biome": "~1.9.3",
|
|
98
|
-
"@fluid-internal/mocha-test-setup": "2.23.0
|
|
99
|
-
"@fluid-tools/build-cli": "^0.
|
|
97
|
+
"@fluid-internal/mocha-test-setup": "~2.23.0",
|
|
98
|
+
"@fluid-tools/build-cli": "^0.54.0",
|
|
100
99
|
"@fluidframework/build-common": "^2.0.3",
|
|
101
|
-
"@fluidframework/build-tools": "^0.
|
|
100
|
+
"@fluidframework/build-tools": "^0.54.0",
|
|
102
101
|
"@fluidframework/eslint-config-fluid": "^5.7.3",
|
|
103
102
|
"@fluidframework/test-utils-previous": "npm:@fluidframework/test-utils@2.22.0",
|
|
104
103
|
"@microsoft/api-extractor": "7.47.8",
|
package/src/TestSummaryUtils.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ContainerRuntimeFactoryWithDefaultDataStore } from "@fluidframework/aqueduct/internal";
|
|
7
6
|
import {
|
|
8
7
|
IContainer,
|
|
9
8
|
IHostLoader,
|
|
@@ -30,8 +29,13 @@ import {
|
|
|
30
29
|
} from "@fluidframework/runtime-definitions/internal";
|
|
31
30
|
|
|
32
31
|
import { createTestConfigProvider } from "./TestConfigs.js";
|
|
32
|
+
// eslint-disable-next-line import/no-deprecated
|
|
33
|
+
import { ContainerRuntimeFactoryWithDefaultDataStore } from "./containerRuntimeFactories.js";
|
|
33
34
|
import { waitForContainerConnection } from "./containerUtils.js";
|
|
34
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
type ContainerRuntimeFactoryWithDefaultDataStoreConstructor,
|
|
37
|
+
createContainerRuntimeFactoryWithDefaultDataStore,
|
|
38
|
+
} from "./testContainerRuntimeFactoryWithDefaultDataStore.js";
|
|
35
39
|
import { ITestContainerConfig, ITestObjectProvider } from "./testObjectProvider.js";
|
|
36
40
|
import { timeoutAwait } from "./timeoutUtils.js";
|
|
37
41
|
|
|
@@ -118,13 +122,14 @@ export async function createSummarizerFromFactory(
|
|
|
118
122
|
container: IContainer,
|
|
119
123
|
dataStoreFactory: IFluidDataStoreFactory,
|
|
120
124
|
summaryVersion?: string,
|
|
121
|
-
containerRuntimeFactoryType
|
|
125
|
+
containerRuntimeFactoryType?: ContainerRuntimeFactoryWithDefaultDataStoreConstructor,
|
|
122
126
|
registryEntries?: NamedFluidDataStoreRegistryEntries,
|
|
123
127
|
logger?: ITelemetryBaseLogger,
|
|
124
128
|
configProvider: IConfigProviderBase = createTestConfigProvider(),
|
|
125
129
|
): Promise<{ container: IContainer; summarizer: ISummarizer }> {
|
|
126
130
|
const runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(
|
|
127
|
-
|
|
131
|
+
// eslint-disable-next-line import/no-deprecated
|
|
132
|
+
containerRuntimeFactoryType ?? ContainerRuntimeFactoryWithDefaultDataStore,
|
|
128
133
|
{
|
|
129
134
|
defaultFactory: dataStoreFactory,
|
|
130
135
|
registryEntries: registryEntries ?? [
|
|
@@ -182,10 +187,8 @@ export async function createSummarizer(
|
|
|
182
187
|
*/
|
|
183
188
|
export async function summarizeNow(
|
|
184
189
|
summarizer: ISummarizer,
|
|
185
|
-
// eslint-disable-next-line import/no-deprecated
|
|
186
190
|
inputs: string | IOnDemandSummarizeOptions = "end-to-end test",
|
|
187
191
|
): Promise<SummaryInfo> {
|
|
188
|
-
// eslint-disable-next-line import/no-deprecated
|
|
189
192
|
const options: IOnDemandSummarizeOptions =
|
|
190
193
|
typeof inputs === "string" ? { reason: inputs } : inputs;
|
|
191
194
|
const result = summarizer.summarizeOnDemand(options);
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
IContainerContext,
|
|
8
|
+
IRuntime,
|
|
9
|
+
} from "@fluidframework/container-definitions/internal";
|
|
10
|
+
import {
|
|
11
|
+
FluidDataStoreRegistry,
|
|
12
|
+
loadContainerRuntime,
|
|
13
|
+
type IContainerRuntimeOptions,
|
|
14
|
+
} from "@fluidframework/container-runtime/internal";
|
|
15
|
+
import type {
|
|
16
|
+
IContainerRuntime,
|
|
17
|
+
// eslint-disable-next-line import/no-deprecated
|
|
18
|
+
IContainerRuntimeWithResolveHandle_Deprecated,
|
|
19
|
+
} from "@fluidframework/container-runtime-definitions/internal";
|
|
20
|
+
import type { FluidObject, IRequest, IResponse } from "@fluidframework/core-interfaces";
|
|
21
|
+
import {
|
|
22
|
+
// eslint-disable-next-line import/no-deprecated
|
|
23
|
+
type RuntimeRequestHandler,
|
|
24
|
+
// eslint-disable-next-line import/no-deprecated
|
|
25
|
+
buildRuntimeRequestHandler,
|
|
26
|
+
} from "@fluidframework/request-handler/internal";
|
|
27
|
+
import type {
|
|
28
|
+
IFluidDataStoreFactory,
|
|
29
|
+
IFluidDataStoreRegistry,
|
|
30
|
+
IProvideFluidDataStoreRegistry,
|
|
31
|
+
NamedFluidDataStoreRegistryEntries,
|
|
32
|
+
} from "@fluidframework/runtime-definitions/internal";
|
|
33
|
+
import { RequestParser, RuntimeFactoryHelper } from "@fluidframework/runtime-utils/internal";
|
|
34
|
+
|
|
35
|
+
const defaultDataStoreId = "default";
|
|
36
|
+
|
|
37
|
+
async function getDefaultFluidObject(runtime: IContainerRuntime): Promise<FluidObject> {
|
|
38
|
+
const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
|
|
39
|
+
if (entryPoint === undefined) {
|
|
40
|
+
throw new Error("default dataStore must exist");
|
|
41
|
+
}
|
|
42
|
+
return entryPoint.get();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* {@link ContainerRuntimeFactoryWithDefaultDataStore} construction properties.
|
|
47
|
+
*
|
|
48
|
+
* @deprecated See notice on {@link ContainerRuntimeFactoryWithDefaultDataStore}.
|
|
49
|
+
*/
|
|
50
|
+
export interface ContainerRuntimeFactoryWithDefaultDataStoreProps {
|
|
51
|
+
readonly defaultFactory: IFluidDataStoreFactory;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The data store registry for containers produced.
|
|
55
|
+
*/
|
|
56
|
+
readonly registryEntries: NamedFluidDataStoreRegistryEntries;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The runtime options passed to the IContainerRuntime when instantiating it
|
|
60
|
+
*/
|
|
61
|
+
readonly runtimeOptions?: IContainerRuntimeOptions;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Function that will initialize the entryPoint of the IContainerRuntime instances
|
|
65
|
+
* created with this factory
|
|
66
|
+
*/
|
|
67
|
+
readonly provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A ContainerRuntimeFactory that initializes Containers with a single default data store, which can be requested from
|
|
72
|
+
* the container with an empty URL.
|
|
73
|
+
*
|
|
74
|
+
* @deprecated
|
|
75
|
+
* Do not reference this type directly. It will be removed in the future.
|
|
76
|
+
* E.g. use {@link IRuntimeFactory} instead.
|
|
77
|
+
*/
|
|
78
|
+
export class ContainerRuntimeFactoryWithDefaultDataStore
|
|
79
|
+
extends RuntimeFactoryHelper
|
|
80
|
+
implements IProvideFluidDataStoreRegistry
|
|
81
|
+
{
|
|
82
|
+
public static readonly defaultDataStoreId = defaultDataStoreId;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreRegistry.IFluidDataStoreRegistry}
|
|
86
|
+
*/
|
|
87
|
+
public get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {
|
|
88
|
+
return this.registry;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
protected readonly defaultFactory: IFluidDataStoreFactory;
|
|
92
|
+
|
|
93
|
+
private readonly registry: IFluidDataStoreRegistry;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.registryEntries}
|
|
97
|
+
*/
|
|
98
|
+
private readonly registryEntries: NamedFluidDataStoreRegistryEntries;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.runtimeOptions}
|
|
102
|
+
*/
|
|
103
|
+
private readonly runtimeOptions?: IContainerRuntimeOptions;
|
|
104
|
+
|
|
105
|
+
// eslint-disable-next-line import/no-deprecated
|
|
106
|
+
private readonly requestHandlers: readonly RuntimeRequestHandler[];
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.provideEntryPoint}
|
|
110
|
+
*/
|
|
111
|
+
private readonly provideEntryPoint: (runtime: IContainerRuntime) => Promise<FluidObject>;
|
|
112
|
+
|
|
113
|
+
public constructor(props: ContainerRuntimeFactoryWithDefaultDataStoreProps) {
|
|
114
|
+
super();
|
|
115
|
+
|
|
116
|
+
const getDefaultObject = async (
|
|
117
|
+
request: IRequest,
|
|
118
|
+
runtime: IContainerRuntime,
|
|
119
|
+
): Promise<IResponse | undefined> => {
|
|
120
|
+
const parser = RequestParser.create(request);
|
|
121
|
+
if (parser.pathParts.length === 0) {
|
|
122
|
+
// This cast is safe as loadContainerRuntime is called in the base class
|
|
123
|
+
// eslint-disable-next-line import/no-deprecated
|
|
124
|
+
return (runtime as IContainerRuntimeWithResolveHandle_Deprecated).resolveHandle({
|
|
125
|
+
url: `/${defaultDataStoreId}${parser.query}`,
|
|
126
|
+
headers: request.headers,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return undefined; // continue search
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
this.defaultFactory = props.defaultFactory;
|
|
133
|
+
this.registryEntries = props.registryEntries;
|
|
134
|
+
this.runtimeOptions = props.runtimeOptions;
|
|
135
|
+
this.provideEntryPoint = props.provideEntryPoint ?? getDefaultFluidObject;
|
|
136
|
+
this.requestHandlers = [getDefaultObject];
|
|
137
|
+
this.registry = new FluidDataStoreRegistry(this.registryEntries);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public async instantiateFirstTime(runtime: IContainerRuntime): Promise<void> {
|
|
141
|
+
await this.containerInitializingFirstTime(runtime);
|
|
142
|
+
await this.containerHasInitialized(runtime);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public async instantiateFromExisting(runtime: IContainerRuntime): Promise<void> {
|
|
146
|
+
await this.containerHasInitialized(runtime);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public async preInitialize(
|
|
150
|
+
context: IContainerContext,
|
|
151
|
+
existing: boolean,
|
|
152
|
+
): Promise<IContainerRuntime & IRuntime> {
|
|
153
|
+
return loadContainerRuntime({
|
|
154
|
+
context,
|
|
155
|
+
existing,
|
|
156
|
+
runtimeOptions: this.runtimeOptions,
|
|
157
|
+
registryEntries: this.registryEntries,
|
|
158
|
+
containerScope: context.scope,
|
|
159
|
+
// eslint-disable-next-line import/no-deprecated
|
|
160
|
+
requestHandler: buildRuntimeRequestHandler(...this.requestHandlers),
|
|
161
|
+
provideEntryPoint: this.provideEntryPoint,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Subclasses may override containerInitializingFirstTime to perform any setup steps at the time the container
|
|
167
|
+
* is created. This likely includes creating any initial data stores that are expected to be there at the outset.
|
|
168
|
+
* @param runtime - The container runtime for the container being initialized.
|
|
169
|
+
* @virtual
|
|
170
|
+
*/
|
|
171
|
+
protected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {
|
|
172
|
+
const dataStore = await runtime.createDataStore(this.defaultFactory.type);
|
|
173
|
+
await dataStore.trySetAlias(defaultDataStoreId);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Subclasses may override containerHasInitialized to perform any steps after the container has initialized.
|
|
178
|
+
* This likely includes loading any data stores that are expected to be there at the outset.
|
|
179
|
+
* @param runtime - The container runtime for the container being initialized.
|
|
180
|
+
* @virtual
|
|
181
|
+
*/
|
|
182
|
+
protected async containerHasInitialized(runtime: IContainerRuntime): Promise<void> {}
|
|
183
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -60,4 +60,8 @@ export {
|
|
|
60
60
|
getContainerEntryPointBackCompat,
|
|
61
61
|
getDataStoreEntryPointBackCompat,
|
|
62
62
|
} from "./containerUtils.js";
|
|
63
|
-
export {
|
|
63
|
+
export {
|
|
64
|
+
type ContainerRuntimeFactoryWithDefaultDataStoreConstructor,
|
|
65
|
+
type ContainerRuntimeFactoryWithDefaultDataStoreProps,
|
|
66
|
+
createContainerRuntimeFactoryWithDefaultDataStore,
|
|
67
|
+
} from "./testContainerRuntimeFactoryWithDefaultDataStore.js";
|
package/src/localCodeLoader.ts
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
|
|
8
|
-
import { ContainerRuntimeFactoryWithDefaultDataStore } from "@fluidframework/aqueduct/internal";
|
|
9
8
|
import {
|
|
10
9
|
ICodeDetailsLoader,
|
|
11
10
|
IFluidCodeDetails,
|
|
@@ -21,6 +20,9 @@ import {
|
|
|
21
20
|
} from "@fluidframework/runtime-definitions/internal";
|
|
22
21
|
import { createDataStoreFactory } from "@fluidframework/runtime-utils/internal";
|
|
23
22
|
|
|
23
|
+
// eslint-disable-next-line import/no-deprecated
|
|
24
|
+
import { ContainerRuntimeFactoryWithDefaultDataStore } from "./containerRuntimeFactories.js";
|
|
25
|
+
|
|
24
26
|
/**
|
|
25
27
|
* @internal
|
|
26
28
|
*/
|
|
@@ -73,6 +75,7 @@ export class LocalCodeLoader implements ICodeDetailsLoader {
|
|
|
73
75
|
fluidModule = {
|
|
74
76
|
fluidExport: {
|
|
75
77
|
...maybeExport,
|
|
78
|
+
// eslint-disable-next-line import/no-deprecated
|
|
76
79
|
IRuntimeFactory: new ContainerRuntimeFactoryWithDefaultDataStore({
|
|
77
80
|
defaultFactory,
|
|
78
81
|
registryEntries: [[defaultFactory.type, Promise.resolve(defaultFactory)]],
|
package/src/packageVersion.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
|
|
7
7
|
import { IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
|
|
8
8
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
|
|
9
9
|
import { FluidObject } from "@fluidframework/core-interfaces";
|
|
@@ -23,25 +23,65 @@ const getDefaultFluidObject = async (runtime: IContainerRuntime) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* {@link ContainerRuntimeFactoryWithDefaultDataStoreConstructor} input properties.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export interface ContainerRuntimeFactoryWithDefaultDataStoreProps {
|
|
31
|
+
readonly defaultFactory: IFluidDataStoreFactory;
|
|
32
|
+
/**
|
|
33
|
+
* The data store registry for containers produced.
|
|
34
|
+
*/
|
|
35
|
+
readonly registryEntries: NamedFluidDataStoreRegistryEntries;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated Do not use. This strictly exists for backwards compatibility.
|
|
39
|
+
*/
|
|
40
|
+
readonly dependencyContainer?: never;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Request handlers for containers produced.
|
|
44
|
+
* @deprecated Will be removed once Loader LTS version is "2.0.0-internal.7.0.0". Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
45
|
+
*/
|
|
46
|
+
// eslint-disable-next-line import/no-deprecated
|
|
47
|
+
readonly requestHandlers?: RuntimeRequestHandler[];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The runtime options passed to the IContainerRuntime when instantiating it
|
|
51
|
+
*/
|
|
52
|
+
readonly runtimeOptions?: IContainerRuntimeOptions;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Function that will initialize the entryPoint of the IContainerRuntime instances
|
|
56
|
+
* created with this factory
|
|
57
|
+
*/
|
|
58
|
+
readonly provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* {@link @fluidframework/container-definitions#IRuntimeFactory} construct signature.
|
|
63
|
+
*
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
export type ContainerRuntimeFactoryWithDefaultDataStoreConstructor = new (
|
|
67
|
+
props: ContainerRuntimeFactoryWithDefaultDataStoreProps,
|
|
68
|
+
) => IRuntimeFactory;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @remarks
|
|
72
|
+
* This function is purely needed for back-compat as the constructor argument structure of
|
|
73
|
+
* `ContainerRuntimeFactoryWithDefaultDataStore` was changed.
|
|
74
|
+
*
|
|
27
75
|
* @internal
|
|
28
76
|
*/
|
|
29
77
|
export const createContainerRuntimeFactoryWithDefaultDataStore = (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
registryEntries: NamedFluidDataStoreRegistryEntries;
|
|
34
|
-
dependencyContainer?: any;
|
|
35
|
-
// eslint-disable-next-line import/no-deprecated
|
|
36
|
-
requestHandlers?: RuntimeRequestHandler[];
|
|
37
|
-
runtimeOptions?: IContainerRuntimeOptions;
|
|
38
|
-
provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;
|
|
39
|
-
},
|
|
40
|
-
): ContainerRuntimeFactoryWithDefaultDataStore => {
|
|
78
|
+
ctor: ContainerRuntimeFactoryWithDefaultDataStoreConstructor,
|
|
79
|
+
ctorProps: ContainerRuntimeFactoryWithDefaultDataStoreProps,
|
|
80
|
+
): IRuntimeFactory => {
|
|
41
81
|
try {
|
|
42
|
-
return new
|
|
82
|
+
return new ctor(ctorProps);
|
|
43
83
|
} catch (err) {
|
|
44
|
-
// IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older ContainerRuntimeFactoryWithDefaultDataStore
|
|
84
|
+
// IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older `ContainerRuntimeFactoryWithDefaultDataStore`s
|
|
45
85
|
const {
|
|
46
86
|
defaultFactory,
|
|
47
87
|
registryEntries,
|
|
@@ -49,9 +89,9 @@ export const createContainerRuntimeFactoryWithDefaultDataStore = (
|
|
|
49
89
|
requestHandlers,
|
|
50
90
|
runtimeOptions,
|
|
51
91
|
provideEntryPoint,
|
|
52
|
-
} =
|
|
92
|
+
} = ctorProps;
|
|
53
93
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
54
|
-
return new (
|
|
94
|
+
return new (ctor as any)(
|
|
55
95
|
defaultFactory,
|
|
56
96
|
registryEntries,
|
|
57
97
|
dependencyContainer,
|