@fluidframework/routerlicious-driver 2.0.0-internal.5.3.2 → 2.0.0-internal.6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/contracts.d.ts +28 -1
  3. package/dist/contracts.d.ts.map +1 -1
  4. package/dist/contracts.js.map +1 -1
  5. package/dist/deltaStorageService.d.ts.map +1 -1
  6. package/dist/deltaStorageService.js +17 -6
  7. package/dist/deltaStorageService.js.map +1 -1
  8. package/dist/documentDeltaConnection.js +1 -1
  9. package/dist/documentDeltaConnection.js.map +1 -1
  10. package/dist/documentService.d.ts +3 -3
  11. package/dist/documentService.d.ts.map +1 -1
  12. package/dist/documentService.js +1 -1
  13. package/dist/documentService.js.map +1 -1
  14. package/dist/documentServiceFactory.d.ts.map +1 -1
  15. package/dist/documentServiceFactory.js +27 -8
  16. package/dist/documentServiceFactory.js.map +1 -1
  17. package/dist/documentStorageService.d.ts +2 -2
  18. package/dist/documentStorageService.d.ts.map +1 -1
  19. package/dist/documentStorageService.js +2 -2
  20. package/dist/documentStorageService.js.map +1 -1
  21. package/dist/errorUtils.d.ts +5 -6
  22. package/dist/errorUtils.d.ts.map +1 -1
  23. package/dist/errorUtils.js +13 -15
  24. package/dist/errorUtils.js.map +1 -1
  25. package/dist/gitManager.d.ts +3 -2
  26. package/dist/gitManager.d.ts.map +1 -1
  27. package/dist/gitManager.js +2 -2
  28. package/dist/gitManager.js.map +1 -1
  29. package/dist/historian.d.ts +3 -2
  30. package/dist/historian.d.ts.map +1 -1
  31. package/dist/historian.js +10 -3
  32. package/dist/historian.js.map +1 -1
  33. package/dist/packageVersion.d.ts +1 -1
  34. package/dist/packageVersion.js +1 -1
  35. package/dist/packageVersion.js.map +1 -1
  36. package/dist/r11sSnapshotParser.d.ts +4 -5
  37. package/dist/r11sSnapshotParser.d.ts.map +1 -1
  38. package/dist/r11sSnapshotParser.js +12 -14
  39. package/dist/r11sSnapshotParser.js.map +1 -1
  40. package/dist/restWrapper.d.ts.map +1 -1
  41. package/dist/restWrapper.js +40 -24
  42. package/dist/restWrapper.js.map +1 -1
  43. package/dist/restWrapperBase.js +39 -5
  44. package/dist/restWrapperBase.js.map +1 -1
  45. package/dist/retriableGitManager.d.ts +3 -2
  46. package/dist/retriableGitManager.d.ts.map +1 -1
  47. package/dist/retriableGitManager.js +2 -2
  48. package/dist/retriableGitManager.js.map +1 -1
  49. package/dist/shreddedSummaryDocumentStorageService.js +10 -13
  50. package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
  51. package/dist/storageContracts.d.ts +4 -3
  52. package/dist/storageContracts.d.ts.map +1 -1
  53. package/dist/storageContracts.js.map +1 -1
  54. package/dist/summaryTreeUploadManager.js +2 -3
  55. package/dist/summaryTreeUploadManager.js.map +1 -1
  56. package/dist/treeUtils.d.ts +2 -2
  57. package/dist/treeUtils.d.ts.map +1 -1
  58. package/dist/treeUtils.js +2 -3
  59. package/dist/treeUtils.js.map +1 -1
  60. package/dist/wholeSummaryDocumentStorageService.d.ts +2 -2
  61. package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  62. package/dist/wholeSummaryDocumentStorageService.js +20 -16
  63. package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
  64. package/dist/wholeSummaryUploadManager.js +1 -2
  65. package/dist/wholeSummaryUploadManager.js.map +1 -1
  66. package/lib/contracts.d.ts +28 -1
  67. package/lib/contracts.d.ts.map +1 -1
  68. package/lib/contracts.js.map +1 -1
  69. package/lib/deltaStorageService.d.ts.map +1 -1
  70. package/lib/deltaStorageService.js +17 -6
  71. package/lib/deltaStorageService.js.map +1 -1
  72. package/lib/documentDeltaConnection.js +1 -1
  73. package/lib/documentDeltaConnection.js.map +1 -1
  74. package/lib/documentService.d.ts +3 -3
  75. package/lib/documentService.d.ts.map +1 -1
  76. package/lib/documentService.js +1 -1
  77. package/lib/documentService.js.map +1 -1
  78. package/lib/documentServiceFactory.d.ts.map +1 -1
  79. package/lib/documentServiceFactory.js +28 -9
  80. package/lib/documentServiceFactory.js.map +1 -1
  81. package/lib/documentStorageService.d.ts +2 -2
  82. package/lib/documentStorageService.d.ts.map +1 -1
  83. package/lib/documentStorageService.js +2 -2
  84. package/lib/documentStorageService.js.map +1 -1
  85. package/lib/errorUtils.d.ts +5 -6
  86. package/lib/errorUtils.d.ts.map +1 -1
  87. package/lib/errorUtils.js +13 -15
  88. package/lib/errorUtils.js.map +1 -1
  89. package/lib/gitManager.d.ts +3 -2
  90. package/lib/gitManager.d.ts.map +1 -1
  91. package/lib/gitManager.js +2 -2
  92. package/lib/gitManager.js.map +1 -1
  93. package/lib/historian.d.ts +3 -2
  94. package/lib/historian.d.ts.map +1 -1
  95. package/lib/historian.js +10 -3
  96. package/lib/historian.js.map +1 -1
  97. package/lib/packageVersion.d.ts +1 -1
  98. package/lib/packageVersion.js +1 -1
  99. package/lib/packageVersion.js.map +1 -1
  100. package/lib/r11sSnapshotParser.d.ts +4 -5
  101. package/lib/r11sSnapshotParser.d.ts.map +1 -1
  102. package/lib/r11sSnapshotParser.js +10 -12
  103. package/lib/r11sSnapshotParser.js.map +1 -1
  104. package/lib/restWrapper.d.ts.map +1 -1
  105. package/lib/restWrapper.js +43 -27
  106. package/lib/restWrapper.js.map +1 -1
  107. package/lib/restWrapperBase.js +39 -5
  108. package/lib/restWrapperBase.js.map +1 -1
  109. package/lib/retriableGitManager.d.ts +3 -2
  110. package/lib/retriableGitManager.d.ts.map +1 -1
  111. package/lib/retriableGitManager.js +2 -2
  112. package/lib/retriableGitManager.js.map +1 -1
  113. package/lib/shreddedSummaryDocumentStorageService.js +11 -14
  114. package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
  115. package/lib/storageContracts.d.ts +4 -3
  116. package/lib/storageContracts.d.ts.map +1 -1
  117. package/lib/storageContracts.js.map +1 -1
  118. package/lib/summaryTreeUploadManager.js +2 -3
  119. package/lib/summaryTreeUploadManager.js.map +1 -1
  120. package/lib/treeUtils.d.ts +2 -2
  121. package/lib/treeUtils.d.ts.map +1 -1
  122. package/lib/treeUtils.js +2 -3
  123. package/lib/treeUtils.js.map +1 -1
  124. package/lib/wholeSummaryDocumentStorageService.d.ts +2 -2
  125. package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  126. package/lib/wholeSummaryDocumentStorageService.js +21 -17
  127. package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
  128. package/lib/wholeSummaryUploadManager.js +1 -2
  129. package/lib/wholeSummaryUploadManager.js.map +1 -1
  130. package/package.json +13 -13
  131. package/src/contracts.ts +45 -1
  132. package/src/deltaStorageService.ts +8 -1
  133. package/src/documentService.ts +2 -2
  134. package/src/documentServiceFactory.ts +17 -10
  135. package/src/documentStorageService.ts +3 -3
  136. package/src/errorUtils.ts +23 -30
  137. package/src/gitManager.ts +3 -3
  138. package/src/historian.ts +3 -3
  139. package/src/packageVersion.ts +1 -1
  140. package/src/r11sSnapshotParser.ts +13 -14
  141. package/src/restWrapper.ts +29 -17
  142. package/src/retriableGitManager.ts +3 -3
  143. package/src/shreddedSummaryDocumentStorageService.ts +2 -2
  144. package/src/storageContracts.ts +3 -3
  145. package/src/treeUtils.ts +2 -2
  146. package/src/wholeSummaryDocumentStorageService.ts +12 -13
