@fluidframework/container-runtime 2.51.0 → 2.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/api-report/container-runtime.legacy.alpha.api.md +1 -2
  3. package/container-runtime.test-files.tar +0 -0
  4. package/dist/blobManager/blobManager.d.ts +15 -7
  5. package/dist/blobManager/blobManager.d.ts.map +1 -1
  6. package/dist/blobManager/blobManager.js +72 -186
  7. package/dist/blobManager/blobManager.js.map +1 -1
  8. package/dist/containerCompatibility.d.ts +34 -0
  9. package/dist/containerCompatibility.d.ts.map +1 -0
  10. package/dist/containerCompatibility.js +125 -0
  11. package/dist/containerCompatibility.js.map +1 -0
  12. package/dist/containerRuntime.d.ts +27 -15
  13. package/dist/containerRuntime.d.ts.map +1 -1
  14. package/dist/containerRuntime.js +175 -136
  15. package/dist/containerRuntime.js.map +1 -1
  16. package/dist/dataStoreContext.d.ts +6 -6
  17. package/dist/dataStoreContext.d.ts.map +1 -1
  18. package/dist/dataStoreContext.js.map +1 -1
  19. package/dist/index.d.ts +5 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/metadata.d.ts +3 -2
  23. package/dist/metadata.d.ts.map +1 -1
  24. package/dist/metadata.js +7 -1
  25. package/dist/metadata.js.map +1 -1
  26. package/dist/packageVersion.d.ts +1 -1
  27. package/dist/packageVersion.js +1 -1
  28. package/dist/packageVersion.js.map +1 -1
  29. package/dist/storageServiceWithAttachBlobs.d.ts +40 -5
  30. package/dist/storageServiceWithAttachBlobs.d.ts.map +1 -1
  31. package/dist/storageServiceWithAttachBlobs.js +56 -5
  32. package/dist/storageServiceWithAttachBlobs.js.map +1 -1
  33. package/dist/summary/documentSchema.d.ts +1 -1
  34. package/dist/summary/documentSchema.d.ts.map +1 -1
  35. package/dist/summary/documentSchema.js.map +1 -1
  36. package/dist/summary/summaryFormat.d.ts +3 -3
  37. package/dist/summary/summaryFormat.d.ts.map +1 -1
  38. package/dist/summary/summaryFormat.js.map +1 -1
  39. package/lib/blobManager/blobManager.d.ts +15 -7
  40. package/lib/blobManager/blobManager.d.ts.map +1 -1
  41. package/lib/blobManager/blobManager.js +39 -153
  42. package/lib/blobManager/blobManager.js.map +1 -1
  43. package/lib/containerCompatibility.d.ts +34 -0
  44. package/lib/containerCompatibility.d.ts.map +1 -0
  45. package/lib/containerCompatibility.js +120 -0
  46. package/lib/containerCompatibility.js.map +1 -0
  47. package/lib/containerRuntime.d.ts +27 -15
  48. package/lib/containerRuntime.d.ts.map +1 -1
  49. package/lib/containerRuntime.js +103 -64
  50. package/lib/containerRuntime.js.map +1 -1
  51. package/lib/dataStoreContext.d.ts +6 -6
  52. package/lib/dataStoreContext.d.ts.map +1 -1
  53. package/lib/dataStoreContext.js +1 -1
  54. package/lib/dataStoreContext.js.map +1 -1
  55. package/lib/index.d.ts +5 -1
  56. package/lib/index.d.ts.map +1 -1
  57. package/lib/index.js.map +1 -1
  58. package/lib/metadata.d.ts +3 -2
  59. package/lib/metadata.d.ts.map +1 -1
  60. package/lib/metadata.js +5 -0
  61. package/lib/metadata.js.map +1 -1
  62. package/lib/packageVersion.d.ts +1 -1
  63. package/lib/packageVersion.js +1 -1
  64. package/lib/packageVersion.js.map +1 -1
  65. package/lib/storageServiceWithAttachBlobs.d.ts +40 -5
  66. package/lib/storageServiceWithAttachBlobs.d.ts.map +1 -1
  67. package/lib/storageServiceWithAttachBlobs.js +56 -5
  68. package/lib/storageServiceWithAttachBlobs.js.map +1 -1
  69. package/lib/summary/documentSchema.d.ts +1 -1
  70. package/lib/summary/documentSchema.d.ts.map +1 -1
  71. package/lib/summary/documentSchema.js.map +1 -1
  72. package/lib/summary/summaryFormat.d.ts +3 -3
  73. package/lib/summary/summaryFormat.d.ts.map +1 -1
  74. package/lib/summary/summaryFormat.js.map +1 -1
  75. package/package.json +20 -20
  76. package/src/blobManager/blobManager.ts +53 -195
  77. package/src/containerCompatibility.ts +176 -0
  78. package/src/containerRuntime.ts +157 -122
  79. package/src/dataStoreContext.ts +13 -5
  80. package/src/index.ts +6 -1
  81. package/src/metadata.ts +10 -2
  82. package/src/packageVersion.ts +1 -1
  83. package/src/storageServiceWithAttachBlobs.ts +92 -10
  84. package/src/summary/documentSchema.ts +1 -1
  85. package/src/summary/summaryFormat.ts +2 -2
  86. package/dist/compatUtils.d.ts +0 -106
  87. package/dist/compatUtils.d.ts.map +0 -1
  88. package/dist/compatUtils.js +0 -251
  89. package/dist/compatUtils.js.map +0 -1
  90. package/lib/compatUtils.d.ts +0 -106
  91. package/lib/compatUtils.d.ts.map +0 -1
  92. package/lib/compatUtils.js +0 -242
  93. package/lib/compatUtils.js.map +0 -1
  94. package/src/compatUtils.ts +0 -365
