@fluidframework/container-loader 2.0.0-rc.1.0.4 → 2.0.0-rc.2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +5 -6
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +48 -0
  4. package/README.md +3 -3
  5. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
  6. package/api-extractor-lint.json +1 -1
  7. package/api-extractor.json +1 -1
  8. package/api-report/container-loader.api.md +2 -2
  9. package/dist/attachment.d.ts +115 -0
  10. package/dist/attachment.d.ts.map +1 -0
  11. package/dist/attachment.js +83 -0
  12. package/dist/attachment.js.map +1 -0
  13. package/dist/audience.d.ts +9 -4
  14. package/dist/audience.d.ts.map +1 -1
  15. package/dist/audience.js +10 -4
  16. package/dist/audience.js.map +1 -1
  17. package/dist/connectionManager.d.ts +3 -3
  18. package/dist/connectionManager.d.ts.map +1 -1
  19. package/dist/connectionManager.js +17 -18
  20. package/dist/connectionManager.js.map +1 -1
  21. package/dist/connectionState.d.ts +1 -0
  22. package/dist/connectionState.d.ts.map +1 -1
  23. package/dist/connectionState.js +1 -0
  24. package/dist/connectionState.js.map +1 -1
  25. package/dist/connectionStateHandler.d.ts +7 -7
  26. package/dist/connectionStateHandler.d.ts.map +1 -1
  27. package/dist/connectionStateHandler.js +32 -32
  28. package/dist/connectionStateHandler.js.map +1 -1
  29. package/dist/container-loader-alpha.d.ts +2 -1
  30. package/dist/container-loader-beta.d.ts +3 -0
  31. package/dist/container-loader-public.d.ts +3 -0
  32. package/dist/container-loader-untrimmed.d.ts +5 -5
  33. package/dist/container.d.ts +29 -27
  34. package/dist/container.d.ts.map +1 -1
  35. package/dist/container.js +219 -284
  36. package/dist/container.js.map +1 -1
  37. package/dist/containerContext.d.ts +3 -2
  38. package/dist/containerContext.d.ts.map +1 -1
  39. package/dist/containerContext.js +2 -1
  40. package/dist/containerContext.js.map +1 -1
  41. package/dist/containerStorageAdapter.d.ts +5 -6
  42. package/dist/containerStorageAdapter.d.ts.map +1 -1
  43. package/dist/containerStorageAdapter.js +14 -21
  44. package/dist/containerStorageAdapter.js.map +1 -1
  45. package/dist/contracts.d.ts +3 -3
  46. package/dist/contracts.d.ts.map +1 -1
  47. package/dist/contracts.js.map +1 -1
  48. package/dist/debugLogger.js.map +1 -1
  49. package/dist/deltaManager.d.ts +5 -5
  50. package/dist/deltaManager.d.ts.map +1 -1
  51. package/dist/deltaManager.js +6 -6
  52. package/dist/deltaManager.js.map +1 -1
  53. package/dist/error.d.ts.map +1 -1
  54. package/dist/error.js.map +1 -1
  55. package/dist/index.d.ts +6 -6
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +11 -11
  58. package/dist/index.js.map +1 -1
  59. package/dist/loader.d.ts +3 -3
  60. package/dist/loader.d.ts.map +1 -1
  61. package/dist/loader.js +13 -17
  62. package/dist/loader.js.map +1 -1
  63. package/dist/location-redirection-utilities/index.d.ts +1 -1
  64. package/dist/location-redirection-utilities/index.d.ts.map +1 -1
  65. package/dist/location-redirection-utilities/index.js +3 -3
  66. package/dist/location-redirection-utilities/index.js.map +1 -1
  67. package/dist/package.json +3 -0
  68. package/dist/packageVersion.d.ts +1 -1
  69. package/dist/packageVersion.js +1 -1
  70. package/dist/packageVersion.js.map +1 -1
  71. package/dist/protocolTreeDocumentStorageService.d.ts +1 -1
  72. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  73. package/dist/protocolTreeDocumentStorageService.js +1 -3
  74. package/dist/protocolTreeDocumentStorageService.js.map +1 -1
  75. package/dist/retriableDocumentStorageService.d.ts +2 -2
  76. package/dist/retriableDocumentStorageService.d.ts.map +1 -1
  77. package/dist/retriableDocumentStorageService.js +8 -6
  78. package/dist/retriableDocumentStorageService.js.map +1 -1
  79. package/dist/serializedStateManager.d.ts +44 -0
  80. package/dist/serializedStateManager.d.ts.map +1 -0
  81. package/dist/serializedStateManager.js +149 -0
  82. package/dist/serializedStateManager.js.map +1 -0
  83. package/dist/tsdoc-metadata.json +1 -1
  84. package/dist/utils.d.ts +16 -11
  85. package/dist/utils.d.ts.map +1 -1
  86. package/dist/utils.js +107 -32
  87. package/dist/utils.js.map +1 -1
  88. package/lib/attachment.d.ts +115 -0
  89. package/lib/attachment.d.ts.map +1 -0
  90. package/lib/attachment.js +79 -0
  91. package/lib/attachment.js.map +1 -0
  92. package/lib/{audience.d.mts → audience.d.ts} +14 -5
  93. package/lib/audience.d.ts.map +1 -0
  94. package/lib/{audience.mjs → audience.js} +14 -4
  95. package/lib/audience.js.map +1 -0
  96. package/lib/{catchUpMonitor.d.mts → catchUpMonitor.d.ts} +1 -1
  97. package/lib/catchUpMonitor.d.ts.map +1 -0
  98. package/lib/{catchUpMonitor.mjs → catchUpMonitor.js} +1 -1
  99. package/lib/catchUpMonitor.js.map +1 -0
  100. package/lib/{connectionManager.d.mts → connectionManager.d.ts} +4 -4
  101. package/lib/connectionManager.d.ts.map +1 -0
  102. package/lib/{connectionManager.mjs → connectionManager.js} +7 -10
  103. package/lib/connectionManager.js.map +1 -0
  104. package/lib/{connectionState.d.mts → connectionState.d.ts} +2 -1
  105. package/lib/connectionState.d.ts.map +1 -0
  106. package/lib/{connectionState.mjs → connectionState.js} +2 -1
  107. package/lib/connectionState.js.map +1 -0
  108. package/lib/{connectionStateHandler.d.mts → connectionStateHandler.d.ts} +8 -8
  109. package/lib/connectionStateHandler.d.ts.map +1 -0
  110. package/lib/{connectionStateHandler.mjs → connectionStateHandler.js} +3 -3
  111. package/lib/connectionStateHandler.js.map +1 -0
  112. package/lib/{container-loader-alpha.d.mts → container-loader-alpha.d.ts} +2 -1
  113. package/lib/{container-loader-beta.d.mts → container-loader-beta.d.ts} +3 -0
  114. package/lib/{container-loader-public.d.mts → container-loader-public.d.ts} +3 -0
  115. package/lib/{container-loader-untrimmed.d.mts → container-loader-untrimmed.d.ts} +5 -5
  116. package/lib/{container.d.mts → container.d.ts} +30 -28
  117. package/lib/container.d.ts.map +1 -0
  118. package/lib/{container.mjs → container.js} +179 -247
  119. package/lib/container.js.map +1 -0
  120. package/lib/{containerContext.d.mts → containerContext.d.ts} +4 -3
  121. package/lib/containerContext.d.ts.map +1 -0
  122. package/lib/{containerContext.mjs → containerContext.js} +3 -2
  123. package/lib/containerContext.js.map +1 -0
  124. package/lib/{containerStorageAdapter.d.mts → containerStorageAdapter.d.ts} +6 -7
  125. package/lib/containerStorageAdapter.d.ts.map +1 -0
  126. package/lib/{containerStorageAdapter.mjs → containerStorageAdapter.js} +13 -20
  127. package/lib/containerStorageAdapter.js.map +1 -0
  128. package/lib/{contracts.d.mts → contracts.d.ts} +4 -4
  129. package/lib/contracts.d.ts.map +1 -0
  130. package/lib/{contracts.mjs → contracts.js} +1 -1
  131. package/lib/contracts.js.map +1 -0
  132. package/lib/{debugLogger.d.mts → debugLogger.d.ts} +1 -1
  133. package/lib/debugLogger.d.ts.map +1 -0
  134. package/lib/{debugLogger.mjs → debugLogger.js} +2 -1
  135. package/lib/debugLogger.js.map +1 -0
  136. package/lib/{deltaManager.d.mts → deltaManager.d.ts} +6 -6
  137. package/lib/deltaManager.d.ts.map +1 -0
  138. package/lib/{deltaManager.mjs → deltaManager.js} +4 -4
  139. package/lib/deltaManager.js.map +1 -0
  140. package/lib/{deltaQueue.d.mts → deltaQueue.d.ts} +1 -1
  141. package/lib/deltaQueue.d.ts.map +1 -0
  142. package/lib/{deltaQueue.mjs → deltaQueue.js} +1 -1
  143. package/lib/deltaQueue.js.map +1 -0
  144. package/lib/{disposal.d.mts → disposal.d.ts} +1 -1
  145. package/lib/disposal.d.ts.map +1 -0
  146. package/lib/{disposal.mjs → disposal.js} +1 -1
  147. package/lib/disposal.js.map +1 -0
  148. package/lib/{error.d.mts → error.d.ts} +1 -1
  149. package/lib/error.d.ts.map +1 -0
  150. package/lib/{error.mjs → error.js} +1 -1
  151. package/lib/error.js.map +1 -0
  152. package/lib/{index.d.mts → index.d.ts} +7 -7
  153. package/lib/index.d.ts.map +1 -0
  154. package/lib/index.js +10 -0
  155. package/lib/index.js.map +1 -0
  156. package/lib/{loader.d.mts → loader.d.ts} +4 -4
  157. package/lib/loader.d.ts.map +1 -0
  158. package/lib/{loader.mjs → loader.js} +7 -11
  159. package/lib/loader.js.map +1 -0
  160. package/lib/location-redirection-utilities/{index.mjs → index.d.ts} +2 -2
  161. package/lib/location-redirection-utilities/index.d.ts.map +1 -0
  162. package/lib/location-redirection-utilities/{index.d.mts → index.js} +2 -2
  163. package/lib/location-redirection-utilities/index.js.map +1 -0
  164. package/lib/location-redirection-utilities/{resolveWithLocationRedirection.d.mts → resolveWithLocationRedirection.d.ts} +1 -1
  165. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
  166. package/lib/location-redirection-utilities/{resolveWithLocationRedirection.mjs → resolveWithLocationRedirection.js} +1 -1
  167. package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -0
  168. package/lib/{noopHeuristic.d.mts → noopHeuristic.d.ts} +1 -1
  169. package/lib/noopHeuristic.d.ts.map +1 -0
  170. package/lib/{noopHeuristic.mjs → noopHeuristic.js} +1 -1
  171. package/lib/noopHeuristic.js.map +1 -0
  172. package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
  173. package/lib/packageVersion.d.ts.map +1 -0
  174. package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
  175. package/lib/packageVersion.js.map +1 -0
  176. package/lib/{protocol.d.mts → protocol.d.ts} +1 -1
  177. package/lib/protocol.d.ts.map +1 -0
  178. package/lib/{protocol.mjs → protocol.js} +1 -1
  179. package/lib/protocol.js.map +1 -0
  180. package/lib/{protocolTreeDocumentStorageService.d.mts → protocolTreeDocumentStorageService.d.ts} +2 -2
  181. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -0
  182. package/lib/{protocolTreeDocumentStorageService.mjs → protocolTreeDocumentStorageService.js} +2 -4
  183. package/lib/protocolTreeDocumentStorageService.js.map +1 -0
  184. package/lib/{quorum.d.mts → quorum.d.ts} +5 -1
  185. package/lib/quorum.d.ts.map +1 -0
  186. package/lib/{quorum.mjs → quorum.js} +1 -1
  187. package/lib/quorum.js.map +1 -0
  188. package/lib/{retriableDocumentStorageService.d.mts → retriableDocumentStorageService.d.ts} +3 -3
  189. package/lib/retriableDocumentStorageService.d.ts.map +1 -0
  190. package/lib/{retriableDocumentStorageService.mjs → retriableDocumentStorageService.js} +10 -8
  191. package/lib/retriableDocumentStorageService.js.map +1 -0
  192. package/lib/serializedStateManager.d.ts +44 -0
  193. package/lib/serializedStateManager.d.ts.map +1 -0
  194. package/lib/serializedStateManager.js +145 -0
  195. package/lib/serializedStateManager.js.map +1 -0
  196. package/lib/test/attachment.spec.js +380 -0
  197. package/lib/test/attachment.spec.js.map +1 -0
  198. package/lib/test/catchUpMonitor.spec.js +88 -0
  199. package/lib/test/catchUpMonitor.spec.js.map +1 -0
  200. package/lib/test/connectionManager.spec.js +201 -0
  201. package/lib/test/connectionManager.spec.js.map +1 -0
  202. package/lib/test/connectionStateHandler.spec.js +555 -0
  203. package/lib/test/connectionStateHandler.spec.js.map +1 -0
  204. package/lib/test/container.spec.js +64 -0
  205. package/lib/test/container.spec.js.map +1 -0
  206. package/lib/test/deltaManager.spec.js +405 -0
  207. package/lib/test/deltaManager.spec.js.map +1 -0
  208. package/lib/test/loader.spec.js +212 -0
  209. package/lib/test/loader.spec.js.map +1 -0
  210. package/lib/test/locationRedirectionTests.spec.js +44 -0
  211. package/lib/test/locationRedirectionTests.spec.js.map +1 -0
  212. package/lib/test/serializedStateManager.spec.js +148 -0
  213. package/lib/test/serializedStateManager.spec.js.map +1 -0
  214. package/lib/test/snapshotConversionTest.spec.js +79 -0
  215. package/lib/test/snapshotConversionTest.spec.js.map +1 -0
  216. package/lib/test/types/validateContainerLoaderPrevious.generated.js +38 -0
  217. package/lib/test/types/validateContainerLoaderPrevious.generated.js.map +1 -0
  218. package/lib/test/utils.spec.js +31 -0
  219. package/lib/test/utils.spec.js.map +1 -0
  220. package/lib/{utils.d.mts → utils.d.ts} +17 -12
  221. package/lib/utils.d.ts.map +1 -0
  222. package/lib/utils.js +206 -0
  223. package/lib/utils.js.map +1 -0
  224. package/package.json +63 -63
  225. package/src/attachment.ts +222 -0
  226. package/src/audience.ts +9 -3
  227. package/src/connectionManager.ts +9 -11
  228. package/src/connectionState.ts +1 -0
  229. package/src/connectionStateHandler.ts +8 -7
  230. package/src/container.ts +297 -323
  231. package/src/containerContext.ts +2 -1
  232. package/src/containerStorageAdapter.ts +21 -26
  233. package/src/contracts.ts +3 -3
  234. package/src/debugLogger.ts +2 -2
  235. package/src/deltaManager.ts +8 -8
  236. package/src/error.ts +2 -2
  237. package/src/index.ts +6 -6
  238. package/src/loader.ts +9 -13
  239. package/src/location-redirection-utilities/index.ts +1 -1
  240. package/src/packageVersion.ts +1 -1
  241. package/src/protocolTreeDocumentStorageService.ts +1 -3
  242. package/src/retriableDocumentStorageService.ts +18 -8
  243. package/src/serializedStateManager.ts +217 -0
  244. package/src/utils.ts +140 -43
  245. package/tsconfig.cjs.json +7 -0
  246. package/tsconfig.json +2 -5
  247. package/lib/audience.d.mts.map +0 -1
  248. package/lib/audience.mjs.map +0 -1
  249. package/lib/catchUpMonitor.d.mts.map +0 -1
  250. package/lib/catchUpMonitor.mjs.map +0 -1
  251. package/lib/connectionManager.d.mts.map +0 -1
  252. package/lib/connectionManager.mjs.map +0 -1
  253. package/lib/connectionState.d.mts.map +0 -1
  254. package/lib/connectionState.mjs.map +0 -1
  255. package/lib/connectionStateHandler.d.mts.map +0 -1
  256. package/lib/connectionStateHandler.mjs.map +0 -1
  257. package/lib/container.d.mts.map +0 -1
  258. package/lib/container.mjs.map +0 -1
  259. package/lib/containerContext.d.mts.map +0 -1
  260. package/lib/containerContext.mjs.map +0 -1
  261. package/lib/containerStorageAdapter.d.mts.map +0 -1
  262. package/lib/containerStorageAdapter.mjs.map +0 -1
  263. package/lib/contracts.d.mts.map +0 -1
  264. package/lib/contracts.mjs.map +0 -1
  265. package/lib/debugLogger.d.mts.map +0 -1
  266. package/lib/debugLogger.mjs.map +0 -1
  267. package/lib/deltaManager.d.mts.map +0 -1
  268. package/lib/deltaManager.mjs.map +0 -1
  269. package/lib/deltaQueue.d.mts.map +0 -1
  270. package/lib/deltaQueue.mjs.map +0 -1
  271. package/lib/disposal.d.mts.map +0 -1
  272. package/lib/disposal.mjs.map +0 -1
  273. package/lib/error.d.mts.map +0 -1
  274. package/lib/error.mjs.map +0 -1
  275. package/lib/index.d.mts.map +0 -1
  276. package/lib/index.mjs +0 -10
  277. package/lib/index.mjs.map +0 -1
  278. package/lib/loader.d.mts.map +0 -1
  279. package/lib/loader.mjs.map +0 -1
  280. package/lib/location-redirection-utilities/index.d.mts.map +0 -1
  281. package/lib/location-redirection-utilities/index.mjs.map +0 -1
  282. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.mts.map +0 -1
  283. package/lib/location-redirection-utilities/resolveWithLocationRedirection.mjs.map +0 -1
  284. package/lib/noopHeuristic.d.mts.map +0 -1
  285. package/lib/noopHeuristic.mjs.map +0 -1
  286. package/lib/packageVersion.d.mts.map +0 -1
  287. package/lib/packageVersion.mjs.map +0 -1
  288. package/lib/protocol.d.mts.map +0 -1
  289. package/lib/protocol.mjs.map +0 -1
  290. package/lib/protocolTreeDocumentStorageService.d.mts.map +0 -1
  291. package/lib/protocolTreeDocumentStorageService.mjs.map +0 -1
  292. package/lib/quorum.d.mts.map +0 -1
  293. package/lib/quorum.mjs.map +0 -1
  294. package/lib/retriableDocumentStorageService.d.mts.map +0 -1
  295. package/lib/retriableDocumentStorageService.mjs.map +0 -1
  296. package/lib/utils.d.mts.map +0 -1
  297. package/lib/utils.mjs +0 -133
  298. package/lib/utils.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+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pB;YACC,WAAW;YACX,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,OAAO,CAAC,IAAI,SAAS;YAC7D,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,QAAQ,CAAC;YAClD,iBAAiB;YACjB,oBAAoB,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,cAAc,CAAC;SACpE,EACD;YACC,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,SAAS,CAAC;YACvD,qBAAqB,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,aAAa,CAAC;YACpE,GAAG,IAAI,CAAC,QAAQ;SAChB,CACD,CAAC;IACH,CAAC;CACD;AAnKD,wBAmKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tITelemetryLoggerExt,\n\tmixinMonitoringContext,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tsessionStorageConfigProvider,\n\tcreateChildMonitoringContext,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tFluidObject,\n\tIRequest,\n\tIConfigProviderBase,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tIContainer,\n\tIFluidModule,\n\tIHostLoader,\n\tILoader,\n\tILoaderOptions as ILoaderOptions1,\n\tLoaderHeader,\n\tIProvideFluidCodeDetailsComparer,\n\tIFluidCodeDetails,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { IClientDetails } from \"@fluidframework/protocol-definitions\";\nimport { Container, IPendingContainerState } from \"./container\";\nimport { IParsedUrl, tryParseCompatibleResolvedUrl } from \"./utils\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { ProtocolHandlerBuilder } from \"./protocol\";\nimport { DebugLogger } from \"./debugLogger\";\n\nfunction ensureResolvedUrlDefined(\n\tresolved: IResolvedUrl | undefined,\n): asserts resolved is IResolvedUrl {\n\tif (resolved === undefined) {\n\t\tthrow new Error(`Object is not a IResolveUrl.`);\n\t}\n}\n/**\n * @internal\n */\nexport class RelativeLoader implements ILoader {\n\tconstructor(\n\t\tprivate readonly container: Container,\n\t\tprivate readonly loader: ILoader | undefined,\n\t) {}\n\n\tpublic async resolve(request: IRequest): Promise<IContainer> {\n\t\tif (request.url.startsWith(\"/\")) {\n\t\t\tensureResolvedUrlDefined(this.container.resolvedUrl);\n\t\t\tconst container = await this.container.clone(\n\t\t\t\t{\n\t\t\t\t\tresolvedUrl: { ...this.container.resolvedUrl },\n\t\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn container;\n\t\t}\n\n\t\tif (this.loader === undefined) {\n\t\t\tthrow new Error(\"Cannot resolve external containers\");\n\t\t}\n\t\treturn this.loader.resolve(request);\n\t}\n}\n\n/**\n * @alpha\n */\nexport interface ILoaderOptions extends ILoaderOptions1 {\n\tsummarizeProtocolTree?: boolean;\n}\n\n/**\n * @deprecated IFluidModuleWithDetails interface is moved to\n * {@link @fluidframework/container-definitions#IFluidModuleWithDetails}\n * to have all the code loading modules in one package. #8193\n * Encapsulates a module entry point with corresponding code details.\n * @alpha\n */\nexport interface IFluidModuleWithDetails {\n\t/** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n\tmodule: IFluidModule;\n\t/**\n\t * Code details associated with the module. Represents a document schema this module supports.\n\t * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n\t * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n\t */\n\tdetails: IFluidCodeDetails;\n}\n\n/**\n * @deprecated ICodeDetailsLoader interface is moved to {@link @fluidframework/container-definition#ICodeDetailsLoader}\n * to have code loading modules in one package. #8193\n * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as\n * a package name and package version range.\n * @alpha\n */\nexport interface ICodeDetailsLoader extends Partial<IProvideFluidCodeDetailsComparer> {\n\t/**\n\t * Load the code module (package) that is capable to interact with the document.\n\t *\n\t * @param source - Code proposal that articulates the current schema the document is written in.\n\t * @returns Code module entry point along with the code details associated with it.\n\t */\n\tload(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n * @alpha\n */\nexport interface ILoaderProps {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options?: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope?: FluidObject;\n\n\t/**\n\t * The logger that all telemetry should be pushed to.\n\t */\n\treadonly logger?: ITelemetryBaseLogger;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * The configuration provider which may be used to control features.\n\t */\n\treadonly configProvider?: IConfigProviderBase;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Services and properties used by and exposed by the loader\n * @alpha\n */\nexport interface ILoaderServices {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope: FluidObject;\n\n\t/**\n\t * The logger downstream consumers should construct their loggers from\n\t */\n\treadonly subLogger: ITelemetryLoggerExt;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Subset of IDocumentStorageService which only supports createBlob() and readBlob(). This is used to support\n * blobs in detached containers.\n * @alpha\n */\nexport type IDetachedBlobStorage = Pick<IDocumentStorageService, \"createBlob\" | \"readBlob\"> & {\n\tsize: number;\n\t/**\n\t * Return an array of all blob IDs present in storage\n\t */\n\tgetBlobIds(): string[];\n};\n\n/**\n * Manages Fluid resource loading\n * @alpha\n */\nexport class Loader implements IHostLoader {\n\tpublic readonly services: ILoaderServices;\n\tprivate readonly mc: MonitoringContext;\n\n\tconstructor(loaderProps: ILoaderProps) {\n\t\tconst {\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions,\n\t\t\tscope,\n\t\t\tlogger,\n\t\t\tdetachedBlobStorage,\n\t\t\tconfigProvider,\n\t\t\tprotocolHandlerBuilder,\n\t\t} = loaderProps;\n\n\t\tconst telemetryProps = {\n\t\t\tloaderId: uuid(),\n\t\t\tloaderVersion: pkgVersion,\n\t\t};\n\n\t\tconst subMc = mixinMonitoringContext(\n\t\t\tDebugLogger.mixinDebugLogger(\"fluid:telemetry\", logger, {\n\t\t\t\tall: telemetryProps,\n\t\t\t}),\n\t\t\tsessionStorageConfigProvider.value,\n\t\t\tconfigProvider,\n\t\t);\n\n\t\tthis.services = {\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions: options ?? {},\n\t\t\tscope:\n\t\t\t\toptions?.provideScopeLoader !== false ? { ...scope, ILoader: this } : { ...scope },\n\t\t\tdetachedBlobStorage,\n\t\t\tprotocolHandlerBuilder,\n\t\t\tsubLogger: subMc.logger,\n\t\t};\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: this.services.subLogger,\n\t\t\tnamespace: \"Loader\",\n\t\t});\n\t}\n\n\tpublic async createDetachedContainer(\n\t\tcodeDetails: IFluidCodeDetails,\n\t\tcreateDetachedProps?: {\n\t\t\tcanReconnect?: boolean;\n\t\t\tclientDetailsOverride?: IClientDetails;\n\t\t},\n\t): Promise<IContainer> {\n\t\treturn Container.createDetached(\n\t\t\t{\n\t\t\t\t...createDetachedProps,\n\t\t\t\t...this.services,\n\t\t\t},\n\t\t\tcodeDetails,\n\t\t);\n\t}\n\n\tpublic async rehydrateDetachedContainerFromSnapshot(\n\t\tsnapshot: string,\n\t\tcreateDetachedProps?: {\n\t\t\tcanReconnect?: boolean;\n\t\t\tclientDetailsOverride?: IClientDetails;\n\t\t},\n\t): Promise<IContainer> {\n\t\treturn Container.rehydrateDetachedFromSnapshot(\n\t\t\t{\n\t\t\t\t...createDetachedProps,\n\t\t\t\t...this.services,\n\t\t\t},\n\t\t\tsnapshot,\n\t\t);\n\t}\n\n\tpublic async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {\n\t\tconst eventName = pendingLocalState === undefined ? \"Resolve\" : \"ResolveWithPendingState\";\n\t\treturn PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {\n\t\t\tconst resolved = await this.resolveCore(\n\t\t\t\trequest,\n\t\t\t\tpendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,\n\t\t\t);\n\t\t\treturn resolved.container;\n\t\t});\n\t}\n\n\tprivate async resolveCore(\n\t\trequest: IRequest,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<{ container: Container; parsed: IParsedUrl }> {\n\t\tconst resolvedAsFluid = await this.services.urlResolver.resolve(request);\n\t\tensureResolvedUrlDefined(resolvedAsFluid);\n\n\t\t// Parse URL into data stores\n\t\tconst parsed = tryParseCompatibleResolvedUrl(resolvedAsFluid.url);\n\t\tif (parsed === undefined) {\n\t\t\tthrow new Error(`Invalid URL ${resolvedAsFluid.url}`);\n\t\t}\n\n\t\tif (pendingLocalState !== undefined) {\n\t\t\tconst parsedPendingUrl = tryParseCompatibleResolvedUrl(pendingLocalState.url);\n\t\t\tif (\n\t\t\t\tparsedPendingUrl?.id !== parsed.id ||\n\t\t\t\tparsedPendingUrl?.path.replace(/\\/$/, \"\") !== parsed.path.replace(/\\/$/, \"\")\n\t\t\t) {\n\t\t\t\tconst message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;\n\t\t\t\tthrow new Error(message);\n\t\t\t}\n\t\t}\n\n\t\trequest.headers ??= {};\n\t\t// If set in both query string and headers, use query string. Also write the value from the query string into the header either way.\n\t\trequest.headers[LoaderHeader.version] =\n\t\t\tparsed.version ?? request.headers[LoaderHeader.version];\n\t\tconst fromSequenceNumber = request.headers[LoaderHeader.sequenceNumber] as\n\t\t\t| number\n\t\t\t| undefined;\n\t\tconst opsBeforeReturn = request.headers[LoaderHeader.loadMode]?.opsBeforeReturn as\n\t\t\t| string\n\t\t\t| undefined;\n\n\t\tif (\n\t\t\topsBeforeReturn === \"sequenceNumber\" &&\n\t\t\t(fromSequenceNumber === undefined || fromSequenceNumber < 0)\n\t\t) {\n\t\t\t// If opsBeforeReturn is set to \"sequenceNumber\", then fromSequenceNumber should be set to a non-negative integer.\n\t\t\tthrow new UsageError(\"sequenceNumber must be set to a non-negative integer\");\n\t\t} else if (opsBeforeReturn !== \"sequenceNumber\" && fromSequenceNumber !== undefined) {\n\t\t\t// If opsBeforeReturn is not set to \"sequenceNumber\", then fromSequenceNumber should be undefined (default value).\n\t\t\t// In this case, we should throw an error since opsBeforeReturn is not explicitly set to \"sequenceNumber\".\n\t\t\tthrow new UsageError('opsBeforeReturn must be set to \"sequenceNumber\"');\n\t\t}\n\n\t\treturn {\n\t\t\tcontainer: await this.loadContainer(request, resolvedAsFluid, pendingLocalState),\n\t\t\tparsed,\n\t\t};\n\t}\n\n\tprivate async loadContainer(\n\t\trequest: IRequest,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<Container> {\n\t\treturn Container.load(\n\t\t\t{\n\t\t\t\tresolvedUrl,\n\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\tpendingLocalState,\n\t\t\t\tloadToSequenceNumber: request.headers?.[LoaderHeader.sequenceNumber],\n\t\t\t},\n\t\t\t{\n\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t...this.services,\n\t\t\t},\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAClC,qEAQyC;AAOzC,iFAS+C;AAQ/C,iDAAmE;AAC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AAY,CAAC,QAAQ,CAAC;YAClD,iBAAiB;YACjB,oBAAoB,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,cAAc,CAAC;SACpE,EACD;YACC,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,SAAS,CAAC;YACvD,qBAAqB,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,aAAa,CAAC;YACpE,GAAG,IAAI,CAAC,QAAQ;SAChB,CACD,CAAC;IACH,CAAC;CACD;AA/JD,wBA+JC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tITelemetryLoggerExt,\n\tmixinMonitoringContext,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tsessionStorageConfigProvider,\n\tcreateChildMonitoringContext,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tFluidObject,\n\tIRequest,\n\tIConfigProviderBase,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tIContainer,\n\tIFluidModule,\n\tIHostLoader,\n\tILoader,\n\tILoaderOptions as ILoaderOptions1,\n\tLoaderHeader,\n\tIProvideFluidCodeDetailsComparer,\n\tIFluidCodeDetails,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { IClientDetails } from \"@fluidframework/protocol-definitions\";\nimport { Container, IPendingContainerState } from \"./container.js\";\nimport { tryParseCompatibleResolvedUrl } from \"./utils.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\nimport { ProtocolHandlerBuilder } from \"./protocol.js\";\nimport { DebugLogger } from \"./debugLogger.js\";\n\nfunction ensureResolvedUrlDefined(\n\tresolved: IResolvedUrl | undefined,\n): asserts resolved is IResolvedUrl {\n\tif (resolved === undefined) {\n\t\tthrow new Error(`Object is not a IResolveUrl.`);\n\t}\n}\n/**\n * @internal\n */\nexport class RelativeLoader implements ILoader {\n\tconstructor(\n\t\tprivate readonly container: Container,\n\t\tprivate readonly loader: ILoader | undefined,\n\t) {}\n\n\tpublic async resolve(request: IRequest): Promise<IContainer> {\n\t\tif (request.url.startsWith(\"/\")) {\n\t\t\tensureResolvedUrlDefined(this.container.resolvedUrl);\n\t\t\tconst container = await this.container.clone(\n\t\t\t\t{\n\t\t\t\t\tresolvedUrl: { ...this.container.resolvedUrl },\n\t\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn container;\n\t\t}\n\n\t\tif (this.loader === undefined) {\n\t\t\tthrow new Error(\"Cannot resolve external containers\");\n\t\t}\n\t\treturn this.loader.resolve(request);\n\t}\n}\n\n/**\n * @alpha\n */\nexport interface ILoaderOptions extends ILoaderOptions1 {\n\tsummarizeProtocolTree?: boolean;\n}\n\n/**\n * @deprecated IFluidModuleWithDetails interface is moved to\n * {@link @fluidframework/container-definitions#IFluidModuleWithDetails}\n * to have all the code loading modules in one package. #8193\n * Encapsulates a module entry point with corresponding code details.\n * @alpha\n */\nexport interface IFluidModuleWithDetails {\n\t/** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n\tmodule: IFluidModule;\n\t/**\n\t * Code details associated with the module. Represents a document schema this module supports.\n\t * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n\t * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n\t */\n\tdetails: IFluidCodeDetails;\n}\n\n/**\n * @deprecated ICodeDetailsLoader interface is moved to {@link @fluidframework/container-definitions#ICodeDetailsLoader}\n * to have code loading modules in one package. #8193\n * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as\n * a package name and package version range.\n * @alpha\n */\nexport interface ICodeDetailsLoader extends Partial<IProvideFluidCodeDetailsComparer> {\n\t/**\n\t * Load the code module (package) that is capable to interact with the document.\n\t *\n\t * @param source - Code proposal that articulates the current schema the document is written in.\n\t * @returns Code module entry point along with the code details associated with it.\n\t */\n\tload(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n * @alpha\n */\nexport interface ILoaderProps {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options?: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope?: FluidObject;\n\n\t/**\n\t * The logger that all telemetry should be pushed to.\n\t */\n\treadonly logger?: ITelemetryBaseLogger;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * The configuration provider which may be used to control features.\n\t */\n\treadonly configProvider?: IConfigProviderBase;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Services and properties used by and exposed by the loader\n * @alpha\n */\nexport interface ILoaderServices {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope: FluidObject;\n\n\t/**\n\t * The logger downstream consumers should construct their loggers from\n\t */\n\treadonly subLogger: ITelemetryLoggerExt;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Subset of IDocumentStorageService which only supports createBlob() and readBlob(). This is used to support\n * blobs in detached containers.\n * @alpha\n */\nexport type IDetachedBlobStorage = Pick<IDocumentStorageService, \"createBlob\" | \"readBlob\"> & {\n\tsize: number;\n\t/**\n\t * Return an array of all blob IDs present in storage\n\t */\n\tgetBlobIds(): string[];\n};\n\n/**\n * Manages Fluid resource loading\n * @alpha\n */\nexport class Loader implements IHostLoader {\n\tpublic readonly services: ILoaderServices;\n\tprivate readonly mc: MonitoringContext;\n\n\tconstructor(loaderProps: ILoaderProps) {\n\t\tconst {\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions,\n\t\t\tscope,\n\t\t\tlogger,\n\t\t\tdetachedBlobStorage,\n\t\t\tconfigProvider,\n\t\t\tprotocolHandlerBuilder,\n\t\t} = loaderProps;\n\n\t\tconst telemetryProps = {\n\t\t\tloaderId: uuid(),\n\t\t\tloaderVersion: pkgVersion,\n\t\t};\n\n\t\tconst subMc = mixinMonitoringContext(\n\t\t\tDebugLogger.mixinDebugLogger(\"fluid:telemetry\", logger, {\n\t\t\t\tall: telemetryProps,\n\t\t\t}),\n\t\t\tsessionStorageConfigProvider.value,\n\t\t\tconfigProvider,\n\t\t);\n\n\t\tthis.services = {\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions: options ?? {},\n\t\t\tscope:\n\t\t\t\toptions?.provideScopeLoader !== false ? { ...scope, ILoader: this } : { ...scope },\n\t\t\tdetachedBlobStorage,\n\t\t\tprotocolHandlerBuilder,\n\t\t\tsubLogger: subMc.logger,\n\t\t};\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: this.services.subLogger,\n\t\t\tnamespace: \"Loader\",\n\t\t});\n\t}\n\n\tpublic async createDetachedContainer(\n\t\tcodeDetails: IFluidCodeDetails,\n\t\tcreateDetachedProps?: {\n\t\t\tcanReconnect?: boolean;\n\t\t\tclientDetailsOverride?: IClientDetails;\n\t\t},\n\t): Promise<IContainer> {\n\t\treturn Container.createDetached(\n\t\t\t{\n\t\t\t\t...createDetachedProps,\n\t\t\t\t...this.services,\n\t\t\t},\n\t\t\tcodeDetails,\n\t\t);\n\t}\n\n\tpublic async rehydrateDetachedContainerFromSnapshot(\n\t\tsnapshot: string,\n\t\tcreateDetachedProps?: {\n\t\t\tcanReconnect?: boolean;\n\t\t\tclientDetailsOverride?: IClientDetails;\n\t\t},\n\t): Promise<IContainer> {\n\t\treturn Container.rehydrateDetachedFromSnapshot(\n\t\t\t{\n\t\t\t\t...createDetachedProps,\n\t\t\t\t...this.services,\n\t\t\t},\n\t\t\tsnapshot,\n\t\t);\n\t}\n\n\tpublic async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {\n\t\tconst eventName = pendingLocalState === undefined ? \"Resolve\" : \"ResolveWithPendingState\";\n\t\treturn PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {\n\t\t\treturn this.resolveCore(\n\t\t\t\trequest,\n\t\t\t\tpendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async resolveCore(\n\t\trequest: IRequest,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<Container> {\n\t\tconst resolvedAsFluid = await this.services.urlResolver.resolve(request);\n\t\tensureResolvedUrlDefined(resolvedAsFluid);\n\n\t\t// Parse URL into data stores\n\t\tconst parsed = tryParseCompatibleResolvedUrl(resolvedAsFluid.url);\n\t\tif (parsed === undefined) {\n\t\t\tthrow new Error(`Invalid URL ${resolvedAsFluid.url}`);\n\t\t}\n\n\t\tif (pendingLocalState !== undefined) {\n\t\t\tconst parsedPendingUrl = tryParseCompatibleResolvedUrl(pendingLocalState.url);\n\t\t\tif (\n\t\t\t\tparsedPendingUrl?.id !== parsed.id ||\n\t\t\t\tparsedPendingUrl?.path.replace(/\\/$/, \"\") !== parsed.path.replace(/\\/$/, \"\")\n\t\t\t) {\n\t\t\t\tconst message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;\n\t\t\t\tthrow new Error(message);\n\t\t\t}\n\t\t}\n\n\t\trequest.headers ??= {};\n\t\t// If set in both query string and headers, use query string. Also write the value from the query string into the header either way.\n\t\trequest.headers[LoaderHeader.version] =\n\t\t\tparsed.version ?? request.headers[LoaderHeader.version];\n\t\tconst fromSequenceNumber = request.headers[LoaderHeader.sequenceNumber] as\n\t\t\t| number\n\t\t\t| undefined;\n\t\tconst opsBeforeReturn = request.headers[LoaderHeader.loadMode]?.opsBeforeReturn as\n\t\t\t| string\n\t\t\t| undefined;\n\n\t\tif (\n\t\t\topsBeforeReturn === \"sequenceNumber\" &&\n\t\t\t(fromSequenceNumber === undefined || fromSequenceNumber < 0)\n\t\t) {\n\t\t\t// If opsBeforeReturn is set to \"sequenceNumber\", then fromSequenceNumber should be set to a non-negative integer.\n\t\t\tthrow new UsageError(\"sequenceNumber must be set to a non-negative integer\");\n\t\t} else if (opsBeforeReturn !== \"sequenceNumber\" && fromSequenceNumber !== undefined) {\n\t\t\t// If opsBeforeReturn is not set to \"sequenceNumber\", then fromSequenceNumber should be undefined (default value).\n\t\t\t// In this case, we should throw an error since opsBeforeReturn is not explicitly set to \"sequenceNumber\".\n\t\t\tthrow new UsageError('opsBeforeReturn must be set to \"sequenceNumber\"');\n\t\t}\n\n\t\treturn this.loadContainer(request, resolvedAsFluid, pendingLocalState);\n\t}\n\n\tprivate async loadContainer(\n\t\trequest: IRequest,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<Container> {\n\t\treturn Container.load(\n\t\t\t{\n\t\t\t\tresolvedUrl,\n\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\tpendingLocalState,\n\t\t\t\tloadToSequenceNumber: request.headers?.[LoaderHeader.sequenceNumber],\n\t\t\t},\n\t\t\t{\n\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t...this.services,\n\t\t\t},\n\t\t);\n\t}\n}\n"]}
