@fluidframework/odsp-driver 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277

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 (666) hide show
  1. package/.eslintrc.js +12 -12
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +162 -0
  4. package/README.md +56 -0
  5. package/api-extractor-esm.json +4 -0
  6. package/api-extractor-lint.json +4 -0
  7. package/api-extractor.json +2 -2
  8. package/api-report/odsp-driver.api.md +309 -0
  9. package/dist/{ReadBufferUtils.js → ReadBufferUtils.cjs} +16 -9
  10. package/dist/ReadBufferUtils.cjs.map +1 -0
  11. package/dist/ReadBufferUtils.d.ts.map +1 -1
  12. package/dist/{WriteBufferUtils.js → WriteBufferUtils.cjs} +73 -69
  13. package/dist/WriteBufferUtils.cjs.map +1 -0
  14. package/dist/WriteBufferUtils.d.ts +3 -5
  15. package/dist/WriteBufferUtils.d.ts.map +1 -1
  16. package/dist/{checkUrl.js → checkUrl.cjs} +7 -6
  17. package/dist/checkUrl.cjs.map +1 -0
  18. package/dist/checkUrl.d.ts +1 -0
  19. package/dist/checkUrl.d.ts.map +1 -1
  20. package/dist/compactSnapshotParser.cjs +207 -0
  21. package/dist/compactSnapshotParser.cjs.map +1 -0
  22. package/dist/compactSnapshotParser.d.ts +12 -3
  23. package/dist/compactSnapshotParser.d.ts.map +1 -1
  24. package/dist/{compactSnapshotWriter.js → compactSnapshotWriter.cjs} +43 -33
  25. package/dist/compactSnapshotWriter.cjs.map +1 -0
  26. package/dist/compactSnapshotWriter.d.ts +2 -3
  27. package/dist/compactSnapshotWriter.d.ts.map +1 -1
  28. package/dist/{constants.js → constants.cjs} +7 -1
  29. package/dist/constants.cjs.map +1 -0
  30. package/dist/constants.d.ts +6 -0
  31. package/dist/constants.d.ts.map +1 -1
  32. package/dist/{contracts.js → contracts.cjs} +1 -1
  33. package/dist/contracts.cjs.map +1 -0
  34. package/dist/contracts.d.ts +16 -53
  35. package/dist/contracts.d.ts.map +1 -1
  36. package/dist/{contractsPublic.js → contractsPublic.cjs} +9 -3
  37. package/dist/contractsPublic.cjs.map +1 -0
  38. package/dist/contractsPublic.d.ts +15 -0
  39. package/dist/contractsPublic.d.ts.map +1 -1
  40. package/dist/createFile.cjs +177 -0
  41. package/dist/createFile.cjs.map +1 -0
  42. package/dist/createFile.d.ts +6 -10
  43. package/dist/createFile.d.ts.map +1 -1
  44. package/dist/createNewContainerOnExistingFile.cjs +60 -0
  45. package/dist/createNewContainerOnExistingFile.cjs.map +1 -0
  46. package/dist/createNewContainerOnExistingFile.d.ts +22 -0
  47. package/dist/createNewContainerOnExistingFile.d.ts.map +1 -0
  48. package/dist/createNewModule.cjs +12 -0
  49. package/dist/createNewModule.cjs.map +1 -0
  50. package/dist/createNewModule.d.ts +7 -0
  51. package/dist/createNewModule.d.ts.map +1 -0
  52. package/dist/createNewUtils.cjs +203 -0
  53. package/dist/createNewUtils.cjs.map +1 -0
  54. package/dist/createNewUtils.d.ts +16 -0
  55. package/dist/createNewUtils.d.ts.map +1 -1
  56. package/dist/{createOdspCreateContainerRequest.js → createOdspCreateContainerRequest.cjs} +8 -4
  57. package/dist/createOdspCreateContainerRequest.cjs.map +1 -0
  58. package/dist/createOdspCreateContainerRequest.d.ts +5 -3
  59. package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
  60. package/dist/{createOdspUrl.js → createOdspUrl.cjs} +2 -1
  61. package/dist/createOdspUrl.cjs.map +1 -0
  62. package/dist/createOdspUrl.d.ts +1 -0
  63. package/dist/createOdspUrl.d.ts.map +1 -1
  64. package/dist/{epochTracker.js → epochTracker.cjs} +102 -48
  65. package/dist/epochTracker.cjs.map +1 -0
  66. package/dist/epochTracker.d.ts +32 -8
  67. package/dist/epochTracker.d.ts.map +1 -1
  68. package/dist/{fetch.js → fetch.cjs} +1 -1
  69. package/dist/fetch.cjs.map +1 -0
  70. package/dist/fetch.d.ts +1 -1
  71. package/dist/fetch.d.ts.map +1 -1
  72. package/dist/{fetchSnapshot.js → fetchSnapshot.cjs} +192 -176
  73. package/dist/fetchSnapshot.cjs.map +1 -0
  74. package/dist/fetchSnapshot.d.ts +10 -5
  75. package/dist/fetchSnapshot.d.ts.map +1 -1
  76. package/dist/{getFileLink.js → getFileLink.cjs} +52 -41
  77. package/dist/getFileLink.cjs.map +1 -0
  78. package/dist/getFileLink.d.ts +4 -7
  79. package/dist/getFileLink.d.ts.map +1 -1
  80. package/dist/{getQueryString.js → getQueryString.cjs} +1 -1
  81. package/dist/getQueryString.cjs.map +1 -0
  82. package/dist/getQueryString.d.ts.map +1 -1
  83. package/dist/{getUrlAndHeadersWithAuth.js → getUrlAndHeadersWithAuth.cjs} +4 -2
  84. package/dist/getUrlAndHeadersWithAuth.cjs.map +1 -0
  85. package/dist/getUrlAndHeadersWithAuth.d.ts.map +1 -1
  86. package/dist/index.cjs +59 -0
  87. package/dist/index.cjs.map +1 -0
  88. package/dist/index.d.ts +19 -16
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/localOdspDriver/localOdspDeltaStorageService.cjs +35 -0
  91. package/dist/localOdspDriver/localOdspDeltaStorageService.cjs.map +1 -0
  92. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts +17 -0
  93. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
  94. package/dist/localOdspDriver/{localOdspDocumentService.js → localOdspDocumentService.cjs} +7 -5
  95. package/dist/localOdspDriver/localOdspDocumentService.cjs.map +1 -0
  96. package/dist/localOdspDriver/localOdspDocumentService.d.ts +3 -2
  97. package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
  98. package/dist/localOdspDriver/{localOdspDocumentServiceFactory.js → localOdspDocumentServiceFactory.cjs} +9 -10
  99. package/dist/localOdspDriver/localOdspDocumentServiceFactory.cjs.map +1 -0
  100. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +2 -3
  101. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
  102. package/dist/localOdspDriver/{localOdspDocumentStorageManager.js → localOdspDocumentStorageManager.cjs} +13 -11
  103. package/dist/localOdspDriver/localOdspDocumentStorageManager.cjs.map +1 -0
  104. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts +2 -2
  105. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
  106. package/dist/odsp-driver-alpha.d.ts +496 -0
  107. package/dist/odsp-driver-beta.d.ts +160 -0
  108. package/dist/odsp-driver-public.d.ts +160 -0
  109. package/dist/odsp-driver-untrimmed.d.ts +565 -0
  110. package/dist/{odspCache.js → odspCache.cjs} +9 -10
  111. package/dist/odspCache.cjs.map +1 -0
  112. package/dist/odspCache.d.ts +19 -4
  113. package/dist/odspCache.d.ts.map +1 -1
  114. package/dist/odspDelayLoadedDeltaStream.cjs +291 -0
  115. package/dist/odspDelayLoadedDeltaStream.cjs.map +1 -0
  116. package/dist/odspDelayLoadedDeltaStream.d.ts +75 -0
  117. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -0
  118. package/dist/{odspDeltaStorageService.js → odspDeltaStorageService.cjs} +70 -71
  119. package/dist/odspDeltaStorageService.cjs.map +1 -0
  120. package/dist/odspDeltaStorageService.d.ts +8 -6
  121. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  122. package/dist/{odspDocumentDeltaConnection.js → odspDocumentDeltaConnection.cjs} +224 -113
  123. package/dist/odspDocumentDeltaConnection.cjs.map +1 -0
  124. package/dist/odspDocumentDeltaConnection.d.ts +32 -12
  125. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  126. package/dist/odspDocumentService.cjs +225 -0
  127. package/dist/odspDocumentService.cjs.map +1 -0
  128. package/dist/odspDocumentService.d.ts +11 -25
  129. package/dist/odspDocumentService.d.ts.map +1 -1
  130. package/dist/{odspDocumentServiceFactory.js → odspDocumentServiceFactory.cjs} +8 -5
  131. package/dist/odspDocumentServiceFactory.cjs.map +1 -0
  132. package/dist/odspDocumentServiceFactory.d.ts +4 -0
  133. package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
  134. package/dist/odspDocumentServiceFactoryCore.cjs +196 -0
  135. package/dist/odspDocumentServiceFactoryCore.cjs.map +1 -0
  136. package/dist/odspDocumentServiceFactoryCore.d.ts +18 -11
  137. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  138. package/dist/odspDocumentServiceFactoryWithCodeSplit.cjs +20 -0
  139. package/dist/odspDocumentServiceFactoryWithCodeSplit.cjs.map +1 -0
  140. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +5 -0
  141. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
  142. package/dist/odspDocumentStorageManager.cjs +490 -0
  143. package/dist/odspDocumentStorageManager.cjs.map +1 -0
  144. package/dist/odspDocumentStorageManager.d.ts +11 -5
  145. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  146. package/dist/{odspDocumentStorageServiceBase.js → odspDocumentStorageServiceBase.cjs} +32 -34
  147. package/dist/odspDocumentStorageServiceBase.cjs.map +1 -0
  148. package/dist/odspDocumentStorageServiceBase.d.ts +7 -9
  149. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  150. package/dist/{odspDriverUrlResolver.js → odspDriverUrlResolver.cjs} +50 -36
  151. package/dist/odspDriverUrlResolver.cjs.map +1 -0
  152. package/dist/odspDriverUrlResolver.d.ts +12 -0
  153. package/dist/odspDriverUrlResolver.d.ts.map +1 -1
  154. package/dist/{odspDriverUrlResolverForShareLink.js → odspDriverUrlResolverForShareLink.cjs} +37 -26
  155. package/dist/odspDriverUrlResolverForShareLink.cjs.map +1 -0
  156. package/dist/odspDriverUrlResolverForShareLink.d.ts +5 -3
  157. package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  158. package/dist/{odspError.js → odspError.cjs} +7 -3
  159. package/dist/odspError.cjs.map +1 -0
  160. package/dist/odspError.d.ts.map +1 -1
  161. package/dist/{odspFluidFileLink.js → odspFluidFileLink.cjs} +25 -18
  162. package/dist/odspFluidFileLink.cjs.map +1 -0
  163. package/dist/odspFluidFileLink.d.ts +10 -1
  164. package/dist/odspFluidFileLink.d.ts.map +1 -1
  165. package/dist/odspLocationRedirection.cjs +24 -0
  166. package/dist/odspLocationRedirection.cjs.map +1 -0
  167. package/dist/odspLocationRedirection.d.ts +14 -0
  168. package/dist/odspLocationRedirection.d.ts.map +1 -0
  169. package/dist/{odspPublicUtils.js → odspPublicUtils.cjs} +7 -4
  170. package/dist/odspPublicUtils.cjs.map +1 -0
  171. package/dist/odspPublicUtils.d.ts +6 -0
  172. package/dist/odspPublicUtils.d.ts.map +1 -1
  173. package/dist/{odspSnapshotParser.js → odspSnapshotParser.cjs} +11 -12
  174. package/dist/odspSnapshotParser.cjs.map +1 -0
  175. package/dist/odspSnapshotParser.d.ts.map +1 -1
  176. package/dist/{odspSummaryUploadManager.js → odspSummaryUploadManager.cjs} +47 -34
  177. package/dist/odspSummaryUploadManager.cjs.map +1 -0
  178. package/dist/odspSummaryUploadManager.d.ts +7 -4
  179. package/dist/odspSummaryUploadManager.d.ts.map +1 -1
  180. package/dist/{odspUrlHelper.js → odspUrlHelper.cjs} +9 -3
  181. package/dist/odspUrlHelper.cjs.map +1 -0
  182. package/dist/odspUrlHelper.d.ts +5 -0
  183. package/dist/odspUrlHelper.d.ts.map +1 -1
  184. package/dist/{odspUtils.js → odspUtils.cjs} +118 -30
  185. package/dist/odspUtils.cjs.map +1 -0
  186. package/dist/odspUtils.d.ts +35 -6
  187. package/dist/odspUtils.d.ts.map +1 -1
  188. package/dist/{opsCaching.js → opsCaching.cjs} +25 -9
  189. package/dist/opsCaching.cjs.map +1 -0
  190. package/dist/opsCaching.d.ts +3 -3
  191. package/dist/opsCaching.d.ts.map +1 -1
  192. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  193. package/dist/packageVersion.cjs.map +1 -0
  194. package/dist/packageVersion.d.ts +1 -1
  195. package/dist/packageVersion.d.ts.map +1 -1
  196. package/dist/prefetchLatestSnapshot.cjs +100 -0
  197. package/dist/prefetchLatestSnapshot.cjs.map +1 -0
  198. package/dist/prefetchLatestSnapshot.d.ts +12 -7
  199. package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
  200. package/dist/{retryErrorsStorageAdapter.js → retryErrorsStorageAdapter.cjs} +13 -6
  201. package/dist/retryErrorsStorageAdapter.cjs.map +1 -0
  202. package/dist/retryErrorsStorageAdapter.d.ts +5 -4
  203. package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
  204. package/dist/{retryUtils.js → retryUtils.cjs} +30 -14
  205. package/dist/retryUtils.cjs.map +1 -0
  206. package/dist/retryUtils.d.ts +2 -2
  207. package/dist/retryUtils.d.ts.map +1 -1
  208. package/dist/socketModule.cjs +10 -0
  209. package/dist/socketModule.cjs.map +1 -0
  210. package/dist/socketModule.d.ts +7 -0
  211. package/dist/socketModule.d.ts.map +1 -0
  212. package/dist/tsdoc-metadata.json +11 -0
  213. package/dist/{vroom.js → vroom.cjs} +24 -9
  214. package/dist/vroom.cjs.map +1 -0
  215. package/dist/vroom.d.ts +4 -4
  216. package/dist/vroom.d.ts.map +1 -1
  217. package/dist/{zipItDataRepresentationUtils.js → zipItDataRepresentationUtils.cjs} +227 -118
  218. package/dist/zipItDataRepresentationUtils.cjs.map +1 -0
  219. package/dist/zipItDataRepresentationUtils.d.ts +47 -20
  220. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  221. package/lib/{ReadBufferUtils.d.ts → ReadBufferUtils.d.mts} +1 -1
  222. package/lib/ReadBufferUtils.d.mts.map +1 -0
  223. package/lib/{ReadBufferUtils.js → ReadBufferUtils.mjs} +14 -7
  224. package/lib/ReadBufferUtils.mjs.map +1 -0
  225. package/lib/{WriteBufferUtils.d.ts → WriteBufferUtils.d.mts} +4 -6
  226. package/lib/WriteBufferUtils.d.mts.map +1 -0
  227. package/lib/{WriteBufferUtils.js → WriteBufferUtils.mjs} +68 -64
  228. package/lib/WriteBufferUtils.mjs.map +1 -0
  229. package/lib/{checkUrl.d.ts → checkUrl.d.mts} +2 -1
  230. package/lib/checkUrl.d.mts.map +1 -0
  231. package/lib/{checkUrl.js → checkUrl.mjs} +7 -6
  232. package/lib/checkUrl.mjs.map +1 -0
  233. package/lib/compactSnapshotParser.d.mts +24 -0
  234. package/lib/compactSnapshotParser.d.mts.map +1 -0
  235. package/lib/compactSnapshotParser.mjs +203 -0
  236. package/lib/compactSnapshotParser.mjs.map +1 -0
  237. package/lib/{compactSnapshotWriter.d.ts → compactSnapshotWriter.d.mts} +4 -5
  238. package/lib/compactSnapshotWriter.d.mts.map +1 -0
  239. package/lib/{compactSnapshotWriter.js → compactSnapshotWriter.mjs} +41 -31
  240. package/lib/compactSnapshotWriter.mjs.map +1 -0
  241. package/lib/{constants.d.ts → constants.d.mts} +7 -1
  242. package/lib/constants.d.mts.map +1 -0
  243. package/lib/{constants.js → constants.mjs} +7 -1
  244. package/lib/constants.mjs.map +1 -0
  245. package/lib/{contracts.d.ts → contracts.d.mts} +18 -55
  246. package/lib/contracts.d.mts.map +1 -0
  247. package/lib/{contracts.js → contracts.mjs} +1 -1
  248. package/lib/contracts.mjs.map +1 -0
  249. package/lib/{contractsPublic.d.ts → contractsPublic.d.mts} +16 -1
  250. package/lib/contractsPublic.d.mts.map +1 -0
  251. package/lib/{contractsPublic.js → contractsPublic.mjs} +7 -1
  252. package/lib/contractsPublic.mjs.map +1 -0
  253. package/lib/createFile.d.mts +18 -0
  254. package/lib/createFile.d.mts.map +1 -0
  255. package/lib/createFile.mjs +171 -0
  256. package/lib/createFile.mjs.map +1 -0
  257. package/lib/createNewContainerOnExistingFile.d.mts +22 -0
  258. package/lib/createNewContainerOnExistingFile.d.mts.map +1 -0
  259. package/lib/createNewContainerOnExistingFile.mjs +56 -0
  260. package/lib/createNewContainerOnExistingFile.mjs.map +1 -0
  261. package/lib/createNewModule.d.mts +7 -0
  262. package/lib/createNewModule.d.mts.map +1 -0
  263. package/lib/createNewModule.mjs +7 -0
  264. package/lib/createNewModule.mjs.map +1 -0
  265. package/lib/createNewUtils.d.mts +27 -0
  266. package/lib/createNewUtils.d.mts.map +1 -0
  267. package/lib/createNewUtils.mjs +197 -0
  268. package/lib/createNewUtils.mjs.map +1 -0
  269. package/lib/{createOdspCreateContainerRequest.d.ts → createOdspCreateContainerRequest.d.mts} +6 -8
  270. package/lib/createOdspCreateContainerRequest.d.mts.map +1 -0
  271. package/lib/{createOdspCreateContainerRequest.js → createOdspCreateContainerRequest.mjs} +8 -4
  272. package/lib/createOdspCreateContainerRequest.mjs.map +1 -0
  273. package/lib/{createOdspUrl.d.ts → createOdspUrl.d.mts} +3 -2
  274. package/lib/createOdspUrl.d.mts.map +1 -0
  275. package/lib/{createOdspUrl.js → createOdspUrl.mjs} +2 -1
  276. package/lib/createOdspUrl.mjs.map +1 -0
  277. package/lib/{epochTracker.d.ts → epochTracker.d.mts} +35 -11
  278. package/lib/epochTracker.d.mts.map +1 -0
  279. package/lib/{epochTracker.js → epochTracker.mjs} +97 -43
  280. package/lib/epochTracker.mjs.map +1 -0
  281. package/lib/{fetch.d.ts → fetch.d.mts} +2 -2
  282. package/lib/fetch.d.mts.map +1 -0
  283. package/lib/{fetch.js → fetch.mjs} +1 -1
  284. package/lib/fetch.mjs.map +1 -0
  285. package/lib/{fetchSnapshot.d.ts → fetchSnapshot.d.mts} +15 -10
  286. package/lib/fetchSnapshot.d.mts.map +1 -0
  287. package/lib/{fetchSnapshot.js → fetchSnapshot.mjs} +185 -167
  288. package/lib/fetchSnapshot.mjs.map +1 -0
  289. package/lib/{getFileLink.d.ts → getFileLink.d.mts} +5 -8
  290. package/lib/getFileLink.d.mts.map +1 -0
  291. package/lib/{getFileLink.js → getFileLink.mjs} +49 -38
  292. package/lib/getFileLink.mjs.map +1 -0
  293. package/lib/{getQueryString.d.ts → getQueryString.d.mts} +1 -5
  294. package/lib/getQueryString.d.mts.map +1 -0
  295. package/lib/{getQueryString.js → getQueryString.mjs} +1 -1
  296. package/lib/getQueryString.mjs.map +1 -0
  297. package/lib/{getUrlAndHeadersWithAuth.d.ts → getUrlAndHeadersWithAuth.d.mts} +1 -1
  298. package/lib/getUrlAndHeadersWithAuth.d.mts.map +1 -0
  299. package/lib/{getUrlAndHeadersWithAuth.js → getUrlAndHeadersWithAuth.mjs} +4 -2
  300. package/lib/getUrlAndHeadersWithAuth.mjs.map +1 -0
  301. package/lib/index.d.mts +24 -0
  302. package/lib/index.d.mts.map +1 -0
  303. package/lib/index.mjs +22 -0
  304. package/lib/index.mjs.map +1 -0
  305. package/lib/localOdspDriver/localOdspDeltaStorageService.d.mts +17 -0
  306. package/lib/localOdspDriver/localOdspDeltaStorageService.d.mts.map +1 -0
  307. package/lib/localOdspDriver/localOdspDeltaStorageService.mjs +31 -0
  308. package/lib/localOdspDriver/localOdspDeltaStorageService.mjs.map +1 -0
  309. package/lib/localOdspDriver/{localOdspDocumentService.d.ts → localOdspDocumentService.d.mts} +4 -3
  310. package/lib/localOdspDriver/localOdspDocumentService.d.mts.map +1 -0
  311. package/lib/localOdspDriver/{localOdspDocumentService.js → localOdspDocumentService.mjs} +8 -6
  312. package/lib/localOdspDriver/localOdspDocumentService.mjs.map +1 -0
  313. package/lib/localOdspDriver/{localOdspDocumentServiceFactory.d.ts → localOdspDocumentServiceFactory.d.mts} +5 -6
  314. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.mts.map +1 -0
  315. package/lib/localOdspDriver/{localOdspDocumentServiceFactory.js → localOdspDocumentServiceFactory.mjs} +9 -10
  316. package/lib/localOdspDriver/localOdspDocumentServiceFactory.mjs.map +1 -0
  317. package/lib/localOdspDriver/{localOdspDocumentStorageManager.d.ts → localOdspDocumentStorageManager.d.mts} +4 -4
  318. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.mts.map +1 -0
  319. package/lib/localOdspDriver/{localOdspDocumentStorageManager.js → localOdspDocumentStorageManager.mjs} +11 -9
  320. package/lib/localOdspDriver/localOdspDocumentStorageManager.mjs.map +1 -0
  321. package/lib/odsp-driver-alpha.d.mts +496 -0
  322. package/lib/odsp-driver-beta.d.mts +160 -0
  323. package/lib/odsp-driver-public.d.mts +160 -0
  324. package/lib/odsp-driver-untrimmed.d.mts +565 -0
  325. package/lib/{odspCache.d.ts → odspCache.d.mts} +20 -9
  326. package/lib/odspCache.d.mts.map +1 -0
  327. package/lib/{odspCache.js → odspCache.mjs} +6 -11
  328. package/lib/odspCache.mjs.map +1 -0
  329. package/lib/odspDelayLoadedDeltaStream.d.mts +75 -0
  330. package/lib/odspDelayLoadedDeltaStream.d.mts.map +1 -0
  331. package/lib/odspDelayLoadedDeltaStream.mjs +287 -0
  332. package/lib/odspDelayLoadedDeltaStream.mjs.map +1 -0
  333. package/lib/{odspDeltaStorageService.d.ts → odspDeltaStorageService.d.mts} +10 -8
  334. package/lib/odspDeltaStorageService.d.mts.map +1 -0
  335. package/lib/{odspDeltaStorageService.js → odspDeltaStorageService.mjs} +70 -68
  336. package/lib/odspDeltaStorageService.mjs.map +1 -0
  337. package/lib/{odspDocumentDeltaConnection.d.ts → odspDocumentDeltaConnection.d.mts} +34 -14
  338. package/lib/odspDocumentDeltaConnection.d.mts.map +1 -0
  339. package/lib/{odspDocumentDeltaConnection.js → odspDocumentDeltaConnection.mjs} +214 -103
  340. package/lib/odspDocumentDeltaConnection.mjs.map +1 -0
  341. package/lib/{odspDocumentService.d.ts → odspDocumentService.d.mts} +15 -29
  342. package/lib/odspDocumentService.d.mts.map +1 -0
  343. package/lib/odspDocumentService.mjs +221 -0
  344. package/lib/odspDocumentService.mjs.map +1 -0
  345. package/lib/{odspDocumentServiceFactory.d.ts → odspDocumentServiceFactory.d.mts} +6 -2
  346. package/lib/odspDocumentServiceFactory.d.mts.map +1 -0
  347. package/lib/{odspDocumentServiceFactory.js → odspDocumentServiceFactory.mjs} +8 -6
  348. package/lib/odspDocumentServiceFactory.mjs.map +1 -0
  349. package/lib/{odspDocumentServiceFactoryCore.d.ts → odspDocumentServiceFactoryCore.d.mts} +20 -13
  350. package/lib/odspDocumentServiceFactoryCore.d.mts.map +1 -0
  351. package/lib/odspDocumentServiceFactoryCore.mjs +192 -0
  352. package/lib/odspDocumentServiceFactoryCore.mjs.map +1 -0
  353. package/lib/{odspDocumentServiceFactoryWithCodeSplit.d.ts → odspDocumentServiceFactoryWithCodeSplit.d.mts} +7 -2
  354. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.mts.map +1 -0
  355. package/lib/{odspDocumentServiceFactoryWithCodeSplit.js → odspDocumentServiceFactoryWithCodeSplit.mjs} +8 -3
  356. package/lib/odspDocumentServiceFactoryWithCodeSplit.mjs.map +1 -0
  357. package/lib/{odspDocumentStorageManager.d.ts → odspDocumentStorageManager.d.mts} +18 -12
  358. package/lib/odspDocumentStorageManager.d.mts.map +1 -0
  359. package/lib/odspDocumentStorageManager.mjs +486 -0
  360. package/lib/odspDocumentStorageManager.mjs.map +1 -0
  361. package/lib/{odspDocumentStorageServiceBase.d.ts → odspDocumentStorageServiceBase.d.mts} +9 -11
  362. package/lib/odspDocumentStorageServiceBase.d.mts.map +1 -0
  363. package/lib/{odspDocumentStorageServiceBase.js → odspDocumentStorageServiceBase.mjs} +31 -33
  364. package/lib/odspDocumentStorageServiceBase.mjs.map +1 -0
  365. package/lib/{odspDriverUrlResolver.d.ts → odspDriverUrlResolver.d.mts} +13 -1
  366. package/lib/odspDriverUrlResolver.d.mts.map +1 -0
  367. package/lib/{odspDriverUrlResolver.js → odspDriverUrlResolver.mjs} +50 -40
  368. package/lib/odspDriverUrlResolver.mjs.map +1 -0
  369. package/lib/{odspDriverUrlResolverForShareLink.d.ts → odspDriverUrlResolverForShareLink.d.mts} +7 -5
  370. package/lib/odspDriverUrlResolverForShareLink.d.mts.map +1 -0
  371. package/lib/{odspDriverUrlResolverForShareLink.js → odspDriverUrlResolverForShareLink.mjs} +36 -29
  372. package/lib/odspDriverUrlResolverForShareLink.mjs.map +1 -0
  373. package/lib/{odspError.d.ts → odspError.d.mts} +2 -2
  374. package/lib/odspError.d.mts.map +1 -0
  375. package/lib/{odspError.js → odspError.mjs} +7 -3
  376. package/lib/odspError.mjs.map +1 -0
  377. package/lib/{odspFluidFileLink.d.ts → odspFluidFileLink.d.mts} +12 -3
  378. package/lib/odspFluidFileLink.d.mts.map +1 -0
  379. package/lib/{odspFluidFileLink.js → odspFluidFileLink.mjs} +23 -16
  380. package/lib/odspFluidFileLink.mjs.map +1 -0
  381. package/lib/odspLocationRedirection.d.mts +14 -0
  382. package/lib/odspLocationRedirection.d.mts.map +1 -0
  383. package/lib/odspLocationRedirection.mjs +20 -0
  384. package/lib/odspLocationRedirection.mjs.map +1 -0
  385. package/lib/{odspPublicUtils.d.ts → odspPublicUtils.d.mts} +7 -1
  386. package/lib/odspPublicUtils.d.mts.map +1 -0
  387. package/lib/{odspPublicUtils.js → odspPublicUtils.mjs} +5 -2
  388. package/lib/odspPublicUtils.mjs.map +1 -0
  389. package/lib/{odspSnapshotParser.d.ts → odspSnapshotParser.d.mts} +3 -3
  390. package/lib/odspSnapshotParser.d.mts.map +1 -0
  391. package/lib/{odspSnapshotParser.js → odspSnapshotParser.mjs} +10 -11
  392. package/lib/odspSnapshotParser.mjs.map +1 -0
  393. package/lib/{odspSummaryUploadManager.d.ts → odspSummaryUploadManager.d.mts} +9 -6
  394. package/lib/odspSummaryUploadManager.d.mts.map +1 -0
  395. package/lib/{odspSummaryUploadManager.js → odspSummaryUploadManager.mjs} +41 -32
  396. package/lib/odspSummaryUploadManager.mjs.map +1 -0
  397. package/lib/{odspUrlHelper.d.ts → odspUrlHelper.d.mts} +6 -1
  398. package/lib/odspUrlHelper.d.mts.map +1 -0
  399. package/lib/{odspUrlHelper.js → odspUrlHelper.mjs} +9 -3
  400. package/lib/odspUrlHelper.mjs.map +1 -0
  401. package/lib/{odspUtils.d.ts → odspUtils.d.mts} +37 -8
  402. package/lib/odspUtils.d.mts.map +1 -0
  403. package/lib/{odspUtils.js → odspUtils.mjs} +109 -27
  404. package/lib/odspUtils.mjs.map +1 -0
  405. package/lib/{opsCaching.d.ts → opsCaching.d.mts} +4 -4
  406. package/lib/opsCaching.d.mts.map +1 -0
  407. package/lib/{opsCaching.js → opsCaching.mjs} +23 -7
  408. package/lib/opsCaching.mjs.map +1 -0
  409. package/lib/{packageVersion.d.ts → packageVersion.d.mts} +2 -2
  410. package/lib/packageVersion.d.mts.map +1 -0
  411. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  412. package/lib/packageVersion.mjs.map +1 -0
  413. package/lib/{prefetchLatestSnapshot.d.ts → prefetchLatestSnapshot.d.mts} +14 -9
  414. package/lib/prefetchLatestSnapshot.d.mts.map +1 -0
  415. package/lib/prefetchLatestSnapshot.mjs +96 -0
  416. package/lib/prefetchLatestSnapshot.mjs.map +1 -0
  417. package/lib/{retryErrorsStorageAdapter.d.ts → retryErrorsStorageAdapter.d.mts} +6 -5
  418. package/lib/retryErrorsStorageAdapter.d.mts.map +1 -0
  419. package/lib/{retryErrorsStorageAdapter.js → retryErrorsStorageAdapter.mjs} +13 -6
  420. package/lib/retryErrorsStorageAdapter.mjs.map +1 -0
  421. package/lib/{retryUtils.d.ts → retryUtils.d.mts} +3 -3
  422. package/lib/retryUtils.d.mts.map +1 -0
  423. package/lib/{retryUtils.js → retryUtils.mjs} +27 -11
  424. package/lib/retryUtils.mjs.map +1 -0
  425. package/lib/socketModule.d.mts +7 -0
  426. package/lib/socketModule.d.mts.map +1 -0
  427. package/lib/socketModule.mjs +7 -0
  428. package/lib/socketModule.mjs.map +1 -0
  429. package/lib/{vroom.d.ts → vroom.d.mts} +7 -7
  430. package/lib/vroom.d.mts.map +1 -0
  431. package/lib/{vroom.js → vroom.mjs} +24 -9
  432. package/lib/vroom.mjs.map +1 -0
  433. package/lib/{zipItDataRepresentationUtils.d.ts → zipItDataRepresentationUtils.d.mts} +49 -22
  434. package/lib/zipItDataRepresentationUtils.d.mts.map +1 -0
  435. package/lib/{zipItDataRepresentationUtils.js → zipItDataRepresentationUtils.mjs} +213 -111
  436. package/lib/zipItDataRepresentationUtils.mjs.map +1 -0
  437. package/package.json +87 -69
  438. package/prettier.config.cjs +8 -0
  439. package/src/ReadBufferUtils.ts +51 -44
  440. package/src/WriteBufferUtils.ts +203 -181
  441. package/src/checkUrl.ts +16 -15
  442. package/src/compactSnapshotParser.ts +219 -103
  443. package/src/compactSnapshotWriter.ts +118 -97
  444. package/src/constants.ts +7 -0
  445. package/src/contracts.ts +96 -136
  446. package/src/contractsPublic.ts +31 -16
  447. package/src/createFile.ts +243 -305
  448. package/src/createNewContainerOnExistingFile.ts +93 -0
  449. package/src/createNewModule.ts +7 -0
  450. package/src/createNewUtils.ts +266 -56
  451. package/src/createOdspCreateContainerRequest.ts +22 -18
  452. package/src/createOdspUrl.ts +12 -13
  453. package/src/epochTracker.ts +596 -457
  454. package/src/fetch.ts +4 -4
  455. package/src/fetchSnapshot.ts +583 -508
  456. package/src/getFileLink.ts +194 -155
  457. package/src/getQueryString.ts +11 -9
  458. package/src/getUrlAndHeadersWithAuth.ts +34 -33
  459. package/src/index.ts +42 -18
  460. package/src/localOdspDriver/localOdspDeltaStorageService.ts +49 -0
  461. package/src/localOdspDriver/localOdspDocumentService.ts +40 -38
  462. package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +46 -43
  463. package/src/localOdspDriver/localOdspDocumentStorageManager.ts +55 -50
  464. package/src/odspCache.ts +112 -90
  465. package/src/odspDelayLoadedDeltaStream.ts +459 -0
  466. package/src/odspDeltaStorageService.ts +232 -221
  467. package/src/odspDocumentDeltaConnection.ts +751 -563
  468. package/src/odspDocumentService.ts +324 -523
  469. package/src/odspDocumentServiceFactory.ts +20 -21
  470. package/src/odspDocumentServiceFactoryCore.ts +329 -200
  471. package/src/odspDocumentServiceFactoryWithCodeSplit.ts +20 -20
  472. package/src/odspDocumentStorageManager.ts +730 -534
  473. package/src/odspDocumentStorageServiceBase.ts +279 -254
  474. package/src/odspDriverUrlResolver.ts +230 -188
  475. package/src/odspDriverUrlResolverForShareLink.ts +223 -203
  476. package/src/odspError.ts +27 -19
  477. package/src/odspFluidFileLink.ts +106 -87
  478. package/src/odspLocationRedirection.ts +26 -0
  479. package/src/odspPublicUtils.ts +20 -14
  480. package/src/odspSnapshotParser.ts +53 -46
  481. package/src/odspSummaryUploadManager.ts +243 -218
  482. package/src/odspUrlHelper.ts +81 -71
  483. package/src/odspUtils.ts +401 -259
  484. package/src/opsCaching.ts +214 -193
  485. package/src/packageVersion.ts +1 -1
  486. package/src/prefetchLatestSnapshot.ts +142 -80
  487. package/src/retryErrorsStorageAdapter.ts +92 -77
  488. package/src/retryUtils.ts +80 -57
  489. package/src/socketModule.ts +8 -0
  490. package/src/vroom.ts +92 -83
  491. package/src/zipItDataRepresentationUtils.ts +534 -394
  492. package/tsc-multi.test.json +4 -0
  493. package/tsconfig.json +11 -13
  494. package/.editorconfig +0 -7
  495. package/dist/ReadBufferUtils.js.map +0 -1
  496. package/dist/WriteBufferUtils.js.map +0 -1
  497. package/dist/checkUrl.js.map +0 -1
  498. package/dist/compactSnapshotParser.js +0 -115
  499. package/dist/compactSnapshotParser.js.map +0 -1
  500. package/dist/compactSnapshotWriter.js.map +0 -1
  501. package/dist/constants.js.map +0 -1
  502. package/dist/contracts.js.map +0 -1
  503. package/dist/contractsPublic.js.map +0 -1
  504. package/dist/createFile.js +0 -242
  505. package/dist/createFile.js.map +0 -1
  506. package/dist/createNewUtils.js +0 -67
  507. package/dist/createNewUtils.js.map +0 -1
  508. package/dist/createOdspCreateContainerRequest.js.map +0 -1
  509. package/dist/createOdspUrl.js.map +0 -1
  510. package/dist/epochTracker.js.map +0 -1
  511. package/dist/fetch.js.map +0 -1
  512. package/dist/fetchSnapshot.js.map +0 -1
  513. package/dist/getFileLink.js.map +0 -1
  514. package/dist/getQueryString.js.map +0 -1
  515. package/dist/getSocketIo.d.ts +0 -11
  516. package/dist/getSocketIo.d.ts.map +0 -1
  517. package/dist/getSocketIo.js +0 -20
  518. package/dist/getSocketIo.js.map +0 -1
  519. package/dist/getUrlAndHeadersWithAuth.js.map +0 -1
  520. package/dist/index.js +0 -41
  521. package/dist/index.js.map +0 -1
  522. package/dist/localOdspDriver/localOdspDocumentService.js.map +0 -1
  523. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +0 -1
  524. package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +0 -1
  525. package/dist/odspCache.js.map +0 -1
  526. package/dist/odspDeltaStorageService.js.map +0 -1
  527. package/dist/odspDocumentDeltaConnection.js.map +0 -1
  528. package/dist/odspDocumentService.js +0 -364
  529. package/dist/odspDocumentService.js.map +0 -1
  530. package/dist/odspDocumentServiceFactory.js.map +0 -1
  531. package/dist/odspDocumentServiceFactoryCore.js +0 -118
  532. package/dist/odspDocumentServiceFactoryCore.js.map +0 -1
  533. package/dist/odspDocumentServiceFactoryWithCodeSplit.js +0 -34
  534. package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +0 -1
  535. package/dist/odspDocumentStorageManager.js +0 -356
  536. package/dist/odspDocumentStorageManager.js.map +0 -1
  537. package/dist/odspDocumentStorageServiceBase.js.map +0 -1
  538. package/dist/odspDriverUrlResolver.js.map +0 -1
  539. package/dist/odspDriverUrlResolverForShareLink.js.map +0 -1
  540. package/dist/odspError.js.map +0 -1
  541. package/dist/odspFluidFileLink.js.map +0 -1
  542. package/dist/odspPublicUtils.js.map +0 -1
  543. package/dist/odspSnapshotParser.js.map +0 -1
  544. package/dist/odspSummaryUploadManager.js.map +0 -1
  545. package/dist/odspUrlHelper.js.map +0 -1
  546. package/dist/odspUtils.js.map +0 -1
  547. package/dist/opsCaching.js.map +0 -1
  548. package/dist/packageVersion.js.map +0 -1
  549. package/dist/prefetchLatestSnapshot.js +0 -57
  550. package/dist/prefetchLatestSnapshot.js.map +0 -1
  551. package/dist/retryErrorsStorageAdapter.js.map +0 -1
  552. package/dist/retryUtils.js.map +0 -1
  553. package/dist/vroom.js.map +0 -1
  554. package/dist/zipItDataRepresentationUtils.js.map +0 -1
  555. package/lib/ReadBufferUtils.d.ts.map +0 -1
  556. package/lib/ReadBufferUtils.js.map +0 -1
  557. package/lib/WriteBufferUtils.d.ts.map +0 -1
  558. package/lib/WriteBufferUtils.js.map +0 -1
  559. package/lib/checkUrl.d.ts.map +0 -1
  560. package/lib/checkUrl.js.map +0 -1
  561. package/lib/compactSnapshotParser.d.ts +0 -15
  562. package/lib/compactSnapshotParser.d.ts.map +0 -1
  563. package/lib/compactSnapshotParser.js +0 -111
  564. package/lib/compactSnapshotParser.js.map +0 -1
  565. package/lib/compactSnapshotWriter.d.ts.map +0 -1
  566. package/lib/compactSnapshotWriter.js.map +0 -1
  567. package/lib/constants.d.ts.map +0 -1
  568. package/lib/constants.js.map +0 -1
  569. package/lib/contracts.d.ts.map +0 -1
  570. package/lib/contracts.js.map +0 -1
  571. package/lib/contractsPublic.d.ts.map +0 -1
  572. package/lib/contractsPublic.js.map +0 -1
  573. package/lib/createFile.d.ts +0 -22
  574. package/lib/createFile.d.ts.map +0 -1
  575. package/lib/createFile.js +0 -235
  576. package/lib/createFile.js.map +0 -1
  577. package/lib/createNewUtils.d.ts +0 -11
  578. package/lib/createNewUtils.d.ts.map +0 -1
  579. package/lib/createNewUtils.js +0 -63
  580. package/lib/createNewUtils.js.map +0 -1
  581. package/lib/createOdspCreateContainerRequest.d.ts.map +0 -1
  582. package/lib/createOdspCreateContainerRequest.js.map +0 -1
  583. package/lib/createOdspUrl.d.ts.map +0 -1
  584. package/lib/createOdspUrl.js.map +0 -1
  585. package/lib/epochTracker.d.ts.map +0 -1
  586. package/lib/epochTracker.js.map +0 -1
  587. package/lib/fetch.d.ts.map +0 -1
  588. package/lib/fetch.js.map +0 -1
  589. package/lib/fetchSnapshot.d.ts.map +0 -1
  590. package/lib/fetchSnapshot.js.map +0 -1
  591. package/lib/getFileLink.d.ts.map +0 -1
  592. package/lib/getFileLink.js.map +0 -1
  593. package/lib/getQueryString.d.ts.map +0 -1
  594. package/lib/getQueryString.js.map +0 -1
  595. package/lib/getSocketIo.d.ts +0 -11
  596. package/lib/getSocketIo.d.ts.map +0 -1
  597. package/lib/getSocketIo.js +0 -13
  598. package/lib/getSocketIo.js.map +0 -1
  599. package/lib/getUrlAndHeadersWithAuth.d.ts.map +0 -1
  600. package/lib/getUrlAndHeadersWithAuth.js.map +0 -1
  601. package/lib/index.d.ts +0 -21
  602. package/lib/index.d.ts.map +0 -1
  603. package/lib/index.js +0 -29
  604. package/lib/index.js.map +0 -1
  605. package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +0 -1
  606. package/lib/localOdspDriver/localOdspDocumentService.js.map +0 -1
  607. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +0 -1
  608. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +0 -1
  609. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +0 -1
  610. package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +0 -1
  611. package/lib/odspCache.d.ts.map +0 -1
  612. package/lib/odspCache.js.map +0 -1
  613. package/lib/odspDeltaStorageService.d.ts.map +0 -1
  614. package/lib/odspDeltaStorageService.js.map +0 -1
  615. package/lib/odspDocumentDeltaConnection.d.ts.map +0 -1
  616. package/lib/odspDocumentDeltaConnection.js.map +0 -1
  617. package/lib/odspDocumentService.d.ts.map +0 -1
  618. package/lib/odspDocumentService.js +0 -360
  619. package/lib/odspDocumentService.js.map +0 -1
  620. package/lib/odspDocumentServiceFactory.d.ts.map +0 -1
  621. package/lib/odspDocumentServiceFactory.js.map +0 -1
  622. package/lib/odspDocumentServiceFactoryCore.d.ts.map +0 -1
  623. package/lib/odspDocumentServiceFactoryCore.js +0 -114
  624. package/lib/odspDocumentServiceFactoryCore.js.map +0 -1
  625. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +0 -1
  626. package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +0 -1
  627. package/lib/odspDocumentStorageManager.d.ts.map +0 -1
  628. package/lib/odspDocumentStorageManager.js +0 -352
  629. package/lib/odspDocumentStorageManager.js.map +0 -1
  630. package/lib/odspDocumentStorageServiceBase.d.ts.map +0 -1
  631. package/lib/odspDocumentStorageServiceBase.js.map +0 -1
  632. package/lib/odspDriverUrlResolver.d.ts.map +0 -1
  633. package/lib/odspDriverUrlResolver.js.map +0 -1
  634. package/lib/odspDriverUrlResolverForShareLink.d.ts.map +0 -1
  635. package/lib/odspDriverUrlResolverForShareLink.js.map +0 -1
  636. package/lib/odspError.d.ts.map +0 -1
  637. package/lib/odspError.js.map +0 -1
  638. package/lib/odspFluidFileLink.d.ts.map +0 -1
  639. package/lib/odspFluidFileLink.js.map +0 -1
  640. package/lib/odspPublicUtils.d.ts.map +0 -1
  641. package/lib/odspPublicUtils.js.map +0 -1
  642. package/lib/odspSnapshotParser.d.ts.map +0 -1
  643. package/lib/odspSnapshotParser.js.map +0 -1
  644. package/lib/odspSummaryUploadManager.d.ts.map +0 -1
  645. package/lib/odspSummaryUploadManager.js.map +0 -1
  646. package/lib/odspUrlHelper.d.ts.map +0 -1
  647. package/lib/odspUrlHelper.js.map +0 -1
  648. package/lib/odspUtils.d.ts.map +0 -1
  649. package/lib/odspUtils.js.map +0 -1
  650. package/lib/opsCaching.d.ts.map +0 -1
  651. package/lib/opsCaching.js.map +0 -1
  652. package/lib/packageVersion.d.ts.map +0 -1
  653. package/lib/packageVersion.js.map +0 -1
  654. package/lib/prefetchLatestSnapshot.d.ts.map +0 -1
  655. package/lib/prefetchLatestSnapshot.js +0 -53
  656. package/lib/prefetchLatestSnapshot.js.map +0 -1
  657. package/lib/retryErrorsStorageAdapter.d.ts.map +0 -1
  658. package/lib/retryErrorsStorageAdapter.js.map +0 -1
  659. package/lib/retryUtils.d.ts.map +0 -1
  660. package/lib/retryUtils.js.map +0 -1
  661. package/lib/vroom.d.ts.map +0 -1
  662. package/lib/vroom.js.map +0 -1
  663. package/lib/zipItDataRepresentationUtils.d.ts.map +0 -1
  664. package/lib/zipItDataRepresentationUtils.js.map +0 -1
  665. package/src/getSocketIo.ts +0 -14
  666. package/tsconfig.esnext.json +0 -7
