@fluidframework/test-utils 2.0.0-internal.7.3.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +3 -3
  3. package/api-extractor-lint.json +13 -0
  4. package/api-extractor.json +3 -3
  5. package/api-report/test-utils.api.md +84 -77
  6. package/dist/DriverWrappers.d.ts +3 -0
  7. package/dist/DriverWrappers.d.ts.map +1 -1
  8. package/dist/DriverWrappers.js +3 -0
  9. package/dist/DriverWrappers.js.map +1 -1
  10. package/dist/TestConfigs.d.ts +4 -1
  11. package/dist/TestConfigs.d.ts.map +1 -1
  12. package/dist/TestConfigs.js +3 -0
  13. package/dist/TestConfigs.js.map +1 -1
  14. package/dist/TestSummaryUtils.d.ts +4 -2
  15. package/dist/TestSummaryUtils.d.ts.map +1 -1
  16. package/dist/TestSummaryUtils.js +3 -2
  17. package/dist/TestSummaryUtils.js.map +1 -1
  18. package/dist/containerUtils.d.ts +17 -0
  19. package/dist/containerUtils.d.ts.map +1 -1
  20. package/dist/containerUtils.js +41 -1
  21. package/dist/containerUtils.js.map +1 -1
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +4 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/interfaces.d.ts +6 -0
  27. package/dist/interfaces.d.ts.map +1 -1
  28. package/dist/interfaces.js.map +1 -1
  29. package/dist/loaderContainerTracker.d.ts +3 -0
  30. package/dist/loaderContainerTracker.d.ts.map +1 -1
  31. package/dist/loaderContainerTracker.js +3 -0
  32. package/dist/loaderContainerTracker.js.map +1 -1
  33. package/dist/localCodeLoader.d.ts +7 -0
  34. package/dist/localCodeLoader.d.ts.map +1 -1
  35. package/dist/localCodeLoader.js +1 -2
  36. package/dist/localCodeLoader.js.map +1 -1
  37. package/dist/localLoader.d.ts +2 -0
  38. package/dist/localLoader.d.ts.map +1 -1
  39. package/dist/localLoader.js +2 -0
  40. package/dist/localLoader.js.map +1 -1
  41. package/dist/packageVersion.d.ts +1 -1
  42. package/dist/packageVersion.js +1 -1
  43. package/dist/packageVersion.js.map +1 -1
  44. package/dist/retry.d.ts +1 -0
  45. package/dist/retry.d.ts.map +1 -1
  46. package/dist/retry.js +1 -0
  47. package/dist/retry.js.map +1 -1
  48. package/dist/test-utils-alpha.d.ts +140 -0
  49. package/dist/test-utils-beta.d.ts +228 -0
  50. package/dist/test-utils-public.d.ts +228 -0
  51. package/dist/test-utils-untrimmed.d.ts +986 -0
  52. package/dist/testContainerRuntimeFactory.d.ts +2 -0
  53. package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
  54. package/dist/testContainerRuntimeFactory.js +49 -12
  55. package/dist/testContainerRuntimeFactory.js.map +1 -1
  56. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +1 -0
  57. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
  58. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js +10 -2
  59. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  60. package/dist/testFluidObject.d.ts +5 -7
  61. package/dist/testFluidObject.d.ts.map +1 -1
  62. package/dist/testFluidObject.js +10 -16
  63. package/dist/testFluidObject.js.map +1 -1
  64. package/dist/testObjectProvider.d.ts +287 -37
  65. package/dist/testObjectProvider.d.ts.map +1 -1
  66. package/dist/testObjectProvider.js +310 -25
  67. package/dist/testObjectProvider.js.map +1 -1
  68. package/dist/timeoutUtils.d.ts +11 -0
  69. package/dist/timeoutUtils.d.ts.map +1 -1
  70. package/dist/timeoutUtils.js +5 -0
  71. package/dist/timeoutUtils.js.map +1 -1
  72. package/lib/test-utils-alpha.d.ts +140 -0
  73. package/lib/test-utils-beta.d.ts +228 -0
  74. package/lib/test-utils-public.d.ts +228 -0
  75. package/lib/test-utils-untrimmed.d.ts +986 -0
  76. package/package.json +59 -28
  77. package/src/DriverWrappers.ts +3 -0
  78. package/src/TestConfigs.ts +4 -1
  79. package/src/TestSummaryUtils.ts +9 -6
  80. package/src/containerUtils.ts +42 -0
  81. package/src/index.ts +7 -1
  82. package/src/interfaces.ts +6 -0
  83. package/src/loaderContainerTracker.ts +3 -0
  84. package/src/localCodeLoader.ts +7 -7
  85. package/src/localLoader.ts +2 -0
  86. package/src/packageVersion.ts +1 -1
  87. package/src/retry.ts +1 -0
  88. package/src/testContainerRuntimeFactory.ts +98 -15
  89. package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +11 -0
  90. package/src/testFluidObject.ts +14 -24
  91. package/src/testObjectProvider.ts +524 -47
  92. 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.0",
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,45 +34,47 @@
34
34
  "temp-directory": "nyc/.nyc_output"
