@fluidframework/container-runtime 2.51.0-347100 → 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.
- package/CHANGELOG.md +14 -0
- package/api-report/container-runtime.legacy.alpha.api.md +1 -2
- package/container-runtime.test-files.tar +0 -0
- package/dist/blobManager/blobManager.d.ts +15 -7
- package/dist/blobManager/blobManager.d.ts.map +1 -1
- package/dist/blobManager/blobManager.js +72 -186
- package/dist/blobManager/blobManager.js.map +1 -1
- package/dist/containerCompatibility.d.ts +34 -0
- package/dist/containerCompatibility.d.ts.map +1 -0
- package/dist/containerCompatibility.js +125 -0
- package/dist/containerCompatibility.js.map +1 -0
- package/dist/containerRuntime.d.ts +27 -15
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +175 -136
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.d.ts +6 -6
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.ts +3 -2
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +7 -1
- package/dist/metadata.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/storageServiceWithAttachBlobs.d.ts +40 -5
- package/dist/storageServiceWithAttachBlobs.d.ts.map +1 -1
- package/dist/storageServiceWithAttachBlobs.js +56 -5
- package/dist/storageServiceWithAttachBlobs.js.map +1 -1
- package/dist/summary/documentSchema.d.ts +1 -1
- package/dist/summary/documentSchema.d.ts.map +1 -1
- package/dist/summary/documentSchema.js.map +1 -1
- package/dist/summary/summaryFormat.d.ts +3 -3
- package/dist/summary/summaryFormat.d.ts.map +1 -1
- package/dist/summary/summaryFormat.js.map +1 -1
- package/lib/blobManager/blobManager.d.ts +15 -7
- package/lib/blobManager/blobManager.d.ts.map +1 -1
- package/lib/blobManager/blobManager.js +39 -153
- package/lib/blobManager/blobManager.js.map +1 -1
- package/lib/containerCompatibility.d.ts +34 -0
- package/lib/containerCompatibility.d.ts.map +1 -0
- package/lib/containerCompatibility.js +120 -0
- package/lib/containerCompatibility.js.map +1 -0
- package/lib/containerRuntime.d.ts +27 -15
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +103 -64
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.d.ts +6 -6
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +1 -1
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/metadata.d.ts +3 -2
- package/lib/metadata.d.ts.map +1 -1
- package/lib/metadata.js +5 -0
- package/lib/metadata.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/storageServiceWithAttachBlobs.d.ts +40 -5
- package/lib/storageServiceWithAttachBlobs.d.ts.map +1 -1
- package/lib/storageServiceWithAttachBlobs.js +56 -5
- package/lib/storageServiceWithAttachBlobs.js.map +1 -1
- package/lib/summary/documentSchema.d.ts +1 -1
- package/lib/summary/documentSchema.d.ts.map +1 -1
- package/lib/summary/documentSchema.js.map +1 -1
- package/lib/summary/summaryFormat.d.ts +3 -3
- package/lib/summary/summaryFormat.d.ts.map +1 -1
- package/lib/summary/summaryFormat.js.map +1 -1
- package/package.json +20 -20
- package/src/blobManager/blobManager.ts +53 -195
- package/src/containerCompatibility.ts +176 -0
- package/src/containerRuntime.ts +157 -122
- package/src/dataStoreContext.ts +13 -5
- package/src/index.ts +6 -1
- package/src/metadata.ts +10 -2
- package/src/packageVersion.ts +1 -1
- package/src/storageServiceWithAttachBlobs.ts +92 -10
- package/src/summary/documentSchema.ts +1 -1
- package/src/summary/summaryFormat.ts +2 -2
- package/dist/compatUtils.d.ts +0 -106
- package/dist/compatUtils.d.ts.map +0 -1
- package/dist/compatUtils.js +0 -251
- package/dist/compatUtils.js.map +0 -1
- package/lib/compatUtils.d.ts +0 -106
- package/lib/compatUtils.d.ts.map +0 -1
- package/lib/compatUtils.js +0 -242
- package/lib/compatUtils.js.map +0 -1
- package/src/compatUtils.ts +0 -365
package/dist/compatUtils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compatUtils.js","sourceRoot":"","sources":["../src/compatUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,2EAAyE;AACzE,uEAAsE;AACtE,yCAAyD;AAEzD,2EAGqC;AAErC,2DAAiD;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,0BAA0B,GACtC,gBAA2D,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,yBAAyB,GAAG,OAAkD,CAAC;AAuErF;;;;;;;;;;;;GAYG;AACH,MAAM,yCAAyC,GAAG;IACjD,qBAAqB,EAAE;QACtB,OAAO,EAAE,KAAK;QACd,gBAAgB,EAAE,IAAI;KACtB;IACD,kBAAkB,EAAE;QACnB,OAAO,EAAE,qDAAyB;QAClC,gBAAgB,EAAE,oDAAwB;KAC1C;IACD,yBAAyB,EAAE;QAC1B,sEAAsE;QACtE,sDAAsD;QACtD,mEAAmE;QACnE,yDAAyD;QACzD,OAAO,EAAE,SAAS;QAClB,qEAAqE;QACrE,qEAAqE;QACrE,mEAAmE;QACnE,qEAAqE;QACrE,wBAAwB;KACxB;IACD,qBAAqB,EAAE;QACtB,OAAO,EAAE,KAAK;QACd,0EAA0E;QAC1E,wEAAwE;QACxE,qEAAqE;QACrE,uEAAuE;QACvE,yBAAyB;QACzB,wEAAwE;QACxE,qEAAqE;QACrE,iEAAiE;QACjE,s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kG;QAClG,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 { FlushMode } from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { compare, gt, gte, lte, valid } from \"semver-ts\";\n\nimport {\n\tdisabledCompressionConfig,\n\tenabledCompressionConfig,\n} from \"./compressionDefinitions.js\";\nimport type { ContainerRuntimeOptionsInternal } from \"./containerRuntime.js\";\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 */\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 */\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 *\n * @legacy\n * @alpha\n */\nexport type MinimumVersionForCollab =\n\t| `${1 | 2}.${bigint}.${bigint}`\n\t| `${1 | 2}.${bigint}.${bigint}-${string}`;\n\n/**\n * String in a valid semver format of a specific version at least specifying minor.\n * Unlike {@link 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 */\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 */\nexport type ConfigValidationMap<T extends Record<string, unknown>> = {\n\t[K in keyof T]-?: (configValue: T[K]) => SemanticVersion | undefined;\n};\n\n/**\n * Subset of the {@link ContainerRuntimeOptionsInternal} properties which\n * affect {@link IDocumentSchemaFeatures}.\n *\n * @remarks\n * When a new option is added to {@link ContainerRuntimeOptionsInternal}, we\n * must consider if it changes the DocumentSchema. If so, then a corresponding\n * entry must be added to {@link runtimeOptionsAffectingDocSchemaConfigMap}\n * below. If not, then it must be omitted from this type.\n *\n * Note: `Omit` is used instead of `Pick` to ensure that all new options are\n * included in this type by default. If any new properties are added to\n * {@link ContainerRuntimeOptionsInternal}, they will be included in this\n * type unless explicitly omitted. This will prevent us from forgetting to\n * account for any new properties in the future.\n */\nexport type RuntimeOptionsAffectingDocSchema = Omit<\n\tContainerRuntimeOptionsInternal,\n\t| \"chunkSizeInBytes\"\n\t| \"maxBatchSizeInBytes\"\n\t| \"loadSequenceNumberVerification\"\n\t| \"summaryOptions\"\n>;\n\n/**\n * Mapping of RuntimeOptionsAffectingDocSchema to their compatibility related configs.\n *\n * Each key in this map corresponds to a property in RuntimeOptionsAffectingDocSchema. The value is an object that maps MinimumVersionForCollab\n * to the appropriate default value for that property to supporting that MinimumVersionForCollab. If clients running MinimumVersionForCollab X are able to understand\n * the format changes introduced by the property, then the default value for that MinimumVersionForCollab will enable the feature associated with the property.\n * Otherwise, the feature will be disabled.\n *\n * 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\n * 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\n * default value for `enableGroupedBatching` will be true because clients running 2.0 or later will be able to understand the format changes associated\n * with the batching feature.\n */\nconst runtimeOptionsAffectingDocSchemaConfigMap = {\n\tenableGroupedBatching: {\n\t\t\"1.0.0\": false,\n\t\t\"2.0.0-defaults\": true,\n\t},\n\tcompressionOptions: {\n\t\t\"1.0.0\": disabledCompressionConfig,\n\t\t\"2.0.0-defaults\": enabledCompressionConfig,\n\t},\n\tenableRuntimeIdCompressor: {\n\t\t// For IdCompressorMode, `undefined` represents a logical state (off).\n\t\t// However, to satisfy the Required<> constraint while\n\t\t// `exactOptionalPropertyTypes` is `false` (TODO: AB#8215), we need\n\t\t// to have it defined, so we trick the type checker here.\n\t\t\"1.0.0\": undefined,\n\t\t// We do not yet want to enable idCompressor by default since it will\n\t\t// increase bundle sizes, and not all customers will benefit from it.\n\t\t// Therefore, we will require customers to explicitly enable it. We\n\t\t// are keeping it as a DocSchema affecting option for now as this may\n\t\t// change in the future.\n\t},\n\texplicitSchemaControl: {\n\t\t\"1.0.0\": false,\n\t\t// This option's intention is to prevent 1.x clients from joining sessions\n\t\t// when enabled. This is set to true when the minVersionForCollab is set\n\t\t// to >=2.0.0 (explicitly). This is different than other 2.0 defaults\n\t\t// because it was not enabled by default prior to the implementation of\n\t\t// `minVersionForCollab`.\n\t\t// `defaultMinVersionForCollab` is set to \"2.0.0-defaults\" which \"2.0.0\"\n\t\t// does not satisfy to avoiding enabling this option by default as of\n\t\t// `minVersionForCollab` introduction, which could be unexpected.\n\t\t// Only enable as a default when `minVersionForCollab` is specified at\n\t\t// 2.0.0+.\n\t\t\"2.0.0\": true,\n\t},\n\tflushMode: {\n\t\t// Note: 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode\n\t\t// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as\n\t\t// fewer messages will be included per flush.\n\t\t\"1.0.0\": FlushMode.Immediate,\n\t\t\"2.0.0-defaults\": FlushMode.TurnBased,\n\t},\n\tgcOptions: {\n\t\t\"1.0.0\": {},\n\t\t// Although sweep is supported in 2.x, it is disabled by default until minVersionForCollab>=3.0.0 to be extra safe.\n\t\t\"3.0.0\": { enableGCSweep: true },\n\t},\n\tcreateBlobPayloadPending: {\n\t\t// This feature is new and disabled by default. In the future we will enable it by default, but we have not\n\t\t// closed on the version where that will happen yet. Probably a .10 release since blob functionality is not\n\t\t// exposed on the `@public` API surface.\n\t\t\"1.0.0\": undefined,\n\t},\n} as const satisfies ConfigMap<RuntimeOptionsAffectingDocSchema>;\n\nconst runtimeOptionsAffectingDocSchemaConfigValidationMap = {\n\tenableGroupedBatching: configValueToMinVersionForCollab([\n\t\t[false, \"1.0.0\"],\n\t\t[true, \"2.0.0-defaults\"],\n\t]),\n\tcompressionOptions: configValueToMinVersionForCollab([\n\t\t[{ ...disabledCompressionConfig }, \"1.0.0\"],\n\t\t[{ ...enabledCompressionConfig }, \"2.0.0-defaults\"],\n\t]),\n\tenableRuntimeIdCompressor: configValueToMinVersionForCollab([\n\t\t[undefined, \"1.0.0\"],\n\t\t[\"on\", \"2.0.0-defaults\"],\n\t\t[\"delayed\", \"2.0.0-defaults\"],\n\t]),\n\texplicitSchemaControl: configValueToMinVersionForCollab([\n\t\t[false, \"1.0.0\"],\n\t\t[true, \"2.0.0-defaults\"],\n\t]),\n\tflushMode: configValueToMinVersionForCollab([\n\t\t[FlushMode.Immediate, \"1.0.0\"],\n\t\t[FlushMode.TurnBased, \"2.0.0-defaults\"],\n\t]),\n\tgcOptions: configValueToMinVersionForCollab([\n\t\t[{ enableGCSweep: undefined }, \"1.0.0\"],\n\t\t[{ enableGCSweep: true }, \"2.0.0-defaults\"],\n\t]),\n\tcreateBlobPayloadPending: configValueToMinVersionForCollab([\n\t\t[undefined, \"1.0.0\"],\n\t\t[true, \"2.40.0\"],\n\t]),\n} as const satisfies ConfigValidationMap<RuntimeOptionsAffectingDocSchema>;\n\n/**\n * Returns the default RuntimeOptionsAffectingDocSchema configuration for a given minVersionForCollab.\n */\nexport function getMinVersionForCollabDefaults(\n\tminVersionForCollab: MinimumVersionForCollab,\n): RuntimeOptionsAffectingDocSchema {\n\treturn getConfigsForMinVersionForCollab(\n\t\tminVersionForCollab,\n\t\truntimeOptionsAffectingDocSchemaConfigMap,\n\t\t// This is a bad cast away from Partial that getConfigsForCompatMode provides.\n\t\t// ConfigMap should be restructured to provide RuntimeOptionsAffectingDocSchema guarantee.\n\t) as RuntimeOptionsAffectingDocSchema;\n}\n\n/**\n * Returns a default configuration given minVersionForCollab and configuration version map.\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 */\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 * Validates if the runtime options passed in from the user are compatible with the minVersionForCollab.\n * For example, if a user sets the `enableGroupedBatching` option to true, but the minVersionForCollab\n * is set to \"1.0.0\", then we should throw a UsageError since 1.x clients do not support batching.\n * */\nexport function validateRuntimeOptions(\n\tminVersionForCollab: MinimumVersionForCollab,\n\truntimeOptions: Partial<ContainerRuntimeOptionsInternal>,\n): void {\n\tgetValidationForRuntimeOptions<RuntimeOptionsAffectingDocSchema>(\n\t\tminVersionForCollab,\n\t\truntimeOptions as Partial<RuntimeOptionsAffectingDocSchema>,\n\t\truntimeOptionsAffectingDocSchemaConfigValidationMap,\n\t);\n}\n\n/**\n * Generic function to validate runtime options against the minVersionForCollab.\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 {@link runtimeOptionsAffectingDocSchemaConfigValidationMap}.\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/compatUtils.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { ContainerRuntimeOptionsInternal } from "./containerRuntime.js";
|
|
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
|
-
export declare const defaultMinVersionForCollab: "2.0.0-defaults";
|
|
25
|
-
/**
|
|
26
|
-
* String in a valid semver format specifying bottom of a minor version
|
|
27
|
-
* or special "defaults" prerelease of a major.
|
|
28
|
-
* @remarks Only 2.0.0-defaults is expected, but index signatures cannot be a
|
|
29
|
-
* literal; so, just allow any major -defaults prerelease.
|
|
30
|
-
*/
|
|
31
|
-
export type MinimumMinorSemanticVersion = `${bigint}.${bigint}.0` | `${bigint}.0.0-defaults`;
|
|
32
|
-
/**
|
|
33
|
-
* String in a valid semver format of a specific version at least specifying minor.
|
|
34
|
-
*
|
|
35
|
-
* @legacy
|
|
36
|
-
* @alpha
|
|
37
|
-
*/
|
|
38
|
-
export type MinimumVersionForCollab = `${1 | 2}.${bigint}.${bigint}` | `${1 | 2}.${bigint}.${bigint}-${string}`;
|
|
39
|
-
/**
|
|
40
|
-
* String in a valid semver format of a specific version at least specifying minor.
|
|
41
|
-
* Unlike {@link MinimumVersionForCollab}, this type allows any bigint for the major version.
|
|
42
|
-
* Used as a more generic type that allows major versions other than 1 or 2.
|
|
43
|
-
*
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
export type SemanticVersion = `${bigint}.${bigint}.${bigint}` | `${bigint}.${bigint}.${bigint}-${string}`;
|
|
47
|
-
/**
|
|
48
|
-
* Generic type for runtimeOptionsAffectingDocSchemaConfigMap
|
|
49
|
-
*/
|
|
50
|
-
export type ConfigMap<T extends Record<string, unknown>> = {
|
|
51
|
-
[K in keyof T]-?: {
|
|
52
|
-
[version: MinimumMinorSemanticVersion]: T[K];
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Generic type for runtimeOptionsAffectingDocSchemaConfigValidationMap
|
|
57
|
-
*/
|
|
58
|
-
export type ConfigValidationMap<T extends Record<string, unknown>> = {
|
|
59
|
-
[K in keyof T]-?: (configValue: T[K]) => SemanticVersion | undefined;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Subset of the {@link ContainerRuntimeOptionsInternal} properties which
|
|
63
|
-
* affect {@link IDocumentSchemaFeatures}.
|
|
64
|
-
*
|
|
65
|
-
* @remarks
|
|
66
|
-
* When a new option is added to {@link ContainerRuntimeOptionsInternal}, we
|
|
67
|
-
* must consider if it changes the DocumentSchema. If so, then a corresponding
|
|
68
|
-
* entry must be added to {@link runtimeOptionsAffectingDocSchemaConfigMap}
|
|
69
|
-
* below. If not, then it must be omitted from this type.
|
|
70
|
-
*
|
|
71
|
-
* Note: `Omit` is used instead of `Pick` to ensure that all new options are
|
|
72
|
-
* included in this type by default. If any new properties are added to
|
|
73
|
-
* {@link ContainerRuntimeOptionsInternal}, they will be included in this
|
|
74
|
-
* type unless explicitly omitted. This will prevent us from forgetting to
|
|
75
|
-
* account for any new properties in the future.
|
|
76
|
-
*/
|
|
77
|
-
export type RuntimeOptionsAffectingDocSchema = Omit<ContainerRuntimeOptionsInternal, "chunkSizeInBytes" | "maxBatchSizeInBytes" | "loadSequenceNumberVerification" | "summaryOptions">;
|
|
78
|
-
/**
|
|
79
|
-
* Returns the default RuntimeOptionsAffectingDocSchema configuration for a given minVersionForCollab.
|
|
80
|
-
*/
|
|
81
|
-
export declare function getMinVersionForCollabDefaults(minVersionForCollab: MinimumVersionForCollab): RuntimeOptionsAffectingDocSchema;
|
|
82
|
-
/**
|
|
83
|
-
* Returns a default configuration given minVersionForCollab and configuration version map.
|
|
84
|
-
*/
|
|
85
|
-
export declare function getConfigsForMinVersionForCollab<T extends Record<SemanticVersion, unknown>>(minVersionForCollab: SemanticVersion, configMap: ConfigMap<T>): Partial<T>;
|
|
86
|
-
/**
|
|
87
|
-
* Checks if the minVersionForCollab is valid.
|
|
88
|
-
* A valid minVersionForCollab is a MinimumVersionForCollab that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
89
|
-
*/
|
|
90
|
-
export declare function isValidMinVersionForCollab(minVersionForCollab: MinimumVersionForCollab): boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Validates if the runtime options passed in from the user are compatible with the minVersionForCollab.
|
|
93
|
-
* For example, if a user sets the `enableGroupedBatching` option to true, but the minVersionForCollab
|
|
94
|
-
* is set to "1.0.0", then we should throw a UsageError since 1.x clients do not support batching.
|
|
95
|
-
* */
|
|
96
|
-
export declare function validateRuntimeOptions(minVersionForCollab: MinimumVersionForCollab, runtimeOptions: Partial<ContainerRuntimeOptionsInternal>): void;
|
|
97
|
-
/**
|
|
98
|
-
* Generic function to validate runtime options against the minVersionForCollab.
|
|
99
|
-
*/
|
|
100
|
-
export declare function getValidationForRuntimeOptions<T extends Record<string, unknown>>(minVersionForCollab: SemanticVersion, runtimeOptions: Partial<T>, validationMap: ConfigValidationMap<T>): void;
|
|
101
|
-
/**
|
|
102
|
-
* Helper function to map ContainerRuntimeOptionsInternal config values to
|
|
103
|
-
* minVersionForCollab in {@link runtimeOptionsAffectingDocSchemaConfigValidationMap}.
|
|
104
|
-
*/
|
|
105
|
-
export declare function configValueToMinVersionForCollab<T extends string | number | boolean | undefined | object, Arr extends readonly [T, SemanticVersion][]>(configToMinVer: Arr): (configValue: T) => SemanticVersion | undefined;
|
|
106
|
-
//# sourceMappingURL=compatUtils.d.ts.map
|
package/lib/compatUtils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compatUtils.d.ts","sourceRoot":"","sources":["../src/compatUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAG7E;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,0BAA0B,kBACqB,CAAC;AAU7D;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,GAAG,GAAG,MAAM,eAAe,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAChC,GAAG,CAAC,GAAG,CAAC,IAAI,MAAM,IAAI,MAAM,EAAE,GAC9B,GAAG,CAAC,GAAG,CAAC,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GACxB,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,GAC/B,GAAG,MAAM,IAAI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AAC,EAC/E,mBAAmB,EAAE,eAAe,EACpC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,EAC1B,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC,GACnC,IAAI,CAwBN;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAC/C,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,EACxD,GAAG,SAAS,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,EAAE,EAC1C,cAAc,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,eAAe,GAAG,SAAS,CAoCtE"}
|
package/lib/compatUtils.js
DELETED
|
@@ -1,242 +0,0 @@
|
|
|
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 { FlushMode } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
-
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
|
-
import { compare, gt, gte, lte, valid } from "semver-ts";
|
|
9
|
-
import { disabledCompressionConfig, enabledCompressionConfig, } from "./compressionDefinitions.js";
|
|
10
|
-
import { pkgVersion } from "./packageVersion.js";
|
|
11
|
-
/**
|
|
12
|
-
* Our policy is to support N/N-1 compatibility by default, where N is the most
|
|
13
|
-
* recent public major release of the runtime.
|
|
14
|
-
* Therefore, if the customer does not provide a minVersionForCollab, we will
|
|
15
|
-
* default to use N-1.
|
|
16
|
-
*
|
|
17
|
-
* However, this is not consistent with today's behavior. Some options (i.e.
|
|
18
|
-
* batching, compression) are enabled by default despite not being compatible
|
|
19
|
-
* with 1.x clients. Since the policy was introduced during 2.x's lifespan,
|
|
20
|
-
* N/N-1 compatibility by **default** will be in effect starting with 3.0.
|
|
21
|
-
* Importantly though, N/N-2 compatibility is still guaranteed with the proper
|
|
22
|
-
* configurations set.
|
|
23
|
-
*
|
|
24
|
-
* Further to distinguish unspecified `minVersionForCollab` from a specified
|
|
25
|
-
* version and allow `enableExplicitSchemaControl` to default to `true` for
|
|
26
|
-
* any 2.0.0+ version, we will use a special value of `2.0.0-defaults`, which
|
|
27
|
-
* is semantically less than 2.0.0.
|
|
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
|
-
* Mapping of RuntimeOptionsAffectingDocSchema to their compatibility related configs.
|
|
39
|
-
*
|
|
40
|
-
* Each key in this map corresponds to a property in RuntimeOptionsAffectingDocSchema. The value is an object that maps MinimumVersionForCollab
|
|
41
|
-
* to the appropriate default value for that property to supporting that MinimumVersionForCollab. If clients running MinimumVersionForCollab X are able to understand
|
|
42
|
-
* the format changes introduced by the property, then the default value for that MinimumVersionForCollab will enable the feature associated with the property.
|
|
43
|
-
* Otherwise, the feature will be disabled.
|
|
44
|
-
*
|
|
45
|
-
* 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
|
|
46
|
-
* 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
|
|
47
|
-
* default value for `enableGroupedBatching` will be true because clients running 2.0 or later will be able to understand the format changes associated
|
|
48
|
-
* with the batching feature.
|
|
49
|
-
*/
|
|
50
|
-
const runtimeOptionsAffectingDocSchemaConfigMap = {
|
|
51
|
-
enableGroupedBatching: {
|
|
52
|
-
"1.0.0": false,
|
|
53
|
-
"2.0.0-defaults": true,
|
|
54
|
-
},
|
|
55
|
-
compressionOptions: {
|
|
56
|
-
"1.0.0": disabledCompressionConfig,
|
|
57
|
-
"2.0.0-defaults": enabledCompressionConfig,
|
|
58
|
-
},
|
|
59
|
-
enableRuntimeIdCompressor: {
|
|
60
|
-
// For IdCompressorMode, `undefined` represents a logical state (off).
|
|
61
|
-
// However, to satisfy the Required<> constraint while
|
|
62
|
-
// `exactOptionalPropertyTypes` is `false` (TODO: AB#8215), we need
|
|
63
|
-
// to have it defined, so we trick the type checker here.
|
|
64
|
-
"1.0.0": undefined,
|
|
65
|
-
// We do not yet want to enable idCompressor by default since it will
|
|
66
|
-
// increase bundle sizes, and not all customers will benefit from it.
|
|
67
|
-
// Therefore, we will require customers to explicitly enable it. We
|
|
68
|
-
// are keeping it as a DocSchema affecting option for now as this may
|
|
69
|
-
// change in the future.
|
|
70
|
-
},
|
|
71
|
-
explicitSchemaControl: {
|
|
72
|
-
"1.0.0": false,
|
|
73
|
-
// This option's intention is to prevent 1.x clients from joining sessions
|
|
74
|
-
// when enabled. This is set to true when the minVersionForCollab is set
|
|
75
|
-
// to >=2.0.0 (explicitly). This is different than other 2.0 defaults
|
|
76
|
-
// because it was not enabled by default prior to the implementation of
|
|
77
|
-
// `minVersionForCollab`.
|
|
78
|
-
// `defaultMinVersionForCollab` is set to "2.0.0-defaults" which "2.0.0"
|
|
79
|
-
// does not satisfy to avoiding enabling this option by default as of
|
|
80
|
-
// `minVersionForCollab` introduction, which could be unexpected.
|
|
81
|
-
// Only enable as a default when `minVersionForCollab` is specified at
|
|
82
|
-
// 2.0.0+.
|
|
83
|
-
"2.0.0": true,
|
|
84
|
-
},
|
|
85
|
-
flushMode: {
|
|
86
|
-
// Note: 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode
|
|
87
|
-
// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as
|
|
88
|
-
// fewer messages will be included per flush.
|
|
89
|
-
"1.0.0": FlushMode.Immediate,
|
|
90
|
-
"2.0.0-defaults": FlushMode.TurnBased,
|
|
91
|
-
},
|
|
92
|
-
gcOptions: {
|
|
93
|
-
"1.0.0": {},
|
|
94
|
-
// Although sweep is supported in 2.x, it is disabled by default until minVersionForCollab>=3.0.0 to be extra safe.
|
|
95
|
-
"3.0.0": { enableGCSweep: true },
|
|
96
|
-
},
|
|
97
|
-
createBlobPayloadPending: {
|
|
98
|
-
// This feature is new and disabled by default. In the future we will enable it by default, but we have not
|
|
99
|
-
// closed on the version where that will happen yet. Probably a .10 release since blob functionality is not
|
|
100
|
-
// exposed on the `@public` API surface.
|
|
101
|
-
"1.0.0": undefined,
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
const runtimeOptionsAffectingDocSchemaConfigValidationMap = {
|
|
105
|
-
enableGroupedBatching: configValueToMinVersionForCollab([
|
|
106
|
-
[false, "1.0.0"],
|
|
107
|
-
[true, "2.0.0-defaults"],
|
|
108
|
-
]),
|
|
109
|
-
compressionOptions: configValueToMinVersionForCollab([
|
|
110
|
-
[{ ...disabledCompressionConfig }, "1.0.0"],
|
|
111
|
-
[{ ...enabledCompressionConfig }, "2.0.0-defaults"],
|
|
112
|
-
]),
|
|
113
|
-
enableRuntimeIdCompressor: configValueToMinVersionForCollab([
|
|
114
|
-
[undefined, "1.0.0"],
|
|
115
|
-
["on", "2.0.0-defaults"],
|
|
116
|
-
["delayed", "2.0.0-defaults"],
|
|
117
|
-
]),
|
|
118
|
-
explicitSchemaControl: configValueToMinVersionForCollab([
|
|
119
|
-
[false, "1.0.0"],
|
|
120
|
-
[true, "2.0.0-defaults"],
|
|
121
|
-
]),
|
|
122
|
-
flushMode: configValueToMinVersionForCollab([
|
|
123
|
-
[FlushMode.Immediate, "1.0.0"],
|
|
124
|
-
[FlushMode.TurnBased, "2.0.0-defaults"],
|
|
125
|
-
]),
|
|
126
|
-
gcOptions: configValueToMinVersionForCollab([
|
|
127
|
-
[{ enableGCSweep: undefined }, "1.0.0"],
|
|
128
|
-
[{ enableGCSweep: true }, "2.0.0-defaults"],
|
|
129
|
-
]),
|
|
130
|
-
createBlobPayloadPending: configValueToMinVersionForCollab([
|
|
131
|
-
[undefined, "1.0.0"],
|
|
132
|
-
[true, "2.40.0"],
|
|
133
|
-
]),
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Returns the default RuntimeOptionsAffectingDocSchema configuration for a given minVersionForCollab.
|
|
137
|
-
*/
|
|
138
|
-
export function getMinVersionForCollabDefaults(minVersionForCollab) {
|
|
139
|
-
return getConfigsForMinVersionForCollab(minVersionForCollab, runtimeOptionsAffectingDocSchemaConfigMap);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Returns a default configuration given minVersionForCollab and configuration version map.
|
|
143
|
-
*/
|
|
144
|
-
export function getConfigsForMinVersionForCollab(minVersionForCollab, configMap) {
|
|
145
|
-
const defaultConfigs = {};
|
|
146
|
-
// Iterate over configMap to get default values for each option.
|
|
147
|
-
for (const key of Object.keys(configMap)) {
|
|
148
|
-
const config = configMap[key];
|
|
149
|
-
// Sort the versions in ascending order so we can short circuit the loop.
|
|
150
|
-
const versions = Object.keys(config).sort(compare);
|
|
151
|
-
// For each config, we iterate over the keys and check if minVersionForCollab is greater than or equal to the version.
|
|
152
|
-
// 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
|
|
153
|
-
// value that is compatible with the version specified as the minVersionForCollab.
|
|
154
|
-
for (const version of versions) {
|
|
155
|
-
if (gte(minVersionForCollab, version)) {
|
|
156
|
-
defaultConfigs[key] = config[version];
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
// If the minVersionForCollab is less than the version, we break out of the loop since we don't need to check
|
|
160
|
-
// any later versions.
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return defaultConfigs;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Checks if the minVersionForCollab is valid.
|
|
169
|
-
* A valid minVersionForCollab is a MinimumVersionForCollab that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
170
|
-
*/
|
|
171
|
-
export function isValidMinVersionForCollab(minVersionForCollab) {
|
|
172
|
-
return (valid(minVersionForCollab) !== null &&
|
|
173
|
-
gte(minVersionForCollab, lowestMinVersionForCollab) &&
|
|
174
|
-
lte(minVersionForCollab, pkgVersion));
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Validates if the runtime options passed in from the user are compatible with the minVersionForCollab.
|
|
178
|
-
* For example, if a user sets the `enableGroupedBatching` option to true, but the minVersionForCollab
|
|
179
|
-
* is set to "1.0.0", then we should throw a UsageError since 1.x clients do not support batching.
|
|
180
|
-
* */
|
|
181
|
-
export function validateRuntimeOptions(minVersionForCollab, runtimeOptions) {
|
|
182
|
-
getValidationForRuntimeOptions(minVersionForCollab, runtimeOptions, runtimeOptionsAffectingDocSchemaConfigValidationMap);
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Generic function to validate runtime options against the minVersionForCollab.
|
|
186
|
-
*/
|
|
187
|
-
export function getValidationForRuntimeOptions(minVersionForCollab, runtimeOptions, validationMap) {
|
|
188
|
-
if (minVersionForCollab === defaultMinVersionForCollab) {
|
|
189
|
-
// If the minVersionForCollab is set to the default value, then we will not validate the runtime options
|
|
190
|
-
// This is to avoid disruption to users who have not yet set the minVersionForCollab value explicitly.
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
// Iterate through each runtime option passed in by the user
|
|
194
|
-
for (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(runtimeOptions)) {
|
|
195
|
-
// Skip if passedRuntimeOption is not in validation map
|
|
196
|
-
if (!(passedRuntimeOption in validationMap)) {
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
const requiredVersion = validationMap[passedRuntimeOption](passedRuntimeOptionValue);
|
|
200
|
-
if (requiredVersion !== undefined && gt(requiredVersion, minVersionForCollab)) {
|
|
201
|
-
throw new UsageError(`Runtime option ${passedRuntimeOption}:${JSON.stringify(passedRuntimeOptionValue)} requires ` +
|
|
202
|
-
`runtime version ${requiredVersion}. Please update minVersionForCollab ` +
|
|
203
|
-
`(currently ${minVersionForCollab}) to ${requiredVersion} or later to proceed.`);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Helper function to map ContainerRuntimeOptionsInternal config values to
|
|
209
|
-
* minVersionForCollab in {@link runtimeOptionsAffectingDocSchemaConfigValidationMap}.
|
|
210
|
-
*/
|
|
211
|
-
export function configValueToMinVersionForCollab(configToMinVer) {
|
|
212
|
-
const configValueToRequiredVersionMap = new Map(configToMinVer);
|
|
213
|
-
return (configValue) => {
|
|
214
|
-
// If the configValue is not an object then we can get the version required directly from the map.
|
|
215
|
-
if (typeof configValue !== "object") {
|
|
216
|
-
return configValueToRequiredVersionMap.get(configValue);
|
|
217
|
-
}
|
|
218
|
-
// When the input `configValue` is an object, this logic determines the minimum runtime version it requires.
|
|
219
|
-
// It iterates through each entry in `configValueToRequiredVersionMap`. If `possibleConfigValue` shares at
|
|
220
|
-
// least one key-value pair with the input `configValue`, its associated `versionRequired` is collected into
|
|
221
|
-
// `matchingVersions`. After checking all entries, the highest among the collected versions is returned.
|
|
222
|
-
// This represents the overall minimum version required to support the features implied by the input `configValue`.
|
|
223
|
-
const matchingVersions = [];
|
|
224
|
-
for (const [possibleConfigValue, versionRequired,] of configValueToRequiredVersionMap.entries()) {
|
|
225
|
-
assert(typeof possibleConfigValue == "object", 0xbb9 /* possibleConfigValue should be an object */);
|
|
226
|
-
// Check if `possibleConfigValue` and the input `configValue` share at least one
|
|
227
|
-
// common key-value pair. If they do, the `versionRequired` for this `possibleConfigValue`
|
|
228
|
-
// is added to `matchingVersions`.
|
|
229
|
-
if (Object.entries(possibleConfigValue).some(([k, v]) => configValue[k] === v)) {
|
|
230
|
-
matchingVersions.push(versionRequired);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
if (matchingVersions.length > 0) {
|
|
234
|
-
// Return the latest minVersionForCollab among all matches.
|
|
235
|
-
return matchingVersions.sort((a, b) => compare(b, a))[0];
|
|
236
|
-
}
|
|
237
|
-
// If no matches then we return undefined. This means that the config value passed in
|
|
238
|
-
// does not require a specific minVersionForCollab to be valid.
|
|
239
|
-
return undefined;
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
//# sourceMappingURL=compatUtils.js.map
|
package/lib/compatUtils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compatUtils.js","sourceRoot":"","sources":["../src/compatUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,EACN,yBAAyB,EACzB,wBAAwB,GACxB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACtC,gBAA2D,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,yBAAyB,GAAG,OAAkD,CAAC;AAuErF;;;;;;;;;;;;GAYG;AACH,MAAM,yCAAyC,GAAG;IACjD,qBAAqB,EAAE;QACtB,OAAO,EAAE,KAAK;QACd,gBAAgB,EAAE,IAAI;KACtB;IACD,kBAAkB,EAAE;QACnB,OAAO,EAAE,yBAAyB;QAClC,gBAAgB,EAAE,wBAAwB;KAC1C;IACD,yBAAyB,EAAE;QAC1B,sEAAsE;QACtE,sDAAsD;QACtD,mEAAmE;QACnE,yDAAyD;QACzD,OAAO,E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corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { compare, gt, gte, lte, valid } from \"semver-ts\";\n\nimport {\n\tdisabledCompressionConfig,\n\tenabledCompressionConfig,\n} from \"./compressionDefinitions.js\";\nimport type { ContainerRuntimeOptionsInternal } from \"./containerRuntime.js\";\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 */\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 */\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 *\n * @legacy\n * @alpha\n */\nexport type MinimumVersionForCollab =\n\t| `${1 | 2}.${bigint}.${bigint}`\n\t| `${1 | 2}.${bigint}.${bigint}-${string}`;\n\n/**\n * String in a valid semver format of a specific version at least specifying minor.\n * Unlike {@link 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 */\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 */\nexport type ConfigValidationMap<T extends Record<string, unknown>> = {\n\t[K in keyof T]-?: (configValue: T[K]) => SemanticVersion | undefined;\n};\n\n/**\n * Subset of the {@link ContainerRuntimeOptionsInternal} properties which\n * affect {@link IDocumentSchemaFeatures}.\n *\n * @remarks\n * When a new option is added to {@link ContainerRuntimeOptionsInternal}, we\n * must consider if it changes the DocumentSchema. If so, then a corresponding\n * entry must be added to {@link runtimeOptionsAffectingDocSchemaConfigMap}\n * below. If not, then it must be omitted from this type.\n *\n * Note: `Omit` is used instead of `Pick` to ensure that all new options are\n * included in this type by default. If any new properties are added to\n * {@link ContainerRuntimeOptionsInternal}, they will be included in this\n * type unless explicitly omitted. This will prevent us from forgetting to\n * account for any new properties in the future.\n */\nexport type RuntimeOptionsAffectingDocSchema = Omit<\n\tContainerRuntimeOptionsInternal,\n\t| \"chunkSizeInBytes\"\n\t| \"maxBatchSizeInBytes\"\n\t| \"loadSequenceNumberVerification\"\n\t| \"summaryOptions\"\n>;\n\n/**\n * Mapping of RuntimeOptionsAffectingDocSchema to their compatibility related configs.\n *\n * Each key in this map corresponds to a property in RuntimeOptionsAffectingDocSchema. The value is an object that maps MinimumVersionForCollab\n * to the appropriate default value for that property to supporting that MinimumVersionForCollab. If clients running MinimumVersionForCollab X are able to understand\n * the format changes introduced by the property, then the default value for that MinimumVersionForCollab will enable the feature associated with the property.\n * Otherwise, the feature will be disabled.\n *\n * 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\n * 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\n * default value for `enableGroupedBatching` will be true because clients running 2.0 or later will be able to understand the format changes associated\n * with the batching feature.\n */\nconst runtimeOptionsAffectingDocSchemaConfigMap = {\n\tenableGroupedBatching: {\n\t\t\"1.0.0\": false,\n\t\t\"2.0.0-defaults\": true,\n\t},\n\tcompressionOptions: {\n\t\t\"1.0.0\": disabledCompressionConfig,\n\t\t\"2.0.0-defaults\": enabledCompressionConfig,\n\t},\n\tenableRuntimeIdCompressor: {\n\t\t// For IdCompressorMode, `undefined` represents a logical state (off).\n\t\t// However, to satisfy the Required<> constraint while\n\t\t// `exactOptionalPropertyTypes` is `false` (TODO: AB#8215), we need\n\t\t// to have it defined, so we trick the type checker here.\n\t\t\"1.0.0\": undefined,\n\t\t// We do not yet want to enable idCompressor by default since it will\n\t\t// increase bundle sizes, and not all customers will benefit from it.\n\t\t// Therefore, we will require customers to explicitly enable it. We\n\t\t// are keeping it as a DocSchema affecting option for now as this may\n\t\t// change in the future.\n\t},\n\texplicitSchemaControl: {\n\t\t\"1.0.0\": false,\n\t\t// This option's intention is to prevent 1.x clients from joining sessions\n\t\t// when enabled. This is set to true when the minVersionForCollab is set\n\t\t// to >=2.0.0 (explicitly). This is different than other 2.0 defaults\n\t\t// because it was not enabled by default prior to the implementation of\n\t\t// `minVersionForCollab`.\n\t\t// `defaultMinVersionForCollab` is set to \"2.0.0-defaults\" which \"2.0.0\"\n\t\t// does not satisfy to avoiding enabling this option by default as of\n\t\t// `minVersionForCollab` introduction, which could be unexpected.\n\t\t// Only enable as a default when `minVersionForCollab` is specified at\n\t\t// 2.0.0+.\n\t\t\"2.0.0\": true,\n\t},\n\tflushMode: {\n\t\t// Note: 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode\n\t\t// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as\n\t\t// fewer messages will be included per flush.\n\t\t\"1.0.0\": FlushMode.Immediate,\n\t\t\"2.0.0-defaults\": FlushMode.TurnBased,\n\t},\n\tgcOptions: {\n\t\t\"1.0.0\": {},\n\t\t// Although sweep is supported in 2.x, it is disabled by default until minVersionForCollab>=3.0.0 to be extra safe.\n\t\t\"3.0.0\": { enableGCSweep: true },\n\t},\n\tcreateBlobPayloadPending: {\n\t\t// This feature is new and disabled by default. In the future we will enable it by default, but we have not\n\t\t// closed on the version where that will happen yet. Probably a .10 release since blob functionality is not\n\t\t// exposed on the `@public` API surface.\n\t\t\"1.0.0\": undefined,\n\t},\n} as const satisfies ConfigMap<RuntimeOptionsAffectingDocSchema>;\n\nconst runtimeOptionsAffectingDocSchemaConfigValidationMap = {\n\tenableGroupedBatching: configValueToMinVersionForCollab([\n\t\t[false, \"1.0.0\"],\n\t\t[true, \"2.0.0-defaults\"],\n\t]),\n\tcompressionOptions: configValueToMinVersionForCollab([\n\t\t[{ ...disabledCompressionConfig }, \"1.0.0\"],\n\t\t[{ ...enabledCompressionConfig }, \"2.0.0-defaults\"],\n\t]),\n\tenableRuntimeIdCompressor: configValueToMinVersionForCollab([\n\t\t[undefined, \"1.0.0\"],\n\t\t[\"on\", \"2.0.0-defaults\"],\n\t\t[\"delayed\", \"2.0.0-defaults\"],\n\t]),\n\texplicitSchemaControl: configValueToMinVersionForCollab([\n\t\t[false, \"1.0.0\"],\n\t\t[true, \"2.0.0-defaults\"],\n\t]),\n\tflushMode: configValueToMinVersionForCollab([\n\t\t[FlushMode.Immediate, \"1.0.0\"],\n\t\t[FlushMode.TurnBased, \"2.0.0-defaults\"],\n\t]),\n\tgcOptions: configValueToMinVersionForCollab([\n\t\t[{ enableGCSweep: undefined }, \"1.0.0\"],\n\t\t[{ enableGCSweep: true }, \"2.0.0-defaults\"],\n\t]),\n\tcreateBlobPayloadPending: configValueToMinVersionForCollab([\n\t\t[undefined, \"1.0.0\"],\n\t\t[true, \"2.40.0\"],\n\t]),\n} as const satisfies ConfigValidationMap<RuntimeOptionsAffectingDocSchema>;\n\n/**\n * Returns the default RuntimeOptionsAffectingDocSchema configuration for a given minVersionForCollab.\n */\nexport function getMinVersionForCollabDefaults(\n\tminVersionForCollab: MinimumVersionForCollab,\n): RuntimeOptionsAffectingDocSchema {\n\treturn getConfigsForMinVersionForCollab(\n\t\tminVersionForCollab,\n\t\truntimeOptionsAffectingDocSchemaConfigMap,\n\t\t// This is a bad cast away from Partial that getConfigsForCompatMode provides.\n\t\t// ConfigMap should be restructured to provide RuntimeOptionsAffectingDocSchema guarantee.\n\t) as RuntimeOptionsAffectingDocSchema;\n}\n\n/**\n * Returns a default configuration given minVersionForCollab and configuration version map.\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 */\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 * Validates if the runtime options passed in from the user are compatible with the minVersionForCollab.\n * For example, if a user sets the `enableGroupedBatching` option to true, but the minVersionForCollab\n * is set to \"1.0.0\", then we should throw a UsageError since 1.x clients do not support batching.\n * */\nexport function validateRuntimeOptions(\n\tminVersionForCollab: MinimumVersionForCollab,\n\truntimeOptions: Partial<ContainerRuntimeOptionsInternal>,\n): void {\n\tgetValidationForRuntimeOptions<RuntimeOptionsAffectingDocSchema>(\n\t\tminVersionForCollab,\n\t\truntimeOptions as Partial<RuntimeOptionsAffectingDocSchema>,\n\t\truntimeOptionsAffectingDocSchemaConfigValidationMap,\n\t);\n}\n\n/**\n * Generic function to validate runtime options against the minVersionForCollab.\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 {@link runtimeOptionsAffectingDocSchemaConfigValidationMap}.\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"]}
|