@fluidframework/odsp-driver 2.0.0-dev-rc.1.0.0.228517 → 2.0.0-dev-rc.2.0.0.245554

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 (623) hide show
  1. package/.eslintrc.cjs +33 -0
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +44 -0
  4. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
  5. package/api-extractor-lint.json +1 -1
  6. package/api-extractor.json +1 -1
  7. package/api-report/odsp-driver.api.md +16 -17
  8. package/dist/ReadBufferUtils.d.ts.map +1 -1
  9. package/dist/ReadBufferUtils.js.map +1 -1
  10. package/dist/WriteBufferUtils.d.ts +1 -1
  11. package/dist/WriteBufferUtils.d.ts.map +1 -1
  12. package/dist/WriteBufferUtils.js +12 -12
  13. package/dist/WriteBufferUtils.js.map +1 -1
  14. package/dist/checkUrl.d.ts.map +1 -1
  15. package/dist/checkUrl.js +5 -3
  16. package/dist/checkUrl.js.map +1 -1
  17. package/dist/compactSnapshotParser.d.ts +2 -2
  18. package/dist/compactSnapshotParser.d.ts.map +1 -1
  19. package/dist/compactSnapshotParser.js +94 -75
  20. package/dist/compactSnapshotParser.js.map +1 -1
  21. package/dist/compactSnapshotWriter.d.ts +2 -2
  22. package/dist/compactSnapshotWriter.d.ts.map +1 -1
  23. package/dist/compactSnapshotWriter.js +26 -20
  24. package/dist/compactSnapshotWriter.js.map +1 -1
  25. package/dist/contracts.d.ts +24 -4
  26. package/dist/contracts.d.ts.map +1 -1
  27. package/dist/contracts.js +5 -1
  28. package/dist/contracts.js.map +1 -1
  29. package/dist/createFile.d.ts +4 -4
  30. package/dist/createFile.d.ts.map +1 -1
  31. package/dist/createFile.js +36 -52
  32. package/dist/createFile.js.map +1 -1
  33. package/dist/createNewContainerOnExistingFile.d.ts +2 -2
  34. package/dist/createNewContainerOnExistingFile.d.ts.map +1 -1
  35. package/dist/createNewContainerOnExistingFile.js +14 -14
  36. package/dist/createNewContainerOnExistingFile.js.map +1 -1
  37. package/dist/createNewModule.d.ts +2 -2
  38. package/dist/createNewModule.d.ts.map +1 -1
  39. package/dist/createNewModule.js +4 -4
  40. package/dist/createNewModule.js.map +1 -1
  41. package/dist/createNewUtils.d.ts +4 -4
  42. package/dist/createNewUtils.d.ts.map +1 -1
  43. package/dist/createNewUtils.js +16 -11
  44. package/dist/createNewUtils.js.map +1 -1
  45. package/dist/createOdspCreateContainerRequest.d.ts +2 -2
  46. package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
  47. package/dist/createOdspCreateContainerRequest.js +2 -2
  48. package/dist/createOdspCreateContainerRequest.js.map +1 -1
  49. package/dist/createOdspUrl.d.ts +1 -1
  50. package/dist/createOdspUrl.d.ts.map +1 -1
  51. package/dist/createOdspUrl.js.map +1 -1
  52. package/dist/epochTracker.d.ts +10 -9
  53. package/dist/epochTracker.d.ts.map +1 -1
  54. package/dist/epochTracker.js +67 -45
  55. package/dist/epochTracker.js.map +1 -1
  56. package/dist/fetchSnapshot.d.ts +14 -11
  57. package/dist/fetchSnapshot.d.ts.map +1 -1
  58. package/dist/fetchSnapshot.js +91 -71
  59. package/dist/fetchSnapshot.js.map +1 -1
  60. package/dist/getFileLink.d.ts.map +1 -1
  61. package/dist/getFileLink.js +25 -18
  62. package/dist/getFileLink.js.map +1 -1
  63. package/dist/getQueryString.d.ts.map +1 -1
  64. package/dist/getQueryString.js +2 -0
  65. package/dist/getQueryString.js.map +1 -1
  66. package/dist/index.d.ts +19 -19
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +44 -44
  69. package/dist/index.js.map +1 -1
  70. package/dist/localOdspDriver/localOdspDocumentService.d.ts +4 -3
  71. package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
  72. package/dist/localOdspDriver/localOdspDocumentService.js +8 -6
  73. package/dist/localOdspDriver/localOdspDocumentService.js.map +1 -1
  74. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +8 -6
  75. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
  76. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js +10 -9
  77. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -1
  78. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts +3 -2
  79. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
  80. package/dist/localOdspDriver/localOdspDocumentStorageManager.js +9 -6
  81. package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -1
  82. package/dist/odsp-driver-alpha.d.ts +31 -15
  83. package/dist/odsp-driver-beta.d.ts +4 -5
  84. package/dist/odsp-driver-public.d.ts +4 -5
  85. package/dist/odsp-driver-untrimmed.d.ts +34 -16
  86. package/dist/odspCache.d.ts +5 -5
  87. package/dist/odspCache.d.ts.map +1 -1
  88. package/dist/odspCache.js +1 -2
  89. package/dist/odspCache.js.map +1 -1
  90. package/dist/odspDelayLoadedDeltaStream.d.ts +12 -6
  91. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  92. package/dist/odspDelayLoadedDeltaStream.js +89 -25
  93. package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
  94. package/dist/odspDeltaStorageService.d.ts +7 -7
  95. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  96. package/dist/odspDeltaStorageService.js +5 -5
  97. package/dist/odspDeltaStorageService.js.map +1 -1
  98. package/dist/odspDocumentDeltaConnection.d.ts +1 -1
  99. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  100. package/dist/odspDocumentDeltaConnection.js +41 -23
  101. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  102. package/dist/odspDocumentService.d.ts +9 -6
  103. package/dist/odspDocumentService.d.ts.map +1 -1
  104. package/dist/odspDocumentService.js +25 -19
  105. package/dist/odspDocumentService.js.map +1 -1
  106. package/dist/odspDocumentServiceFactory.d.ts +6 -1
  107. package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
  108. package/dist/odspDocumentServiceFactory.js +9 -4
  109. package/dist/odspDocumentServiceFactory.js.map +1 -1
  110. package/dist/odspDocumentServiceFactoryCore.d.ts +4 -4
  111. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  112. package/dist/odspDocumentServiceFactoryCore.js +27 -30
  113. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  114. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +1 -1
  115. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
  116. package/dist/odspDocumentServiceFactoryWithCodeSplit.js +2 -2
  117. package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
  118. package/dist/odspDocumentStorageManager.d.ts +17 -10
  119. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  120. package/dist/odspDocumentStorageManager.js +226 -169
  121. package/dist/odspDocumentStorageManager.js.map +1 -1
  122. package/dist/odspDocumentStorageServiceBase.d.ts +4 -6
  123. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  124. package/dist/odspDocumentStorageServiceBase.js +34 -31
  125. package/dist/odspDocumentStorageServiceBase.js.map +1 -1
  126. package/dist/odspDriverUrlResolver.d.ts +1 -1
  127. package/dist/odspDriverUrlResolver.d.ts.map +1 -1
  128. package/dist/odspDriverUrlResolver.js +26 -32
  129. package/dist/odspDriverUrlResolver.js.map +1 -1
  130. package/dist/odspDriverUrlResolverForShareLink.d.ts +13 -6
  131. package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  132. package/dist/odspDriverUrlResolverForShareLink.js +47 -37
  133. package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
  134. package/dist/odspError.d.ts +1 -1
  135. package/dist/odspError.d.ts.map +1 -1
  136. package/dist/odspError.js +6 -6
  137. package/dist/odspError.js.map +1 -1
  138. package/dist/odspFluidFileLink.d.ts +1 -1
  139. package/dist/odspFluidFileLink.d.ts.map +1 -1
  140. package/dist/odspFluidFileLink.js +2 -2
  141. package/dist/odspFluidFileLink.js.map +1 -1
  142. package/dist/odspLocationRedirection.js +2 -2
  143. package/dist/odspLocationRedirection.js.map +1 -1
  144. package/dist/odspPublicUtils.d.ts +4 -0
  145. package/dist/odspPublicUtils.d.ts.map +1 -1
  146. package/dist/odspPublicUtils.js +3 -0
  147. package/dist/odspPublicUtils.js.map +1 -1
  148. package/dist/odspSnapshotParser.d.ts +3 -3
  149. package/dist/odspSnapshotParser.d.ts.map +1 -1
  150. package/dist/odspSnapshotParser.js +5 -3
  151. package/dist/odspSnapshotParser.js.map +1 -1
  152. package/dist/odspSummaryUploadManager.d.ts +1 -1
  153. package/dist/odspSummaryUploadManager.d.ts.map +1 -1
  154. package/dist/odspSummaryUploadManager.js +9 -6
  155. package/dist/odspSummaryUploadManager.js.map +1 -1
  156. package/dist/odspUrlHelper.d.ts.map +1 -1
  157. package/dist/odspUrlHelper.js +1 -2
  158. package/dist/odspUrlHelper.js.map +1 -1
  159. package/dist/odspUtils.d.ts +29 -13
  160. package/dist/odspUtils.d.ts.map +1 -1
  161. package/dist/odspUtils.js +75 -41
  162. package/dist/odspUtils.js.map +1 -1
  163. package/dist/opsCaching.d.ts +1 -1
  164. package/dist/opsCaching.d.ts.map +1 -1
  165. package/dist/opsCaching.js +2 -1
  166. package/dist/opsCaching.js.map +1 -1
  167. package/dist/package.json +3 -0
  168. package/dist/packageVersion.d.ts +1 -1
  169. package/dist/packageVersion.js +1 -1
  170. package/dist/packageVersion.js.map +1 -1
  171. package/dist/prefetchLatestSnapshot.d.ts +2 -2
  172. package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
  173. package/dist/prefetchLatestSnapshot.js +17 -12
  174. package/dist/prefetchLatestSnapshot.js.map +1 -1
  175. package/dist/retryErrorsStorageAdapter.d.ts +2 -2
  176. package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
  177. package/dist/retryErrorsStorageAdapter.js +10 -5
  178. package/dist/retryErrorsStorageAdapter.js.map +1 -1
  179. package/dist/retryUtils.d.ts.map +1 -1
  180. package/dist/retryUtils.js +7 -3
  181. package/dist/retryUtils.js.map +1 -1
  182. package/dist/socketModule.d.ts.map +1 -1
  183. package/dist/socketModule.js +2 -0
  184. package/dist/socketModule.js.map +1 -1
  185. package/dist/tsdoc-metadata.json +1 -1
  186. package/dist/vroom.d.ts +2 -2
  187. package/dist/vroom.d.ts.map +1 -1
  188. package/dist/vroom.js +5 -5
  189. package/dist/vroom.js.map +1 -1
  190. package/dist/zipItDataRepresentationUtils.d.ts +1 -1
  191. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  192. package/dist/zipItDataRepresentationUtils.js +17 -13
  193. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  194. package/lib/{ReadBufferUtils.d.mts → ReadBufferUtils.d.ts} +1 -1
  195. package/lib/ReadBufferUtils.d.ts.map +1 -0
  196. package/lib/{ReadBufferUtils.mjs → ReadBufferUtils.js} +1 -1
  197. package/lib/ReadBufferUtils.js.map +1 -0
  198. package/lib/{WriteBufferUtils.d.mts → WriteBufferUtils.d.ts} +2 -2
  199. package/lib/WriteBufferUtils.d.ts.map +1 -0
  200. package/lib/{WriteBufferUtils.mjs → WriteBufferUtils.js} +2 -2
  201. package/lib/WriteBufferUtils.js.map +1 -0
  202. package/lib/{checkUrl.d.mts → checkUrl.d.ts} +1 -1
  203. package/lib/checkUrl.d.ts.map +1 -0
  204. package/lib/{checkUrl.mjs → checkUrl.js} +5 -3
  205. package/lib/checkUrl.js.map +1 -0
  206. package/lib/{compactSnapshotParser.d.mts → compactSnapshotParser.d.ts} +3 -3
  207. package/lib/compactSnapshotParser.d.ts.map +1 -0
  208. package/lib/{compactSnapshotParser.mjs → compactSnapshotParser.js} +69 -50
  209. package/lib/compactSnapshotParser.js.map +1 -0
  210. package/lib/{compactSnapshotWriter.d.mts → compactSnapshotWriter.d.ts} +3 -3
  211. package/lib/compactSnapshotWriter.d.ts.map +1 -0
  212. package/lib/{compactSnapshotWriter.mjs → compactSnapshotWriter.js} +14 -8
  213. package/lib/compactSnapshotWriter.js.map +1 -0
  214. package/lib/{constants.d.mts → constants.d.ts} +1 -1
  215. package/lib/constants.d.ts.map +1 -0
  216. package/lib/{constants.mjs → constants.js} +1 -1
  217. package/lib/constants.js.map +1 -0
  218. package/lib/{contracts.d.mts → contracts.d.ts} +25 -5
  219. package/lib/contracts.d.ts.map +1 -0
  220. package/lib/contracts.js +10 -0
  221. package/lib/contracts.js.map +1 -0
  222. package/lib/{contractsPublic.d.mts → contractsPublic.d.ts} +1 -1
  223. package/lib/contractsPublic.d.ts.map +1 -0
  224. package/lib/{contractsPublic.mjs → contractsPublic.js} +1 -1
  225. package/lib/contractsPublic.js.map +1 -0
  226. package/lib/{createFile.d.mts → createFile.d.ts} +5 -5
  227. package/lib/createFile.d.ts.map +1 -0
  228. package/lib/{createFile.mjs → createFile.js} +25 -41
  229. package/lib/createFile.js.map +1 -0
  230. package/lib/{createNewContainerOnExistingFile.d.mts → createNewContainerOnExistingFile.d.ts} +3 -3
  231. package/lib/createNewContainerOnExistingFile.d.ts.map +1 -0
  232. package/lib/{createNewContainerOnExistingFile.mjs → createNewContainerOnExistingFile.js} +7 -7
  233. package/lib/createNewContainerOnExistingFile.js.map +1 -0
  234. package/lib/{createNewModule.mjs → createNewModule.d.ts} +3 -3
  235. package/lib/createNewModule.d.ts.map +1 -0
  236. package/lib/{createNewModule.d.mts → createNewModule.js} +3 -3
  237. package/lib/createNewModule.js.map +1 -0
  238. package/lib/{createNewUtils.d.mts → createNewUtils.d.ts} +5 -5
  239. package/lib/createNewUtils.d.ts.map +1 -0
  240. package/lib/{createNewUtils.mjs → createNewUtils.js} +13 -8
  241. package/lib/createNewUtils.js.map +1 -0
  242. package/lib/{createOdspCreateContainerRequest.d.mts → createOdspCreateContainerRequest.d.ts} +7 -3
  243. package/lib/createOdspCreateContainerRequest.d.ts.map +1 -0
  244. package/lib/{createOdspCreateContainerRequest.mjs → createOdspCreateContainerRequest.js} +2 -2
  245. package/lib/createOdspCreateContainerRequest.js.map +1 -0
  246. package/lib/{createOdspUrl.d.mts → createOdspUrl.d.ts} +2 -2
  247. package/lib/createOdspUrl.d.ts.map +1 -0
  248. package/lib/{createOdspUrl.mjs → createOdspUrl.js} +1 -1
  249. package/lib/createOdspUrl.js.map +1 -0
  250. package/lib/{epochTracker.d.mts → epochTracker.d.ts} +11 -10
  251. package/lib/epochTracker.d.ts.map +1 -0
  252. package/lib/{epochTracker.mjs → epochTracker.js} +58 -36
  253. package/lib/epochTracker.js.map +1 -0
  254. package/lib/{fetch.d.mts → fetch.d.ts} +1 -1
  255. package/lib/fetch.d.ts.map +1 -0
  256. package/lib/{fetch.mjs → fetch.js} +1 -1
  257. package/lib/fetch.js.map +1 -0
  258. package/lib/{fetchSnapshot.d.mts → fetchSnapshot.d.ts} +15 -12
  259. package/lib/fetchSnapshot.d.ts.map +1 -0
  260. package/lib/{fetchSnapshot.mjs → fetchSnapshot.js} +74 -54
  261. package/lib/fetchSnapshot.js.map +1 -0
  262. package/lib/{getFileLink.d.mts → getFileLink.d.ts} +1 -1
  263. package/lib/getFileLink.d.ts.map +1 -0
  264. package/lib/{getFileLink.mjs → getFileLink.js} +17 -10
  265. package/lib/getFileLink.js.map +1 -0
  266. package/lib/{getQueryString.d.mts → getQueryString.d.ts} +5 -1
  267. package/lib/getQueryString.d.ts.map +1 -0
  268. package/lib/{getQueryString.mjs → getQueryString.js} +3 -1
  269. package/lib/getQueryString.js.map +1 -0
  270. package/lib/{getUrlAndHeadersWithAuth.d.mts → getUrlAndHeadersWithAuth.d.ts} +1 -1
  271. package/lib/getUrlAndHeadersWithAuth.d.ts.map +1 -0
  272. package/lib/{getUrlAndHeadersWithAuth.mjs → getUrlAndHeadersWithAuth.js} +1 -1
  273. package/lib/getUrlAndHeadersWithAuth.js.map +1 -0
  274. package/lib/{index.d.mts → index.d.ts} +20 -20
  275. package/lib/index.d.ts.map +1 -0
  276. package/lib/index.js +29 -0
  277. package/lib/index.js.map +1 -0
  278. package/lib/localOdspDriver/{localOdspDeltaStorageService.d.mts → localOdspDeltaStorageService.d.ts} +1 -1
  279. package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
  280. package/lib/localOdspDriver/{localOdspDeltaStorageService.mjs → localOdspDeltaStorageService.js} +1 -1
  281. package/lib/localOdspDriver/localOdspDeltaStorageService.js.map +1 -0
  282. package/lib/localOdspDriver/{localOdspDocumentService.d.mts → localOdspDocumentService.d.ts} +5 -4
  283. package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +1 -0
  284. package/lib/localOdspDriver/{localOdspDocumentService.mjs → localOdspDocumentService.js} +7 -5
  285. package/lib/localOdspDriver/localOdspDocumentService.js.map +1 -0
  286. package/lib/localOdspDriver/{localOdspDocumentServiceFactory.d.mts → localOdspDocumentServiceFactory.d.ts} +9 -7
  287. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -0
  288. package/lib/localOdspDriver/{localOdspDocumentServiceFactory.mjs → localOdspDocumentServiceFactory.js} +9 -8
  289. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -0
  290. package/lib/localOdspDriver/{localOdspDocumentStorageManager.d.mts → localOdspDocumentStorageManager.d.ts} +4 -3
  291. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -0
  292. package/lib/localOdspDriver/{localOdspDocumentStorageManager.mjs → localOdspDocumentStorageManager.js} +7 -4
  293. package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -0
  294. package/lib/{odsp-driver-alpha.d.mts → odsp-driver-alpha.d.ts} +31 -15
  295. package/lib/{odsp-driver-beta.d.mts → odsp-driver-beta.d.ts} +4 -5
  296. package/lib/{odsp-driver-public.d.mts → odsp-driver-public.d.ts} +4 -5
  297. package/lib/{odsp-driver-untrimmed.d.mts → odsp-driver-untrimmed.d.ts} +34 -16
  298. package/lib/{odspCache.d.mts → odspCache.d.ts} +10 -6
  299. package/lib/odspCache.d.ts.map +1 -0
  300. package/lib/{odspCache.mjs → odspCache.js} +6 -3
  301. package/lib/odspCache.js.map +1 -0
  302. package/lib/{odspDelayLoadedDeltaStream.d.mts → odspDelayLoadedDeltaStream.d.ts} +13 -7
  303. package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -0
  304. package/lib/{odspDelayLoadedDeltaStream.mjs → odspDelayLoadedDeltaStream.js} +84 -20
  305. package/lib/odspDelayLoadedDeltaStream.js.map +1 -0
  306. package/lib/{odspDeltaStorageService.d.mts → odspDeltaStorageService.d.ts} +8 -8
  307. package/lib/odspDeltaStorageService.d.ts.map +1 -0
  308. package/lib/{odspDeltaStorageService.mjs → odspDeltaStorageService.js} +5 -5
  309. package/lib/odspDeltaStorageService.js.map +1 -0
  310. package/lib/{odspDocumentDeltaConnection.d.mts → odspDocumentDeltaConnection.d.ts} +2 -2
  311. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -0
  312. package/lib/{odspDocumentDeltaConnection.mjs → odspDocumentDeltaConnection.js} +34 -16
  313. package/lib/odspDocumentDeltaConnection.js.map +1 -0
  314. package/lib/{odspDocumentService.d.mts → odspDocumentService.d.ts} +10 -7
  315. package/lib/odspDocumentService.d.ts.map +1 -0
  316. package/lib/{odspDocumentService.mjs → odspDocumentService.js} +22 -14
  317. package/lib/odspDocumentService.js.map +1 -0
  318. package/lib/{odspDocumentServiceFactory.d.mts → odspDocumentServiceFactory.d.ts} +7 -2
  319. package/lib/odspDocumentServiceFactory.d.ts.map +1 -0
  320. package/lib/{odspDocumentServiceFactory.mjs → odspDocumentServiceFactory.js} +9 -3
  321. package/lib/odspDocumentServiceFactory.js.map +1 -0
  322. package/lib/{odspDocumentServiceFactoryCore.d.mts → odspDocumentServiceFactoryCore.d.ts} +5 -5
  323. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -0
  324. package/lib/{odspDocumentServiceFactoryCore.mjs → odspDocumentServiceFactoryCore.js} +25 -26
  325. package/lib/odspDocumentServiceFactoryCore.js.map +1 -0
  326. package/lib/{odspDocumentServiceFactoryWithCodeSplit.d.mts → odspDocumentServiceFactoryWithCodeSplit.d.ts} +2 -2
  327. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -0
  328. package/lib/{odspDocumentServiceFactoryWithCodeSplit.mjs → odspDocumentServiceFactoryWithCodeSplit.js} +2 -2
  329. package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -0
  330. package/lib/{odspDocumentStorageManager.d.mts → odspDocumentStorageManager.d.ts} +18 -11
  331. package/lib/odspDocumentStorageManager.d.ts.map +1 -0
  332. package/lib/{odspDocumentStorageManager.mjs → odspDocumentStorageManager.js} +221 -162
  333. package/lib/odspDocumentStorageManager.js.map +1 -0
  334. package/lib/{odspDocumentStorageServiceBase.d.mts → odspDocumentStorageServiceBase.d.ts} +5 -7
  335. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -0
  336. package/lib/{odspDocumentStorageServiceBase.mjs → odspDocumentStorageServiceBase.js} +34 -31
  337. package/lib/odspDocumentStorageServiceBase.js.map +1 -0
  338. package/lib/{odspDriverUrlResolver.d.mts → odspDriverUrlResolver.d.ts} +2 -2
  339. package/lib/odspDriverUrlResolver.d.ts.map +1 -0
  340. package/lib/{odspDriverUrlResolver.mjs → odspDriverUrlResolver.js} +27 -29
  341. package/lib/odspDriverUrlResolver.js.map +1 -0
  342. package/lib/{odspDriverUrlResolverForShareLink.d.mts → odspDriverUrlResolverForShareLink.d.ts} +14 -7
  343. package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -0
  344. package/lib/{odspDriverUrlResolverForShareLink.mjs → odspDriverUrlResolverForShareLink.js} +41 -27
  345. package/lib/odspDriverUrlResolverForShareLink.js.map +1 -0
  346. package/lib/{odspError.d.mts → odspError.d.ts} +2 -2
  347. package/lib/odspError.d.ts.map +1 -0
  348. package/lib/{odspError.mjs → odspError.js} +6 -6
  349. package/lib/odspError.js.map +1 -0
  350. package/lib/{odspFluidFileLink.d.mts → odspFluidFileLink.d.ts} +2 -2
  351. package/lib/odspFluidFileLink.d.ts.map +1 -0
  352. package/lib/{odspFluidFileLink.mjs → odspFluidFileLink.js} +2 -2
  353. package/lib/odspFluidFileLink.js.map +1 -0
  354. package/lib/{odspLocationRedirection.d.mts → odspLocationRedirection.d.ts} +1 -1
  355. package/lib/odspLocationRedirection.d.ts.map +1 -0
  356. package/lib/{odspLocationRedirection.mjs → odspLocationRedirection.js} +2 -2
  357. package/lib/odspLocationRedirection.js.map +1 -0
  358. package/lib/{odspPublicUtils.d.mts → odspPublicUtils.d.ts} +5 -1
  359. package/lib/odspPublicUtils.d.ts.map +1 -0
  360. package/lib/{odspPublicUtils.mjs → odspPublicUtils.js} +4 -1
  361. package/lib/odspPublicUtils.js.map +1 -0
  362. package/lib/{odspSnapshotParser.d.mts → odspSnapshotParser.d.ts} +4 -4
  363. package/lib/odspSnapshotParser.d.ts.map +1 -0
  364. package/lib/{odspSnapshotParser.mjs → odspSnapshotParser.js} +6 -4
  365. package/lib/odspSnapshotParser.js.map +1 -0
  366. package/lib/{odspSummaryUploadManager.d.mts → odspSummaryUploadManager.d.ts} +2 -2
  367. package/lib/odspSummaryUploadManager.d.ts.map +1 -0
  368. package/lib/{odspSummaryUploadManager.mjs → odspSummaryUploadManager.js} +8 -5
  369. package/lib/odspSummaryUploadManager.js.map +1 -0
  370. package/lib/{odspUrlHelper.d.mts → odspUrlHelper.d.ts} +1 -1
  371. package/lib/odspUrlHelper.d.ts.map +1 -0
  372. package/lib/{odspUrlHelper.mjs → odspUrlHelper.js} +2 -3
  373. package/lib/odspUrlHelper.js.map +1 -0
  374. package/lib/{odspUtils.d.mts → odspUtils.d.ts} +30 -14
  375. package/lib/odspUtils.d.ts.map +1 -0
  376. package/lib/{odspUtils.mjs → odspUtils.js} +61 -30
  377. package/lib/odspUtils.js.map +1 -0
  378. package/lib/{opsCaching.d.mts → opsCaching.d.ts} +2 -2
  379. package/lib/opsCaching.d.ts.map +1 -0
  380. package/lib/{opsCaching.mjs → opsCaching.js} +3 -2
  381. package/lib/opsCaching.js.map +1 -0
  382. package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
  383. package/lib/packageVersion.d.ts.map +1 -0
  384. package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
  385. package/lib/packageVersion.js.map +1 -0
  386. package/lib/{prefetchLatestSnapshot.d.mts → prefetchLatestSnapshot.d.ts} +3 -3
  387. package/lib/prefetchLatestSnapshot.d.ts.map +1 -0
  388. package/lib/{prefetchLatestSnapshot.mjs → prefetchLatestSnapshot.js} +16 -11
  389. package/lib/prefetchLatestSnapshot.js.map +1 -0
  390. package/lib/{retryErrorsStorageAdapter.d.mts → retryErrorsStorageAdapter.d.ts} +3 -3
  391. package/lib/retryErrorsStorageAdapter.d.ts.map +1 -0
  392. package/lib/{retryErrorsStorageAdapter.mjs → retryErrorsStorageAdapter.js} +11 -6
  393. package/lib/retryErrorsStorageAdapter.js.map +1 -0
  394. package/lib/{retryUtils.d.mts → retryUtils.d.ts} +1 -1
  395. package/lib/retryUtils.d.ts.map +1 -0
  396. package/lib/{retryUtils.mjs → retryUtils.js} +8 -4
  397. package/lib/retryUtils.js.map +1 -0
  398. package/lib/{socketModule.d.mts → socketModule.d.ts} +1 -1
  399. package/lib/socketModule.d.ts.map +1 -0
  400. package/lib/{socketModule.mjs → socketModule.js} +3 -1
  401. package/lib/socketModule.js.map +1 -0
  402. package/lib/test/buildOdspShareLinkReqParams.spec.js +25 -0
  403. package/lib/test/buildOdspShareLinkReqParams.spec.js.map +1 -0
  404. package/lib/test/createNewUtilsTests.spec.js +221 -0
  405. package/lib/test/createNewUtilsTests.spec.js.map +1 -0
  406. package/lib/test/deltaStorageService.spec.js +176 -0
  407. package/lib/test/deltaStorageService.spec.js.map +1 -0
  408. package/lib/test/epochTests.spec.js +340 -0
  409. package/lib/test/epochTests.spec.js.map +1 -0
  410. package/lib/test/epochTestsWithRedemption.spec.js +119 -0
  411. package/lib/test/epochTestsWithRedemption.spec.js.map +1 -0
  412. package/lib/test/fetchSnapshot.spec.js +412 -0
  413. package/lib/test/fetchSnapshot.spec.js.map +1 -0
  414. package/lib/test/getFileLink.spec.js +62 -0
  415. package/lib/test/getFileLink.spec.js.map +1 -0
  416. package/lib/test/getUrlAndHeadersWithAuth.spec.js +66 -0
  417. package/lib/test/getUrlAndHeadersWithAuth.spec.js.map +1 -0
  418. package/lib/test/getVersions.spec.js +284 -0
  419. package/lib/test/getVersions.spec.js.map +1 -0
  420. package/lib/test/joinSessionCacheTests.spec.js +53 -0
  421. package/lib/test/joinSessionCacheTests.spec.js.map +1 -0
  422. package/lib/test/joinSessionPeriodicCall.spec.js +158 -0
  423. package/lib/test/joinSessionPeriodicCall.spec.js.map +1 -0
  424. package/lib/test/jsonSnapshotFormatTests.spec.js +107 -0
  425. package/lib/test/jsonSnapshotFormatTests.spec.js.map +1 -0
  426. package/lib/test/localOdspDriver.spec.js +177 -0
  427. package/lib/test/localOdspDriver.spec.js.map +1 -0
  428. package/lib/test/mockFetch.js +61 -0
  429. package/lib/test/mockFetch.js.map +1 -0
  430. package/lib/test/odspCreateContainer.spec.js +116 -0
  431. package/lib/test/odspCreateContainer.spec.js.map +1 -0
  432. package/lib/test/odspDriverResolverTest.spec.js +289 -0
  433. package/lib/test/odspDriverResolverTest.spec.js.map +1 -0
  434. package/lib/test/odspDriverUrlResolverForShareLink.spec.js +287 -0
  435. package/lib/test/odspDriverUrlResolverForShareLink.spec.js.map +1 -0
  436. package/lib/test/odspError.spec.js +299 -0
  437. package/lib/test/odspError.spec.js.map +1 -0
  438. package/lib/test/opsCaching.spec.js +357 -0
  439. package/lib/test/opsCaching.spec.js.map +1 -0
  440. package/lib/test/prefetchSnapshotTests.spec.js +420 -0
  441. package/lib/test/prefetchSnapshotTests.spec.js.map +1 -0
  442. package/lib/test/snapshotFormatTests.spec.js +218 -0
  443. package/lib/test/snapshotFormatTests.spec.js.map +1 -0
  444. package/lib/test/socketTests/deltaConnectionUpdateTests.spec.js +152 -0
  445. package/lib/test/socketTests/deltaConnectionUpdateTests.spec.js.map +1 -0
  446. package/lib/test/socketTests/socketMock.js +109 -0
  447. package/lib/test/socketTests/socketMock.js.map +1 -0
  448. package/lib/test/socketTests/socketTests.spec.js +256 -0
  449. package/lib/test/socketTests/socketTests.spec.js.map +1 -0
  450. package/lib/test/tokenFetch.spec.js +39 -0
  451. package/lib/test/tokenFetch.spec.js.map +1 -0
  452. package/lib/test/types/validateOdspDriverPrevious.generated.js +96 -0
  453. package/lib/test/types/validateOdspDriverPrevious.generated.js.map +1 -0
  454. package/lib/test/zipItDataRepresentationTests.spec.js +207 -0
  455. package/lib/test/zipItDataRepresentationTests.spec.js.map +1 -0
  456. package/lib/{vroom.d.mts → vroom.d.ts} +3 -3
  457. package/lib/vroom.d.ts.map +1 -0
  458. package/lib/{vroom.mjs → vroom.js} +4 -4
  459. package/lib/vroom.js.map +1 -0
  460. package/lib/{zipItDataRepresentationUtils.d.mts → zipItDataRepresentationUtils.d.ts} +2 -2
  461. package/lib/zipItDataRepresentationUtils.d.ts.map +1 -0
  462. package/lib/{zipItDataRepresentationUtils.mjs → zipItDataRepresentationUtils.js} +19 -11
  463. package/lib/zipItDataRepresentationUtils.js.map +1 -0
  464. package/package.json +100 -32
  465. package/src/ReadBufferUtils.ts +7 -7
  466. package/src/WriteBufferUtils.ts +13 -9
  467. package/src/checkUrl.ts +4 -2
  468. package/src/compactSnapshotParser.ts +97 -61
  469. package/src/compactSnapshotWriter.ts +22 -15
  470. package/src/contracts.ts +33 -4
  471. package/src/createFile.ts +26 -51
  472. package/src/createNewContainerOnExistingFile.ts +10 -10
  473. package/src/createNewModule.ts +2 -2
  474. package/src/createNewUtils.ts +26 -15
  475. package/src/createOdspCreateContainerRequest.ts +3 -3
  476. package/src/createOdspUrl.ts +1 -1
  477. package/src/epochTracker.ts +93 -58
  478. package/src/fetchSnapshot.ts +122 -66
  479. package/src/getFileLink.ts +24 -16
  480. package/src/getQueryString.ts +2 -0
  481. package/src/index.ts +27 -19
  482. package/src/localOdspDriver/localOdspDocumentService.ts +12 -5
  483. package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +12 -11
  484. package/src/localOdspDriver/localOdspDocumentStorageManager.ts +15 -8
  485. package/src/odspCache.ts +14 -11
  486. package/src/odspDelayLoadedDeltaStream.ts +113 -31
  487. package/src/odspDeltaStorageService.ts +17 -16
  488. package/src/odspDocumentDeltaConnection.ts +52 -34
  489. package/src/odspDocumentService.ts +33 -22
  490. package/src/odspDocumentServiceFactory.ts +7 -2
  491. package/src/odspDocumentServiceFactoryCore.ts +28 -29
  492. package/src/odspDocumentServiceFactoryWithCodeSplit.ts +1 -1
  493. package/src/odspDocumentStorageManager.ts +303 -210
  494. package/src/odspDocumentStorageServiceBase.ts +52 -47
  495. package/src/odspDriverUrlResolver.ts +41 -41
  496. package/src/odspDriverUrlResolverForShareLink.ts +50 -31
  497. package/src/odspError.ts +6 -7
  498. package/src/odspFluidFileLink.ts +3 -3
  499. package/src/odspLocationRedirection.ts +1 -1
  500. package/src/odspPublicUtils.ts +4 -0
  501. package/src/odspSnapshotParser.ts +9 -9
  502. package/src/odspSummaryUploadManager.ts +21 -9
  503. package/src/odspUrlHelper.ts +2 -3
  504. package/src/odspUtils.ts +102 -53
  505. package/src/opsCaching.ts +13 -12
  506. package/src/packageVersion.ts +1 -1
  507. package/src/prefetchLatestSnapshot.ts +24 -15
  508. package/src/retryErrorsStorageAdapter.ts +16 -9
  509. package/src/retryUtils.ts +8 -4
  510. package/src/socketModule.ts +2 -0
  511. package/src/vroom.ts +6 -6
  512. package/src/zipItDataRepresentationUtils.ts +65 -37
  513. package/tsconfig.cjs.json +7 -0
  514. package/tsconfig.json +2 -5
  515. package/.eslintrc.js +0 -18
  516. package/lib/ReadBufferUtils.d.mts.map +0 -1
  517. package/lib/ReadBufferUtils.mjs.map +0 -1
  518. package/lib/WriteBufferUtils.d.mts.map +0 -1
  519. package/lib/WriteBufferUtils.mjs.map +0 -1
  520. package/lib/checkUrl.d.mts.map +0 -1
  521. package/lib/checkUrl.mjs.map +0 -1
  522. package/lib/compactSnapshotParser.d.mts.map +0 -1
  523. package/lib/compactSnapshotParser.mjs.map +0 -1
  524. package/lib/compactSnapshotWriter.d.mts.map +0 -1
  525. package/lib/compactSnapshotWriter.mjs.map +0 -1
  526. package/lib/constants.d.mts.map +0 -1
  527. package/lib/constants.mjs.map +0 -1
  528. package/lib/contracts.d.mts.map +0 -1
  529. package/lib/contracts.mjs +0 -6
  530. package/lib/contracts.mjs.map +0 -1
  531. package/lib/contractsPublic.d.mts.map +0 -1
  532. package/lib/contractsPublic.mjs.map +0 -1
  533. package/lib/createFile.d.mts.map +0 -1
  534. package/lib/createFile.mjs.map +0 -1
  535. package/lib/createNewContainerOnExistingFile.d.mts.map +0 -1
  536. package/lib/createNewContainerOnExistingFile.mjs.map +0 -1
  537. package/lib/createNewModule.d.mts.map +0 -1
  538. package/lib/createNewModule.mjs.map +0 -1
  539. package/lib/createNewUtils.d.mts.map +0 -1
  540. package/lib/createNewUtils.mjs.map +0 -1
  541. package/lib/createOdspCreateContainerRequest.d.mts.map +0 -1
  542. package/lib/createOdspCreateContainerRequest.mjs.map +0 -1
  543. package/lib/createOdspUrl.d.mts.map +0 -1
  544. package/lib/createOdspUrl.mjs.map +0 -1
  545. package/lib/epochTracker.d.mts.map +0 -1
  546. package/lib/epochTracker.mjs.map +0 -1
  547. package/lib/fetch.d.mts.map +0 -1
  548. package/lib/fetch.mjs.map +0 -1
  549. package/lib/fetchSnapshot.d.mts.map +0 -1
  550. package/lib/fetchSnapshot.mjs.map +0 -1
  551. package/lib/getFileLink.d.mts.map +0 -1
  552. package/lib/getFileLink.mjs.map +0 -1
  553. package/lib/getQueryString.d.mts.map +0 -1
  554. package/lib/getQueryString.mjs.map +0 -1
  555. package/lib/getUrlAndHeadersWithAuth.d.mts.map +0 -1
  556. package/lib/getUrlAndHeadersWithAuth.mjs.map +0 -1
  557. package/lib/index.d.mts.map +0 -1
  558. package/lib/index.mjs +0 -22
  559. package/lib/index.mjs.map +0 -1
  560. package/lib/localOdspDriver/localOdspDeltaStorageService.d.mts.map +0 -1
  561. package/lib/localOdspDriver/localOdspDeltaStorageService.mjs.map +0 -1
  562. package/lib/localOdspDriver/localOdspDocumentService.d.mts.map +0 -1
  563. package/lib/localOdspDriver/localOdspDocumentService.mjs.map +0 -1
  564. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.mts.map +0 -1
  565. package/lib/localOdspDriver/localOdspDocumentServiceFactory.mjs.map +0 -1
  566. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.mts.map +0 -1
  567. package/lib/localOdspDriver/localOdspDocumentStorageManager.mjs.map +0 -1
  568. package/lib/odspCache.d.mts.map +0 -1
  569. package/lib/odspCache.mjs.map +0 -1
  570. package/lib/odspDelayLoadedDeltaStream.d.mts.map +0 -1
  571. package/lib/odspDelayLoadedDeltaStream.mjs.map +0 -1
  572. package/lib/odspDeltaStorageService.d.mts.map +0 -1
  573. package/lib/odspDeltaStorageService.mjs.map +0 -1
  574. package/lib/odspDocumentDeltaConnection.d.mts.map +0 -1
  575. package/lib/odspDocumentDeltaConnection.mjs.map +0 -1
  576. package/lib/odspDocumentService.d.mts.map +0 -1
  577. package/lib/odspDocumentService.mjs.map +0 -1
  578. package/lib/odspDocumentServiceFactory.d.mts.map +0 -1
  579. package/lib/odspDocumentServiceFactory.mjs.map +0 -1
  580. package/lib/odspDocumentServiceFactoryCore.d.mts.map +0 -1
  581. package/lib/odspDocumentServiceFactoryCore.mjs.map +0 -1
  582. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.mts.map +0 -1
  583. package/lib/odspDocumentServiceFactoryWithCodeSplit.mjs.map +0 -1
  584. package/lib/odspDocumentStorageManager.d.mts.map +0 -1
  585. package/lib/odspDocumentStorageManager.mjs.map +0 -1
  586. package/lib/odspDocumentStorageServiceBase.d.mts.map +0 -1
  587. package/lib/odspDocumentStorageServiceBase.mjs.map +0 -1
  588. package/lib/odspDriverUrlResolver.d.mts.map +0 -1
  589. package/lib/odspDriverUrlResolver.mjs.map +0 -1
  590. package/lib/odspDriverUrlResolverForShareLink.d.mts.map +0 -1
  591. package/lib/odspDriverUrlResolverForShareLink.mjs.map +0 -1
  592. package/lib/odspError.d.mts.map +0 -1
  593. package/lib/odspError.mjs.map +0 -1
  594. package/lib/odspFluidFileLink.d.mts.map +0 -1
  595. package/lib/odspFluidFileLink.mjs.map +0 -1
  596. package/lib/odspLocationRedirection.d.mts.map +0 -1
  597. package/lib/odspLocationRedirection.mjs.map +0 -1
  598. package/lib/odspPublicUtils.d.mts.map +0 -1
  599. package/lib/odspPublicUtils.mjs.map +0 -1
  600. package/lib/odspSnapshotParser.d.mts.map +0 -1
  601. package/lib/odspSnapshotParser.mjs.map +0 -1
  602. package/lib/odspSummaryUploadManager.d.mts.map +0 -1
  603. package/lib/odspSummaryUploadManager.mjs.map +0 -1
  604. package/lib/odspUrlHelper.d.mts.map +0 -1
  605. package/lib/odspUrlHelper.mjs.map +0 -1
  606. package/lib/odspUtils.d.mts.map +0 -1
  607. package/lib/odspUtils.mjs.map +0 -1
  608. package/lib/opsCaching.d.mts.map +0 -1
  609. package/lib/opsCaching.mjs.map +0 -1
  610. package/lib/packageVersion.d.mts.map +0 -1
  611. package/lib/packageVersion.mjs.map +0 -1
  612. package/lib/prefetchLatestSnapshot.d.mts.map +0 -1
  613. package/lib/prefetchLatestSnapshot.mjs.map +0 -1
  614. package/lib/retryErrorsStorageAdapter.d.mts.map +0 -1
  615. package/lib/retryErrorsStorageAdapter.mjs.map +0 -1
  616. package/lib/retryUtils.d.mts.map +0 -1
  617. package/lib/retryUtils.mjs.map +0 -1
  618. package/lib/socketModule.d.mts.map +0 -1
  619. package/lib/socketModule.mjs.map +0 -1
  620. package/lib/vroom.d.mts.map +0 -1
  621. package/lib/vroom.mjs.map +0 -1
  622. package/lib/zipItDataRepresentationUtils.d.mts.map +0 -1
  623. package/lib/zipItDataRepresentationUtils.mjs.map +0 -1
