@fluidframework/routerlicious-driver 2.3.0-288113 → 2.4.0-294316
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 +4 -0
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +3 -1
- package/dist/createNewUtils.js.map +1 -1
- package/dist/deltaStorageService.js +1 -1
- package/dist/deltaStorageService.js.map +1 -1
- package/dist/documentService.d.ts +6 -11
- package/dist/documentService.d.ts.map +1 -1
- package/dist/documentService.js +16 -61
- package/dist/documentService.js.map +1 -1
- package/dist/documentServiceFactory.d.ts +1 -0
- package/dist/documentServiceFactory.d.ts.map +1 -1
- package/dist/documentServiceFactory.js +33 -42
- package/dist/documentServiceFactory.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.map +1 -1
- package/dist/r11sSnapshotParser.js +2 -4
- package/dist/r11sSnapshotParser.js.map +1 -1
- package/dist/sessionInfoManager.d.ts +55 -0
- package/dist/sessionInfoManager.d.ts.map +1 -0
- package/dist/sessionInfoManager.js +100 -0
- package/dist/sessionInfoManager.js.map +1 -0
- package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/shreddedSummaryDocumentStorageService.js +3 -4
- package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/dist/summaryTreeUploadManager.d.ts.map +1 -1
- package/dist/summaryTreeUploadManager.js +3 -3
- package/dist/summaryTreeUploadManager.js.map +1 -1
- package/dist/urlUtils.d.ts.map +1 -1
- package/dist/urlUtils.js +0 -2
- package/dist/urlUtils.js.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.js +3 -4
- package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
- package/lib/createNewUtils.d.ts.map +1 -1
- package/lib/createNewUtils.js +3 -1
- package/lib/createNewUtils.js.map +1 -1
- package/lib/deltaStorageService.js +1 -1
- package/lib/deltaStorageService.js.map +1 -1
- package/lib/documentService.d.ts +6 -11
- package/lib/documentService.d.ts.map +1 -1
- package/lib/documentService.js +16 -61
- package/lib/documentService.js.map +1 -1
- package/lib/documentServiceFactory.d.ts +1 -0
- package/lib/documentServiceFactory.d.ts.map +1 -1
- package/lib/documentServiceFactory.js +19 -28
- package/lib/documentServiceFactory.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.map +1 -1
- package/lib/r11sSnapshotParser.js +2 -4
- package/lib/r11sSnapshotParser.js.map +1 -1
- package/lib/sessionInfoManager.d.ts +55 -0
- package/lib/sessionInfoManager.d.ts.map +1 -0
- package/lib/sessionInfoManager.js +96 -0
- package/lib/sessionInfoManager.js.map +1 -0
- package/lib/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/shreddedSummaryDocumentStorageService.js +3 -4
- package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/lib/summaryTreeUploadManager.d.ts.map +1 -1
- package/lib/summaryTreeUploadManager.js +3 -3
- package/lib/summaryTreeUploadManager.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/urlUtils.d.ts.map +1 -1
- package/lib/urlUtils.js +0 -2
- package/lib/urlUtils.js.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.js +3 -4
- package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
- package/package.json +17 -16
- package/src/createNewUtils.ts +4 -1
- package/src/deltaStorageService.ts +1 -1
- package/src/documentService.ts +19 -75
- package/src/documentServiceFactory.ts +25 -38
- package/src/packageVersion.ts +1 -1
- package/src/r11sSnapshotParser.ts +3 -5
- package/src/sessionInfoManager.ts +148 -0
- package/src/shreddedSummaryDocumentStorageService.ts +3 -4
- package/src/summaryTreeUploadManager.ts +4 -4
- package/src/urlUtils.ts +2 -4
- package/src/wholeSummaryDocumentStorageService.ts +3 -4
- package/tsconfig.json +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryTreeUploadManager.js","sourceRoot":"","sources":["../src/summaryTreeUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAA+B,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAG9F,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAK/E;;GAEG;AACH,MAAM,OAAO,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,EACpB,WAAqC,EACrC,cAAuB,EACvB,OAAiB;QAEjB,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;QAC9E,OAAO,IAAI,CAAC,oBAAoB,CAAC,WAAW,EAAE,oBAAoB,IAAI,SAAS,CAAC,CAAC;IAClF,CAAC;IAEO,KAAK,CAAC,oBAAoB,CACjC,WAAyB,EACzB,oBAAiD;QAEjD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAChC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"summaryTreeUploadManager.js","sourceRoot":"","sources":["../src/summaryTreeUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAA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,EACvB,IAAc;IACd,4DAA4D;IAC5D,gBAAiC;QAEjC,MAAM,CAAC,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,CAAC;YACvB,QAAQ,UAAU,EAAE,CAAC;gBACpB,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;oBACvB,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAC1C,MAAM,CACL,CAAC,CAAC,KAAK,EACP,KAAK,CAAC,oEAAoE,CAC1E,CAAC;oBACF,OAAO,KAAK,CAAC;gBACd,CAAC;gBACD,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;oBACvB,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;oBAC9C,MAAM,CACL,CAAC,CAAC,KAAK,EACP,KAAK,CAAC,oEAAoE,CAC1E,CAAC;oBACF,OAAO,KAAK,CAAC;gBACd,CAAC;gBACD;oBACC,MAAM,KAAK,CAAC,2CAA2C,UAAU,IAAI,CAAC,CAAC;YACzE,CAAC;QACF,CAAC;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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer, Uint8ArrayToString, gitHashFile } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryTree, SummaryObject, SummaryType } from \"@fluidframework/driver-definitions\";\nimport type { IGitCreateTreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport { ISnapshotTreeEx } from \"@fluidframework/driver-definitions/internal\";\nimport { getGitMode, getGitType } from \"@fluidframework/driver-utils/internal\";\nimport { IWholeSummaryPayloadType } from \"@fluidframework/server-services-client\";\n\nimport { IGitManager, ISummaryUploadManager } from \"./storageContracts.js\";\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: IGitCreateTreeEntry = {\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/lib/tsdoc-metadata.json
CHANGED
package/lib/urlUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,YAAa,MAAM,cAAc,MAAM,KAAG,MACf,CAAC;AAEhE,eAAO,MAAM,6BAA6B,gBAC5B,YAAY,WAChB,QAAQ,KACf,
|
|
1
|
+
{"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,YAAa,MAAM,cAAc,MAAM,KAAG,MACf,CAAC;AAEhE,eAAO,MAAM,6BAA6B,gBAC5B,YAAY,WAChB,QAAQ,KACf,YAuBF,CAAC"}
|
package/lib/urlUtils.js
CHANGED
|
@@ -11,11 +11,9 @@
|
|
|
11
11
|
export const replaceDocumentIdInPath = (urlPath, documentId) => urlPath.split("/").slice(0, -1).concat([documentId]).join("/");
|
|
12
12
|
export const getDiscoveredFluidResolvedUrl = (resolvedUrl, session) => {
|
|
13
13
|
const discoveredOrdererUrl = new URL(session.ordererUrl);
|
|
14
|
-
// TODO why are we non null asserting here?
|
|
15
14
|
const deltaStorageUrl = new URL(resolvedUrl.endpoints.deltaStorageUrl);
|
|
16
15
|
deltaStorageUrl.host = discoveredOrdererUrl.host;
|
|
17
16
|
const discoveredStorageUrl = new URL(session.historianUrl);
|
|
18
|
-
// TODO why are we non null asserting here?
|
|
19
17
|
const storageUrl = new URL(resolvedUrl.endpoints.storageUrl);
|
|
20
18
|
storageUrl.host = discoveredStorageUrl.host;
|
|
21
19
|
const parsedUrl = new URL(resolvedUrl.url);
|
package/lib/urlUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlUtils.js","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;;G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C,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC;IAE5C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,qBAAqB,GAAiB;QAC3C,SAAS,EAAE;YACV,eAAe,EAAE,eAAe,CAAC,QAAQ,EAAE;YAC3C,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;SACjC;QACD,EAAE,EAAE,WAAW,CAAC,EAAE;QAClB,MAAM,EAAE,WAAW,CAAC,MAAM;QAC1B,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,GAAG,EAAE,IAAI,GAAG,CAAC,WAAW,oBAAoB,CAAC,IAAI,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE;KACpF,CAAC;IACF,OAAO,qBAAqB,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions/internal\";\nimport { ISession } from \"@fluidframework/server-services-client\";\n\n/**\n * Assume documentId is at end of url path.\n * This is true for Routerlicious' and Tinylicious' documentUrl and deltaStorageUrl.\n * Routerlicious and Tinylicious do not use documentId in storageUrl nor ordererUrl.\n * TODO: Ideally we would be able to regenerate the resolvedUrl, rather than patching the current one.\n */\nexport const replaceDocumentIdInPath = (urlPath: string, documentId: string): string =>\n\turlPath.split(\"/\").slice(0, -1).concat([documentId]).join(\"/\");\n\nexport const getDiscoveredFluidResolvedUrl = (\n\tresolvedUrl: IResolvedUrl,\n\tsession: ISession,\n): IResolvedUrl => {\n\tconst discoveredOrdererUrl = new URL(session.ordererUrl);\n\tconst deltaStorageUrl = new URL(resolvedUrl.endpoints.deltaStorageUrl);\n\tdeltaStorageUrl.host = discoveredOrdererUrl.host;\n\n\tconst discoveredStorageUrl = new URL(session.historianUrl);\n\tconst storageUrl = new URL(resolvedUrl.endpoints.storageUrl);\n\tstorageUrl.host = discoveredStorageUrl.host;\n\n\tconst parsedUrl = new URL(resolvedUrl.url);\n\tconst discoveredResolvedUrl: IResolvedUrl = {\n\t\tendpoints: {\n\t\t\tdeltaStorageUrl: deltaStorageUrl.toString(),\n\t\t\tordererUrl: session.ordererUrl,\n\t\t\tdeltaStreamUrl: session.deltaStreamUrl,\n\t\t\tstorageUrl: storageUrl.toString(),\n\t\t},\n\t\tid: resolvedUrl.id,\n\t\ttokens: resolvedUrl.tokens,\n\t\ttype: resolvedUrl.type,\n\t\turl: new URL(`https://${discoveredOrdererUrl.host}${parsedUrl.pathname}`).toString(),\n\t};\n\treturn discoveredResolvedUrl;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wholeSummaryDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EACN,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,mBAAmB,EAInB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,MAAM,EAAiB,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAsB,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAa7D,qBAAa,kCAAmC,YAAW,uBAAuB;IAUhF,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM;IAC7B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU;IACtC,SAAS,CAAC,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Q,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IA+BlE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA+BlD,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAqBL,eAAe,CAAC,aAAa,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAwBrE,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAqB9D,iBAAiB;YA4CjB,sBAAsB;YAetB,gBAAgB;IAS9B,OAAO,CAAC,WAAW;CAGnB"}
|
|
@@ -109,13 +109,12 @@ export class WholeSummaryDocumentStorageService {
|
|
|
109
109
|
// eslint-disable-next-line @rushstack/no-new-null
|
|
110
110
|
async getSnapshotTree(version) {
|
|
111
111
|
let requestVersion = version;
|
|
112
|
-
if (requestVersion
|
|
112
|
+
if (!requestVersion) {
|
|
113
113
|
const versions = await this.getVersions(this.id, 1);
|
|
114
|
-
|
|
115
|
-
if (firstVersion === undefined) {
|
|
114
|
+
if (versions.length === 0) {
|
|
116
115
|
return null;
|
|
117
116
|
}
|
|
118
|
-
requestVersion =
|
|
117
|
+
requestVersion = versions[0];
|
|
119
118
|
}
|
|
120
119
|
let normalizedWholeSnapshot = await this.snapshotTreeCache.get(this.getCacheKey(requestVersion.id));
|
|
121
120
|
if (normalizedWholeSnapshot !== undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,qBAAqB,E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B,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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, performance, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { getW3CData, promiseRaceWithWinner } from \"@fluidframework/driver-base/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ICache, InMemoryCache } from \"./cache.js\";\nimport { INormalizedWholeSnapshot, IWholeFlatSnapshot } from \"./contracts.js\";\nimport { GitManager } from \"./gitManager.js\";\nimport { IRouterliciousDriverPolicies } from \"./policies.js\";\nimport { convertWholeFlatSnapshotToSnapshotTreeAndBlobs } from \"./r11sSnapshotParser.js\";\nimport { IR11sResponse } from \"./restWrapper.js\";\nimport { ISummaryUploadManager } from \"./storageContracts.js\";\nimport {\n\tconvertSnapshotAndBlobsToSummaryTree,\n\tevalBlobsAndTrees,\n\tvalidateBlobsAndTrees,\n} from \"./treeUtils.js\";\nimport { WholeSummaryUploadManager } from \"./wholeSummaryUploadManager.js\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate readonly mc: MonitoringContext;\n\tprivate firstVersionsCall: boolean = true;\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\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger,\n\t\t});\n\t}\n\n\t// eslint-disable-next-line @rushstack/no-new-null\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\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tlet requestVersion = version;\n\t\tif (requestVersion === undefined) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tconst firstVersion = versions[0];\n\t\t\tif (firstVersion === undefined) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = firstVersion;\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\tundefined, // workers\n\t\t\tthis.mc.config.getNumber(\"Fluid.Driver.ReadBlobTelemetrySampling\"),\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> =\n\t\t\t\t\tawait manager.getSnapshot(versionId);\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"]}
|
|
1
|
+
{"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAUzF,OAAO,EAGN,gBAAgB,EAChB,4BAA4B,GAC5B,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAU,aAAa,EAAE,MAAM,YAAY,CAAC;AAInD,OAAO,EAAE,8CAA8C,EAAE,MAAM,yBAAyB,CAAC;AAGzF,OAAO,EACN,oCAAoC,EACpC,iBAAiB,EACjB,qBAAqB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,MAAM,gBAAgB,GAAW,QAAQ,CAAC;AAE1C,MAAM,OAAO,kCAAkC;IAItC,KAAK,CAAC,uBAAuB;QACpC,MAAM,OAAO,GA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,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, performance, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { getW3CData, promiseRaceWithWinner } from \"@fluidframework/driver-base/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ICache, InMemoryCache } from \"./cache.js\";\nimport { INormalizedWholeSnapshot, IWholeFlatSnapshot } from \"./contracts.js\";\nimport { GitManager } from \"./gitManager.js\";\nimport { IRouterliciousDriverPolicies } from \"./policies.js\";\nimport { convertWholeFlatSnapshotToSnapshotTreeAndBlobs } from \"./r11sSnapshotParser.js\";\nimport { IR11sResponse } from \"./restWrapper.js\";\nimport { ISummaryUploadManager } from \"./storageContracts.js\";\nimport {\n\tconvertSnapshotAndBlobsToSummaryTree,\n\tevalBlobsAndTrees,\n\tvalidateBlobsAndTrees,\n} from \"./treeUtils.js\";\nimport { WholeSummaryUploadManager } from \"./wholeSummaryUploadManager.js\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate readonly mc: MonitoringContext;\n\tprivate firstVersionsCall: boolean = true;\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\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger,\n\t\t});\n\t}\n\n\t// eslint-disable-next-line @rushstack/no-new-null\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\t// eslint-disable-next-line @rushstack/no-new-null\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\tundefined, // workers\n\t\t\tthis.mc.config.getNumber(\"Fluid.Driver.ReadBlobTelemetrySampling\"),\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> =\n\t\t\t\t\tawait manager.getSnapshot(versionId);\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/routerlicious-driver",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-294316",
|
|
4
4
|
"description": "Socket.IO + Git implementation of Fluid service API",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -67,14 +67,14 @@
|
|
|
67
67
|
"temp-directory": "nyc/.nyc_output"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@fluid-internal/client-utils": "2.
|
|
71
|
-
"@fluidframework/core-interfaces": "2.
|
|
72
|
-
"@fluidframework/core-utils": "2.
|
|
73
|
-
"@fluidframework/driver-base": "2.
|
|
74
|
-
"@fluidframework/driver-definitions": "2.
|
|
75
|
-
"@fluidframework/driver-utils": "2.
|
|
70
|
+
"@fluid-internal/client-utils": "2.4.0-294316",
|
|
71
|
+
"@fluidframework/core-interfaces": "2.4.0-294316",
|
|
72
|
+
"@fluidframework/core-utils": "2.4.0-294316",
|
|
73
|
+
"@fluidframework/driver-base": "2.4.0-294316",
|
|
74
|
+
"@fluidframework/driver-definitions": "2.4.0-294316",
|
|
75
|
+
"@fluidframework/driver-utils": "2.4.0-294316",
|
|
76
76
|
"@fluidframework/server-services-client": "^5.0.0",
|
|
77
|
-
"@fluidframework/telemetry-utils": "2.
|
|
77
|
+
"@fluidframework/telemetry-utils": "2.4.0-294316",
|
|
78
78
|
"cross-fetch": "^3.1.5",
|
|
79
79
|
"json-stringify-safe": "5.0.1",
|
|
80
80
|
"socket.io-client": "^4.7.3",
|
|
@@ -83,19 +83,19 @@
|
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
85
85
|
"@biomejs/biome": "~1.8.3",
|
|
86
|
-
"@fluid-internal/mocha-test-setup": "2.
|
|
87
|
-
"@fluid-tools/build-cli": "^0.
|
|
86
|
+
"@fluid-internal/mocha-test-setup": "2.4.0-294316",
|
|
87
|
+
"@fluid-tools/build-cli": "^0.46.0",
|
|
88
88
|
"@fluidframework/build-common": "^2.0.3",
|
|
89
|
-
"@fluidframework/build-tools": "^0.
|
|
90
|
-
"@fluidframework/eslint-config-fluid": "^5.
|
|
91
|
-
"@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@2.
|
|
92
|
-
"@microsoft/api-extractor": "
|
|
89
|
+
"@fluidframework/build-tools": "^0.46.0",
|
|
90
|
+
"@fluidframework/eslint-config-fluid": "^5.4.0",
|
|
91
|
+
"@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@2.3.0",
|
|
92
|
+
"@microsoft/api-extractor": "7.47.8",
|
|
93
93
|
"@types/mocha": "^9.1.1",
|
|
94
94
|
"@types/nock": "^9.3.0",
|
|
95
95
|
"@types/node": "^18.19.0",
|
|
96
96
|
"@types/sinon": "^17.0.3",
|
|
97
97
|
"@types/uuid": "^9.0.2",
|
|
98
|
-
"axios": "^1.
|
|
98
|
+
"axios": "^1.7.7",
|
|
99
99
|
"c8": "^8.0.1",
|
|
100
100
|
"concurrently": "^8.2.1",
|
|
101
101
|
"copyfiles": "^2.4.1",
|
|
@@ -112,7 +112,8 @@
|
|
|
112
112
|
"typescript": "~5.4.5"
|
|
113
113
|
},
|
|
114
114
|
"typeValidation": {
|
|
115
|
-
"broken": {}
|
|
115
|
+
"broken": {},
|
|
116
|
+
"entrypoint": "internal"
|
|
116
117
|
},
|
|
117
118
|
"scripts": {
|
|
118
119
|
"api": "fluid-build . --task api",
|
package/src/createNewUtils.ts
CHANGED
|
@@ -12,7 +12,10 @@ import { ISummaryTree, SummaryType } from "@fluidframework/driver-definitions";
|
|
|
12
12
|
* @returns Modified summary tree where the blob contents could be utf8 string only.
|
|
13
13
|
*/
|
|
14
14
|
export function convertSummaryToCreateNewSummary(summary: ISummaryTree): ISummaryTree {
|
|
15
|
-
|
|
15
|
+
const keys = Object.keys(summary.tree);
|
|
16
|
+
for (const key of keys) {
|
|
17
|
+
const summaryObject = summary.tree[key];
|
|
18
|
+
|
|
16
19
|
switch (summaryObject.type) {
|
|
17
20
|
case SummaryType.Tree: {
|
|
18
21
|
summary.tree[key] = convertSummaryToCreateNewSummary(summaryObject);
|
|
@@ -83,7 +83,7 @@ export class DocumentDeltaStorageService implements IDocumentDeltaStorageService
|
|
|
83
83
|
(op) => op.sequenceNumber >= from && op.sequenceNumber < to,
|
|
84
84
|
);
|
|
85
85
|
validateMessages("snapshotOps", messages, from, this.logger, false /* strict */);
|
|
86
|
-
if (messages.length > 0 && messages[0]
|
|
86
|
+
if (messages.length > 0 && messages[0].sequenceNumber === from) {
|
|
87
87
|
this.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);
|
|
88
88
|
opsFromSnapshot += messages.length;
|
|
89
89
|
return { messages, partialResult: true };
|
package/src/documentService.ts
CHANGED
|
@@ -46,16 +46,9 @@ import {
|
|
|
46
46
|
TokenFetcher,
|
|
47
47
|
} from "./restWrapper.js";
|
|
48
48
|
import { RestWrapper } from "./restWrapperBase.js";
|
|
49
|
+
import type { IGetSessionInfoResponse } from "./sessionInfoManager.js";
|
|
49
50
|
import { ITokenProvider } from "./tokens.js";
|
|
50
51
|
|
|
51
|
-
/**
|
|
52
|
-
* Amount of time between discoveries within which we don't need to rediscover on re-connect.
|
|
53
|
-
* Currently, R11s defines session length at 10 minutes. To avoid any weird unknown edge-cases though,
|
|
54
|
-
* we set the limit to 5 minutes here.
|
|
55
|
-
* In the future, we likely want to retrieve this information from service's "inactive session" definition.
|
|
56
|
-
*/
|
|
57
|
-
const RediscoverAfterTimeSinceDiscoveryMs = 5 * 60000; // 5 minute
|
|
58
|
-
|
|
59
52
|
/**
|
|
60
53
|
* The DocumentService manages the Socket.IO connection and manages routing requests to connected
|
|
61
54
|
* clients.
|
|
@@ -65,9 +58,6 @@ export class DocumentService
|
|
|
65
58
|
// eslint-disable-next-line import/namespace
|
|
66
59
|
implements IDocumentService
|
|
67
60
|
{
|
|
68
|
-
private lastDiscoveredAt: number = Date.now();
|
|
69
|
-
private discoverP: Promise<void> | undefined;
|
|
70
|
-
|
|
71
61
|
private storageManager: GitManager | undefined;
|
|
72
62
|
private noCacheStorageManager: GitManager | undefined;
|
|
73
63
|
|
|
@@ -93,7 +83,7 @@ export class DocumentService
|
|
|
93
83
|
private readonly blobCache: ICache<ArrayBufferLike>,
|
|
94
84
|
private readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot>,
|
|
95
85
|
private readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion>,
|
|
96
|
-
private readonly
|
|
86
|
+
private readonly getSessionInfo: () => Promise<IGetSessionInfoResponse>,
|
|
97
87
|
private storageRestWrapper: RouterliciousStorageRestWrapper,
|
|
98
88
|
private readonly storageTokenFetcher: TokenFetcher,
|
|
99
89
|
private readonly ordererTokenFetcher: TokenFetcher,
|
|
@@ -124,16 +114,9 @@ export class DocumentService
|
|
|
124
114
|
}
|
|
125
115
|
|
|
126
116
|
const getStorageManager = async (disableCache?: boolean): Promise<GitManager> => {
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
if (
|
|
132
|
-
!this.storageManager ||
|
|
133
|
-
!this.noCacheStorageManager ||
|
|
134
|
-
shouldUpdateDiscoveredSessionInfo
|
|
135
|
-
) {
|
|
136
|
-
if (shouldUpdateDiscoveredSessionInfo) {
|
|
117
|
+
const refreshed = await this.refreshSessionInfoIfNeeded();
|
|
118
|
+
if (!this.storageManager || !this.noCacheStorageManager || refreshed) {
|
|
119
|
+
if (refreshed) {
|
|
137
120
|
const rateLimiter = new RateLimiter(
|
|
138
121
|
this.driverPolicies.maxConcurrentStorageRequests,
|
|
139
122
|
);
|
|
@@ -182,10 +165,9 @@ export class DocumentService
|
|
|
182
165
|
assert(!!this.documentStorageService, 0x0b1 /* "Storage service not initialized" */);
|
|
183
166
|
|
|
184
167
|
const getRestWrapper = async (): Promise<RestWrapper> => {
|
|
185
|
-
const
|
|
168
|
+
const refreshed = await this.refreshSessionInfoIfNeeded();
|
|
186
169
|
|
|
187
|
-
if (
|
|
188
|
-
await this.refreshDiscovery();
|
|
170
|
+
if (refreshed) {
|
|
189
171
|
const rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);
|
|
190
172
|
this.ordererRestWrapper = RouterliciousOrdererRestWrapper.load(
|
|
191
173
|
this.ordererTokenFetcher,
|
|
@@ -221,9 +203,7 @@ export class DocumentService
|
|
|
221
203
|
public async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {
|
|
222
204
|
const connect = async (refreshToken?: boolean) => {
|
|
223
205
|
let ordererToken = await this.ordererRestWrapper.getToken();
|
|
224
|
-
|
|
225
|
-
await this.refreshDiscovery();
|
|
226
|
-
}
|
|
206
|
+
await this.refreshSessionInfoIfNeeded();
|
|
227
207
|
|
|
228
208
|
if (refreshToken) {
|
|
229
209
|
ordererToken = await PerformanceEvent.timedExecAsync(
|
|
@@ -309,56 +289,20 @@ export class DocumentService
|
|
|
309
289
|
}
|
|
310
290
|
|
|
311
291
|
/**
|
|
312
|
-
*
|
|
292
|
+
* Refresh session info URLs if necessary.
|
|
293
|
+
* @returns boolean - true if session info was refreshed
|
|
313
294
|
*/
|
|
314
|
-
private async
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
{
|
|
319
|
-
eventName: "RefreshDiscovery",
|
|
320
|
-
},
|
|
321
|
-
async () => this.refreshDiscoveryCore(),
|
|
322
|
-
);
|
|
295
|
+
private async refreshSessionInfoIfNeeded(): Promise<boolean> {
|
|
296
|
+
const response = await this.getSessionInfo();
|
|
297
|
+
if (!response.refreshed) {
|
|
298
|
+
return false;
|
|
323
299
|
}
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
private async refreshDiscoveryCore(): Promise<void> {
|
|
328
|
-
const fluidResolvedUrl = await this.discoverFluidResolvedUrl();
|
|
300
|
+
const fluidResolvedUrl = response.resolvedUrl;
|
|
329
301
|
this._resolvedUrl = fluidResolvedUrl;
|
|
330
|
-
|
|
331
|
-
this.
|
|
332
|
-
|
|
333
|
-
this.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl!;
|
|
334
|
-
// TODO why are we non null asserting here?
|
|
335
|
-
this.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl!;
|
|
302
|
+
this.storageUrl = fluidResolvedUrl.endpoints.storageUrl;
|
|
303
|
+
this.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;
|
|
304
|
+
this.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;
|
|
336
305
|
this.deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl ?? this.ordererUrl;
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Whether enough time has passed since last disconnect to warrant a new discovery call on reconnect.
|
|
341
|
-
*/
|
|
342
|
-
private shouldUpdateDiscoveredSessionInfo(): boolean {
|
|
343
|
-
if (!this.driverPolicies.enableDiscovery) {
|
|
344
|
-
return false;
|
|
345
|
-
}
|
|
346
|
-
const now = Date.now();
|
|
347
|
-
// When connection is disconnected, we cannot know if session has moved or document has been deleted
|
|
348
|
-
// without re-doing discovery on the next attempt to connect.
|
|
349
|
-
// Disconnect event is not so reliable in local testing. To ensure re-discovery when necessary,
|
|
350
|
-
// re-discover if enough time has passed since last discovery.
|
|
351
|
-
const pastLastDiscoveryTimeThreshold =
|
|
352
|
-
now - this.lastDiscoveredAt > RediscoverAfterTimeSinceDiscoveryMs;
|
|
353
|
-
if (pastLastDiscoveryTimeThreshold) {
|
|
354
|
-
// Reset discover promise and refresh discovery.
|
|
355
|
-
this.lastDiscoveredAt = Date.now();
|
|
356
|
-
this.discoverP = undefined;
|
|
357
|
-
this.refreshDiscovery().catch(() => {
|
|
358
|
-
// Undo discovery time set on failure, so that next check refreshes.
|
|
359
|
-
this.lastDiscoveredAt = 0;
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
return pastLastDiscoveryTimeThreshold;
|
|
306
|
+
return true;
|
|
363
307
|
}
|
|
364
308
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
|
-
import { getW3CData } from "@fluidframework/driver-base/internal";
|
|
9
8
|
import { ISummaryTree } from "@fluidframework/driver-definitions";
|
|
10
9
|
import {
|
|
11
10
|
FiveDaysMs,
|
|
@@ -40,8 +39,9 @@ import {
|
|
|
40
39
|
toInstrumentedR11sStorageTokenFetcher,
|
|
41
40
|
} from "./restWrapper.js";
|
|
42
41
|
import { isRouterliciousResolvedUrl } from "./routerliciousResolvedUrl.js";
|
|
42
|
+
import { SessionInfoManager } from "./sessionInfoManager.js";
|
|
43
43
|
import { ITokenProvider } from "./tokens.js";
|
|
44
|
-
import {
|
|
44
|
+
import { replaceDocumentIdInPath } from "./urlUtils.js";
|
|
45
45
|
|
|
46
46
|
const maximumSnapshotCacheDurationMs: FiveDaysMs = 432_000_000; // 5 days in ms
|
|
47
47
|
|
|
@@ -66,6 +66,7 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
66
66
|
private readonly blobCache: ICache<ArrayBufferLike>;
|
|
67
67
|
private readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot> = new NullCache();
|
|
68
68
|
private readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion> = new NullCache();
|
|
69
|
+
private readonly sessionInfoManager: SessionInfoManager;
|
|
69
70
|
|
|
70
71
|
constructor(
|
|
71
72
|
private readonly tokenProvider: ITokenProvider,
|
|
@@ -90,6 +91,7 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
90
91
|
);
|
|
91
92
|
}
|
|
92
93
|
}
|
|
94
|
+
this.sessionInfoManager = new SessionInfoManager(this.driverPolicies.enableDiscovery);
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
/**
|
|
@@ -113,7 +115,6 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
113
115
|
throw new Error("Parsed url should contain tenant and doc Id!!");
|
|
114
116
|
}
|
|
115
117
|
const [, tenantId] = parsedUrl.pathname.split("/");
|
|
116
|
-
assert(tenantId !== undefined, 0x9ac /* "Missing tenant ID!" */);
|
|
117
118
|
|
|
118
119
|
if (!isCombinedAppAndProtocolSummary(createNewSummary)) {
|
|
119
120
|
throw new Error("Protocol and App Summary required in the full summary");
|
|
@@ -291,42 +292,21 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
291
292
|
ordererTokenP,
|
|
292
293
|
);
|
|
293
294
|
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
},
|
|
305
|
-
async (event) => {
|
|
306
|
-
// The service responds with the current document session associated with the container.
|
|
307
|
-
const response = await ordererRestWrapper.get<ISession>(
|
|
308
|
-
`${resolvedUrl.endpoints.ordererUrl}/documents/${tenantId}/session/${documentId}`,
|
|
309
|
-
);
|
|
310
|
-
event.end({
|
|
311
|
-
...response.propsToLog,
|
|
312
|
-
...getW3CData(response.requestUrl, "xmlhttprequest"),
|
|
313
|
-
});
|
|
314
|
-
return response.content;
|
|
315
|
-
},
|
|
316
|
-
);
|
|
317
|
-
return getDiscoveredFluidResolvedUrl(resolvedUrl, discoveredSession);
|
|
318
|
-
};
|
|
319
|
-
const fluidResolvedUrl: IResolvedUrl =
|
|
320
|
-
session !== undefined
|
|
321
|
-
? getDiscoveredFluidResolvedUrl(resolvedUrl, session)
|
|
322
|
-
: await discoverFluidResolvedUrl();
|
|
295
|
+
const fluidResolvedUrl: IResolvedUrl = await this.sessionInfoManager.initializeSessionInfo(
|
|
296
|
+
{
|
|
297
|
+
session,
|
|
298
|
+
resolvedUrl,
|
|
299
|
+
documentId,
|
|
300
|
+
tenantId,
|
|
301
|
+
ordererRestWrapper,
|
|
302
|
+
logger: logger2,
|
|
303
|
+
},
|
|
304
|
+
);
|
|
323
305
|
|
|
324
|
-
|
|
325
|
-
const
|
|
326
|
-
// TODO why are we non null asserting here?
|
|
327
|
-
const ordererUrl = fluidResolvedUrl.endpoints.ordererUrl!;
|
|
306
|
+
const storageUrl = fluidResolvedUrl.endpoints.storageUrl;
|
|
307
|
+
const ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;
|
|
328
308
|
const deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;
|
|
329
|
-
const deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl
|
|
309
|
+
const deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || ordererUrl; // backward compatibility
|
|
330
310
|
if (!ordererUrl || !deltaStorageUrl) {
|
|
331
311
|
throw new Error(
|
|
332
312
|
`All endpoints urls must be provided. [ordererUrl:${ordererUrl}][deltaStorageUrl:${deltaStorageUrl}]`,
|
|
@@ -366,7 +346,14 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
366
346
|
this.blobCache,
|
|
367
347
|
this.wholeSnapshotTreeCache,
|
|
368
348
|
this.shreddedSummaryTreeCache,
|
|
369
|
-
|
|
349
|
+
async () =>
|
|
350
|
+
this.sessionInfoManager.getSessionInfo({
|
|
351
|
+
resolvedUrl,
|
|
352
|
+
documentId,
|
|
353
|
+
tenantId,
|
|
354
|
+
ordererRestWrapper,
|
|
355
|
+
logger: logger2,
|
|
356
|
+
}),
|
|
370
357
|
storageRestWrapper,
|
|
371
358
|
storageTokenFetcher,
|
|
372
359
|
ordererTokenFetcher,
|
package/src/packageVersion.ts
CHANGED
|
@@ -36,8 +36,7 @@ function buildHierarchy(
|
|
|
36
36
|
const entryPathBase = entryPath.slice(lastIndex + 1);
|
|
37
37
|
|
|
38
38
|
// The flat output is breadth-first so we can assume we see tree nodes prior to their contents
|
|
39
|
-
|
|
40
|
-
const node = lookup[entryPathDir]!;
|
|
39
|
+
const node = lookup[entryPathDir];
|
|
41
40
|
|
|
42
41
|
// Add in either the blob or tree
|
|
43
42
|
if (entry.type === "tree") {
|
|
@@ -76,9 +75,8 @@ export function convertWholeFlatSnapshotToSnapshotTreeAndBlobs(
|
|
|
76
75
|
blobs.set(blob.id, stringToBuffer(blob.content, blob.encoding ?? "utf-8"));
|
|
77
76
|
});
|
|
78
77
|
}
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
const sequenceNumber = flatSnapshotTree.sequenceNumber;
|
|
78
|
+
const flatSnapshotTree = flatSnapshot.trees?.[0];
|
|
79
|
+
const sequenceNumber = flatSnapshotTree?.sequenceNumber;
|
|
82
80
|
const snapshotTree = buildHierarchy(flatSnapshotTree, treePrefixToRemove);
|
|
83
81
|
|
|
84
82
|
return {
|