@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.
Files changed (92) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/api-extractor-lint.json +13 -0
  3. package/api-extractor.json +3 -3
  4. package/api-report/test-utils.api.md +83 -74
  5. package/dist/DriverWrappers.d.ts +3 -0
  6. package/dist/DriverWrappers.d.ts.map +1 -1
  7. package/dist/DriverWrappers.js +3 -0
  8. package/dist/DriverWrappers.js.map +1 -1
  9. package/dist/TestConfigs.d.ts +4 -1
  10. package/dist/TestConfigs.d.ts.map +1 -1
  11. package/dist/TestConfigs.js +3 -0
  12. package/dist/TestConfigs.js.map +1 -1
  13. package/dist/TestSummaryUtils.d.ts +4 -2
  14. package/dist/TestSummaryUtils.d.ts.map +1 -1
  15. package/dist/TestSummaryUtils.js +3 -0
  16. package/dist/TestSummaryUtils.js.map +1 -1
  17. package/dist/containerUtils.d.ts +17 -0
  18. package/dist/containerUtils.d.ts.map +1 -1
  19. package/dist/containerUtils.js +41 -1
  20. package/dist/containerUtils.js.map +1 -1
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +4 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/interfaces.d.ts +6 -0
  26. package/dist/interfaces.d.ts.map +1 -1
  27. package/dist/interfaces.js.map +1 -1
  28. package/dist/loaderContainerTracker.d.ts +3 -0
  29. package/dist/loaderContainerTracker.d.ts.map +1 -1
  30. package/dist/loaderContainerTracker.js +3 -0
  31. package/dist/loaderContainerTracker.js.map +1 -1
  32. package/dist/localCodeLoader.d.ts +7 -0
  33. package/dist/localCodeLoader.d.ts.map +1 -1
  34. package/dist/localCodeLoader.js +1 -0
  35. package/dist/localCodeLoader.js.map +1 -1
  36. package/dist/localLoader.d.ts +2 -0
  37. package/dist/localLoader.d.ts.map +1 -1
  38. package/dist/localLoader.js +2 -0
  39. package/dist/localLoader.js.map +1 -1
  40. package/dist/packageVersion.d.ts +1 -1
  41. package/dist/packageVersion.js +1 -1
  42. package/dist/packageVersion.js.map +1 -1
  43. package/dist/retry.d.ts +1 -0
  44. package/dist/retry.d.ts.map +1 -1
  45. package/dist/retry.js +1 -0
  46. package/dist/retry.js.map +1 -1
  47. package/dist/test-utils-alpha.d.ts +140 -0
  48. package/dist/test-utils-beta.d.ts +228 -0
  49. package/dist/test-utils-public.d.ts +228 -0
  50. package/dist/test-utils-untrimmed.d.ts +993 -0
  51. package/dist/testContainerRuntimeFactory.d.ts +2 -0
  52. package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
  53. package/dist/testContainerRuntimeFactory.js +35 -12
  54. package/dist/testContainerRuntimeFactory.js.map +1 -1
  55. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +1 -0
  56. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
  57. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js +10 -2
  58. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  59. package/dist/testFluidObject.d.ts +5 -0
  60. package/dist/testFluidObject.d.ts.map +1 -1
  61. package/dist/testFluidObject.js +6 -3
  62. package/dist/testFluidObject.js.map +1 -1
  63. package/dist/testObjectProvider.d.ts +287 -37
  64. package/dist/testObjectProvider.d.ts.map +1 -1
  65. package/dist/testObjectProvider.js +310 -25
  66. package/dist/testObjectProvider.js.map +1 -1
  67. package/dist/timeoutUtils.d.ts +11 -0
  68. package/dist/timeoutUtils.d.ts.map +1 -1
  69. package/dist/timeoutUtils.js +5 -0
  70. package/dist/timeoutUtils.js.map +1 -1
  71. package/dist/tsdoc-metadata.json +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 +993 -0
  76. package/package.json +63 -35
  77. package/src/DriverWrappers.ts +3 -0
  78. package/src/TestConfigs.ts +4 -1
  79. package/src/TestSummaryUtils.ts +9 -2
  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 -0
  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 +40 -13
  89. package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +11 -0
  90. package/src/testFluidObject.ts +10 -10
  91. package/src/testObjectProvider.ts +524 -47
  92. package/src/timeoutUtils.ts +11 -0
@@ -2,7 +2,13 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ /**
6
+ * @internal
7
+ */
5
8
  export declare const defaultTimeoutDurationMs = 250;
