@fluidframework/runtime-utils 2.53.0 → 2.60.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/.eslintrc.cjs +1 -4
- package/CHANGELOG.md +4 -0
- package/api-report/{runtime-utils.legacy.alpha.api.md → runtime-utils.legacy.beta.api.md} +12 -12
- package/dist/compatibilityBase.d.ts +1 -3
- package/dist/compatibilityBase.d.ts.map +1 -1
- package/dist/compatibilityBase.js +3 -0
- package/dist/compatibilityBase.js.map +1 -1
- package/dist/dataStoreHandleContextUtils.d.ts +1 -1
- package/dist/dataStoreHandleContextUtils.d.ts.map +1 -1
- package/dist/dataStoreHandleContextUtils.js.map +1 -1
- package/dist/dataStoreHelpers.d.ts +18 -6
- package/dist/dataStoreHelpers.d.ts.map +1 -1
- package/dist/dataStoreHelpers.js +39 -11
- package/dist/dataStoreHelpers.js.map +1 -1
- package/dist/deltaManager.d.ts +1 -2
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +3 -2
- package/dist/deltaManager.js.map +1 -1
- package/dist/handles.d.ts +8 -12
- package/dist/handles.d.ts.map +1 -1
- package/dist/handles.js +14 -12
- package/dist/handles.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/objectstoragepartition.d.ts +1 -1
- package/dist/objectstoragepartition.d.ts.map +1 -1
- package/dist/objectstoragepartition.js.map +1 -1
- package/dist/objectstorageutils.d.ts +9 -1
- package/dist/objectstorageutils.d.ts.map +1 -1
- package/dist/objectstorageutils.js +15 -6
- package/dist/objectstorageutils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/remoteFluidObjectHandle.d.ts +2 -2
- package/dist/remoteFluidObjectHandle.d.ts.map +1 -1
- package/dist/remoteFluidObjectHandle.js +1 -0
- package/dist/remoteFluidObjectHandle.js.map +1 -1
- package/dist/requestParser.d.ts +2 -3
- package/dist/requestParser.d.ts.map +1 -1
- package/dist/requestParser.js +9 -11
- package/dist/requestParser.js.map +1 -1
- package/dist/runtimeFactoryHelper.d.ts +3 -4
- package/dist/runtimeFactoryHelper.d.ts.map +1 -1
- package/dist/runtimeFactoryHelper.js +1 -2
- package/dist/runtimeFactoryHelper.js.map +1 -1
- package/dist/summaryUtils.d.ts +29 -20
- package/dist/summaryUtils.d.ts.map +1 -1
- package/dist/summaryUtils.js +49 -21
- package/dist/summaryUtils.js.map +1 -1
- package/dist/unpackUsedRoutes.d.ts.map +1 -1
- package/dist/unpackUsedRoutes.js +3 -3
- package/dist/unpackUsedRoutes.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/lib/compatibilityBase.d.ts +1 -3
- package/lib/compatibilityBase.d.ts.map +1 -1
- package/lib/compatibilityBase.js +3 -0
- package/lib/compatibilityBase.js.map +1 -1
- package/lib/dataStoreHandleContextUtils.d.ts +1 -1
- package/lib/dataStoreHandleContextUtils.d.ts.map +1 -1
- package/lib/dataStoreHandleContextUtils.js.map +1 -1
- package/lib/dataStoreHelpers.d.ts +18 -6
- package/lib/dataStoreHelpers.d.ts.map +1 -1
- package/lib/dataStoreHelpers.js +39 -11
- package/lib/dataStoreHelpers.js.map +1 -1
- package/lib/deltaManager.d.ts +1 -2
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +3 -2
- package/lib/deltaManager.js.map +1 -1
- package/lib/handles.d.ts +8 -12
- package/lib/handles.d.ts.map +1 -1
- package/lib/handles.js +14 -12
- package/lib/handles.js.map +1 -1
- package/lib/index.d.ts +6 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/objectstoragepartition.d.ts +1 -1
- package/lib/objectstoragepartition.d.ts.map +1 -1
- package/lib/objectstoragepartition.js.map +1 -1
- package/lib/objectstorageutils.d.ts +9 -1
- package/lib/objectstorageutils.d.ts.map +1 -1
- package/lib/objectstorageutils.js +15 -6
- package/lib/objectstorageutils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/remoteFluidObjectHandle.d.ts +2 -2
- package/lib/remoteFluidObjectHandle.d.ts.map +1 -1
- package/lib/remoteFluidObjectHandle.js +1 -0
- package/lib/remoteFluidObjectHandle.js.map +1 -1
- package/lib/requestParser.d.ts +2 -3
- package/lib/requestParser.d.ts.map +1 -1
- package/lib/requestParser.js +9 -11
- package/lib/requestParser.js.map +1 -1
- package/lib/runtimeFactoryHelper.d.ts +3 -4
- package/lib/runtimeFactoryHelper.d.ts.map +1 -1
- package/lib/runtimeFactoryHelper.js +1 -2
- package/lib/runtimeFactoryHelper.js.map +1 -1
- package/lib/summaryUtils.d.ts +29 -20
- package/lib/summaryUtils.d.ts.map +1 -1
- package/lib/summaryUtils.js +51 -23
- package/lib/summaryUtils.js.map +1 -1
- package/lib/unpackUsedRoutes.d.ts.map +1 -1
- package/lib/unpackUsedRoutes.js +3 -3
- package/lib/unpackUsedRoutes.js.map +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +14 -14
- package/src/compatibilityBase.ts +4 -3
- package/src/dataStoreHandleContextUtils.ts +1 -1
- package/src/dataStoreHelpers.ts +49 -16
- package/src/deltaManager.ts +3 -2
- package/src/handles.ts +14 -13
- package/src/index.ts +6 -4
- package/src/objectstoragepartition.ts +2 -2
- package/src/objectstorageutils.ts +17 -8
- package/src/packageVersion.ts +1 -1
- package/src/remoteFluidObjectHandle.ts +4 -3
- package/src/requestParser.ts +15 -15
- package/src/runtimeFactoryHelper.ts +4 -5
- package/src/summaryUtils.ts +70 -43
- package/src/unpackUsedRoutes.ts +7 -5
- package/src/utils.ts +2 -2
package/lib/summaryUtils.js.map
CHANGED
|
@@ -1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AC/C,CAAC;IAED;;;;;OAKG;IACI,iBAAiB,CAAC,QAAgB,EAAE,OAAmC;QAC7E,KAAK,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5D,0CAA0C;YAC1C,IAAI,YAAY,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAC;YAC1C,4CAA4C;YAC5C,YAAY,GAAG,IAAI,QAAQ,IAAI,YAAY,EAAE,CAAC;YAC9C,uGAAuG;YACvG,mEAAmE;YACnE,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;YAEjD,qFAAqF;YACrF,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;IAEM,QAAQ,CAAC,OAAmC;QAClD,KAAK,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5D,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC;IAED;;OAEG;IACI,kBAAkB,CAAC,aAAqB;QAC9C,KAAK,MAAM,cAAc,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7D,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;IAEM,SAAS;QACf,OAAO;YACN,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tfromBase64ToUtf8,\n} from \"@fluid-internal/client-utils\";\nimport { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISummaryBlob,\n\tISummaryTree,\n\tSummaryObject,\n\tSummaryType,\n} from \"@fluidframework/driver-definitions\";\nimport { ITree, ITreeEntry, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tAttachmentTreeEntry,\n\tBlobTreeEntry,\n\tTreeTreeEntry,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tISummaryStats,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIGarbageCollectionData,\n\tISummarizeResult,\n\tITelemetryContextExt,\n\tgcDataBlobKey,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { TelemetryEventPropertyTypeExt } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Combines summary stats by adding their totals together.\n * Returns empty stats if called without args.\n * @param stats - stats to merge\n * @internal\n */\nexport function mergeStats(...stats: ISummaryStats[]): ISummaryStats {\n\tconst results = {\n\t\ttreeNodeCount: 0,\n\t\tblobNodeCount: 0,\n\t\thandleNodeCount: 0,\n\t\ttotalBlobSize: 0,\n\t\tunreferencedBlobSize: 0,\n\t};\n\tfor (const stat of stats) {\n\t\tresults.treeNodeCount += stat.treeNodeCount;\n\t\tresults.blobNodeCount += stat.blobNodeCount;\n\t\tresults.handleNodeCount += stat.handleNodeCount;\n\t\tresults.totalBlobSize += stat.totalBlobSize;\n\t\tresults.unreferencedBlobSize += stat.unreferencedBlobSize;\n\t}\n\treturn results;\n}\n\n/**\n * @internal\n */\nexport function utf8ByteLength(str: string): number {\n\t// returns the byte length of an utf8 string\n\tlet s = str.length;\n\tfor (let i = str.length - 1; i >= 0; i--) {\n\t\tconst code = str.charCodeAt(i);\n\t\tif (code > 0x7f && code <= 0x7ff) {\n\t\t\ts++;\n\t\t} else if (code > 0x7ff && code <= 0xffff) {\n\t\t\ts += 2;\n\t\t}\n\t\tif (code >= 0xdc00 && code <= 0xdfff) {\n\t\t\ti--; // trail surrogate\n\t\t}\n\t}\n\treturn s;\n}\n\n/**\n * @internal\n */\nexport function getBlobSize(content: ISummaryBlob[\"content\"]): number {\n\treturn typeof content === \"string\" ? utf8ByteLength(content) : content.byteLength;\n}\n\nfunction calculateStatsCore(summaryObject: SummaryObject, stats: ISummaryStats): void {\n\tswitch (summaryObject.type) {\n\t\tcase SummaryType.Tree: {\n\t\t\tstats.treeNodeCount++;\n\t\t\tfor (const value of Object.values(summaryObject.tree)) {\n\t\t\t\tcalculateStatsCore(value, stats);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tcase SummaryType.Handle: {\n\t\t\tstats.handleNodeCount++;\n\t\t\treturn;\n\t\t}\n\t\tcase SummaryType.Blob: {\n\t\t\tstats.blobNodeCount++;\n\t\t\tstats.totalBlobSize += getBlobSize(summaryObject.content);\n\t\t\treturn;\n\t\t}\n\t\tdefault:\n\t\t\treturn;\n\t}\n}\n\n/**\n * @internal\n */\nexport function calculateStats(summary: SummaryObject): ISummaryStats {\n\tconst stats = mergeStats();\n\tcalculateStatsCore(summary, stats);\n\treturn stats;\n}\n\n/**\n * @internal\n */\nexport function addBlobToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tcontent: string | Uint8Array,\n): void {\n\tconst blob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent,\n\t};\n\tsummary.summary.tree[key] = blob;\n\tsummary.stats.blobNodeCount++;\n\tsummary.stats.totalBlobSize += getBlobSize(content);\n}\n\n/**\n * @internal\n */\nexport function addSummarizeResultToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tsummarizeResult: ISummarizeResult,\n): void {\n\tsummary.summary.tree[key] = summarizeResult.summary;\n\tsummary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\n/**\n * An object who's properties are used to initialize a {@link SummaryTreeBuilder}\n * @legacy\n * @alpha\n */\nexport interface SummaryTreeBuilderParams {\n\t/**\n\t * This value will become the {@link @fluidframework/driver-definitions#ISummaryTree.groupId}\n\t * of the {@link @fluidframework/driver-definitions#ISummaryTree} built by the {@link SummaryTreeBuilder}.\n\t */\n\tgroupId?: string;\n}\n/**\n * A helper class for building summary trees.\n * @remarks Uses the builder pattern.\n * @legacy\n * @alpha\n */\nexport class SummaryTreeBuilder implements ISummaryTreeWithStats {\n\tprivate attachmentCounter: number = 0;\n\tprivate readonly groupId?: string;\n\n\tpublic get summary(): ISummaryTree {\n\t\tconst summary: ISummaryTree = {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t};\n\t\tif (this.groupId !== undefined) {\n\t\t\tsummary.groupId = this.groupId;\n\t\t}\n\t\treturn summary;\n\t}\n\n\tpublic get stats(): Readonly<ISummaryStats> {\n\t\treturn { ...this.summaryStats };\n\t}\n\n\tconstructor(params?: { groupId?: string }) {\n\t\tthis.summaryStats = mergeStats();\n\t\tthis.summaryStats.treeNodeCount++;\n\t\tthis.groupId = params?.groupId;\n\t}\n\n\tprivate readonly summaryTree: { [path: string]: SummaryObject } = {};\n\tprivate summaryStats: ISummaryStats;\n\n\t/**\n\t * Add a blob to the summary tree. This blob will be stored at the given key in the summary tree.\n\t * @param key - The key to store the blob at in the current summary tree being generated. Should not contain any \"/\" characters.\n\t * @param content - The content of the blob to be added to the summary tree.\n\t */\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\t// Prevent cloning by directly referencing underlying private properties\n\t\taddBlobToSummary(\n\t\t\t{\n\t\t\t\tsummary: {\n\t\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\t\ttree: this.summaryTree,\n\t\t\t\t},\n\t\t\t\tstats: this.summaryStats,\n\t\t\t},\n\t\t\tkey,\n\t\t\tcontent,\n\t\t);\n\t}\n\n\t/**\n\t * Adds an {@link @fluidframework/driver-definitions#ISummaryHandle} that references a subtree, blob, or attachment in a previous summary.\n\t *\n\t * @param key - The key to store the handle at in the current summary tree being generated. Should not contain any \"/\" characters.\n\t * @param handleType - the type of {@link @fluidframework/driver-definitions#SummaryObject} besides a SummaryHandle, i.e. {@link @fluidframework/driver-definitions#SummaryType.Tree}, {@link @fluidframework/driver-definitions#SummaryType.Blob}, {@link @fluidframework/driver-definitions#SummaryType.Attachment}\n\t * @param handle - The path pointing to the part of the previous summary being used to duplicate the data. Use {@link @fluidframework/driver-definitions#ISummaryHandle.handle} to help generate proper handle strings. Should not contain any \"/\" characters.\n\t */\n\tpublic addHandle(\n\t\tkey: string,\n\t\thandleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n\t\thandle: string,\n\t): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType,\n\t\t\thandle,\n\t\t};\n\t\tthis.summaryStats.handleNodeCount++;\n\t}\n\n\t/**\n\t * Adds a child and updates the stats accordingly.\n\t * @param key - The key to store the handle at in the current summary tree being generated. Should not contain any \"/\" characters.\n\t * The key should be unique within the current summary tree, and not transform when encodeURIComponent is called.\n\t * @param summarizeResult - Similar to {@link @fluidframework/runtime-definitions#ISummaryTreeWithStats}. The provided summary can be either a {@link @fluidframework/driver-definitions#ISummaryHandle} or {@link @fluidframework/driver-definitions#ISummaryTree}.\n\t */\n\tpublic addWithStats(key: string, summarizeResult: ISummarizeResult): void {\n\t\tthis.summaryTree[key] = summarizeResult.summary;\n\t\tthis.summaryStats = mergeStats(this.summaryStats, summarizeResult.stats);\n\t}\n\n\t/**\n\t * Adds an {@link @fluidframework/driver-definitions#ISummaryAttachment} to the summary. This blob needs to already be uploaded to storage.\n\t * @param id - The id of the uploaded attachment to be added to the summary tree.\n\t */\n\tpublic addAttachment(id: string) {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n\n\t/**\n\t * Gives you the in-memory summary tree with stats built by the SummaryTreeBuilder.\n\t *\n\t * @remarks\n\t * Use this once you're done building the summary tree, the stats should automatically be generated.\n\t * @returns The summary tree and stats built by the SummaryTreeBuilder.\n\t */\n\tpublic getSummaryTree(): ISummaryTreeWithStats {\n\t\treturn { summary: this.summary, stats: this.stats };\n\t}\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n * @legacy\n * @alpha\n */\nexport function convertToSummaryTreeWithStats(\n\tsnapshot: ITree,\n\tfullTree: boolean = false,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tfor (const entry of snapshot.entries) {\n\t\tswitch (entry.type) {\n\t\t\tcase TreeEntry.Blob: {\n\t\t\t\tconst blob = entry.value;\n\t\t\t\tconst content =\n\t\t\t\t\tblob.encoding === \"base64\" ? IsoBuffer.from(blob.contents, \"base64\") : blob.contents;\n\t\t\t\tbuilder.addBlob(entry.path, content);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase TreeEntry.Tree: {\n\t\t\t\tconst subtree = convertToSummaryTree(entry.value, fullTree);\n\t\t\t\tbuilder.addWithStats(entry.path, subtree);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase TreeEntry.Attachment: {\n\t\t\t\tconst id = entry.value.id;\n\t\t\t\tbuilder.addAttachment(id);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unexpected TreeEntry type\");\n\t\t}\n\t}\n\n\tconst summaryTree = builder.getSummaryTree();\n\tsummaryTree.summary.unreferenced = snapshot.unreferenced;\n\tsummaryTree.summary.groupId = snapshot.groupId;\n\treturn summaryTree;\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n * @internal\n */\nexport function convertToSummaryTree(\n\tsnapshot: ITree,\n\tfullTree: boolean = false,\n): ISummarizeResult {\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tif (snapshot.id && !fullTree) {\n\t\tconst stats = mergeStats();\n\t\tstats.handleNodeCount++;\n\t\treturn {\n\t\t\tsummary: {\n\t\t\t\thandle: snapshot.id,\n\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\ttype: SummaryType.Handle,\n\t\t\t},\n\t\t\tstats,\n\t\t};\n\t} else {\n\t\treturn convertToSummaryTreeWithStats(snapshot, fullTree);\n\t}\n}\n\n/**\n * Converts ISnapshotTree to ISummaryTree format and tracks stats. This snapshot tree was\n * was taken by serialize api in detached container.\n * @param snapshot - snapshot in ISnapshotTree format\n * @internal\n */\nexport function convertSnapshotTreeToSummaryTree(\n\tsnapshot: ISnapshotTreeWithBlobContents,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tlet decoded: string | undefined;\n\t\tif (snapshot.blobsContents !== undefined) {\n\t\t\t// TODO Why are we non null asserting here?\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst content: ArrayBufferLike = snapshot.blobsContents[id]!;\n\t\t\tif (content !== undefined) {\n\t\t\t\tdecoded = bufferToString(content, \"utf-8\");\n\t\t\t}\n\t\t\t// 0.44 back-compat We still put contents in same blob for back-compat so need to add blob\n\t\t\t// only for blobPath -> blobId mapping and not for blobId -> blob value contents.\n\t\t} else if (snapshot.blobs[id] !== undefined) {\n\t\t\t// Non null asserting here because of the undefined check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tdecoded = fromBase64ToUtf8(snapshot.blobs[id]!);\n\t\t}\n\t\tif (decoded !== undefined) {\n\t\t\tbuilder.addBlob(path, decoded);\n\t\t}\n\t}\n\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotTreeToSummaryTree(tree);\n\t\tbuilder.addWithStats(key, subtree);\n\t}\n\n\tconst summaryTree = builder.getSummaryTree();\n\tsummaryTree.summary.unreferenced = snapshot.unreferenced;\n\tsummaryTree.summary.groupId = snapshot.groupId;\n\treturn summaryTree;\n}\n\n/**\n * Converts ISummaryTree to ITree format. This is needed for back-compat while we get rid of snapshot.\n * @param summaryTree - summary tree in ISummaryTree format\n * @internal\n */\nexport function convertSummaryTreeToITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tfor (const [key, value] of Object.entries(summaryTree.tree)) {\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(key, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(key, convertSummaryTreeToITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(key, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t\tgroupId: summaryTree.groupId,\n\t};\n}\n\n/**\n * Looks in the given attach message snapshot for the .gcdata blob, which would\n * contain the initial GC Data for the node being attached.\n * If it finds it, it notifies GC of all the new outbound routes being added by the attach.\n *\n * @param snapshot - The snapshot from the attach message\n * @param addedGCOutboundRoute - Callback to notify GC of a new outbound route.\n * IMPORTANT: addedGCOutboundRoute's param nodeId is \"/\" for the attaching node itself, or \"/<id>\" for its children.\n *\n * @returns true if it found/processed GC Data, false otherwise\n *\n * @internal\n */\nexport function processAttachMessageGCData(\n\tsnapshot: ITree | null,\n\taddedGCOutboundRoute: (fromNodeId: string, toPath: string) => void,\n): boolean {\n\tconst gcDataEntry = snapshot?.entries.find((e) => e.path === gcDataBlobKey);\n\n\t// Old attach messages won't have GC Data\n\t// (And REALLY old DataStore Attach messages won't even have a snapshot!)\n\tif (gcDataEntry === undefined) {\n\t\treturn false;\n\t}\n\n\tassert(\n\t\tgcDataEntry.type === TreeEntry.Blob && gcDataEntry.value.encoding === \"utf-8\",\n\t\t0x8ff /* GC data should be a utf-8-encoded blob */,\n\t);\n\n\tconst gcData = JSON.parse(gcDataEntry.value.contents) as IGarbageCollectionData;\n\tfor (const [nodeId, outboundRoutes] of Object.entries(gcData.gcNodes)) {\n\t\toutboundRoutes.forEach((toPath) => {\n\t\t\taddedGCOutboundRoute(nodeId, toPath);\n\t\t});\n\t}\n\treturn true;\n}\n\n/**\n * @internal\n */\nexport class TelemetryContext implements ITelemetryContext, ITelemetryContextExt {\n\tprivate readonly telemetry = new Map<string, TelemetryEventPropertyTypeExt>();\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}\n\t */\n\tset(prefix: string, property: string, value: TelemetryEventPropertyTypeExt): void {\n\t\tthis.telemetry.set(`${prefix}${property}`, value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.setMultiple}\n\t */\n\tsetMultiple(\n\t\tprefix: string,\n\t\tproperty: string,\n\t\tvalues: Record<string, TelemetryEventPropertyTypeExt>,\n\t): void {\n\t\t// Set the values individually so that they are logged as a flat list along with other properties.\n\t\tfor (const key of Object.keys(values)) {\n\t\t\tthis.set(prefix, `${property}_${key}`, values[key]);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}\n\t */\n\tget(prefix: string, property: string): TelemetryEventPropertyTypeExt {\n\t\treturn this.telemetry.get(`${prefix}${property}`);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}\n\t */\n\tserialize(): string {\n\t\tconst jsonObject = {};\n\t\tthis.telemetry.forEach((value, key) => {\n\t\t\tjsonObject[key] = value;\n\t\t});\n\t\treturn JSON.stringify(jsonObject);\n\t}\n}\n\n/**\n * Trims the leading slashes from the given string.\n * @param str - A string that may contain leading slashes.\n * @returns A new string without leading slashes.\n */\nfunction trimLeadingSlashes(str: string) {\n\treturn str.replace(/^\\/+/g, \"\");\n}\n\n/**\n * Trims the trailing slashes from the given string.\n * @param str - A string that may contain trailing slashes.\n * @returns A new string without trailing slashes.\n */\nfunction trimTrailingSlashes(str: string) {\n\treturn str.replace(/\\/+$/g, \"\");\n}\n\n/**\n * Helper class to build the garbage collection data of a node by combining the data from multiple nodes.\n * @internal\n */\nexport class GCDataBuilder implements IGarbageCollectionData {\n\tprivate readonly gcNodesSet: { [id: string]: Set<string> } = {};\n\tpublic get gcNodes(): { [id: string]: string[] } {\n\t\tconst gcNodes = {};\n\t\tfor (const [nodeId, outboundRoutes] of Object.entries(this.gcNodesSet)) {\n\t\t\tgcNodes[nodeId] = [...outboundRoutes];\n\t\t}\n\t\treturn gcNodes;\n\t}\n\n\tpublic addNode(id: string, outboundRoutes: string[]) {\n\t\tthis.gcNodesSet[id] = new Set(outboundRoutes);\n\t}\n\n\t/**\n\t * Adds the given GC nodes. It does the following:\n\t * - Normalizes the ids of the given nodes.\n\t * - Prefixes the given `prefixId` to the given nodes' ids.\n\t * - Adds the outbound routes of the nodes against the normalized and prefixed id.\n\t */\n\tpublic prefixAndAddNodes(prefixId: string, gcNodes: { [id: string]: string[] }) {\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcNodes)) {\n\t\t\t// Remove any leading slashes from the id.\n\t\t\tlet normalizedId = trimLeadingSlashes(id);\n\t\t\t// Prefix the given id to the normalized id.\n\t\t\tnormalizedId = `/${prefixId}/${normalizedId}`;\n\t\t\t// Remove any trailing slashes from the normalized id. Note that the trailing slashes are removed after\n\t\t\t// adding the prefix for handling the special case where id is \"/\".\n\t\t\tnormalizedId = trimTrailingSlashes(normalizedId);\n\n\t\t\t// Add the outbound routes against the normalized and prefixed id without duplicates.\n\t\t\tthis.gcNodesSet[normalizedId] = new Set(outboundRoutes);\n\t\t}\n\t}\n\n\tpublic addNodes(gcNodes: { [id: string]: string[] }) {\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcNodes)) {\n\t\t\tthis.gcNodesSet[id] = new Set(outboundRoutes);\n\t\t}\n\t}\n\n\t/**\n\t * Adds the given outbound route to the outbound routes of all GC nodes.\n\t */\n\tpublic addRouteToAllNodes(outboundRoute: string) {\n\t\tfor (const outboundRoutes of Object.values(this.gcNodesSet)) {\n\t\t\toutboundRoutes.add(outboundRoute);\n\t\t}\n\t}\n\n\tpublic getGCData(): IGarbageCollectionData {\n\t\treturn {\n\t\t\tgcNodes: this.gcNodes,\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"summaryUtils.js","sourceRoot":"","sources":["../src/summaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GAChB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAM9E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AACxE,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,aAAa,GACb,MAAM,uCAAuC,CAAC;AAS/C,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAG7E;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,KAAsB;IACnD,MAAM,OAAO,GAAG;QACf,aAAa,EAAE,CAAC;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E,CAAC;YAC9C,uGAAuG;YACvG,mEAAmE;YACnE,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;YAEjD,qFAAqF;YACrF,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;IAEM,QAAQ,CAAC,OAAiC;QAChD,KAAK,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5D,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC;IAED;;OAEG;IACI,kBAAkB,CAAC,aAAqB;QAC9C,KAAK,MAAM,cAAc,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7D,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;IAEM,SAAS;QACf,OAAO;YACN,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tfromBase64ToUtf8,\n} from \"@fluid-internal/client-utils\";\nimport type { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tISummaryBlob,\n\tISummaryTree,\n\tSummaryObject,\n} from \"@fluidframework/driver-definitions\";\nimport { SummaryType } from \"@fluidframework/driver-definitions\";\nimport type { ITree, ITreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport { TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tAttachmentTreeEntry,\n\tBlobTreeEntry,\n\tTreeTreeEntry,\n} from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryStats,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIGarbageCollectionData,\n\tISummarizeResult,\n\tITelemetryContextExt,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { gcDataBlobKey } from \"@fluidframework/runtime-definitions/internal\";\nimport type { TelemetryEventPropertyTypeExt } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Combines summary stats by adding their totals together.\n * Returns empty stats if called without args.\n * @param stats - stats to merge\n * @internal\n */\nexport function mergeStats(...stats: ISummaryStats[]): ISummaryStats {\n\tconst results = {\n\t\ttreeNodeCount: 0,\n\t\tblobNodeCount: 0,\n\t\thandleNodeCount: 0,\n\t\ttotalBlobSize: 0,\n\t\tunreferencedBlobSize: 0,\n\t};\n\tfor (const stat of stats) {\n\t\tresults.treeNodeCount += stat.treeNodeCount;\n\t\tresults.blobNodeCount += stat.blobNodeCount;\n\t\tresults.handleNodeCount += stat.handleNodeCount;\n\t\tresults.totalBlobSize += stat.totalBlobSize;\n\t\tresults.unreferencedBlobSize += stat.unreferencedBlobSize;\n\t}\n\treturn results;\n}\n\n/**\n * Calculates the byte length of an UTF-8 encoded string\n * @param str - The string to calculate the byte length of\n * @returns The byte length of the string\n * @internal\n */\nexport function utf8ByteLength(str: string): number {\n\t// returns the byte length of an utf8 string\n\tlet s = str.length;\n\tfor (let i = str.length - 1; i >= 0; i--) {\n\t\tconst code = str.codePointAt(i);\n\t\tif (code !== undefined) {\n\t\t\tif (code > 0x7f && code <= 0x7ff) {\n\t\t\t\ts++;\n\t\t\t} else if (code > 0x7ff && code <= 0xffff) {\n\t\t\t\ts += 2;\n\t\t\t}\n\t\t\tif (code >= 0xdc00 && code <= 0xdfff) {\n\t\t\t\ti--; // trail surrogate\n\t\t\t}\n\t\t}\n\t}\n\treturn s;\n}\n\n/**\n * Gets the size of a blob\n * @param content - The content of the blob\n * @returns The size of the blob in bytes\n * @internal\n */\nexport function getBlobSize(content: ISummaryBlob[\"content\"]): number {\n\treturn typeof content === \"string\" ? utf8ByteLength(content) : content.byteLength;\n}\n\nfunction calculateStatsCore(summaryObject: SummaryObject, stats: ISummaryStats): void {\n\tswitch (summaryObject.type) {\n\t\tcase SummaryType.Tree: {\n\t\t\tstats.treeNodeCount++;\n\t\t\tfor (const value of Object.values(summaryObject.tree)) {\n\t\t\t\tcalculateStatsCore(value, stats);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tcase SummaryType.Handle: {\n\t\t\tstats.handleNodeCount++;\n\t\t\treturn;\n\t\t}\n\t\tcase SummaryType.Blob: {\n\t\t\tstats.blobNodeCount++;\n\t\t\tstats.totalBlobSize += getBlobSize(summaryObject.content);\n\t\t\treturn;\n\t\t}\n\t\tdefault: {\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n/**\n * Calculates the stats for a summary object\n * @param summary - The summary object to calculate stats for\n * @returns The calculated stats\n * @internal\n */\nexport function calculateStats(summary: SummaryObject): ISummaryStats {\n\tconst stats = mergeStats();\n\tcalculateStatsCore(summary, stats);\n\treturn stats;\n}\n\n/**\n * Adds a blob to the summary tree\n * @param summary - The summary tree to add the blob to\n * @param key - The key to store the blob at\n * @param content - The content of the blob to be added\n * @internal\n */\nexport function addBlobToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tcontent: string | Uint8Array,\n): void {\n\tconst blob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent,\n\t};\n\tsummary.summary.tree[key] = blob;\n\tsummary.stats.blobNodeCount++;\n\tsummary.stats.totalBlobSize += getBlobSize(content);\n}\n\n/**\n * Adds a summarize result to the summary tree\n * @param summary - The summary tree to add the summarize result to\n * @param key - The key to store the summarize result at\n * @param summarizeResult - The summarize result to be added\n * @internal\n */\nexport function addSummarizeResultToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tsummarizeResult: ISummarizeResult,\n): void {\n\tsummary.summary.tree[key] = summarizeResult.summary;\n\tsummary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\n/**\n * An object who's properties are used to initialize a {@link SummaryTreeBuilder}\n * @legacy @beta\n */\nexport interface SummaryTreeBuilderParams {\n\t/**\n\t * This value will become the {@link @fluidframework/driver-definitions#ISummaryTree.groupId}\n\t * of the {@link @fluidframework/driver-definitions#ISummaryTree} built by the {@link SummaryTreeBuilder}.\n\t */\n\tgroupId?: string;\n}\n/**\n * A helper class for building summary trees.\n * @remarks Uses the builder pattern.\n * @legacy @beta\n */\nexport class SummaryTreeBuilder implements ISummaryTreeWithStats {\n\tprivate attachmentCounter: number = 0;\n\tprivate readonly groupId?: string;\n\n\tpublic get summary(): ISummaryTree {\n\t\tconst summary: ISummaryTree = {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t};\n\t\tif (this.groupId !== undefined) {\n\t\t\tsummary.groupId = this.groupId;\n\t\t}\n\t\treturn summary;\n\t}\n\n\tpublic get stats(): Readonly<ISummaryStats> {\n\t\treturn { ...this.summaryStats };\n\t}\n\n\tpublic constructor(params?: { groupId?: string }) {\n\t\tthis.summaryStats = mergeStats();\n\t\tthis.summaryStats.treeNodeCount++;\n\t\tthis.groupId = params?.groupId;\n\t}\n\n\tprivate readonly summaryTree: Record<string, SummaryObject> = {};\n\tprivate summaryStats: ISummaryStats;\n\n\t/**\n\t * Add a blob to the summary tree. This blob will be stored at the given key in the summary tree.\n\t * @param key - The key to store the blob at in the current summary tree being generated. Should not contain any \"/\" characters.\n\t * @param content - The content of the blob to be added to the summary tree.\n\t */\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\t// Prevent cloning by directly referencing underlying private properties\n\t\taddBlobToSummary(\n\t\t\t{\n\t\t\t\tsummary: {\n\t\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\t\ttree: this.summaryTree,\n\t\t\t\t},\n\t\t\t\tstats: this.summaryStats,\n\t\t\t},\n\t\t\tkey,\n\t\t\tcontent,\n\t\t);\n\t}\n\n\t/**\n\t * Adds an {@link @fluidframework/driver-definitions#ISummaryHandle} that references a subtree, blob, or attachment in a previous summary.\n\t *\n\t * @param key - The key to store the handle at in the current summary tree being generated. Should not contain any \"/\" characters.\n\t * @param handleType - the type of {@link @fluidframework/driver-definitions#SummaryObject} besides a SummaryHandle, i.e. {@link @fluidframework/driver-definitions#SummaryType.Tree}, {@link @fluidframework/driver-definitions#SummaryType.Blob}, {@link @fluidframework/driver-definitions#SummaryType.Attachment}\n\t * @param handle - The path pointing to the part of the previous summary being used to duplicate the data. Use {@link @fluidframework/driver-definitions#ISummaryHandle.handle} to help generate proper handle strings. Should not contain any \"/\" characters.\n\t */\n\tpublic addHandle(\n\t\tkey: string,\n\t\thandleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n\t\thandle: string,\n\t): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType,\n\t\t\thandle,\n\t\t};\n\t\tthis.summaryStats.handleNodeCount++;\n\t}\n\n\t/**\n\t * Adds a child and updates the stats accordingly.\n\t * @param key - The key to store the handle at in the current summary tree being generated. Should not contain any \"/\" characters.\n\t * The key should be unique within the current summary tree, and not transform when encodeURIComponent is called.\n\t * @param summarizeResult - Similar to {@link @fluidframework/runtime-definitions#ISummaryTreeWithStats}. The provided summary can be either a {@link @fluidframework/driver-definitions#ISummaryHandle} or {@link @fluidframework/driver-definitions#ISummaryTree}.\n\t */\n\tpublic addWithStats(key: string, summarizeResult: ISummarizeResult): void {\n\t\tthis.summaryTree[key] = summarizeResult.summary;\n\t\tthis.summaryStats = mergeStats(this.summaryStats, summarizeResult.stats);\n\t}\n\n\t/**\n\t * Adds an {@link @fluidframework/driver-definitions#ISummaryAttachment} to the summary. This blob needs to already be uploaded to storage.\n\t * @param id - The id of the uploaded attachment to be added to the summary tree.\n\t */\n\tpublic addAttachment(id: string): void {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n\n\t/**\n\t * Gives you the in-memory summary tree with stats built by the SummaryTreeBuilder.\n\t *\n\t * @remarks\n\t * Use this once you're done building the summary tree, the stats should automatically be generated.\n\t * @returns The summary tree and stats built by the SummaryTreeBuilder.\n\t */\n\tpublic getSummaryTree(): ISummaryTreeWithStats {\n\t\treturn { summary: this.summary, stats: this.stats };\n\t}\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n * @legacy @beta\n */\nexport function convertToSummaryTreeWithStats(\n\tsnapshot: ITree,\n\tfullTree: boolean = false,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tfor (const entry of snapshot.entries) {\n\t\tswitch (entry.type) {\n\t\t\tcase TreeEntry.Blob: {\n\t\t\t\tconst blob = entry.value;\n\t\t\t\tconst content =\n\t\t\t\t\tblob.encoding === \"base64\" ? IsoBuffer.from(blob.contents, \"base64\") : blob.contents;\n\t\t\t\tbuilder.addBlob(entry.path, content);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase TreeEntry.Tree: {\n\t\t\t\tconst subtree = convertToSummaryTree(entry.value, fullTree);\n\t\t\t\tbuilder.addWithStats(entry.path, subtree);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase TreeEntry.Attachment: {\n\t\t\t\tconst id = entry.value.id;\n\t\t\t\tbuilder.addAttachment(id);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"Unexpected TreeEntry type\");\n\t\t\t}\n\t\t}\n\t}\n\n\tconst summaryTree = builder.getSummaryTree();\n\tsummaryTree.summary.unreferenced = snapshot.unreferenced;\n\tsummaryTree.summary.groupId = snapshot.groupId;\n\treturn summaryTree;\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n * @internal\n */\nexport function convertToSummaryTree(\n\tsnapshot: ITree,\n\tfullTree: boolean = false,\n): ISummarizeResult {\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tif (snapshot.id && !fullTree) {\n\t\tconst stats = mergeStats();\n\t\tstats.handleNodeCount++;\n\t\treturn {\n\t\t\tsummary: {\n\t\t\t\thandle: snapshot.id,\n\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\ttype: SummaryType.Handle,\n\t\t\t},\n\t\t\tstats,\n\t\t};\n\t} else {\n\t\treturn convertToSummaryTreeWithStats(snapshot, fullTree);\n\t}\n}\n\n/**\n * Converts ISnapshotTree to ISummaryTree format and tracks stats. This snapshot tree was\n * was taken by serialize api in detached container.\n * @param snapshot - snapshot in ISnapshotTree format\n * @internal\n */\nexport function convertSnapshotTreeToSummaryTree(\n\tsnapshot: ISnapshotTreeWithBlobContents,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tlet decoded: string | undefined;\n\t\tif (snapshot.blobsContents !== undefined) {\n\t\t\t// TODO Why are we non null asserting here?\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst content: ArrayBufferLike = snapshot.blobsContents[id]!;\n\t\t\tif (content !== undefined) {\n\t\t\t\t// Cannot change \"utf-8\" to \"utf8\" as this encoding value is stored in summaries and would be a breaking change which needs to be done first before changing to utf8.\n\t\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- External on-disk format is 'utf-8'.\n\t\t\t\tdecoded = bufferToString(content, \"utf-8\");\n\t\t\t}\n\t\t\t// 0.44 back-compat We still put contents in same blob for back-compat so need to add blob\n\t\t\t// only for blobPath -> blobId mapping and not for blobId -> blob value contents.\n\t\t} else if (snapshot.blobs[id] !== undefined) {\n\t\t\t// Non null asserting here because of the undefined check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tdecoded = fromBase64ToUtf8(snapshot.blobs[id]!);\n\t\t}\n\t\tif (decoded !== undefined) {\n\t\t\tbuilder.addBlob(path, decoded);\n\t\t}\n\t}\n\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotTreeToSummaryTree(tree);\n\t\tbuilder.addWithStats(key, subtree);\n\t}\n\n\tconst summaryTree = builder.getSummaryTree();\n\tsummaryTree.summary.unreferenced = snapshot.unreferenced;\n\tsummaryTree.summary.groupId = snapshot.groupId;\n\treturn summaryTree;\n}\n\n/**\n * Converts ISummaryTree to ITree format. This is needed for back-compat while we get rid of snapshot.\n * @param summaryTree - summary tree in ISummaryTree format\n * @internal\n */\nexport function convertSummaryTreeToITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tfor (const [key, value] of Object.entries(summaryTree.tree)) {\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\t// Cannot change \"utf-8\" to \"utf8\" as this encoding value is stored in summaries and would be a breaking change which needs to be done first before changing to utf8.\n\t\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- external contract uses 'utf-8'.\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(key, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(key, convertSummaryTreeToITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(key, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t\t}\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t\tgroupId: summaryTree.groupId,\n\t};\n}\n\n/**\n * Looks in the given attach message snapshot for the .gcdata blob, which would\n * contain the initial GC Data for the node being attached.\n * If it finds it, it notifies GC of all the new outbound routes being added by the attach.\n *\n * @param snapshot - The snapshot from the attach message\n * @param addedGCOutboundRoute - Callback to notify GC of a new outbound route.\n * IMPORTANT: addedGCOutboundRoute's param nodeId is \"/\" for the attaching node itself, or \"/<id>\" for its children.\n *\n * @returns true if it found/processed GC Data, false otherwise\n *\n * @internal\n */\nexport function processAttachMessageGCData(\n\tsnapshot: ITree | undefined,\n\taddedGCOutboundRoute: (fromNodeId: string, toPath: string) => void,\n): boolean {\n\tconst gcDataEntry = snapshot?.entries.find((e) => e.path === gcDataBlobKey);\n\n\t// Old attach messages won't have GC Data\n\t// (And REALLY old DataStore Attach messages won't even have a snapshot!)\n\tif (gcDataEntry === undefined) {\n\t\treturn false;\n\t}\n\n\tassert(\n\t\t// Cannot change \"utf-8\" to \"utf8\" as this encoding value is stored in summaries and would be a breaking change which needs to be done first before changing to utf8.\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- external contract uses 'utf-8'.\n\t\tgcDataEntry.type === TreeEntry.Blob && gcDataEntry.value.encoding === \"utf-8\",\n\t\t0x8ff /* GC data should be a utf-8-encoded blob */,\n\t);\n\n\t// Type assertion is safe as we expect the GC data to conform to IGarbageCollectionData schema\n\tconst gcData = JSON.parse(gcDataEntry.value.contents) as IGarbageCollectionData;\n\tfor (const [nodeId, outboundRoutes] of Object.entries(gcData.gcNodes)) {\n\t\tfor (const toPath of outboundRoutes) {\n\t\t\taddedGCOutboundRoute(nodeId, toPath);\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * @internal\n */\nexport class TelemetryContext implements ITelemetryContext, ITelemetryContextExt {\n\tprivate readonly telemetry = new Map<string, TelemetryEventPropertyTypeExt>();\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}\n\t */\n\tpublic set(prefix: string, property: string, value: TelemetryEventPropertyTypeExt): void {\n\t\tthis.telemetry.set(`${prefix}${property}`, value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.setMultiple}\n\t */\n\tpublic setMultiple(\n\t\tprefix: string,\n\t\tproperty: string,\n\t\tvalues: Record<string, TelemetryEventPropertyTypeExt>,\n\t): void {\n\t\t// Set the values individually so that they are logged as a flat list along with other properties.\n\t\tfor (const key of Object.keys(values)) {\n\t\t\tthis.set(prefix, `${property}_${key}`, values[key]);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}\n\t */\n\tpublic get(prefix: string, property: string): TelemetryEventPropertyTypeExt {\n\t\treturn this.telemetry.get(`${prefix}${property}`);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}\n\t */\n\tpublic serialize(): string {\n\t\tconst jsonObject = {};\n\t\tfor (const [key, value] of this.telemetry.entries()) {\n\t\t\tjsonObject[key] = value;\n\t\t}\n\t\treturn JSON.stringify(jsonObject);\n\t}\n}\n\n/**\n * Trims the leading slashes from the given string.\n * @param str - A string that may contain leading slashes.\n * @returns A new string without leading slashes.\n */\nfunction trimLeadingSlashes(str: string): string {\n\treturn str.replace(/^\\/+/g, \"\");\n}\n\n/**\n * Trims the trailing slashes from the given string.\n * @param str - A string that may contain trailing slashes.\n * @returns A new string without trailing slashes.\n */\nfunction trimTrailingSlashes(str: string): string {\n\treturn str.replace(/\\/+$/g, \"\");\n}\n\n/**\n * Helper class to build the garbage collection data of a node by combining the data from multiple nodes.\n * @internal\n */\nexport class GCDataBuilder implements IGarbageCollectionData {\n\tprivate readonly gcNodesSet: Record<string, Set<string>> = {};\n\tpublic get gcNodes(): Record<string, string[]> {\n\t\tconst gcNodes = {};\n\t\tfor (const [nodeId, outboundRoutes] of Object.entries(this.gcNodesSet)) {\n\t\t\tgcNodes[nodeId] = [...outboundRoutes];\n\t\t}\n\t\treturn gcNodes;\n\t}\n\n\tpublic addNode(id: string, outboundRoutes: string[]): void {\n\t\tthis.gcNodesSet[id] = new Set(outboundRoutes);\n\t}\n\n\t/**\n\t * Adds the given GC nodes. It does the following:\n\t * - Normalizes the ids of the given nodes.\n\t * - Prefixes the given `prefixId` to the given nodes' ids.\n\t * - Adds the outbound routes of the nodes against the normalized and prefixed id.\n\t */\n\tpublic prefixAndAddNodes(prefixId: string, gcNodes: Record<string, string[]>): void {\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcNodes)) {\n\t\t\t// Remove any leading slashes from the id.\n\t\t\tlet normalizedId = trimLeadingSlashes(id);\n\t\t\t// Prefix the given id to the normalized id.\n\t\t\tnormalizedId = `/${prefixId}/${normalizedId}`;\n\t\t\t// Remove any trailing slashes from the normalized id. Note that the trailing slashes are removed after\n\t\t\t// adding the prefix for handling the special case where id is \"/\".\n\t\t\tnormalizedId = trimTrailingSlashes(normalizedId);\n\n\t\t\t// Add the outbound routes against the normalized and prefixed id without duplicates.\n\t\t\tthis.gcNodesSet[normalizedId] = new Set(outboundRoutes);\n\t\t}\n\t}\n\n\tpublic addNodes(gcNodes: Record<string, string[]>): void {\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcNodes)) {\n\t\t\tthis.gcNodesSet[id] = new Set(outboundRoutes);\n\t\t}\n\t}\n\n\t/**\n\t * Adds the given outbound route to the outbound routes of all GC nodes.\n\t */\n\tpublic addRouteToAllNodes(outboundRoute: string): void {\n\t\tfor (const outboundRoutes of Object.values(this.gcNodesSet)) {\n\t\t\toutboundRoutes.add(outboundRoute);\n\t\t}\n\t}\n\n\tpublic getGCData(): IGarbageCollectionData {\n\t\treturn {\n\t\t\tgcNodes: this.gcNodes,\n\t\t};\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unpackUsedRoutes.d.ts","sourceRoot":"","sources":["../src/unpackUsedRoutes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;GAKG;AACH,wBAAgB,0BAA0B,
|
|
1
|
+
{"version":3,"file":"unpackUsedRoutes.d.ts","sourceRoot":"","sources":["../src/unpackUsedRoutes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACzC,UAAU,EAAE,SAAS,MAAM,EAAE,GAC3B,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAqBvB"}
|
package/lib/unpackUsedRoutes.js
CHANGED
|
@@ -19,11 +19,11 @@ export function unpackChildNodesUsedRoutes(usedRoutes) {
|
|
|
19
19
|
assert(childId !== undefined, 0x9ab /* childId is undefined in unpackChildNodesUsedRoutes */);
|
|
20
20
|
const childUsedRoute = route.slice(childId.length + 1);
|
|
21
21
|
const childUsedRoutes = childUsedRoutesMap.get(childId);
|
|
22
|
-
if (childUsedRoutes
|
|
23
|
-
|
|
22
|
+
if (childUsedRoutes === undefined) {
|
|
23
|
+
childUsedRoutesMap.set(childId, [childUsedRoute]);
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
|
-
|
|
26
|
+
childUsedRoutes.push(childUsedRoute);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
return childUsedRoutesMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unpackUsedRoutes.js","sourceRoot":"","sources":["../src/unpackUsedRoutes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,
|
|
1
|
+
{"version":3,"file":"unpackUsedRoutes.js","sourceRoot":"","sources":["../src/unpackUsedRoutes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CACzC,UAA6B;IAE7B,oFAAoF;IACpF,MAAM,kBAAkB,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC;IACvF,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACvD,KAAK,MAAM,KAAK,IAAI,kBAAkB,EAAE,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACzF,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,CACL,OAAO,KAAK,SAAS,EACrB,KAAK,CAAC,wDAAwD,CAC9D,CAAC;QACF,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAEvD,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YACnC,kBAAkB,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACP,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC3B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\n/**\n * Helper function that unpacks the used routes of children from a given node's used routes.\n * @param usedRoutes - The used routes of a node.\n * @returns A map of used routes of each children of the the given node.\n * @internal\n */\nexport function unpackChildNodesUsedRoutes(\n\tusedRoutes: readonly string[],\n): Map<string, string[]> {\n\t// Remove the node's self used route, if any, and generate the children used routes.\n\tconst filteredUsedRoutes = usedRoutes.filter((route) => route !== \"\" && route !== \"/\");\n\tconst childUsedRoutesMap = new Map<string, string[]>();\n\tfor (const route of filteredUsedRoutes) {\n\t\tassert(route.startsWith(\"/\"), 0x5e0 /* Used route should always be an absolute route */);\n\t\tconst childId = route.split(\"/\")[1];\n\t\tassert(\n\t\t\tchildId !== undefined,\n\t\t\t0x9ab /* childId is undefined in unpackChildNodesUsedRoutes */,\n\t\t);\n\t\tconst childUsedRoute = route.slice(childId.length + 1);\n\n\t\tconst childUsedRoutes = childUsedRoutesMap.get(childId);\n\t\tif (childUsedRoutes === undefined) {\n\t\t\tchildUsedRoutesMap.set(childId, [childUsedRoute]);\n\t\t} else {\n\t\t\tchildUsedRoutes.push(childUsedRoute);\n\t\t}\n\t}\n\treturn childUsedRoutesMap;\n}\n"]}
|
package/lib/utils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISnapshotTree } from "@fluidframework/driver-definitions/internal";
|
|
5
|
+
import type { ISnapshotTree } from "@fluidframework/driver-definitions/internal";
|
|
6
6
|
/**
|
|
7
7
|
* Accepted header keys for requests coming to the runtime.
|
|
8
8
|
* @internal
|
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAG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,CAAsB,cAAc,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,cAAc,CAAC;AAC9B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GACjC,kEAAkE,CAAC;AAEpE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAsB,EAAE,MAAM,GAAG,EAAE;IAC1E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,0DAA0D;IAC1D,yEAAyE;IACzE,wFAAwF;IACxF,iEAAiE;IACjE,8FAA8F;IAC9F,gDAAgD;IAChD,8EAA8E;IAC9E,wDAAwD;IACxD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzE,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,IAAI,GAAG,GAAG,KAAK,CAAC;IAChB,GAAG,CAAC;QACH,gDAAgD;QAChD,WAAW;QACX,WAAW;QACX,aAAa;QACb,cAAc;QACd,iBAAiB;QACjB,kBAAkB;QAClB,MAAM,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC;QACxB,EAAE,GAAG,qBAAqB,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACxC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,EAAE;IACrB,OAAO,MAAM,GAAG,EAAE,CAAC;AACpB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentAttributes,\n\tISnapshotTree,\n} from \"@fluidframework/driver-definitions/internal\";\n\n/**\n * Accepted header keys for requests coming to the runtime.\n * @internal\n */\nexport enum RuntimeHeaders {\n\t/**\n\t * True to wait for a data store to be created and loaded before returning it.\n\t */\n\twait = \"wait\",\n\t/**\n\t * True if the request is coming from an IFluidHandle.\n\t */\n\tviaHandle = \"viaHandle\",\n\t/**\n\t * True if the request is coming from a handle with a pending payload.\n\t */\n\tpayloadPending = \"payloadPending\",\n}\n\n/**\n * Reads a blob from storage and parses it from JSON.\n *\n * @internal\n */\nexport type ReadAndParseBlob = <T>(id: string) => Promise<T>;\n\n/**\n * Fetches the sequence number of the snapshot tree by examining the protocol.\n * @param tree - snapshot tree to examine\n * @param readAndParseBlob - function to read blob contents from storage\n * and parse the result from JSON.\n * @internal\n */\nexport async function seqFromTree(\n\ttree: ISnapshotTree,\n\treadAndParseBlob: ReadAndParseBlob,\n): Promise<number> {\n\t// TODO why are we non null asserting here?\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst attributesHash = tree.trees[\".protocol\"]!.blobs.attributes!;\n\tconst attrib = await readAndParseBlob<IDocumentAttributes>(attributesHash);\n\treturn attrib.sequenceNumber;\n}\n\n/**\n * The following characters emulates the UTF-16 code sequence from 65 - 123, except for the `[` and `{`\n * positioned at 91 and 123 respectively - which are changed to '(' and ')'. Used in the `encodeCompactIdToString` utility below.\n * NOTE: The character set must never be changed - since it could result in collisions with existing ids.\n * If changing, make sure to choose new characters that have never been\n * used before, and the characters must not change their encoding with 'encodeURIComponent'.\n * @internal\n */\nexport const charSetForEncodingIds =\n\t\"ABCDEFGHIJKLMNOPQRSTUVWXYZ(abcdefghijklmnopqrstuvwxyz)0123456789\";\n\n/**\n * Encode compact ID (returned by IContainerRuntime.generateDocumentUniqueId()) to a compact string representation.\n * While this is the main usage pattern, it works with any non-negative integer or a string.\n * Strings are returned as is, and assumed to be UUIDs, i.e. unique enough to never overlap with\n * numbers encoded as strings by this function. Any other strings are likely to run into collisions and should not be used!\n * This function is useful in places where we serialize resulting ID as string and use them as strings, thus we are not\n * gaining any efficiency from having a number type.\n * We do not provide a decode function, so this API is only useful only result is stored and there is no need to go back to original form.\n * @param idArg - input - either a non-negative integer or a string. Strings are returned as is, while numbers are encoded in compat form\n * @param prefix - optional string prefix\n * @returns A string - representation of an input\n * @internal\n */\nexport function encodeCompactIdToString(idArg: number | string, prefix = \"\") {\n\tif (typeof idArg === \"string\") {\n\t\treturn idArg;\n\t}\n\n\t// WARNING: result of this function are stored in storage!\n\t// If you ever need to change this function, you will need to ensure that\n\t// for any inputs N1 & N2, old(N1) !== new(N2), where old() - is the old implementation,\n\t// and new() - is new implementation of encodeCompactIdToString()\n\t// This likely means - this function can't be changed, unless it uses some prefix that ensures\n\t// new values have zero overlap with old values.\n\t// Also resulting string can't contain \"/\", as that's disallowed by some users\n\t// (data store and DDS IDs can't have \"/\" in their IDs).\n\tassert(Number.isInteger(idArg) && idArg >= 0, 0x900 /* invalid input */);\n\tlet id = \"\";\n\tlet num = idArg;\n\tdo {\n\t\t// Here are some examples of the input & output:\n\t\t// 0 -> 'A'\n\t\t// 1 -> 'B'\n\t\t// 64 -> \"AA\"\n\t\t// 100 -> 'Aj'\n\t\t// 10000 -> 'BaQ'\n\t\t// 100000 -> 'XZf'\n\t\tconst encode = num % 64;\n\t\tid = charSetForEncodingIds[encode] + id;\n\t\tnum = Math.floor(num / 64) - 1;\n\t} while (num !== -1);\n\treturn prefix + id;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D;;;GAGG;AACH,MAAM,CAAN,IAAY,cAaX;AAbD,WAAY,cAAc;IACzB;;OAEG;IACH,+BAAa,CAAA;IACb;;OAEG;IACH,yCAAuB,CAAA;IACvB;;OAEG;IACH,mDAAiC,CAAA;AAClC,CAAC,EAbW,cAAc,KAAd,cAAc,QAazB;AASD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,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(c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIDocumentAttributes,\n\tISnapshotTree,\n} from \"@fluidframework/driver-definitions/internal\";\n\n/**\n * Accepted header keys for requests coming to the runtime.\n * @internal\n */\nexport enum RuntimeHeaders {\n\t/**\n\t * True to wait for a data store to be created and loaded before returning it.\n\t */\n\twait = \"wait\",\n\t/**\n\t * True if the request is coming from an IFluidHandle.\n\t */\n\tviaHandle = \"viaHandle\",\n\t/**\n\t * True if the request is coming from a handle with a pending payload.\n\t */\n\tpayloadPending = \"payloadPending\",\n}\n\n/**\n * Reads a blob from storage and parses it from JSON.\n *\n * @internal\n */\nexport type ReadAndParseBlob = <T>(id: string) => Promise<T>;\n\n/**\n * Fetches the sequence number of the snapshot tree by examining the protocol.\n * @param tree - snapshot tree to examine\n * @param readAndParseBlob - function to read blob contents from storage\n * and parse the result from JSON.\n * @internal\n */\nexport async function seqFromTree(\n\ttree: ISnapshotTree,\n\treadAndParseBlob: ReadAndParseBlob,\n): Promise<number> {\n\t// TODO why are we non null asserting here?\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst attributesHash = tree.trees[\".protocol\"]!.blobs.attributes!;\n\tconst attrib = await readAndParseBlob<IDocumentAttributes>(attributesHash);\n\treturn attrib.sequenceNumber;\n}\n\n/**\n * The following characters emulates the UTF-16 code sequence from 65 - 123, except for the `[` and `{`\n * positioned at 91 and 123 respectively - which are changed to '(' and ')'. Used in the `encodeCompactIdToString` utility below.\n * NOTE: The character set must never be changed - since it could result in collisions with existing ids.\n * If changing, make sure to choose new characters that have never been\n * used before, and the characters must not change their encoding with 'encodeURIComponent'.\n * @internal\n */\nexport const charSetForEncodingIds =\n\t\"ABCDEFGHIJKLMNOPQRSTUVWXYZ(abcdefghijklmnopqrstuvwxyz)0123456789\";\n\n/**\n * Encode compact ID (returned by IContainerRuntime.generateDocumentUniqueId()) to a compact string representation.\n * While this is the main usage pattern, it works with any non-negative integer or a string.\n * Strings are returned as is, and assumed to be UUIDs, i.e. unique enough to never overlap with\n * numbers encoded as strings by this function. Any other strings are likely to run into collisions and should not be used!\n * This function is useful in places where we serialize resulting ID as string and use them as strings, thus we are not\n * gaining any efficiency from having a number type.\n * We do not provide a decode function, so this API is only useful only result is stored and there is no need to go back to original form.\n * @param idArg - input - either a non-negative integer or a string. Strings are returned as is, while numbers are encoded in compat form\n * @param prefix - optional string prefix\n * @returns A string - representation of an input\n * @internal\n */\nexport function encodeCompactIdToString(idArg: number | string, prefix = \"\"): string {\n\tif (typeof idArg === \"string\") {\n\t\treturn idArg;\n\t}\n\n\t// WARNING: result of this function are stored in storage!\n\t// If you ever need to change this function, you will need to ensure that\n\t// for any inputs N1 & N2, old(N1) !== new(N2), where old() - is the old implementation,\n\t// and new() - is new implementation of encodeCompactIdToString()\n\t// This likely means - this function can't be changed, unless it uses some prefix that ensures\n\t// new values have zero overlap with old values.\n\t// Also resulting string can't contain \"/\", as that's disallowed by some users\n\t// (data store and DDS IDs can't have \"/\" in their IDs).\n\tassert(Number.isInteger(idArg) && idArg >= 0, 0x900 /* invalid input */);\n\tlet id = \"\";\n\tlet num = idArg;\n\tdo {\n\t\t// Here are some examples of the input & output:\n\t\t// 0 -> 'A'\n\t\t// 1 -> 'B'\n\t\t// 64 -> \"AA\"\n\t\t// 100 -> 'Aj'\n\t\t// 10000 -> 'BaQ'\n\t\t// 100000 -> 'XZf'\n\t\tconst encode = num % 64;\n\t\tid = charSetForEncodingIds[encode] + id;\n\t\tnum = Math.floor(num / 64) - 1;\n\t} while (num !== -1);\n\treturn prefix + id;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/runtime-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.60.0",
|
|
4
4
|
"description": "Collection of utility functions for Fluid Runtime",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,27 +69,27 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluid-internal/client-utils": "~2.
|
|
73
|
-
"@fluidframework/container-definitions": "~2.
|
|
74
|
-
"@fluidframework/container-runtime-definitions": "~2.
|
|
75
|
-
"@fluidframework/core-interfaces": "~2.
|
|
76
|
-
"@fluidframework/core-utils": "~2.
|
|
77
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
78
|
-
"@fluidframework/driver-definitions": "~2.
|
|
79
|
-
"@fluidframework/driver-utils": "~2.
|
|
80
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
81
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
72
|
+
"@fluid-internal/client-utils": "~2.60.0",
|
|
73
|
+
"@fluidframework/container-definitions": "~2.60.0",
|
|
74
|
+
"@fluidframework/container-runtime-definitions": "~2.60.0",
|
|
75
|
+
"@fluidframework/core-interfaces": "~2.60.0",
|
|
76
|
+
"@fluidframework/core-utils": "~2.60.0",
|
|
77
|
+
"@fluidframework/datastore-definitions": "~2.60.0",
|
|
78
|
+
"@fluidframework/driver-definitions": "~2.60.0",
|
|
79
|
+
"@fluidframework/driver-utils": "~2.60.0",
|
|
80
|
+
"@fluidframework/runtime-definitions": "~2.60.0",
|
|
81
|
+
"@fluidframework/telemetry-utils": "~2.60.0",
|
|
82
82
|
"semver-ts": "^1.0.3"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
86
86
|
"@biomejs/biome": "~1.9.3",
|
|
87
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
87
|
+
"@fluid-internal/mocha-test-setup": "~2.60.0",
|
|
88
88
|
"@fluid-tools/build-cli": "^0.57.0",
|
|
89
89
|
"@fluidframework/build-common": "^2.0.3",
|
|
90
90
|
"@fluidframework/build-tools": "^0.57.0",
|
|
91
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
92
|
-
"@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.
|
|
91
|
+
"@fluidframework/eslint-config-fluid": "^6.0.0",
|
|
92
|
+
"@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.53.0",
|
|
93
93
|
"@microsoft/api-extractor": "7.52.8",
|
|
94
94
|
"@types/mocha": "^10.0.10",
|
|
95
95
|
"@types/node": "^18.19.0",
|
package/src/compatibilityBase.ts
CHANGED
|
@@ -68,9 +68,7 @@ export type SemanticVersion =
|
|
|
68
68
|
* @internal
|
|
69
69
|
*/
|
|
70
70
|
export type ConfigMap<T extends Record<string, unknown>> = {
|
|
71
|
-
[K in keyof T]-?:
|
|
72
|
-
[version: MinimumMinorSemanticVersion]: T[K];
|
|
73
|
-
};
|
|
71
|
+
[K in keyof T]-?: Record<MinimumMinorSemanticVersion, T[K]>;
|
|
74
72
|
};
|
|
75
73
|
|
|
76
74
|
/**
|
|
@@ -94,6 +92,7 @@ export function getConfigsForMinVersionForCollab<T extends Record<SemanticVersio
|
|
|
94
92
|
const defaultConfigs: Partial<T> = {};
|
|
95
93
|
// Iterate over configMap to get default values for each option.
|
|
96
94
|
for (const key of Object.keys(configMap)) {
|
|
95
|
+
// Type assertion is safe as key comes from Object.keys(configMap)
|
|
97
96
|
const config = configMap[key as keyof T];
|
|
98
97
|
// Sort the versions in ascending order so we can short circuit the loop.
|
|
99
98
|
const versions = Object.keys(config).sort(compare);
|
|
@@ -102,6 +101,7 @@ export function getConfigsForMinVersionForCollab<T extends Record<SemanticVersio
|
|
|
102
101
|
// value that is compatible with the version specified as the minVersionForCollab.
|
|
103
102
|
for (const version of versions) {
|
|
104
103
|
if (gte(minVersionForCollab, version)) {
|
|
104
|
+
// Type assertion is safe as version is a key from the config object
|
|
105
105
|
defaultConfigs[key] = config[version as MinimumMinorSemanticVersion];
|
|
106
106
|
} else {
|
|
107
107
|
// If the minVersionForCollab is less than the version, we break out of the loop since we don't need to check
|
|
@@ -145,6 +145,7 @@ export function getValidationForRuntimeOptions<T extends Record<string, unknown>
|
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
147
|
// Iterate through each runtime option passed in by the user
|
|
148
|
+
// Type assertion is safe as entries come from runtimeOptions object
|
|
148
149
|
for (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(
|
|
149
150
|
runtimeOptions,
|
|
150
151
|
) as [keyof T & string, T[keyof T & string]][]) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IFluidHandleContext } from "@fluidframework/core-interfaces/internal";
|
|
6
|
+
import type { IFluidHandleContext } from "@fluidframework/core-interfaces/internal";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Generates the absolute path for a Fluid object given its path and its parent routeContext.
|
package/src/dataStoreHelpers.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IRequest, IResponse } from "@fluidframework/core-interfaces";
|
|
6
|
+
import type { IRequest, IResponse } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
8
|
import { generateErrorWithStack } from "@fluidframework/telemetry-utils/internal";
|
|
9
9
|
|
|
@@ -12,45 +12,69 @@ interface IResponseException extends Error {
|
|
|
12
12
|
message: string;
|
|
13
13
|
code: number;
|
|
14
14
|
stack?: string;
|
|
15
|
-
underlyingResponseHeaders?:
|
|
15
|
+
underlyingResponseHeaders?: Record<string, unknown>;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
+
* Type guard for determining if an error is an {@link IResponseException}.
|
|
19
20
|
* @internal
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
+
function isResponseException(err: unknown): err is IResponseException {
|
|
23
|
+
return (
|
|
24
|
+
err !== null &&
|
|
25
|
+
typeof err === "object" &&
|
|
26
|
+
"errorFromRequestFluidObject" in err &&
|
|
27
|
+
(err as { errorFromRequestFluidObject: unknown }).errorFromRequestFluidObject === true
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Converts an error object into an {@link @fluidframework/core-interfaces#IResponse}.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export function exceptionToResponse(error: unknown): IResponse {
|
|
22
36
|
const status = 500;
|
|
23
|
-
if (
|
|
24
|
-
const responseErr: IResponseException = err;
|
|
37
|
+
if (isResponseException(error)) {
|
|
25
38
|
return {
|
|
26
39
|
mimeType: "text/plain",
|
|
27
|
-
status:
|
|
28
|
-
value:
|
|
40
|
+
status: error.code,
|
|
41
|
+
value: error.message,
|
|
29
42
|
get stack() {
|
|
30
|
-
return
|
|
43
|
+
return error.stack;
|
|
31
44
|
},
|
|
32
|
-
headers:
|
|
45
|
+
headers: error.underlyingResponseHeaders,
|
|
33
46
|
};
|
|
34
47
|
}
|
|
35
48
|
|
|
36
|
-
// Capture error objects, not stack itself, as stack retrieval is very expensive operation
|
|
49
|
+
// Capture error objects, not stack itself, as stack retrieval is very expensive operation
|
|
37
50
|
const errWithStack = generateErrorWithStack();
|
|
38
51
|
|
|
39
52
|
return {
|
|
40
53
|
mimeType: "text/plain",
|
|
41
54
|
status,
|
|
42
|
-
value: `${
|
|
55
|
+
value: `${error}`,
|
|
43
56
|
get stack() {
|
|
44
|
-
|
|
57
|
+
// Use type assertion after checking if error is an object with stack
|
|
58
|
+
return (
|
|
59
|
+
(typeof error === "object" && error !== null && "stack" in error
|
|
60
|
+
? (error.stack as string | undefined)
|
|
61
|
+
: undefined) ?? errWithStack.stack
|
|
62
|
+
);
|
|
45
63
|
},
|
|
46
64
|
};
|
|
47
65
|
}
|
|
48
66
|
|
|
49
67
|
/**
|
|
68
|
+
* Converts an {@link @fluidframework/core-interfaces#IResponse} back into an Error object that can be thrown.
|
|
69
|
+
* @param response - The {@link @fluidframework/core-interfaces#IResponse} to convert.
|
|
70
|
+
* @param request - The original {@link @fluidframework/core-interfaces#IRequest}.
|
|
71
|
+
* @returns An Error object with additional properties from the response
|
|
50
72
|
* @internal
|
|
51
73
|
*/
|
|
52
74
|
export function responseToException(response: IResponse, request: IRequest): Error {
|
|
53
|
-
|
|
75
|
+
// As of 2025-08-20 the code seems to assume `response.value` is always a string.
|
|
76
|
+
// This type assertion just encodes that assumption as we move to stricter linting rules, but it might need to be revisited.
|
|
77
|
+
const message = response.value as string;
|
|
54
78
|
const errWithStack = generateErrorWithStack();
|
|
55
79
|
const responseErr: Error & IResponseException = {
|
|
56
80
|
errorFromRequestFluidObject: true,
|
|
@@ -67,20 +91,29 @@ export function responseToException(response: IResponse, request: IRequest): Err
|
|
|
67
91
|
}
|
|
68
92
|
|
|
69
93
|
/**
|
|
94
|
+
* Creates a 404 "not found" response for the given request
|
|
95
|
+
* @param request - The request that resulted in the 404 response
|
|
96
|
+
* @returns An {@link @fluidframework/core-interfaces#IResponse} with 404 status code.
|
|
70
97
|
* @legacy
|
|
71
|
-
* @
|
|
98
|
+
* @beta
|
|
72
99
|
*/
|
|
73
|
-
export const create404Response = (request: IRequest) =>
|
|
100
|
+
export const create404Response = (request: IRequest): IResponse =>
|
|
74
101
|
createResponseError(404, "not found", request);
|
|
75
102
|
|
|
76
103
|
/**
|
|
104
|
+
* Creates an error response with the specified status code and message
|
|
105
|
+
* @param status - HTTP status code for the error (must not be 200)
|
|
106
|
+
* @param value - Error message or description
|
|
107
|
+
* @param request - The request that resulted in this error
|
|
108
|
+
* @param headers - Optional headers to include in the response
|
|
109
|
+
* @returns An {@link @fluidframework/core-interfaces#IResponse} representing the error
|
|
77
110
|
* @internal
|
|
78
111
|
*/
|
|
79
112
|
export function createResponseError(
|
|
80
113
|
status: number,
|
|
81
114
|
value: string,
|
|
82
115
|
request: IRequest,
|
|
83
|
-
headers?:
|
|
116
|
+
headers?: Record<string, unknown>,
|
|
84
117
|
): IResponse {
|
|
85
118
|
assert(status !== 200, 0x19b /* "Cannot not create response error on 200 status" */);
|
|
86
119
|
// Omit query string which could contain personal data unfit for logging
|
package/src/deltaManager.ts
CHANGED
|
@@ -13,12 +13,12 @@ import type {
|
|
|
13
13
|
/**
|
|
14
14
|
* Casts the public API for delta manager into the internal one,
|
|
15
15
|
* exposing access to APIs needed by the implementation of Fluid Framework but not its users.
|
|
16
|
-
* @legacy
|
|
17
|
-
* @alpha
|
|
16
|
+
* @legacy @beta
|
|
18
17
|
*/
|
|
19
18
|
export function toDeltaManagerInternal(
|
|
20
19
|
deltaManager: IDeltaManagerErased,
|
|
21
20
|
): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> {
|
|
21
|
+
// Type assertion is safe as IDeltaManagerErased is specifically designed to be a type-erased version of IDeltaManager
|
|
22
22
|
return deltaManager as unknown as IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -29,5 +29,6 @@ export function toDeltaManagerInternal(
|
|
|
29
29
|
export function toDeltaManagerErased(
|
|
30
30
|
deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,
|
|
31
31
|
): IDeltaManagerErased {
|
|
32
|
+
// Type assertion is safe as we're intentionally erasing the type information for public API safety
|
|
32
33
|
return deltaManager as unknown as IDeltaManagerErased;
|
|
33
34
|
}
|
package/src/handles.ts
CHANGED
|
@@ -36,13 +36,15 @@ export interface ISerializedHandle {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Narrow a value to {@link ISerializedHandle} by checking its type property.
|
|
40
40
|
* @internal
|
|
41
41
|
*/
|
|
42
|
-
export const isSerializedHandle = (value:
|
|
43
|
-
|
|
42
|
+
export const isSerializedHandle = (value: unknown): value is ISerializedHandle =>
|
|
43
|
+
// Type assertion is safe as we're only checking for the existence of the type property
|
|
44
|
+
(value as { type?: string } | undefined)?.type === "__fluid_handle__";
|
|
44
45
|
|
|
45
46
|
/**
|
|
47
|
+
* Checks if a Fluid handle's internal payload is pending.
|
|
46
48
|
* @internal
|
|
47
49
|
*/
|
|
48
50
|
export const isFluidHandleInternalPayloadPending = (
|
|
@@ -55,8 +57,7 @@ export const isFluidHandleInternalPayloadPending = (
|
|
|
55
57
|
* @privateRemarks
|
|
56
58
|
* This should be true for locally-created BlobHandles currently. When IFluidHandlePayloadPending is merged
|
|
57
59
|
* to IFluidHandle, this type guard will no longer be necessary.
|
|
58
|
-
* @legacy
|
|
59
|
-
* @alpha
|
|
60
|
+
* @legacy @beta
|
|
60
61
|
*/
|
|
61
62
|
export const isFluidHandlePayloadPending = <T>(
|
|
62
63
|
handle: IFluidHandle<T>,
|
|
@@ -66,8 +67,7 @@ export const isFluidHandlePayloadPending = <T>(
|
|
|
66
67
|
|
|
67
68
|
/**
|
|
68
69
|
* Check if the handle is an ILocalFluidHandle.
|
|
69
|
-
* @legacy
|
|
70
|
-
* @alpha
|
|
70
|
+
* @legacy @beta
|
|
71
71
|
*/
|
|
72
72
|
export const isLocalFluidHandle = <T>(
|
|
73
73
|
handle: IFluidHandle<T>,
|
|
@@ -122,6 +122,7 @@ export function isFluidHandle(value: unknown): value is IFluidHandle {
|
|
|
122
122
|
// If enableBackwardsCompatibility, run check for FluidHandles predating use of fluidHandleSymbol.
|
|
123
123
|
if (enableBackwardsCompatibility && IFluidHandle in value) {
|
|
124
124
|
// Since this check can have false positives, make it a bit more robust by checking value[IFluidHandle][IFluidHandle]
|
|
125
|
+
// Type assertion is needed for backward compatibility with old FluidHandle format
|
|
125
126
|
const inner = value[IFluidHandle] as IFluidHandle;
|
|
126
127
|
if (typeof inner !== "object" || inner === null) {
|
|
127
128
|
return false;
|
|
@@ -145,12 +146,12 @@ export function compareFluidHandles(a: IFluidHandle, b: IFluidHandle): boolean {
|
|
|
145
146
|
|
|
146
147
|
/**
|
|
147
148
|
* Downcast an IFluidHandle to an IFluidHandleInternal.
|
|
148
|
-
* @legacy
|
|
149
|
-
* @alpha
|
|
149
|
+
* @legacy @beta
|
|
150
150
|
*/
|
|
151
151
|
export function toFluidHandleInternal<T>(handle: IFluidHandle<T>): IFluidHandleInternal<T> {
|
|
152
152
|
if (!(fluidHandleSymbol in handle) || !(fluidHandleSymbol in handle[fluidHandleSymbol])) {
|
|
153
153
|
if (enableBackwardsCompatibility && IFluidHandle in handle) {
|
|
154
|
+
// Type assertion needed for backward compatibility with old handle format
|
|
154
155
|
return handle[IFluidHandle] as IFluidHandleInternal<T>;
|
|
155
156
|
}
|
|
156
157
|
throw new TypeError("Invalid IFluidHandle");
|
|
@@ -158,24 +159,24 @@ export function toFluidHandleInternal<T>(handle: IFluidHandle<T>): IFluidHandleI
|
|
|
158
159
|
|
|
159
160
|
// This casts the IFluidHandleErased from the symbol instead of `handle` to ensure that if someone
|
|
160
161
|
// implements their own IFluidHandle in terms of an existing handle, it won't break anything.
|
|
162
|
+
// Type assertion is safe as fluidHandleSymbol is guaranteed to contain an IFluidHandleInternal
|
|
161
163
|
return handle[fluidHandleSymbol] as unknown as IFluidHandleInternal<T>;
|
|
162
164
|
}
|
|
163
165
|
|
|
164
166
|
/**
|
|
165
167
|
* Type erase IFluidHandleInternal for use with {@link @fluidframework/core-interfaces#fluidHandleSymbol}.
|
|
166
|
-
* @legacy
|
|
167
|
-
* @alpha
|
|
168
|
+
* @legacy @beta
|
|
168
169
|
*/
|
|
169
170
|
export function toFluidHandleErased<T>(
|
|
170
171
|
handle: IFluidHandleInternal<T>,
|
|
171
172
|
): IFluidHandleErased<T> {
|
|
173
|
+
// Type assertion is safe as we're intentionally erasing internal type information
|
|
172
174
|
return handle as unknown as IFluidHandleErased<T>;
|
|
173
175
|
}
|
|
174
176
|
|
|
175
177
|
/**
|
|
176
178
|
* Base class which can be uses to assist implementing IFluidHandleInternal.
|
|
177
|
-
* @legacy
|
|
178
|
-
* @alpha
|
|
179
|
+
* @legacy @beta
|
|
179
180
|
*/
|
|
180
181
|
export abstract class FluidHandleBase<T> implements IFluidHandleInternal<T> {
|
|
181
182
|
public abstract absolutePath: string;
|
package/src/index.ts
CHANGED
|
@@ -14,7 +14,6 @@ export {
|
|
|
14
14
|
compareFluidHandles,
|
|
15
15
|
encodeHandleForSerialization,
|
|
16
16
|
FluidHandleBase,
|
|
17
|
-
ISerializedHandle,
|
|
18
17
|
isFluidHandle,
|
|
19
18
|
isFluidHandleInternalPayloadPending,
|
|
20
19
|
isFluidHandlePayloadPending,
|
|
@@ -23,6 +22,7 @@ export {
|
|
|
23
22
|
toFluidHandleErased,
|
|
24
23
|
toFluidHandleInternal,
|
|
25
24
|
} from "./handles.js";
|
|
25
|
+
export type { ISerializedHandle } from "./handles.js";
|
|
26
26
|
export { ObjectStoragePartition } from "./objectstoragepartition.js";
|
|
27
27
|
export {
|
|
28
28
|
getNormalizedObjectStoragePathParts,
|
|
@@ -49,24 +49,26 @@ export {
|
|
|
49
49
|
} from "./summaryUtils.js";
|
|
50
50
|
export { unpackChildNodesUsedRoutes } from "./unpackUsedRoutes.js";
|
|
51
51
|
export {
|
|
52
|
-
ReadAndParseBlob,
|
|
53
52
|
RuntimeHeaders,
|
|
54
53
|
seqFromTree,
|
|
55
54
|
encodeCompactIdToString,
|
|
56
55
|
} from "./utils.js";
|
|
56
|
+
export type { ReadAndParseBlob } from "./utils.js";
|
|
57
57
|
export { isSnapshotFetchRequiredForLoadingGroupId } from "./snapshotUtils.js";
|
|
58
58
|
export {
|
|
59
59
|
toDeltaManagerErased,
|
|
60
60
|
toDeltaManagerInternal,
|
|
61
61
|
} from "./deltaManager.js";
|
|
62
62
|
export {
|
|
63
|
-
ConfigMap,
|
|
64
63
|
configValueToMinVersionForCollab,
|
|
65
|
-
ConfigValidationMap,
|
|
66
64
|
defaultMinVersionForCollab,
|
|
67
65
|
getValidationForRuntimeOptions,
|
|
68
66
|
getConfigsForMinVersionForCollab,
|
|
69
67
|
isValidMinVersionForCollab,
|
|
68
|
+
} from "./compatibilityBase.js";
|
|
69
|
+
export type {
|
|
70
|
+
ConfigMap,
|
|
71
|
+
ConfigValidationMap,
|
|
70
72
|
MinimumMinorSemanticVersion,
|
|
71
73
|
SemanticVersion,
|
|
72
74
|
} from "./compatibilityBase.js";
|