@fluidframework/runtime-utils 2.115.0 → 2.116.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 +4 -0
- package/README.md +5 -3
- package/dist/compatibilityBase.d.ts +18 -18
- package/dist/compatibilityBase.d.ts.map +1 -1
- package/dist/compatibilityBase.js +8 -8
- package/dist/compatibilityBase.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/serviceClientUtils.d.ts +3 -3
- package/dist/serviceClientUtils.d.ts.map +1 -1
- package/dist/serviceClientUtils.js.map +1 -1
- package/lib/compatibilityBase.d.ts +18 -18
- package/lib/compatibilityBase.d.ts.map +1 -1
- package/lib/compatibilityBase.js +8 -8
- package/lib/compatibilityBase.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/serviceClientUtils.d.ts +3 -3
- package/lib/serviceClientUtils.d.ts.map +1 -1
- package/lib/serviceClientUtils.js.map +1 -1
- package/package.json +17 -17
- package/src/compatibilityBase.ts +31 -27
- package/src/packageVersion.ts +1 -1
- package/src/serviceClientUtils.ts +3 -3
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ There are many ways to [contribute](https://github.com/microsoft/FluidFramework/
|
|
|
99
99
|
- Review the [source code changes](https://github.com/microsoft/FluidFramework/pulls).
|
|
100
100
|
- [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
|
|
101
101
|
|
|
102
|
-
Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/
|
|
102
|
+
Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Home.md).
|
|
103
103
|
|
|
104
104
|
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
105
105
|
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
@@ -110,9 +110,11 @@ Use of Microsoft trademarks or logos in modified versions of this project must n
|
|
|
110
110
|
|
|
111
111
|
## Help
|
|
112
112
|
|
|
113
|
-
Not finding what you're looking for in this README?
|
|
113
|
+
Not finding what you're looking for in this README?
|
|
114
|
+
Check out [fluidframework.com](https://fluidframework.com/docs/).
|
|
114
115
|
|
|
115
|
-
Still not finding what you're looking for?
|
|
116
|
+
Still not finding what you're looking for?
|
|
117
|
+
Please [file an issue](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Contributing/Submitting-Bugs-and-Feature-Requests.md).
|
|
116
118
|
|
|
117
119
|
Thank you!
|
|
118
120
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
5
|
+
import type { OldestSupportedClientVersion } from "@fluidframework/runtime-definitions/internal";
|
|
6
6
|
/**
|
|
7
7
|
* Our policy is to support major versions N and N-1, where N is most
|
|
8
8
|
* recent public major release of the Fluid Framework Client.
|
|
@@ -47,7 +47,7 @@ export declare const lowestMinVersionForCollab: "1.0.0";
|
|
|
47
47
|
export type MinimumMinorSemanticVersion = `${bigint}.${bigint}.0` | `${bigint}.0.0-defaults`;
|
|
48
48
|
/**
|
|
49
49
|
* String in a valid semver format of a specific version at least specifying minor.
|
|
50
|
-
* Unlike {@link @fluidframework/runtime-definitions#
|
|
50
|
+
* Unlike {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}, this type allows any bigint for the major version.
|
|
51
51
|
* Used as a more generic type that allows major versions other than 1 or 2.
|
|
52
52
|
*
|
|
53
53
|
* @internal
|
|
@@ -56,11 +56,11 @@ export type SemanticVersion = `${bigint}.${bigint}.${bigint}` | `${bigint}.${big
|
|
|
56
56
|
/**
|
|
57
57
|
* Converts a record into a configuration map that associates each key with an instance of its value type that is based on a {@link MinimumMinorSemanticVersion}.
|
|
58
58
|
* @remarks
|
|
59
|
-
* For a given input {@link @fluidframework/runtime-definitions#
|
|
59
|
+
* For a given input {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion},
|
|
60
60
|
* the corresponding configuration values can be found by using the entry in the inner objects with the highest {@link MinimumMinorSemanticVersion}
|
|
61
|
-
* that does not exceed the given {@link @fluidframework/runtime-definitions#
|
|
61
|
+
* that does not exceed the given {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}.
|
|
62
62
|
*
|
|
63
|
-
* Use {@link getConfigsForMinVersionForCollab} to retrieve the configuration for a given a {@link @fluidframework/runtime-definitions#
|
|
63
|
+
* Use {@link getConfigsForMinVersionForCollab} to retrieve the configuration for a given a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}.
|
|
64
64
|
*
|
|
65
65
|
* See the remarks on {@link MinimumMinorSemanticVersion} for some limitation on how ConfigMaps must handle versioning.
|
|
66
66
|
* @internal
|
|
@@ -94,13 +94,13 @@ export type ConfigValidationMap<T extends Record<string, unknown>> = {
|
|
|
94
94
|
* It should have no impact on the user of this function.
|
|
95
95
|
* @internal
|
|
96
96
|
*/
|
|
97
|
-
export declare function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(minVersionForCollab:
|
|
97
|
+
export declare function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(minVersionForCollab: OldestSupportedClientVersion, configMap: ConfigMap<T> & Record<keyof T, unknown>): T;
|
|
98
98
|
/**
|
|
99
99
|
* Returns a default configuration given minVersionForCollab and {@link ConfigMapEntry}.
|
|
100
100
|
*
|
|
101
101
|
* @internal
|
|
102
102
|
*/
|
|
103
|
-
export declare function getConfigForMinVersionForCollab<T>(minVersionForCollab:
|
|
103
|
+
export declare function getConfigForMinVersionForCollab<T>(minVersionForCollab: OldestSupportedClientVersion, config: ConfigMapEntry<T>): T;
|
|
104
104
|
/**
|
|
105
105
|
* Returns a default configuration given minVersionForCollab and the contents of a {@link ConfigMapEntry} in an Iterable.
|
|
106
106
|
* @remarks
|
|
@@ -112,7 +112,7 @@ export declare function getConfigForMinVersionForCollab<T>(minVersionForCollab:
|
|
|
112
112
|
* like cases which transform a ConfigMapEntry before selecting a value from it.
|
|
113
113
|
* @internal
|
|
114
114
|
*/
|
|
115
|
-
export declare function getConfigForMinVersionForCollabIterable<T>(minVersionForCollab:
|
|
115
|
+
export declare function getConfigForMinVersionForCollabIterable<T>(minVersionForCollab: OldestSupportedClientVersion, entries: Iterable<readonly [MinimumMinorSemanticVersion | OldestSupportedClientVersion, T]>): T;
|
|
116
116
|
/**
|
|
117
117
|
* Finds the entry for the highest version that is less than or equal to the provided minVersionForCollab.
|
|
118
118
|
* @remarks
|
|
@@ -137,11 +137,11 @@ export declare function checkValidMinVersionForCollabVerbose(minVersionForCollab
|
|
|
137
137
|
};
|
|
138
138
|
/**
|
|
139
139
|
* Checks if the minVersionForCollab is valid.
|
|
140
|
-
* A valid minVersionForCollab is a
|
|
140
|
+
* A valid minVersionForCollab is a OldestSupportedClientVersion that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
141
141
|
*
|
|
142
142
|
* @internal
|
|
143
143
|
*/
|
|
144
|
-
export declare function isValidMinVersionForCollab(minVersionForCollab: SemanticVersion): minVersionForCollab is
|
|
144
|
+
export declare function isValidMinVersionForCollab(minVersionForCollab: SemanticVersion): minVersionForCollab is OldestSupportedClientVersion;
|
|
145
145
|
/**
|
|
146
146
|
* `pkgVersion` version without pre-release.
|
|
147
147
|
* @remarks
|
|
@@ -163,24 +163,24 @@ export declare function isValidMinVersionForCollab(minVersionForCollab: Semantic
|
|
|
163
163
|
* To accommodate some uses of the second case, it might be useful to package export this in the future.
|
|
164
164
|
*
|
|
165
165
|
* @privateRemarks
|
|
166
|
-
* Since this is used by validateMinimumVersionForCollab, the type case to
|
|
166
|
+
* Since this is used by validateMinimumVersionForCollab, the type case to OldestSupportedClientVersion can not use it directly.
|
|
167
167
|
* Thus this is just `as` cast here, and a test confirms it is valid according to validateMinimumVersionForCollab.
|
|
168
168
|
*
|
|
169
169
|
* @internal
|
|
170
170
|
*/
|
|
171
|
-
export declare const cleanedPackageVersion:
|
|
171
|
+
export declare const cleanedPackageVersion: OldestSupportedClientVersion;
|
|
172
172
|
/**
|
|
173
|
-
* Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#
|
|
173
|
+
* Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}, throwing a UsageError if it is not valid.
|
|
174
174
|
* @remarks
|
|
175
|
-
* This is more strict than the type constraints imposed by `
|
|
176
|
-
* Currently there is no type which is used to separate semantically valid and typescript allowed
|
|
177
|
-
* thus users that care about strict validation may want to call this on un-validated `
|
|
175
|
+
* This is more strict than the type constraints imposed by `OldestSupportedClientVersion`.
|
|
176
|
+
* Currently there is no type which is used to separate semantically valid and typescript allowed OldestSupportedClientVersion values:
|
|
177
|
+
* thus users that care about strict validation may want to call this on un-validated `OldestSupportedClientVersion` values.
|
|
178
178
|
* @param semanticVersion - The version to check.
|
|
179
|
-
* @throws UsageError if the version is not a valid
|
|
179
|
+
* @throws UsageError if the version is not a valid OldestSupportedClientVersion.
|
|
180
180
|
*
|
|
181
181
|
* @internal
|
|
182
182
|
*/
|
|
183
|
-
export declare function validateMinimumVersionForCollab(semanticVersion: string): asserts semanticVersion is
|
|
183
|
+
export declare function validateMinimumVersionForCollab(semanticVersion: string): asserts semanticVersion is OldestSupportedClientVersion;
|
|
184
184
|
/**
|
|
185
185
|
* Validates the given `overrides`.
|
|
186
186
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibilityBase.d.ts","sourceRoot":"","sources":["../src/compatibilityBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAA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,CAC9C,eAAe,EAAE,MAAM,GACrB,OAAO,CAAC,eAAe,IAAI,4BAA4B,CAYzD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3E,mBAAmB,EAAE,eAAe,EACpC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,EACrB,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC,GACnC,IAAI,CA2BN;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC/C,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,EACxD,GAAG,SAAS,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,EAAE,EAC1C,cAAc,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,eAAe,GAAG,SAAS,CAoCtE"}
|
|
@@ -134,7 +134,7 @@ function checkValidMinVersionForCollabVerbose(minVersionForCollab) {
|
|
|
134
134
|
exports.checkValidMinVersionForCollabVerbose = checkValidMinVersionForCollabVerbose;
|
|
135
135
|
/**
|
|
136
136
|
* Checks if the minVersionForCollab is valid.
|
|
137
|
-
* A valid minVersionForCollab is a
|
|
137
|
+
* A valid minVersionForCollab is a OldestSupportedClientVersion that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
138
138
|
*
|
|
139
139
|
* @internal
|
|
140
140
|
*/
|
|
@@ -165,20 +165,20 @@ const parsedPackageVersion = (0, semver_ts_1.parse)(packageVersion_js_1.pkgVersi
|
|
|
165
165
|
* To accommodate some uses of the second case, it might be useful to package export this in the future.
|
|
166
166
|
*
|
|
167
167
|
* @privateRemarks
|
|
168
|
-
* Since this is used by validateMinimumVersionForCollab, the type case to
|
|
168
|
+
* Since this is used by validateMinimumVersionForCollab, the type case to OldestSupportedClientVersion can not use it directly.
|
|
169
169
|
* Thus this is just `as` cast here, and a test confirms it is valid according to validateMinimumVersionForCollab.
|
|
170
170
|
*
|
|
171
171
|
* @internal
|
|
172
172
|
*/
|
|
173
173
|
exports.cleanedPackageVersion = `${parsedPackageVersion.major}.${parsedPackageVersion.minor}.${parsedPackageVersion.patch}`;
|
|
174
174
|
/**
|
|
175
|
-
* Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#
|
|
175
|
+
* Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}, throwing a UsageError if it is not valid.
|
|
176
176
|
* @remarks
|
|
177
|
-
* This is more strict than the type constraints imposed by `
|
|
178
|
-
* Currently there is no type which is used to separate semantically valid and typescript allowed
|
|
179
|
-
* thus users that care about strict validation may want to call this on un-validated `
|
|
177
|
+
* This is more strict than the type constraints imposed by `OldestSupportedClientVersion`.
|
|
178
|
+
* Currently there is no type which is used to separate semantically valid and typescript allowed OldestSupportedClientVersion values:
|
|
179
|
+
* thus users that care about strict validation may want to call this on un-validated `OldestSupportedClientVersion` values.
|
|
180
180
|
* @param semanticVersion - The version to check.
|
|
181
|
-
* @throws UsageError if the version is not a valid
|
|
181
|
+
* @throws UsageError if the version is not a valid OldestSupportedClientVersion.
|
|
182
182
|
*
|
|
183
183
|
* @internal
|
|
184
184
|
*/
|
|
@@ -186,7 +186,7 @@ function validateMinimumVersionForCollab(semanticVersion) {
|
|
|
186
186
|
const minVersionForCollab = semanticVersion;
|
|
187
187
|
const { isValidSemver, isGteLowestMinVersion, isLtePkgVersion } = checkValidMinVersionForCollabVerbose(minVersionForCollab);
|
|
188
188
|
if (!(isValidSemver && isGteLowestMinVersion && isLtePkgVersion)) {
|
|
189
|
-
throw new internal_2.UsageError(`Version ${minVersionForCollab} is not a valid
|
|
189
|
+
throw new internal_2.UsageError(`Version ${minVersionForCollab} is not a valid OldestSupportedClientVersion. ` +
|
|
190
190
|
`It must be in a valid semver format, at least ${exports.lowestMinVersionForCollab}, ` +
|
|
191
191
|
`and less than or equal to the current package version ${exports.cleanedPackageVersion}. ` +
|
|
192
192
|
`Details: { isValidSemver: ${isValidSemver}, isGteLowestMinVersion: ${isGteLowestMinVersion}, isLtePkgVersion: ${isLtePkgVersion} }`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibilityBase.js","sourceRoot":"","sources":["../src/compatibilityBase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AAEnE,uEAAsE;AACtE,yCAAgE;AAEhE,2DAAiD;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACU,QAAA,0BAA0B,GACtC,gBAA2D,CAAC;AAE7D;;;;;;;;;;GAUG;AACU,QAAA,yBAAyB,GAAG,OAAkD,CAAC;AAiE5F;;;;;;;GAOG;AACH,SAAgB,gCAAgC,CAC/C,mBAA4C,EAC5C,SAAkD;IAElD,+BAA+B,CAAC,mBAAmB,CAAC,CAAC;IACrD,MAAM,cAAc,GAAe,EAAE,CAAC;IACtC,gEAAgE;IAChE,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACvD,cAAc,CAAC,GAAG,CAAC,GAAG,+BAA+B,CACpD,mBAAmB,EACnB,MAAiC,CACjC,CAAC;IACH,CAAC;IACD,wEAAwE;IACxE,OAAO,cAAmB,CAAC;AAC5B,CAAC;AAfD,4EAeC;AAED;;;;GAIG;AACH,SAAgB,+BAA+B,CAC9C,mBAA4C,EAC5C,MAAyB;IAEzB,OAAO,uCAAuC,CAC7C,mBAAmB,EACnB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAuC,CAC5D,CAAC;AACH,CAAC;AARD,0EAQC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,uCAAuC,CACtD,mBAA4C,EAC5C,OAAsF;IAEtF,8DAA8D;IAC9D,MAAM,QAAQ,GAAmC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,EAA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;YAChF,0FAA0F;YAC1F,kCAAkC;YAClC,IAAI,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAChF,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;QACD,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjC,2DAA2D;YAC3D,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAA,mBAAO,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;QACD,qFAAqF;QACrF,+DAA+D;QAC/D,OAAO,SAAS,CAAC;IAClB,CAAC,CAAC;AACH,CAAC;AAvCD,4EAuCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { compare, gt, gte, lte, valid, parse } from \"semver-ts\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Our policy is to support major versions N and N-1, where N is most\n * recent public major release of the Fluid Framework Client.\n * Therefore, if the customer does not provide a minVersionForCollab, we will\n * default to use N-1.\n *\n * However, this is not consistent with today's behavior. Some options (i.e.\n * batching, compression) are enabled by default despite not being compatible\n * with 1.x clients. Since the policy was introduced during 2.x's lifespan,\n * N/N-1 compatibility by **default** will be in effect starting with 3.0.\n * Importantly though, N/N-2 compatibility is still guaranteed with the proper\n * configurations set.\n *\n * Further to distinguish unspecified `minVersionForCollab` from a specified\n * version and allow `enableExplicitSchemaControl` to default to `true` for\n * any 2.0.0+ version, we will use a special value of `2.0.0-defaults`, which\n * is semantically less than 2.0.0.\n *\n * @internal\n */\nexport const defaultMinVersionForCollab =\n\t\"2.0.0-defaults\" as const satisfies MinimumVersionForCollab;\n\n/**\n * We don't want allow a version before the major public release of the LTS version.\n * Today we use \"1.0.0\", because our policy supports N/N-1 & N/N-2, which includes\n * all minor versions of N. Though LTS starts at 1.4.0, we should stay consistent\n * with our policy and allow all 1.x versions to be compatible with 2.x.\n *\n * @privateRemarks\n * Exported for use in tests.\n *\n * @internal\n */\nexport const lowestMinVersionForCollab = \"1.0.0\" as const satisfies MinimumVersionForCollab;\n\n/**\n * String in a valid semver format specifying bottom of a minor version\n * or special \"defaults\" prerelease of a major.\n * @remarks Only 2.0.0-defaults is expected, but index signatures cannot be a\n * literal; so, just allow any major -defaults prerelease.\n *\n * @internal\n */\nexport type MinimumMinorSemanticVersion = `${bigint}.${bigint}.0` | `${bigint}.0.0-defaults`;\n\n/**\n * String in a valid semver format of a specific version at least specifying minor.\n * Unlike {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}, this type allows any bigint for the major version.\n * Used as a more generic type that allows major versions other than 1 or 2.\n *\n * @internal\n */\nexport type SemanticVersion =\n\t| `${bigint}.${bigint}.${bigint}`\n\t| `${bigint}.${bigint}.${bigint}-${string}`;\n\n/**\n * Converts a record into a configuration map that associates each key with an instance of its value type that is based on a {@link MinimumMinorSemanticVersion}.\n * @remarks\n * For a given input {@link @fluidframework/runtime-definitions#MinimumVersionForCollab},\n * the corresponding configuration values can be found by using the entry in the inner objects with the highest {@link MinimumMinorSemanticVersion}\n * that does not exceed the given {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}.\n *\n * Use {@link getConfigsForMinVersionForCollab} to retrieve the configuration for a given a {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}.\n *\n * See the remarks on {@link MinimumMinorSemanticVersion} for some limitation on how ConfigMaps must handle versioning.\n * @internal\n */\nexport type ConfigMap<T extends Record<string, unknown>> = {\n\treadonly [K in keyof T]-?: ConfigMapEntry<T[K]>;\n};\n\n/**\n * Entry in {@link ConfigMap} associating {@link MinimumMinorSemanticVersion} with configuration values that became supported in that version.\n * @remarks\n * All entries must at least provide an entry for {@link lowestMinVersionForCollab}.\n * @internal\n */\nexport interface ConfigMapEntry<T> {\n\t// This index signature (See https://www.typescriptlang.org/docs/handbook/2/objects.html#index-signatures) requires all properties on this type to to have keys that are a MinimumMinorSemanticVersion and values of type T.\n\t// Note that the \"version\" part of this syntax is really just documentation and has no impact on the type checking (other than some identifier being required to the syntax here to differentiate it from the computed property syntax).\n\t[version: MinimumMinorSemanticVersion]: T;\n\t// Require an entry for the defaultMinVersionForCollab:\n\t// this ensures that all versions of lowestMinVersionForCollab or later have a specified value in the ConfigMap.\n\t// Note that this is NOT an index signature.\n\t// This is a regular property with a computed name (See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#computed_property_names).\n\t[lowestMinVersionForCollab]: T;\n}\n\n/**\n * Generic type for runtimeOptionsAffectingDocSchemaConfigValidationMap\n *\n * @internal\n */\nexport type ConfigValidationMap<T extends Record<string, unknown>> = {\n\treadonly [K in keyof T]-?: (configValue: T[K]) => SemanticVersion | undefined;\n};\n\n/**\n * Returns a default configuration given minVersionForCollab and configuration version map.\n *\n * @privateRemarks\n * The extra `Record` type for the `configMap` is just used to allow the body of this function to be more type-safe due to limitations of generic types in TypeScript.\n * It should have no impact on the user of this function.\n * @internal\n */\nexport function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(\n\tminVersionForCollab: MinimumVersionForCollab,\n\tconfigMap: ConfigMap<T> & Record<keyof T, unknown>,\n): T {\n\tvalidateMinimumVersionForCollab(minVersionForCollab);\n\tconst defaultConfigs: Partial<T> = {};\n\t// Iterate over configMap to get default values for each option.\n\tfor (const [key, config] of Object.entries(configMap)) {\n\t\tdefaultConfigs[key] = getConfigForMinVersionForCollab(\n\t\t\tminVersionForCollab,\n\t\t\tconfig as ConfigMapEntry<unknown>,\n\t\t);\n\t}\n\t// We have populated every key, so casting away the Partial is now safe:\n\treturn defaultConfigs as T;\n}\n\n/**\n * Returns a default configuration given minVersionForCollab and {@link ConfigMapEntry}.\n *\n * @internal\n */\nexport function getConfigForMinVersionForCollab<T>(\n\tminVersionForCollab: MinimumVersionForCollab,\n\tconfig: ConfigMapEntry<T>,\n): T {\n\treturn getConfigForMinVersionForCollabIterable(\n\t\tminVersionForCollab,\n\t\tObject.entries(config) as [MinimumMinorSemanticVersion, T][],\n\t);\n}\n\n/**\n * Returns a default configuration given minVersionForCollab and the contents of a {@link ConfigMapEntry} in an Iterable.\n * @remarks\n * See also {@link getConfigForMinVersionForCollab} for consuming a ConfigMapEntry directly.\n *\n * `ConfigMapEntry` is a nice type safe format for developers to directly author this data,\n * but it is messy and less type safe to work with it in this format programmatically.\n * Thus this function exists to help meet the needs of programmatic use cases,\n * like cases which transform a ConfigMapEntry before selecting a value from it.\n * @internal\n */\nexport function getConfigForMinVersionForCollabIterable<T>(\n\tminVersionForCollab: MinimumVersionForCollab,\n\tentries: Iterable<readonly [MinimumMinorSemanticVersion | MinimumVersionForCollab, T]>, // [[typeof lowestMinVersionForCollab, T], ...[MinimumVersionForCollab, T][]],\n): T {\n\t// Validate and strongly type the versions from the configMap.\n\tconst versions: [MinimumVersionForCollab, T][] = Array.from(entries, ([version, value]) => {\n\t\tvalidateMinimumVersionForCollab(version);\n\t\treturn [version, value];\n\t});\n\treturn (selectVersionRoundedDown(minVersionForCollab, versions) ??\n\t\tfail(0xcb8 /* No config map entry for version */))[1];\n}\n\n/**\n * Finds the entry for the highest version that is less than or equal to the provided minVersionForCollab.\n * @remarks\n * If none is found, returns undefined.\n *\n * When used with Fluid client versions, use the stricter {@link getConfigForMinVersionForCollabIterable} instead.\n *\n * @internal\n */\nexport function selectVersionRoundedDown<T>(\n\tminVersionForCollab: string,\n\tentries: Iterable<readonly [string, T]>,\n\tcompareVersions: (a: string, b: string) => number = compare,\n): readonly [string, T] | undefined {\n\t// Sort a copy of the iterable in descending order\n\tconst versions: (readonly [string, T])[] = [...entries];\n\tversions.sort((a, b) => compareVersions(b[0], a[0]));\n\n\t// For each config, we iterate over the keys and check if minVersionForCollab is greater than or equal to the version.\n\t// If so, we set it as the default value for the option.\n\tfor (const pair of versions) {\n\t\tconst [version, _] = pair;\n\t\tif (compareVersions(minVersionForCollab, version) >= 0) {\n\t\t\treturn pair;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * Returns detailed information about the validity of a minVersionForCollab.\n * @param minVersionForCollab - The minVersionForCollab to validate.\n * @returns An object containing the validity information.\n *\n * @internal\n */\nexport function checkValidMinVersionForCollabVerbose(minVersionForCollab: SemanticVersion): {\n\tisValidSemver: boolean;\n\tisGteLowestMinVersion: boolean;\n\tisLtePkgVersion: boolean;\n} {\n\tconst isValidSemver = valid(minVersionForCollab) !== null;\n\treturn {\n\t\tisValidSemver,\n\n\t\t// We have to check if the value is a valid semver before calling gte/lte, otherwise they will throw when parsing the version.\n\t\tisGteLowestMinVersion:\n\t\t\tisValidSemver && gte(minVersionForCollab, lowestMinVersionForCollab),\n\t\tisLtePkgVersion: isValidSemver && lte(minVersionForCollab, cleanedPackageVersion),\n\t};\n}\n\n/**\n * Checks if the minVersionForCollab is valid.\n * A valid minVersionForCollab is a MinimumVersionForCollab that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.\n *\n * @internal\n */\nexport function isValidMinVersionForCollab(\n\tminVersionForCollab: SemanticVersion,\n): minVersionForCollab is MinimumVersionForCollab {\n\tconst { isValidSemver, isGteLowestMinVersion, isLtePkgVersion } =\n\t\tcheckValidMinVersionForCollabVerbose(minVersionForCollab);\n\treturn isValidSemver && isGteLowestMinVersion && isLtePkgVersion;\n}\n\nconst parsedPackageVersion = parse(pkgVersion) ?? fail(0xcb9 /* Invalid package version */);\n\n/**\n * `pkgVersion` version without pre-release.\n * @remarks\n * This is the version that the code in the current version of the codebase will have when officially released.\n * Generally, compatibility of prerelease builds is not guaranteed (especially for how they interact with future releases).\n * So while technically a prerelease build is less (older) than the released version which follows it and thus supports less features,\n * it makes sense for them to claim to support the same features as the following release so they can be used to test how the release would actually behave.\n *\n * To accomplish this, the version the next release will have is provided here as `cleanedPackageVersion` while `pkgVersion` may be a prerelease in some cases,\n * like when running tests on CI, or in an actual prerelease published package.\n * This is then used in {@link validateMinimumVersionForCollab} to allow the version shown on main to be usable as a `minVersionForCollab`, even in CI and prerelease packages.\n *\n * This is of particular note in two cases:\n * 1. When landing a new feature, and setting the minVersionForCollab which enables it to be the version that the next release will have.\n * Having that version be valid on main, pass tests locally, then fail on CI and when using published prerelease packages would be confusing, and probably undesired.\n * 2. Setting the minVersionForCollab to the current version for scenarios that do no involve collab with other package versions seems like it should be valid.\n * This is useful for testing new features, and also non collaborative scenarios where the latest features are desired.\n *\n * To accommodate some uses of the second case, it might be useful to package export this in the future.\n *\n * @privateRemarks\n * Since this is used by validateMinimumVersionForCollab, the type case to MinimumVersionForCollab can not use it directly.\n * Thus this is just `as` cast here, and a test confirms it is valid according to validateMinimumVersionForCollab.\n *\n * @internal\n */\nexport const cleanedPackageVersion =\n\t`${parsedPackageVersion.major}.${parsedPackageVersion.minor}.${parsedPackageVersion.patch}` as MinimumVersionForCollab;\n\n/**\n * Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}, throwing a UsageError if it is not valid.\n * @remarks\n * This is more strict than the type constraints imposed by `MinimumVersionForCollab`.\n * Currently there is no type which is used to separate semantically valid and typescript allowed MinimumVersionForCollab values:\n * thus users that care about strict validation may want to call this on un-validated `MinimumVersionForCollab` values.\n * @param semanticVersion - The version to check.\n * @throws UsageError if the version is not a valid MinimumVersionForCollab.\n *\n * @internal\n */\nexport function validateMinimumVersionForCollab(\n\tsemanticVersion: string,\n): asserts semanticVersion is MinimumVersionForCollab {\n\tconst minVersionForCollab = semanticVersion as MinimumVersionForCollab;\n\tconst { isValidSemver, isGteLowestMinVersion, isLtePkgVersion } =\n\t\tcheckValidMinVersionForCollabVerbose(minVersionForCollab);\n\tif (!(isValidSemver && isGteLowestMinVersion && isLtePkgVersion)) {\n\t\tthrow new UsageError(\n\t\t\t`Version ${minVersionForCollab} is not a valid MinimumVersionForCollab. ` +\n\t\t\t\t`It must be in a valid semver format, at least ${lowestMinVersionForCollab}, ` +\n\t\t\t\t`and less than or equal to the current package version ${cleanedPackageVersion}. ` +\n\t\t\t\t`Details: { isValidSemver: ${isValidSemver}, isGteLowestMinVersion: ${isGteLowestMinVersion}, isLtePkgVersion: ${isLtePkgVersion} }`,\n\t\t);\n\t}\n}\n\n/**\n * Validates the given `overrides`.\n *\n * No-op when minVersionForCollab is set to defaultMinVersionForCollab.\n *\n * Otherwise this checks that for keys which are in both the `validationMap` and the `overrides`,\n * that the `validationMap` function for that key either returns undefined or a version less than or equal to `minVersionForCollab`.\n * @privateRemarks\n * This design seems odd, and might want to be revisited.\n * Currently it only permits opting out of features, not into them (unless validationMap returns undefined),\n * and the handling of defaultMinVersionForCollab and undefined versions seems questionable.\n * Also ignoring of extra keys in overrides might be bad since it seems like overrides is supposed to be validated.\n * @internal\n */\nexport function validateConfigMapOverrides<T extends Record<string, unknown>>(\n\tminVersionForCollab: SemanticVersion,\n\toverrides: Partial<T>,\n\tvalidationMap: ConfigValidationMap<T>,\n): void {\n\tif (minVersionForCollab === defaultMinVersionForCollab) {\n\t\t// If the minVersionForCollab is set to the default value, then we will not validate the runtime options\n\t\t// This is to avoid disruption to users who have not yet set the minVersionForCollab value explicitly.\n\t\t// TODO: This also skips validation for users which explicitly request defaultMinVersionForCollab which seems like a bug.\n\t\treturn;\n\t}\n\t// Iterate through each runtime option passed in by the user\n\t// Type assertion is safe as entries come from runtimeOptions object\n\tfor (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(overrides) as [\n\t\tkeyof T & string,\n\t\tT[keyof T & string],\n\t][]) {\n\t\t// Skip if passedRuntimeOption is not in validation map\n\t\tif (!(passedRuntimeOption in validationMap)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst requiredVersion = validationMap[passedRuntimeOption](passedRuntimeOptionValue);\n\t\tif (requiredVersion !== undefined && gt(requiredVersion, minVersionForCollab)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Runtime option ${passedRuntimeOption}:${JSON.stringify(passedRuntimeOptionValue)} requires ` +\n\t\t\t\t\t`runtime version ${requiredVersion}. Please update minVersionForCollab ` +\n\t\t\t\t\t`(currently ${minVersionForCollab}) to ${requiredVersion} or later to proceed.`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * Helper function to map ContainerRuntimeOptionsInternal config values to\n * minVersionForCollab in, e.g., {@link @fluidframework/container-runtime#runtimeOptionsAffectingDocSchemaConfigValidationMap}.\n *\n * @internal\n */\nexport function configValueToMinVersionForCollab<\n\tT extends string | number | boolean | undefined | object,\n\tArr extends readonly [T, SemanticVersion][],\n>(configToMinVer: Arr): (configValue: T) => SemanticVersion | undefined {\n\tconst configValueToRequiredVersionMap = new Map(configToMinVer);\n\treturn (configValue: T) => {\n\t\t// If the configValue is not an object then we can get the version required directly from the map.\n\t\tif (typeof configValue !== \"object\") {\n\t\t\treturn configValueToRequiredVersionMap.get(configValue);\n\t\t}\n\t\t// When the input `configValue` is an object, this logic determines the minimum runtime version it requires.\n\t\t// It iterates through each entry in `configValueToRequiredVersionMap`. If `possibleConfigValue` shares at\n\t\t// least one key-value pair with the input `configValue`, its associated `versionRequired` is collected into\n\t\t// `matchingVersions`. After checking all entries, the highest among the collected versions is returned.\n\t\t// This represents the overall minimum version required to support the features implied by the input `configValue`.\n\t\tconst matchingVersions: SemanticVersion[] = [];\n\t\tfor (const [\n\t\t\tpossibleConfigValue,\n\t\t\tversionRequired,\n\t\t] of configValueToRequiredVersionMap.entries()) {\n\t\t\tassert(\n\t\t\t\ttypeof possibleConfigValue == \"object\",\n\t\t\t\t0xbb9 /* possibleConfigValue should be an object */,\n\t\t\t);\n\t\t\t// Check if `possibleConfigValue` and the input `configValue` share at least one\n\t\t\t// common key-value pair. If they do, the `versionRequired` for this `possibleConfigValue`\n\t\t\t// is added to `matchingVersions`.\n\t\t\tif (Object.entries(possibleConfigValue).some(([k, v]) => configValue[k] === v)) {\n\t\t\t\tmatchingVersions.push(versionRequired);\n\t\t\t}\n\t\t}\n\t\tif (matchingVersions.length > 0) {\n\t\t\t// Return the latest minVersionForCollab among all matches.\n\t\t\treturn matchingVersions.sort((a, b) => compare(b, a))[0];\n\t\t}\n\t\t// If no matches then we return undefined. This means that the config value passed in\n\t\t// does not require a specific minVersionForCollab to be valid.\n\t\treturn undefined;\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compatibilityBase.js","sourceRoot":"","sources":["../src/compatibilityBase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AAEnE,uEAAsE;AACtE,yCAAgE;AAEhE,2DAAiD;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACU,QAAA,0BAA0B,GACtC,gBAAgE,CAAC;AAElE;;;;;;;;;;GAUG;AACU,QAAA,yBAAyB,GACrC,OAAuD,CAAC;AAiEzD;;;;;;;GAOG;AACH,SAAgB,gCAAgC,CAC/C,mBAAiD,EACjD,SAAkD;IAElD,+BAA+B,CAAC,mBAAmB,CAAC,CAAC;IACrD,MAAM,cAAc,GAAe,EAAE,CAAC;IACtC,gEAAgE;IAChE,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACvD,cAAc,CAAC,GAAG,CAAC,GAAG,+BAA+B,CACpD,mBAAmB,EACnB,MAAiC,CACjC,CAAC;IACH,CAAC;IACD,wEAAwE;IACxE,OAAO,cAAmB,CAAC;AAC5B,CAAC;AAfD,4EAeC;AAED;;;;GAIG;AACH,SAAgB,+BAA+B,CAC9C,mBAAiD,EACjD,MAAyB;IAEzB,OAAO,uCAAuC,CAC7C,mBAAm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C1G,4GAA4G;QAC5G,wGAAwG;QACxG,mHAAmH;QACnH,MAAM,gBAAgB,GAAsB,EAAE,CAAC;QAC/C,KAAK,MAAM,CACV,mBAAmB,EACnB,eAAe,EACf,IAAI,+BAA+B,CAAC,OAAO,EAAE,EAAE,CAAC;YAChD,IAAA,iBAAM,EACL,OAAO,mBAAmB,IAAI,QAAQ,EACtC,KAAK,CAAC,6CAA6C,CACnD,CAAC;YACF,gFAAgF;YAChF,0FAA0F;YAC1F,kCAAkC;YAClC,IAAI,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAChF,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;QACD,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjC,2DAA2D;YAC3D,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAA,mBAAO,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;QACD,qFAAqF;QACrF,+DAA+D;QAC/D,OAAO,SAAS,CAAC;IAClB,CAAC,CAAC;AACH,CAAC;AAvCD,4EAuCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { OldestSupportedClientVersion } from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { compare, gt, gte, lte, valid, parse } from \"semver-ts\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Our policy is to support major versions N and N-1, where N is most\n * recent public major release of the Fluid Framework Client.\n * Therefore, if the customer does not provide a minVersionForCollab, we will\n * default to use N-1.\n *\n * However, this is not consistent with today's behavior. Some options (i.e.\n * batching, compression) are enabled by default despite not being compatible\n * with 1.x clients. Since the policy was introduced during 2.x's lifespan,\n * N/N-1 compatibility by **default** will be in effect starting with 3.0.\n * Importantly though, N/N-2 compatibility is still guaranteed with the proper\n * configurations set.\n *\n * Further to distinguish unspecified `minVersionForCollab` from a specified\n * version and allow `enableExplicitSchemaControl` to default to `true` for\n * any 2.0.0+ version, we will use a special value of `2.0.0-defaults`, which\n * is semantically less than 2.0.0.\n *\n * @internal\n */\nexport const defaultMinVersionForCollab =\n\t\"2.0.0-defaults\" as const satisfies OldestSupportedClientVersion;\n\n/**\n * We don't want allow a version before the major public release of the LTS version.\n * Today we use \"1.0.0\", because our policy supports N/N-1 & N/N-2, which includes\n * all minor versions of N. Though LTS starts at 1.4.0, we should stay consistent\n * with our policy and allow all 1.x versions to be compatible with 2.x.\n *\n * @privateRemarks\n * Exported for use in tests.\n *\n * @internal\n */\nexport const lowestMinVersionForCollab =\n\t\"1.0.0\" as const satisfies OldestSupportedClientVersion;\n\n/**\n * String in a valid semver format specifying bottom of a minor version\n * or special \"defaults\" prerelease of a major.\n * @remarks Only 2.0.0-defaults is expected, but index signatures cannot be a\n * literal; so, just allow any major -defaults prerelease.\n *\n * @internal\n */\nexport type MinimumMinorSemanticVersion = `${bigint}.${bigint}.0` | `${bigint}.0.0-defaults`;\n\n/**\n * String in a valid semver format of a specific version at least specifying minor.\n * Unlike {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}, this type allows any bigint for the major version.\n * Used as a more generic type that allows major versions other than 1 or 2.\n *\n * @internal\n */\nexport type SemanticVersion =\n\t| `${bigint}.${bigint}.${bigint}`\n\t| `${bigint}.${bigint}.${bigint}-${string}`;\n\n/**\n * Converts a record into a configuration map that associates each key with an instance of its value type that is based on a {@link MinimumMinorSemanticVersion}.\n * @remarks\n * For a given input {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion},\n * the corresponding configuration values can be found by using the entry in the inner objects with the highest {@link MinimumMinorSemanticVersion}\n * that does not exceed the given {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}.\n *\n * Use {@link getConfigsForMinVersionForCollab} to retrieve the configuration for a given a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}.\n *\n * See the remarks on {@link MinimumMinorSemanticVersion} for some limitation on how ConfigMaps must handle versioning.\n * @internal\n */\nexport type ConfigMap<T extends Record<string, unknown>> = {\n\treadonly [K in keyof T]-?: ConfigMapEntry<T[K]>;\n};\n\n/**\n * Entry in {@link ConfigMap} associating {@link MinimumMinorSemanticVersion} with configuration values that became supported in that version.\n * @remarks\n * All entries must at least provide an entry for {@link lowestMinVersionForCollab}.\n * @internal\n */\nexport interface ConfigMapEntry<T> {\n\t// This index signature (See https://www.typescriptlang.org/docs/handbook/2/objects.html#index-signatures) requires all properties on this type to to have keys that are a MinimumMinorSemanticVersion and values of type T.\n\t// Note that the \"version\" part of this syntax is really just documentation and has no impact on the type checking (other than some identifier being required to the syntax here to differentiate it from the computed property syntax).\n\t[version: MinimumMinorSemanticVersion]: T;\n\t// Require an entry for the defaultMinVersionForCollab:\n\t// this ensures that all versions of lowestMinVersionForCollab or later have a specified value in the ConfigMap.\n\t// Note that this is NOT an index signature.\n\t// This is a regular property with a computed name (See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#computed_property_names).\n\t[lowestMinVersionForCollab]: T;\n}\n\n/**\n * Generic type for runtimeOptionsAffectingDocSchemaConfigValidationMap\n *\n * @internal\n */\nexport type ConfigValidationMap<T extends Record<string, unknown>> = {\n\treadonly [K in keyof T]-?: (configValue: T[K]) => SemanticVersion | undefined;\n};\n\n/**\n * Returns a default configuration given minVersionForCollab and configuration version map.\n *\n * @privateRemarks\n * The extra `Record` type for the `configMap` is just used to allow the body of this function to be more type-safe due to limitations of generic types in TypeScript.\n * It should have no impact on the user of this function.\n * @internal\n */\nexport function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(\n\tminVersionForCollab: OldestSupportedClientVersion,\n\tconfigMap: ConfigMap<T> & Record<keyof T, unknown>,\n): T {\n\tvalidateMinimumVersionForCollab(minVersionForCollab);\n\tconst defaultConfigs: Partial<T> = {};\n\t// Iterate over configMap to get default values for each option.\n\tfor (const [key, config] of Object.entries(configMap)) {\n\t\tdefaultConfigs[key] = getConfigForMinVersionForCollab(\n\t\t\tminVersionForCollab,\n\t\t\tconfig as ConfigMapEntry<unknown>,\n\t\t);\n\t}\n\t// We have populated every key, so casting away the Partial is now safe:\n\treturn defaultConfigs as T;\n}\n\n/**\n * Returns a default configuration given minVersionForCollab and {@link ConfigMapEntry}.\n *\n * @internal\n */\nexport function getConfigForMinVersionForCollab<T>(\n\tminVersionForCollab: OldestSupportedClientVersion,\n\tconfig: ConfigMapEntry<T>,\n): T {\n\treturn getConfigForMinVersionForCollabIterable(\n\t\tminVersionForCollab,\n\t\tObject.entries(config) as [MinimumMinorSemanticVersion, T][],\n\t);\n}\n\n/**\n * Returns a default configuration given minVersionForCollab and the contents of a {@link ConfigMapEntry} in an Iterable.\n * @remarks\n * See also {@link getConfigForMinVersionForCollab} for consuming a ConfigMapEntry directly.\n *\n * `ConfigMapEntry` is a nice type safe format for developers to directly author this data,\n * but it is messy and less type safe to work with it in this format programmatically.\n * Thus this function exists to help meet the needs of programmatic use cases,\n * like cases which transform a ConfigMapEntry before selecting a value from it.\n * @internal\n */\nexport function getConfigForMinVersionForCollabIterable<T>(\n\tminVersionForCollab: OldestSupportedClientVersion,\n\tentries: Iterable<readonly [MinimumMinorSemanticVersion | OldestSupportedClientVersion, T]>, // [[typeof lowestMinVersionForCollab, T], ...[OldestSupportedClientVersion, T][]],\n): T {\n\t// Validate and strongly type the versions from the configMap.\n\tconst versions: [OldestSupportedClientVersion, T][] = Array.from(\n\t\tentries,\n\t\t([version, value]) => {\n\t\t\tvalidateMinimumVersionForCollab(version);\n\t\t\treturn [version, value];\n\t\t},\n\t);\n\treturn (selectVersionRoundedDown(minVersionForCollab, versions) ??\n\t\tfail(0xcb8 /* No config map entry for version */))[1];\n}\n\n/**\n * Finds the entry for the highest version that is less than or equal to the provided minVersionForCollab.\n * @remarks\n * If none is found, returns undefined.\n *\n * When used with Fluid client versions, use the stricter {@link getConfigForMinVersionForCollabIterable} instead.\n *\n * @internal\n */\nexport function selectVersionRoundedDown<T>(\n\tminVersionForCollab: string,\n\tentries: Iterable<readonly [string, T]>,\n\tcompareVersions: (a: string, b: string) => number = compare,\n): readonly [string, T] | undefined {\n\t// Sort a copy of the iterable in descending order\n\tconst versions: (readonly [string, T])[] = [...entries];\n\tversions.sort((a, b) => compareVersions(b[0], a[0]));\n\n\t// For each config, we iterate over the keys and check if minVersionForCollab is greater than or equal to the version.\n\t// If so, we set it as the default value for the option.\n\tfor (const pair of versions) {\n\t\tconst [version, _] = pair;\n\t\tif (compareVersions(minVersionForCollab, version) >= 0) {\n\t\t\treturn pair;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * Returns detailed information about the validity of a minVersionForCollab.\n * @param minVersionForCollab - The minVersionForCollab to validate.\n * @returns An object containing the validity information.\n *\n * @internal\n */\nexport function checkValidMinVersionForCollabVerbose(minVersionForCollab: SemanticVersion): {\n\tisValidSemver: boolean;\n\tisGteLowestMinVersion: boolean;\n\tisLtePkgVersion: boolean;\n} {\n\tconst isValidSemver = valid(minVersionForCollab) !== null;\n\treturn {\n\t\tisValidSemver,\n\n\t\t// We have to check if the value is a valid semver before calling gte/lte, otherwise they will throw when parsing the version.\n\t\tisGteLowestMinVersion:\n\t\t\tisValidSemver && gte(minVersionForCollab, lowestMinVersionForCollab),\n\t\tisLtePkgVersion: isValidSemver && lte(minVersionForCollab, cleanedPackageVersion),\n\t};\n}\n\n/**\n * Checks if the minVersionForCollab is valid.\n * A valid minVersionForCollab is a OldestSupportedClientVersion that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.\n *\n * @internal\n */\nexport function isValidMinVersionForCollab(\n\tminVersionForCollab: SemanticVersion,\n): minVersionForCollab is OldestSupportedClientVersion {\n\tconst { isValidSemver, isGteLowestMinVersion, isLtePkgVersion } =\n\t\tcheckValidMinVersionForCollabVerbose(minVersionForCollab);\n\treturn isValidSemver && isGteLowestMinVersion && isLtePkgVersion;\n}\n\nconst parsedPackageVersion = parse(pkgVersion) ?? fail(0xcb9 /* Invalid package version */);\n\n/**\n * `pkgVersion` version without pre-release.\n * @remarks\n * This is the version that the code in the current version of the codebase will have when officially released.\n * Generally, compatibility of prerelease builds is not guaranteed (especially for how they interact with future releases).\n * So while technically a prerelease build is less (older) than the released version which follows it and thus supports less features,\n * it makes sense for them to claim to support the same features as the following release so they can be used to test how the release would actually behave.\n *\n * To accomplish this, the version the next release will have is provided here as `cleanedPackageVersion` while `pkgVersion` may be a prerelease in some cases,\n * like when running tests on CI, or in an actual prerelease published package.\n * This is then used in {@link validateMinimumVersionForCollab} to allow the version shown on main to be usable as a `minVersionForCollab`, even in CI and prerelease packages.\n *\n * This is of particular note in two cases:\n * 1. When landing a new feature, and setting the minVersionForCollab which enables it to be the version that the next release will have.\n * Having that version be valid on main, pass tests locally, then fail on CI and when using published prerelease packages would be confusing, and probably undesired.\n * 2. Setting the minVersionForCollab to the current version for scenarios that do no involve collab with other package versions seems like it should be valid.\n * This is useful for testing new features, and also non collaborative scenarios where the latest features are desired.\n *\n * To accommodate some uses of the second case, it might be useful to package export this in the future.\n *\n * @privateRemarks\n * Since this is used by validateMinimumVersionForCollab, the type case to OldestSupportedClientVersion can not use it directly.\n * Thus this is just `as` cast here, and a test confirms it is valid according to validateMinimumVersionForCollab.\n *\n * @internal\n */\nexport const cleanedPackageVersion =\n\t`${parsedPackageVersion.major}.${parsedPackageVersion.minor}.${parsedPackageVersion.patch}` as OldestSupportedClientVersion;\n\n/**\n * Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}, throwing a UsageError if it is not valid.\n * @remarks\n * This is more strict than the type constraints imposed by `OldestSupportedClientVersion`.\n * Currently there is no type which is used to separate semantically valid and typescript allowed OldestSupportedClientVersion values:\n * thus users that care about strict validation may want to call this on un-validated `OldestSupportedClientVersion` values.\n * @param semanticVersion - The version to check.\n * @throws UsageError if the version is not a valid OldestSupportedClientVersion.\n *\n * @internal\n */\nexport function validateMinimumVersionForCollab(\n\tsemanticVersion: string,\n): asserts semanticVersion is OldestSupportedClientVersion {\n\tconst minVersionForCollab = semanticVersion as OldestSupportedClientVersion;\n\tconst { isValidSemver, isGteLowestMinVersion, isLtePkgVersion } =\n\t\tcheckValidMinVersionForCollabVerbose(minVersionForCollab);\n\tif (!(isValidSemver && isGteLowestMinVersion && isLtePkgVersion)) {\n\t\tthrow new UsageError(\n\t\t\t`Version ${minVersionForCollab} is not a valid OldestSupportedClientVersion. ` +\n\t\t\t\t`It must be in a valid semver format, at least ${lowestMinVersionForCollab}, ` +\n\t\t\t\t`and less than or equal to the current package version ${cleanedPackageVersion}. ` +\n\t\t\t\t`Details: { isValidSemver: ${isValidSemver}, isGteLowestMinVersion: ${isGteLowestMinVersion}, isLtePkgVersion: ${isLtePkgVersion} }`,\n\t\t);\n\t}\n}\n\n/**\n * Validates the given `overrides`.\n *\n * No-op when minVersionForCollab is set to defaultMinVersionForCollab.\n *\n * Otherwise this checks that for keys which are in both the `validationMap` and the `overrides`,\n * that the `validationMap` function for that key either returns undefined or a version less than or equal to `minVersionForCollab`.\n * @privateRemarks\n * This design seems odd, and might want to be revisited.\n * Currently it only permits opting out of features, not into them (unless validationMap returns undefined),\n * and the handling of defaultMinVersionForCollab and undefined versions seems questionable.\n * Also ignoring of extra keys in overrides might be bad since it seems like overrides is supposed to be validated.\n * @internal\n */\nexport function validateConfigMapOverrides<T extends Record<string, unknown>>(\n\tminVersionForCollab: SemanticVersion,\n\toverrides: Partial<T>,\n\tvalidationMap: ConfigValidationMap<T>,\n): void {\n\tif (minVersionForCollab === defaultMinVersionForCollab) {\n\t\t// If the minVersionForCollab is set to the default value, then we will not validate the runtime options\n\t\t// This is to avoid disruption to users who have not yet set the minVersionForCollab value explicitly.\n\t\t// TODO: This also skips validation for users which explicitly request defaultMinVersionForCollab which seems like a bug.\n\t\treturn;\n\t}\n\t// Iterate through each runtime option passed in by the user\n\t// Type assertion is safe as entries come from runtimeOptions object\n\tfor (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(overrides) as [\n\t\tkeyof T & string,\n\t\tT[keyof T & string],\n\t][]) {\n\t\t// Skip if passedRuntimeOption is not in validation map\n\t\tif (!(passedRuntimeOption in validationMap)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst requiredVersion = validationMap[passedRuntimeOption](passedRuntimeOptionValue);\n\t\tif (requiredVersion !== undefined && gt(requiredVersion, minVersionForCollab)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Runtime option ${passedRuntimeOption}:${JSON.stringify(passedRuntimeOptionValue)} requires ` +\n\t\t\t\t\t`runtime version ${requiredVersion}. Please update minVersionForCollab ` +\n\t\t\t\t\t`(currently ${minVersionForCollab}) to ${requiredVersion} or later to proceed.`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * Helper function to map ContainerRuntimeOptionsInternal config values to\n * minVersionForCollab in, e.g., {@link @fluidframework/container-runtime#runtimeOptionsAffectingDocSchemaConfigValidationMap}.\n *\n * @internal\n */\nexport function configValueToMinVersionForCollab<\n\tT extends string | number | boolean | undefined | object,\n\tArr extends readonly [T, SemanticVersion][],\n>(configToMinVer: Arr): (configValue: T) => SemanticVersion | undefined {\n\tconst configValueToRequiredVersionMap = new Map(configToMinVer);\n\treturn (configValue: T) => {\n\t\t// If the configValue is not an object then we can get the version required directly from the map.\n\t\tif (typeof configValue !== \"object\") {\n\t\t\treturn configValueToRequiredVersionMap.get(configValue);\n\t\t}\n\t\t// When the input `configValue` is an object, this logic determines the minimum runtime version it requires.\n\t\t// It iterates through each entry in `configValueToRequiredVersionMap`. If `possibleConfigValue` shares at\n\t\t// least one key-value pair with the input `configValue`, its associated `versionRequired` is collected into\n\t\t// `matchingVersions`. After checking all entries, the highest among the collected versions is returned.\n\t\t// This represents the overall minimum version required to support the features implied by the input `configValue`.\n\t\tconst matchingVersions: SemanticVersion[] = [];\n\t\tfor (const [\n\t\t\tpossibleConfigValue,\n\t\t\tversionRequired,\n\t\t] of configValueToRequiredVersionMap.entries()) {\n\t\t\tassert(\n\t\t\t\ttypeof possibleConfigValue == \"object\",\n\t\t\t\t0xbb9 /* possibleConfigValue should be an object */,\n\t\t\t);\n\t\t\t// Check if `possibleConfigValue` and the input `configValue` share at least one\n\t\t\t// common key-value pair. If they do, the `versionRequired` for this `possibleConfigValue`\n\t\t\t// is added to `matchingVersions`.\n\t\t\tif (Object.entries(possibleConfigValue).some(([k, v]) => configValue[k] === v)) {\n\t\t\t\tmatchingVersions.push(versionRequired);\n\t\t\t}\n\t\t}\n\t\tif (matchingVersions.length > 0) {\n\t\t\t// Return the latest minVersionForCollab among all matches.\n\t\t\treturn matchingVersions.sort((a, b) => compare(b, a))[0];\n\t\t}\n\t\t// If no matches then we return undefined. This means that the config value passed in\n\t\t// does not require a specific minVersionForCollab to be valid.\n\t\treturn undefined;\n\t};\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/runtime-utils";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.116.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/runtime-utils";
|
|
11
|
-
exports.pkgVersion = "2.
|
|
11
|
+
exports.pkgVersion = "2.116.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"2.116.0\";\n"]}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { ICodeDetailsLoader, IContainerContext, IRuntime } from "@fluidframework/container-definitions/internal";
|
|
6
6
|
import type { FluidObject } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { type DataStoreKey, type DataStoreKind, type DataStoreRegistry, type FluidContainerAttached, type FluidContainerWithService, type Registry, type ServiceClient } from "@fluidframework/driver-definitions/internal";
|
|
8
|
-
import type { IContainerRuntimeBase, IFluidDataStoreRegistry,
|
|
8
|
+
import type { IContainerRuntimeBase, IFluidDataStoreRegistry, OldestSupportedClientVersion } from "@fluidframework/runtime-definitions/internal";
|
|
9
9
|
/**
|
|
10
10
|
* The constant ID used for the root data store alias in service containers.
|
|
11
11
|
* @internal
|
|
@@ -34,7 +34,7 @@ export interface ContainerRuntimeLoaderParams {
|
|
|
34
34
|
registry: IFluidDataStoreRegistry;
|
|
35
35
|
provideEntryPoint: (runtime: IContainerRuntimeBase) => Promise<FluidObject>;
|
|
36
36
|
existing: boolean;
|
|
37
|
-
minVersionForCollab:
|
|
37
|
+
minVersionForCollab: OldestSupportedClientVersion;
|
|
38
38
|
/**
|
|
39
39
|
* The type string of the root data store to create. Only set when `existing` is false.
|
|
40
40
|
*/
|
|
@@ -65,7 +65,7 @@ export type ContainerRuntimeLoader = (parameters: ContainerRuntimeLoaderParams)
|
|
|
65
65
|
*
|
|
66
66
|
* @internal
|
|
67
67
|
*/
|
|
68
|
-
export declare function makeCodeLoader<T>(registry: DataStoreRegistry<T>, minVersionForCollab:
|
|
68
|
+
export declare function makeCodeLoader<T>(registry: DataStoreRegistry<T>, minVersionForCollab: OldestSupportedClientVersion, loadRuntime: ContainerRuntimeLoader, root?: DataStoreKind<T>): ICodeDetailsLoader;
|
|
69
69
|
/**
|
|
70
70
|
* Minimal interface for the static container factory methods used by {@link ServiceClientImplementation}.
|
|
71
71
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceClientUtils.d.ts","sourceRoot":"","sources":["../src/serviceClientUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,iBAAiB,EAIjB,QAAQ,EAER,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,QAAQ,EAEb,KAAK,aAAa,EAClB,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EAEX,qBAAqB,EACrB,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corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tICodeDetailsLoader,\n\tIContainerContext,\n\tIFluidCodeDetails,\n\tIFluidCodeDetailsComparer,\n\tIFluidModuleWithDetails,\n\tIRuntime,\n\tIRuntimeFactory,\n} from \"@fluidframework/container-definitions/internal\";\nimport type { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tcreateBasicRegistryKey,\n\ttype DataStoreKey,\n\ttype DataStoreKind,\n\ttype DataStoreRegistry,\n\ttype FluidContainerAttached,\n\ttype FluidContainerWithService,\n\ttype Registry,\n\tlookupInRegistry,\n\ttype ServiceClient,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tFluidDataStoreRegistryEntry,\n\tIContainerRuntimeBase,\n\tIFluidDataStoreRegistry,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { DataStoreKindImplementation } from \"./serviceClientBase.js\";\n\n/**\n * The constant ID used for the root data store alias in service containers.\n * @internal\n */\nexport const rootDataStoreId = \"root\";\n\n/**\n * Converts a `DataStoreRegistry` to the `IFluidDataStoreRegistry` interface expected by the container runtime.\n * @remarks\n * This does not leverage the ability for `IFluidDataStoreRegistry.get` to return undefined.\n * Note that all use-cases of `IFluidDataStoreRegistry.get` returning undefined currently end up as a fatal error.\n * Therefore it should be fine for the error to instead be thrown by the registry function, which is what this function does.\n * @internal\n */\nexport function convertRegistry<T>(registry: DataStoreRegistry<T>): IFluidDataStoreRegistry {\n\treturn {\n\t\tasync get(name: string): Promise<FluidDataStoreRegistryEntry | undefined> {\n\t\t\tconst dataStoreKind = await lookupInRegistry(registry, createBasicRegistryKey(name));\n\t\t\tDataStoreKindImplementation.narrowGeneric(dataStoreKind);\n\t\t\treturn dataStoreKind;\n\t\t},\n\t\tget IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\t\treturn this;\n\t\t},\n\t};\n}\n\n/**\n * Normalizes a `DataStoreKind` or registry function into a registry function.\n * @internal\n */\nexport function normalizeRegistry<T>(\n\tinput: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>,\n): Registry<Promise<DataStoreKind<T>>> {\n\tif (DataStoreKindImplementation.guard(input)) {\n\t\treturn async () => input;\n\t}\n\tassert(typeof input === \"function\", 0xd17 /* Registry must be a function */);\n\treturn input;\n}\n\n/**\n * Parameters passed to a {@link ContainerRuntimeLoader}.\n * @internal\n */\nexport interface ContainerRuntimeLoaderParams {\n\tcontext: IContainerContext;\n\tregistry: IFluidDataStoreRegistry;\n\tprovideEntryPoint: (runtime: IContainerRuntimeBase) => Promise<FluidObject>;\n\texisting: boolean;\n\tminVersionForCollab: MinimumVersionForCollab;\n\t/**\n\t * The type string of the root data store to create. Only set when `existing` is false.\n\t */\n\tnewContainerRootType: string | undefined;\n}\n\n/**\n * A service-specific callback that creates or loads the container runtime.\n *\n * @remarks\n * Receives the runtime parameters assembled by {@link makeCodeLoader} and is responsible for\n * calling the concrete runtime factory (e.g. `ContainerRuntime.loadRuntime2`) and, when\n * `existing` is `false`, initializing the root data store before returning.\n *\n * @internal\n */\nexport type ContainerRuntimeLoader = (\n\tparameters: ContainerRuntimeLoaderParams,\n) => Promise<IRuntime>;\n\n/**\n * Creates an `ICodeDetailsLoader` that wires up the container runtime via the supplied\n * `loadRuntime` callback.\n *\n * @remarks\n * The `loadRuntime` callback is responsible for invoking the concrete runtime factory and,\n * when `parameters.existing` is `false` and `parameters.newContainerRootType` is set, creating and\n * aliasing the root data store.\n *\n * This loader never does any code loading, and always assumes it is compatible.\n * TODO: We should reevaluate this before promoting ServiceClient APIs to beta.\n *\n * @internal\n */\nexport function makeCodeLoader<T>(\n\tregistry: DataStoreRegistry<T>,\n\tminVersionForCollab: MinimumVersionForCollab,\n\tloadRuntime: ContainerRuntimeLoader,\n\troot?: DataStoreKind<T>,\n): ICodeDetailsLoader {\n\tconst fluidExport: IRuntimeFactory & IFluidCodeDetailsComparer = {\n\t\tasync instantiateRuntime(\n\t\t\tcontext: IContainerContext,\n\t\t\texisting: boolean,\n\t\t): Promise<IRuntime> {\n\t\t\tconst provideEntryPoint = async (\n\t\t\t\tentryPointRuntime: IContainerRuntimeBase,\n\t\t\t): Promise<T & FluidObject> => {\n\t\t\t\tconst data = await entryPointRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\t\tif (data === undefined) {\n\t\t\t\t\tthrow new Error(\"Root data store missing!\");\n\t\t\t\t}\n\t\t\t\tconst rootDataStore = await data.get();\n\t\t\t\treturn rootDataStore as T & FluidObject;\n\t\t\t};\n\n\t\t\treturn loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistry: convertRegistry(registry),\n\t\t\t\tprovideEntryPoint,\n\t\t\t\texisting,\n\t\t\t\tminVersionForCollab,\n\t\t\t\tnewContainerRootType: root?.type,\n\t\t\t});\n\t\t},\n\n\t\tasync satisfies(\n\t\t\tcandidate: IFluidCodeDetails,\n\t\t\tconstraint: IFluidCodeDetails,\n\t\t): Promise<boolean> {\n\t\t\treturn true;\n\t\t},\n\n\t\tasync compare(a: IFluidCodeDetails, b: IFluidCodeDetails): Promise<number | undefined> {\n\t\t\treturn 0;\n\t\t},\n\n\t\tget IRuntimeFactory(): IRuntimeFactory {\n\t\t\treturn fluidExport;\n\t\t},\n\n\t\tget IFluidCodeDetailsComparer(): IFluidCodeDetailsComparer {\n\t\t\treturn fluidExport;\n\t\t},\n\t};\n\n\treturn {\n\t\tload: async (details: IFluidCodeDetails): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn { module: { fluidExport }, details };\n\t\t},\n\t};\n}\n\n/**\n * Minimal interface for the static container factory methods used by {@link ServiceClientImplementation}.\n * @internal\n */\nexport interface ServiceContainerStatics<TOptions> {\n\tcreateDetached<T>(\n\t\tregistry: DataStoreRegistry<T>,\n\t\toptions: TOptions,\n\t\troot: DataStoreKind<T>,\n\t): Promise<FluidContainerWithService<T>>;\n\n\tload<T>(\n\t\tregistry: DataStoreRegistry<T>,\n\t\toptions: TOptions,\n\t\tid: string,\n\t): Promise<FluidContainerAttached<T>>;\n}\n\n/**\n * Creates a {@link @fluidframework/driver-definitions#ServiceClient} that delegates container\n * creation and loading to the supplied container class statics.\n * @internal\n */\nexport class ServiceClientImplementation<TOptions> implements ServiceClient {\n\tpublic constructor(\n\t\tprivate readonly options: TOptions,\n\t\tprivate readonly statics: ServiceContainerStatics<TOptions>,\n\t) {}\n\n\t// This implements the ServiceClient interface's safer version of this with overloads.\n\t// For use in the implementation however, this is simpler, and allows createAttachedContainer to forward to it more easily.\n\tpublic async createContainer<T>(\n\t\troot: DataStoreKey<T> | DataStoreKind<T>,\n\t\tregistry?: Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerWithService<T>> {\n\t\tif (registry === undefined) {\n\t\t\tDataStoreKindImplementation.narrowGeneric(root);\n\t\t\treturn this.statics.createDetached(normalizeRegistry(root), this.options, root);\n\t\t} else {\n\t\t\tconst result = await lookupInRegistry(registry, root);\n\t\t\treturn this.statics.createDetached(registry, this.options, result);\n\t\t}\n\t}\n\n\tpublic async createAttachedContainer<T>(\n\t\troot: DataStoreKey<T> | DataStoreKind<T>,\n\t\tregistry?: Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerAttached<T>> {\n\t\tconst container = await this.createContainer(root, registry);\n\t\treturn container.attach();\n\t}\n\n\tpublic async loadContainer<T>(\n\t\tid: string,\n\t\troot: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerAttached<T>> {\n\t\treturn this.statics.load(normalizeRegistry(root), this.options, id);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serviceClientUtils.js","sourceRoot":"","sources":["../src/serviceClientUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAYH,kEAA6D;AAC7D,0EAUqD;AAQrD,iEAAqE;AAErE;;;GAGG;AACU,QAAA,eAAe,GAAG,MAAM,CAAC;AAEtC;;;;;;;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,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACpE,CAAC;IACF,CAAC;IAEM,KAAK,CAAC,uBAAuB,CACnC,IAAwC,EACxC,QAA8C;QAE9C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC7D,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,aAAa,CACzB,EAAU,EACV,IAA4D;QAE5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC;CACD;AAnCD,kEAmCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tICodeDetailsLoader,\n\tIContainerContext,\n\tIFluidCodeDetails,\n\tIFluidCodeDetailsComparer,\n\tIFluidModuleWithDetails,\n\tIRuntime,\n\tIRuntimeFactory,\n} from \"@fluidframework/container-definitions/internal\";\nimport type { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tcreateBasicRegistryKey,\n\ttype DataStoreKey,\n\ttype DataStoreKind,\n\ttype DataStoreRegistry,\n\ttype FluidContainerAttached,\n\ttype FluidContainerWithService,\n\ttype Registry,\n\tlookupInRegistry,\n\ttype ServiceClient,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tFluidDataStoreRegistryEntry,\n\tIContainerRuntimeBase,\n\tIFluidDataStoreRegistry,\n\tOldestSupportedClientVersion,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { DataStoreKindImplementation } from \"./serviceClientBase.js\";\n\n/**\n * The constant ID used for the root data store alias in service containers.\n * @internal\n */\nexport const rootDataStoreId = \"root\";\n\n/**\n * Converts a `DataStoreRegistry` to the `IFluidDataStoreRegistry` interface expected by the container runtime.\n * @remarks\n * This does not leverage the ability for `IFluidDataStoreRegistry.get` to return undefined.\n * Note that all use-cases of `IFluidDataStoreRegistry.get` returning undefined currently end up as a fatal error.\n * Therefore it should be fine for the error to instead be thrown by the registry function, which is what this function does.\n * @internal\n */\nexport function convertRegistry<T>(registry: DataStoreRegistry<T>): IFluidDataStoreRegistry {\n\treturn {\n\t\tasync get(name: string): Promise<FluidDataStoreRegistryEntry | undefined> {\n\t\t\tconst dataStoreKind = await lookupInRegistry(registry, createBasicRegistryKey(name));\n\t\t\tDataStoreKindImplementation.narrowGeneric(dataStoreKind);\n\t\t\treturn dataStoreKind;\n\t\t},\n\t\tget IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\t\treturn this;\n\t\t},\n\t};\n}\n\n/**\n * Normalizes a `DataStoreKind` or registry function into a registry function.\n * @internal\n */\nexport function normalizeRegistry<T>(\n\tinput: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>,\n): Registry<Promise<DataStoreKind<T>>> {\n\tif (DataStoreKindImplementation.guard(input)) {\n\t\treturn async () => input;\n\t}\n\tassert(typeof input === \"function\", 0xd17 /* Registry must be a function */);\n\treturn input;\n}\n\n/**\n * Parameters passed to a {@link ContainerRuntimeLoader}.\n * @internal\n */\nexport interface ContainerRuntimeLoaderParams {\n\tcontext: IContainerContext;\n\tregistry: IFluidDataStoreRegistry;\n\tprovideEntryPoint: (runtime: IContainerRuntimeBase) => Promise<FluidObject>;\n\texisting: boolean;\n\tminVersionForCollab: OldestSupportedClientVersion;\n\t/**\n\t * The type string of the root data store to create. Only set when `existing` is false.\n\t */\n\tnewContainerRootType: string | undefined;\n}\n\n/**\n * A service-specific callback that creates or loads the container runtime.\n *\n * @remarks\n * Receives the runtime parameters assembled by {@link makeCodeLoader} and is responsible for\n * calling the concrete runtime factory (e.g. `ContainerRuntime.loadRuntime2`) and, when\n * `existing` is `false`, initializing the root data store before returning.\n *\n * @internal\n */\nexport type ContainerRuntimeLoader = (\n\tparameters: ContainerRuntimeLoaderParams,\n) => Promise<IRuntime>;\n\n/**\n * Creates an `ICodeDetailsLoader` that wires up the container runtime via the supplied\n * `loadRuntime` callback.\n *\n * @remarks\n * The `loadRuntime` callback is responsible for invoking the concrete runtime factory and,\n * when `parameters.existing` is `false` and `parameters.newContainerRootType` is set, creating and\n * aliasing the root data store.\n *\n * This loader never does any code loading, and always assumes it is compatible.\n * TODO: We should reevaluate this before promoting ServiceClient APIs to beta.\n *\n * @internal\n */\nexport function makeCodeLoader<T>(\n\tregistry: DataStoreRegistry<T>,\n\tminVersionForCollab: OldestSupportedClientVersion,\n\tloadRuntime: ContainerRuntimeLoader,\n\troot?: DataStoreKind<T>,\n): ICodeDetailsLoader {\n\tconst fluidExport: IRuntimeFactory & IFluidCodeDetailsComparer = {\n\t\tasync instantiateRuntime(\n\t\t\tcontext: IContainerContext,\n\t\t\texisting: boolean,\n\t\t): Promise<IRuntime> {\n\t\t\tconst provideEntryPoint = async (\n\t\t\t\tentryPointRuntime: IContainerRuntimeBase,\n\t\t\t): Promise<T & FluidObject> => {\n\t\t\t\tconst data = await entryPointRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\t\tif (data === undefined) {\n\t\t\t\t\tthrow new Error(\"Root data store missing!\");\n\t\t\t\t}\n\t\t\t\tconst rootDataStore = await data.get();\n\t\t\t\treturn rootDataStore as T & FluidObject;\n\t\t\t};\n\n\t\t\treturn loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistry: convertRegistry(registry),\n\t\t\t\tprovideEntryPoint,\n\t\t\t\texisting,\n\t\t\t\tminVersionForCollab,\n\t\t\t\tnewContainerRootType: root?.type,\n\t\t\t});\n\t\t},\n\n\t\tasync satisfies(\n\t\t\tcandidate: IFluidCodeDetails,\n\t\t\tconstraint: IFluidCodeDetails,\n\t\t): Promise<boolean> {\n\t\t\treturn true;\n\t\t},\n\n\t\tasync compare(a: IFluidCodeDetails, b: IFluidCodeDetails): Promise<number | undefined> {\n\t\t\treturn 0;\n\t\t},\n\n\t\tget IRuntimeFactory(): IRuntimeFactory {\n\t\t\treturn fluidExport;\n\t\t},\n\n\t\tget IFluidCodeDetailsComparer(): IFluidCodeDetailsComparer {\n\t\t\treturn fluidExport;\n\t\t},\n\t};\n\n\treturn {\n\t\tload: async (details: IFluidCodeDetails): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn { module: { fluidExport }, details };\n\t\t},\n\t};\n}\n\n/**\n * Minimal interface for the static container factory methods used by {@link ServiceClientImplementation}.\n * @internal\n */\nexport interface ServiceContainerStatics<TOptions> {\n\tcreateDetached<T>(\n\t\tregistry: DataStoreRegistry<T>,\n\t\toptions: TOptions,\n\t\troot: DataStoreKind<T>,\n\t): Promise<FluidContainerWithService<T>>;\n\n\tload<T>(\n\t\tregistry: DataStoreRegistry<T>,\n\t\toptions: TOptions,\n\t\tid: string,\n\t): Promise<FluidContainerAttached<T>>;\n}\n\n/**\n * Creates a {@link @fluidframework/driver-definitions#ServiceClient} that delegates container\n * creation and loading to the supplied container class statics.\n * @internal\n */\nexport class ServiceClientImplementation<TOptions> implements ServiceClient {\n\tpublic constructor(\n\t\tprivate readonly options: TOptions,\n\t\tprivate readonly statics: ServiceContainerStatics<TOptions>,\n\t) {}\n\n\t// This implements the ServiceClient interface's safer version of this with overloads.\n\t// For use in the implementation however, this is simpler, and allows createAttachedContainer to forward to it more easily.\n\tpublic async createContainer<T>(\n\t\troot: DataStoreKey<T> | DataStoreKind<T>,\n\t\tregistry?: Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerWithService<T>> {\n\t\tif (registry === undefined) {\n\t\t\tDataStoreKindImplementation.narrowGeneric(root);\n\t\t\treturn this.statics.createDetached(normalizeRegistry(root), this.options, root);\n\t\t} else {\n\t\t\tconst result = await lookupInRegistry(registry, root);\n\t\t\treturn this.statics.createDetached(registry, this.options, result);\n\t\t}\n\t}\n\n\tpublic async createAttachedContainer<T>(\n\t\troot: DataStoreKey<T> | DataStoreKind<T>,\n\t\tregistry?: Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerAttached<T>> {\n\t\tconst container = await this.createContainer(root, registry);\n\t\treturn container.attach();\n\t}\n\n\tpublic async loadContainer<T>(\n\t\tid: string,\n\t\troot: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerAttached<T>> {\n\t\treturn this.statics.load(normalizeRegistry(root), this.options, id);\n\t}\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
5
|
+
import type { OldestSupportedClientVersion } from "@fluidframework/runtime-definitions/internal";
|
|
6
6
|
/**
|
|
7
7
|
* Our policy is to support major versions N and N-1, where N is most
|
|
8
8
|
* recent public major release of the Fluid Framework Client.
|
|
@@ -47,7 +47,7 @@ export declare const lowestMinVersionForCollab: "1.0.0";
|
|
|
47
47
|
export type MinimumMinorSemanticVersion = `${bigint}.${bigint}.0` | `${bigint}.0.0-defaults`;
|
|
48
48
|
/**
|
|
49
49
|
* String in a valid semver format of a specific version at least specifying minor.
|
|
50
|
-
* Unlike {@link @fluidframework/runtime-definitions#
|
|
50
|
+
* Unlike {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}, this type allows any bigint for the major version.
|
|
51
51
|
* Used as a more generic type that allows major versions other than 1 or 2.
|
|
52
52
|
*
|
|
53
53
|
* @internal
|
|
@@ -56,11 +56,11 @@ export type SemanticVersion = `${bigint}.${bigint}.${bigint}` | `${bigint}.${big
|
|
|
56
56
|
/**
|
|
57
57
|
* Converts a record into a configuration map that associates each key with an instance of its value type that is based on a {@link MinimumMinorSemanticVersion}.
|
|
58
58
|
* @remarks
|
|
59
|
-
* For a given input {@link @fluidframework/runtime-definitions#
|
|
59
|
+
* For a given input {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion},
|
|
60
60
|
* the corresponding configuration values can be found by using the entry in the inner objects with the highest {@link MinimumMinorSemanticVersion}
|
|
61
|
-
* that does not exceed the given {@link @fluidframework/runtime-definitions#
|
|
61
|
+
* that does not exceed the given {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}.
|
|
62
62
|
*
|
|
63
|
-
* Use {@link getConfigsForMinVersionForCollab} to retrieve the configuration for a given a {@link @fluidframework/runtime-definitions#
|
|
63
|
+
* Use {@link getConfigsForMinVersionForCollab} to retrieve the configuration for a given a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}.
|
|
64
64
|
*
|
|
65
65
|
* See the remarks on {@link MinimumMinorSemanticVersion} for some limitation on how ConfigMaps must handle versioning.
|
|
66
66
|
* @internal
|
|
@@ -94,13 +94,13 @@ export type ConfigValidationMap<T extends Record<string, unknown>> = {
|
|
|
94
94
|
* It should have no impact on the user of this function.
|
|
95
95
|
* @internal
|
|
96
96
|
*/
|
|
97
|
-
export declare function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(minVersionForCollab:
|
|
97
|
+
export declare function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(minVersionForCollab: OldestSupportedClientVersion, configMap: ConfigMap<T> & Record<keyof T, unknown>): T;
|
|
98
98
|
/**
|
|
99
99
|
* Returns a default configuration given minVersionForCollab and {@link ConfigMapEntry}.
|
|
100
100
|
*
|
|
101
101
|
* @internal
|
|
102
102
|
*/
|
|
103
|
-
export declare function getConfigForMinVersionForCollab<T>(minVersionForCollab:
|
|
103
|
+
export declare function getConfigForMinVersionForCollab<T>(minVersionForCollab: OldestSupportedClientVersion, config: ConfigMapEntry<T>): T;
|
|
104
104
|
/**
|
|
105
105
|
* Returns a default configuration given minVersionForCollab and the contents of a {@link ConfigMapEntry} in an Iterable.
|
|
106
106
|
* @remarks
|
|
@@ -112,7 +112,7 @@ export declare function getConfigForMinVersionForCollab<T>(minVersionForCollab:
|
|
|
112
112
|
* like cases which transform a ConfigMapEntry before selecting a value from it.
|
|
113
113
|
* @internal
|
|
114
114
|
*/
|
|
115
|
-
export declare function getConfigForMinVersionForCollabIterable<T>(minVersionForCollab:
|
|
115
|
+
export declare function getConfigForMinVersionForCollabIterable<T>(minVersionForCollab: OldestSupportedClientVersion, entries: Iterable<readonly [MinimumMinorSemanticVersion | OldestSupportedClientVersion, T]>): T;
|
|
116
116
|
/**
|
|
117
117
|
* Finds the entry for the highest version that is less than or equal to the provided minVersionForCollab.
|
|
118
118
|
* @remarks
|
|
@@ -137,11 +137,11 @@ export declare function checkValidMinVersionForCollabVerbose(minVersionForCollab
|
|
|
137
137
|
};
|
|
138
138
|
/**
|
|
139
139
|
* Checks if the minVersionForCollab is valid.
|
|
140
|
-
* A valid minVersionForCollab is a
|
|
140
|
+
* A valid minVersionForCollab is a OldestSupportedClientVersion that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
141
141
|
*
|
|
142
142
|
* @internal
|
|
143
143
|
*/
|
|
144
|
-
export declare function isValidMinVersionForCollab(minVersionForCollab: SemanticVersion): minVersionForCollab is
|
|
144
|
+
export declare function isValidMinVersionForCollab(minVersionForCollab: SemanticVersion): minVersionForCollab is OldestSupportedClientVersion;
|
|
145
145
|
/**
|
|
146
146
|
* `pkgVersion` version without pre-release.
|
|
147
147
|
* @remarks
|
|
@@ -163,24 +163,24 @@ export declare function isValidMinVersionForCollab(minVersionForCollab: Semantic
|
|
|
163
163
|
* To accommodate some uses of the second case, it might be useful to package export this in the future.
|
|
164
164
|
*
|
|
165
165
|
* @privateRemarks
|
|
166
|
-
* Since this is used by validateMinimumVersionForCollab, the type case to
|
|
166
|
+
* Since this is used by validateMinimumVersionForCollab, the type case to OldestSupportedClientVersion can not use it directly.
|
|
167
167
|
* Thus this is just `as` cast here, and a test confirms it is valid according to validateMinimumVersionForCollab.
|
|
168
168
|
*
|
|
169
169
|
* @internal
|
|
170
170
|
*/
|
|
171
|
-
export declare const cleanedPackageVersion:
|
|
171
|
+
export declare const cleanedPackageVersion: OldestSupportedClientVersion;
|
|
172
172
|
/**
|
|
173
|
-
* Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#
|
|
173
|
+
* Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}, throwing a UsageError if it is not valid.
|
|
174
174
|
* @remarks
|
|
175
|
-
* This is more strict than the type constraints imposed by `
|
|
176
|
-
* Currently there is no type which is used to separate semantically valid and typescript allowed
|
|
177
|
-
* thus users that care about strict validation may want to call this on un-validated `
|
|
175
|
+
* This is more strict than the type constraints imposed by `OldestSupportedClientVersion`.
|
|
176
|
+
* Currently there is no type which is used to separate semantically valid and typescript allowed OldestSupportedClientVersion values:
|
|
177
|
+
* thus users that care about strict validation may want to call this on un-validated `OldestSupportedClientVersion` values.
|
|
178
178
|
* @param semanticVersion - The version to check.
|
|
179
|
-
* @throws UsageError if the version is not a valid
|
|
179
|
+
* @throws UsageError if the version is not a valid OldestSupportedClientVersion.
|
|
180
180
|
*
|
|
181
181
|
* @internal
|
|
182
182
|
*/
|
|
183
|
-
export declare function validateMinimumVersionForCollab(semanticVersion: string): asserts semanticVersion is
|
|
183
|
+
export declare function validateMinimumVersionForCollab(semanticVersion: string): asserts semanticVersion is OldestSupportedClientVersion;
|
|
184
184
|
/**
|
|
185
185
|
* Validates the given `overrides`.
|
|
186
186
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibilityBase.d.ts","sourceRoot":"","sources":["../src/compatibilityBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"compatibilityBase.d.ts","sourceRoot":"","sources":["../src/compatibilityBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAMjG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,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E,OAAO,CAAC,CAAC,CAAC,EACrB,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC,GACnC,IAAI,CA2BN;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC/C,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,EACxD,GAAG,SAAS,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,EAAE,EAC1C,cAAc,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,eAAe,GAAG,SAAS,CAoCtE"}
|
package/lib/compatibilityBase.js
CHANGED
|
@@ -126,7 +126,7 @@ export function checkValidMinVersionForCollabVerbose(minVersionForCollab) {
|
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Checks if the minVersionForCollab is valid.
|
|
129
|
-
* A valid minVersionForCollab is a
|
|
129
|
+
* A valid minVersionForCollab is a OldestSupportedClientVersion that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
130
130
|
*
|
|
131
131
|
* @internal
|
|
132
132
|
*/
|
|
@@ -156,20 +156,20 @@ const parsedPackageVersion = parse(pkgVersion) ?? fail(0xcb9 /* Invalid package
|
|
|
156
156
|
* To accommodate some uses of the second case, it might be useful to package export this in the future.
|
|
157
157
|
*
|
|
158
158
|
* @privateRemarks
|
|
159
|
-
* Since this is used by validateMinimumVersionForCollab, the type case to
|
|
159
|
+
* Since this is used by validateMinimumVersionForCollab, the type case to OldestSupportedClientVersion can not use it directly.
|
|
160
160
|
* Thus this is just `as` cast here, and a test confirms it is valid according to validateMinimumVersionForCollab.
|
|
161
161
|
*
|
|
162
162
|
* @internal
|
|
163
163
|
*/
|
|
164
164
|
export const cleanedPackageVersion = `${parsedPackageVersion.major}.${parsedPackageVersion.minor}.${parsedPackageVersion.patch}`;
|
|
165
165
|
/**
|
|
166
|
-
* Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#
|
|
166
|
+
* Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}, throwing a UsageError if it is not valid.
|
|
167
167
|
* @remarks
|
|
168
|
-
* This is more strict than the type constraints imposed by `
|
|
169
|
-
* Currently there is no type which is used to separate semantically valid and typescript allowed
|
|
170
|
-
* thus users that care about strict validation may want to call this on un-validated `
|
|
168
|
+
* This is more strict than the type constraints imposed by `OldestSupportedClientVersion`.
|
|
169
|
+
* Currently there is no type which is used to separate semantically valid and typescript allowed OldestSupportedClientVersion values:
|
|
170
|
+
* thus users that care about strict validation may want to call this on un-validated `OldestSupportedClientVersion` values.
|
|
171
171
|
* @param semanticVersion - The version to check.
|
|
172
|
-
* @throws UsageError if the version is not a valid
|
|
172
|
+
* @throws UsageError if the version is not a valid OldestSupportedClientVersion.
|
|
173
173
|
*
|
|
174
174
|
* @internal
|
|
175
175
|
*/
|
|
@@ -177,7 +177,7 @@ export function validateMinimumVersionForCollab(semanticVersion) {
|
|
|
177
177
|
const minVersionForCollab = semanticVersion;
|
|
178
178
|
const { isValidSemver, isGteLowestMinVersion, isLtePkgVersion } = checkValidMinVersionForCollabVerbose(minVersionForCollab);
|
|
179
179
|
if (!(isValidSemver && isGteLowestMinVersion && isLtePkgVersion)) {
|
|
180
|
-
throw new UsageError(`Version ${minVersionForCollab} is not a valid
|
|
180
|
+
throw new UsageError(`Version ${minVersionForCollab} is not a valid OldestSupportedClientVersion. ` +
|
|
181
181
|
`It must be in a valid semver format, at least ${lowestMinVersionForCollab}, ` +
|
|
182
182
|
`and less than or equal to the current package version ${cleanedPackageVersion}. ` +
|
|
183
183
|
`Details: { isValidSemver: ${isValidSemver}, isGteLowestMinVersion: ${isGteLowestMinVersion}, isLtePkgVersion: ${isLtePkgVersion} }`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibilityBase.js","sourceRoot":"","sources":["../src/compatibilityBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,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AAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAChF,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;QACD,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjC,2DAA2D;YAC3D,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;QACD,qFAAqF;QACrF,+DAA+D;QAC/D,OAAO,SAAS,CAAC;IAClB,CAAC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { compare, gt, gte, lte, valid, parse } from \"semver-ts\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Our policy is to support major versions N and N-1, where N is most\n * recent public major release of the Fluid Framework Client.\n * Therefore, if the customer does not provide a minVersionForCollab, we will\n * default to use N-1.\n *\n * However, this is not consistent with today's behavior. Some options (i.e.\n * batching, compression) are enabled by default despite not being compatible\n * with 1.x clients. Since the policy was introduced during 2.x's lifespan,\n * N/N-1 compatibility by **default** will be in effect starting with 3.0.\n * Importantly though, N/N-2 compatibility is still guaranteed with the proper\n * configurations set.\n *\n * Further to distinguish unspecified `minVersionForCollab` from a specified\n * version and allow `enableExplicitSchemaControl` to default to `true` for\n * any 2.0.0+ version, we will use a special value of `2.0.0-defaults`, which\n * is semantically less than 2.0.0.\n *\n * @internal\n */\nexport const defaultMinVersionForCollab =\n\t\"2.0.0-defaults\" as const satisfies MinimumVersionForCollab;\n\n/**\n * We don't want allow a version before the major public release of the LTS version.\n * Today we use \"1.0.0\", because our policy supports N/N-1 & N/N-2, which includes\n * all minor versions of N. Though LTS starts at 1.4.0, we should stay consistent\n * with our policy and allow all 1.x versions to be compatible with 2.x.\n *\n * @privateRemarks\n * Exported for use in tests.\n *\n * @internal\n */\nexport const lowestMinVersionForCollab = \"1.0.0\" as const satisfies MinimumVersionForCollab;\n\n/**\n * String in a valid semver format specifying bottom of a minor version\n * or special \"defaults\" prerelease of a major.\n * @remarks Only 2.0.0-defaults is expected, but index signatures cannot be a\n * literal; so, just allow any major -defaults prerelease.\n *\n * @internal\n */\nexport type MinimumMinorSemanticVersion = `${bigint}.${bigint}.0` | `${bigint}.0.0-defaults`;\n\n/**\n * String in a valid semver format of a specific version at least specifying minor.\n * Unlike {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}, this type allows any bigint for the major version.\n * Used as a more generic type that allows major versions other than 1 or 2.\n *\n * @internal\n */\nexport type SemanticVersion =\n\t| `${bigint}.${bigint}.${bigint}`\n\t| `${bigint}.${bigint}.${bigint}-${string}`;\n\n/**\n * Converts a record into a configuration map that associates each key with an instance of its value type that is based on a {@link MinimumMinorSemanticVersion}.\n * @remarks\n * For a given input {@link @fluidframework/runtime-definitions#MinimumVersionForCollab},\n * the corresponding configuration values can be found by using the entry in the inner objects with the highest {@link MinimumMinorSemanticVersion}\n * that does not exceed the given {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}.\n *\n * Use {@link getConfigsForMinVersionForCollab} to retrieve the configuration for a given a {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}.\n *\n * See the remarks on {@link MinimumMinorSemanticVersion} for some limitation on how ConfigMaps must handle versioning.\n * @internal\n */\nexport type ConfigMap<T extends Record<string, unknown>> = {\n\treadonly [K in keyof T]-?: ConfigMapEntry<T[K]>;\n};\n\n/**\n * Entry in {@link ConfigMap} associating {@link MinimumMinorSemanticVersion} with configuration values that became supported in that version.\n * @remarks\n * All entries must at least provide an entry for {@link lowestMinVersionForCollab}.\n * @internal\n */\nexport interface ConfigMapEntry<T> {\n\t// This index signature (See https://www.typescriptlang.org/docs/handbook/2/objects.html#index-signatures) requires all properties on this type to to have keys that are a MinimumMinorSemanticVersion and values of type T.\n\t// Note that the \"version\" part of this syntax is really just documentation and has no impact on the type checking (other than some identifier being required to the syntax here to differentiate it from the computed property syntax).\n\t[version: MinimumMinorSemanticVersion]: T;\n\t// Require an entry for the defaultMinVersionForCollab:\n\t// this ensures that all versions of lowestMinVersionForCollab or later have a specified value in the ConfigMap.\n\t// Note that this is NOT an index signature.\n\t// This is a regular property with a computed name (See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#computed_property_names).\n\t[lowestMinVersionForCollab]: T;\n}\n\n/**\n * Generic type for runtimeOptionsAffectingDocSchemaConfigValidationMap\n *\n * @internal\n */\nexport type ConfigValidationMap<T extends Record<string, unknown>> = {\n\treadonly [K in keyof T]-?: (configValue: T[K]) => SemanticVersion | undefined;\n};\n\n/**\n * Returns a default configuration given minVersionForCollab and configuration version map.\n *\n * @privateRemarks\n * The extra `Record` type for the `configMap` is just used to allow the body of this function to be more type-safe due to limitations of generic types in TypeScript.\n * It should have no impact on the user of this function.\n * @internal\n */\nexport function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(\n\tminVersionForCollab: MinimumVersionForCollab,\n\tconfigMap: ConfigMap<T> & Record<keyof T, unknown>,\n): T {\n\tvalidateMinimumVersionForCollab(minVersionForCollab);\n\tconst defaultConfigs: Partial<T> = {};\n\t// Iterate over configMap to get default values for each option.\n\tfor (const [key, config] of Object.entries(configMap)) {\n\t\tdefaultConfigs[key] = getConfigForMinVersionForCollab(\n\t\t\tminVersionForCollab,\n\t\t\tconfig as ConfigMapEntry<unknown>,\n\t\t);\n\t}\n\t// We have populated every key, so casting away the Partial is now safe:\n\treturn defaultConfigs as T;\n}\n\n/**\n * Returns a default configuration given minVersionForCollab and {@link ConfigMapEntry}.\n *\n * @internal\n */\nexport function getConfigForMinVersionForCollab<T>(\n\tminVersionForCollab: MinimumVersionForCollab,\n\tconfig: ConfigMapEntry<T>,\n): T {\n\treturn getConfigForMinVersionForCollabIterable(\n\t\tminVersionForCollab,\n\t\tObject.entries(config) as [MinimumMinorSemanticVersion, T][],\n\t);\n}\n\n/**\n * Returns a default configuration given minVersionForCollab and the contents of a {@link ConfigMapEntry} in an Iterable.\n * @remarks\n * See also {@link getConfigForMinVersionForCollab} for consuming a ConfigMapEntry directly.\n *\n * `ConfigMapEntry` is a nice type safe format for developers to directly author this data,\n * but it is messy and less type safe to work with it in this format programmatically.\n * Thus this function exists to help meet the needs of programmatic use cases,\n * like cases which transform a ConfigMapEntry before selecting a value from it.\n * @internal\n */\nexport function getConfigForMinVersionForCollabIterable<T>(\n\tminVersionForCollab: MinimumVersionForCollab,\n\tentries: Iterable<readonly [MinimumMinorSemanticVersion | MinimumVersionForCollab, T]>, // [[typeof lowestMinVersionForCollab, T], ...[MinimumVersionForCollab, T][]],\n): T {\n\t// Validate and strongly type the versions from the configMap.\n\tconst versions: [MinimumVersionForCollab, T][] = Array.from(entries, ([version, value]) => {\n\t\tvalidateMinimumVersionForCollab(version);\n\t\treturn [version, value];\n\t});\n\treturn (selectVersionRoundedDown(minVersionForCollab, versions) ??\n\t\tfail(0xcb8 /* No config map entry for version */))[1];\n}\n\n/**\n * Finds the entry for the highest version that is less than or equal to the provided minVersionForCollab.\n * @remarks\n * If none is found, returns undefined.\n *\n * When used with Fluid client versions, use the stricter {@link getConfigForMinVersionForCollabIterable} instead.\n *\n * @internal\n */\nexport function selectVersionRoundedDown<T>(\n\tminVersionForCollab: string,\n\tentries: Iterable<readonly [string, T]>,\n\tcompareVersions: (a: string, b: string) => number = compare,\n): readonly [string, T] | undefined {\n\t// Sort a copy of the iterable in descending order\n\tconst versions: (readonly [string, T])[] = [...entries];\n\tversions.sort((a, b) => compareVersions(b[0], a[0]));\n\n\t// For each config, we iterate over the keys and check if minVersionForCollab is greater than or equal to the version.\n\t// If so, we set it as the default value for the option.\n\tfor (const pair of versions) {\n\t\tconst [version, _] = pair;\n\t\tif (compareVersions(minVersionForCollab, version) >= 0) {\n\t\t\treturn pair;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * Returns detailed information about the validity of a minVersionForCollab.\n * @param minVersionForCollab - The minVersionForCollab to validate.\n * @returns An object containing the validity information.\n *\n * @internal\n */\nexport function checkValidMinVersionForCollabVerbose(minVersionForCollab: SemanticVersion): {\n\tisValidSemver: boolean;\n\tisGteLowestMinVersion: boolean;\n\tisLtePkgVersion: boolean;\n} {\n\tconst isValidSemver = valid(minVersionForCollab) !== null;\n\treturn {\n\t\tisValidSemver,\n\n\t\t// We have to check if the value is a valid semver before calling gte/lte, otherwise they will throw when parsing the version.\n\t\tisGteLowestMinVersion:\n\t\t\tisValidSemver && gte(minVersionForCollab, lowestMinVersionForCollab),\n\t\tisLtePkgVersion: isValidSemver && lte(minVersionForCollab, cleanedPackageVersion),\n\t};\n}\n\n/**\n * Checks if the minVersionForCollab is valid.\n * A valid minVersionForCollab is a MinimumVersionForCollab that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.\n *\n * @internal\n */\nexport function isValidMinVersionForCollab(\n\tminVersionForCollab: SemanticVersion,\n): minVersionForCollab is MinimumVersionForCollab {\n\tconst { isValidSemver, isGteLowestMinVersion, isLtePkgVersion } =\n\t\tcheckValidMinVersionForCollabVerbose(minVersionForCollab);\n\treturn isValidSemver && isGteLowestMinVersion && isLtePkgVersion;\n}\n\nconst parsedPackageVersion = parse(pkgVersion) ?? fail(0xcb9 /* Invalid package version */);\n\n/**\n * `pkgVersion` version without pre-release.\n * @remarks\n * This is the version that the code in the current version of the codebase will have when officially released.\n * Generally, compatibility of prerelease builds is not guaranteed (especially for how they interact with future releases).\n * So while technically a prerelease build is less (older) than the released version which follows it and thus supports less features,\n * it makes sense for them to claim to support the same features as the following release so they can be used to test how the release would actually behave.\n *\n * To accomplish this, the version the next release will have is provided here as `cleanedPackageVersion` while `pkgVersion` may be a prerelease in some cases,\n * like when running tests on CI, or in an actual prerelease published package.\n * This is then used in {@link validateMinimumVersionForCollab} to allow the version shown on main to be usable as a `minVersionForCollab`, even in CI and prerelease packages.\n *\n * This is of particular note in two cases:\n * 1. When landing a new feature, and setting the minVersionForCollab which enables it to be the version that the next release will have.\n * Having that version be valid on main, pass tests locally, then fail on CI and when using published prerelease packages would be confusing, and probably undesired.\n * 2. Setting the minVersionForCollab to the current version for scenarios that do no involve collab with other package versions seems like it should be valid.\n * This is useful for testing new features, and also non collaborative scenarios where the latest features are desired.\n *\n * To accommodate some uses of the second case, it might be useful to package export this in the future.\n *\n * @privateRemarks\n * Since this is used by validateMinimumVersionForCollab, the type case to MinimumVersionForCollab can not use it directly.\n * Thus this is just `as` cast here, and a test confirms it is valid according to validateMinimumVersionForCollab.\n *\n * @internal\n */\nexport const cleanedPackageVersion =\n\t`${parsedPackageVersion.major}.${parsedPackageVersion.minor}.${parsedPackageVersion.patch}` as MinimumVersionForCollab;\n\n/**\n * Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}, throwing a UsageError if it is not valid.\n * @remarks\n * This is more strict than the type constraints imposed by `MinimumVersionForCollab`.\n * Currently there is no type which is used to separate semantically valid and typescript allowed MinimumVersionForCollab values:\n * thus users that care about strict validation may want to call this on un-validated `MinimumVersionForCollab` values.\n * @param semanticVersion - The version to check.\n * @throws UsageError if the version is not a valid MinimumVersionForCollab.\n *\n * @internal\n */\nexport function validateMinimumVersionForCollab(\n\tsemanticVersion: string,\n): asserts semanticVersion is MinimumVersionForCollab {\n\tconst minVersionForCollab = semanticVersion as MinimumVersionForCollab;\n\tconst { isValidSemver, isGteLowestMinVersion, isLtePkgVersion } =\n\t\tcheckValidMinVersionForCollabVerbose(minVersionForCollab);\n\tif (!(isValidSemver && isGteLowestMinVersion && isLtePkgVersion)) {\n\t\tthrow new UsageError(\n\t\t\t`Version ${minVersionForCollab} is not a valid MinimumVersionForCollab. ` +\n\t\t\t\t`It must be in a valid semver format, at least ${lowestMinVersionForCollab}, ` +\n\t\t\t\t`and less than or equal to the current package version ${cleanedPackageVersion}. ` +\n\t\t\t\t`Details: { isValidSemver: ${isValidSemver}, isGteLowestMinVersion: ${isGteLowestMinVersion}, isLtePkgVersion: ${isLtePkgVersion} }`,\n\t\t);\n\t}\n}\n\n/**\n * Validates the given `overrides`.\n *\n * No-op when minVersionForCollab is set to defaultMinVersionForCollab.\n *\n * Otherwise this checks that for keys which are in both the `validationMap` and the `overrides`,\n * that the `validationMap` function for that key either returns undefined or a version less than or equal to `minVersionForCollab`.\n * @privateRemarks\n * This design seems odd, and might want to be revisited.\n * Currently it only permits opting out of features, not into them (unless validationMap returns undefined),\n * and the handling of defaultMinVersionForCollab and undefined versions seems questionable.\n * Also ignoring of extra keys in overrides might be bad since it seems like overrides is supposed to be validated.\n * @internal\n */\nexport function validateConfigMapOverrides<T extends Record<string, unknown>>(\n\tminVersionForCollab: SemanticVersion,\n\toverrides: Partial<T>,\n\tvalidationMap: ConfigValidationMap<T>,\n): void {\n\tif (minVersionForCollab === defaultMinVersionForCollab) {\n\t\t// If the minVersionForCollab is set to the default value, then we will not validate the runtime options\n\t\t// This is to avoid disruption to users who have not yet set the minVersionForCollab value explicitly.\n\t\t// TODO: This also skips validation for users which explicitly request defaultMinVersionForCollab which seems like a bug.\n\t\treturn;\n\t}\n\t// Iterate through each runtime option passed in by the user\n\t// Type assertion is safe as entries come from runtimeOptions object\n\tfor (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(overrides) as [\n\t\tkeyof T & string,\n\t\tT[keyof T & string],\n\t][]) {\n\t\t// Skip if passedRuntimeOption is not in validation map\n\t\tif (!(passedRuntimeOption in validationMap)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst requiredVersion = validationMap[passedRuntimeOption](passedRuntimeOptionValue);\n\t\tif (requiredVersion !== undefined && gt(requiredVersion, minVersionForCollab)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Runtime option ${passedRuntimeOption}:${JSON.stringify(passedRuntimeOptionValue)} requires ` +\n\t\t\t\t\t`runtime version ${requiredVersion}. Please update minVersionForCollab ` +\n\t\t\t\t\t`(currently ${minVersionForCollab}) to ${requiredVersion} or later to proceed.`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * Helper function to map ContainerRuntimeOptionsInternal config values to\n * minVersionForCollab in, e.g., {@link @fluidframework/container-runtime#runtimeOptionsAffectingDocSchemaConfigValidationMap}.\n *\n * @internal\n */\nexport function configValueToMinVersionForCollab<\n\tT extends string | number | boolean | undefined | object,\n\tArr extends readonly [T, SemanticVersion][],\n>(configToMinVer: Arr): (configValue: T) => SemanticVersion | undefined {\n\tconst configValueToRequiredVersionMap = new Map(configToMinVer);\n\treturn (configValue: T) => {\n\t\t// If the configValue is not an object then we can get the version required directly from the map.\n\t\tif (typeof configValue !== \"object\") {\n\t\t\treturn configValueToRequiredVersionMap.get(configValue);\n\t\t}\n\t\t// When the input `configValue` is an object, this logic determines the minimum runtime version it requires.\n\t\t// It iterates through each entry in `configValueToRequiredVersionMap`. If `possibleConfigValue` shares at\n\t\t// least one key-value pair with the input `configValue`, its associated `versionRequired` is collected into\n\t\t// `matchingVersions`. After checking all entries, the highest among the collected versions is returned.\n\t\t// This represents the overall minimum version required to support the features implied by the input `configValue`.\n\t\tconst matchingVersions: SemanticVersion[] = [];\n\t\tfor (const [\n\t\t\tpossibleConfigValue,\n\t\t\tversionRequired,\n\t\t] of configValueToRequiredVersionMap.entries()) {\n\t\t\tassert(\n\t\t\t\ttypeof possibleConfigValue == \"object\",\n\t\t\t\t0xbb9 /* possibleConfigValue should be an object */,\n\t\t\t);\n\t\t\t// Check if `possibleConfigValue` and the input `configValue` share at least one\n\t\t\t// common key-value pair. If they do, the `versionRequired` for this `possibleConfigValue`\n\t\t\t// is added to `matchingVersions`.\n\t\t\tif (Object.entries(possibleConfigValue).some(([k, v]) => configValue[k] === v)) {\n\t\t\t\tmatchingVersions.push(versionRequired);\n\t\t\t}\n\t\t}\n\t\tif (matchingVersions.length > 0) {\n\t\t\t// Return the latest minVersionForCollab among all matches.\n\t\t\treturn matchingVersions.sort((a, b) => compare(b, a))[0];\n\t\t}\n\t\t// If no matches then we return undefined. This means that the config value passed in\n\t\t// does not require a specific minVersionForCollab to be valid.\n\t\treturn undefined;\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compatibilityBase.js","sourceRoot":"","sources":["../src/compatibilityBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACtC,gBAAgE,CAAC;AAElE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACrC,OAAuD,CAAC;AAiEzD;;;;;;;GAOG;AACH,MAAM,UAAU,gCAAgC,CAC/C,mBAAiD,EACjD,SAAkD;IAElD,+BAA+B,CAAC,mBAAmB,CAAC,CAAC;IACrD,MAAM,cAAc,GAAe,EAAE,CAAC;IACtC,gEAAgE;IAChE,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACvD,cAAc,CAAC,GAAG,CAAC,GAAG,+BAA+B,CACpD,mBAAmB,EACnB,MAAiC,CACjC,CAAC;IACH,CAAC;IACD,wEAAwE;IACxE,OAAO,cAAmB,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,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wGAAwG;QACxG,mHAAmH;QACnH,MAAM,gBAAgB,GAAsB,EAAE,CAAC;QAC/C,KAAK,MAAM,CACV,mBAAmB,EACnB,eAAe,EACf,IAAI,+BAA+B,CAAC,OAAO,EAAE,EAAE,CAAC;YAChD,MAAM,CACL,OAAO,mBAAmB,IAAI,QAAQ,EACtC,KAAK,CAAC,6CAA6C,CACnD,CAAC;YACF,gFAAgF;YAChF,0FAA0F;YAC1F,kCAAkC;YAClC,IAAI,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAChF,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;QACD,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjC,2DAA2D;YAC3D,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;QACD,qFAAqF;QACrF,+DAA+D;QAC/D,OAAO,SAAS,CAAC;IAClB,CAAC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { OldestSupportedClientVersion } from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { compare, gt, gte, lte, valid, parse } from \"semver-ts\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Our policy is to support major versions N and N-1, where N is most\n * recent public major release of the Fluid Framework Client.\n * Therefore, if the customer does not provide a minVersionForCollab, we will\n * default to use N-1.\n *\n * However, this is not consistent with today's behavior. Some options (i.e.\n * batching, compression) are enabled by default despite not being compatible\n * with 1.x clients. Since the policy was introduced during 2.x's lifespan,\n * N/N-1 compatibility by **default** will be in effect starting with 3.0.\n * Importantly though, N/N-2 compatibility is still guaranteed with the proper\n * configurations set.\n *\n * Further to distinguish unspecified `minVersionForCollab` from a specified\n * version and allow `enableExplicitSchemaControl` to default to `true` for\n * any 2.0.0+ version, we will use a special value of `2.0.0-defaults`, which\n * is semantically less than 2.0.0.\n *\n * @internal\n */\nexport const defaultMinVersionForCollab =\n\t\"2.0.0-defaults\" as const satisfies OldestSupportedClientVersion;\n\n/**\n * We don't want allow a version before the major public release of the LTS version.\n * Today we use \"1.0.0\", because our policy supports N/N-1 & N/N-2, which includes\n * all minor versions of N. Though LTS starts at 1.4.0, we should stay consistent\n * with our policy and allow all 1.x versions to be compatible with 2.x.\n *\n * @privateRemarks\n * Exported for use in tests.\n *\n * @internal\n */\nexport const lowestMinVersionForCollab =\n\t\"1.0.0\" as const satisfies OldestSupportedClientVersion;\n\n/**\n * String in a valid semver format specifying bottom of a minor version\n * or special \"defaults\" prerelease of a major.\n * @remarks Only 2.0.0-defaults is expected, but index signatures cannot be a\n * literal; so, just allow any major -defaults prerelease.\n *\n * @internal\n */\nexport type MinimumMinorSemanticVersion = `${bigint}.${bigint}.0` | `${bigint}.0.0-defaults`;\n\n/**\n * String in a valid semver format of a specific version at least specifying minor.\n * Unlike {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}, this type allows any bigint for the major version.\n * Used as a more generic type that allows major versions other than 1 or 2.\n *\n * @internal\n */\nexport type SemanticVersion =\n\t| `${bigint}.${bigint}.${bigint}`\n\t| `${bigint}.${bigint}.${bigint}-${string}`;\n\n/**\n * Converts a record into a configuration map that associates each key with an instance of its value type that is based on a {@link MinimumMinorSemanticVersion}.\n * @remarks\n * For a given input {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion},\n * the corresponding configuration values can be found by using the entry in the inner objects with the highest {@link MinimumMinorSemanticVersion}\n * that does not exceed the given {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}.\n *\n * Use {@link getConfigsForMinVersionForCollab} to retrieve the configuration for a given a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}.\n *\n * See the remarks on {@link MinimumMinorSemanticVersion} for some limitation on how ConfigMaps must handle versioning.\n * @internal\n */\nexport type ConfigMap<T extends Record<string, unknown>> = {\n\treadonly [K in keyof T]-?: ConfigMapEntry<T[K]>;\n};\n\n/**\n * Entry in {@link ConfigMap} associating {@link MinimumMinorSemanticVersion} with configuration values that became supported in that version.\n * @remarks\n * All entries must at least provide an entry for {@link lowestMinVersionForCollab}.\n * @internal\n */\nexport interface ConfigMapEntry<T> {\n\t// This index signature (See https://www.typescriptlang.org/docs/handbook/2/objects.html#index-signatures) requires all properties on this type to to have keys that are a MinimumMinorSemanticVersion and values of type T.\n\t// Note that the \"version\" part of this syntax is really just documentation and has no impact on the type checking (other than some identifier being required to the syntax here to differentiate it from the computed property syntax).\n\t[version: MinimumMinorSemanticVersion]: T;\n\t// Require an entry for the defaultMinVersionForCollab:\n\t// this ensures that all versions of lowestMinVersionForCollab or later have a specified value in the ConfigMap.\n\t// Note that this is NOT an index signature.\n\t// This is a regular property with a computed name (See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#computed_property_names).\n\t[lowestMinVersionForCollab]: T;\n}\n\n/**\n * Generic type for runtimeOptionsAffectingDocSchemaConfigValidationMap\n *\n * @internal\n */\nexport type ConfigValidationMap<T extends Record<string, unknown>> = {\n\treadonly [K in keyof T]-?: (configValue: T[K]) => SemanticVersion | undefined;\n};\n\n/**\n * Returns a default configuration given minVersionForCollab and configuration version map.\n *\n * @privateRemarks\n * The extra `Record` type for the `configMap` is just used to allow the body of this function to be more type-safe due to limitations of generic types in TypeScript.\n * It should have no impact on the user of this function.\n * @internal\n */\nexport function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(\n\tminVersionForCollab: OldestSupportedClientVersion,\n\tconfigMap: ConfigMap<T> & Record<keyof T, unknown>,\n): T {\n\tvalidateMinimumVersionForCollab(minVersionForCollab);\n\tconst defaultConfigs: Partial<T> = {};\n\t// Iterate over configMap to get default values for each option.\n\tfor (const [key, config] of Object.entries(configMap)) {\n\t\tdefaultConfigs[key] = getConfigForMinVersionForCollab(\n\t\t\tminVersionForCollab,\n\t\t\tconfig as ConfigMapEntry<unknown>,\n\t\t);\n\t}\n\t// We have populated every key, so casting away the Partial is now safe:\n\treturn defaultConfigs as T;\n}\n\n/**\n * Returns a default configuration given minVersionForCollab and {@link ConfigMapEntry}.\n *\n * @internal\n */\nexport function getConfigForMinVersionForCollab<T>(\n\tminVersionForCollab: OldestSupportedClientVersion,\n\tconfig: ConfigMapEntry<T>,\n): T {\n\treturn getConfigForMinVersionForCollabIterable(\n\t\tminVersionForCollab,\n\t\tObject.entries(config) as [MinimumMinorSemanticVersion, T][],\n\t);\n}\n\n/**\n * Returns a default configuration given minVersionForCollab and the contents of a {@link ConfigMapEntry} in an Iterable.\n * @remarks\n * See also {@link getConfigForMinVersionForCollab} for consuming a ConfigMapEntry directly.\n *\n * `ConfigMapEntry` is a nice type safe format for developers to directly author this data,\n * but it is messy and less type safe to work with it in this format programmatically.\n * Thus this function exists to help meet the needs of programmatic use cases,\n * like cases which transform a ConfigMapEntry before selecting a value from it.\n * @internal\n */\nexport function getConfigForMinVersionForCollabIterable<T>(\n\tminVersionForCollab: OldestSupportedClientVersion,\n\tentries: Iterable<readonly [MinimumMinorSemanticVersion | OldestSupportedClientVersion, T]>, // [[typeof lowestMinVersionForCollab, T], ...[OldestSupportedClientVersion, T][]],\n): T {\n\t// Validate and strongly type the versions from the configMap.\n\tconst versions: [OldestSupportedClientVersion, T][] = Array.from(\n\t\tentries,\n\t\t([version, value]) => {\n\t\t\tvalidateMinimumVersionForCollab(version);\n\t\t\treturn [version, value];\n\t\t},\n\t);\n\treturn (selectVersionRoundedDown(minVersionForCollab, versions) ??\n\t\tfail(0xcb8 /* No config map entry for version */))[1];\n}\n\n/**\n * Finds the entry for the highest version that is less than or equal to the provided minVersionForCollab.\n * @remarks\n * If none is found, returns undefined.\n *\n * When used with Fluid client versions, use the stricter {@link getConfigForMinVersionForCollabIterable} instead.\n *\n * @internal\n */\nexport function selectVersionRoundedDown<T>(\n\tminVersionForCollab: string,\n\tentries: Iterable<readonly [string, T]>,\n\tcompareVersions: (a: string, b: string) => number = compare,\n): readonly [string, T] | undefined {\n\t// Sort a copy of the iterable in descending order\n\tconst versions: (readonly [string, T])[] = [...entries];\n\tversions.sort((a, b) => compareVersions(b[0], a[0]));\n\n\t// For each config, we iterate over the keys and check if minVersionForCollab is greater than or equal to the version.\n\t// If so, we set it as the default value for the option.\n\tfor (const pair of versions) {\n\t\tconst [version, _] = pair;\n\t\tif (compareVersions(minVersionForCollab, version) >= 0) {\n\t\t\treturn pair;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * Returns detailed information about the validity of a minVersionForCollab.\n * @param minVersionForCollab - The minVersionForCollab to validate.\n * @returns An object containing the validity information.\n *\n * @internal\n */\nexport function checkValidMinVersionForCollabVerbose(minVersionForCollab: SemanticVersion): {\n\tisValidSemver: boolean;\n\tisGteLowestMinVersion: boolean;\n\tisLtePkgVersion: boolean;\n} {\n\tconst isValidSemver = valid(minVersionForCollab) !== null;\n\treturn {\n\t\tisValidSemver,\n\n\t\t// We have to check if the value is a valid semver before calling gte/lte, otherwise they will throw when parsing the version.\n\t\tisGteLowestMinVersion:\n\t\t\tisValidSemver && gte(minVersionForCollab, lowestMinVersionForCollab),\n\t\tisLtePkgVersion: isValidSemver && lte(minVersionForCollab, cleanedPackageVersion),\n\t};\n}\n\n/**\n * Checks if the minVersionForCollab is valid.\n * A valid minVersionForCollab is a OldestSupportedClientVersion that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.\n *\n * @internal\n */\nexport function isValidMinVersionForCollab(\n\tminVersionForCollab: SemanticVersion,\n): minVersionForCollab is OldestSupportedClientVersion {\n\tconst { isValidSemver, isGteLowestMinVersion, isLtePkgVersion } =\n\t\tcheckValidMinVersionForCollabVerbose(minVersionForCollab);\n\treturn isValidSemver && isGteLowestMinVersion && isLtePkgVersion;\n}\n\nconst parsedPackageVersion = parse(pkgVersion) ?? fail(0xcb9 /* Invalid package version */);\n\n/**\n * `pkgVersion` version without pre-release.\n * @remarks\n * This is the version that the code in the current version of the codebase will have when officially released.\n * Generally, compatibility of prerelease builds is not guaranteed (especially for how they interact with future releases).\n * So while technically a prerelease build is less (older) than the released version which follows it and thus supports less features,\n * it makes sense for them to claim to support the same features as the following release so they can be used to test how the release would actually behave.\n *\n * To accomplish this, the version the next release will have is provided here as `cleanedPackageVersion` while `pkgVersion` may be a prerelease in some cases,\n * like when running tests on CI, or in an actual prerelease published package.\n * This is then used in {@link validateMinimumVersionForCollab} to allow the version shown on main to be usable as a `minVersionForCollab`, even in CI and prerelease packages.\n *\n * This is of particular note in two cases:\n * 1. When landing a new feature, and setting the minVersionForCollab which enables it to be the version that the next release will have.\n * Having that version be valid on main, pass tests locally, then fail on CI and when using published prerelease packages would be confusing, and probably undesired.\n * 2. Setting the minVersionForCollab to the current version for scenarios that do no involve collab with other package versions seems like it should be valid.\n * This is useful for testing new features, and also non collaborative scenarios where the latest features are desired.\n *\n * To accommodate some uses of the second case, it might be useful to package export this in the future.\n *\n * @privateRemarks\n * Since this is used by validateMinimumVersionForCollab, the type case to OldestSupportedClientVersion can not use it directly.\n * Thus this is just `as` cast here, and a test confirms it is valid according to validateMinimumVersionForCollab.\n *\n * @internal\n */\nexport const cleanedPackageVersion =\n\t`${parsedPackageVersion.major}.${parsedPackageVersion.minor}.${parsedPackageVersion.patch}` as OldestSupportedClientVersion;\n\n/**\n * Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}, throwing a UsageError if it is not valid.\n * @remarks\n * This is more strict than the type constraints imposed by `OldestSupportedClientVersion`.\n * Currently there is no type which is used to separate semantically valid and typescript allowed OldestSupportedClientVersion values:\n * thus users that care about strict validation may want to call this on un-validated `OldestSupportedClientVersion` values.\n * @param semanticVersion - The version to check.\n * @throws UsageError if the version is not a valid OldestSupportedClientVersion.\n *\n * @internal\n */\nexport function validateMinimumVersionForCollab(\n\tsemanticVersion: string,\n): asserts semanticVersion is OldestSupportedClientVersion {\n\tconst minVersionForCollab = semanticVersion as OldestSupportedClientVersion;\n\tconst { isValidSemver, isGteLowestMinVersion, isLtePkgVersion } =\n\t\tcheckValidMinVersionForCollabVerbose(minVersionForCollab);\n\tif (!(isValidSemver && isGteLowestMinVersion && isLtePkgVersion)) {\n\t\tthrow new UsageError(\n\t\t\t`Version ${minVersionForCollab} is not a valid OldestSupportedClientVersion. ` +\n\t\t\t\t`It must be in a valid semver format, at least ${lowestMinVersionForCollab}, ` +\n\t\t\t\t`and less than or equal to the current package version ${cleanedPackageVersion}. ` +\n\t\t\t\t`Details: { isValidSemver: ${isValidSemver}, isGteLowestMinVersion: ${isGteLowestMinVersion}, isLtePkgVersion: ${isLtePkgVersion} }`,\n\t\t);\n\t}\n}\n\n/**\n * Validates the given `overrides`.\n *\n * No-op when minVersionForCollab is set to defaultMinVersionForCollab.\n *\n * Otherwise this checks that for keys which are in both the `validationMap` and the `overrides`,\n * that the `validationMap` function for that key either returns undefined or a version less than or equal to `minVersionForCollab`.\n * @privateRemarks\n * This design seems odd, and might want to be revisited.\n * Currently it only permits opting out of features, not into them (unless validationMap returns undefined),\n * and the handling of defaultMinVersionForCollab and undefined versions seems questionable.\n * Also ignoring of extra keys in overrides might be bad since it seems like overrides is supposed to be validated.\n * @internal\n */\nexport function validateConfigMapOverrides<T extends Record<string, unknown>>(\n\tminVersionForCollab: SemanticVersion,\n\toverrides: Partial<T>,\n\tvalidationMap: ConfigValidationMap<T>,\n): void {\n\tif (minVersionForCollab === defaultMinVersionForCollab) {\n\t\t// If the minVersionForCollab is set to the default value, then we will not validate the runtime options\n\t\t// This is to avoid disruption to users who have not yet set the minVersionForCollab value explicitly.\n\t\t// TODO: This also skips validation for users which explicitly request defaultMinVersionForCollab which seems like a bug.\n\t\treturn;\n\t}\n\t// Iterate through each runtime option passed in by the user\n\t// Type assertion is safe as entries come from runtimeOptions object\n\tfor (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(overrides) as [\n\t\tkeyof T & string,\n\t\tT[keyof T & string],\n\t][]) {\n\t\t// Skip if passedRuntimeOption is not in validation map\n\t\tif (!(passedRuntimeOption in validationMap)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst requiredVersion = validationMap[passedRuntimeOption](passedRuntimeOptionValue);\n\t\tif (requiredVersion !== undefined && gt(requiredVersion, minVersionForCollab)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Runtime option ${passedRuntimeOption}:${JSON.stringify(passedRuntimeOptionValue)} requires ` +\n\t\t\t\t\t`runtime version ${requiredVersion}. Please update minVersionForCollab ` +\n\t\t\t\t\t`(currently ${minVersionForCollab}) to ${requiredVersion} or later to proceed.`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * Helper function to map ContainerRuntimeOptionsInternal config values to\n * minVersionForCollab in, e.g., {@link @fluidframework/container-runtime#runtimeOptionsAffectingDocSchemaConfigValidationMap}.\n *\n * @internal\n */\nexport function configValueToMinVersionForCollab<\n\tT extends string | number | boolean | undefined | object,\n\tArr extends readonly [T, SemanticVersion][],\n>(configToMinVer: Arr): (configValue: T) => SemanticVersion | undefined {\n\tconst configValueToRequiredVersionMap = new Map(configToMinVer);\n\treturn (configValue: T) => {\n\t\t// If the configValue is not an object then we can get the version required directly from the map.\n\t\tif (typeof configValue !== \"object\") {\n\t\t\treturn configValueToRequiredVersionMap.get(configValue);\n\t\t}\n\t\t// When the input `configValue` is an object, this logic determines the minimum runtime version it requires.\n\t\t// It iterates through each entry in `configValueToRequiredVersionMap`. If `possibleConfigValue` shares at\n\t\t// least one key-value pair with the input `configValue`, its associated `versionRequired` is collected into\n\t\t// `matchingVersions`. After checking all entries, the highest among the collected versions is returned.\n\t\t// This represents the overall minimum version required to support the features implied by the input `configValue`.\n\t\tconst matchingVersions: SemanticVersion[] = [];\n\t\tfor (const [\n\t\t\tpossibleConfigValue,\n\t\t\tversionRequired,\n\t\t] of configValueToRequiredVersionMap.entries()) {\n\t\t\tassert(\n\t\t\t\ttypeof possibleConfigValue == \"object\",\n\t\t\t\t0xbb9 /* possibleConfigValue should be an object */,\n\t\t\t);\n\t\t\t// Check if `possibleConfigValue` and the input `configValue` share at least one\n\t\t\t// common key-value pair. If they do, the `versionRequired` for this `possibleConfigValue`\n\t\t\t// is added to `matchingVersions`.\n\t\t\tif (Object.entries(possibleConfigValue).some(([k, v]) => configValue[k] === v)) {\n\t\t\t\tmatchingVersions.push(versionRequired);\n\t\t\t}\n\t\t}\n\t\tif (matchingVersions.length > 0) {\n\t\t\t// Return the latest minVersionForCollab among all matches.\n\t\t\treturn matchingVersions.sort((a, b) => compare(b, a))[0];\n\t\t}\n\t\t// If no matches then we return undefined. This means that the config value passed in\n\t\t// does not require a specific minVersionForCollab to be valid.\n\t\treturn undefined;\n\t};\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/runtime-utils";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.116.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,+BAA+B,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,+BAA+B,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"2.116.0\";\n"]}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { ICodeDetailsLoader, IContainerContext, IRuntime } from "@fluidframework/container-definitions/internal";
|
|
6
6
|
import type { FluidObject } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { type DataStoreKey, type DataStoreKind, type DataStoreRegistry, type FluidContainerAttached, type FluidContainerWithService, type Registry, type ServiceClient } from "@fluidframework/driver-definitions/internal";
|
|
8
|
-
import type { IContainerRuntimeBase, IFluidDataStoreRegistry,
|
|
8
|
+
import type { IContainerRuntimeBase, IFluidDataStoreRegistry, OldestSupportedClientVersion } from "@fluidframework/runtime-definitions/internal";
|
|
9
9
|
/**
|
|
10
10
|
* The constant ID used for the root data store alias in service containers.
|
|
11
11
|
* @internal
|
|
@@ -34,7 +34,7 @@ export interface ContainerRuntimeLoaderParams {
|
|
|
34
34
|
registry: IFluidDataStoreRegistry;
|
|
35
35
|
provideEntryPoint: (runtime: IContainerRuntimeBase) => Promise<FluidObject>;
|
|
36
36
|
existing: boolean;
|
|
37
|
-
minVersionForCollab:
|
|
37
|
+
minVersionForCollab: OldestSupportedClientVersion;
|
|
38
38
|
/**
|
|
39
39
|
* The type string of the root data store to create. Only set when `existing` is false.
|
|
40
40
|
*/
|
|
@@ -65,7 +65,7 @@ export type ContainerRuntimeLoader = (parameters: ContainerRuntimeLoaderParams)
|
|
|
65
65
|
*
|
|
66
66
|
* @internal
|
|
67
67
|
*/
|
|
68
|
-
export declare function makeCodeLoader<T>(registry: DataStoreRegistry<T>, minVersionForCollab:
|
|
68
|
+
export declare function makeCodeLoader<T>(registry: DataStoreRegistry<T>, minVersionForCollab: OldestSupportedClientVersion, loadRuntime: ContainerRuntimeLoader, root?: DataStoreKind<T>): ICodeDetailsLoader;
|
|
69
69
|
/**
|
|
70
70
|
* Minimal interface for the static container factory methods used by {@link ServiceClientImplementation}.
|
|
71
71
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceClientUtils.d.ts","sourceRoot":"","sources":["../src/serviceClientUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,iBAAiB,EAIjB,QAAQ,EAER,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,QAAQ,EAEb,KAAK,aAAa,EAClB,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EAEX,qBAAqB,EACrB,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"serviceClientUtils.d.ts","sourceRoot":"","sources":["../src/serviceClientUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,iBAAiB,EAIjB,QAAQ,EAER,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CA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IACvC,YACkB,OAAiB,EACjB,OAA0C;QAD1C,YAAO,GAAP,OAAO,CAAU;QACjB,YAAO,GAAP,OAAO,CAAmC;IACzD,CAAC;IAEJ,sFAAsF;IACtF,2HAA2H;IACpH,KAAK,CAAC,eAAe,CAC3B,IAAwC,EACxC,QAA8C;QAE9C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5B,2BAA2B,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAChD,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACjF,CAAC;aAAM,CAAC;YACP,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACpE,CAAC;IACF,CAAC;IAEM,KAAK,CAAC,uBAAuB,CACnC,IAAwC,EACxC,QAA8C;QAE9C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC7D,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,aAAa,CACzB,EAAU,EACV,IAA4D;QAE5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tICodeDetailsLoader,\n\tIContainerContext,\n\tIFluidCodeDetails,\n\tIFluidCodeDetailsComparer,\n\tIFluidModuleWithDetails,\n\tIRuntime,\n\tIRuntimeFactory,\n} from \"@fluidframework/container-definitions/internal\";\nimport type { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tcreateBasicRegistryKey,\n\ttype DataStoreKey,\n\ttype DataStoreKind,\n\ttype DataStoreRegistry,\n\ttype FluidContainerAttached,\n\ttype FluidContainerWithService,\n\ttype Registry,\n\tlookupInRegistry,\n\ttype ServiceClient,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tFluidDataStoreRegistryEntry,\n\tIContainerRuntimeBase,\n\tIFluidDataStoreRegistry,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { DataStoreKindImplementation } from \"./serviceClientBase.js\";\n\n/**\n * The constant ID used for the root data store alias in service containers.\n * @internal\n */\nexport const rootDataStoreId = \"root\";\n\n/**\n * Converts a `DataStoreRegistry` to the `IFluidDataStoreRegistry` interface expected by the container runtime.\n * @remarks\n * This does not leverage the ability for `IFluidDataStoreRegistry.get` to return undefined.\n * Note that all use-cases of `IFluidDataStoreRegistry.get` returning undefined currently end up as a fatal error.\n * Therefore it should be fine for the error to instead be thrown by the registry function, which is what this function does.\n * @internal\n */\nexport function convertRegistry<T>(registry: DataStoreRegistry<T>): IFluidDataStoreRegistry {\n\treturn {\n\t\tasync get(name: string): Promise<FluidDataStoreRegistryEntry | undefined> {\n\t\t\tconst dataStoreKind = await lookupInRegistry(registry, createBasicRegistryKey(name));\n\t\t\tDataStoreKindImplementation.narrowGeneric(dataStoreKind);\n\t\t\treturn dataStoreKind;\n\t\t},\n\t\tget IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\t\treturn this;\n\t\t},\n\t};\n}\n\n/**\n * Normalizes a `DataStoreKind` or registry function into a registry function.\n * @internal\n */\nexport function normalizeRegistry<T>(\n\tinput: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>,\n): Registry<Promise<DataStoreKind<T>>> {\n\tif (DataStoreKindImplementation.guard(input)) {\n\t\treturn async () => input;\n\t}\n\tassert(typeof input === \"function\", 0xd17 /* Registry must be a function */);\n\treturn input;\n}\n\n/**\n * Parameters passed to a {@link ContainerRuntimeLoader}.\n * @internal\n */\nexport interface ContainerRuntimeLoaderParams {\n\tcontext: IContainerContext;\n\tregistry: IFluidDataStoreRegistry;\n\tprovideEntryPoint: (runtime: IContainerRuntimeBase) => Promise<FluidObject>;\n\texisting: boolean;\n\tminVersionForCollab: MinimumVersionForCollab;\n\t/**\n\t * The type string of the root data store to create. Only set when `existing` is false.\n\t */\n\tnewContainerRootType: string | undefined;\n}\n\n/**\n * A service-specific callback that creates or loads the container runtime.\n *\n * @remarks\n * Receives the runtime parameters assembled by {@link makeCodeLoader} and is responsible for\n * calling the concrete runtime factory (e.g. `ContainerRuntime.loadRuntime2`) and, when\n * `existing` is `false`, initializing the root data store before returning.\n *\n * @internal\n */\nexport type ContainerRuntimeLoader = (\n\tparameters: ContainerRuntimeLoaderParams,\n) => Promise<IRuntime>;\n\n/**\n * Creates an `ICodeDetailsLoader` that wires up the container runtime via the supplied\n * `loadRuntime` callback.\n *\n * @remarks\n * The `loadRuntime` callback is responsible for invoking the concrete runtime factory and,\n * when `parameters.existing` is `false` and `parameters.newContainerRootType` is set, creating and\n * aliasing the root data store.\n *\n * This loader never does any code loading, and always assumes it is compatible.\n * TODO: We should reevaluate this before promoting ServiceClient APIs to beta.\n *\n * @internal\n */\nexport function makeCodeLoader<T>(\n\tregistry: DataStoreRegistry<T>,\n\tminVersionForCollab: MinimumVersionForCollab,\n\tloadRuntime: ContainerRuntimeLoader,\n\troot?: DataStoreKind<T>,\n): ICodeDetailsLoader {\n\tconst fluidExport: IRuntimeFactory & IFluidCodeDetailsComparer = {\n\t\tasync instantiateRuntime(\n\t\t\tcontext: IContainerContext,\n\t\t\texisting: boolean,\n\t\t): Promise<IRuntime> {\n\t\t\tconst provideEntryPoint = async (\n\t\t\t\tentryPointRuntime: IContainerRuntimeBase,\n\t\t\t): Promise<T & FluidObject> => {\n\t\t\t\tconst data = await entryPointRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\t\tif (data === undefined) {\n\t\t\t\t\tthrow new Error(\"Root data store missing!\");\n\t\t\t\t}\n\t\t\t\tconst rootDataStore = await data.get();\n\t\t\t\treturn rootDataStore as T & FluidObject;\n\t\t\t};\n\n\t\t\treturn loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistry: convertRegistry(registry),\n\t\t\t\tprovideEntryPoint,\n\t\t\t\texisting,\n\t\t\t\tminVersionForCollab,\n\t\t\t\tnewContainerRootType: root?.type,\n\t\t\t});\n\t\t},\n\n\t\tasync satisfies(\n\t\t\tcandidate: IFluidCodeDetails,\n\t\t\tconstraint: IFluidCodeDetails,\n\t\t): Promise<boolean> {\n\t\t\treturn true;\n\t\t},\n\n\t\tasync compare(a: IFluidCodeDetails, b: IFluidCodeDetails): Promise<number | undefined> {\n\t\t\treturn 0;\n\t\t},\n\n\t\tget IRuntimeFactory(): IRuntimeFactory {\n\t\t\treturn fluidExport;\n\t\t},\n\n\t\tget IFluidCodeDetailsComparer(): IFluidCodeDetailsComparer {\n\t\t\treturn fluidExport;\n\t\t},\n\t};\n\n\treturn {\n\t\tload: async (details: IFluidCodeDetails): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn { module: { fluidExport }, details };\n\t\t},\n\t};\n}\n\n/**\n * Minimal interface for the static container factory methods used by {@link ServiceClientImplementation}.\n * @internal\n */\nexport interface ServiceContainerStatics<TOptions> {\n\tcreateDetached<T>(\n\t\tregistry: DataStoreRegistry<T>,\n\t\toptions: TOptions,\n\t\troot: DataStoreKind<T>,\n\t): Promise<FluidContainerWithService<T>>;\n\n\tload<T>(\n\t\tregistry: DataStoreRegistry<T>,\n\t\toptions: TOptions,\n\t\tid: string,\n\t): Promise<FluidContainerAttached<T>>;\n}\n\n/**\n * Creates a {@link @fluidframework/driver-definitions#ServiceClient} that delegates container\n * creation and loading to the supplied container class statics.\n * @internal\n */\nexport class ServiceClientImplementation<TOptions> implements ServiceClient {\n\tpublic constructor(\n\t\tprivate readonly options: TOptions,\n\t\tprivate readonly statics: ServiceContainerStatics<TOptions>,\n\t) {}\n\n\t// This implements the ServiceClient interface's safer version of this with overloads.\n\t// For use in the implementation however, this is simpler, and allows createAttachedContainer to forward to it more easily.\n\tpublic async createContainer<T>(\n\t\troot: DataStoreKey<T> | DataStoreKind<T>,\n\t\tregistry?: Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerWithService<T>> {\n\t\tif (registry === undefined) {\n\t\t\tDataStoreKindImplementation.narrowGeneric(root);\n\t\t\treturn this.statics.createDetached(normalizeRegistry(root), this.options, root);\n\t\t} else {\n\t\t\tconst result = await lookupInRegistry(registry, root);\n\t\t\treturn this.statics.createDetached(registry, this.options, result);\n\t\t}\n\t}\n\n\tpublic async createAttachedContainer<T>(\n\t\troot: DataStoreKey<T> | DataStoreKind<T>,\n\t\tregistry?: Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerAttached<T>> {\n\t\tconst container = await this.createContainer(root, registry);\n\t\treturn container.attach();\n\t}\n\n\tpublic async loadContainer<T>(\n\t\tid: string,\n\t\troot: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerAttached<T>> {\n\t\treturn this.statics.load(normalizeRegistry(root), this.options, id);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serviceClientUtils.js","sourceRoot":"","sources":["../src/serviceClientUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EACN,sBAAsB,EAOtB,gBAAgB,GAEhB,MAAM,6CAA6C,CAAC;AAQrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAErE;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAI,QAA8B;I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,CAAC;IAEM,KAAK,CAAC,uBAAuB,CACnC,IAAwC,EACxC,QAA8C;QAE9C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC7D,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,aAAa,CACzB,EAAU,EACV,IAA4D;QAE5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tICodeDetailsLoader,\n\tIContainerContext,\n\tIFluidCodeDetails,\n\tIFluidCodeDetailsComparer,\n\tIFluidModuleWithDetails,\n\tIRuntime,\n\tIRuntimeFactory,\n} from \"@fluidframework/container-definitions/internal\";\nimport type { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tcreateBasicRegistryKey,\n\ttype DataStoreKey,\n\ttype DataStoreKind,\n\ttype DataStoreRegistry,\n\ttype FluidContainerAttached,\n\ttype FluidContainerWithService,\n\ttype Registry,\n\tlookupInRegistry,\n\ttype ServiceClient,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tFluidDataStoreRegistryEntry,\n\tIContainerRuntimeBase,\n\tIFluidDataStoreRegistry,\n\tOldestSupportedClientVersion,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { DataStoreKindImplementation } from \"./serviceClientBase.js\";\n\n/**\n * The constant ID used for the root data store alias in service containers.\n * @internal\n */\nexport const rootDataStoreId = \"root\";\n\n/**\n * Converts a `DataStoreRegistry` to the `IFluidDataStoreRegistry` interface expected by the container runtime.\n * @remarks\n * This does not leverage the ability for `IFluidDataStoreRegistry.get` to return undefined.\n * Note that all use-cases of `IFluidDataStoreRegistry.get` returning undefined currently end up as a fatal error.\n * Therefore it should be fine for the error to instead be thrown by the registry function, which is what this function does.\n * @internal\n */\nexport function convertRegistry<T>(registry: DataStoreRegistry<T>): IFluidDataStoreRegistry {\n\treturn {\n\t\tasync get(name: string): Promise<FluidDataStoreRegistryEntry | undefined> {\n\t\t\tconst dataStoreKind = await lookupInRegistry(registry, createBasicRegistryKey(name));\n\t\t\tDataStoreKindImplementation.narrowGeneric(dataStoreKind);\n\t\t\treturn dataStoreKind;\n\t\t},\n\t\tget IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\t\treturn this;\n\t\t},\n\t};\n}\n\n/**\n * Normalizes a `DataStoreKind` or registry function into a registry function.\n * @internal\n */\nexport function normalizeRegistry<T>(\n\tinput: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>,\n): Registry<Promise<DataStoreKind<T>>> {\n\tif (DataStoreKindImplementation.guard(input)) {\n\t\treturn async () => input;\n\t}\n\tassert(typeof input === \"function\", 0xd17 /* Registry must be a function */);\n\treturn input;\n}\n\n/**\n * Parameters passed to a {@link ContainerRuntimeLoader}.\n * @internal\n */\nexport interface ContainerRuntimeLoaderParams {\n\tcontext: IContainerContext;\n\tregistry: IFluidDataStoreRegistry;\n\tprovideEntryPoint: (runtime: IContainerRuntimeBase) => Promise<FluidObject>;\n\texisting: boolean;\n\tminVersionForCollab: OldestSupportedClientVersion;\n\t/**\n\t * The type string of the root data store to create. Only set when `existing` is false.\n\t */\n\tnewContainerRootType: string | undefined;\n}\n\n/**\n * A service-specific callback that creates or loads the container runtime.\n *\n * @remarks\n * Receives the runtime parameters assembled by {@link makeCodeLoader} and is responsible for\n * calling the concrete runtime factory (e.g. `ContainerRuntime.loadRuntime2`) and, when\n * `existing` is `false`, initializing the root data store before returning.\n *\n * @internal\n */\nexport type ContainerRuntimeLoader = (\n\tparameters: ContainerRuntimeLoaderParams,\n) => Promise<IRuntime>;\n\n/**\n * Creates an `ICodeDetailsLoader` that wires up the container runtime via the supplied\n * `loadRuntime` callback.\n *\n * @remarks\n * The `loadRuntime` callback is responsible for invoking the concrete runtime factory and,\n * when `parameters.existing` is `false` and `parameters.newContainerRootType` is set, creating and\n * aliasing the root data store.\n *\n * This loader never does any code loading, and always assumes it is compatible.\n * TODO: We should reevaluate this before promoting ServiceClient APIs to beta.\n *\n * @internal\n */\nexport function makeCodeLoader<T>(\n\tregistry: DataStoreRegistry<T>,\n\tminVersionForCollab: OldestSupportedClientVersion,\n\tloadRuntime: ContainerRuntimeLoader,\n\troot?: DataStoreKind<T>,\n): ICodeDetailsLoader {\n\tconst fluidExport: IRuntimeFactory & IFluidCodeDetailsComparer = {\n\t\tasync instantiateRuntime(\n\t\t\tcontext: IContainerContext,\n\t\t\texisting: boolean,\n\t\t): Promise<IRuntime> {\n\t\t\tconst provideEntryPoint = async (\n\t\t\t\tentryPointRuntime: IContainerRuntimeBase,\n\t\t\t): Promise<T & FluidObject> => {\n\t\t\t\tconst data = await entryPointRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\t\tif (data === undefined) {\n\t\t\t\t\tthrow new Error(\"Root data store missing!\");\n\t\t\t\t}\n\t\t\t\tconst rootDataStore = await data.get();\n\t\t\t\treturn rootDataStore as T & FluidObject;\n\t\t\t};\n\n\t\t\treturn loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistry: convertRegistry(registry),\n\t\t\t\tprovideEntryPoint,\n\t\t\t\texisting,\n\t\t\t\tminVersionForCollab,\n\t\t\t\tnewContainerRootType: root?.type,\n\t\t\t});\n\t\t},\n\n\t\tasync satisfies(\n\t\t\tcandidate: IFluidCodeDetails,\n\t\t\tconstraint: IFluidCodeDetails,\n\t\t): Promise<boolean> {\n\t\t\treturn true;\n\t\t},\n\n\t\tasync compare(a: IFluidCodeDetails, b: IFluidCodeDetails): Promise<number | undefined> {\n\t\t\treturn 0;\n\t\t},\n\n\t\tget IRuntimeFactory(): IRuntimeFactory {\n\t\t\treturn fluidExport;\n\t\t},\n\n\t\tget IFluidCodeDetailsComparer(): IFluidCodeDetailsComparer {\n\t\t\treturn fluidExport;\n\t\t},\n\t};\n\n\treturn {\n\t\tload: async (details: IFluidCodeDetails): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn { module: { fluidExport }, details };\n\t\t},\n\t};\n}\n\n/**\n * Minimal interface for the static container factory methods used by {@link ServiceClientImplementation}.\n * @internal\n */\nexport interface ServiceContainerStatics<TOptions> {\n\tcreateDetached<T>(\n\t\tregistry: DataStoreRegistry<T>,\n\t\toptions: TOptions,\n\t\troot: DataStoreKind<T>,\n\t): Promise<FluidContainerWithService<T>>;\n\n\tload<T>(\n\t\tregistry: DataStoreRegistry<T>,\n\t\toptions: TOptions,\n\t\tid: string,\n\t): Promise<FluidContainerAttached<T>>;\n}\n\n/**\n * Creates a {@link @fluidframework/driver-definitions#ServiceClient} that delegates container\n * creation and loading to the supplied container class statics.\n * @internal\n */\nexport class ServiceClientImplementation<TOptions> implements ServiceClient {\n\tpublic constructor(\n\t\tprivate readonly options: TOptions,\n\t\tprivate readonly statics: ServiceContainerStatics<TOptions>,\n\t) {}\n\n\t// This implements the ServiceClient interface's safer version of this with overloads.\n\t// For use in the implementation however, this is simpler, and allows createAttachedContainer to forward to it more easily.\n\tpublic async createContainer<T>(\n\t\troot: DataStoreKey<T> | DataStoreKind<T>,\n\t\tregistry?: Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerWithService<T>> {\n\t\tif (registry === undefined) {\n\t\t\tDataStoreKindImplementation.narrowGeneric(root);\n\t\t\treturn this.statics.createDetached(normalizeRegistry(root), this.options, root);\n\t\t} else {\n\t\t\tconst result = await lookupInRegistry(registry, root);\n\t\t\treturn this.statics.createDetached(registry, this.options, result);\n\t\t}\n\t}\n\n\tpublic async createAttachedContainer<T>(\n\t\troot: DataStoreKey<T> | DataStoreKind<T>,\n\t\tregistry?: Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerAttached<T>> {\n\t\tconst container = await this.createContainer(root, registry);\n\t\treturn container.attach();\n\t}\n\n\tpublic async loadContainer<T>(\n\t\tid: string,\n\t\troot: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerAttached<T>> {\n\t\treturn this.statics.load(normalizeRegistry(root), this.options, id);\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/runtime-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.116.0",
|
|
4
4
|
"description": "Collection of utility functions for Fluid Runtime",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -79,27 +79,27 @@
|
|
|
79
79
|
"temp-directory": "nyc/.nyc_output"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@fluid-internal/client-utils": "~2.
|
|
83
|
-
"@fluidframework/container-definitions": "~2.
|
|
84
|
-
"@fluidframework/container-runtime-definitions": "~2.
|
|
85
|
-
"@fluidframework/core-interfaces": "~2.
|
|
86
|
-
"@fluidframework/core-utils": "~2.
|
|
87
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
88
|
-
"@fluidframework/driver-definitions": "~2.
|
|
89
|
-
"@fluidframework/driver-utils": "~2.
|
|
90
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
91
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
82
|
+
"@fluid-internal/client-utils": "~2.116.0",
|
|
83
|
+
"@fluidframework/container-definitions": "~2.116.0",
|
|
84
|
+
"@fluidframework/container-runtime-definitions": "~2.116.0",
|
|
85
|
+
"@fluidframework/core-interfaces": "~2.116.0",
|
|
86
|
+
"@fluidframework/core-utils": "~2.116.0",
|
|
87
|
+
"@fluidframework/datastore-definitions": "~2.116.0",
|
|
88
|
+
"@fluidframework/driver-definitions": "~2.116.0",
|
|
89
|
+
"@fluidframework/driver-utils": "~2.116.0",
|
|
90
|
+
"@fluidframework/runtime-definitions": "~2.116.0",
|
|
91
|
+
"@fluidframework/telemetry-utils": "~2.116.0",
|
|
92
92
|
"semver-ts": "^1.0.3"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@arethetypeswrong/cli": "^0.18.
|
|
95
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
96
96
|
"@biomejs/biome": "~2.4.5",
|
|
97
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
98
|
-
"@fluid-tools/build-cli": "^0.
|
|
97
|
+
"@fluid-internal/mocha-test-setup": "~2.116.0",
|
|
98
|
+
"@fluid-tools/build-cli": "^0.67.0",
|
|
99
99
|
"@fluidframework/build-common": "^2.0.3",
|
|
100
|
-
"@fluidframework/build-tools": "^0.
|
|
101
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
102
|
-
"@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.
|
|
100
|
+
"@fluidframework/build-tools": "^0.67.0",
|
|
101
|
+
"@fluidframework/eslint-config-fluid": "^14.0.0",
|
|
102
|
+
"@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.114.0",
|
|
103
103
|
"@microsoft/api-extractor": "7.58.1",
|
|
104
104
|
"@types/mocha": "^10.0.10",
|
|
105
105
|
"@types/node": "~22.19.17",
|
package/src/compatibilityBase.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert, fail } from "@fluidframework/core-utils/internal";
|
|
7
|
-
import type {
|
|
7
|
+
import type { OldestSupportedClientVersion } from "@fluidframework/runtime-definitions/internal";
|
|
8
8
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
9
9
|
import { compare, gt, gte, lte, valid, parse } from "semver-ts";
|
|
10
10
|
|
|
@@ -31,7 +31,7 @@ import { pkgVersion } from "./packageVersion.js";
|
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
33
|
export const defaultMinVersionForCollab =
|
|
34
|
-
"2.0.0-defaults" as const satisfies
|
|
34
|
+
"2.0.0-defaults" as const satisfies OldestSupportedClientVersion;
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* We don't want allow a version before the major public release of the LTS version.
|
|
@@ -44,7 +44,8 @@ export const defaultMinVersionForCollab =
|
|
|
44
44
|
*
|
|
45
45
|
* @internal
|
|
46
46
|
*/
|
|
47
|
-
export const lowestMinVersionForCollab =
|
|
47
|
+
export const lowestMinVersionForCollab =
|
|
48
|
+
"1.0.0" as const satisfies OldestSupportedClientVersion;
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
51
|
* String in a valid semver format specifying bottom of a minor version
|
|
@@ -58,7 +59,7 @@ export type MinimumMinorSemanticVersion = `${bigint}.${bigint}.0` | `${bigint}.0
|
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
61
|
* String in a valid semver format of a specific version at least specifying minor.
|
|
61
|
-
* Unlike {@link @fluidframework/runtime-definitions#
|
|
62
|
+
* Unlike {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}, this type allows any bigint for the major version.
|
|
62
63
|
* Used as a more generic type that allows major versions other than 1 or 2.
|
|
63
64
|
*
|
|
64
65
|
* @internal
|
|
@@ -70,11 +71,11 @@ export type SemanticVersion =
|
|
|
70
71
|
/**
|
|
71
72
|
* Converts a record into a configuration map that associates each key with an instance of its value type that is based on a {@link MinimumMinorSemanticVersion}.
|
|
72
73
|
* @remarks
|
|
73
|
-
* For a given input {@link @fluidframework/runtime-definitions#
|
|
74
|
+
* For a given input {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion},
|
|
74
75
|
* the corresponding configuration values can be found by using the entry in the inner objects with the highest {@link MinimumMinorSemanticVersion}
|
|
75
|
-
* that does not exceed the given {@link @fluidframework/runtime-definitions#
|
|
76
|
+
* that does not exceed the given {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}.
|
|
76
77
|
*
|
|
77
|
-
* Use {@link getConfigsForMinVersionForCollab} to retrieve the configuration for a given a {@link @fluidframework/runtime-definitions#
|
|
78
|
+
* Use {@link getConfigsForMinVersionForCollab} to retrieve the configuration for a given a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}.
|
|
78
79
|
*
|
|
79
80
|
* See the remarks on {@link MinimumMinorSemanticVersion} for some limitation on how ConfigMaps must handle versioning.
|
|
80
81
|
* @internal
|
|
@@ -118,7 +119,7 @@ export type ConfigValidationMap<T extends Record<string, unknown>> = {
|
|
|
118
119
|
* @internal
|
|
119
120
|
*/
|
|
120
121
|
export function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(
|
|
121
|
-
minVersionForCollab:
|
|
122
|
+
minVersionForCollab: OldestSupportedClientVersion,
|
|
122
123
|
configMap: ConfigMap<T> & Record<keyof T, unknown>,
|
|
123
124
|
): T {
|
|
124
125
|
validateMinimumVersionForCollab(minVersionForCollab);
|
|
@@ -140,7 +141,7 @@ export function getConfigsForMinVersionForCollab<T extends Record<SemanticVersio
|
|
|
140
141
|
* @internal
|
|
141
142
|
*/
|
|
142
143
|
export function getConfigForMinVersionForCollab<T>(
|
|
143
|
-
minVersionForCollab:
|
|
144
|
+
minVersionForCollab: OldestSupportedClientVersion,
|
|
144
145
|
config: ConfigMapEntry<T>,
|
|
145
146
|
): T {
|
|
146
147
|
return getConfigForMinVersionForCollabIterable(
|
|
@@ -161,14 +162,17 @@ export function getConfigForMinVersionForCollab<T>(
|
|
|
161
162
|
* @internal
|
|
162
163
|
*/
|
|
163
164
|
export function getConfigForMinVersionForCollabIterable<T>(
|
|
164
|
-
minVersionForCollab:
|
|
165
|
-
entries: Iterable<readonly [MinimumMinorSemanticVersion |
|
|
165
|
+
minVersionForCollab: OldestSupportedClientVersion,
|
|
166
|
+
entries: Iterable<readonly [MinimumMinorSemanticVersion | OldestSupportedClientVersion, T]>, // [[typeof lowestMinVersionForCollab, T], ...[OldestSupportedClientVersion, T][]],
|
|
166
167
|
): T {
|
|
167
168
|
// Validate and strongly type the versions from the configMap.
|
|
168
|
-
const versions: [
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
const versions: [OldestSupportedClientVersion, T][] = Array.from(
|
|
170
|
+
entries,
|
|
171
|
+
([version, value]) => {
|
|
172
|
+
validateMinimumVersionForCollab(version);
|
|
173
|
+
return [version, value];
|
|
174
|
+
},
|
|
175
|
+
);
|
|
172
176
|
return (selectVersionRoundedDown(minVersionForCollab, versions) ??
|
|
173
177
|
fail(0xcb8 /* No config map entry for version */))[1];
|
|
174
178
|
}
|
|
@@ -227,13 +231,13 @@ export function checkValidMinVersionForCollabVerbose(minVersionForCollab: Semant
|
|
|
227
231
|
|
|
228
232
|
/**
|
|
229
233
|
* Checks if the minVersionForCollab is valid.
|
|
230
|
-
* A valid minVersionForCollab is a
|
|
234
|
+
* A valid minVersionForCollab is a OldestSupportedClientVersion that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
231
235
|
*
|
|
232
236
|
* @internal
|
|
233
237
|
*/
|
|
234
238
|
export function isValidMinVersionForCollab(
|
|
235
239
|
minVersionForCollab: SemanticVersion,
|
|
236
|
-
): minVersionForCollab is
|
|
240
|
+
): minVersionForCollab is OldestSupportedClientVersion {
|
|
237
241
|
const { isValidSemver, isGteLowestMinVersion, isLtePkgVersion } =
|
|
238
242
|
checkValidMinVersionForCollabVerbose(minVersionForCollab);
|
|
239
243
|
return isValidSemver && isGteLowestMinVersion && isLtePkgVersion;
|
|
@@ -262,34 +266,34 @@ const parsedPackageVersion = parse(pkgVersion) ?? fail(0xcb9 /* Invalid package
|
|
|
262
266
|
* To accommodate some uses of the second case, it might be useful to package export this in the future.
|
|
263
267
|
*
|
|
264
268
|
* @privateRemarks
|
|
265
|
-
* Since this is used by validateMinimumVersionForCollab, the type case to
|
|
269
|
+
* Since this is used by validateMinimumVersionForCollab, the type case to OldestSupportedClientVersion can not use it directly.
|
|
266
270
|
* Thus this is just `as` cast here, and a test confirms it is valid according to validateMinimumVersionForCollab.
|
|
267
271
|
*
|
|
268
272
|
* @internal
|
|
269
273
|
*/
|
|
270
274
|
export const cleanedPackageVersion =
|
|
271
|
-
`${parsedPackageVersion.major}.${parsedPackageVersion.minor}.${parsedPackageVersion.patch}` as
|
|
275
|
+
`${parsedPackageVersion.major}.${parsedPackageVersion.minor}.${parsedPackageVersion.patch}` as OldestSupportedClientVersion;
|
|
272
276
|
|
|
273
277
|
/**
|
|
274
|
-
* Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#
|
|
278
|
+
* Narrows the type of the provided {@link SemanticVersion} to a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}, throwing a UsageError if it is not valid.
|
|
275
279
|
* @remarks
|
|
276
|
-
* This is more strict than the type constraints imposed by `
|
|
277
|
-
* Currently there is no type which is used to separate semantically valid and typescript allowed
|
|
278
|
-
* thus users that care about strict validation may want to call this on un-validated `
|
|
280
|
+
* This is more strict than the type constraints imposed by `OldestSupportedClientVersion`.
|
|
281
|
+
* Currently there is no type which is used to separate semantically valid and typescript allowed OldestSupportedClientVersion values:
|
|
282
|
+
* thus users that care about strict validation may want to call this on un-validated `OldestSupportedClientVersion` values.
|
|
279
283
|
* @param semanticVersion - The version to check.
|
|
280
|
-
* @throws UsageError if the version is not a valid
|
|
284
|
+
* @throws UsageError if the version is not a valid OldestSupportedClientVersion.
|
|
281
285
|
*
|
|
282
286
|
* @internal
|
|
283
287
|
*/
|
|
284
288
|
export function validateMinimumVersionForCollab(
|
|
285
289
|
semanticVersion: string,
|
|
286
|
-
): asserts semanticVersion is
|
|
287
|
-
const minVersionForCollab = semanticVersion as
|
|
290
|
+
): asserts semanticVersion is OldestSupportedClientVersion {
|
|
291
|
+
const minVersionForCollab = semanticVersion as OldestSupportedClientVersion;
|
|
288
292
|
const { isValidSemver, isGteLowestMinVersion, isLtePkgVersion } =
|
|
289
293
|
checkValidMinVersionForCollabVerbose(minVersionForCollab);
|
|
290
294
|
if (!(isValidSemver && isGteLowestMinVersion && isLtePkgVersion)) {
|
|
291
295
|
throw new UsageError(
|
|
292
|
-
`Version ${minVersionForCollab} is not a valid
|
|
296
|
+
`Version ${minVersionForCollab} is not a valid OldestSupportedClientVersion. ` +
|
|
293
297
|
`It must be in a valid semver format, at least ${lowestMinVersionForCollab}, ` +
|
|
294
298
|
`and less than or equal to the current package version ${cleanedPackageVersion}. ` +
|
|
295
299
|
`Details: { isValidSemver: ${isValidSemver}, isGteLowestMinVersion: ${isGteLowestMinVersion}, isLtePkgVersion: ${isLtePkgVersion} }`,
|
package/src/packageVersion.ts
CHANGED
|
@@ -29,7 +29,7 @@ import type {
|
|
|
29
29
|
FluidDataStoreRegistryEntry,
|
|
30
30
|
IContainerRuntimeBase,
|
|
31
31
|
IFluidDataStoreRegistry,
|
|
32
|
-
|
|
32
|
+
OldestSupportedClientVersion,
|
|
33
33
|
} from "@fluidframework/runtime-definitions/internal";
|
|
34
34
|
|
|
35
35
|
import { DataStoreKindImplementation } from "./serviceClientBase.js";
|
|
@@ -84,7 +84,7 @@ export interface ContainerRuntimeLoaderParams {
|
|
|
84
84
|
registry: IFluidDataStoreRegistry;
|
|
85
85
|
provideEntryPoint: (runtime: IContainerRuntimeBase) => Promise<FluidObject>;
|
|
86
86
|
existing: boolean;
|
|
87
|
-
minVersionForCollab:
|
|
87
|
+
minVersionForCollab: OldestSupportedClientVersion;
|
|
88
88
|
/**
|
|
89
89
|
* The type string of the root data store to create. Only set when `existing` is false.
|
|
90
90
|
*/
|
|
@@ -121,7 +121,7 @@ export type ContainerRuntimeLoader = (
|
|
|
121
121
|
*/
|
|
122
122
|
export function makeCodeLoader<T>(
|
|
123
123
|
registry: DataStoreRegistry<T>,
|
|
124
|
-
minVersionForCollab:
|
|
124
|
+
minVersionForCollab: OldestSupportedClientVersion,
|
|
125
125
|
loadRuntime: ContainerRuntimeLoader,
|
|
126
126
|
root?: DataStoreKind<T>,
|
|
127
127
|
): ICodeDetailsLoader {
|