9
+ /**
10
+ * @internal
11
+ */
6
12
  export interface TimeoutWithError {
7
13
  /**
8
14
  * Timeout duration in milliseconds, if it is great than 0 and not Infinity
@@ -13,6 +19,9 @@ export interface TimeoutWithError {
13
19
  reject?: true;
14
20
  errorMsg?: string;
15
21
  }
22
+ /**
23
+ * @internal
24
+ */
16
25
  export interface TimeoutWithValue<T = void> {
17
26
  /**
18
27
  * Timeout duration in milliseconds, if it is great than 0 and not Infinity
@@ -34,6 +43,7 @@ export type PromiseExecutor<T = void> = (resolve: (value: T | PromiseLike<T>) =>
34
43
  * when the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a
35
44
  * specific value.
36
45
  * @returns A new promise that will complete when the given promise resolves or the timeout expires.
46
+ * @internal
37
47
  */
38
48
  export declare function timeoutAwait<T = void>(promise: PromiseLike<T>, timeoutOptions?: TimeoutWithError | TimeoutWithValue<T>): Promise<T>;
39
49
  /**
@@ -44,6 +54,7 @@ export declare function timeoutAwait<T = void>(promise: PromiseLike<T>, timeoutO
44
54
  * @param timeoutOptions - Options that can be used to override the timeout and / or define the behavior when
45
55
  * the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a specific value.
46
56
  * @returns A new promise that will complete when the given executor resolves or the timeout expires.
57
+ * @internal
47
58
  */
48
59
  export declare function timeoutPromise<T = void>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void, timeoutOptions?: TimeoutWithError | TimeoutWithValue<T>): Promise<T>;
49
60
  //# sourceMappingURL=timeoutUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timeoutUtils.d.ts","sourceRoot":"","sources":["../src/timeoutUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,eAAO,MAAM,wBAAwB,MAAM,CAAC;AA8F5C,MAAM,WAAW,gBAAgB;IAChC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,IAAI;IACzC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,KAAK,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;CACT;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,IAAI,IAAI,CACvC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,EAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,KAC1B,IAAI,CAAC;AAEV;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,CAAC,GAAG,IAAI,EAC1C,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,EACvB,cAAc,GAAE,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAM,GACzD,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;;;;GAQG;AACH,wBAA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;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,CAAC,GAAG,IAAI,EAC5C,QAAQ,EAAE,CACT,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,EAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,KAC1B,IAAI,EACT,cAAc,GAAE,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAM,GACzD,OAAO,CAAC,CAAC,CAAC,CA6BZ"}
@@ -7,6 +7,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.timeoutPromise = exports.timeoutAwait = exports.defaultTimeoutDurationMs = void 0;
8
8
  const core_utils_1 = require("@fluidframework/core-utils");
9
9
  // @deprecated this value is no longer used
10
+ /**
11
+ * @internal
12
+ */
10
13
  exports.defaultTimeoutDurationMs = 250;
11
14
  const timeBuffer = 15; // leave 15 ms leeway for finish processing
12
15
  // TestTimeout class that manages tracking of test timeout. It creates a timer when timeout is in effect,
@@ -96,6 +99,7 @@ if (globalThis.getMochaModule !== undefined) {
96
99
  * when the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a
97
100
  * specific value.
98
101
  * @returns A new promise that will complete when the given promise resolves or the timeout expires.
102
+ * @internal
99
103
  */
100
104
  async function timeoutAwait(promise, timeoutOptions = {}) {
101
105
  return Promise.race([promise, timeoutPromise(() => { }, timeoutOptions)]);
@@ -109,6 +113,7 @@ exports.timeoutAwait = timeoutAwait;
109
113
  * @param timeoutOptions - Options that can be used to override the timeout and / or define the behavior when
110
114
  * the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a specific value.
111
115
  * @returns A new promise that will complete when the given executor resolves or the timeout expires.
116
+ * @internal
112
117
  */
113
118
  async function timeoutPromise(executor, timeoutOptions = {}) {
114
119
  // create the timeout error outside the async task, so its callstack includes
@@ -1 +1 @@
1
- {"version":3,"file":"timeoutUtils.js","sourceRoot":"","sources":["../src/timeoutUtils.ts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CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/core-utils\";\n\n// @deprecated this value is no longer used\nexport const defaultTimeoutDurationMs = 250;\n\nconst timeBuffer = 15; // leave 15 ms leeway for finish processing\n\n// TestTimeout class that manages tracking of test timeout. It creates a timer when timeout is in effect,\n// and provides a promise that will be rejected some time (as defined by `timeBuffer`) before the test timeout happens.\n// This will ensure that async awaits in tests do not end up timing out the tests but resolve / reject\n// before that happens.\n// Once rejected, a new TestTimeout object will be create for the timeout.\nclass TestTimeout {\n\tprivate timeout: number = 0;\n\tprivate timer: NodeJS.Timeout | undefined;\n\tprivate readonly deferred: Deferred<void>;\n\tprivate rejected = false;\n\n\tprivate static instance: TestTimeout = new TestTimeout();\n\tpublic static reset(runnable: Mocha.Runnable) {\n\t\tTestTimeout.clear();\n\t\tTestTimeout.instance.resetTimer(runnable);\n\t}\n\n\tpublic static clear() {\n\t\tif (TestTimeout.instance.rejected) {\n\t\t\tTestTimeout.instance = new TestTimeout();\n\t\t} else {\n\t\t\tTestTimeout.instance.clearTimer();\n\t\t}\n\t}\n\n\tpublic static getInstance() {\n\t\treturn TestTimeout.instance;\n\t}\n\n\tpublic async getPromise() {\n\t\treturn this.deferred.promise;\n\t}\n\n\tpublic getTimeout() {\n\t\treturn this.timeout;\n\t}\n\n\tprivate constructor() {\n\t\tthis.deferred = new Deferred();\n\t\t// Ignore rejection for timeout promise if no one is waiting for it.\n\t\tthis.deferred.promise.catch(() => {});\n\t}\n\n\tprivate resetTimer(runnable: Mocha.Runnable) {\n\t\tassert(!this.timer, \"clearTimer should have been called before reset\");\n\t\tassert(!this.deferred.isCompleted, \"can't reset a completed TestTimeout\");\n\n\t\t// Check the test timeout setting\n\t\tconst timeout = runnable.timeout();\n\t\tif (!(Number.isFinite(timeout) && timeout > 0)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// subtract a buffer\n\t\tthis.timeout = Math.max(timeout - timeBuffer, 1);\n\n\t\t// Set up timer to reject near the test timeout.\n\t\tthis.timer = setTimeout(() => {\n\t\t\tthis.deferred.reject(this);\n\t\t\tthis.rejected = true;\n\t\t}, this.timeout);\n\t}\n\tprivate clearTimer() {\n\t\tif (this.timer) {\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = undefined;\n\t\t}\n\t}\n}\n\n// only register if we are running with mocha-test-setup loaded\nif (globalThis.getMochaModule !== undefined) {\n\t// patching resetTimeout and clearTimeout on the runnable object\n\t// so we can track when test timeout are enforced\n\tconst mochaModule = globalThis.getMochaModule() as typeof Mocha;\n\tconst runnablePrototype = mochaModule.Runnable.prototype;\n\t// eslint-disable-next-line @typescript-eslint/unbound-method\n\tconst oldResetTimeoutFunc = runnablePrototype.resetTimeout;\n\trunnablePrototype.resetTimeout = function (this: Mocha.Runnable) {\n\t\toldResetTimeoutFunc.call(this);\n\t\tTestTimeout.reset(this);\n\t};\n\t// eslint-disable-next-line @typescript-eslint/unbound-method\n\tconst oldClearTimeoutFunc = runnablePrototype.clearTimeout;\n\trunnablePrototype.clearTimeout = function (this: Mocha.Runnable) {\n\t\tTestTimeout.clear();\n\t\toldClearTimeoutFunc.call(this);\n\t};\n}\n\nexport interface TimeoutWithError {\n\t/**\n\t * Timeout duration in milliseconds, if it is great than 0 and not Infinity\n\t * If it is undefined, then it will use test timeout if we are in side the test function\n\t * Otherwise, there is no timeout\n\t */\n\tdurationMs?: number;\n\treject?: true;\n\terrorMsg?: string;\n}\nexport interface TimeoutWithValue<T = void> {\n\t/**\n\t * Timeout duration in milliseconds, if it is great than 0 and not Infinity\n\t * If it is undefined, then it will use test timeout if we are in side the test function\n\t * Otherwise, there is no timeout\n\t */\n\tdurationMs?: number;\n\treject: false;\n\tvalue: T;\n}\n\nexport type PromiseExecutor<T = void> = (\n\tresolve: (value: T | PromiseLike<T>) => void,\n\treject: (reason?: any) => void,\n) => void;\n\n/**\n * Wraps the given promise around with promise that will complete after a specific timeout if the original promise does\n * not resolve by then. By default, it uses the mocha test timeout and complete the promise just before that so that\n * tests don't time out because of unpredictable awaits.\n * The timeout can be overridden via timeoutOptions but it's recommended to use the default value.\n * @param promise - The promise to be awaited.\n * @param timeoutOptions - Options that can be used to override the timeout and / or define the behavior\n * when the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a\n * specific value.\n * @returns A new promise that will complete when the given promise resolves or the timeout expires.\n */\nexport async function timeoutAwait<T = void>(\n\tpromise: PromiseLike<T>,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n): Promise<T> {\n\treturn Promise.race([promise, timeoutPromise<T>(() => {}, timeoutOptions)]);\n}\n\n/**\n * Creates a promise from the given executor that will complete after a specific timeout. By default, it uses the mocha\n * test timeout and complete the promise just before that so that tests don't time out because of unpredictable awaits.\n * The timeout can be overridden via timeoutOptions but it's recommended to use the default value.\n * @param executor - The executor for the promise.\n * @param timeoutOptions - Options that can be used to override the timeout and / or define the behavior when\n * the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a specific value.\n * @returns A new promise that will complete when the given executor resolves or the timeout expires.\n */\nexport async function timeoutPromise<T = void>(\n\texecutor: (\n\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\treject: (reason?: any) => void,\n\t) => void,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n): Promise<T> {\n\t// create the timeout error outside the async task, so its callstack includes\n\t// the original call site, this makes it easier to debug\n\tconst err =\n\t\ttimeoutOptions.reject === false\n\t\t\t? undefined\n\t\t\t: new Error(timeoutOptions.errorMsg ?? \"Timed out\");\n\tconst executorPromise = getTimeoutPromise(executor, timeoutOptions, err);\n\n\tconst currentTestTimeout = TestTimeout.getInstance();\n\tif (currentTestTimeout === undefined) {\n\t\treturn executorPromise;\n\t}\n\n\treturn Promise.race([executorPromise, currentTestTimeout.getPromise()]).catch((e) => {\n\t\tif (e === currentTestTimeout) {\n\t\t\tif (timeoutOptions.reject !== false) {\n\t\t\t\t// If the rejection is because of the timeout then\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst errorObject = err!;\n\t\t\t\terrorObject.message = `${\n\t\t\t\t\ttimeoutOptions.errorMsg ?? \"Test timed out\"\n\t\t\t\t} (${currentTestTimeout.getTimeout()}ms)`;\n\t\t\t\tthrow errorObject;\n\t\t\t}\n\t\t\treturn timeoutOptions.value;\n\t\t}\n\t\tthrow e;\n\t}) as Promise<T>;\n}\n\n// Create a promise based on the timeout options\nasync function getTimeoutPromise<T = void>(\n\texecutor: (\n\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\treject: (reason?: any) => void,\n\t) => void,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T>,\n\terr: Error | undefined,\n) {\n\tconst timeout = timeoutOptions.durationMs ?? 0;\n\tif (timeout <= 0 || !Number.isFinite(timeout)) {\n\t\treturn new Promise(executor);\n\t}\n\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst timeoutRejections = () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst errorObject = err!;\n\t\t\terrorObject.message = `${errorObject.message} (${timeout}ms)`;\n\t\t\treject(err);\n\t\t};\n\t\tconst timer = setTimeout(\n\t\t\t() =>\n\t\t\t\ttimeoutOptions.reject === false\n\t\t\t\t\t? resolve(timeoutOptions.value)\n\t\t\t\t\t: timeoutRejections(),\n\t\t\ttimeout,\n\t\t);\n\n\t\texecutor(\n\t\t\t(value) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve(value);\n\t\t\t},\n\t\t\t(reason) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\treject(reason);\n\t\t\t},\n\t\t);\n\t});\n}\n"]}
1
+ {"version":3,"file":"timeoutUtils.js","sourceRoot":"","sources":["../src/timeoutUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAA8D;AAE9D,2CAA2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Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/core-utils\";\n\n// @deprecated this value is no longer used\n/**\n * @internal\n */\nexport const defaultTimeoutDurationMs = 250;\n\nconst timeBuffer = 15; // leave 15 ms leeway for finish processing\n\n// TestTimeout class that manages tracking of test timeout. It creates a timer when timeout is in effect,\n// and provides a promise that will be rejected some time (as defined by `timeBuffer`) before the test timeout happens.\n// This will ensure that async awaits in tests do not end up timing out the tests but resolve / reject\n// before that happens.\n// Once rejected, a new TestTimeout object will be create for the timeout.\nclass TestTimeout {\n\tprivate timeout: number = 0;\n\tprivate timer: NodeJS.Timeout | undefined;\n\tprivate readonly deferred: Deferred<void>;\n\tprivate rejected = false;\n\n\tprivate static instance: TestTimeout = new TestTimeout();\n\tpublic static reset(runnable: Mocha.Runnable) {\n\t\tTestTimeout.clear();\n\t\tTestTimeout.instance.resetTimer(runnable);\n\t}\n\n\tpublic static clear() {\n\t\tif (TestTimeout.instance.rejected) {\n\t\t\tTestTimeout.instance = new TestTimeout();\n\t\t} else {\n\t\t\tTestTimeout.instance.clearTimer();\n\t\t}\n\t}\n\n\tpublic static getInstance() {\n\t\treturn TestTimeout.instance;\n\t}\n\n\tpublic async getPromise() {\n\t\treturn this.deferred.promise;\n\t}\n\n\tpublic getTimeout() {\n\t\treturn this.timeout;\n\t}\n\n\tprivate constructor() {\n\t\tthis.deferred = new Deferred();\n\t\t// Ignore rejection for timeout promise if no one is waiting for it.\n\t\tthis.deferred.promise.catch(() => {});\n\t}\n\n\tprivate resetTimer(runnable: Mocha.Runnable) {\n\t\tassert(!this.timer, \"clearTimer should have been called before reset\");\n\t\tassert(!this.deferred.isCompleted, \"can't reset a completed TestTimeout\");\n\n\t\t// Check the test timeout setting\n\t\tconst timeout = runnable.timeout();\n\t\tif (!(Number.isFinite(timeout) && timeout > 0)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// subtract a buffer\n\t\tthis.timeout = Math.max(timeout - timeBuffer, 1);\n\n\t\t// Set up timer to reject near the test timeout.\n\t\tthis.timer = setTimeout(() => {\n\t\t\tthis.deferred.reject(this);\n\t\t\tthis.rejected = true;\n\t\t}, this.timeout);\n\t}\n\tprivate clearTimer() {\n\t\tif (this.timer) {\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = undefined;\n\t\t}\n\t}\n}\n\n// only register if we are running with mocha-test-setup loaded\nif (globalThis.getMochaModule !== undefined) {\n\t// patching resetTimeout and clearTimeout on the runnable object\n\t// so we can track when test timeout are enforced\n\tconst mochaModule = globalThis.getMochaModule() as typeof Mocha;\n\tconst runnablePrototype = mochaModule.Runnable.prototype;\n\t// eslint-disable-next-line @typescript-eslint/unbound-method\n\tconst oldResetTimeoutFunc = runnablePrototype.resetTimeout;\n\trunnablePrototype.resetTimeout = function (this: Mocha.Runnable) {\n\t\toldResetTimeoutFunc.call(this);\n\t\tTestTimeout.reset(this);\n\t};\n\t// eslint-disable-next-line @typescript-eslint/unbound-method\n\tconst oldClearTimeoutFunc = runnablePrototype.clearTimeout;\n\trunnablePrototype.clearTimeout = function (this: Mocha.Runnable) {\n\t\tTestTimeout.clear();\n\t\toldClearTimeoutFunc.call(this);\n\t};\n}\n\n/**\n * @internal\n */\nexport interface TimeoutWithError {\n\t/**\n\t * Timeout duration in milliseconds, if it is great than 0 and not Infinity\n\t * If it is undefined, then it will use test timeout if we are in side the test function\n\t * Otherwise, there is no timeout\n\t */\n\tdurationMs?: number;\n\treject?: true;\n\terrorMsg?: string;\n}\n/**\n * @internal\n */\nexport interface TimeoutWithValue<T = void> {\n\t/**\n\t * Timeout duration in milliseconds, if it is great than 0 and not Infinity\n\t * If it is undefined, then it will use test timeout if we are in side the test function\n\t * Otherwise, there is no timeout\n\t */\n\tdurationMs?: number;\n\treject: false;\n\tvalue: T;\n}\n\nexport type PromiseExecutor<T = void> = (\n\tresolve: (value: T | PromiseLike<T>) => void,\n\treject: (reason?: any) => void,\n) => void;\n\n/**\n * Wraps the given promise around with promise that will complete after a specific timeout if the original promise does\n * not resolve by then. By default, it uses the mocha test timeout and complete the promise just before that so that\n * tests don't time out because of unpredictable awaits.\n * The timeout can be overridden via timeoutOptions but it's recommended to use the default value.\n * @param promise - The promise to be awaited.\n * @param timeoutOptions - Options that can be used to override the timeout and / or define the behavior\n * when the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a\n * specific value.\n * @returns A new promise that will complete when the given promise resolves or the timeout expires.\n * @internal\n */\nexport async function timeoutAwait<T = void>(\n\tpromise: PromiseLike<T>,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n): Promise<T> {\n\treturn Promise.race([promise, timeoutPromise<T>(() => {}, timeoutOptions)]);\n}\n\n/**\n * Creates a promise from the given executor that will complete after a specific timeout. By default, it uses the mocha\n * test timeout and complete the promise just before that so that tests don't time out because of unpredictable awaits.\n * The timeout can be overridden via timeoutOptions but it's recommended to use the default value.\n * @param executor - The executor for the promise.\n * @param timeoutOptions - Options that can be used to override the timeout and / or define the behavior when\n * the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a specific value.\n * @returns A new promise that will complete when the given executor resolves or the timeout expires.\n * @internal\n */\nexport async function timeoutPromise<T = void>(\n\texecutor: (\n\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\treject: (reason?: any) => void,\n\t) => void,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n): Promise<T> {\n\t// create the timeout error outside the async task, so its callstack includes\n\t// the original call site, this makes it easier to debug\n\tconst err =\n\t\ttimeoutOptions.reject === false\n\t\t\t? undefined\n\t\t\t: new Error(timeoutOptions.errorMsg ?? \"Timed out\");\n\tconst executorPromise = getTimeoutPromise(executor, timeoutOptions, err);\n\n\tconst currentTestTimeout = TestTimeout.getInstance();\n\tif (currentTestTimeout === undefined) {\n\t\treturn executorPromise;\n\t}\n\n\treturn Promise.race([executorPromise, currentTestTimeout.getPromise()]).catch((e) => {\n\t\tif (e === currentTestTimeout) {\n\t\t\tif (timeoutOptions.reject !== false) {\n\t\t\t\t// If the rejection is because of the timeout then\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst errorObject = err!;\n\t\t\t\terrorObject.message = `${\n\t\t\t\t\ttimeoutOptions.errorMsg ?? \"Test timed out\"\n\t\t\t\t} (${currentTestTimeout.getTimeout()}ms)`;\n\t\t\t\tthrow errorObject;\n\t\t\t}\n\t\t\treturn timeoutOptions.value;\n\t\t}\n\t\tthrow e;\n\t}) as Promise<T>;\n}\n\n// Create a promise based on the timeout options\nasync function getTimeoutPromise<T = void>(\n\texecutor: (\n\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\treject: (reason?: any) => void,\n\t) => void,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T>,\n\terr: Error | undefined,\n) {\n\tconst timeout = timeoutOptions.durationMs ?? 0;\n\tif (timeout <= 0 || !Number.isFinite(timeout)) {\n\t\treturn new Promise(executor);\n\t}\n\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst timeoutRejections = () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst errorObject = err!;\n\t\t\terrorObject.message = `${errorObject.message} (${timeout}ms)`;\n\t\t\treject(err);\n\t\t};\n\t\tconst timer = setTimeout(\n\t\t\t() =>\n\t\t\t\ttimeoutOptions.reject === false\n\t\t\t\t\t? resolve(timeoutOptions.value)\n\t\t\t\t\t: timeoutRejections(),\n\t\t\ttimeout,\n\t\t);\n\n\t\texecutor(\n\t\t\t(value) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve(value);\n\t\t\t},\n\t\t\t(reason) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\treject(reason);\n\t\t\t},\n\t\t);\n\t});\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.38.0"
8
+ "packageVersion": "7.38.3"
9
9
  }
10
10
  ]
11
11
  }
@@ -0,0 +1,140 @@
1
+ import { ConfigTypes } from '@fluidframework/core-interfaces';
2
+ import { ContainerRuntime } from '@fluidframework/container-runtime';
3
+ import { ContainerRuntimeFactoryWithDefaultDataStore } from '@fluidframework/aqueduct';
4
+ import { FluidDataStoreRuntime } from '@fluidframework/datastore';
5
+ import { FluidObject } from '@fluidframework/core-interfaces';
6
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
7
+ import { ICodeDetailsLoader } from '@fluidframework/container-definitions';
8
+ import { IConfigProviderBase } from '@fluidframework/core-interfaces';
9
+ import { IContainer } from '@fluidframework/container-definitions';
10
+ import { IContainerContext } from '@fluidframework/container-definitions';
11
+ import { IContainerRuntime } from '@fluidframework/container-runtime-definitions';
12
+ import { IContainerRuntimeOptions } from '@fluidframework/container-runtime';
13
+ import { IDataStore } from '@fluidframework/runtime-definitions';
14
+ import { IDocumentService } from '@fluidframework/driver-definitions';
15
+ import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
16
+ import { IDocumentStorageService } from '@fluidframework/driver-definitions';
17
+ import { IFluidCodeDetails } from '@fluidframework/container-definitions';
18
+ import { IFluidDataStoreChannel } from '@fluidframework/runtime-definitions';
19
+ import { IFluidDataStoreContext } from '@fluidframework/runtime-definitions';
20
+ import { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
21
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
22
+ import { IFluidHandle } from '@fluidframework/core-interfaces';
23
+ import { IFluidLoadable } from '@fluidframework/core-interfaces';
24
+ import { IFluidModule } from '@fluidframework/container-definitions';
25
+ import { IFluidModuleWithDetails } from '@fluidframework/container-definitions';
26
+ import { IHostLoader } from '@fluidframework/container-definitions';
27
+ import { ILoaderOptions } from '@fluidframework/container-definitions';
28
+ import { ILoaderProps } from '@fluidframework/container-loader';
29
+ import { IOnDemandSummarizeOptions } from '@fluidframework/container-runtime';
30
+ import { IProvideFluidCodeDetailsComparer } from '@fluidframework/container-definitions';
31
+ import { IProvideFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
32
+ import { IProvideFluidDataStoreRegistry } from '@fluidframework/runtime-definitions';
33
+ import { IProvideRuntimeFactory } from '@fluidframework/container-definitions';
34
+ import { IRequest } from '@fluidframework/core-interfaces';
35
+ import { IRequestHeader } from '@fluidframework/core-interfaces';
36
+ import { IResolvedUrl } from '@fluidframework/driver-definitions';
37
+ import { IResponse } from '@fluidframework/core-interfaces';
38
+ import { IRuntime } from '@fluidframework/container-definitions';
39
+ import { ISharedMap } from '@fluidframework/map';
40
+ import { ISummarizer } from '@fluidframework/container-runtime';
41
+ import { ISummaryContext } from '@fluidframework/driver-definitions';
42
+ import { ISummaryTree } from '@fluidframework/protocol-definitions';
43
+ import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
44
+ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
45
+ import { ITelemetryGenericEvent } from '@fluidframework/core-interfaces';
46
+ import { ITestDriver } from '@fluidframework/test-driver-definitions';
47
+ import { IUrlResolver } from '@fluidframework/driver-definitions';
48
+ import { Loader } from '@fluidframework/container-loader';
49
+ import { NamedFluidDataStoreRegistryEntries } from '@fluidframework/runtime-definitions';
50
+ import { RuntimeRequestHandler } from '@fluidframework/request-handler';
51
+
52
+ /* Excluded from this release type: ChannelFactoryRegistry */
53
+
54
+ /* Excluded from this release type: createAndAttachContainer */
55
+
56
+ /* Excluded from this release type: createContainerRuntimeFactoryWithDefaultDataStore */
57
+
58
+ /* Excluded from this release type: createDocumentId */
59
+
60
+ /* Excluded from this release type: createLoader */
61
+
62
+ /* Excluded from this release type: createSummarizer */
63
+
64
+ /* Excluded from this release type: createSummarizerFromFactory */
65
+
66
+ /* Excluded from this release type: createTestContainerRuntimeFactory */
67
+
68
+ /* Excluded from this release type: DataObjectFactoryType */
69
+
70
+ /* Excluded from this release type: defaultTimeoutDurationMs */
71
+
72
+ /* Excluded from this release type: EventAndErrorTrackingLogger */
73
+
74
+ /* Excluded from this release type: fluidEntryPoint */
75
+
76
+ /* Excluded from this release type: getContainerEntryPointBackCompat */
77
+
78
+ /* Excluded from this release type: getDataStoreEntryPointBackCompat */
79
+
80
+ /* Excluded from this release type: getUnexpectedLogErrorException */
81
+
82
+ /* Excluded from this release type: ICodeDetailsLoader */
83
+
84
+ /* Excluded from this release type: IDocumentIdStrategy */
85
+
86
+ /* Excluded from this release type: IFluidModuleWithDetails */
87
+
88
+ /* Excluded from this release type: IOpProcessingController */
89
+
90
+ /* Excluded from this release type: IProvideTestFluidObject */
91
+
92
+ /* Excluded from this release type: ISummarizer */
93
+
94
+ /* Excluded from this release type: ITestContainerConfig */
95
+
96
+ /* Excluded from this release type: ITestDriver */
97
+
98
+ /* Excluded from this release type: ITestFluidObject */
99
+
100
+ /* Excluded from this release type: ITestObjectProvider */
101
+
102
+ /* Excluded from this release type: LoaderContainerTracker */
103
+
104
+ /* Excluded from this release type: LocalCodeLoader */
105
+
106
+ /* Excluded from this release type: mockConfigProvider */
107
+
108
+ /* Excluded from this release type: retryWithEventualValue */
109
+
110
+ /* Excluded from this release type: summarizeNow */
111
+
112
+ /* Excluded from this release type: SupportedExportInterfaces */
113
+
114
+ /* Excluded from this release type: TestContainerRuntimeFactory */
115
+
116
+ /* Excluded from this release type: TestFluidObject */
117
+
118
+ /* Excluded from this release type: TestFluidObjectFactory */
119
+
120
+ /* Excluded from this release type: TestObjectProvider */
121
+
122
+ /* Excluded from this release type: TestObjectProviderWithVersionedLoad */
123
+
124
+ /* Excluded from this release type: timeoutAwait */
125
+
126
+ /* Excluded from this release type: timeoutPromise */
127
+
128
+ /* Excluded from this release type: TimeoutWithError */
129
+
130
+ /* Excluded from this release type: TimeoutWithValue */
131
+
132
+ /* Excluded from this release type: waitForContainerConnection */
133
+
134
+ /* Excluded from this release type: wrapDocumentService */
135
+
136
+ /* Excluded from this release type: wrapDocumentServiceFactory */
137
+
138
+ /* Excluded from this release type: wrapDocumentStorageService */
139
+
140
+ export { }
@@ -0,0 +1,228 @@
1
+ import { ConfigTypes } from '@fluidframework/core-interfaces';
2
+ import { ContainerRuntime } from '@fluidframework/container-runtime';
3
+ import { ContainerRuntimeFactoryWithDefaultDataStore } from '@fluidframework/aqueduct';
4
+ import { FluidDataStoreRuntime } from '@fluidframework/datastore';
5
+ import { FluidObject } from '@fluidframework/core-interfaces';
6
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
7
+ import { ICodeDetailsLoader } from '@fluidframework/container-definitions';
8
+ import { IConfigProviderBase } from '@fluidframework/core-interfaces';
9
+ import { IContainer } from '@fluidframework/container-definitions';
10
+ import { IContainerContext } from '@fluidframework/container-definitions';
11
+ import { IContainerRuntime } from '@fluidframework/container-runtime-definitions';
12
+ import { IContainerRuntimeOptions } from '@fluidframework/container-runtime';
13
+ import { IDataStore } from '@fluidframework/runtime-definitions';
14
+ import { IDocumentService } from '@fluidframework/driver-definitions';
15
+ import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
16
+ import { IDocumentStorageService } from '@fluidframework/driver-definitions';
17
+ import { IFluidCodeDetails } from '@fluidframework/container-definitions';
18
+ import { IFluidDataStoreChannel } from '@fluidframework/runtime-definitions';
19
+ import { IFluidDataStoreContext } from '@fluidframework/runtime-definitions';
20
+ import { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
21
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
22
+ import { IFluidHandle } from '@fluidframework/core-interfaces';
23
+ import { IFluidLoadable } from '@fluidframework/core-interfaces';
24
+ import { IFluidModule } from '@fluidframework/container-definitions';
25
+ import { IFluidModuleWithDetails } from '@fluidframework/container-definitions';
26
+ import { IHostLoader } from '@fluidframework/container-definitions';
27
+ import { ILoaderOptions } from '@fluidframework/container-definitions';
28
+ import { ILoaderProps } from '@fluidframework/container-loader';
29
+ import { IOnDemandSummarizeOptions } from '@fluidframework/container-runtime';
30
+ import { IProvideFluidCodeDetailsComparer } from '@fluidframework/container-definitions';
31
+ import { IProvideFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
32
+ import { IProvideFluidDataStoreRegistry } from '@fluidframework/runtime-definitions';
33
+ import { IProvideRuntimeFactory } from '@fluidframework/container-definitions';
34
+ import { IRequest } from '@fluidframework/core-interfaces';
35
+ import { IRequestHeader } from '@fluidframework/core-interfaces';
36
+ import { IResolvedUrl } from '@fluidframework/driver-definitions';
37
+ import { IResponse } from '@fluidframework/core-interfaces';
38
+ import { IRuntime } from '@fluidframework/container-definitions';
39
+ import { ISharedMap } from '@fluidframework/map';
40
+ import { ISummarizer } from '@fluidframework/container-runtime';
41
+ import { ISummaryContext } from '@fluidframework/driver-definitions';
42
+ import { ISummaryTree } from '@fluidframework/protocol-definitions';
43
+ import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
44
+ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
45
+ import { ITelemetryGenericEvent } from '@fluidframework/core-interfaces';
46
+ import { ITestDriver } from '@fluidframework/test-driver-definitions';
47
+ import { IUrlResolver } from '@fluidframework/driver-definitions';
48
+ import { Loader } from '@fluidframework/container-loader';
49
+ import { NamedFluidDataStoreRegistryEntries } from '@fluidframework/runtime-definitions';
50
+ import { RuntimeRequestHandler } from '@fluidframework/request-handler';
51
+
52
+ /* Excluded from this release type: ChannelFactoryRegistry */
53
+
54
+ /* Excluded from this release type: ConfigTypes */
55
+
56
+ /* Excluded from this release type: ContainerRuntime */
57
+
58
+ /* Excluded from this release type: ContainerRuntimeFactoryWithDefaultDataStore */
59
+
60
+ /* Excluded from this release type: createAndAttachContainer */
61
+
62
+ /* Excluded from this release type: createContainerRuntimeFactoryWithDefaultDataStore */
63
+
64
+ /* Excluded from this release type: createDocumentId */
65
+
66
+ /* Excluded from this release type: createLoader */
67
+
68
+ /* Excluded from this release type: createSummarizer */
69
+
70
+ /* Excluded from this release type: createSummarizerFromFactory */
71
+
72
+ /* Excluded from this release type: createTestContainerRuntimeFactory */
73
+
74
+ /* Excluded from this release type: DataObjectFactoryType */
75
+
76
+ /* Excluded from this release type: defaultTimeoutDurationMs */
77
+
78
+ /* Excluded from this release type: EventAndErrorTrackingLogger */
79
+
80
+ /* Excluded from this release type: FluidDataStoreRuntime */
81
+
82
+ /* Excluded from this release type: fluidEntryPoint */
83
+
84
+ /* Excluded from this release type: FluidObject */
85
+
86
+ /* Excluded from this release type: getContainerEntryPointBackCompat */
87
+
88
+ /* Excluded from this release type: getDataStoreEntryPointBackCompat */
89
+
90
+ /* Excluded from this release type: getUnexpectedLogErrorException */
91
+
92
+ /* Excluded from this release type: IChannelFactory */
93
+
94
+ /* Excluded from this release type: ICodeDetailsLoader */
95
+
96
+ /* Excluded from this release type: IConfigProviderBase */
97
+
98
+ /* Excluded from this release type: IContainer */
99
+
100
+ /* Excluded from this release type: IContainerContext */
101
+
102
+ /* Excluded from this release type: IContainerRuntime */
103
+
104
+ /* Excluded from this release type: IContainerRuntimeOptions */
105
+
106
+ /* Excluded from this release type: IDataStore */
107
+
108
+ /* Excluded from this release type: IDocumentIdStrategy */
109
+
110
+ /* Excluded from this release type: IDocumentService */
111
+
112
+ /* Excluded from this release type: IDocumentServiceFactory */
113
+
114
+ /* Excluded from this release type: IDocumentStorageService */
115
+
116
+ /* Excluded from this release type: IFluidCodeDetails */
117
+
118
+ /* Excluded from this release type: IFluidDataStoreChannel */
119
+
120
+ /* Excluded from this release type: IFluidDataStoreContext */
121
+
122
+ /* Excluded from this release type: IFluidDataStoreFactory */
123
+
124
+ /* Excluded from this release type: IFluidDataStoreRuntime */
125
+
126
+ /* Excluded from this release type: IFluidHandle */
127
+
128
+ /* Excluded from this release type: IFluidLoadable */
129
+
130
+ /* Excluded from this release type: IFluidModule */
131
+
132
+ /* Excluded from this release type: IFluidModuleWithDetails */
133
+
134
+ /* Excluded from this release type: IHostLoader */
135
+
136
+ /* Excluded from this release type: ILoaderOptions */
137
+
138
+ /* Excluded from this release type: ILoaderProps */
139
+
140
+ /* Excluded from this release type: IOnDemandSummarizeOptions */
141
+
142
+ /* Excluded from this release type: IOpProcessingController */
143
+
144
+ /* Excluded from this release type: IProvideFluidCodeDetailsComparer */
145
+
146
+ /* Excluded from this release type: IProvideFluidDataStoreFactory */
147
+
148
+ /* Excluded from this release type: IProvideFluidDataStoreRegistry */
149
+
150
+ /* Excluded from this release type: IProvideRuntimeFactory */
151
+
152
+ /* Excluded from this release type: IProvideTestFluidObject */
153
+
154
+ /* Excluded from this release type: IRequest */
155
+
156
+ /* Excluded from this release type: IResolvedUrl */
157
+
158
+ /* Excluded from this release type: IResponse */
159
+
160
+ /* Excluded from this release type: IRuntime */
161
+
162
+ /* Excluded from this release type: ISharedMap */
163
+
164
+ /* Excluded from this release type: ISummarizer */
165
+
166
+ /* Excluded from this release type: ISummaryContext */
167
+
168
+ /* Excluded from this release type: ITelemetryBaseEvent */
169
+
170
+ /* Excluded from this release type: ITelemetryBaseLogger */
171
+
172
+ /* Excluded from this release type: ITelemetryGenericEvent */
173
+
174
+ /* Excluded from this release type: ITestContainerConfig */
175
+
176
+ /* Excluded from this release type: ITestDriver */
177
+
178
+ /* Excluded from this release type: ITestFluidObject */
179
+
180
+ /* Excluded from this release type: ITestObjectProvider */
181
+
182
+ /* Excluded from this release type: IUrlResolver */
183
+
184
+ /* Excluded from this release type: Loader */
185
+
186
+ /* Excluded from this release type: LoaderContainerTracker */
187
+
188
+ /* Excluded from this release type: LocalCodeLoader */
189
+
190
+ /* Excluded from this release type: mockConfigProvider */
191
+
192
+ /* Excluded from this release type: NamedFluidDataStoreRegistryEntries */
193
+
194
+ /* Excluded from this release type: retryWithEventualValue */
195
+
196
+ /* Excluded from this release type: RuntimeRequestHandler */
197
+
198
+ /* Excluded from this release type: summarizeNow */
199
+
200
+ /* Excluded from this release type: SupportedExportInterfaces */
201
+
202
+ /* Excluded from this release type: TestContainerRuntimeFactory */
203
+
204
+ /* Excluded from this release type: TestFluidObject */
205
+
206
+ /* Excluded from this release type: TestFluidObjectFactory */
207
+
208
+ /* Excluded from this release type: TestObjectProvider */
209
+
210
+ /* Excluded from this release type: TestObjectProviderWithVersionedLoad */
211
+
212
+ /* Excluded from this release type: timeoutAwait */
213
+
214
+ /* Excluded from this release type: timeoutPromise */
215
+
216
+ /* Excluded from this release type: TimeoutWithError */
217
+
218
+ /* Excluded from this release type: TimeoutWithValue */
219
+
220
+ /* Excluded from this release type: waitForContainerConnection */
221
+
222
+ /* Excluded from this release type: wrapDocumentService */
223
+
224
+ /* Excluded from this release type: wrapDocumentServiceFactory */
225
+
226
+ /* Excluded from this release type: wrapDocumentStorageService */
227
+
228
+ export { }