@fluidframework/routerlicious-driver 2.0.0-internal.7.2.2 → 2.0.0-internal.7.3.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 (184) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -2
  3. package/dist/{cache.js → cache.cjs} +2 -2
  4. package/dist/cache.cjs.map +1 -0
  5. package/dist/{policies.js → contracts.cjs} +1 -1
  6. package/dist/contracts.cjs.map +1 -0
  7. package/dist/{createNewUtils.js → createNewUtils.cjs} +1 -1
  8. package/dist/createNewUtils.cjs.map +1 -0
  9. package/dist/{defaultTokenProvider.js → defaultTokenProvider.cjs} +1 -1
  10. package/dist/defaultTokenProvider.cjs.map +1 -0
  11. package/dist/{definitions.js → definitions.cjs} +1 -1
  12. package/dist/definitions.cjs.map +1 -0
  13. package/dist/{deltaStorageService.js → deltaStorageService.cjs} +1 -1
  14. package/dist/deltaStorageService.cjs.map +1 -0
  15. package/dist/{documentDeltaConnection.js → documentDeltaConnection.cjs} +3 -3
  16. package/dist/documentDeltaConnection.cjs.map +1 -0
  17. package/dist/{documentService.js → documentService.cjs} +9 -9
  18. package/dist/documentService.cjs.map +1 -0
  19. package/dist/{documentServiceFactory.js → documentServiceFactory.cjs} +6 -6
  20. package/dist/documentServiceFactory.cjs.map +1 -0
  21. package/dist/{documentStorageService.js → documentStorageService.cjs} +3 -3
  22. package/dist/documentStorageService.cjs.map +1 -0
  23. package/dist/{errorUtils.js → errorUtils.cjs} +2 -2
  24. package/dist/errorUtils.cjs.map +1 -0
  25. package/dist/{gitManager.js → gitManager.cjs} +1 -1
  26. package/dist/gitManager.cjs.map +1 -0
  27. package/dist/{historian.js → historian.cjs} +1 -1
  28. package/{lib/historian.js.map → dist/historian.cjs.map} +1 -1
  29. package/dist/{index.js → index.cjs} +4 -4
  30. package/dist/index.cjs.map +1 -0
  31. package/dist/{mapWithExpiration.js → mapWithExpiration.cjs} +1 -1
  32. package/dist/mapWithExpiration.cjs.map +1 -0
  33. package/dist/{nullBlobStorageService.js → nullBlobStorageService.cjs} +1 -1
  34. package/dist/nullBlobStorageService.cjs.map +1 -0
  35. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  36. package/dist/packageVersion.cjs.map +1 -0
  37. package/dist/packageVersion.d.ts +1 -1
  38. package/dist/{contracts.js → policies.cjs} +1 -1
  39. package/dist/policies.cjs.map +1 -0
  40. package/dist/{r11sSnapshotParser.js → r11sSnapshotParser.cjs} +1 -1
  41. package/dist/r11sSnapshotParser.cjs.map +1 -0
  42. package/dist/{restWrapper.js → restWrapper.cjs} +4 -4
  43. package/dist/restWrapper.cjs.map +1 -0
  44. package/dist/{restWrapperBase.js → restWrapperBase.cjs} +1 -1
  45. package/dist/restWrapperBase.cjs.map +1 -0
  46. package/dist/{retriableGitManager.js → retriableGitManager.cjs} +1 -1
  47. package/dist/retriableGitManager.cjs.map +1 -0
  48. package/dist/{shreddedSummaryDocumentStorageService.js → shreddedSummaryDocumentStorageService.cjs} +4 -4
  49. package/dist/shreddedSummaryDocumentStorageService.cjs.map +1 -0
  50. package/dist/{storageContracts.js → storageContracts.cjs} +1 -1
  51. package/dist/storageContracts.cjs.map +1 -0
  52. package/dist/{summaryTreeUploadManager.js → summaryTreeUploadManager.cjs} +1 -1
  53. package/dist/summaryTreeUploadManager.cjs.map +1 -0
  54. package/dist/{tokens.js → tokens.cjs} +1 -1
  55. package/dist/tokens.cjs.map +1 -0
  56. package/dist/{treeUtils.js → treeUtils.cjs} +1 -1
  57. package/dist/treeUtils.cjs.map +1 -0
  58. package/dist/tsdoc-metadata.json +1 -1
  59. package/dist/{urlUtils.js → urlUtils.cjs} +1 -1
  60. package/dist/urlUtils.cjs.map +1 -0
  61. package/dist/{wholeSummaryDocumentStorageService.js → wholeSummaryDocumentStorageService.cjs} +5 -5
  62. package/dist/wholeSummaryDocumentStorageService.cjs.map +1 -0
  63. package/dist/{wholeSummaryUploadManager.js → wholeSummaryUploadManager.cjs} +1 -1
  64. package/dist/wholeSummaryUploadManager.cjs.map +1 -0
  65. package/lib/{cache.js → cache.mjs} +2 -2
  66. package/lib/cache.mjs.map +1 -0
  67. package/lib/{policies.js → contracts.mjs} +1 -1
  68. package/{dist/contracts.js.map → lib/contracts.mjs.map} +1 -1
  69. package/lib/{createNewUtils.js → createNewUtils.mjs} +1 -1
  70. package/lib/createNewUtils.mjs.map +1 -0
  71. package/lib/{defaultTokenProvider.js → defaultTokenProvider.mjs} +1 -1
  72. package/lib/defaultTokenProvider.mjs.map +1 -0
  73. package/lib/{definitions.js → definitions.mjs} +1 -1
  74. package/{dist/definitions.js.map → lib/definitions.mjs.map} +1 -1
  75. package/lib/{deltaStorageService.js → deltaStorageService.mjs} +1 -1
  76. package/lib/deltaStorageService.mjs.map +1 -0
  77. package/lib/{documentDeltaConnection.js → documentDeltaConnection.mjs} +3 -3
  78. package/lib/documentDeltaConnection.mjs.map +1 -0
  79. package/lib/{documentService.js → documentService.mjs} +9 -9
  80. package/lib/documentService.mjs.map +1 -0
  81. package/lib/{documentServiceFactory.js → documentServiceFactory.mjs} +6 -6
  82. package/lib/documentServiceFactory.mjs.map +1 -0
  83. package/lib/{documentStorageService.js → documentStorageService.mjs} +3 -3
  84. package/lib/documentStorageService.mjs.map +1 -0
  85. package/lib/{errorUtils.js → errorUtils.mjs} +2 -2
  86. package/lib/errorUtils.mjs.map +1 -0
  87. package/lib/{gitManager.js → gitManager.mjs} +1 -1
  88. package/lib/gitManager.mjs.map +1 -0
  89. package/lib/{historian.js → historian.mjs} +1 -1
  90. package/lib/historian.mjs.map +1 -0
  91. package/lib/{index.js → index.mjs} +4 -7
  92. package/lib/index.mjs.map +1 -0
  93. package/lib/{mapWithExpiration.js → mapWithExpiration.mjs} +1 -1
  94. package/lib/mapWithExpiration.mjs.map +1 -0
  95. package/lib/{nullBlobStorageService.js → nullBlobStorageService.mjs} +1 -1
  96. package/lib/nullBlobStorageService.mjs.map +1 -0
  97. package/lib/packageVersion.d.ts +1 -1
  98. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  99. package/lib/packageVersion.mjs.map +1 -0
  100. package/lib/{contracts.js → policies.mjs} +1 -1
  101. package/{dist/policies.js.map → lib/policies.mjs.map} +1 -1
  102. package/lib/{r11sSnapshotParser.js → r11sSnapshotParser.mjs} +1 -1
  103. package/lib/r11sSnapshotParser.mjs.map +1 -0
  104. package/lib/{restWrapper.js → restWrapper.mjs} +4 -4
  105. package/lib/restWrapper.mjs.map +1 -0
  106. package/lib/{restWrapperBase.js → restWrapperBase.mjs} +1 -1
  107. package/lib/restWrapperBase.mjs.map +1 -0
  108. package/lib/{retriableGitManager.js → retriableGitManager.mjs} +1 -1
  109. package/lib/retriableGitManager.mjs.map +1 -0
  110. package/lib/{shreddedSummaryDocumentStorageService.js → shreddedSummaryDocumentStorageService.mjs} +4 -4
  111. package/lib/shreddedSummaryDocumentStorageService.mjs.map +1 -0
  112. package/lib/{storageContracts.js → storageContracts.mjs} +1 -1
  113. package/{dist/storageContracts.js.map → lib/storageContracts.mjs.map} +1 -1
  114. package/lib/{summaryTreeUploadManager.js → summaryTreeUploadManager.mjs} +1 -1
  115. package/lib/summaryTreeUploadManager.mjs.map +1 -0
  116. package/lib/{tokens.js → tokens.mjs} +1 -1
  117. package/{dist/tokens.js.map → lib/tokens.mjs.map} +1 -1
  118. package/lib/{treeUtils.js → treeUtils.mjs} +1 -1
  119. package/lib/treeUtils.mjs.map +1 -0
  120. package/lib/{urlUtils.js → urlUtils.mjs} +1 -1
  121. package/lib/urlUtils.mjs.map +1 -0
  122. package/lib/{wholeSummaryDocumentStorageService.js → wholeSummaryDocumentStorageService.mjs} +5 -5
  123. package/lib/wholeSummaryDocumentStorageService.mjs.map +1 -0
  124. package/lib/{wholeSummaryUploadManager.js → wholeSummaryUploadManager.mjs} +1 -1
  125. package/lib/wholeSummaryUploadManager.mjs.map +1 -0
  126. package/package.json +34 -21
  127. package/src/packageVersion.ts +1 -1
  128. package/tsc-multi.test.json +4 -0
  129. package/tsconfig.json +5 -4
  130. package/dist/cache.js.map +0 -1
  131. package/dist/createNewUtils.js.map +0 -1
  132. package/dist/defaultTokenProvider.js.map +0 -1
  133. package/dist/deltaStorageService.js.map +0 -1
  134. package/dist/documentDeltaConnection.js.map +0 -1
  135. package/dist/documentService.js.map +0 -1
  136. package/dist/documentServiceFactory.js.map +0 -1
  137. package/dist/documentStorageService.js.map +0 -1
  138. package/dist/errorUtils.js.map +0 -1
  139. package/dist/gitManager.js.map +0 -1
  140. package/dist/historian.js.map +0 -1
  141. package/dist/index.js.map +0 -1
  142. package/dist/mapWithExpiration.js.map +0 -1
  143. package/dist/nullBlobStorageService.js.map +0 -1
  144. package/dist/packageVersion.js.map +0 -1
  145. package/dist/r11sSnapshotParser.js.map +0 -1
  146. package/dist/restWrapper.js.map +0 -1
  147. package/dist/restWrapperBase.js.map +0 -1
  148. package/dist/retriableGitManager.js.map +0 -1
  149. package/dist/shreddedSummaryDocumentStorageService.js.map +0 -1
  150. package/dist/summaryTreeUploadManager.js.map +0 -1
  151. package/dist/treeUtils.js.map +0 -1
  152. package/dist/urlUtils.js.map +0 -1
  153. package/dist/wholeSummaryDocumentStorageService.js.map +0 -1
  154. package/dist/wholeSummaryUploadManager.js.map +0 -1
  155. package/lib/cache.js.map +0 -1
  156. package/lib/contracts.js.map +0 -1
  157. package/lib/createNewUtils.js.map +0 -1
  158. package/lib/defaultTokenProvider.js.map +0 -1
  159. package/lib/definitions.js.map +0 -1
  160. package/lib/deltaStorageService.js.map +0 -1
  161. package/lib/documentDeltaConnection.js.map +0 -1
  162. package/lib/documentService.js.map +0 -1
  163. package/lib/documentServiceFactory.js.map +0 -1
  164. package/lib/documentStorageService.js.map +0 -1
  165. package/lib/errorUtils.js.map +0 -1
  166. package/lib/gitManager.js.map +0 -1
  167. package/lib/index.js.map +0 -1
  168. package/lib/mapWithExpiration.js.map +0 -1
  169. package/lib/nullBlobStorageService.js.map +0 -1
  170. package/lib/packageVersion.js.map +0 -1
  171. package/lib/policies.js.map +0 -1
  172. package/lib/r11sSnapshotParser.js.map +0 -1
  173. package/lib/restWrapper.js.map +0 -1
  174. package/lib/restWrapperBase.js.map +0 -1
  175. package/lib/retriableGitManager.js.map +0 -1
  176. package/lib/shreddedSummaryDocumentStorageService.js.map +0 -1
  177. package/lib/storageContracts.js.map +0 -1
  178. package/lib/summaryTreeUploadManager.js.map +0 -1
  179. package/lib/tokens.js.map +0 -1
  180. package/lib/treeUtils.js.map +0 -1
  181. package/lib/urlUtils.js.map +0 -1
  182. package/lib/wholeSummaryDocumentStorageService.js.map +0 -1
  183. package/lib/wholeSummaryUploadManager.js.map +0 -1
  184. package/tsconfig.esnext.json +0 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summaryTreeUploadManager.mjs","sourceRoot":"","sources":["../src/summaryTreeUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,WAAW,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,8BAA8B;OAClF,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4BAA4B;OAE7D,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,+BAA+B;OAC/D,EAIN,WAAW,GACX,MAAM,sCAAsC;AAI7C;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACpC,YACkB,OAAoB,EACpB,aAAkC,EAClC,uBAE+B;QAJ/B,YAAO,GAAP,OAAO,CAAa;QACpB,kBAAa,GAAb,aAAa,CAAqB;QAClC,4BAAuB,GAAvB,uBAAuB,CAEQ;IAC9C,CAAC;IAEG,KAAK,CAAC,gBAAgB,CAC5B,WAAyB,EACzB,YAAoB,EACpB,WAAqC,EACrC,cAAuB,EACvB,OAAiB;QAEjB,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;QAC9E,OAAO,IAAI,CAAC,oBAAoB,CAAC,WAAW,EAAE,oBAAoB,IAAI,SAAS,CAAC,CAAC;IAClF,C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,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACvF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { gitHashFile, IsoBuffer, Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { ICreateTreeEntry } from \"@fluidframework/gitresources\";\nimport { getGitMode, getGitType } from \"@fluidframework/protocol-base\";\nimport {\n\tISnapshotTreeEx,\n\tISummaryTree,\n\tSummaryObject,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport { IWholeSummaryPayloadType } from \"@fluidframework/server-services-client\";\nimport { IGitManager, ISummaryUploadManager } from \"./storageContracts\";\n\n/**\n * Recursively writes summary tree as individual summary blobs.\n */\nexport class SummaryTreeUploadManager implements ISummaryUploadManager {\n\tconstructor(\n\t\tprivate readonly manager: IGitManager,\n\t\tprivate readonly blobsShaCache: Map<string, string>,\n\t\tprivate readonly getPreviousFullSnapshot: (\n\t\t\tparentHandle: string,\n\t\t) => Promise<ISnapshotTreeEx | null | undefined>,\n\t) {}\n\n\tpublic async writeSummaryTree(\n\t\tsummaryTree: ISummaryTree,\n\t\tparentHandle: string,\n\t\tsummaryType: IWholeSummaryPayloadType,\n\t\tsequenceNumber?: number,\n\t\tinitial?: boolean,\n\t): Promise<string> {\n\t\tconst previousFullSnapshot = await this.getPreviousFullSnapshot(parentHandle);\n\t\treturn this.writeSummaryTreeCore(summaryTree, previousFullSnapshot ?? undefined);\n\t}\n\n\tprivate async writeSummaryTreeCore(\n\t\tsummaryTree: ISummaryTree,\n\t\tpreviousFullSnapshot: ISnapshotTreeEx | undefined,\n\t): Promise<string> {\n\t\tconst entries = await Promise.all(\n\t\t\tObject.keys(summaryTree.tree).map(async (key) => {\n\t\t\t\tconst entry = summaryTree.tree[key];\n\t\t\t\tconst pathHandle = await this.writeSummaryTreeObject(entry, previousFullSnapshot);\n\t\t\t\tconst treeEntry: ICreateTreeEntry = {\n\t\t\t\t\tmode: getGitMode(entry),\n\t\t\t\t\tpath: encodeURIComponent(key),\n\t\t\t\t\tsha: pathHandle,\n\t\t\t\t\ttype: getGitType(entry),\n\t\t\t\t};\n\t\t\t\treturn treeEntry;\n\t\t\t}),\n\t\t);\n\n\t\tconst treeHandle = (await this.manager.createGitTree({ tree: entries })).content;\n\t\treturn treeHandle.sha;\n\t}\n\n\tprivate async writeSummaryTreeObject(\n\t\tobject: SummaryObject,\n\t\tpreviousFullSnapshot: ISnapshotTreeEx | undefined,\n\t): Promise<string> {\n\t\tswitch (object.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\treturn this.writeSummaryBlob(object.content);\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tif (previousFullSnapshot === undefined) {\n\t\t\t\t\tthrow Error(\"Parent summary does not exist to reference by handle.\");\n\t\t\t\t}\n\t\t\t\treturn this.getIdFromPath(object.handleType, object.handle, previousFullSnapshot);\n\t\t\t}\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\treturn this.writeSummaryTreeCore(object, previousFullSnapshot);\n\t\t\t}\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\treturn object.id;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(object, `Unknown type: ${(object as any).type}`);\n\t\t}\n\t}\n\n\tprivate async writeSummaryBlob(content: string | Uint8Array): Promise<string> {\n\t\tconst { parsedContent, encoding } =\n\t\t\ttypeof content === \"string\"\n\t\t\t\t? { parsedContent: content, encoding: \"utf-8\" }\n\t\t\t\t: { parsedContent: Uint8ArrayToString(content, \"base64\"), encoding: \"base64\" };\n\n\t\t// The gitHashFile would return the same hash as returned by the server as blob.sha\n\t\tconst hash = await gitHashFile(IsoBuffer.from(parsedContent, encoding));\n\t\tif (!this.blobsShaCache.has(hash)) {\n\t\t\tthis.blobsShaCache.set(hash, \"\");\n\t\t\tconst blob = (await this.manager.createBlob(parsedContent, encoding)).content;\n\t\t\tassert(hash === blob.sha, 0x0b6 /* \"Blob.sha and hash do not match!!\" */);\n\t\t}\n\t\treturn hash;\n\t}\n\n\tprivate getIdFromPath(\n\t\thandleType: SummaryType,\n\t\thandlePath: string,\n\t\tpreviousFullSnapshot: ISnapshotTreeEx,\n\t): string {\n\t\tconst path = handlePath.split(\"/\").map((part) => decodeURIComponent(part));\n\t\tif (path[0] === \"\") {\n\t\t\t// root of tree should be unnamed\n\t\t\tpath.shift();\n\t\t}\n\t\tif (path.length === 0) {\n\t\t\treturn previousFullSnapshot.id;\n\t\t}\n\n\t\treturn this.getIdFromPathCore(handleType, path, previousFullSnapshot);\n\t}\n\n\tprivate getIdFromPathCore(\n\t\thandleType: SummaryType,\n\t\tpath: string[],\n\t\t/** Previous snapshot, subtree relative to this path part */\n\t\tpreviousSnapshot: ISnapshotTreeEx,\n\t): string {\n\t\tassert(path.length > 0, 0x0b3 /* \"Expected at least 1 path part\" */);\n\t\tconst key = path[0];\n\t\tif (path.length === 1) {\n\t\t\tswitch (handleType) {\n\t\t\t\tcase SummaryType.Blob: {\n\t\t\t\t\tconst tryId = previousSnapshot.blobs[key];\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!tryId,\n\t\t\t\t\t\t0x0b4 /* \"Parent summary does not have blob handle for specified path.\" */,\n\t\t\t\t\t);\n\t\t\t\t\treturn tryId;\n\t\t\t\t}\n\t\t\t\tcase SummaryType.Tree: {\n\t\t\t\t\tconst tryId = previousSnapshot.trees[key]?.id;\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!tryId,\n\t\t\t\t\t\t0x0b5 /* \"Parent summary does not have tree handle for specified path.\" */,\n\t\t\t\t\t);\n\t\t\t\t\treturn tryId;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tthrow Error(`Unexpected handle summary object type: \"${handleType}\".`);\n\t\t\t}\n\t\t}\n\t\treturn this.getIdFromPathCore(handleType, path.slice(1), previousSnapshot.trees[key]);\n\t}\n}\n"]}
