@fluidframework/test-utils 2.0.0-dev.7.3.0.212138 → 2.0.0-dev.7.4.0.214930

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 (37) hide show
  1. package/api-extractor.json +9 -2
  2. package/api-report/test-utils.api.md +3 -0
  3. package/dist/containerUtils.d.ts +6 -0
  4. package/dist/containerUtils.d.ts.map +1 -1
  5. package/dist/containerUtils.js +16 -1
  6. package/dist/containerUtils.js.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +2 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/packageVersion.d.ts +1 -1
  12. package/dist/packageVersion.js +1 -1
  13. package/dist/packageVersion.js.map +1 -1
  14. package/dist/test-utils-alpha.d.ts +682 -0
  15. package/dist/test-utils-beta.d.ts +682 -0
  16. package/dist/test-utils-public.d.ts +682 -0
  17. package/dist/test-utils-untrimmed.d.ts +682 -0
  18. package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
  19. package/dist/testContainerRuntimeFactory.js +11 -5
  20. package/dist/testContainerRuntimeFactory.js.map +1 -1
  21. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
  22. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js +9 -2
  23. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  24. package/dist/testFluidObject.d.ts.map +1 -1
  25. package/dist/testFluidObject.js +4 -3
  26. package/dist/testFluidObject.js.map +1 -1
  27. package/lib/test-utils-alpha.d.ts +682 -0
  28. package/lib/test-utils-beta.d.ts +682 -0
  29. package/lib/test-utils-public.d.ts +682 -0
  30. package/lib/test-utils-untrimmed.d.ts +682 -0
  31. package/package.json +41 -25
  32. package/src/containerUtils.ts +16 -0
  33. package/src/index.ts +1 -1
  34. package/src/packageVersion.ts +1 -1
  35. package/src/testContainerRuntimeFactory.ts +12 -7
  36. package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +10 -0
  37. package/src/testFluidObject.ts +5 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/test-utils",
3
- "version": "2.0.0-dev.7.3.0.212138",
3
+ "version": "2.0.0-dev.7.4.0.214930",
4
4
  "description": "Utilities for Fluid tests",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -34,27 +34,27 @@
34
34
  "temp-directory": "nyc/.nyc_output"
35
35
  },
