@fluidframework/routerlicious-driver 2.1.0-276985 → 2.1.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 +4 -0
- package/README.md +93 -2
- package/api-extractor/{api-extractor-lint-beta.cjs.json → api-extractor.current.json} +2 -2
- package/api-extractor/api-extractor.legacy.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/routerlicious-driver.legacy.public.api.md +22 -0
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +1 -3
- 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.map +1 -1
- package/dist/documentService.js +5 -2
- package/dist/documentService.js.map +1 -1
- package/dist/documentServiceFactory.d.ts.map +1 -1
- package/dist/documentServiceFactory.js +6 -3
- package/dist/documentServiceFactory.js.map +1 -1
- package/dist/historian.d.ts.map +1 -1
- package/dist/historian.js.map +1 -1
- package/dist/legacy.d.ts +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +1 -1
- package/dist/queryStringUtils.d.ts +12 -0
- package/dist/queryStringUtils.d.ts.map +1 -0
- package/dist/queryStringUtils.js +25 -0
- package/dist/queryStringUtils.js.map +1 -0
- package/dist/r11sSnapshotParser.d.ts.map +1 -1
- package/dist/r11sSnapshotParser.js +4 -2
- package/dist/r11sSnapshotParser.js.map +1 -1
- package/dist/restWrapper.d.ts +9 -2
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/restWrapper.js +44 -13
- package/dist/restWrapper.js.map +1 -1
- package/dist/restWrapperBase.d.ts +27 -7
- package/dist/restWrapperBase.d.ts.map +1 -1
- package/dist/restWrapperBase.js +35 -27
- package/dist/restWrapperBase.js.map +1 -1
- package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/shreddedSummaryDocumentStorageService.js +4 -3
- 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 +2 -0
- package/dist/urlUtils.js.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.js +4 -3
- package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
- package/internal.d.ts +1 -1
- package/legacy.d.ts +1 -1
- package/lib/createNewUtils.d.ts.map +1 -1
- package/lib/createNewUtils.js +1 -3
- 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.map +1 -1
- package/lib/documentService.js +5 -2
- package/lib/documentService.js.map +1 -1
- package/lib/documentServiceFactory.d.ts.map +1 -1
- package/lib/documentServiceFactory.js +6 -3
- package/lib/documentServiceFactory.js.map +1 -1
- package/lib/historian.d.ts.map +1 -1
- package/lib/historian.js.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/lib/queryStringUtils.d.ts +12 -0
- package/lib/queryStringUtils.d.ts.map +1 -0
- package/lib/queryStringUtils.js +21 -0
- package/lib/queryStringUtils.js.map +1 -0
- package/lib/r11sSnapshotParser.d.ts.map +1 -1
- package/lib/r11sSnapshotParser.js +4 -2
- package/lib/r11sSnapshotParser.js.map +1 -1
- package/lib/restWrapper.d.ts +9 -2
- package/lib/restWrapper.d.ts.map +1 -1
- package/lib/restWrapper.js +44 -12
- package/lib/restWrapper.js.map +1 -1
- package/lib/restWrapperBase.d.ts +27 -7
- package/lib/restWrapperBase.d.ts.map +1 -1
- package/lib/restWrapperBase.js +34 -25
- package/lib/restWrapperBase.js.map +1 -1
- package/lib/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/shreddedSummaryDocumentStorageService.js +4 -3
- 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/urlUtils.d.ts.map +1 -1
- package/lib/urlUtils.js +2 -0
- package/lib/urlUtils.js.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.js +4 -3
- package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
- package/package.json +23 -33
- package/src/createNewUtils.ts +1 -4
- package/src/deltaStorageService.ts +1 -1
- package/src/documentService.ts +8 -5
- package/src/documentServiceFactory.ts +8 -5
- package/src/historian.ts +2 -1
- package/src/packageVersion.ts +1 -1
- package/src/queryStringUtils.ts +23 -0
- package/src/r11sSnapshotParser.ts +5 -3
- package/src/restWrapper.ts +78 -35
- package/src/restWrapperBase.ts +35 -32
- package/src/shreddedSummaryDocumentStorageService.ts +4 -3
- package/src/summaryTreeUploadManager.ts +4 -4
- package/src/urlUtils.ts +4 -2
- package/src/wholeSummaryDocumentStorageService.ts +4 -3
- package/tsconfig.json +0 -1
- package/api-extractor/api-extractor-lint-beta.esm.json +0 -5
- package/beta.d.ts +0 -11
- package/dist/beta.d.ts +0 -15
- package/lib/beta.d.ts +0 -15
|
@@ -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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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,2CAA2C;QAC3C,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAE,CAAC,CAAC;IACxF,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.entries(summaryTree.tree).map(async ([key, entry]) => {\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\tconst key = path[0];\n\t\tassert(path.length > 0 && key !== undefined, 0x0b3 /* \"Expected at least 1 path part\" */);\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\t// TODO why are we non null asserting here?\n\t\treturn this.getIdFromPathCore(handleType, path.slice(1), previousSnapshot.trees[key]!);\n\t}\n}\n"]}
|
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,YAyBF,CAAC"}
|
package/lib/urlUtils.js
CHANGED
|
@@ -11,9 +11,11 @@
|
|
|
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?
|
|
14
15
|
const deltaStorageUrl = new URL(resolvedUrl.endpoints.deltaStorageUrl);
|
|
15
16
|
deltaStorageUrl.host = discoveredOrdererUrl.host;
|
|
16
17
|
const discoveredStorageUrl = new URL(session.historianUrl);
|
|
18
|
+
// TODO why are we non null asserting here?
|
|
17
19
|
const storageUrl = new URL(resolvedUrl.endpoints.storageUrl);
|
|
18
20
|
storageUrl.host = discoveredStorageUrl.host;
|
|
19
21
|
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;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAe,EAAE,UAAkB,EAAU,EAAE,CACtF,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC5C,WAAyB,EACzB,OAAiB,EACF,EAAE;IACjB,MAAM,oBAAoB,GAAG,IAAI,GA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AAC,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\t// TODO why are we non null asserting here?\n\tconst deltaStorageUrl = new URL(resolvedUrl.endpoints.deltaStorageUrl!);\n\tdeltaStorageUrl.host = discoveredOrdererUrl.host;\n\n\tconst discoveredStorageUrl = new URL(session.historianUrl);\n\t// TODO why are we non null asserting here?\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,QAAQ,CAAC,MAAM,EAAE,mBAAmB;aAC9B,QAAQ,EAAE,+BAA+B;IACzD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB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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,12 +109,13 @@ 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 (
|
|
112
|
+
if (requestVersion === undefined) {
|
|
113
113
|
const versions = await this.getVersions(this.id, 1);
|
|
114
|
-
|
|
114
|
+
const firstVersion = versions[0];
|
|
115
|
+
if (firstVersion === undefined) {
|
|
115
116
|
return null;
|
|
116
117
|
}
|
|
117
|
-
requestVersion =
|
|
118
|
+
requestVersion = firstVersion;
|
|
118
119
|
}
|
|
119
120
|
let normalizedWholeSnapshot = await this.snapshotTreeCache.get(this.getCacheKey(requestVersion.id));
|
|
120
121
|
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,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,E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AAC,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) {\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"]}
|
|
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,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC/C,OAAO,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,YACoB,EAAU,EACV,OAAmB,EACnB,MAA2B,EAC9B,QAAyC,EACxC,cAA6C,EAC7C,YAAqC,IAAI,aAAa,EAAE,EACxD,oBAAsD,IAAI,aAAa,EAAE,EACzE,iBAA8B,EAC9B,oBAEU,KAAK,EAAE,Y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CAAC;IAC/B,CAAC;IAEO,KAAK,CAAC,sBAAsB,CACnC,sBAAgD;QAEhD,MAAM,UAAU,GAAG,sBAAsB,CAAC,EAAE,CAAC;QAC7C,MAAM,CAAC,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","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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/routerlicious-driver",
|
|
3
|
-
"version": "2.1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Socket.IO + Git implementation of Fluid service API",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -23,16 +23,6 @@
|
|
|
23
23
|
"default": "./dist/index.js"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
-
"./beta": {
|
|
27
|
-
"import": {
|
|
28
|
-
"types": "./lib/beta.d.ts",
|
|
29
|
-
"default": "./lib/index.js"
|
|
30
|
-
},
|
|
31
|
-
"require": {
|
|
32
|
-
"types": "./dist/beta.d.ts",
|
|
33
|
-
"default": "./dist/index.js"
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
26
|
"./legacy": {
|
|
37
27
|
"import": {
|
|
38
28
|
"types": "./lib/legacy.d.ts",
|
|
@@ -77,14 +67,14 @@
|
|
|
77
67
|
"temp-directory": "nyc/.nyc_output"
|
|
78
68
|
},
|
|
79
69
|
"dependencies": {
|
|
80
|
-
"@fluid-internal/client-utils": "2.1.0
|
|
81
|
-
"@fluidframework/core-interfaces": "2.1.0
|
|
82
|
-
"@fluidframework/core-utils": "2.1.0
|
|
83
|
-
"@fluidframework/driver-base": "2.1.0
|
|
84
|
-
"@fluidframework/driver-definitions": "2.1.0
|
|
85
|
-
"@fluidframework/driver-utils": "2.1.0
|
|
70
|
+
"@fluid-internal/client-utils": "~2.1.0",
|
|
71
|
+
"@fluidframework/core-interfaces": "~2.1.0",
|
|
72
|
+
"@fluidframework/core-utils": "~2.1.0",
|
|
73
|
+
"@fluidframework/driver-base": "~2.1.0",
|
|
74
|
+
"@fluidframework/driver-definitions": "~2.1.0",
|
|
75
|
+
"@fluidframework/driver-utils": "~2.1.0",
|
|
86
76
|
"@fluidframework/server-services-client": "^5.0.0",
|
|
87
|
-
"@fluidframework/telemetry-utils": "2.1.0
|
|
77
|
+
"@fluidframework/telemetry-utils": "~2.1.0",
|
|
88
78
|
"cross-fetch": "^3.1.5",
|
|
89
79
|
"json-stringify-safe": "5.0.1",
|
|
90
80
|
"socket.io-client": "^4.7.3",
|
|
@@ -92,13 +82,13 @@
|
|
|
92
82
|
},
|
|
93
83
|
"devDependencies": {
|
|
94
84
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
95
|
-
"@biomejs/biome": "
|
|
96
|
-
"@fluid-internal/mocha-test-setup": "2.1.0
|
|
97
|
-
"@fluid-tools/build-cli": "^0.
|
|
85
|
+
"@biomejs/biome": "~1.8.3",
|
|
86
|
+
"@fluid-internal/mocha-test-setup": "~2.1.0",
|
|
87
|
+
"@fluid-tools/build-cli": "^0.41.0",
|
|
98
88
|
"@fluidframework/build-common": "^2.0.3",
|
|
99
|
-
"@fluidframework/build-tools": "^0.
|
|
89
|
+
"@fluidframework/build-tools": "^0.41.0",
|
|
100
90
|
"@fluidframework/eslint-config-fluid": "^5.3.0",
|
|
101
|
-
"@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@2.0.0
|
|
91
|
+
"@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@2.0.0",
|
|
102
92
|
"@microsoft/api-extractor": "^7.45.1",
|
|
103
93
|
"@types/mocha": "^9.1.1",
|
|
104
94
|
"@types/nock": "^9.3.0",
|
|
@@ -129,36 +119,36 @@
|
|
|
129
119
|
"api-extractor:commonjs": "flub generate entrypoints --outDir ./dist",
|
|
130
120
|
"api-extractor:esnext": "flub generate entrypoints --outDir ./lib --node10TypeCompat",
|
|
131
121
|
"build": "fluid-build . --task build",
|
|
122
|
+
"build:api-reports": "concurrently \"npm:build:api-reports:*\"",
|
|
123
|
+
"build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor.current.json",
|
|
124
|
+
"build:api-reports:legacy": "api-extractor run --local --config api-extractor/api-extractor.legacy.json",
|
|
132
125
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
133
126
|
"build:compile": "fluid-build . --task compile",
|
|
134
|
-
"build:docs": "
|
|
135
|
-
"build:docs:current": "api-extractor run --local",
|
|
136
|
-
"build:docs:legacy": "api-extractor run --local --config api-extractor/api-extractor.legacy.json",
|
|
127
|
+
"build:docs": "api-extractor run --local",
|
|
137
128
|
"build:esnext": "tsc --project ./tsconfig.json",
|
|
138
129
|
"build:genver": "gen-version",
|
|
139
130
|
"build:test": "npm run build:test:esm && npm run build:test:cjs",
|
|
140
131
|
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
|
|
141
132
|
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
|
|
142
133
|
"check:are-the-types-wrong": "attw --pack .",
|
|
143
|
-
"check:biome": "biome check .
|
|
134
|
+
"check:biome": "biome check .",
|
|
144
135
|
"check:exports": "concurrently \"npm:check:exports:*\"",
|
|
145
136
|
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
|
|
146
|
-
"check:exports:cjs:beta": "api-extractor run --config api-extractor/api-extractor-lint-beta.cjs.json",
|
|
147
137
|
"check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
|
|
148
138
|
"check:exports:cjs:public": "api-extractor run --config api-extractor/api-extractor-lint-public.cjs.json",
|
|
149
|
-
"check:exports:esm:beta": "api-extractor run --config api-extractor/api-extractor-lint-beta.esm.json",
|
|
150
139
|
"check:exports:esm:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.esm.json",
|
|
151
140
|
"check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
|
|
152
141
|
"check:format": "npm run check:biome",
|
|
153
142
|
"check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
154
|
-
"ci:build:
|
|
155
|
-
"ci:build:
|
|
156
|
-
"ci:build:
|
|
143
|
+
"ci:build:api-reports": "concurrently \"npm:ci:build:api-reports:*\"",
|
|
144
|
+
"ci:build:api-reports:current": "api-extractor run --config api-extractor/api-extractor.current.json",
|
|
145
|
+
"ci:build:api-reports:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
|
|
146
|
+
"ci:build:docs": "api-extractor run",
|
|
157
147
|
"clean": "rimraf --glob dist lib \"*.d.ts\" \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
158
148
|
"eslint": "eslint --format stylish src",
|
|
159
149
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
160
150
|
"format": "npm run format:biome",
|
|
161
|
-
"format:biome": "biome check . --
|
|
151
|
+
"format:biome": "biome check . --write",
|
|
162
152
|
"format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
163
153
|
"lint": "fluid-build . --task lint",
|
|
164
154
|
"lint:fix": "fluid-build . --task eslint:fix --task format",
|
package/src/createNewUtils.ts
CHANGED
|
@@ -12,10 +12,7 @@ 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
|
-
const
|
|
16
|
-
for (const key of keys) {
|
|
17
|
-
const summaryObject = summary.tree[key];
|
|
18
|
-
|
|
15
|
+
for (const [key, summaryObject] of Object.entries(summary.tree)) {
|
|
19
16
|
switch (summaryObject.type) {
|
|
20
17
|
case SummaryType.Tree: {
|
|
21
18
|
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].sequenceNumber === from) {
|
|
86
|
+
if (messages.length > 0 && messages[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
|
@@ -143,7 +143,7 @@ export class DocumentService
|
|
|
143
143
|
this.logger,
|
|
144
144
|
rateLimiter,
|
|
145
145
|
this.driverPolicies.enableRestLess,
|
|
146
|
-
this.storageUrl
|
|
146
|
+
this.storageUrl /* baseUrl */,
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
149
|
const historian = new Historian(true, false, this.storageRestWrapper);
|
|
@@ -327,10 +327,13 @@ export class DocumentService
|
|
|
327
327
|
private async refreshDiscoveryCore(): Promise<void> {
|
|
328
328
|
const fluidResolvedUrl = await this.discoverFluidResolvedUrl();
|
|
329
329
|
this._resolvedUrl = fluidResolvedUrl;
|
|
330
|
-
|
|
331
|
-
this.
|
|
332
|
-
|
|
333
|
-
this.
|
|
330
|
+
// TODO why are we non null asserting here?
|
|
331
|
+
this.storageUrl = fluidResolvedUrl.endpoints.storageUrl!;
|
|
332
|
+
// TODO why are we non null asserting here?
|
|
333
|
+
this.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl!;
|
|
334
|
+
// TODO why are we non null asserting here?
|
|
335
|
+
this.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl!;
|
|
336
|
+
this.deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl ?? this.ordererUrl;
|
|
334
337
|
}
|
|
335
338
|
|
|
336
339
|
/**
|
|
@@ -113,6 +113,7 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
113
113
|
throw new Error("Parsed url should contain tenant and doc Id!!");
|
|
114
114
|
}
|
|
115
115
|
const [, tenantId] = parsedUrl.pathname.split("/");
|
|
116
|
+
assert(tenantId !== undefined, 0x9ac /* "Missing tenant ID!" */);
|
|
116
117
|
|
|
117
118
|
if (!isCombinedAppAndProtocolSummary(createNewSummary)) {
|
|
118
119
|
throw new Error("Protocol and App Summary required in the full summary");
|
|
@@ -136,7 +137,7 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
136
137
|
logger2,
|
|
137
138
|
rateLimiter,
|
|
138
139
|
this.driverPolicies.enableRestLess,
|
|
139
|
-
resolvedUrl.endpoints.ordererUrl
|
|
140
|
+
resolvedUrl.endpoints.ordererUrl /* baseUrl */,
|
|
140
141
|
);
|
|
141
142
|
|
|
142
143
|
const createAsEphemeral = isRouterliciousResolvedUrl(resolvedUrl)
|
|
@@ -320,10 +321,12 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
320
321
|
? getDiscoveredFluidResolvedUrl(resolvedUrl, session)
|
|
321
322
|
: await discoverFluidResolvedUrl();
|
|
322
323
|
|
|
323
|
-
|
|
324
|
-
const
|
|
324
|
+
// TODO why are we non null asserting here?
|
|
325
|
+
const storageUrl = fluidResolvedUrl.endpoints.storageUrl!;
|
|
326
|
+
// TODO why are we non null asserting here?
|
|
327
|
+
const ordererUrl = fluidResolvedUrl.endpoints.ordererUrl!;
|
|
325
328
|
const deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;
|
|
326
|
-
const deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl
|
|
329
|
+
const deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl ?? ordererUrl; // backward compatibility
|
|
327
330
|
if (!ordererUrl || !deltaStorageUrl) {
|
|
328
331
|
throw new Error(
|
|
329
332
|
`All endpoints urls must be provided. [ordererUrl:${ordererUrl}][deltaStorageUrl:${deltaStorageUrl}]`,
|
|
@@ -336,7 +339,7 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
336
339
|
logger2,
|
|
337
340
|
new RateLimiter(this.driverPolicies.maxConcurrentStorageRequests),
|
|
338
341
|
this.driverPolicies.enableRestLess,
|
|
339
|
-
storageUrl
|
|
342
|
+
storageUrl /* baseUrl */,
|
|
340
343
|
storageTokenP,
|
|
341
344
|
);
|
|
342
345
|
|
package/src/historian.ts
CHANGED
|
@@ -18,8 +18,9 @@ import {
|
|
|
18
18
|
} from "@fluidframework/server-services-client";
|
|
19
19
|
|
|
20
20
|
import { IWholeFlatSnapshot } from "./contracts.js";
|
|
21
|
+
import { type QueryStringType } from "./queryStringUtils.js";
|
|
21
22
|
import { IR11sResponse } from "./restWrapper.js";
|
|
22
|
-
import {
|
|
23
|
+
import { RestWrapper } from "./restWrapperBase.js";
|
|
23
24
|
import { IHistorian } from "./storageContracts.js";
|
|
24
25
|
|
|
25
26
|
export interface ICredentials {
|
package/src/packageVersion.ts
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type QueryStringType = Record<string, string | number | boolean>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Generates URL object from the given string request url and query parameters.
|
|
10
|
+
* @param url - URL to which query params should be appended. Can include base/default query params.
|
|
11
|
+
* @param queryParams - Query parameters to append. Will override any query params in url.
|
|
12
|
+
*/
|
|
13
|
+
export function addOrUpdateQueryParams(url: URL | string, queryParams: QueryStringType): URL {
|
|
14
|
+
// Initialize urlSearchParams with query params from the base URL itself
|
|
15
|
+
const outputUrl = new URL(url);
|
|
16
|
+
const updatedSearchParams = outputUrl.searchParams;
|
|
17
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
18
|
+
// Add/override search params from query params
|
|
19
|
+
updatedSearchParams.set(key, encodeURIComponent(value));
|
|
20
|
+
}
|
|
21
|
+
outputUrl.search = updatedSearchParams.toString();
|
|
22
|
+
return outputUrl;
|
|
23
|
+
}
|
|
@@ -36,7 +36,8 @@ 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
|
-
|
|
39
|
+
// TODO why are we non null asserting here?
|
|
40
|
+
const node = lookup[entryPathDir]!;
|
|
40
41
|
|
|
41
42
|
// Add in either the blob or tree
|
|
42
43
|
if (entry.type === "tree") {
|
|
@@ -75,8 +76,9 @@ export function convertWholeFlatSnapshotToSnapshotTreeAndBlobs(
|
|
|
75
76
|
blobs.set(blob.id, stringToBuffer(blob.content, blob.encoding ?? "utf-8"));
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
-
const
|
|
79
|
+
// TODO why are we non null asserting here?
|
|
80
|
+
const flatSnapshotTree = flatSnapshot.trees[0]!;
|
|
81
|
+
const sequenceNumber = flatSnapshotTree.sequenceNumber;
|
|
80
82
|
const snapshotTree = buildHierarchy(flatSnapshotTree, treePrefixToRemove);
|
|
81
83
|
|
|
82
84
|
return {
|