@@ -2,5 +2,5 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { isLocationRedirectionError, resolveWithLocationRedirectionHandling, } from "./resolveWithLocationRedirection";
5
+ export { isLocationRedirectionError, resolveWithLocationRedirectionHandling, } from "./resolveWithLocationRedirection.js";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/location-redirection-utilities/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,0BAA0B,EAC1B,sCAAsC,GACtC,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/location-redirection-utilities/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,0BAA0B,EAC1B,sCAAsC,GACtC,MAAM,qCAAqC,CAAC"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.resolveWithLocationRedirectionHandling = exports.isLocationRedirectionError = void 0;
8
- var resolveWithLocationRedirection_1 = require("./resolveWithLocationRedirection");
9
- Object.defineProperty(exports, "isLocationRedirectionError", { enumerable: true, get: function () { return resolveWithLocationRedirection_1.isLocationRedirectionError; } });
10
- Object.defineProperty(exports, "resolveWithLocationRedirectionHandling", { enumerable: true, get: function () { return resolveWithLocationRedirection_1.resolveWithLocationRedirectionHandling; } });
8
+ var resolveWithLocationRedirection_js_1 = require("./resolveWithLocationRedirection.js");
9
+ Object.defineProperty(exports, "isLocationRedirectionError", { enumerable: true, get: function () { return resolveWithLocationRedirection_js_1.isLocationRedirectionError; } });
10
+ Object.defineProperty(exports, "resolveWithLocationRedirectionHandling", { enumerable: true, get: function () { return resolveWithLocationRedirection_js_1.resolveWithLocationRedirectionHandling; } });
11
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/location-redirection-utilities/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mFAG0C;AAFzC,4IAAA,0BAA0B,OAAA;AAC1B,wJAAA,sCAAsC,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tisLocationRedirectionError,\n\tresolveWithLocationRedirectionHandling,\n} from \"./resolveWithLocationRedirection\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/location-redirection-utilities/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yFAG6C;AAF5C,+IAAA,0BAA0B,OAAA;AAC1B,2JAAA,sCAAsC,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tisLocationRedirectionError,\n\tresolveWithLocationRedirectionHandling,\n} from \"./resolveWithLocationRedirection.js\";\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/container-loader";
8
- export declare const pkgVersion = "2.0.0-rc.1.0.4";
8
+ export declare const pkgVersion = "2.0.0-rc.2.0.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/container-loader";
11
- exports.pkgVersion = "2.0.0-rc.1.0.4";
11
+ exports.pkgVersion = "2.0.0-rc.2.0.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,kCAAkC,CAAC;AAC7C,QAAA,UAAU,GAAG,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"2.0.0-rc.1.0.4\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,kCAAkC,CAAC;AAC7C,QAAA,UAAU,GAAG,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"2.0.0-rc.2.0.0\";\n"]}
@@ -14,9 +14,9 @@ export declare class ProtocolTreeStorageService implements IDocumentStorageServi
14
14
  private readonly addProtocolSummaryIfMissing;