35
35
  },
36
36
  "dependencies": {
37
- "@fluidframework/aqueduct": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
38
- "@fluidframework/container-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
39
- "@fluidframework/container-loader": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
40
- "@fluidframework/container-runtime": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
41
- "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
42
- "@fluidframework/core-interfaces": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
43
- "@fluidframework/core-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
44
- "@fluidframework/datastore": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
45
- "@fluidframework/datastore-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
46
- "@fluidframework/driver-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
47
- "@fluidframework/driver-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
48
- "@fluidframework/local-driver": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
49
- "@fluidframework/map": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
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.7.3.0 <2.0.0-internal.7.4.0",
52
- "@fluidframework/routerlicious-driver": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
53
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
54
- "@fluidframework/runtime-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
55
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
56
- "@fluidframework/test-driver-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
57
- "@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
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"
61
61
  },
62
62
  "devDependencies": {
63
+ "@arethetypeswrong/cli": "^0.13.3",
63
64
  "@fluid-tools/build-cli": "^0.28.0",
64
65
  "@fluidframework/build-common": "^2.0.3",
65
66
  "@fluidframework/build-tools": "^0.28.0",
66
67
  "@fluidframework/eslint-config-fluid": "^3.1.0",
67
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
68
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
68
69
  "@fluidframework/test-utils-previous": "npm:@fluidframework/test-utils@2.0.0-internal.7.2.0",
69
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": "^16.18.38",
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,25 +86,54 @@
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
+ "ClassDeclaration_TestFluidObject": {
104
+ "backCompat": false
105
+ },
106
+ "InterfaceDeclaration_ITestObjectProvider": {
107
+ "backCompat": false,
108
+ "forwardCompat": false
109
+ },
110
+ "ClassDeclaration_TestObjectProvider": {
111
+ "backCompat": false,
112
+ "forwardCompat": false
113
+ }
114
+ }
89
115
  },
90
116
  "scripts": {
117
+ "api": "fluid-build . --task api",
118
+ "api-extractor:commonjs": "api-extractor run --local",
119
+ "api-extractor:esnext": "copyfiles -u 1 \"dist/**/*-@(alpha|beta|public|untrimmed).d.ts\" lib",
91
120
  "build": "fluid-build . --task build",
92
121
  "build:compile": "fluid-build . --task compile",
93
122
  "build:compile:min": "npm run build:compile",
94
- "build:docs": "api-extractor run --local",
123
+ "build:docs": "fluid-build . --task api",
95
124
  "build:genver": "gen-version",
96
125
  "build:test": "tsc --project ./src/test/tsconfig.json",
126
+ "check:are-the-types-wrong": "attw --pack",
127
+ "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
97
128
  "ci:build:docs": "api-extractor run",
98
129
  "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
99
130
  "eslint": "eslint --format stylish src",
100
131
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
101
132
  "format": "npm run prettier:fix",
102
- "lint": "npm run prettier && npm run eslint",
133
+ "lint": "npm run prettier && npm run check:release-tags && npm run eslint",
103
134
  "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",
135
+ "prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
136
+ "prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
106
137
  "test": "npm run test:mocha",
107
138
  "test:mocha": "mocha --recursive \"dist/test/*.spec.js\" --exit --project src/test/tsconfig.json -r node_modules/@fluidframework/mocha-test-setup",
108
139
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
@@ -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,
@@ -3,8 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ConfigTypes, IConfigProviderBase } from "@fluidframework/telemetry-utils";
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 => {
@@ -11,14 +11,17 @@ import {
11
11
  ISummarizer,
12
12
  ISummaryRuntimeOptions,
13
13
  } from "@fluidframework/container-runtime";
14
- import { ITelemetryBaseLogger, FluidObject, IRequest } from "@fluidframework/core-interfaces";
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
- IContainerRuntimeBase,
18
22
  IFluidDataStoreFactory,
19
23
  NamedFluidDataStoreRegistryEntries,
20
24
  } from "@fluidframework/runtime-definitions";
21
- import { IConfigProviderBase } from "@fluidframework/telemetry-utils";
22
25
  import { ITestContainerConfig, ITestObjectProvider } from "./testObjectProvider";
