@fluidframework/runtime-utils 2.118.0 → 3.0.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 +34 -4
- package/README.md +53 -50
- package/{api-extractor.json → api-extractor/api-extractor-model.json} +1 -1
- package/dist/compatibilityBase.d.ts +27 -54
- package/dist/compatibilityBase.d.ts.map +1 -1
- package/dist/compatibilityBase.js +49 -74
- package/dist/compatibilityBase.js.map +1 -1
- package/dist/dataStoreHandleContextUtils.js +1 -2
- package/dist/dataStoreHandleContextUtils.js.map +1 -1
- package/dist/dataStoreHelpers.d.ts.map +1 -1
- package/dist/dataStoreHelpers.js +6 -6
- package/dist/dataStoreHelpers.js.map +1 -1
- package/dist/deltaManager.js +2 -3
- package/dist/deltaManager.js.map +1 -1
- package/dist/handles.d.ts +1 -1
- package/dist/handles.d.ts.map +1 -1
- package/dist/handles.js +7 -7
- package/dist/handles.js.map +1 -1
- package/dist/objectstoragepartition.js +2 -0
- package/dist/objectstoragepartition.js.map +1 -1
- package/dist/objectstorageutils.js +2 -3
- package/dist/objectstorageutils.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/remoteFluidObjectHandle.js +5 -1
- package/dist/remoteFluidObjectHandle.js.map +1 -1
- package/dist/requestParser.js +4 -0
- package/dist/requestParser.js.map +1 -1
- package/dist/serviceClientBase.js +14 -6
- package/dist/serviceClientBase.js.map +1 -1
- package/dist/serviceClientUtils.js +6 -4
- package/dist/serviceClientUtils.js.map +1 -1
- package/dist/snapshotUtils.js +1 -2
- package/dist/snapshotUtils.js.map +1 -1
- package/dist/summaryUtils.d.ts.map +1 -1
- package/dist/summaryUtils.js +18 -22
- package/dist/summaryUtils.js.map +1 -1
- package/dist/unpackUsedRoutes.js +1 -2
- package/dist/unpackUsedRoutes.js.map +1 -1
- package/dist/utils.js +3 -3
- package/dist/utils.js.map +1 -1
- package/lib/compatibilityBase.d.ts +27 -54
- package/lib/compatibilityBase.d.ts.map +1 -1
- package/lib/compatibilityBase.js +40 -65
- package/lib/compatibilityBase.js.map +1 -1
- package/lib/dataStoreHelpers.d.ts.map +1 -1
- package/lib/handles.d.ts +1 -1
- package/lib/handles.d.ts.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/legacyAlpha.d.ts +1 -1
- package/lib/objectstoragepartition.js +2 -0
- package/lib/objectstoragepartition.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/public.d.ts +1 -1
- package/lib/remoteFluidObjectHandle.js +5 -1
- package/lib/remoteFluidObjectHandle.js.map +1 -1
- package/lib/requestParser.js +4 -0
- package/lib/requestParser.js.map +1 -1
- package/lib/serviceClientBase.js +12 -4
- package/lib/serviceClientBase.js.map +1 -1
- package/lib/serviceClientUtils.js +2 -0
- package/lib/serviceClientUtils.js.map +1 -1
- package/lib/summaryUtils.d.ts.map +1 -1
- package/lib/summaryUtils.js +6 -10
- package/lib/summaryUtils.js.map +1 -1
- package/package.json +37 -54
- package/src/compatibilityBase.ts +62 -82
- package/src/packageVersion.ts +1 -1
- package/src/summaryUtils.ts +1 -3
- package/tsconfig.json +1 -1
- package/internal.d.ts +0 -11
- package/legacy/alpha.d.ts +0 -11
- package/legacy.d.ts +0 -11
- /package/api-extractor/{api-extractor.current.json → api-extractor-report.current.json} +0 -0
- /package/api-extractor/{api-extractor.legacy.json → api-extractor-report.legacy.json} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestParser.js","sourceRoot":"","sources":["../src/requestParser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;;GAGG;AACH,MAAa,aAAa;
|
|
1
|
+
{"version":3,"file":"requestParser.js","sourceRoot":"","sources":["../src/request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KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;YACvD,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC;IACH,CAAC;CACD;AA5FD,sCA4FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IRequest, IRequestHeader } from \"@fluidframework/core-interfaces\";\n\n/**\n * The Request Parser takes an IRequest provides parsing and sub request creation\n * @legacy @beta\n */\nexport class RequestParser implements IRequest {\n\t/**\n\t * Splits the path of the url and decodes each path part\n\t * @param url - the url to get path parts of\n\t */\n\tpublic static getPathParts(url: string): readonly string[] {\n\t\tconst queryStartIndex = url.indexOf(\"?\");\n\t\tconst pathParts: string[] = [];\n\t\tconst urlPath = url.slice(0, queryStartIndex < 0 ? url.length : queryStartIndex);\n\n\t\tfor (const part of urlPath.split(\"/\")) {\n\t\t\tif (part !== undefined && part.length > 0) {\n\t\t\t\tpathParts.push(decodeURIComponent(part));\n\t\t\t}\n\t\t}\n\n\t\treturn pathParts;\n\t}\n\n\tprivate requestPathParts: readonly string[] | undefined;\n\tpublic readonly query: string;\n\n\tpublic static create(request: Readonly<IRequest>): RequestParser {\n\t\t// Perf optimizations.\n\t\tif (request instanceof RequestParser) {\n\t\t\treturn request;\n\t\t}\n\t\treturn new RequestParser(request);\n\t}\n\n\tprotected constructor(private readonly request: Readonly<IRequest>) {\n\t\tconst queryStartIndex = this.request.url.indexOf(\"?\");\n\t\tthis.query = queryStartIndex >= 0 ? this.request.url.slice(queryStartIndex) : \"\";\n\t\tif (request.headers !== undefined) {\n\t\t\tthis.headers = request.headers;\n\t\t}\n\t}\n\n\tpublic get url(): string {\n\t\treturn this.request.url;\n\t}\n\n\tpublic readonly headers?: IRequestHeader;\n\n\t/**\n\t * Returns the decoded path parts of the request's url\n\t */\n\tpublic get pathParts(): readonly string[] {\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\tif (this.requestPathParts === undefined) {\n\t\t\tthis.requestPathParts = RequestParser.getPathParts(this.url);\n\t\t}\n\t\treturn this.requestPathParts;\n\t}\n\n\t/**\n\t * Returns true if it's a terminating path, i.e. no more elements after `elements` entries and empty query.\n\t * @param elements - number of elements in path\n\t */\n\tpublic isLeaf(elements: number): boolean {\n\t\treturn this.query === \"\" && this.pathParts.length === elements;\n\t}\n\n\t/**\n\t * Creates a sub request starting at a specific path part of this request's url\n\t * The sub request url always has a leading slash, and always include query params if original url has any\n\t * e.g. original url is /a/b/?queryParams, createSubRequest(0) is /a/b/?queryParams\n\t * createSubRequest(1) is /b/?queryParams\n\t * createSubRequest(2) is /?queryParams\n\t * createSubRequest(n) where n is bigger than parts length, e.g. 2, or n is less than 0 will throw an exception\n\t *\n\t * note: query params are not counted towards path parts.\n\t *\n\t * @param startingPathIndex - The index of the first path part of the sub request\n\t */\n\tpublic createSubRequest(startingPathIndex: number): IRequest {\n\t\tconst pathLen = this.pathParts.length;\n\t\tif (startingPathIndex < 0 || startingPathIndex > pathLen) {\n\t\t\tthrow new Error(\"incorrect sub-request\");\n\t\t}\n\t\tif (startingPathIndex === pathLen && this.url.includes(\"?\")) {\n\t\t\treturn {\n\t\t\t\turl: `/${this.query}`,\n\t\t\t\theaders: this.headers,\n\t\t\t};\n\t\t}\n\t\tconst path = `/${this.pathParts.slice(startingPathIndex).join(\"/\")}`;\n\t\treturn {\n\t\t\turl: this.query === \"\" ? path : `${path}/${this.query}`,\n\t\t\theaders: this.headers,\n\t\t};\n\t}\n}\n"]}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.ServiceContainerBase = exports.DataStoreKindImplementation = void 0;
|
|
8
|
+
exports.getContainerAudience = getContainerAudience;
|
|
8
9
|
const internal_1 = require("@fluidframework/container-definitions/internal");
|
|
9
10
|
const internal_2 = require("@fluidframework/core-interfaces/internal");
|
|
10
11
|
const internal_3 = require("@fluidframework/core-utils/internal");
|
|
@@ -18,6 +19,7 @@ const internal_5 = require("@fluidframework/telemetry-utils/internal");
|
|
|
18
19
|
* @internal
|
|
19
20
|
*/
|
|
20
21
|
class DataStoreKindImplementation extends internal_2.ErasedTypeImplementation {
|
|
22
|
+
factory;
|
|
21
23
|
/**
|
|
22
24
|
* Type guard for narrowing unions which contain DataStoreKind<T> to DataStoreKind<T>.
|
|
23
25
|
*/
|
|
@@ -32,6 +34,8 @@ class DataStoreKindImplementation extends internal_2.ErasedTypeImplementation {
|
|
|
32
34
|
throw new Error("Invalid DataStoreKindImplementation");
|
|
33
35
|
}
|
|
34
36
|
}
|
|
37
|
+
type;
|
|
38
|
+
createDataStore;
|
|
35
39
|
constructor(factory) {
|
|
36
40
|
super();
|
|
37
41
|
this.factory = factory;
|
|
@@ -68,6 +72,15 @@ exports.DataStoreKindImplementation = DataStoreKindImplementation;
|
|
|
68
72
|
* @internal
|
|
69
73
|
*/
|
|
70
74
|
class ServiceContainerBase extends internal_2.ErasedTypeImplementation {
|
|
75
|
+
registry;
|
|
76
|
+
options;
|
|
77
|
+
container;
|
|
78
|
+
data;
|
|
79
|
+
id;
|
|
80
|
+
/**
|
|
81
|
+
* True if an attempt to attach has been started. This is used to prevent multiple concurrent attach attempts.
|
|
82
|
+
*/
|
|
83
|
+
startedAttach = false;
|
|
71
84
|
constructor(registry, options, container, data, id) {
|
|
72
85
|
super();
|
|
73
86
|
this.registry = registry;
|
|
@@ -75,10 +88,6 @@ class ServiceContainerBase extends internal_2.ErasedTypeImplementation {
|
|
|
75
88
|
this.container = container;
|
|
76
89
|
this.data = data;
|
|
77
90
|
this.id = id;
|
|
78
|
-
/**
|
|
79
|
-
* True if an attempt to attach has been started. This is used to prevent multiple concurrent attach attempts.
|
|
80
|
-
*/
|
|
81
|
-
this.startedAttach = false;
|
|
82
91
|
}
|
|
83
92
|
/**
|
|
84
93
|
* Extracts the container ID from {@link ServiceContainerBase.container}'s resolved URL after attachment.
|
|
@@ -161,5 +170,4 @@ function getContainerAudience(container) {
|
|
|
161
170
|
ServiceContainerBase.narrow(container);
|
|
162
171
|
return container.audience;
|
|
163
172
|
}
|
|
164
|
-
exports.getContainerAudience = getContainerAudience;
|
|
165
173
|
//# sourceMappingURL=serviceClientBase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceClientBase.js","sourceRoot":"","sources":["../src/serviceClientBase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6EAA8F;AAE9F,uEAAoF;AACpF,kEAA6D;AAC7D,0EAOqD;AAOrD,uEAAsE;AAEtE;;GAEG;AAEH;;;GAGG;AACH,MAAa,2BACZ,SAAQ,mCAA0C;IAGlD;;OAEG;IACI,MAAM,CAAC,KAAK,CAClB,KAAQ;QAER,OAAO,KAAK,YAAY,2BAA2B,CAAC;IACrD,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,aAAa,CAC1B,KAAQ;QAKR,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACxD,CAAC;IACF,CAAC;IAOD,YACkB,OAGhB;QAED,KAAK,EAAE,CAAC;QALS,YAAO,GAAP,OAAO,CAGvB;QAGD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,OAAO,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YAC3C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9D,CAAC;IACF,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAChC,OAA+B,EAC/B,QAAiB;QAEjB,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAA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,MAAM,IAAI,GAAG,MAAM,IAAA,2BAAgB,EAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACxD,2BAA2B,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAE3C,+EAA+E;QAC/E,MAAM,OAAO,GAAG,gBAAgB,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACtE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAChE,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7D,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;QACpD,wEAAwE;QACxE,4EAA4E;QAC5E,OAAO,UAAe,CAAC;IACxB,CAAC;CACD;AAtHD,oDAsHC;AAeD;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAAC,SAAiC;IACrE,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACvC,OAAO,SAAS,CAAC,QAAQ,CAAC;AAC3B,CAAC;AAHD,oDAGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IAudience } from \"@fluidframework/container-definitions\";\nimport { AttachState, type IContainer } from \"@fluidframework/container-definitions/internal\";\nimport type { IRequest } from \"@fluidframework/core-interfaces\";\nimport { ErasedTypeImplementation } from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype DataStoreKey,\n\ttype DataStoreKind,\n\ttype FluidContainerAttached,\n\ttype FluidContainerWithService,\n\ttype Registry,\n\tlookupInRegistry,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIContainerRuntimeBase,\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n\tIFluidDataStoreFactory,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/*\n * This file provides common implementation logic for ServiceClient implementations.\n */\n\n/**\n * Implementation of `DataStoreKind`.\n * @internal\n */\nexport class DataStoreKindImplementation<T>\n\textends ErasedTypeImplementation<DataStoreKind<T>>\n\timplements DataStoreKind<T>, IFluidDataStoreFactory\n{\n\t/**\n\t * Type guard for narrowing unions which contain DataStoreKind<T> to DataStoreKind<T>.\n\t */\n\tpublic static guard<T>(\n\t\tvalue: T,\n\t): value is DataStoreKindImplementation<T extends DataStoreKind<infer T2> ? T2 : never> & T {\n\t\treturn value instanceof DataStoreKindImplementation;\n\t}\n\n\t/**\n\t * Type guard for narrowing unions which contain DataStoreKind<T> to DataStoreKind<T>.\n\t */\n\tpublic static narrowGeneric<T>(\n\t\tvalue: T,\n\t): asserts value is DataStoreKindImplementation<\n\t\tT extends DataStoreKind<infer T2> ? T2 : never\n\t> &\n\t\tT {\n\t\tif (!DataStoreKindImplementation.guard(value)) {\n\t\t\tthrow new Error(\"Invalid DataStoreKindImplementation\");\n\t\t}\n\t}\n\n\tpublic readonly type: string;\n\tpublic readonly createDataStore?: (context: IFluidDataStoreContext) => {\n\t\treadonly runtime: IFluidDataStoreChannel;\n\t};\n\n\tpublic constructor(\n\t\tprivate readonly factory: Pick<\n\t\t\tDataStoreKindImplementation<T>,\n\t\t\t\"type\" | \"instantiateDataStore\" | \"createDataStore\"\n\t\t>,\n\t) {\n\t\tsuper();\n\t\tthis.type = factory.type;\n\t\tif (factory.createDataStore !== undefined) {\n\t\t\tthis.createDataStore = factory.createDataStore.bind(factory);\n\t\t}\n\t}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<IFluidDataStoreChannel> {\n\t\treturn this.factory.instantiateDataStore(context, existing);\n\t}\n\n\tpublic get IFluidDataStoreFactory(): IFluidDataStoreFactory {\n\t\treturn this;\n\t}\n\n\tpublic async adapt(value: Promise<DataStoreKind>): Promise<DataStoreKind<T>> {\n\t\tconst input = await value;\n\t\tif (input === this) {\n\t\t\treturn this;\n\t\t}\n\t\tif (input.type === this.type) {\n\t\t\tthrow new UsageError(`Conflicting DataStoreKinds with same type: ${this.type}`);\n\t\t}\n\t\tthrow new UsageError(\n\t\t\t`Mismatched DataStoreKind type. Expected: ${this.type}, got: ${input.type}`,\n\t\t);\n\t}\n}\n\n/**\n * Shared base class for all `ServiceClient` container implementations.\n *\n * @remarks\n * Extends `ErasedTypeImplementation` so that\n * {@link getContainerAudience} can narrow via `ServiceContainerBase.narrow()`.\n *\n * @internal\n */\nexport abstract class ServiceContainerBase<TData, TOptions = unknown>\n\textends ErasedTypeImplementation<FluidContainerWithService<TData>>\n\timplements FluidContainerWithService<TData>\n{\n\t/**\n\t * True if an attempt to attach has been started. This is used to prevent multiple concurrent attach attempts.\n\t */\n\tprivate startedAttach = false;\n\n\tprotected constructor(\n\t\tpublic readonly registry: Registry<Promise<DataStoreKind<TData>>>,\n\t\tpublic readonly options: TOptions,\n\t\tpublic readonly container: IContainer,\n\t\tpublic readonly data: TData,\n\t\tpublic id: string | undefined,\n\t) {\n\t\tsuper();\n\t}\n\n\t/**\n\t * Creates the service-specific request used to attach this container.\n\t * @remarks\n\t * Called by {@link ServiceContainerBase.attach} after validating that no attach is already in progress.\n\t */\n\tprotected abstract createAttachRequest(): IRequest;\n\n\t/**\n\t * Extracts the container ID from {@link ServiceContainerBase.container}'s resolved URL after attachment.\n\t * @remarks\n\t * Override when the service's resolved URL stores the id in a non-standard field.\n\t */\n\tprotected getContainerId(): string {\n\t\tif (this.container.resolvedUrl === undefined) {\n\t\t\tthrow new Error(\"Resolved URL unexpectedly missing!\");\n\t\t}\n\t\treturn this.container.resolvedUrl.id;\n\t}\n\n\tpublic async attach(): Promise<FluidContainerAttached<TData>> {\n\t\tif (this.id !== undefined) {\n\t\t\tthrow new UsageError(\"Container already attached\");\n\t\t}\n\t\tif (this.startedAttach) {\n\t\t\tthrow new UsageError(\"Container attach already in progress\");\n\t\t}\n\n\t\tassert(\n\t\t\tthis.container.attachState === AttachState.Detached,\n\t\t\t0xd15 /* Container not detached */,\n\t\t);\n\t\tthis.startedAttach = true;\n\n\t\t// TODO: support setting where attach can fail, and leave the container in a valid (non-closed) state.\n\t\t// Likely the best way to support this is by adding a `tryAttach(request): Promise<FluidContainerAttached<TData> | undefined>`.\n\n\t\tawait this.container.attach(this.createAttachRequest());\n\t\t// This type cast is needed to work around the fact that TypeScript assumes the \"attach\" methods can't modify \"attachState\".\n\t\tassert(\n\t\t\tthis.container.attachState === (AttachState.Attached as AttachState),\n\t\t\t0xd16 /* Container failed to attach */,\n\t\t);\n\t\tthis.id = this.getContainerId();\n\t\treturn this as typeof this & { id: string };\n\t}\n\n\tpublic get audience(): IAudience {\n\t\treturn this.container.audience;\n\t}\n\n\tpublic getRuntime(): IContainerRuntimeBase {\n\t\t// The runtime is not part of the public IContainer surface, so it is reached via a structural cast.\n\t\t// This relies on an implementation detail of the containers produced by the loader\n\t\t// (createDetachedContainer / loadExistingContainer): they carry a `runtime` property.\n\t\t// The undefined guard below turns an incompatible container implementation into a clear error\n\t\t// instead of a confusing failure later when the missing runtime is used.\n\t\t// This is extra risky since IContainer is not marked sealed.\n\t\t// TODO: Replace this with a supported, type-safe accessor once the loader exposes one.\n\t\tinterface IContainerWithRuntime extends IContainer {\n\t\t\treadonly runtime?: IContainerRuntimeBase;\n\t\t}\n\n\t\tconst container = this.container as IContainerWithRuntime;\n\t\tif (container.runtime === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Container does not expose a runtime: incompatible container implementation.\",\n\t\t\t);\n\t\t}\n\t\treturn container.runtime;\n\t}\n\n\tpublic close(): void {\n\t\t// TODO: `container.close()` cancels the container runtime's GC timers, but a couple of\n\t\t// container-level timers are only bounded `setTimeout`s that survive close (they are not\n\t\t// cancelled here, nor even on `dispose`):\n\t\t// - The container-loader `NoopHeuristic` timer (~2s), which has no disposal hook.\n\t\t// - The container-runtime `SummaryManager` \"delay before creating summarizer\" timer, whose\n\t\t// pending timeout is not cleared when the SummaryManager is torn down.\n\t\t// These self-expire, so they do not cause indefinite hangs, but until they fire they keep the\n\t\t// Node.js event loop alive, delaying a clean process exit after close. That is a common reason\n\t\t// tests resort to Mocha's `--exit` flag. Ideally close() (via the runtime's close path) would\n\t\t// cancel these too so that closing a single container is sufficient to release all its timers.\n\t\tthis.container.close();\n\t}\n\n\tpublic async createDataStore<T>(key: DataStoreKey<T>): Promise<T> {\n\t\tconst kind = await lookupInRegistry(this.registry, key);\n\t\tDataStoreKindImplementation.narrowGeneric(kind);\n\t\tconst containerRuntime = this.getRuntime();\n\n\t\t// TODO: There should probably be a higher level more type safe way to do this.\n\t\tconst context = containerRuntime.createDetachedDataStore([kind.type]);\n\t\tconst channel = await kind.instantiateDataStore(context, false);\n\t\tconst dataStore = await context.attachRuntime(kind, channel);\n\t\tconst entryPoint = await dataStore.entryPoint.get();\n\t\t// The data store's entry point type is erased at the registry boundary;\n\t\t// the DataStoreKind<T> used to create it guarantees the entry point is a T.\n\t\treturn entryPoint as T;\n\t}\n}\n\n/**\n * All clients connected to the op stream, both read-only and read/write.\n * @remarks\n * Currently just {@link @fluidframework/container-definitions#IAudience}, but may diverge before stabilizing.\n * @privateRemarks\n * This is currently just an alias for IAudience, but it is defined separately to allow for:\n * 1. Following the no I prefix naming convention.\n * 2. The possibility of diverging from IAudience in the future if desired.\n * 3. Make it easy for the reexport from fluid-framework to be `@alpha` so the name is not locked down prematurely.\n * @sealed @alpha\n */\nexport type Audience = IAudience;\n\n/**\n * Gets the {@link Audience} from a Fluid container\n * created by any {@link @fluidframework/driver-definitions#ServiceClient}.\n * @privateRemarks\n * This is exposed via a free function rather than as a property of FluidContainerAttached\n * for a few minor reasons:\n * 1. This allows stabilizing the FluidContainerAttached API independently committing to how we want to expose the audience.\n * 2. This demonstrates the pattern of how we can have possible less stable APIs to expose service specific features without them being part of the core FluidContainer API.\n * This will be important for both new feature stabilization, and also exposing anything needed for legacy interop.\n * @alpha\n */\nexport function getContainerAudience(container: FluidContainerAttached): Audience {\n\tServiceContainerBase.narrow(container);\n\treturn container.audience;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serviceClientBase.js","sourceRoot":"","sources":["../src/serviceClientBase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA8PH,oDAGC;AA9PD,6EAA8F;AAE9F,uEAAoF;AACpF,kEAA6D;AAC7D,0EAOqD;AAOrD,uEAAsE;AAEtE;;GAEG;AAEH;;;GAGG;AACH,MAAa,2BACZ,SAAQ,mCAA0C;IAgChC;IA7BlB;;OAEG;IACI,MAAM,CAAC,KAAK,CAClB,KAAQ;QAER,OAAO,KAAK,YAAY,2BAA2B,CAAC;IACrD,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,aAAa,CAC1B,KAAQ;QAKR,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACxD,CAAC;IACF,CAAC;IAEe,IAAI,CAAS;IACb,eAAe,CAE7B;IAEF,YACkB,OAGhB;QAED,KAAK,EAAE,CAAC;QALS,YAAO,GAAP,OAAO,CAGvB;QAGD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,OAAO,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YAC3C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9D,CAAC;IACF,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAChC,OAA+B,EAC/B,QAAiB;QAEjB,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7D,CAAC;IAED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AA,2BAAgB,EAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACxD,2BAA2B,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAE3C,+EAA+E;QAC/E,MAAM,OAAO,GAAG,gBAAgB,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACtE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAChE,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7D,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;QACpD,wEAAwE;QACxE,4EAA4E;QAC5E,OAAO,UAAe,CAAC;IACxB,CAAC;CACD;AAtHD,oDAsHC;AAeD;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAAC,SAAiC;IACrE,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACvC,OAAO,SAAS,CAAC,QAAQ,CAAC;AAC3B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IAudience } from \"@fluidframework/container-definitions\";\nimport { AttachState, type IContainer } from \"@fluidframework/container-definitions/internal\";\nimport type { IRequest } from \"@fluidframework/core-interfaces\";\nimport { ErasedTypeImplementation } from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype DataStoreKey,\n\ttype DataStoreKind,\n\ttype FluidContainerAttached,\n\ttype FluidContainerWithService,\n\ttype Registry,\n\tlookupInRegistry,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIContainerRuntimeBase,\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n\tIFluidDataStoreFactory,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/*\n * This file provides common implementation logic for ServiceClient implementations.\n */\n\n/**\n * Implementation of `DataStoreKind`.\n * @internal\n */\nexport class DataStoreKindImplementation<T>\n\textends ErasedTypeImplementation<DataStoreKind<T>>\n\timplements DataStoreKind<T>, IFluidDataStoreFactory\n{\n\t/**\n\t * Type guard for narrowing unions which contain DataStoreKind<T> to DataStoreKind<T>.\n\t */\n\tpublic static guard<T>(\n\t\tvalue: T,\n\t): value is DataStoreKindImplementation<T extends DataStoreKind<infer T2> ? T2 : never> & T {\n\t\treturn value instanceof DataStoreKindImplementation;\n\t}\n\n\t/**\n\t * Type guard for narrowing unions which contain DataStoreKind<T> to DataStoreKind<T>.\n\t */\n\tpublic static narrowGeneric<T>(\n\t\tvalue: T,\n\t): asserts value is DataStoreKindImplementation<\n\t\tT extends DataStoreKind<infer T2> ? T2 : never\n\t> &\n\t\tT {\n\t\tif (!DataStoreKindImplementation.guard(value)) {\n\t\t\tthrow new Error(\"Invalid DataStoreKindImplementation\");\n\t\t}\n\t}\n\n\tpublic readonly type: string;\n\tpublic readonly createDataStore?: (context: IFluidDataStoreContext) => {\n\t\treadonly runtime: IFluidDataStoreChannel;\n\t};\n\n\tpublic constructor(\n\t\tprivate readonly factory: Pick<\n\t\t\tDataStoreKindImplementation<T>,\n\t\t\t\"type\" | \"instantiateDataStore\" | \"createDataStore\"\n\t\t>,\n\t) {\n\t\tsuper();\n\t\tthis.type = factory.type;\n\t\tif (factory.createDataStore !== undefined) {\n\t\t\tthis.createDataStore = factory.createDataStore.bind(factory);\n\t\t}\n\t}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<IFluidDataStoreChannel> {\n\t\treturn this.factory.instantiateDataStore(context, existing);\n\t}\n\n\tpublic get IFluidDataStoreFactory(): IFluidDataStoreFactory {\n\t\treturn this;\n\t}\n\n\tpublic async adapt(value: Promise<DataStoreKind>): Promise<DataStoreKind<T>> {\n\t\tconst input = await value;\n\t\tif (input === this) {\n\t\t\treturn this;\n\t\t}\n\t\tif (input.type === this.type) {\n\t\t\tthrow new UsageError(`Conflicting DataStoreKinds with same type: ${this.type}`);\n\t\t}\n\t\tthrow new UsageError(\n\t\t\t`Mismatched DataStoreKind type. Expected: ${this.type}, got: ${input.type}`,\n\t\t);\n\t}\n}\n\n/**\n * Shared base class for all `ServiceClient` container implementations.\n *\n * @remarks\n * Extends `ErasedTypeImplementation` so that\n * {@link getContainerAudience} can narrow via `ServiceContainerBase.narrow()`.\n *\n * @internal\n */\nexport abstract class ServiceContainerBase<TData, TOptions = unknown>\n\textends ErasedTypeImplementation<FluidContainerWithService<TData>>\n\timplements FluidContainerWithService<TData>\n{\n\t/**\n\t * True if an attempt to attach has been started. This is used to prevent multiple concurrent attach attempts.\n\t */\n\tprivate startedAttach = false;\n\n\tprotected constructor(\n\t\tpublic readonly registry: Registry<Promise<DataStoreKind<TData>>>,\n\t\tpublic readonly options: TOptions,\n\t\tpublic readonly container: IContainer,\n\t\tpublic readonly data: TData,\n\t\tpublic id: string | undefined,\n\t) {\n\t\tsuper();\n\t}\n\n\t/**\n\t * Creates the service-specific request used to attach this container.\n\t * @remarks\n\t * Called by {@link ServiceContainerBase.attach} after validating that no attach is already in progress.\n\t */\n\tprotected abstract createAttachRequest(): IRequest;\n\n\t/**\n\t * Extracts the container ID from {@link ServiceContainerBase.container}'s resolved URL after attachment.\n\t * @remarks\n\t * Override when the service's resolved URL stores the id in a non-standard field.\n\t */\n\tprotected getContainerId(): string {\n\t\tif (this.container.resolvedUrl === undefined) {\n\t\t\tthrow new Error(\"Resolved URL unexpectedly missing!\");\n\t\t}\n\t\treturn this.container.resolvedUrl.id;\n\t}\n\n\tpublic async attach(): Promise<FluidContainerAttached<TData>> {\n\t\tif (this.id !== undefined) {\n\t\t\tthrow new UsageError(\"Container already attached\");\n\t\t}\n\t\tif (this.startedAttach) {\n\t\t\tthrow new UsageError(\"Container attach already in progress\");\n\t\t}\n\n\t\tassert(\n\t\t\tthis.container.attachState === AttachState.Detached,\n\t\t\t0xd15 /* Container not detached */,\n\t\t);\n\t\tthis.startedAttach = true;\n\n\t\t// TODO: support setting where attach can fail, and leave the container in a valid (non-closed) state.\n\t\t// Likely the best way to support this is by adding a `tryAttach(request): Promise<FluidContainerAttached<TData> | undefined>`.\n\n\t\tawait this.container.attach(this.createAttachRequest());\n\t\t// This type cast is needed to work around the fact that TypeScript assumes the \"attach\" methods can't modify \"attachState\".\n\t\tassert(\n\t\t\tthis.container.attachState === (AttachState.Attached as AttachState),\n\t\t\t0xd16 /* Container failed to attach */,\n\t\t);\n\t\tthis.id = this.getContainerId();\n\t\treturn this as typeof this & { id: string };\n\t}\n\n\tpublic get audience(): IAudience {\n\t\treturn this.container.audience;\n\t}\n\n\tpublic getRuntime(): IContainerRuntimeBase {\n\t\t// The runtime is not part of the public IContainer surface, so it is reached via a structural cast.\n\t\t// This relies on an implementation detail of the containers produced by the loader\n\t\t// (createDetachedContainer / loadExistingContainer): they carry a `runtime` property.\n\t\t// The undefined guard below turns an incompatible container implementation into a clear error\n\t\t// instead of a confusing failure later when the missing runtime is used.\n\t\t// This is extra risky since IContainer is not marked sealed.\n\t\t// TODO: Replace this with a supported, type-safe accessor once the loader exposes one.\n\t\tinterface IContainerWithRuntime extends IContainer {\n\t\t\treadonly runtime?: IContainerRuntimeBase;\n\t\t}\n\n\t\tconst container = this.container as IContainerWithRuntime;\n\t\tif (container.runtime === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Container does not expose a runtime: incompatible container implementation.\",\n\t\t\t);\n\t\t}\n\t\treturn container.runtime;\n\t}\n\n\tpublic close(): void {\n\t\t// TODO: `container.close()` cancels the container runtime's GC timers, but a couple of\n\t\t// container-level timers are only bounded `setTimeout`s that survive close (they are not\n\t\t// cancelled here, nor even on `dispose`):\n\t\t// - The container-loader `NoopHeuristic` timer (~2s), which has no disposal hook.\n\t\t// - The container-runtime `SummaryManager` \"delay before creating summarizer\" timer, whose\n\t\t// pending timeout is not cleared when the SummaryManager is torn down.\n\t\t// These self-expire, so they do not cause indefinite hangs, but until they fire they keep the\n\t\t// Node.js event loop alive, delaying a clean process exit after close. That is a common reason\n\t\t// tests resort to Mocha's `--exit` flag. Ideally close() (via the runtime's close path) would\n\t\t// cancel these too so that closing a single container is sufficient to release all its timers.\n\t\tthis.container.close();\n\t}\n\n\tpublic async createDataStore<T>(key: DataStoreKey<T>): Promise<T> {\n\t\tconst kind = await lookupInRegistry(this.registry, key);\n\t\tDataStoreKindImplementation.narrowGeneric(kind);\n\t\tconst containerRuntime = this.getRuntime();\n\n\t\t// TODO: There should probably be a higher level more type safe way to do this.\n\t\tconst context = containerRuntime.createDetachedDataStore([kind.type]);\n\t\tconst channel = await kind.instantiateDataStore(context, false);\n\t\tconst dataStore = await context.attachRuntime(kind, channel);\n\t\tconst entryPoint = await dataStore.entryPoint.get();\n\t\t// The data store's entry point type is erased at the registry boundary;\n\t\t// the DataStoreKind<T> used to create it guarantees the entry point is a T.\n\t\treturn entryPoint as T;\n\t}\n}\n\n/**\n * All clients connected to the op stream, both read-only and read/write.\n * @remarks\n * Currently just {@link @fluidframework/container-definitions#IAudience}, but may diverge before stabilizing.\n * @privateRemarks\n * This is currently just an alias for IAudience, but it is defined separately to allow for:\n * 1. Following the no I prefix naming convention.\n * 2. The possibility of diverging from IAudience in the future if desired.\n * 3. Make it easy for the reexport from fluid-framework to be `@alpha` so the name is not locked down prematurely.\n * @sealed @alpha\n */\nexport type Audience = IAudience;\n\n/**\n * Gets the {@link Audience} from a Fluid container\n * created by any {@link @fluidframework/driver-definitions#ServiceClient}.\n * @privateRemarks\n * This is exposed via a free function rather than as a property of FluidContainerAttached\n * for a few minor reasons:\n * 1. This allows stabilizing the FluidContainerAttached API independently committing to how we want to expose the audience.\n * 2. This demonstrates the pattern of how we can have possible less stable APIs to expose service specific features without them being part of the core FluidContainer API.\n * This will be important for both new feature stabilization, and also exposing anything needed for legacy interop.\n * @alpha\n */\nexport function getContainerAudience(container: FluidContainerAttached): Audience {\n\tServiceContainerBase.narrow(container);\n\treturn container.audience;\n}\n"]}
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ServiceClientImplementation = exports.
|
|
7
|
+
exports.ServiceClientImplementation = exports.rootDataStoreId = void 0;
|
|
8
|
+
exports.convertRegistry = convertRegistry;
|
|
9
|
+
exports.normalizeRegistry = normalizeRegistry;
|
|
10
|
+
exports.makeCodeLoader = makeCodeLoader;
|
|
8
11
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
12
|
const internal_2 = require("@fluidframework/driver-definitions/internal");
|
|
10
13
|
const serviceClientBase_js_1 = require("./serviceClientBase.js");
|
|
@@ -33,7 +36,6 @@ function convertRegistry(registry) {
|
|
|
33
36
|
},
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
|
-
exports.convertRegistry = convertRegistry;
|
|
37
39
|
/**
|
|
38
40
|
* Normalizes a `DataStoreKind` or registry function into a registry function.
|
|
39
41
|
* @internal
|
|
@@ -45,7 +47,6 @@ function normalizeRegistry(input) {
|
|
|
45
47
|
(0, internal_1.assert)(typeof input === "function", 0xd17 /* Registry must be a function */);
|
|
46
48
|
return input;
|
|
47
49
|
}
|
|
48
|
-
exports.normalizeRegistry = normalizeRegistry;
|
|
49
50
|
/**
|
|
50
51
|
* Creates an `ICodeDetailsLoader` that wires up the container runtime via the supplied
|
|
51
52
|
* `loadRuntime` callback.
|
|
@@ -99,13 +100,14 @@ function makeCodeLoader(registry, minVersionForCollab, loadRuntime, root) {
|
|
|
99
100
|
},
|
|
100
101
|
};
|
|
101
102
|
}
|
|
102
|
-
exports.makeCodeLoader = makeCodeLoader;
|
|
103
103
|
/**
|
|
104
104
|
* Creates a {@link @fluidframework/driver-definitions#ServiceClient} that delegates container
|
|
105
105
|
* creation and loading to the supplied container class statics.
|
|
106
106
|
* @internal
|
|
107
107
|
*/
|
|
108
108
|
class ServiceClientImplementation {
|
|
109
|
+
options;
|
|
110
|
+
statics;
|
|
109
111
|
constructor(options, statics) {
|
|
110
112
|
this.options = options;
|
|
111
113
|
this.statics = statics;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceClientUtils.js","sourceRoot":"","sources":["../src/serviceClientUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAYH,kEAA6D;AAC7D,0EAUqD;AAQrD,iEAAqE;AAErE;;;GAGG;AACU,QAAA,eAAe,GAAG,MAAM,CAAC;AAEtC;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAI,QAA8B;IAChE,OAAO;QACN,KAAK,CAAC,GAAG,CAAC,IAAY;YACrB,MAAM,aAAa,GAAG,MAAM,IAAA,2BAAgB,EAAC,QAAQ,EAAE,IAAA,iCAAsB,EAAC,IAAI,CAAC,CAAC,CAAC;YACrF,kDAA2B,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;YACzD,OAAO,aAAa,CAAC;QACtB,CAAC;QACD,IAAI,uBAAuB;YAC1B,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAXD,0CAWC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAChC,KAA6D;IAE7D,IAAI,kDAA2B,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9C,OAAO,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC;IAC1B,CAAC;IACD,IAAA,iBAAM,EAAC,OAAO,KAAK,KAAK,UAAU,EAAE,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC7E,OAAO,KAAK,CAAC;AACd,CAAC;AARD,8CAQC;AAgCD;;;;;;;;;;;;;GAaG;AACH,SAAgB,cAAc,CAC7B,QAA8B,EAC9B,mBAAiD,EACjD,WA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AAO,GAAP,OAAO,CAAmC;IACzD,CAAC;IAEJ,sFAAsF;IACtF,2HAA2H;IACpH,KAAK,CAAC,eAAe,CAC3B,IAAwC,EACxC,QAA8C;QAE9C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5B,kDAA2B,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAChD,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACjF,CAAC;aAAM,CAAC;YACP,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAgB,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACpE,CAAC;IACF,CAAC;IAEM,KAAK,CAAC,uBAAuB,CACnC,IAAwC,EACxC,QAA8C;QAE9C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC7D,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,aAAa,CACzB,EAAU,EACV,IAA4D;QAE5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC;CACD;AAnCD,kEAmCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tICodeDetailsLoader,\n\tIContainerContext,\n\tIFluidCodeDetails,\n\tIFluidCodeDetailsComparer,\n\tIFluidModuleWithDetails,\n\tIRuntime,\n\tIRuntimeFactory,\n} from \"@fluidframework/container-definitions/internal\";\nimport type { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tcreateBasicRegistryKey,\n\ttype DataStoreKey,\n\ttype DataStoreKind,\n\ttype DataStoreRegistry,\n\ttype FluidContainerAttached,\n\ttype FluidContainerWithService,\n\ttype Registry,\n\tlookupInRegistry,\n\ttype ServiceClient,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tFluidDataStoreRegistryEntry,\n\tIContainerRuntimeBase,\n\tIFluidDataStoreRegistry,\n\tOldestSupportedClientVersion,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { DataStoreKindImplementation } from \"./serviceClientBase.js\";\n\n/**\n * The constant ID used for the root data store alias in service containers.\n * @internal\n */\nexport const rootDataStoreId = \"root\";\n\n/**\n * Converts a `DataStoreRegistry` to the `IFluidDataStoreRegistry` interface expected by the container runtime.\n * @remarks\n * This does not leverage the ability for `IFluidDataStoreRegistry.get` to return undefined.\n * Note that all use-cases of `IFluidDataStoreRegistry.get` returning undefined currently end up as a fatal error.\n * Therefore it should be fine for the error to instead be thrown by the registry function, which is what this function does.\n * @internal\n */\nexport function convertRegistry<T>(registry: DataStoreRegistry<T>): IFluidDataStoreRegistry {\n\treturn {\n\t\tasync get(name: string): Promise<FluidDataStoreRegistryEntry | undefined> {\n\t\t\tconst dataStoreKind = await lookupInRegistry(registry, createBasicRegistryKey(name));\n\t\t\tDataStoreKindImplementation.narrowGeneric(dataStoreKind);\n\t\t\treturn dataStoreKind;\n\t\t},\n\t\tget IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\t\treturn this;\n\t\t},\n\t};\n}\n\n/**\n * Normalizes a `DataStoreKind` or registry function into a registry function.\n * @internal\n */\nexport function normalizeRegistry<T>(\n\tinput: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>,\n): Registry<Promise<DataStoreKind<T>>> {\n\tif (DataStoreKindImplementation.guard(input)) {\n\t\treturn async () => input;\n\t}\n\tassert(typeof input === \"function\", 0xd17 /* Registry must be a function */);\n\treturn input;\n}\n\n/**\n * Parameters passed to a {@link ContainerRuntimeLoader}.\n * @internal\n */\nexport interface ContainerRuntimeLoaderParams {\n\tcontext: IContainerContext;\n\tregistry: IFluidDataStoreRegistry;\n\tprovideEntryPoint: (runtime: IContainerRuntimeBase) => Promise<FluidObject>;\n\texisting: boolean;\n\tminVersionForCollab: OldestSupportedClientVersion;\n\t/**\n\t * The type string of the root data store to create. Only set when `existing` is false.\n\t */\n\tnewContainerRootType: string | undefined;\n}\n\n/**\n * A service-specific callback that creates or loads the container runtime.\n *\n * @remarks\n * Receives the runtime parameters assembled by {@link makeCodeLoader} and is responsible for\n * calling the concrete runtime factory (e.g. `ContainerRuntime.loadRuntime2`) and, when\n * `existing` is `false`, initializing the root data store before returning.\n *\n * @internal\n */\nexport type ContainerRuntimeLoader = (\n\tparameters: ContainerRuntimeLoaderParams,\n) => Promise<IRuntime>;\n\n/**\n * Creates an `ICodeDetailsLoader` that wires up the container runtime via the supplied\n * `loadRuntime` callback.\n *\n * @remarks\n * The `loadRuntime` callback is responsible for invoking the concrete runtime factory and,\n * when `parameters.existing` is `false` and `parameters.newContainerRootType` is set, creating and\n * aliasing the root data store.\n *\n * This loader never does any code loading, and always assumes it is compatible.\n * TODO: We should reevaluate this before promoting ServiceClient APIs to beta.\n *\n * @internal\n */\nexport function makeCodeLoader<T>(\n\tregistry: DataStoreRegistry<T>,\n\tminVersionForCollab: OldestSupportedClientVersion,\n\tloadRuntime: ContainerRuntimeLoader,\n\troot?: DataStoreKind<T>,\n): ICodeDetailsLoader {\n\tconst fluidExport: IRuntimeFactory & IFluidCodeDetailsComparer = {\n\t\tasync instantiateRuntime(\n\t\t\tcontext: IContainerContext,\n\t\t\texisting: boolean,\n\t\t): Promise<IRuntime> {\n\t\t\tconst provideEntryPoint = async (\n\t\t\t\tentryPointRuntime: IContainerRuntimeBase,\n\t\t\t): Promise<T & FluidObject> => {\n\t\t\t\tconst data = await entryPointRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\t\tif (data === undefined) {\n\t\t\t\t\tthrow new Error(\"Root data store missing!\");\n\t\t\t\t}\n\t\t\t\tconst rootDataStore = await data.get();\n\t\t\t\treturn rootDataStore as T & FluidObject;\n\t\t\t};\n\n\t\t\treturn loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistry: convertRegistry(registry),\n\t\t\t\tprovideEntryPoint,\n\t\t\t\texisting,\n\t\t\t\tminVersionForCollab,\n\t\t\t\tnewContainerRootType: root?.type,\n\t\t\t});\n\t\t},\n\n\t\tasync satisfies(\n\t\t\tcandidate: IFluidCodeDetails,\n\t\t\tconstraint: IFluidCodeDetails,\n\t\t): Promise<boolean> {\n\t\t\treturn true;\n\t\t},\n\n\t\tasync compare(a: IFluidCodeDetails, b: IFluidCodeDetails): Promise<number | undefined> {\n\t\t\treturn 0;\n\t\t},\n\n\t\tget IRuntimeFactory(): IRuntimeFactory {\n\t\t\treturn fluidExport;\n\t\t},\n\n\t\tget IFluidCodeDetailsComparer(): IFluidCodeDetailsComparer {\n\t\t\treturn fluidExport;\n\t\t},\n\t};\n\n\treturn {\n\t\tload: async (details: IFluidCodeDetails): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn { module: { fluidExport }, details };\n\t\t},\n\t};\n}\n\n/**\n * Minimal interface for the static container factory methods used by {@link ServiceClientImplementation}.\n * @internal\n */\nexport interface ServiceContainerStatics<TOptions> {\n\tcreateDetached<T>(\n\t\tregistry: DataStoreRegistry<T>,\n\t\toptions: TOptions,\n\t\troot: DataStoreKind<T>,\n\t): Promise<FluidContainerWithService<T>>;\n\n\tload<T>(\n\t\tregistry: DataStoreRegistry<T>,\n\t\toptions: TOptions,\n\t\tid: string,\n\t): Promise<FluidContainerAttached<T>>;\n}\n\n/**\n * Creates a {@link @fluidframework/driver-definitions#ServiceClient} that delegates container\n * creation and loading to the supplied container class statics.\n * @internal\n */\nexport class ServiceClientImplementation<TOptions> implements ServiceClient {\n\tpublic constructor(\n\t\tprivate readonly options: TOptions,\n\t\tprivate readonly statics: ServiceContainerStatics<TOptions>,\n\t) {}\n\n\t// This implements the ServiceClient interface's safer version of this with overloads.\n\t// For use in the implementation however, this is simpler, and allows createAttachedContainer to forward to it more easily.\n\tpublic async createContainer<T>(\n\t\troot: DataStoreKey<T> | DataStoreKind<T>,\n\t\tregistry?: Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerWithService<T>> {\n\t\tif (registry === undefined) {\n\t\t\tDataStoreKindImplementation.narrowGeneric(root);\n\t\t\treturn this.statics.createDetached(normalizeRegistry(root), this.options, root);\n\t\t} else {\n\t\t\tconst result = await lookupInRegistry(registry, root);\n\t\t\treturn this.statics.createDetached(registry, this.options, result);\n\t\t}\n\t}\n\n\tpublic async createAttachedContainer<T>(\n\t\troot: DataStoreKey<T> | DataStoreKind<T>,\n\t\tregistry?: Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerAttached<T>> {\n\t\tconst container = await this.createContainer(root, registry);\n\t\treturn container.attach();\n\t}\n\n\tpublic async loadContainer<T>(\n\t\tid: string,\n\t\troot: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerAttached<T>> {\n\t\treturn this.statics.load(normalizeRegistry(root), this.options, id);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serviceClientUtils.js","sourceRoot":"","sources":["../src/serviceClientUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA+CH,0CAWC;AAMD,8CAQC;AA8CD,wCAyDC;AAnKD,kEAA6D;AAC7D,0EAUqD;AAQrD,iEAAqE;AAErE;;;GAGG;AACU,QAAA,eAAe,GAAG,MAAM,CAAC;AAEtC;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAI,QAA8B;IAChE,OAAO;QACN,KAAK,CAAC,GAAG,CAAC,IAAY;YACrB,MAAM,aAAa,GAAG,MAAM,IAAA,2BAAgB,EAAC,QAAQ,EAAE,IAAA,iCAAsB,EAAC,IAAI,CAAC,CA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EAAE,QAAQ,CAAC,CAAC;QAC7D,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,aAAa,CACzB,EAAU,EACV,IAA4D;QAE5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC;CACD;AAnCD,kEAmCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tICodeDetailsLoader,\n\tIContainerContext,\n\tIFluidCodeDetails,\n\tIFluidCodeDetailsComparer,\n\tIFluidModuleWithDetails,\n\tIRuntime,\n\tIRuntimeFactory,\n} from \"@fluidframework/container-definitions/internal\";\nimport type { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tcreateBasicRegistryKey,\n\ttype DataStoreKey,\n\ttype DataStoreKind,\n\ttype DataStoreRegistry,\n\ttype FluidContainerAttached,\n\ttype FluidContainerWithService,\n\ttype Registry,\n\tlookupInRegistry,\n\ttype ServiceClient,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tFluidDataStoreRegistryEntry,\n\tIContainerRuntimeBase,\n\tIFluidDataStoreRegistry,\n\tOldestSupportedClientVersion,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { DataStoreKindImplementation } from \"./serviceClientBase.js\";\n\n/**\n * The constant ID used for the root data store alias in service containers.\n * @internal\n */\nexport const rootDataStoreId = \"root\";\n\n/**\n * Converts a `DataStoreRegistry` to the `IFluidDataStoreRegistry` interface expected by the container runtime.\n * @remarks\n * This does not leverage the ability for `IFluidDataStoreRegistry.get` to return undefined.\n * Note that all use-cases of `IFluidDataStoreRegistry.get` returning undefined currently end up as a fatal error.\n * Therefore it should be fine for the error to instead be thrown by the registry function, which is what this function does.\n * @internal\n */\nexport function convertRegistry<T>(registry: DataStoreRegistry<T>): IFluidDataStoreRegistry {\n\treturn {\n\t\tasync get(name: string): Promise<FluidDataStoreRegistryEntry | undefined> {\n\t\t\tconst dataStoreKind = await lookupInRegistry(registry, createBasicRegistryKey(name));\n\t\t\tDataStoreKindImplementation.narrowGeneric(dataStoreKind);\n\t\t\treturn dataStoreKind;\n\t\t},\n\t\tget IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\t\treturn this;\n\t\t},\n\t};\n}\n\n/**\n * Normalizes a `DataStoreKind` or registry function into a registry function.\n * @internal\n */\nexport function normalizeRegistry<T>(\n\tinput: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>,\n): Registry<Promise<DataStoreKind<T>>> {\n\tif (DataStoreKindImplementation.guard(input)) {\n\t\treturn async () => input;\n\t}\n\tassert(typeof input === \"function\", 0xd17 /* Registry must be a function */);\n\treturn input;\n}\n\n/**\n * Parameters passed to a {@link ContainerRuntimeLoader}.\n * @internal\n */\nexport interface ContainerRuntimeLoaderParams {\n\tcontext: IContainerContext;\n\tregistry: IFluidDataStoreRegistry;\n\tprovideEntryPoint: (runtime: IContainerRuntimeBase) => Promise<FluidObject>;\n\texisting: boolean;\n\tminVersionForCollab: OldestSupportedClientVersion;\n\t/**\n\t * The type string of the root data store to create. Only set when `existing` is false.\n\t */\n\tnewContainerRootType: string | undefined;\n}\n\n/**\n * A service-specific callback that creates or loads the container runtime.\n *\n * @remarks\n * Receives the runtime parameters assembled by {@link makeCodeLoader} and is responsible for\n * calling the concrete runtime factory (e.g. `ContainerRuntime.loadRuntime2`) and, when\n * `existing` is `false`, initializing the root data store before returning.\n *\n * @internal\n */\nexport type ContainerRuntimeLoader = (\n\tparameters: ContainerRuntimeLoaderParams,\n) => Promise<IRuntime>;\n\n/**\n * Creates an `ICodeDetailsLoader` that wires up the container runtime via the supplied\n * `loadRuntime` callback.\n *\n * @remarks\n * The `loadRuntime` callback is responsible for invoking the concrete runtime factory and,\n * when `parameters.existing` is `false` and `parameters.newContainerRootType` is set, creating and\n * aliasing the root data store.\n *\n * This loader never does any code loading, and always assumes it is compatible.\n * TODO: We should reevaluate this before promoting ServiceClient APIs to beta.\n *\n * @internal\n */\nexport function makeCodeLoader<T>(\n\tregistry: DataStoreRegistry<T>,\n\tminVersionForCollab: OldestSupportedClientVersion,\n\tloadRuntime: ContainerRuntimeLoader,\n\troot?: DataStoreKind<T>,\n): ICodeDetailsLoader {\n\tconst fluidExport: IRuntimeFactory & IFluidCodeDetailsComparer = {\n\t\tasync instantiateRuntime(\n\t\t\tcontext: IContainerContext,\n\t\t\texisting: boolean,\n\t\t): Promise<IRuntime> {\n\t\t\tconst provideEntryPoint = async (\n\t\t\t\tentryPointRuntime: IContainerRuntimeBase,\n\t\t\t): Promise<T & FluidObject> => {\n\t\t\t\tconst data = await entryPointRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\t\tif (data === undefined) {\n\t\t\t\t\tthrow new Error(\"Root data store missing!\");\n\t\t\t\t}\n\t\t\t\tconst rootDataStore = await data.get();\n\t\t\t\treturn rootDataStore as T & FluidObject;\n\t\t\t};\n\n\t\t\treturn loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistry: convertRegistry(registry),\n\t\t\t\tprovideEntryPoint,\n\t\t\t\texisting,\n\t\t\t\tminVersionForCollab,\n\t\t\t\tnewContainerRootType: root?.type,\n\t\t\t});\n\t\t},\n\n\t\tasync satisfies(\n\t\t\tcandidate: IFluidCodeDetails,\n\t\t\tconstraint: IFluidCodeDetails,\n\t\t): Promise<boolean> {\n\t\t\treturn true;\n\t\t},\n\n\t\tasync compare(a: IFluidCodeDetails, b: IFluidCodeDetails): Promise<number | undefined> {\n\t\t\treturn 0;\n\t\t},\n\n\t\tget IRuntimeFactory(): IRuntimeFactory {\n\t\t\treturn fluidExport;\n\t\t},\n\n\t\tget IFluidCodeDetailsComparer(): IFluidCodeDetailsComparer {\n\t\t\treturn fluidExport;\n\t\t},\n\t};\n\n\treturn {\n\t\tload: async (details: IFluidCodeDetails): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn { module: { fluidExport }, details };\n\t\t},\n\t};\n}\n\n/**\n * Minimal interface for the static container factory methods used by {@link ServiceClientImplementation}.\n * @internal\n */\nexport interface ServiceContainerStatics<TOptions> {\n\tcreateDetached<T>(\n\t\tregistry: DataStoreRegistry<T>,\n\t\toptions: TOptions,\n\t\troot: DataStoreKind<T>,\n\t): Promise<FluidContainerWithService<T>>;\n\n\tload<T>(\n\t\tregistry: DataStoreRegistry<T>,\n\t\toptions: TOptions,\n\t\tid: string,\n\t): Promise<FluidContainerAttached<T>>;\n}\n\n/**\n * Creates a {@link @fluidframework/driver-definitions#ServiceClient} that delegates container\n * creation and loading to the supplied container class statics.\n * @internal\n */\nexport class ServiceClientImplementation<TOptions> implements ServiceClient {\n\tpublic constructor(\n\t\tprivate readonly options: TOptions,\n\t\tprivate readonly statics: ServiceContainerStatics<TOptions>,\n\t) {}\n\n\t// This implements the ServiceClient interface's safer version of this with overloads.\n\t// For use in the implementation however, this is simpler, and allows createAttachedContainer to forward to it more easily.\n\tpublic async createContainer<T>(\n\t\troot: DataStoreKey<T> | DataStoreKind<T>,\n\t\tregistry?: Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerWithService<T>> {\n\t\tif (registry === undefined) {\n\t\t\tDataStoreKindImplementation.narrowGeneric(root);\n\t\t\treturn this.statics.createDetached(normalizeRegistry(root), this.options, root);\n\t\t} else {\n\t\t\tconst result = await lookupInRegistry(registry, root);\n\t\t\treturn this.statics.createDetached(registry, this.options, result);\n\t\t}\n\t}\n\n\tpublic async createAttachedContainer<T>(\n\t\troot: DataStoreKey<T> | DataStoreKind<T>,\n\t\tregistry?: Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerAttached<T>> {\n\t\tconst container = await this.createContainer(root, registry);\n\t\treturn container.attach();\n\t}\n\n\tpublic async loadContainer<T>(\n\t\tid: string,\n\t\troot: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>,\n\t): Promise<FluidContainerAttached<T>> {\n\t\treturn this.statics.load(normalizeRegistry(root), this.options, id);\n\t}\n}\n"]}
|
package/dist/snapshotUtils.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.isSnapshotFetchRequiredForLoadingGroupId =
|
|
7
|
+
exports.isSnapshotFetchRequiredForLoadingGroupId = isSnapshotFetchRequiredForLoadingGroupId;
|
|
8
8
|
/**
|
|
9
9
|
* Utility function to check if any blobs under a snapshot tree is missing and if so, then return
|
|
10
10
|
* true if that is the case.
|
|
@@ -33,5 +33,4 @@ function isSnapshotFetchRequiredForLoadingGroupId(snapshotTree, blobContents) {
|
|
|
33
33
|
}
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
36
|
-
exports.isSnapshotFetchRequiredForLoadingGroupId = isSnapshotFetchRequiredForLoadingGroupId;
|
|
37
36
|
//# sourceMappingURL=snapshotUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshotUtils.js","sourceRoot":"","sources":["../src/snapshotUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"snapshotUtils.js","sourceRoot":"","sources":["../src/snapshotUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAWH,4FAuBC;AA9BD;;;;;;GAMG;AACH,SAAgB,wCAAwC,CACvD,YAA2B,EAC3B,YAAsC;IAEtC,KAAK,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1D,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IACD,KAAK,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACjE,uGAAuG;QACvG,kGAAkG;QAClG,sGAAsG;QACtG,sGAAsG;QACtG,iEAAiE;QACjE,IAAI,SAAS,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,KAAK,GAAG,wCAAwC,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;YAChF,IAAI,KAAK,EAAE,CAAC;gBACX,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\n\n/**\n * Utility function to check if any blobs under a snapshot tree is missing and if so, then return\n * true if that is the case.\n * @internal\n * @param snapshotTree - snapshotTree to be evaluated for missing blobs.\n * @param blobContents - blobContents of the snapshot.\n */\nexport function isSnapshotFetchRequiredForLoadingGroupId(\n\tsnapshotTree: ISnapshotTree,\n\tblobContents: Map<string, ArrayBuffer>,\n): boolean {\n\tfor (const [_, id] of Object.entries(snapshotTree.blobs)) {\n\t\tif (!blobContents.has(id)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\tfor (const [_, childTree] of Object.entries(snapshotTree.trees)) {\n\t\t// Only evaluate childTree if it does not have a loading groupId because if the childTree has a loading\n\t\t// groupId then it will be evaluated whether we want to fetch blobs for that childTree or not when\n\t\t// that particular childTree is getting realized. Now we just want to check for blobs which belongs to\n\t\t// tree with current loading groupId. Note: Child with no loading groupId, will fall under parent with\n\t\t// a loading groupId as it does not have its own loading groupId.\n\t\tif (childTree.groupId === undefined) {\n\t\t\tconst value = isSnapshotFetchRequiredForLoadingGroupId(childTree, blobContents);\n\t\t\tif (value) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn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IAMxD;;OAEG;IACI,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAM/C,SAAS,IAAI,sBAAsB;CAK1C"}
|
package/dist/summaryUtils.js
CHANGED
|
@@ -4,7 +4,18 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.GCDataBuilder = exports.TelemetryContext = exports.
|
|
7
|
+
exports.GCDataBuilder = exports.TelemetryContext = exports.SummaryTreeBuilder = void 0;
|
|
8
|
+
exports.mergeStats = mergeStats;
|
|
9
|
+
exports.utf8ByteLength = utf8ByteLength;
|
|
10
|
+
exports.getBlobSize = getBlobSize;
|
|
11
|
+
exports.calculateStats = calculateStats;
|
|
12
|
+
exports.addBlobToSummary = addBlobToSummary;
|
|
13
|
+
exports.addSummarizeResultToSummary = addSummarizeResultToSummary;
|
|
14
|
+
exports.convertToSummaryTreeWithStats = convertToSummaryTreeWithStats;
|
|
15
|
+
exports.convertToSummaryTree = convertToSummaryTree;
|
|
16
|
+
exports.convertSnapshotTreeToSummaryTree = convertSnapshotTreeToSummaryTree;
|
|
17
|
+
exports.convertSummaryTreeToITree = convertSummaryTreeToITree;
|
|
18
|
+
exports.processAttachMessageGCData = processAttachMessageGCData;
|
|
8
19
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
20
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
10
21
|
const driver_definitions_1 = require("@fluidframework/driver-definitions");
|
|
@@ -34,7 +45,6 @@ function mergeStats(...stats) {
|
|
|
34
45
|
}
|
|
35
46
|
return results;
|
|
36
47
|
}
|
|
37
|
-
exports.mergeStats = mergeStats;
|
|
38
48
|
/**
|
|
39
49
|
* Calculates the byte length of an UTF-8 encoded string
|
|
40
50
|
* @param str - The string to calculate the byte length of
|
|
@@ -60,7 +70,6 @@ function utf8ByteLength(str) {
|
|
|
60
70
|
}
|
|
61
71
|
return s;
|
|
62
72
|
}
|
|
63
|
-
exports.utf8ByteLength = utf8ByteLength;
|
|
64
73
|
/**
|
|
65
74
|
* Gets the size of a blob
|
|
66
75
|
* @param content - The content of the blob
|
|
@@ -70,7 +79,6 @@ exports.utf8ByteLength = utf8ByteLength;
|
|
|
70
79
|
function getBlobSize(content) {
|
|
71
80
|
return typeof content === "string" ? utf8ByteLength(content) : content.byteLength;
|
|
72
81
|
}
|
|
73
|
-
exports.getBlobSize = getBlobSize;
|
|
74
82
|
function calculateStatsCore(summaryObject, stats) {
|
|
75
83
|
switch (summaryObject.type) {
|
|
76
84
|
case driver_definitions_1.SummaryType.Tree: {
|
|
@@ -105,7 +113,6 @@ function calculateStats(summary) {
|
|
|
105
113
|
calculateStatsCore(summary, stats);
|
|
106
114
|
return stats;
|
|
107
115
|
}
|
|
108
|
-
exports.calculateStats = calculateStats;
|
|
109
116
|
/**
|
|
110
117
|
* Adds a blob to the summary tree
|
|
111
118
|
* @param summary - The summary tree to add the blob to
|
|
@@ -122,7 +129,6 @@ function addBlobToSummary(summary, key, content) {
|
|
|
122
129
|
summary.stats.blobNodeCount++;
|
|
123
130
|
summary.stats.totalBlobSize += getBlobSize(content);
|
|
124
131
|
}
|
|
125
|
-
exports.addBlobToSummary = addBlobToSummary;
|
|
126
132
|
/**
|
|
127
133
|
* Adds a summarize result to the summary tree
|
|
128
134
|
* @param summary - The summary tree to add the summarize result to
|
|
@@ -134,13 +140,14 @@ function addSummarizeResultToSummary(summary, key, summarizeResult) {
|
|
|
134
140
|
summary.summary.tree[key] = summarizeResult.summary;
|
|
135
141
|
summary.stats = mergeStats(summary.stats, summarizeResult.stats);
|
|
136
142
|
}
|
|
137
|
-
exports.addSummarizeResultToSummary = addSummarizeResultToSummary;
|
|
138
143
|
/**
|
|
139
144
|
* A helper class for building summary trees.
|
|
140
145
|
* @remarks Uses the builder pattern.
|
|
141
146
|
* @legacy @beta
|
|
142
147
|
*/
|
|
143
148
|
class SummaryTreeBuilder {
|
|
149
|
+
attachmentCounter = 0;
|
|
150
|
+
groupId;
|
|
144
151
|
get summary() {
|
|
145
152
|
const summary = {
|
|
146
153
|
type: driver_definitions_1.SummaryType.Tree,
|
|
@@ -155,12 +162,12 @@ class SummaryTreeBuilder {
|
|
|
155
162
|
return { ...this.summaryStats };
|
|
156
163
|
}
|
|
157
164
|
constructor(params) {
|
|
158
|
-
this.attachmentCounter = 0;
|
|
159
|
-
this.summaryTree = {};
|
|
160
165
|
this.summaryStats = mergeStats();
|
|
161
166
|
this.summaryStats.treeNodeCount++;
|
|
162
167
|
this.groupId = params?.groupId;
|
|
163
168
|
}
|
|
169
|
+
summaryTree = {};
|
|
170
|
+
summaryStats;
|
|
164
171
|
/**
|
|
165
172
|
* Add a blob to the summary tree. This blob will be stored at the given key in the summary tree.
|
|
166
173
|
* @param key - The key to store the blob at in the current summary tree being generated. Should not contain any "/" characters.
|
|
@@ -256,7 +263,6 @@ function convertToSummaryTreeWithStats(snapshot, fullTree = false) {
|
|
|
256
263
|
summaryTree.summary.groupId = snapshot.groupId;
|
|
257
264
|
return summaryTree;
|
|
258
265
|
}
|
|
259
|
-
exports.convertToSummaryTreeWithStats = convertToSummaryTreeWithStats;
|
|
260
266
|
/**
|
|
261
267
|
* Converts snapshot ITree to ISummaryTree format and tracks stats.
|
|
262
268
|
* @param snapshot - snapshot in ITree format
|
|
@@ -281,7 +287,6 @@ function convertToSummaryTree(snapshot, fullTree = false) {
|
|
|
281
287
|
return convertToSummaryTreeWithStats(snapshot, fullTree);
|
|
282
288
|
}
|
|
283
289
|
}
|
|
284
|
-
exports.convertToSummaryTree = convertToSummaryTree;
|
|
285
290
|
/**
|
|
286
291
|
* Converts ISnapshotTree to ISummaryTree format and tracks stats. This snapshot tree was
|
|
287
292
|
* was taken by serialize api in detached container.
|
|
@@ -305,8 +310,6 @@ function convertSnapshotTreeToSummaryTree(snapshot) {
|
|
|
305
310
|
// only for blobPath -> blobId mapping and not for blobId -> blob value contents.
|
|
306
311
|
}
|
|
307
312
|
else if (snapshot.blobs[id] !== undefined) {
|
|
308
|
-
// Non null asserting here because of the undefined check above
|
|
309
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
310
313
|
decoded = (0, client_utils_1.fromBase64ToUtf8)(snapshot.blobs[id]);
|
|
311
314
|
}
|
|
312
315
|
if (decoded !== undefined) {
|
|
@@ -322,7 +325,6 @@ function convertSnapshotTreeToSummaryTree(snapshot) {
|
|
|
322
325
|
summaryTree.summary.groupId = snapshot.groupId;
|
|
323
326
|
return summaryTree;
|
|
324
327
|
}
|
|
325
|
-
exports.convertSnapshotTreeToSummaryTree = convertSnapshotTreeToSummaryTree;
|
|
326
328
|
/**
|
|
327
329
|
* Converts ISummaryTree to ITree format. This is needed for back-compat while we get rid of snapshot.
|
|
328
330
|
* @param summaryTree - summary tree in ISummaryTree format
|
|
@@ -369,7 +371,6 @@ function convertSummaryTreeToITree(summaryTree) {
|
|
|
369
371
|
groupId: summaryTree.groupId,
|
|
370
372
|
};
|
|
371
373
|
}
|
|
372
|
-
exports.convertSummaryTreeToITree = convertSummaryTreeToITree;
|
|
373
374
|
/**
|
|
374
375
|
* Looks in the given attach message snapshot for the .gcdata blob, which would
|
|
375
376
|
* contain the initial GC Data for the node being attached.
|
|
@@ -403,14 +404,11 @@ function processAttachMessageGCData(snapshot, addedGCOutboundRoute) {
|
|
|
403
404
|
}
|
|
404
405
|
return true;
|
|
405
406
|
}
|
|
406
|
-
exports.processAttachMessageGCData = processAttachMessageGCData;
|
|
407
407
|
/**
|
|
408
408
|
* @internal
|
|
409
409
|
*/
|
|
410
410
|
class TelemetryContext {
|
|
411
|
-
|
|
412
|
-
this.telemetry = new Map();
|
|
413
|
-
}
|
|
411
|
+
telemetry = new Map();
|
|
414
412
|
/**
|
|
415
413
|
* {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}
|
|
416
414
|
*/
|
|
@@ -475,9 +473,7 @@ function trimTrailingSlashes(str) {
|
|
|
475
473
|
* @internal
|
|
476
474
|
*/
|
|
477
475
|
class GCDataBuilder {
|
|
478
|
-
|
|
479
|
-
this.gcNodesSet = {};
|
|
480
|
-
}
|
|
476
|
+
gcNodesSet = {};
|
|
481
477
|
get gcNodes() {
|
|
482
478
|
const gcNodes = {};
|
|
483
479
|
for (const [nodeId, outboundRoutes] of Object.entries(this.gcNodesSet)) {
|