15
15
  constructor(internalStorageService: IDocumentStorageService & IDisposable, addProtocolSummaryIfMissing: (summaryTree: ISummaryTree) => ISummaryTree);
16
16
  get policies(): import("@fluidframework/driver-definitions").IDocumentStorageServicePolicies | undefined;
17
- get repositoryUrl(): string;
18
17
  get disposed(): boolean;
19
18
  getSnapshotTree: (version?: import("@fluidframework/protocol-definitions").IVersion | undefined, scenarioName?: string | undefined) => Promise<import("@fluidframework/protocol-definitions").ISnapshotTree | null>;
19
+ getSnapshot: ((snapshotFetchOptions?: import("@fluidframework/driver-definitions").ISnapshotFetchOptions | undefined) => Promise<import("@fluidframework/driver-definitions").ISnapshot>) | undefined;
20
20
  getVersions: (versionId: string | null, count: number, scenarioName?: string | undefined, fetchSource?: import("@fluidframework/driver-definitions").FetchSource | undefined) => Promise<import("@fluidframework/protocol-definitions").IVersion[]>;
21
21
  createBlob: (file: ArrayBufferLike) => Promise<import("@fluidframework/protocol-definitions").ICreateBlobResponse>;
22
22
  readBlob: (id: string) => Promise<ArrayBufferLike>;
