@fluidframework/test-utils 2.0.0-internal.7.2.2 → 2.0.0-internal.7.4.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 +8 -0
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +3 -3
- package/api-report/test-utils.api.md +83 -74
- package/dist/DriverWrappers.d.ts +3 -0
- package/dist/DriverWrappers.d.ts.map +1 -1
- package/dist/DriverWrappers.js +3 -0
- package/dist/DriverWrappers.js.map +1 -1
- package/dist/TestConfigs.d.ts +4 -1
- package/dist/TestConfigs.d.ts.map +1 -1
- package/dist/TestConfigs.js +3 -0
- package/dist/TestConfigs.js.map +1 -1
- package/dist/TestSummaryUtils.d.ts +4 -2
- package/dist/TestSummaryUtils.d.ts.map +1 -1
- package/dist/TestSummaryUtils.js +3 -0
- package/dist/TestSummaryUtils.js.map +1 -1
- package/dist/containerUtils.d.ts +17 -0
- package/dist/containerUtils.d.ts.map +1 -1
- package/dist/containerUtils.js +41 -1
- package/dist/containerUtils.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +6 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/loaderContainerTracker.d.ts +3 -0
- package/dist/loaderContainerTracker.d.ts.map +1 -1
- package/dist/loaderContainerTracker.js +3 -0
- package/dist/loaderContainerTracker.js.map +1 -1
- package/dist/localCodeLoader.d.ts +7 -0
- package/dist/localCodeLoader.d.ts.map +1 -1
- package/dist/localCodeLoader.js +1 -0
- package/dist/localCodeLoader.js.map +1 -1
- package/dist/localLoader.d.ts +2 -0
- package/dist/localLoader.d.ts.map +1 -1
- package/dist/localLoader.js +2 -0
- package/dist/localLoader.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/retry.d.ts +1 -0
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +1 -0
- package/dist/retry.js.map +1 -1
- package/dist/test-utils-alpha.d.ts +140 -0
- package/dist/test-utils-beta.d.ts +228 -0
- package/dist/test-utils-public.d.ts +228 -0
- package/dist/test-utils-untrimmed.d.ts +993 -0
- package/dist/testContainerRuntimeFactory.d.ts +2 -0
- package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
- package/dist/testContainerRuntimeFactory.js +35 -12
- package/dist/testContainerRuntimeFactory.js.map +1 -1
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +1 -0
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js +10 -2
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
- package/dist/testFluidObject.d.ts +5 -0
- package/dist/testFluidObject.d.ts.map +1 -1
- package/dist/testFluidObject.js +6 -3
- package/dist/testFluidObject.js.map +1 -1
- package/dist/testObjectProvider.d.ts +287 -37
- package/dist/testObjectProvider.d.ts.map +1 -1
- package/dist/testObjectProvider.js +310 -25
- package/dist/testObjectProvider.js.map +1 -1
- package/dist/timeoutUtils.d.ts +11 -0
- package/dist/timeoutUtils.d.ts.map +1 -1
- package/dist/timeoutUtils.js +5 -0
- package/dist/timeoutUtils.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/test-utils-alpha.d.ts +140 -0
- package/lib/test-utils-beta.d.ts +228 -0
- package/lib/test-utils-public.d.ts +228 -0
- package/lib/test-utils-untrimmed.d.ts +993 -0
- package/package.json +63 -35
- package/src/DriverWrappers.ts +3 -0
- package/src/TestConfigs.ts +4 -1
- package/src/TestSummaryUtils.ts +9 -2
- package/src/containerUtils.ts +42 -0
- package/src/index.ts +7 -1
- package/src/interfaces.ts +6 -0
- package/src/loaderContainerTracker.ts +3 -0
- package/src/localCodeLoader.ts +7 -0
- package/src/localLoader.ts +2 -0
- package/src/packageVersion.ts +1 -1
- package/src/retry.ts +1 -0
- package/src/testContainerRuntimeFactory.ts +40 -13
- package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +11 -0
- package/src/testFluidObject.ts +10 -10
- package/src/testObjectProvider.ts +524 -47
- package/src/timeoutUtils.ts +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/test-utils",
|
|
3
|
-
"version": "2.0.0-internal.7.
|
|
3
|
+
"version": "2.0.0-internal.7.4.0",
|
|
4
4
|
"description": "Utilities for Fluid tests",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -34,45 +34,47 @@
|
|
|
34
34
|
"temp-directory": "nyc/.nyc_output"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@fluidframework/aqueduct": ">=2.0.0-internal.7.
|
|
38
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.7.
|
|
39
|
-
"@fluidframework/container-loader": ">=2.0.0-internal.7.
|
|
40
|
-
"@fluidframework/container-runtime": ">=2.0.0-internal.7.
|
|
41
|
-
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.7.
|
|
42
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.
|
|
43
|
-
"@fluidframework/core-utils": ">=2.0.0-internal.7.
|
|
44
|
-
"@fluidframework/datastore": ">=2.0.0-internal.7.
|
|
45
|
-
"@fluidframework/datastore-definitions": ">=2.0.0-internal.7.
|
|
46
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.7.
|
|
47
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.7.
|
|
48
|
-
"@fluidframework/local-driver": ">=2.0.0-internal.7.
|
|
49
|
-
"@fluidframework/map": ">=2.0.0-internal.7.
|
|
37
|
+
"@fluidframework/aqueduct": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
38
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
39
|
+
"@fluidframework/container-loader": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
40
|
+
"@fluidframework/container-runtime": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
41
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
42
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
43
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
44
|
+
"@fluidframework/datastore": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
45
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
46
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
47
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
48
|
+
"@fluidframework/local-driver": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
49
|
+
"@fluidframework/map": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
50
50
|
"@fluidframework/protocol-definitions": "^3.0.0",
|
|
51
|
-
"@fluidframework/request-handler": ">=2.0.0-internal.7.
|
|
52
|
-
"@fluidframework/routerlicious-driver": ">=2.0.0-internal.7.
|
|
53
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-internal.7.
|
|
54
|
-
"@fluidframework/runtime-utils": ">=2.0.0-internal.7.
|
|
55
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-internal.7.
|
|
56
|
-
"@fluidframework/test-driver-definitions": ">=2.0.0-internal.7.
|
|
57
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.
|
|
51
|
+
"@fluidframework/request-handler": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
52
|
+
"@fluidframework/routerlicious-driver": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
53
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
54
|
+
"@fluidframework/runtime-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
55
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
56
|
+
"@fluidframework/test-driver-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
57
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
58
58
|
"best-random": "^1.0.0",
|
|
59
59
|
"debug": "^4.3.4",
|
|
60
60
|
"uuid": "^9.0.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@
|
|
63
|
+
"@arethetypeswrong/cli": "^0.13.3",
|
|
64
|
+
"@fluid-tools/build-cli": "^0.28.0",
|
|
64
65
|
"@fluidframework/build-common": "^2.0.3",
|
|
65
|
-
"@fluidframework/build-tools": "^0.
|
|
66
|
-
"@fluidframework/eslint-config-fluid": "^3.
|
|
67
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.
|
|
68
|
-
"@fluidframework/test-utils-previous": "npm:@fluidframework/test-utils@2.0.0-internal.7.2.
|
|
69
|
-
"@microsoft/api-extractor": "^7.
|
|
66
|
+
"@fluidframework/build-tools": "^0.28.0",
|
|
67
|
+
"@fluidframework/eslint-config-fluid": "^3.1.0",
|
|
68
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
69
|
+
"@fluidframework/test-utils-previous": "npm:@fluidframework/test-utils@2.0.0-internal.7.2.0",
|
|
70
|
+
"@microsoft/api-extractor": "^7.38.3",
|
|
70
71
|
"@types/debug": "^4.1.5",
|
|
71
72
|
"@types/diff": "^3.5.1",
|
|
72
73
|
"@types/mocha": "^9.1.1",
|
|
73
|
-
"@types/node": "^
|
|
74
|
+
"@types/node": "^18.19.0",
|
|
74
75
|
"@types/uuid": "^9.0.2",
|
|
75
76
|
"c8": "^7.7.1",
|
|
77
|
+
"copyfiles": "^2.4.1",
|
|
76
78
|
"cross-env": "^7.0.3",
|
|
77
79
|
"diff": "^3.5.0",
|
|
78
80
|
"eslint": "~8.50.0",
|
|
@@ -84,27 +86,53 @@
|
|
|
84
86
|
"rimraf": "^4.4.0",
|
|
85
87
|
"typescript": "~5.1.6"
|
|
86
88
|
},
|
|
89
|
+
"fluidBuild": {
|
|
90
|
+
"tasks": {
|
|
91
|
+
"build:docs": {
|
|
92
|
+
"dependsOn": [
|
|
93
|
+
"...",
|
|
94
|
+
"api-extractor:commonjs",
|
|
95
|
+
"api-extractor:esnext"
|
|
96
|
+
],
|
|
97
|
+
"script": false
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
87
101
|
"typeValidation": {
|
|
88
|
-
"broken": {
|
|
102
|
+
"broken": {
|
|
103
|
+
"InterfaceDeclaration_ITestObjectProvider": {
|
|
104
|
+
"backCompat": false,
|
|
105
|
+
"forwardCompat": false
|
|
106
|
+
},
|
|
107
|
+
"ClassDeclaration_TestObjectProvider": {
|
|
108
|
+
"backCompat": false,
|
|
109
|
+
"forwardCompat": false
|
|
110
|
+
}
|
|
111
|
+
}
|
|
89
112
|
},
|
|
90
113
|
"scripts": {
|
|
114
|
+
"api": "fluid-build . --task api",
|
|
115
|
+
"api-extractor:commonjs": "api-extractor run --local",
|
|
116
|
+
"api-extractor:esnext": "copyfiles -u 1 \"dist/**/*-@(alpha|beta|public|untrimmed).d.ts\" lib",
|
|
91
117
|
"build": "fluid-build . --task build",
|
|
92
118
|
"build:compile": "fluid-build . --task compile",
|
|
93
119
|
"build:compile:min": "npm run build:compile",
|
|
94
|
-
"build:docs": "
|
|
120
|
+
"build:docs": "fluid-build . --task api",
|
|
95
121
|
"build:genver": "gen-version",
|
|
96
122
|
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
123
|
+
"check:are-the-types-wrong": "attw --pack",
|
|
124
|
+
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
97
125
|
"ci:build:docs": "api-extractor run",
|
|
98
|
-
"clean": "rimraf --glob dist lib \"
|
|
126
|
+
"clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
99
127
|
"eslint": "eslint --format stylish src",
|
|
100
128
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
101
129
|
"format": "npm run prettier:fix",
|
|
102
|
-
"lint": "npm run prettier && npm run eslint",
|
|
130
|
+
"lint": "npm run prettier && npm run check:release-tags && npm run eslint",
|
|
103
131
|
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
104
|
-
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
105
|
-
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
132
|
+
"prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
133
|
+
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
106
134
|
"test": "npm run test:mocha",
|
|
107
|
-
"test:mocha": "mocha --recursive dist/test/*.spec.js --exit --project src/test/tsconfig.json -r node_modules/@fluidframework/mocha-test-setup",
|
|
135
|
+
"test:mocha": "mocha --recursive \"dist/test/*.spec.js\" --exit --project src/test/tsconfig.json -r node_modules/@fluidframework/mocha-test-setup",
|
|
108
136
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
109
137
|
"tsc": "tsc",
|
|
110
138
|
"typetests:gen": "fluid-type-test-generator",
|
package/src/DriverWrappers.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
|
17
17
|
* Wraps the given IDocumentStorageService to override the `uploadSummaryWithContext` method. It calls the
|
|
18
18
|
* `uploadSummaryCb` whenever a summary is uploaded by the client. The summary context can be updated in the
|
|
19
19
|
* callback before it is uploaded to the server.
|
|
20
|
+
* @internal
|
|
20
21
|
*/
|
|
21
22
|
export function wrapDocumentStorageService(
|
|
22
23
|
innerDocStorageService: IDocumentStorageService,
|
|
@@ -39,6 +40,7 @@ export function wrapDocumentStorageService(
|
|
|
39
40
|
* the client.
|
|
40
41
|
* The document storage service that is created in `connectToStorage` is wrapped by calling `wrapDocumentStorageService`
|
|
41
42
|
* to pass in the `uploadSummaryCb`.
|
|
43
|
+
* @internal
|
|
42
44
|
*/
|
|
43
45
|
export function wrapDocumentService(
|
|
44
46
|
innerDocService: IDocumentService,
|
|
@@ -58,6 +60,7 @@ export function wrapDocumentService(
|
|
|
58
60
|
* uploaded by the client.
|
|
59
61
|
* The document service that is created in `createDocumentService` is wrapped by calling `wrapDocumentService` to
|
|
60
62
|
* pass in the `uploadSummaryCb`.
|
|
63
|
+
* @internal
|
|
61
64
|
*/
|
|
62
65
|
export function wrapDocumentServiceFactory(
|
|
63
66
|
innerDocServiceFactory: IDocumentServiceFactory,
|
package/src/TestConfigs.ts
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ConfigTypes, IConfigProviderBase } from "@fluidframework/
|
|
6
|
+
import { ConfigTypes, IConfigProviderBase } from "@fluidframework/core-interfaces";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
8
11
|
export const mockConfigProvider = (
|
|
9
12
|
settings: Record<string, ConfigTypes> = {},
|
|
10
13
|
): IConfigProviderBase => {
|
package/src/TestSummaryUtils.ts
CHANGED
|
@@ -11,14 +11,18 @@ import {
|
|
|
11
11
|
ISummarizer,
|
|
12
12
|
ISummaryRuntimeOptions,
|
|
13
13
|
} from "@fluidframework/container-runtime";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
ITelemetryBaseLogger,
|
|
16
|
+
FluidObject,
|
|
17
|
+
IRequest,
|
|
18
|
+
IConfigProviderBase,
|
|
19
|
+
} from "@fluidframework/core-interfaces";
|
|
15
20
|
import { DriverHeader } from "@fluidframework/driver-definitions";
|
|
16
21
|
import {
|
|
17
22
|
IContainerRuntimeBase,
|
|
18
23
|
IFluidDataStoreFactory,
|
|
19
24
|
NamedFluidDataStoreRegistryEntries,
|
|
20
25
|
} from "@fluidframework/runtime-definitions";
|
|
21
|
-
import { IConfigProviderBase } from "@fluidframework/telemetry-utils";
|
|
22
26
|
import { ITestContainerConfig, ITestObjectProvider } from "./testObjectProvider";
|
|
23
27
|
import { mockConfigProvider } from "./TestConfigs";
|
|
24
28
|
import { waitForContainerConnection } from "./containerUtils";
|
|
@@ -77,6 +81,7 @@ const defaultSummaryOptions: ISummaryRuntimeOptions = {
|
|
|
77
81
|
* Creates a summarizer client from the given container and data store factory, and returns the summarizer client's
|
|
78
82
|
* IContainer and ISummarizer.
|
|
79
83
|
* The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.
|
|
84
|
+
* @internal
|
|
80
85
|
*/
|
|
81
86
|
export async function createSummarizerFromFactory(
|
|
82
87
|
provider: ITestObjectProvider,
|
|
@@ -114,6 +119,7 @@ export async function createSummarizerFromFactory(
|
|
|
114
119
|
* The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.
|
|
115
120
|
*
|
|
116
121
|
* Can pass in a test config provider to enable/disable features.
|
|
122
|
+
* @internal
|
|
117
123
|
*/
|
|
118
124
|
export async function createSummarizer(
|
|
119
125
|
provider: ITestObjectProvider,
|
|
@@ -145,6 +151,7 @@ export async function createSummarizer(
|
|
|
145
151
|
* @param summarizer - The ISummarizer to use to summarize on demand
|
|
146
152
|
* @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.
|
|
147
153
|
* Defaults to the reason "end-to-end test".
|
|
154
|
+
* @internal
|
|
148
155
|
*/
|
|
149
156
|
export async function summarizeNow(
|
|
150
157
|
summarizer: ISummarizer,
|
package/src/containerUtils.ts
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
import { IContainer } from "@fluidframework/container-definitions";
|
|
7
7
|
import { ConnectionState } from "@fluidframework/container-loader";
|
|
8
|
+
import { IResponse } from "@fluidframework/core-interfaces";
|
|
9
|
+
import { assert } from "@fluidframework/core-utils";
|
|
10
|
+
import { IDataStore } from "@fluidframework/runtime-definitions";
|
|
8
11
|
import { PromiseExecutor, timeoutPromise, TimeoutWithError } from "./timeoutUtils";
|
|
9
12
|
|
|
10
13
|
/**
|
|
@@ -27,6 +30,7 @@ import { PromiseExecutor, timeoutPromise, TimeoutWithError } from "./timeoutUtil
|
|
|
27
30
|
* - Rejects if failOnContainerClose === true and the container emits a 'closed' event before a 'connected' event.
|
|
28
31
|
* - Rejects after timeoutOptions.durationMs if timeoutOptions !== undefined and the container does not emit relevant
|
|
29
32
|
* events, within that timeframe.
|
|
33
|
+
* @internal
|
|
30
34
|
*/
|
|
31
35
|
export async function waitForContainerConnection(
|
|
32
36
|
container: IContainer,
|
|
@@ -46,3 +50,41 @@ export async function waitForContainerConnection(
|
|
|
46
50
|
: timeoutPromise(executor, timeoutOptions);
|
|
47
51
|
}
|
|
48
52
|
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* This function should ONLY be used for back compat purposes
|
|
56
|
+
* LTS versions of the Loader/Container will not have the "getEntryPoint" method, so we need to fallback to "request"
|
|
57
|
+
* This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
export async function getContainerEntryPointBackCompat<T>(container: IContainer): Promise<T> {
|
|
61
|
+
if (container.getEntryPoint !== undefined) {
|
|
62
|
+
const entryPoint = await container.getEntryPoint();
|
|
63
|
+
// Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running
|
|
64
|
+
// cross version compat testing scenarios, if we create with 1.X container and load with 2.X then the
|
|
65
|
+
// function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined
|
|
66
|
+
// since the container's runtime will be on version 1.X, which does not have an entry point defined.
|
|
67
|
+
if (entryPoint !== undefined) {
|
|
68
|
+
return entryPoint as T;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const response: IResponse = await (container as any).request({ url: "/" });
|
|
72
|
+
assert(response.status === 200, "requesting '/' should return default data object");
|
|
73
|
+
return response.value as T;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* This function should ONLY be used for back compat purposes
|
|
78
|
+
* Older supported versions of IDataStore do not have the "entryPoint" property, so we need to fallback to "request"
|
|
79
|
+
* This function can be removed once back-compat support for IDataStore moves to 2.0.0-internal.7.0.0
|
|
80
|
+
*
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
export async function getDataStoreEntryPointBackCompat<T>(dataStore: IDataStore): Promise<T> {
|
|
84
|
+
if (dataStore.entryPoint !== undefined) {
|
|
85
|
+
return dataStore.entryPoint.get() as Promise<T>;
|
|
86
|
+
}
|
|
87
|
+
const response: IResponse = await (dataStore as any).request({ url: "" });
|
|
88
|
+
assert(response.status === 200, "empty request should return data object");
|
|
89
|
+
return response.value as T;
|
|
90
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -24,10 +24,12 @@ export {
|
|
|
24
24
|
DataObjectFactoryType,
|
|
25
25
|
EventAndErrorTrackingLogger,
|
|
26
26
|
getUnexpectedLogErrorException,
|
|
27
|
+
IDocumentIdStrategy,
|
|
27
28
|
IOpProcessingController,
|
|
28
29
|
ITestContainerConfig,
|
|
29
30
|
ITestObjectProvider,
|
|
30
31
|
TestObjectProvider,
|
|
32
|
+
TestObjectProviderWithVersionedLoad,
|
|
31
33
|
} from "./testObjectProvider";
|
|
32
34
|
export { createSummarizer, createSummarizerFromFactory, summarizeNow } from "./TestSummaryUtils";
|
|
33
35
|
export {
|
|
@@ -37,5 +39,9 @@ export {
|
|
|
37
39
|
TimeoutWithError,
|
|
38
40
|
TimeoutWithValue,
|
|
39
41
|
} from "./timeoutUtils";
|
|
40
|
-
export {
|
|
42
|
+
export {
|
|
43
|
+
waitForContainerConnection,
|
|
44
|
+
getContainerEntryPointBackCompat,
|
|
45
|
+
getDataStoreEntryPointBackCompat,
|
|
46
|
+
} from "./containerUtils";
|
|
41
47
|
export { createContainerRuntimeFactoryWithDefaultDataStore } from "./testContainerRuntimeFactoryWithDefaultDataStore";
|
package/src/interfaces.ts
CHANGED
|
@@ -11,10 +11,16 @@ import {
|
|
|
11
11
|
} from "@fluidframework/runtime-definitions";
|
|
12
12
|
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
14
17
|
export interface IProvideTestFluidObject {
|
|
15
18
|
readonly ITestFluidObject: ITestFluidObject;
|
|
16
19
|
}
|
|
17
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
18
24
|
export interface ITestFluidObject extends IProvideTestFluidObject, IFluidLoadable {
|
|
19
25
|
root: ISharedMap;
|
|
20
26
|
readonly runtime: IFluidDataStoreRuntime;
|
|
@@ -41,6 +41,9 @@ interface ContainerRecord {
|
|
|
41
41
|
lastProposal: number;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
44
47
|
export class LoaderContainerTracker implements IOpProcessingController {
|
|
45
48
|
private readonly containers = new Map<IContainer, ContainerRecord>();
|
|
46
49
|
private lastProposalSeqNum: number = 0;
|
package/src/localCodeLoader.ts
CHANGED
|
@@ -22,6 +22,9 @@ import {
|
|
|
22
22
|
import { createDataStoreFactory } from "@fluidframework/runtime-utils";
|
|
23
23
|
import { IContainerRuntimeOptions } from "@fluidframework/container-runtime";
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
25
28
|
export type SupportedExportInterfaces = Partial<
|
|
26
29
|
IProvideRuntimeFactory &
|
|
27
30
|
IProvideFluidDataStoreFactory &
|
|
@@ -30,11 +33,15 @@ export type SupportedExportInterfaces = Partial<
|
|
|
30
33
|
>;
|
|
31
34
|
|
|
32
35
|
// Represents the entry point for a Fluid container.
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
33
39
|
export type fluidEntryPoint = SupportedExportInterfaces | IFluidModule;
|
|
34
40
|
|
|
35
41
|
/**
|
|
36
42
|
* A simple code loader that caches a mapping of package name to a Fluid entry point.
|
|
37
43
|
* On load, it retrieves the entry point matching the package name in the given code details.
|
|
44
|
+
* @internal
|
|
38
45
|
*/
|
|
39
46
|
export class LocalCodeLoader implements ICodeDetailsLoader {
|
|
40
47
|
private readonly fluidPackageCache = new Map<string, IFluidModuleWithDetails>();
|
package/src/localLoader.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { fluidEntryPoint, LocalCodeLoader } from "./localCodeLoader";
|
|
|
21
21
|
* @param documentServiceFactory - the driver factory to use
|
|
22
22
|
* @param urlResolver - the url resolver to use
|
|
23
23
|
* @param options - loader options
|
|
24
|
+
* @internal
|
|
24
25
|
*/
|
|
25
26
|
export function createLoader(
|
|
26
27
|
packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,
|
|
@@ -45,6 +46,7 @@ export function createLoader(
|
|
|
45
46
|
* @param source - The code details used to create the Container.
|
|
46
47
|
* @param loader - The loader to use to initialize the container.
|
|
47
48
|
* @param attachRequest - The request to create new from.
|
|
49
|
+
* @internal
|
|
48
50
|
*/
|
|
49
51
|
|
|
50
52
|
export async function createAndAttachContainer(
|
package/src/packageVersion.ts
CHANGED
package/src/retry.ts
CHANGED
|
@@ -33,6 +33,7 @@ const retry = async <T>(
|
|
|
33
33
|
* @param maxTries - maximum number of attempts
|
|
34
34
|
* @param backOffMs - back off between attempts in milliseconds
|
|
35
35
|
* @returns the actual value from the callback when successful or the default value otherwise
|
|
36
|
+
* @internal
|
|
36
37
|
*/
|
|
37
38
|
export const retryWithEventualValue = async <T>(
|
|
38
39
|
callback: () => Promise<T>,
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
// eslint-disable-next-line import/no-deprecated
|
|
7
6
|
import { defaultRouteRequestHandler } from "@fluidframework/aqueduct";
|
|
8
7
|
import { IContainerContext, IRuntime } from "@fluidframework/container-definitions";
|
|
9
8
|
import {
|
|
@@ -12,13 +11,13 @@ import {
|
|
|
12
11
|
DefaultSummaryConfiguration,
|
|
13
12
|
} from "@fluidframework/container-runtime";
|
|
14
13
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
15
|
-
// eslint-disable-next-line import/no-deprecated
|
|
16
14
|
import { buildRuntimeRequestHandler, RuntimeRequestHandler } from "@fluidframework/request-handler";
|
|
17
15
|
import { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions";
|
|
18
16
|
import { RuntimeFactoryHelper } from "@fluidframework/runtime-utils";
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
19
|
* Create a container runtime factory class that allows you to set runtime options
|
|
20
|
+
* @internal
|
|
22
21
|
*/
|
|
23
22
|
export const createTestContainerRuntimeFactory = (
|
|
24
23
|
containerRuntimeCtor: typeof ContainerRuntime,
|
|
@@ -54,36 +53,64 @@ export const createTestContainerRuntimeFactory = (
|
|
|
54
53
|
public async instantiateFromExisting(runtime: ContainerRuntime): Promise<void> {
|
|
55
54
|
// Validate we can load root data stores.
|
|
56
55
|
// We should be able to load any data store that was created in initializeFirstTime!
|
|
57
|
-
|
|
56
|
+
// Note: We use the deprecated `getRootDataStore` from v1.X here to allow for cross-major version compat
|
|
57
|
+
// testing. Can be removed when we no longer support v1.X.
|
|
58
|
+
await (runtime.getAliasedDataStoreEntryPoint?.("default") ??
|
|
59
|
+
runtime.getRootDataStore("default"));
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
async preInitialize(
|
|
61
63
|
context: IContainerContext,
|
|
62
64
|
existing: boolean,
|
|
63
65
|
): Promise<IRuntime & IContainerRuntime> {
|
|
64
|
-
|
|
66
|
+
if (containerRuntimeCtor.loadRuntime === undefined) {
|
|
67
|
+
// Note: We use the deprecated `load` from v1.X here to allow for cross-major version compat testing.
|
|
68
|
+
// Can be removed when we no longer support v1.X.
|
|
69
|
+
return containerRuntimeCtor.load(
|
|
70
|
+
context,
|
|
71
|
+
[
|
|
72
|
+
["default", Promise.resolve(this.dataStoreFactory)],
|
|
73
|
+
[this.type, Promise.resolve(this.dataStoreFactory)],
|
|
74
|
+
],
|
|
75
|
+
buildRuntimeRequestHandler(
|
|
76
|
+
defaultRouteRequestHandler("default"),
|
|
77
|
+
...this.requestHandlers,
|
|
78
|
+
),
|
|
79
|
+
this.runtimeOptions,
|
|
80
|
+
context.scope,
|
|
81
|
+
existing,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
const provideEntryPoint = async (runtime: IContainerRuntime) => {
|
|
85
|
+
const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
|
|
86
|
+
if (entryPoint === undefined) {
|
|
87
|
+
throw new Error("default dataStore must exist");
|
|
88
|
+
}
|
|
89
|
+
return entryPoint.get();
|
|
90
|
+
};
|
|
91
|
+
return containerRuntimeCtor.loadRuntime({
|
|
65
92
|
context,
|
|
66
|
-
[
|
|
93
|
+
registryEntries: [
|
|
67
94
|
["default", Promise.resolve(this.dataStoreFactory)],
|
|
68
95
|
[this.type, Promise.resolve(this.dataStoreFactory)],
|
|
69
96
|
],
|
|
70
|
-
|
|
71
|
-
buildRuntimeRequestHandler(
|
|
72
|
-
// eslint-disable-next-line import/no-deprecated
|
|
97
|
+
requestHandler: buildRuntimeRequestHandler(
|
|
73
98
|
defaultRouteRequestHandler("default"),
|
|
74
99
|
...this.requestHandlers,
|
|
75
100
|
),
|
|
76
|
-
|
|
77
|
-
|
|
101
|
+
provideEntryPoint,
|
|
102
|
+
// ! This prop is needed for back-compat. Can be removed in 2.0.0-internal.8.0.0
|
|
103
|
+
initializeEntryPoint: provideEntryPoint,
|
|
104
|
+
runtimeOptions: this.runtimeOptions,
|
|
105
|
+
containerScope: context.scope,
|
|
78
106
|
existing,
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
return runtime;
|
|
107
|
+
} as any);
|
|
82
108
|
}
|
|
83
109
|
};
|
|
84
110
|
};
|
|
85
111
|
|
|
86
112
|
/**
|
|
87
113
|
* A container runtime factory that allows you to set runtime options
|
|
114
|
+
* @internal
|
|
88
115
|
*/
|
|
89
116
|
export const TestContainerRuntimeFactory = createTestContainerRuntimeFactory(ContainerRuntime);
|
|
@@ -13,8 +13,17 @@ import {
|
|
|
13
13
|
NamedFluidDataStoreRegistryEntries,
|
|
14
14
|
} from "@fluidframework/runtime-definitions";
|
|
15
15
|
|
|
16
|
+
const getDefaultFluidObject = async (runtime: IContainerRuntime) => {
|
|
17
|
+
const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
|
|
18
|
+
if (entryPoint === undefined) {
|
|
19
|
+
throw new Error("default dataStore must exist");
|
|
20
|
+
}
|
|
21
|
+
return entryPoint.get();
|
|
22
|
+
};
|
|
23
|
+
|
|
16
24
|
/**
|
|
17
25
|
* ! Note: This function is purely needed for back-compat as the constructor argument structure was changed
|
|
26
|
+
* @internal
|
|
18
27
|
*/
|
|
19
28
|
export const createContainerRuntimeFactoryWithDefaultDataStore = (
|
|
20
29
|
Base: typeof ContainerRuntimeFactoryWithDefaultDataStore = ContainerRuntimeFactoryWithDefaultDataStore,
|
|
@@ -37,6 +46,7 @@ export const createContainerRuntimeFactoryWithDefaultDataStore = (
|
|
|
37
46
|
dependencyContainer,
|
|
38
47
|
requestHandlers,
|
|
39
48
|
runtimeOptions,
|
|
49
|
+
provideEntryPoint,
|
|
40
50
|
} = ctorArgs;
|
|
41
51
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
42
52
|
return new (Base as any)(
|
|
@@ -45,6 +55,7 @@ export const createContainerRuntimeFactoryWithDefaultDataStore = (
|
|
|
45
55
|
dependencyContainer,
|
|
46
56
|
requestHandlers,
|
|
47
57
|
runtimeOptions,
|
|
58
|
+
provideEntryPoint ?? getDefaultFluidObject,
|
|
48
59
|
);
|
|
49
60
|
}
|
|
50
61
|
};
|
package/src/testFluidObject.ts
CHANGED
|
@@ -5,13 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
// eslint-disable-next-line import/no-deprecated
|
|
7
7
|
import { defaultFluidObjectRequestHandler } from "@fluidframework/aqueduct";
|
|
8
|
-
import {
|
|
9
|
-
IRequest,
|
|
10
|
-
IResponse,
|
|
11
|
-
IFluidHandle,
|
|
12
|
-
FluidObject,
|
|
13
|
-
IProvideFluidRouter,
|
|
14
|
-
} from "@fluidframework/core-interfaces";
|
|
8
|
+
import { IRequest, IResponse, IFluidHandle } from "@fluidframework/core-interfaces";
|
|
15
9
|
import {
|
|
16
10
|
FluidObjectHandle,
|
|
17
11
|
FluidDataStoreRuntime,
|
|
@@ -31,6 +25,7 @@ import { ITestFluidObject } from "./interfaces";
|
|
|
31
25
|
* A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load.
|
|
32
26
|
* The shared objects can be retrieved by passing the key of the entry to getSharedObject.
|
|
33
27
|
* It exposes the IFluidDataStoreContext and IFluidDataStoreRuntime.
|
|
28
|
+
* @internal
|
|
34
29
|
*/
|
|
35
30
|
export class TestFluidObject implements ITestFluidObject {
|
|
36
31
|
public get ITestFluidObject() {
|
|
@@ -128,6 +123,9 @@ export class TestFluidObject implements ITestFluidObject {
|
|
|
128
123
|
}
|
|
129
124
|
}
|
|
130
125
|
|
|
126
|
+
/**
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
131
129
|
export type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFactory]>;
|
|
132
130
|
|
|
133
131
|
/**
|
|
@@ -159,6 +157,7 @@ export type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFacto
|
|
|
159
157
|
* `describeCompat` aims to provide:
|
|
160
158
|
* `SharedMap`s always reference the current version of SharedMap.
|
|
161
159
|
* AB#4670 tracks improving this situation.
|
|
160
|
+
* @internal
|
|
162
161
|
*/
|
|
163
162
|
export class TestFluidObjectFactory implements IFluidDataStoreFactory {
|
|
164
163
|
public get IFluidDataStoreFactory() {
|
|
@@ -202,12 +201,13 @@ export class TestFluidObjectFactory implements IFluidDataStoreFactory {
|
|
|
202
201
|
|
|
203
202
|
const runtimeClass = mixinRequestHandler(
|
|
204
203
|
async (request: IRequest, rt: FluidDataStoreRuntime) => {
|
|
205
|
-
|
|
204
|
+
// The provideEntryPoint callback below always returns FluidDataStoreRuntime, so this cast is safe
|
|
205
|
+
const dataObject = (await rt.entryPoint.get()) as FluidDataStoreRuntime;
|
|
206
206
|
assert(
|
|
207
|
-
|
|
207
|
+
dataObject.request !== undefined,
|
|
208
208
|
"entryPoint should have been initialized by now",
|
|
209
209
|
);
|
|
210
|
-
return
|
|
210
|
+
return dataObject.request(request);
|
|
211
211
|
},
|
|
212
212
|
);
|
|
213
213
|
|