@fluidframework/routerlicious-driver 2.0.0-internal.5.3.2 → 2.0.0-internal.6.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 +20 -0
- package/dist/contracts.d.ts +28 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/deltaStorageService.d.ts.map +1 -1
- package/dist/deltaStorageService.js +17 -6
- package/dist/deltaStorageService.js.map +1 -1
- package/dist/documentDeltaConnection.js +1 -1
- package/dist/documentDeltaConnection.js.map +1 -1
- package/dist/documentService.d.ts +3 -3
- package/dist/documentService.d.ts.map +1 -1
- package/dist/documentService.js +1 -1
- package/dist/documentService.js.map +1 -1
- package/dist/documentServiceFactory.d.ts.map +1 -1
- package/dist/documentServiceFactory.js +27 -8
- package/dist/documentServiceFactory.js.map +1 -1
- package/dist/documentStorageService.d.ts +2 -2
- package/dist/documentStorageService.d.ts.map +1 -1
- package/dist/documentStorageService.js +2 -2
- package/dist/documentStorageService.js.map +1 -1
- package/dist/errorUtils.d.ts +5 -6
- package/dist/errorUtils.d.ts.map +1 -1
- package/dist/errorUtils.js +13 -15
- package/dist/errorUtils.js.map +1 -1
- package/dist/gitManager.d.ts +3 -2
- package/dist/gitManager.d.ts.map +1 -1
- package/dist/gitManager.js +2 -2
- package/dist/gitManager.js.map +1 -1
- package/dist/historian.d.ts +3 -2
- package/dist/historian.d.ts.map +1 -1
- package/dist/historian.js +10 -3
- package/dist/historian.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/r11sSnapshotParser.d.ts +4 -5
- package/dist/r11sSnapshotParser.d.ts.map +1 -1
- package/dist/r11sSnapshotParser.js +12 -14
- package/dist/r11sSnapshotParser.js.map +1 -1
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/restWrapper.js +40 -24
- package/dist/restWrapper.js.map +1 -1
- package/dist/restWrapperBase.js +39 -5
- package/dist/restWrapperBase.js.map +1 -1
- package/dist/retriableGitManager.d.ts +3 -2
- package/dist/retriableGitManager.d.ts.map +1 -1
- package/dist/retriableGitManager.js +2 -2
- package/dist/retriableGitManager.js.map +1 -1
- package/dist/shreddedSummaryDocumentStorageService.js +10 -13
- package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/dist/storageContracts.d.ts +4 -3
- package/dist/storageContracts.d.ts.map +1 -1
- package/dist/storageContracts.js.map +1 -1
- package/dist/summaryTreeUploadManager.js +2 -3
- package/dist/summaryTreeUploadManager.js.map +1 -1
- package/dist/treeUtils.d.ts +2 -2
- package/dist/treeUtils.d.ts.map +1 -1
- package/dist/treeUtils.js +2 -3
- package/dist/treeUtils.js.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.d.ts +2 -2
- package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.js +20 -16
- package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
- package/dist/wholeSummaryUploadManager.js +1 -2
- package/dist/wholeSummaryUploadManager.js.map +1 -1
- package/lib/contracts.d.ts +28 -1
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/deltaStorageService.d.ts.map +1 -1
- package/lib/deltaStorageService.js +17 -6
- package/lib/deltaStorageService.js.map +1 -1
- package/lib/documentDeltaConnection.js +1 -1
- package/lib/documentDeltaConnection.js.map +1 -1
- package/lib/documentService.d.ts +3 -3
- package/lib/documentService.d.ts.map +1 -1
- package/lib/documentService.js +1 -1
- package/lib/documentService.js.map +1 -1
- package/lib/documentServiceFactory.d.ts.map +1 -1
- package/lib/documentServiceFactory.js +28 -9
- package/lib/documentServiceFactory.js.map +1 -1
- package/lib/documentStorageService.d.ts +2 -2
- package/lib/documentStorageService.d.ts.map +1 -1
- package/lib/documentStorageService.js +2 -2
- package/lib/documentStorageService.js.map +1 -1
- package/lib/errorUtils.d.ts +5 -6
- package/lib/errorUtils.d.ts.map +1 -1
- package/lib/errorUtils.js +13 -15
- package/lib/errorUtils.js.map +1 -1
- package/lib/gitManager.d.ts +3 -2
- package/lib/gitManager.d.ts.map +1 -1
- package/lib/gitManager.js +2 -2
- package/lib/gitManager.js.map +1 -1
- package/lib/historian.d.ts +3 -2
- package/lib/historian.d.ts.map +1 -1
- package/lib/historian.js +10 -3
- package/lib/historian.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/r11sSnapshotParser.d.ts +4 -5
- package/lib/r11sSnapshotParser.d.ts.map +1 -1
- package/lib/r11sSnapshotParser.js +10 -12
- package/lib/r11sSnapshotParser.js.map +1 -1
- package/lib/restWrapper.d.ts.map +1 -1
- package/lib/restWrapper.js +43 -27
- package/lib/restWrapper.js.map +1 -1
- package/lib/restWrapperBase.js +39 -5
- package/lib/restWrapperBase.js.map +1 -1
- package/lib/retriableGitManager.d.ts +3 -2
- package/lib/retriableGitManager.d.ts.map +1 -1
- package/lib/retriableGitManager.js +2 -2
- package/lib/retriableGitManager.js.map +1 -1
- package/lib/shreddedSummaryDocumentStorageService.js +11 -14
- package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/lib/storageContracts.d.ts +4 -3
- package/lib/storageContracts.d.ts.map +1 -1
- package/lib/storageContracts.js.map +1 -1
- package/lib/summaryTreeUploadManager.js +2 -3
- package/lib/summaryTreeUploadManager.js.map +1 -1
- package/lib/treeUtils.d.ts +2 -2
- package/lib/treeUtils.d.ts.map +1 -1
- package/lib/treeUtils.js +2 -3
- package/lib/treeUtils.js.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts +2 -2
- package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.js +21 -17
- package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
- package/lib/wholeSummaryUploadManager.js +1 -2
- package/lib/wholeSummaryUploadManager.js.map +1 -1
- package/package.json +13 -13
- package/src/contracts.ts +45 -1
- package/src/deltaStorageService.ts +8 -1
- package/src/documentService.ts +2 -2
- package/src/documentServiceFactory.ts +17 -10
- package/src/documentStorageService.ts +3 -3
- package/src/errorUtils.ts +23 -30
- package/src/gitManager.ts +3 -3
- package/src/historian.ts +3 -3
- package/src/packageVersion.ts +1 -1
- package/src/r11sSnapshotParser.ts +13 -14
- package/src/restWrapper.ts +29 -17
- package/src/retriableGitManager.ts +3 -3
- package/src/shreddedSummaryDocumentStorageService.ts +2 -2
- package/src/storageContracts.ts +3 -3
- package/src/treeUtils.ts +2 -2
- package/src/wholeSummaryDocumentStorageService.ts +12 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storageContracts.js","sourceRoot":"","sources":["../src/storageContracts.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as git from \"@fluidframework/gitresources\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport {\n\
|
|
1
|
+
{"version":3,"file":"storageContracts.js","sourceRoot":"","sources":["../src/storageContracts.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as git from \"@fluidframework/gitresources\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport {\n\tIWholeSummaryPayload,\n\tIWholeSummaryPayloadType,\n\tIWriteSummaryResponse,\n} from \"@fluidframework/server-services-client\";\nimport { IR11sResponse } from \"./restWrapper\";\nimport { IWholeFlatSnapshot } from \"./contracts\";\n\n/**\n * Interface to a generic Git provider\n */\nexport interface IHistorian {\n\tgetBlob(sha: string): Promise<IR11sResponse<git.IBlob>>;\n\tcreateBlob(blob: git.ICreateBlobParams): Promise<IR11sResponse<git.ICreateBlobResponse>>;\n\tgetCommits(sha: string, count: number): Promise<IR11sResponse<git.ICommitDetails[]>>;\n\tcreateTree(tree: git.ICreateTreeParams): Promise<IR11sResponse<git.ITree>>;\n\tgetTree(sha: string, recursive: boolean): Promise<IR11sResponse<git.ITree>>;\n\tcreateSummary(\n\t\tsummary: IWholeSummaryPayload,\n\t\tinitial?: boolean,\n\t): Promise<IR11sResponse<IWriteSummaryResponse>>;\n\tgetSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>>;\n}\n\nexport interface IGitManager {\n\tgetCommits(sha: string, count: number): Promise<IR11sResponse<git.ICommitDetails[]>>;\n\tgetTree(root: string, recursive: boolean): Promise<IR11sResponse<git.ITree>>;\n\tgetBlob(sha: string): Promise<IR11sResponse<git.IBlob>>;\n\tcreateBlob(content: string, encoding: string): Promise<IR11sResponse<git.ICreateBlobResponse>>;\n\tcreateGitTree(params: git.ICreateTreeParams): Promise<IR11sResponse<git.ITree>>;\n\tcreateSummary(\n\t\tsummary: IWholeSummaryPayload,\n\t\tinitial?: boolean,\n\t): Promise<IR11sResponse<IWriteSummaryResponse>>;\n\tgetSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>>;\n}\n\n/**\n * Uploads a summary to storage.\n */\nexport interface ISummaryUploadManager {\n\t/**\n\t * Writes summary tree to storage.\n\t * @param summaryTree - Summary tree to write to storage\n\t * @param parentHandle - Parent summary acked handle (if available from summary ack)\n\t * @param summaryType - type of summary being uploaded\n\t * @param sequenceNumber - optional reference sequence number of the summary\n\t * @returns Id of created tree as a string.\n\t */\n\twriteSummaryTree(\n\t\tsummaryTree: api.ISummaryTree,\n\t\tparentHandle: string,\n\t\tsummaryType: IWholeSummaryPayloadType,\n\t\tsequenceNumber?: number,\n\t): Promise<string>;\n}\n"]}
|
|
@@ -19,7 +19,7 @@ class SummaryTreeUploadManager {
|
|
|
19
19
|
}
|
|
20
20
|
async writeSummaryTree(summaryTree, parentHandle, summaryType, sequenceNumber, initial) {
|
|
21
21
|
const previousFullSnapshot = await this.getPreviousFullSnapshot(parentHandle);
|
|
22
|
-
return this.writeSummaryTreeCore(summaryTree, previousFullSnapshot
|
|
22
|
+
return this.writeSummaryTreeCore(summaryTree, previousFullSnapshot ?? undefined);
|
|
23
23
|
}
|
|
24
24
|
async writeSummaryTreeCore(summaryTree, previousFullSnapshot) {
|
|
25
25
|
const entries = await Promise.all(Object.keys(summaryTree.tree).map(async (key) => {
|
|
@@ -84,7 +84,6 @@ class SummaryTreeUploadManager {
|
|
|
84
84
|
getIdFromPathCore(handleType, path,
|
|
85
85
|
/** Previous snapshot, subtree relative to this path part */
|
|
86
86
|
previousSnapshot) {
|
|
87
|
-
var _a;
|
|
88
87
|
(0, common_utils_1.assert)(path.length > 0, 0x0b3 /* "Expected at least 1 path part" */);
|
|
89
88
|
const key = path[0];
|
|
90
89
|
if (path.length === 1) {
|
|
@@ -95,7 +94,7 @@ class SummaryTreeUploadManager {
|
|
|
95
94
|
return tryId;
|
|
96
95
|
}
|
|
97
96
|
case protocol_definitions_1.SummaryType.Tree: {
|
|
98
|
-
const tryId =
|
|
97
|
+
const tryId = previousSnapshot.trees[key]?.id;
|
|
99
98
|
(0, common_utils_1.assert)(!!tryId, 0x0b5 /* "Parent summary does not have tree handle for specified path." */);
|
|
100
99
|
return tryId;
|
|
101
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryTreeUploadManager.js","sourceRoot":"","sources":["../src/summaryTreeUploadManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAMsC;AAEtC,iEAAuE;AACvE,+EAK8C;AAI9C;;GAEG;AACH,MAAa,wBAAwB;IACpC,YACkB,OAAoB,EACpB,aAAkC,EAClC,uBAE+B;QAJ/B,YAAO,GAAP,OAAO,CAAa;QACpB,kBAAa,GAAb,aAAa,CAAqB;QAClC,4BAAuB,GAAvB,uBAAuB,CAEQ;IAC9C,CAAC;IAEG,KAAK,CAAC,gBAAgB,CAC5B,WAAyB,EACzB,YAAoB,EAC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ACvE,CAAC;IAEO,iBAAiB,CACxB,UAAuB,EACvB,IAAc;IACd,4DAA4D;IAC5D,gBAAiC;QAEjC,IAAA,qBAAM,EAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACrE,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACtB,QAAQ,UAAU,EAAE;gBACnB,KAAK,kCAAW,CAAC,IAAI,CAAC,CAAC;oBACtB,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAC1C,IAAA,qBAAM,EACL,CAAC,CAAC,KAAK,EACP,KAAK,CAAC,oEAAoE,CAC1E,CAAC;oBACF,OAAO,KAAK,CAAC;iBACb;gBACD,KAAK,kCAAW,CAAC,IAAI,CAAC,CAAC;oBACtB,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;oBAC9C,IAAA,qBAAM,EACL,CAAC,CAAC,KAAK,EACP,KAAK,CAAC,oEAAoE,CAC1E,CAAC;oBACF,OAAO,KAAK,CAAC;iBACb;gBACD;oBACC,MAAM,KAAK,CAAC,2CAA2C,UAAU,IAAI,CAAC,CAAC;aACxE;SACD;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACvF,CAAC;CACD;AArID,4DAqIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tgitHashFile,\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tunreachableCase,\n} from \"@fluidframework/common-utils\";\nimport { ICreateTreeEntry } from \"@fluidframework/gitresources\";\nimport { getGitMode, getGitType } from \"@fluidframework/protocol-base\";\nimport {\n\tISnapshotTreeEx,\n\tISummaryTree,\n\tSummaryObject,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport { IWholeSummaryPayloadType } from \"@fluidframework/server-services-client\";\nimport { IGitManager, ISummaryUploadManager } from \"./storageContracts\";\n\n/**\n * Recursively writes summary tree as individual summary blobs.\n */\nexport class SummaryTreeUploadManager implements ISummaryUploadManager {\n\tconstructor(\n\t\tprivate readonly manager: IGitManager,\n\t\tprivate readonly blobsShaCache: Map<string, string>,\n\t\tprivate readonly getPreviousFullSnapshot: (\n\t\t\tparentHandle: string,\n\t\t) => Promise<ISnapshotTreeEx | null | undefined>,\n\t) {}\n\n\tpublic async writeSummaryTree(\n\t\tsummaryTree: ISummaryTree,\n\t\tparentHandle: string,\n\t\tsummaryType: IWholeSummaryPayloadType,\n\t\tsequenceNumber?: number,\n\t\tinitial?: boolean,\n\t): Promise<string> {\n\t\tconst previousFullSnapshot = await this.getPreviousFullSnapshot(parentHandle);\n\t\treturn this.writeSummaryTreeCore(summaryTree, previousFullSnapshot ?? undefined);\n\t}\n\n\tprivate async writeSummaryTreeCore(\n\t\tsummaryTree: ISummaryTree,\n\t\tpreviousFullSnapshot: ISnapshotTreeEx | undefined,\n\t): Promise<string> {\n\t\tconst entries = await Promise.all(\n\t\t\tObject.keys(summaryTree.tree).map(async (key) => {\n\t\t\t\tconst entry = summaryTree.tree[key];\n\t\t\t\tconst pathHandle = await this.writeSummaryTreeObject(entry, previousFullSnapshot);\n\t\t\t\tconst treeEntry: ICreateTreeEntry = {\n\t\t\t\t\tmode: getGitMode(entry),\n\t\t\t\t\tpath: encodeURIComponent(key),\n\t\t\t\t\tsha: pathHandle,\n\t\t\t\t\ttype: getGitType(entry),\n\t\t\t\t};\n\t\t\t\treturn treeEntry;\n\t\t\t}),\n\t\t);\n\n\t\tconst treeHandle = (await this.manager.createGitTree({ tree: entries })).content;\n\t\treturn treeHandle.sha;\n\t}\n\n\tprivate async writeSummaryTreeObject(\n\t\tobject: SummaryObject,\n\t\tpreviousFullSnapshot: ISnapshotTreeEx | undefined,\n\t): Promise<string> {\n\t\tswitch (object.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\treturn this.writeSummaryBlob(object.content);\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tif (previousFullSnapshot === undefined) {\n\t\t\t\t\tthrow Error(\"Parent summary does not exist to reference by handle.\");\n\t\t\t\t}\n\t\t\t\treturn this.getIdFromPath(object.handleType, object.handle, previousFullSnapshot);\n\t\t\t}\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\treturn this.writeSummaryTreeCore(object, previousFullSnapshot);\n\t\t\t}\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\treturn object.id;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(object, `Unknown type: ${(object as any).type}`);\n\t\t}\n\t}\n\n\tprivate async writeSummaryBlob(content: string | Uint8Array): Promise<string> {\n\t\tconst { parsedContent, encoding } =\n\t\t\ttypeof content === \"string\"\n\t\t\t\t? { parsedContent: content, encoding: \"utf-8\" }\n\t\t\t\t: { parsedContent: Uint8ArrayToString(content, \"base64\"), encoding: \"base64\" };\n\n\t\t// The gitHashFile would return the same hash as returned by the server as blob.sha\n\t\tconst hash = await gitHashFile(IsoBuffer.from(parsedContent, encoding));\n\t\tif (!this.blobsShaCache.has(hash)) {\n\t\t\tthis.blobsShaCache.set(hash, \"\");\n\t\t\tconst blob = (await this.manager.createBlob(parsedContent, encoding)).content;\n\t\t\tassert(hash === blob.sha, 0x0b6 /* \"Blob.sha and hash do not match!!\" */);\n\t\t}\n\t\treturn hash;\n\t}\n\n\tprivate getIdFromPath(\n\t\thandleType: SummaryType,\n\t\thandlePath: string,\n\t\tpreviousFullSnapshot: ISnapshotTreeEx,\n\t): string {\n\t\tconst path = handlePath.split(\"/\").map((part) => decodeURIComponent(part));\n\t\tif (path[0] === \"\") {\n\t\t\t// root of tree should be unnamed\n\t\t\tpath.shift();\n\t\t}\n\t\tif (path.length === 0) {\n\t\t\treturn previousFullSnapshot.id;\n\t\t}\n\n\t\treturn this.getIdFromPathCore(handleType, path, previousFullSnapshot);\n\t}\n\n\tprivate getIdFromPathCore(\n\t\thandleType: SummaryType,\n\t\tpath: string[],\n\t\t/** Previous snapshot, subtree relative to this path part */\n\t\tpreviousSnapshot: ISnapshotTreeEx,\n\t): string {\n\t\tassert(path.length > 0, 0x0b3 /* \"Expected at least 1 path part\" */);\n\t\tconst key = path[0];\n\t\tif (path.length === 1) {\n\t\t\tswitch (handleType) {\n\t\t\t\tcase SummaryType.Blob: {\n\t\t\t\t\tconst tryId = previousSnapshot.blobs[key];\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!tryId,\n\t\t\t\t\t\t0x0b4 /* \"Parent summary does not have blob handle for specified path.\" */,\n\t\t\t\t\t);\n\t\t\t\t\treturn tryId;\n\t\t\t\t}\n\t\t\t\tcase SummaryType.Tree: {\n\t\t\t\t\tconst tryId = previousSnapshot.trees[key]?.id;\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!tryId,\n\t\t\t\t\t\t0x0b5 /* \"Parent summary does not have tree handle for specified path.\" */,\n\t\t\t\t\t);\n\t\t\t\t\treturn tryId;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tthrow Error(`Unexpected handle summary object type: \"${handleType}\".`);\n\t\t\t}\n\t\t}\n\t\treturn this.getIdFromPathCore(handleType, path.slice(1), previousSnapshot.trees[key]);\n\t}\n}\n"]}
|
package/dist/treeUtils.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { SummaryType, ISnapshotTree, ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
6
|
-
import {
|
|
6
|
+
import { INormalizedWholeSnapshot } from "./contracts";
|
|
7
7
|
/**
|
|
8
8
|
* Summary tree assembler props
|
|
9
9
|
*/
|
|
@@ -49,7 +49,7 @@ export declare class SummaryTreeAssembler {
|
|
|
49
49
|
* @returns Converted snapshot in ISummaryTree format
|
|
50
50
|
*/
|
|
51
51
|
export declare function convertSnapshotAndBlobsToSummaryTree(snapshot: ISnapshotTree, blobs: Map<string, ArrayBuffer>): ISummaryTree;
|
|
52
|
-
export declare function evalBlobsAndTrees(snapshot:
|
|
52
|
+
export declare function evalBlobsAndTrees(snapshot: INormalizedWholeSnapshot): {
|
|
53
53
|
trees: number;
|
|
54
54
|
numBlobs: number;
|
|
55
55
|
encodedBlobsSize: number;
|
package/dist/treeUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeUtils.d.ts","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,aAAa,EACb,YAAY,EAEZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"treeUtils.d.ts","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,aAAa,EACb,YAAY,EAEZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,oBAAoB;IAIpB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IAHnC,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyC;gBAExC,KAAK,CAAC,wCAA4B;IAE/D;;OAEG;IACH,IAAW,OAAO,IAAI,YAAY,CAMjC;IAED;;OAEG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAO/D;;OAEG;IACI,SAAS,CACf,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,UAAU,EACxE,MAAM,EAAE,MAAM,GACZ,IAAI;IAQP;;OAEG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI;IAIxD;;OAEG;IACI,aAAa,CAAC,EAAE,EAAE,MAAM;CAG/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CACnD,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAC7B,YAAY,CAcd;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,wBAAwB;;;;EAQnE;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,QAS5D"}
|
package/dist/treeUtils.js
CHANGED
|
@@ -20,11 +20,10 @@ class SummaryTreeAssembler {
|
|
|
20
20
|
* Get final summary
|
|
21
21
|
*/
|
|
22
22
|
get summary() {
|
|
23
|
-
var _a;
|
|
24
23
|
return {
|
|
25
24
|
type: protocol_definitions_1.SummaryType.Tree,
|
|
26
|
-
tree:
|
|
27
|
-
unreferenced:
|
|
25
|
+
tree: { ...this.summaryTree },
|
|
26
|
+
unreferenced: this.props?.unreferenced,
|
|
28
27
|
};
|
|
29
28
|
}
|
|
30
29
|
/**
|
package/dist/treeUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeUtils.js","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,+EAK8C;AAa9C;;GAEG;AACH,MAAa,oBAAoB;IAIhC,YAA6B,KAAkC;QAAlC,UAAK,GAAL,KAAK,CAA6B;QAHvD,sBAAiB,GAAW,CAAC,CAAC;QACrB,gBAAW,GAAsC,EAA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AgB,EAAE,CAAC;AAC9C,CAAC;AARD,8CAQC;AAED,SAAgB,qBAAqB,CAAC,QAAuB;IAC5D,IAAA,qBAAM,EACL,QAAQ,CAAC,KAAK,KAAK,SAAS,EAC5B,KAAK,CAAC,oDAAoD,CAC1D,CAAC;IACF,IAAA,qBAAM,EACL,QAAQ,CAAC,KAAK,KAAK,SAAS,EAC5B,KAAK,CAAC,oDAAoD,CAC1D,CAAC;AACH,CAAC;AATD,sDASC;AAED,SAAS,wBAAwB,CAAC,YAA2B;IAC5D,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;QAC3D,QAAQ,IAAI,CAAC,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;KAC/C;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, IsoBuffer } from \"@fluidframework/common-utils\";\nimport {\n\tSummaryType,\n\tISnapshotTree,\n\tISummaryTree,\n\tSummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport { INormalizedWholeSnapshot } from \"./contracts\";\n\n/**\n * Summary tree assembler props\n */\nexport interface ISummaryTreeAssemblerProps {\n\t/**\n\t * Indicates that this tree is unreferenced. If this is not present, the tree is considered referenced.\n\t */\n\tunreferenced?: true;\n}\n\n/**\n * Summary tree assembler (without stats collection).\n */\nexport class SummaryTreeAssembler {\n\tprivate attachmentCounter: number = 0;\n\tprivate readonly summaryTree: { [path: string]: SummaryObject } = {};\n\n\tconstructor(private readonly props?: ISummaryTreeAssemblerProps) {}\n\n\t/**\n\t * Get final summary\n\t */\n\tpublic get summary(): ISummaryTree {\n\t\treturn {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t\tunreferenced: this.props?.unreferenced,\n\t\t};\n\t}\n\n\t/**\n\t * Add blob to summary\n\t */\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Blob,\n\t\t\tcontent,\n\t\t};\n\t}\n\n\t/**\n\t * Add handle to summary\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}\n\n\t/**\n\t * Add tree to summary\n\t */\n\tpublic addTree(key: string, summary: ISummaryTree): void {\n\t\tthis.summaryTree[key] = summary;\n\t}\n\n\t/**\n\t * Add attachment to summary\n\t */\n\tpublic addAttachment(id: string) {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n}\n\n/**\n * Helper function that converts ISnapshotTree and blobs to ISummaryTree\n * @param snapshot - Source snapshot tree\n * @param blobs - Blobs cache\n * @returns Converted snapshot in ISummaryTree format\n */\nexport function convertSnapshotAndBlobsToSummaryTree(\n\tsnapshot: ISnapshotTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISummaryTree {\n\tconst assembler = new SummaryTreeAssembler({\n\t\tunreferenced: snapshot.unreferenced,\n\t});\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tconst blob = blobs.get(id);\n\t\tassert(blob !== undefined, 0x2dd /* \"Cannot find blob for a given id\" */);\n\t\tassembler.addBlob(path, IsoBuffer.from(blob).toString(\"utf-8\"));\n\t}\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotAndBlobsToSummaryTree(tree, blobs);\n\t\tassembler.addTree(key, subtree);\n\t}\n\treturn assembler.summary;\n}\n\nexport function evalBlobsAndTrees(snapshot: INormalizedWholeSnapshot) {\n\tconst trees = countTreesInSnapshotTree(snapshot.snapshotTree);\n\tconst numBlobs = snapshot.blobs.size;\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobs) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { trees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: ISnapshotTree) {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x5d0 /* Returned r11s snapshot is malformed. No trees! */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x5d1 /* Returned r11s snapshot is malformed. No blobs! */,\n\t);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n\tlet numTrees = 0;\n\tfor (const [_, tree] of Object.entries(snapshotTree.trees)) {\n\t\tnumTrees += 1 + countTreesInSnapshotTree(tree);\n\t}\n\treturn numTrees;\n}\n"]}
|
|
@@ -8,7 +8,7 @@ import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree, IVers
|
|
|
8
8
|
import { ICache } from "./cache";
|
|
9
9
|
import { IRouterliciousDriverPolicies } from "./policies";
|
|
10
10
|
import { GitManager } from "./gitManager";
|
|
11
|
-
import {
|
|
11
|
+
import { INormalizedWholeSnapshot } from "./contracts";
|
|
12
12
|
export declare class WholeSummaryDocumentStorageService implements IDocumentStorageService {
|
|
13
13
|
protected readonly id: string;
|
|
14
14
|
protected readonly manager: GitManager;
|
|
@@ -22,7 +22,7 @@ export declare class WholeSummaryDocumentStorageService implements IDocumentStor
|
|
|
22
22
|
private firstVersionsCall;
|
|
23
23
|
get repositoryUrl(): string;
|
|
24
24
|
private getSummaryUploadManager;
|
|
25
|
-
constructor(id: string, manager: GitManager, logger: ITelemetryLoggerExt, policies: IDocumentStorageServicePolicies, driverPolicies?: IRouterliciousDriverPolicies | undefined, blobCache?: ICache<ArrayBufferLike>, snapshotTreeCache?: ICache<
|
|
25
|
+
constructor(id: string, manager: GitManager, logger: ITelemetryLoggerExt, policies: IDocumentStorageServicePolicies, driverPolicies?: IRouterliciousDriverPolicies | undefined, blobCache?: ICache<ArrayBufferLike>, snapshotTreeCache?: ICache<INormalizedWholeSnapshot>, noCacheGitManager?: GitManager | undefined, getStorageManager?: (disableCache?: boolean) => Promise<GitManager>);
|
|
26
26
|
getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
|
|
27
27
|
getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null>;
|
|
28
28
|
readBlob(blobId: string): Promise<ArrayBufferLike>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wholeSummaryDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAAC;AAQxF,OAAO,EACN,uBAAuB,EACvB,eAAe,EACf,+BAA+B,EAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"wholeSummaryDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAAC;AAQxF,OAAO,EACN,uBAAuB,EACvB,eAAe,EACf,+BAA+B,EAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAiB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAM1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAE,wBAAwB,EA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IAqBL,eAAe,CAAC,aAAa,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAwBrE,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAqB9D,iBAAiB;YA6CjB,sBAAsB;YAetB,gBAAgB;IAS9B,OAAO,CAAC,WAAW;CAGnB"}
|
|
@@ -36,7 +36,6 @@ class WholeSummaryDocumentStorageService {
|
|
|
36
36
|
return new wholeSummaryUploadManager_1.WholeSummaryUploadManager(manager);
|
|
37
37
|
}
|
|
38
38
|
async getVersions(versionId, count) {
|
|
39
|
-
var _a;
|
|
40
39
|
if (versionId !== this.id && versionId !== null) {
|
|
41
40
|
// Blobs/Trees in this scenario will never have multiple versions, so return versionId as is
|
|
42
41
|
return [
|
|
@@ -51,14 +50,13 @@ class WholeSummaryDocumentStorageService {
|
|
|
51
50
|
if (this.firstVersionsCall && count === 1) {
|
|
52
51
|
const normalizedSnapshotContents = await telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
|
|
53
52
|
eventName: "ObtainSnapshot",
|
|
54
|
-
versionId: versionId
|
|
53
|
+
versionId: versionId ?? undefined,
|
|
55
54
|
count,
|
|
56
|
-
enableDiscovery:
|
|
55
|
+
enableDiscovery: this.driverPolicies?.enableDiscovery,
|
|
57
56
|
}, async (event) => {
|
|
58
|
-
var _a;
|
|
59
57
|
let method;
|
|
60
58
|
const cachedSnapshotP = this.snapshotTreeCache.get(this.getCacheKey(latestSnapshotId));
|
|
61
|
-
const networkSnapshotP = !
|
|
59
|
+
const networkSnapshotP = !this.driverPolicies?.enableDiscovery
|
|
62
60
|
? this.fetchSnapshotTree(latestSnapshotId, false, "getVersions")
|
|
63
61
|
: this.fetchSnapshotTree(latestSnapshotId, true, "getVersions");
|
|
64
62
|
const promiseRaceWinner = await (0, driver_base_1.promiseRaceWithWinner)([
|
|
@@ -156,26 +154,24 @@ class WholeSummaryDocumentStorageService {
|
|
|
156
154
|
ackHandle: context.ackHandle,
|
|
157
155
|
referenceSequenceNumber: context.referenceSequenceNumber,
|
|
158
156
|
}, async () => {
|
|
159
|
-
var _a;
|
|
160
157
|
const summaryUploadManager = await this.getSummaryUploadManager();
|
|
161
|
-
return summaryUploadManager.writeSummaryTree(summary,
|
|
158
|
+
return summaryUploadManager.writeSummaryTree(summary, context.ackHandle ?? "", "channel");
|
|
162
159
|
});
|
|
163
160
|
return summaryHandle;
|
|
164
161
|
}
|
|
165
162
|
async downloadSummary(summaryHandle) {
|
|
166
|
-
const
|
|
163
|
+
const wholeFlatSnapshot = await telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
|
|
167
164
|
eventName: "getWholeFlatSummary",
|
|
168
165
|
treeId: summaryHandle.handle,
|
|
169
166
|
}, async (event) => {
|
|
170
|
-
var _a;
|
|
171
167
|
const manager = await this.getStorageManager();
|
|
172
|
-
const response = await manager.
|
|
168
|
+
const response = await manager.getSnapshot(summaryHandle.handle);
|
|
173
169
|
event.end({
|
|
174
|
-
size:
|
|
170
|
+
size: response.content.trees[0]?.entries.length,
|
|
175
171
|
});
|
|
176
172
|
return response.content;
|
|
177
173
|
});
|
|
178
|
-
const { blobs, snapshotTree } = (0, r11sSnapshotParser_1.
|
|
174
|
+
const { blobs, snapshotTree } = (0, r11sSnapshotParser_1.convertWholeFlatSnapshotToSnapshotTreeAndBlobs)(wholeFlatSnapshot, "");
|
|
179
175
|
return (0, treeUtils_1.convertSnapshotAndBlobsToSummaryTree)(snapshotTree, blobs);
|
|
180
176
|
}
|
|
181
177
|
async createBlob(file) {
|
|
@@ -200,15 +196,23 @@ class WholeSummaryDocumentStorageService {
|
|
|
200
196
|
treeId: versionId,
|
|
201
197
|
scenarioName,
|
|
202
198
|
}, async (event) => {
|
|
203
|
-
var _a;
|
|
204
199
|
const manager = await this.getStorageManager(disableCache);
|
|
205
|
-
const response = await manager.
|
|
200
|
+
const response = await manager.getSnapshot(versionId);
|
|
206
201
|
const start = common_utils_1.performance.now();
|
|
207
|
-
const snapshot = (0, r11sSnapshotParser_1.
|
|
202
|
+
const snapshot = (0, r11sSnapshotParser_1.convertWholeFlatSnapshotToSnapshotTreeAndBlobs)(response.content);
|
|
208
203
|
const snapshotConversionTime = common_utils_1.performance.now() - start;
|
|
209
204
|
(0, treeUtils_1.validateBlobsAndTrees)(snapshot.snapshotTree);
|
|
210
205
|
const { trees, numBlobs, encodedBlobsSize } = (0, treeUtils_1.evalBlobsAndTrees)(snapshot);
|
|
211
|
-
event.end(
|
|
206
|
+
event.end({
|
|
207
|
+
size: response.content.trees[0]?.entries.length,
|
|
208
|
+
trees,
|
|
209
|
+
blobs: numBlobs,
|
|
210
|
+
encodedBlobsSize,
|
|
211
|
+
sequenceNumber: snapshot.sequenceNumber,
|
|
212
|
+
...response.propsToLog,
|
|
213
|
+
snapshotConversionTime,
|
|
214
|
+
...(0, driver_base_1.getW3CData)(response.requestUrl, "xmlhttprequest"),
|
|
215
|
+
});
|
|
212
216
|
return snapshot;
|
|
213
217
|
});
|
|
214
218
|
// Also add the result into the cache.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAAwF;AACxF,+DAKsC;AACtC,6DAAgF;AAchF,mCAAgD;AAEhD,2CAIqB;AAErB,2EAAwE;AAIxE,6DAAqF;AAErF,MAAM,gBAAgB,GAAW,QAAQ,CAAC;AAE1C,MAAa,kCAAkC;IAY9C,YACoB,EAAU,EACV,OAAmB,EACnB,MAA2B,EAC9B,QAAyC,EACxC,cAA6C,EAC7C,YAAqC,IAAI,qBAAa,EAAE,EACxD,oBAAqD,IAAI,qBAAa,EAAE,EACxE,iBAA8B,EAC9B,oBAEU,KAAK,EAAE,YAAY,EAAE,EAAE,CACjD,YAAY,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS;QACnD,CAAC,CAAC,IAAI,CAAC,iB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QAC7C,IAAA,qBAAM,EAAC,UAAU,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAChF,MAAM,OAAO,GAAmB;YAC/B,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,sBAAsB,CAAC;YAChF,IAAI,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,KAAK,CAAC;SACnD,CAAC;QAEF,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE3B,OAAO,UAAU,CAAC;IACnB,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAC,KAA+B;QAC7D,MAAM,cAAc,GAAoB,EAAE,CAAC;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;YAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACtC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;IAEO,WAAW,CAAC,MAAc;QACjC,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAC/B,CAAC;CACD;AA/TD,gFA+TC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tassert,\n\tperformance,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"@fluidframework/common-utils\";\nimport { getW3CData, promiseRaceWithWinner } from \"@fluidframework/driver-base\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IWholeFlatSummary } from \"@fluidframework/server-services-client\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport {\n\tconvertSnapshotAndBlobsToSummaryTree,\n\tevalBlobsAndTrees,\n\tvalidateBlobsAndTrees,\n} from \"./treeUtils\";\nimport { GitManager } from \"./gitManager\";\nimport { WholeSummaryUploadManager } from \"./wholeSummaryUploadManager\";\nimport { ISummaryUploadManager } from \"./storageContracts\";\nimport { IR11sResponse } from \"./restWrapper\";\nimport { INormalizedWholeSummary } from \"./contracts\";\nimport { convertWholeFlatSummaryToSnapshotTreeAndBlobs } from \"./r11sSnapshotParser\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate firstVersionsCall: boolean = true;\n\n\tpublic get repositoryUrl(): string {\n\t\treturn \"\";\n\t}\n\n\tprivate async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n\t\tconst manager = await this.getStorageManager();\n\t\treturn new WholeSummaryUploadManager(manager);\n\t}\n\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly manager: GitManager,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies?: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),\n\t\tprivate readonly snapshotTreeCache: ICache<INormalizedWholeSummary> = new InMemoryCache(),\n\t\tprivate readonly noCacheGitManager?: GitManager,\n\t\tprivate readonly getStorageManager: (\n\t\t\tdisableCache?: boolean,\n\t\t) => Promise<GitManager> = async (disableCache) =>\n\t\t\tdisableCache && this.noCacheGitManager !== undefined\n\t\t\t\t? this.noCacheGitManager\n\t\t\t\t: this.manager,\n\t) {}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tif (versionId !== this.id && versionId !== null) {\n\t\t\t// Blobs/Trees in this scenario will never have multiple versions, so return versionId as is\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\t// If this is the first versions call for the document, we know we will want the latest summary.\n\t\t// Fetch latest summary, cache it, and return its id.\n\t\tif (this.firstVersionsCall && count === 1) {\n\t\t\tconst normalizedSnapshotContents = await PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"ObtainSnapshot\",\n\t\t\t\t\tversionId: versionId ?? undefined,\n\t\t\t\t\tcount,\n\t\t\t\t\tenableDiscovery: this.driverPolicies?.enableDiscovery,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tlet method: string;\n\t\t\t\t\tconst cachedSnapshotP = this.snapshotTreeCache.get(\n\t\t\t\t\t\tthis.getCacheKey(latestSnapshotId),\n\t\t\t\t\t);\n\n\t\t\t\t\tconst networkSnapshotP = !this.driverPolicies?.enableDiscovery\n\t\t\t\t\t\t? this.fetchSnapshotTree(latestSnapshotId, false, \"getVersions\")\n\t\t\t\t\t\t: this.fetchSnapshotTree(latestSnapshotId, true, \"getVersions\");\n\n\t\t\t\t\tconst promiseRaceWinner = await promiseRaceWithWinner([\n\t\t\t\t\t\tcachedSnapshotP.catch(() => undefined),\n\t\t\t\t\t\tnetworkSnapshotP.catch(() => undefined),\n\t\t\t\t\t]);\n\n\t\t\t\t\tlet retrievedSnapshot = promiseRaceWinner.value;\n\t\t\t\t\tmethod = promiseRaceWinner.index === 0 ? \"cache\" : \"network\";\n\n\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t// if network failed -> wait for cache ( then return network failure)\n\t\t\t\t\t\t// If cache returned empty or failed -> wait for network (success of failure)\n\t\t\t\t\t\tif (promiseRaceWinner.index === 1) {\n\t\t\t\t\t\t\tretrievedSnapshot = await cachedSnapshotP;\n\t\t\t\t\t\t\tmethod = \"cache\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\tretrievedSnapshot = await networkSnapshotP;\n\t\t\t\t\t\t\tmethod = \"network\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t});\n\t\t\t\t\treturn retrievedSnapshot;\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tconst _id = await this.initializeFromSnapshot(normalizedSnapshotContents);\n\t\t\tthis.firstVersionsCall = false;\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: _id,\n\t\t\t\t\ttreeId: normalizedSnapshotContents.snapshotTree.id!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// Otherwise, get the latest version of the document as normal.\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getVersions\",\n\t\t\t\tversionId: id,\n\t\t\t\tcount,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\treturn (await manager.getCommits(id, count)).content;\n\t\t\t},\n\t\t);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\tlet normalizedWholeSnapshot = await this.snapshotTreeCache.get(\n\t\t\tthis.getCacheKey(requestVersion.id),\n\t\t);\n\t\tif (normalizedWholeSnapshot !== undefined) {\n\t\t\treturn normalizedWholeSnapshot.snapshotTree;\n\t\t}\n\n\t\tnormalizedWholeSnapshot = await this.fetchSnapshotTree(\n\t\t\trequestVersion.id,\n\t\t\tundefined,\n\t\t\t\"getSnapshotTree\",\n\t\t);\n\n\t\t// Currently retrieving blobs from network is not supported by AFR for WholeSummaryDocumentStorageService\n\t\t// Blobs are expected to be put in the cache\n\t\tawait this.updateBlobsCache(normalizedWholeSnapshot.blobs);\n\n\t\treturn normalizedWholeSnapshot.snapshotTree;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));\n\t\tif (cachedBlob !== undefined) {\n\t\t\treturn cachedBlob;\n\t\t}\n\n\t\t// Note: AFR does not support readBlobs, but potentially other r11s like servers do\n\t\tconst blob = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"readBlob\",\n\t\t\t\tblobId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getBlob(blobId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.size,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst bufferValue = stringToBuffer(blob.content, blob.encoding);\n\n\t\tawait this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);\n\n\t\treturn bufferValue;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryHandle = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"uploadSummaryWithContext\",\n\t\t\t\tproposalHandle: context.proposalHandle,\n\t\t\t\tackHandle: context.ackHandle,\n\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryUploadManager = await this.getSummaryUploadManager();\n\t\t\t\treturn summaryUploadManager.writeSummaryTree(\n\t\t\t\t\tsummary,\n\t\t\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\t\t\"channel\",\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t\treturn summaryHandle;\n\t}\n\n\tpublic async downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst wholeFlatSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: summaryHandle.handle,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager.getSummary(summaryHandle.handle);\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t});\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\n\t\tconst { blobs, snapshotTree } = convertWholeFlatSummaryToSnapshotTreeAndBlobs(\n\t\t\twholeFlatSummary,\n\t\t\t\"\",\n\t\t);\n\t\treturn convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"createBlob\",\n\t\t\t\tsize: uint8ArrayFile.length,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager\n\t\t\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t\t\t.then((r) => ({ id: r.content.sha, url: r.content.url }));\n\t\t\t\tevent.end({\n\t\t\t\t\tblobId: response.id,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async fetchSnapshotTree(\n\t\tversionId: string,\n\t\tdisableCache?: boolean,\n\t\tscenarioName?: string,\n\t): Promise<INormalizedWholeSummary> {\n\t\tconst normalizedWholeSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: versionId,\n\t\t\t\tscenarioName,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager(disableCache);\n\t\t\t\tconst response: IR11sResponse<IWholeFlatSummary> = await manager.getSummary(\n\t\t\t\t\tversionId,\n\t\t\t\t);\n\t\t\t\tconst start = performance.now();\n\t\t\t\tconst snapshot: INormalizedWholeSummary =\n\t\t\t\t\tconvertWholeFlatSummaryToSnapshotTreeAndBlobs(response.content);\n\t\t\t\tconst snapshotConversionTime = performance.now() - start;\n\t\t\t\tvalidateBlobsAndTrees(snapshot.snapshotTree);\n\t\t\t\tconst { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t\ttrees,\n\t\t\t\t\tblobs: numBlobs,\n\t\t\t\t\tencodedBlobsSize,\n\t\t\t\t\tsequenceNumber: snapshot.sequenceNumber,\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\tsnapshotConversionTime,\n\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t});\n\t\t\t\treturn snapshot;\n\t\t\t},\n\t\t);\n\n\t\t// Also add the result into the cache.\n\t\tawait this.snapshotTreeCache\n\t\t\t.put(this.getCacheKey(versionId), normalizedWholeSummary)\n\t\t\t.catch(() => undefined);\n\t\treturn normalizedWholeSummary;\n\t}\n\n\tprivate async initializeFromSnapshot(\n\t\tnormalizedWholeSummary: INormalizedWholeSummary,\n\t): Promise<string> {\n\t\tconst snapshotId = normalizedWholeSummary.id;\n\t\tassert(snapshotId !== undefined, 0x275 /* \"Root tree should contain the id\" */);\n\t\tconst cachePs: Promise<any>[] = [\n\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(snapshotId), normalizedWholeSummary),\n\t\t\tthis.updateBlobsCache(normalizedWholeSummary.blobs),\n\t\t];\n\n\t\tawait Promise.all(cachePs);\n\n\t\treturn snapshotId;\n\t}\n\n\tprivate async updateBlobsCache(blobs: Map<string, ArrayBuffer>): Promise<void> {\n\t\tconst blobCachePutPs: Promise<void>[] = [];\n\t\tblobs.forEach((value, id) => {\n\t\t\tconst cacheKey = this.getCacheKey(id);\n\t\t\tblobCachePutPs.push(this.blobCache.put(cacheKey, value));\n\t\t});\n\t\tawait Promise.all(blobCachePutPs);\n\t}\n\n\tprivate getCacheKey(blobId: string): string {\n\t\treturn `${this.id}:${blobId}`;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAAwF;AACxF,+DAKsC;AACtC,6DAAgF;AAahF,mCAAgD;AAEhD,2CAIqB;AAErB,2EAAwE;AAIxE,6DAAsF;AAEtF,MAAM,gBAAgB,GAAW,QAAQ,CAAC;AAE1C,MAAa,kCAAkC;IAY9C,YACoB,EAAU,EACV,OAAmB,EACnB,MAA2B,EAC9B,QAAyC,EACxC,cAA6C,EAC7C,YAAqC,IAAI,qBAAa,EAAE,EACxD,oBAAsD,IAAI,qBAAa,EAAE,EACzE,iBAA8B,EAC9B,oBAEU,KAAK,EAAE,YAAY,EAAE,EAAE,CACjD,YAAY,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS;QACnD,CAAC,CAAC,IAAI,CAAC,iBAAiB;QACxB,CAAC,CAAC,IAAI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C,CAAC;QAChF,MAAM,OAAO,GAAmB;YAC/B,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,sBAAsB,CAAC;YAChF,IAAI,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,KAAK,CAAC;SACnD,CAAC;QAEF,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE3B,OAAO,UAAU,CAAC;IACnB,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAC,KAA+B;QAC7D,MAAM,cAAc,GAAoB,EAAE,CAAC;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;YAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACtC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;IAEO,WAAW,CAAC,MAAc;QACjC,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAC/B,CAAC;CACD;AA/TD,gFA+TC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tassert,\n\tperformance,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"@fluidframework/common-utils\";\nimport { getW3CData, promiseRaceWithWinner } from \"@fluidframework/driver-base\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport {\n\tconvertSnapshotAndBlobsToSummaryTree,\n\tevalBlobsAndTrees,\n\tvalidateBlobsAndTrees,\n} from \"./treeUtils\";\nimport { GitManager } from \"./gitManager\";\nimport { WholeSummaryUploadManager } from \"./wholeSummaryUploadManager\";\nimport { ISummaryUploadManager } from \"./storageContracts\";\nimport { IR11sResponse } from \"./restWrapper\";\nimport { INormalizedWholeSnapshot, IWholeFlatSnapshot } from \"./contracts\";\nimport { convertWholeFlatSnapshotToSnapshotTreeAndBlobs } from \"./r11sSnapshotParser\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate firstVersionsCall: boolean = true;\n\n\tpublic get repositoryUrl(): string {\n\t\treturn \"\";\n\t}\n\n\tprivate async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n\t\tconst manager = await this.getStorageManager();\n\t\treturn new WholeSummaryUploadManager(manager);\n\t}\n\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly manager: GitManager,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies?: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),\n\t\tprivate readonly snapshotTreeCache: ICache<INormalizedWholeSnapshot> = new InMemoryCache(),\n\t\tprivate readonly noCacheGitManager?: GitManager,\n\t\tprivate readonly getStorageManager: (\n\t\t\tdisableCache?: boolean,\n\t\t) => Promise<GitManager> = async (disableCache) =>\n\t\t\tdisableCache && this.noCacheGitManager !== undefined\n\t\t\t\t? this.noCacheGitManager\n\t\t\t\t: this.manager,\n\t) {}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tif (versionId !== this.id && versionId !== null) {\n\t\t\t// Blobs/Trees in this scenario will never have multiple versions, so return versionId as is\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\t// If this is the first versions call for the document, we know we will want the latest summary.\n\t\t// Fetch latest summary, cache it, and return its id.\n\t\tif (this.firstVersionsCall && count === 1) {\n\t\t\tconst normalizedSnapshotContents = await PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"ObtainSnapshot\",\n\t\t\t\t\tversionId: versionId ?? undefined,\n\t\t\t\t\tcount,\n\t\t\t\t\tenableDiscovery: this.driverPolicies?.enableDiscovery,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tlet method: string;\n\t\t\t\t\tconst cachedSnapshotP = this.snapshotTreeCache.get(\n\t\t\t\t\t\tthis.getCacheKey(latestSnapshotId),\n\t\t\t\t\t);\n\n\t\t\t\t\tconst networkSnapshotP = !this.driverPolicies?.enableDiscovery\n\t\t\t\t\t\t? this.fetchSnapshotTree(latestSnapshotId, false, \"getVersions\")\n\t\t\t\t\t\t: this.fetchSnapshotTree(latestSnapshotId, true, \"getVersions\");\n\n\t\t\t\t\tconst promiseRaceWinner = await promiseRaceWithWinner([\n\t\t\t\t\t\tcachedSnapshotP.catch(() => undefined),\n\t\t\t\t\t\tnetworkSnapshotP.catch(() => undefined),\n\t\t\t\t\t]);\n\n\t\t\t\t\tlet retrievedSnapshot = promiseRaceWinner.value;\n\t\t\t\t\tmethod = promiseRaceWinner.index === 0 ? \"cache\" : \"network\";\n\n\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t// if network failed -> wait for cache ( then return network failure)\n\t\t\t\t\t\t// If cache returned empty or failed -> wait for network (success of failure)\n\t\t\t\t\t\tif (promiseRaceWinner.index === 1) {\n\t\t\t\t\t\t\tretrievedSnapshot = await cachedSnapshotP;\n\t\t\t\t\t\t\tmethod = \"cache\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\tretrievedSnapshot = await networkSnapshotP;\n\t\t\t\t\t\t\tmethod = \"network\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t});\n\t\t\t\t\treturn retrievedSnapshot;\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tconst _id = await this.initializeFromSnapshot(normalizedSnapshotContents);\n\t\t\tthis.firstVersionsCall = false;\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: _id,\n\t\t\t\t\ttreeId: normalizedSnapshotContents.snapshotTree.id!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// Otherwise, get the latest version of the document as normal.\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getVersions\",\n\t\t\t\tversionId: id,\n\t\t\t\tcount,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\treturn (await manager.getCommits(id, count)).content;\n\t\t\t},\n\t\t);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\tlet normalizedWholeSnapshot = await this.snapshotTreeCache.get(\n\t\t\tthis.getCacheKey(requestVersion.id),\n\t\t);\n\t\tif (normalizedWholeSnapshot !== undefined) {\n\t\t\treturn normalizedWholeSnapshot.snapshotTree;\n\t\t}\n\n\t\tnormalizedWholeSnapshot = await this.fetchSnapshotTree(\n\t\t\trequestVersion.id,\n\t\t\tundefined,\n\t\t\t\"getSnapshotTree\",\n\t\t);\n\n\t\t// Currently retrieving blobs from network is not supported by AFR for WholeSummaryDocumentStorageService\n\t\t// Blobs are expected to be put in the cache\n\t\tawait this.updateBlobsCache(normalizedWholeSnapshot.blobs);\n\n\t\treturn normalizedWholeSnapshot.snapshotTree;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));\n\t\tif (cachedBlob !== undefined) {\n\t\t\treturn cachedBlob;\n\t\t}\n\n\t\t// Note: AFR does not support readBlobs, but potentially other r11s like servers do\n\t\tconst blob = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"readBlob\",\n\t\t\t\tblobId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getBlob(blobId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.size,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst bufferValue = stringToBuffer(blob.content, blob.encoding);\n\n\t\tawait this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);\n\n\t\treturn bufferValue;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryHandle = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"uploadSummaryWithContext\",\n\t\t\t\tproposalHandle: context.proposalHandle,\n\t\t\t\tackHandle: context.ackHandle,\n\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryUploadManager = await this.getSummaryUploadManager();\n\t\t\t\treturn summaryUploadManager.writeSummaryTree(\n\t\t\t\t\tsummary,\n\t\t\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\t\t\"channel\",\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t\treturn summaryHandle;\n\t}\n\n\tpublic async downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst wholeFlatSnapshot = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: summaryHandle.handle,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager.getSnapshot(summaryHandle.handle);\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t});\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\n\t\tconst { blobs, snapshotTree } = convertWholeFlatSnapshotToSnapshotTreeAndBlobs(\n\t\t\twholeFlatSnapshot,\n\t\t\t\"\",\n\t\t);\n\t\treturn convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"createBlob\",\n\t\t\t\tsize: uint8ArrayFile.length,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager\n\t\t\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t\t\t.then((r) => ({ id: r.content.sha, url: r.content.url }));\n\t\t\t\tevent.end({\n\t\t\t\t\tblobId: response.id,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async fetchSnapshotTree(\n\t\tversionId: string,\n\t\tdisableCache?: boolean,\n\t\tscenarioName?: string,\n\t): Promise<INormalizedWholeSnapshot> {\n\t\tconst normalizedWholeSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: versionId,\n\t\t\t\tscenarioName,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager(disableCache);\n\t\t\t\tconst response: IR11sResponse<IWholeFlatSnapshot> = await manager.getSnapshot(\n\t\t\t\t\tversionId,\n\t\t\t\t);\n\t\t\t\tconst start = performance.now();\n\t\t\t\tconst snapshot: INormalizedWholeSnapshot =\n\t\t\t\t\tconvertWholeFlatSnapshotToSnapshotTreeAndBlobs(response.content);\n\t\t\t\tconst snapshotConversionTime = performance.now() - start;\n\t\t\t\tvalidateBlobsAndTrees(snapshot.snapshotTree);\n\t\t\t\tconst { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t\ttrees,\n\t\t\t\t\tblobs: numBlobs,\n\t\t\t\t\tencodedBlobsSize,\n\t\t\t\t\tsequenceNumber: snapshot.sequenceNumber,\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\tsnapshotConversionTime,\n\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t});\n\t\t\t\treturn snapshot;\n\t\t\t},\n\t\t);\n\n\t\t// Also add the result into the cache.\n\t\tawait this.snapshotTreeCache\n\t\t\t.put(this.getCacheKey(versionId), normalizedWholeSummary)\n\t\t\t.catch(() => undefined);\n\t\treturn normalizedWholeSummary;\n\t}\n\n\tprivate async initializeFromSnapshot(\n\t\tnormalizedWholeSummary: INormalizedWholeSnapshot,\n\t): Promise<string> {\n\t\tconst snapshotId = normalizedWholeSummary.id;\n\t\tassert(snapshotId !== undefined, 0x275 /* \"Root tree should contain the id\" */);\n\t\tconst cachePs: Promise<any>[] = [\n\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(snapshotId), normalizedWholeSummary),\n\t\t\tthis.updateBlobsCache(normalizedWholeSummary.blobs),\n\t\t];\n\n\t\tawait Promise.all(cachePs);\n\n\t\treturn snapshotId;\n\t}\n\n\tprivate async updateBlobsCache(blobs: Map<string, ArrayBuffer>): Promise<void> {\n\t\tconst blobCachePutPs: Promise<void>[] = [];\n\t\tblobs.forEach((value, id) => {\n\t\t\tconst cacheKey = this.getCacheKey(id);\n\t\t\tblobCachePutPs.push(this.blobCache.put(cacheKey, value));\n\t\t});\n\t\tawait Promise.all(blobCachePutPs);\n\t}\n\n\tprivate getCacheKey(blobId: string): string {\n\t\treturn `${this.id}:${blobId}`;\n\t}\n}\n"]}
|
|
@@ -21,10 +21,9 @@ class WholeSummaryUploadManager {
|
|
|
21
21
|
return id;
|
|
22
22
|
}
|
|
23
23
|
async writeSummaryTreeCore(parentHandle, tree, type, sequenceNumber, initial) {
|
|
24
|
-
var _a;
|
|
25
24
|
const snapshotTree = (0, server_services_client_1.convertSummaryTreeToWholeSummaryTree)(parentHandle, tree, "", type === "channel" ? ".app" : "");
|
|
26
25
|
const snapshotPayload = {
|
|
27
|
-
entries:
|
|
26
|
+
entries: snapshotTree.entries ?? [],
|
|
28
27
|
message: "",
|
|
29
28
|
sequenceNumber,
|
|
30
29
|
type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wholeSummaryUploadManager.js","sourceRoot":"","sources":["../src/wholeSummaryUploadManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mFAKgD;AAGhD;;GAEG;AACH,MAAa,yBAAyB;IACrC,YAA6B,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;IAAG,CAAC;IAE9C,KAAK,CAAC,gBAAgB,CAC5B,WAAyB,EACzB,YAAgC,EAChC,WAAqC,EACrC,iBAAyB,CAAC,EAC1B,UAAmB,KAAK;QAExB,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,oBAAoB,CACzC,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,OAAO,CACP,CAAC;QACF,IAAI,CAAC,EAAE,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SAChD;QACD,OAAO,EAAE,CAAC;IACX,CAAC;IAEO,KAAK,CAAC,oBAAoB,CACjC,YAAgC,EAChC,IAAkB,EAClB,IAA8B,EAC9B,cAAsB,EACtB,OAAgB
|
|
1
|
+
{"version":3,"file":"wholeSummaryUploadManager.js","sourceRoot":"","sources":["../src/wholeSummaryUploadManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mFAKgD;AAGhD;;GAEG;AACH,MAAa,yBAAyB;IACrC,YAA6B,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;IAAG,CAAC;IAE9C,KAAK,CAAC,gBAAgB,CAC5B,WAAyB,EACzB,YAAgC,EAChC,WAAqC,EACrC,iBAAyB,CAAC,EAC1B,UAAmB,KAAK;QAExB,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,oBAAoB,CACzC,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,OAAO,CACP,CAAC;QACF,IAAI,CAAC,EAAE,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SAChD;QACD,OAAO,EAAE,CAAC;IACX,CAAC;IAEO,KAAK,CAAC,oBAAoB,CACjC,YAAgC,EAChC,IAAkB,EAClB,IAA8B,EAC9B,cAAsB,EACtB,OAAgB;QAEhB,MAAM,YAAY,GAAG,IAAA,6DAAoC,EACxD,YAAY,EACZ,IAAI,EACJ,EAAE,EACF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAChC,CAAC;QACF,MAAM,eAAe,GAAyB;YAC7C,OAAO,EAAE,YAAY,CAAC,OAAO,IAAI,EAAE;YACnC,OAAO,EAAE,EAAE;YACX,cAAc;YACd,IAAI;SACJ,CAAC;QAEF,OAAO,IAAI,CAAC,OAAO;aACjB,aAAa,CAAC,eAAe,EAAE,OAAO,CAAC;aACvC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;CACD;AA/CD,8DA+CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tISummaryTree,\n\tIWholeSummaryPayload,\n\tIWholeSummaryPayloadType,\n\tconvertSummaryTreeToWholeSummaryTree,\n} from \"@fluidframework/server-services-client\";\nimport { IGitManager, ISummaryUploadManager } from \"./storageContracts\";\n\n/**\n * Converts summary to snapshot tree and uploads with single snaphot tree payload.\n */\nexport class WholeSummaryUploadManager implements ISummaryUploadManager {\n\tconstructor(private readonly manager: IGitManager) {}\n\n\tpublic async writeSummaryTree(\n\t\tsummaryTree: ISummaryTree,\n\t\tparentHandle: string | undefined,\n\t\tsummaryType: IWholeSummaryPayloadType,\n\t\tsequenceNumber: number = 0,\n\t\tinitial: boolean = false,\n\t): Promise<string> {\n\t\tconst id = await this.writeSummaryTreeCore(\n\t\t\tparentHandle,\n\t\t\tsummaryTree,\n\t\t\tsummaryType,\n\t\t\tsequenceNumber,\n\t\t\tinitial,\n\t\t);\n\t\tif (!id) {\n\t\t\tthrow new Error(`Failed to write summary tree`);\n\t\t}\n\t\treturn id;\n\t}\n\n\tprivate async writeSummaryTreeCore(\n\t\tparentHandle: string | undefined,\n\t\ttree: ISummaryTree,\n\t\ttype: IWholeSummaryPayloadType,\n\t\tsequenceNumber: number,\n\t\tinitial: boolean,\n\t): Promise<string> {\n\t\tconst snapshotTree = convertSummaryTreeToWholeSummaryTree(\n\t\t\tparentHandle,\n\t\t\ttree,\n\t\t\t\"\",\n\t\t\ttype === \"channel\" ? \".app\" : \"\",\n\t\t);\n\t\tconst snapshotPayload: IWholeSummaryPayload = {\n\t\t\tentries: snapshotTree.entries ?? [],\n\t\t\tmessage: \"\",\n\t\t\tsequenceNumber,\n\t\t\ttype,\n\t\t};\n\n\t\treturn this.manager\n\t\t\t.createSummary(snapshotPayload, initial)\n\t\t\t.then((response) => response.content.id);\n\t}\n}\n"]}
|
package/lib/contracts.d.ts
CHANGED
|
@@ -3,10 +3,37 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
6
|
+
export interface IWholeFlatSnapshotTreeEntryTree {
|
|
7
|
+
path: string;
|
|
8
|
+
type: "tree";
|
|
9
|
+
unreferenced?: true;
|
|
10
|
+
}
|
|
11
|
+
export interface IWholeFlatSnapshotTreeEntryBlob {
|
|
12
|
+
id: string;
|
|
13
|
+
path: string;
|
|
14
|
+
type: "blob";
|
|
15
|
+
}
|
|
16
|
+
export declare type IWholeFlatSnapshotTreeEntry = IWholeFlatSnapshotTreeEntryTree | IWholeFlatSnapshotTreeEntryBlob;
|
|
17
|
+
export interface IWholeFlatSnapshotTree {
|
|
18
|
+
entries: IWholeFlatSnapshotTreeEntry[];
|
|
19
|
+
id: string;
|
|
20
|
+
sequenceNumber: number;
|
|
21
|
+
}
|
|
22
|
+
export interface IWholeFlatSnapshotBlob {
|
|
23
|
+
content: string;
|
|
24
|
+
encoding: "base64" | "utf-8";
|
|
25
|
+
id: string;
|
|
26
|
+
size: number;
|
|
27
|
+
}
|
|
28
|
+
export interface IWholeFlatSnapshot {
|
|
29
|
+
id: string;
|
|
30
|
+
trees: IWholeFlatSnapshotTree[];
|
|
31
|
+
blobs?: IWholeFlatSnapshotBlob[];
|
|
32
|
+
}
|
|
6
33
|
/**
|
|
7
34
|
* Normalized Whole Summary with decoded blobs and unflattened snapshot tree.
|
|
8
35
|
*/
|
|
9
|
-
export interface
|
|
36
|
+
export interface INormalizedWholeSnapshot {
|
|
10
37
|
blobs: Map<string, ArrayBuffer>;
|
|
11
38
|
snapshotTree: ISnapshotTree;
|
|
12
39
|
sequenceNumber: number | undefined;
|
package/lib/contracts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAQrE,MAAM,WAAW,+BAA+B;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAEb,YAAY,CAAC,EAAE,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,+BAA+B;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AAED,oBAAY,2BAA2B,GACpC,+BAA+B,GAC/B,+BAA+B,CAAC;AAEnC,MAAM,WAAW,sBAAsB;IACtC,OAAO,EAAE,2BAA2B,EAAE,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,kBAAkB;IAElC,EAAE,EAAE,MAAM,CAAC;IAEX,KAAK,EAAE,sBAAsB,EAAE,CAAC;IAChC,KAAK,CAAC,EAAE,sBAAsB,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAChC,YAAY,EAAE,aAAa,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,EAAE,EAAE,MAAM,CAAC;CACX"}
|
package/lib/contracts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Normalized Whole Summary with decoded blobs and unflattened snapshot tree.\n */\nexport interface
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\n/*\n *\n * Whole Snapshot Download Data Structures\n *\n */\n\nexport interface IWholeFlatSnapshotTreeEntryTree {\n\tpath: string;\n\ttype: \"tree\";\n\t// Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.\n\tunreferenced?: true;\n}\n\nexport interface IWholeFlatSnapshotTreeEntryBlob {\n\tid: string;\n\tpath: string;\n\ttype: \"blob\";\n}\n\nexport type IWholeFlatSnapshotTreeEntry =\n\t| IWholeFlatSnapshotTreeEntryTree\n\t| IWholeFlatSnapshotTreeEntryBlob;\n\nexport interface IWholeFlatSnapshotTree {\n\tentries: IWholeFlatSnapshotTreeEntry[];\n\tid: string;\n\tsequenceNumber: number;\n}\n\nexport interface IWholeFlatSnapshotBlob {\n\tcontent: string;\n\tencoding: \"base64\" | \"utf-8\";\n\tid: string;\n\tsize: number;\n}\n\nexport interface IWholeFlatSnapshot {\n\t// The same as the id of the first snapshot tree in the trees array.\n\tid: string;\n\t// Receive an array of snapshot trees for future-proofing, however, always length 1 for now.\n\ttrees: IWholeFlatSnapshotTree[];\n\tblobs?: IWholeFlatSnapshotBlob[];\n}\n\n/**\n * Normalized Whole Summary with decoded blobs and unflattened snapshot tree.\n */\nexport interface INormalizedWholeSnapshot {\n\tblobs: Map<string, ArrayBuffer>;\n\tsnapshotTree: ISnapshotTree;\n\tsequenceNumber: number | undefined;\n\tid: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltaStorageService.d.ts","sourceRoot":"","sources":["../src/deltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,oBAAoB,EACpB,4BAA4B,EAC5B,kBAAkB,EAClB,OAAO,EACP,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAOjF,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"deltaStorageService.d.ts","sourceRoot":"","sources":["../src/deltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,oBAAoB,EACpB,4BAA4B,EAC5B,kBAAkB,EAClB,OAAO,EACP,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAOjF,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAWhD;;GAEG;AACH,qBAAa,2BAA4B,YAAW,4BAA4B;IAE9E,OAAO,CAAC,QAA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readAndParse, requestOps, emptyMessageStream, streamObserver, } from "@fluidframework/driver-utils";
|
|
7
7
|
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Maximum number of ops we can fetch at a time. This should be kept at 2k, as
|
|
10
|
+
* server determines whether to try to fallback to long-term storage if the ops range requested is larger than
|
|
11
|
+
* what they have locally available in short-term storage. So if we request 2k ops, they know it is not a
|
|
12
|
+
* specific request and they don't fall to long term storage which takes time.
|
|
13
|
+
* Please coordinate to AFR team if this value need to be changed.
|
|
14
|
+
*/
|
|
15
|
+
const MaxBatchDeltas = 2000;
|
|
9
16
|
/**
|
|
10
17
|
* Storage service limited to only being able to fetch documents for a specific document
|
|
11
18
|
*/
|
|
@@ -85,17 +92,21 @@ export class DeltaStorageService {
|
|
|
85
92
|
from,
|
|
86
93
|
to,
|
|
87
94
|
}, async (event) => {
|
|
88
|
-
var _a, _b;
|
|
89
95
|
const restWrapper = await this.getRestWrapper();
|
|
90
96
|
const url = this.getDeltaStorageUrl();
|
|
91
97
|
const response = await restWrapper.get(url, {
|
|
92
98
|
from: from - 1,
|
|
93
99
|
to,
|
|
94
100
|
});
|
|
95
|
-
event.end(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
event.end({
|
|
102
|
+
length: response.content.length,
|
|
103
|
+
details: JSON.stringify({
|
|
104
|
+
firstOpSeqNumber: response.content[0]?.sequenceNumber,
|
|
105
|
+
lastOpSeqNumber: response.content[response.content.length - 1]?.sequenceNumber,
|
|
106
|
+
}),
|
|
107
|
+
...response.propsToLog,
|
|
108
|
+
...getW3CData(response.requestUrl, "xmlhttprequest"),
|
|
109
|
+
});
|
|
99
110
|
return response.content;
|
|
100
111
|
});
|
|
101
112
|
// It is assumed that server always returns all the ops that it has in the range that was requested.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltaStorageService.js","sourceRoot":"","sources":["../src/deltaStorageService.ts"],"names":[],"m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AAE;;YACf,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAChD,MAAM,GAAG,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACtC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAA8B,GAAG,EAAE;gBACxE,IAAI,EAAE,IAAI,GAAG,CAAC;gBACd,EAAE;aACF,CAAC,CAAC;YACH,KAAK,CAAC,GAAG,+BACR,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,EAC/B,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;oBACvB,gBAAgB,EAAE,MAAA,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,0CAAE,cAAc;oBACrD,eAAe,EACd,MAAA,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,cAAc;iBAC9D,CAAC,IACC,QAAQ,CAAC,UAAU,GACnB,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,EACnD,CAAC;YACH,OAAO,QAAQ,CAAC,OAAO,CAAC;QACzB,CAAC,CACD,CAAC;QAEF,oGAAoG;QACpG,4GAA4G;QAC5G,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IAChD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport { getW3CData, validateMessages } from \"@fluidframework/driver-base\";\nimport {\n\tIDeltaStorageService,\n\tIDocumentDeltaStorageService,\n\tIDeltasFetchResult,\n\tIStream,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\treadAndParse,\n\trequestOps,\n\temptyMessageStream,\n\tstreamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { DocumentStorageService } from \"./documentStorageService\";\nimport { RestWrapper } from \"./restWrapperBase\";\n\nconst MaxBatchDeltas = 5000; // Maximum number of ops we can fetch at a time\n\n/**\n * Storage service limited to only being able to fetch documents for a specific document\n */\nexport class DocumentDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly deltaStorageService: IDeltaStorageService,\n\t\tprivate readonly documentStorageService: DocumentStorageService,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tprivate logtailSha: string | undefined = this.documentStorageService.logTailSha;\n\tprivate snapshotOps: ISequencedDocumentMessage[] | undefined;\n\n\tfetchMessages(\n\t\tfromTotal: number,\n\t\ttoTotal: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t\tfetchReason?: string,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\tif (cachedOnly) {\n\t\t\treturn emptyMessageStream;\n\t\t}\n\n\t\tlet opsFromSnapshot = 0;\n\t\tlet opsFromStorage = 0;\n\t\tconst requestCallback = async (\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\ttelemetryProps: ITelemetryProperties,\n\t\t) => {\n\t\t\tthis.snapshotOps = this.logtailSha\n\t\t\t\t? await readAndParse<ISequencedDocumentMessage[]>(\n\t\t\t\t\t\tthis.documentStorageService,\n\t\t\t\t\t\tthis.logtailSha,\n\t\t\t\t )\n\t\t\t\t: [];\n\t\t\tthis.logtailSha = undefined;\n\n\t\t\tif (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n\t\t\t\tconst messages = this.snapshotOps.filter(\n\t\t\t\t\t(op) => op.sequenceNumber >= from && op.sequenceNumber < to,\n\t\t\t\t);\n\t\t\t\tvalidateMessages(\"snapshotOps\", messages, from, this.logger, false /* strict */);\n\t\t\t\tif (messages.length > 0 && messages[0].sequenceNumber === from) {\n\t\t\t\t\tthis.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n\t\t\t\t\topsFromSnapshot += messages.length;\n\t\t\t\t\treturn { messages, partialResult: true };\n\t\t\t\t}\n\t\t\t\tthis.snapshotOps = undefined;\n\t\t\t}\n\n\t\t\tconst ops = await this.deltaStorageService.get(this.tenantId, this.id, from, to);\n\t\t\tvalidateMessages(\"storage\", ops.messages, from, this.logger, false /* strict */);\n\t\t\topsFromStorage += ops.messages.length;\n\t\t\treturn ops;\n\t\t};\n\n\t\tconst stream = requestOps(\n\t\t\tasync (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n\t\t\t\tconst result = await requestCallback(from, to, telemetryProps);\n\t\t\t\t// Catch all case, just in case\n\t\t\t\tvalidateMessages(\"catch all\", result.messages, from, this.logger);\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\t// Staging: starting with no concurrency, listening for feedback first.\n\t\t\t// In future releases we will switch to actual concurrency\n\t\t\t1, // concurrency\n\t\t\tfromTotal, // inclusive\n\t\t\ttoTotal, // exclusive\n\t\t\tMaxBatchDeltas,\n\t\t\tthis.logger,\n\t\t\tabortSignal,\n\t\t\tfetchReason,\n\t\t);\n\n\t\treturn streamObserver(stream, (result) => {\n\t\t\tif (result.done && opsFromSnapshot + opsFromStorage !== 0) {\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"CacheOpsRetrieved\",\n\t\t\t\t\topsFromSnapshot,\n\t\t\t\t\topsFromStorage,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Provides access to the underlying delta storage on the server for routerlicious driver.\n */\nexport class DeltaStorageService implements IDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly url: string,\n\t\tprivate readonly restWrapper: RestWrapper,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly getRestWrapper: () => Promise<RestWrapper> = async () => this.restWrapper,\n\t\tprivate readonly getDeltaStorageUrl: () => string = () => this.url,\n\t) {}\n\n\tpublic async get(\n\t\ttenantId: string,\n\t\tid: string,\n\t\tfrom: number, // inclusive\n\t\tto: number, // exclusive\n\t): Promise<IDeltasFetchResult> {\n\t\tconst ops = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"OpsFetch\",\n\t\t\t\tfrom,\n\t\t\t\tto,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst restWrapper = await this.getRestWrapper();\n\t\t\t\tconst url = this.getDeltaStorageUrl();\n\t\t\t\tconst response = await restWrapper.get<ISequencedDocumentMessage[]>(url, {\n\t\t\t\t\tfrom: from - 1,\n\t\t\t\t\tto,\n\t\t\t\t});\n\t\t\t\tevent.end({\n\t\t\t\t\tlength: response.content.length,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tfirstOpSeqNumber: response.content[0]?.sequenceNumber,\n\t\t\t\t\t\tlastOpSeqNumber:\n\t\t\t\t\t\t\tresponse.content[response.content.length - 1]?.sequenceNumber,\n\t\t\t\t\t}),\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t});\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\n\t\t// It is assumed that server always returns all the ops that it has in the range that was requested.\n\t\t// This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n\t\treturn { messages: ops, partialResult: false };\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"deltaStorageService.js","sourceRoot":"","sources":["../src/deltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAQ3E,OAAO,EACN,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,cAAc,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAuB,gBAAgB,EAAE,MAAM,iCAAi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AAG,CAAC;gBACd,EAAE;aACF,CAAC,CAAC;YACH,KAAK,CAAC,GAAG,CAAC;gBACT,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM;gBAC/B,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;oBACvB,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc;oBACrD,eAAe,EACd,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,cAAc;iBAC9D,CAAC;gBACF,GAAG,QAAQ,CAAC,UAAU;gBACtB,GAAG,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;aACpD,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,OAAO,CAAC;QACzB,CAAC,CACD,CAAC;QAEF,oGAAoG;QACpG,4GAA4G;QAC5G,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IAChD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport { getW3CData, validateMessages } from \"@fluidframework/driver-base\";\nimport {\n\tIDeltaStorageService,\n\tIDocumentDeltaStorageService,\n\tIDeltasFetchResult,\n\tIStream,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\treadAndParse,\n\trequestOps,\n\temptyMessageStream,\n\tstreamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { DocumentStorageService } from \"./documentStorageService\";\nimport { RestWrapper } from \"./restWrapperBase\";\n\n/**\n * Maximum number of ops we can fetch at a time. This should be kept at 2k, as\n * server determines whether to try to fallback to long-term storage if the ops range requested is larger than\n * what they have locally available in short-term storage. So if we request 2k ops, they know it is not a\n * specific request and they don't fall to long term storage which takes time.\n * Please coordinate to AFR team if this value need to be changed.\n */\nconst MaxBatchDeltas = 2000;\n\n/**\n * Storage service limited to only being able to fetch documents for a specific document\n */\nexport class DocumentDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly deltaStorageService: IDeltaStorageService,\n\t\tprivate readonly documentStorageService: DocumentStorageService,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tprivate logtailSha: string | undefined = this.documentStorageService.logTailSha;\n\tprivate snapshotOps: ISequencedDocumentMessage[] | undefined;\n\n\tfetchMessages(\n\t\tfromTotal: number,\n\t\ttoTotal: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t\tfetchReason?: string,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\tif (cachedOnly) {\n\t\t\treturn emptyMessageStream;\n\t\t}\n\n\t\tlet opsFromSnapshot = 0;\n\t\tlet opsFromStorage = 0;\n\t\tconst requestCallback = async (\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\ttelemetryProps: ITelemetryProperties,\n\t\t) => {\n\t\t\tthis.snapshotOps = this.logtailSha\n\t\t\t\t? await readAndParse<ISequencedDocumentMessage[]>(\n\t\t\t\t\t\tthis.documentStorageService,\n\t\t\t\t\t\tthis.logtailSha,\n\t\t\t\t )\n\t\t\t\t: [];\n\t\t\tthis.logtailSha = undefined;\n\n\t\t\tif (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n\t\t\t\tconst messages = this.snapshotOps.filter(\n\t\t\t\t\t(op) => op.sequenceNumber >= from && op.sequenceNumber < to,\n\t\t\t\t);\n\t\t\t\tvalidateMessages(\"snapshotOps\", messages, from, this.logger, false /* strict */);\n\t\t\t\tif (messages.length > 0 && messages[0].sequenceNumber === from) {\n\t\t\t\t\tthis.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n\t\t\t\t\topsFromSnapshot += messages.length;\n\t\t\t\t\treturn { messages, partialResult: true };\n\t\t\t\t}\n\t\t\t\tthis.snapshotOps = undefined;\n\t\t\t}\n\n\t\t\tconst ops = await this.deltaStorageService.get(this.tenantId, this.id, from, to);\n\t\t\tvalidateMessages(\"storage\", ops.messages, from, this.logger, false /* strict */);\n\t\t\topsFromStorage += ops.messages.length;\n\t\t\treturn ops;\n\t\t};\n\n\t\tconst stream = requestOps(\n\t\t\tasync (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n\t\t\t\tconst result = await requestCallback(from, to, telemetryProps);\n\t\t\t\t// Catch all case, just in case\n\t\t\t\tvalidateMessages(\"catch all\", result.messages, from, this.logger);\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\t// Staging: starting with no concurrency, listening for feedback first.\n\t\t\t// In future releases we will switch to actual concurrency\n\t\t\t1, // concurrency\n\t\t\tfromTotal, // inclusive\n\t\t\ttoTotal, // exclusive\n\t\t\tMaxBatchDeltas,\n\t\t\tthis.logger,\n\t\t\tabortSignal,\n\t\t\tfetchReason,\n\t\t);\n\n\t\treturn streamObserver(stream, (result) => {\n\t\t\tif (result.done && opsFromSnapshot + opsFromStorage !== 0) {\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"CacheOpsRetrieved\",\n\t\t\t\t\topsFromSnapshot,\n\t\t\t\t\topsFromStorage,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Provides access to the underlying delta storage on the server for routerlicious driver.\n */\nexport class DeltaStorageService implements IDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly url: string,\n\t\tprivate readonly restWrapper: RestWrapper,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly getRestWrapper: () => Promise<RestWrapper> = async () => this.restWrapper,\n\t\tprivate readonly getDeltaStorageUrl: () => string = () => this.url,\n\t) {}\n\n\tpublic async get(\n\t\ttenantId: string,\n\t\tid: string,\n\t\tfrom: number, // inclusive\n\t\tto: number, // exclusive\n\t): Promise<IDeltasFetchResult> {\n\t\tconst ops = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"OpsFetch\",\n\t\t\t\tfrom,\n\t\t\t\tto,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst restWrapper = await this.getRestWrapper();\n\t\t\t\tconst url = this.getDeltaStorageUrl();\n\t\t\t\tconst response = await restWrapper.get<ISequencedDocumentMessage[]>(url, {\n\t\t\t\t\tfrom: from - 1,\n\t\t\t\t\tto,\n\t\t\t\t});\n\t\t\t\tevent.end({\n\t\t\t\t\tlength: response.content.length,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tfirstOpSeqNumber: response.content[0]?.sequenceNumber,\n\t\t\t\t\t\tlastOpSeqNumber:\n\t\t\t\t\t\t\tresponse.content[response.content.length - 1]?.sequenceNumber,\n\t\t\t\t\t}),\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t});\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\n\t\t// It is assumed that server always returns all the ops that it has in the range that was requested.\n\t\t// This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n\t\treturn { messages: ops, partialResult: false };\n\t}\n}\n"]}
|
|
@@ -41,7 +41,7 @@ export class R11sDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
|
41
41
|
// Note: we suspect the incoming error object is either:
|
|
42
42
|
// - a socketError: add it to the R11sError object for driver to be able to parse it and reason over it.
|
|
43
43
|
// - anything else: let base class handle it
|
|
44
|
-
return canRetry && Number.isInteger(error
|
|
44
|
+
return canRetry && Number.isInteger(error?.code) && typeof error?.message === "string"
|
|
45
45
|
? errorObjectFromSocketError(error, handler)
|
|
46
46
|
: super.createErrorObject(handler, error, canRetry);
|
|
47
47
|
}
|