@fluidframework/test-utils 2.117.0 → 3.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.
- package/CHANGELOG.md +64 -2
- package/README.md +53 -50
- package/{api-extractor.json → api-extractor/api-extractor-model.json} +1 -1
- package/dist/TestConfigs.d.ts.map +1 -1
- package/dist/TestSummaryUtils.d.ts.map +1 -1
- package/dist/TestSummaryUtils.js +6 -5
- package/dist/TestSummaryUtils.js.map +1 -1
- package/dist/containerRuntimeFactories.d.ts.map +1 -1
- package/dist/containerRuntimeFactories.js +23 -2
- package/dist/containerRuntimeFactories.js.map +1 -1
- package/dist/containerUtils.js +5 -6
- package/dist/containerUtils.js.map +1 -1
- package/dist/eventAndErrorLogger.d.ts +2 -2
- package/dist/eventAndErrorLogger.d.ts.map +1 -1
- package/dist/eventAndErrorLogger.js +20 -19
- package/dist/eventAndErrorLogger.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/loaderContainerTracker.js +3 -2
- package/dist/loaderContainerTracker.js.map +1 -1
- package/dist/localCodeLoader.js +3 -3
- package/dist/localCodeLoader.js.map +1 -1
- package/dist/localLoader.js +4 -5
- package/dist/localLoader.js.map +1 -1
- package/dist/nonEmptyArrayType.js +1 -2
- package/dist/nonEmptyArrayType.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/retry.d.ts.map +1 -1
- package/dist/testCompatibility.d.ts +12 -0
- package/dist/testCompatibility.d.ts.map +1 -0
- package/dist/testCompatibility.js +16 -0
- package/dist/testCompatibility.js.map +1 -0
- package/dist/testContainerRuntimeFactory.d.ts +6 -6
- package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
- package/dist/testContainerRuntimeFactory.js +7 -1
- package/dist/testContainerRuntimeFactory.js.map +1 -1
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +17 -4
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js +16 -6
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
- package/dist/testFluidObject.js +10 -0
- package/dist/testFluidObject.js.map +1 -1
- package/dist/testFluidObjectInternal.js +6 -0
- package/dist/testFluidObjectInternal.js.map +1 -1
- package/dist/testObjectProvider.d.ts.map +1 -1
- package/dist/testObjectProvider.js +44 -23
- package/dist/testObjectProvider.js.map +1 -1
- package/dist/timeoutUtils.js +7 -8
- package/dist/timeoutUtils.js.map +1 -1
- package/lib/TestConfigs.d.ts.map +1 -1
- package/lib/TestSummaryUtils.d.ts.map +1 -1
- package/lib/TestSummaryUtils.js +2 -0
- package/lib/TestSummaryUtils.js.map +1 -1
- package/lib/containerRuntimeFactories.d.ts.map +1 -1
- package/lib/containerRuntimeFactories.js +23 -2
- package/lib/containerRuntimeFactories.js.map +1 -1
- package/lib/eventAndErrorLogger.d.ts +2 -2
- package/lib/eventAndErrorLogger.d.ts.map +1 -1
- package/lib/eventAndErrorLogger.js +18 -17
- package/lib/eventAndErrorLogger.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/loaderContainerTracker.js +3 -2
- package/lib/loaderContainerTracker.js.map +1 -1
- package/lib/localCodeLoader.js +1 -1
- package/lib/localCodeLoader.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/testCompatibility.d.ts +12 -0
- package/lib/testCompatibility.d.ts.map +1 -0
- package/lib/testCompatibility.js +13 -0
- package/lib/testCompatibility.js.map +1 -0
- package/lib/testContainerRuntimeFactory.d.ts +6 -6
- package/lib/testContainerRuntimeFactory.d.ts.map +1 -1
- package/lib/testContainerRuntimeFactory.js +7 -1
- package/lib/testContainerRuntimeFactory.js.map +1 -1
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +17 -4
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js +16 -6
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
- package/lib/testFluidObject.js +10 -0
- package/lib/testFluidObject.js.map +1 -1
- package/lib/testFluidObjectInternal.js +6 -0
- package/lib/testFluidObjectInternal.js.map +1 -1
- package/lib/testObjectProvider.d.ts.map +1 -1
- package/lib/testObjectProvider.js +44 -23
- package/lib/testObjectProvider.js.map +1 -1
- package/lib/timeoutUtils.js +5 -5
- package/lib/timeoutUtils.js.map +1 -1
- package/package.json +53 -58
- package/src/TestSummaryUtils.ts +2 -0
- package/src/containerRuntimeFactories.ts +4 -2
- package/src/eventAndErrorLogger.ts +3 -2
- package/src/index.ts +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/testCompatibility.ts +16 -0
- package/src/testContainerRuntimeFactory.ts +3 -1
- package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +72 -11
- package/src/testObjectProvider.ts +17 -10
- package/tsconfig.json +1 -1
- package/internal.d.ts +0 -11
- package/legacy.d.ts +0 -11
- /package/api-extractor/{api-extractor.current.json → api-extractor-report.current.json} +0 -0
- /package/api-extractor/{api-extractor.legacy.json → api-extractor-report.legacy.json} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,70 @@
|
|
|
1
1
|
# @fluidframework/test-utils
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 3.0.0
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Require oldest supported clients to use Fluid Framework 2.0 or later ([#28127](https://github.com/microsoft/FluidFramework/pull/28127)) [98956144ada](https://github.com/microsoft/FluidFramework/commit/98956144ada9cfc3a278e73adb2d5812b5ce2a67)
|
|
8
|
+
|
|
9
|
+
Client 3.0 narrows
|
|
10
|
+
[`OldestSupportedClientVersion`](https://fluidframework.com/docs/api/runtime-definitions/oldestsupportedclientversion-typealias)
|
|
11
|
+
to stable 2.x versions and 3.x minor checkpoints whose patch is zero. The deprecated
|
|
12
|
+
[`MinimumVersionForCollab`](https://fluidframework.com/docs/api/runtime-definitions/minimumversionforcollab-typealias)
|
|
13
|
+
alias inherits the same restriction and remains available until Client 4.0.
|
|
14
|
+
|
|
15
|
+
Container runtimes now reject values below `"2.0.0"` and prerelease values. APIs that still
|
|
16
|
+
permit the setting to be omitted use `"2.0.0"`, with the same runtime defaults and validation
|
|
17
|
+
as explicitly passing `"2.0.0"`.
|
|
18
|
+
|
|
19
|
+
Before upgrading an application to Client 3.0, upgrade every active deployment that must
|
|
20
|
+
collaborate to Fluid Framework 2.0.0 or later. Explicit compatibility settings must use the
|
|
21
|
+
canonical property or Azure, ODSP, or Tinylicious service-client argument with a stable 2.x
|
|
22
|
+
version or a 3.x minor checkpoint such as `"3.1.0"`:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
const { container } = await azureClient.getContainer(
|
|
26
|
+
id,
|
|
27
|
+
schema,
|
|
28
|
+
"2.0.0", // oldestSupportedClient
|
|
29
|
+
);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
See [microsoft/FluidFramework#27460](https://github.com/microsoft/FluidFramework/issues/27460)
|
|
33
|
+
for migration context.
|
|
34
|
+
|
|
35
|
+
- Removal of direct CommonJS support ([#28124](https://github.com/microsoft/FluidFramework/pull/28124)) [0f84e3b8878](https://github.com/microsoft/FluidFramework/commit/0f84e3b8878a5e75b2253976d98fd963bbd9db88)
|
|
36
|
+
|
|
37
|
+
Direct `require()` import is no longer directly supported.
|
|
38
|
+
Package is transpiled as ECMAScript Module.
|
|
39
|
+
|
|
40
|
+
See [Removal of direct CommonJS support in v3.0](https://github.com/microsoft/FluidFramework/issues/27444) for more information.
|
|
41
|
+
|
|
42
|
+
- Require modern TypeScript module resolution ([#27970](https://github.com/microsoft/FluidFramework/pull/27970)) [325e2016ca9](https://github.com/microsoft/FluidFramework/commit/325e2016ca9978d4a1f7552c97ba34feac9df41f)
|
|
43
|
+
|
|
44
|
+
Fluid Framework Client packages no longer include type declaration compatibility entrypoints for TypeScript's legacy Node10 resolution mode (`"moduleResolution": "node"` or `"node10"`).
|
|
45
|
+
Applications upgrading to Fluid Framework 3.0 must use one of the following supported configurations:
|
|
46
|
+
- `"module": "Node16"` with `"moduleResolution": "Node16"`
|
|
47
|
+
- `"module": "NodeNext"` with `"moduleResolution": "NodeNext"`
|
|
48
|
+
- `"module": "ESNext"` with `"moduleResolution": "Bundler"`
|
|
49
|
+
|
|
50
|
+
Existing public package entrypoints exposed through `package.json` exports, including `/alpha`, `/beta`, and `/legacy`, remain available under supported module resolution modes.
|
|
51
|
+
|
|
52
|
+
See [Removal of Node10 resolutions in v3.0](https://github.com/microsoft/FluidFramework/issues/27457) for more information.
|
|
53
|
+
|
|
54
|
+
- Client packages now target ES2022 ([#27846](https://github.com/microsoft/FluidFramework/pull/27846)) [91c78541bdd](https://github.com/microsoft/FluidFramework/commit/91c78541bddcbca5d6c5f357b023eeaee617d885)
|
|
55
|
+
|
|
56
|
+
The TypeScript compilation `target` and `lib` for the Fluid Framework client packages have been raised from ES2021/ES2020 to **ES2022**.
|
|
57
|
+
The published JavaScript now uses ES2022 language features (with correspondingly less down-leveling), so consuming these packages requires a runtime that supports ES2022.
|
|
58
|
+
All actively supported Node.js versions and evergreen browsers already meet this requirement.
|
|
59
|
+
|
|
60
|
+
Note that Fluid Framework has not officially supported targets older than ES2022 since before 2.0: this is documented in [ClientRequirements.md](https://github.com/microsoft/FluidFramework/blob/main/ClientRequirements.md) as well as the README for every client package.
|
|
61
|
+
|
|
62
|
+
It is possible this change could impact users of less up to date JavaScript runtimes.
|
|
63
|
+
Impacted users can use a tool like [babel](https://babeljs.io/) to transpile out unsupported language features.
|
|
64
|
+
|
|
65
|
+
- Build with TypeScript 6 ([#28052](https://github.com/microsoft/FluidFramework/pull/28052)) [7ab015c49de](https://github.com/microsoft/FluidFramework/commit/7ab015c49deec84833cdfe1fb5e1606b901f6e81)
|
|
66
|
+
|
|
67
|
+
FluidFramework Client SDK is now built using TypeScript 6. Consumers should build with TypeScript v6 or v7 or compatible tooling.
|
|
6
68
|
|
|
7
69
|
## 2.116.0
|
|
8
70
|
|
package/README.md
CHANGED
|
@@ -11,15 +11,15 @@ Internal note: Currently, it also has a load side-effect when loaded under mocha
|
|
|
11
11
|
|
|
12
12
|
## Using Fluid Framework libraries
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
library consumers should always prefer `^`.
|
|
14
|
+
For a dependency on a Fluid Framework library's public APIs, we recommend a `^` (caret) version range.
|
|
15
|
+
For example, use `^1.3.4`.
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
For a dependency on an unstable API, such as a `beta` API, we recommend a more restrictive version range.
|
|
18
|
+
For example, use a `~` version range.
|
|
19
19
|
|
|
20
20
|
## Installation
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Run this command to install the package:
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
25
|
npm i @fluidframework/test-utils -D
|
|
@@ -27,16 +27,16 @@ npm i @fluidframework/test-utils -D
|
|
|
27
27
|
|
|
28
28
|
## Importing from this package
|
|
29
29
|
|
|
30
|
-
This package
|
|
31
|
-
For
|
|
30
|
+
This package uses [package.json exports](https://nodejs.org/api/packages.html#exports) to separate APIs by support level.
|
|
31
|
+
For information about the support guarantees, read [API Support Levels](https://fluidframework.com/docs/build/releases-and-apitags/#api-support-levels).
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Import the `public` APIs from `@fluidframework/test-utils`.
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Import the `legacy` APIs from `@fluidframework/test-utils/legacy`.
|
|
36
36
|
|
|
37
37
|
## API Documentation
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Read the **@fluidframework/test-utils** API documentation at <https://fluidframework.com/docs/apis/test-utils>.
|
|
40
40
|
|
|
41
41
|
<!-- prettier-ignore-end -->
|
|
42
42
|
|
|
@@ -227,62 +227,69 @@ There are a number of other examples (some a little more complex) in the same [d
|
|
|
227
227
|
|
|
228
228
|
## Minimum Client Requirements
|
|
229
229
|
|
|
230
|
-
|
|
231
|
-
These requirements
|
|
232
|
-
|
|
230
|
+
Fluid Framework client libraries support the platforms in this document.
|
|
231
|
+
These requirements are intentionally restrictive.
|
|
232
|
+
Within a major version series, we can relax these requirements, but we cannot make them stricter.
|
|
233
|
+
For a Long Term Support (LTS) version, we might need to support these platforms for several years.
|
|
233
234
|
|
|
234
|
-
|
|
235
|
-
If
|
|
236
|
-
|
|
235
|
+
Other configurations can work, but Fluid Framework does not support them.
|
|
236
|
+
If an unsupported configuration stops working, we do not classify this as a bug.
|
|
237
|
+
To request support for a configuration that is not listed, file an issue.
|
|
238
|
+
The product team will evaluate your request.
|
|
239
|
+
In the issue, specify the current status of the configuration:
|
|
240
|
+
|
|
241
|
+
- The configuration works but needs official support.
|
|
242
|
+
- The configuration does not work and requires changes.
|
|
237
243
|
|
|
238
244
|
### Supported Runtimes
|
|
239
245
|
|
|
240
|
-
-
|
|
241
|
-
-
|
|
242
|
-
-
|
|
246
|
+
- Fluid Framework supports Node.js versions 22 and 24 while they receive [upstream support](https://nodejs.org/en/about/previous-releases).
|
|
247
|
+
- Fluid Framework will stop support for version 22 [when upstream support ends on 2027-04-30](https://github.com/nodejs/release#release-schedule).
|
|
248
|
+
- Fluid Framework does not support Node.js with the `--no-experimental-fetch` flag.
|
|
249
|
+
- Fluid Framework supports modern browsers that support the ES2022 standard library.
|
|
243
250
|
|
|
244
251
|
### Supported Tools
|
|
245
252
|
|
|
246
|
-
- TypeScript
|
|
247
|
-
-
|
|
248
|
-
-
|
|
249
|
-
- [
|
|
250
|
-
-
|
|
251
|
-
|
|
253
|
+
- [TypeScript 6.0](https://typescriptdocs.com/release-notes/TypeScript%206.0):
|
|
254
|
+
- Fluid Framework supports all [`strict`](https://www.typescriptlang.org/tsconfig) options.
|
|
255
|
+
- Set the build targets (`lib`, `target`) to `ES2022` or later.
|
|
256
|
+
- Enable [`strictNullChecks`](https://www.typescriptlang.org/tsconfig).
|
|
257
|
+
- Fluid Framework does not support [configuration options deprecated in TypeScript 6.0](https://typescriptdocs.com/release-notes/TypeScript%206.0#breaking-changes-and-deprecations-in-typescript-6-0).
|
|
258
|
+
- Fluid Framework does not fully support `exactOptionalPropertyTypes`.
|
|
259
|
+
If you enable this option, do not use `in`, `Reflect.has`, `Object.hasOwn`, or `Object.prototype.hasOwnProperty` to narrow members of Fluid Framework types.
|
|
260
|
+
These methods can incorrectly exclude `undefined` from the possible values.
|
|
252
261
|
- [webpack](https://webpack.js.org/) 5
|
|
253
|
-
- We
|
|
254
|
-
Other bundlers
|
|
262
|
+
- We do not require a specific bundler.
|
|
263
|
+
Other bundlers that handle ES Modules can work, but we actively test only webpack.
|
|
255
264
|
|
|
256
265
|
### Module Resolution
|
|
257
266
|
|
|
258
|
-
[`Node16`, `NodeNext`, or `Bundler`](https://www.typescriptlang.org/tsconfig#moduleResolution)
|
|
259
|
-
|
|
267
|
+
In TypeScript `compilerOptions`, use [`Node16`, `Node20`, `NodeNext`, or `Bundler`](https://www.typescriptlang.org/tsconfig#moduleResolution) module resolution.
|
|
268
|
+
These settings follow the [Node.js v12+ ESM Resolution and Loading algorithm](https://nodejs.github.io/nodejs.dev/en/api/v20/esm/#resolution-and-loading-algorithm).
|
|
269
|
+
|
|
270
|
+
Do not use `Node10` module resolution.
|
|
260
271
|
|
|
261
272
|
### Module Formats
|
|
262
273
|
|
|
263
274
|
- ES Modules:
|
|
264
|
-
ES Modules
|
|
265
|
-
-
|
|
266
|
-
|
|
267
|
-
This is done to accommodate some workflows without good ES Module support.
|
|
268
|
-
If you have a workflow you would like included in this list, file an issue.
|
|
269
|
-
Once this list of workflows motivating CommonJS support is empty, we may drop support for CommonJS one year after notice of the change is posted here.
|
|
270
|
-
|
|
271
|
-
- Testing with Jest (which lacks [stable ESM support](https://jestjs.io/docs/ecmascript-modules) due to [unstable APIs in NodeJs](https://github.com/nodejs/node/issues/37648))
|
|
275
|
+
Use ES Modules to consume Fluid Framework client packages, including in Node.js.
|
|
276
|
+
- CommonJS:
|
|
277
|
+
Fluid Framework does not officially support CommonJS in version 3.0 or later.
|
|
272
278
|
|
|
273
279
|
## Contribution Guidelines
|
|
274
280
|
|
|
275
|
-
|
|
281
|
+
You can [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid Framework in these ways:
|
|
276
282
|
|
|
277
|
-
-
|
|
278
|
-
- [Submit
|
|
279
|
-
- Review
|
|
283
|
+
- Answer questions in [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
|
|
284
|
+
- [Submit bug reports](https://github.com/microsoft/FluidFramework/issues) and help verify fixes.
|
|
285
|
+
- Review [source code changes](https://github.com/microsoft/FluidFramework/pulls).
|
|
280
286
|
- [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
|
|
281
287
|
|
|
282
|
-
|
|
288
|
+
For detailed instructions, read the [repo documentation](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Home.md).
|
|
283
289
|
|
|
284
|
-
This project
|
|
285
|
-
For more information
|
|
290
|
+
This project follows the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
291
|
+
For more information, read the [Code of Conduct frequently asked questions](https://opensource.microsoft.com/codeofconduct/faq/).
|
|
292
|
+
For questions or comments, contact [opencode@microsoft.com](mailto:opencode@microsoft.com).
|
|
286
293
|
|
|
287
294
|
This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
|
|
288
295
|
Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
|
|
@@ -290,13 +297,9 @@ Use of Microsoft trademarks or logos in modified versions of this project must n
|
|
|
290
297
|
|
|
291
298
|
## Help
|
|
292
299
|
|
|
293
|
-
|
|
294
|
-
Check out [fluidframework.com](https://fluidframework.com/docs/).
|
|
295
|
-
|
|
296
|
-
Still not finding what you're looking for?
|
|
297
|
-
Please [file an issue](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Contributing/Submitting-Bugs-and-Feature-Requests.md).
|
|
300
|
+
Read the [Fluid Framework documentation](https://fluidframework.com/docs/) for information about Fluid Framework concepts and APIs.
|
|
298
301
|
|
|
299
|
-
|
|
302
|
+
To request information that the documentation does not contain, [create an issue](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Contributing/Submitting-Bugs-and-Feature-Requests.md).
|
|
300
303
|
|
|
301
304
|
## Trademark
|
|
302
305
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "
|
|
3
|
+
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-model.esm.json"
|
|
4
4
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestConfigs.d.ts","sourceRoot":"","sources":["../src/TestConfigs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEnF;;;;;GAKG;AACH,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC/D,yBAAyB;IACzB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAC/C,8BAA8B;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;CAClB;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,
|
|
1
|
+
{"version":3,"file":"TestConfigs.d.ts","sourceRoot":"","sources":["../src/TestConfigs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEnF;;;;;GAKG;AACH,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC/D,yBAAyB;IACzB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAC/C,8BAA8B;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;CAClB;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACpC,WAAU,MAAM,CAAC,MAAM,EAAE,WAAW,CAAM,KACxC,mBAcF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestSummaryUtils.d.ts","sourceRoot":"","sources":["../src/TestSummaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,UAAU,EACV,WAAW,EAEX,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACN,yBAAyB,EACzB,WAAW,EAEX,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACN,mBAAmB,EAGnB,oBAAoB,EACpB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EACN,sBAAsB,EACtB,kCAAkC,EAClC,MAAM,8CAA8C,CAAC;AAMtD,OAAO,EACN,KAAK,sDAAsD,EAE3D,MAAM,sDAAsD,CAAC;
|
|
1
|
+
{"version":3,"file":"TestSummaryUtils.d.ts","sourceRoot":"","sources":["../src/TestSummaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,UAAU,EACV,WAAW,EAEX,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACN,yBAAyB,EACzB,WAAW,EAEX,MAAM,4CAA4C,CAA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ACjC,UAAU,EAAE,WAAW,EACvB,MAAM,GAAE,MAAM,GAAG,yBAA6C,GAC5D,OAAO,CAAC,WAAW,CAAC,CAsCtB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,WAAW,EAAE,YAAY,CAAC;IAC1B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACtB"}
|
package/dist/TestSummaryUtils.js
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.createSummarizerCore = createSummarizerCore;
|
|
8
|
+
exports.createSummarizerFromFactory = createSummarizerFromFactory;
|
|
9
|
+
exports.createSummarizer = createSummarizer;
|
|
10
|
+
exports.summarizeNow = summarizeNow;
|
|
8
11
|
const internal_1 = require("@fluidframework/container-definitions/internal");
|
|
9
12
|
const internal_2 = require("@fluidframework/core-utils/internal");
|
|
10
13
|
const internal_3 = require("@fluidframework/driver-definitions/internal");
|
|
@@ -13,6 +16,7 @@ const TestConfigs_js_1 = require("./TestConfigs.js");
|
|
|
13
16
|
const containerRuntimeFactories_js_1 = require("./containerRuntimeFactories.js");
|
|
14
17
|
const containerUtils_js_1 = require("./containerUtils.js");
|
|
15
18
|
const testContainerRuntimeFactoryWithDefaultDataStore_js_1 = require("./testContainerRuntimeFactoryWithDefaultDataStore.js");
|
|
19
|
+
const testCompatibility_js_1 = require("./testCompatibility.js");
|
|
16
20
|
const timeoutUtils_js_1 = require("./timeoutUtils.js");
|
|
17
21
|
const summarizerClientType = "summarizer";
|
|
18
22
|
/**
|
|
@@ -69,7 +73,6 @@ async function createSummarizerCore(container, loader, summaryVersion) {
|
|
|
69
73
|
summarizer: fluidObject.ISummarizer,
|
|
70
74
|
};
|
|
71
75
|
}
|
|
72
|
-
exports.createSummarizerCore = createSummarizerCore;
|
|
73
76
|
const defaultSummaryOptions = {
|
|
74
77
|
summaryConfigOverrides: {
|
|
75
78
|
state: "disableHeuristics",
|
|
@@ -89,6 +92,7 @@ async function createSummarizerFromFactory(provider, container, dataStoreFactory
|
|
|
89
92
|
// eslint-disable-next-line import-x/no-deprecated
|
|
90
93
|
containerRuntimeFactoryType ?? containerRuntimeFactories_js_1.ContainerRuntimeFactoryWithDefaultDataStore, {
|
|
91
94
|
defaultFactory: dataStoreFactory,
|
|
95
|
+
oldestSupportedClient: testCompatibility_js_1.defaultTestOldestSupportedClient,
|
|
92
96
|
registryEntries: registryEntries ?? [
|
|
93
97
|
[dataStoreFactory.type, Promise.resolve(dataStoreFactory)],
|
|
94
98
|
],
|
|
@@ -100,7 +104,6 @@ async function createSummarizerFromFactory(provider, container, dataStoreFactory
|
|
|
100
104
|
});
|
|
101
105
|
return createSummarizerCore(container, loader, summaryVersion);
|
|
102
106
|
}
|
|
103
|
-
exports.createSummarizerFromFactory = createSummarizerFromFactory;
|
|
104
107
|
/**
|
|
105
108
|
* Creates a summarizer client from the given container and returns the summarizer client's IContainer and ISummarizer.
|
|
106
109
|
* The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.
|
|
@@ -124,7 +127,6 @@ async function createSummarizer(provider, container, config, summaryVersion, log
|
|
|
124
127
|
const loader = provider.makeTestLoader(testContainerConfig);
|
|
125
128
|
return createSummarizerCore(container, loader, summaryVersion);
|
|
126
129
|
}
|
|
127
|
-
exports.createSummarizer = createSummarizer;
|
|
128
130
|
/**
|
|
129
131
|
* Summarizes on demand and returns the summary tree, the version number and the reference sequence number of the
|
|
130
132
|
* submitted summary.
|
|
@@ -164,5 +166,4 @@ async function summarizeNow(summarizer, inputs = "end-to-end test") {
|
|
|
164
166
|
summaryRefSeq: submitResult.data.referenceSequenceNumber,
|
|
165
167
|
};
|
|
166
168
|
}
|
|
167
|
-
exports.summarizeNow = summarizeNow;
|
|
168
169
|
//# sourceMappingURL=T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and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIContainer,\n\tIHostLoader,\n\tLoaderHeader,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tIOnDemandSummarizeOptions,\n\tISummarizer,\n\tISummaryRuntimeOptions,\n} from \"@fluidframework/container-runtime/internal\";\nimport {\n\tIConfigProviderBase,\n\tIRequest,\n\tIResponse,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { DriverHeader } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { createTestConfigProvider } from \"./TestConfigs.js\";\n// eslint-disable-next-line import-x/no-deprecated\nimport { ContainerRuntimeFactoryWithDefaultDataStore } from \"./containerRuntimeFactories.js\";\nimport { waitForContainerConnection } from \"./containerUtils.js\";\nimport {\n\ttype ContainerRuntimeFactoryWithDefaultDataStoreConstructor,\n\tcreateContainerRuntimeFactoryWithDefaultDataStore,\n} from \"./testContainerRuntimeFactoryWithDefaultDataStore.js\";\nimport { ITestContainerConfig, ITestObjectProvider } from \"./testObjectProvider.js\";\nimport { timeoutAwait } from \"./timeoutUtils.js\";\n\nconst summarizerClientType = \"summarizer\";\n\n/**\n * This function should ONLY be used for back compat purposes\n * LTS versions of the Loader/Container will not have the \"getEntryPoint\" method, so we need to fallback to \"request\"\n * This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0\n * @internal\n */\nasync function getSummarizerBackCompat(container: IContainer): Promise<ISummarizer> {\n\tif (container.getEntryPoint !== undefined) {\n\t\tconst entryPoint = await container.getEntryPoint();\n\t\t// Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running\n\t\t// cross-client compat testing scenarios, if we create with 1.X container and load with 2.X then the\n\t\t// function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined\n\t\t// since the container's runtime will be on version 1.X, which does not have an entry point defined.\n\t\tif (entryPoint !== undefined) {\n\t\t\treturn entryPoint as ISummarizer;\n\t\t}\n\t}\n\tconst response: IResponse = await (container as any).request({ url: \"_summarizer\" });\n\tassert(response.status === 200, \"requesting '/' should return default data object\");\n\treturn response.value as ISummarizer;\n}\n\n/**\n * @internal\n */\nexport async function createSummarizerCore(\n\tcontainer: IContainer,\n\tloader: IHostLoader,\n\tsummaryVersion?: string,\n): Promise<{\n\tcontainer: IContainer;\n\tsummarizer: ISummarizer;\n}> {\n\tconst absoluteUrl = await container.getAbsoluteUrl(\"\");\n\tif (absoluteUrl === undefined) {\n\t\tthrow new Error(\"URL could not be resolved\");\n\t}\n\n\tconst request: IRequest = {\n\t\theaders: {\n\t\t\t[LoaderHeader.cache]: false,\n\t\t\t[LoaderHeader.clientDetails]: {\n\t\t\t\tcapabilities: { interactive: false },\n\t\t\t\ttype: summarizerClientType,\n\t\t\t},\n\t\t\t[DriverHeader.summarizingClient]: true,\n\t\t\t[LoaderHeader.version]: summaryVersion,\n\t\t},\n\t\turl: absoluteUrl,\n\t};\n\tconst summarizerContainer = await loader.resolve(request);\n\tawait waitForContainerConnection(summarizerContainer);\n\n\t// Old loaders will not have getEntryPoint API on the container. So, use getSummarizerBackCompat which\n\t// will use request pattern to get the summarizer in these old loaders.\n\tconst fluidObject = await getSummarizerBackCompat(summarizerContainer);\n\tif (fluidObject.ISummarizer === undefined) {\n\t\tthrow new Error(\"Fluid object does not implement ISummarizer\");\n\t}\n\n\treturn {\n\t\tcontainer: summarizerContainer,\n\t\tsummarizer: fluidObject.ISummarizer,\n\t};\n}\n\nconst defaultSummaryOptions: ISummaryRuntimeOptions = {\n\tsummaryConfigOverrides: {\n\t\tstate: \"disableHeuristics\",\n\t\tmaxAckWaitTime: 20000, // Some of the AFR tests take a long time to ack.\n\t\tmaxOpsSinceLastSummary: 7000,\n\t\tinitialSummarizerDelayMs: 0,\n\t},\n};\n\n/**\n * Creates a summarizer client from the given container and data store factory, and returns the summarizer client's\n * IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n * @internal\n */\nexport async function createSummarizerFromFactory(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tdataStoreFactory: IFluidDataStoreFactory,\n\tsummaryVersion?: string,\n\tcontainerRuntimeFactoryType?: ContainerRuntimeFactoryWithDefaultDataStoreConstructor,\n\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\tlogger?: ITelemetryBaseLogger,\n\tconfigProvider: IConfigProviderBase = createTestConfigProvider(),\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(\n\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\tcontainerRuntimeFactoryType ?? ContainerRuntimeFactoryWithDefaultDataStore,\n\t\t{\n\t\t\tdefaultFactory: dataStoreFactory,\n\t\t\tregistryEntries: registryEntries ?? [\n\t\t\t\t[dataStoreFactory.type, Promise.resolve(dataStoreFactory)],\n\t\t\t],\n\t\t\truntimeOptions: { summaryOptions: defaultSummaryOptions },\n\t\t},\n\t);\n\n\tconst loader = provider.createLoader([[provider.defaultCodeDetails, runtimeFactory]], {\n\t\tconfigProvider,\n\t\tlogger,\n\t});\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Creates a summarizer client from the given container and returns the summarizer client's IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n *\n * Can pass in a test config provider to enable/disable features.\n * @internal\n */\nexport async function createSummarizer(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tconfig?: ITestContainerConfig,\n\tsummaryVersion?: string,\n\tlogger?: ITelemetryBaseLogger,\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst testContainerConfig: ITestContainerConfig = {\n\t\t...config,\n\t\truntimeOptions: {\n\t\t\t...config?.runtimeOptions,\n\t\t\tsummaryOptions: config?.runtimeOptions?.summaryOptions ?? defaultSummaryOptions,\n\t\t},\n\t\tloaderProps: {\n\t\t\t...config?.loaderProps,\n\t\t\tconfigProvider: config?.loaderProps?.configProvider ?? createTestConfigProvider(),\n\t\t\tlogger,\n\t\t},\n\t};\n\tconst loader = provider.makeTestLoader(testContainerConfig);\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Summarizes on demand and returns the summary tree, the version number and the reference sequence number of the\n * submitted summary.\n *\n * @param summarizer - The ISummarizer to use to summarize on demand\n * @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.\n * Defaults to the reason \"end-to-end test\".\n * @internal\n */\nexport async function summarizeNow(\n\tsummarizer: ISummarizer,\n\tinputs: string | IOnDemandSummarizeOptions = \"end-to-end test\",\n): Promise<SummaryInfo> {\n\tconst options: IOnDemandSummarizeOptions =\n\t\ttypeof inputs === \"string\" ? { reason: inputs } : inputs;\n\tconst result = summarizer.summarizeOnDemand(options);\n\n\tconst submitResult = await timeoutAwait(result.summarySubmitted, {\n\t\terrorMsg: \"Promise timed out: summarySubmitted\",\n\t});\n\tif (!submitResult.success) {\n\t\tthrow submitResult.error;\n\t}\n\tassert(\n\t\tsubmitResult.data.stage === \"submit\",\n\t\t\"on-demand summary submitted data stage should be submit\",\n\t);\n\tassert(submitResult.data.summaryTree !== undefined, \"summary tree should exist\");\n\n\tconst broadcastResult = await timeoutAwait(result.summaryOpBroadcasted, {\n\t\terrorMsg: \"Promise timed out: summaryOpBroadcasted\",\n\t});\n\tif (!broadcastResult.success) {\n\t\tthrow broadcastResult.error;\n\t}\n\n\tconst ackNackResult = await timeoutAwait(result.receivedSummaryAckOrNack, {\n\t\terrorMsg: \"Promise timed out: receivedSummaryAckOrNack\",\n\t});\n\tif (!ackNackResult.success) {\n\t\tthrow ackNackResult.error;\n\t}\n\n\tawait new Promise((resolve) => process.nextTick(resolve));\n\n\treturn {\n\t\tsummaryTree: submitResult.data.summaryTree,\n\t\tsummaryVersion: ackNackResult.data.summaryAckOp.contents.handle,\n\t\tsummaryRefSeq: submitResult.data.referenceSequenceNumber,\n\t};\n}\n\n/**\n * Summary information containing the summary tree, summary version, and summary sequence number.\n * @internal\n */\nexport interface SummaryInfo {\n\t/**\n\t * The summary tree generated\n\t */\n\tsummaryTree: ISummaryTree;\n\t/**\n\t * Handle of the completed summary\n\t */\n\tsummaryVersion: string;\n\t/**\n\t * Reference sequence number of the current summary generation\n\t */\n\tsummaryRefSeq: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TestSummaryUtils.js","sourceRoot":"","sources":["../src/TestSummaryUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAiEH,oDAuCC;AAiBD,kEA4BC;AASD,4CAqBC;AAWD,oCAyCC;AArOD,6EAIwD;AAYxD,kEAA6D;AAE7D,0EAA2E;AAM3E,qDAA4D;AAC5D,kDAAkD;AAClD,iFAA6F;AAC7F,2DAAiE;AACjE,6HAG8D;AAC9D,iEAA0E;AAE1E,uDAAiD;AAEjD,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C;;;;;GAKG;AACH,KAAK,UAAU,uBAAuB,CAAC,SAAqB;IAC3D,IAAI,SAAS,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QACnD,0GAA0G;QAC1G,oGAAoG;QACpG,gHAAgH;QAChH,oGAAoG;QACpG,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,UAAyB,CAAC;QAClC,CAAC;IACF,CAAC;IACD,MAAM,QAAQ,GAAc,MAAO,SAAiB,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC,CAAC;IACrF,IAAA,iBAAM,EAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,kDAAkD,CAAC,CAAC;IACpF,OAAO,QAAQ,CAAC,KAA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AAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAE1D,OAAO;QACN,WAAW,EAAE,YAAY,CAAC,IAAI,CAAC,WAAW;QAC1C,cAAc,EAAE,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM;QAC/D,aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,uBAAuB;KACxD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIContainer,\n\tIHostLoader,\n\tLoaderHeader,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tIOnDemandSummarizeOptions,\n\tISummarizer,\n\tISummaryRuntimeOptions,\n} from \"@fluidframework/container-runtime/internal\";\nimport {\n\tIConfigProviderBase,\n\tIRequest,\n\tIResponse,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { DriverHeader } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { createTestConfigProvider } from \"./TestConfigs.js\";\n// eslint-disable-next-line import-x/no-deprecated\nimport { ContainerRuntimeFactoryWithDefaultDataStore } from \"./containerRuntimeFactories.js\";\nimport { waitForContainerConnection } from \"./containerUtils.js\";\nimport {\n\ttype ContainerRuntimeFactoryWithDefaultDataStoreConstructor,\n\tcreateContainerRuntimeFactoryWithDefaultDataStore,\n} from \"./testContainerRuntimeFactoryWithDefaultDataStore.js\";\nimport { defaultTestOldestSupportedClient } from \"./testCompatibility.js\";\nimport { ITestContainerConfig, ITestObjectProvider } from \"./testObjectProvider.js\";\nimport { timeoutAwait } from \"./timeoutUtils.js\";\n\nconst summarizerClientType = \"summarizer\";\n\n/**\n * This function should ONLY be used for back compat purposes\n * LTS versions of the Loader/Container will not have the \"getEntryPoint\" method, so we need to fallback to \"request\"\n * This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0\n * @internal\n */\nasync function getSummarizerBackCompat(container: IContainer): Promise<ISummarizer> {\n\tif (container.getEntryPoint !== undefined) {\n\t\tconst entryPoint = await container.getEntryPoint();\n\t\t// Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running\n\t\t// cross-client compat testing scenarios, if we create with 1.X container and load with 2.X then the\n\t\t// function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined\n\t\t// since the container's runtime will be on version 1.X, which does not have an entry point defined.\n\t\tif (entryPoint !== undefined) {\n\t\t\treturn entryPoint as ISummarizer;\n\t\t}\n\t}\n\tconst response: IResponse = await (container as any).request({ url: \"_summarizer\" });\n\tassert(response.status === 200, \"requesting '/' should return default data object\");\n\treturn response.value as ISummarizer;\n}\n\n/**\n * @internal\n */\nexport async function createSummarizerCore(\n\tcontainer: IContainer,\n\tloader: IHostLoader,\n\tsummaryVersion?: string,\n): Promise<{\n\tcontainer: IContainer;\n\tsummarizer: ISummarizer;\n}> {\n\tconst absoluteUrl = await container.getAbsoluteUrl(\"\");\n\tif (absoluteUrl === undefined) {\n\t\tthrow new Error(\"URL could not be resolved\");\n\t}\n\n\tconst request: IRequest = {\n\t\theaders: {\n\t\t\t[LoaderHeader.cache]: false,\n\t\t\t[LoaderHeader.clientDetails]: {\n\t\t\t\tcapabilities: { interactive: false },\n\t\t\t\ttype: summarizerClientType,\n\t\t\t},\n\t\t\t[DriverHeader.summarizingClient]: true,\n\t\t\t[LoaderHeader.version]: summaryVersion,\n\t\t},\n\t\turl: absoluteUrl,\n\t};\n\tconst summarizerContainer = await loader.resolve(request);\n\tawait waitForContainerConnection(summarizerContainer);\n\n\t// Old loaders will not have getEntryPoint API on the container. So, use getSummarizerBackCompat which\n\t// will use request pattern to get the summarizer in these old loaders.\n\tconst fluidObject = await getSummarizerBackCompat(summarizerContainer);\n\tif (fluidObject.ISummarizer === undefined) {\n\t\tthrow new Error(\"Fluid object does not implement ISummarizer\");\n\t}\n\n\treturn {\n\t\tcontainer: summarizerContainer,\n\t\tsummarizer: fluidObject.ISummarizer,\n\t};\n}\n\nconst defaultSummaryOptions: ISummaryRuntimeOptions = {\n\tsummaryConfigOverrides: {\n\t\tstate: \"disableHeuristics\",\n\t\tmaxAckWaitTime: 20000, // Some of the AFR tests take a long time to ack.\n\t\tmaxOpsSinceLastSummary: 7000,\n\t\tinitialSummarizerDelayMs: 0,\n\t},\n};\n\n/**\n * Creates a summarizer client from the given container and data store factory, and returns the summarizer client's\n * IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n * @internal\n */\nexport async function createSummarizerFromFactory(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tdataStoreFactory: IFluidDataStoreFactory,\n\tsummaryVersion?: string,\n\tcontainerRuntimeFactoryType?: ContainerRuntimeFactoryWithDefaultDataStoreConstructor,\n\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\tlogger?: ITelemetryBaseLogger,\n\tconfigProvider: IConfigProviderBase = createTestConfigProvider(),\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(\n\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\tcontainerRuntimeFactoryType ?? ContainerRuntimeFactoryWithDefaultDataStore,\n\t\t{\n\t\t\tdefaultFactory: dataStoreFactory,\n\t\t\toldestSupportedClient: defaultTestOldestSupportedClient,\n\t\t\tregistryEntries: registryEntries ?? [\n\t\t\t\t[dataStoreFactory.type, Promise.resolve(dataStoreFactory)],\n\t\t\t],\n\t\t\truntimeOptions: { summaryOptions: defaultSummaryOptions },\n\t\t},\n\t);\n\n\tconst loader = provider.createLoader([[provider.defaultCodeDetails, runtimeFactory]], {\n\t\tconfigProvider,\n\t\tlogger,\n\t});\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Creates a summarizer client from the given container and returns the summarizer client's IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n *\n * Can pass in a test config provider to enable/disable features.\n * @internal\n */\nexport async function createSummarizer(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tconfig?: ITestContainerConfig,\n\tsummaryVersion?: string,\n\tlogger?: ITelemetryBaseLogger,\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst testContainerConfig: ITestContainerConfig = {\n\t\t...config,\n\t\truntimeOptions: {\n\t\t\t...config?.runtimeOptions,\n\t\t\tsummaryOptions: config?.runtimeOptions?.summaryOptions ?? defaultSummaryOptions,\n\t\t},\n\t\tloaderProps: {\n\t\t\t...config?.loaderProps,\n\t\t\tconfigProvider: config?.loaderProps?.configProvider ?? createTestConfigProvider(),\n\t\t\tlogger,\n\t\t},\n\t};\n\tconst loader = provider.makeTestLoader(testContainerConfig);\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Summarizes on demand and returns the summary tree, the version number and the reference sequence number of the\n * submitted summary.\n *\n * @param summarizer - The ISummarizer to use to summarize on demand\n * @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.\n * Defaults to the reason \"end-to-end test\".\n * @internal\n */\nexport async function summarizeNow(\n\tsummarizer: ISummarizer,\n\tinputs: string | IOnDemandSummarizeOptions = \"end-to-end test\",\n): Promise<SummaryInfo> {\n\tconst options: IOnDemandSummarizeOptions =\n\t\ttypeof inputs === \"string\" ? { reason: inputs } : inputs;\n\tconst result = summarizer.summarizeOnDemand(options);\n\n\tconst submitResult = await timeoutAwait(result.summarySubmitted, {\n\t\terrorMsg: \"Promise timed out: summarySubmitted\",\n\t});\n\tif (!submitResult.success) {\n\t\tthrow submitResult.error;\n\t}\n\tassert(\n\t\tsubmitResult.data.stage === \"submit\",\n\t\t\"on-demand summary submitted data stage should be submit\",\n\t);\n\tassert(submitResult.data.summaryTree !== undefined, \"summary tree should exist\");\n\n\tconst broadcastResult = await timeoutAwait(result.summaryOpBroadcasted, {\n\t\terrorMsg: \"Promise timed out: summaryOpBroadcasted\",\n\t});\n\tif (!broadcastResult.success) {\n\t\tthrow broadcastResult.error;\n\t}\n\n\tconst ackNackResult = await timeoutAwait(result.receivedSummaryAckOrNack, {\n\t\terrorMsg: \"Promise timed out: receivedSummaryAckOrNack\",\n\t});\n\tif (!ackNackResult.success) {\n\t\tthrow ackNackResult.error;\n\t}\n\n\tawait new Promise((resolve) => process.nextTick(resolve));\n\n\treturn {\n\t\tsummaryTree: submitResult.data.summaryTree,\n\t\tsummaryVersion: ackNackResult.data.summaryAckOp.contents.handle,\n\t\tsummaryRefSeq: submitResult.data.referenceSequenceNumber,\n\t};\n}\n\n/**\n * Summary information containing the summary tree, summary version, and summary sequence number.\n * @internal\n */\nexport interface SummaryInfo {\n\t/**\n\t * The summary tree generated\n\t */\n\tsummaryTree: ISummaryTree;\n\t/**\n\t * Handle of the completed summary\n\t */\n\tsummaryVersion: string;\n\t/**\n\t * Reference sequence number of the current summary generation\n\t */\n\tsummaryRefSeq: number;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerRuntimeFactories.d.ts","sourceRoot":"","sources":["../src/containerRuntimeFactories.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,iBAAiB,EACjB,QAAQ,EACR,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAGN,KAAK,wBAAwB,EAC7B,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EACX,iBAAiB,EAGjB,MAAM,wDAAwD,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,iCAAiC,CAAC;AAOxF,OAAO,KAAK,EACX,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,4BAA4B,EAC5B,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AC;IAE1D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;IAEnD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqC;IAErE;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAA2B;IAG3D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmC;IAEnE;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAuD;IAEzF;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA+B;gBAEhD,KAAK,EAAE,gDAAgD;IA4B7D,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/D,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlE,aAAa,CACzB,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,OAAO,GACf,OAAO,CAAC,iBAAiB,GAAG,QAAQ,CAAC;IAcxC;;;;;OAKG;cACa,8BAA8B,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzF;;;;;OAKG;cACa,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAClF"}
|
|
@@ -8,6 +8,7 @@ exports.ContainerRuntimeFactoryWithDefaultDataStore = void 0;
|
|
|
8
8
|
const internal_1 = require("@fluidframework/container-runtime/internal");
|
|
9
9
|
const internal_2 = require("@fluidframework/request-handler/internal");
|
|
10
10
|
const internal_3 = require("@fluidframework/runtime-utils/internal");
|
|
11
|
+
const testCompatibility_js_1 = require("./testCompatibility.js");
|
|
11
12
|
const defaultDataStoreId = "default";
|
|
12
13
|
async function getDefaultFluidObject(runtime) {
|
|
13
14
|
const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
|
|
@@ -25,12 +26,33 @@ async function getDefaultFluidObject(runtime) {
|
|
|
25
26
|
* E.g. use {@link IRuntimeFactory} instead.
|
|
26
27
|
*/
|
|
27
28
|
class ContainerRuntimeFactoryWithDefaultDataStore extends internal_3.RuntimeFactoryHelper {
|
|
29
|
+
static defaultDataStoreId = defaultDataStoreId;
|
|
28
30
|
/**
|
|
29
31
|
* {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreRegistry.IFluidDataStoreRegistry}
|
|
30
32
|
*/
|
|
31
33
|
get IFluidDataStoreRegistry() {
|
|
32
34
|
return this.registry;
|
|
33
35
|
}
|
|
36
|
+
defaultFactory;
|
|
37
|
+
registry;
|
|
38
|
+
/**
|
|
39
|
+
* {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.registryEntries}
|
|
40
|
+
*/
|
|
41
|
+
registryEntries;
|
|
42
|
+
/**
|
|
43
|
+
* {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.runtimeOptions}
|
|
44
|
+
*/
|
|
45
|
+
runtimeOptions;
|
|
46
|
+
// eslint-disable-next-line import-x/no-deprecated
|
|
47
|
+
requestHandlers;
|
|
48
|
+
/**
|
|
49
|
+
* {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.provideEntryPoint}
|
|
50
|
+
*/
|
|
51
|
+
provideEntryPoint;
|
|
52
|
+
/**
|
|
53
|
+
* {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.minVersionForCollab}
|
|
54
|
+
*/
|
|
55
|
+
minVersionForCollab;
|
|
34
56
|
constructor(props) {
|
|
35
57
|
super();
|
|
36
58
|
const getDefaultObject = async (request, runtime) => {
|
|
@@ -51,7 +73,7 @@ class ContainerRuntimeFactoryWithDefaultDataStore extends internal_3.RuntimeFact
|
|
|
51
73
|
this.provideEntryPoint = props.provideEntryPoint ?? getDefaultFluidObject;
|
|
52
74
|
this.requestHandlers = [getDefaultObject];
|
|
53
75
|
this.registry = new internal_1.FluidDataStoreRegistry(this.registryEntries);
|
|
54
|
-
this.minVersionForCollab = props.minVersionForCollab;
|
|
76
|
+
this.minVersionForCollab = props.minVersionForCollab ?? testCompatibility_js_1.defaultTestOldestSupportedClient;
|
|
55
77
|
}
|
|
56
78
|
async instantiateFirstTime(runtime) {
|
|
57
79
|
await this.containerInitializingFirstTime(runtime);
|
|
@@ -92,5 +114,4 @@ class ContainerRuntimeFactoryWithDefaultDataStore extends internal_3.RuntimeFact
|
|
|
92
114
|
async containerHasInitialized(runtime) { }
|
|
93
115
|
}
|
|
94
116
|
exports.ContainerRuntimeFactoryWithDefaultDataStore = ContainerRuntimeFactoryWithDefaultDataStore;
|
|
95
|
-
ContainerRuntimeFactoryWithDefaultDataStore.defaultDataStoreId = defaultDataStoreId;
|
|
96
117
|
//# sourceMappingURL=containerRuntimeFactories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerRuntimeFactories.js","sourceRoot":"","sources":["../src/containerRuntimeFactories.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,yEAIoD;AAOpD,uEAKkD;AAQlD,qEAA6F;AAE7F,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAErC,KAAK,UAAU,qBAAqB,CAAC,OAA0B;IAC9D,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC;IAC1E,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC;AACzB,CAAC;AAuCD;;;;;;;GAOG;AACH,MAAa,2CACZ,SAAQ,+BAAoB;IAK5B;;OAEG;IACH,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IA6BD,YAAmB,KAAuD;QACzE,KAAK,EAAE,CAAC;QAER,MAAM,gBAAgB,GAAG,KAAK,EAC7B,OAAiB,EACjB,OAA0B,EACO,EAAE;YACnC,MAAM,MAAM,GAAG,wBAAa,CAAC,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;YACnC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,cAAc,EAAE,OAAO,CAAC,KAAK;YAC7B,kDAAkD;YAClD,cAAc,EAAE,IAAA,qCAA0B,EAAC,GAAG,IAAI,CAAC,eAAe,CAAC;YACnE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,qBAAqB,EAAE,IAAI,CAAC,mBAAmB;SAC/C,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,8BAA8B,CAAC,OAA0B;QACxE,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC1E,MAAM,SAAS,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,uBAAuB,CAAC,OAA0B,IAAkB,CAAC;;AA/GtF,kGAgHC;AA5GuB,8DAAkB,GAAG,kBAAkB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIContainerContext,\n\tIRuntime,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tFluidDataStoreRegistry,\n\tloadContainerRuntime,\n\ttype IContainerRuntimeOptions,\n} from \"@fluidframework/container-runtime/internal\";\nimport type {\n\tIContainerRuntime,\n\t// eslint-disable-next-line import-x/no-deprecated\n\tIContainerRuntimeWithResolveHandle_Deprecated,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { FluidObject, IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport {\n\t// eslint-disable-next-line import-x/no-deprecated\n\ttype RuntimeRequestHandler,\n\t// eslint-disable-next-line import-x/no-deprecated\n\tbuildRuntimeRequestHandler,\n} from \"@fluidframework/request-handler/internal\";\nimport type {\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreRegistry,\n\tIProvideFluidDataStoreRegistry,\n\tOldestSupportedClientVersion,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { RequestParser, RuntimeFactoryHelper } from \"@fluidframework/runtime-utils/internal\";\n\nconst defaultDataStoreId = \"default\";\n\nasync function getDefaultFluidObject(runtime: IContainerRuntime): Promise<FluidObject> {\n\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(\"default\");\n\tif (entryPoint === undefined) {\n\t\tthrow new Error(\"default dataStore must exist\");\n\t}\n\treturn entryPoint.get();\n}\n\n/**\n * {@link ContainerRuntimeFactoryWithDefaultDataStore} construction properties.\n *\n * @deprecated See notice on {@link ContainerRuntimeFactoryWithDefaultDataStore}.\n */\nexport interface ContainerRuntimeFactoryWithDefaultDataStoreProps {\n\treadonly defaultFactory: IFluidDataStoreFactory;\n\n\t/**\n\t * The data store registry for containers produced.\n\t */\n\treadonly registryEntries: NamedFluidDataStoreRegistryEntries;\n\n\t/**\n\t * The runtime options passed to the IContainerRuntime when instantiating it\n\t */\n\treadonly runtimeOptions?: IContainerRuntimeOptions;\n\n\t/**\n\t * Function that will initialize the entryPoint of the IContainerRuntime instances\n\t * created with this factory\n\t */\n\treadonly provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;\n\n\t/**\n\t * Oldest Fluid Framework client version that must be able to process documents written by the\n\t * runtime.\n\t * See {@link @fluidframework/container-runtime#LoadContainerRuntimeParams.oldestSupportedClient}\n\t * for more details.\n\t *\n\t * @remarks\n\t * The property name is retained while the cross-layer dual-property migration in\n\t * {@link https://github.com/microsoft/FluidFramework/issues/27851} is completed.\n\t */\n\treadonly minVersionForCollab?: OldestSupportedClientVersion;\n}\n\n/**\n * A ContainerRuntimeFactory that initializes Containers with a single default data store, which can be requested from\n * the container with an empty URL.\n *\n * @deprecated\n * Do not reference this type directly. It will be removed in the future.\n * E.g. use {@link IRuntimeFactory} instead.\n */\nexport class ContainerRuntimeFactoryWithDefaultDataStore\n\textends RuntimeFactoryHelper\n\timplements IProvideFluidDataStoreRegistry\n{\n\tpublic static readonly defaultDataStoreId = defaultDataStoreId;\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreRegistry.IFluidDataStoreRegistry}\n\t */\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.registry;\n\t}\n\n\tprotected readonly defaultFactory: IFluidDataStoreFactory;\n\n\tprivate readonly registry: IFluidDataStoreRegistry;\n\n\t/**\n\t * {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.registryEntries}\n\t */\n\tprivate readonly registryEntries: NamedFluidDataStoreRegistryEntries;\n\n\t/**\n\t * {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.runtimeOptions}\n\t */\n\tprivate readonly runtimeOptions?: IContainerRuntimeOptions;\n\n\t// eslint-disable-next-line import-x/no-deprecated\n\tprivate readonly requestHandlers: readonly RuntimeRequestHandler[];\n\n\t/**\n\t * {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.provideEntryPoint}\n\t */\n\tprivate readonly provideEntryPoint: (runtime: IContainerRuntime) => Promise<FluidObject>;\n\n\t/**\n\t * {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.minVersionForCollab}\n\t */\n\tprivate readonly minVersionForCollab: OldestSupportedClientVersion | undefined;\n\n\tpublic constructor(props: ContainerRuntimeFactoryWithDefaultDataStoreProps) {\n\t\tsuper();\n\n\t\tconst getDefaultObject = async (\n\t\t\trequest: IRequest,\n\t\t\truntime: IContainerRuntime,\n\t\t): Promise<IResponse | undefined> => {\n\t\t\tconst parser = RequestParser.create(request);\n\t\t\tif (parser.pathParts.length === 0) {\n\t\t\t\t// This cast is safe as loadContainerRuntime is called in the base class\n\t\t\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\t\t\treturn (runtime as IContainerRuntimeWithResolveHandle_Deprecated).resolveHandle({\n\t\t\t\t\turl: `/${defaultDataStoreId}${parser.query}`,\n\t\t\t\t\theaders: request.headers,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn undefined; // continue search\n\t\t};\n\n\t\tthis.defaultFactory = props.defaultFactory;\n\t\tthis.registryEntries = props.registryEntries;\n\t\tthis.runtimeOptions = props.runtimeOptions;\n\t\tthis.provideEntryPoint = props.provideEntryPoint ?? getDefaultFluidObject;\n\t\tthis.requestHandlers = [getDefaultObject];\n\t\tthis.registry = new FluidDataStoreRegistry(this.registryEntries);\n\t\tthis.minVersionForCollab = props.minVersionForCollab;\n\t}\n\n\tpublic async instantiateFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\tawait this.containerInitializingFirstTime(runtime);\n\t\tawait this.containerHasInitialized(runtime);\n\t}\n\n\tpublic async instantiateFromExisting(runtime: IContainerRuntime): Promise<void> {\n\t\tawait this.containerHasInitialized(runtime);\n\t}\n\n\tpublic async preInitialize(\n\t\tcontext: IContainerContext,\n\t\texisting: boolean,\n\t): Promise<IContainerRuntime & IRuntime> {\n\t\treturn loadContainerRuntime({\n\t\t\tcontext,\n\t\t\texisting,\n\t\t\truntimeOptions: this.runtimeOptions,\n\t\t\tregistryEntries: this.registryEntries,\n\t\t\tcontainerScope: context.scope,\n\t\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\t\trequestHandler: buildRuntimeRequestHandler(...this.requestHandlers),\n\t\t\tprovideEntryPoint: this.provideEntryPoint,\n\t\t\toldestSupportedClient: this.minVersionForCollab,\n\t\t});\n\t}\n\n\t/**\n\t * Subclasses may override containerInitializingFirstTime to perform any setup steps at the time the container\n\t * is created. This likely includes creating any initial data stores that are expected to be there at the outset.\n\t * @param runtime - The container runtime for the container being initialized.\n\t * @virtual\n\t */\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\tconst dataStore = await runtime.createDataStore(this.defaultFactory.type);\n\t\tawait dataStore.trySetAlias(defaultDataStoreId);\n\t}\n\n\t/**\n\t * Subclasses may override containerHasInitialized to perform any steps after the container has initialized.\n\t * This likely includes loading any data stores that are expected to be there at the outset.\n\t * @param runtime - The container runtime for the container being initialized.\n\t * @virtual\n\t */\n\tprotected async containerHasInitialized(runtime: IContainerRuntime): Promise<void> {}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"containerRuntimeFactories.js","sourceRoot":"","sources":["../src/containerRuntimeFactories.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,yEAIoD;AAOpD,uEAKkD;AAQlD,qEAA6F;AAE7F,iEAA0E;AAE1E,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAErC,KAAK,UAAU,qBAAqB,CAAC,OAA0B;IAC9D,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC;IAC1E,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC;AACzB,CAAC;AAuCD;;;;;;;GAOG;AACH,MAAa,2CACZ,SAAQ,+BAAoB;IAGrB,MAAM,CAAU,kBAAkB,GAAG,kBAAkB,CAAC;IAE/D;;OAEG;IACH,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAEkB,cAAc,CAAyB;IAEzC,QAAQ,CAA0B;IAEnD;;OAEG;IACc,eAAe,CAAqC;IAErE;;OAEG;IACc,cAAc,CAA4B;IAE3D,kDAAkD;IACjC,eAAe,CAAmC;IAEnE;;OAEG;IACc,iBAAiB,CAAuD;IAEzF;;OAEG;IACc,mBAAmB,CAA+B;IAEnE,YAAmB,KAAuD;QACzE,KAAK,EAAE,CAAC;QAER,MAAM,gBAAgB,GAAG,KAAK,EAC7B,OAAiB,EACjB,OAA0B,EACO,EAAE;YACnC,MAAM,MAAM,GAAG,wBAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC7C,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,KAAK,CAA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KAAK;YAC7B,kDAAkD;YAClD,cAAc,EAAE,IAAA,qCAA0B,EAAC,GAAG,IAAI,CAAC,eAAe,CAAC;YACnE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,qBAAqB,EAAE,IAAI,CAAC,mBAAmB;SAC/C,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,8BAA8B,CAAC,OAA0B;QACxE,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC1E,MAAM,SAAS,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,uBAAuB,CAAC,OAA0B,IAAkB,CAAC;;AA/GtF,kGAgHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIContainerContext,\n\tIRuntime,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tFluidDataStoreRegistry,\n\tloadContainerRuntime,\n\ttype IContainerRuntimeOptions,\n} from \"@fluidframework/container-runtime/internal\";\nimport type {\n\tIContainerRuntime,\n\t// eslint-disable-next-line import-x/no-deprecated\n\tIContainerRuntimeWithResolveHandle_Deprecated,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { FluidObject, IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport {\n\t// eslint-disable-next-line import-x/no-deprecated\n\ttype RuntimeRequestHandler,\n\t// eslint-disable-next-line import-x/no-deprecated\n\tbuildRuntimeRequestHandler,\n} from \"@fluidframework/request-handler/internal\";\nimport type {\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreRegistry,\n\tIProvideFluidDataStoreRegistry,\n\tOldestSupportedClientVersion,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { RequestParser, RuntimeFactoryHelper } from \"@fluidframework/runtime-utils/internal\";\n\nimport { defaultTestOldestSupportedClient } from \"./testCompatibility.js\";\n\nconst defaultDataStoreId = \"default\";\n\nasync function getDefaultFluidObject(runtime: IContainerRuntime): Promise<FluidObject> {\n\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(\"default\");\n\tif (entryPoint === undefined) {\n\t\tthrow new Error(\"default dataStore must exist\");\n\t}\n\treturn entryPoint.get();\n}\n\n/**\n * {@link ContainerRuntimeFactoryWithDefaultDataStore} construction properties.\n *\n * @deprecated See notice on {@link ContainerRuntimeFactoryWithDefaultDataStore}.\n */\nexport interface ContainerRuntimeFactoryWithDefaultDataStoreProps {\n\treadonly defaultFactory: IFluidDataStoreFactory;\n\n\t/**\n\t * The data store registry for containers produced.\n\t */\n\treadonly registryEntries: NamedFluidDataStoreRegistryEntries;\n\n\t/**\n\t * The runtime options passed to the IContainerRuntime when instantiating it\n\t */\n\treadonly runtimeOptions?: IContainerRuntimeOptions;\n\n\t/**\n\t * Function that will initialize the entryPoint of the IContainerRuntime instances\n\t * created with this factory\n\t */\n\treadonly provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;\n\n\t/**\n\t * Oldest Fluid Framework client version that must be able to process documents written by the\n\t * runtime.\n\t * See {@link @fluidframework/container-runtime#LoadContainerRuntimeParams.oldestSupportedClient}\n\t * for more details.\n\t *\n\t * @remarks\n\t * The property name is retained while the cross-layer dual-property migration in\n\t * {@link https://github.com/microsoft/FluidFramework/issues/27851} is completed.\n\t */\n\treadonly minVersionForCollab?: OldestSupportedClientVersion;\n}\n\n/**\n * A ContainerRuntimeFactory that initializes Containers with a single default data store, which can be requested from\n * the container with an empty URL.\n *\n * @deprecated\n * Do not reference this type directly. It will be removed in the future.\n * E.g. use {@link IRuntimeFactory} instead.\n */\nexport class ContainerRuntimeFactoryWithDefaultDataStore\n\textends RuntimeFactoryHelper\n\timplements IProvideFluidDataStoreRegistry\n{\n\tpublic static readonly defaultDataStoreId = defaultDataStoreId;\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreRegistry.IFluidDataStoreRegistry}\n\t */\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.registry;\n\t}\n\n\tprotected readonly defaultFactory: IFluidDataStoreFactory;\n\n\tprivate readonly registry: IFluidDataStoreRegistry;\n\n\t/**\n\t * {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.registryEntries}\n\t */\n\tprivate readonly registryEntries: NamedFluidDataStoreRegistryEntries;\n\n\t/**\n\t * {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.runtimeOptions}\n\t */\n\tprivate readonly runtimeOptions?: IContainerRuntimeOptions;\n\n\t// eslint-disable-next-line import-x/no-deprecated\n\tprivate readonly requestHandlers: readonly RuntimeRequestHandler[];\n\n\t/**\n\t * {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.provideEntryPoint}\n\t */\n\tprivate readonly provideEntryPoint: (runtime: IContainerRuntime) => Promise<FluidObject>;\n\n\t/**\n\t * {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.minVersionForCollab}\n\t */\n\tprivate readonly minVersionForCollab: OldestSupportedClientVersion;\n\n\tpublic constructor(props: ContainerRuntimeFactoryWithDefaultDataStoreProps) {\n\t\tsuper();\n\n\t\tconst getDefaultObject = async (\n\t\t\trequest: IRequest,\n\t\t\truntime: IContainerRuntime,\n\t\t): Promise<IResponse | undefined> => {\n\t\t\tconst parser = RequestParser.create(request);\n\t\t\tif (parser.pathParts.length === 0) {\n\t\t\t\t// This cast is safe as loadContainerRuntime is called in the base class\n\t\t\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\t\t\treturn (runtime as IContainerRuntimeWithResolveHandle_Deprecated).resolveHandle({\n\t\t\t\t\turl: `/${defaultDataStoreId}${parser.query}`,\n\t\t\t\t\theaders: request.headers,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn undefined; // continue search\n\t\t};\n\n\t\tthis.defaultFactory = props.defaultFactory;\n\t\tthis.registryEntries = props.registryEntries;\n\t\tthis.runtimeOptions = props.runtimeOptions;\n\t\tthis.provideEntryPoint = props.provideEntryPoint ?? getDefaultFluidObject;\n\t\tthis.requestHandlers = [getDefaultObject];\n\t\tthis.registry = new FluidDataStoreRegistry(this.registryEntries);\n\t\tthis.minVersionForCollab = props.minVersionForCollab ?? defaultTestOldestSupportedClient;\n\t}\n\n\tpublic async instantiateFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\tawait this.containerInitializingFirstTime(runtime);\n\t\tawait this.containerHasInitialized(runtime);\n\t}\n\n\tpublic async instantiateFromExisting(runtime: IContainerRuntime): Promise<void> {\n\t\tawait this.containerHasInitialized(runtime);\n\t}\n\n\tpublic async preInitialize(\n\t\tcontext: IContainerContext,\n\t\texisting: boolean,\n\t): Promise<IContainerRuntime & IRuntime> {\n\t\treturn loadContainerRuntime({\n\t\t\tcontext,\n\t\t\texisting,\n\t\t\truntimeOptions: this.runtimeOptions,\n\t\t\tregistryEntries: this.registryEntries,\n\t\t\tcontainerScope: context.scope,\n\t\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\t\trequestHandler: buildRuntimeRequestHandler(...this.requestHandlers),\n\t\t\tprovideEntryPoint: this.provideEntryPoint,\n\t\t\toldestSupportedClient: this.minVersionForCollab,\n\t\t});\n\t}\n\n\t/**\n\t * Subclasses may override containerInitializingFirstTime to perform any setup steps at the time the container\n\t * is created. This likely includes creating any initial data stores that are expected to be there at the outset.\n\t * @param runtime - The container runtime for the container being initialized.\n\t * @virtual\n\t */\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\tconst dataStore = await runtime.createDataStore(this.defaultFactory.type);\n\t\tawait dataStore.trySetAlias(defaultDataStoreId);\n\t}\n\n\t/**\n\t * Subclasses may override containerHasInitialized to perform any steps after the container has initialized.\n\t * This likely includes loading any data stores that are expected to be there at the outset.\n\t * @param runtime - The container runtime for the container being initialized.\n\t * @virtual\n\t */\n\tprotected async containerHasInitialized(runtime: IContainerRuntime): Promise<void> {}\n}\n"]}
|
package/dist/containerUtils.js
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.waitForContainerConnection = waitForContainerConnection;
|
|
8
|
+
exports.getContainerEntryPointBackCompat = getContainerEntryPointBackCompat;
|
|
9
|
+
exports.getDataStoreEntryPointBackCompat = getDataStoreEntryPointBackCompat;
|
|
10
|
+
exports.getRequiredPendingLocalState = getRequiredPendingLocalState;
|
|
11
|
+
exports.toIDeltaManagerFull = toIDeltaManagerFull;
|
|
8
12
|
const container_loader_1 = require("@fluidframework/container-loader");
|
|
9
13
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
10
14
|
const timeoutUtils_js_1 = require("./timeoutUtils.js");
|
|
@@ -43,7 +47,6 @@ async function waitForContainerConnection(container, failOnContainerClose = true
|
|
|
43
47
|
: (0, timeoutUtils_js_1.timeoutPromise)(executor, timeoutOptions);
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
|
-
exports.waitForContainerConnection = waitForContainerConnection;
|
|
47
50
|
/**
|
|
48
51
|
* This function should ONLY be used for back compat purposes
|
|
49
52
|
* LTS versions of the Loader/Container will not have the "getEntryPoint" method, so we need to fallback to "request"
|
|
@@ -65,7 +68,6 @@ async function getContainerEntryPointBackCompat(container) {
|
|
|
65
68
|
(0, internal_1.assert)(response.status === 200, "requesting '/' should return default data object");
|
|
66
69
|
return response.value;
|
|
67
70
|
}
|
|
68
|
-
exports.getContainerEntryPointBackCompat = getContainerEntryPointBackCompat;
|
|
69
71
|
/**
|
|
70
72
|
* This function should ONLY be used for back compat purposes
|
|
71
73
|
* Older supported versions of IDataStore do not have the "entryPoint" property, so we need to fallback to "request"
|
|
@@ -81,7 +83,6 @@ async function getDataStoreEntryPointBackCompat(dataStore) {
|
|
|
81
83
|
(0, internal_1.assert)(response.status === 200, "empty request should return data object");
|
|
82
84
|
return response.value;
|
|
83
85
|
}
|
|
84
|
-
exports.getDataStoreEntryPointBackCompat = getDataStoreEntryPointBackCompat;
|
|
85
86
|
/**
|
|
86
87
|
* Calls `container.getPendingLocalState()` and asserts the method is implemented.
|
|
87
88
|
*
|
|
@@ -98,7 +99,6 @@ async function getRequiredPendingLocalState(container) {
|
|
|
98
99
|
(0, internal_1.assert)(container.getPendingLocalState !== undefined, "IContainer.getPendingLocalState is not implemented by this container");
|
|
99
100
|
return container.getPendingLocalState();
|
|
100
101
|
}
|
|
101
|
-
exports.getRequiredPendingLocalState = getRequiredPendingLocalState;
|
|
102
102
|
/**
|
|
103
103
|
* Casts a delta manager to its full interface type with inbound/outbound queues.
|
|
104
104
|
*
|
|
@@ -108,5 +108,4 @@ function toIDeltaManagerFull(deltaManager) {
|
|
|
108
108
|
(0, internal_1.assert)("inbound" in deltaManager && "outbound" in deltaManager, "Delta manager does not have inbound/outbound queues.");
|
|
109
109
|
return deltaManager;
|
|
110
110
|
}
|
|
111
|
-
exports.toIDeltaManagerFull = toIDeltaManagerFull;
|
|
112
111
|
//# sourceMappingURL=containerUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerUtils.js","sourceRoot":"","sources":["../src/containerUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"containerUtils.js","sourceRoot":"","sources":["../src/containerUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAyCH,gEAiBC;AAQD,4EAcC;AASD,4EAOC;AAcD,oEAMC;AAOD,kDAYC;AAhID,uEAAmE;AAEnE,kEAA6D;AAQ7D,uDAAsF;AAEtF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,KAAK,UAAU,0BAA0B,CAC/C,SAAqB,EACrB,uBAAgC,IAAI,EACpC,cAAiC;IAEjC,IAAI,SAAS,CAAC,eAAe,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AAG,EAAgB,CAAC;IACjD,CAAC;IACD,MAAM,QAAQ,GAAc,MAAO,SAAiB,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1E,IAAA,iBAAM,EAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,yCAAyC,CAAC,CAAC;IAC3E,OAAO,QAAQ,CAAC,KAAU,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,4BAA4B,CAAC,SAAqB;IACvE,IAAA,iBAAM,EACL,SAAS,CAAC,oBAAoB,KAAK,SAAS,EAC5C,sEAAsE,CACtE,CAAC;IACF,OAAO,SAAS,CAAC,oBAAoB,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAClC,YAEsB;IAEtB,IAAA,iBAAM,EACL,SAAS,IAAI,YAAY,IAAI,UAAU,IAAI,YAAY,EACvD,sDAAsD,CACtD,CAAC;IACF,OAAO,YAE2E,CAAC;AACpF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIContainer,\n\tIDeltaManager,\n\ttype IDeltaManagerFull,\n} from \"@fluidframework/container-definitions/internal\";\nimport { ConnectionState } from \"@fluidframework/container-loader\";\nimport { IResponse } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IDeltaManagerErased } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { IDataStore } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { PromiseExecutor, TimeoutWithError, timeoutPromise } from \"./timeoutUtils.js\";\n\n/**\n * Utility function to wait for the specified Container to be in Connected state.\n * If the Container is already connected, the Promise returns immediately; otherwise it resolves when the Container emits\n * its 'connected' event.\n * If failOnContainerClose === true, the returned Promise will be rejected if the container emits a 'closed' event\n * before a 'connected' event.\n * @param container - The container to wait for.\n * @param failOnContainerClose - If true, the returned Promise will be rejected if the container emits a 'closed' event\n * before a 'connected' event.\n * Defaults to true.\n * @param timeoutOptions - Options related to the behavior of the timeout.\n * If provided, the returned Promise will reject if the container hasn't emitted relevant events in timeoutOptions.durationMs.\n * If not provided, the Promise will wait indefinitely for the Container to emit its 'connected' (or 'closed', if\n * failOnContainerClose === true) event.\n *\n * @returns A Promise that either:\n * - Resolves when the specified container emits a 'connected' event (or immediately if the Container is already connected).\n * - Rejects if failOnContainerClose === true and the container emits a 'closed' event before a 'connected' event.\n * - Rejects after timeoutOptions.durationMs if timeoutOptions !== undefined and the container does not emit relevant\n * events, within that timeframe.\n * @internal\n */\nexport async function waitForContainerConnection(\n\tcontainer: IContainer,\n\tfailOnContainerClose: boolean = true,\n\ttimeoutOptions?: TimeoutWithError,\n): Promise<void> {\n\tif (container.connectionState !== ConnectionState.Connected) {\n\t\tconst executor: PromiseExecutor = (resolve, reject) => {\n\t\t\tcontainer.once(\"connected\", () => resolve());\n\t\t\tif (failOnContainerClose) {\n\t\t\t\tcontainer.once(\"closed\", (error) => reject(error));\n\t\t\t}\n\t\t};\n\n\t\treturn timeoutOptions === undefined\n\t\t\t? new Promise(executor)\n\t\t\t: timeoutPromise(executor, timeoutOptions);\n\t}\n}\n\n/**\n * This function should ONLY be used for back compat purposes\n * LTS versions of the Loader/Container will not have the \"getEntryPoint\" method, so we need to fallback to \"request\"\n * This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0\n * @internal\n */\nexport async function getContainerEntryPointBackCompat<T>(container: IContainer): Promise<T> {\n\tif (container.getEntryPoint !== undefined) {\n\t\tconst entryPoint = await container.getEntryPoint();\n\t\t// Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running\n\t\t// cross-client compat testing scenarios, if we create with 1.X container and load with 2.X then the\n\t\t// function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined\n\t\t// since the container's runtime will be on version 1.X, which does not have an entry point defined.\n\t\tif (entryPoint !== undefined) {\n\t\t\treturn entryPoint as T;\n\t\t}\n\t}\n\tconst response: IResponse = await (container as any).request({ url: \"/\" });\n\tassert(response.status === 200, \"requesting '/' should return default data object\");\n\treturn response.value as T;\n}\n\n/**\n * This function should ONLY be used for back compat purposes\n * Older supported versions of IDataStore do not have the \"entryPoint\" property, so we need to fallback to \"request\"\n * This function can be removed once back-compat support for IDataStore moves to 2.0.0-internal.7.0.0\n *\n * @internal\n */\nexport async function getDataStoreEntryPointBackCompat<T>(dataStore: IDataStore): Promise<T> {\n\tif (dataStore.entryPoint !== undefined) {\n\t\treturn dataStore.entryPoint.get() as Promise<T>;\n\t}\n\tconst response: IResponse = await (dataStore as any).request({ url: \"\" });\n\tassert(response.status === 200, \"empty request should return data object\");\n\treturn response.value as T;\n}\n\n/**\n * Calls `container.getPendingLocalState()` and asserts the method is implemented.\n *\n * @remarks\n * `getPendingLocalState` is currently optional on `IContainer` for forward-compat with external\n * implementers; the first-party `Container` always implements it. This helper centralises the\n * existence check so test code does not duplicate `assert(... !== undefined, ...)` at every\n * callsite. Once `getPendingLocalState` becomes required on `IContainer` this helper can be\n * removed in favour of a direct call.\n *\n * @internal\n */\nexport async function getRequiredPendingLocalState(container: IContainer): Promise<string> {\n\tassert(\n\t\tcontainer.getPendingLocalState !== undefined,\n\t\t\"IContainer.getPendingLocalState is not implemented by this container\",\n\t);\n\treturn container.getPendingLocalState();\n}\n\n/**\n * Casts a delta manager to its full interface type with inbound/outbound queues.\n *\n * @internal\n */\nexport function toIDeltaManagerFull(\n\tdeltaManager:\n\t\t| IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>\n\t\t| IDeltaManagerErased,\n): IDeltaManagerFull {\n\tassert(\n\t\t\"inbound\" in deltaManager && \"outbound\" in deltaManager,\n\t\t\"Delta manager does not have inbound/outbound queues.\",\n\t);\n\treturn deltaManager as unknown as\n\t\t| IDeltaManagerErased\n\t\t| IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> as IDeltaManagerFull;\n}\n"]}
|