@fluidframework/runtime-utils 2.51.0 → 2.53.0-350190
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 +10 -0
- package/dist/compatibilityBase.d.ts +88 -0
- package/dist/compatibilityBase.d.ts.map +1 -0
- package/dist/compatibilityBase.js +145 -0
- package/dist/compatibilityBase.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +9 -0
- package/dist/packageVersion.d.ts.map +1 -0
- package/dist/packageVersion.js +12 -0
- package/dist/packageVersion.js.map +1 -0
- package/lib/compatibilityBase.d.ts +88 -0
- package/lib/compatibilityBase.d.ts.map +1 -0
- package/lib/compatibilityBase.js +138 -0
- package/lib/compatibilityBase.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +9 -0
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/packageVersion.js +9 -0
- package/lib/packageVersion.js.map +1 -0
- package/package.json +17 -15
- package/src/compatibilityBase.ts +212 -0
- package/src/index.ts +11 -0
- package/src/packageVersion.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @fluidframework/runtime-utils
|
|
2
2
|
|
|
3
|
+
## 2.52.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Moved MinimumVersionForCollab to @fluidframework/runtime-definitions ([#25059](https://github.com/microsoft/FluidFramework/pull/25059)) [4a7b370667](https://github.com/microsoft/FluidFramework/commit/4a7b3706675139af6d8aaae707b96b74081f1fc8)
|
|
8
|
+
|
|
9
|
+
MinimumVersionForCollab has been moved from @fluidframework/container-runtime to @fluidframework/runtime-definitions.
|
|
10
|
+
The export in @fluidframework/container-runtime is now deprecated and will be removed in a future version.
|
|
11
|
+
Consumers should import it from @fluidframework/runtime-definitions going forward.
|
|
12
|
+
|
|
3
13
|
## 2.51.0
|
|
4
14
|
|
|
5
15
|
Dependency updates only.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
|
|
6
|
+
/**
|
|
7
|
+
* Our policy is to support N/N-1 compatibility by default, where N is the most
|
|
8
|
+
* recent public major release of the runtime.
|
|
9
|
+
* Therefore, if the customer does not provide a minVersionForCollab, we will
|
|
10
|
+
* default to use N-1.
|
|
11
|
+
*
|
|
12
|
+
* However, this is not consistent with today's behavior. Some options (i.e.
|
|
13
|
+
* batching, compression) are enabled by default despite not being compatible
|
|
14
|
+
* with 1.x clients. Since the policy was introduced during 2.x's lifespan,
|
|
15
|
+
* N/N-1 compatibility by **default** will be in effect starting with 3.0.
|
|
16
|
+
* Importantly though, N/N-2 compatibility is still guaranteed with the proper
|
|
17
|
+
* configurations set.
|
|
18
|
+
*
|
|
19
|
+
* Further to distinguish unspecified `minVersionForCollab` from a specified
|
|
20
|
+
* version and allow `enableExplicitSchemaControl` to default to `true` for
|
|
21
|
+
* any 2.0.0+ version, we will use a special value of `2.0.0-defaults`, which
|
|
22
|
+
* is semantically less than 2.0.0.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare const defaultMinVersionForCollab: "2.0.0-defaults";
|
|
27
|
+
/**
|
|
28
|
+
* String in a valid semver format specifying bottom of a minor version
|
|
29
|
+
* or special "defaults" prerelease of a major.
|
|
30
|
+
* @remarks Only 2.0.0-defaults is expected, but index signatures cannot be a
|
|
31
|
+
* literal; so, just allow any major -defaults prerelease.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export type MinimumMinorSemanticVersion = `${bigint}.${bigint}.0` | `${bigint}.0.0-defaults`;
|
|
36
|
+
/**
|
|
37
|
+
* String in a valid semver format of a specific version at least specifying minor.
|
|
38
|
+
* Unlike {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}, this type allows any bigint for the major version.
|
|
39
|
+
* Used as a more generic type that allows major versions other than 1 or 2.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export type SemanticVersion = `${bigint}.${bigint}.${bigint}` | `${bigint}.${bigint}.${bigint}-${string}`;
|
|
44
|
+
/**
|
|
45
|
+
* Generic type for runtimeOptionsAffectingDocSchemaConfigMap
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export type ConfigMap<T extends Record<string, unknown>> = {
|
|
50
|
+
[K in keyof T]-?: {
|
|
51
|
+
[version: MinimumMinorSemanticVersion]: T[K];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Generic type for runtimeOptionsAffectingDocSchemaConfigValidationMap
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
export type ConfigValidationMap<T extends Record<string, unknown>> = {
|
|
60
|
+
[K in keyof T]-?: (configValue: T[K]) => SemanticVersion | undefined;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Returns a default configuration given minVersionForCollab and configuration version map.
|
|
64
|
+
*
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
export declare function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(minVersionForCollab: SemanticVersion, configMap: ConfigMap<T>): Partial<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Checks if the minVersionForCollab is valid.
|
|
70
|
+
* A valid minVersionForCollab is a MinimumVersionForCollab that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
71
|
+
*
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
export declare function isValidMinVersionForCollab(minVersionForCollab: MinimumVersionForCollab): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Generic function to validate runtime options against the minVersionForCollab.
|
|
77
|
+
*
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
export declare function getValidationForRuntimeOptions<T extends Record<string, unknown>>(minVersionForCollab: SemanticVersion, runtimeOptions: Partial<T>, validationMap: ConfigValidationMap<T>): void;
|
|
81
|
+
/**
|
|
82
|
+
* Helper function to map ContainerRuntimeOptionsInternal config values to
|
|
83
|
+
* minVersionForCollab in, e.g., {@link @fluidframework/container-runtime#runtimeOptionsAffectingDocSchemaConfigValidationMap}.
|
|
84
|
+
*
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
export declare function configValueToMinVersionForCollab<T extends string | number | boolean | undefined | object, Arr extends readonly [T, SemanticVersion][]>(configToMinVer: Arr): (configValue: T) => SemanticVersion | undefined;
|
|
88
|
+
//# sourceMappingURL=compatibilityBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibilityBase.d.ts","sourceRoot":"","sources":["../src/compatibilityBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAM5F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,0BAA0B,kBACqB,CAAC;AAU7D;;;;;;;GAOG;AACH,MAAM,MAAM,2BAA2B,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,GAAG,GAAG,MAAM,eAAe,CAAC;AAE7F;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GACxB,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,GAC/B,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;AAE7C;;;;GAIG;AACH,MAAM,MAAM,SAAS,CA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strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.configValueToMinVersionForCollab = exports.getValidationForRuntimeOptions = exports.isValidMinVersionForCollab = exports.getConfigsForMinVersionForCollab = exports.defaultMinVersionForCollab = void 0;
|
|
8
|
+
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
|
+
const internal_2 = require("@fluidframework/telemetry-utils/internal");
|
|
10
|
+
const semver_ts_1 = require("semver-ts");
|
|
11
|
+
const packageVersion_js_1 = require("./packageVersion.js");
|
|
12
|
+
/**
|
|
13
|
+
* Our policy is to support N/N-1 compatibility by default, where N is the most
|
|
14
|
+
* recent public major release of the runtime.
|
|
15
|
+
* Therefore, if the customer does not provide a minVersionForCollab, we will
|
|
16
|
+
* default to use N-1.
|
|
17
|
+
*
|
|
18
|
+
* However, this is not consistent with today's behavior. Some options (i.e.
|
|
19
|
+
* batching, compression) are enabled by default despite not being compatible
|
|
20
|
+
* with 1.x clients. Since the policy was introduced during 2.x's lifespan,
|
|
21
|
+
* N/N-1 compatibility by **default** will be in effect starting with 3.0.
|
|
22
|
+
* Importantly though, N/N-2 compatibility is still guaranteed with the proper
|
|
23
|
+
* configurations set.
|
|
24
|
+
*
|
|
25
|
+
* Further to distinguish unspecified `minVersionForCollab` from a specified
|
|
26
|
+
* version and allow `enableExplicitSchemaControl` to default to `true` for
|
|
27
|
+
* any 2.0.0+ version, we will use a special value of `2.0.0-defaults`, which
|
|
28
|
+
* is semantically less than 2.0.0.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
exports.defaultMinVersionForCollab = "2.0.0-defaults";
|
|
33
|
+
/**
|
|
34
|
+
* We don't want allow a version before the major public release of the LTS version.
|
|
35
|
+
* Today we use "1.0.0", because our policy supports N/N-1 & N/N-2, which includes
|
|
36
|
+
* all minor versions of N. Though LTS starts at 1.4.0, we should stay consistent
|
|
37
|
+
* with our policy and allow all 1.x versions to be compatible with 2.x.
|
|
38
|
+
*/
|
|
39
|
+
const lowestMinVersionForCollab = "1.0.0";
|
|
40
|
+
/**
|
|
41
|
+
* Returns a default configuration given minVersionForCollab and configuration version map.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
function getConfigsForMinVersionForCollab(minVersionForCollab, configMap) {
|
|
46
|
+
const defaultConfigs = {};
|
|
47
|
+
// Iterate over configMap to get default values for each option.
|
|
48
|
+
for (const key of Object.keys(configMap)) {
|
|
49
|
+
const config = configMap[key];
|
|
50
|
+
// Sort the versions in ascending order so we can short circuit the loop.
|
|
51
|
+
const versions = Object.keys(config).sort(semver_ts_1.compare);
|
|
52
|
+
// For each config, we iterate over the keys and check if minVersionForCollab is greater than or equal to the version.
|
|
53
|
+
// If so, we set it as the default value for the option. At the end of the loop we should have the most recent default
|
|
54
|
+
// value that is compatible with the version specified as the minVersionForCollab.
|
|
55
|
+
for (const version of versions) {
|
|
56
|
+
if ((0, semver_ts_1.gte)(minVersionForCollab, version)) {
|
|
57
|
+
defaultConfigs[key] = config[version];
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// If the minVersionForCollab is less than the version, we break out of the loop since we don't need to check
|
|
61
|
+
// any later versions.
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return defaultConfigs;
|
|
67
|
+
}
|
|
68
|
+
exports.getConfigsForMinVersionForCollab = getConfigsForMinVersionForCollab;
|
|
69
|
+
/**
|
|
70
|
+
* Checks if the minVersionForCollab is valid.
|
|
71
|
+
* A valid minVersionForCollab is a MinimumVersionForCollab that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
function isValidMinVersionForCollab(minVersionForCollab) {
|
|
76
|
+
return ((0, semver_ts_1.valid)(minVersionForCollab) !== null &&
|
|
77
|
+
(0, semver_ts_1.gte)(minVersionForCollab, lowestMinVersionForCollab) &&
|
|
78
|
+
(0, semver_ts_1.lte)(minVersionForCollab, packageVersion_js_1.pkgVersion));
|
|
79
|
+
}
|
|
80
|
+
exports.isValidMinVersionForCollab = isValidMinVersionForCollab;
|
|
81
|
+
/**
|
|
82
|
+
* Generic function to validate runtime options against the minVersionForCollab.
|
|
83
|
+
*
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
function getValidationForRuntimeOptions(minVersionForCollab, runtimeOptions, validationMap) {
|
|
87
|
+
if (minVersionForCollab === exports.defaultMinVersionForCollab) {
|
|
88
|
+
// If the minVersionForCollab is set to the default value, then we will not validate the runtime options
|
|
89
|
+
// This is to avoid disruption to users who have not yet set the minVersionForCollab value explicitly.
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// Iterate through each runtime option passed in by the user
|
|
93
|
+
for (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(runtimeOptions)) {
|
|
94
|
+
// Skip if passedRuntimeOption is not in validation map
|
|
95
|
+
if (!(passedRuntimeOption in validationMap)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const requiredVersion = validationMap[passedRuntimeOption](passedRuntimeOptionValue);
|
|
99
|
+
if (requiredVersion !== undefined && (0, semver_ts_1.gt)(requiredVersion, minVersionForCollab)) {
|
|
100
|
+
throw new internal_2.UsageError(`Runtime option ${passedRuntimeOption}:${JSON.stringify(passedRuntimeOptionValue)} requires ` +
|
|
101
|
+
`runtime version ${requiredVersion}. Please update minVersionForCollab ` +
|
|
102
|
+
`(currently ${minVersionForCollab}) to ${requiredVersion} or later to proceed.`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.getValidationForRuntimeOptions = getValidationForRuntimeOptions;
|
|
107
|
+
/**
|
|
108
|
+
* Helper function to map ContainerRuntimeOptionsInternal config values to
|
|
109
|
+
* minVersionForCollab in, e.g., {@link @fluidframework/container-runtime#runtimeOptionsAffectingDocSchemaConfigValidationMap}.
|
|
110
|
+
*
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
function configValueToMinVersionForCollab(configToMinVer) {
|
|
114
|
+
const configValueToRequiredVersionMap = new Map(configToMinVer);
|
|
115
|
+
return (configValue) => {
|
|
116
|
+
// If the configValue is not an object then we can get the version required directly from the map.
|
|
117
|
+
if (typeof configValue !== "object") {
|
|
118
|
+
return configValueToRequiredVersionMap.get(configValue);
|
|
119
|
+
}
|
|
120
|
+
// When the input `configValue` is an object, this logic determines the minimum runtime version it requires.
|
|
121
|
+
// It iterates through each entry in `configValueToRequiredVersionMap`. If `possibleConfigValue` shares at
|
|
122
|
+
// least one key-value pair with the input `configValue`, its associated `versionRequired` is collected into
|
|
123
|
+
// `matchingVersions`. After checking all entries, the highest among the collected versions is returned.
|
|
124
|
+
// This represents the overall minimum version required to support the features implied by the input `configValue`.
|
|
125
|
+
const matchingVersions = [];
|
|
126
|
+
for (const [possibleConfigValue, versionRequired,] of configValueToRequiredVersionMap.entries()) {
|
|
127
|
+
(0, internal_1.assert)(typeof possibleConfigValue == "object", 0xbb9 /* possibleConfigValue should be an object */);
|
|
128
|
+
// Check if `possibleConfigValue` and the input `configValue` share at least one
|
|
129
|
+
// common key-value pair. If they do, the `versionRequired` for this `possibleConfigValue`
|
|
130
|
+
// is added to `matchingVersions`.
|
|
131
|
+
if (Object.entries(possibleConfigValue).some(([k, v]) => configValue[k] === v)) {
|
|
132
|
+
matchingVersions.push(versionRequired);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (matchingVersions.length > 0) {
|
|
136
|
+
// Return the latest minVersionForCollab among all matches.
|
|
137
|
+
return matchingVersions.sort((a, b) => (0, semver_ts_1.compare)(b, a))[0];
|
|
138
|
+
}
|
|
139
|
+
// If no matches then we return undefined. This means that the config value passed in
|
|
140
|
+
// does not require a specific minVersionForCollab to be valid.
|
|
141
|
+
return undefined;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
exports.configValueToMinVersionForCollab = configValueToMinVersionForCollab;
|
|
145
|
+
//# sourceMappingURL=compatibilityBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibilityBase.js","sourceRoot":"","sources":["../src/compatibilityBase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,uEAAsE;AACtE,yCAAyD;AAEzD,2DAAiD;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACU,QAAA,0BAA0B,GACtC,gBAA2D,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,yBAAyB,GAAG,OAAkD,CAAC;AA2CrF;;;;GAIG;AACH,SAAgB,gCAAgC,CAC/C,mBAAoC,EACpC,SAAuB;IAEvB,MAAM,cAAc,GAAe,EAAE,CAAC;IACtC,gEAAgE;IAChE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,SAAS,CAAC,GAAc,CAAC,CAAC;QACzC,yEAAyE;QACzE,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,mBAAO,CAAC,CAAC;QACnD,sHAAsH;QACtH,sHAAsH;QACtH,kFAAkF;QAClF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAChC,IAAI,IAAA,eAAG,EAAC,mBAAmB,EAAE,OAAO,CAAC,EAAE,CAAC;gBACvC,cAAc,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,OAAsC,CAAC,CAAC;YACtE,CAAC;iBAAM,CAAC;gBACP,6GAA6G;gBAC7G,sBAAsB;gBACtB,MAAM;YACP,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,cAAc,CAAC;AACvB,CAAC;AAxBD,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AClG,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACrC,OAAO,+BAA+B,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzD,CAAC;QACD,4GAA4G;QAC5G,0GAA0G;QAC1G,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 } 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 } from \"semver-ts\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Our policy is to support N/N-1 compatibility by default, where N is the most\n * recent public major release of the runtime.\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 */\nconst 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 * Generic type for runtimeOptionsAffectingDocSchemaConfigMap\n *\n * @internal\n */\nexport type ConfigMap<T extends Record<string, unknown>> = {\n\t[K in keyof T]-?: {\n\t\t[version: MinimumMinorSemanticVersion]: T[K];\n\t};\n};\n\n/**\n * Generic type for runtimeOptionsAffectingDocSchemaConfigValidationMap\n *\n * @internal\n */\nexport type ConfigValidationMap<T extends Record<string, unknown>> = {\n\t[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 * @internal\n */\nexport function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(\n\tminVersionForCollab: SemanticVersion,\n\tconfigMap: ConfigMap<T>,\n): Partial<T> {\n\tconst defaultConfigs: Partial<T> = {};\n\t// Iterate over configMap to get default values for each option.\n\tfor (const key of Object.keys(configMap)) {\n\t\tconst config = configMap[key as keyof T];\n\t\t// Sort the versions in ascending order so we can short circuit the loop.\n\t\tconst versions = Object.keys(config).sort(compare);\n\t\t// For each config, we iterate over the keys and check if minVersionForCollab is greater than or equal to the version.\n\t\t// If so, we set it as the default value for the option. At the end of the loop we should have the most recent default\n\t\t// value that is compatible with the version specified as the minVersionForCollab.\n\t\tfor (const version of versions) {\n\t\t\tif (gte(minVersionForCollab, version)) {\n\t\t\t\tdefaultConfigs[key] = config[version as MinimumMinorSemanticVersion];\n\t\t\t} else {\n\t\t\t\t// If the minVersionForCollab is less than the version, we break out of the loop since we don't need to check\n\t\t\t\t// any later versions.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn defaultConfigs;\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: MinimumVersionForCollab,\n): boolean {\n\treturn (\n\t\tvalid(minVersionForCollab) !== null &&\n\t\tgte(minVersionForCollab, lowestMinVersionForCollab) &&\n\t\tlte(minVersionForCollab, pkgVersion)\n\t);\n}\n\n/**\n * Generic function to validate runtime options against the minVersionForCollab.\n *\n * @internal\n */\nexport function getValidationForRuntimeOptions<T extends Record<string, unknown>>(\n\tminVersionForCollab: SemanticVersion,\n\truntimeOptions: 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\treturn;\n\t}\n\t// Iterate through each runtime option passed in by the user\n\tfor (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(\n\t\truntimeOptions,\n\t) as [keyof T & string, T[keyof T & string]][]) {\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/index.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ export { unpackChildNodesUsedRoutes } from "./unpackUsedRoutes.js";
|
|
|
15
15
|
export { ReadAndParseBlob, RuntimeHeaders, seqFromTree, encodeCompactIdToString, } from "./utils.js";
|
|
16
16
|
export { isSnapshotFetchRequiredForLoadingGroupId } from "./snapshotUtils.js";
|
|
17
17
|
export { toDeltaManagerErased, toDeltaManagerInternal, } from "./deltaManager.js";
|
|
18
|
+
export { ConfigMap, configValueToMinVersionForCollab, ConfigValidationMap, defaultMinVersionForCollab, getValidationForRuntimeOptions, getConfigsForMinVersionForCollab, isValidMinVersionForCollab, MinimumMinorSemanticVersion, SemanticVersion, } from "./compatibilityBase.js";
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,mBAAmB,EACnB,4BAA4B,EAC5B,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,mCAAmC,EACnC,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACN,mCAAmC,EACnC,mBAAmB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACN,gBAAgB,EAChB,2BAA2B,EAC3B,cAAc,EACd,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,EACpB,6BAA6B,EAC7B,aAAa,EACb,WAAW,EACX,UAAU,EACV,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EACN,gBAAgB,EAChB,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AAY,CAAC;AACpB,OAAO,EAAE,wCAAwC,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EACN,oBAAoB,EACpB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,SAAS,EACT,gCAAgC,EAChC,mBAAmB,EACnB,0BAA0B,EAC1B,8BAA8B,EAC9B,gCAAgC,EAChC,0BAA0B,EAC1B,2BAA2B,EAC3B,eAAe,GACf,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.toDeltaManagerInternal = exports.toDeltaManagerErased = exports.isSnapshotFetchRequiredForLoadingGroupId = exports.encodeCompactIdToString = exports.seqFromTree = exports.RuntimeHeaders = exports.unpackChildNodesUsedRoutes = exports.utf8ByteLength = exports.TelemetryContext = exports.SummaryTreeBuilder = exports.processAttachMessageGCData = exports.mergeStats = exports.getBlobSize = exports.GCDataBuilder = exports.convertToSummaryTreeWithStats = exports.convertToSummaryTree = exports.convertSummaryTreeToITree = exports.convertSnapshotTreeToSummaryTree = exports.calculateStats = exports.addSummarizeResultToSummary = exports.addBlobToSummary = exports.RuntimeFactoryHelper = exports.RequestParser = exports.RemoteFluidObjectHandle = exports.listBlobsAtTreePath = exports.getNormalizedObjectStoragePathParts = exports.ObjectStoragePartition = exports.toFluidHandleInternal = exports.toFluidHandleErased = exports.isSerializedHandle = exports.isLocalFluidHandle = exports.isFluidHandlePayloadPending = exports.isFluidHandleInternalPayloadPending = exports.isFluidHandle = exports.FluidHandleBase = exports.encodeHandleForSerialization = exports.compareFluidHandles = exports.responseToException = exports.exceptionToResponse = exports.createResponseError = exports.create404Response = exports.generateHandleContextPath = void 0;
|
|
7
|
+
exports.isValidMinVersionForCollab = exports.getConfigsForMinVersionForCollab = exports.getValidationForRuntimeOptions = exports.defaultMinVersionForCollab = exports.configValueToMinVersionForCollab = exports.toDeltaManagerInternal = exports.toDeltaManagerErased = exports.isSnapshotFetchRequiredForLoadingGroupId = exports.encodeCompactIdToString = exports.seqFromTree = exports.RuntimeHeaders = exports.unpackChildNodesUsedRoutes = exports.utf8ByteLength = exports.TelemetryContext = exports.SummaryTreeBuilder = exports.processAttachMessageGCData = exports.mergeStats = exports.getBlobSize = exports.GCDataBuilder = exports.convertToSummaryTreeWithStats = exports.convertToSummaryTree = exports.convertSummaryTreeToITree = exports.convertSnapshotTreeToSummaryTree = exports.calculateStats = exports.addSummarizeResultToSummary = exports.addBlobToSummary = exports.RuntimeFactoryHelper = exports.RequestParser = exports.RemoteFluidObjectHandle = exports.listBlobsAtTreePath = exports.getNormalizedObjectStoragePathParts = exports.ObjectStoragePartition = exports.toFluidHandleInternal = exports.toFluidHandleErased = exports.isSerializedHandle = exports.isLocalFluidHandle = exports.isFluidHandlePayloadPending = exports.isFluidHandleInternalPayloadPending = exports.isFluidHandle = exports.FluidHandleBase = exports.encodeHandleForSerialization = exports.compareFluidHandles = exports.responseToException = exports.exceptionToResponse = exports.createResponseError = exports.create404Response = exports.generateHandleContextPath = void 0;
|
|
8
8
|
var dataStoreHandleContextUtils_js_1 = require("./dataStoreHandleContextUtils.js");
|
|
9
9
|
Object.defineProperty(exports, "generateHandleContextPath", { enumerable: true, get: function () { return dataStoreHandleContextUtils_js_1.generateHandleContextPath; } });
|
|
10
10
|
var dataStoreHelpers_js_1 = require("./dataStoreHelpers.js");
|
|
@@ -60,4 +60,10 @@ Object.defineProperty(exports, "isSnapshotFetchRequiredForLoadingGroupId", { enu
|
|
|
60
60
|
var deltaManager_js_1 = require("./deltaManager.js");
|
|
61
61
|
Object.defineProperty(exports, "toDeltaManagerErased", { enumerable: true, get: function () { return deltaManager_js_1.toDeltaManagerErased; } });
|
|
62
62
|
Object.defineProperty(exports, "toDeltaManagerInternal", { enumerable: true, get: function () { return deltaManager_js_1.toDeltaManagerInternal; } });
|
|
63
|
+
var compatibilityBase_js_1 = require("./compatibilityBase.js");
|
|
64
|
+
Object.defineProperty(exports, "configValueToMinVersionForCollab", { enumerable: true, get: function () { return compatibilityBase_js_1.configValueToMinVersionForCollab; } });
|
|
65
|
+
Object.defineProperty(exports, "defaultMinVersionForCollab", { enumerable: true, get: function () { return compatibilityBase_js_1.defaultMinVersionForCollab; } });
|
|
66
|
+
Object.defineProperty(exports, "getValidationForRuntimeOptions", { enumerable: true, get: function () { return compatibilityBase_js_1.getValidationForRuntimeOptions; } });
|
|
67
|
+
Object.defineProperty(exports, "getConfigsForMinVersionForCollab", { enumerable: true, get: function () { return compatibilityBase_js_1.getConfigsForMinVersionForCollab; } });
|
|
68
|
+
Object.defineProperty(exports, "isValidMinVersionForCollab", { enumerable: true, get: function () { return compatibilityBase_js_1.isValidMinVersionForCollab; } });
|
|
63
69
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mFAA6E;AAApE,2IAAA,yBAAyB,OAAA;AAClC,6DAK+B;AAJ9B,wHAAA,iBAAiB,OAAA;AACjB,0HAAA,mBAAmB,OAAA;AACnB,0HAAA,mBAAmB,OAAA;AACnB,0HAAA,mBAAmB,OAAA;AAEpB,2CAYsB;AAXrB,iHAAA,mBAAmB,OAAA;AACnB,0HAAA,4BAA4B,OAAA;AAC5B,6GAAA,eAAe,OAAA;AAEf,2GAAA,aAAa,OAAA;AACb,iIAAA,mCAAmC,OAAA;AACnC,yHAAA,2BAA2B,OAAA;AAC3B,gHAAA,kBAAkB,OAAA;AAClB,gHAAA,kBAAkB,OAAA;AAClB,iHAAA,mBAAmB,OAAA;AACnB,mHAAA,qBAAqB,OAAA;AAEtB,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAC/B,iEAGiC;AAFhC,4IAAA,mCAAmC,OAAA;AACnC,4HAAA,mBAAmB,OAAA;AAEpB,2EAAuE;AAA9D,qIAAA,uBAAuB,OAAA;AAChC,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,qDAe2B;AAd1B,mHAAA,gBAAgB,OAAA;AAChB,8HAAA,2BAA2B,OAAA;AAC3B,iHAAA,cAAc,OAAA;AACd,mIAAA,gCAAgC,OAAA;AAChC,4HAAA,yBAAyB,OAAA;AACzB,uHAAA,oBAAoB,OAAA;AACpB,gIAAA,6BAA6B,OAAA;AAC7B,gHAAA,aAAa,OAAA;AACb,8GAAA,WAAW,OAAA;AACX,6GAAA,UAAU,OAAA;AACV,6HAAA,0BAA0B,OAAA;AAC1B,qHAAA,kBAAkB,OAAA;AAClB,mHAAA,gBAAgB,OAAA;AAChB,iHAAA,cAAc,OAAA;AAEf,6DAAmE;AAA1D,iIAAA,0BAA0B,OAAA;AACnC,uCAKoB;AAHnB,0GAAA,cAAc,OAAA;AACd,uGAAA,WAAW,OAAA;AACX,mHAAA,uBAAuB,OAAA;AAExB,uDAA8E;AAArE,4IAAA,wCAAwC,OAAA;AACjD,qDAG2B;AAF1B,uHAAA,oBAAoB,OAAA;AACpB,yHAAA,sBAAsB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { generateHandleContextPath } from \"./dataStoreHandleContextUtils.js\";\nexport {\n\tcreate404Response,\n\tcreateResponseError,\n\texceptionToResponse,\n\tresponseToException,\n} from \"./dataStoreHelpers.js\";\nexport {\n\tcompareFluidHandles,\n\tencodeHandleForSerialization,\n\tFluidHandleBase,\n\tISerializedHandle,\n\tisFluidHandle,\n\tisFluidHandleInternalPayloadPending,\n\tisFluidHandlePayloadPending,\n\tisLocalFluidHandle,\n\tisSerializedHandle,\n\ttoFluidHandleErased,\n\ttoFluidHandleInternal,\n} from \"./handles.js\";\nexport { ObjectStoragePartition } from \"./objectstoragepartition.js\";\nexport {\n\tgetNormalizedObjectStoragePathParts,\n\tlistBlobsAtTreePath,\n} from \"./objectstorageutils.js\";\nexport { RemoteFluidObjectHandle } from \"./remoteFluidObjectHandle.js\";\nexport { RequestParser } from \"./requestParser.js\";\nexport { RuntimeFactoryHelper } from \"./runtimeFactoryHelper.js\";\nexport {\n\taddBlobToSummary,\n\taddSummarizeResultToSummary,\n\tcalculateStats,\n\tconvertSnapshotTreeToSummaryTree,\n\tconvertSummaryTreeToITree,\n\tconvertToSummaryTree,\n\tconvertToSummaryTreeWithStats,\n\tGCDataBuilder,\n\tgetBlobSize,\n\tmergeStats,\n\tprocessAttachMessageGCData,\n\tSummaryTreeBuilder,\n\tTelemetryContext,\n\tutf8ByteLength,\n} from \"./summaryUtils.js\";\nexport { unpackChildNodesUsedRoutes } from \"./unpackUsedRoutes.js\";\nexport {\n\tReadAndParseBlob,\n\tRuntimeHeaders,\n\tseqFromTree,\n\tencodeCompactIdToString,\n} from \"./utils.js\";\nexport { isSnapshotFetchRequiredForLoadingGroupId } from \"./snapshotUtils.js\";\nexport {\n\ttoDeltaManagerErased,\n\ttoDeltaManagerInternal,\n} from \"./deltaManager.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mFAA6E;AAApE,2IAAA,yBAAyB,OAAA;AAClC,6DAK+B;AAJ9B,wHAAA,iBAAiB,OAAA;AACjB,0HAAA,mBAAmB,OAAA;AACnB,0HAAA,mBAAmB,OAAA;AACnB,0HAAA,mBAAmB,OAAA;AAEpB,2CAYsB;AAXrB,iHAAA,mBAAmB,OAAA;AACnB,0HAAA,4BAA4B,OAAA;AAC5B,6GAAA,eAAe,OAAA;AAEf,2GAAA,aAAa,OAAA;AACb,iIAAA,mCAAmC,OAAA;AACnC,yHAAA,2BAA2B,OAAA;AAC3B,gHAAA,kBAAkB,OAAA;AAClB,gHAAA,kBAAkB,OAAA;AAClB,iHAAA,mBAAmB,OAAA;AACnB,mHAAA,qBAAqB,OAAA;AAEtB,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAC/B,iEAGiC;AAFhC,4IAAA,mCAAmC,OAAA;AACnC,4HAAA,mBAAmB,OAAA;AAEpB,2EAAuE;AAA9D,qIAAA,uBAAuB,OAAA;AAChC,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,qDAe2B;AAd1B,mHAAA,gBAAgB,OAAA;AAChB,8HAAA,2BAA2B,OAAA;AAC3B,iHAAA,cAAc,OAAA;AACd,mIAAA,gCAAgC,OAAA;AAChC,4HAAA,yBAAyB,OAAA;AACzB,uHAAA,oBAAoB,OAAA;AACpB,gIAAA,6BAA6B,OAAA;AAC7B,gHAAA,aAAa,OAAA;AACb,8GAAA,WAAW,OAAA;AACX,6GAAA,UAAU,OAAA;AACV,6HAAA,0BAA0B,OAAA;AAC1B,qHAAA,kBAAkB,OAAA;AAClB,mHAAA,gBAAgB,OAAA;AAChB,iHAAA,cAAc,OAAA;AAEf,6DAAmE;AAA1D,iIAAA,0BAA0B,OAAA;AACnC,uCAKoB;AAHnB,0GAAA,cAAc,OAAA;AACd,uGAAA,WAAW,OAAA;AACX,mHAAA,uBAAuB,OAAA;AAExB,uDAA8E;AAArE,4IAAA,wCAAwC,OAAA;AACjD,qDAG2B;AAF1B,uHAAA,oBAAoB,OAAA;AACpB,yHAAA,sBAAsB,OAAA;AAEvB,+DAUgC;AAR/B,wIAAA,gCAAgC,OAAA;AAEhC,kIAAA,0BAA0B,OAAA;AAC1B,sIAAA,8BAA8B,OAAA;AAC9B,wIAAA,gCAAgC,OAAA;AAChC,kIAAA,0BAA0B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { generateHandleContextPath } from \"./dataStoreHandleContextUtils.js\";\nexport {\n\tcreate404Response,\n\tcreateResponseError,\n\texceptionToResponse,\n\tresponseToException,\n} from \"./dataStoreHelpers.js\";\nexport {\n\tcompareFluidHandles,\n\tencodeHandleForSerialization,\n\tFluidHandleBase,\n\tISerializedHandle,\n\tisFluidHandle,\n\tisFluidHandleInternalPayloadPending,\n\tisFluidHandlePayloadPending,\n\tisLocalFluidHandle,\n\tisSerializedHandle,\n\ttoFluidHandleErased,\n\ttoFluidHandleInternal,\n} from \"./handles.js\";\nexport { ObjectStoragePartition } from \"./objectstoragepartition.js\";\nexport {\n\tgetNormalizedObjectStoragePathParts,\n\tlistBlobsAtTreePath,\n} from \"./objectstorageutils.js\";\nexport { RemoteFluidObjectHandle } from \"./remoteFluidObjectHandle.js\";\nexport { RequestParser } from \"./requestParser.js\";\nexport { RuntimeFactoryHelper } from \"./runtimeFactoryHelper.js\";\nexport {\n\taddBlobToSummary,\n\taddSummarizeResultToSummary,\n\tcalculateStats,\n\tconvertSnapshotTreeToSummaryTree,\n\tconvertSummaryTreeToITree,\n\tconvertToSummaryTree,\n\tconvertToSummaryTreeWithStats,\n\tGCDataBuilder,\n\tgetBlobSize,\n\tmergeStats,\n\tprocessAttachMessageGCData,\n\tSummaryTreeBuilder,\n\tTelemetryContext,\n\tutf8ByteLength,\n} from \"./summaryUtils.js\";\nexport { unpackChildNodesUsedRoutes } from \"./unpackUsedRoutes.js\";\nexport {\n\tReadAndParseBlob,\n\tRuntimeHeaders,\n\tseqFromTree,\n\tencodeCompactIdToString,\n} from \"./utils.js\";\nexport { isSnapshotFetchRequiredForLoadingGroupId } from \"./snapshotUtils.js\";\nexport {\n\ttoDeltaManagerErased,\n\ttoDeltaManagerInternal,\n} from \"./deltaManager.js\";\nexport {\n\tConfigMap,\n\tconfigValueToMinVersionForCollab,\n\tConfigValidationMap,\n\tdefaultMinVersionForCollab,\n\tgetValidationForRuntimeOptions,\n\tgetConfigsForMinVersionForCollab,\n\tisValidMinVersionForCollab,\n\tMinimumMinorSemanticVersion,\n\tSemanticVersion,\n} from \"./compatibilityBase.js\";\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
export declare const pkgName = "@fluidframework/runtime-utils";
|
|
8
|
+
export declare const pkgVersion = "2.53.0-350190";
|
|
9
|
+
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*
|
|
6
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
|
+
exports.pkgName = "@fluidframework/runtime-utils";
|
|
11
|
+
exports.pkgVersion = "2.53.0-350190";
|
|
12
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +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,eAAe,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.53.0-350190\";\n"]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
|
|
6
|
+
/**
|
|
7
|
+
* Our policy is to support N/N-1 compatibility by default, where N is the most
|
|
8
|
+
* recent public major release of the runtime.
|
|
9
|
+
* Therefore, if the customer does not provide a minVersionForCollab, we will
|
|
10
|
+
* default to use N-1.
|
|
11
|
+
*
|
|
12
|
+
* However, this is not consistent with today's behavior. Some options (i.e.
|
|
13
|
+
* batching, compression) are enabled by default despite not being compatible
|
|
14
|
+
* with 1.x clients. Since the policy was introduced during 2.x's lifespan,
|
|
15
|
+
* N/N-1 compatibility by **default** will be in effect starting with 3.0.
|
|
16
|
+
* Importantly though, N/N-2 compatibility is still guaranteed with the proper
|
|
17
|
+
* configurations set.
|
|
18
|
+
*
|
|
19
|
+
* Further to distinguish unspecified `minVersionForCollab` from a specified
|
|
20
|
+
* version and allow `enableExplicitSchemaControl` to default to `true` for
|
|
21
|
+
* any 2.0.0+ version, we will use a special value of `2.0.0-defaults`, which
|
|
22
|
+
* is semantically less than 2.0.0.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare const defaultMinVersionForCollab: "2.0.0-defaults";
|
|
27
|
+
/**
|
|
28
|
+
* String in a valid semver format specifying bottom of a minor version
|
|
29
|
+
* or special "defaults" prerelease of a major.
|
|
30
|
+
* @remarks Only 2.0.0-defaults is expected, but index signatures cannot be a
|
|
31
|
+
* literal; so, just allow any major -defaults prerelease.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export type MinimumMinorSemanticVersion = `${bigint}.${bigint}.0` | `${bigint}.0.0-defaults`;
|
|
36
|
+
/**
|
|
37
|
+
* String in a valid semver format of a specific version at least specifying minor.
|
|
38
|
+
* Unlike {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}, this type allows any bigint for the major version.
|
|
39
|
+
* Used as a more generic type that allows major versions other than 1 or 2.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export type SemanticVersion = `${bigint}.${bigint}.${bigint}` | `${bigint}.${bigint}.${bigint}-${string}`;
|
|
44
|
+
/**
|
|
45
|
+
* Generic type for runtimeOptionsAffectingDocSchemaConfigMap
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export type ConfigMap<T extends Record<string, unknown>> = {
|
|
50
|
+
[K in keyof T]-?: {
|
|
51
|
+
[version: MinimumMinorSemanticVersion]: T[K];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Generic type for runtimeOptionsAffectingDocSchemaConfigValidationMap
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
export type ConfigValidationMap<T extends Record<string, unknown>> = {
|
|
60
|
+
[K in keyof T]-?: (configValue: T[K]) => SemanticVersion | undefined;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Returns a default configuration given minVersionForCollab and configuration version map.
|
|
64
|
+
*
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
export declare function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(minVersionForCollab: SemanticVersion, configMap: ConfigMap<T>): Partial<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Checks if the minVersionForCollab is valid.
|
|
70
|
+
* A valid minVersionForCollab is a MinimumVersionForCollab that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
71
|
+
*
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
export declare function isValidMinVersionForCollab(minVersionForCollab: MinimumVersionForCollab): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Generic function to validate runtime options against the minVersionForCollab.
|
|
77
|
+
*
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
export declare function getValidationForRuntimeOptions<T extends Record<string, unknown>>(minVersionForCollab: SemanticVersion, runtimeOptions: Partial<T>, validationMap: ConfigValidationMap<T>): void;
|
|
81
|
+
/**
|
|
82
|
+
* Helper function to map ContainerRuntimeOptionsInternal config values to
|
|
83
|
+
* minVersionForCollab in, e.g., {@link @fluidframework/container-runtime#runtimeOptionsAffectingDocSchemaConfigValidationMap}.
|
|
84
|
+
*
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
export declare function configValueToMinVersionForCollab<T extends string | number | boolean | undefined | object, Arr extends readonly [T, SemanticVersion][]>(configToMinVer: Arr): (configValue: T) => SemanticVersion | undefined;
|
|
88
|
+
//# sourceMappingURL=compatibilityBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibilityBase.d.ts","sourceRoot":"","sources":["../src/compatibilityBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAM5F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,0BAA0B,kBACqB,CAAC;AAU7D;;;;;;;GAOG;AACH,MAAM,MAAM,2BAA2B,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,GAAG,GAAG,MAAM,eAAe,CAAC;AAE7F;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GACxB,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,GAC/B,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;AAE7C;;;;GA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0 +1,138 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
|
+
import { compare, gt, gte, lte, valid } from "semver-ts";
|
|
8
|
+
import { pkgVersion } from "./packageVersion.js";
|
|
9
|
+
/**
|
|
10
|
+
* Our policy is to support N/N-1 compatibility by default, where N is the most
|
|
11
|
+
* recent public major release of the runtime.
|
|
12
|
+
* Therefore, if the customer does not provide a minVersionForCollab, we will
|
|
13
|
+
* default to use N-1.
|
|
14
|
+
*
|
|
15
|
+
* However, this is not consistent with today's behavior. Some options (i.e.
|
|
16
|
+
* batching, compression) are enabled by default despite not being compatible
|
|
17
|
+
* with 1.x clients. Since the policy was introduced during 2.x's lifespan,
|
|
18
|
+
* N/N-1 compatibility by **default** will be in effect starting with 3.0.
|
|
19
|
+
* Importantly though, N/N-2 compatibility is still guaranteed with the proper
|
|
20
|
+
* configurations set.
|
|
21
|
+
*
|
|
22
|
+
* Further to distinguish unspecified `minVersionForCollab` from a specified
|
|
23
|
+
* version and allow `enableExplicitSchemaControl` to default to `true` for
|
|
24
|
+
* any 2.0.0+ version, we will use a special value of `2.0.0-defaults`, which
|
|
25
|
+
* is semantically less than 2.0.0.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export const defaultMinVersionForCollab = "2.0.0-defaults";
|
|
30
|
+
/**
|
|
31
|
+
* We don't want allow a version before the major public release of the LTS version.
|
|
32
|
+
* Today we use "1.0.0", because our policy supports N/N-1 & N/N-2, which includes
|
|
33
|
+
* all minor versions of N. Though LTS starts at 1.4.0, we should stay consistent
|
|
34
|
+
* with our policy and allow all 1.x versions to be compatible with 2.x.
|
|
35
|
+
*/
|
|
36
|
+
const lowestMinVersionForCollab = "1.0.0";
|
|
37
|
+
/**
|
|
38
|
+
* Returns a default configuration given minVersionForCollab and configuration version map.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export function getConfigsForMinVersionForCollab(minVersionForCollab, configMap) {
|
|
43
|
+
const defaultConfigs = {};
|
|
44
|
+
// Iterate over configMap to get default values for each option.
|
|
45
|
+
for (const key of Object.keys(configMap)) {
|
|
46
|
+
const config = configMap[key];
|
|
47
|
+
// Sort the versions in ascending order so we can short circuit the loop.
|
|
48
|
+
const versions = Object.keys(config).sort(compare);
|
|
49
|
+
// For each config, we iterate over the keys and check if minVersionForCollab is greater than or equal to the version.
|
|
50
|
+
// If so, we set it as the default value for the option. At the end of the loop we should have the most recent default
|
|
51
|
+
// value that is compatible with the version specified as the minVersionForCollab.
|
|
52
|
+
for (const version of versions) {
|
|
53
|
+
if (gte(minVersionForCollab, version)) {
|
|
54
|
+
defaultConfigs[key] = config[version];
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// If the minVersionForCollab is less than the version, we break out of the loop since we don't need to check
|
|
58
|
+
// any later versions.
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return defaultConfigs;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Checks if the minVersionForCollab is valid.
|
|
67
|
+
* A valid minVersionForCollab is a MinimumVersionForCollab that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export function isValidMinVersionForCollab(minVersionForCollab) {
|
|
72
|
+
return (valid(minVersionForCollab) !== null &&
|
|
73
|
+
gte(minVersionForCollab, lowestMinVersionForCollab) &&
|
|
74
|
+
lte(minVersionForCollab, pkgVersion));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Generic function to validate runtime options against the minVersionForCollab.
|
|
78
|
+
*
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
export function getValidationForRuntimeOptions(minVersionForCollab, runtimeOptions, validationMap) {
|
|
82
|
+
if (minVersionForCollab === defaultMinVersionForCollab) {
|
|
83
|
+
// If the minVersionForCollab is set to the default value, then we will not validate the runtime options
|
|
84
|
+
// This is to avoid disruption to users who have not yet set the minVersionForCollab value explicitly.
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// Iterate through each runtime option passed in by the user
|
|
88
|
+
for (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(runtimeOptions)) {
|
|
89
|
+
// Skip if passedRuntimeOption is not in validation map
|
|
90
|
+
if (!(passedRuntimeOption in validationMap)) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const requiredVersion = validationMap[passedRuntimeOption](passedRuntimeOptionValue);
|
|
94
|
+
if (requiredVersion !== undefined && gt(requiredVersion, minVersionForCollab)) {
|
|
95
|
+
throw new UsageError(`Runtime option ${passedRuntimeOption}:${JSON.stringify(passedRuntimeOptionValue)} requires ` +
|
|
96
|
+
`runtime version ${requiredVersion}. Please update minVersionForCollab ` +
|
|
97
|
+
`(currently ${minVersionForCollab}) to ${requiredVersion} or later to proceed.`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Helper function to map ContainerRuntimeOptionsInternal config values to
|
|
103
|
+
* minVersionForCollab in, e.g., {@link @fluidframework/container-runtime#runtimeOptionsAffectingDocSchemaConfigValidationMap}.
|
|
104
|
+
*
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
export function configValueToMinVersionForCollab(configToMinVer) {
|
|
108
|
+
const configValueToRequiredVersionMap = new Map(configToMinVer);
|
|
109
|
+
return (configValue) => {
|
|
110
|
+
// If the configValue is not an object then we can get the version required directly from the map.
|
|
111
|
+
if (typeof configValue !== "object") {
|
|
112
|
+
return configValueToRequiredVersionMap.get(configValue);
|
|
113
|
+
}
|
|
114
|
+
// When the input `configValue` is an object, this logic determines the minimum runtime version it requires.
|
|
115
|
+
// It iterates through each entry in `configValueToRequiredVersionMap`. If `possibleConfigValue` shares at
|
|
116
|
+
// least one key-value pair with the input `configValue`, its associated `versionRequired` is collected into
|
|
117
|
+
// `matchingVersions`. After checking all entries, the highest among the collected versions is returned.
|
|
118
|
+
// This represents the overall minimum version required to support the features implied by the input `configValue`.
|
|
119
|
+
const matchingVersions = [];
|
|
120
|
+
for (const [possibleConfigValue, versionRequired,] of configValueToRequiredVersionMap.entries()) {
|
|
121
|
+
assert(typeof possibleConfigValue == "object", 0xbb9 /* possibleConfigValue should be an object */);
|
|
122
|
+
// Check if `possibleConfigValue` and the input `configValue` share at least one
|
|
123
|
+
// common key-value pair. If they do, the `versionRequired` for this `possibleConfigValue`
|
|
124
|
+
// is added to `matchingVersions`.
|
|
125
|
+
if (Object.entries(possibleConfigValue).some(([k, v]) => configValue[k] === v)) {
|
|
126
|
+
matchingVersions.push(versionRequired);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (matchingVersions.length > 0) {
|
|
130
|
+
// Return the latest minVersionForCollab among all matches.
|
|
131
|
+
return matchingVersions.sort((a, b) => compare(b, a))[0];
|
|
132
|
+
}
|
|
133
|
+
// If no matches then we return undefined. This means that the config value passed in
|
|
134
|
+
// does not require a specific minVersionForCollab to be valid.
|
|
135
|
+
return undefined;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=compatibilityBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibilityBase.js","sourceRoot":"","sources":["../src/compatibilityBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,M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ACL,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 } 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 } from \"semver-ts\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Our policy is to support N/N-1 compatibility by default, where N is the most\n * recent public major release of the runtime.\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 */\nconst 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 * Generic type for runtimeOptionsAffectingDocSchemaConfigMap\n *\n * @internal\n */\nexport type ConfigMap<T extends Record<string, unknown>> = {\n\t[K in keyof T]-?: {\n\t\t[version: MinimumMinorSemanticVersion]: T[K];\n\t};\n};\n\n/**\n * Generic type for runtimeOptionsAffectingDocSchemaConfigValidationMap\n *\n * @internal\n */\nexport type ConfigValidationMap<T extends Record<string, unknown>> = {\n\t[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 * @internal\n */\nexport function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(\n\tminVersionForCollab: SemanticVersion,\n\tconfigMap: ConfigMap<T>,\n): Partial<T> {\n\tconst defaultConfigs: Partial<T> = {};\n\t// Iterate over configMap to get default values for each option.\n\tfor (const key of Object.keys(configMap)) {\n\t\tconst config = configMap[key as keyof T];\n\t\t// Sort the versions in ascending order so we can short circuit the loop.\n\t\tconst versions = Object.keys(config).sort(compare);\n\t\t// For each config, we iterate over the keys and check if minVersionForCollab is greater than or equal to the version.\n\t\t// If so, we set it as the default value for the option. At the end of the loop we should have the most recent default\n\t\t// value that is compatible with the version specified as the minVersionForCollab.\n\t\tfor (const version of versions) {\n\t\t\tif (gte(minVersionForCollab, version)) {\n\t\t\t\tdefaultConfigs[key] = config[version as MinimumMinorSemanticVersion];\n\t\t\t} else {\n\t\t\t\t// If the minVersionForCollab is less than the version, we break out of the loop since we don't need to check\n\t\t\t\t// any later versions.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn defaultConfigs;\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: MinimumVersionForCollab,\n): boolean {\n\treturn (\n\t\tvalid(minVersionForCollab) !== null &&\n\t\tgte(minVersionForCollab, lowestMinVersionForCollab) &&\n\t\tlte(minVersionForCollab, pkgVersion)\n\t);\n}\n\n/**\n * Generic function to validate runtime options against the minVersionForCollab.\n *\n * @internal\n */\nexport function getValidationForRuntimeOptions<T extends Record<string, unknown>>(\n\tminVersionForCollab: SemanticVersion,\n\truntimeOptions: 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\treturn;\n\t}\n\t// Iterate through each runtime option passed in by the user\n\tfor (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(\n\t\truntimeOptions,\n\t) as [keyof T & string, T[keyof T & string]][]) {\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/index.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ export { unpackChildNodesUsedRoutes } from "./unpackUsedRoutes.js";
|
|
|
15
15
|
export { ReadAndParseBlob, RuntimeHeaders, seqFromTree, encodeCompactIdToString, } from "./utils.js";
|
|
16
16
|
export { isSnapshotFetchRequiredForLoadingGroupId } from "./snapshotUtils.js";
|
|
17
17
|
export { toDeltaManagerErased, toDeltaManagerInternal, } from "./deltaManager.js";
|
|
18
|
+
export { ConfigMap, configValueToMinVersionForCollab, ConfigValidationMap, defaultMinVersionForCollab, getValidationForRuntimeOptions, getConfigsForMinVersionForCollab, isValidMinVersionForCollab, MinimumMinorSemanticVersion, SemanticVersion, } from "./compatibilityBase.js";
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,O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packUsedRoutes.js";
|
|
|
15
15
|
export { RuntimeHeaders, seqFromTree, encodeCompactIdToString, } from "./utils.js";
|
|
16
16
|
export { isSnapshotFetchRequiredForLoadingGroupId } from "./snapshotUtils.js";
|
|
17
17
|
export { toDeltaManagerErased, toDeltaManagerInternal, } from "./deltaManager.js";
|
|
18
|
+
export { configValueToMinVersionForCollab, defaultMinVersionForCollab, getValidationForRuntimeOptions, getConfigsForMinVersionForCollab, isValidMinVersionForCollab, } from "./compatibilityBase.js";
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,mBAAmB,EACnB,4BAA4B,EAC5B,eAAe,EAEf,aAAa,EACb,mCAAmC,EACnC,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACN,mCAAmC,EACnC,mBAAmB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACN,gBAAgB,EAChB,2BAA2B,EAC3B,cAAc,EACd,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,EACpB,6BAA6B,EAC7B,aAAa,EACb,WAAW,EACX,UAAU,EACV,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAEN,cAAc,EACd,WAAW,EACX,uBAAuB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,wCAAwC,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EACN,oBAAoB,EACpB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { generateHandleContextPath } from \"./dataStoreHandleContextUtils.js\";\nexport {\n\tcreate404Response,\n\tcreateResponseError,\n\texceptionToResponse,\n\tresponseToException,\n} from \"./dataStoreHelpers.js\";\nexport {\n\tcompareFluidHandles,\n\tencodeHandleForSerialization,\n\tFluidHandleBase,\n\tISerializedHandle,\n\tisFluidHandle,\n\tisFluidHandleInternalPayloadPending,\n\tisFluidHandlePayloadPending,\n\tisLocalFluidHandle,\n\tisSerializedHandle,\n\ttoFluidHandleErased,\n\ttoFluidHandleInternal,\n} from \"./handles.js\";\nexport { ObjectStoragePartition } from \"./objectstoragepartition.js\";\nexport {\n\tgetNormalizedObjectStoragePathParts,\n\tlistBlobsAtTreePath,\n} from \"./objectstorageutils.js\";\nexport { RemoteFluidObjectHandle } from \"./remoteFluidObjectHandle.js\";\nexport { RequestParser } from \"./requestParser.js\";\nexport { RuntimeFactoryHelper } from \"./runtimeFactoryHelper.js\";\nexport {\n\taddBlobToSummary,\n\taddSummarizeResultToSummary,\n\tcalculateStats,\n\tconvertSnapshotTreeToSummaryTree,\n\tconvertSummaryTreeToITree,\n\tconvertToSummaryTree,\n\tconvertToSummaryTreeWithStats,\n\tGCDataBuilder,\n\tgetBlobSize,\n\tmergeStats,\n\tprocessAttachMessageGCData,\n\tSummaryTreeBuilder,\n\tTelemetryContext,\n\tutf8ByteLength,\n} from \"./summaryUtils.js\";\nexport { unpackChildNodesUsedRoutes } from \"./unpackUsedRoutes.js\";\nexport {\n\tReadAndParseBlob,\n\tRuntimeHeaders,\n\tseqFromTree,\n\tencodeCompactIdToString,\n} from \"./utils.js\";\nexport { isSnapshotFetchRequiredForLoadingGroupId } from \"./snapshotUtils.js\";\nexport {\n\ttoDeltaManagerErased,\n\ttoDeltaManagerInternal,\n} from \"./deltaManager.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,mBAAmB,EACnB,4BAA4B,EAC5B,eAAe,EAEf,aAAa,EACb,mCAAmC,EACnC,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACN,mCAAmC,EACnC,mBAAmB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACN,gBAAgB,EAChB,2BAA2B,EAC3B,cAAc,EACd,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,EACpB,6BAA6B,EAC7B,aAAa,EACb,WAAW,EACX,UAAU,EACV,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAEN,cAAc,EACd,WAAW,EACX,uBAAuB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,wCAAwC,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EACN,oBAAoB,EACpB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEN,gCAAgC,EAEhC,0BAA0B,EAC1B,8BAA8B,EAC9B,gCAAgC,EAChC,0BAA0B,GAG1B,MAAM,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { generateHandleContextPath } from \"./dataStoreHandleContextUtils.js\";\nexport {\n\tcreate404Response,\n\tcreateResponseError,\n\texceptionToResponse,\n\tresponseToException,\n} from \"./dataStoreHelpers.js\";\nexport {\n\tcompareFluidHandles,\n\tencodeHandleForSerialization,\n\tFluidHandleBase,\n\tISerializedHandle,\n\tisFluidHandle,\n\tisFluidHandleInternalPayloadPending,\n\tisFluidHandlePayloadPending,\n\tisLocalFluidHandle,\n\tisSerializedHandle,\n\ttoFluidHandleErased,\n\ttoFluidHandleInternal,\n} from \"./handles.js\";\nexport { ObjectStoragePartition } from \"./objectstoragepartition.js\";\nexport {\n\tgetNormalizedObjectStoragePathParts,\n\tlistBlobsAtTreePath,\n} from \"./objectstorageutils.js\";\nexport { RemoteFluidObjectHandle } from \"./remoteFluidObjectHandle.js\";\nexport { RequestParser } from \"./requestParser.js\";\nexport { RuntimeFactoryHelper } from \"./runtimeFactoryHelper.js\";\nexport {\n\taddBlobToSummary,\n\taddSummarizeResultToSummary,\n\tcalculateStats,\n\tconvertSnapshotTreeToSummaryTree,\n\tconvertSummaryTreeToITree,\n\tconvertToSummaryTree,\n\tconvertToSummaryTreeWithStats,\n\tGCDataBuilder,\n\tgetBlobSize,\n\tmergeStats,\n\tprocessAttachMessageGCData,\n\tSummaryTreeBuilder,\n\tTelemetryContext,\n\tutf8ByteLength,\n} from \"./summaryUtils.js\";\nexport { unpackChildNodesUsedRoutes } from \"./unpackUsedRoutes.js\";\nexport {\n\tReadAndParseBlob,\n\tRuntimeHeaders,\n\tseqFromTree,\n\tencodeCompactIdToString,\n} from \"./utils.js\";\nexport { isSnapshotFetchRequiredForLoadingGroupId } from \"./snapshotUtils.js\";\nexport {\n\ttoDeltaManagerErased,\n\ttoDeltaManagerInternal,\n} from \"./deltaManager.js\";\nexport {\n\tConfigMap,\n\tconfigValueToMinVersionForCollab,\n\tConfigValidationMap,\n\tdefaultMinVersionForCollab,\n\tgetValidationForRuntimeOptions,\n\tgetConfigsForMinVersionForCollab,\n\tisValidMinVersionForCollab,\n\tMinimumMinorSemanticVersion,\n\tSemanticVersion,\n} from \"./compatibilityBase.js\";\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
export declare const pkgName = "@fluidframework/runtime-utils";
|
|
8
|
+
export declare const pkgVersion = "2.53.0-350190";
|
|
9
|
+
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
export const pkgName = "@fluidframework/runtime-utils";
|
|
8
|
+
export const pkgVersion = "2.53.0-350190";
|
|
9
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +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,eAAe,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.53.0-350190\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/runtime-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.53.0-350190",
|
|
4
4
|
"description": "Collection of utility functions for Fluid Runtime",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,26 +69,27 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluid-internal/client-utils": "
|
|
73
|
-
"@fluidframework/container-definitions": "
|
|
74
|
-
"@fluidframework/container-runtime-definitions": "
|
|
75
|
-
"@fluidframework/core-interfaces": "
|
|
76
|
-
"@fluidframework/core-utils": "
|
|
77
|
-
"@fluidframework/datastore-definitions": "
|
|
78
|
-
"@fluidframework/driver-definitions": "
|
|
79
|
-
"@fluidframework/driver-utils": "
|
|
80
|
-
"@fluidframework/runtime-definitions": "
|
|
81
|
-
"@fluidframework/telemetry-utils": "
|
|
72
|
+
"@fluid-internal/client-utils": "2.53.0-350190",
|
|
73
|
+
"@fluidframework/container-definitions": "2.53.0-350190",
|
|
74
|
+
"@fluidframework/container-runtime-definitions": "2.53.0-350190",
|
|
75
|
+
"@fluidframework/core-interfaces": "2.53.0-350190",
|
|
76
|
+
"@fluidframework/core-utils": "2.53.0-350190",
|
|
77
|
+
"@fluidframework/datastore-definitions": "2.53.0-350190",
|
|
78
|
+
"@fluidframework/driver-definitions": "2.53.0-350190",
|
|
79
|
+
"@fluidframework/driver-utils": "2.53.0-350190",
|
|
80
|
+
"@fluidframework/runtime-definitions": "2.53.0-350190",
|
|
81
|
+
"@fluidframework/telemetry-utils": "2.53.0-350190",
|
|
82
|
+
"semver-ts": "^1.0.3"
|
|
82
83
|
},
|
|
83
84
|
"devDependencies": {
|
|
84
85
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
85
86
|
"@biomejs/biome": "~1.9.3",
|
|
86
|
-
"@fluid-internal/mocha-test-setup": "
|
|
87
|
-
"@fluid-tools/build-cli": "^0.
|
|
87
|
+
"@fluid-internal/mocha-test-setup": "2.53.0-350190",
|
|
88
|
+
"@fluid-tools/build-cli": "^0.57.0",
|
|
88
89
|
"@fluidframework/build-common": "^2.0.3",
|
|
89
|
-
"@fluidframework/build-tools": "^0.
|
|
90
|
+
"@fluidframework/build-tools": "^0.57.0",
|
|
90
91
|
"@fluidframework/eslint-config-fluid": "^5.7.4",
|
|
91
|
-
"@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.
|
|
92
|
+
"@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.52.0",
|
|
92
93
|
"@microsoft/api-extractor": "7.52.8",
|
|
93
94
|
"@types/mocha": "^10.0.10",
|
|
94
95
|
"@types/node": "^18.19.0",
|
|
@@ -121,6 +122,7 @@
|
|
|
121
122
|
"build:compile": "fluid-build . --task compile",
|
|
122
123
|
"build:docs": "api-extractor run --local",
|
|
123
124
|
"build:esnext": "tsc --project ./tsconfig.json",
|
|
125
|
+
"build:genver": "gen-version",
|
|
124
126
|
"build:test": "npm run build:test:esm && npm run build:test:cjs",
|
|
125
127
|
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
|
|
126
128
|
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
|
|
8
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
9
|
+
import { compare, gt, gte, lte, valid } from "semver-ts";
|
|
10
|
+
|
|
11
|
+
import { pkgVersion } from "./packageVersion.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Our policy is to support N/N-1 compatibility by default, where N is the most
|
|
15
|
+
* recent public major release of the runtime.
|
|
16
|
+
* Therefore, if the customer does not provide a minVersionForCollab, we will
|
|
17
|
+
* default to use N-1.
|
|
18
|
+
*
|
|
19
|
+
* However, this is not consistent with today's behavior. Some options (i.e.
|
|
20
|
+
* batching, compression) are enabled by default despite not being compatible
|
|
21
|
+
* with 1.x clients. Since the policy was introduced during 2.x's lifespan,
|
|
22
|
+
* N/N-1 compatibility by **default** will be in effect starting with 3.0.
|
|
23
|
+
* Importantly though, N/N-2 compatibility is still guaranteed with the proper
|
|
24
|
+
* configurations set.
|
|
25
|
+
*
|
|
26
|
+
* Further to distinguish unspecified `minVersionForCollab` from a specified
|
|
27
|
+
* version and allow `enableExplicitSchemaControl` to default to `true` for
|
|
28
|
+
* any 2.0.0+ version, we will use a special value of `2.0.0-defaults`, which
|
|
29
|
+
* is semantically less than 2.0.0.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export const defaultMinVersionForCollab =
|
|
34
|
+
"2.0.0-defaults" as const satisfies MinimumVersionForCollab;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* We don't want allow a version before the major public release of the LTS version.
|
|
38
|
+
* Today we use "1.0.0", because our policy supports N/N-1 & N/N-2, which includes
|
|
39
|
+
* all minor versions of N. Though LTS starts at 1.4.0, we should stay consistent
|
|
40
|
+
* with our policy and allow all 1.x versions to be compatible with 2.x.
|
|
41
|
+
*/
|
|
42
|
+
const lowestMinVersionForCollab = "1.0.0" as const satisfies MinimumVersionForCollab;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* String in a valid semver format specifying bottom of a minor version
|
|
46
|
+
* or special "defaults" prerelease of a major.
|
|
47
|
+
* @remarks Only 2.0.0-defaults is expected, but index signatures cannot be a
|
|
48
|
+
* literal; so, just allow any major -defaults prerelease.
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
export type MinimumMinorSemanticVersion = `${bigint}.${bigint}.0` | `${bigint}.0.0-defaults`;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* String in a valid semver format of a specific version at least specifying minor.
|
|
56
|
+
* Unlike {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}, this type allows any bigint for the major version.
|
|
57
|
+
* Used as a more generic type that allows major versions other than 1 or 2.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export type SemanticVersion =
|
|
62
|
+
| `${bigint}.${bigint}.${bigint}`
|
|
63
|
+
| `${bigint}.${bigint}.${bigint}-${string}`;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Generic type for runtimeOptionsAffectingDocSchemaConfigMap
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export type ConfigMap<T extends Record<string, unknown>> = {
|
|
71
|
+
[K in keyof T]-?: {
|
|
72
|
+
[version: MinimumMinorSemanticVersion]: T[K];
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Generic type for runtimeOptionsAffectingDocSchemaConfigValidationMap
|
|
78
|
+
*
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
export type ConfigValidationMap<T extends Record<string, unknown>> = {
|
|
82
|
+
[K in keyof T]-?: (configValue: T[K]) => SemanticVersion | undefined;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns a default configuration given minVersionForCollab and configuration version map.
|
|
87
|
+
*
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
export function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(
|
|
91
|
+
minVersionForCollab: SemanticVersion,
|
|
92
|
+
configMap: ConfigMap<T>,
|
|
93
|
+
): Partial<T> {
|
|
94
|
+
const defaultConfigs: Partial<T> = {};
|
|
95
|
+
// Iterate over configMap to get default values for each option.
|
|
96
|
+
for (const key of Object.keys(configMap)) {
|
|
97
|
+
const config = configMap[key as keyof T];
|
|
98
|
+
// Sort the versions in ascending order so we can short circuit the loop.
|
|
99
|
+
const versions = Object.keys(config).sort(compare);
|
|
100
|
+
// For each config, we iterate over the keys and check if minVersionForCollab is greater than or equal to the version.
|
|
101
|
+
// If so, we set it as the default value for the option. At the end of the loop we should have the most recent default
|
|
102
|
+
// value that is compatible with the version specified as the minVersionForCollab.
|
|
103
|
+
for (const version of versions) {
|
|
104
|
+
if (gte(minVersionForCollab, version)) {
|
|
105
|
+
defaultConfigs[key] = config[version as MinimumMinorSemanticVersion];
|
|
106
|
+
} else {
|
|
107
|
+
// If the minVersionForCollab is less than the version, we break out of the loop since we don't need to check
|
|
108
|
+
// any later versions.
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return defaultConfigs;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Checks if the minVersionForCollab is valid.
|
|
118
|
+
* A valid minVersionForCollab is a MinimumVersionForCollab that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
119
|
+
*
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
export function isValidMinVersionForCollab(
|
|
123
|
+
minVersionForCollab: MinimumVersionForCollab,
|
|
124
|
+
): boolean {
|
|
125
|
+
return (
|
|
126
|
+
valid(minVersionForCollab) !== null &&
|
|
127
|
+
gte(minVersionForCollab, lowestMinVersionForCollab) &&
|
|
128
|
+
lte(minVersionForCollab, pkgVersion)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Generic function to validate runtime options against the minVersionForCollab.
|
|
134
|
+
*
|
|
135
|
+
* @internal
|
|
136
|
+
*/
|
|
137
|
+
export function getValidationForRuntimeOptions<T extends Record<string, unknown>>(
|
|
138
|
+
minVersionForCollab: SemanticVersion,
|
|
139
|
+
runtimeOptions: Partial<T>,
|
|
140
|
+
validationMap: ConfigValidationMap<T>,
|
|
141
|
+
): void {
|
|
142
|
+
if (minVersionForCollab === defaultMinVersionForCollab) {
|
|
143
|
+
// If the minVersionForCollab is set to the default value, then we will not validate the runtime options
|
|
144
|
+
// This is to avoid disruption to users who have not yet set the minVersionForCollab value explicitly.
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
// Iterate through each runtime option passed in by the user
|
|
148
|
+
for (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(
|
|
149
|
+
runtimeOptions,
|
|
150
|
+
) as [keyof T & string, T[keyof T & string]][]) {
|
|
151
|
+
// Skip if passedRuntimeOption is not in validation map
|
|
152
|
+
if (!(passedRuntimeOption in validationMap)) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const requiredVersion = validationMap[passedRuntimeOption](passedRuntimeOptionValue);
|
|
157
|
+
if (requiredVersion !== undefined && gt(requiredVersion, minVersionForCollab)) {
|
|
158
|
+
throw new UsageError(
|
|
159
|
+
`Runtime option ${passedRuntimeOption}:${JSON.stringify(passedRuntimeOptionValue)} requires ` +
|
|
160
|
+
`runtime version ${requiredVersion}. Please update minVersionForCollab ` +
|
|
161
|
+
`(currently ${minVersionForCollab}) to ${requiredVersion} or later to proceed.`,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Helper function to map ContainerRuntimeOptionsInternal config values to
|
|
169
|
+
* minVersionForCollab in, e.g., {@link @fluidframework/container-runtime#runtimeOptionsAffectingDocSchemaConfigValidationMap}.
|
|
170
|
+
*
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
export function configValueToMinVersionForCollab<
|
|
174
|
+
T extends string | number | boolean | undefined | object,
|
|
175
|
+
Arr extends readonly [T, SemanticVersion][],
|
|
176
|
+
>(configToMinVer: Arr): (configValue: T) => SemanticVersion | undefined {
|
|
177
|
+
const configValueToRequiredVersionMap = new Map(configToMinVer);
|
|
178
|
+
return (configValue: T) => {
|
|
179
|
+
// If the configValue is not an object then we can get the version required directly from the map.
|
|
180
|
+
if (typeof configValue !== "object") {
|
|
181
|
+
return configValueToRequiredVersionMap.get(configValue);
|
|
182
|
+
}
|
|
183
|
+
// When the input `configValue` is an object, this logic determines the minimum runtime version it requires.
|
|
184
|
+
// It iterates through each entry in `configValueToRequiredVersionMap`. If `possibleConfigValue` shares at
|
|
185
|
+
// least one key-value pair with the input `configValue`, its associated `versionRequired` is collected into
|
|
186
|
+
// `matchingVersions`. After checking all entries, the highest among the collected versions is returned.
|
|
187
|
+
// This represents the overall minimum version required to support the features implied by the input `configValue`.
|
|
188
|
+
const matchingVersions: SemanticVersion[] = [];
|
|
189
|
+
for (const [
|
|
190
|
+
possibleConfigValue,
|
|
191
|
+
versionRequired,
|
|
192
|
+
] of configValueToRequiredVersionMap.entries()) {
|
|
193
|
+
assert(
|
|
194
|
+
typeof possibleConfigValue == "object",
|
|
195
|
+
0xbb9 /* possibleConfigValue should be an object */,
|
|
196
|
+
);
|
|
197
|
+
// Check if `possibleConfigValue` and the input `configValue` share at least one
|
|
198
|
+
// common key-value pair. If they do, the `versionRequired` for this `possibleConfigValue`
|
|
199
|
+
// is added to `matchingVersions`.
|
|
200
|
+
if (Object.entries(possibleConfigValue).some(([k, v]) => configValue[k] === v)) {
|
|
201
|
+
matchingVersions.push(versionRequired);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (matchingVersions.length > 0) {
|
|
205
|
+
// Return the latest minVersionForCollab among all matches.
|
|
206
|
+
return matchingVersions.sort((a, b) => compare(b, a))[0];
|
|
207
|
+
}
|
|
208
|
+
// If no matches then we return undefined. This means that the config value passed in
|
|
209
|
+
// does not require a specific minVersionForCollab to be valid.
|
|
210
|
+
return undefined;
|
|
211
|
+
};
|
|
212
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -59,3 +59,14 @@ export {
|
|
|
59
59
|
toDeltaManagerErased,
|
|
60
60
|
toDeltaManagerInternal,
|
|
61
61
|
} from "./deltaManager.js";
|
|
62
|
+
export {
|
|
63
|
+
ConfigMap,
|
|
64
|
+
configValueToMinVersionForCollab,
|
|
65
|
+
ConfigValidationMap,
|
|
66
|
+
defaultMinVersionForCollab,
|
|
67
|
+
getValidationForRuntimeOptions,
|
|
68
|
+
getConfigsForMinVersionForCollab,
|
|
69
|
+
isValidMinVersionForCollab,
|
|
70
|
+
MinimumMinorSemanticVersion,
|
|
71
|
+
SemanticVersion,
|
|
72
|
+
} from "./compatibilityBase.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const pkgName = "@fluidframework/runtime-utils";
|
|
9
|
+
export const pkgVersion = "2.53.0-350190";
|