@@ -3,559 +3,755 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { default as AbortController } from "abort-controller";
7
- import { ITelemetryLogger } from "@fluidframework/common-definitions";
8
6
  import {
9
- assert,
10
- delay,
11
- } from "@fluidframework/common-utils";
12
- import {
13
- PerformanceEvent,
7
+ generateStack,
8
+ ITelemetryLoggerExt,
9
+ loggerToMonitoringContext,
10
+ normalizeError,
11
+ overwriteStack,
12
+ PerformanceEvent,
14
13
  } from "@fluidframework/telemetry-utils";
14
+ import { performance } from "@fluid-internal/client-utils";
15
+ import { assert, delay } from "@fluidframework/core-utils";
16
+ import { LogLevel } from "@fluidframework/core-interfaces";
15
17
  import * as api from "@fluidframework/protocol-definitions";
16
- import {
17
- ISummaryContext,
18
- DriverErrorType,
19
- } from "@fluidframework/driver-definitions";
18
+ import { promiseRaceWithWinner } from "@fluidframework/driver-base";
19
+ import { ISummaryContext, DriverErrorType, FetchSource } from "@fluidframework/driver-definitions";
20
20
  import { RateLimiter, NonRetryableError } from "@fluidframework/driver-utils";
21
21
  import {
22
- IOdspResolvedUrl,
23
- ISnapshotOptions,
24
- OdspErrorType,
25
- InstrumentedStorageTokenFetcher,
22
+ IOdspResolvedUrl,
23
+ ISnapshotOptions,
24
+ OdspErrorType,
25
+ InstrumentedStorageTokenFetcher,
26
+ getKeyForCacheEntry,
26
27
  } from "@fluidframework/odsp-driver-definitions";