36
36
  "dependencies": {
37
- "@fluidframework/aqueduct": "2.0.0-dev.7.3.0.212138",
38
- "@fluidframework/container-definitions": "2.0.0-dev.7.3.0.212138",
39
- "@fluidframework/container-loader": "2.0.0-dev.7.3.0.212138",
40
- "@fluidframework/container-runtime": "2.0.0-dev.7.3.0.212138",
41
- "@fluidframework/container-runtime-definitions": "2.0.0-dev.7.3.0.212138",
42
- "@fluidframework/core-interfaces": "2.0.0-dev.7.3.0.212138",
43
- "@fluidframework/core-utils": "2.0.0-dev.7.3.0.212138",
44
- "@fluidframework/datastore": "2.0.0-dev.7.3.0.212138",
45
- "@fluidframework/datastore-definitions": "2.0.0-dev.7.3.0.212138",
46
- "@fluidframework/driver-definitions": "2.0.0-dev.7.3.0.212138",
47
- "@fluidframework/driver-utils": "2.0.0-dev.7.3.0.212138",
48
- "@fluidframework/local-driver": "2.0.0-dev.7.3.0.212138",
49
- "@fluidframework/map": "2.0.0-dev.7.3.0.212138",
37
+ "@fluidframework/aqueduct": "2.0.0-dev.7.4.0.214930",
38
+ "@fluidframework/container-definitions": "2.0.0-dev.7.4.0.214930",
39
+ "@fluidframework/container-loader": "2.0.0-dev.7.4.0.214930",
40
+ "@fluidframework/container-runtime": "2.0.0-dev.7.4.0.214930",
41
+ "@fluidframework/container-runtime-definitions": "2.0.0-dev.7.4.0.214930",
42
+ "@fluidframework/core-interfaces": "2.0.0-dev.7.4.0.214930",
43
+ "@fluidframework/core-utils": "2.0.0-dev.7.4.0.214930",
44
+ "@fluidframework/datastore": "2.0.0-dev.7.4.0.214930",
45
+ "@fluidframework/datastore-definitions": "2.0.0-dev.7.4.0.214930",
46
+ "@fluidframework/driver-definitions": "2.0.0-dev.7.4.0.214930",
47
+ "@fluidframework/driver-utils": "2.0.0-dev.7.4.0.214930",
48
+ "@fluidframework/local-driver": "2.0.0-dev.7.4.0.214930",
49
+ "@fluidframework/map": "2.0.0-dev.7.4.0.214930",
50
50
  "@fluidframework/protocol-definitions": "^3.0.0",
51
- "@fluidframework/request-handler": "2.0.0-dev.7.3.0.212138",
52
- "@fluidframework/routerlicious-driver": "2.0.0-dev.7.3.0.212138",
53
- "@fluidframework/runtime-definitions": "2.0.0-dev.7.3.0.212138",
54
- "@fluidframework/runtime-utils": "2.0.0-dev.7.3.0.212138",
55
- "@fluidframework/telemetry-utils": "2.0.0-dev.7.3.0.212138",
56
- "@fluidframework/test-driver-definitions": "2.0.0-dev.7.3.0.212138",
57
- "@fluidframework/test-runtime-utils": "2.0.0-dev.7.3.0.212138",
51
+ "@fluidframework/request-handler": "2.0.0-dev.7.4.0.214930",
52
+ "@fluidframework/routerlicious-driver": "2.0.0-dev.7.4.0.214930",
53
+ "@fluidframework/runtime-definitions": "2.0.0-dev.7.4.0.214930",
54
+ "@fluidframework/runtime-utils": "2.0.0-dev.7.4.0.214930",
55
+ "@fluidframework/telemetry-utils": "2.0.0-dev.7.4.0.214930",
56
+ "@fluidframework/test-driver-definitions": "2.0.0-dev.7.4.0.214930",
57
+ "@fluidframework/test-runtime-utils": "2.0.0-dev.7.4.0.214930",
58
58
  "best-random": "^1.0.0",
59
59
  "debug": "^4.3.4",
60
60
  "uuid": "^9.0.0"
@@ -64,7 +64,7 @@
64
64
  "@fluidframework/build-common": "^2.0.3",
65
65
  "@fluidframework/build-tools": "^0.28.0",
66
66
  "@fluidframework/eslint-config-fluid": "^3.1.0",
67
- "@fluidframework/mocha-test-setup": "2.0.0-dev.7.3.0.212138",
67
+ "@fluidframework/mocha-test-setup": "2.0.0-dev.7.4.0.214930",
68
68
  "@fluidframework/test-utils-previous": "npm:@fluidframework/test-utils@2.0.0-internal.7.2.0",
69
69
  "@microsoft/api-extractor": "^7.38.3",
70
70
  "@types/debug": "^4.1.5",
@@ -73,6 +73,7 @@
73
73
  "@types/node": "^16.18.38",
74
74
  "@types/uuid": "^9.0.2",
75
75
  "c8": "^7.7.1",
76
+ "copyfiles": "^2.4.1",
76
77
  "cross-env": "^7.0.3",
77
78
  "diff": "^3.5.0",
78
79
  "eslint": "~8.50.0",
@@ -84,14 +85,29 @@
84
85
  "rimraf": "^4.4.0",
85
86
  "typescript": "~5.1.6"
86
87
  },
88
+ "fluidBuild": {
89
+ "tasks": {
90
+ "build:docs": {
91
+ "dependsOn": [
92
+ "...",
93
+ "api-extractor:commonjs",
94
+ "api-extractor:esnext"
95
+ ],
96
+ "script": false
97
+ }
98
+ }
99
+ },
87
100
  "typeValidation": {
88
101
  "broken": {}
89
102
  },
