@fluidframework/driver-utils 2.0.0-dev.5.2.0.169897 → 2.0.0-dev.6.4.0.191258

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 (198) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +4 -3
  3. package/dist/adapters/compression/compressionTypes.d.ts +17 -0
  4. package/dist/adapters/compression/compressionTypes.d.ts.map +1 -0
  5. package/dist/adapters/compression/compressionTypes.js +17 -0
  6. package/dist/adapters/compression/compressionTypes.js.map +1 -0
  7. package/dist/adapters/compression/documentServiceCompressionAdapter.d.ts +13 -0
  8. package/dist/adapters/compression/documentServiceCompressionAdapter.d.ts.map +1 -0
  9. package/dist/adapters/compression/documentServiceCompressionAdapter.js +23 -0
  10. package/dist/adapters/compression/documentServiceCompressionAdapter.js.map +1 -0
  11. package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.d.ts +16 -0
  12. package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.d.ts.map +1 -0
  13. package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.js +39 -0
  14. package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.js.map +1 -0
  15. package/dist/adapters/compression/index.d.ts +8 -0
  16. package/dist/adapters/compression/index.d.ts.map +1 -0
  17. package/dist/adapters/compression/index.js +15 -0
  18. package/dist/adapters/compression/index.js.map +1 -0
  19. package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts +161 -0
  20. package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -0
  21. package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +366 -0
  22. package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -0
  23. package/dist/adapters/compression/summaryblob/index.d.ts +6 -0
  24. package/dist/adapters/compression/summaryblob/index.d.ts.map +1 -0
  25. package/dist/adapters/compression/summaryblob/index.js +11 -0
  26. package/dist/adapters/compression/summaryblob/index.js.map +1 -0
  27. package/dist/adapters/index.d.ts +7 -0
  28. package/dist/adapters/index.d.ts.map +1 -0
  29. package/dist/adapters/index.js +14 -0
  30. package/dist/adapters/index.js.map +1 -0
  31. package/dist/adapters/predefinedAdapters.d.ts +20 -0
  32. package/dist/adapters/predefinedAdapters.d.ts.map +1 -0
  33. package/dist/adapters/predefinedAdapters.js +51 -0
  34. package/dist/adapters/predefinedAdapters.js.map +1 -0
  35. package/dist/buildSnapshotTree.d.ts.map +1 -1
  36. package/dist/buildSnapshotTree.js +5 -4
  37. package/dist/buildSnapshotTree.js.map +1 -1
  38. package/dist/documentServiceFactoryProxy.d.ts +19 -0
  39. package/dist/documentServiceFactoryProxy.d.ts.map +1 -0
  40. package/dist/documentServiceFactoryProxy.js +27 -0
  41. package/dist/documentServiceFactoryProxy.js.map +1 -0
  42. package/dist/documentServiceProxy.d.ts +21 -0
  43. package/dist/documentServiceProxy.d.ts.map +1 -0
  44. package/dist/documentServiceProxy.js +36 -0
  45. package/dist/documentServiceProxy.js.map +1 -0
  46. package/dist/documentStorageServiceProxy.js +1 -2
  47. package/dist/documentStorageServiceProxy.js.map +1 -1
  48. package/dist/error.d.ts.map +1 -1
  49. package/dist/error.js +2 -0
  50. package/dist/error.js.map +1 -1
  51. package/dist/index.d.ts +3 -2
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +5 -2
  54. package/dist/index.js.map +1 -1
  55. package/dist/insecureUrlResolver.js +4 -6
  56. package/dist/insecureUrlResolver.js.map +1 -1
  57. package/dist/network.d.ts +2 -2
  58. package/dist/network.d.ts.map +1 -1
  59. package/dist/network.js +11 -5
  60. package/dist/network.js.map +1 -1
  61. package/dist/networkUtils.d.ts +1 -1
  62. package/dist/networkUtils.d.ts.map +1 -1
  63. package/dist/networkUtils.js +3 -4
  64. package/dist/networkUtils.js.map +1 -1
  65. package/dist/packageVersion.d.ts +1 -1
  66. package/dist/packageVersion.js +1 -1
  67. package/dist/packageVersion.js.map +1 -1
  68. package/dist/parallelRequests.d.ts +3 -3
  69. package/dist/parallelRequests.d.ts.map +1 -1
  70. package/dist/parallelRequests.js +67 -48
  71. package/dist/parallelRequests.js.map +1 -1
  72. package/dist/prefetchDocumentStorageService.js +1 -1
  73. package/dist/prefetchDocumentStorageService.js.map +1 -1
  74. package/dist/rateLimiter.js +2 -2
  75. package/dist/rateLimiter.js.map +1 -1
  76. package/dist/readAndParse.js +2 -2
  77. package/dist/readAndParse.js.map +1 -1
  78. package/dist/runWithRetry.d.ts +8 -0
  79. package/dist/runWithRetry.d.ts.map +1 -1
  80. package/dist/runWithRetry.js +37 -13
  81. package/dist/runWithRetry.js.map +1 -1
  82. package/dist/summaryForCreateNew.d.ts +0 -9
  83. package/dist/summaryForCreateNew.d.ts.map +1 -1
  84. package/dist/summaryForCreateNew.js +4 -27
  85. package/dist/summaryForCreateNew.js.map +1 -1
  86. package/dist/treeConversions.d.ts.map +1 -1
  87. package/dist/treeConversions.js +4 -3
  88. package/dist/treeConversions.js.map +1 -1
  89. package/lib/adapters/compression/compressionTypes.d.ts +17 -0
  90. package/lib/adapters/compression/compressionTypes.d.ts.map +1 -0
  91. package/lib/adapters/compression/compressionTypes.js +14 -0
  92. package/lib/adapters/compression/compressionTypes.js.map +1 -0
  93. package/lib/adapters/compression/documentServiceCompressionAdapter.d.ts +13 -0
  94. package/lib/adapters/compression/documentServiceCompressionAdapter.d.ts.map +1 -0
  95. package/lib/adapters/compression/documentServiceCompressionAdapter.js +19 -0
  96. package/lib/adapters/compression/documentServiceCompressionAdapter.js.map +1 -0
  97. package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.d.ts +16 -0
  98. package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.d.ts.map +1 -0
  99. package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.js +35 -0
  100. package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.js.map +1 -0
  101. package/lib/adapters/compression/index.d.ts +8 -0
  102. package/lib/adapters/compression/index.d.ts.map +1 -0
  103. package/lib/adapters/compression/index.js +8 -0
  104. package/lib/adapters/compression/index.js.map +1 -0
  105. package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts +161 -0
  106. package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -0
  107. package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +362 -0
  108. package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -0
  109. package/lib/adapters/compression/summaryblob/index.d.ts +6 -0
  110. package/lib/adapters/compression/summaryblob/index.d.ts.map +1 -0
  111. package/lib/adapters/compression/summaryblob/index.js +6 -0
  112. package/lib/adapters/compression/summaryblob/index.js.map +1 -0
  113. package/lib/adapters/index.d.ts +7 -0
  114. package/lib/adapters/index.d.ts.map +1 -0
  115. package/lib/adapters/index.js +7 -0
  116. package/lib/adapters/index.js.map +1 -0
  117. package/lib/adapters/predefinedAdapters.d.ts +20 -0
  118. package/lib/adapters/predefinedAdapters.d.ts.map +1 -0
  119. package/lib/adapters/predefinedAdapters.js +46 -0
  120. package/lib/adapters/predefinedAdapters.js.map +1 -0
  121. package/lib/buildSnapshotTree.d.ts.map +1 -1
  122. package/lib/buildSnapshotTree.js +4 -3
  123. package/lib/buildSnapshotTree.js.map +1 -1
  124. package/lib/documentServiceFactoryProxy.d.ts +19 -0
  125. package/lib/documentServiceFactoryProxy.d.ts.map +1 -0
  126. package/lib/documentServiceFactoryProxy.js +23 -0
  127. package/lib/documentServiceFactoryProxy.js.map +1 -0
  128. package/lib/documentServiceProxy.d.ts +21 -0
  129. package/lib/documentServiceProxy.d.ts.map +1 -0
  130. package/lib/documentServiceProxy.js +32 -0
  131. package/lib/documentServiceProxy.js.map +1 -0
  132. package/lib/documentStorageServiceProxy.js +1 -2
  133. package/lib/documentStorageServiceProxy.js.map +1 -1
  134. package/lib/error.d.ts.map +1 -1
  135. package/lib/error.js +2 -0
  136. package/lib/error.js.map +1 -1
  137. package/lib/index.d.ts +3 -2
  138. package/lib/index.d.ts.map +1 -1
  139. package/lib/index.js +3 -2
  140. package/lib/index.js.map +1 -1
  141. package/lib/insecureUrlResolver.js +3 -5
  142. package/lib/insecureUrlResolver.js.map +1 -1
  143. package/lib/network.d.ts +2 -2
  144. package/lib/network.d.ts.map +1 -1
  145. package/lib/network.js +14 -6
  146. package/lib/network.js.map +1 -1
  147. package/lib/networkUtils.d.ts +1 -1
  148. package/lib/networkUtils.d.ts.map +1 -1
  149. package/lib/networkUtils.js +3 -4
  150. package/lib/networkUtils.js.map +1 -1
  151. package/lib/packageVersion.d.ts +1 -1
  152. package/lib/packageVersion.js +1 -1
  153. package/lib/packageVersion.js.map +1 -1
  154. package/lib/parallelRequests.d.ts +3 -3
  155. package/lib/parallelRequests.d.ts.map +1 -1
  156. package/lib/parallelRequests.js +37 -18
  157. package/lib/parallelRequests.js.map +1 -1
  158. package/lib/prefetchDocumentStorageService.js +1 -1
  159. package/lib/prefetchDocumentStorageService.js.map +1 -1
  160. package/lib/rateLimiter.js +1 -1
  161. package/lib/rateLimiter.js.map +1 -1
  162. package/lib/readAndParse.js +1 -1
  163. package/lib/readAndParse.js.map +1 -1
  164. package/lib/runWithRetry.d.ts +8 -0
  165. package/lib/runWithRetry.d.ts.map +1 -1
  166. package/lib/runWithRetry.js +30 -7
  167. package/lib/runWithRetry.js.map +1 -1
  168. package/lib/summaryForCreateNew.d.ts +0 -9
  169. package/lib/summaryForCreateNew.d.ts.map +1 -1
  170. package/lib/summaryForCreateNew.js +3 -25
  171. package/lib/summaryForCreateNew.js.map +1 -1
  172. package/lib/treeConversions.d.ts.map +1 -1
  173. package/lib/treeConversions.js +2 -1
  174. package/lib/treeConversions.js.map +1 -1
  175. package/package.json +24 -29
  176. package/src/adapters/compression/compressionTypes.ts +19 -0
  177. package/src/adapters/compression/documentServiceCompressionAdapter.ts +25 -0
  178. package/src/adapters/compression/documentServiceFactoryCompressionAdapter.ts +62 -0
  179. package/src/adapters/compression/index.ts +12 -0
  180. package/src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts +447 -0
  181. package/src/adapters/compression/summaryblob/index.ts +9 -0
  182. package/src/adapters/index.ts +13 -0
  183. package/src/adapters/predefinedAdapters.ts +73 -0
  184. package/src/buildSnapshotTree.ts +4 -3
  185. package/src/documentServiceFactoryProxy.ts +47 -0
  186. package/src/documentServiceProxy.ts +46 -0
  187. package/src/error.ts +2 -0
  188. package/src/index.ts +6 -2
  189. package/src/insecureUrlResolver.ts +1 -1
  190. package/src/network.ts +10 -2
  191. package/src/networkUtils.ts +1 -1
  192. package/src/packageVersion.ts +1 -1
  193. package/src/parallelRequests.ts +10 -8
  194. package/src/rateLimiter.ts +1 -1
  195. package/src/readAndParse.ts +1 -1
  196. package/src/runWithRetry.ts +32 -7
  197. package/src/summaryForCreateNew.ts +0 -31
  198. package/src/treeConversions.ts +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"rateLimiter.js","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAEtD,MAAa,WAAW;IAEvB,YAAoB,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;QADtB,UAAK,GAAmB,EAAE,CAAC;QAS5C,8CAA8C;QAC9C,0EAA0E;QACvD,YAAO,GAAG,GAAG,EAAE;YACjC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,IAAI,KAAK,SAAS,EAAE;gBACvB,OAAO,IAAI,EAAE,CAAC;aACd;YACD,IAAI,CAAC,WAAW,EAAE,CAAC;QACpB,CAAC,CAAC;QAfD,IAAA,qBAAM,EAAC,WAAW,GAAG,CAAC,EAAE,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC1F,CAAC;IAED,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IAYS,KAAK,CAAC,OAAO;QACtB,IAAI,IAAI,CAAC,WAAW,GAAG,CAAC,EAAE;YACzB,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,OAAO;SACP;QAED,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAI,IAAsB;QAC9C,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACD;AAnCD,kCAmCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\n\nexport class RateLimiter {\n\tprivate readonly tasks: (() => void)[] = [];\n\tconstructor(private maxRequests: number) {\n\t\tassert(maxRequests > 0, 0x0ae /* \"Tried to create rate limiter with 0 max requests!\" */);\n\t}\n\n\tpublic get waitQueueLength(): number {\n\t\treturn this.tasks.length;\n\t}\n\n\t// Run when one of the tasks finished running.\n\t// Release next task if we have one, or allow more tasks to run in future.\n\tprotected readonly release = () => {\n\t\tconst task = this.tasks.shift();\n\t\tif (task !== undefined) {\n\t\t\treturn task();\n\t\t}\n\t\tthis.maxRequests++;\n\t};\n\n\tprotected async acquire() {\n\t\tif (this.maxRequests > 0) {\n\t\t\tthis.maxRequests--;\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tthis.tasks.push(resolve);\n\t\t});\n\t}\n\n\tpublic async schedule<T>(work: () => Promise<T>) {\n\t\tawait this.acquire();\n\t\treturn work().finally(this.release);\n\t}\n}\n"]}