@@ -1 +1 @@
1
- {"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxF,OAAO,EACN,MAAM,EACN,WAAW,EACX,cAAc,EACd,kBAAkB,GAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAchF,OAAO,EAAU,aAAa,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EACN,oCAAoC,EACpC,iBAAiB,EACjB,qBAAqB,G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,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 { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tassert,\n\tperformance,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"@fluidframework/common-utils\";\nimport { getW3CData, promiseRaceWithWinner } from \"@fluidframework/driver-base\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IWholeFlatSummary } from \"@fluidframework/server-services-client\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport {\n\tconvertSnapshotAndBlobsToSummaryTree,\n\tevalBlobsAndTrees,\n\tvalidateBlobsAndTrees,\n} from \"./treeUtils\";\nimport { GitManager } from \"./gitManager\";\nimport { WholeSummaryUploadManager } from \"./wholeSummaryUploadManager\";\nimport { ISummaryUploadManager } from \"./storageContracts\";\nimport { IR11sResponse } from \"./restWrapper\";\nimport { INormalizedWholeSummary } from \"./contracts\";\nimport { convertWholeFlatSummaryToSnapshotTreeAndBlobs } from \"./r11sSnapshotParser\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate firstVersionsCall: boolean = true;\n\n\tpublic get repositoryUrl(): string {\n\t\treturn \"\";\n\t}\n\n\tprivate async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n\t\tconst manager = await this.getStorageManager();\n\t\treturn new WholeSummaryUploadManager(manager);\n\t}\n\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly manager: GitManager,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies?: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),\n\t\tprivate readonly snapshotTreeCache: ICache<INormalizedWholeSummary> = new InMemoryCache(),\n\t\tprivate readonly noCacheGitManager?: GitManager,\n\t\tprivate readonly getStorageManager: (\n\t\t\tdisableCache?: boolean,\n\t\t) => Promise<GitManager> = async (disableCache) =>\n\t\t\tdisableCache && this.noCacheGitManager !== undefined\n\t\t\t\t? this.noCacheGitManager\n\t\t\t\t: this.manager,\n\t) {}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tif (versionId !== this.id && versionId !== null) {\n\t\t\t// Blobs/Trees in this scenario will never have multiple versions, so return versionId as is\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\t// If this is the first versions call for the document, we know we will want the latest summary.\n\t\t// Fetch latest summary, cache it, and return its id.\n\t\tif (this.firstVersionsCall && count === 1) {\n\t\t\tconst normalizedSnapshotContents = await PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"ObtainSnapshot\",\n\t\t\t\t\tversionId: versionId ?? undefined,\n\t\t\t\t\tcount,\n\t\t\t\t\tenableDiscovery: this.driverPolicies?.enableDiscovery,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tlet method: string;\n\t\t\t\t\tconst cachedSnapshotP = this.snapshotTreeCache.get(\n\t\t\t\t\t\tthis.getCacheKey(latestSnapshotId),\n\t\t\t\t\t);\n\n\t\t\t\t\tconst networkSnapshotP = !this.driverPolicies?.enableDiscovery\n\t\t\t\t\t\t? this.fetchSnapshotTree(latestSnapshotId, false, \"getVersions\")\n\t\t\t\t\t\t: this.fetchSnapshotTree(latestSnapshotId, true, \"getVersions\");\n\n\t\t\t\t\tconst promiseRaceWinner = await promiseRaceWithWinner([\n\t\t\t\t\t\tcachedSnapshotP.catch(() => undefined),\n\t\t\t\t\t\tnetworkSnapshotP.catch(() => undefined),\n\t\t\t\t\t]);\n\n\t\t\t\t\tlet retrievedSnapshot = promiseRaceWinner.value;\n\t\t\t\t\tmethod = promiseRaceWinner.index === 0 ? \"cache\" : \"network\";\n\n\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t// if network failed -> wait for cache ( then return network failure)\n\t\t\t\t\t\t// If cache returned empty or failed -> wait for network (success of failure)\n\t\t\t\t\t\tif (promiseRaceWinner.index === 1) {\n\t\t\t\t\t\t\tretrievedSnapshot = await cachedSnapshotP;\n\t\t\t\t\t\t\tmethod = \"cache\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\tretrievedSnapshot = await networkSnapshotP;\n\t\t\t\t\t\t\tmethod = \"network\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t});\n\t\t\t\t\treturn retrievedSnapshot;\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tconst _id = await this.initializeFromSnapshot(normalizedSnapshotContents);\n\t\t\tthis.firstVersionsCall = false;\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: _id,\n\t\t\t\t\ttreeId: normalizedSnapshotContents.snapshotTree.id!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// Otherwise, get the latest version of the document as normal.\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getVersions\",\n\t\t\t\tversionId: id,\n\t\t\t\tcount,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\treturn (await manager.getCommits(id, count)).content;\n\t\t\t},\n\t\t);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\tlet normalizedWholeSnapshot = await this.snapshotTreeCache.get(\n\t\t\tthis.getCacheKey(requestVersion.id),\n\t\t);\n\t\tif (normalizedWholeSnapshot !== undefined) {\n\t\t\treturn normalizedWholeSnapshot.snapshotTree;\n\t\t}\n\n\t\tnormalizedWholeSnapshot = await this.fetchSnapshotTree(\n\t\t\trequestVersion.id,\n\t\t\tundefined,\n\t\t\t\"getSnapshotTree\",\n\t\t);\n\n\t\t// Currently retrieving blobs from network is not supported by AFR for WholeSummaryDocumentStorageService\n\t\t// Blobs are expected to be put in the cache\n\t\tawait this.updateBlobsCache(normalizedWholeSnapshot.blobs);\n\n\t\treturn normalizedWholeSnapshot.snapshotTree;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));\n\t\tif (cachedBlob !== undefined) {\n\t\t\treturn cachedBlob;\n\t\t}\n\n\t\t// Note: AFR does not support readBlobs, but potentially other r11s like servers do\n\t\tconst blob = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"readBlob\",\n\t\t\t\tblobId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getBlob(blobId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.size,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst bufferValue = stringToBuffer(blob.content, blob.encoding);\n\n\t\tawait this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);\n\n\t\treturn bufferValue;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryHandle = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"uploadSummaryWithContext\",\n\t\t\t\tproposalHandle: context.proposalHandle,\n\t\t\t\tackHandle: context.ackHandle,\n\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryUploadManager = await this.getSummaryUploadManager();\n\t\t\t\treturn summaryUploadManager.writeSummaryTree(\n\t\t\t\t\tsummary,\n\t\t\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\t\t\"channel\",\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t\treturn summaryHandle;\n\t}\n\n\tpublic async downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst wholeFlatSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: summaryHandle.handle,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager.getSummary(summaryHandle.handle);\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t});\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\n\t\tconst { blobs, snapshotTree } = convertWholeFlatSummaryToSnapshotTreeAndBlobs(\n\t\t\twholeFlatSummary,\n\t\t\t\"\",\n\t\t);\n\t\treturn convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"createBlob\",\n\t\t\t\tsize: uint8ArrayFile.length,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager\n\t\t\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t\t\t.then((r) => ({ id: r.content.sha, url: r.content.url }));\n\t\t\t\tevent.end({\n\t\t\t\t\tblobId: response.id,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async fetchSnapshotTree(\n\t\tversionId: string,\n\t\tdisableCache?: boolean,\n\t\tscenarioName?: string,\n\t): Promise<INormalizedWholeSummary> {\n\t\tconst normalizedWholeSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: versionId,\n\t\t\t\tscenarioName,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager(disableCache);\n\t\t\t\tconst response: IR11sResponse<IWholeFlatSummary> = await manager.getSummary(\n\t\t\t\t\tversionId,\n\t\t\t\t);\n\t\t\t\tconst start = performance.now();\n\t\t\t\tconst snapshot: INormalizedWholeSummary =\n\t\t\t\t\tconvertWholeFlatSummaryToSnapshotTreeAndBlobs(response.content);\n\t\t\t\tconst snapshotConversionTime = performance.now() - start;\n\t\t\t\tvalidateBlobsAndTrees(snapshot.snapshotTree);\n\t\t\t\tconst { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t\ttrees,\n\t\t\t\t\tblobs: numBlobs,\n\t\t\t\t\tencodedBlobsSize,\n\t\t\t\t\tsequenceNumber: snapshot.sequenceNumber,\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\tsnapshotConversionTime,\n\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t});\n\t\t\t\treturn snapshot;\n\t\t\t},\n\t\t);\n\n\t\t// Also add the result into the cache.\n\t\tawait this.snapshotTreeCache\n\t\t\t.put(this.getCacheKey(versionId), normalizedWholeSummary)\n\t\t\t.catch(() => undefined);\n\t\treturn normalizedWholeSummary;\n\t}\n\n\tprivate async initializeFromSnapshot(\n\t\tnormalizedWholeSummary: INormalizedWholeSummary,\n\t): Promise<string> {\n\t\tconst snapshotId = normalizedWholeSummary.id;\n\t\tassert(snapshotId !== undefined, 0x275 /* \"Root tree should contain the id\" */);\n\t\tconst cachePs: Promise<any>[] = [\n\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(snapshotId), normalizedWholeSummary),\n\t\t\tthis.updateBlobsCache(normalizedWholeSummary.blobs),\n\t\t];\n\n\t\tawait Promise.all(cachePs);\n\n\t\treturn snapshotId;\n\t}\n\n\tprivate async updateBlobsCache(blobs: Map<string, ArrayBuffer>): Promise<void> {\n\t\tconst blobCachePutPs: Promise<void>[] = [];\n\t\tblobs.forEach((value, id) => {\n\t\t\tconst cacheKey = this.getCacheKey(id);\n\t\t\tblobCachePutPs.push(this.blobCache.put(cacheKey, value));\n\t\t});\n\t\tawait Promise.all(blobCachePutPs);\n\t}\n\n\tprivate getCacheKey(blobId: string): string {\n\t\treturn `${this.id}:${blobId}`;\n\t}\n}\n"]}
1
+ {"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxF,OAAO,EACN,MAAM,EACN,WAAW,EACX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AC,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 { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tassert,\n\tperformance,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"@fluidframework/common-utils\";\nimport { getW3CData, promiseRaceWithWinner } from \"@fluidframework/driver-base\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport {\n\tconvertSnapshotAndBlobsToSummaryTree,\n\tevalBlobsAndTrees,\n\tvalidateBlobsAndTrees,\n} from \"./treeUtils\";\nimport { GitManager } from \"./gitManager\";\nimport { WholeSummaryUploadManager } from \"./wholeSummaryUploadManager\";\nimport { ISummaryUploadManager } from \"./storageContracts\";\nimport { IR11sResponse } from \"./restWrapper\";\nimport { INormalizedWholeSnapshot, IWholeFlatSnapshot } from \"./contracts\";\nimport { convertWholeFlatSnapshotToSnapshotTreeAndBlobs } from \"./r11sSnapshotParser\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate firstVersionsCall: boolean = true;\n\n\tpublic get repositoryUrl(): string {\n\t\treturn \"\";\n\t}\n\n\tprivate async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n\t\tconst manager = await this.getStorageManager();\n\t\treturn new WholeSummaryUploadManager(manager);\n\t}\n\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly manager: GitManager,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies?: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),\n\t\tprivate readonly snapshotTreeCache: ICache<INormalizedWholeSnapshot> = new InMemoryCache(),\n\t\tprivate readonly noCacheGitManager?: GitManager,\n\t\tprivate readonly getStorageManager: (\n\t\t\tdisableCache?: boolean,\n\t\t) => Promise<GitManager> = async (disableCache) =>\n\t\t\tdisableCache && this.noCacheGitManager !== undefined\n\t\t\t\t? this.noCacheGitManager\n\t\t\t\t: this.manager,\n\t) {}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tif (versionId !== this.id && versionId !== null) {\n\t\t\t// Blobs/Trees in this scenario will never have multiple versions, so return versionId as is\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\t// If this is the first versions call for the document, we know we will want the latest summary.\n\t\t// Fetch latest summary, cache it, and return its id.\n\t\tif (this.firstVersionsCall && count === 1) {\n\t\t\tconst normalizedSnapshotContents = await PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"ObtainSnapshot\",\n\t\t\t\t\tversionId: versionId ?? undefined,\n\t\t\t\t\tcount,\n\t\t\t\t\tenableDiscovery: this.driverPolicies?.enableDiscovery,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tlet method: string;\n\t\t\t\t\tconst cachedSnapshotP = this.snapshotTreeCache.get(\n\t\t\t\t\t\tthis.getCacheKey(latestSnapshotId),\n\t\t\t\t\t);\n\n\t\t\t\t\tconst networkSnapshotP = !this.driverPolicies?.enableDiscovery\n\t\t\t\t\t\t? this.fetchSnapshotTree(latestSnapshotId, false, \"getVersions\")\n\t\t\t\t\t\t: this.fetchSnapshotTree(latestSnapshotId, true, \"getVersions\");\n\n\t\t\t\t\tconst promiseRaceWinner = await promiseRaceWithWinner([\n\t\t\t\t\t\tcachedSnapshotP.catch(() => undefined),\n\t\t\t\t\t\tnetworkSnapshotP.catch(() => undefined),\n\t\t\t\t\t]);\n\n\t\t\t\t\tlet retrievedSnapshot = promiseRaceWinner.value;\n\t\t\t\t\tmethod = promiseRaceWinner.index === 0 ? \"cache\" : \"network\";\n\n\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t// if network failed -> wait for cache ( then return network failure)\n\t\t\t\t\t\t// If cache returned empty or failed -> wait for network (success of failure)\n\t\t\t\t\t\tif (promiseRaceWinner.index === 1) {\n\t\t\t\t\t\t\tretrievedSnapshot = await cachedSnapshotP;\n\t\t\t\t\t\t\tmethod = \"cache\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\tretrievedSnapshot = await networkSnapshotP;\n\t\t\t\t\t\t\tmethod = \"network\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t});\n\t\t\t\t\treturn retrievedSnapshot;\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tconst _id = await this.initializeFromSnapshot(normalizedSnapshotContents);\n\t\t\tthis.firstVersionsCall = false;\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: _id,\n\t\t\t\t\ttreeId: normalizedSnapshotContents.snapshotTree.id!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// Otherwise, get the latest version of the document as normal.\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getVersions\",\n\t\t\t\tversionId: id,\n\t\t\t\tcount,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\treturn (await manager.getCommits(id, count)).content;\n\t\t\t},\n\t\t);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\tlet normalizedWholeSnapshot = await this.snapshotTreeCache.get(\n\t\t\tthis.getCacheKey(requestVersion.id),\n\t\t);\n\t\tif (normalizedWholeSnapshot !== undefined) {\n\t\t\treturn normalizedWholeSnapshot.snapshotTree;\n\t\t}\n\n\t\tnormalizedWholeSnapshot = await this.fetchSnapshotTree(\n\t\t\trequestVersion.id,\n\t\t\tundefined,\n\t\t\t\"getSnapshotTree\",\n\t\t);\n\n\t\t// Currently retrieving blobs from network is not supported by AFR for WholeSummaryDocumentStorageService\n\t\t// Blobs are expected to be put in the cache\n\t\tawait this.updateBlobsCache(normalizedWholeSnapshot.blobs);\n\n\t\treturn normalizedWholeSnapshot.snapshotTree;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));\n\t\tif (cachedBlob !== undefined) {\n\t\t\treturn cachedBlob;\n\t\t}\n\n\t\t// Note: AFR does not support readBlobs, but potentially other r11s like servers do\n\t\tconst blob = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"readBlob\",\n\t\t\t\tblobId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getBlob(blobId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.size,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst bufferValue = stringToBuffer(blob.content, blob.encoding);\n\n\t\tawait this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);\n\n\t\treturn bufferValue;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryHandle = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"uploadSummaryWithContext\",\n\t\t\t\tproposalHandle: context.proposalHandle,\n\t\t\t\tackHandle: context.ackHandle,\n\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryUploadManager = await this.getSummaryUploadManager();\n\t\t\t\treturn summaryUploadManager.writeSummaryTree(\n\t\t\t\t\tsummary,\n\t\t\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\t\t\"channel\",\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t\treturn summaryHandle;\n\t}\n\n\tpublic async downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst wholeFlatSnapshot = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: summaryHandle.handle,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager.getSnapshot(summaryHandle.handle);\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t});\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\n\t\tconst { blobs, snapshotTree } = convertWholeFlatSnapshotToSnapshotTreeAndBlobs(\n\t\t\twholeFlatSnapshot,\n\t\t\t\"\",\n\t\t);\n\t\treturn convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"createBlob\",\n\t\t\t\tsize: uint8ArrayFile.length,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager\n\t\t\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t\t\t.then((r) => ({ id: r.content.sha, url: r.content.url }));\n\t\t\t\tevent.end({\n\t\t\t\t\tblobId: response.id,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async fetchSnapshotTree(\n\t\tversionId: string,\n\t\tdisableCache?: boolean,\n\t\tscenarioName?: string,\n\t): Promise<INormalizedWholeSnapshot> {\n\t\tconst normalizedWholeSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: versionId,\n\t\t\t\tscenarioName,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager(disableCache);\n\t\t\t\tconst response: IR11sResponse<IWholeFlatSnapshot> = await manager.getSnapshot(\n\t\t\t\t\tversionId,\n\t\t\t\t);\n\t\t\t\tconst start = performance.now();\n\t\t\t\tconst snapshot: INormalizedWholeSnapshot =\n\t\t\t\t\tconvertWholeFlatSnapshotToSnapshotTreeAndBlobs(response.content);\n\t\t\t\tconst snapshotConversionTime = performance.now() - start;\n\t\t\t\tvalidateBlobsAndTrees(snapshot.snapshotTree);\n\t\t\t\tconst { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t\ttrees,\n\t\t\t\t\tblobs: numBlobs,\n\t\t\t\t\tencodedBlobsSize,\n\t\t\t\t\tsequenceNumber: snapshot.sequenceNumber,\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\tsnapshotConversionTime,\n\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t});\n\t\t\t\treturn snapshot;\n\t\t\t},\n\t\t);\n\n\t\t// Also add the result into the cache.\n\t\tawait this.snapshotTreeCache\n\t\t\t.put(this.getCacheKey(versionId), normalizedWholeSummary)\n\t\t\t.catch(() => undefined);\n\t\treturn normalizedWholeSummary;\n\t}\n\n\tprivate async initializeFromSnapshot(\n\t\tnormalizedWholeSummary: INormalizedWholeSnapshot,\n\t): Promise<string> {\n\t\tconst snapshotId = normalizedWholeSummary.id;\n\t\tassert(snapshotId !== undefined, 0x275 /* \"Root tree should contain the id\" */);\n\t\tconst cachePs: Promise<any>[] = [\n\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(snapshotId), normalizedWholeSummary),\n\t\t\tthis.updateBlobsCache(normalizedWholeSummary.blobs),\n\t\t];\n\n\t\tawait Promise.all(cachePs);\n\n\t\treturn snapshotId;\n\t}\n\n\tprivate async updateBlobsCache(blobs: Map<string, ArrayBuffer>): Promise<void> {\n\t\tconst blobCachePutPs: Promise<void>[] = [];\n\t\tblobs.forEach((value, id) => {\n\t\t\tconst cacheKey = this.getCacheKey(id);\n\t\t\tblobCachePutPs.push(this.blobCache.put(cacheKey, value));\n\t\t});\n\t\tawait Promise.all(blobCachePutPs);\n\t}\n\n\tprivate getCacheKey(blobId: string): string {\n\t\treturn `${this.id}:${blobId}`;\n\t}\n}\n"]}
@@ -18,10 +18,9 @@ export class WholeSummaryUploadManager {
18
18
  return id;
19
19
  }