90
103
  "scripts": {
104
+ "api": "fluid-build . --task api",
105
+ "api-extractor:commonjs": "api-extractor run --local",
106
+ "api-extractor:esnext": "copyfiles -u 1 \"dist/**/*-@(alpha|beta|public|untrimmed).d.ts\" lib",
91
107
  "build": "fluid-build . --task build",
92
108
  "build:compile": "fluid-build . --task compile",
93
109
  "build:compile:min": "npm run build:compile",
94
- "build:docs": "api-extractor run --local",
110
+ "build:docs": "fluid-build . --task api",
95
111
  "build:genver": "gen-version",
96
112
  "build:test": "tsc --project ./src/test/tsconfig.json",
97
113
  "ci:build:docs": "api-extractor run",
@@ -101,8 +117,8 @@
101
117
  "format": "npm run prettier:fix",
102
118
  "lint": "npm run prettier && npm run eslint",
103
119
  "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",
120
+ "prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
121
+ "prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
106
122
  "test": "npm run test:mocha",
107
123
  "test:mocha": "mocha --recursive \"dist/test/*.spec.js\" --exit --project src/test/tsconfig.json -r node_modules/@fluidframework/mocha-test-setup",
108
124
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
@@ -5,6 +5,8 @@
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";
8
10
  import { PromiseExecutor, timeoutPromise, TimeoutWithError } from "./timeoutUtils";
9
11
 
10
12
  /**
@@ -46,3 +48,17 @@ export async function waitForContainerConnection(
46
48
  : timeoutPromise(executor, timeoutOptions);
47
49
  }
48
50
  }
51
+
52
+ /**
53
+ * This function should ONLY be used for back compat purposes
54
+ * LTS versions of the Loader/Container will not have the "getEntryPoint" method, so we need to fallback to "request"
55
+ * This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0
56
+ */
57
+ export async function getContainerEntryPointBackCompat<T>(container: IContainer): Promise<T> {
58
+ if (container.getEntryPoint !== undefined) {
59
+ return (await container.getEntryPoint()) as T;
60
+ }
61
+ const response: IResponse = await (container as any).request({ url: "/" });
62
+ assert(response.status === 200, "requesting '/' should return default data object");
63
+ return response.value as T;
64
+ }
package/src/index.ts CHANGED
@@ -37,5 +37,5 @@ export {
37
37
  TimeoutWithError,
38
38
  TimeoutWithValue,
39
39
  } from "./timeoutUtils";
40
- export { waitForContainerConnection } from "./containerUtils";
40
+ export { waitForContainerConnection, getContainerEntryPointBackCompat } from "./containerUtils";
41
41
  export { createContainerRuntimeFactoryWithDefaultDataStore } from "./testContainerRuntimeFactoryWithDefaultDataStore";
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/test-utils";
9
- export const pkgVersion = "2.0.0-dev.7.3.0.212138";
9
+ export const pkgVersion = "2.0.0-dev.7.4.0.214930";
@@ -61,7 +61,14 @@ export const createTestContainerRuntimeFactory = (
61
61
  context: IContainerContext,
62
62
  existing: boolean,
63
63
  ): Promise<IRuntime & IContainerRuntime> {
64
- const runtime: ContainerRuntime = await containerRuntimeCtor.loadRuntime({
64
+ const provideEntryPoint = async (runtime: IContainerRuntime) => {
65
+ const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
66
+ if (entryPoint === undefined) {
67
+ throw new Error("default dataStore must exist");
68
+ }
69
+ return entryPoint.get();
70
+ };
71
+ return containerRuntimeCtor.loadRuntime({
65
72
  context,
66
73
  registryEntries: [
67
74
  ["default", Promise.resolve(this.dataStoreFactory)],
@@ -73,15 +80,13 @@ export const createTestContainerRuntimeFactory = (
73
80
  defaultRouteRequestHandler("default"),
74
81
  ...this.requestHandlers,
75
82
  ),
76
- provideEntryPoint: () => {
77
- throw new Error("TODO: AB#4993");
78
- },
83
+ provideEntryPoint,
84
+ // ! This prop is needed for back-compat. Can be removed in 2.0.0-internal.8.0.0
85
+ initializeEntryPoint: provideEntryPoint,
79
86
  runtimeOptions: this.runtimeOptions,
80
87
  containerScope: context.scope,
81
88
  existing,
82
- });
83
-
84
- return runtime;
89
+ } as any);
85
90
  }
86
91
  };
87
92
  };
@@ -13,6 +13,14 @@ 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
18
26
  */
@@ -37,6 +45,7 @@ export const createContainerRuntimeFactoryWithDefaultDataStore = (
37
45
  dependencyContainer,
38
46
  requestHandlers,
39
47
  runtimeOptions,
48
+ provideEntryPoint,
40
49
  } = ctorArgs;
41
50
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
42
51
  return new (Base as any)(
@@ -45,6 +54,7 @@ export const createContainerRuntimeFactoryWithDefaultDataStore = (
45
54
  dependencyContainer,
46
55
  requestHandlers,
47
56
  runtimeOptions,
57
+ provideEntryPoint ?? getDefaultFluidObject,
48
58
  );
49
59
  }
50
60
  };
@@ -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,
@@ -202,12 +196,13 @@ export class TestFluidObjectFactory implements IFluidDataStoreFactory {
202
196
 
203
197
  const runtimeClass = mixinRequestHandler(
204
198
  async (request: IRequest, rt: FluidDataStoreRuntime) => {
205
- const maybeRouter: FluidObject<IProvideFluidRouter> = await rt.entryPoint.get();
199
+ // The provideEntryPoint callback below always returns FluidDataStoreRuntime, so this cast is safe
200
+ const dataObject = (await rt.entryPoint.get()) as FluidDataStoreRuntime;
206
201
  assert(
207
- maybeRouter.IFluidRouter !== undefined,
202
+ dataObject.request !== undefined,
208
203
  "entryPoint should have been initialized by now",
209
204
  );
210
- return maybeRouter.IFluidRouter.request(request);
205
+ return dataObject.request(request);
211
206
  },
212
207
  );
213
208