23
26
  import { mockConfigProvider } from "./TestConfigs";
24
27
  import { waitForContainerConnection } from "./containerUtils";
@@ -77,6 +80,7 @@ const defaultSummaryOptions: ISummaryRuntimeOptions = {
77
80
  * Creates a summarizer client from the given container and data store factory, and returns the summarizer client's
78
81
  * IContainer and ISummarizer.
79
82
  * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.
83
+ * @internal
80
84
  */
81
85
  export async function createSummarizerFromFactory(
82
86
  provider: ITestObjectProvider,
@@ -88,8 +92,6 @@ export async function createSummarizerFromFactory(
88
92
  logger?: ITelemetryBaseLogger,
89
93
  configProvider: IConfigProviderBase = mockConfigProvider(),
90
94
  ): Promise<{ container: IContainer; summarizer: ISummarizer }> {
91
- const innerRequestHandler = async (request: IRequest, runtime: IContainerRuntimeBase) =>
92
- runtime.IFluidHandleContext.resolveHandle(request);
93
95
  const runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(
94
96
  containerRuntimeFactoryType,
95
97
  {
@@ -97,7 +99,6 @@ export async function createSummarizerFromFactory(
97
99
  registryEntries: registryEntries ?? [
98
100
  [dataStoreFactory.type, Promise.resolve(dataStoreFactory)],
99
101
  ],
100
- requestHandlers: [innerRequestHandler],
101
102
  runtimeOptions: { summaryOptions: defaultSummaryOptions },
102
103
  },
103
104
  );
@@ -114,6 +115,7 @@ export async function createSummarizerFromFactory(
114
115
  * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.
115
116
  *
116
117
  * Can pass in a test config provider to enable/disable features.
118
+ * @internal
117
119
  */
118
120
  export async function createSummarizer(
119
121
  provider: ITestObjectProvider,
@@ -145,6 +147,7 @@ export async function createSummarizer(
145
147
  * @param summarizer - The ISummarizer to use to summarize on demand
146
148
  * @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.
147
149
  * Defaults to the reason "end-to-end test".
150
+ * @internal
148
151
  */
149
152
  export async function summarizeNow(
150
153
  summarizer: ISummarizer,
@@ -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 { waitForContainerConnection } from "./containerUtils";
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;
@@ -13,15 +13,16 @@ 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";
22
20
  import { createDataStoreFactory } from "@fluidframework/runtime-utils";
23
21
  import { IContainerRuntimeOptions } from "@fluidframework/container-runtime";
24
22
 
23
+ /**
24
+ * @internal
25
+ */
25
26
  export type SupportedExportInterfaces = Partial<
26
27
  IProvideRuntimeFactory &
27
28
  IProvideFluidDataStoreFactory &
@@ -30,11 +31,15 @@ export type SupportedExportInterfaces = Partial<
30
31
  >;
31
32
 
32
33
  // Represents the entry point for a Fluid container.
34
+ /**
35
+ * @internal
36
+ */
33
37
  export type fluidEntryPoint = SupportedExportInterfaces | IFluidModule;
34
38
 
35
39
  /**
36
40
  * A simple code loader that caches a mapping of package name to a Fluid entry point.
37
41
  * On load, it retrieves the entry point matching the package name in the given code details.
42
+ * @internal
38
43
  */
39
44
  export class LocalCodeLoader implements ICodeDetailsLoader {
40
45
  private readonly fluidPackageCache = new Map<string, IFluidModuleWithDetails>();
@@ -64,10 +69,6 @@ export class LocalCodeLoader implements ICodeDetailsLoader {
64
69
  "default",
65
70
  maybeExport.IFluidDataStoreFactory,
66
71
  );
67
- const innerRequestHandler = async (
68
- request: IRequest,
69
- runtime: IContainerRuntimeBase,
70
- ) => runtime.IFluidHandleContext.resolveHandle(request);
71
72
  fluidModule = {
72
73
  fluidExport: {
73
74
  ...maybeExport,
@@ -76,7 +77,6 @@ export class LocalCodeLoader implements ICodeDetailsLoader {
76
77
  registryEntries: [
77
78
  [defaultFactory.type, Promise.resolve(defaultFactory)],
78
79
  ],
79
- requestHandlers: [innerRequestHandler],
80
80
  runtimeOptions,
81
81
  }),
82
82
  },
@@ -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(
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/test-utils";
9
- export const pkgVersion = "2.0.0-internal.7.3.0";
9
+ export const pkgVersion = "2.0.0-internal.8.0.0";
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,8 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- // eslint-disable-next-line import/no-deprecated
7
- import { defaultRouteRequestHandler } from "@fluidframework/aqueduct";
8
6
  import { IContainerContext, IRuntime } from "@fluidframework/container-definitions";
9
7
  import {
10
8
  ContainerRuntime,
@@ -12,13 +10,55 @@ import {
12
10
  DefaultSummaryConfiguration,
13
11
  } from "@fluidframework/container-runtime";
14
12
  import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
13
+ import {
14
+ FluidObject,
15
+ IFluidHandleContext,
16
+ IRequest,
17
+ IResponse,
18
+ } from "@fluidframework/core-interfaces";
15
19
  // eslint-disable-next-line import/no-deprecated
16
20
  import { buildRuntimeRequestHandler, RuntimeRequestHandler } from "@fluidframework/request-handler";
17
- import { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions";
18
- import { RuntimeFactoryHelper } from "@fluidframework/runtime-utils";
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
+ }
19
58
 
20
59
  /**
21
60
  * Create a container runtime factory class that allows you to set runtime options
61
+ * @internal
22
62
  */
23
63
  export const createTestContainerRuntimeFactory = (
24
64
  containerRuntimeCtor: typeof ContainerRuntime,
@@ -54,39 +94,82 @@ export const createTestContainerRuntimeFactory = (
54
94
  public async instantiateFromExisting(runtime: ContainerRuntime): Promise<void> {
55
95
  // Validate we can load root data stores.
56
96
  // We should be able to load any data store that was created in initializeFirstTime!
57
- await runtime.getAliasedDataStoreEntryPoint("default");
97
+ // Note: We use the deprecated `getRootDataStore` from v1.X here to allow for cross-major version compat
98
+ // testing. Can be removed when we no longer support v1.X.
99
+ await (runtime.getAliasedDataStoreEntryPoint?.("default") ??
100
+ (
101
+ runtime as any as {
102
+ getRootDataStore(
103
+ id: string,
104
+ wait?: boolean,
105
+ ): Promise<backCompat_IFluidRouter>;
106
+ }
107
+ ).getRootDataStore("default"));
58
108
  }
59
109
 
60
110
  async preInitialize(
61
111
  context: IContainerContext,
62
112
  existing: boolean,
63
113
  ): Promise<IRuntime & IContainerRuntime> {
64
- const runtime: ContainerRuntime = await containerRuntimeCtor.loadRuntime({
114
+ if (containerRuntimeCtor.loadRuntime === undefined) {
115
+ // Note: We use the deprecated `load` from v1.X here to allow for cross-major version compat testing.
116
+ // Can be removed when we no longer support v1.X.
117
+ return (containerRuntimeCtor as any as backCompat_ContainerRuntime).load(
118
+ context,
119
+ [
120
+ ["default", Promise.resolve(this.dataStoreFactory)],
121
+ [this.type, Promise.resolve(this.dataStoreFactory)],
122
+ ],
123
+ buildRuntimeRequestHandler(
124
+ backCompat_DefaultRouteRequestHandler("default"),
125
+ ...this.requestHandlers,
126
+ ),
127
+ this.runtimeOptions,
128
+ context.scope,
129
+ existing,
130
+ );
131
+ }
132
+ const provideEntryPoint = async (runtime: IContainerRuntime) => {
133
+ const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
134
+ if (entryPoint === undefined) {
135
+ throw new Error("default dataStore must exist");
136
+ }
137
+ return entryPoint.get();
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
+ };
150
+ return containerRuntimeCtor.loadRuntime({
65
151
  context,
66
152
  registryEntries: [
67
153
  ["default", Promise.resolve(this.dataStoreFactory)],
68
154
  [this.type, Promise.resolve(this.dataStoreFactory)],
69
155
  ],
70
- // eslint-disable-next-line import/no-deprecated
71
156
  requestHandler: buildRuntimeRequestHandler(
72
- // eslint-disable-next-line import/no-deprecated
73
- defaultRouteRequestHandler("default"),
157
+ getDefaultObject,
74
158
  ...this.requestHandlers,
75
159
  ),
76
- provideEntryPoint: () => {
77
- throw new Error("TODO: AB#4993");
78
- },
160
+ provideEntryPoint,
161
+ // ! This prop is needed for back-compat. Can be removed in 2.0.0-internal.8.0.0
162
+ initializeEntryPoint: provideEntryPoint,
79
163
  runtimeOptions: this.runtimeOptions,
80
164
  containerScope: context.scope,
81
165
  existing,
82
- });
83
-
84
- return runtime;
166
+ } as any);
85
167
  }
86
168
  };
87
169
  };
88
170
 
89
171
  /**
90
172
  * A container runtime factory that allows you to set runtime options
173
+ * @internal
91
174
  */
92
175
  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
  };