27
28
  import {
28
- IDocumentStorageGetVersionsResponse,
29
- HostStoragePolicyInternal,
30
- IVersionedValueWithEpoch,
31
- ISnapshotCachedEntry,
29
+ IDocumentStorageGetVersionsResponse,
30
+ HostStoragePolicyInternal,
31
+ IVersionedValueWithEpoch,
32
+ ISnapshotCachedEntry,
32
33
  } from "./contracts";
33
- import { downloadSnapshot, fetchSnapshot, fetchSnapshotWithRedeem, SnapshotFormatSupportType } from "./fetchSnapshot";
34
- import { getUrlAndHeadersWithAuth } from "./getUrlAndHeadersWithAuth";
35
- import { IOdspCache } from "./odspCache";
36
34
  import {
37
- createCacheSnapshotKey,
38
- getWithRetryForTokenRefresh,
39
- } from "./odspUtils";
35
+ downloadSnapshot,
36
+ evalBlobsAndTrees,
37
+ fetchSnapshot,
38
+ fetchSnapshotWithRedeem,
39
+ SnapshotFormatSupportType,
40
+ } from "./fetchSnapshot";
41
+ import { getUrlAndHeadersWithAuth } from "./getUrlAndHeadersWithAuth";
42
+ import { IOdspCache, IPrefetchSnapshotContents } from "./odspCache";
43
+ import { createCacheSnapshotKey, getWithRetryForTokenRefresh } from "./odspUtils";
40
44
  import { ISnapshotContents } from "./odspPublicUtils";