@@ -1 +1 @@
1
- {"version":3,"file":"protocolTreeDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/protocolTreeDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC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F,UAAU,yGAA4E;IACtF,QAAQ,2CAA0E;IAClF,eAAe,mGAAiF;IAChG,OAAO,sCAAyE;IAE1E,wBAAwB,CAC7B,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;CAMlB"}
@@ -14,6 +14,7 @@ class ProtocolTreeStorageService {
14
14
  this.internalStorageService = internalStorageService;
15
15
  this.addProtocolSummaryIfMissing = addProtocolSummaryIfMissing;
16
16
  this.getSnapshotTree = this.internalStorageService.getSnapshotTree.bind(this.internalStorageService);
17
+ this.getSnapshot = this.internalStorageService.getSnapshot?.bind(this.internalStorageService);
17
18
  this.getVersions = this.internalStorageService.getVersions.bind(this.internalStorageService);
18
19
  this.createBlob = this.internalStorageService.createBlob.bind(this.internalStorageService);
19
20
  this.readBlob = this.internalStorageService.readBlob.bind(this.internalStorageService);
@@ -23,9 +24,6 @@ class ProtocolTreeStorageService {
23
24
  get policies() {
24
25
  return this.internalStorageService.policies;
25
26
  }
26
- get repositoryUrl() {
27
- return this.internalStorageService.repositoryUrl;
28
- }
29
27
  get disposed() {
30
28
  return this.internalStorageService.disposed;
31
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"protocolTreeDocumentStorageService.js","sourceRoot":"","sources":["../src/protocolTreeDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;;GAGG;AACH,MAAa,0BAA0B;IACtC,YACkB,sBAA6D,EAC7D,2BAAwE;QADxE,2BAAsB,GAAtB,sBAAsB,CAAuC;QAC7D,gCAA2B,GAA3B,2BAA2B,CAA6C;QAY1F,oBAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAChG,gBAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACxF,eAAU,GAAG,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtF,aAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAClF,oBAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAChG,YAAO,GAAG,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAhB7E,CAAC;IACJ,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAC7C,CAAC;IACD,IAAW,aAAa;QACvB,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;IAClD,CAAC;IACD,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAC7C,CAAC;IASD,KAAK,CAAC,wBAAwB,CAC7B,OAAqB,EACrB,OAAwB;QAExB,OAAO,IAAI,CAAC,sBAAsB,CAAC,wBAAwB,CAC1D,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAAC,EACzC,OAAO,CACP,CAAC;IACH,CAAC;CACD;AA/BD,gEA+BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\n\n/**\n * A storage service wrapper whose sole job is to intercept calls to uploadSummaryWithContext and ensure they include\n * the protocol summary, using the provided callback to add it if necessary.\n */\nexport class ProtocolTreeStorageService implements IDocumentStorageService, IDisposable {\n\tconstructor(\n\t\tprivate readonly internalStorageService: IDocumentStorageService & IDisposable,\n\t\tprivate readonly addProtocolSummaryIfMissing: (summaryTree: ISummaryTree) => ISummaryTree,\n\t) {}\n\tpublic get policies() {\n\t\treturn this.internalStorageService.policies;\n\t}\n\tpublic get repositoryUrl() {\n\t\treturn this.internalStorageService.repositoryUrl;\n\t}\n\tpublic get disposed() {\n\t\treturn this.internalStorageService.disposed;\n\t}\n\n\tgetSnapshotTree = this.internalStorageService.getSnapshotTree.bind(this.internalStorageService);\n\tgetVersions = this.internalStorageService.getVersions.bind(this.internalStorageService);\n\tcreateBlob = this.internalStorageService.createBlob.bind(this.internalStorageService);\n\treadBlob = this.internalStorageService.readBlob.bind(this.internalStorageService);\n\tdownloadSummary = this.internalStorageService.downloadSummary.bind(this.internalStorageService);\n\tdispose = this.internalStorageService.dispose.bind(this.internalStorageService);\n\n\tasync uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\treturn this.internalStorageService.uploadSummaryWithContext(\n\t\t\tthis.addProtocolSummaryIfMissing(summary),\n\t\t\tcontext,\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"protocolTreeDocumentStorageService.js","sourceRoot":"","sources":["../src/protocolTreeDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;;GAGG;AACH,MAAa,0BAA0B;IACtC,YACkB,sBAA6D,EAC7D,2BAAwE;QADxE,2BAAsB,GAAtB,sBAAsB,CAAuC;QAC7D,gCAA2B,GAA3B,2BAA2B,CAA6C;QAS1F,oBAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAChG,gBAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACzF,gBAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACxF,eAAU,GAAG,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtF,aAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAClF,oBAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAChG,YAAO,GAAG,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAd7E,CAAC;IACJ,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAC7C,CAAC;IACD,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAC7C,CAAC;IAUD,KAAK,CAAC,wBAAwB,CAC7B,OAAqB,EACrB,OAAwB;QAExB,OAAO,IAAI,CAAC,sBAAsB,CAAC,wBAAwB,CAC1D,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAAC,EACzC,OAAO,CACP,CAAC;IACH,CAAC;CACD;AA7BD,gEA6BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\n\n/**\n * A storage service wrapper whose sole job is to intercept calls to uploadSummaryWithContext and ensure they include\n * the protocol summary, using the provided callback to add it if necessary.\n */\nexport class ProtocolTreeStorageService implements IDocumentStorageService, IDisposable {\n\tconstructor(\n\t\tprivate readonly internalStorageService: IDocumentStorageService & IDisposable,\n\t\tprivate readonly addProtocolSummaryIfMissing: (summaryTree: ISummaryTree) => ISummaryTree,\n\t) {}\n\tpublic get policies() {\n\t\treturn this.internalStorageService.policies;\n\t}\n\tpublic get disposed() {\n\t\treturn this.internalStorageService.disposed;\n\t}\n\n\tgetSnapshotTree = this.internalStorageService.getSnapshotTree.bind(this.internalStorageService);\n\tgetSnapshot = this.internalStorageService.getSnapshot?.bind(this.internalStorageService);\n\tgetVersions = this.internalStorageService.getVersions.bind(this.internalStorageService);\n\tcreateBlob = this.internalStorageService.createBlob.bind(this.internalStorageService);\n\treadBlob = this.internalStorageService.readBlob.bind(this.internalStorageService);\n\tdownloadSummary = this.internalStorageService.downloadSummary.bind(this.internalStorageService);\n\tdispose = this.internalStorageService.dispose.bind(this.internalStorageService);\n\n\tasync uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\treturn this.internalStorageService.uploadSummaryWithContext(\n\t\t\tthis.addProtocolSummaryIfMissing(summary),\n\t\t\tcontext,\n\t\t);\n\t}\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { FetchSource, IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
5
+ import { FetchSource, IDocumentStorageService, IDocumentStorageServicePolicies, ISnapshot, ISnapshotFetchOptions, ISummaryContext } from "@fluidframework/driver-definitions";
6
6
  import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
7
7
  import { IDisposable } from "@fluidframework/core-interfaces";
8
8
  import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
@@ -15,8 +15,8 @@ export declare class RetriableDocumentStorageService implements IDocumentStorage
15
15
  get policies(): IDocumentStorageServicePolicies | undefined;
16
16
  get disposed(): boolean;
17
17
  dispose(): void;
18
- get repositoryUrl(): string;
19
18
  getSnapshotTree(version?: IVersion, scenarioName?: string): Promise<ISnapshotTree | null>;
19
+ getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot>;
20
20
  readBlob(id: string): Promise<ArrayBufferLike>;
21
21
  getVersions(versionId: string | null, count: number, scenarioName?: string, fetchSource?: FetchSource): Promise<IVersion[]>;
22
22
  uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"retriableDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAgB,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGpF,qBAAa,+BAAgC,YAAW,uBAAuB,EAAE,WAAW;IAI1F,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJxB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,sBAAsB,CAAsC;gBAElD,uBAAuB,EAAE,OAAO,CAAC,uBAAuB,CAAC,EACzD,MAAM,EAAE,mBAAmB;IAK7C,IAAW,QAAQ,IAAI,+BAA+B,GAAG,SAAS,CAKjE;IACD,IAAW,QAAQ,YAElB;IACM,OAAO;IAId,IAAW,aAAa,IAAI,MAAM,CAKjC;IAEY,eAAe,CAC3B,OAAO,CAAC,EAAE,QAAQ,EAClB,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAUnB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAO9C,WAAW,CACvB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,QAAQ,EAAE,CAAC;IAUT,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IA8BL,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAO9D,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO5E,OAAO,CAAC,oBAAoB;YAiBd,YAAY;CAM1B"}
1
+ {"version":3,"file":"retriableDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,uBAAuB,EACvB,+BAA+B,EAC/B,SAAS,EACT,qBAAqB,EACrB,eAAe,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAgB,mBAAmB,EAAc,MAAM,iCAAiC,CAAC;AAGhG,qBAAa,+BAAgC,YAAW,uBAAuB,EAAE,WAAW;IAI1F,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJxB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,sBAAsB,CAAsC;gBAElD,uBAAuB,EAAE,OAAO,CAAC,uBAAuB,CAAC,EACzD,MAAM,EAAE,mBAAmB;IAK7C,IAAW,QAAQ,IAAI,+BAA+B,GAAG,SAAS,CAKjE;IACD,IAAW,QAAQ,YAElB;IACM,OAAO;IAID,eAAe,CAC3B,OAAO,CAAC,EAAE,QAAQ,EAClB,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAUnB,WAAW,CAAC,oBAAoB,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,CAAC;IAe7E,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAO9C,WAAW,CACvB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,QAAQ,EAAE,CAAC;IAUT,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IA8BL,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAO9D,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO5E,OAAO,CAAC,oBAAoB;YAiBd,YAAY;CAM1B"}
@@ -27,15 +27,17 @@ class RetriableDocumentStorageService {
27
27
  dispose() {
28
28
  this._disposed = true;
29
29
  }
30
- get repositoryUrl() {
31
- if (this.internalStorageService) {
32
- return this.internalStorageService.repositoryUrl;
33
- }
34
- throw new Error("storage service not yet instantiated");
35
- }
36
30
  async getSnapshotTree(version, scenarioName) {
37
31
  return this.runWithRetry(async () => this.internalStorageServiceP.then(async (s) => s.getSnapshotTree(version, scenarioName)), "storage_getSnapshotTree");
38
32
  }
33
+ async getSnapshot(snapshotFetchOptions) {
34
+ return this.runWithRetry(async () => this.internalStorageServiceP.then(async (s) => {
35
+ if (s.getSnapshot !== undefined) {
36
+ return s.getSnapshot(snapshotFetchOptions);
37
+ }
38
+ throw new telemetry_utils_1.UsageError("getSnapshot api should exist on internal storage in RetriableDocStorageService class");
39
+ }), "storage_getSnapshot");
40
+ }
39
41
  async readBlob(id) {
40
42
  return this.runWithRetry(async () => this.internalStorageServiceP.then(async (s) => s.readBlob(id)), "storage_readBlob");
41
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"retriableDocumentStorageService.js","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AAepD,qEAAoF;AACpF,+DAA4D;AAE5D,MAAa,+BAA+B;IAG3C,YACkB,uBAAyD,EACzD,MAA2B;QAD3B,4BAAuB,GAAvB,uBAAuB,CAAkC;QACzD,WAAM,GAAN,MAAM,CAAqB;QAJrC,cAAS,GAAG,KAAK,CAAC;QAMzB,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC7F,CAAC;IAED,IAAW,QAAQ;QAClB,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAChC,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;SAC5C;QACD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACzD,CAAC;IACD,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IACM,OAAO;QACb,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,IAAW,aAAa;QACvB,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAChC,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;SACjD;QACD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,eAAe,CAC3B,OAAkB,EAClB,YAAqB;QAErB,OAAO,IAAI,CAAC,YAAY,CACvB,KAAK,IAAI,EAAE,CACV,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,KAAK,EAAE,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,IAAI,CAAC,MAAM,EAAE;YAC/C,OAAO,EAAE,CAAC,UAAkB,EAAE,KAAc,EAAE,EAAE,CAC/C,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,KAAK,CAAC;SAC3C,CAAC,CAAC;IACJ,CAAC;CACD;AAvID,0EAuIC","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 {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { GenericError, ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { runWithRetry } from \"@fluidframework/driver-utils\";\n\nexport class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {\n\tprivate _disposed = false;\n\tprivate internalStorageService: IDocumentStorageService | undefined;\n\tconstructor(\n\t\tprivate readonly internalStorageServiceP: Promise<IDocumentStorageService>,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tthis.internalStorageServiceP.then((s) => (this.internalStorageService = s)).catch(() => {});\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\tif (this.internalStorageService) {\n\t\t\treturn this.internalStorageService.policies;\n\t\t}\n\t\tthrow new Error(\"storage service not yet instantiated\");\n\t}\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\tif (this.internalStorageService) {\n\t\t\treturn this.internalStorageService.repositoryUrl;\n\t\t}\n\t\tthrow new Error(\"storage service not yet instantiated\");\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.getSnapshotTree(version, scenarioName),\n\t\t\t\t),\n\t\t\t\"storage_getSnapshotTree\",\n\t\t);\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.readBlob(id)),\n\t\t\t\"storage_readBlob\",\n\t\t);\n\t}\n\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.getVersions(versionId, count, scenarioName, fetchSource),\n\t\t\t\t),\n\t\t\t\"storage_getVersions\",\n\t\t);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\t// Not using retry loop here. Couple reasons:\n\t\t// 1. If client lost connectivity, then retry loop will result in uploading stale summary\n\t\t// by stale summarizer after connectivity comes back. It will cause failures for this client and for\n\t\t// real (new) summarizer. This problem in particular should be solved in future by supplying abort handle\n\t\t// on all APIs and caller (ContainerRuntime.submitSummary) aborting call on loss of connectivity\n\t\t// 2. Similar, if we get 429 with retryAfter = 10 minutes, it's likely not the right call to retry summary\n\t\t// upload in 10 minutes - it's better to keep processing ops and retry later. Though caller needs to take\n\t\t// retryAfter into account!\n\t\t// But retry loop is required for creation flow (Container.attach)\n\t\tassert(\n\t\t\t(context.referenceSequenceNumber === 0) === (context.ackHandle === undefined),\n\t\t\t0x251 /* \"creation summary has to have seq=0 && handle === undefined\" */,\n\t\t);\n\t\tif (context.referenceSequenceNumber !== 0) {\n\t\t\treturn this.internalStorageServiceP.then(async (s) =>\n\t\t\t\ts.uploadSummaryWithContext(summary, context),\n\t\t\t);\n\t\t}\n\n\t\t// Creation flow with attachment blobs - need to do retries!\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.uploadSummaryWithContext(summary, context),\n\t\t\t\t),\n\t\t\t\"storage_uploadSummaryWithContext\",\n\t\t);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.downloadSummary(handle)),\n\t\t\t\"storage_downloadSummary\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.createBlob(file)),\n\t\t\t\"storage_createBlob\",\n\t\t);\n\t}\n\n\tprivate checkStorageDisposed(callName: string, error: unknown) {\n\t\tif (this._disposed) {\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: `${callName}_abortedStorageDisposed`,\n\t\t\t\t\tfetchCallName: callName, // fetchCallName matches logs in runWithRetry.ts\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\t// pre-0.58 error message: storageServiceDisposedCannotRetry\n\t\t\tthrow new GenericError(\"Storage Service is disposed. Cannot retry\", {\n\t\t\t\tcanRetry: false,\n\t\t\t});\n\t\t}\n\t\treturn;\n\t}\n\n\tprivate async runWithRetry<T>(api: () => Promise<T>, callName: string): Promise<T> {\n\t\treturn runWithRetry(api, callName, this.logger, {\n\t\t\tonRetry: (_delayInMs: number, error: unknown) =>\n\t\t\t\tthis.checkStorageDisposed(callName, error),\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"retriableDocumentStorageService.js","sourceRoot":"","sources":["../src/retriableDocumentStor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QACpE,OAAO,IAAA,2BAAY,EAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE;YAC/C,OAAO,EAAE,CAAC,UAAkB,EAAE,KAAc,EAAE,EAAE,CAC/C,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,KAAK,CAAC;SAC3C,CAAC,CAAC;IACJ,CAAC;CACD;AA/ID,0EA+IC","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 {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { GenericError, ITelemetryLoggerExt, UsageError } from \"@fluidframework/telemetry-utils\";\nimport { runWithRetry } from \"@fluidframework/driver-utils\";\n\nexport class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {\n\tprivate _disposed = false;\n\tprivate internalStorageService: IDocumentStorageService | undefined;\n\tconstructor(\n\t\tprivate readonly internalStorageServiceP: Promise<IDocumentStorageService>,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tthis.internalStorageServiceP.then((s) => (this.internalStorageService = s)).catch(() => {});\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\tif (this.internalStorageService) {\n\t\t\treturn this.internalStorageService.policies;\n\t\t}\n\t\tthrow new Error(\"storage service not yet instantiated\");\n\t}\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.getSnapshotTree(version, scenarioName),\n\t\t\t\t),\n\t\t\t\"storage_getSnapshotTree\",\n\t\t);\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) => {\n\t\t\t\t\tif (s.getSnapshot !== undefined) {\n\t\t\t\t\t\treturn s.getSnapshot(snapshotFetchOptions);\n\t\t\t\t\t}\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"getSnapshot api should exist on internal storage in RetriableDocStorageService class\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t\"storage_getSnapshot\",\n\t\t);\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.readBlob(id)),\n\t\t\t\"storage_readBlob\",\n\t\t);\n\t}\n\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.getVersions(versionId, count, scenarioName, fetchSource),\n\t\t\t\t),\n\t\t\t\"storage_getVersions\",\n\t\t);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\t// Not using retry loop here. Couple reasons:\n\t\t// 1. If client lost connectivity, then retry loop will result in uploading stale summary\n\t\t// by stale summarizer after connectivity comes back. It will cause failures for this client and for\n\t\t// real (new) summarizer. This problem in particular should be solved in future by supplying abort handle\n\t\t// on all APIs and caller (ContainerRuntime.submitSummary) aborting call on loss of connectivity\n\t\t// 2. Similar, if we get 429 with retryAfter = 10 minutes, it's likely not the right call to retry summary\n\t\t// upload in 10 minutes - it's better to keep processing ops and retry later. Though caller needs to take\n\t\t// retryAfter into account!\n\t\t// But retry loop is required for creation flow (Container.attach)\n\t\tassert(\n\t\t\t(context.referenceSequenceNumber === 0) === (context.ackHandle === undefined),\n\t\t\t0x251 /* \"creation summary has to have seq=0 && handle === undefined\" */,\n\t\t);\n\t\tif (context.referenceSequenceNumber !== 0) {\n\t\t\treturn this.internalStorageServiceP.then(async (s) =>\n\t\t\t\ts.uploadSummaryWithContext(summary, context),\n\t\t\t);\n\t\t}\n\n\t\t// Creation flow with attachment blobs - need to do retries!\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.uploadSummaryWithContext(summary, context),\n\t\t\t\t),\n\t\t\t\"storage_uploadSummaryWithContext\",\n\t\t);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.downloadSummary(handle)),\n\t\t\t\"storage_downloadSummary\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.createBlob(file)),\n\t\t\t\"storage_createBlob\",\n\t\t);\n\t}\n\n\tprivate checkStorageDisposed(callName: string, error: unknown) {\n\t\tif (this._disposed) {\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: `${callName}_abortedStorageDisposed`,\n\t\t\t\t\tfetchCallName: callName, // fetchCallName matches logs in runWithRetry.ts\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\t// pre-0.58 error message: storageServiceDisposedCannotRetry\n\t\t\tthrow new GenericError(\"Storage Service is disposed. Cannot retry\", {\n\t\t\t\tcanRetry: false,\n\t\t\t});\n\t\t}\n\t\treturn;\n\t}\n\n\tprivate async runWithRetry<T>(api: () => Promise<T>, callName: string): Promise<T> {\n\t\treturn runWithRetry(api, callName, this.logger, {\n\t\t\tonRetry: (_delayInMs: number, error: unknown) =>\n\t\t\t\tthis.checkStorageDisposed(callName, error),\n\t\t});\n\t}\n}\n"]}
@@ -0,0 +1,44 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ISequencedDocumentMessage, ISnapshotTree, IVersion } from "@fluidframework/protocol-definitions";
6
+ import { IGetPendingLocalStateProps, IRuntime } from "@fluidframework/container-definitions";
7
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
8
+ import { IDocumentStorageService, IResolvedUrl } from "@fluidframework/driver-definitions";
9
+ import { ISerializableBlobContents } from "./containerStorageAdapter.js";
10
+ import { IPendingContainerState } from "./container.js";
11
+ export declare class SerializedStateManager {
12
+ private readonly pendingLocalState;
13
+ private readonly storageAdapter;
14
+ private readonly _offlineLoadEnabled;
15
+ private readonly processedOps;
16
+ private snapshot;
17
+ private readonly mc;
18
+ constructor(pendingLocalState: IPendingContainerState | undefined, subLogger: ITelemetryLoggerExt, storageAdapter: Pick<IDocumentStorageService, "readBlob" | "getSnapshotTree" | "getSnapshot" | "getVersions">, _offlineLoadEnabled: boolean);
19
+ get offlineLoadEnabled(): boolean;
20
+ addProcessedOp(message: ISequencedDocumentMessage): void;
21
+ private getVersion;
22
+ fetchSnapshot(specifiedVersion: string | undefined, supportGetSnapshotApi: boolean | undefined): Promise<{
23
+ snapshotTree: ISnapshotTree | undefined;
24
+ version: IVersion | undefined;
25
+ }>;
26
+ private fetchSnapshotCore;
27
+ /**
28
+ * Get the most recent snapshot, or a specific version.
29
+ * @param specifiedVersion - The specific version of the snapshot to retrieve
30
+ * @returns The snapshot requested, or the latest snapshot if no version was specified, plus version ID
31
+ */
32
+ private fetchSnapshotTree;
33
+ /**
34
+ * This method is only meant to be used by Container.attach() to set the initial
35
+ * base snapshot when attaching.
36
+ * @param snapshot - snapshot and blobs collected while attaching
37
+ */
38
+ setSnapshot(snapshot: {
39
+ tree: ISnapshotTree;
40
+ blobs: ISerializableBlobContents;
41
+ } | undefined): void;
42
+ getPendingLocalStateCore(props: IGetPendingLocalStateProps, clientId: string | undefined, runtime: Pick<IRuntime, "getPendingLocalState">, resolvedUrl: IResolvedUrl): Promise<string>;
43
+ }
44
+ //# sourceMappingURL=serializedStateManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializedStateManager.d.ts","sourceRoot":"","sources":["../src/serializedStateManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,yBAAyB,EACzB,aAAa,EACb,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAC7F,OAAO,EACN,mBAAmB,EAKnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACN,uBAAuB,EACvB,YAAY,EAEZ,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,yBAAyB,EAA2B,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,qBAAa,sBAAsB;IAWjC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAElC,OAAO,CAAC,QAAQ,CAAC,cAAc;IAI/B,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IAhBrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAmC;IAChE,OAAO,CAAC,QAAQ,CAKH;IACb,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;gBAGrB,iBAAiB,EAAE,sBAAsB,GAAG,SAAS,EACtE,SAAS,EAAE,mBAAmB,EACb,cAAc,EAAE,IAAI,CACpC,uBAAuB,EACvB,UAAU,GAAG,iBAAiB,GAAG,aAAa,GAAG,aAAa,CAC9D,EACgB,mBAAmB,EAAE,OAAO;IAQ9C,IAAW,kBAAkB,IAAI,OAAO,CAEvC;IAEM,cAAc,CAAC,OAAO,EAAE,yBAAyB;YAM1C,UAAU;IAKX,aAAa,CACzB,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,qBAAqB,EAAE,OAAO,GAAG,SAAS;;;;YAyB7B,iBAAiB;IAsC/B;;;;OAIG;YACW,iBAAiB;IAyB/B;;;;OAIG;IACI,WAAW,CACjB,QAAQ,EACL;QACA,IAAI,EAAE,aAAa,CAAC;QACpB,KAAK,EAAE,yBAAyB,CAAC;KAChC,GACD,SAAS;IAKA,wBAAwB,CACpC,KAAK,EAAE,0BAA0B,EACjC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,sBAAsB,CAAC,EAC/C,WAAW,EAAE,YAAY;CAiC1B"}
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SerializedStateManager = void 0;
8
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
9
+ const core_utils_1 = require("@fluidframework/core-utils");
10
+ const driver_utils_1 = require("@fluidframework/driver-utils");
11
+ const containerStorageAdapter_js_1 = require("./containerStorageAdapter.js");
12
+ class SerializedStateManager {
13
+ constructor(pendingLocalState, subLogger, storageAdapter, _offlineLoadEnabled) {
14
+ this.pendingLocalState = pendingLocalState;
15
+ this.storageAdapter = storageAdapter;
16
+ this._offlineLoadEnabled = _offlineLoadEnabled;
17
+ this.processedOps = [];
18
+ this.mc = (0, telemetry_utils_1.createChildMonitoringContext)({
19
+ logger: subLogger,
20
+ namespace: "serializedStateManager",
21
+ });
22
+ }
23
+ get offlineLoadEnabled() {
24
+ return this._offlineLoadEnabled;
25
+ }
26
+ addProcessedOp(message) {
27
+ if (this.offlineLoadEnabled) {
28
+ this.processedOps.push(message);
29
+ }
30
+ }
31
+ async getVersion(version) {
32
+ const versions = await this.storageAdapter.getVersions(version, 1);
33
+ return versions[0];
34
+ }
35
+ async fetchSnapshot(specifiedVersion, supportGetSnapshotApi) {
36
+ const { snapshot, version } = this.pendingLocalState === undefined
37
+ ? await this.fetchSnapshotCore(specifiedVersion, supportGetSnapshotApi)
38
+ : { snapshot: this.pendingLocalState.baseSnapshot, version: undefined };
39
+ const snapshotTree = (0, driver_utils_1.isInstanceOfISnapshot)(snapshot)
40
+ ? snapshot.snapshotTree
41
+ : snapshot;
42
+ if (this.pendingLocalState) {
43
+ this.snapshot = {
44
+ tree: this.pendingLocalState.baseSnapshot,
45
+ blobs: this.pendingLocalState.snapshotBlobs,
46
+ };
47
+ }
48
+ else {
49
+ (0, core_utils_1.assert)(snapshotTree !== undefined, 0x8e4 /* Snapshot should exist */);
50
+ // non-interactive clients will not have any pending state we want to save
51
+ if (this.offlineLoadEnabled) {
52
+ const blobs = await (0, containerStorageAdapter_js_1.getBlobContentsFromTree)(snapshotTree, this.storageAdapter);
53
+ this.snapshot = { tree: snapshotTree, blobs };
54
+ }
55
+ }
56
+ return { snapshotTree, version };
57
+ }
58
+ async fetchSnapshotCore(specifiedVersion, supportGetSnapshotApi) {
59
+ if (this.mc.config.getBoolean("Fluid.Container.UseLoadingGroupIdForSnapshotFetch") ===
60
+ true &&
61
+ supportGetSnapshotApi === true) {
62
+ const snapshot = (await this.storageAdapter.getSnapshot?.({
63
+ versionId: specifiedVersion,
64
+ })) ?? undefined;
65
+ const version = snapshot?.snapshotTree.id === undefined
66
+ ? undefined
67
+ : {
68
+ id: snapshot.snapshotTree.id,
69
+ treeId: snapshot.snapshotTree.id,
70
+ };
71
+ if (snapshot === undefined && specifiedVersion !== undefined) {
72
+ this.mc.logger.sendErrorEvent({
73
+ eventName: "getSnapshotTreeFailed",
74
+ id: specifiedVersion,
75
+ });
76
+ // Not sure if this should be here actually
77
+ }
78
+ else if (snapshot !== undefined && version?.id === undefined) {
79
+ this.mc.logger.sendErrorEvent({
80
+ eventName: "getSnapshotFetchedTreeWithoutVersionId",
81
+ hasVersion: version !== undefined, // if hasVersion is true, this means that the contract with the service was broken.
82
+ });
83
+ }
84
+ return { snapshot, version };
85
+ }
86
+ return this.fetchSnapshotTree(specifiedVersion);
87
+ }
88
+ /**
89
+ * Get the most recent snapshot, or a specific version.
90
+ * @param specifiedVersion - The specific version of the snapshot to retrieve
91
+ * @returns The snapshot requested, or the latest snapshot if no version was specified, plus version ID
92
+ */
93
+ async fetchSnapshotTree(specifiedVersion) {
94
+ const version = await this.getVersion(specifiedVersion ?? null);
95
+ if (version === undefined && specifiedVersion !== undefined) {
96
+ // We should have a defined version to load from if specified version requested
97
+ this.mc.logger.sendErrorEvent({
98
+ eventName: "NoVersionFoundWhenSpecified",
99
+ id: specifiedVersion,
100
+ });
101
+ }
102
+ const snapshot = (await this.storageAdapter.getSnapshotTree(version)) ?? undefined;
103
+ if (snapshot === undefined && version !== undefined) {
104
+ this.mc.logger.sendErrorEvent({ eventName: "getSnapshotTreeFailed", id: version.id });
105
+ }
106
+ else if (snapshot !== undefined && version?.id === undefined) {
107
+ this.mc.logger.sendErrorEvent({
108
+ eventName: "getSnapshotFetchedTreeWithoutVersionId",
109
+ hasVersion: version !== undefined, // if hasVersion is true, this means that the contract with the service was broken.
110
+ });
111
+ }
112
+ return { snapshot, version };
113
+ }
114
+ /**
115
+ * This method is only meant to be used by Container.attach() to set the initial
116
+ * base snapshot when attaching.
117
+ * @param snapshot - snapshot and blobs collected while attaching
118
+ */
119
+ setSnapshot(snapshot) {
120
+ this.snapshot = snapshot;
121
+ }
122
+ async getPendingLocalStateCore(props, clientId, runtime, resolvedUrl) {
123
+ return telemetry_utils_1.PerformanceEvent.timedExecAsync(this.mc.logger, {
124
+ eventName: "getPendingLocalState",
125
+ notifyImminentClosure: props.notifyImminentClosure,
126
+ processedOpsSize: this.processedOps.length,
127
+ clientId,
128
+ }, async () => {
129
+ if (!this.offlineLoadEnabled) {
130
+ throw new telemetry_utils_1.UsageError("Can't get pending local state unless offline load is enabled");
131
+ }
132
+ (0, core_utils_1.assert)(this.snapshot !== undefined, 0x8e5 /* no base data */);
133
+ const pendingRuntimeState = await runtime.getPendingLocalState(props);
134
+ const pendingState = {
135
+ attached: true,
136
+ pendingRuntimeState,
137
+ baseSnapshot: this.snapshot.tree,
138
+ snapshotBlobs: this.snapshot.blobs,
139
+ savedOps: this.processedOps,
140
+ url: resolvedUrl.url,
141
+ // no need to save this if there is no pending runtime state
142
+ clientId: pendingRuntimeState !== undefined ? clientId : undefined,
143
+ };
144
+ return JSON.stringify(pendingState);
145
+ });
146
+ }
147
+ }
148
+ exports.SerializedStateManager = SerializedStateManager;
149
+ //# sourceMappingURL=serializedStateManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializedStateManager.js","sourceRoot":"","sources":["../src/serializedStateManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,qEAMyC;AACzC,2DAAoD;AAMpD,+DAAqE;AACrE,6EAAkG;AAGlG,MAAa,sBAAsB;IAUlC,YACkB,iBAAqD,EACtE,SAA8B,EACb,cAGhB,EACgB,mBAA4B;QAN5B,sBAAiB,GAAjB,iBAAiB,CAAoC;QAErD,mBAAc,GAAd,cAAc,CAG9B;QACgB,wBAAmB,GAAnB,mBAAmB,CAAS;QAhB7B,iBAAY,GAAgC,EAAE,CAAC;QAkB/D,IAAI,CAAC,EAAE,GAAG,IAAA,8CAA4B,EAAC;YACtC,MAAM,EAAE,SAAS;YACjB,SAAS,EAAE,wBAAwB;SACnC,CAAC,CAAC;IACJ,CAAC;IAED,IAAW,kBAAkB;QAC5B,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACjC,CAAC;IAEM,cAAc,CAAC,OAAkC;QACvD,IAAI,IAAI,CAAC,k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AE,KAAK,CAAC,qBAAqB;YAClD,gBAAgB,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM;YAC1C,QAAQ;SACR,EACD,KAAK,IAAI,EAAE;YACV,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;gBAC7B,MAAM,IAAI,4BAAU,CACnB,8DAA8D,CAC9D,CAAC;aACF;YACD,IAAA,mBAAM,EAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;YAC9D,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACtE,MAAM,YAAY,GAA2B;gBAC5C,QAAQ,EAAE,IAAI;gBACd,mBAAmB;gBACnB,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;gBAChC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK;gBAClC,QAAQ,EAAE,IAAI,CAAC,YAAY;gBAC3B,GAAG,EAAE,WAAW,CAAC,GAAG;gBACpB,4DAA4D;gBAC5D,QAAQ,EAAE,mBAAmB,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;aAClE,CAAC;YAEF,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QACrC,CAAC,CACD,CAAC;IACH,CAAC;CACD;AA5LD,wDA4LC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tISequencedDocumentMessage,\n\tISnapshotTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IGetPendingLocalStateProps, IRuntime } from \"@fluidframework/container-definitions\";\nimport {\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tUsageError,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tISnapshot,\n} from \"@fluidframework/driver-definitions\";\nimport { isInstanceOfISnapshot } from \"@fluidframework/driver-utils\";\nimport { ISerializableBlobContents, getBlobContentsFromTree } from \"./containerStorageAdapter.js\";\nimport { IPendingContainerState } from \"./container.js\";\n\nexport class SerializedStateManager {\n\tprivate readonly processedOps: ISequencedDocumentMessage[] = [];\n\tprivate snapshot:\n\t\t| {\n\t\t\t\ttree: ISnapshotTree;\n\t\t\t\tblobs: ISerializableBlobContents;\n\t\t }\n\t\t| undefined;\n\tprivate readonly mc: MonitoringContext;\n\n\tconstructor(\n\t\tprivate readonly pendingLocalState: IPendingContainerState | undefined,\n\t\tsubLogger: ITelemetryLoggerExt,\n\t\tprivate readonly storageAdapter: Pick<\n\t\t\tIDocumentStorageService,\n\t\t\t\"readBlob\" | \"getSnapshotTree\" | \"getSnapshot\" | \"getVersions\"\n\t\t>,\n\t\tprivate readonly _offlineLoadEnabled: boolean,\n\t) {\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: subLogger,\n\t\t\tnamespace: \"serializedStateManager\",\n\t\t});\n\t}\n\n\tpublic get offlineLoadEnabled(): boolean {\n\t\treturn this._offlineLoadEnabled;\n\t}\n\n\tpublic addProcessedOp(message: ISequencedDocumentMessage) {\n\t\tif (this.offlineLoadEnabled) {\n\t\t\tthis.processedOps.push(message);\n\t\t}\n\t}\n\n\tprivate async getVersion(version: string | null): Promise<IVersion | undefined> {\n\t\tconst versions = await this.storageAdapter.getVersions(version, 1);\n\t\treturn versions[0];\n\t}\n\n\tpublic async fetchSnapshot(\n\t\tspecifiedVersion: string | undefined,\n\t\tsupportGetSnapshotApi: boolean | undefined,\n\t) {\n\t\tconst { snapshot, version } =\n\t\t\tthis.pendingLocalState === undefined\n\t\t\t\t? await this.fetchSnapshotCore(specifiedVersion, supportGetSnapshotApi)\n\t\t\t\t: { snapshot: this.pendingLocalState.baseSnapshot, version: undefined };\n\t\tconst snapshotTree: ISnapshotTree | undefined = isInstanceOfISnapshot(snapshot)\n\t\t\t? snapshot.snapshotTree\n\t\t\t: snapshot;\n\t\tif (this.pendingLocalState) {\n\t\t\tthis.snapshot = {\n\t\t\t\ttree: this.pendingLocalState.baseSnapshot,\n\t\t\t\tblobs: this.pendingLocalState.snapshotBlobs,\n\t\t\t};\n\t\t} else {\n\t\t\tassert(snapshotTree !== undefined, 0x8e4 /* Snapshot should exist */);\n\t\t\t// non-interactive clients will not have any pending state we want to save\n\t\t\tif (this.offlineLoadEnabled) {\n\t\t\t\tconst blobs = await getBlobContentsFromTree(snapshotTree, this.storageAdapter);\n\t\t\t\tthis.snapshot = { tree: snapshotTree, blobs };\n\t\t\t}\n\t\t}\n\t\treturn { snapshotTree, version };\n\t}\n\n\tprivate async fetchSnapshotCore(\n\t\tspecifiedVersion: string | undefined,\n\t\tsupportGetSnapshotApi: boolean | undefined,\n\t): Promise<{ snapshot?: ISnapshot | ISnapshotTree; version?: IVersion }> {\n\t\tif (\n\t\t\tthis.mc.config.getBoolean(\"Fluid.Container.UseLoadingGroupIdForSnapshotFetch\") ===\n\t\t\t\ttrue &&\n\t\t\tsupportGetSnapshotApi === true\n\t\t) {\n\t\t\tconst snapshot =\n\t\t\t\t(await this.storageAdapter.getSnapshot?.({\n\t\t\t\t\tversionId: specifiedVersion,\n\t\t\t\t})) ?? undefined;\n\t\t\tconst version: IVersion | undefined =\n\t\t\t\tsnapshot?.snapshotTree.id === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tid: snapshot.snapshotTree.id,\n\t\t\t\t\t\t\ttreeId: snapshot.snapshotTree.id,\n\t\t\t\t\t };\n\n\t\t\tif (snapshot === undefined && specifiedVersion !== undefined) {\n\t\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"getSnapshotTreeFailed\",\n\t\t\t\t\tid: specifiedVersion,\n\t\t\t\t});\n\t\t\t\t// Not sure if this should be here actually\n\t\t\t} else if (snapshot !== undefined && version?.id === undefined) {\n\t\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"getSnapshotFetchedTreeWithoutVersionId\",\n\t\t\t\t\thasVersion: version !== undefined, // if hasVersion is true, this means that the contract with the service was broken.\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn { snapshot, version };\n\t\t}\n\t\treturn this.fetchSnapshotTree(specifiedVersion);\n\t}\n\n\t/**\n\t * Get the most recent snapshot, or a specific version.\n\t * @param specifiedVersion - The specific version of the snapshot to retrieve\n\t * @returns The snapshot requested, or the latest snapshot if no version was specified, plus version ID\n\t */\n\tprivate async fetchSnapshotTree(\n\t\tspecifiedVersion: string | undefined,\n\t): Promise<{ snapshot?: ISnapshotTree; version?: IVersion | undefined }> {\n\t\tconst version = await this.getVersion(specifiedVersion ?? null);\n\n\t\tif (version === undefined && specifiedVersion !== undefined) {\n\t\t\t// We should have a defined version to load from if specified version requested\n\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\teventName: \"NoVersionFoundWhenSpecified\",\n\t\t\t\tid: specifiedVersion,\n\t\t\t});\n\t\t}\n\t\tconst snapshot = (await this.storageAdapter.getSnapshotTree(version)) ?? undefined;\n\n\t\tif (snapshot === undefined && version !== undefined) {\n\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"getSnapshotTreeFailed\", id: version.id });\n\t\t} else if (snapshot !== undefined && version?.id === undefined) {\n\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\teventName: \"getSnapshotFetchedTreeWithoutVersionId\",\n\t\t\t\thasVersion: version !== undefined, // if hasVersion is true, this means that the contract with the service was broken.\n\t\t\t});\n\t\t}\n\t\treturn { snapshot, version };\n\t}\n\n\t/**\n\t * This method is only meant to be used by Container.attach() to set the initial\n\t * base snapshot when attaching.\n\t * @param snapshot - snapshot and blobs collected while attaching\n\t */\n\tpublic setSnapshot(\n\t\tsnapshot:\n\t\t\t| {\n\t\t\t\t\ttree: ISnapshotTree;\n\t\t\t\t\tblobs: ISerializableBlobContents;\n\t\t\t }\n\t\t\t| undefined,\n\t) {\n\t\tthis.snapshot = snapshot;\n\t}\n\n\tpublic async getPendingLocalStateCore(\n\t\tprops: IGetPendingLocalStateProps,\n\t\tclientId: string | undefined,\n\t\truntime: Pick<IRuntime, \"getPendingLocalState\">,\n\t\tresolvedUrl: IResolvedUrl,\n\t) {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{\n\t\t\t\teventName: \"getPendingLocalState\",\n\t\t\t\tnotifyImminentClosure: props.notifyImminentClosure,\n\t\t\t\tprocessedOpsSize: this.processedOps.length,\n\t\t\t\tclientId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tif (!this.offlineLoadEnabled) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"Can't get pending local state unless offline load is enabled\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tassert(this.snapshot !== undefined, 0x8e5 /* no base data */);\n\t\t\t\tconst pendingRuntimeState = await runtime.getPendingLocalState(props);\n\t\t\t\tconst pendingState: IPendingContainerState = {\n\t\t\t\t\tattached: true,\n\t\t\t\t\tpendingRuntimeState,\n\t\t\t\t\tbaseSnapshot: this.snapshot.tree,\n\t\t\t\t\tsnapshotBlobs: this.snapshot.blobs,\n\t\t\t\t\tsavedOps: this.processedOps,\n\t\t\t\t\turl: resolvedUrl.url,\n\t\t\t\t\t// no need to save this if there is no pending runtime state\n\t\t\t\t\tclientId: pendingRuntimeState !== undefined ? clientId : undefined,\n\t\t\t\t};\n\n\t\t\t\treturn JSON.stringify(pendingState);\n\t\t\t},\n\t\t);\n\t}\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.38.3"
8
+ "packageVersion": "7.42.3"
9
9
  }
10
10
  ]
11
11
  }
package/dist/utils.d.ts CHANGED
@@ -4,6 +4,8 @@
4
4
  */
5
5
  import { ISummaryTree, ISnapshotTree } from "@fluidframework/protocol-definitions";
6
6
  import { CombinedAppAndProtocolSummary, DeltaStreamConnectionForbiddenError } from "@fluidframework/driver-utils";
7
+ import { ISerializableBlobContents } from "./containerStorageAdapter.js";
8
+ import { IPendingDetachedContainerState } from "./container.js";
7
9
  export interface ISnapshotTreeWithBlobContents extends ISnapshotTree {
8
10
  blobsContents: {
9
11
  [path: string]: ArrayBufferLike;
@@ -32,11 +34,10 @@ export interface IParsedUrl {
32
34
  */
33
35
  query: string;
34
36
  /**
35
- * Null means do not use snapshots, undefined means load latest snapshot
36
- * otherwise it's version ID passed to IDocumentStorageService.getVersions() to figure out what snapshot to use.
37
- * If needed, can add undefined which is treated by Container.load() as load latest snapshot.
37
+ * Undefined means load latest snapshot, otherwise it's version ID passed to IDocumentStorageService.getVersions()
38
+ * to figure out what snapshot to use.
38
39
  */
39
- version: string | null | undefined;
40
+ version: string | undefined;
40
41
  }
41
42
  /**
42
43
  * Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get
@@ -55,13 +56,17 @@ export declare function tryParseCompatibleResolvedUrl(url: string): IParsedUrl |
55
56
  * @internal
56
57
  */
57
58
  export declare function combineAppAndProtocolSummary(appSummary: ISummaryTree, protocolSummary: ISummaryTree): CombinedAppAndProtocolSummary;
58
- /**
59
- * Combine and convert protocol and app summary tree to format which is readable by container while rehydrating.
60
- * @param protocolSummaryTree - Protocol Summary Tree
61
- * @param appSummaryTree - App Summary Tree
62
- */
63
- export declare function convertProtocolAndAppSummaryToSnapshotTree(protocolSummaryTree: ISummaryTree, appSummaryTree: ISummaryTree): ISnapshotTreeWithBlobContents;
64
- export declare const getSnapshotTreeFromSerializedContainer: (detachedContainerSnapshot: ISummaryTree) => ISnapshotTreeWithBlobContents;
59
+ export declare const getSnapshotTreeAndBlobsFromSerializedContainer: (detachedContainerSnapshot: ISummaryTree) => {
60
+ tree: ISnapshotTree;
61
+ blobs: ISerializableBlobContents;
62
+ };
65
63
  export declare function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree;
64
+ export declare const combineSnapshotTreeAndSnapshotBlobs: (baseSnapshot: ISnapshotTree, snapshotBlobs: ISerializableBlobContents) => ISnapshotTreeWithBlobContents;
66
65
  export declare function isDeltaStreamConnectionForbiddenError(error: any): error is DeltaStreamConnectionForbiddenError;
66
+ export declare function getDetachedContainerStateFromSerializedContainer(serializedContainer: string): IPendingDetachedContainerState;
67
+ /**
68
+ * Ensures only a single instance of the provided async function is running.
69
+ * If there are multiple calls they will all get the same promise to wait on.
70
+ */
71
+ export declare const runSingle: <A extends any[], R>(func: (...args: A) => Promise<R>) => (...args: A) => Promise<R>;
67
72
  //# sourceMappingURL=utils.d.ts.map