@@ -10,17 +10,16 @@ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
10
10
  const client_utils_1 = require("@fluid-internal/client-utils");
11
11
  const core_utils_1 = require("@fluidframework/core-utils");
12
12
  const driver_base_1 = require("@fluidframework/driver-base");
13
- const driver_definitions_1 = require("@fluidframework/driver-definitions");
14
13
  const odsp_driver_definitions_1 = require("@fluidframework/odsp-driver-definitions");
15
14
  const driver_utils_1 = require("@fluidframework/driver-utils");
16
- const odsp_doclib_utils_1 = require("@fluidframework/odsp-doclib-utils");
17
- const contracts_1 = require("./contracts");
18
- const getQueryString_1 = require("./getQueryString");
19
- const getUrlAndHeadersWithAuth_1 = require("./getUrlAndHeadersWithAuth");
20
- const odspUtils_1 = require("./odspUtils");
21
- const odspSnapshotParser_1 = require("./odspSnapshotParser");
22
- const compactSnapshotParser_1 = require("./compactSnapshotParser");
23
- const packageVersion_1 = require("./packageVersion");
15
+ const internal_1 = require("@fluidframework/odsp-doclib-utils/internal");
16
+ const contracts_js_1 = require("./contracts.js");
17
+ const getQueryString_js_1 = require("./getQueryString.js");
18
+ const getUrlAndHeadersWithAuth_js_1 = require("./getUrlAndHeadersWithAuth.js");
19
+ const odspUtils_js_1 = require("./odspUtils.js");
20
+ const odspSnapshotParser_js_1 = require("./odspSnapshotParser.js");
21
+ const compactSnapshotParser_js_1 = require("./compactSnapshotParser.js");
22
+ const packageVersion_js_1 = require("./packageVersion.js");
24
23
  /**
25
24
  * Enum to support different types of snapshot formats.
26
25
  * @alpha
@@ -47,25 +46,28 @@ token, versionId, fetchFullSnapshot, forceAccessTokenViaAuthorizationHeader, log
47
46
  const path = `/trees/${versionId}`;
48
47
  let queryParams = {};
49
48
  if (fetchFullSnapshot) {
50
- queryParams = versionId !== "latest" ? { blobs: 2 } : { deltas: 1, blobs: 2 };
49
+ queryParams = versionId === "latest" ? { deltas: 1, blobs: 2 } : { blobs: 2 };
51
50
  }
52
- const queryString = (0, getQueryString_1.getQueryString)(queryParams);
53
- const { url, headers } = (0, getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth)(`${snapshotUrl}${path}${queryString}`, token, forceAccessTokenViaAuthorizationHeader);
51
+ const queryString = (0, getQueryString_js_1.getQueryString)(queryParams);
52
+ const { url, headers } = (0, getUrlAndHeadersWithAuth_js_1.getUrlAndHeadersWithAuth)(`${snapshotUrl}${path}${queryString}`, token, forceAccessTokenViaAuthorizationHeader);
54
53
  const response = (await telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, {
55
54
  eventName: "fetchSnapshot",
56
- headers: Object.keys(headers).length !== 0 ? true : undefined,
55
+ headers: Object.keys(headers).length > 0 ? true : undefined,
57
56
  }, async () => snapshotDownloader(url, { headers })));
58
- return (0, odspSnapshotParser_1.convertOdspSnapshotToSnapshotTreeAndBlobs)(response.content);
57
+ return (0, odspSnapshotParser_js_1.convertOdspSnapshotToSnapshotTreeAndBlobs)(response.content);
59
58
  }
60
59
  exports.fetchSnapshot = fetchSnapshot;
61
- async function fetchSnapshotWithRedeem(odspResolvedUrl, storageTokenFetcher, snapshotOptions, forceAccessTokenViaAuthorizationHeader, logger, snapshotDownloader, putInCache, removeEntries, enableRedeemFallback) {
60
+ async function fetchSnapshotWithRedeem(odspResolvedUrl, storageTokenFetcher, snapshotOptions, forceAccessTokenViaAuthorizationHeader, logger, snapshotDownloader, putInCache, removeEntries, loadingGroupIds, enableRedeemFallback) {
62
61
  // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51
62
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
63
63
  const sharingLinkToRedeem = odspResolvedUrl.sharingLinkToRedeem;
64
64
  if (sharingLinkToRedeem) {
65
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
65
66
  odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };
66
67
  }
67
- return fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, snapshotOptions, logger, snapshotDownloader, putInCache, enableRedeemFallback)
68
+ return fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, snapshotOptions, logger, snapshotDownloader, putInCache, loadingGroupIds, enableRedeemFallback)
68
69
  .catch(async (error) => {
70
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
69
71
  if (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {
70
72
  // Execute the redeem fallback
71
73
  await redeemSharingLink(odspResolvedUrl, storageTokenFetcher, logger, forceAccessTokenViaAuthorizationHeader);
@@ -82,9 +84,10 @@ async function fetchSnapshotWithRedeem(odspResolvedUrl, storageTokenFetcher, sna
82
84
  // flow (container open) based on a failure above.
83
85
  logger.sendTelemetryEvent({
84
86
  eventName: "RedeemFallback",
87
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
85
88
  errorType: error.errorType,
86
89
  }, error);
87
- return fetchLatestSnapshotCore(odspResolvedUrlWithoutShareLink, storageTokenFetcher, snapshotOptions, logger, snapshotDownloader, putInCache);
90
+ return fetchLatestSnapshotCore(odspResolvedUrlWithoutShareLink, storageTokenFetcher, snapshotOptions, logger, snapshotDownloader, putInCache, loadingGroupIds);
88
91
  }
89
92
  else {
90
93
  throw error;
@@ -96,8 +99,10 @@ async function fetchSnapshotWithRedeem(odspResolvedUrl, storageTokenFetcher, sna
96
99
  // snapshot from cache in the future.
97
100
  if ((typeof error === "object" &&
98
101
  error !== null &&
99
- error.errorType === driver_definitions_1.DriverErrorType.authorizationError) ||
100
- error.errorType === driver_definitions_1.DriverErrorType.fileNotFoundOrAccessDeniedError) {
102
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
103
+ error.errorType === odsp_driver_definitions_1.OdspErrorTypes.authorizationError) ||
104
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
105
+ error.errorType === odsp_driver_definitions_1.OdspErrorTypes.fileNotFoundOrAccessDeniedError) {
101
106
  await removeEntries();
102
107
  }
103
108
  throw error;
@@ -107,33 +112,36 @@ exports.fetchSnapshotWithRedeem = fetchSnapshotWithRedeem;
107
112
  async function redeemSharingLink(odspResolvedUrl, storageTokenFetcher, logger, forceAccessTokenViaAuthorizationHeader) {
108
113
  return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, {
109
114
  eventName: "RedeemShareLink",
110
- }, async () => (0, odspUtils_1.getWithRetryForTokenRefresh)(async (tokenFetchOptions) => {
115
+ }, async () => (0, odspUtils_js_1.getWithRetryForTokenRefresh)(async (tokenFetchOptions) => {
111
116
  (0, core_utils_1.assert)(!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem, 0x1ed /* "Share link should be present" */);