@@ -3,4 +3,4 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=tokens.js.map
6
+ //# sourceMappingURL=tokens.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITokenClaims } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Abstracts the discovery of claims contained within a token.\n */\nexport interface ITokenService {\n\t/**\n\t * Extracts the {@link @fluidframework/protocol-definitions#ITokenClaims | token claims} from the provided\n\t * {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} string representation.\n\t */\n\textractClaims(token: string): ITokenClaims;\n}\n\nexport interface ITokenResponse {\n\t/**\n\t * {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} value.\n\t */\n\tjwt: string;\n\n\t/**\n\t * A flag indicating whether token was obtained from local cache.\n\t *\n\t * @remarks `undefined` indicates that the source of the token could not be determined.\n\t */\n\tfromCache?: boolean;\n}\n\n/**\n * Abstracts the token fetching mechanism for a hosting application.\n * The hosting application is responsible for providing an implementation.\n */\nexport interface ITokenProvider {\n\t/**\n\t * Fetches the orderer token from host.\n\t *\n\t * @param tenantId - Tenant ID.\n\t * @param documentId - Optional. Document ID is only required for document-scoped requests.\n\t * @param refresh - Optional flag indicating whether token fetch must bypass local cache.\n\t * This likely indicates that some previous request failed authorization due to an expired token,\n\t * and so a fresh token is required.\n\t *\n\t * Default: `false`.\n\t *\n\t * NOTE: This parameter will be made required in the future.\n\t */\n\tfetchOrdererToken(\n\t\ttenantId: string,\n\t\tdocumentId?: string,\n\t\trefresh?: boolean,\n\t): Promise<ITokenResponse>;\n\n\t/**\n\t * Fetches the storage token from host.\n\t *\n\t * @param tenantId - Tenant ID.\n\t * @param documentId - Document ID.\n\t * @param refresh - Optional flag indicating whether token fetch must bypass local cache.\n\t * This likely indicates that some previous request failed authorization due to an expired token,\n\t * and so a fresh token is required.\n\t *\n\t * Default: `false`.\n\t *\n\t * NOTE: This parameter will be made required in the future.\n\t */\n\tfetchStorageToken(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\trefresh?: boolean,\n\t): Promise<ITokenResponse>;\n\n\t/**\n\t * A callback triggered directly after creating the document. In this callback the client has the opportunity, to\n\t * verify against an authorization service, if the user who claims to create the document is the same user who\n\t * created it.\n\t *\n\t * @remarks Notes:\n\t *\n\t * * Using the callback may have performance impact on the document creation process.\n\t *\n\t * * Any exceptions thrown in the callback would fail the creation workflow\n\t * (see {@link RouterliciousDocumentServiceFactory.createContainer} for more details).\n\t *\n\t * @param documentId - Document ID.\n\t * @param creationToken - A special token that doesn't provide any kind of access, but it has the user's payload\n\t * and document id. It can be used to validate the identity of the document creator.\n\t */\n\tdocumentPostCreateCallback?(documentId: string, creationToken: string): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"tokens.mjs","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITokenClaims } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Abstracts the discovery of claims contained within a token.\n */\nexport interface ITokenService {\n\t/**\n\t * Extracts the {@link @fluidframework/protocol-definitions#ITokenClaims | token claims} from the provided\n\t * {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} string representation.\n\t */\n\textractClaims(token: string): ITokenClaims;\n}\n\nexport interface ITokenResponse {\n\t/**\n\t * {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} value.\n\t */\n\tjwt: string;\n\n\t/**\n\t * A flag indicating whether token was obtained from local cache.\n\t *\n\t * @remarks `undefined` indicates that the source of the token could not be determined.\n\t */\n\tfromCache?: boolean;\n}\n\n/**\n * Abstracts the token fetching mechanism for a hosting application.\n * The hosting application is responsible for providing an implementation.\n */\nexport interface ITokenProvider {\n\t/**\n\t * Fetches the orderer token from host.\n\t *\n\t * @param tenantId - Tenant ID.\n\t * @param documentId - Optional. Document ID is only required for document-scoped requests.\n\t * @param refresh - Optional flag indicating whether token fetch must bypass local cache.\n\t * This likely indicates that some previous request failed authorization due to an expired token,\n\t * and so a fresh token is required.\n\t *\n\t * Default: `false`.\n\t *\n\t * NOTE: This parameter will be made required in the future.\n\t */\n\tfetchOrdererToken(\n\t\ttenantId: string,\n\t\tdocumentId?: string,\n\t\trefresh?: boolean,\n\t): Promise<ITokenResponse>;\n\n\t/**\n\t * Fetches the storage token from host.\n\t *\n\t * @param tenantId - Tenant ID.\n\t * @param documentId - Document ID.\n\t * @param refresh - Optional flag indicating whether token fetch must bypass local cache.\n\t * This likely indicates that some previous request failed authorization due to an expired token,\n\t * and so a fresh token is required.\n\t *\n\t * Default: `false`.\n\t *\n\t * NOTE: This parameter will be made required in the future.\n\t */\n\tfetchStorageToken(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\trefresh?: boolean,\n\t): Promise<ITokenResponse>;\n\n\t/**\n\t * A callback triggered directly after creating the document. In this callback the client has the opportunity, to\n\t * verify against an authorization service, if the user who claims to create the document is the same user who\n\t * created it.\n\t *\n\t * @remarks Notes:\n\t *\n\t * * Using the callback may have performance impact on the document creation process.\n\t *\n\t * * Any exceptions thrown in the callback would fail the creation workflow\n\t * (see {@link RouterliciousDocumentServiceFactory.createContainer} for more details).\n\t *\n\t * @param documentId - Document ID.\n\t * @param creationToken - A special token that doesn't provide any kind of access, but it has the user's payload\n\t * and document id. It can be used to validate the identity of the document creator.\n\t */\n\tdocumentPostCreateCallback?(documentId: string, creationToken: string): Promise<void>;\n}\n"]}
@@ -97,4 +97,4 @@ function countTreesInSnapshotTree(snapshotTree) {
97
97
  }
98
98
  return numTrees;
99
99
  }
100
- //# sourceMappingURL=treeUtils.js.map
100
+ //# sourceMappingURL=treeUtils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeUtils.mjs","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,SAAS,EAAE,MAAM,8BAA8B;OACjD,EAAE,MAAM,EAAE,MAAM,4BAA4B;OAC5C,EACN,WAAW,GAIX,MAAM,sCAAsC;AAa7C;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAIhC,YAA6B,KAAkC;QAAlC,UAAK,GAAL,KAAK,CAA6B;QAHvD,sBAAiB,GAAW,CAAC,CAAC;QACrB,gBAAW,GAAsC,EAAE,CAAC;IAEH,CAAC;IAEnE;;OAEG;IACH,IAAW,OAAO;QACjB,OAAO;YACN,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE;YAC7B,YAAY,EAAE,IAAI,CAAC,KAAK,EAAE,YAAY;SACtC,CAAC;IACH,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,GAAW,EAAE,OAA4B;QACvD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG;YACvB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,OAAO;SACP,CAAC;IACH,CAAC;IAED;;OAEG;IACI,SAAS,CACf,GAAW,EACX,UAAwE,EACxE,MAAc;QAEd,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG;YACvB,IAAI,EAAE,WAAW,CAAC,MAAM;YACxB,UAAU;YACV,MAAM;SACN,CAAC;IACH,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,GAAW,EAAE,OAAqB;QAChD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,aAAa,CAAC,EAAU;QAC9B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,iBAAiB,EAA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AgB,IAAI,WAAW,CAAC,UAAU,CAAC;KAC3C;IACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,QAAuB;IAC5D,MAAM,CACL,QAAQ,CAAC,KAAK,KAAK,SAAS,EAC5B,KAAK,CAAC,oDAAoD,CAC1D,CAAC;IACF,MAAM,CACL,QAAQ,CAAC,KAAK,KAAK,SAAS,EAC5B,KAAK,CAAC,oDAAoD,CAC1D,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,YAA2B;IAC5D,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;QAC3D,QAAQ,IAAI,CAAC,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;KAC/C;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\tSummaryType,\n\tISnapshotTree,\n\tISummaryTree,\n\tSummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport { INormalizedWholeSnapshot } from \"./contracts\";\n\n/**\n * Summary tree assembler props\n */\nexport interface ISummaryTreeAssemblerProps {\n\t/**\n\t * Indicates that this tree is unreferenced. If this is not present, the tree is considered referenced.\n\t */\n\tunreferenced?: true;\n}\n\n/**\n * Summary tree assembler (without stats collection).\n */\nexport class SummaryTreeAssembler {\n\tprivate attachmentCounter: number = 0;\n\tprivate readonly summaryTree: { [path: string]: SummaryObject } = {};\n\n\tconstructor(private readonly props?: ISummaryTreeAssemblerProps) {}\n\n\t/**\n\t * Get final summary\n\t */\n\tpublic get summary(): ISummaryTree {\n\t\treturn {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t\tunreferenced: this.props?.unreferenced,\n\t\t};\n\t}\n\n\t/**\n\t * Add blob to summary\n\t */\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Blob,\n\t\t\tcontent,\n\t\t};\n\t}\n\n\t/**\n\t * Add handle to summary\n\t */\n\tpublic addHandle(\n\t\tkey: string,\n\t\thandleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n\t\thandle: string,\n\t): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType,\n\t\t\thandle,\n\t\t};\n\t}\n\n\t/**\n\t * Add tree to summary\n\t */\n\tpublic addTree(key: string, summary: ISummaryTree): void {\n\t\tthis.summaryTree[key] = summary;\n\t}\n\n\t/**\n\t * Add attachment to summary\n\t */\n\tpublic addAttachment(id: string) {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n}\n\n/**\n * Helper function that converts ISnapshotTree and blobs to ISummaryTree\n * @param snapshot - Source snapshot tree\n * @param blobs - Blobs cache\n * @returns Converted snapshot in ISummaryTree format\n */\nexport function convertSnapshotAndBlobsToSummaryTree(\n\tsnapshot: ISnapshotTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISummaryTree {\n\tconst assembler = new SummaryTreeAssembler({\n\t\tunreferenced: snapshot.unreferenced,\n\t});\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tconst blob = blobs.get(id);\n\t\tassert(blob !== undefined, 0x2dd /* \"Cannot find blob for a given id\" */);\n\t\tassembler.addBlob(path, IsoBuffer.from(blob).toString(\"utf-8\"));\n\t}\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotAndBlobsToSummaryTree(tree, blobs);\n\t\tassembler.addTree(key, subtree);\n\t}\n\treturn assembler.summary;\n}\n\nexport function evalBlobsAndTrees(snapshot: INormalizedWholeSnapshot) {\n\tconst trees = countTreesInSnapshotTree(snapshot.snapshotTree);\n\tconst numBlobs = snapshot.blobs.size;\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobs) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { trees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: ISnapshotTree) {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x5d0 /* Returned r11s snapshot is malformed. No trees! */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x5d1 /* Returned r11s snapshot is malformed. No blobs! */,\n\t);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n\tlet numTrees = 0;\n\tfor (const [_, tree] of Object.entries(snapshotTree.trees)) {\n\t\tnumTrees += 1 + countTreesInSnapshotTree(tree);\n\t}\n\treturn numTrees;\n}\n"]}
@@ -35,4 +35,4 @@ export const getDiscoveredFluidResolvedUrl = (resolvedUrl, session) => {
35
35
  };