41
45
  import { EpochTracker } from "./epochTracker";
42
- import { OdspSummaryUploadManager } from "./odspSummaryUploadManager";
46
+ import type { OdspSummaryUploadManager } from "./odspSummaryUploadManager";
43
47
  import { FlushResult } from "./odspDocumentDeltaConnection";
44
48
  import { pkgVersion as driverVersion } from "./packageVersion";
45
49
  import { OdspDocumentStorageServiceBase } from "./odspDocumentStorageServiceBase";
46
50
 
47
51
  export const defaultSummarizerCacheExpiryTimeout: number = 60 * 1000; // 60 seconds.
48
52
 
49
- /* eslint-disable max-len */
50
-
51
- // An implementation of Promise.race that gives you the winner of the promise race
52
- async function promiseRaceWithWinner<T>(promises: Promise<T>[]): Promise<{ index: number; value: T; }> {
53
- return new Promise((resolve, reject) => {
54
- promises.forEach((p, index) => {
55
- p.then((v) => resolve({ index, value: v })).catch(reject);
56
- });
57
- });
58
- }
59
-
60
53
  interface GetVersionsTelemetryProps {
61
- cacheEntryAge?: number;
62
- cacheSummarizerExpired?: boolean;
54
+ cacheEntryAge?: number;
55
+ cacheSummarizerExpired?: boolean;
63
56
  }