1
+ {"version":3,"file":"rateLimiter.js","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AAEpD,MAAa,WAAW;IAEvB,YAAoB,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;QADtB,UAAK,GAAmB,EAAE,CAAC;QAS5C,8CAA8C;QAC9C,0EAA0E;QACvD,YAAO,GAAG,GAAG,EAAE;YACjC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,IAAI,KAAK,SAAS,EAAE;gBACvB,OAAO,IAAI,EAAE,CAAC;aACd;YACD,IAAI,CAAC,WAAW,EAAE,CAAC;QACpB,CAAC,CAAC;QAfD,IAAA,mBAAM,EAAC,WAAW,GAAG,CAAC,EAAE,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC1F,CAAC;IAED,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IAYS,KAAK,CAAC,OAAO;QACtB,IAAI,IAAI,CAAC,WAAW,GAAG,CAAC,EAAE;YACzB,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,OAAO;SACP;QAED,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAI,IAAsB;QAC9C,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACD;AAnCD,kCAmCC","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\nexport class RateLimiter {\n\tprivate readonly tasks: (() => void)[] = [];\n\tconstructor(private maxRequests: number) {\n\t\tassert(maxRequests > 0, 0x0ae /* \"Tried to create rate limiter with 0 max requests!\" */);\n\t}\n\n\tpublic get waitQueueLength(): number {\n\t\treturn this.tasks.length;\n\t}\n\n\t// Run when one of the tasks finished running.\n\t// Release next task if we have one, or allow more tasks to run in future.\n\tprotected readonly release = () => {\n\t\tconst task = this.tasks.shift();\n\t\tif (task !== undefined) {\n\t\t\treturn task();\n\t\t}\n\t\tthis.maxRequests++;\n\t};\n\n\tprotected async acquire() {\n\t\tif (this.maxRequests > 0) {\n\t\t\tthis.maxRequests--;\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tthis.tasks.push(resolve);\n\t\t});\n\t}\n\n\tpublic async schedule<T>(work: () => Promise<T>) {\n\t\tawait this.acquire();\n\t\treturn work().finally(this.release);\n\t}\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.readAndParse = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
8
+ const client_utils_1 = require("@fluid-internal/client-utils");
9
9
  /**
10
10
  * Read a blob from {@link @fluidframework/driver-definitions#IDocumentStorageService} and
11
11
  * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}
@@ -20,7 +20,7 @@ const common_utils_1 = require("@fluidframework/common-utils");
20
20
  */
21
21
  async function readAndParse(storage, id) {
22
22
  const blob = await storage.readBlob(id);
23
- const decoded = (0, common_utils_1.bufferToString)(blob, "utf8");
23
+ const decoded = (0, client_utils_1.bufferToString)(blob, "utf8");
24
24
  return JSON.parse(decoded);
25
25
  }
26
26
  exports.readAndParse = readAndParse;
@@ -1 +1 @@
1
- {"version":3,"file":"readAndParse.js","sourceRoot":"","sources":["../src/readAndParse.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAG9D;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,YAAY,CACjC,OAAkD,EAClD,EAAU;IAEV,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAA,6BAAc,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAM,CAAC;AACjC,CAAC;AAPD,oCAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluidframework/common-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\n\n/**\n * Read a blob from {@link @fluidframework/driver-definitions#IDocumentStorageService} and\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}\n * it into object of type `T`.\n *\n * @param storage - The `DocumentStorageService` to read from.\n * @param id - The ID of the blob to read and parse.\n *\n * @typeParam T - Output type matching JSON format of inpyt blob data.\n *\n * @returns The object that we decoded and parsed via `JSON.parse`.\n */\nexport async function readAndParse<T>(\n\tstorage: Pick<IDocumentStorageService, \"readBlob\">,\n\tid: string,\n): Promise<T> {\n\tconst blob = await storage.readBlob(id);\n\tconst decoded = bufferToString(blob, \"utf8\");\n\treturn JSON.parse(decoded) as T;\n}\n"]}
1
+ {"version":3,"file":"readAndParse.js","sourceRoot":"","sources":["../src/readAndParse.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAG9D;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,YAAY,CACjC,OAAkD,EAClD,EAAU;IAEV,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAA,6BAAc,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAM,CAAC;AACjC,CAAC;AAPD,oCAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\n\n/**\n * Read a blob from {@link @fluidframework/driver-definitions#IDocumentStorageService} and\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}\n * it into object of type `T`.\n *\n * @param storage - The `DocumentStorageService` to read from.\n * @param id - The ID of the blob to read and parse.\n *\n * @typeParam T - Output type matching JSON format of inpyt blob data.\n *\n * @returns The object that we decoded and parsed via `JSON.parse`.\n */\nexport async function readAndParse<T>(\n\tstorage: Pick<IDocumentStorageService, \"readBlob\">,\n\tid: string,\n): Promise<T> {\n\tconst blob = await storage.readBlob(id);\n\tconst decoded = bufferToString(blob, \"utf8\");\n\treturn JSON.parse(decoded) as T;\n}\n"]}
@@ -34,4 +34,12 @@ export interface IProgress {
34
34
  onRetry?(delayInMs: number, error: any): void;
35
35
  }
36
36
  export declare function runWithRetry<T>(api: (cancel?: AbortSignal) => Promise<T>, fetchCallName: string, logger: ITelemetryLoggerExt, progress: IProgress): Promise<T>;
37
+ /**
38
+ * In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error
39
+ * not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared
40
+ * to when endpoint is reachable in which case it is 30s.
41
+ * @param error - error based on which we decide max wait time.
42
+ * @returns Max wait time.
43
+ */
44
+ export declare function calculateMaxWaitTime(error: unknown): number;
37
45
  //# sourceMappingURL=runWithRetry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAOtE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;CAC9C;AAED,wBAAsB,YAAY,CAAC,CAAC,EACnC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACzC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,SAAS,GACjB,OAAO,CAAC,CAAC,CAAC,CAiFZ"}
1
+ {"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAgB,MAAM,iCAAiC,CAAC;AAQpF;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;CAC9C;AAED,wBAAsB,YAAY,CAAC,CAAC,EACnC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACzC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,SAAS,GACjB,OAAO,CAAC,CAAC,CAAC,CAyFZ;AAKD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI3D"}
@@ -4,19 +4,20 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.runWithRetry = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
7
+ exports.calculateMaxWaitTime = exports.runWithRetry = void 0;
8
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
9
+ const client_utils_1 = require("@fluid-internal/client-utils");
10
+ const core_utils_1 = require("@fluidframework/core-utils");
9
11
  const driver_definitions_1 = require("@fluidframework/driver-definitions");
10
12
  const network_1 = require("./network");
11
13
  const packageVersion_1 = require("./packageVersion");
12
14
  const _1 = require(".");
13
15
  async function runWithRetry(api, fetchCallName, logger, progress) {
14
- var _a, _b;
15
16
  let result;
16
17
  let success = false;
17
18
  let retryAfterMs = 1000; // has to be positive!
18
19
  let numRetries = 0;
19
- const startTime = common_utils_1.performance.now();
20
+ const startTime = client_utils_1.performance.now();
20
21
  let lastError;
21
22
  do {
22
23
  try {
@@ -29,19 +30,26 @@ async function runWithRetry(api, fetchCallName, logger, progress) {
29
30
  logger.sendTelemetryEvent({
30
31
  eventName: `${fetchCallName}_cancel`,
31
32
  retry: numRetries,
32
- duration: common_utils_1.performance.now() - startTime,
33
+ duration: client_utils_1.performance.now() - startTime,
33
34
  fetchCallName,
34
35
  }, err);
35
36
  throw err;
36
37
  }
37
- if (((_a = progress.cancel) === null || _a === void 0 ? void 0 : _a.aborted) === true) {
38
+ if (progress.cancel?.aborted === true) {
38
39
  logger.sendTelemetryEvent({
39
40
  eventName: `${fetchCallName}_runWithRetryAborted`,
40
41
  retry: numRetries,
41
- duration: common_utils_1.performance.now() - startTime,
42
+ duration: client_utils_1.performance.now() - startTime,
42
43
  fetchCallName,
44
+ // TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
45
+ reason: progress.cancel.reason,
43
46
  }, err);
44
- throw new _1.NonRetryableError("runWithRetry was Aborted", driver_definitions_1.DriverErrorType.genericError, { driverVersion: packageVersion_1.pkgVersion, fetchCallName });
47
+ throw new _1.NonRetryableError("runWithRetry was Aborted", driver_definitions_1.DriverErrorTypes.genericError, {
48
+ driverVersion: packageVersion_1.pkgVersion,
49
+ fetchCallName,
50
+ // TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
51
+ reason: progress.cancel.reason,
52
+ });
45
53
  }
46
54
  // logging the first failed retry instead of every attempt. We want to avoid filling telemetry
47
55
  // when we have tight loop of retrying in offline mode, but we also want to know what caused
@@ -49,26 +57,27 @@ async function runWithRetry(api, fetchCallName, logger, progress) {
49
57
  if (numRetries === 0) {
50
58
  logger.sendTelemetryEvent({
51
59
  eventName: `${fetchCallName}_firstFailed`,
52
- duration: common_utils_1.performance.now() - startTime,
60
+ duration: client_utils_1.performance.now() - startTime,
53
61
  fetchCallName,
54
62
  }, err);
55
63
  }
56
64
  numRetries++;
57
65
  lastError = err;
58
66
  // If the error is throttling error, then wait for the specified time before retrying.
59
- // If the waitTime is not specified, then we start with retrying immediately to max of 8s.
60
- retryAfterMs = (_b = (0, network_1.getRetryDelayFromError)(err)) !== null && _b !== void 0 ? _b : Math.min(retryAfterMs * 2, 8000);
67
+ retryAfterMs =
68
+ (0, network_1.getRetryDelayFromError)(err) ??
69
+ Math.min(retryAfterMs * 2, calculateMaxWaitTime(err));
61
70
  if (progress.onRetry) {
62
71
  progress.onRetry(retryAfterMs, err);
63
72
  }
64
- await (0, common_utils_1.delay)(retryAfterMs);
73
+ await (0, core_utils_1.delay)(retryAfterMs);
65
74
  }
66
75
  } while (!success);
67
76
  if (numRetries > 0) {
68
77
  logger.sendTelemetryEvent({
69
78
  eventName: `${fetchCallName}_lastError`,
70
79
  retry: numRetries,
71
- duration: common_utils_1.performance.now() - startTime,
80
+ duration: client_utils_1.performance.now() - startTime,
72
81
  fetchCallName,
73
82
  }, lastError);
74
83
  }
@@ -76,4 +85,19 @@ async function runWithRetry(api, fetchCallName, logger, progress) {
76
85
  return result;
77
86
  }
78
87
  exports.runWithRetry = runWithRetry;
88
+ const MaxReconnectDelayInMsWhenEndpointIsReachable = 30000;
89
+ const MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;
90
+ /**
91
+ * In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error
92
+ * not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared
93
+ * to when endpoint is reachable in which case it is 30s.
94
+ * @param error - error based on which we decide max wait time.
95
+ * @returns Max wait time.
96
+ */
97
+ function calculateMaxWaitTime(error) {
98
+ return (0, telemetry_utils_1.isFluidError)(error) && error.getTelemetryProperties().endpointReached === true
99
+ ? MaxReconnectDelayInMsWhenEndpointIsReachable
100
+ : MaxReconnectDelayInMsWhenEndpointIsNotReachable;
101
+ }
102
+ exports.calculateMaxWaitTime = calculateMaxWaitTime;
79
103
  //# sourceMappingURL=runWithRetry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAkE;AAClE,2EAAqE;AACrE,uCAAoE;AACpE,qDAA8C;AAC9C,wBAAsC;AAkC/B,KAAK,UAAU,YAAY,CACjC,GAAyC,EACzC,aAAqB,EACrB,MAA2B,EAC3B,QAAmB;;IAEnB,IAAI,MAAqB,CAAC;IAC1B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,YAAY,GAAG,IAAI,CAAC,CAAC,sBAAsB;IAC/C,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,SAAS,GAAG,0BAAW,CAAC,GAAG,EAAE,CAAC;IACpC,IAAI,SAAc,CAAC;IACnB,GAAG;QACF,IAAI;YACH,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACpC,OAAO,GAAG,IAAI,CAAC;SACf;QAAC,OAAO,GAAG,EAAE;YACb,qDAAqD;YACrD,IAAI,CAAC,IAAA,yBAAe,EAAC,GAAG,CAAC,EAAE;gBAC1B,MAAM,CAAC,kBAAkB,CACxB;oBACC,SAAS,EAAE,GAAG,aAAa,SAAS;oBACpC,KAAK,EAAE,UAAU;oBACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;oBACvC,aAAa;iBACb,EACD,GAAG,CACH,CAAC;gBACF,MAAM,GAAG,CAAC;aACV;YAED,IAAI,CAAA,MAAA,QAAQ,CAAC,MAAM,0CAAE,OAAO,MAAK,IAAI,EAAE;gBACtC,MAAM,CAAC,kBAAkB,CACxB;oBACC,SAAS,EAAE,GAAG,aAAa,sBAAsB;oBACjD,KAAK,EAAE,UAAU;oBACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;oBACvC,aAAa;iBACb,EACD,GAAG,CACH,CAAC;gBACF,MAAM,IAAI,oBAAiB,CAC1B,0BAA0B,EAC1B,oCAAe,CAAC,YAAY,EAC5B,EAAE,aAAa,EAAE,2BAAU,EAAE,aAAa,EAAE,CAC5C,CAAC;aACF;YAED,8FAA8F;YAC9F,4FAA4F;YAC5F,iCAAiC;YACjC,IAAI,UAAU,KAAK,CAAC,EAAE;gBACrB,MAAM,CAAC,kBAAkB,CACxB;oBACC,SAAS,EAAE,GAAG,aAAa,cAAc;oBACzC,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;oBACvC,aAAa;iBACb,EACD,GAAG,CACH,CAAC;aACF;YAED,UAAU,EAAE,CAAC;YACb,SAAS,GAAG,GAAG,CAAC;YAChB,sFAAsF;YACtF,0FAA0F;YAC1F,YAAY,GAAG,MAAA,IAAA,gCAAsB,EAAC,GAAG,CAAC,mCAAI,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;YAC/E,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACrB,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;aACpC;YACD,MAAM,IAAA,oBAAK,EAAC,YAAY,CAAC,CAAC;SAC1B;KACD,QAAQ,CAAC,OAAO,EAAE;IACnB,IAAI,UAAU,GAAG,CAAC,EAAE;QACnB,MAAM,CAAC,kBAAkB,CACxB;YACC,SAAS,EAAE,GAAG,aAAa,YAAY;YACvC,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;YACvC,aAAa;SACb,EACD,SAAS,CACT,CAAC;KACF;IACD,oEAAoE;IACpE,OAAO,MAAO,CAAC;AAChB,CAAC;AAtFD,oCAsFC","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 { delay, performance } from \"@fluidframework/common-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { canRetryOnError, getRetryDelayFromError } from \"./network\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { NonRetryableError } from \".\";\n\n/**\n * Interface describing an object passed to various network APIs.\n * It allows caller to control cancellation, as well as learn about any delays.\n */\nexport interface IProgress {\n\t/**\n\t * Abort signal used to cancel operation.\n\t *\n\t * @remarks Note that most of the layers do not use this signal yet. We need to change that over time.\n\t * Please consult with API documentation / implementation.\n\t * Note that number of layers may not check this signal while holding this request in a queue,\n\t * so it may take a while it takes effect. This can be improved in the future.\n\t *\n\t * The layers in question are:\n\t *\n\t * - driver (RateLimiter)\n\t *\n\t * - runWithRetry\n\t */\n\tcancel?: AbortSignal;\n\n\t/**\n\t * Called whenever api returns cancellable error and the call is going to be retried.\n\t * Any exception thrown from this call back result in cancellation of operation\n\t * and propagation of thrown exception.\n\t * @param delayInMs - delay before next retry. This value will depend on internal back-off logic,\n\t * as well as information provided by service (like 429 error asking to wait for some time before retry)\n\t * @param error - error object returned from the call.\n\t */\n\tonRetry?(delayInMs: number, error: any): void;\n}\n\nexport async function runWithRetry<T>(\n\tapi: (cancel?: AbortSignal) => Promise<T>,\n\tfetchCallName: string,\n\tlogger: ITelemetryLoggerExt,\n\tprogress: IProgress,\n): Promise<T> {\n\tlet result: T | undefined;\n\tlet success = false;\n\tlet retryAfterMs = 1000; // has to be positive!\n\tlet numRetries = 0;\n\tconst startTime = performance.now();\n\tlet lastError: any;\n\tdo {\n\t\ttry {\n\t\t\tresult = await api(progress.cancel);\n\t\t\tsuccess = true;\n\t\t} catch (err) {\n\t\t\t// If it is not retriable, then just throw the error.\n\t\t\tif (!canRetryOnError(err)) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_cancel`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow err;\n\t\t\t}\n\n\t\t\tif (progress.cancel?.aborted === true) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_runWithRetryAborted`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"runWithRetry was Aborted\",\n\t\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t\t{ driverVersion: pkgVersion, fetchCallName },\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// logging the first failed retry instead of every attempt. We want to avoid filling telemetry\n\t\t\t// when we have tight loop of retrying in offline mode, but we also want to know what caused\n\t\t\t// the failure in the first place\n\t\t\tif (numRetries === 0) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_firstFailed`,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tnumRetries++;\n\t\t\tlastError = err;\n\t\t\t// If the error is throttling error, then wait for the specified time before retrying.\n\t\t\t// If the waitTime is not specified, then we start with retrying immediately to max of 8s.\n\t\t\tretryAfterMs = getRetryDelayFromError(err) ?? Math.min(retryAfterMs * 2, 8000);\n\t\t\tif (progress.onRetry) {\n\t\t\t\tprogress.onRetry(retryAfterMs, err);\n\t\t\t}\n\t\t\tawait delay(retryAfterMs);\n\t\t}\n\t} while (!success);\n\tif (numRetries > 0) {\n\t\tlogger.sendTelemetryEvent(\n\t\t\t{\n\t\t\t\teventName: `${fetchCallName}_lastError`,\n\t\t\t\tretry: numRetries,\n\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\tfetchCallName,\n\t\t\t},\n\t\t\tlastError,\n\t\t);\n\t}\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\treturn result!;\n}\n"]}
1
+ {"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAAoF;AACpF,+DAA2D;AAC3D,2DAAmD;AACnD,2EAAsE;AACtE,uCAAoE;AACpE,qDAA8C;AAC9C,wBAAsC;AAkC/B,KAAK,UAAU,YAAY,CACjC,GAAyC,EACzC,aAAqB,EACrB,MAA2B,EAC3B,QAAmB;IAEnB,IAAI,MAAqB,CAAC;IAC1B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,YAAY,GAAG,IAAI,CAAC,CAAC,sBAAsB;IAC/C,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,SAAS,GAAG,0BAAW,CAAC,GAAG,EAAE,CAAC;IACpC,IAAI,SAAc,CAAC;IACnB,GAAG;QACF,IAAI;YACH,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACpC,OAAO,GAAG,IAAI,CAAC;SACf;QAAC,OAAO,GAAG,EAAE;YACb,qDAAqD;YACrD,IAAI,CAAC,IAAA,yBAAe,EAAC,GAAG,CAAC,EAAE;gBAC1B,MAAM,CAAC,kBAAkB,CACxB;oBACC,SAAS,EAAE,GAAG,aAAa,SAAS;oBACpC,KAAK,EAAE,UAAU;oBACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;oBACvC,aAAa;iBACb,EACD,GAAG,CACH,CAAC;gBACF,MAAM,GAAG,CAAC;aACV;YAED,IAAI,QAAQ,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,EAAE;gBACtC,MAAM,CAAC,kBAAkB,CACxB;oBACC,SAAS,EAAE,GAAG,aAAa,sBAAsB;oBACjD,KAAK,EAAE,UAAU;oBACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;oBACvC,aAAa;oBACb,sGAAsG;oBACtG,MAAM,EAAG,QAAQ,CAAC,MAAwC,CAAC,MAAM;iBACjE,EACD,GAAG,CACH,CAAC;gBACF,MAAM,IAAI,oBAAiB,CAC1B,0BAA0B,EAC1B,qCAAgB,CAAC,YAAY,EAC7B;oBACC,aAAa,EAAE,2BAAU;oBACzB,aAAa;oBACb,sGAAsG;oBACtG,MAAM,EAAG,QAAQ,CAAC,MAAwC,CAAC,MAAM;iBACjE,CACD,CAAC;aACF;YAED,8FAA8F;YAC9F,4FAA4F;YAC5F,iCAAiC;YACjC,IAAI,UAAU,KAAK,CAAC,EAAE;gBACrB,MAAM,CAAC,kBAAkB,CACxB;oBACC,SAAS,EAAE,GAAG,aAAa,cAAc;oBACzC,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;oBACvC,aAAa;iBACb,EACD,GAAG,CACH,CAAC;aACF;YAED,UAAU,EAAE,CAAC;YACb,SAAS,GAAG,GAAG,CAAC;YAChB,sFAAsF;YACtF,YAAY;gBACX,IAAA,gCAAsB,EAAC,GAAG,CAAC;oBAC3B,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC;YACvD,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACrB,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;aACpC;YACD,MAAM,IAAA,kBAAK,EAAC,YAAY,CAAC,CAAC;SAC1B;KACD,QAAQ,CAAC,OAAO,EAAE;IACnB,IAAI,UAAU,GAAG,CAAC,EAAE;QACnB,MAAM,CAAC,kBAAkB,CACxB;YACC,SAAS,EAAE,GAAG,aAAa,YAAY;YACvC,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;YACvC,aAAa;SACb,EACD,SAAS,CACT,CAAC;KACF;IACD,oEAAoE;IACpE,OAAO,MAAO,CAAC;AAChB,CAAC;AA9FD,oCA8FC;AAED,MAAM,4CAA4C,GAAG,KAAK,CAAC;AAC3D,MAAM,+CAA+C,GAAG,IAAI,CAAC;AAE7D;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,KAAc;IAClD,OAAO,IAAA,8BAAY,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,sBAAsB,EAAE,CAAC,eAAe,KAAK,IAAI;QACpF,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,+CAA+C,CAAC;AACpD,CAAC;AAJD,oDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt, isFluidError } from \"@fluidframework/telemetry-utils\";\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { delay } from \"@fluidframework/core-utils\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\nimport { canRetryOnError, getRetryDelayFromError } from \"./network\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { NonRetryableError } from \".\";\n\n/**\n * Interface describing an object passed to various network APIs.\n * It allows caller to control cancellation, as well as learn about any delays.\n */\nexport interface IProgress {\n\t/**\n\t * Abort signal used to cancel operation.\n\t *\n\t * @remarks Note that most of the layers do not use this signal yet. We need to change that over time.\n\t * Please consult with API documentation / implementation.\n\t * Note that number of layers may not check this signal while holding this request in a queue,\n\t * so it may take a while it takes effect. This can be improved in the future.\n\t *\n\t * The layers in question are:\n\t *\n\t * - driver (RateLimiter)\n\t *\n\t * - runWithRetry\n\t */\n\tcancel?: AbortSignal;\n\n\t/**\n\t * Called whenever api returns cancellable error and the call is going to be retried.\n\t * Any exception thrown from this call back result in cancellation of operation\n\t * and propagation of thrown exception.\n\t * @param delayInMs - delay before next retry. This value will depend on internal back-off logic,\n\t * as well as information provided by service (like 429 error asking to wait for some time before retry)\n\t * @param error - error object returned from the call.\n\t */\n\tonRetry?(delayInMs: number, error: any): void;\n}\n\nexport async function runWithRetry<T>(\n\tapi: (cancel?: AbortSignal) => Promise<T>,\n\tfetchCallName: string,\n\tlogger: ITelemetryLoggerExt,\n\tprogress: IProgress,\n): Promise<T> {\n\tlet result: T | undefined;\n\tlet success = false;\n\tlet retryAfterMs = 1000; // has to be positive!\n\tlet numRetries = 0;\n\tconst startTime = performance.now();\n\tlet lastError: any;\n\tdo {\n\t\ttry {\n\t\t\tresult = await api(progress.cancel);\n\t\t\tsuccess = true;\n\t\t} catch (err) {\n\t\t\t// If it is not retriable, then just throw the error.\n\t\t\tif (!canRetryOnError(err)) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_cancel`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow err;\n\t\t\t}\n\n\t\t\tif (progress.cancel?.aborted === true) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_runWithRetryAborted`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t\t// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)\n\t\t\t\t\t\treason: (progress.cancel as AbortSignal & { reason: any }).reason,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"runWithRetry was Aborted\",\n\t\t\t\t\tDriverErrorTypes.genericError,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t\t// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)\n\t\t\t\t\t\treason: (progress.cancel as AbortSignal & { reason: any }).reason,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// logging the first failed retry instead of every attempt. We want to avoid filling telemetry\n\t\t\t// when we have tight loop of retrying in offline mode, but we also want to know what caused\n\t\t\t// the failure in the first place\n\t\t\tif (numRetries === 0) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_firstFailed`,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tnumRetries++;\n\t\t\tlastError = err;\n\t\t\t// If the error is throttling error, then wait for the specified time before retrying.\n\t\t\tretryAfterMs =\n\t\t\t\tgetRetryDelayFromError(err) ??\n\t\t\t\tMath.min(retryAfterMs * 2, calculateMaxWaitTime(err));\n\t\t\tif (progress.onRetry) {\n\t\t\t\tprogress.onRetry(retryAfterMs, err);\n\t\t\t}\n\t\t\tawait delay(retryAfterMs);\n\t\t}\n\t} while (!success);\n\tif (numRetries > 0) {\n\t\tlogger.sendTelemetryEvent(\n\t\t\t{\n\t\t\t\teventName: `${fetchCallName}_lastError`,\n\t\t\t\tretry: numRetries,\n\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\tfetchCallName,\n\t\t\t},\n\t\t\tlastError,\n\t\t);\n\t}\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\treturn result!;\n}\n\nconst MaxReconnectDelayInMsWhenEndpointIsReachable = 30000;\nconst MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;\n\n/**\n * In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error\n * not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared\n * to when endpoint is reachable in which case it is 30s.\n * @param error - error based on which we decide max wait time.\n * @returns Max wait time.\n */\nexport function calculateMaxWaitTime(error: unknown): number {\n\treturn isFluidError(error) && error.getTelemetryProperties().endpointReached === true\n\t\t? MaxReconnectDelayInMsWhenEndpointIsReachable\n\t\t: MaxReconnectDelayInMsWhenEndpointIsNotReachable;\n}\n"]}
@@ -20,15 +20,6 @@ export interface CombinedAppAndProtocolSummary extends ISummaryTree {
20
20
  * @internal
21
21
  */
22
22
  export declare function isCombinedAppAndProtocolSummary(summary: ISummaryTree | undefined): summary is CombinedAppAndProtocolSummary;
23
- /**
24
- * Combine the app summary and protocol summary in 1 tree.
25
- * @param appSummary - Summary of the app.
26
- * @param protocolSummary - Summary of the protocol.
27
- * @internal
28
- *
29
- * @deprecated 2.0.0-internal.3.4.0 - Not intended for public use. Will be moved to container-loader and no longer exported in an upcoming release.
30
- */
31
- export declare function combineAppAndProtocolSummary(appSummary: ISummaryTree, protocolSummary: ISummaryTree): CombinedAppAndProtocolSummary;
32
23
  /**
33
24
  * Extract the attributes from the protocol summary.
34
25
  * @param protocolSummary - protocol summary from which the values are to be extracted.
@@ -1 +1 @@
1
- {"version":3,"file":"summaryForCreateNew.d.ts","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,YAAY,EAGZ,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,sCAAsC,CAAC;AAE9C;;;;GAIG;AACH,MAAM,WAAW,6BAA8B,SAAQ,YAAY;IAClE,IAAI,EAAE;QACL,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;QACvB,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC;KAC5B,CAAC;CACF;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC9C,OAAO,EAAE,YAAY,GAAG,SAAS,GAC/B,OAAO,IAAI,6BAA6B,CAa1C;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC3C,UAAU,EAAE,YAAY,EACxB,eAAe,EAAE,YAAY,GAC3B,6BAA6B,CAiB/B;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAClD,eAAe,EAAE,YAAY,GAC3B,mBAAmB,CAGrB;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CACjD,eAAe,EAAE,YAAY,GAC3B,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAOhC"}
1
+ {"version":3,"file":"summaryForCreateNew.d.ts","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,YAAY,EAGZ,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,sCAAsC,CAAC;AAE9C;;;;GAIG;AACH,MAAM,WAAW,6BAA8B,SAAQ,YAAY;IAClE,IAAI,EAAE;QACL,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;QACvB,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC;KAC5B,CAAC;CACF;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC9C,OAAO,EAAE,YAAY,GAAG,SAAS,GAC/B,OAAO,IAAI,6BAA6B,CAa1C;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAClD,eAAe,EAAE,YAAY,GAC3B,mBAAmB,CAGrB;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CACjD,eAAe,EAAE,YAAY,GAC3B,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAOhC"}
@@ -4,8 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getQuorumValuesFromProtocolSummary = exports.getDocAttributesFromProtocolSummary = exports.combineAppAndProtocolSummary = exports.isCombinedAppAndProtocolSummary = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
7
+ exports.getQuorumValuesFromProtocolSummary = exports.getDocAttributesFromProtocolSummary = exports.isCombinedAppAndProtocolSummary = void 0;
9
8
  const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
10
9
  /**
11
10
  * Validates the current layout of an .app + .protocol summary tree
@@ -13,10 +12,9 @@ const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
13
12
  * @internal
14
13
  */
15
14
  function isCombinedAppAndProtocolSummary(summary) {
16
- var _a, _b, _c, _d;
17
- if ((summary === null || summary === void 0 ? void 0 : summary.tree) === undefined ||
18
- ((_b = (_a = summary.tree) === null || _a === void 0 ? void 0 : _a[".app"]) === null || _b === void 0 ? void 0 : _b.type) !== protocol_definitions_1.SummaryType.Tree ||
19
- ((_d = (_c = summary.tree) === null || _c === void 0 ? void 0 : _c[".protocol"]) === null || _d === void 0 ? void 0 : _d.type) !== protocol_definitions_1.SummaryType.Tree) {
15
+ if (summary?.tree === undefined ||
16
+ summary.tree?.[".app"]?.type !== protocol_definitions_1.SummaryType.Tree ||
17
+ summary.tree?.[".protocol"]?.type !== protocol_definitions_1.SummaryType.Tree) {
20
18
  return false;
21
19
  }
22
20
  const treeKeys = Object.keys(summary.tree);
@@ -26,27 +24,6 @@ function isCombinedAppAndProtocolSummary(summary) {
26
24
  return true;
27
25
  }
28
26
  exports.isCombinedAppAndProtocolSummary = isCombinedAppAndProtocolSummary;
29
- /**
30
- * Combine the app summary and protocol summary in 1 tree.
31
- * @param appSummary - Summary of the app.
32
- * @param protocolSummary - Summary of the protocol.
33
- * @internal
34
- *
35
- * @deprecated 2.0.0-internal.3.4.0 - Not intended for public use. Will be moved to container-loader and no longer exported in an upcoming release.
36
- */
37
- function combineAppAndProtocolSummary(appSummary, protocolSummary) {
38
- (0, common_utils_1.assert)(!isCombinedAppAndProtocolSummary(appSummary), 0x5a8 /* app summary is already a combined tree! */);
39
- (0, common_utils_1.assert)(!isCombinedAppAndProtocolSummary(protocolSummary), 0x5a9 /* protocol summary is already a combined tree! */);
40
- const createNewSummary = {
41
- type: protocol_definitions_1.SummaryType.Tree,
42
- tree: {
43
- ".protocol": protocolSummary,
44
- ".app": appSummary,
45
- },
46
- };
47
- return createNewSummary;
48
- }
49
- exports.combineAppAndProtocolSummary = combineAppAndProtocolSummary;
50
27
  /**
51
28
  * Extract the attributes from the protocol summary.
52
29
  * @param protocolSummary - protocol summary from which the values are to be extracted.
@@ -1 +1 @@
1
- {"version":3,"file":"summaryForCreateNew.js","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,+EAM8C;AAc9C;;;;GAIG;AACH,SAAgB,+BAA+B,CAC9C,OAAiC;;IAEjC,IACC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,SAAS;QAC3B,CAAA,MAAA,MAAA,OAAO,CAAC,IAAI,0CAAG,MAAM,CAAC,0CAAE,IAAI,MAAK,kCAAW,CAAC,IAAI;QACjD,CAAA,MAAA,MAAA,OAAO,CAAC,IAAI,0CAAG,WAAW,CAAC,0CAAE,IAAI,MAAK,kCAAW,CAAC,IAAI,EACrD;QACD,OAAO,KAAK,CAAC;KACb;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,OAAO,KAAK,CAAC;KACb;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAfD,0EAeC;AAED;;;;;;;GAOG;AACH,SAAgB,4BAA4B,CAC3C,UAAwB,EACxB,eAA6B;IAE7B,IAAA,qBAAM,EACL,CAAC,+BAA+B,CAAC,UAAU,CAAC,EAC5C,KAAK,CAAC,6CAA6C,CACnD,CAAC;IACF,IAAA,qBAAM,EACL,CAAC,+BAA+B,CAAC,eAAe,CAAC,EACjD,KAAK,CAAC,kDAAkD,CACxD,CAAC;IACF,MAAM,gBAAgB,GAAkC;QACvD,IAAI,EAAE,kCAAW,CAAC,IAAI;QACtB,IAAI,EAAE;YACL,WAAW,EAAE,eAAe;YAC5B,MAAM,EAAE,UAAU;SAClB;KACD,CAAC;IACF,OAAO,gBAAgB,CAAC;AACzB,CAAC;AApBD,oEAoBC;AAED;;;GAGG;AACH,SAAgB,mCAAmC,CAClD,eAA6B;IAE7B,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,UAA0B,CAAC;IACvE,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAiB,CAAwB,CAAC;AAC5E,CAAC;AALD,kFAKC;AAED;;;GAGG;AACH,SAAgB,kCAAkC,CACjD,eAA6B;IAE7B,MAAM,gBAAgB,GAAG,eAAe,CAAC,IAAI,CAAC,YAA4B,CAAC;IAC3E,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAiB,CAG/D,CAAC;IACJ,OAAO,YAAY,CAAC;AACrB,CAAC;AATD,gFASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n\tISummaryTree,\n\tSummaryType,\n\tISummaryBlob,\n\tICommittedProposal,\n\tIDocumentAttributes,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Defines the current layout of an .app + .protocol summary tree\n * this is used internally for create new, and single commit summary\n * @internal\n */\nexport interface CombinedAppAndProtocolSummary extends ISummaryTree {\n\ttree: {\n\t\t[\".app\"]: ISummaryTree;\n\t\t[\".protocol\"]: ISummaryTree;\n\t};\n}\n\n/**\n * Validates the current layout of an .app + .protocol summary tree\n * this is used internally for create new, and single commit summary\n * @internal\n */\nexport function isCombinedAppAndProtocolSummary(\n\tsummary: ISummaryTree | undefined,\n): summary is CombinedAppAndProtocolSummary {\n\tif (\n\t\tsummary?.tree === undefined ||\n\t\tsummary.tree?.[\".app\"]?.type !== SummaryType.Tree ||\n\t\tsummary.tree?.[\".protocol\"]?.type !== SummaryType.Tree\n\t) {\n\t\treturn false;\n\t}\n\tconst treeKeys = Object.keys(summary.tree);\n\tif (treeKeys.length !== 2) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n * @internal\n *\n * @deprecated 2.0.0-internal.3.4.0 - Not intended for public use. Will be moved to container-loader and no longer exported in an upcoming release.\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): CombinedAppAndProtocolSummary {\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(appSummary),\n\t\t0x5a8 /* app summary is already a combined tree! */,\n\t);\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(protocolSummary),\n\t\t0x5a9 /* protocol summary is already a combined tree! */,\n\t);\n\tconst createNewSummary: CombinedAppAndProtocolSummary = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Extract the attributes from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n */\nexport function getDocAttributesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): IDocumentAttributes {\n\tconst attributesBlob = protocolSummary.tree.attributes as ISummaryBlob;\n\treturn JSON.parse(attributesBlob.content as string) as IDocumentAttributes;\n}\n\n/**\n * Extract quorum values from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n */\nexport function getQuorumValuesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): [string, ICommittedProposal][] {\n\tconst quorumValuesBlob = protocolSummary.tree.quorumValues as ISummaryBlob;\n\tconst quorumValues = JSON.parse(quorumValuesBlob.content as string) as [\n\t\tstring,\n\t\tICommittedProposal,\n\t][];\n\treturn quorumValues;\n}\n"]}
1
+ {"version":3,"file":"summaryForCreateNew.js","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+EAM8C;AAc9C;;;;GAIG;AACH,SAAgB,+BAA+B,CAC9C,OAAiC;IAEjC,IACC,OAAO,EAAE,IAAI,KAAK,SAAS;QAC3B,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,KAAK,kCAAW,CAAC,IAAI;QACjD,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,KAAK,kCAAW,CAAC,IAAI,EACrD;QACD,OAAO,KAAK,CAAC;KACb;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,OAAO,KAAK,CAAC;KACb;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAfD,0EAeC;AAED;;;GAGG;AACH,SAAgB,mCAAmC,CAClD,eAA6B;IAE7B,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,UAA0B,CAAC;IACvE,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAiB,CAAwB,CAAC;AAC5E,CAAC;AALD,kFAKC;AAED;;;GAGG;AACH,SAAgB,kCAAkC,CACjD,eAA6B;IAE7B,MAAM,gBAAgB,GAAG,eAAe,CAAC,IAAI,CAAC,YAA4B,CAAC;IAC3E,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAiB,CAG/D,CAAC;IACJ,OAAO,YAAY,CAAC;AACrB,CAAC;AATD,gFASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tISummaryTree,\n\tSummaryType,\n\tISummaryBlob,\n\tICommittedProposal,\n\tIDocumentAttributes,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Defines the current layout of an .app + .protocol summary tree\n * this is used internally for create new, and single commit summary\n * @internal\n */\nexport interface CombinedAppAndProtocolSummary extends ISummaryTree {\n\ttree: {\n\t\t[\".app\"]: ISummaryTree;\n\t\t[\".protocol\"]: ISummaryTree;\n\t};\n}\n\n/**\n * Validates the current layout of an .app + .protocol summary tree\n * this is used internally for create new, and single commit summary\n * @internal\n */\nexport function isCombinedAppAndProtocolSummary(\n\tsummary: ISummaryTree | undefined,\n): summary is CombinedAppAndProtocolSummary {\n\tif (\n\t\tsummary?.tree === undefined ||\n\t\tsummary.tree?.[\".app\"]?.type !== SummaryType.Tree ||\n\t\tsummary.tree?.[\".protocol\"]?.type !== SummaryType.Tree\n\t) {\n\t\treturn false;\n\t}\n\tconst treeKeys = Object.keys(summary.tree);\n\tif (treeKeys.length !== 2) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/**\n * Extract the attributes from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n */\nexport function getDocAttributesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): IDocumentAttributes {\n\tconst attributesBlob = protocolSummary.tree.attributes as ISummaryBlob;\n\treturn JSON.parse(attributesBlob.content as string) as IDocumentAttributes;\n}\n\n/**\n * Extract quorum values from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n */\nexport function getQuorumValuesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): [string, ICommittedProposal][] {\n\tconst quorumValuesBlob = protocolSummary.tree.quorumValues as ISummaryBlob;\n\tconst quorumValues = JSON.parse(quorumValuesBlob.content as string) as [\n\t\tstring,\n\t\tICommittedProposal,\n\t][];\n\treturn quorumValues;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"treeConversions.d.ts","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,KAAK,EAA2B,MAAM,sCAAsC,CAAC;AAIpG;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAgDlF"}
1
+ {"version":3,"file":"treeConversions.d.ts","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,KAAK,EAA2B,MAAM,sCAAsC,CAAC;AAIpG;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAgDlF"}
@@ -5,7 +5,8 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.convertSummaryTreeToSnapshotITree = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
8
+ const client_utils_1 = require("@fluid-internal/client-utils");
9
+ const core_utils_1 = require("@fluidframework/core-utils");
9
10
  const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
10
11
  const blob_1 = require("./blob");
11
12
  const summaryForCreateNew_1 = require("./summaryForCreateNew");
@@ -32,7 +33,7 @@ function convertSummaryTreeToSnapshotITree(summaryTree) {
32
33
  parsedContent = value.content;
33
34
  }
34
35
  else {
35
- parsedContent = (0, common_utils_1.Uint8ArrayToString)(value.content, "base64");
36
+ parsedContent = (0, client_utils_1.Uint8ArrayToString)(value.content, "base64");
36
37
  encoding = "base64";
37
38
  }
38
39
  entries.push(new blob_1.BlobTreeEntry(k, parsedContent, encoding));
@@ -50,7 +51,7 @@ function convertSummaryTreeToSnapshotITree(summaryTree) {
50
51
  throw new Error("Should not have Handle type in summary tree");
51
52
  }
52
53
  default:
53
- (0, common_utils_1.unreachableCase)(value, "Unexpected summary tree type");
54
+ (0, core_utils_1.unreachableCase)(value, "Unexpected summary tree type");
54
55
  }
55
56
  }
56
57
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"treeConversions.js","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAmF;AACnF,+EAAoG;AACpG,iCAA2E;AAC3E,+DAAwE;AAExE;;;GAGG;AACH,SAAgB,iCAAiC,CAAC,WAAyB;IAC1E,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,MAAM,gBAAgB,GAAG,IAAA,qDAA+B,EAAC,WAAW,CAAC,CAAC;IACtE,MAAM,iBAAiB,GAAG,gBAAgB;QACzC,CAAC,CAAC;YACA,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;YACrD,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;SAC/C;QACH,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,iBAAiB,EAAE;QAC7C,MAAM,CAAC,GAAG,gBAAgB,IAAI,GAAG,KAAK,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC;QACzE,QAAQ,KAAK,CAAC,IAAI,EAAE;YACnB,KAAK,kCAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,IAAI,aAAqB,CAAC;gBAC1B,IAAI,QAAQ,GAAuB,OAAO,CAAC;gBAC3C,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;oBACtC,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC;iBAC9B;qBAAM;oBACN,aAAa,GAAG,IAAA,iCAAkB,EAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;oBAC5D,QAAQ,GAAG,QAAQ,CAAC;iBACpB;gBACD,OAAO,CAAC,IAAI,CAAC,IAAI,oBAAa,CAAC,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAC5D,MAAM;aACN;YAED,KAAK,kCAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,IAAI,oBAAa,CAAC,CAAC,EAAE,iCAAiC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC7E,MAAM;aACN;YAED,KAAK,kCAAW,CAAC,UAAU,CAAC,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,0BAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;gBACnD,MAAM;aACN;YAED,KAAK,kCAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;aAC/D;YAED;gBACC,IAAA,8BAAe,EAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;SACxD;KACD;IACD,OAAO;QACN,OAAO;QACP,YAAY,EAAE,WAAW,CAAC,YAAY;KACtC,CAAC;AACH,CAAC;AAhDD,8EAgDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { ISummaryTree, ITree, ITreeEntry, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"./blob\";\nimport { isCombinedAppAndProtocolSummary } from \"./summaryForCreateNew\";\n\n/**\n * Converts ISummaryTree to ITree format.\n * @param summaryTree - summary tree in ISummaryTree format\n */\nexport function convertSummaryTreeToSnapshotITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tconst adaptSummaryTree = isCombinedAppAndProtocolSummary(summaryTree);\n\tconst allSummaryEntries = adaptSummaryTree\n\t\t? [\n\t\t\t\t...Object.entries(summaryTree.tree[\".protocol\"].tree),\n\t\t\t\t...Object.entries(summaryTree.tree[\".app\"].tree),\n\t\t ]\n\t\t: Object.entries(summaryTree.tree);\n\n\tfor (const [key, value] of allSummaryEntries) {\n\t\tconst k = adaptSummaryTree && key === \"attributes\" ? \".attributes\" : key;\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(k, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(k, convertSummaryTreeToSnapshotITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(k, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t};\n}\n"]}
1
+ {"version":3,"file":"treeConversions.js","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAkE;AAClE,2DAA6D;AAC7D,+EAAoG;AACpG,iCAA2E;AAC3E,+DAAwE;AAExE;;;GAGG;AACH,SAAgB,iCAAiC,CAAC,WAAyB;IAC1E,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,MAAM,gBAAgB,GAAG,IAAA,qDAA+B,EAAC,WAAW,CAAC,CAAC;IACtE,MAAM,iBAAiB,GAAG,gBAAgB;QACzC,CAAC,CAAC;YACA,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;YACrD,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;SAC/C;QACH,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,iBAAiB,EAAE;QAC7C,MAAM,CAAC,GAAG,gBAAgB,IAAI,GAAG,KAAK,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC;QACzE,QAAQ,KAAK,CAAC,IAAI,EAAE;YACnB,KAAK,kCAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,IAAI,aAAqB,CAAC;gBAC1B,IAAI,QAAQ,GAAuB,OAAO,CAAC;gBAC3C,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;oBACtC,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC;iBAC9B;qBAAM;oBACN,aAAa,GAAG,IAAA,iCAAkB,EAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;oBAC5D,QAAQ,GAAG,QAAQ,CAAC;iBACpB;gBACD,OAAO,CAAC,IAAI,CAAC,IAAI,oBAAa,CAAC,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAC5D,MAAM;aACN;YAED,KAAK,kCAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,IAAI,oBAAa,CAAC,CAAC,EAAE,iCAAiC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC7E,MAAM;aACN;YAED,KAAK,kCAAW,CAAC,UAAU,CAAC,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,0BAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;gBACnD,MAAM;aACN;YAED,KAAK,kCAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;aAC/D;YAED;gBACC,IAAA,4BAAe,EAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;SACxD;KACD;IACD,OAAO;QACN,OAAO;QACP,YAAY,EAAE,WAAW,CAAC,YAAY;KACtC,CAAC;AACH,CAAC;AAhDD,8EAgDC","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 { unreachableCase } from \"@fluidframework/core-utils\";\nimport { ISummaryTree, ITree, ITreeEntry, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"./blob\";\nimport { isCombinedAppAndProtocolSummary } from \"./summaryForCreateNew\";\n\n/**\n * Converts ISummaryTree to ITree format.\n * @param summaryTree - summary tree in ISummaryTree format\n */\nexport function convertSummaryTreeToSnapshotITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tconst adaptSummaryTree = isCombinedAppAndProtocolSummary(summaryTree);\n\tconst allSummaryEntries = adaptSummaryTree\n\t\t? [\n\t\t\t\t...Object.entries(summaryTree.tree[\".protocol\"].tree),\n\t\t\t\t...Object.entries(summaryTree.tree[\".app\"].tree),\n\t\t ]\n\t\t: Object.entries(summaryTree.tree);\n\n\tfor (const [key, value] of allSummaryEntries) {\n\t\tconst k = adaptSummaryTree && key === \"attributes\" ? \".attributes\" : key;\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(k, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(k, convertSummaryTreeToSnapshotITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(k, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t};\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export declare enum SummaryCompressionAlgorithm {
6
+ None = 0,
7
+ LZ4 = 1
8
+ }
9
+ export interface ICompressionStorageConfig {
10
+ algorithm: SummaryCompressionAlgorithm;
11
+ minSizeToCompress: number;
12
+ }
13
+ export declare const DefaultCompressionStorageConfig: {
14
+ algorithm: SummaryCompressionAlgorithm;
15
+ minSizeToCompress: number;
16
+ };
17
+ //# sourceMappingURL=compressionTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compressionTypes.d.ts","sourceRoot":"","sources":["../../../src/adapters/compression/compressionTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oBAAY,2BAA2B;IACtC,IAAI,IAAI;IACR,GAAG,IAAI;CACP;AAED,MAAM,WAAW,yBAAyB;IACzC,SAAS,EAAE,2BAA2B,CAAC;IACvC,iBAAiB,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,+BAA+B;;;CAG3C,CAAC"}
@@ -0,0 +1,14 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export var SummaryCompressionAlgorithm;
6
+ (function (SummaryCompressionAlgorithm) {
7
+ SummaryCompressionAlgorithm[SummaryCompressionAlgorithm["None"] = 0] = "None";
8
+ SummaryCompressionAlgorithm[SummaryCompressionAlgorithm["LZ4"] = 1] = "LZ4";
9
+ })(SummaryCompressionAlgorithm || (SummaryCompressionAlgorithm = {}));
10
+ export const DefaultCompressionStorageConfig = {
11
+ algorithm: SummaryCompressionAlgorithm.LZ4,
12
+ minSizeToCompress: 500,
13
+ };
14
+ //# sourceMappingURL=compressionTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compressionTypes.js","sourceRoot":"","sources":["../../../src/adapters/compression/compressionTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAN,IAAY,2BAGX;AAHD,WAAY,2BAA2B;IACtC,6EAAQ,CAAA;IACR,2EAAO,CAAA;AACR,CAAC,EAHW,2BAA2B,KAA3B,2BAA2B,QAGtC;AAOD,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC9C,SAAS,EAAE,2BAA2B,CAAC,GAAG;IAC1C,iBAAiB,EAAE,GAAG;CACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport enum SummaryCompressionAlgorithm {\n\tNone = 0,\n\tLZ4 = 1,\n}\n\nexport interface ICompressionStorageConfig {\n\talgorithm: SummaryCompressionAlgorithm;\n\tminSizeToCompress: number;\n}\n\nexport const DefaultCompressionStorageConfig = {\n\talgorithm: SummaryCompressionAlgorithm.LZ4,\n\tminSizeToCompress: 500,\n};\n"]}
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IDocumentService, IDocumentStorageService } from "@fluidframework/driver-definitions";
6
+ import { DocumentServiceProxy } from "../../documentServiceProxy";
7
+ import { ICompressionStorageConfig } from "./compressionTypes";
8
+ export declare class DocumentServiceCompressionAdapter extends DocumentServiceProxy {
9
+ private readonly _config;
10
+ constructor(service: IDocumentService, _config: ICompressionStorageConfig);
11
+ connectToStorage(): Promise<IDocumentStorageService>;
12
+ }
13
+ //# sourceMappingURL=documentServiceCompressionAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentServiceCompressionAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,qBAAa,iCAAkC,SAAQ,oBAAoB;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAnD,OAAO,EAAE,gBAAgB,EAAmB,OAAO,EAAE,yBAAyB;IAI7E,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC;CASjE"}
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { DocumentServiceProxy } from "../../documentServiceProxy";
6
+ import { DocumentStorageServiceCompressionAdapter as DocumentStorageServiceSummaryBlobCompressionAdapter } from "./summaryblob";
7
+ export class DocumentServiceCompressionAdapter extends DocumentServiceProxy {
8
+ constructor(service, _config) {
9
+ super(service);
10
+ this._config = _config;
11
+ }
12
+ async connectToStorage() {
13
+ const storage = await super.connectToStorage();
14
+ const wrapped = new DocumentStorageServiceSummaryBlobCompressionAdapter(storage, this._config);
15
+ await wrapped.getSnapshotTree();
16
+ return wrapped;
17
+ }
18
+ }
19
+ //# sourceMappingURL=documentServiceCompressionAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentServiceCompressionAdapter.js","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,wCAAwC,IAAI,mDAAmD,EAAE,MAAM,eAAe,CAAC;AAGhI,MAAM,OAAO,iCAAkC,SAAQ,oBAAoB;IAC1E,YAAY,OAAyB,EAAmB,OAAkC;QACzF,KAAK,CAAC,OAAO,CAAC,CAAC;QADwC,YAAO,GAAP,OAAO,CAA2B;IAE1F,CAAC;IAEM,KAAK,CAAC,gBAAgB;QAC5B,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,MAAM,OAAO,GAAG,IAAI,mDAAmD,CACtE,OAAO,EACP,IAAI,CAAC,OAAO,CACZ,CAAC;QACF,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IAChB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentService, IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { DocumentServiceProxy } from \"../../documentServiceProxy\";\nimport { DocumentStorageServiceCompressionAdapter as DocumentStorageServiceSummaryBlobCompressionAdapter } from \"./summaryblob\";\nimport { ICompressionStorageConfig } from \"./compressionTypes\";\n\nexport class DocumentServiceCompressionAdapter extends DocumentServiceProxy {\n\tconstructor(service: IDocumentService, private readonly _config: ICompressionStorageConfig) {\n\t\tsuper(service);\n\t}\n\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\tconst storage = await super.connectToStorage();\n\t\tconst wrapped = new DocumentStorageServiceSummaryBlobCompressionAdapter(\n\t\t\tstorage,\n\t\t\tthis._config,\n\t\t);\n\t\tawait wrapped.getSnapshotTree();\n\t\treturn wrapped;\n\t}\n}\n"]}
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
6
+ import { IDocumentService, IDocumentServiceFactory, IResolvedUrl } from "@fluidframework/driver-definitions";
7
+ import { ISummaryTree } from "@fluidframework/protocol-definitions";
8
+ import { DocumentServiceFactoryProxy } from "../../documentServiceFactoryProxy";
9
+ import { ICompressionStorageConfig } from "..";
10
+ export declare class DocumentServiceFactoryCompressionAdapter extends DocumentServiceFactoryProxy {
11
+ private readonly _config;
12
+ constructor(serviceFactory: IDocumentServiceFactory, _config: ICompressionStorageConfig);
13
+ createContainer(createNewSummary: ISummaryTree | undefined, createNewResolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
14
+ createDocumentService(resolvedUrl: IResolvedUrl): Promise<IDocumentService>;
15
+ }
16
+ //# sourceMappingURL=documentServiceFactoryCompressionAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentServiceFactoryCompressionAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceFactoryCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,IAAI,CAAC;AAI/C,qBAAa,wCAAyC,SAAQ,2BAA2B;IAGvF,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADxB,cAAc,EAAE,uBAAuB,EACtB,OAAO,EAAE,yBAAyB;IAKvC,eAAe,CAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,oBAAoB,EAAE,YAAY,EAClC,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IA2Bf,qBAAqB,CAAC,WAAW,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAIxF"}
@@ -0,0 +1,35 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { DocumentServiceFactoryProxy } from "../../documentServiceFactoryProxy";
6
+ import { DocumentStorageServiceCompressionAdapter as DocumentStorageServiceSummaryBlobCompressionAdapter } from "./summaryblob";
7
+ import { DocumentServiceCompressionAdapter } from "./documentServiceCompressionAdapter";
8
+ export class DocumentServiceFactoryCompressionAdapter extends DocumentServiceFactoryProxy {
9
+ constructor(serviceFactory, _config) {
10
+ super(serviceFactory);
11
+ this._config = _config;
12
+ }
13
+ async createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer) {
14
+ if (createNewSummary !== undefined) {
15
+ // TODO : this is a hack to make sure that the initial summary is not compressed
16
+ // We must prevent the initial summary from being compressed because
17
+ // of the hack at packages/drivers/routerlicious-driver/src/createNewUtils.ts
18
+ // where the binary blob is converted to a string using UTF-8 encoding
19
+ // which is producing incorrect results for compressed data.
20
+ const configForInitial = {
21
+ ...this._config,
22
+ minSizeToCompress: Number.POSITIVE_INFINITY,
23
+ };
24
+ const newAppSumary = DocumentStorageServiceSummaryBlobCompressionAdapter.compressSummary(createNewSummary.tree[".app"], configForInitial);
25
+ createNewSummary.tree[".app"] = newAppSumary;
26
+ }
27
+ const service = await this.serviceFactory.createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer);
28
+ return new DocumentServiceCompressionAdapter(service, this._config);
29
+ }
30
+ async createDocumentService(resolvedUrl) {
31
+ const service = await this.serviceFactory.createDocumentService(resolvedUrl);
32
+ return new DocumentServiceCompressionAdapter(service, this._config);
33
+ }
34
+ }
35
+ //# sourceMappingURL=documentServiceFactoryCompressionAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentServiceFactoryCompressionAdapter.js","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceFactoryCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,OAAO,EAAE,wCAAwC,IAAI,mDAAmD,EAAE,MAAM,eAAe,CAAC;AAChI,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,MAAM,OAAO,wCAAyC,SAAQ,2BAA2B;IACxF,YACC,cAAuC,EACtB,OAAkC;QAEnD,KAAK,CAAC,cAAc,CAAC,CAAC;QAFL,YAAO,GAAP,OAAO,CAA2B;IAGpD,CAAC;IAEM,KAAK,CAAC,eAAe,CAC3B,gBAA0C,EAC1C,oBAAkC,EAClC,MAA6B,EAC7B,kBAA4B;QAE5B,IAAI,gBAAgB,KAAK,SAAS,EAAE;YACnC,gFAAgF;YAChF,oEAAoE;YACpE,6EAA6E;YAC7E,sEAAsE;YACtE,4DAA4D;YAC5D,MAAM,gBAAgB,GAAG;gBACxB,GAAG,IAAI,CAAC,OAAO;gBACf,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;aAC3C,CAAC;YACF,MAAM,YAAY,GACjB,mDAAmD,CAAC,eAAe,CAClE,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAiB,EAC7C,gBAAgB,CAChB,CAAC;YACH,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC;SAC7C;QACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CACxD,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,EACN,kBAAkB,CAClB,CAAC;QACF,OAAO,IAAI,iCAAiC,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAAC,WAAyB;QAC3D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;QAC7E,OAAO,IAAI,iCAAiC,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { DocumentServiceFactoryProxy } from \"../../documentServiceFactoryProxy\";\nimport { ICompressionStorageConfig } from \"..\";\nimport { DocumentStorageServiceCompressionAdapter as DocumentStorageServiceSummaryBlobCompressionAdapter } from \"./summaryblob\";\nimport { DocumentServiceCompressionAdapter } from \"./documentServiceCompressionAdapter\";\n\nexport class DocumentServiceFactoryCompressionAdapter extends DocumentServiceFactoryProxy {\n\tconstructor(\n\t\tserviceFactory: IDocumentServiceFactory,\n\t\tprivate readonly _config: ICompressionStorageConfig,\n\t) {\n\t\tsuper(serviceFactory);\n\t}\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tcreateNewResolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (createNewSummary !== undefined) {\n\t\t\t// TODO : this is a hack to make sure that the initial summary is not compressed\n\t\t\t// We must prevent the initial summary from being compressed because\n\t\t\t// of the hack at packages/drivers/routerlicious-driver/src/createNewUtils.ts\n\t\t\t// where the binary blob is converted to a string using UTF-8 encoding\n\t\t\t// which is producing incorrect results for compressed data.\n\t\t\tconst configForInitial = {\n\t\t\t\t...this._config,\n\t\t\t\tminSizeToCompress: Number.POSITIVE_INFINITY,\n\t\t\t};\n\t\t\tconst newAppSumary =\n\t\t\t\tDocumentStorageServiceSummaryBlobCompressionAdapter.compressSummary(\n\t\t\t\t\tcreateNewSummary.tree[\".app\"] as ISummaryTree,\n\t\t\t\t\tconfigForInitial,\n\t\t\t\t);\n\t\t\tcreateNewSummary.tree[\".app\"] = newAppSumary;\n\t\t}\n\t\tconst service = await this.serviceFactory.createContainer(\n\t\t\tcreateNewSummary,\n\t\t\tcreateNewResolvedUrl,\n\t\t\tlogger,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t\treturn new DocumentServiceCompressionAdapter(service, this._config);\n\t}\n\n\tpublic async createDocumentService(resolvedUrl: IResolvedUrl): Promise<IDocumentService> {\n\t\tconst service = await this.serviceFactory.createDocumentService(resolvedUrl);\n\t\treturn new DocumentServiceCompressionAdapter(service, this._config);\n\t}\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { SummaryCompressionAlgorithm, ICompressionStorageConfig, DefaultCompressionStorageConfig, } from "./compressionTypes";
6
+ export { DocumentServiceFactoryCompressionAdapter } from "./documentServiceFactoryCompressionAdapter";
7
+ export { blobHeadersBlobName } from "./summaryblob";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/compression/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,2BAA2B,EAC3B,yBAAyB,EACzB,+BAA+B,GAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { SummaryCompressionAlgorithm, DefaultCompressionStorageConfig, } from "./compressionTypes";
6
+ export { DocumentServiceFactoryCompressionAdapter } from "./documentServiceFactoryCompressionAdapter";
7
+ export { blobHeadersBlobName } from "./summaryblob";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/compression/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,2BAA2B,EAE3B,+BAA+B,GAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tSummaryCompressionAlgorithm,\n\tICompressionStorageConfig,\n\tDefaultCompressionStorageConfig,\n} from \"./compressionTypes\";\nexport { DocumentServiceFactoryCompressionAdapter } from \"./documentServiceFactoryCompressionAdapter\";\nexport { blobHeadersBlobName } from \"./summaryblob\";\n"]}