36
36
  return discoveredResolvedUrl;
37
37
  };
38
- //# sourceMappingURL=urlUtils.js.map
38
+ //# sourceMappingURL=urlUtils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlUtils.mjs","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAGI,QAAQ,MAAM,WAAW;AAGhC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAY,EAAE;IAC3D,OAAO,IAAI,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAe,EAAE,UAAkB,EAAU,EAAE,CACtF,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EA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n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport URLParse from \"url-parse\";\nimport { ISession } from \"@fluidframework/server-services-client\";\n\nexport const parseFluidUrl = (fluidUrl: string): URLParse => {\n\treturn new URLParse(fluidUrl, true);\n};\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 URLParse(session.ordererUrl);\n\tconst deltaStorageUrl = new URLParse(resolvedUrl.endpoints.deltaStorageUrl);\n\tdeltaStorageUrl.set(\"host\", discoveredOrdererUrl.host);\n\n\tconst discoveredStorageUrl = new URLParse(session.historianUrl);\n\tconst storageUrl = new URLParse(resolvedUrl.endpoints.storageUrl);\n\tstorageUrl.set(\"host\", discoveredStorageUrl.host);\n\n\tconst parsedUrl = parseFluidUrl(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 URLParse(`fluid://${discoveredOrdererUrl.host}${parsedUrl.pathname}`).toString(),\n\t};\n\treturn discoveredResolvedUrl;\n};\n"]}
@@ -6,10 +6,10 @@ import { PerformanceEvent, createChildMonitoringContext, } from "@fluidframework
6
6
  import { performance, stringToBuffer, Uint8ArrayToString } from "@fluid-internal/client-utils";
7
7
  import { assert } from "@fluidframework/core-utils";
8
8
  import { getW3CData, promiseRaceWithWinner } from "@fluidframework/driver-base";
9
- import { InMemoryCache } from "./cache";
10
- import { convertSnapshotAndBlobsToSummaryTree, evalBlobsAndTrees, validateBlobsAndTrees, } from "./treeUtils";
11
- import { WholeSummaryUploadManager } from "./wholeSummaryUploadManager";
12
- import { convertWholeFlatSnapshotToSnapshotTreeAndBlobs } from "./r11sSnapshotParser";
9
+ import { InMemoryCache } from "./cache.mjs";
10
+ import { convertSnapshotAndBlobsToSummaryTree, evalBlobsAndTrees, validateBlobsAndTrees, } from "./treeUtils.mjs";
11
+ import { WholeSummaryUploadManager } from "./wholeSummaryUploadManager.mjs";
12
+ import { convertWholeFlatSnapshotToSnapshotTreeAndBlobs } from "./r11sSnapshotParser.mjs";
13
13
  const latestSnapshotId = "latest";
14
14
  export class WholeSummaryDocumentStorageService {
15
15
  async getSummaryUploadManager() {
@@ -246,4 +246,4 @@ export class WholeSummaryDocumentStorageService {
246
246
  return `${this.id}:${blobId}`;
247
247
  }
248
248
  }
249
- //# sourceMappingURL=wholeSummaryDocumentStorageService.js.map
249
+ //# sourceMappingURL=wholeSummaryDocumentStorageService.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wholeSummaryDocumentStorageService.mjs","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAGN,gBAAgB,EAChB,4BAA4B,GAC5B,MAAM,iCAAiC;OACjC,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,8BAA8B;OACvF,EAAE,MAAM,EAAE,MAAM,4BAA4B;OAC5C,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,6BAA6B;OAaxE,EAAU,aAAa,EAAE;OAEzB,EACN,oCAAoC,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AAC;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 {\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { performance, stringToBuffer, Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-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 readonly mc: MonitoringContext;\n\tprivate firstVersionsCall: boolean = true;\n\n\tpublic readonly repositoryUrl = \"\";\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\tundefined, // recordHeapSize\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"]}
@@ -30,4 +30,4 @@ export class WholeSummaryUploadManager {
30
30
  .then((response) => response.content.id);
31
31
  }
32
32
  }
33
- //# sourceMappingURL=wholeSummaryUploadManager.js.map
33
+ //# sourceMappingURL=wholeSummaryUploadManager.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wholeSummaryUploadManager.mjs","sourceRoot":"","sources":["../src/wholeSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAIN,oCAAoC,GACpC,MAAM,wCAAwC;AAG/C;;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.7.2.2",
3
+ "version": "2.0.0-internal.7.3.0",
4
4
  "description": "Socket.IO + Git implementation of Fluid service API",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -11,8 +11,20 @@
11
11
  "license": "MIT",
12
12
  "author": "Microsoft and contributors",
13
13
  "sideEffects": false,
14
- "main": "dist/index.js",
15
- "module": "lib/index.js",
14
+ "exports": {
15
+ ".": {
16
+ "import": {
17
+ "types": "./lib/index.d.ts",
18
+ "default": "./lib/index.mjs"
19
+ },
20
+ "require": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.cjs"
23
+ }
24
+ }
25
+ },
26
+ "main": "dist/index.cjs",
27
+ "module": "lib/index.mjs",
16
28
  "types": "dist/index.d.ts",
17
29
  "c8": {
18
30
  "all": true,
@@ -35,17 +47,17 @@
35
47
  "temp-directory": "nyc/.nyc_output"
36
48
  },
37
49
  "dependencies": {
38
- "@fluid-internal/client-utils": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
39
- "@fluidframework/core-interfaces": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
40
- "@fluidframework/core-utils": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
41
- "@fluidframework/driver-base": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
42
- "@fluidframework/driver-definitions": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
43
- "@fluidframework/driver-utils": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
50
+ "@fluid-internal/client-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
51
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
52
+ "@fluidframework/core-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
53
+ "@fluidframework/driver-base": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
54
+ "@fluidframework/driver-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
55
+ "@fluidframework/driver-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
44
56
  "@fluidframework/gitresources": "^2.0.1",
45
57
  "@fluidframework/protocol-base": "^2.0.1",
46
58
  "@fluidframework/protocol-definitions": "^3.0.0",
47
59
  "@fluidframework/server-services-client": "^2.0.1",
48
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
60
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
49
61
  "cross-fetch": "^3.1.5",
50
62
  "json-stringify-safe": "5.0.1",
51
63
  "socket.io-client": "^4.6.1",
@@ -53,13 +65,13 @@
53
65
  "uuid": "^9.0.0"
54
66
  },
55
67
  "devDependencies": {
56
- "@fluid-tools/build-cli": "^0.26.1",
68
+ "@fluid-tools/build-cli": "^0.28.0",
57
69
  "@fluidframework/build-common": "^2.0.3",
58
- "@fluidframework/build-tools": "^0.26.1",
59
- "@fluidframework/eslint-config-fluid": "^3.0.0",
60
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
61
- "@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@2.0.0-internal.7.2.1",
62
- "@microsoft/api-extractor": "^7.37.0",
70
+ "@fluidframework/build-tools": "^0.28.0",
71
+ "@fluidframework/eslint-config-fluid": "^3.1.0",
72
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
73
+ "@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@2.0.0-internal.7.2.0",
74
+ "@microsoft/api-extractor": "^7.38.3",
63
75
  "@types/mocha": "^9.1.1",
64
76
  "@types/nock": "^9.3.0",
65
77
  "@types/node": "^16.18.38",
@@ -78,6 +90,7 @@
78
90
  "prettier": "~3.0.3",
79
91
  "rimraf": "^4.4.0",
80
92
  "sinon": "^7.4.2",
93
+ "tsc-multi": "^1.1.0",
81
94
  "typescript": "~5.1.6"
82
95
  },
83
96
  "typeValidation": {
@@ -88,11 +101,11 @@
88
101
  "build:commonjs": "fluid-build . --task commonjs",
89
102
  "build:compile": "fluid-build . --task compile",
90
103
  "build:docs": "api-extractor run --local",
91
- "build:esnext": "tsc --project ./tsconfig.esnext.json",
104
+ "build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
92
105
  "build:genver": "gen-version",
93
- "build:test": "tsc --project ./src/test/tsconfig.json",
106
+ "build:test": "tsc-multi --config ./tsc-multi.test.json",
94
107
  "ci:build:docs": "api-extractor run",
95
- "clean": "rimraf --glob dist lib \"*.tsbuildinfo\" \"*.build.log\" _api-extractor-temp nyc",
108
+ "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
96
109
  "eslint": "eslint --format stylish src",
97
110
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
98
111
  "format": "npm run prettier:fix",
@@ -102,9 +115,9 @@
102
115
  "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
103
116
  "test": "npm run test:mocha",
104
117
  "test:coverage": "c8 npm test",
105
- "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup",
118
+ "test:mocha": "mocha --ignore \"dist/test/types/*\" --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup",
106
119
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
107
- "tsc": "tsc",
120
+ "tsc": "tsc-multi --config ../../../common/build/build-common/tsc-multi.cjs.json",
108
121
  "typetests:gen": "fluid-type-test-generator",
109
122
  "typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
110
123
  }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/routerlicious-driver";
9
- export const pkgVersion = "2.0.0-internal.7.2.2";
9
+ export const pkgVersion = "2.0.0-internal.7.3.0";
@@ -0,0 +1,4 @@
1
+ {
2
+ "targets": [{ "extname": ".cjs", "module": "CommonJS", "moduleResolution": "Node10" }],
3
+ "projects": ["./tsconfig.json", "./src/test/tsconfig.json"]
4
+ }
package/tsconfig.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
- "extends": "@fluidframework/build-common/ts-common-config.json",
2
+ "extends": [
3
+ "../../../common/build/build-common/tsconfig.base.json",
4
+ "../../../common/build/build-common/tsconfig.cjs.json",
5
+ ],
6
+ "include": ["src/**/*"],
3
7
  "exclude": ["src/test/**/*"],
4
8
  "compilerOptions": {
5
9
  "rootDir": "./src",
6
10
  "outDir": "./dist",
7
- "composite": true,
8
- "types": ["node"],
9
11
  },
10
- "include": ["src/**/*"],
11
12
  }