20
20
  async writeSummaryTreeCore(parentHandle, tree, type, sequenceNumber, initial) {
21
- var _a;
22
21
  const snapshotTree = convertSummaryTreeToWholeSummaryTree(parentHandle, tree, "", type === "channel" ? ".app" : "");
23
22
  const snapshotPayload = {
24
- entries: (_a = snapshotTree.entries) !== null && _a !== void 0 ? _a : [],
23
+ entries: snapshotTree.entries ?? [],
25
24
  message: "",
26
25
  sequenceNumber,
27
26
  type,
@@ -1 +1 @@
1
- {"version":3,"file":"wholeSummaryUploadManager.js","sourceRoot":"","sources":["../src/wholeSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIN,oCAAoC,GACpC,MAAM,wCAAwC,CAAC;AAGhD;;GAEG;AACH,MAAM,OAAO,yBAAyB;IACrC,YAA6B,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;IAAG,CAAC;IAE9C,KAAK,CAAC,gBAAgB,CAC5B,WAAyB,EACzB,YAAgC,EAChC,WAAqC,EACrC,iBAAyB,CAAC,EAC1B,UAAmB,KAAK;QAExB,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,oBAAoB,CACzC,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,OAAO,CACP,CAAC;QACF,IAAI,CAAC,EAAE,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SAChD;QACD,OAAO,EAAE,CAAC;IACX,CAAC;IAEO,KAAK,CAAC,oBAAoB,CACjC,YAAgC,EAChC,IAAkB,EAClB,IAA8B,EAC9B,cAAsB,EACtB,OAAgB;;QAEhB,MAAM,YAAY,GAAG,oCAAoC,CACxD,YAAY,EACZ,IAAI,EACJ,EAAE,EACF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAChC,CAAC;QACF,MAAM,eAAe,GAAyB;YAC7C,OAAO,EAAE,MAAA,YAAY,CAAC,OAAO,mCAAI,EAAE;YACnC,OAAO,EAAE,EAAE;YACX,cAAc;YACd,IAAI;SACJ,CAAC;QAEF,OAAO,IAAI,CAAC,OAAO;aACjB,aAAa,CAAC,eAAe,EAAE,OAAO,CAAC;aACvC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tISummaryTree,\n\tIWholeSummaryPayload,\n\tIWholeSummaryPayloadType,\n\tconvertSummaryTreeToWholeSummaryTree,\n} from \"@fluidframework/server-services-client\";\nimport { IGitManager, ISummaryUploadManager } from \"./storageContracts\";\n\n/**\n * Converts summary to snapshot tree and uploads with single snaphot tree payload.\n */\nexport class WholeSummaryUploadManager implements ISummaryUploadManager {\n\tconstructor(private readonly manager: IGitManager) {}\n\n\tpublic async writeSummaryTree(\n\t\tsummaryTree: ISummaryTree,\n\t\tparentHandle: string | undefined,\n\t\tsummaryType: IWholeSummaryPayloadType,\n\t\tsequenceNumber: number = 0,\n\t\tinitial: boolean = false,\n\t): Promise<string> {\n\t\tconst id = await this.writeSummaryTreeCore(\n\t\t\tparentHandle,\n\t\t\tsummaryTree,\n\t\t\tsummaryType,\n\t\t\tsequenceNumber,\n\t\t\tinitial,\n\t\t);\n\t\tif (!id) {\n\t\t\tthrow new Error(`Failed to write summary tree`);\n\t\t}\n\t\treturn id;\n\t}\n\n\tprivate async writeSummaryTreeCore(\n\t\tparentHandle: string | undefined,\n\t\ttree: ISummaryTree,\n\t\ttype: IWholeSummaryPayloadType,\n\t\tsequenceNumber: number,\n\t\tinitial: boolean,\n\t): Promise<string> {\n\t\tconst snapshotTree = convertSummaryTreeToWholeSummaryTree(\n\t\t\tparentHandle,\n\t\t\ttree,\n\t\t\t\"\",\n\t\t\ttype === \"channel\" ? \".app\" : \"\",\n\t\t);\n\t\tconst snapshotPayload: IWholeSummaryPayload = {\n\t\t\tentries: snapshotTree.entries ?? [],\n\t\t\tmessage: \"\",\n\t\t\tsequenceNumber,\n\t\t\ttype,\n\t\t};\n\n\t\treturn this.manager\n\t\t\t.createSummary(snapshotPayload, initial)\n\t\t\t.then((response) => response.content.id);\n\t}\n}\n"]}
1
+ {"version":3,"file":"wholeSummaryUploadManager.js","sourceRoot":"","sources":["../src/wholeSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIN,oCAAoC,GACpC,MAAM,wCAAwC,CAAC;AAGhD;;GAEG;AACH,MAAM,OAAO,yBAAyB;IACrC,YAA6B,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;IAAG,CAAC;IAE9C,KAAK,CAAC,gBAAgB,CAC5B,WAAyB,EACzB,YAAgC,EAChC,WAAqC,EACrC,iBAAyB,CAAC,EAC1B,UAAmB,KAAK;QAExB,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,oBAAoB,CACzC,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,OAAO,CACP,CAAC;QACF,IAAI,CAAC,EAAE,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SAChD;QACD,OAAO,EAAE,CAAC;IACX,CAAC;IAEO,KAAK,CAAC,oBAAoB,CACjC,YAAgC,EAChC,IAAkB,EAClB,IAA8B,EAC9B,cAAsB,EACtB,OAAgB;QAEhB,MAAM,YAAY,GAAG,oCAAoC,CACxD,YAAY,EACZ,IAAI,EACJ,EAAE,EACF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAChC,CAAC;QACF,MAAM,eAAe,GAAyB;YAC7C,OAAO,EAAE,YAAY,CAAC,OAAO,IAAI,EAAE;YACnC,OAAO,EAAE,EAAE;YACX,cAAc;YACd,IAAI;SACJ,CAAC;QAEF,OAAO,IAAI,CAAC,OAAO;aACjB,aAAa,CAAC,eAAe,EAAE,OAAO,CAAC;aACvC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tISummaryTree,\n\tIWholeSummaryPayload,\n\tIWholeSummaryPayloadType,\n\tconvertSummaryTreeToWholeSummaryTree,\n} from \"@fluidframework/server-services-client\";\nimport { IGitManager, ISummaryUploadManager } from \"./storageContracts\";\n\n/**\n * Converts summary to snapshot tree and uploads with single snaphot tree payload.\n */\nexport class WholeSummaryUploadManager implements ISummaryUploadManager {\n\tconstructor(private readonly manager: IGitManager) {}\n\n\tpublic async writeSummaryTree(\n\t\tsummaryTree: ISummaryTree,\n\t\tparentHandle: string | undefined,\n\t\tsummaryType: IWholeSummaryPayloadType,\n\t\tsequenceNumber: number = 0,\n\t\tinitial: boolean = false,\n\t): Promise<string> {\n\t\tconst id = await this.writeSummaryTreeCore(\n\t\t\tparentHandle,\n\t\t\tsummaryTree,\n\t\t\tsummaryType,\n\t\t\tsequenceNumber,\n\t\t\tinitial,\n\t\t);\n\t\tif (!id) {\n\t\t\tthrow new Error(`Failed to write summary tree`);\n\t\t}\n\t\treturn id;\n\t}\n\n\tprivate async writeSummaryTreeCore(\n\t\tparentHandle: string | undefined,\n\t\ttree: ISummaryTree,\n\t\ttype: IWholeSummaryPayloadType,\n\t\tsequenceNumber: number,\n\t\tinitial: boolean,\n\t): Promise<string> {\n\t\tconst snapshotTree = convertSummaryTreeToWholeSummaryTree(\n\t\t\tparentHandle,\n\t\t\ttree,\n\t\t\t\"\",\n\t\t\ttype === \"channel\" ? \".app\" : \"\",\n\t\t);\n\t\tconst snapshotPayload: IWholeSummaryPayload = {\n\t\t\tentries: snapshotTree.entries ?? [],\n\t\t\tmessage: \"\",\n\t\t\tsequenceNumber,\n\t\t\ttype,\n\t\t};\n\n\t\treturn this.manager\n\t\t\t.createSummary(snapshotPayload, initial)\n\t\t\t.then((response) => response.content.id);\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/routerlicious-driver",
3
- "version": "2.0.0-internal.5.3.2",
3
+ "version": "2.0.0-internal.6.0.0",
4
4
  "description": "Socket.IO + Git implementation of Fluid service API",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -37,15 +37,15 @@
37
37
  "dependencies": {
38
38
  "@fluidframework/common-definitions": "^0.20.1",
39
39
  "@fluidframework/common-utils": "^1.1.1",
40
- "@fluidframework/core-interfaces": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
41
- "@fluidframework/driver-base": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
42
- "@fluidframework/driver-definitions": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
43
- "@fluidframework/driver-utils": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
44
- "@fluidframework/gitresources": "^0.1039.1000",
45
- "@fluidframework/protocol-base": "^0.1039.1000",
40
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
41
+ "@fluidframework/driver-base": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
42
+ "@fluidframework/driver-definitions": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
43
+ "@fluidframework/driver-utils": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
44
+ "@fluidframework/gitresources": "^1.0.0",
45
+ "@fluidframework/protocol-base": "^1.0.0",
46
46
  "@fluidframework/protocol-definitions": "^1.1.0",
47
- "@fluidframework/server-services-client": "^0.1039.1000",
48
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
47
+ "@fluidframework/server-services-client": "^1.0.0",
48
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
49
49
  "cross-fetch": "^3.1.5",
50
50
  "json-stringify-safe": "5.0.1",
51
51
  "socket.io-client": "^4.6.1",
@@ -54,15 +54,15 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@fluid-tools/build-cli": "^0.21.0",
57
- "@fluidframework/build-common": "^1.2.0",
57
+ "@fluidframework/build-common": "^2.0.0",
58
58
  "@fluidframework/build-tools": "^0.21.0",
59
59
  "@fluidframework/eslint-config-fluid": "^2.0.0",
60
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
60
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
61
61
  "@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@2.0.0-internal.5.2.0",
62
62
  "@microsoft/api-extractor": "^7.34.4",
63
63
  "@types/mocha": "^9.1.1",
64
64
  "@types/nock": "^9.3.0",
65
- "@types/node": "^14.18.38",
65
+ "@types/node": "^16.18.38",
66
66
  "@types/sinon": "^7.0.13",
67
67
  "@types/url-parse": "1.4.4",
68
68
  "@types/uuid": "^8.3.0",
@@ -94,7 +94,7 @@
94
94
  "build:genver": "gen-version",
95
95
  "build:test": "tsc --project ./src/test/tsconfig.json",
96
96
  "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
97
- "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
97
+ "clean": "rimraf --glob \"dist\" \"lib\" \"*.tsbuildinfo\" \"*.build.log\"",
98
98
  "eslint": "eslint --format stylish src",
99
99
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
100
100
  "format": "npm run prettier:fix",
package/src/contracts.ts CHANGED
@@ -5,10 +5,54 @@
5
5
 
6
6
  import { ISnapshotTree } from "@fluidframework/protocol-definitions";
7
7
 
8
+ /*
9
+ *
10
+ * Whole Snapshot Download Data Structures
11
+ *
12
+ */
13
+
14
+ export interface IWholeFlatSnapshotTreeEntryTree {
15
+ path: string;
16
+ type: "tree";
17
+ // Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.
18
+ unreferenced?: true;
19
+ }
20
+
21
+ export interface IWholeFlatSnapshotTreeEntryBlob {
22
+ id: string;
23
+ path: string;
24
+ type: "blob";
25
+ }
26
+
27
+ export type IWholeFlatSnapshotTreeEntry =
28
+ | IWholeFlatSnapshotTreeEntryTree
29
+ | IWholeFlatSnapshotTreeEntryBlob;
30
+
31
+ export interface IWholeFlatSnapshotTree {
32
+ entries: IWholeFlatSnapshotTreeEntry[];
33
+ id: string;
34
+ sequenceNumber: number;
35
+ }
36
+
37
+ export interface IWholeFlatSnapshotBlob {
38
+ content: string;
39
+ encoding: "base64" | "utf-8";
40
+ id: string;
41
+ size: number;
42
+ }
43
+
44
+ export interface IWholeFlatSnapshot {
45
+ // The same as the id of the first snapshot tree in the trees array.
46
+ id: string;
47
+ // Receive an array of snapshot trees for future-proofing, however, always length 1 for now.
48
+ trees: IWholeFlatSnapshotTree[];
49
+ blobs?: IWholeFlatSnapshotBlob[];
50
+ }
51
+
8
52
  /**
9
53
  * Normalized Whole Summary with decoded blobs and unflattened snapshot tree.
10
54
  */
11
- export interface INormalizedWholeSummary {
55
+ export interface INormalizedWholeSnapshot {
12
56
  blobs: Map<string, ArrayBuffer>;
13
57
  snapshotTree: ISnapshotTree;
14
58
  sequenceNumber: number | undefined;
@@ -22,7 +22,14 @@ import { ITelemetryLoggerExt, PerformanceEvent } from "@fluidframework/telemetry
22
22
  import { DocumentStorageService } from "./documentStorageService";
23
23
  import { RestWrapper } from "./restWrapperBase";
24
24
 
25
- const MaxBatchDeltas = 5000; // Maximum number of ops we can fetch at a time
25
+ /**
26
+ * Maximum number of ops we can fetch at a time. This should be kept at 2k, as
27
+ * server determines whether to try to fallback to long-term storage if the ops range requested is larger than
28
+ * what they have locally available in short-term storage. So if we request 2k ops, they know it is not a
29
+ * specific request and they don't fall to long term storage which takes time.
30
+ * Please coordinate to AFR team if this value need to be changed.
31
+ */
32
+ const MaxBatchDeltas = 2000;
26
33
 
27
34
  /**
28
35
  * Storage service limited to only being able to fetch documents for a specific document
@@ -27,7 +27,7 @@ import { pkgVersion as driverVersion } from "./packageVersion";
27
27
  import { GitManager } from "./gitManager";
28
28
  import { Historian } from "./historian";
29
29
  import { RestWrapper } from "./restWrapperBase";
30
- import { INormalizedWholeSummary } from "./contracts";
30
+ import { INormalizedWholeSnapshot } from "./contracts";
31
31
 
32
32
  /**
33
33
  * Amount of time between discoveries within which we don't need to rediscover on re-connect.
@@ -67,7 +67,7 @@ export class DocumentService implements api.IDocumentService {
67
67
  private readonly documentStorageServicePolicies: api.IDocumentStorageServicePolicies,
68
68
  private readonly driverPolicies: IRouterliciousDriverPolicies,
69
69
  private readonly blobCache: ICache<ArrayBufferLike>,
70
- private readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSummary>,
70
+ private readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot>,
71
71
  private readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion>,
72
72
  private readonly discoverFluidResolvedUrl: () => Promise<api.IResolvedUrl>,
73
73
  private storageRestWrapper: RouterliciousStorageRestWrapper,
@@ -21,8 +21,11 @@ import {
21
21
  isCombinedAppAndProtocolSummary,
22
22
  RateLimiter,
23
23
  } from "@fluidframework/driver-utils";
24
- import { ChildLogger, PerformanceEvent } from "@fluidframework/telemetry-utils";
25
- import { ISession } from "@fluidframework/server-services-client";
24
+ import { createChildLogger, PerformanceEvent } from "@fluidframework/telemetry-utils";
25
+ import {
26
+ ISession,
27
+ convertSummaryTreeToWholeSummaryTree,
28
+ } from "@fluidframework/server-services-client";
26
29
  import { DocumentService } from "./documentService";
27
30
  import { IRouterliciousDriverPolicies } from "./policies";
28
31
  import { ITokenProvider } from "./tokens";
@@ -32,12 +35,11 @@ import {
32
35
  toInstrumentedR11sOrdererTokenFetcher,
33
36
  toInstrumentedR11sStorageTokenFetcher,
34
37
  } from "./restWrapper";
35
- import { convertSummaryToCreateNewSummary } from "./createNewUtils";
36
38
  import { parseFluidUrl, replaceDocumentIdInPath, getDiscoveredFluidResolvedUrl } from "./urlUtils";
37
39
  import { ICache, InMemoryCache, NullCache } from "./cache";
38
40
  import { pkgVersion as driverVersion } from "./packageVersion";
39
41
  import { ISnapshotTreeVersion } from "./definitions";
40
- import { INormalizedWholeSummary } from "./contracts";
42
+ import { INormalizedWholeSnapshot } from "./contracts";
41
43
 
42
44
  const maximumSnapshotCacheDurationMs: FiveDaysMs = 432_000_000; // 5 days in ms
43
45
 
@@ -60,7 +62,7 @@ const defaultRouterliciousDriverPolicies: IRouterliciousDriverPolicies = {
60
62
  export class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {
61
63
  private readonly driverPolicies: IRouterliciousDriverPolicies;
62
64
  private readonly blobCache: ICache<ArrayBufferLike>;
63
- private readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSummary> = new NullCache();
65
+ private readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot> = new NullCache();
64
66
  private readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion> = new NullCache();
65
67
 
66
68
  constructor(
@@ -77,7 +79,7 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
77
79
  this.blobCache = new InMemoryCache<ArrayBufferLike>();
78
80
  if (this.driverPolicies.enableInternalSummaryCaching) {
79
81
  if (this.driverPolicies.enableWholeSummaryUpload) {
80
- this.wholeSnapshotTreeCache = new InMemoryCache<INormalizedWholeSummary>(
82
+ this.wholeSnapshotTreeCache = new InMemoryCache<INormalizedWholeSnapshot>(
81
83
  snapshotCacheExpiryMs,
82
84
  );
83
85
  } else {
@@ -119,7 +121,7 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
119
121
  const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);
120
122
  const quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);
121
123
 
122
- const logger2 = ChildLogger.create(logger, "RouterliciousDriver");
124
+ const logger2 = createChildLogger({ logger, namespace: "RouterliciousDriver" });
123
125
  const ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(
124
126
  tenantId,
125
127
  undefined /* documentId */,
@@ -150,11 +152,12 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
150
152
  await ordererRestWrapper.post<
151
153
  { id: string; token?: string; session?: ISession } | string
152
154
  >(`/documents/${tenantId}`, {
153
- summary: convertSummaryToCreateNewSummary(appSummary),
155
+ summary: convertSummaryTreeToWholeSummaryTree(undefined, appSummary),
154
156
  sequenceNumber: documentAttributes.sequenceNumber,
155
157
  values: quorumValues,
156
158
  enableDiscovery: this.driverPolicies.enableDiscovery,
157
159
  generateToken: this.tokenProvider.documentPostCreateCallback !== undefined,
160
+ enableAnyBinaryBlobOnFirstSummary: true,
158
161
  })
159
162
  ).content;
160
163
 
@@ -247,8 +250,12 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
247
250
  `Couldn't parse documentId and/or tenantId. [documentId:${documentId}][tenantId:${tenantId}]`,
248
251
  );
249
252
  }
250
- const logger2 = ChildLogger.create(logger, "RouterliciousDriver", {
251
- all: { driverVersion },
253
+ const logger2 = createChildLogger({
254
+ logger,
255
+ namespace: "RouterliciousDriver",
256
+ properties: {
257
+ all: { driverVersion },
258
+ },
252
259
  });
253
260
 
254
261
  const ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(
@@ -20,7 +20,7 @@ import { WholeSummaryDocumentStorageService } from "./wholeSummaryDocumentStorag
20
20
  import { ShreddedSummaryDocumentStorageService } from "./shreddedSummaryDocumentStorageService";
21
21
  import { GitManager } from "./gitManager";
22
22
  import { ISnapshotTreeVersion } from "./definitions";
23
- import { INormalizedWholeSummary } from "./contracts";
23
+ import { INormalizedWholeSnapshot } from "./contracts";
24
24
 
25
25
  export class DocumentStorageService extends DocumentStorageServiceProxy {
26
26
  private _logTailSha: string | undefined = undefined;
@@ -36,7 +36,7 @@ export class DocumentStorageService extends DocumentStorageServiceProxy {
36
36
  policies: IDocumentStorageServicePolicies,
37
37
  driverPolicies?: IRouterliciousDriverPolicies,
38
38
  blobCache?: ICache<ArrayBufferLike>,
39
- snapshotTreeCache?: ICache<INormalizedWholeSummary>,
39
+ snapshotTreeCache?: ICache<INormalizedWholeSnapshot>,
40
40
  shreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>,
41
41
  noCacheGitManager?: GitManager,
42
42
  getStorageManager?: (disableCache?: boolean) => Promise<GitManager>,
@@ -80,7 +80,7 @@ export class DocumentStorageService extends DocumentStorageServiceProxy {
80
80
  policies: IDocumentStorageServicePolicies,
81
81
  driverPolicies?: IRouterliciousDriverPolicies,
82
82
  blobCache?: ICache<ArrayBufferLike>,
83
- snapshotTreeCache?: ICache<INormalizedWholeSummary>,
83
+ snapshotTreeCache?: ICache<INormalizedWholeSnapshot>,
84
84
  shreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>,
85
85
  public noCacheGitManager?: GitManager,
86
86
  getStorageManager?: (disableCache?: boolean) => Promise<GitManager>,
package/src/errorUtils.ts CHANGED
@@ -3,13 +3,14 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { DriverError } from "@fluidframework/driver-definitions";
6
+ import { DriverError, IDriverErrorBase } from "@fluidframework/driver-definitions";
7
7
  import {
8
8
  NonRetryableError,
9
9
  GenericNetworkError,
10
10
  createGenericNetworkError,
11
11
  AuthorizationError,
12
12
  } from "@fluidframework/driver-utils";
13
+ import { IFluidErrorBase } from "@fluidframework/telemetry-utils";
13
14
  import { pkgVersion as driverVersion } from "./packageVersion";
14
15
 
15
16
  /**
@@ -55,61 +56,53 @@ export interface IR11sSocketError {
55
56
  retryAfterMs?: number;
56
57
  }
57
58
 
58
- export interface IR11sError {
59
+ export interface IR11sError extends Omit<IDriverErrorBase, "errorType"> {
59
60
  readonly errorType: RouterliciousErrorType;
60
- readonly message: string;
61
- canRetry: boolean;
62
61
  }
63
62
 
64
63
  export type R11sError = DriverError | IR11sError;
65
64
 
66
65
  export function createR11sNetworkError(
67
66
  errorMessage: string,
68
- statusCode?: number,
67
+ statusCode: number,
69
68
  retryAfterMs?: number,
70
- ): R11sError {
69
+ ): IFluidErrorBase & R11sError {
70
+ let error: IFluidErrorBase & R11sError;
71
71
  const props = { statusCode, driverVersion };
72
72
  switch (statusCode) {
73
- case undefined:
74
- // If a service is temporarily down or a browser resource limit is reached, RestWrapper will throw
75
- // a network error with no status code (e.g. err:ERR_CONN_REFUSED or err:ERR_FAILED) and
76
- // the error message will start with NetworkError as defined in restWrapper.ts
77
- // If there exists a self-signed SSL certificates error, throw a NonRetryableError
78
- // TODO: instead of relying on string matching, filter error based on the error code like we do for websocket connections
79
- if (errorMessage.includes("failed, reason: self signed certificate")) {
80
- return new NonRetryableError(
81
- errorMessage,
82
- RouterliciousErrorType.sslCertError,
83
- props,
84
- );
85
- }
86
- return new GenericNetworkError(
87
- errorMessage,
88
- errorMessage.startsWith("NetworkError"),
89
- props,
90
- );
91
73
  case 401:
92
74
  // The first 401 is manually retried in RouterliciousRestWrapper with a refreshed token,
93
75
  // so we treat repeat 401s the same as 403.
94
76
  case 403:
95
- return new AuthorizationError(errorMessage, undefined, undefined, props);
77
+ error = new AuthorizationError(errorMessage, undefined, undefined, props);
78
+ break;
96
79
  case 404:
97
80
  const errorType = RouterliciousErrorType.fileNotFoundOrAccessDeniedError;
98
- return new NonRetryableError(errorMessage, errorType, props);
81
+ error = new NonRetryableError(errorMessage, errorType, props);
82
+ break;
99
83
  case 429:
100
- return createGenericNetworkError(errorMessage, { canRetry: true, retryAfterMs }, props);
84
+ error = createGenericNetworkError(
85
+ errorMessage,
86
+ { canRetry: true, retryAfterMs },
87
+ props,
88
+ );
89
+ break;
101
90
  case 500:
102
91
  case 502:
103
- return new GenericNetworkError(errorMessage, true, props);
92
+ error = new GenericNetworkError(errorMessage, true, props);
93
+ break;
104
94
  default:
105
95
  const retryInfo = { canRetry: retryAfterMs !== undefined, retryAfterMs };
106
- return createGenericNetworkError(errorMessage, retryInfo, props);
96
+ error = createGenericNetworkError(errorMessage, retryInfo, props);
97
+ break;
107
98
  }
99
+ error.addTelemetryProperties({ endpointReached: true });
100
+ return error;
108
101
  }
109
102
 
110
103
  export function throwR11sNetworkError(
111
104
  errorMessage: string,
112
- statusCode?: number,
105
+ statusCode: number,
113
106
  retryAfterMs?: number,
114
107
  ): never {
115
108
  const networkError = createR11sNetworkError(errorMessage, statusCode, retryAfterMs);
package/src/gitManager.ts CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  import * as resources from "@fluidframework/gitresources";
7
7
  import {
8
- IWholeFlatSummary,
9
8
  IWholeSummaryPayload,
10
9
  IWriteSummaryResponse,
11
10
  } from "@fluidframework/server-services-client";
12
11
  import { IGitManager, IHistorian } from "./storageContracts";
13
12
  import { IR11sResponse, createR11sResponseFromContent } from "./restWrapper";
13
+ import { IWholeFlatSnapshot } from "./contracts";
14
14
 
15
15
  export class GitManager implements IGitManager {
16
16
  private readonly blobCache = new Map<string, resources.IBlob>();
@@ -110,7 +110,7 @@ export class GitManager implements IGitManager {
110
110
  return this.historian.createSummary(summary, initial);
111
111
  }
112
112
 
113
- public async getSummary(sha: string): Promise<IR11sResponse<IWholeFlatSummary>> {
114
- return this.historian.getSummary(sha);
113
+ public async getSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>> {
114
+ return this.historian.getSnapshot(sha);
115
115
  }
116
116
  }
package/src/historian.ts CHANGED
@@ -6,13 +6,13 @@
6
6
  import { fromUtf8ToBase64 } from "@fluidframework/common-utils";
7
7
  import * as git from "@fluidframework/gitresources";
8
8
  import {
9
- IWholeFlatSummary,
10
9
  IWholeSummaryPayload,
11
10
  IWriteSummaryResponse,
12
11
  } from "@fluidframework/server-services-client";
13
12
  import { QueryStringType, RestWrapper } from "./restWrapperBase";
14
13
  import { IR11sResponse } from "./restWrapper";
15
14
  import { IHistorian } from "./storageContracts";
15
+ import { IWholeFlatSnapshot } from "./contracts";
16
16
 
17
17
  export interface ICredentials {
18
18
  user: string;
@@ -98,8 +98,8 @@ export class Historian implements IHistorian {
98
98
  );
99
99
  }
100
100
 
101
- public async getSummary(sha: string): Promise<IR11sResponse<IWholeFlatSummary>> {
102
- return this.restWrapper.get<IWholeFlatSummary>(
101
+ public async getSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>> {
102
+ return this.restWrapper.get<IWholeFlatSnapshot>(
103
103
  `/git/summaries/${sha}`,
104
104
  this.getQueryString(),
105
105
  );
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/routerlicious-driver";
9
- export const pkgVersion = "2.0.0-internal.5.3.2";
9
+ export const pkgVersion = "2.0.0-internal.6.0.0";
@@ -4,9 +4,8 @@
4
4
  */
5
5
 
6
6
  import { ISnapshotTree } from "@fluidframework/protocol-definitions";
7
- import { IWholeFlatSummary, IWholeFlatSummaryTree } from "@fluidframework/server-services-client";
8
7
  import { stringToBuffer } from "@fluidframework/common-utils";
9
- import { INormalizedWholeSummary } from "./contracts";
8
+ import { INormalizedWholeSnapshot, IWholeFlatSnapshot, IWholeFlatSnapshotTree } from "./contracts";
10
9
 
11
10
  /**
12
11
  * Build a tree hierarchy from a flat tree.
@@ -16,7 +15,7 @@ import { INormalizedWholeSummary } from "./contracts";
16
15
  * @returns the heirarchical tree
17
16
  */
18
17
  function buildHierarchy(
19
- flatTree: IWholeFlatSummaryTree,
18
+ flatTree: IWholeFlatSnapshotTree,
20
19
  treePrefixToRemove: string,
21
20
  ): ISnapshotTree {
22
21
  const lookup: { [path: string]: ISnapshotTree } = {};
@@ -54,30 +53,30 @@ function buildHierarchy(
54
53
  }
55
54
 
56
55
  /**
57
- * Converts existing IWholeFlatSummary to snapshot tree, blob array, and sequence number.
56
+ * Converts existing IWholeFlatSnapshot to snapshot tree, blob array, and sequence number.
58
57
  *
59
- * @param flatSummary - flat summary
58
+ * @param flatSnapshot - flat snapshot
60
59
  * @param treePrefixToRemove - tree prefix to strip. By default we are stripping ".app" prefix
61
60
  * @returns snapshot tree, blob array, and sequence number
62
61
  */
63
- export function convertWholeFlatSummaryToSnapshotTreeAndBlobs(
64
- flatSummary: IWholeFlatSummary,
62
+ export function convertWholeFlatSnapshotToSnapshotTreeAndBlobs(
63
+ flatSnapshot: IWholeFlatSnapshot,
65
64
  treePrefixToRemove: string = ".app",
66
- ): INormalizedWholeSummary {
65
+ ): INormalizedWholeSnapshot {
67
66
  const blobs = new Map<string, ArrayBuffer>();
68
- if (flatSummary.blobs) {
69
- flatSummary.blobs.forEach((blob) => {
67
+ if (flatSnapshot.blobs) {
68
+ flatSnapshot.blobs.forEach((blob) => {
70
69
  blobs.set(blob.id, stringToBuffer(blob.content, blob.encoding ?? "utf-8"));
71
70
  });
72
71
  }
73
- const flatSummaryTree = flatSummary.trees?.[0];
74
- const sequenceNumber = flatSummaryTree?.sequenceNumber;
75
- const snapshotTree = buildHierarchy(flatSummaryTree, treePrefixToRemove);
72
+ const flatSnapshotTree = flatSnapshot.trees?.[0];
73
+ const sequenceNumber = flatSnapshotTree?.sequenceNumber;
74
+ const snapshotTree = buildHierarchy(flatSnapshotTree, treePrefixToRemove);
76
75
 
77
76
  return {
78
77
  blobs,
79
78
  snapshotTree,
80
79
  sequenceNumber,
81
- id: flatSummary.id,
80
+ id: flatSnapshot.id,
82
81
  };
83
82
  }