@@ -1,365 +0,0 @@
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 { FlushMode } 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 {
12
- disabledCompressionConfig,
13
- enabledCompressionConfig,
14
- } from "./compressionDefinitions.js";
15
- import type { ContainerRuntimeOptionsInternal } from "./containerRuntime.js";
16
- import { pkgVersion } from "./packageVersion.js";
17
-
18
- /**
19
- * Our policy is to support N/N-1 compatibility by default, where N is the most
20
- * recent public major release of the runtime.
21
- * Therefore, if the customer does not provide a minVersionForCollab, we will
22
- * default to use N-1.
23
- *
24
- * However, this is not consistent with today's behavior. Some options (i.e.
25
- * batching, compression) are enabled by default despite not being compatible
26
- * with 1.x clients. Since the policy was introduced during 2.x's lifespan,
27
- * N/N-1 compatibility by **default** will be in effect starting with 3.0.
28
- * Importantly though, N/N-2 compatibility is still guaranteed with the proper
29
- * configurations set.
30
- *
31
- * Further to distinguish unspecified `minVersionForCollab` from a specified
32
- * version and allow `enableExplicitSchemaControl` to default to `true` for
33
- * any 2.0.0+ version, we will use a special value of `2.0.0-defaults`, which
34
- * is semantically less than 2.0.0.
35
- */
36
- export const defaultMinVersionForCollab =
37
- "2.0.0-defaults" as const satisfies MinimumVersionForCollab;
38
-
39
- /**
40
- * We don't want allow a version before the major public release of the LTS version.
41
- * Today we use "1.0.0", because our policy supports N/N-1 & N/N-2, which includes
42
- * all minor versions of N. Though LTS starts at 1.4.0, we should stay consistent
43
- * with our policy and allow all 1.x versions to be compatible with 2.x.
44
- */
45
- const lowestMinVersionForCollab = "1.0.0" as const satisfies MinimumVersionForCollab;
46
-
47
- /**
48
- * String in a valid semver format specifying bottom of a minor version
49
- * or special "defaults" prerelease of a major.
50
- * @remarks Only 2.0.0-defaults is expected, but index signatures cannot be a
51
- * literal; so, just allow any major -defaults prerelease.
52
- */
53
- export type MinimumMinorSemanticVersion = `${bigint}.${bigint}.0` | `${bigint}.0.0-defaults`;
54
-
55
- /**
56
- * String in a valid semver format of a specific version at least specifying minor.
57
- *
58
- * @legacy
59
- * @alpha
60
- */
61
- export type MinimumVersionForCollab =
62
- | `${1 | 2}.${bigint}.${bigint}`
63
- | `${1 | 2}.${bigint}.${bigint}-${string}`;
64
-
65
- /**
66
- * String in a valid semver format of a specific version at least specifying minor.
67
- * Unlike {@link MinimumVersionForCollab}, this type allows any bigint for the major version.
68
- * Used as a more generic type that allows major versions other than 1 or 2.
69
- *
70
- * @internal
71
- */
72
- export type SemanticVersion =
73
- | `${bigint}.${bigint}.${bigint}`
74
- | `${bigint}.${bigint}.${bigint}-${string}`;
75
-
76
- /**
77
- * Generic type for runtimeOptionsAffectingDocSchemaConfigMap
78
- */
79
- export type ConfigMap<T extends Record<string, unknown>> = {
80
- [K in keyof T]-?: {
81
- [version: MinimumMinorSemanticVersion]: T[K];
82
- };
83
- };
84
-
85
- /**
86
- * Generic type for runtimeOptionsAffectingDocSchemaConfigValidationMap
87
- */
88
- export type ConfigValidationMap<T extends Record<string, unknown>> = {
89
- [K in keyof T]-?: (configValue: T[K]) => SemanticVersion | undefined;
90
- };
91
-
92
- /**
93
- * Subset of the {@link ContainerRuntimeOptionsInternal} properties which
94
- * affect {@link IDocumentSchemaFeatures}.
95
- *
96
- * @remarks
97
- * When a new option is added to {@link ContainerRuntimeOptionsInternal}, we
98
- * must consider if it changes the DocumentSchema. If so, then a corresponding
99
- * entry must be added to {@link runtimeOptionsAffectingDocSchemaConfigMap}
100
- * below. If not, then it must be omitted from this type.
101
- *
102
- * Note: `Omit` is used instead of `Pick` to ensure that all new options are
103
- * included in this type by default. If any new properties are added to
104
- * {@link ContainerRuntimeOptionsInternal}, they will be included in this
105
- * type unless explicitly omitted. This will prevent us from forgetting to
106
- * account for any new properties in the future.
107
- */
108
- export type RuntimeOptionsAffectingDocSchema = Omit<
109
- ContainerRuntimeOptionsInternal,
110
- | "chunkSizeInBytes"
111
- | "maxBatchSizeInBytes"
112
- | "loadSequenceNumberVerification"
113
- | "summaryOptions"
114
- >;
115
-
116
- /**
117
- * Mapping of RuntimeOptionsAffectingDocSchema to their compatibility related configs.
118
- *
119
- * Each key in this map corresponds to a property in RuntimeOptionsAffectingDocSchema. The value is an object that maps MinimumVersionForCollab
120
- * to the appropriate default value for that property to supporting that MinimumVersionForCollab. If clients running MinimumVersionForCollab X are able to understand
121
- * the format changes introduced by the property, then the default value for that MinimumVersionForCollab will enable the feature associated with the property.
122
- * Otherwise, the feature will be disabled.
123
- *
124
- * For example if the minVersionForCollab is a 1.x version (i.e. "1.5.0"), then the default value for `enableGroupedBatching` will be false since 1.x
125
- * clients do not understand the document format when batching is enabled. If the minVersionForCollab is a 2.x client (i.e. "2.0.0" or later), then the
126
- * default value for `enableGroupedBatching` will be true because clients running 2.0 or later will be able to understand the format changes associated
127
- * with the batching feature.
128
- */
129
- const runtimeOptionsAffectingDocSchemaConfigMap = {
130
- enableGroupedBatching: {
131
- "1.0.0": false,
132
- "2.0.0-defaults": true,
133
- },
134
- compressionOptions: {
135
- "1.0.0": disabledCompressionConfig,
136
- "2.0.0-defaults": enabledCompressionConfig,
137
- },
138
- enableRuntimeIdCompressor: {
139
- // For IdCompressorMode, `undefined` represents a logical state (off).
140
- // However, to satisfy the Required<> constraint while
141
- // `exactOptionalPropertyTypes` is `false` (TODO: AB#8215), we need
142
- // to have it defined, so we trick the type checker here.
143
- "1.0.0": undefined,
144
- // We do not yet want to enable idCompressor by default since it will
145
- // increase bundle sizes, and not all customers will benefit from it.
146
- // Therefore, we will require customers to explicitly enable it. We
147
- // are keeping it as a DocSchema affecting option for now as this may
148
- // change in the future.
149
- },
150
- explicitSchemaControl: {
151
- "1.0.0": false,
152
- // This option's intention is to prevent 1.x clients from joining sessions
153
- // when enabled. This is set to true when the minVersionForCollab is set
154
- // to >=2.0.0 (explicitly). This is different than other 2.0 defaults
155
- // because it was not enabled by default prior to the implementation of
156
- // `minVersionForCollab`.
157
- // `defaultMinVersionForCollab` is set to "2.0.0-defaults" which "2.0.0"
158
- // does not satisfy to avoiding enabling this option by default as of
159
- // `minVersionForCollab` introduction, which could be unexpected.
160
- // Only enable as a default when `minVersionForCollab` is specified at
161
- // 2.0.0+.
162
- "2.0.0": true,
163
- },
164
- flushMode: {
165
- // Note: 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode
166
- // as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as
167
- // fewer messages will be included per flush.
168
- "1.0.0": FlushMode.Immediate,
169
- "2.0.0-defaults": FlushMode.TurnBased,
170
- },
171
- gcOptions: {
172
- "1.0.0": {},
173
- // Although sweep is supported in 2.x, it is disabled by default until minVersionForCollab>=3.0.0 to be extra safe.
174
- "3.0.0": { enableGCSweep: true },
175
- },
176
- createBlobPayloadPending: {
177
- // This feature is new and disabled by default. In the future we will enable it by default, but we have not
178
- // closed on the version where that will happen yet. Probably a .10 release since blob functionality is not
179
- // exposed on the `@public` API surface.
180
- "1.0.0": undefined,
181
- },
182
- } as const satisfies ConfigMap<RuntimeOptionsAffectingDocSchema>;
183
-
184
- const runtimeOptionsAffectingDocSchemaConfigValidationMap = {
185
- enableGroupedBatching: configValueToMinVersionForCollab([
186
- [false, "1.0.0"],
187
- [true, "2.0.0-defaults"],
188
- ]),
189
- compressionOptions: configValueToMinVersionForCollab([
190
- [{ ...disabledCompressionConfig }, "1.0.0"],
191
- [{ ...enabledCompressionConfig }, "2.0.0-defaults"],
192
- ]),
193
- enableRuntimeIdCompressor: configValueToMinVersionForCollab([
194
- [undefined, "1.0.0"],
195
- ["on", "2.0.0-defaults"],
196
- ["delayed", "2.0.0-defaults"],
197
- ]),
198
- explicitSchemaControl: configValueToMinVersionForCollab([
199
- [false, "1.0.0"],
200
- [true, "2.0.0-defaults"],
201
- ]),
202
- flushMode: configValueToMinVersionForCollab([
203
- [FlushMode.Immediate, "1.0.0"],
204
- [FlushMode.TurnBased, "2.0.0-defaults"],
205
- ]),
206
- gcOptions: configValueToMinVersionForCollab([
207
- [{ enableGCSweep: undefined }, "1.0.0"],
208
- [{ enableGCSweep: true }, "2.0.0-defaults"],
209
- ]),
210
- createBlobPayloadPending: configValueToMinVersionForCollab([
211
- [undefined, "1.0.0"],
212
- [true, "2.40.0"],
213
- ]),
214
- } as const satisfies ConfigValidationMap<RuntimeOptionsAffectingDocSchema>;
215
-
216
- /**
217
- * Returns the default RuntimeOptionsAffectingDocSchema configuration for a given minVersionForCollab.
218
- */
219
- export function getMinVersionForCollabDefaults(
220
- minVersionForCollab: MinimumVersionForCollab,
221
- ): RuntimeOptionsAffectingDocSchema {
222
- return getConfigsForMinVersionForCollab(
223
- minVersionForCollab,
224
- runtimeOptionsAffectingDocSchemaConfigMap,
225
- // This is a bad cast away from Partial that getConfigsForCompatMode provides.
226
- // ConfigMap should be restructured to provide RuntimeOptionsAffectingDocSchema guarantee.
227
- ) as RuntimeOptionsAffectingDocSchema;
228
- }
229
-
230
- /**
231
- * Returns a default configuration given minVersionForCollab and configuration version map.
232
- */
233
- export function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(
234
- minVersionForCollab: SemanticVersion,
235
- configMap: ConfigMap<T>,
236
- ): Partial<T> {
237
- const defaultConfigs: Partial<T> = {};
238
- // Iterate over configMap to get default values for each option.
239
- for (const key of Object.keys(configMap)) {
240
- const config = configMap[key as keyof T];
241
- // Sort the versions in ascending order so we can short circuit the loop.
242
- const versions = Object.keys(config).sort(compare);
243
- // For each config, we iterate over the keys and check if minVersionForCollab is greater than or equal to the version.
244
- // 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
245
- // value that is compatible with the version specified as the minVersionForCollab.
246
- for (const version of versions) {
247
- if (gte(minVersionForCollab, version)) {
248
- defaultConfigs[key] = config[version as MinimumMinorSemanticVersion];
249
- } else {
250
- // If the minVersionForCollab is less than the version, we break out of the loop since we don't need to check
251
- // any later versions.
252
- break;
253
- }
254
- }
255
- }
256
- return defaultConfigs;
257
- }
258
-
259
- /**
260
- * Checks if the minVersionForCollab is valid.
261
- * A valid minVersionForCollab is a MinimumVersionForCollab that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
262
- */
263
- export function isValidMinVersionForCollab(
264
- minVersionForCollab: MinimumVersionForCollab,
265
- ): boolean {
266
- return (
267
- valid(minVersionForCollab) !== null &&
268
- gte(minVersionForCollab, lowestMinVersionForCollab) &&
269
- lte(minVersionForCollab, pkgVersion)
270
- );
271
- }
272
-
273
- /**
274
- * Validates if the runtime options passed in from the user are compatible with the minVersionForCollab.
275
- * For example, if a user sets the `enableGroupedBatching` option to true, but the minVersionForCollab
276
- * is set to "1.0.0", then we should throw a UsageError since 1.x clients do not support batching.
277
- * */
278
- export function validateRuntimeOptions(
279
- minVersionForCollab: MinimumVersionForCollab,
280
- runtimeOptions: Partial<ContainerRuntimeOptionsInternal>,
281
- ): void {
282
- getValidationForRuntimeOptions<RuntimeOptionsAffectingDocSchema>(
283
- minVersionForCollab,
284
- runtimeOptions as Partial<RuntimeOptionsAffectingDocSchema>,
285
- runtimeOptionsAffectingDocSchemaConfigValidationMap,
286
- );
287
- }
288
-
289
- /**
290
- * Generic function to validate runtime options against the minVersionForCollab.
291
- */
292
- export function getValidationForRuntimeOptions<T extends Record<string, unknown>>(
293
- minVersionForCollab: SemanticVersion,
294
- runtimeOptions: Partial<T>,
295
- validationMap: ConfigValidationMap<T>,
296
- ): void {
297
- if (minVersionForCollab === defaultMinVersionForCollab) {
298
- // If the minVersionForCollab is set to the default value, then we will not validate the runtime options
299
- // This is to avoid disruption to users who have not yet set the minVersionForCollab value explicitly.
300
- return;
301
- }
302
- // Iterate through each runtime option passed in by the user
303
- for (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(
304
- runtimeOptions,
305
- ) as [keyof T & string, T[keyof T & string]][]) {
306
- // Skip if passedRuntimeOption is not in validation map
307
- if (!(passedRuntimeOption in validationMap)) {
308
- continue;
309
- }
310
-
311
- const requiredVersion = validationMap[passedRuntimeOption](passedRuntimeOptionValue);
312
- if (requiredVersion !== undefined && gt(requiredVersion, minVersionForCollab)) {
313
- throw new UsageError(
314
- `Runtime option ${passedRuntimeOption}:${JSON.stringify(passedRuntimeOptionValue)} requires ` +
315
- `runtime version ${requiredVersion}. Please update minVersionForCollab ` +
316
- `(currently ${minVersionForCollab}) to ${requiredVersion} or later to proceed.`,
317
- );
318
- }
319
- }
320
- }
321
-
322
- /**
323
- * Helper function to map ContainerRuntimeOptionsInternal config values to
324
- * minVersionForCollab in {@link runtimeOptionsAffectingDocSchemaConfigValidationMap}.
325
- */
326
- export function configValueToMinVersionForCollab<
327
- T extends string | number | boolean | undefined | object,
328
- Arr extends readonly [T, SemanticVersion][],
329
- >(configToMinVer: Arr): (configValue: T) => SemanticVersion | undefined {
330
- const configValueToRequiredVersionMap = new Map(configToMinVer);
331
- return (configValue: T) => {
332
- // If the configValue is not an object then we can get the version required directly from the map.
333
- if (typeof configValue !== "object") {
334
- return configValueToRequiredVersionMap.get(configValue);
335
- }
336
- // When the input `configValue` is an object, this logic determines the minimum runtime version it requires.
337
- // It iterates through each entry in `configValueToRequiredVersionMap`. If `possibleConfigValue` shares at
338
- // least one key-value pair with the input `configValue`, its associated `versionRequired` is collected into
339
- // `matchingVersions`. After checking all entries, the highest among the collected versions is returned.
340
- // This represents the overall minimum version required to support the features implied by the input `configValue`.
341
- const matchingVersions: SemanticVersion[] = [];
342
- for (const [
343
- possibleConfigValue,
344
- versionRequired,
345
- ] of configValueToRequiredVersionMap.entries()) {
346
- assert(
347
- typeof possibleConfigValue == "object",
348
- 0xbb9 /* possibleConfigValue should be an object */,
349
- );
350
- // Check if `possibleConfigValue` and the input `configValue` share at least one
351
- // common key-value pair. If they do, the `versionRequired` for this `possibleConfigValue`
352
- // is added to `matchingVersions`.
353
- if (Object.entries(possibleConfigValue).some(([k, v]) => configValue[k] === v)) {
354
- matchingVersions.push(versionRequired);
355
- }
356
- }
357
- if (matchingVersions.length > 0) {
358
- // Return the latest minVersionForCollab among all matches.
359
- return matchingVersions.sort((a, b) => compare(b, a))[0];
360
- }
361
- // If no matches then we return undefined. This means that the config value passed in
362
- // does not require a specific minVersionForCollab to be valid.
363
- return undefined;
364
- };
365
- }