@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/src/dataStoreContext.ts
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
TypedEventEmitter,
|
|
8
|
+
type ILayerCompatDetails,
|
|
9
|
+
type IProvideLayerCompatDetails,
|
|
10
|
+
} from "@fluid-internal/client-utils";
|
|
7
11
|
import { AttachState, IAudience } from "@fluidframework/container-definitions";
|
|
8
12
|
import {
|
|
9
13
|
IDeltaManager,
|
|
@@ -25,7 +29,6 @@ import {
|
|
|
25
29
|
import { assert, LazyPromise, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
26
30
|
import { IClientDetails, IQuorumClients } from "@fluidframework/driver-definitions";
|
|
27
31
|
import {
|
|
28
|
-
IDocumentStorageService,
|
|
29
32
|
type ISnapshot,
|
|
30
33
|
IDocumentMessage,
|
|
31
34
|
ISnapshotTree,
|
|
@@ -63,6 +66,7 @@ import {
|
|
|
63
66
|
type IRuntimeMessageCollection,
|
|
64
67
|
type IFluidDataStoreFactory,
|
|
65
68
|
type PackagePath,
|
|
69
|
+
type IRuntimeStorageService,
|
|
66
70
|
} from "@fluidframework/runtime-definitions/internal";
|
|
67
71
|
import {
|
|
68
72
|
addBlobToSummary,
|
|
@@ -146,7 +150,7 @@ export interface IFluidDataStoreContextInternal extends IFluidDataStoreContext {
|
|
|
146
150
|
export interface IFluidDataStoreContextProps {
|
|
147
151
|
readonly id: string;
|
|
148
152
|
readonly parentContext: IFluidParentContextPrivate;
|
|
149
|
-
readonly storage:
|
|
153
|
+
readonly storage: IRuntimeStorageService;
|
|
150
154
|
readonly scope: FluidObject;
|
|
151
155
|
readonly createSummarizerNodeFn: CreateChildSummarizerNodeFn;
|
|
152
156
|
/**
|
|
@@ -243,7 +247,11 @@ class ContextDeltaManagerProxy extends BaseDeltaManagerProxy {
|
|
|
243
247
|
*/
|
|
244
248
|
export abstract class FluidDataStoreContext
|
|
245
249
|
extends TypedEventEmitter<IFluidDataStoreContextEvents>
|
|
246
|
-
implements
|
|
250
|
+
implements
|
|
251
|
+
IFluidDataStoreContextInternal,
|
|
252
|
+
IFluidDataStoreContext,
|
|
253
|
+
IDisposable,
|
|
254
|
+
IProvideLayerCompatDetails
|
|
247
255
|
{
|
|
248
256
|
public get packagePath(): PackagePath {
|
|
249
257
|
assert(this.pkg !== undefined, 0x139 /* "Undefined package path" */);
|
|
@@ -424,7 +432,7 @@ export abstract class FluidDataStoreContext
|
|
|
424
432
|
* The parent which provided this information currently can be the container runtime or a datastore (if the datastore this context is for is nested under another one).
|
|
425
433
|
*/
|
|
426
434
|
private readonly parentContext: IFluidParentContextPrivate;
|
|
427
|
-
public readonly storage:
|
|
435
|
+
public readonly storage: IRuntimeStorageService;
|
|
428
436
|
public readonly scope: FluidObject;
|
|
429
437
|
/**
|
|
430
438
|
* The loading group to which the data store belongs to.
|
package/src/index.ts
CHANGED
|
@@ -20,6 +20,12 @@ export {
|
|
|
20
20
|
} from "./containerRuntime.js";
|
|
21
21
|
export type { ICompressionRuntimeOptions } from "./compressionDefinitions.js";
|
|
22
22
|
export { CompressionAlgorithms, disabledCompressionConfig } from "./compressionDefinitions.js";
|
|
23
|
+
export {
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Import from `@fluidframework/runtime-definitions/legacy` instead.
|
|
26
|
+
*/
|
|
27
|
+
MinimumVersionForCollab,
|
|
28
|
+
} from "@fluidframework/runtime-definitions/internal";
|
|
23
29
|
export {
|
|
24
30
|
ContainerMessageType,
|
|
25
31
|
UnknownContainerRuntimeMessage,
|
|
@@ -31,7 +37,6 @@ export {
|
|
|
31
37
|
ChannelCollectionFactory,
|
|
32
38
|
AllowTombstoneRequestHeaderKey,
|
|
33
39
|
} from "./channelCollection.js";
|
|
34
|
-
export type { MinimumVersionForCollab, SemanticVersion } from "./compatUtils.js";
|
|
35
40
|
export {
|
|
36
41
|
GCNodeType,
|
|
37
42
|
IGCMetadata,
|
package/src/metadata.ts
CHANGED
|
@@ -46,10 +46,18 @@ export interface IBatchMetadata {
|
|
|
46
46
|
* Blob handling makes assumptions about what might be on the metadata. This interface codifies those assumptions, but does not validate them.
|
|
47
47
|
*/
|
|
48
48
|
export interface IBlobMetadata {
|
|
49
|
-
blobId
|
|
50
|
-
localId
|
|
49
|
+
blobId: string;
|
|
50
|
+
localId: string;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
export const isBlobMetadata = (metadata: unknown): metadata is IBlobMetadata => {
|
|
54
|
+
return (
|
|
55
|
+
!!metadata &&
|
|
56
|
+
typeof (metadata as IBlobMetadata).blobId === "string" &&
|
|
57
|
+
typeof (metadata as IBlobMetadata).localId === "string"
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
53
61
|
/**
|
|
54
62
|
* ContainerRuntime needs to know if this is a replayed savedOp as those need to be skipped in stashed ops scenarios.
|
|
55
63
|
*/
|
package/src/packageVersion.ts
CHANGED
|
@@ -4,23 +4,34 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
type FetchSource,
|
|
8
|
+
type ICreateBlobResponse,
|
|
9
|
+
type IDocumentStorageServicePolicies,
|
|
10
|
+
type ISnapshot,
|
|
11
|
+
type ISnapshotFetchOptions,
|
|
12
|
+
type ISnapshotTree,
|
|
13
|
+
type ISummaryContext,
|
|
14
|
+
type ISummaryHandle,
|
|
15
|
+
type ISummaryTree,
|
|
16
|
+
type IVersion,
|
|
9
17
|
} from "@fluidframework/driver-definitions/internal";
|
|
10
|
-
import {
|
|
18
|
+
import type { IRuntimeStorageService } from "@fluidframework/runtime-definitions/internal";
|
|
19
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
11
20
|
|
|
12
21
|
/**
|
|
13
|
-
*
|
|
22
|
+
* IRuntimeStorageService proxy which intercepts requests if they can be satisfied by the blobs received in the
|
|
14
23
|
* attach message. We use this to avoid an unnecessary request to the storage service.
|
|
15
24
|
*/
|
|
16
|
-
export class StorageServiceWithAttachBlobs
|
|
25
|
+
export class StorageServiceWithAttachBlobs implements IRuntimeStorageService {
|
|
17
26
|
constructor(
|
|
18
|
-
internalStorageService:
|
|
27
|
+
private readonly internalStorageService: IRuntimeStorageService,
|
|
19
28
|
private readonly attachBlobs: Map<string, ArrayBufferLike>,
|
|
20
|
-
) {
|
|
21
|
-
super(internalStorageService);
|
|
22
|
-
}
|
|
29
|
+
) {}
|
|
23
30
|
|
|
31
|
+
/**
|
|
32
|
+
* {@link IRuntimeStorageService.policies}.
|
|
33
|
+
* @deprecated - This will be removed in a future release. The DataStore layer does not need this.
|
|
34
|
+
*/
|
|
24
35
|
public get policies(): IDocumentStorageServicePolicies | undefined {
|
|
25
36
|
return this.internalStorageService.policies;
|
|
26
37
|
}
|
|
@@ -32,7 +43,78 @@ export class StorageServiceWithAttachBlobs extends DocumentStorageServiceProxy {
|
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
// Note that it is intentional not to cache the result of this readBlob - we'll trust the real
|
|
35
|
-
//
|
|
46
|
+
// IRuntimeStorageService to cache appropriately, no need to double-cache.
|
|
36
47
|
return this.internalStorageService.readBlob(id);
|
|
37
48
|
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* {@link IRuntimeStorageService.getSnapshotTree}.
|
|
52
|
+
* @deprecated - This will be removed in a future release. The DataStore layer does not need this.
|
|
53
|
+
*/
|
|
54
|
+
public async getSnapshotTree(
|
|
55
|
+
version?: IVersion,
|
|
56
|
+
scenarioName?: string,
|
|
57
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
|
58
|
+
): Promise<ISnapshotTree | null> {
|
|
59
|
+
return this.internalStorageService.getSnapshotTree(version, scenarioName);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* {@link IRuntimeStorageService.getSnapshot}.
|
|
64
|
+
* @deprecated - This will be removed in a future release. The DataStore layer does not need this.
|
|
65
|
+
*/
|
|
66
|
+
public async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {
|
|
67
|
+
if (this.internalStorageService.getSnapshot !== undefined) {
|
|
68
|
+
return this.internalStorageService.getSnapshot(snapshotFetchOptions);
|
|
69
|
+
}
|
|
70
|
+
throw new UsageError(
|
|
71
|
+
"getSnapshot api should exist on internal storage in documentStorageServiceProxy class",
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* {@link IRuntimeStorageService.getVersions}.
|
|
77
|
+
* @deprecated - This will be removed in a future release. The DataStore layer does not need this.
|
|
78
|
+
*/
|
|
79
|
+
public async getVersions(
|
|
80
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
|
81
|
+
versionId: string | null,
|
|
82
|
+
count: number,
|
|
83
|
+
scenarioName?: string,
|
|
84
|
+
fetchSource?: FetchSource,
|
|
85
|
+
): Promise<IVersion[]> {
|
|
86
|
+
return this.internalStorageService.getVersions(
|
|
87
|
+
versionId,
|
|
88
|
+
count,
|
|
89
|
+
scenarioName,
|
|
90
|
+
fetchSource,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* {@link IRuntimeStorageService.uploadSummaryWithContext}.
|
|
96
|
+
* @deprecated - This will be removed in a future release. The DataStore layer does not need this.
|
|
97
|
+
*/
|
|
98
|
+
public async uploadSummaryWithContext(
|
|
99
|
+
summary: ISummaryTree,
|
|
100
|
+
context: ISummaryContext,
|
|
101
|
+
): Promise<string> {
|
|
102
|
+
return this.internalStorageService.uploadSummaryWithContext(summary, context);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* {@link IRuntimeStorageService.createBlob}.
|
|
107
|
+
* @deprecated - This will be removed in a future release. The DataStore layer does not need this.
|
|
108
|
+
*/
|
|
109
|
+
public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {
|
|
110
|
+
return this.internalStorageService.createBlob(file);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* {@link IRuntimeStorageService.downloadSummary}.
|
|
115
|
+
* @deprecated - This will be removed in a future release. The DataStore layer does not need this.
|
|
116
|
+
*/
|
|
117
|
+
public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {
|
|
118
|
+
return this.internalStorageService.downloadSummary(handle);
|
|
119
|
+
}
|
|
38
120
|
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import type { SemanticVersion } from "@fluidframework/runtime-utils/internal";
|
|
7
8
|
import type { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
8
9
|
import { DataProcessingError } from "@fluidframework/telemetry-utils/internal";
|
|
9
10
|
import { gt, lt, parse } from "semver-ts";
|
|
10
11
|
|
|
11
|
-
import type { SemanticVersion } from "../compatUtils.js";
|
|
12
12
|
import { pkgVersion } from "../packageVersion.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { SummaryType } from "@fluidframework/driver-definitions";
|
|
8
8
|
import {
|
|
9
|
-
IDocumentStorageService,
|
|
10
9
|
ISnapshotTree,
|
|
11
10
|
ISequencedDocumentMessage,
|
|
12
11
|
} from "@fluidframework/driver-definitions/internal";
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
ISummaryTreeWithStats,
|
|
16
15
|
channelsTreeName,
|
|
17
16
|
gcTreeKey,
|
|
17
|
+
type IRuntimeStorageService,
|
|
18
18
|
} from "@fluidframework/runtime-definitions/internal";
|
|
19
19
|
|
|
20
20
|
import { blobsTreeName } from "../blobManager/index.js";
|
|
@@ -287,7 +287,7 @@ export function wrapSummaryInChannelsTree(summarizeResult: ISummaryTreeWithStats
|
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
export async function getFluidDataStoreAttributes(
|
|
290
|
-
storage:
|
|
290
|
+
storage: IRuntimeStorageService,
|
|
291
291
|
snapshot: ISnapshotTree,
|
|
292
292
|
): Promise<ReadFluidDataStoreAttributes> {
|
|
293
293
|
const attributes = await readAndParse<ReadFluidDataStoreAttributes>(
|
package/dist/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
|
|
@@ -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,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;KACzD,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG;QACjB,CAAC,OAAO,EAAE,2BAA2B,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7C;CACD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;KACnE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,eAAe,GAAG,SAAS;CACpE,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,gCAAgC,GAAG,IAAI,CAClD,+BAA+B,EAC7B,kBAAkB,GAClB,qBAAqB,GACrB,gCAAgC,GAChC,gBAAgB,CAClB,CAAC;AAsGF;;GAEG;AACH,wBAAgB,8BAA8B,CAC7C,mBAAmB,EAAE,uBAAuB,GAC1C,gCAAgC,CAOlC;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,CAAC,SAAS,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,EAC1F,mBAAmB,EAAE,eAAe,EACpC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,CAAC,CAqBZ;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACzC,mBAAmB,EAAE,uBAAuB,GAC1C,OAAO,CAMT;AAED;;;;KAIK;AACL,wBAAgB,sBAAsB,CACrC,mBAAmB,EAAE,uBAAuB,EAC5C,cAAc,EAAE,OAAO,CAAC,+BAA+B,CAAC,GACtD,IAAI,CAMN;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,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/dist/compatUtils.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
"use 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.validateRuntimeOptions = exports.isValidMinVersionForCollab = exports.getConfigsForMinVersionForCollab = exports.getMinVersionForCollabDefaults = exports.defaultMinVersionForCollab = void 0;
|
|
8
|
-
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
|
-
const internal_2 = require("@fluidframework/runtime-definitions/internal");
|
|
10
|
-
const internal_3 = require("@fluidframework/telemetry-utils/internal");
|
|
11
|
-
const semver_ts_1 = require("semver-ts");
|
|
12
|
-
const compressionDefinitions_js_1 = require("./compressionDefinitions.js");
|
|
13
|
-
const packageVersion_js_1 = require("./packageVersion.js");
|
|
14
|
-
/**
|
|
15
|
-
* Our policy is to support N/N-1 compatibility by default, where N is the most
|
|
16
|
-
* recent public major release of the runtime.
|
|
17
|
-
* Therefore, if the customer does not provide a minVersionForCollab, we will
|
|
18
|
-
* default to use N-1.
|
|
19
|
-
*
|
|
20
|
-
* However, this is not consistent with today's behavior. Some options (i.e.
|
|
21
|
-
* batching, compression) are enabled by default despite not being compatible
|
|
22
|
-
* with 1.x clients. Since the policy was introduced during 2.x's lifespan,
|
|
23
|
-
* N/N-1 compatibility by **default** will be in effect starting with 3.0.
|
|
24
|
-
* Importantly though, N/N-2 compatibility is still guaranteed with the proper
|
|
25
|
-
* configurations set.
|
|
26
|
-
*
|
|
27
|
-
* Further to distinguish unspecified `minVersionForCollab` from a specified
|
|
28
|
-
* version and allow `enableExplicitSchemaControl` to default to `true` for
|
|
29
|
-
* any 2.0.0+ version, we will use a special value of `2.0.0-defaults`, which
|
|
30
|
-
* is semantically less than 2.0.0.
|
|
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
|
-
* Mapping of RuntimeOptionsAffectingDocSchema to their compatibility related configs.
|
|
42
|
-
*
|
|
43
|
-
* Each key in this map corresponds to a property in RuntimeOptionsAffectingDocSchema. The value is an object that maps MinimumVersionForCollab
|
|
44
|
-
* to the appropriate default value for that property to supporting that MinimumVersionForCollab. If clients running MinimumVersionForCollab X are able to understand
|
|
45
|
-
* the format changes introduced by the property, then the default value for that MinimumVersionForCollab will enable the feature associated with the property.
|
|
46
|
-
* Otherwise, the feature will be disabled.
|
|
47
|
-
*
|
|
48
|
-
* 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
|
|
49
|
-
* 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
|
|
50
|
-
* default value for `enableGroupedBatching` will be true because clients running 2.0 or later will be able to understand the format changes associated
|
|
51
|
-
* with the batching feature.
|
|
52
|
-
*/
|
|
53
|
-
const runtimeOptionsAffectingDocSchemaConfigMap = {
|
|
54
|
-
enableGroupedBatching: {
|
|
55
|
-
"1.0.0": false,
|
|
56
|
-
"2.0.0-defaults": true,
|
|
57
|
-
},
|
|
58
|
-
compressionOptions: {
|
|
59
|
-
"1.0.0": compressionDefinitions_js_1.disabledCompressionConfig,
|
|
60
|
-
"2.0.0-defaults": compressionDefinitions_js_1.enabledCompressionConfig,
|
|
61
|
-
},
|
|
62
|
-
enableRuntimeIdCompressor: {
|
|
63
|
-
// For IdCompressorMode, `undefined` represents a logical state (off).
|
|
64
|
-
// However, to satisfy the Required<> constraint while
|
|
65
|
-
// `exactOptionalPropertyTypes` is `false` (TODO: AB#8215), we need
|
|
66
|
-
// to have it defined, so we trick the type checker here.
|
|
67
|
-
"1.0.0": undefined,
|
|
68
|
-
// We do not yet want to enable idCompressor by default since it will
|
|
69
|
-
// increase bundle sizes, and not all customers will benefit from it.
|
|
70
|
-
// Therefore, we will require customers to explicitly enable it. We
|
|
71
|
-
// are keeping it as a DocSchema affecting option for now as this may
|
|
72
|
-
// change in the future.
|
|
73
|
-
},
|
|
74
|
-
explicitSchemaControl: {
|
|
75
|
-
"1.0.0": false,
|
|
76
|
-
// This option's intention is to prevent 1.x clients from joining sessions
|
|
77
|
-
// when enabled. This is set to true when the minVersionForCollab is set
|
|
78
|
-
// to >=2.0.0 (explicitly). This is different than other 2.0 defaults
|
|
79
|
-
// because it was not enabled by default prior to the implementation of
|
|
80
|
-
// `minVersionForCollab`.
|
|
81
|
-
// `defaultMinVersionForCollab` is set to "2.0.0-defaults" which "2.0.0"
|
|
82
|
-
// does not satisfy to avoiding enabling this option by default as of
|
|
83
|
-
// `minVersionForCollab` introduction, which could be unexpected.
|
|
84
|
-
// Only enable as a default when `minVersionForCollab` is specified at
|
|
85
|
-
// 2.0.0+.
|
|
86
|
-
"2.0.0": true,
|
|
87
|
-
},
|
|
88
|
-
flushMode: {
|
|
89
|
-
// Note: 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode
|
|
90
|
-
// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as
|
|
91
|
-
// fewer messages will be included per flush.
|
|
92
|
-
"1.0.0": internal_2.FlushMode.Immediate,
|
|
93
|
-
"2.0.0-defaults": internal_2.FlushMode.TurnBased,
|
|
94
|
-
},
|
|
95
|
-
gcOptions: {
|
|
96
|
-
"1.0.0": {},
|
|
97
|
-
// Although sweep is supported in 2.x, it is disabled by default until minVersionForCollab>=3.0.0 to be extra safe.
|
|
98
|
-
"3.0.0": { enableGCSweep: true },
|
|
99
|
-
},
|
|
100
|
-
createBlobPayloadPending: {
|
|
101
|
-
// This feature is new and disabled by default. In the future we will enable it by default, but we have not
|
|
102
|
-
// closed on the version where that will happen yet. Probably a .10 release since blob functionality is not
|
|
103
|
-
// exposed on the `@public` API surface.
|
|
104
|
-
"1.0.0": undefined,
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
const runtimeOptionsAffectingDocSchemaConfigValidationMap = {
|
|
108
|
-
enableGroupedBatching: configValueToMinVersionForCollab([
|
|
109
|
-
[false, "1.0.0"],
|
|
110
|
-
[true, "2.0.0-defaults"],
|
|
111
|
-
]),
|
|
112
|
-
compressionOptions: configValueToMinVersionForCollab([
|
|
113
|
-
[{ ...compressionDefinitions_js_1.disabledCompressionConfig }, "1.0.0"],
|
|
114
|
-
[{ ...compressionDefinitions_js_1.enabledCompressionConfig }, "2.0.0-defaults"],
|
|
115
|
-
]),
|
|
116
|
-
enableRuntimeIdCompressor: configValueToMinVersionForCollab([
|
|
117
|
-
[undefined, "1.0.0"],
|
|
118
|
-
["on", "2.0.0-defaults"],
|
|
119
|
-
["delayed", "2.0.0-defaults"],
|
|
120
|
-
]),
|
|
121
|
-
explicitSchemaControl: configValueToMinVersionForCollab([
|
|
122
|
-
[false, "1.0.0"],
|
|
123
|
-
[true, "2.0.0-defaults"],
|
|
124
|
-
]),
|
|
125
|
-
flushMode: configValueToMinVersionForCollab([
|
|
126
|
-
[internal_2.FlushMode.Immediate, "1.0.0"],
|
|
127
|
-
[internal_2.FlushMode.TurnBased, "2.0.0-defaults"],
|
|
128
|
-
]),
|
|
129
|
-
gcOptions: configValueToMinVersionForCollab([
|
|
130
|
-
[{ enableGCSweep: undefined }, "1.0.0"],
|
|
131
|
-
[{ enableGCSweep: true }, "2.0.0-defaults"],
|
|
132
|
-
]),
|
|
133
|
-
createBlobPayloadPending: configValueToMinVersionForCollab([
|
|
134
|
-
[undefined, "1.0.0"],
|
|
135
|
-
[true, "2.40.0"],
|
|
136
|
-
]),
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* Returns the default RuntimeOptionsAffectingDocSchema configuration for a given minVersionForCollab.
|
|
140
|
-
*/
|
|
141
|
-
function getMinVersionForCollabDefaults(minVersionForCollab) {
|
|
142
|
-
return getConfigsForMinVersionForCollab(minVersionForCollab, runtimeOptionsAffectingDocSchemaConfigMap);
|
|
143
|
-
}
|
|
144
|
-
exports.getMinVersionForCollabDefaults = getMinVersionForCollabDefaults;
|
|
145
|
-
/**
|
|
146
|
-
* Returns a default configuration given minVersionForCollab and configuration version map.
|
|
147
|
-
*/
|
|
148
|
-
function getConfigsForMinVersionForCollab(minVersionForCollab, configMap) {
|
|
149
|
-
const defaultConfigs = {};
|
|
150
|
-
// Iterate over configMap to get default values for each option.
|
|
151
|
-
for (const key of Object.keys(configMap)) {
|
|
152
|
-
const config = configMap[key];
|
|
153
|
-
// Sort the versions in ascending order so we can short circuit the loop.
|
|
154
|
-
const versions = Object.keys(config).sort(semver_ts_1.compare);
|
|
155
|
-
// For each config, we iterate over the keys and check if minVersionForCollab is greater than or equal to the version.
|
|
156
|
-
// 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
|
|
157
|
-
// value that is compatible with the version specified as the minVersionForCollab.
|
|
158
|
-
for (const version of versions) {
|
|
159
|
-
if ((0, semver_ts_1.gte)(minVersionForCollab, version)) {
|
|
160
|
-
defaultConfigs[key] = config[version];
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
// If the minVersionForCollab is less than the version, we break out of the loop since we don't need to check
|
|
164
|
-
// any later versions.
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return defaultConfigs;
|
|
170
|
-
}
|
|
171
|
-
exports.getConfigsForMinVersionForCollab = getConfigsForMinVersionForCollab;
|
|
172
|
-
/**
|
|
173
|
-
* Checks if the minVersionForCollab is valid.
|
|
174
|
-
* A valid minVersionForCollab is a MinimumVersionForCollab that is at least `lowestMinVersionForCollab` and less than or equal to the current package version.
|
|
175
|
-
*/
|
|
176
|
-
function isValidMinVersionForCollab(minVersionForCollab) {
|
|
177
|
-
return ((0, semver_ts_1.valid)(minVersionForCollab) !== null &&
|
|
178
|
-
(0, semver_ts_1.gte)(minVersionForCollab, lowestMinVersionForCollab) &&
|
|
179
|
-
(0, semver_ts_1.lte)(minVersionForCollab, packageVersion_js_1.pkgVersion));
|
|
180
|
-
}
|
|
181
|
-
exports.isValidMinVersionForCollab = isValidMinVersionForCollab;
|
|
182
|
-
/**
|
|
183
|
-
* Validates if the runtime options passed in from the user are compatible with the minVersionForCollab.
|
|
184
|
-
* For example, if a user sets the `enableGroupedBatching` option to true, but the minVersionForCollab
|
|
185
|
-
* is set to "1.0.0", then we should throw a UsageError since 1.x clients do not support batching.
|
|
186
|
-
* */
|
|
187
|
-
function validateRuntimeOptions(minVersionForCollab, runtimeOptions) {
|
|
188
|
-
getValidationForRuntimeOptions(minVersionForCollab, runtimeOptions, runtimeOptionsAffectingDocSchemaConfigValidationMap);
|
|
189
|
-
}
|
|
190
|
-
exports.validateRuntimeOptions = validateRuntimeOptions;
|
|
191
|
-
/**
|
|
192
|
-
* Generic function to validate runtime options against the minVersionForCollab.
|
|
193
|
-
*/
|
|
194
|
-
function getValidationForRuntimeOptions(minVersionForCollab, runtimeOptions, validationMap) {
|
|
195
|
-
if (minVersionForCollab === exports.defaultMinVersionForCollab) {
|
|
196
|
-
// If the minVersionForCollab is set to the default value, then we will not validate the runtime options
|
|
197
|
-
// This is to avoid disruption to users who have not yet set the minVersionForCollab value explicitly.
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
// Iterate through each runtime option passed in by the user
|
|
201
|
-
for (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(runtimeOptions)) {
|
|
202
|
-
// Skip if passedRuntimeOption is not in validation map
|
|
203
|
-
if (!(passedRuntimeOption in validationMap)) {
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
const requiredVersion = validationMap[passedRuntimeOption](passedRuntimeOptionValue);
|
|
207
|
-
if (requiredVersion !== undefined && (0, semver_ts_1.gt)(requiredVersion, minVersionForCollab)) {
|
|
208
|
-
throw new internal_3.UsageError(`Runtime option ${passedRuntimeOption}:${JSON.stringify(passedRuntimeOptionValue)} requires ` +
|
|
209
|
-
`runtime version ${requiredVersion}. Please update minVersionForCollab ` +
|
|
210
|
-
`(currently ${minVersionForCollab}) to ${requiredVersion} or later to proceed.`);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
exports.getValidationForRuntimeOptions = getValidationForRuntimeOptions;
|
|
215
|
-
/**
|
|
216
|
-
* Helper function to map ContainerRuntimeOptionsInternal config values to
|
|
217
|
-
* minVersionForCollab in {@link runtimeOptionsAffectingDocSchemaConfigValidationMap}.
|
|
218
|
-
*/
|
|
219
|
-
function configValueToMinVersionForCollab(configToMinVer) {
|
|
220
|
-
const configValueToRequiredVersionMap = new Map(configToMinVer);
|
|
221
|
-
return (configValue) => {
|
|
222
|
-
// If the configValue is not an object then we can get the version required directly from the map.
|
|
223
|
-
if (typeof configValue !== "object") {
|
|
224
|
-
return configValueToRequiredVersionMap.get(configValue);
|
|
225
|
-
}
|
|
226
|
-
// When the input `configValue` is an object, this logic determines the minimum runtime version it requires.
|
|
227
|
-
// It iterates through each entry in `configValueToRequiredVersionMap`. If `possibleConfigValue` shares at
|
|
228
|
-
// least one key-value pair with the input `configValue`, its associated `versionRequired` is collected into
|
|
229
|
-
// `matchingVersions`. After checking all entries, the highest among the collected versions is returned.
|
|
230
|
-
// This represents the overall minimum version required to support the features implied by the input `configValue`.
|
|
231
|
-
const matchingVersions = [];
|
|
232
|
-
for (const [possibleConfigValue, versionRequired,] of configValueToRequiredVersionMap.entries()) {
|
|
233
|
-
(0, internal_1.assert)(typeof possibleConfigValue == "object", 0xbb9 /* possibleConfigValue should be an object */);
|
|
234
|
-
// Check if `possibleConfigValue` and the input `configValue` share at least one
|
|
235
|
-
// common key-value pair. If they do, the `versionRequired` for this `possibleConfigValue`
|
|
236
|
-
// is added to `matchingVersions`.
|
|
237
|
-
if (Object.entries(possibleConfigValue).some(([k, v]) => configValue[k] === v)) {
|
|
238
|
-
matchingVersions.push(versionRequired);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (matchingVersions.length > 0) {
|
|
242
|
-
// Return the latest minVersionForCollab among all matches.
|
|
243
|
-
return matchingVersions.sort((a, b) => (0, semver_ts_1.compare)(b, a))[0];
|
|
244
|
-
}
|
|
245
|
-
// If no matches then we return undefined. This means that the config value passed in
|
|
246
|
-
// does not require a specific minVersionForCollab to be valid.
|
|
247
|
-
return undefined;
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
exports.configValueToMinVersionForCollab = configValueToMinVersionForCollab;
|
|
251
|
-
//# sourceMappingURL=compatUtils.js.map
|