package/dist/cache.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAwD;AAOxD,qGAAqG;AACrG,MAAa,aAAa;IAGzB,YAAY,YAAqB;QAChC,IAAI,CAAC,KAAK,GAAG,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,qCAAiB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;IAC3F,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAW;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAQ;QACrC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;CACD;AAdD,sCAcC;AAED,yEAAyE;AACzE,MAAa,SAAS;IACd,KAAK,CAAC,GAAG,CAAC,GAAW;QAC3B,OAAO,SAAS,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAQ,IAAkB,CAAC;CACzD;AAND,8BAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { MapWithExpiration } from \"./mapWithExpiration\";\n\nexport interface ICache<T> {\n\tget(key: string): Promise<T | undefined>;\n\tput(key: string, value: T): Promise<void>;\n}\n\n/** A basic in-memory cache that optionally supports expiring entries after a period of inactivity */\nexport class InMemoryCache<T> implements ICache<T> {\n\tprivate readonly cache: Map<string, T>;\n\n\tconstructor(expirationMs?: number) {\n\t\tthis.cache = expirationMs !== undefined ? new MapWithExpiration(expirationMs) : new Map();\n\t}\n\n\tpublic async get(key: string): Promise<T | undefined> {\n\t\treturn this.cache.get(key);\n\t}\n\n\tpublic async put(key: string, value: T): Promise<void> {\n\t\tthis.cache.set(key, value);\n\t}\n}\n\n/** This \"cache\" does nothing on put, and get always returns undefined */\nexport class NullCache<T> implements ICache<T> {\n\tpublic async get(key: string): Promise<T | undefined> {\n\t\treturn undefined;\n\t}\n\n\tpublic async put(key: string, value: T): Promise<void> {}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAkE;AAClE,+EAAiF;AAEjF;;;;GAIG;AACH,SAAgB,gCAAgC,CAAC,OAAqB;IACrE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACvB,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAExC,QAAQ,aAAa,CAAC,IAAI,EAAE;YAC3B,KAAK,kCAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,gCAAgC,CAAC,aAAa,CAAC,CAAC;gBACpE,MAAM;aACN;YACD,KAAK,kCAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,aAAa,CAAC,OAAO;oBACpB,OAAO,aAAa,CAAC,OAAO,KAAK,QAAQ;wBACxC,CAAC,CAAC,aAAa,CAAC,OAAO;wBACvB,CAAC,CAAC,IAAA,iCAAkB,EAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBACtD,MAAM;aACN;YACD,KAAK,kCAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;aACnE;YACD,OAAO,CAAC,CAAC;gBACR,MAAM,IAAI,KAAK,CAAC,qBAAqB,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;aAC3D;SACD;KACD;IAED,OAAO,OAAO,CAAC;AAChB,CAAC;AA3BD,4EA2BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport { ISummaryTree, SummaryType } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Utility api to convert ISummaryTree to a summary tree where blob contents are only utf8 strings.\n * @param summary - Summary supplied by the runtime to upload.\n * @returns Modified summary tree where the blob contents could be utf8 string only.\n */\nexport function convertSummaryToCreateNewSummary(summary: ISummaryTree): ISummaryTree {\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tsummary.tree[key] = convertSummaryToCreateNewSummary(summaryObject);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tsummaryObject.content =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? summaryObject.content\n\t\t\t\t\t\t: Uint8ArrayToString(summaryObject.content, \"utf8\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"No handle should be present for first summary!!\");\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unknown tree type ${summaryObject.type}`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn summary;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultTokenProvider.js","sourceRoot":"","sources":["../src/defaultTokenProvider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AAEH,MAAa,oBAAoB;IAChC,YAA6B,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAErC,KAAK,CAAC,iBAAiB;QAC7B,OAAO;YACN,SAAS,EAAE,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;SACb,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,iBAAiB;QAC7B,OAAO;YACN,SAAS,EAAE,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;SACb,CAAC;IACH,CAAC;CACD;AAhBD,oDAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITokenProvider, ITokenResponse } from \"./tokens\";\n\n/**\n * Default token provider in case the host does not provide one. It simply caches the provided jwt and returns it back.\n */\n\nexport class DefaultTokenProvider implements ITokenProvider {\n\tconstructor(private readonly jwt: string) {}\n\n\tpublic async fetchOrdererToken(): Promise<ITokenResponse> {\n\t\treturn {\n\t\t\tfromCache: true,\n\t\t\tjwt: this.jwt,\n\t\t};\n\t}\n\n\tpublic async fetchStorageToken(): Promise<ITokenResponse> {\n\t\treturn {\n\t\t\tfromCache: true,\n\t\t\tjwt: this.jwt,\n\t\t};\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"deltaStorageService.js","sourceRoot":"","sources":["../src/deltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6DAA2E;AAQ3E,+DAKsC;AACtC,qEAAwF;AAIxF;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B;;GAEG;AACH,MAAa,2BAA2B;IACvC,YACkB,QAAgB,EAChB,EAAU,EACV,mBAAyC,EACzC,sBAA8C,EAC9C,MAA2B;QAJ3B,aAAQ,GAAR,QAAQ,CAAQ;QAChB,OAAE,GAAF,EAAE,CAAQ;QACV,wBAAmB,GAAnB,mBAAmB,CAAsB;QACzC,2BAAsB,GAAtB,sBAAsB,CAAwB;QAC9C,WAAM,GAAN,MAAM,CAAqB;QAGrC,eAAU,GAAuB,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC;IAF7E,CAAC;IAKJ,aAAa,CACZ,SAAiB,EACjB,OAA2B,EAC3B,WAAyB,EACzB,UAAoB,EACpB,WAAoB;QAEpB,IAAI,UAAU,EAAE;YACf,OAAO,iCAAkB,CAAC;SAC1B;QAED,IAAI,eAAe,GAAG,CAAC,CAAC;QACxB,IAAI,cAAc,GAAG,CAAC,CAAC;QACvB,MAAM,eAAe,GAAG,KAAK,EAC5B,IAAY,EACZ,EAAU,EACV,cAAoC,EACnC,EAAE;YACH,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU;gBACjC,CAAC,CAAC,MAAM,IAAA,2BAAY,EAClB,IAAI,CAAC,sBAAsB,EAC3B,IAAI,CAAC,UAAU,CACd;gBACH,CAAC,CAAC,EAAE,CAAC;YACN,IAAI,CAAC,UAAU,GAAG,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AAM,GAAG,GAAG,MAAM,kCAAgB,CAAC,cAAc,CAChD,IAAI,CAAC,MAAM,EACX;YACC,SAAS,EAAE,UAAU;YACrB,IAAI;YACJ,EAAE;SACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;YACf,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAChD,MAAM,GAAG,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACtC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAA8B,GAAG,EAAE;gBACxE,IAAI,EAAE,IAAI,GAAG,CAAC;gBACd,EAAE;aACF,CAAC,CAAC;YACH,KAAK,CAAC,GAAG,CAAC;gBACT,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM;gBAC/B,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;oBACvB,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc;oBACrD,eAAe,EACd,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,cAAc;iBAC9D,CAAC;gBACF,GAAG,QAAQ,CAAC,UAAU;gBACtB,GAAG,IAAA,wBAAU,EAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;aACpD,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,OAAO,CAAC;QACzB,CAAC,CACD,CAAC;QAEF,oGAAoG;QACpG,4GAA4G;QAC5G,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IAChD,CAAC;CACD;AA/CD,kDA+CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport { getW3CData, validateMessages } from \"@fluidframework/driver-base\";\nimport {\n\tIDeltaStorageService,\n\tIDocumentDeltaStorageService,\n\tIDeltasFetchResult,\n\tIStream,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\treadAndParse,\n\trequestOps,\n\temptyMessageStream,\n\tstreamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { DocumentStorageService } from \"./documentStorageService\";\nimport { RestWrapper } from \"./restWrapperBase\";\n\n/**\n * Maximum number of ops we can fetch at a time. This should be kept at 2k, as\n * server determines whether to try to fallback to long-term storage if the ops range requested is larger than\n * what they have locally available in short-term storage. So if we request 2k ops, they know it is not a\n * specific request and they don't fall to long term storage which takes time.\n * Please coordinate to AFR team if this value need to be changed.\n */\nconst MaxBatchDeltas = 2000;\n\n/**\n * Storage service limited to only being able to fetch documents for a specific document\n */\nexport class DocumentDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly deltaStorageService: IDeltaStorageService,\n\t\tprivate readonly documentStorageService: DocumentStorageService,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tprivate logtailSha: string | undefined = this.documentStorageService.logTailSha;\n\tprivate snapshotOps: ISequencedDocumentMessage[] | undefined;\n\n\tfetchMessages(\n\t\tfromTotal: number,\n\t\ttoTotal: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t\tfetchReason?: string,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\tif (cachedOnly) {\n\t\t\treturn emptyMessageStream;\n\t\t}\n\n\t\tlet opsFromSnapshot = 0;\n\t\tlet opsFromStorage = 0;\n\t\tconst requestCallback = async (\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\ttelemetryProps: ITelemetryProperties,\n\t\t) => {\n\t\t\tthis.snapshotOps = this.logtailSha\n\t\t\t\t? await readAndParse<ISequencedDocumentMessage[]>(\n\t\t\t\t\t\tthis.documentStorageService,\n\t\t\t\t\t\tthis.logtailSha,\n\t\t\t\t )\n\t\t\t\t: [];\n\t\t\tthis.logtailSha = undefined;\n\n\t\t\tif (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n\t\t\t\tconst messages = this.snapshotOps.filter(\n\t\t\t\t\t(op) => op.sequenceNumber >= from && op.sequenceNumber < to,\n\t\t\t\t);\n\t\t\t\tvalidateMessages(\"snapshotOps\", messages, from, this.logger, false /* strict */);\n\t\t\t\tif (messages.length > 0 && messages[0].sequenceNumber === from) {\n\t\t\t\t\tthis.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n\t\t\t\t\topsFromSnapshot += messages.length;\n\t\t\t\t\treturn { messages, partialResult: true };\n\t\t\t\t}\n\t\t\t\tthis.snapshotOps = undefined;\n\t\t\t}\n\n\t\t\tconst ops = await this.deltaStorageService.get(this.tenantId, this.id, from, to);\n\t\t\tvalidateMessages(\"storage\", ops.messages, from, this.logger, false /* strict */);\n\t\t\topsFromStorage += ops.messages.length;\n\t\t\treturn ops;\n\t\t};\n\n\t\tconst stream = requestOps(\n\t\t\tasync (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n\t\t\t\tconst result = await requestCallback(from, to, telemetryProps);\n\t\t\t\t// Catch all case, just in case\n\t\t\t\tvalidateMessages(\"catch all\", result.messages, from, this.logger);\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\t// Staging: starting with no concurrency, listening for feedback first.\n\t\t\t// In future releases we will switch to actual concurrency\n\t\t\t1, // concurrency\n\t\t\tfromTotal, // inclusive\n\t\t\ttoTotal, // exclusive\n\t\t\tMaxBatchDeltas,\n\t\t\tthis.logger,\n\t\t\tabortSignal,\n\t\t\tfetchReason,\n\t\t);\n\n\t\treturn streamObserver(stream, (result) => {\n\t\t\tif (result.done && opsFromSnapshot + opsFromStorage !== 0) {\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"CacheOpsRetrieved\",\n\t\t\t\t\topsFromSnapshot,\n\t\t\t\t\topsFromStorage,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Provides access to the underlying delta storage on the server for routerlicious driver.\n */\nexport class DeltaStorageService implements IDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly url: string,\n\t\tprivate readonly restWrapper: RestWrapper,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly getRestWrapper: () => Promise<RestWrapper> = async () => this.restWrapper,\n\t\tprivate readonly getDeltaStorageUrl: () => string = () => this.url,\n\t) {}\n\n\tpublic async get(\n\t\ttenantId: string,\n\t\tid: string,\n\t\tfrom: number, // inclusive\n\t\tto: number, // exclusive\n\t): Promise<IDeltasFetchResult> {\n\t\tconst ops = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"OpsFetch\",\n\t\t\t\tfrom,\n\t\t\t\tto,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst restWrapper = await this.getRestWrapper();\n\t\t\t\tconst url = this.getDeltaStorageUrl();\n\t\t\t\tconst response = await restWrapper.get<ISequencedDocumentMessage[]>(url, {\n\t\t\t\t\tfrom: from - 1,\n\t\t\t\t\tto,\n\t\t\t\t});\n\t\t\t\tevent.end({\n\t\t\t\t\tlength: response.content.length,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tfirstOpSeqNumber: response.content[0]?.sequenceNumber,\n\t\t\t\t\t\tlastOpSeqNumber:\n\t\t\t\t\t\t\tresponse.content[response.content.length - 1]?.sequenceNumber,\n\t\t\t\t\t}),\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t});\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\n\t\t// It is assumed that server always returns all the ops that it has in the range that was requested.\n\t\t// This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n\t\treturn { messages: ops, partialResult: false };\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"documentDeltaConnection.js","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6DAAsE;AAItE,6CAA4E;AAC5E,qDAA+D;AAE/D,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAElE;;GAEG;AACH,MAAa,2BAA4B,SAAQ,qCAAuB;IAChE,MAAM,CAAC,KAAK,CAAC,MAAM,CACzB,QAAgB,EAChB,EAAU,EACV,KAAoB,EACpB,EAA+B,EAC/B,MAAe,EACf,GAAW,EACX,MAA2B,EAC3B,SAAS,GAAG,KAAK,EACjB,0BAA0B,GAAG,IAAI;QAEjC,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,EAAE;YACtB,KAAK,EAAE;gBACN,UAAU,EAAE,EAAE;gBACd,QAAQ;aACR;YACD,YAAY,EAAE,KAAK;YACnB,8DAA8D;YAC9D,UAAU,EAAE,CAAC,WAAW,CAAC;YACzB,OAAO,EAAE,SAAS;SAClB,CAAC,CAAC;QAEH,MAAM,cAAc,GAAa;YAChC,MAAM;YACN,EAAE;YACF,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ;YACR,KAAK;YACL,QAAQ,EAAE,gBAAgB;YAC1B,cAAc,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,kBAAkB,2BAAa,EAAE,CAAC,CAAC,IAAI,CACnF,GAAG,CACH;SACD,CAAC;QAEF,MAAM,eAAe,GAAG,IAAI,2BAA2B,CACtD,MAAM,EACN,EAAE,EACF,MAAM,EACN,0BAA0B,CAC1B,CAAC;QAEF,MAAM,eAAe,CAAC,UAAU,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QAC5D,OAAO,eAAe,CAAC;IACxB,CAAC;IAED;;OAEG;IACO,iBAAiB,CAAC,OAAe,EAAE,KAAW,EAAE,QAAQ,GAAG,IAAI;QACxE,wDAAwD;QACxD,wGAAwG;QACxG,4CAA4C;QAC5C,OAAO,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,OAAO,KAAK,EAAE,OAAO,KAAK,QAAQ;YACrF,CAAC,CAAC,IAAA,uCAA0B,EAAC,KAAyB,EAAE,OAAO,CAAC;YAChE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;CACD;AAzDD,kEAyDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base\";\nimport { IAnyDriverError, IDocumentDeltaConnection } from \"@fluidframework/driver-definitions\";\nimport { IClient, IConnect } from \"@fluidframework/protocol-definitions\";\nimport type { io as SocketIOClientStatic } from \"socket.io-client\";\nimport { errorObjectFromSocketError, IR11sSocketError } from \"./errorUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\nconst protocolVersions = [\"^0.4.0\", \"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\n\n/**\n * Wrapper over the shared one for driver specific translation.\n */\nexport class R11sDocumentDeltaConnection extends DocumentDeltaConnection {\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tid: string,\n\t\ttoken: string | null,\n\t\tio: typeof SocketIOClientStatic,\n\t\tclient: IClient,\n\t\turl: string,\n\t\tlogger: ITelemetryLoggerExt,\n\t\ttimeoutMs = 20000,\n\t\tenableLongPollingDowngrade = true,\n\t): Promise<IDocumentDeltaConnection> {\n\t\tconst socket = io(url, {\n\t\t\tquery: {\n\t\t\t\tdocumentId: id,\n\t\t\t\ttenantId,\n\t\t\t},\n\t\t\treconnection: false,\n\t\t\t// Default to websocket connection, with long-polling disabled\n\t\t\ttransports: [\"websocket\"],\n\t\t\ttimeout: timeoutMs,\n\t\t});\n\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: protocolVersions,\n\t\t\trelayUserAgent: [client.details.environment, ` driverVersion:${driverVersion}`].join(\n\t\t\t\t\";\",\n\t\t\t),\n\t\t};\n\n\t\tconst deltaConnection = new R11sDocumentDeltaConnection(\n\t\t\tsocket,\n\t\t\tid,\n\t\t\tlogger,\n\t\t\tenableLongPollingDowngrade,\n\t\t);\n\n\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\treturn deltaConnection;\n\t}\n\n\t/**\n\t * Error raising for socket.io issues\n\t */\n\tprotected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {\n\t\t// Note: we suspect the incoming error object is either:\n\t\t// - a socketError: add it to the R11sError object for driver to be able to parse it and reason over it.\n\t\t// - anything else: let base class handle it\n\t\treturn canRetry && Number.isInteger(error?.code) && typeof error?.message === \"string\"\n\t\t\t? errorObjectFromSocketError(error as IR11sSocketError, handler)\n\t\t\t: super.createErrorObject(handler, error, canRetry);\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"documentService.js","sourceRoot":"","sources":["../src/documentService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,2DAAoD;AAEpD,2EAAsE;AACtE,+DAA+F;AAE/F,wEAAkC;AAClC,qEAAmG;AACnG,+DAAyF;AACzF,qEAAkE;AAClE,uEAAwE;AACxE,qEAAkE;AAElE,+CAIuB;AAIvB,qDAA+D;AAC/D,6CAA0C;AAC1C,2CAAwC;AAIxC;;;;;GAKG;AACH,MAAM,mCAAmC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,WAAW;AAElE;;;GAGG;AACH,4CAA4C;AAC5C,MAAa,eAAe;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BAAgB,GAAG,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC/D,IAAI,CAAC,YAAY,GAAG,gBAAgB,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC,SAAS,CAAC,eAAe,CAAC;QAClE,IAAI,CAAC,cAAc,GAAG,gBAAgB,CAAC,SAAS,CAAC,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC;IACpF,CAAC;IAED;;OAEG;IACK,iCAAiC;QACxC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE;YACzC,OAAO,KAAK,CAAC;SACb;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,oGAAoG;QACpG,6DAA6D;QAC7D,+FAA+F;QAC/F,8DAA8D;QAC9D,MAAM,8BAA8B,GACnC,GAAG,GAAG,IAAI,CAAC,gBAAgB,GAAG,mCAAmC,CAAC;QACnE,IAAI,8BAA8B,EAAE;YACnC,gDAAgD;YAChD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACnC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;YAC3B,IAAI,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;gBAClC,oEAAoE;gBACpE,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;SACH;QACD,OAAO,8BAA8B,CAAC;IACvC,CAAC;CACD;AArRD,0CAqRC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport * as api from \"@fluidframework/driver-definitions\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\nimport { RateLimiter, NetworkErrorBasic, canRetryOnError } from \"@fluidframework/driver-utils\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport io from \"socket.io-client\";\nimport { PerformanceEvent, wrapError, ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { DeltaStorageService, DocumentDeltaStorageService } from \"./deltaStorageService\";\nimport { DocumentStorageService } from \"./documentStorageService\";\nimport { R11sDocumentDeltaConnection } from \"./documentDeltaConnection\";\nimport { NullBlobStorageService } from \"./nullBlobStorageService\";\nimport { ITokenProvider } from \"./tokens\";\nimport {\n\tRouterliciousOrdererRestWrapper,\n\tRouterliciousStorageRestWrapper,\n\tTokenFetcher,\n} from \"./restWrapper\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ICache } from \"./cache\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { GitManager } from \"./gitManager\";\nimport { Historian } from \"./historian\";\nimport { RestWrapper } from \"./restWrapperBase\";\nimport { INormalizedWholeSnapshot } from \"./contracts\";\n\n/**\n * Amount of time between discoveries within which we don't need to rediscover on re-connect.\n * Currently, R11s defines session length at 10 minutes. To avoid any weird unknown edge-cases though,\n * we set the limit to 5 minutes here.\n * In the future, we likely want to retrieve this information from service's \"inactive session\" definition.\n */\nconst RediscoverAfterTimeSinceDiscoveryMs = 5 * 60000; // 5 minute\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients.\n */\n// eslint-disable-next-line import/namespace\nexport class DocumentService implements api.IDocumentService {\n\tprivate lastDiscoveredAt: number = Date.now();\n\tprivate discoverP: Promise<void> | undefined;\n\n\tprivate storageManager: GitManager | undefined;\n\tprivate noCacheStorageManager: GitManager | undefined;\n\n\tpublic get resolvedUrl() {\n\t\treturn this._resolvedUrl;\n\t}\n\n\tconstructor(\n\t\tprivate _resolvedUrl: api.IResolvedUrl,\n\t\tprotected ordererUrl: string,\n\t\tprivate deltaStorageUrl: string,\n\t\tprivate deltaStreamUrl: string,\n\t\tprivate storageUrl: string,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprotected tokenProvider: ITokenProvider,\n\t\tprotected tenantId: string,\n\t\tprotected documentId: string,\n\t\tprotected ordererRestWrapper: RouterliciousOrdererRestWrapper,\n\t\tprivate readonly documentStorageServicePolicies: api.IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike>,\n\t\tprivate readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot>,\n\t\tprivate readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion>,\n\t\tprivate readonly discoverFluidResolvedUrl: () => Promise<api.IResolvedUrl>,\n\t\tprivate storageRestWrapper: RouterliciousStorageRestWrapper,\n\t\tprivate readonly storageTokenFetcher: TokenFetcher,\n\t\tprivate readonly ordererTokenFetcher: TokenFetcher,\n\t) {}\n\n\tprivate documentStorageService: DocumentStorageService | undefined;\n\n\tpublic dispose() {}\n\n\t/**\n\t * Connects to a storage endpoint for snapshot service.\n\t *\n\t * @returns returns the document storage service for routerlicious driver.\n\t */\n\tpublic async connectToStorage(): Promise<api.IDocumentStorageService> {\n\t\tif (this.documentStorageService !== undefined) {\n\t\t\treturn this.documentStorageService;\n\t\t}\n\n\t\tif (this.storageUrl === undefined) {\n\t\t\treturn new NullBlobStorageService();\n\t\t}\n\n\t\tconst getStorageManager = async (disableCache?: boolean): Promise<GitManager> => {\n\t\t\tconst shouldUpdateDiscoveredSessionInfo = this.shouldUpdateDiscoveredSessionInfo();\n\t\t\tif (shouldUpdateDiscoveredSessionInfo) {\n\t\t\t\tawait this.refreshDiscovery();\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!this.storageManager ||\n\t\t\t\t!this.noCacheStorageManager ||\n\t\t\t\tshouldUpdateDiscoveredSessionInfo\n\t\t\t) {\n\t\t\t\tif (shouldUpdateDiscoveredSessionInfo) {\n\t\t\t\t\tconst rateLimiter = new RateLimiter(\n\t\t\t\t\t\tthis.driverPolicies.maxConcurrentStorageRequests,\n\t\t\t\t\t);\n\t\t\t\t\tthis.storageRestWrapper = await RouterliciousStorageRestWrapper.load(\n\t\t\t\t\t\tthis.tenantId,\n\t\t\t\t\t\tthis.storageTokenFetcher,\n\t\t\t\t\t\tthis.logger,\n\t\t\t\t\t\trateLimiter,\n\t\t\t\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\t\t\t\tthis.storageUrl,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst historian = new Historian(true, false, this.storageRestWrapper);\n\t\t\t\tthis.storageManager = new GitManager(historian);\n\t\t\t\tconst noCacheHistorian = new Historian(true, true, this.storageRestWrapper);\n\t\t\t\tthis.noCacheStorageManager = new GitManager(noCacheHistorian);\n\t\t\t}\n\n\t\t\treturn disableCache ? this.noCacheStorageManager : this.storageManager;\n\t\t};\n\t\t// Initialize storageManager and noCacheStorageManager\n\t\tconst storageManager = await getStorageManager();\n\t\tconst noCacheStorageManager = await getStorageManager(true);\n\t\tthis.documentStorageService = new DocumentStorageService(\n\t\t\tthis.documentId,\n\t\t\tstorageManager,\n\t\t\tthis.logger,\n\t\t\tthis.documentStorageServicePolicies,\n\t\t\tthis.driverPolicies,\n\t\t\tthis.blobCache,\n\t\t\tthis.wholeSnapshotTreeCache,\n\t\t\tthis.shreddedSummaryTreeCache,\n\t\t\tnoCacheStorageManager,\n\t\t\tgetStorageManager,\n\t\t);\n\t\treturn this.documentStorageService;\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint for getting ops between a range.\n\t *\n\t * @returns returns the document delta storage service for routerlicious driver.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<api.IDocumentDeltaStorageService> {\n\t\tawait this.connectToStorage();\n\t\tassert(!!this.documentStorageService, 0x0b1 /* \"Storage service not initialized\" */);\n\n\t\tconst getRestWrapper = async (): Promise<RestWrapper> => {\n\t\t\tconst shouldUpdateDiscoveredSessionInfo = this.shouldUpdateDiscoveredSessionInfo();\n\n\t\t\tif (shouldUpdateDiscoveredSessionInfo) {\n\t\t\t\tawait this.refreshDiscovery();\n\t\t\t\tconst rateLimiter = new RateLimiter(\n\t\t\t\t\tthis.driverPolicies.maxConcurrentOrdererRequests,\n\t\t\t\t);\n\t\t\t\tthis.ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\t\t\tthis.ordererTokenFetcher,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\trateLimiter,\n\t\t\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn this.ordererRestWrapper;\n\t\t};\n\t\tconst restWrapper = await getRestWrapper();\n\t\tconst deltaStorageService = new DeltaStorageService(\n\t\t\tthis.deltaStorageUrl,\n\t\t\trestWrapper,\n\t\t\tthis.logger,\n\t\t\tgetRestWrapper,\n\t\t\t() => this.deltaStorageUrl,\n\t\t);\n\t\treturn new DocumentDeltaStorageService(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tdeltaStorageService,\n\t\t\tthis.documentStorageService,\n\t\t\tthis.logger,\n\t\t);\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for routerlicious driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<api.IDocumentDeltaConnection> {\n\t\tconst connect = async (refreshToken?: boolean) => {\n\t\t\tlet ordererToken = await this.ordererRestWrapper.getToken();\n\t\t\tif (this.shouldUpdateDiscoveredSessionInfo()) {\n\t\t\t\tawait this.refreshDiscovery();\n\t\t\t}\n\n\t\t\tif (refreshToken) {\n\t\t\t\tordererToken = await PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.logger,\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"GetDeltaStreamToken\",\n\t\t\t\t\t\tdocId: this.documentId,\n\t\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t\trefreshToken,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tthis.tokenProvider\n\t\t\t\t\t\t\t.fetchOrdererToken(this.tenantId, this.documentId, refreshToken)\n\t\t\t\t\t\t\t.then(\n\t\t\t\t\t\t\t\t(newOrdererToken) => {\n\t\t\t\t\t\t\t\t\tthis.ordererRestWrapper.setToken(newOrdererToken);\n\t\t\t\t\t\t\t\t\treturn newOrdererToken;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\t\tconst tokenError = wrapError(\n\t\t\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\t\t\t\t\t\tnew NetworkErrorBasic(\n\t\t\t\t\t\t\t\t\t\t\t\t`The Host-provided token fetcher threw an error`,\n\t\t\t\t\t\t\t\t\t\t\t\tDriverErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t\t\t\t\tcanRetryOnError(error),\n\t\t\t\t\t\t\t\t\t\t\t\t{ errorMessage, driverVersion },\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tthrow tokenError;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"ConnectToDeltaStream\",\n\t\t\t\t\tdocId: this.documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\treturn R11sDocumentDeltaConnection.create(\n\t\t\t\t\t\tthis.tenantId,\n\t\t\t\t\t\tthis.documentId,\n\t\t\t\t\t\tordererToken.jwt,\n\t\t\t\t\t\tio,\n\t\t\t\t\t\tclient,\n\t\t\t\t\t\tthis.deltaStreamUrl,\n\t\t\t\t\t\tthis.logger,\n\t\t\t\t\t\tundefined /* timeoutMs */,\n\t\t\t\t\t\tthis.driverPolicies.enableLongPollingDowngrade,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\t// Attempt to establish connection.\n\t\t// Retry with new token on authorization error; otherwise, allow container layer to handle.\n\t\ttry {\n\t\t\tconst connection = await connect();\n\t\t\treturn connection;\n\t\t} catch (error: any) {\n\t\t\tif (error?.statusCode === 401) {\n\t\t\t\t// Fetch new token and retry once,\n\t\t\t\t// otherwise 401 will be bubbled up as non-retriable AuthorizationError.\n\t\t\t\treturn connect(true /* refreshToken */);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Re-discover session URLs if necessary.\n\t */\n\tprivate async refreshDiscovery(): Promise<void> {\n\t\tif (!this.discoverP) {\n\t\t\tthis.discoverP = PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"RefreshDiscovery\",\n\t\t\t\t},\n\t\t\t\tasync () => this.refreshDiscoveryCore(),\n\t\t\t);\n\t\t}\n\t\treturn this.discoverP;\n\t}\n\n\tprivate async refreshDiscoveryCore(): Promise<void> {\n\t\tconst fluidResolvedUrl = await this.discoverFluidResolvedUrl();\n\t\tthis._resolvedUrl = fluidResolvedUrl;\n\t\tthis.storageUrl = fluidResolvedUrl.endpoints.storageUrl;\n\t\tthis.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;\n\t\tthis.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;\n\t\tthis.deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || this.ordererUrl;\n\t}\n\n\t/**\n\t * Whether enough time has passed since last disconnect to warrant a new discovery call on reconnect.\n\t */\n\tprivate shouldUpdateDiscoveredSessionInfo(): boolean {\n\t\tif (!this.driverPolicies.enableDiscovery) {\n\t\t\treturn false;\n\t\t}\n\t\tconst now = Date.now();\n\t\t// When connection is disconnected, we cannot know if session has moved or document has been deleted\n\t\t// without re-doing discovery on the next attempt to connect.\n\t\t// Disconnect event is not so reliable in local testing. To ensure re-discovery when necessary,\n\t\t// re-discover if enough time has passed since last discovery.\n\t\tconst pastLastDiscoveryTimeThreshold =\n\t\t\tnow - this.lastDiscoveredAt > RediscoverAfterTimeSinceDiscoveryMs;\n\t\tif (pastLastDiscoveryTimeThreshold) {\n\t\t\t// Reset discover promise and refresh discovery.\n\t\t\tthis.lastDiscoveredAt = Date.now();\n\t\t\tthis.discoverP = undefined;\n\t\t\tthis.refreshDiscovery().catch(() => {\n\t\t\t\t// Undo discovery time set on failure, so that next check refreshes.\n\t\t\t\tthis.lastDiscoveredAt = 0;\n\t\t\t});\n\t\t}\n\t\treturn pastLastDiscoveryTimeThreshold;\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"documentServiceFactory.js","sourceRoot":"","sources":["../src/documentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,6DAAyD;AACzD,2EAO4C;AAG5C,+DAKsC;AACtC,qEAAsF;AACtF,mFAGgD;AAChD,uDAAoD;AAGpD,+CAKuB;AACvB,yCAAmG;AACnG,mCAA2D;AAC3D,qDAA+D;AAI/D,MAAM,8BAA8B,GAAe,SAAW,CAAC,CAAC,eAAe;AAE/E,MAAM,kCAAkC,GAAiC;IACxE,cAAc,EAAE,IAAI;IACpB,4BAA4B,EAAE,GAAG;IACjC,4BAA4B,EAAE,GAAG;IACjC,eAAe,EAAE,KAAK;IACtB,wBAAwB,EAAE,KAAK;IAC/B,cAAc,EAAE,IAAI;IACpB,4BAA4B,EAAE,IAAI;IAClC,0BAA0B,EAAE,IAAI;IAChC,oBAAoB,EAAE,KAAK;CAC3B,CAAC;AAEF;;;GAGG;AACH,MAAa,mCAAmC;IAM/C,YACkB,aAA6B,EAC9C,iBAAwD,EAAE;QADzC,kBAAa,GAAb,aAAa,CAAgB;QAJ9B,2BAAsB,GAAqC,IAA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B,CAAC,QAAQ;gBAC9B,CAAC,CAAC,wCAAmB,CAAC,SAAS;YAChC,sBAAsB,EAAE,8BAA8B;SACtD,CAAC;QAEF,OAAO,IAAI,iCAAe,CACzB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,OAAO,EACP,IAAI,CAAC,aAAa,EAClB,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,8BAA8B,EAC9B,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,sBAAsB,EAC3B,IAAI,CAAC,wBAAwB,EAC7B,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,CACnB,CAAC;IACH,CAAC;CACD;AAjTD,kFAiTC;AAED;;;;;;;;;;GAUG;AACH,MAAa,uBAAwB,SAAQ,KAAK;IACjD;IACC;;OAEG;IACc,UAAiB;QAElC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAFT,eAAU,GAAV,UAAU,CAAO;QAKnB,SAAI,GAAG,yBAAyB,CAAC;IAFjD,CAAC;IAID,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;IAC9B,CAAC;CACD;AAfD,0DAeC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { getW3CData } from \"@fluidframework/driver-base\";\nimport {\n\tFiveDaysMs,\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\tLoaderCachingPolicy,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n\tRateLimiter,\n} from \"@fluidframework/driver-utils\";\nimport { createChildLogger, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tISession,\n\tconvertSummaryTreeToWholeSummaryTree,\n} from \"@fluidframework/server-services-client\";\nimport { DocumentService } from \"./documentService\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ITokenProvider } from \"./tokens\";\nimport {\n\tRouterliciousOrdererRestWrapper,\n\tRouterliciousStorageRestWrapper,\n\ttoInstrumentedR11sOrdererTokenFetcher,\n\ttoInstrumentedR11sStorageTokenFetcher,\n} from \"./restWrapper\";\nimport { parseFluidUrl, replaceDocumentIdInPath, getDiscoveredFluidResolvedUrl } from \"./urlUtils\";\nimport { ICache, InMemoryCache, NullCache } from \"./cache\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { INormalizedWholeSnapshot } from \"./contracts\";\n\nconst maximumSnapshotCacheDurationMs: FiveDaysMs = 432_000_000; // 5 days in ms\n\nconst defaultRouterliciousDriverPolicies: IRouterliciousDriverPolicies = {\n\tenablePrefetch: true,\n\tmaxConcurrentStorageRequests: 100,\n\tmaxConcurrentOrdererRequests: 100,\n\tenableDiscovery: false,\n\tenableWholeSummaryUpload: false,\n\tenableRestLess: true,\n\tenableInternalSummaryCaching: true,\n\tenableLongPollingDowngrade: true,\n\tisEphemeralContainer: false,\n};\n\n/**\n * Factory for creating the routerlicious document service. Use this if you want to\n * use the routerlicious implementation.\n */\nexport class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {\n\tprivate readonly driverPolicies: IRouterliciousDriverPolicies;\n\tprivate readonly blobCache: ICache<ArrayBufferLike>;\n\tprivate readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot> = new NullCache();\n\tprivate readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion> = new NullCache();\n\n\tconstructor(\n\t\tprivate readonly tokenProvider: ITokenProvider,\n\t\tdriverPolicies: Partial<IRouterliciousDriverPolicies> = {},\n\t) {\n\t\t// Use the maximum allowed by the policy (IDocumentStorageServicePolicies.maximumCacheDurationMs set below)\n\t\tconst snapshotCacheExpiryMs: FiveDaysMs = maximumSnapshotCacheDurationMs;\n\n\t\tthis.driverPolicies = {\n\t\t\t...defaultRouterliciousDriverPolicies,\n\t\t\t...driverPolicies,\n\t\t};\n\t\tthis.blobCache = new InMemoryCache<ArrayBufferLike>();\n\t\tif (this.driverPolicies.enableInternalSummaryCaching) {\n\t\t\tif (this.driverPolicies.enableWholeSummaryUpload) {\n\t\t\t\tthis.wholeSnapshotTreeCache = new InMemoryCache<INormalizedWholeSnapshot>(\n\t\t\t\t\tsnapshotCacheExpiryMs,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.shreddedSummaryTreeCache = new InMemoryCache<ISnapshotTreeVersion>(\n\t\t\t\t\tsnapshotCacheExpiryMs,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createContainer}\n\t *\n\t * @throws {@link DocumentPostCreateError}\n\t * If an exception is thrown while invoking the provided {@link ITokenProvider.documentPostCreateCallback}.\n\t */\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (createNewSummary === undefined) {\n\t\t\tthrow new Error(\"Empty file summary creation isn't supported in this driver.\");\n\t\t}\n\t\tassert(!!resolvedUrl.endpoints.ordererUrl, 0x0b2 /* \"Missing orderer URL!\" */);\n\t\tlet parsedUrl = parseFluidUrl(resolvedUrl.url);\n\t\tif (!parsedUrl.pathname) {\n\t\t\tthrow new Error(\"Parsed url should contain tenant and doc Id!!\");\n\t\t}\n\t\tconst [, tenantId] = parsedUrl.pathname.split(\"/\");\n\n\t\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t\t}\n\t\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\t\tconst appSummary = createNewSummary.tree[\".app\"];\n\n\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\t\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\n\t\tconst logger2 = createChildLogger({ logger, namespace: \"RouterliciousDriver\" });\n\t\tconst ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(\n\t\t\ttenantId,\n\t\t\tundefined /* documentId */,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n\t\tconst ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\tordererTokenFetcher,\n\t\t\tlogger2,\n\t\t\trateLimiter,\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tresolvedUrl.endpoints.ordererUrl,\n\t\t);\n\n\t\tconst res = await PerformanceEvent.timedExecAsync(\n\t\t\tlogger2,\n\t\t\t{\n\t\t\t\teventName: \"CreateNew\",\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\tenableDiscovery: this.driverPolicies.enableDiscovery,\n\t\t\t\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\t\t\t\tisEphemeralContainer: this.driverPolicies.isEphemeralContainer,\n\t\t\t\t}),\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\t// @TODO: Remove returned \"string\" type when removing back-compat code\n\t\t\t\tconst postRes = (\n\t\t\t\t\tawait ordererRestWrapper.post<\n\t\t\t\t\t\t{ id: string; token?: string; session?: ISession } | string\n\t\t\t\t\t>(`/documents/${tenantId}`, {\n\t\t\t\t\t\tsummary: convertSummaryTreeToWholeSummaryTree(undefined, appSummary),\n\t\t\t\t\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\t\t\t\t\tvalues: quorumValues,\n\t\t\t\t\t\tenableDiscovery: this.driverPolicies.enableDiscovery,\n\t\t\t\t\t\tgenerateToken: this.tokenProvider.documentPostCreateCallback !== undefined,\n\t\t\t\t\t\tisEphemeralContainer: this.driverPolicies.isEphemeralContainer,\n\t\t\t\t\t\tenableAnyBinaryBlobOnFirstSummary: true,\n\t\t\t\t\t})\n\t\t\t\t).content;\n\n\t\t\t\tevent.end({\n\t\t\t\t\tdocId: typeof postRes === \"string\" ? postRes : postRes.id,\n\t\t\t\t});\n\t\t\t\treturn postRes;\n\t\t\t},\n\t\t);\n\n\t\t// For supporting backward compatibility, when the request has generateToken === true, it will return\n\t\t// an object instead of string\n\t\t// @TODO: Remove the logic when no need to support back-compat\n\n\t\tlet documentId: string;\n\t\tlet token: string | undefined;\n\t\tlet session: ISession | undefined;\n\t\tif (typeof res === \"string\") {\n\t\t\tdocumentId = res;\n\t\t} else {\n\t\t\tdocumentId = res.id;\n\t\t\ttoken = res.token;\n\t\t\tsession = this.driverPolicies.enableDiscovery ? res.session : undefined;\n\t\t}\n\t\tparsedUrl = parseFluidUrl(resolvedUrl.url);\n\n\t\t// @TODO: Remove token from the condition, checking the documentPostCreateCallback !== undefined\n\t\t// is sufficient to determine if the token will be undefined or not.\n\t\ttry {\n\t\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger2,\n\t\t\t\t{\n\t\t\t\t\teventName: \"DocPostCreateCallback\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\tif (token && this.tokenProvider.documentPostCreateCallback !== undefined) {\n\t\t\t\t\t\treturn this.tokenProvider.documentPostCreateCallback(documentId, token);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t} catch (error: any) {\n\t\t\tthrow new DocumentPostCreateError(error);\n\t\t}\n\n\t\tparsedUrl.set(\"pathname\", replaceDocumentIdInPath(parsedUrl.pathname, documentId));\n\t\tconst deltaStorageUrl = resolvedUrl.endpoints.deltaStorageUrl;\n\t\tif (!deltaStorageUrl) {\n\t\t\tthrow new Error(\n\t\t\t\t`All endpoints urls must be provided. [deltaStorageUrl:${deltaStorageUrl}]`,\n\t\t\t);\n\t\t}\n\t\tconst parsedDeltaStorageUrl = new URL(deltaStorageUrl);\n\t\tparsedDeltaStorageUrl.pathname = replaceDocumentIdInPath(\n\t\t\tparsedDeltaStorageUrl.pathname,\n\t\t\tdocumentId,\n\t\t);\n\n\t\treturn this.createDocumentService(\n\t\t\t{\n\t\t\t\t...resolvedUrl,\n\t\t\t\turl: parsedUrl.toString(),\n\t\t\t\tid: documentId,\n\t\t\t\tendpoints: {\n\t\t\t\t\t...resolvedUrl.endpoints,\n\t\t\t\t\tdeltaStorageUrl: parsedDeltaStorageUrl.toString(),\n\t\t\t\t},\n\t\t\t},\n\t\t\tlogger,\n\t\t\tclientIsSummarizer,\n\t\t\tsession,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createDocumentService}\n\t *\n\t * @returns Routerlicious document service.\n\t */\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t\tsession?: ISession,\n\t): Promise<IDocumentService> {\n\t\tconst parsedUrl = parseFluidUrl(resolvedUrl.url);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname.split(\"/\");\n\t\tif (!documentId || !tenantId) {\n\t\t\tthrow new Error(\n\t\t\t\t`Couldn't parse documentId and/or tenantId. [documentId:${documentId}][tenantId:${tenantId}]`,\n\t\t\t);\n\t\t}\n\t\tconst logger2 = createChildLogger({\n\t\t\tlogger,\n\t\t\tnamespace: \"RouterliciousDriver\",\n\t\t\tproperties: {\n\t\t\t\tall: { driverVersion },\n\t\t\t},\n\t\t});\n\n\t\tconst ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst storageTokenFetcher = toInstrumentedR11sStorageTokenFetcher(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst ordererTokenP = ordererTokenFetcher();\n\t\tconst storageTokenP = storageTokenFetcher();\n\n\t\tconst rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n\t\tconst ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\tordererTokenFetcher,\n\t\t\tlogger2,\n\t\t\trateLimiter,\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tundefined /* baseUrl */,\n\t\t\tordererTokenP,\n\t\t);\n\n\t\tconst discoverFluidResolvedUrl = async (): Promise<IResolvedUrl> => {\n\t\t\tif (!this.driverPolicies.enableDiscovery) {\n\t\t\t\treturn resolvedUrl;\n\t\t\t}\n\n\t\t\tconst discoveredSession = await PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger2,\n\t\t\t\t{\n\t\t\t\t\teventName: \"DiscoverSession\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\t// The service responds with the current document session associated with the container.\n\t\t\t\t\tconst response = await ordererRestWrapper.get<ISession>(\n\t\t\t\t\t\t`${resolvedUrl.endpoints.ordererUrl}/documents/${tenantId}/session/${documentId}`,\n\t\t\t\t\t);\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t\t});\n\t\t\t\t\treturn response.content;\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn getDiscoveredFluidResolvedUrl(resolvedUrl, discoveredSession);\n\t\t};\n\t\tconst fluidResolvedUrl: IResolvedUrl =\n\t\t\tsession !== undefined\n\t\t\t\t? getDiscoveredFluidResolvedUrl(resolvedUrl, session)\n\t\t\t\t: await discoverFluidResolvedUrl();\n\n\t\tconst storageUrl = fluidResolvedUrl.endpoints.storageUrl;\n\t\tconst ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;\n\t\tconst deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;\n\t\tconst deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || ordererUrl; // backward compatibility\n\t\tif (!ordererUrl || !deltaStorageUrl) {\n\t\t\tthrow new Error(\n\t\t\t\t`All endpoints urls must be provided. [ordererUrl:${ordererUrl}][deltaStorageUrl:${deltaStorageUrl}]`,\n\t\t\t);\n\t\t}\n\n\t\tconst storageRestWrapper = await RouterliciousStorageRestWrapper.load(\n\t\t\ttenantId,\n\t\t\tstorageTokenFetcher,\n\t\t\tlogger2,\n\t\t\tnew RateLimiter(this.driverPolicies.maxConcurrentStorageRequests),\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tstorageUrl,\n\t\t\tstorageTokenP,\n\t\t);\n\n\t\tconst documentStorageServicePolicies: IDocumentStorageServicePolicies = {\n\t\t\tcaching: this.driverPolicies.enablePrefetch\n\t\t\t\t? LoaderCachingPolicy.Prefetch\n\t\t\t\t: LoaderCachingPolicy.NoCaching,\n\t\t\tmaximumCacheDurationMs: maximumSnapshotCacheDurationMs,\n\t\t};\n\n\t\treturn new DocumentService(\n\t\t\tfluidResolvedUrl,\n\t\t\tordererUrl,\n\t\t\tdeltaStorageUrl,\n\t\t\tdeltaStreamUrl,\n\t\t\tstorageUrl,\n\t\t\tlogger2,\n\t\t\tthis.tokenProvider,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tordererRestWrapper,\n\t\t\tdocumentStorageServicePolicies,\n\t\t\tthis.driverPolicies,\n\t\t\tthis.blobCache,\n\t\t\tthis.wholeSnapshotTreeCache,\n\t\t\tthis.shreddedSummaryTreeCache,\n\t\t\tdiscoverFluidResolvedUrl,\n\t\t\tstorageRestWrapper,\n\t\t\tstorageTokenFetcher,\n\t\t\tordererTokenFetcher,\n\t\t);\n\t}\n}\n\n/**\n * Error returned by {@link RouterliciousDocumentServiceFactory.createContainer} when an error is thrown\n * in {@link ITokenProvider.documentPostCreateCallback}.\n * It is the consumer's responsibility to ensure that any state related to container creation is appropriately\n * cleaned up in the event of failure.\n * This includes the document itself, which will have been created by the time this error was thrown.\n *\n * @remarks TODO: examples of suggested actions for recovery.\n * - How would a user delete the created document?\n * - What would a retry pattern look like here?\n */\nexport class DocumentPostCreateError extends Error {\n\tpublic constructor(\n\t\t/**\n\t\t * Inner error being wrapped.\n\t\t */\n\t\tprivate readonly innerError: Error,\n\t) {\n\t\tsuper(innerError.message);\n\t}\n\n\tpublic readonly name = \"DocumentPostCreateError\";\n\n\tpublic get stack() {\n\t\treturn this.innerError.stack;\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"documentStorageService.js","sourceRoot":"","sources":["../src/documentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2EAI4C;AAE5C,+DAGsC;AAGtC,6FAA0F;AAC1F,mGAAgG;AAKhG,MAAa,sBAAuB,SAAQ,0CAA2B;IAGtE,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,kCAAkC,CAChD,EAAU,EACV,OAAmB,EACnB,MAA2B,EAC3B,QAAyC,EACzC,cAA6C,EAC7C,SAAmC,EACnC,iBAAoD,EACpD,wBAAuD,EACvD,iBAA8B,EAC9B,iBAAmE;QAEnE,MAAM,cAAc,GAAG,cAAc,EAAE,wBAAwB;YAC9D,CAAC,CAAC,IAAI,uEAAkC,CACtC,EAAE,EACF,OAAO,EACP,MAAM,EACN,QAAQ,EACR,cAAc,EACd,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,CAChB;YACH,CAAC,CAAC,IAAI,6EAAqC,CACzC,EAAE,EACF,OAAO,EACP,MAAM,EACN,QAAQ,EACR,cAAc,EACd,SAAS,EACT,wBAAwB,EACxB,iBAAiB,CAChB,CAAC;QACL,mGAAmG;QACnG,IACC,CAAC,cAAc,EAAE,wBAAwB;YACzC,QAAQ,CAAC,OAAO,KAAK,wCAAmB,CAAC,QAAQ,EAChD;YACD,OAAO,IAAI,6CAA8B,CAAC,cAAc,CAAC,CAAC;SAC1D;QACD,OAAO,cAAc,CAAC;IACvB,CAAC;IAED,YACiB,EAAU,EACnB,OAAmB,EAC1B,MAA2B,EAC3B,QAAyC,EACzC,cAA6C,EAC7C,SAAmC,EACnC,iBAAoD,EACpD,wBAAuD,EAChD,iBAA8B,EACrC,iBAAmE;QAEnE,KAAK,CACJ,sBAAsB,CAAC,kCAAkC,CACxD,EAAE,EACF,OAAO,EACP,MAAM,EACN,QAAQ,EACR,cAAc,EACd,SAAS,EACT,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,CACjB,CACD,CAAC;QAxBc,OAAE,GAAF,EAAE,CAAQ;QACnB,YAAO,GAAP,OAAO,CAAY;QAOnB,sBAAiB,GAAjB,iBAAiB,CAAa;QA3D9B,gBAAW,GAAuB,SAAS,CAAC;IA4EpD,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,OAAkB;QAC9C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACxE,IAAI,IAAI,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,WAAW;gBACf,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;SAC7E;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAvFD,wDAuFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tLoaderCachingPolicy,\n} from \"@fluidframework/driver-definitions\";\nimport { ISnapshotTree, IVersion } from \"@fluidframework/protocol-definitions\";\nimport {\n\tDocumentStorageServiceProxy,\n\tPrefetchDocumentStorageService,\n} from \"@fluidframework/driver-utils\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ICache } from \"./cache\";\nimport { WholeSummaryDocumentStorageService } from \"./wholeSummaryDocumentStorageService\";\nimport { ShreddedSummaryDocumentStorageService } from \"./shreddedSummaryDocumentStorageService\";\nimport { GitManager } from \"./gitManager\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { INormalizedWholeSnapshot } from \"./contracts\";\n\nexport class DocumentStorageService extends DocumentStorageServiceProxy {\n\tprivate _logTailSha: string | undefined = undefined;\n\n\tpublic get logTailSha(): string | undefined {\n\t\treturn this._logTailSha;\n\t}\n\n\tprivate static loadInternalDocumentStorageService(\n\t\tid: string,\n\t\tmanager: GitManager,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tpolicies: IDocumentStorageServicePolicies,\n\t\tdriverPolicies?: IRouterliciousDriverPolicies,\n\t\tblobCache?: ICache<ArrayBufferLike>,\n\t\tsnapshotTreeCache?: ICache<INormalizedWholeSnapshot>,\n\t\tshreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>,\n\t\tnoCacheGitManager?: GitManager,\n\t\tgetStorageManager?: (disableCache?: boolean) => Promise<GitManager>,\n\t): IDocumentStorageService {\n\t\tconst storageService = driverPolicies?.enableWholeSummaryUpload\n\t\t\t? new WholeSummaryDocumentStorageService(\n\t\t\t\t\tid,\n\t\t\t\t\tmanager,\n\t\t\t\t\tlogger,\n\t\t\t\t\tpolicies,\n\t\t\t\t\tdriverPolicies,\n\t\t\t\t\tblobCache,\n\t\t\t\t\tsnapshotTreeCache,\n\t\t\t\t\tnoCacheGitManager,\n\t\t\t\t\tgetStorageManager,\n\t\t\t )\n\t\t\t: new ShreddedSummaryDocumentStorageService(\n\t\t\t\t\tid,\n\t\t\t\t\tmanager,\n\t\t\t\t\tlogger,\n\t\t\t\t\tpolicies,\n\t\t\t\t\tdriverPolicies,\n\t\t\t\t\tblobCache,\n\t\t\t\t\tshreddedSummaryTreeCache,\n\t\t\t\t\tgetStorageManager,\n\t\t\t );\n\t\t// TODO: worth prefetching latest summary making version + snapshot call with WholeSummary storage?\n\t\tif (\n\t\t\t!driverPolicies?.enableWholeSummaryUpload &&\n\t\t\tpolicies.caching === LoaderCachingPolicy.Prefetch\n\t\t) {\n\t\t\treturn new PrefetchDocumentStorageService(storageService);\n\t\t}\n\t\treturn storageService;\n\t}\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic manager: GitManager,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tpolicies: IDocumentStorageServicePolicies,\n\t\tdriverPolicies?: IRouterliciousDriverPolicies,\n\t\tblobCache?: ICache<ArrayBufferLike>,\n\t\tsnapshotTreeCache?: ICache<INormalizedWholeSnapshot>,\n\t\tshreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>,\n\t\tpublic noCacheGitManager?: GitManager,\n\t\tgetStorageManager?: (disableCache?: boolean) => Promise<GitManager>,\n\t) {\n\t\tsuper(\n\t\t\tDocumentStorageService.loadInternalDocumentStorageService(\n\t\t\t\tid,\n\t\t\t\tmanager,\n\t\t\t\tlogger,\n\t\t\t\tpolicies,\n\t\t\t\tdriverPolicies,\n\t\t\t\tblobCache,\n\t\t\t\tsnapshotTreeCache,\n\t\t\t\tshreddedSummaryTreeCache,\n\t\t\t\tnoCacheGitManager,\n\t\t\t\tgetStorageManager,\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tconst tree = await this.internalStorageService.getSnapshotTree(version);\n\t\tif (tree !== null) {\n\t\t\tthis._logTailSha =\n\t\t\t\t\".logTail\" in tree.trees ? tree.trees[\".logTail\"].blobs.logTail : undefined;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YAAY,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM;QACP;YACC,MAAM,SAAS,GAAG,EAAE,QAAQ,EAAE,YAAY,KAAK,SAAS,EAAE,YAAY,EAAE,CAAC;YACzE,KAAK,GAAG,IAAA,wCAAyB,EAAC,YAAY,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YAClE,MAAM;KACP;IACD,KAAK,CAAC,sBAAsB,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,OAAO,KAAK,CAAC;AACd,CAAC;AApCD,wDAoCC;AAED,SAAgB,qBAAqB,CACpC,YAAoB,EACpB,UAAkB,EAClB,YAAqB;IAErB,MAAM,YAAY,GAAG,sBAAsB,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAEpF,+DAA+D;IAC/D,MAAM,YAAY,CAAC;AACpB,CAAC;AATD,sDASC;AAED;;GAEG;AACH,SAAgB,0BAA0B,CACzC,WAA6B,EAC7B,OAAe;IAEf,iDAAiD;IACjD,MAAM,OAAO,GAAG,sBAAsB,OAAO,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;IACzE,OAAO,sBAAsB,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;AACpF,CAAC;AAPD,gEAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tDriverError,\n\tIDriverErrorBase,\n\tDriverErrorTypes,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tNonRetryableError,\n\tGenericNetworkError,\n\tcreateGenericNetworkError,\n\tAuthorizationError,\n} from \"@fluidframework/driver-utils\";\nimport { IFluidErrorBase } from \"@fluidframework/telemetry-utils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * Routerlicious Error types\n * Different error types that may be thrown by the routerlicious driver\n */\nexport const RouterliciousErrorTypes = {\n\t// Inherit base driver error types\n\t...DriverErrorTypes,\n\n\t/**\n\t * SSL Certificate Error.\n\t */\n\tsslCertError: \"sslCertError\",\n} as const;\nexport type RouterliciousErrorTypes =\n\t(typeof RouterliciousErrorTypes)[keyof typeof RouterliciousErrorTypes];\n\n/**\n * Routerlicious Error types\n * Different error types that may be thrown by the routerlicious driver\n *\n * @deprecated Use {@link (RouterliciousErrorTypes:variable)} instead.\n */\nexport enum RouterliciousErrorType {\n\t/**\n\t * File not found, or file deleted during session\n\t */\n\tfileNotFoundOrAccessDeniedError = \"fileNotFoundOrAccessDeniedError\",\n\n\t/**\n\t * SSL Certificate Error.\n\t */\n\tsslCertError = \"sslCertError\",\n}\n\n/**\n * Interface for error responses for the WebSocket connection\n * Intended to be compatible with output from {@link NetworkError.toJSON}\n */\nexport interface IR11sSocketError {\n\t/**\n\t * An error code number for the error that occurred.\n\t * It will be a valid HTTP status code.\n\t */\n\tcode: number;\n\n\t/**\n\t * A message about the error that occurred for debugging / logging purposes.\n\t * This should not be displayed to the user directly.\n\t */\n\tmessage: string;\n\n\t/**\n\t * Optional Retry-After time in seconds.\n\t * The client should wait this many seconds before retrying its request.\n\t */\n\tretryAfter?: number;\n\n\t/**\n\t * Optional Retry-After time in milliseconds.\n\t * The client should wait this many milliseconds before retrying its request.\n\t */\n\tretryAfterMs?: number;\n}\n\nexport interface IR11sError extends Omit<IDriverErrorBase, \"errorType\"> {\n\treadonly errorType: RouterliciousErrorType;\n}\n\nexport type R11sError = DriverError | IR11sError;\n\nexport function createR11sNetworkError(\n\terrorMessage: string,\n\tstatusCode: number,\n\tretryAfterMs?: number,\n): IFluidErrorBase & R11sError {\n\tlet error: IFluidErrorBase & R11sError;\n\tconst props = { statusCode, driverVersion };\n\tswitch (statusCode) {\n\t\tcase 401:\n\t\t// The first 401 is manually retried in RouterliciousRestWrapper with a refreshed token,\n\t\t// so we treat repeat 401s the same as 403.\n\t\tcase 403:\n\t\t\terror = new AuthorizationError(errorMessage, undefined, undefined, props);\n\t\t\tbreak;\n\t\tcase 404:\n\t\t\tconst errorType = RouterliciousErrorType.fileNotFoundOrAccessDeniedError;\n\t\t\terror = new NonRetryableError(errorMessage, errorType, props);\n\t\t\tbreak;\n\t\tcase 429:\n\t\t\terror = createGenericNetworkError(\n\t\t\t\terrorMessage,\n\t\t\t\t{ canRetry: true, retryAfterMs },\n\t\t\t\tprops,\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 500:\n\t\tcase 502:\n\t\t\terror = new GenericNetworkError(errorMessage, true, props);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tconst retryInfo = { canRetry: retryAfterMs !== undefined, retryAfterMs };\n\t\t\terror = createGenericNetworkError(errorMessage, retryInfo, props);\n\t\t\tbreak;\n\t}\n\terror.addTelemetryProperties({ endpointReached: true });\n\treturn error;\n}\n\nexport function throwR11sNetworkError(\n\terrorMessage: string,\n\tstatusCode: number,\n\tretryAfterMs?: number,\n): never {\n\tconst networkError = createR11sNetworkError(errorMessage, statusCode, retryAfterMs);\n\n\t// eslint-disable-next-line @typescript-eslint/no-throw-literal\n\tthrow networkError;\n}\n\n/**\n * Returns network error based on error object from R11s socket (IR11sSocketError)\n */\nexport function errorObjectFromSocketError(\n\tsocketError: IR11sSocketError,\n\thandler: string,\n): R11sError {\n\t// pre-0.58 error message prefix: R11sSocketError\n\tconst message = `R11s socket error (${handler}): ${socketError.message}`;\n\treturn createR11sNetworkError(message, socketError.code, socketError.retryAfterMs);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"gitManager.js","sourceRoot":"","sources":["../src/gitManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAWH,MAAa,UAAU;IACtB,YAA6B,SAAqB;QAArB,cAAS,GAAT,SAAS,CAAY;IAAG,CAAC;IAEtD;;OAEG;IACI,KAAK,CAAC,UAAU,CACtB,GAAW,EACX,KAAa;QAEb,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,SAAS,GAAG,IAAI;QAClD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,GAAW;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAEM,KAAK,CAAC,UAAU,CACtB,OAAe,EACf,QAA4B;QAE5B,MAAM,IAAI,GAAgC;YACzC,OAAO;YACP,QAAQ;SACR,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAEM,KAAK,CAAC,aAAa,CACzB,MAAmC;QAEnC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAChD,OAAO,KAAK,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,aAAa,CACzB,OAA6B,EAC7B,UAAmB,KAAK;QAExB,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,GAAW;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;CACD;AApDD,gCAoDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as resources from \"@fluidframework/gitresources\";\nimport {\n\tIWholeSummaryPayload,\n\tIWriteSummaryResponse,\n} from \"@fluidframework/server-services-client\";\nimport { IGitManager, IHistorian } from \"./storageContracts\";\nimport { IR11sResponse } from \"./restWrapper\";\nimport { IWholeFlatSnapshot } from \"./contracts\";\n\nexport class GitManager implements IGitManager {\n\tconstructor(private readonly historian: IHistorian) {}\n\n\t/**\n\t * Reads the object with the given ID. We defer to the client implementation to do the actual read.\n\t */\n\tpublic async getCommits(\n\t\tsha: string,\n\t\tcount: number,\n\t): Promise<IR11sResponse<resources.ICommitDetails[]>> {\n\t\treturn this.historian.getCommits(sha, count);\n\t}\n\n\t/**\n\t * Reads the object with the given ID. We defer to the client implementation to do the actual read.\n\t */\n\tpublic async getTree(root: string, recursive = true): Promise<IR11sResponse<resources.ITree>> {\n\t\treturn this.historian.getTree(root, recursive);\n\t}\n\n\tpublic async getBlob(sha: string): Promise<IR11sResponse<resources.IBlob>> {\n\t\treturn this.historian.getBlob(sha);\n\t}\n\n\tpublic async createBlob(\n\t\tcontent: string,\n\t\tencoding: \"utf-8\" | \"base64\",\n\t): Promise<IR11sResponse<resources.ICreateBlobResponse>> {\n\t\tconst blob: resources.ICreateBlobParams = {\n\t\t\tcontent,\n\t\t\tencoding,\n\t\t};\n\t\treturn this.historian.createBlob(blob);\n\t}\n\n\tpublic async createGitTree(\n\t\tparams: resources.ICreateTreeParams,\n\t): Promise<IR11sResponse<resources.ITree>> {\n\t\tconst treeP = this.historian.createTree(params);\n\t\treturn treeP;\n\t}\n\n\tpublic async createSummary(\n\t\tsummary: IWholeSummaryPayload,\n\t\tinitial: boolean = false,\n\t): Promise<IR11sResponse<IWriteSummaryResponse>> {\n\t\treturn this.historian.createSummary(summary, initial);\n\t}\n\n\tpublic async getSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>> {\n\t\treturn this.historian.getSnapshot(sha);\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"historian.js","sourceRoot":"","sources":["../src/historian.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAgE;AAgBzD,MAAM,oCAAoC,GAAG,CAAC,WAAyB,EAAU,EAAE,CACzF,SAAS,IAAA,+BAAgB,EAAC,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC;AAD/D,Q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License.\n */\n\nimport { fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport * as git from \"@fluidframework/gitresources\";\nimport {\n\tIWholeSummaryPayload,\n\tIWriteSummaryResponse,\n} from \"@fluidframework/server-services-client\";\nimport { QueryStringType, RestWrapper } from \"./restWrapperBase\";\nimport { IR11sResponse } from \"./restWrapper\";\nimport { IHistorian } from \"./storageContracts\";\nimport { IWholeFlatSnapshot } from \"./contracts\";\n\nexport interface ICredentials {\n\tuser: string;\n\tpassword: string;\n}\n\nexport const getAuthorizationTokenFromCredentials = (credentials: ICredentials): string =>\n\t`Basic ${fromUtf8ToBase64(`${credentials.user}:${credentials.password}`)}`;\n\n/**\n * Implementation of the IHistorian interface that calls out to a REST interface\n */\nexport class Historian implements IHistorian {\n\tprivate readonly defaultQueryString: QueryStringType = {};\n\tprivate readonly cacheBust: boolean;\n\n\tconstructor(\n\t\tprivate readonly historianApi: boolean,\n\t\tdisableCache: boolean,\n\t\tprivate readonly restWrapper: RestWrapper,\n\t) {\n\t\tif (disableCache && this.historianApi) {\n\t\t\tthis.defaultQueryString.disableCache = disableCache;\n\t\t\tthis.cacheBust = false;\n\t\t} else {\n\t\t\tthis.cacheBust = disableCache;\n\t\t}\n\t}\n\n\tpublic async getBlob(sha: string): Promise<IR11sResponse<git.IBlob>> {\n\t\treturn this.restWrapper.get<git.IBlob>(\n\t\t\t`/git/blobs/${encodeURIComponent(sha)}`,\n\t\t\tthis.getQueryString(),\n\t\t);\n\t}\n\n\tpublic async createBlob(\n\t\tblob: git.ICreateBlobParams,\n\t): Promise<IR11sResponse<git.ICreateBlobResponse>> {\n\t\treturn this.restWrapper.post<git.ICreateBlobResponse>(\n\t\t\t`/git/blobs`,\n\t\t\tblob,\n\t\t\tthis.getQueryString(),\n\t\t);\n\t}\n\n\tpublic async getCommits(\n\t\tsha: string,\n\t\tcount: number,\n\t): Promise<IR11sResponse<git.ICommitDetails[]>> {\n\t\treturn this.restWrapper\n\t\t\t.get<git.ICommitDetails[]>(`/commits`, this.getQueryString({ count, sha }))\n\t\t\t.catch(async (error) =>\n\t\t\t\terror.statusCode === 400 || error.statusCode === 404\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tcontent: [],\n\t\t\t\t\t\t\theaders: new Map(),\n\t\t\t\t\t\t\tpropsToLog: {},\n\t\t\t\t\t\t\trequestUrl: \"\",\n\t\t\t\t\t }\n\t\t\t\t\t: Promise.reject<IR11sResponse<git.ICommitDetails[]>>(error),\n\t\t\t);\n\t}\n\n\tpublic async createTree(tree: git.ICreateTreeParams): Promise<IR11sResponse<git.ITree>> {\n\t\treturn this.restWrapper.post<git.ITree>(`/git/trees`, tree, this.getQueryString());\n\t}\n\n\tpublic async getTree(sha: string, recursive: boolean): Promise<IR11sResponse<git.ITree>> {\n\t\treturn this.restWrapper.get<git.ITree>(\n\t\t\t`/git/trees/${encodeURIComponent(sha)}`,\n\t\t\tthis.getQueryString({ recursive: recursive ? 1 : 0 }),\n\t\t);\n\t}\n\tpublic async createSummary(\n\t\tsummary: IWholeSummaryPayload,\n\t\tinitial?: boolean,\n\t): Promise<IR11sResponse<IWriteSummaryResponse>> {\n\t\treturn this.restWrapper.post<IWriteSummaryResponse>(\n\t\t\t`/git/summaries`,\n\t\t\tsummary,\n\t\t\tthis.getQueryString(initial !== undefined ? { initial } : undefined),\n\t\t);\n\t}\n\n\tpublic async getSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>> {\n\t\treturn this.restWrapper.get<IWholeFlatSnapshot>(\n\t\t\t`/git/summaries/${sha}`,\n\t\t\tthis.getQueryString(),\n\t\t);\n\t}\n\n\tprivate getQueryString(queryString?: QueryStringType): QueryStringType {\n\t\tif (this.cacheBust) {\n\t\t\treturn {\n\t\t\t\tcacheBust: Date.now(),\n\t\t\t\t...this.defaultQueryString,\n\t\t\t\t...queryString,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...this.defaultQueryString,\n\t\t\t...queryString,\n\t\t};\n\t}\n}\n"]}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,SAAS;AACT,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAG7B,SAAS;AACT,2CAA+E;AAAtE,oHAAA,sBAAsB,OAAA;AAAE,qHAAA,uBAAuB,OAAA;AAExD,UAAU;AACV,mEAGkC;AAFjC,iIAAA,uBAAuB,OAAA;AACvB,6IAAA,mCAAmC,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// Tokens\nexport { DefaultTokenProvider } from \"./defaultTokenProvider\";\nexport { ITokenProvider, ITokenResponse, ITokenService } from \"./tokens\";\n\n// Errors\nexport { RouterliciousErrorType, RouterliciousErrorTypes } from \"./errorUtils\";\n\n// Factory\nexport {\n\tDocumentPostCreateError,\n\tRouterliciousDocumentServiceFactory,\n} from \"./documentServiceFactory\";\n\n// Configuration\nexport { IRouterliciousDriverPolicies } from \"./policies\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mapWithExpiration.js","sourceRoot":"","sources":["../src/mapWithExpiration.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AAEpD;;;GAGG;AACH,MAAa,iBAA4C,SAAQ,GAAiB;IAIjF,YAA6B,QAAgB;QAC5C,KAAK,EAAE,CAAC;QADoB,aAAQ,GAAR,QAAQ,CAAQ;QAH7C,2EAA2E;QAC1D,uBAAkB,GAAG,IAAI,GAAG,EAAgB,CAAC;IAI9D,CAAC;IAEO,OAAO,CAAC,GAAS;QACxB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;IACxD,CAAC;IAED;;;OAGG;IACK,WAAW,CAAC,GAAS,EAAE,UAAmB,KAAK;QACtD,MAAM,WAAW,GAAG,IA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AAC;IAED,OAAO;QACN,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;CACD;AAhHD,8CAgHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\n\n/**\n * An extension of Map that expires (deletes) entries after a period of inactivity.\n * The policy is based on the last time a key was written to.\n */\nexport class MapWithExpiration<TKey = any, TValue = any> extends Map<TKey, TValue> {\n\t/** Timestamps (as epoch ms numbers) of when each key was last refreshed */\n\tprivate readonly lastRefreshedTimes = new Map<TKey, number>();\n\n\tconstructor(private readonly expiryMs: number) {\n\t\tsuper();\n\t}\n\n\tprivate refresh(key: TKey): void {\n\t\tthis.lastRefreshedTimes.set(key, new Date().valueOf());\n\t}\n\n\t/**\n\t * Returns true if the key is present and expired, false if it's not expired, and undefined if it's not found\n\t * If cleanUp is passed as true, then delete any expired entry before returning.\n\t */\n\tprivate checkExpiry(key: TKey, cleanUp: boolean = false): boolean | undefined {\n\t\tconst refreshTime = this.lastRefreshedTimes.get(key);\n\t\tassert(\n\t\t\t(refreshTime !== undefined) === super.has(key),\n\t\t\t0x50c /* freshness map out of sync */,\n\t\t);\n\n\t\tif (refreshTime === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst expired = new Date().valueOf() - refreshTime >= this.expiryMs;\n\t\tif (expired && cleanUp) {\n\t\t\tthis.delete(key);\n\t\t}\n\t\treturn expired;\n\t}\n\n\tprivate clearExpiredEntries() {\n\t\t// forEach clears out any expired entries\n\t\tthis.forEach(() => {});\n\t}\n\n\tget size(): number {\n\t\tthis.clearExpiredEntries();\n\t\treturn super.size;\n\t}\n\n\thas(key: TKey): boolean {\n\t\tthis.checkExpiry(key, true /* cleanUp */);\n\t\treturn super.has(key);\n\t}\n\n\tget(key: TKey): TValue | undefined {\n\t\tthis.checkExpiry(key, true /* cleanUp */);\n\t\treturn super.get(key);\n\t}\n\n\tset(key: TKey, value: TValue): this {\n\t\t// Sliding window expiration policy (on write)\n\t\tthis.refresh(key);\n\t\treturn super.set(key, value);\n\t}\n\n\tdelete(key: TKey): boolean {\n\t\tthis.lastRefreshedTimes.delete(key);\n\t\treturn super.delete(key);\n\t}\n\n\tclear(): void {\n\t\tthis.lastRefreshedTimes.clear();\n\t\tsuper.clear();\n\t}\n\n\tforEach(\n\t\tcallbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void,\n\t\tthisArg?: any,\n\t): void {\n\t\tconst expiredKeys: TKey[] = [];\n\t\tsuper.forEach(\n\t\t\t(v, k, m) => {\n\t\t\t\tif (this.checkExpiry(k) === true) {\n\t\t\t\t\texpiredKeys.push(k);\n\t\t\t\t} else {\n\t\t\t\t\tcallbackfn.bind(thisArg)(v, k, m);\n\t\t\t\t}\n\t\t\t},\n\t\t\t// Note we don't pass thisArg here, since we bind it directly to callbackFn and don't need it otherwise\n\t\t);\n\n\t\t// Clean up keys we know are expired now that we're done iterating\n\t\texpiredKeys.forEach((key: TKey) => {\n\t\t\tthis.delete(key);\n\t\t});\n\t}\n\n\tentries(): IterableIterator<[TKey, TValue]> {\n\t\tthis.clearExpiredEntries();\n\t\treturn super.entries();\n\t}\n\tkeys(): IterableIterator<TKey> {\n\t\tthis.clearExpiredEntries();\n\t\treturn super.keys();\n\t}\n\tvalues(): IterableIterator<TValue> {\n\t\tthis.clearExpiredEntries();\n\t\treturn super.values();\n\t}\n\t[Symbol.iterator](): IterableIterator<[TKey, TValue]> {\n\t\tthis.clearExpiredEntries();\n\t\treturn super[Symbol.iterator]();\n\t}\n\n\tvalueOf() {\n\t\tthis.clearExpiredEntries();\n\t\treturn super.valueOf();\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"nullBlobStorageService.js","sourceRoot":"","sources":["../src/nullBlobStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH;;;GAGG;AACH,MAAa,sBAAsB;IAClC,IAAW,aAAa;QACvB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACtC,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,OAAsB;QAClD,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxE,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,SAAwB,EAAE,KAAa;QAC/D,OAAO,EAAE,CAAC;IACX,CAAC;IAEM,KAAK,CAAC,wBAAwB,CACpC,OAAyB,EACzB,OAAwB;QAExB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACtC,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAA0B;QACtD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACtC,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC1D,CAAC;IACM,KAAK,CAAC,QAAQ,CAAC,MAAc;QACnC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACxD,CAAC;CACD;AA9BD,wDA8BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport * as api from \"@fluidframework/protocol-definitions\";\n\n/**\n * Document access to underlying storage. It is default implementation of a storage service.\n * Does not read/write anything.\n */\nexport class NullBlobStorageService implements IDocumentStorageService {\n\tpublic get repositoryUrl(): string {\n\t\tthrow new Error(\"Invalid operation\");\n\t}\n\n\tpublic async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n\t\treturn version ? Promise.reject(new Error(\"Invalid operation\")) : null;\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {\n\t\treturn [];\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: api.ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tthrow new Error(\"Invalid operation\");\n\t}\n\n\tpublic async downloadSummary(handle: api.ISummaryHandle): Promise<api.ISummaryTree> {\n\t\tthrow new Error(\"Invalid operation\");\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse> {\n\t\tthrow new Error(\"Null blob storage can not create blob\");\n\t}\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tthrow new Error(\"Null blob storage can not read blob\");\n\t}\n}\n"]}