112
117
  const storageToken = await storageTokenFetcher(tokenFetchOptions, "RedeemShareLink");
113
118
  const encodedShareUrl = getEncodedShareUrl(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem);
114
119
  const redeemUrl = `${odspResolvedUrl.siteUrl}/_api/v2.0/shares/${encodedShareUrl}`;
115
- const { url, headers } = (0, getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth)(redeemUrl, storageToken, forceAccessTokenViaAuthorizationHeader);
120
+ const { url, headers } = (0, getUrlAndHeadersWithAuth_js_1.getUrlAndHeadersWithAuth)(redeemUrl, storageToken, forceAccessTokenViaAuthorizationHeader);
116
121
  headers.prefer = "redeemSharingLink";
117
- return (0, odspUtils_1.fetchAndParseAsJSONHelper)(url, { headers });
122
+ return (0, odspUtils_js_1.fetchAndParseAsJSONHelper)(url, { headers });
118
123
  }));
119
124
  }
120
- async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, snapshotOptions, logger, snapshotDownloader, putInCache, enableRedeemFallback) {
121
- return (0, odspUtils_1.getWithRetryForTokenRefresh)(async (tokenFetchOptions) => {
122
- const storageToken = await storageTokenFetcher(tokenFetchOptions, "TreesLatest", true);
125
+ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, snapshotOptions, logger, snapshotDownloader, putInCache, loadingGroupIds, enableRedeemFallback) {
126
+ return (0, odspUtils_js_1.getWithRetryForTokenRefresh)(async (tokenFetchOptions) => {
127
+ const fetchSnapshotForLoadingGroup = (0, odspUtils_js_1.isSnapshotFetchForLoadingGroup)(loadingGroupIds);
128
+ const eventName = fetchSnapshotForLoadingGroup ? "TreesLatestForGroup" : "TreesLatest";
129
+ const storageToken = await storageTokenFetcher(tokenFetchOptions, eventName, true);
123
130
  (0, core_utils_1.assert)(storageToken !== null, 0x1e5 /* "Storage token should not be null" */);
124
131
  const perfEvent = {
125
- eventName: "TreesLatest",
132
+ eventName,
126
133
  attempts: tokenFetchOptions.refresh ? 2 : 1,
127
134
  shareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,
128
135
  isSummarizer: odspResolvedUrl.summarizer,
129
136
  redeemFallbackEnabled: enableRedeemFallback,
130
137
  };
131
138
  if (snapshotOptions !== undefined) {
132
- Object.entries(snapshotOptions).forEach(([key, value]) => {
139
+ for (const [key, value] of Object.entries(snapshotOptions)) {
133
140
  if (value !== undefined) {
141
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
134
142
  perfEvent[`snapshotOption_${key}`] = value;
135
143
  }
136
- });
144
+ }
137
145
  }
138
146
  // This event measures only successful cases of getLatest call (no tokens, no retries).
139
147
  return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, perfEvent, async (event) => {
@@ -143,7 +151,7 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
143
151
  controller = new AbortController();
144
152
  fetchTimeout = setTimeout(() => controller.abort(), snapshotOptions.timeout);
145
153
  }
146
- const [response, fetchTime] = await (0, odspUtils_1.measureP)(async () => snapshotDownloader(odspResolvedUrl, storageToken, snapshotOptions, controller)).finally(() => {
154
+ const [response, fetchTime] = await (0, odspUtils_js_1.measureP)(async () => snapshotDownloader(odspResolvedUrl, storageToken, loadingGroupIds, snapshotOptions, controller)).finally(() => {
147
155
  // Clear the fetchTimeout once the response is fetched.
148
156
  if (fetchTimeout !== undefined) {
149
157
  clearTimeout(fetchTimeout);
@@ -156,7 +164,7 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
156
164
  ...odspResponse.propsToLog,
157
165
  contentType,
158
166
  accept: response.requestHeaders.accept,
159
- driverVersion: packageVersion_1.pkgVersion,
167
+ driverVersion: packageVersion_js_1.pkgVersion,
160
168
  };
161
169
  let parsedSnapshotContents;
162
170
  let contentTypeToRead;
@@ -172,17 +180,17 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
172
180
  switch (contentTypeToRead) {
173
181
  case "application/json": {
174
182
  let text;
175
- [text, receiveContentTime] = await (0, odspUtils_1.measureP)(async () => odspResponse.content.text().catch((err) =>
183
+ [text, receiveContentTime] = await (0, odspUtils_js_1.measureP)(async () => odspResponse.content.text().catch((error) =>
176
184
  // Parsing can fail and message could contain full request URI, including
177
185
  // tokens, etc. So do not log error object itself.
178
- (0, odsp_doclib_utils_1.throwOdspNetworkError)("Error while parsing fetch response", odsp_doclib_utils_1.fetchIncorrectResponse, odspResponse.content, // response
186
+ (0, internal_1.throwOdspNetworkError)("Error while parsing fetch response", internal_1.fetchIncorrectResponse, odspResponse.content, // response
179
187
  undefined, // response text
180
188
  propsToLog)));
181
189
  propsToLog.bodySize = text.length;
182
190
  let content;
183
- [content, parseTime] = (0, odspUtils_1.measure)(() => JSON.parse(text));
191
+ [content, parseTime] = (0, odspUtils_js_1.measure)(() => JSON.parse(text));
184
192
  validateBlobsAndTrees(content);
185
- const snapshotContents = (0, odspSnapshotParser_1.convertOdspSnapshotToSnapshotTreeAndBlobs)(content);
193
+ const snapshotContents = (0, odspSnapshotParser_js_1.convertOdspSnapshotToSnapshotTreeAndBlobs)(content);
186
194
  parsedSnapshotContents = {
187
195
  ...odspResponse,
188
196
  content: {
@@ -194,18 +202,18 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
194
202
  }
195
203
  case "application/ms-fluid": {
196
204
  let content;
197
- [content, receiveContentTime] = await (0, odspUtils_1.measureP)(async () => odspResponse.content.arrayBuffer().catch((err) =>
205
+ [content, receiveContentTime] = await (0, odspUtils_js_1.measureP)(async () => odspResponse.content.arrayBuffer().catch((error) =>
198
206
  // Parsing can fail and message could contain full request URI, including
199
207
  // tokens, etc. So do not log error object itself.
200
- (0, odsp_doclib_utils_1.throwOdspNetworkError)("Error while parsing fetch response", odsp_doclib_utils_1.fetchIncorrectResponse, odspResponse.content, // response
208
+ (0, internal_1.throwOdspNetworkError)("Error while parsing fetch response", internal_1.fetchIncorrectResponse, odspResponse.content, // response
201
209
  undefined, // response text
202
210
  propsToLog)));
203
211
  propsToLog.bodySize = content.byteLength;
204
212
  let snapshotContents;
205
- [snapshotContents, parseTime] = (0, odspUtils_1.measure)(() => (0, compactSnapshotParser_1.parseCompactSnapshotResponse)(new Uint8Array(content), logger));
213
+ [snapshotContents, parseTime] = (0, odspUtils_js_1.measure)(() => (0, compactSnapshotParser_js_1.parseCompactSnapshotResponse)(new Uint8Array(content), logger));
206
214
  if (snapshotContents.snapshotTree.trees === undefined ||
207
215
  snapshotContents.snapshotTree.blobs === undefined) {
208
- throw new driver_utils_1.NonRetryableError("Returned odsp snapshot is malformed. No trees or blobs!", driver_definitions_1.DriverErrorType.incorrectServerResponse, propsToLog);
216
+ throw new driver_utils_1.NonRetryableError("Returned odsp snapshot is malformed. No trees or blobs!", odsp_driver_definitions_1.OdspErrorTypes.incorrectServerResponse, propsToLog);
209
217
  }
210
218
  const props = snapshotContents.telemetryProps;
211
219
  const slowTreeParseCodePaths = props.slowTreeStructureCount ?? 0;
@@ -220,8 +228,9 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
220
228
  parsedSnapshotContents = { ...odspResponse, content: snapshotContents };
221
229
  break;
222
230
  }
223
- default:
224
- throw new driver_utils_1.NonRetryableError("Unknown snapshot content type", driver_definitions_1.DriverErrorType.incorrectServerResponse, propsToLog);
231
+ default: {
232
+ throw new driver_utils_1.NonRetryableError("Unknown snapshot content type", odsp_driver_definitions_1.OdspErrorTypes.incorrectServerResponse, propsToLog);
233
+ }
225
234
  }
226
235
  }
227
236
  catch (error) {
@@ -229,15 +238,16 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
229
238
  error.addTelemetryProperties(propsToLog);
230
239
  throw error;
231
240
  }
232
- const enhancedError = (0, telemetry_utils_1.wrapError)(error, (errorMessage) => new driver_utils_1.NonRetryableError(`Error parsing snapshot response: ${errorMessage}`, driver_definitions_1.DriverErrorType.genericError, propsToLog));
241
+ const enhancedError = (0, telemetry_utils_1.wrapError)(error, (errorMessage) => new driver_utils_1.NonRetryableError(`Error parsing snapshot response: ${errorMessage}`, odsp_driver_definitions_1.OdspErrorTypes.genericError, propsToLog));
233
242
  throw enhancedError;
234
243
  }
235
244
  (0, core_utils_1.assert)(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);
236
245
  const snapshot = parsedSnapshotContents.content;
237
246
  const { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);
238
247
  // There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we
239
- // cannot cache using an HTTP response header.
240
- const canCache = odspResponse.headers.get("disablebrowsercachingofusercontent") !== "true";
248
+ // cannot cache using an HTTP response header. Only cache snapshot if it is not for a loading group.
249
+ const canCache = odspResponse.headers.get("disablebrowsercachingofusercontent") !== "true" &&
250
+ !fetchSnapshotForLoadingGroup;
241
251
  const sequenceNumber = snapshot.sequenceNumber ?? 0;
242
252
  const seqNumberFromOps = snapshot.ops && snapshot.ops.length > 0
243
253
  ? snapshot.ops[0].sequenceNumber - 1
@@ -261,20 +271,22 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
261
271
  const valueWithEpoch = {
262
272
  value,
263
273
  fluidEpoch,
264
- version: contracts_1.persistedCacheValueVersion,
274
+ version: contracts_js_1.persistedCacheValueVersion,
265
275
  };
266
276
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
267
277
  putInCache(valueWithEpoch);
268
278
  }
269
279
  event.end({
270
280
  trees,
271
- blobs: snapshot.blobs?.size ?? 0,
281
+ blobs: snapshot.blobContents?.size ?? 0,
272
282
  leafNodes: numBlobs,
273
283
  encodedBlobsSize,
274
284
  sequenceNumber,
275
285
  ops: snapshot.ops?.length ?? 0,
286
+ fetchSnapshotForLoadingGroup,
287
+ useLegacyFlowWithoutGroups: (0, odspUtils_js_1.useLegacyFlowWithoutGroupsForSnapshotFetch)(loadingGroupIds),
276
288
  userOps: snapshot.ops?.filter((op) => (0, driver_utils_1.isRuntimeMessage)(op)).length ?? 0,
277
- headers: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,
289
+ headers: Object.keys(response.requestHeaders).length > 0 ? true : undefined,
278
290
  // Measures time to make fetch call. Should be similar to
279
291
  // fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /
280
292
  // end of response headers
@@ -305,9 +317,10 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
305
317
  // It's useful to try one more time in such case.
306
318
  if (typeof error === "object" &&
307
319
  error !== null &&
308
- (error.errorType === driver_definitions_1.DriverErrorType.fetchFailure ||
309
- error.errorType === odsp_driver_definitions_1.OdspErrorType.fetchTimeout)) {
310
- error[odspUtils_1.getWithRetryForTokenRefreshRepeat] = true;
320
+ (error.errorType === odsp_driver_definitions_1.OdspErrorTypes.fetchFailure ||
321
+ error.errorType === odsp_driver_definitions_1.OdspErrorTypes.fetchTimeout)) {
322
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
323
+ error[odspUtils_js_1.getWithRetryForTokenRefreshRepeat] = true;
311
324
  }
312
325
  throw error;
313
326
  });
@@ -316,21 +329,18 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
316
329
  function getFormBodyAndHeaders(odspResolvedUrl, storageToken, headers) {
317
330
  const formBoundary = (0, uuid_1.v4)();
318
331
  const formParams = [];
319
- formParams.push(`--${formBoundary}`);
320
- formParams.push(`Authorization: Bearer ${storageToken}`);
321
- formParams.push(`X-HTTP-Method-Override: GET`);
332
+ formParams.push(`--${formBoundary}`, `Authorization: Bearer ${storageToken}`, `X-HTTP-Method-Override: GET`);
322
333
  if (headers !== undefined) {
323
- Object.entries(headers).forEach(([key, value]) => {
334
+ for (const [key, value] of Object.entries(headers)) {
324
335
  if (value !== undefined) {
325
336
  formParams.push(`${key}: ${value}`);
326
337
  }
327
- });
338
+ }
328
339
  }
329
340
  if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {
330
341
  formParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);
331
342
  }
332
- formParams.push(`_post: 1`);
333
- formParams.push(`\r\n--${formBoundary}--`);
343
+ formParams.push(`_post: 1`, `\r\n--${formBoundary}--`);
334
344
  const postBody = formParams.join("\r\n");
335
345
  const header = {
336
346
  "Content-Type": `multipart/form-data;boundary=${formBoundary}`,
@@ -339,9 +349,9 @@ function getFormBodyAndHeaders(odspResolvedUrl, storageToken, headers) {
339
349
  }
340
350
  function evalBlobsAndTrees(snapshot) {
341
351
  const trees = countTreesInSnapshotTree(snapshot.snapshotTree);
342
- const numBlobs = snapshot.blobs.size;
352
+ const numBlobs = snapshot.blobContents.size;
343
353
  let encodedBlobsSize = 0;
344
- for (const [_, blobContent] of snapshot.blobs) {
354
+ for (const [_, blobContent] of snapshot.blobContents) {
345
355
  encodedBlobsSize += blobContent.byteLength;
346
356
  }
347
357
  return { trees, numBlobs, encodedBlobsSize };
@@ -365,34 +375,42 @@ function countTreesInSnapshotTree(snapshotTree) {
365
375
  * @param odspResolvedUrl - resolved odsp url.
366
376
  * @param storageToken - token to do the auth for network request.
367
377
  * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.
368
- * @param logger - logger
378
+ * @param loadingGroupIds - loadingGroupIds for which snapshot needs to be downloaded. Note:
379
+ * 1.) If undefined, then legacy trees latest call will be used where no groupId query param would be specified.
380
+ * 2.) If [] is passed, then snapshot with all ungrouped data will be fetched.
381
+ * 3.) If any groupId is specified like ["g1"], then snapshot for g1 group will be fetched.
369
382
  * @param snapshotFormatFetchType - Snapshot format to fetch.
370
383
  * @param controller - abort controller if caller needs to abort the network call.
371
384
  * @param epochTracker - epoch tracker used to add/validate epoch in the network call.
372
385
  * @returns fetched snapshot.
373
386
  */
374
- async function downloadSnapshot(odspResolvedUrl, storageToken, logger, snapshotOptions, snapshotFormatFetchType, controller, epochTracker, scenarioName) {
387
+ async function downloadSnapshot(odspResolvedUrl, storageToken, loadingGroupIds, snapshotOptions, snapshotFormatFetchType, controller, epochTracker, scenarioName) {
375
388
  // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51
389
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
376
390
  const sharingLinkToRedeem = odspResolvedUrl.sharingLinkToRedeem;
377
391
  if (sharingLinkToRedeem) {
392
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
378
393
  odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };
379
394
  }
380
395
  const snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;
381
396
  const queryParams = { ump: 1 };
382
397
  if (snapshotOptions !== undefined) {
383
- Object.entries(snapshotOptions).forEach(([key, value]) => {
398
+ for (const [key, value] of Object.entries(snapshotOptions)) {
384
399
  // Exclude "timeout" from query string
385
400
  if (value !== undefined && key !== "timeout") {
386
401
  queryParams[key] = value;
387
402
  }
388
- });
403
+ }
404
+ }
405
+ if (loadingGroupIds !== undefined) {
406
+ queryParams.groupId = loadingGroupIds.join(",");
389
407
  }
390
- const queryString = (0, getQueryString_1.getQueryString)(queryParams);
408
+ const queryString = (0, getQueryString_js_1.getQueryString)(queryParams);
391
409
  const url = `${snapshotUrl}/trees/latest${queryString}`;
392
410
  // The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.
393
411
  // Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.
394
412
  // This error thrown by server will contain the new redirect location. Look at the 404 error parsing
395
- // for futher reference here: \packages\utils\odsp-doclib-utils\src\odspErrorUtils.ts
413
+ // for further reference here: \packages\utils\odsp-doclib-utils\src\odspErrorUtils.ts
396
414
  const header = { prefer: "manualredirect" };
397
415
  const { body, headers } = getFormBodyAndHeaders(odspResolvedUrl, storageToken, header);
398
416
  const fetchOptions = {
@@ -403,14 +421,16 @@ async function downloadSnapshot(odspResolvedUrl, storageToken, logger, snapshotO
403
421
  };
404
422
  // Decide what snapshot format to fetch as per the feature gate.
405
423
  switch (snapshotFormatFetchType) {
406
- case SnapshotFormatSupportType.Binary:
407
- headers.accept = `application/ms-fluid; v=${compactSnapshotParser_1.currentReadVersion}`;
424
+ case SnapshotFormatSupportType.Binary: {
425
+ headers.accept = `application/ms-fluid; v=${compactSnapshotParser_js_1.currentReadVersion}`;
408
426
  break;
409
- default:
427
+ }
428
+ default: {
410
429
  // By default ask both versions and let the server decide the format.
411
- headers.accept = `application/json, application/ms-fluid; v=${compactSnapshotParser_1.currentReadVersion}`;
430
+ headers.accept = `application/json, application/ms-fluid; v=${compactSnapshotParser_js_1.currentReadVersion}`;
431
+ }
412
432
  }
413
- const odspResponse = await (epochTracker?.fetch(url, fetchOptions, "treesLatest", true, scenarioName) ?? (0, odspUtils_1.fetchHelper)(url, fetchOptions));
433
+ const odspResponse = await (epochTracker?.fetch(url, fetchOptions, "treesLatest", true, scenarioName) ?? (0, odspUtils_js_1.fetchHelper)(url, fetchOptions));
414
434
  return {
415
435
  odspResponse,
416
436
  requestHeaders: headers,
@@ -422,8 +442,8 @@ function isRedeemSharingLinkError(odspResolvedUrl, error) {
422
442
  if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined &&
423
443
  typeof error === "object" &&
424
444
  error !== null &&
425
- (error.errorType === driver_definitions_1.DriverErrorType.authorizationError ||
426
- error.errorType === driver_definitions_1.DriverErrorType.fileNotFoundOrAccessDeniedError)) {
445
+ (error.errorType === odsp_driver_definitions_1.OdspErrorTypes.authorizationError ||
446
+ error.errorType === odsp_driver_definitions_1.OdspErrorTypes.fileNotFoundOrAccessDeniedError)) {
427
447
  return true;
428
448
  }
429
449
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAClC,qEAKyC;AACzC,+DAAgE;AAChE,2DAAoD;AACpD,6DAAyD;AACzD,2EAAqE;AACrE,qFAKiD;AAEjD,+DAIsC;AACtC,yEAAkG;AAClG,2CAKqB;AACrB,qDAAkD;AAClD,yEAAsE;AACtE,2CAQqB;AAErB,6DAAiF;AACjF,mEAIiC;AAEjC,qDAA8C;AAE9C;;;GAGG;AACH,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACpC,yEAAQ,CAAA;IACR,6EAAU,CAAA;IACV,2FAAiB,CAAA;AAClB,CAAC,EAJW,yBAAyB,yCAAzB,yBAAyB,QAIpC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,aAAa,CAClC,WAAmB;AACnB,kDAAkD;AAClD,KAAoB,EACpB,SAAiB,EACjB,iBAA0B,EAC1B,sCAA+C,EAC/C,MAA2B,EAC3B,kBAGoC;IAEpC,MAAM,IAAI,GAAG,UAAU,SAAS,EAAE,CAAC;IACnC,IAAI,WAAW,GAAqB,EAAE,CAAC;IAEvC,IAAI,iBAAiB,EAAE;QACtB,WAAW,GAAG,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KAC9E;IAED,MAAM,WAAW,GAAG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,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,SAAS,KAAK,oCAAe,CAAC,kBAAkB;YACtD,KAAK,CAAC,SAAS,KAAK,oCAAe,CAAC,+BAA+B,CAAC,EACpE;QACD,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACtC;;;OAGG;IACH,IAAI,UAAU,GAAG,IAAA,+BAAgB,EAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpF,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACnB,CAAC","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\tisFluidError,\n\tPerformanceEvent,\n\twrapError,\n} from \"@fluidframework/telemetry-utils\";\nimport { fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { getW3CData } from \"@fluidframework/driver-base\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n\tIOdspResolvedUrl,\n\tISnapshotOptions,\n\tOdspErrorType,\n\tInstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tDriverErrorTelemetryProps,\n\tisRuntimeMessage,\n\tNonRetryableError,\n} from \"@fluidframework/driver-utils\";\nimport { fetchIncorrectResponse, throwOdspNetworkError } from \"@fluidframework/odsp-doclib-utils\";\nimport {\n\tIOdspSnapshot,\n\tISnapshotCachedEntry,\n\tIVersionedValueWithEpoch,\n\tpersistedCacheValueVersion,\n} from \"./contracts\";\nimport { getQueryString } from \"./getQueryString\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n\tfetchAndParseAsJSONHelper,\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\tgetWithRetryForTokenRefreshRepeat,\n\tIOdspResponse,\n\tmeasure,\n\tmeasureP,\n} from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser\";\nimport {\n\tcurrentReadVersion,\n\tISnapshotContentsWithProps,\n\tparseCompactSnapshotResponse,\n} from \"./compactSnapshotParser\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * Enum to support different types of snapshot formats.\n * @alpha\n */\nexport enum SnapshotFormatSupportType {\n\tJson = 0,\n\tBinary = 1,\n\tJsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param token - token used for authorization in the request\n * @param storageFetchWrapper - Implementation of the get/post methods used to fetch the snapshot\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n\tsnapshotUrl: string,\n\t// eslint-disable-next-line @rushstack/no-new-null\n\ttoken: string | null,\n\tversionId: string,\n\tfetchFullSnapshot: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: any },\n\t) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshotContents> {\n\tconst path = `/trees/${versionId}`;\n\tlet queryParams: ISnapshotOptions = {};\n\n\tif (fetchFullSnapshot) {\n\t\tqueryParams = versionId !== \"latest\" ? { blobs: 2 } : { deltas: 1, blobs: 2 };\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t`${snapshotUrl}${path}${queryString}`,\n\t\ttoken,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t);\n\tconst response = (await PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"fetchSnapshot\",\n\t\t\theaders: Object.keys(headers).length !== 0 ? true : undefined,\n\t\t},\n\t\tasync () => snapshotDownloader(url, { headers }),\n\t)) as IOdspResponse<IOdspSnapshot>;\n\treturn convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tstorageToken: string,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tremoveEntries: () => Promise<void>,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\treturn fetchLatestSnapshotCore(\n\t\todspResolvedUrl,\n\t\tstorageTokenFetcher,\n\t\tsnapshotOptions,\n\t\tlogger,\n\t\tsnapshotDownloader,\n\t\tputInCache,\n\t\tenableRedeemFallback,\n\t)\n\t\t.catch(async (error) => {\n\t\t\tif (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n\t\t\t\t// Execute the redeem fallback\n\n\t\t\t\tawait redeemSharingLink(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tlogger,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\tconst odspResolvedUrlWithoutShareLink: IOdspResolvedUrl = {\n\t\t\t\t\t...odspResolvedUrl,\n\t\t\t\t\tshareLinkInfo: {\n\t\t\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t\t\tsharingLinkToRedeem: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\t// Log initial failure only if redeem succeeded - it points out to some bug somewhere\n\t\t\t\t// If redeem failed, that most likely means user has no permissions to access a file,\n\t\t\t\t// and thus it's not worth it logging extra errors - same error will be logged by end-to-end\n\t\t\t\t// flow (container open) based on a failure above.\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"RedeemFallback\",\n\t\t\t\t\t\terrorType: error.errorType,\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn fetchLatestSnapshotCore(\n\t\t\t\t\todspResolvedUrlWithoutShareLink,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tlogger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})\n\t\t.catch(async (error) => {\n\t\t\t// Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n\t\t\t// have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n\t\t\t// snapshot from cache in the future.\n\t\t\tif (\n\t\t\t\t(typeof error === \"object\" &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\terror.errorType === DriverErrorType.authorizationError) ||\n\t\t\t\terror.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError\n\t\t\t) {\n\t\t\t\tawait removeEntries();\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n}\n\nasync function redeemSharingLink(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tlogger: ITelemetryLoggerExt,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n) {\n\treturn PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"RedeemShareLink\",\n\t\t},\n\t\tasync () =>\n\t\t\tgetWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\t\t\tassert(\n\t\t\t\t\t!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t\t0x1ed /* \"Share link should be present\" */,\n\t\t\t\t);\n\t\t\t\tconst storageToken = await storageTokenFetcher(\n\t\t\t\t\ttokenFetchOptions,\n\t\t\t\t\t\"RedeemShareLink\",\n\t\t\t\t);\n\t\t\t\tconst encodedShareUrl = getEncodedShareUrl(\n\t\t\t\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t);\n\t\t\t\tconst redeemUrl = `${odspResolvedUrl.siteUrl}/_api/v2.0/shares/${encodedShareUrl}`;\n\t\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\t\tredeemUrl,\n\t\t\t\t\tstorageToken,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\theaders.prefer = \"redeemSharingLink\";\n\t\t\t\treturn fetchAndParseAsJSONHelper(url, { headers });\n\t\t\t}),\n\t);\n}\n\nasync function fetchLatestSnapshotCore(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tstorageToken: string,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n\treturn getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\tconst storageToken = await storageTokenFetcher(tokenFetchOptions, \"TreesLatest\", true);\n\t\tassert(storageToken !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\n\t\tconst perfEvent = {\n\t\t\teventName: \"TreesLatest\",\n\t\t\tattempts: tokenFetchOptions.refresh ? 2 : 1,\n\t\t\tshareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n\t\t\tisSummarizer: odspResolvedUrl.summarizer,\n\t\t\tredeemFallbackEnabled: enableRedeemFallback,\n\t\t};\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tObject.entries(snapshotOptions).forEach(([key, value]) => {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\tperfEvent[`snapshotOption_${key}`] = value;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\t// This event measures only successful cases of getLatest call (no tokens, no retries).\n\t\treturn PerformanceEvent.timedExecAsync(logger, perfEvent, async (event) => {\n\t\t\tlet controller: AbortController | undefined;\n\t\t\tlet fetchTimeout: ReturnType<typeof setTimeout> | undefined;\n\t\t\tif (snapshotOptions?.timeout !== undefined) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\tfetchTimeout = setTimeout(() => controller!.abort(), snapshotOptions.timeout);\n\t\t\t}\n\n\t\t\tconst [response, fetchTime] = await measureP(async () =>\n\t\t\t\tsnapshotDownloader(odspResolvedUrl, storageToken, snapshotOptions, controller),\n\t\t\t).finally(() => {\n\t\t\t\t// Clear the fetchTimeout once the response is fetched.\n\t\t\t\tif (fetchTimeout !== undefined) {\n\t\t\t\t\tclearTimeout(fetchTimeout);\n\t\t\t\t\tfetchTimeout = undefined;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst odspResponse = response.odspResponse;\n\t\t\tconst contentType = odspResponse.headers.get(\"content-type\");\n\n\t\t\tconst propsToLog: DriverErrorTelemetryProps = {\n\t\t\t\t...odspResponse.propsToLog,\n\t\t\t\tcontentType,\n\t\t\t\taccept: response.requestHeaders.accept,\n\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t};\n\n\t\t\tlet parsedSnapshotContents: IOdspResponse<ISnapshotContentsWithProps> | undefined;\n\t\t\tlet contentTypeToRead: string | undefined;\n\t\t\tif (contentType?.includes(\"application/ms-fluid\")) {\n\t\t\t\tcontentTypeToRead = \"application/ms-fluid\";\n\t\t\t} else if (contentType?.includes(\"application/json\")) {\n\t\t\t\tcontentTypeToRead = \"application/json\";\n\t\t\t}\n\n\t\t\tlet parseTime: number;\n\t\t\tlet receiveContentTime: number;\n\t\t\ttry {\n\t\t\t\tswitch (contentTypeToRead) {\n\t\t\t\t\tcase \"application/json\": {\n\t\t\t\t\t\tlet text: string;\n\t\t\t\t\t\t[text, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content.text().catch((err) =>\n\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = text.length;\n\t\t\t\t\t\tlet content: IOdspSnapshot;\n\t\t\t\t\t\t[content, parseTime] = measure(() => JSON.parse(text) as IOdspSnapshot);\n\t\t\t\t\t\tvalidateBlobsAndTrees(content);\n\t\t\t\t\t\tconst snapshotContents: ISnapshotContents =\n\t\t\t\t\t\t\tconvertOdspSnapshotToSnapshotTreeAndBlobs(content);\n\t\t\t\t\t\tparsedSnapshotContents = {\n\t\t\t\t\t\t\t...odspResponse,\n\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t...snapshotContents,\n\t\t\t\t\t\t\t\ttelemetryProps: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"application/ms-fluid\": {\n\t\t\t\t\t\tlet content: ArrayBuffer;\n\t\t\t\t\t\t[content, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content.arrayBuffer().catch((err) =>\n\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = content.byteLength;\n\t\t\t\t\t\tlet snapshotContents: ISnapshotContentsWithProps;\n\t\t\t\t\t\t[snapshotContents, parseTime] = measure(() =>\n\t\t\t\t\t\t\tparseCompactSnapshotResponse(new Uint8Array(content), logger),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.trees === undefined ||\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.blobs === undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t\"Returned odsp snapshot is malformed. No trees or blobs!\",\n\t\t\t\t\t\t\t\tDriverErrorType.incorrectServerResponse,\n\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst props = snapshotContents.telemetryProps;\n\t\t\t\t\t\tconst slowTreeParseCodePaths = props.slowTreeStructureCount ?? 0;\n\t\t\t\t\t\tconst slowBlobParseCodePaths = props.slowBlobStructureCount ?? 0;\n\t\t\t\t\t\tif (slowTreeParseCodePaths > 10 || slowBlobParseCodePaths > 10) {\n\t\t\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\t\t\teventName: \"SlowSnapshotParseCodePaths\",\n\t\t\t\t\t\t\t\tslowTreeStructureCount: slowTreeParseCodePaths,\n\t\t\t\t\t\t\t\tslowBlobStructureCount: slowBlobParseCodePaths,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\"Unknown snapshot content type\",\n\t\t\t\t\t\t\tDriverErrorType.incorrectServerResponse,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isFluidError(error)) {\n\t\t\t\t\terror.addTelemetryProperties(propsToLog);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst enhancedError = wrapError(\n\t\t\t\t\terror,\n\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\tnew NonRetryableError(\n\t\t\t\t\t\t\t`Error parsing snapshot response: ${errorMessage}`,\n\t\t\t\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tthrow enhancedError;\n\t\t\t}\n\n\t\t\tassert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n\t\t\tconst snapshot = parsedSnapshotContents.content;\n\t\t\tconst { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n\t\t\t// There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n\t\t\t// cannot cache using an HTTP response header.\n\t\t\tconst canCache =\n\t\t\t\todspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\";\n\t\t\tconst sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n\t\t\tconst seqNumberFromOps =\n\t\t\t\tsnapshot.ops && snapshot.ops.length > 0\n\t\t\t\t\t? snapshot.ops[0].sequenceNumber - 1\n\t\t\t\t\t: undefined;\n\n\t\t\tif (\n\t\t\t\t!Number.isInteger(sequenceNumber) ||\n\t\t\t\t(seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber)\n\t\t\t) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"fetchSnapshotError\",\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t\tseqNumberFromOps,\n\t\t\t\t});\n\t\t\t\tsnapshot.sequenceNumber = undefined;\n\t\t\t} else if (canCache) {\n\t\t\t\tconst fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n\t\t\t\tassert(\n\t\t\t\t\tfluidEpoch !== undefined,\n\t\t\t\t\t0x1e6 /* \"Epoch should be present in response\" */,\n\t\t\t\t);\n\t\t\t\tconst value: ISnapshotCachedEntry = {\n\t\t\t\t\t...snapshot,\n\t\t\t\t\tcacheEntryTime: Date.now(),\n\t\t\t\t};\n\t\t\t\tconst valueWithEpoch: IVersionedValueWithEpoch = {\n\t\t\t\t\tvalue,\n\t\t\t\t\tfluidEpoch,\n\t\t\t\t\tversion: persistedCacheValueVersion,\n\t\t\t\t};\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\t\tputInCache(valueWithEpoch);\n\t\t\t}\n\n\t\t\tevent.end({\n\t\t\t\ttrees,\n\t\t\t\tblobs: snapshot.blobs?.size ?? 0,\n\t\t\t\tleafNodes: numBlobs,\n\t\t\t\tencodedBlobsSize,\n\t\t\t\tsequenceNumber,\n\t\t\t\tops: snapshot.ops?.length ?? 0,\n\t\t\t\tuserOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n\t\t\t\theaders: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,\n\t\t\t\t// Measures time to make fetch call. Should be similar to\n\t\t\t\t// fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /\n\t\t\t\t// end of response headers\n\t\t\t\tfetchTime,\n\t\t\t\t// time it takes client to parse payload. Same payload as in \"SnapshotParse\" event, here for\n\t\t\t\t// easier analyzes.\n\t\t\t\tparseTime,\n\t\t\t\t// Time it takes to receive content (text of buffer) from Response object.\n\t\t\t\t// This time likely is very closely correlated with networkTime, i.e. time it takes to receive\n\t\t\t\t// actual content (starting measuring from first bite / end of response header)\n\t\t\t\treceiveContentTime,\n\t\t\t\t...getW3CData(response.requestUrl, \"fetch\"),\n\t\t\t\t// Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n\t\t\t\t// Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n\t\t\t\t// Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n\t\t\t\t// if the permission has changed.\n\t\t\t\tsltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n\t\t\t\t// All other props\n\t\t\t\t...propsToLog,\n\t\t\t\t// Various perf counters and measures collected by binary parsing code:\n\t\t\t\t// slowTreeStructureCount, slowBlobStructureCount, durationStructure, durationStrings,\n\t\t\t\t// durationSnapshotTree, durationBlobs, etc.\n\t\t\t\t...parsedSnapshotContents.content.telemetryProps,\n\t\t\t});\n\t\t\treturn snapshot;\n\t\t}).catch((error) => {\n\t\t\t// We hit these errors in stress tests, under load\n\t\t\t// It's useful to try one more time in such case.\n\t\t\tif (\n\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\terror !== null &&\n\t\t\t\t(error.errorType === DriverErrorType.fetchFailure ||\n\t\t\t\t\terror.errorType === OdspErrorType.fetchTimeout)\n\t\t\t) {\n\t\t\t\terror[getWithRetryForTokenRefreshRepeat] = true;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n\todspResponse: IOdspResponse<Response>;\n\trequestUrl: string;\n\trequestHeaders: { [index: string]: any };\n}\n\nfunction getFormBodyAndHeaders(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageToken: string,\n\theaders?: { [index: string]: string },\n) {\n\tconst formBoundary = uuid();\n\tconst formParams: string[] = [];\n\tformParams.push(`--${formBoundary}`);\n\tformParams.push(`Authorization: Bearer ${storageToken}`);\n\tformParams.push(`X-HTTP-Method-Override: GET`);\n\n\tif (headers !== undefined) {\n\t\tObject.entries(headers).forEach(([key, value]) => {\n\t\t\tif (value !== undefined) {\n\t\t\t\tformParams.push(`${key}: ${value}`);\n\t\t\t}\n\t\t});\n\t}\n\tif (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n\t\tformParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n\t}\n\tformParams.push(`_post: 1`);\n\tformParams.push(`\\r\\n--${formBoundary}--`);\n\tconst postBody = formParams.join(\"\\r\\n\");\n\tconst header: { [index: string]: any } = {\n\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t};\n\treturn { body: postBody, headers: header };\n}\n\nexport function evalBlobsAndTrees(snapshot: ISnapshotContents) {\n\tconst trees = countTreesInSnapshotTree(snapshot.snapshotTree);\n\tconst numBlobs = snapshot.blobs.size;\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobs) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { trees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot) {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */,\n\t);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n\tlet numTrees = 0;\n\tfor (const [_, tree] of Object.entries(snapshotTree.trees)) {\n\t\tnumTrees += 1;\n\t\tnumTrees += countTreesInSnapshotTree(tree);\n\t}\n\treturn numTrees;\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param logger - logger\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport async function downloadSnapshot(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageToken: string,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tsnapshotFormatFetchType?: SnapshotFormatSupportType,\n\tcontroller?: AbortController,\n\tepochTracker?: EpochTracker,\n\tscenarioName?: string,\n): Promise<ISnapshotRequestAndResponseOptions> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\tconst snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n\n\tconst queryParams = { ump: 1 };\n\tif (snapshotOptions !== undefined) {\n\t\tObject.entries(snapshotOptions).forEach(([key, value]) => {\n\t\t\t// Exclude \"timeout\" from query string\n\t\t\tif (value !== undefined && key !== \"timeout\") {\n\t\t\t\tqueryParams[key] = value;\n\t\t\t}\n\t\t});\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst url = `${snapshotUrl}/trees/latest${queryString}`;\n\t// The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n\t// Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n\t// This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n\t// for futher reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n\tconst header = { prefer: \"manualredirect\" };\n\tconst { body, headers } = getFormBodyAndHeaders(odspResolvedUrl, storageToken, header);\n\tconst fetchOptions = {\n\t\tbody,\n\t\theaders,\n\t\tsignal: controller?.signal,\n\t\tmethod: \"POST\",\n\t};\n\t// Decide what snapshot format to fetch as per the feature gate.\n\tswitch (snapshotFormatFetchType) {\n\t\tcase SnapshotFormatSupportType.Binary:\n\t\t\theaders.accept = `application/ms-fluid; v=${currentReadVersion}`;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t// By default ask both versions and let the server decide the format.\n\t\t\theaders.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n\t}\n\n\tconst odspResponse = await (epochTracker?.fetch(\n\t\turl,\n\t\tfetchOptions,\n\t\t\"treesLatest\",\n\t\ttrue,\n\t\tscenarioName,\n\t) ?? fetchHelper(url, fetchOptions));\n\n\treturn {\n\t\todspResponse,\n\t\trequestHeaders: headers,\n\t\trequestUrl: url,\n\t};\n}\n\nfunction isRedeemSharingLinkError(odspResolvedUrl: IOdspResolvedUrl, error: any) {\n\tif (\n\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined &&\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t(error.errorType === DriverErrorType.authorizationError ||\n\t\t\terror.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError)\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n\t/**\n\t * Encode the url to accepted format by Sharepoint\n\t * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n\t */\n\tlet encodedUrl = fromUtf8ToBase64(encodeURI(url));\n\tencodedUrl = encodedUrl.replace(/=+$/g, \"\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\");\n\tencodedUrl = \"u!\".concat(encodedUrl);\n\treturn encodedUrl;\n}\n"]}
1
+ {"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAClC,qEAKyC;AACzC,+DAAgE;AAChE,2DAAoD;AACpD,6DAAyD;AAEzD,qFAMiD;AAEjD,+DAIsC;AACtC,yEAGoD;AACpD,iDAKwB;AACxB,2DAAqD;AACrD,+EAAyE;AACzE,iDAUwB;AACxB,mEAAoF;AACpF,yEAIoC;AAEpC,2DAAiD;AAEjD;;;GAGG;AACH,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACpC,yEAAQ,CAAA;IACR,6EAAU,CAAA;IACV,2FAAiB,CAAA;AAClB,CAAC,EAJW,yBAAyB,yCAAzB,yBAAyB,QAIpC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,aAAa,CAClC,WAAmB;AACnB,kDAAkD;AAClD,KAAoB,EACpB,SAAiB,EACjB,iBAA0B,EAC1B,sCAA+C,EAC/C,MAA2B,EAC3B,kBAGoC;IAEpC,MAAM,IAAI,GAAG,UAAU,SAAS,EAAE,CA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,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACnB,CAAC","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\tisFluidError,\n\tPerformanceEvent,\n\twrapError,\n} from \"@fluidframework/telemetry-utils\";\nimport { fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { getW3CData } from \"@fluidframework/driver-base\";\nimport { ISnapshot } from \"@fluidframework/driver-definitions\";\nimport {\n\tIOdspResolvedUrl,\n\tISnapshotOptions,\n\tOdspErrorTypes,\n\tInstrumentedStorageTokenFetcher,\n\ttype IOdspError,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tDriverErrorTelemetryProps,\n\tisRuntimeMessage,\n\tNonRetryableError,\n} from \"@fluidframework/driver-utils\";\nimport {\n\tfetchIncorrectResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tIOdspSnapshot,\n\tISnapshotCachedEntry2,\n\tIVersionedValueWithEpoch,\n\tpersistedCacheValueVersion,\n} from \"./contracts.js\";\nimport { getQueryString } from \"./getQueryString.js\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport {\n\tfetchAndParseAsJSONHelper,\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\tgetWithRetryForTokenRefreshRepeat,\n\tIOdspResponse,\n\tisSnapshotFetchForLoadingGroup,\n\tmeasure,\n\tmeasureP,\n\tuseLegacyFlowWithoutGroupsForSnapshotFetch,\n} from \"./odspUtils.js\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser.js\";\nimport {\n\tcurrentReadVersion,\n\tISnapshotContentsWithProps,\n\tparseCompactSnapshotResponse,\n} from \"./compactSnapshotParser.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Enum to support different types of snapshot formats.\n * @alpha\n */\nexport enum SnapshotFormatSupportType {\n\tJson = 0,\n\tBinary = 1,\n\tJsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param token - token used for authorization in the request\n * @param storageFetchWrapper - Implementation of the get/post methods used to fetch the snapshot\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n\tsnapshotUrl: string,\n\t// eslint-disable-next-line @rushstack/no-new-null\n\ttoken: string | null,\n\tversionId: string,\n\tfetchFullSnapshot: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: RequestInit },\n\t) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshot> {\n\tconst path = `/trees/${versionId}`;\n\tlet queryParams: ISnapshotOptions = {};\n\n\tif (fetchFullSnapshot) {\n\t\tqueryParams = versionId === \"latest\" ? { deltas: 1, blobs: 2 } : { blobs: 2 };\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t`${snapshotUrl}${path}${queryString}`,\n\t\ttoken,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t);\n\tconst response = (await PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"fetchSnapshot\",\n\t\t\theaders: Object.keys(headers).length > 0 ? true : undefined,\n\t\t},\n\t\tasync () => snapshotDownloader(url, { headers }),\n\t)) as IOdspResponse<IOdspSnapshot>;\n\treturn convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tstorageToken: string,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tremoveEntries: () => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\treturn fetchLatestSnapshotCore(\n\t\todspResolvedUrl,\n\t\tstorageTokenFetcher,\n\t\tsnapshotOptions,\n\t\tlogger,\n\t\tsnapshotDownloader,\n\t\tputInCache,\n\t\tloadingGroupIds,\n\t\tenableRedeemFallback,\n\t)\n\t\t.catch(async (error) => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tif (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n\t\t\t\t// Execute the redeem fallback\n\n\t\t\t\tawait redeemSharingLink(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tlogger,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\tconst odspResolvedUrlWithoutShareLink: IOdspResolvedUrl = {\n\t\t\t\t\t...odspResolvedUrl,\n\t\t\t\t\tshareLinkInfo: {\n\t\t\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t\t\tsharingLinkToRedeem: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\t// Log initial failure only if redeem succeeded - it points out to some bug somewhere\n\t\t\t\t// If redeem failed, that most likely means user has no permissions to access a file,\n\t\t\t\t// and thus it's not worth it logging extra errors - same error will be logged by end-to-end\n\t\t\t\t// flow (container open) based on a failure above.\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"RedeemFallback\",\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\terrorType: error.errorType,\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn fetchLatestSnapshotCore(\n\t\t\t\t\todspResolvedUrlWithoutShareLink,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tlogger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})\n\t\t.catch(async (error) => {\n\t\t\t// Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n\t\t\t// have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n\t\t\t// snapshot from cache in the future.\n\t\t\tif (\n\t\t\t\t(typeof error === \"object\" &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\terror.errorType === OdspErrorTypes.authorizationError) ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError\n\t\t\t) {\n\t\t\t\tawait removeEntries();\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n}\n\nasync function redeemSharingLink(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tlogger: ITelemetryLoggerExt,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<IOdspResponse<unknown>> {\n\treturn PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"RedeemShareLink\",\n\t\t},\n\t\tasync () =>\n\t\t\tgetWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\t\t\tassert(\n\t\t\t\t\t!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t\t0x1ed /* \"Share link should be present\" */,\n\t\t\t\t);\n\t\t\t\tconst storageToken = await storageTokenFetcher(\n\t\t\t\t\ttokenFetchOptions,\n\t\t\t\t\t\"RedeemShareLink\",\n\t\t\t\t);\n\t\t\t\tconst encodedShareUrl = getEncodedShareUrl(\n\t\t\t\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t);\n\t\t\t\tconst redeemUrl = `${odspResolvedUrl.siteUrl}/_api/v2.0/shares/${encodedShareUrl}`;\n\t\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\t\tredeemUrl,\n\t\t\t\t\tstorageToken,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\theaders.prefer = \"redeemSharingLink\";\n\t\t\t\treturn fetchAndParseAsJSONHelper(url, { headers });\n\t\t\t}),\n\t);\n}\n\nasync function fetchLatestSnapshotCore(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tstorageToken: string,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\treturn getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\tconst fetchSnapshotForLoadingGroup = isSnapshotFetchForLoadingGroup(loadingGroupIds);\n\t\tconst eventName = fetchSnapshotForLoadingGroup ? \"TreesLatestForGroup\" : \"TreesLatest\";\n\t\tconst storageToken = await storageTokenFetcher(tokenFetchOptions, eventName, true);\n\t\tassert(storageToken !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\n\t\tconst perfEvent = {\n\t\t\teventName,\n\t\t\tattempts: tokenFetchOptions.refresh ? 2 : 1,\n\t\t\tshareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n\t\t\tisSummarizer: odspResolvedUrl.summarizer,\n\t\t\tredeemFallbackEnabled: enableRedeemFallback,\n\t\t};\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\tperfEvent[`snapshotOption_${key}`] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// This event measures only successful cases of getLatest call (no tokens, no retries).\n\t\treturn PerformanceEvent.timedExecAsync(logger, perfEvent, async (event) => {\n\t\t\tlet controller: AbortController | undefined;\n\t\t\tlet fetchTimeout: ReturnType<typeof setTimeout> | undefined;\n\t\t\tif (snapshotOptions?.timeout !== undefined) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\tfetchTimeout = setTimeout(() => controller!.abort(), snapshotOptions.timeout);\n\t\t\t}\n\n\t\t\tconst [response, fetchTime] = await measureP(async () =>\n\t\t\t\tsnapshotDownloader(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\tstorageToken,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tcontroller,\n\t\t\t\t),\n\t\t\t).finally(() => {\n\t\t\t\t// Clear the fetchTimeout once the response is fetched.\n\t\t\t\tif (fetchTimeout !== undefined) {\n\t\t\t\t\tclearTimeout(fetchTimeout);\n\t\t\t\t\tfetchTimeout = undefined;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst odspResponse = response.odspResponse;\n\t\t\tconst contentType = odspResponse.headers.get(\"content-type\");\n\n\t\t\tconst propsToLog: DriverErrorTelemetryProps = {\n\t\t\t\t...odspResponse.propsToLog,\n\t\t\t\tcontentType,\n\t\t\t\taccept: response.requestHeaders.accept,\n\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t};\n\n\t\t\tlet parsedSnapshotContents: IOdspResponse<ISnapshotContentsWithProps> | undefined;\n\t\t\tlet contentTypeToRead: string | undefined;\n\t\t\tif (contentType?.includes(\"application/ms-fluid\")) {\n\t\t\t\tcontentTypeToRead = \"application/ms-fluid\";\n\t\t\t} else if (contentType?.includes(\"application/json\")) {\n\t\t\t\tcontentTypeToRead = \"application/json\";\n\t\t\t}\n\n\t\t\tlet parseTime: number;\n\t\t\tlet receiveContentTime: number;\n\t\t\ttry {\n\t\t\t\tswitch (contentTypeToRead) {\n\t\t\t\t\tcase \"application/json\": {\n\t\t\t\t\t\tlet text: string;\n\t\t\t\t\t\t[text, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content.text().catch((error) =>\n\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = text.length;\n\t\t\t\t\t\tlet content: IOdspSnapshot;\n\t\t\t\t\t\t[content, parseTime] = measure(() => JSON.parse(text) as IOdspSnapshot);\n\t\t\t\t\t\tvalidateBlobsAndTrees(content);\n\t\t\t\t\t\tconst snapshotContents: ISnapshot =\n\t\t\t\t\t\t\tconvertOdspSnapshotToSnapshotTreeAndBlobs(content);\n\t\t\t\t\t\tparsedSnapshotContents = {\n\t\t\t\t\t\t\t...odspResponse,\n\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t...snapshotContents,\n\t\t\t\t\t\t\t\ttelemetryProps: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"application/ms-fluid\": {\n\t\t\t\t\t\tlet content: ArrayBuffer;\n\t\t\t\t\t\t[content, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content.arrayBuffer().catch((error) =>\n\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = content.byteLength;\n\t\t\t\t\t\tlet snapshotContents: ISnapshotContentsWithProps;\n\t\t\t\t\t\t[snapshotContents, parseTime] = measure(() =>\n\t\t\t\t\t\t\tparseCompactSnapshotResponse(new Uint8Array(content), logger),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.trees === undefined ||\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.blobs === undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t\"Returned odsp snapshot is malformed. No trees or blobs!\",\n\t\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst props = snapshotContents.telemetryProps;\n\t\t\t\t\t\tconst slowTreeParseCodePaths = props.slowTreeStructureCount ?? 0;\n\t\t\t\t\t\tconst slowBlobParseCodePaths = props.slowBlobStructureCount ?? 0;\n\t\t\t\t\t\tif (slowTreeParseCodePaths > 10 || slowBlobParseCodePaths > 10) {\n\t\t\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\t\t\teventName: \"SlowSnapshotParseCodePaths\",\n\t\t\t\t\t\t\t\tslowTreeStructureCount: slowTreeParseCodePaths,\n\t\t\t\t\t\t\t\tslowBlobStructureCount: slowBlobParseCodePaths,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\"Unknown snapshot content type\",\n\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isFluidError(error)) {\n\t\t\t\t\terror.addTelemetryProperties(propsToLog);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst enhancedError = wrapError(\n\t\t\t\t\terror,\n\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\tnew NonRetryableError(\n\t\t\t\t\t\t\t`Error parsing snapshot response: ${errorMessage}`,\n\t\t\t\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tthrow enhancedError;\n\t\t\t}\n\n\t\t\tassert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n\t\t\tconst snapshot = parsedSnapshotContents.content;\n\t\t\tconst { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n\t\t\t// There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n\t\t\t// cannot cache using an HTTP response header. Only cache snapshot if it is not for a loading group.\n\t\t\tconst canCache =\n\t\t\t\todspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\" &&\n\t\t\t\t!fetchSnapshotForLoadingGroup;\n\t\t\tconst sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n\t\t\tconst seqNumberFromOps =\n\t\t\t\tsnapshot.ops && snapshot.ops.length > 0\n\t\t\t\t\t? snapshot.ops[0].sequenceNumber - 1\n\t\t\t\t\t: undefined;\n\n\t\t\tif (\n\t\t\t\t!Number.isInteger(sequenceNumber) ||\n\t\t\t\t(seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber)\n\t\t\t) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"fetchSnapshotError\",\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t\tseqNumberFromOps,\n\t\t\t\t});\n\t\t\t\tsnapshot.sequenceNumber = undefined;\n\t\t\t} else if (canCache) {\n\t\t\t\tconst fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n\t\t\t\tassert(\n\t\t\t\t\tfluidEpoch !== undefined,\n\t\t\t\t\t0x1e6 /* \"Epoch should be present in response\" */,\n\t\t\t\t);\n\t\t\t\tconst value: ISnapshotCachedEntry2 = {\n\t\t\t\t\t...snapshot,\n\t\t\t\t\tcacheEntryTime: Date.now(),\n\t\t\t\t};\n\t\t\t\tconst valueWithEpoch: IVersionedValueWithEpoch = {\n\t\t\t\t\tvalue,\n\t\t\t\t\tfluidEpoch,\n\t\t\t\t\tversion: persistedCacheValueVersion,\n\t\t\t\t};\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\t\tputInCache(valueWithEpoch);\n\t\t\t}\n\n\t\t\tevent.end({\n\t\t\t\ttrees,\n\t\t\t\tblobs: snapshot.blobContents?.size ?? 0,\n\t\t\t\tleafNodes: numBlobs,\n\t\t\t\tencodedBlobsSize,\n\t\t\t\tsequenceNumber,\n\t\t\t\tops: snapshot.ops?.length ?? 0,\n\t\t\t\tfetchSnapshotForLoadingGroup,\n\t\t\t\tuseLegacyFlowWithoutGroups:\n\t\t\t\t\tuseLegacyFlowWithoutGroupsForSnapshotFetch(loadingGroupIds),\n\t\t\t\tuserOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n\t\t\t\theaders: Object.keys(response.requestHeaders).length > 0 ? true : undefined,\n\t\t\t\t// Measures time to make fetch call. Should be similar to\n\t\t\t\t// fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /\n\t\t\t\t// end of response headers\n\t\t\t\tfetchTime,\n\t\t\t\t// time it takes client to parse payload. Same payload as in \"SnapshotParse\" event, here for\n\t\t\t\t// easier analyzes.\n\t\t\t\tparseTime,\n\t\t\t\t// Time it takes to receive content (text of buffer) from Response object.\n\t\t\t\t// This time likely is very closely correlated with networkTime, i.e. time it takes to receive\n\t\t\t\t// actual content (starting measuring from first bite / end of response header)\n\t\t\t\treceiveContentTime,\n\t\t\t\t...getW3CData(response.requestUrl, \"fetch\"),\n\t\t\t\t// Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n\t\t\t\t// Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n\t\t\t\t// Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n\t\t\t\t// if the permission has changed.\n\t\t\t\tsltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n\t\t\t\t// All other props\n\t\t\t\t...propsToLog,\n\t\t\t\t// Various perf counters and measures collected by binary parsing code:\n\t\t\t\t// slowTreeStructureCount, slowBlobStructureCount, durationStructure, durationStrings,\n\t\t\t\t// durationSnapshotTree, durationBlobs, etc.\n\t\t\t\t...parsedSnapshotContents.content.telemetryProps,\n\t\t\t});\n\t\t\treturn snapshot;\n\t\t}).catch((error) => {\n\t\t\t// We hit these errors in stress tests, under load\n\t\t\t// It's useful to try one more time in such case.\n\t\t\tif (\n\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\terror !== null &&\n\t\t\t\t((error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchFailure ||\n\t\t\t\t\t(error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchTimeout)\n\t\t\t) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror[getWithRetryForTokenRefreshRepeat] = true;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n\todspResponse: IOdspResponse<Response>;\n\trequestUrl: string;\n\trequestHeaders: { [index: string]: string };\n}\n\nfunction getFormBodyAndHeaders(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageToken: string,\n\theaders?: { [index: string]: string },\n): {\n\tbody: string;\n\theaders: {\n\t\t[index: string]: string;\n\t};\n} {\n\tconst formBoundary = uuid();\n\tconst formParams: string[] = [];\n\tformParams.push(\n\t\t`--${formBoundary}`,\n\t\t`Authorization: Bearer ${storageToken}`,\n\t\t`X-HTTP-Method-Override: GET`,\n\t);\n\n\tif (headers !== undefined) {\n\t\tfor (const [key, value] of Object.entries(headers)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tformParams.push(`${key}: ${value}`);\n\t\t\t}\n\t\t}\n\t}\n\tif (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n\t\tformParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n\t}\n\tformParams.push(`_post: 1`, `\\r\\n--${formBoundary}--`);\n\tconst postBody = formParams.join(\"\\r\\n\");\n\tconst header: { [index: string]: string } = {\n\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t};\n\treturn { body: postBody, headers: header };\n}\n\nexport function evalBlobsAndTrees(snapshot: ISnapshot): {\n\ttrees: number;\n\tnumBlobs: number;\n\tencodedBlobsSize: number;\n} {\n\tconst trees = countTreesInSnapshotTree(snapshot.snapshotTree);\n\tconst numBlobs = snapshot.blobContents.size;\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobContents) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { trees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot): void {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */,\n\t);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n\tlet numTrees = 0;\n\tfor (const [_, tree] of Object.entries(snapshotTree.trees)) {\n\t\tnumTrees += 1;\n\t\tnumTrees += countTreesInSnapshotTree(tree);\n\t}\n\treturn numTrees;\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param loadingGroupIds - loadingGroupIds for which snapshot needs to be downloaded. Note:\n * 1.) If undefined, then legacy trees latest call will be used where no groupId query param would be specified.\n * 2.) If [] is passed, then snapshot with all ungrouped data will be fetched.\n * 3.) If any groupId is specified like [\"g1\"], then snapshot for g1 group will be fetched.\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport async function downloadSnapshot(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageToken: string,\n\tloadingGroupIds: string[] | undefined,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tsnapshotFormatFetchType?: SnapshotFormatSupportType,\n\tcontroller?: AbortController,\n\tepochTracker?: EpochTracker,\n\tscenarioName?: string,\n): Promise<ISnapshotRequestAndResponseOptions> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\tconst snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n\n\tconst queryParams: Record<string, unknown> = { ump: 1 };\n\tif (snapshotOptions !== undefined) {\n\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t// Exclude \"timeout\" from query string\n\t\t\tif (value !== undefined && key !== \"timeout\") {\n\t\t\t\tqueryParams[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (loadingGroupIds !== undefined) {\n\t\tqueryParams.groupId = loadingGroupIds.join(\",\");\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst url = `${snapshotUrl}/trees/latest${queryString}`;\n\t// The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n\t// Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n\t// This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n\t// for further reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n\tconst header = { prefer: \"manualredirect\" };\n\tconst { body, headers } = getFormBodyAndHeaders(odspResolvedUrl, storageToken, header);\n\tconst fetchOptions = {\n\t\tbody,\n\t\theaders,\n\t\tsignal: controller?.signal,\n\t\tmethod: \"POST\",\n\t};\n\t// Decide what snapshot format to fetch as per the feature gate.\n\tswitch (snapshotFormatFetchType) {\n\t\tcase SnapshotFormatSupportType.Binary: {\n\t\t\theaders.accept = `application/ms-fluid; v=${currentReadVersion}`;\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// By default ask both versions and let the server decide the format.\n\t\t\theaders.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n\t\t}\n\t}\n\n\tconst odspResponse = await (epochTracker?.fetch(\n\t\turl,\n\t\tfetchOptions,\n\t\t\"treesLatest\",\n\t\ttrue,\n\t\tscenarioName,\n\t) ?? fetchHelper(url, fetchOptions));\n\n\treturn {\n\t\todspResponse,\n\t\trequestHeaders: headers,\n\t\trequestUrl: url,\n\t};\n}\n\nfunction isRedeemSharingLinkError(\n\todspResolvedUrl: IOdspResolvedUrl,\n\terror: Partial<IOdspError>,\n): boolean {\n\tif (\n\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined &&\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t(error.errorType === OdspErrorTypes.authorizationError ||\n\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError)\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n\t/**\n\t * Encode the url to accepted format by Sharepoint\n\t * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n\t */\n\tlet encodedUrl = fromUtf8ToBase64(encodeURI(url));\n\tencodedUrl = encodedUrl.replace(/=+$/g, \"\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\");\n\tencodedUrl = \"u!\".concat(encodedUrl);\n\treturn encodedUrl;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getFileLink.d.ts","sourceRoot":"","sources":["../src/getFileLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAAC;AAIxF,OAAO,EACN,aAAa,EACb,6BAA6B,EAC7B,YAAY,EACZ,MAAM,yCAAyC,CAAC;AAajD;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAChC,QAAQ,EAAE,YAAY,CAAC,6BAA6B,CAAC,EACrD,YAAY,EAAE,aAAa,EAC3B,MAAM,EAAE,mBAAmB,GACzB,OAAO,CAAC,MAAM,CAAC,CAiDjB"}
1
+ {"version":3,"file":"getFileLink.d.ts","sourceRoot":"","sources":["../src/getFileLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAAC;AAGxF,OAAO,EACN,aAAa,EAEb,6BAA6B,EAC7B,YAAY,EACZ,MAAM,yCAAyC,CAAC;AAajD;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAChC,QAAQ,EAAE,YAAY,CAAC,6BAA6B,CAAC,EACrD,YAAY,EAAE,aAAa,EAC3B,MAAM,EAAE,mBAAmB,GACzB,OAAO,CAAC,MAAM,CAAC,CAoDjB"}