64
57
 
65
58
  export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
66
- private readonly odspSummaryUploadManager: OdspSummaryUploadManager;
67
-
68
- private firstVersionCall = true;
69
-
70
- private readonly documentId: string;
71
- private readonly snapshotUrl: string | undefined;
72
- private readonly attachmentPOSTUrl: string | undefined;
73
- private readonly attachmentGETUrl: string | undefined;
74
- // Driver specified limits for snapshot size and time.
75
- /**
76
- * NOTE: While commit cfff6e3 added restrictions to prevent large payloads, snapshot failures will continue to
77
- * happen until blob request throttling is implemented. Until then, as a temporary fix we set arbitrarily large
78
- * snapshot size and timeout limits so that such failures are unlikely to occur.
79
- */
80
- private readonly maxSnapshotSizeLimit = 500000000; // 500 MB
81
- private readonly maxSnapshotFetchTimeout = 120000; // 2 min
82
-
83
- // limits the amount of parallel "attachment" blob uploads
84
- private readonly createBlobRateLimiter = new RateLimiter(1);
85
-
86
- constructor(
87
- private readonly odspResolvedUrl: IOdspResolvedUrl,
88
- private readonly getStorageToken: InstrumentedStorageTokenFetcher,
89
- private readonly logger: ITelemetryLogger,
90
- private readonly fetchFullSnapshot: boolean,
91
- private readonly cache: IOdspCache,
92
- private readonly hostPolicy: HostStoragePolicyInternal,
93
- private readonly epochTracker: EpochTracker,
94
- private readonly flushCallback: () => Promise<FlushResult>,
95
- private readonly snapshotFormatFetchType?: SnapshotFormatSupportType,
96
- ) {
97
- super();
98
-
99
- this.documentId = this.odspResolvedUrl.hashedDocumentId;
100
- this.snapshotUrl = this.odspResolvedUrl.endpoints.snapshotStorageUrl;
101
- this.attachmentPOSTUrl = this.odspResolvedUrl.endpoints.attachmentPOSTStorageUrl;
102
- this.attachmentGETUrl = this.odspResolvedUrl.endpoints.attachmentGETStorageUrl;
103
-
104
- this.odspSummaryUploadManager = new OdspSummaryUploadManager(
105
- this.snapshotUrl,
106
- getStorageToken,
107
- logger,
108
- epochTracker,
109
- !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
110
- );
111
- }
112
-
113
- public async createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse> {
114
- this.checkAttachmentPOSTUrl();
115
-
116
- const response = await getWithRetryForTokenRefresh(async (options) => {
117
- const storageToken = await this.getStorageToken(options, "CreateBlob");
118
- const { url, headers } = getUrlAndHeadersWithAuth(
119
- `${this.attachmentPOSTUrl}/content`,
120
- storageToken,
121
- !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
122
- );
123
- headers["Content-Type"] = "application/octet-stream";
124
-
125
- return PerformanceEvent.timedExecAsync(
126
- this.logger,
127
- {
128
- eventName: "createBlob",
129
- size: file.byteLength,
130
- waitQueueLength: this.createBlobRateLimiter.waitQueueLength,
131
- },
132
- async (event) => {
133
- const res = await this.createBlobRateLimiter.schedule(async () =>
134
- this.epochTracker.fetchAndParseAsJSON<api.ICreateBlobResponse>(
135
- url,
136
- {
137
- body: file,
138
- headers,
139
- method: "POST",
140
- },
141
- "createBlob",
142
- ));
143
- event.end({
144
- blobId: res.content.id,
145
- ...res.propsToLog,
146
- });
147
- return res;
148
- },
149
- );
150
- });
151
-
152
- return response.content;
153
- }
154
-
155
- protected async fetchBlobFromStorage(blobId: string, evicted: boolean): Promise<ArrayBuffer> {
156
- this.checkAttachmentGETUrl();
157
-
158
- const blob = await getWithRetryForTokenRefresh(async (options) => {
159
- const storageToken = await this.getStorageToken(options, "GetBlob");
160
- const unAuthedUrl = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;
161
- const { url, headers } = getUrlAndHeadersWithAuth(
162
- unAuthedUrl,
163
- storageToken,
164
- !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
165
- );
166
-
167
- return PerformanceEvent.timedExecAsync(
168
- this.logger,
169
- {
170
- eventName: "readDataBlob",
171
- blobId,
172
- evicted,
173
- headers: Object.keys(headers).length !== 0 ? true : undefined,
174
- waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,
175
- },
176
- async (event) => {
177
- const res = await this.epochTracker.fetchArray(url, { headers }, "blob");
178
- event.end({
179
- waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,
180
- ...res.propsToLog,
181
- attempts: options.refresh ? 2 : 1,
182
- });
183
- const cacheControl = res.headers.get("cache-control");
184
- if (cacheControl === undefined || !(cacheControl.includes("private") || cacheControl.includes("public"))) {
185
- this.logger.sendErrorEvent({
186
- eventName: "NonCacheableBlob",
187
- cacheControl,
188
- blobId,
189
- ...res.propsToLog,
190
- });
191
- }
192
- return res.content;
193
- },
194
- );
195
- });
196
- this.blobCache.setBlob(blobId, blob);
197
- return blob;
198
- }
199
-
200
- public async getSnapshotTree(version?: api.IVersion, scenarioName?: string): Promise<api.ISnapshotTree | null> {
201
- if (!this.snapshotUrl) {
202
- return null;
203
- }
204
- return super.getSnapshotTree(version, scenarioName);
205
- }
206
-
207
- public async getVersions(blobid: string | null, count: number, scenarioName?: string): Promise<api.IVersion[]> {
208
- // Regular load workflow uses blobId === documentID to indicate "latest".
209
- if (blobid !== this.documentId && blobid) {
210
- // FluidFetch & FluidDebugger tools use empty sting to query for versions
211
- // In such case we need to make a call against SPO to give full picture to the tool.
212
- // Otherwise, each commit calls getVersions but odsp doesn't have a history for each commit
213
- // return the blobid as is
214
- return [
215
- {
216
- id: blobid,
217
- treeId: undefined!,
218
- },
219
- ];
220
- }
221
-
222
- // Can't really make a call if we do not have URL
223
- if (!this.snapshotUrl) {
224
- return [];
225
- }
226
-
227
- // If count is one, we can use the trees/latest API, which returns the latest version and trees in a single request for better performance
228
- // Do it only once - we might get more here due to summarizer - it needs only container tree, not full snapshot.
229
- if (this.firstVersionCall && count === 1 && (blobid === null || blobid === this.documentId)) {
230
- const hostSnapshotOptions = this.hostPolicy.snapshotOptions;
231
- const odspSnapshotCacheValue: ISnapshotContents = await PerformanceEvent.timedExecAsync(
232
- this.logger,
233
- { eventName: "ObtainSnapshot" },
234
- async (event: PerformanceEvent) => {
235
- const props: GetVersionsTelemetryProps = {};
236
- let retrievedSnapshot: ISnapshotContents | undefined;
237
- // Here's the logic to grab the persistent cache snapshot implemented by the host
238
- // Epoch tracker is responsible for communicating with the persistent cache, handling epochs and cache versions
239
- const cachedSnapshotP: Promise<ISnapshotContents | undefined> =
240
- this.epochTracker.get(createCacheSnapshotKey(this.odspResolvedUrl))
241
- .then(async (snapshotCachedEntry: ISnapshotCachedEntry) => {
242
- if (snapshotCachedEntry !== undefined) {
243
- // If the cached entry does not contain the entry time, then assign it a default of 30 days old.
244
- const age = Date.now() - (snapshotCachedEntry.cacheEntryTime ??
245
- (Date.now() - 30 * 24 * 60 * 60 * 1000));
246
-
247
- // In order to decrease the number of times we have to execute a snapshot refresh,
248
- // if this is the summarizer and we have a cache entry but it is past the defaultSummarizerCacheExpiryTimeout,
249
- // force the network retrieval instead as there might be a more recent snapshot available.
250
- // See: https://github.com/microsoft/FluidFramework/issues/8995 for additional information.
251
- if (this.hostPolicy.summarizerClient) {
252
- if (age > defaultSummarizerCacheExpiryTimeout) {
253
- props.cacheSummarizerExpired = true;
254
- return undefined;
255
- } else {
256
- props.cacheSummarizerExpired = false;
257
- }
258
- }
259
-
260
- // Record the cache age
261
- props.cacheEntryAge = age;
262
- }
263
-
264
- return snapshotCachedEntry;
265
- });
266
-
267
- // Based on the concurrentSnapshotFetch policy:
268
- // Either retrieve both the network and cache snapshots concurrently and pick the first to return,
269
- // or grab the cache value and then the network value if the cache value returns undefined.
270
- let method: string;
271
- if (this.hostPolicy.concurrentSnapshotFetch && !this.hostPolicy.summarizerClient) {
272
- const networkSnapshotP = this.fetchSnapshot(hostSnapshotOptions, scenarioName);
273
-
274
- // Ensure that failures on both paths are ignored initially.
275
- // I.e. if cache fails for some reason, we will proceed with network result.
276
- // And vice versa - if (for example) client is offline and network request fails first, we
277
- // do want to attempt to succeed with cached data!
278
- const promiseRaceWinner = await promiseRaceWithWinner([
279
- cachedSnapshotP.catch(() => undefined),
280
- networkSnapshotP.catch(() => undefined),
281
- ]);
282
- retrievedSnapshot = promiseRaceWinner.value;
283
- method = promiseRaceWinner.index === 0 ? "cache" : "network";
284
-
285
- if (retrievedSnapshot === undefined) {
286
- // if network failed -> wait for cache ( then return network failure)
287
- // If cache returned empty or failed -> wait for network (success of failure)
288
- if (promiseRaceWinner.index === 1) {
289
- retrievedSnapshot = await cachedSnapshotP;
290
- method = "cache";
291
- }
292
- if (retrievedSnapshot === undefined) {
293
- retrievedSnapshot = await networkSnapshotP;
294
- method = "network";
295
- }
296
- }
297
- } else {
298
- // Note: There's a race condition here - another caller may come past the undefined check
299
- // while the first caller is awaiting later async code in this block.
300
-
301
- retrievedSnapshot = await cachedSnapshotP;
302
-
303
- method = retrievedSnapshot !== undefined ? "cache" : "network";
304
-
305
- if (retrievedSnapshot === undefined) {
306
- retrievedSnapshot = await this.fetchSnapshot(hostSnapshotOptions, scenarioName);
307
- }
308
- }
309
- if (method === "network") {
310
- props.cacheEntryAge = undefined;
311
- }
312
- event.end({ ...props, method });
313
- return retrievedSnapshot;
314
- },
315
- );
316
-
317
- // Successful call, make network calls only
318
- this.firstVersionCall = false;
319
- const id = this.initializeFromSnapshot(odspSnapshotCacheValue);
320
-
321
- return id ? [{ id, treeId: undefined! }] : [];
322
- }
323
-
324
- return getWithRetryForTokenRefresh(async (options) => {
325
- const storageToken = await this.getStorageToken(options, "GetVersions");
326
- const { url, headers } = getUrlAndHeadersWithAuth(
327
- `${this.snapshotUrl}/versions?top=${count}`,
328
- storageToken,
329
- !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
330
- );
331
-
332
- // Fetch the latest snapshot versions for the document
333
- const response = await PerformanceEvent.timedExecAsync(
334
- this.logger,
335
- {
336
- eventName: "getVersions",
337
- headers: Object.keys(headers).length !== 0 ? true : undefined,
338
- },
339
- async () => this.epochTracker.fetchAndParseAsJSON<IDocumentStorageGetVersionsResponse>(url, { headers }, "versions", undefined, scenarioName),
340
- );
341
- const versionsResponse = response.content;
342
- if (!versionsResponse) {
343
- throw new NonRetryableError(
344
- "No response from /versions endpoint",
345
- DriverErrorType.genericNetworkError,
346
- { driverVersion });
347
- }
348
- if (!Array.isArray(versionsResponse.value)) {
349
- throw new NonRetryableError(
350
- "Incorrect response from /versions endpoint, expected an array",
351
- DriverErrorType.genericNetworkError,
352
- { driverVersion });
353
- }
354
- return versionsResponse.value.map((version) => {
355
- return {
356
- id: version.id,
357
- treeId: undefined!,
358
- };
359
- });
360
- });
361
- }
362
-
363
- private async fetchSnapshot(hostSnapshotOptions: ISnapshotOptions | undefined, scenarioName?: string) {
364
- return this.fetchSnapshotCore(hostSnapshotOptions, scenarioName).catch((error) => {
365
- // Issue #5895:
366
- // If we are offline, this error is retryable. But that means that RetriableDocumentStorageService
367
- // will run in circles calling getSnapshotTree, which would result in OdspDocumentStorageService class
368
- // going getVersions / individual blob download path. This path is very slow, and will not work with
369
- // delay-loaded data stores and ODSP storage deleting old snapshots and blobs.
370
- if (typeof error === "object" && error !== null) {
371
- error.canRetry = false;
372
- }
373
- throw error;
374
- });
375
- }
376
-
377
- private async fetchSnapshotCore(hostSnapshotOptions: ISnapshotOptions | undefined, scenarioName?: string) {
378
- const snapshotOptions: ISnapshotOptions = {
379
- mds: this.maxSnapshotSizeLimit,
380
- ...hostSnapshotOptions,
381
- timeout: hostSnapshotOptions?.timeout ? Math.min(hostSnapshotOptions.timeout, this.maxSnapshotFetchTimeout) : this.maxSnapshotFetchTimeout,
382
- };
383
-
384
- // No limit on size of snapshot or time to fetch, as otherwise we fail all clients to summarize
385
- if (this.hostPolicy.summarizerClient) {
386
- snapshotOptions.mds = undefined;
387
- snapshotOptions.timeout = undefined;
388
- }
389
-
390
- const snapshotDownloader = async (
391
- finalOdspResolvedUrl: IOdspResolvedUrl,
392
- storageToken: string,
393
- options: ISnapshotOptions | undefined,
394
- controller?: AbortController,
395
- ) => {
396
- return downloadSnapshot(
397
- finalOdspResolvedUrl,
398
- storageToken,
399
- this.logger,
400
- options,
401
- this.snapshotFormatFetchType,
402
- controller,
403
- this.epochTracker,
404
- scenarioName,
405
- );
406
- };
407
- const putInCache = async (valueWithEpoch: IVersionedValueWithEpoch) => {
408
- return this.cache.persistedCache.put(
409
- createCacheSnapshotKey(this.odspResolvedUrl),
410
- // Epoch tracker will add the epoch and version to the value here. So just send value to cache.
411
- valueWithEpoch.value,
412
- );
413
- };
414
- const removeEntries = async () => this.cache.persistedCache.removeEntries();
415
- try {
416
- const odspSnapshot = await fetchSnapshotWithRedeem(
417
- this.odspResolvedUrl,
418
- this.getStorageToken,
419
- snapshotOptions,
420
- !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
421
- this.logger,
422
- snapshotDownloader,
423
- putInCache,
424
- removeEntries,
425
- this.hostPolicy.enableRedeemFallback,
426
- );
427
- return odspSnapshot;
428
- } catch (error: any) {
429
- const errorType = error.errorType;
430
- // If the snapshot size is too big and the host specified the size limitation(specified in hostSnapshotOptions), then don't try to fetch the snapshot again.
431
- if ((errorType === OdspErrorType.snapshotTooBig && hostSnapshotOptions?.mds !== undefined) && (this.hostPolicy.summarizerClient !== true)) {
432
- throw error;
433
- }
434
- // If the first snapshot request was with blobs and we either timed out or the size was too big, then try to fetch without blobs.
435
- if ((errorType === OdspErrorType.snapshotTooBig || errorType === OdspErrorType.fetchTimeout) && snapshotOptions.blobs) {
436
- this.logger.sendErrorEvent({
437
- eventName: "TreeLatest_SecondCall",
438
- errorType,
439
- });
440
- const snapshotOptionsWithoutBlobs: ISnapshotOptions = { ...snapshotOptions, blobs: 0, mds: undefined, timeout: undefined };
441
- const odspSnapshot = await fetchSnapshotWithRedeem(
442
- this.odspResolvedUrl,
443
- this.getStorageToken,
444
- snapshotOptionsWithoutBlobs,
445
- !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
446
- this.logger,
447
- snapshotDownloader,
448
- putInCache,
449
- removeEntries,
450
- this.hostPolicy.enableRedeemFallback,
451
- );
452
- return odspSnapshot;
453
- }
454
- throw error;
455
- }
456
- }
457
-
458
- public async uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string> {
459
- this.checkSnapshotUrl();
460
-
461
- // Enable flushing only if we have single commit summary and this is not the initial summary for an empty file
462
- if (".protocol" in summary.tree && context.ackHandle !== undefined) {
463
- let retry = 1;
464
- for (;;) {
465
- const result = await this.flushCallback();
466
- const seq = result.lastPersistedSequenceNumber;
467
- if (seq !== undefined && seq >= context.referenceSequenceNumber) {
468
- break;
469
- }
470
-
471
- if (retry > 3) {
472
- this.logger.sendErrorEvent({
473
- eventName: "FlushFailure",
474
- ...result,
475
- retry,
476
- referenceSequenceNumber: context.referenceSequenceNumber,
477
- });
478
- break;
479
- }
480
-
481
- this.logger.sendPerformanceEvent({
482
- eventName: "FlushExtraCall",
483
- ...result,
484
- retry,
485
- referenceSequenceNumber: context.referenceSequenceNumber,
486
- });
487
-
488
- retry++;
489
- await delay(1000 * (result.retryAfter ?? 1));
490
- }
491
- }
492
-
493
- const id = await this.odspSummaryUploadManager.writeSummaryTree(summary, context);
494
- return id;
495
- }
496
-
497
- private checkSnapshotUrl() {
498
- if (!this.snapshotUrl) {
499
- throw new NonRetryableError(
500
- "Method failed because no snapshot url was available",
501
- DriverErrorType.genericError,
502
- { driverVersion });
503
- }
504
- }
505
-
506
- private checkAttachmentPOSTUrl() {
507
- if (!this.attachmentPOSTUrl) {
508
- throw new NonRetryableError(
509
- "Method failed because no attachment POST url was available",
510
- DriverErrorType.genericError,
511
- { driverVersion });
512
- }
513
- }
514
-
515
- private checkAttachmentGETUrl() {
516
- if (!this.attachmentGETUrl) {
517
- throw new NonRetryableError(
518
- "Method failed because no attachment GET url was available",
519
- DriverErrorType.genericError,
520
- { driverVersion });
521
- }
522
- }
523
-
524
- protected async fetchTreeFromSnapshot(id: string, scenarioName?: string): Promise<api.ISnapshotTree | undefined> {
525
- return getWithRetryForTokenRefresh(async (options) => {
526
- const storageToken = await this.getStorageToken(options, "ReadCommit");
527
- const snapshotDownloader = async (url: string, fetchOptions: { [index: string]: any; }) => {
528
- return this.epochTracker.fetchAndParseAsJSON(
529
- url,
530
- fetchOptions,
531
- "snapshotTree",
532
- undefined,
533
- scenarioName,
534
- );
535
- };
536
- const snapshot = await fetchSnapshot(
537
- this.snapshotUrl!,
538
- storageToken,
539
- id,
540
- this.fetchFullSnapshot,
541
- !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
542
- this.logger,
543
- snapshotDownloader,
544
- );
545
- let treeId = "";
546
- if (snapshot.snapshotTree) {
547
- assert(snapshot.snapshotTree.id !== undefined, 0x222 /* "Root tree should contain the id!!" */);
548
- treeId = snapshot.snapshotTree.id;
549
- this.setRootTree(treeId, snapshot.snapshotTree);
550
- }
551
- if (snapshot.blobs) {
552
- this.initBlobsCache(snapshot.blobs);
553
- }
554
- // If the version id doesn't match with the id of the tree, then use the id of first tree which in that case
555
- // will be the actual id of tree to be fetched.
556
- return this.commitCache.get(id) ?? this.commitCache.get(treeId);
557
- });
558
- }
59
+ private odspSummaryModuleLoaded: boolean = false;
60
+ private summaryModuleP: Promise<OdspSummaryUploadManager> | undefined;
61
+ private odspSummaryUploadManager: OdspSummaryUploadManager | undefined;
62
+
63
+ private firstVersionCall = true;
64
+ private _isFirstSnapshotFromNetwork: boolean | undefined;
65
+ private readonly documentId: string;
66
+ private readonly snapshotUrl: string | undefined;
67
+ private readonly attachmentPOSTUrl: string | undefined;
68
+ private readonly attachmentGETUrl: string | undefined;
69
+ // Driver specified limits for snapshot size and time.
70
+ /**
71
+ * NOTE: While commit cfff6e3 added restrictions to prevent large payloads, snapshot failures will continue to
72
+ * happen until blob request throttling is implemented. Until then, as a temporary fix we set arbitrarily large
73
+ * snapshot size and timeout limits so that such failures are unlikely to occur.
74
+ */
75
+ private readonly maxSnapshotSizeLimit = 500000000; // 500 MB
76
+ private readonly maxSnapshotFetchTimeout = 120000; // 2 min
77
+
78
+ // limits the amount of parallel "attachment" blob uploads
79
+ private readonly createBlobRateLimiter = new RateLimiter(1);
80
+
81
+ constructor(
82
+ private readonly odspResolvedUrl: IOdspResolvedUrl,
83
+ private readonly getStorageToken: InstrumentedStorageTokenFetcher,
84
+ private readonly logger: ITelemetryLoggerExt,
85
+ private readonly fetchFullSnapshot: boolean,
86
+ private readonly cache: IOdspCache,
87
+ private readonly hostPolicy: HostStoragePolicyInternal,
88
+ private readonly epochTracker: EpochTracker,
89
+ private readonly flushCallback: () => Promise<FlushResult>,
90
+ private readonly relayServiceTenantAndSessionId: () => string | undefined,
91
+ private readonly snapshotFormatFetchType?: SnapshotFormatSupportType,
92
+ ) {
93
+ super(loggerToMonitoringContext(logger).config);
94
+
95
+ this.documentId = this.odspResolvedUrl.hashedDocumentId;
96
+ this.snapshotUrl = this.odspResolvedUrl.endpoints.snapshotStorageUrl;
97
+ this.attachmentPOSTUrl = this.odspResolvedUrl.endpoints.attachmentPOSTStorageUrl;
98
+ this.attachmentGETUrl = this.odspResolvedUrl.endpoints.attachmentGETStorageUrl;
99
+ }
100
+
101
+ public get isFirstSnapshotFromNetwork() {
102
+ return this._isFirstSnapshotFromNetwork;
103
+ }
104
+
105
+ public async createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse> {
106
+ this.checkAttachmentPOSTUrl();
107
+
108
+ const response = await getWithRetryForTokenRefresh(async (options) => {
109
+ const storageToken = await this.getStorageToken(options, "CreateBlob");
110
+ const { url, headers } = getUrlAndHeadersWithAuth(
111
+ `${this.attachmentPOSTUrl}/content`,
112
+ storageToken,
113
+ !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
114
+ );
115
+ headers["Content-Type"] = "application/octet-stream";
116
+
117
+ return PerformanceEvent.timedExecAsync(
118
+ this.logger,
119
+ {
120
+ eventName: "createBlob",
121
+ size: file.byteLength,
122
+ waitQueueLength: this.createBlobRateLimiter.waitQueueLength,
123
+ },
124
+ async (event) => {
125
+ const res = await this.createBlobRateLimiter.schedule(async () =>
126
+ this.epochTracker.fetchAndParseAsJSON<api.ICreateBlobResponse>(
127
+ url,
128
+ {
129
+ body: file,
130
+ headers,
131
+ method: "POST",
132
+ },
133
+ "createBlob",
134
+ ),
135
+ );
136
+ event.end({
137
+ blobId: res.content.id,
138
+ ...res.propsToLog,
139
+ });
140
+ return res;
141
+ },
142
+ );
143
+ });
144
+
145
+ return response.content;
146
+ }
147
+
148
+ protected async fetchBlobFromStorage(blobId: string, evicted: boolean): Promise<ArrayBuffer> {
149
+ this.checkAttachmentGETUrl();
150
+
151
+ const blob = await getWithRetryForTokenRefresh(async (options) => {
152
+ const storageToken = await this.getStorageToken(options, "GetBlob");
153
+ const unAuthedUrl = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;
154
+ const { url, headers } = getUrlAndHeadersWithAuth(
155
+ unAuthedUrl,
156
+ storageToken,
157
+ !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
158
+ );
159
+
160
+ return PerformanceEvent.timedExecAsync(
161
+ this.logger,
162
+ {
163
+ eventName: "readDataBlob",
164
+ blobId,
165
+ evicted,
166
+ headers: Object.keys(headers).length !== 0 ? true : undefined,
167
+ waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,
168
+ },
169
+ async (event) => {
170
+ const res = await this.epochTracker.fetchArray(url, { headers }, "blob");
171
+ event.end({
172
+ waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,
173
+ ...res.propsToLog,
174
+ attempts: options.refresh ? 2 : 1,
175
+ });
176
+ const cacheControl = res.headers.get("cache-control");
177
+ if (
178
+ cacheControl === undefined ||
179
+ !(cacheControl.includes("private") || cacheControl.includes("public"))
180
+ ) {
181
+ this.logger.sendErrorEvent({
182
+ eventName: "NonCacheableBlob",
183
+ cacheControl,
184
+ blobId,
185
+ ...res.propsToLog,
186
+ });
187
+ }
188
+ return res.content;
189
+ },
190
+ );
191
+ });
192
+ this.blobCache.setBlob(blobId, blob);
193
+ return blob;
194
+ }
195
+
196
+ public async getSnapshotTree(
197
+ version?: api.IVersion,
198
+ scenarioName?: string,
199
+ // eslint-disable-next-line @rushstack/no-new-null
200
+ ): Promise<api.ISnapshotTree | null> {
201
+ if (!this.snapshotUrl) {
202
+ return null;
203
+ }
204
+ return super.getSnapshotTree(version, scenarioName);
205
+ }
206
+
207
+ public async getVersions(
208
+ // eslint-disable-next-line @rushstack/no-new-null
209
+ blobid: string | null,
210
+ count: number,
211
+ scenarioName?: string,
212
+ fetchSource?: FetchSource,
213
+ ): Promise<api.IVersion[]> {
214
+ // Regular load workflow uses blobId === documentID to indicate "latest".
215
+ if (blobid !== this.documentId && blobid) {
216
+ // FluidFetch & FluidDebugger tools use empty sting to query for versions
217
+ // In such case we need to make a call against SPO to give full picture to the tool.
218
+ // Otherwise, each commit calls getVersions but odsp doesn't have a history for each commit
219
+ // return the blobid as is
220
+ return [
221
+ {
222
+ id: blobid,
223
+ treeId: undefined!,
224
+ },
225
+ ];
226
+ }
227
+
228
+ // Can't really make a call if we do not have URL
229
+ if (!this.snapshotUrl) {
230
+ return [];
231
+ }
232
+
233
+ // If count is one, we can use the trees/latest API, which returns the latest version and trees in a single request for better performance
234
+ if (count === 1 && (blobid === null || blobid === this.documentId)) {
235
+ const hostSnapshotOptions = this.hostPolicy.snapshotOptions;
236
+ const odspSnapshotCacheValue: ISnapshotContents = await PerformanceEvent.timedExecAsync(
237
+ this.logger,
238
+ { eventName: "ObtainSnapshot", fetchSource },
239
+ async (event: PerformanceEvent) => {
240
+ const props: GetVersionsTelemetryProps = {};
241
+ let cacheLookupTimeInSerialFetch = 0;
242
+ let retrievedSnapshot:
243
+ | ISnapshotContents
244
+ | IPrefetchSnapshotContents
245
+ | undefined;
246
+
247
+ let method: string;
248
+ let prefetchWaitStartTime: number = performance.now();
249
+ if (fetchSource === FetchSource.noCache) {
250
+ retrievedSnapshot = await this.fetchSnapshot(
251
+ hostSnapshotOptions,
252
+ scenarioName,
253
+ );
254
+ method = "networkOnly";
255
+ } else {
256
+ // Here's the logic to grab the persistent cache snapshot implemented by the host
257
+ // Epoch tracker is responsible for communicating with the persistent cache, handling epochs and cache versions
258
+ const cachedSnapshotP: Promise<ISnapshotContents | undefined> =
259
+ this.epochTracker
260
+ .get(createCacheSnapshotKey(this.odspResolvedUrl))
261
+ .then(async (snapshotCachedEntry: ISnapshotCachedEntry) => {
262
+ if (snapshotCachedEntry !== undefined) {
263
+ // If the cached entry does not contain the entry time, then assign it a default of 30 days old.
264
+ const age =
265
+ Date.now() -
266
+ (snapshotCachedEntry.cacheEntryTime ??
267
+ Date.now() - 30 * 24 * 60 * 60 * 1000);
268
+
269
+ // In order to decrease the number of times we have to execute a snapshot refresh,
270
+ // if this is the summarizer and we have a cache entry but it is past the defaultSummarizerCacheExpiryTimeout,
271
+ // force the network retrieval instead as there might be a more recent snapshot available.
272
+ // See: https://github.com/microsoft/FluidFramework/issues/8995 for additional information.
273
+ if (this.hostPolicy.summarizerClient) {
274
+ if (age > defaultSummarizerCacheExpiryTimeout) {
275
+ props.cacheSummarizerExpired = true;
276
+ return undefined;
277
+ } else {
278
+ props.cacheSummarizerExpired = false;
279
+ }
280
+ }
281
+
282
+ // Record the cache age
283
+ props.cacheEntryAge = age;
284
+ }
285
+
286
+ return snapshotCachedEntry;
287
+ });
288
+ // Based on the concurrentSnapshotFetch policy:
289
+ // Either retrieve both the network and cache snapshots concurrently and pick the first to return,
290
+ // or grab the cache value and then the network value if the cache value returns undefined.
291
+ // For summarizer which could call this during refreshing of summary parent, always use the cache
292
+ // first. Also for other clients, if it is not critical path which is determined by firstVersionCall,
293
+ // then also check the cache first.
294
+ if (
295
+ this.firstVersionCall &&
296
+ this.hostPolicy.concurrentSnapshotFetch &&
297
+ !this.hostPolicy.summarizerClient
298
+ ) {
299
+ const networkSnapshotP = this.fetchSnapshot(
300
+ hostSnapshotOptions,
301
+ scenarioName,
302
+ );
303
+
304
+ // Ensure that failures on both paths are ignored initially.
305
+ // I.e. if cache fails for some reason, we will proceed with network result.
306
+ // And vice versa - if (for example) client is offline and network request fails first, we
307
+ // do want to attempt to succeed with cached data!
308
+ const promiseRaceWinner = await promiseRaceWithWinner([
309
+ cachedSnapshotP.catch(() => undefined),
310
+ networkSnapshotP.catch(() => undefined),
311
+ ]);
312
+ retrievedSnapshot = promiseRaceWinner.value;
313
+ method = promiseRaceWinner.index === 0 ? "cache" : "network";
314
+
315
+ if (retrievedSnapshot === undefined) {
316
+ // if network failed -> wait for cache ( then return network failure)
317
+ // If cache returned empty or failed -> wait for network (success of failure)
318
+ try {
319
+ if (promiseRaceWinner.index === 1) {
320
+ retrievedSnapshot = await cachedSnapshotP;
321
+ method = "cache";
322
+ }
323
+ if (retrievedSnapshot === undefined) {
324
+ retrievedSnapshot = await networkSnapshotP;
325
+ method = "network";
326
+ }
327
+ } catch (err: unknown) {
328
+ // The call stacks of any errors thrown by cached snapshot or network snapshot aren't very useful:
329
+ // they get truncated at this stack frame due to the promise race and how v8 tracks async stack traces--
330
+ // see https://v8.dev/docs/stack-trace-api#async-stack-traces and the "zero-cost async stack traces" document
331
+ // linked there. https://v8.dev/blog/fast-async#await-under-the-hood may also be helpful for context on internals.
332
+ // Regenerating the stack at this level provides more information for logged errors.
333
+ // Once FF uses an ES2021 target, we could convert the above promise race to use `Promise.any` + AggregateError and
334
+ // get similar quality stacks with less hand-crafted code.
335
+ const innerStack = (err as Error).stack;
336
+ const normalizedError = normalizeError(err);
337
+ normalizedError.addTelemetryProperties({ innerStack });
338
+
339
+ const newStack = `<<STACK TRUNCATED: see innerStack property>> \n${generateStack()}`;
340
+ overwriteStack(normalizedError, newStack);
341
+
342
+ throw normalizedError;
343
+ }
344
+ }
345
+ } else {
346
+ // Note: There's a race condition here - another caller may come past the undefined check
347
+ // while the first caller is awaiting later async code in this block.
348
+ const startTime = performance.now();
349
+ retrievedSnapshot = await cachedSnapshotP;
350
+ cacheLookupTimeInSerialFetch = performance.now() - startTime;
351
+ method = retrievedSnapshot !== undefined ? "cache" : "network";
352
+
353
+ if (retrievedSnapshot === undefined) {
354
+ prefetchWaitStartTime = performance.now();
355
+ retrievedSnapshot = await this.fetchSnapshot(
356
+ hostSnapshotOptions,
357
+ scenarioName,
358
+ );
359
+ }
360
+ }
361
+ }
362
+ if (method === "network") {
363
+ props.cacheEntryAge = undefined;
364
+ }
365
+ if (this.firstVersionCall) {
366
+ this._isFirstSnapshotFromNetwork = method === "cache" ? false : true;
367
+ }
368
+ const prefetchStartTime: number | undefined = (
369
+ retrievedSnapshot as IPrefetchSnapshotContents
370
+ ).prefetchStartTime;
371
+ event.end({
372
+ ...props,
373
+ method,
374
+ avoidPrefetchSnapshotCache: this.hostPolicy.avoidPrefetchSnapshotCache,
375
+ ...evalBlobsAndTrees(retrievedSnapshot),
376
+ cacheLookupTimeInSerialFetch,
377
+ prefetchSavedDuration:
378
+ prefetchStartTime !== undefined && method !== "cache"
379
+ ? prefetchWaitStartTime - prefetchStartTime
380
+ : undefined,
381
+ });
382
+ return retrievedSnapshot;
383
+ },
384
+ );
385
+
386
+ const stTime = performance.now();
387
+ // Don't override ops which were fetched during initial load, since we could still need them.
388
+ const id = this.initializeFromSnapshot(odspSnapshotCacheValue, this.firstVersionCall);
389
+ this.logger.sendTelemetryEvent(
390
+ {
391
+ eventName: "SnapshotInitializeTime",
392
+ duration: performance.now() - stTime,
393
+ },
394
+ undefined,
395
+ LogLevel.verbose,
396
+ );
397
+ this.firstVersionCall = false;
398
+
399
+ return id ? [{ id, treeId: undefined! }] : [];
400
+ }
401
+
402
+ return getWithRetryForTokenRefresh(async (options) => {
403
+ const storageToken = await this.getStorageToken(options, "GetVersions");
404
+ const { url, headers } = getUrlAndHeadersWithAuth(
405
+ `${this.snapshotUrl}/versions?top=${count}`,
406
+ storageToken,
407
+ !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
408
+ );
409
+
410
+ // Fetch the latest snapshot versions for the document
411
+ const response = await PerformanceEvent.timedExecAsync(
412
+ this.logger,
413
+ {
414
+ eventName: "getVersions",
415
+ headers: Object.keys(headers).length !== 0 ? true : undefined,
416
+ },
417
+ async () =>
418
+ this.epochTracker.fetchAndParseAsJSON<IDocumentStorageGetVersionsResponse>(
419
+ url,
420
+ { headers },
421
+ "versions",
422
+ undefined,
423
+ scenarioName,
424
+ ),
425
+ );
426
+ const versionsResponse = response.content;
427
+ if (!versionsResponse) {
428
+ throw new NonRetryableError(
429
+ "No response from /versions endpoint",
430
+ DriverErrorType.genericNetworkError,
431
+ { driverVersion },
432
+ );
433
+ }
434
+ if (!Array.isArray(versionsResponse.value)) {
435
+ throw new NonRetryableError(
436
+ "Incorrect response from /versions endpoint, expected an array",
437
+ DriverErrorType.genericNetworkError,
438
+ { driverVersion },
439
+ );
440
+ }
441
+ return versionsResponse.value.map((version) => {
442
+ return {
443
+ id: version.id,
444
+ treeId: undefined!,
445
+ };
446
+ });
447
+ });
448
+ }
449
+
450
+ private async fetchSnapshot(
451
+ hostSnapshotOptions: ISnapshotOptions | undefined,
452
+ scenarioName?: string,
453
+ ) {
454
+ return this.fetchSnapshotCore(hostSnapshotOptions, scenarioName).catch((error) => {
455
+ // Issue #5895:
456
+ // If we are offline, this error is retryable. But that means that RetriableDocumentStorageService
457
+ // will run in circles calling getSnapshotTree, which would result in OdspDocumentStorageService class
458
+ // going getVersions / individual blob download path. This path is very slow, and will not work with
459
+ // delay-loaded data stores and ODSP storage deleting old snapshots and blobs.
460
+ if (typeof error === "object" && error !== null) {
461
+ error.canRetry = false;
462
+ }
463
+ throw error;
464
+ });
465
+ }
466
+
467
+ private async fetchSnapshotCore(
468
+ hostSnapshotOptions: ISnapshotOptions | undefined,
469
+ scenarioName?: string,
470
+ ): Promise<ISnapshotContents | IPrefetchSnapshotContents> {
471
+ // Don't look into cache, if the host specifically tells us so.
472
+ if (!this.hostPolicy.avoidPrefetchSnapshotCache) {
473
+ const prefetchCacheKey = getKeyForCacheEntry(
474
+ createCacheSnapshotKey(this.odspResolvedUrl),
475
+ );
476
+ const result = await this.cache.snapshotPrefetchResultCache
477
+ ?.get(prefetchCacheKey)
478
+ ?.then(async (response) => {
479
+ // Remove it from cache once used.
480
+ this.cache.snapshotPrefetchResultCache.remove(prefetchCacheKey);
481
+ // Validate the epoch from the prefetched snapshot result.
482
+ await this.epochTracker.validateEpoch(response.fluidEpoch, "treesLatest");
483
+ return response;
484
+ })
485
+ .catch(async (err) => {
486
+ this.logger.sendTelemetryEvent(
487
+ {
488
+ eventName: "PrefetchSnapshotError",
489
+ concurrentSnapshotFetch: this.hostPolicy.concurrentSnapshotFetch,
490
+ },
491
+ err,
492
+ );
493
+ return undefined;
494
+ });
495
+ // If the prefetch call, is successful, then return the contents otherwise as backup for now, just
496
+ // proceed with the old snapshot fetch flow.
497
+ if (result !== undefined) {
498
+ return result;
499
+ }
500
+ }
501
+ const snapshotOptions: ISnapshotOptions = {
502
+ mds: this.maxSnapshotSizeLimit,
503
+ ...hostSnapshotOptions,
504
+ timeout: hostSnapshotOptions?.timeout
505
+ ? Math.min(hostSnapshotOptions.timeout, this.maxSnapshotFetchTimeout)
506
+ : this.maxSnapshotFetchTimeout,
507
+ };
508
+
509
+ // No limit on size of snapshot or time to fetch, as otherwise we fail all clients to summarize
510
+ if (this.hostPolicy.summarizerClient) {
511
+ snapshotOptions.mds = undefined;
512
+ snapshotOptions.timeout = undefined;
513
+ }
514
+
515
+ const snapshotDownloader = async (
516
+ finalOdspResolvedUrl: IOdspResolvedUrl,
517
+ storageToken: string,
518
+ options: ISnapshotOptions | undefined,
519
+ controller?: AbortController,
520
+ ) => {
521
+ return downloadSnapshot(
522
+ finalOdspResolvedUrl,
523
+ storageToken,
524
+ this.logger,
525
+ options,
526
+ this.snapshotFormatFetchType,
527
+ controller,
528
+ this.epochTracker,
529
+ scenarioName,
530
+ );
531
+ };
532
+ const putInCache = async (valueWithEpoch: IVersionedValueWithEpoch) => {
533
+ return this.cache.persistedCache.put(
534
+ createCacheSnapshotKey(this.odspResolvedUrl),
535
+ // Epoch tracker will add the epoch and version to the value here. So just send value to cache.
536
+ valueWithEpoch.value,
537
+ );
538
+ };
539
+ const removeEntries = async () => this.cache.persistedCache.removeEntries();
540
+ try {
541
+ const odspSnapshot = await fetchSnapshotWithRedeem(
542
+ this.odspResolvedUrl,
543
+ this.getStorageToken,
544
+ snapshotOptions,
545
+ !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
546
+ this.logger,
547
+ snapshotDownloader,
548
+ putInCache,
549
+ removeEntries,
550
+ this.hostPolicy.enableRedeemFallback,
551
+ );
552
+ return odspSnapshot;
553
+ } catch (error: any) {
554
+ const errorType = error.errorType;
555
+ // If the snapshot size is too big and the host specified the size limitation(specified in hostSnapshotOptions), then don't try to fetch the snapshot again.
556
+ if (
557
+ errorType === OdspErrorType.snapshotTooBig &&
558
+ hostSnapshotOptions?.mds !== undefined &&
559
+ this.hostPolicy.summarizerClient !== true
560
+ ) {
561
+ throw error;
562
+ }
563
+ // If the first snapshot request was with blobs and we either timed out or the size was too big, then try to fetch without blobs.
564
+ if (
565
+ (errorType === OdspErrorType.snapshotTooBig ||
566
+ errorType === OdspErrorType.fetchTimeout) &&
567
+ snapshotOptions.blobs
568
+ ) {
569
+ this.logger.sendErrorEvent({
570
+ eventName: "TreeLatest_SecondCall",
571
+ errorType,
572
+ });
573
+ const snapshotOptionsWithoutBlobs: ISnapshotOptions = {
574
+ ...snapshotOptions,
575
+ blobs: 0,
576
+ mds: undefined,
577
+ timeout: undefined,
578
+ };
579
+ const odspSnapshot = await fetchSnapshotWithRedeem(
580
+ this.odspResolvedUrl,
581
+ this.getStorageToken,
582
+ snapshotOptionsWithoutBlobs,
583
+ !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
584
+ this.logger,
585
+ snapshotDownloader,
586
+ putInCache,
587
+ removeEntries,
588
+ this.hostPolicy.enableRedeemFallback,
589
+ );
590
+ return odspSnapshot;
591
+ }
592
+ throw error;
593
+ }
594
+ }
595
+
596
+ public async uploadSummaryWithContext(
597
+ summary: api.ISummaryTree,
598
+ context: ISummaryContext,
599
+ ): Promise<string> {
600
+ this.checkSnapshotUrl();
601
+
602
+ // Set the module promise right away, so as to not call it twice.
603
+ if (this.summaryModuleP === undefined) {
604
+ this.summaryModuleP = this.getDelayLoadedSummaryManager();
605
+ }
606
+
607
+ // Enable flushing only if we have single commit summary and this is not the initial summary for an empty file
608
+ if (".protocol" in summary.tree && context.ackHandle !== undefined) {
609
+ let retry = 1;
610
+ for (;;) {
611
+ const result = await this.flushCallback();
612
+ const seq = result.lastPersistedSequenceNumber;
613
+ if (seq !== undefined && seq >= context.referenceSequenceNumber) {
614
+ break;
615
+ }
616
+
617
+ if (retry > 3) {
618
+ this.logger.sendErrorEvent({
619
+ eventName: "FlushFailure",
620
+ ...result,
621
+ retry,
622
+ referenceSequenceNumber: context.referenceSequenceNumber,
623
+ });
624
+ break;
625
+ }
626
+
627
+ this.logger.sendPerformanceEvent({
628
+ eventName: "FlushExtraCall",
629
+ ...result,
630
+ retry,
631
+ referenceSequenceNumber: context.referenceSequenceNumber,
632
+ });
633
+
634
+ retry++;
635
+ await delay(1000 * (result.retryAfter ?? 1));
636
+ }
637
+ }
638
+
639
+ if (!this.odspSummaryUploadManager) {
640
+ this.odspSummaryUploadManager = await this.summaryModuleP
641
+ .then(async (m) => {
642
+ this.odspSummaryModuleLoaded = true;
643
+ return m;
644
+ })
645
+ .catch((error) => {
646
+ this.odspSummaryModuleLoaded = false;
647
+ throw error;
648
+ });
649
+ }
650
+
651
+ assert(
652
+ this.odspSummaryUploadManager !== undefined,
653
+ 0x56e /* summary upload manager should have been initialized */,
654
+ );
655
+ const id = await this.odspSummaryUploadManager.writeSummaryTree(summary, context);
656
+ return id;
657
+ }
658
+
659
+ private async getDelayLoadedSummaryManager() {
660
+ assert(this.odspSummaryModuleLoaded === false, 0x56f /* Should be loaded only once */);
661
+ const module = await import(
662
+ /* webpackChunkName: "summaryModule" */ "./odspSummaryUploadManager.js"
663
+ )
664
+ .then((m) => {
665
+ this.logger.sendTelemetryEvent({ eventName: "SummaryModuleLoaded" });
666
+ return m;
667
+ })
668
+ .catch((error) => {
669
+ this.logger.sendErrorEvent({ eventName: "SummaryModuleLoadFailed" }, error);
670
+ throw error;
671
+ });
672
+ this.odspSummaryUploadManager = new module.OdspSummaryUploadManager(
673
+ this.odspResolvedUrl.endpoints.snapshotStorageUrl,
674
+ this.getStorageToken,
675
+ this.logger,
676
+ this.epochTracker,
677
+ !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
678
+ this.relayServiceTenantAndSessionId,
679
+ );
680
+ return this.odspSummaryUploadManager;
681
+ }
682
+
683
+ private checkSnapshotUrl() {
684
+ if (!this.snapshotUrl) {
685
+ throw new NonRetryableError(
686
+ "Method failed because no snapshot url was available",
687
+ DriverErrorType.genericError,
688
+ { driverVersion },
689
+ );
690
+ }
691
+ }
692
+
693
+ private checkAttachmentPOSTUrl() {
694
+ if (!this.attachmentPOSTUrl) {
695
+ throw new NonRetryableError(
696
+ "Method failed because no attachment POST url was available",
697
+ DriverErrorType.genericError,
698
+ { driverVersion },
699
+ );
700
+ }
701
+ }
702
+
703
+ private checkAttachmentGETUrl() {
704
+ if (!this.attachmentGETUrl) {
705
+ throw new NonRetryableError(
706
+ "Method failed because no attachment GET url was available",
707
+ DriverErrorType.genericError,
708
+ { driverVersion },
709
+ );
710
+ }
711
+ }
712
+
713
+ protected async fetchTreeFromSnapshot(
714
+ id: string,
715
+ scenarioName?: string,
716
+ ): Promise<api.ISnapshotTree | undefined> {
717
+ return getWithRetryForTokenRefresh(async (options) => {
718
+ const storageToken = await this.getStorageToken(options, "ReadCommit");
719
+ const snapshotDownloader = async (
720
+ url: string,
721
+ fetchOptions: { [index: string]: any },
722
+ ) => {
723
+ return this.epochTracker.fetchAndParseAsJSON(
724
+ url,
725
+ fetchOptions,
726
+ "snapshotTree",
727
+ undefined,
728
+ scenarioName,
729
+ );
730
+ };
731
+ const snapshot = await fetchSnapshot(
732
+ this.snapshotUrl!,
733
+ storageToken,
734
+ id,
735
+ this.fetchFullSnapshot,
736
+ !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
737
+ this.logger,
738
+ snapshotDownloader,
739
+ );
740
+ let treeId = "";
741
+ if (snapshot.snapshotTree) {
742
+ assert(
743
+ snapshot.snapshotTree.id !== undefined,
744
+ 0x222 /* "Root tree should contain the id!!" */,
745
+ );
746
+ treeId = snapshot.snapshotTree.id;
747
+ this.setRootTree(treeId, snapshot.snapshotTree);
748
+ }
749
+ if (snapshot.blobs) {
750
+ this.initBlobsCache(snapshot.blobs);
751
+ }
752
+ // If the version id doesn't match with the id of the tree, then use the id of first tree which in that case
753
+ // will be the actual id of tree to be fetched.
754
+ return this.commitCache.get(id) ?? this.commitCache.get(treeId);
755
+ });
756
+ }
559
757
  }
560
-
561
- /* eslint-enable max-len */