@fluidframework/odsp-driver 2.0.0-dev.7.3.0.210328 → 2.0.0-dev.7.3.0.211848

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 (328) hide show
  1. package/api-report/odsp-driver.api.md +2 -1
  2. package/dist/{ReadBufferUtils.js → ReadBufferUtils.cjs} +1 -1
  3. package/{lib/ReadBufferUtils.js.map → dist/ReadBufferUtils.cjs.map} +1 -1
  4. package/dist/{WriteBufferUtils.js → WriteBufferUtils.cjs} +2 -2
  5. package/dist/WriteBufferUtils.cjs.map +1 -0
  6. package/dist/{checkUrl.js → checkUrl.cjs} +2 -2
  7. package/dist/checkUrl.cjs.map +1 -0
  8. package/dist/{compactSnapshotParser.js → compactSnapshotParser.cjs} +4 -4
  9. package/dist/compactSnapshotParser.cjs.map +1 -0
  10. package/dist/{compactSnapshotWriter.js → compactSnapshotWriter.cjs} +4 -4
  11. package/dist/compactSnapshotWriter.cjs.map +1 -0
  12. package/dist/{constants.js → constants.cjs} +1 -1
  13. package/dist/constants.cjs.map +1 -0
  14. package/dist/{contracts.js → contracts.cjs} +1 -1
  15. package/dist/contracts.cjs.map +1 -0
  16. package/dist/{contractsPublic.js → contractsPublic.cjs} +1 -1
  17. package/dist/contractsPublic.cjs.map +1 -0
  18. package/dist/{createFile.js → createFile.cjs} +10 -10
  19. package/dist/createFile.cjs.map +1 -0
  20. package/dist/{createNewContainerOnExistingFile.js → createNewContainerOnExistingFile.cjs} +7 -7
  21. package/dist/createNewContainerOnExistingFile.cjs.map +1 -0
  22. package/dist/{createNewModule.js → createNewModule.cjs} +3 -3
  23. package/dist/createNewModule.cjs.map +1 -0
  24. package/dist/{createNewUtils.js → createNewUtils.cjs} +4 -4
  25. package/dist/createNewUtils.cjs.map +1 -0
  26. package/dist/{createOdspCreateContainerRequest.js → createOdspCreateContainerRequest.cjs} +2 -2
  27. package/dist/createOdspCreateContainerRequest.cjs.map +1 -0
  28. package/dist/{createOdspUrl.js → createOdspUrl.cjs} +1 -1
  29. package/dist/createOdspUrl.cjs.map +1 -0
  30. package/dist/{epochTracker.js → epochTracker.cjs} +6 -6
  31. package/dist/epochTracker.cjs.map +1 -0
  32. package/dist/{fetch.js → fetch.cjs} +1 -1
  33. package/dist/fetch.cjs.map +1 -0
  34. package/dist/{fetchSnapshot.js → fetchSnapshot.cjs} +8 -8
  35. package/dist/fetchSnapshot.cjs.map +1 -0
  36. package/dist/{getFileLink.js → getFileLink.cjs} +5 -5
  37. package/dist/getFileLink.cjs.map +1 -0
  38. package/dist/{getQueryString.js → getQueryString.cjs} +1 -1
  39. package/dist/getQueryString.cjs.map +1 -0
  40. package/dist/{getUrlAndHeadersWithAuth.js → getUrlAndHeadersWithAuth.cjs} +1 -1
  41. package/dist/getUrlAndHeadersWithAuth.cjs.map +1 -0
  42. package/dist/{index.js → index.cjs} +17 -17
  43. package/dist/index.cjs.map +1 -0
  44. package/dist/localOdspDriver/{localOdspDeltaStorageService.js → localOdspDeltaStorageService.cjs} +1 -1
  45. package/dist/localOdspDriver/localOdspDeltaStorageService.cjs.map +1 -0
  46. package/dist/localOdspDriver/{localOdspDocumentService.js → localOdspDocumentService.cjs} +3 -3
  47. package/dist/localOdspDriver/localOdspDocumentService.cjs.map +1 -0
  48. package/dist/localOdspDriver/{localOdspDocumentServiceFactory.js → localOdspDocumentServiceFactory.cjs} +4 -4
  49. package/dist/localOdspDriver/localOdspDocumentServiceFactory.cjs.map +1 -0
  50. package/dist/localOdspDriver/{localOdspDocumentStorageManager.js → localOdspDocumentStorageManager.cjs} +4 -4
  51. package/dist/localOdspDriver/localOdspDocumentStorageManager.cjs.map +1 -0
  52. package/dist/{odspCache.js → odspCache.cjs} +1 -1
  53. package/dist/odspCache.cjs.map +1 -0
  54. package/dist/{odspDelayLoadedDeltaStream.js → odspDelayLoadedDeltaStream.cjs} +5 -5
  55. package/dist/odspDelayLoadedDeltaStream.cjs.map +1 -0
  56. package/dist/{odspDeltaStorageService.js → odspDeltaStorageService.cjs} +2 -2
  57. package/dist/odspDeltaStorageService.cjs.map +1 -0
  58. package/dist/{odspDocumentDeltaConnection.js → odspDocumentDeltaConnection.cjs} +4 -4
  59. package/dist/odspDocumentDeltaConnection.cjs.map +1 -0
  60. package/dist/{odspDocumentService.js → odspDocumentService.cjs} +8 -32
  61. package/dist/odspDocumentService.cjs.map +1 -0
  62. package/dist/{odspDocumentServiceFactory.js → odspDocumentServiceFactory.cjs} +3 -3
  63. package/dist/odspDocumentServiceFactory.cjs.map +1 -0
  64. package/dist/{odspDocumentServiceFactoryCore.js → odspDocumentServiceFactoryCore.cjs} +6 -30
  65. package/dist/odspDocumentServiceFactoryCore.cjs.map +1 -0
  66. package/dist/{odspDocumentServiceFactoryWithCodeSplit.js → odspDocumentServiceFactoryWithCodeSplit.cjs} +2 -2
  67. package/dist/odspDocumentServiceFactoryWithCodeSplit.cjs.map +1 -0
  68. package/dist/{odspDocumentStorageManager.js → odspDocumentStorageManager.cjs} +7 -31
  69. package/dist/odspDocumentStorageManager.cjs.map +1 -0
  70. package/dist/{odspDocumentStorageServiceBase.js → odspDocumentStorageServiceBase.cjs} +1 -1
  71. package/dist/odspDocumentStorageServiceBase.cjs.map +1 -0
  72. package/dist/{odspDriverUrlResolver.js → odspDriverUrlResolver.cjs} +7 -7
  73. package/dist/odspDriverUrlResolver.cjs.map +1 -0
  74. package/dist/{odspDriverUrlResolverForShareLink.js → odspDriverUrlResolverForShareLink.cjs} +7 -7
  75. package/dist/odspDriverUrlResolverForShareLink.cjs.map +1 -0
  76. package/dist/{odspError.js → odspError.cjs} +2 -2
  77. package/dist/odspError.cjs.map +1 -0
  78. package/dist/{odspFluidFileLink.js → odspFluidFileLink.cjs} +2 -2
  79. package/dist/odspFluidFileLink.cjs.map +1 -0
  80. package/dist/{odspLocationRedirection.js → odspLocationRedirection.cjs} +2 -2
  81. package/dist/odspLocationRedirection.cjs.map +1 -0
  82. package/dist/{odspPublicUtils.js → odspPublicUtils.cjs} +1 -1
  83. package/dist/odspPublicUtils.cjs.map +1 -0
  84. package/dist/{odspSnapshotParser.js → odspSnapshotParser.cjs} +1 -1
  85. package/dist/odspSnapshotParser.cjs.map +1 -0
  86. package/dist/{odspSummaryUploadManager.js → odspSummaryUploadManager.cjs} +3 -3
  87. package/dist/odspSummaryUploadManager.cjs.map +1 -0
  88. package/dist/{odspUrlHelper.js → odspUrlHelper.cjs} +1 -1
  89. package/dist/odspUrlHelper.cjs.map +1 -0
  90. package/dist/{odspUtils.js → odspUtils.cjs} +3 -3
  91. package/dist/odspUtils.cjs.map +1 -0
  92. package/dist/{opsCaching.js → opsCaching.cjs} +1 -1
  93. package/dist/opsCaching.cjs.map +1 -0
  94. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  95. package/dist/packageVersion.cjs.map +1 -0
  96. package/dist/packageVersion.d.ts +1 -1
  97. package/dist/{prefetchLatestSnapshot.js → prefetchLatestSnapshot.cjs} +3 -3
  98. package/dist/prefetchLatestSnapshot.cjs.map +1 -0
  99. package/dist/{retryErrorsStorageAdapter.js → retryErrorsStorageAdapter.cjs} +2 -2
  100. package/dist/retryErrorsStorageAdapter.cjs.map +1 -0
  101. package/dist/{retryUtils.js → retryUtils.cjs} +2 -2
  102. package/dist/retryUtils.cjs.map +1 -0
  103. package/dist/{socketModule.js → socketModule.cjs} +1 -1
  104. package/dist/socketModule.cjs.map +1 -0
  105. package/dist/tsdoc-metadata.json +1 -1
  106. package/dist/{vroom.js → vroom.cjs} +4 -4
  107. package/{lib/vroom.js.map → dist/vroom.cjs.map} +1 -1
  108. package/dist/{zipItDataRepresentationUtils.js → zipItDataRepresentationUtils.cjs} +3 -3
  109. package/dist/zipItDataRepresentationUtils.cjs.map +1 -0
  110. package/lib/{ReadBufferUtils.js → ReadBufferUtils.mjs} +1 -1
  111. package/lib/ReadBufferUtils.mjs.map +1 -0
  112. package/lib/{WriteBufferUtils.js → WriteBufferUtils.mjs} +2 -2
  113. package/lib/WriteBufferUtils.mjs.map +1 -0
  114. package/lib/{checkUrl.js → checkUrl.mjs} +2 -2
  115. package/lib/checkUrl.mjs.map +1 -0
  116. package/lib/{compactSnapshotParser.js → compactSnapshotParser.mjs} +4 -4
  117. package/lib/compactSnapshotParser.mjs.map +1 -0
  118. package/lib/{compactSnapshotWriter.js → compactSnapshotWriter.mjs} +4 -4
  119. package/lib/compactSnapshotWriter.mjs.map +1 -0
  120. package/lib/{constants.js → constants.mjs} +1 -1
  121. package/lib/constants.mjs.map +1 -0
  122. package/lib/{contracts.js → contracts.mjs} +1 -1
  123. package/lib/contracts.mjs.map +1 -0
  124. package/lib/{contractsPublic.js → contractsPublic.mjs} +1 -1
  125. package/lib/contractsPublic.mjs.map +1 -0
  126. package/lib/{createFile.js → createFile.mjs} +10 -10
  127. package/lib/createFile.mjs.map +1 -0
  128. package/lib/{createNewContainerOnExistingFile.js → createNewContainerOnExistingFile.mjs} +7 -7
  129. package/lib/createNewContainerOnExistingFile.mjs.map +1 -0
  130. package/lib/{createNewModule.js → createNewModule.mjs} +3 -3
  131. package/lib/createNewModule.mjs.map +1 -0
  132. package/lib/{createNewUtils.js → createNewUtils.mjs} +4 -4
  133. package/lib/createNewUtils.mjs.map +1 -0
  134. package/lib/{createOdspCreateContainerRequest.js → createOdspCreateContainerRequest.mjs} +2 -2
  135. package/lib/createOdspCreateContainerRequest.mjs.map +1 -0
  136. package/lib/{createOdspUrl.js → createOdspUrl.mjs} +1 -1
  137. package/lib/createOdspUrl.mjs.map +1 -0
  138. package/lib/{epochTracker.js → epochTracker.mjs} +6 -6
  139. package/lib/epochTracker.mjs.map +1 -0
  140. package/lib/{fetch.js → fetch.mjs} +1 -1
  141. package/lib/fetch.mjs.map +1 -0
  142. package/lib/{fetchSnapshot.js → fetchSnapshot.mjs} +8 -8
  143. package/lib/fetchSnapshot.mjs.map +1 -0
  144. package/lib/{getFileLink.js → getFileLink.mjs} +5 -5
  145. package/lib/getFileLink.mjs.map +1 -0
  146. package/lib/{getQueryString.js → getQueryString.mjs} +1 -1
  147. package/lib/getQueryString.mjs.map +1 -0
  148. package/lib/{getUrlAndHeadersWithAuth.js → getUrlAndHeadersWithAuth.mjs} +1 -1
  149. package/lib/getUrlAndHeadersWithAuth.mjs.map +1 -0
  150. package/lib/{index.js → index.mjs} +17 -24
  151. package/lib/index.mjs.map +1 -0
  152. package/lib/localOdspDriver/{localOdspDeltaStorageService.js → localOdspDeltaStorageService.mjs} +1 -1
  153. package/lib/localOdspDriver/localOdspDeltaStorageService.mjs.map +1 -0
  154. package/lib/localOdspDriver/{localOdspDocumentService.js → localOdspDocumentService.mjs} +3 -3
  155. package/lib/localOdspDriver/localOdspDocumentService.mjs.map +1 -0
  156. package/lib/localOdspDriver/{localOdspDocumentServiceFactory.js → localOdspDocumentServiceFactory.mjs} +4 -4
  157. package/lib/localOdspDriver/localOdspDocumentServiceFactory.mjs.map +1 -0
  158. package/lib/localOdspDriver/{localOdspDocumentStorageManager.js → localOdspDocumentStorageManager.mjs} +4 -4
  159. package/lib/localOdspDriver/localOdspDocumentStorageManager.mjs.map +1 -0
  160. package/lib/{odspCache.js → odspCache.mjs} +1 -5
  161. package/lib/odspCache.mjs.map +1 -0
  162. package/lib/{odspDelayLoadedDeltaStream.js → odspDelayLoadedDeltaStream.mjs} +5 -5
  163. package/lib/odspDelayLoadedDeltaStream.mjs.map +1 -0
  164. package/lib/{odspDeltaStorageService.js → odspDeltaStorageService.mjs} +2 -2
  165. package/lib/odspDeltaStorageService.mjs.map +1 -0
  166. package/lib/{odspDocumentDeltaConnection.js → odspDocumentDeltaConnection.mjs} +4 -4
  167. package/lib/odspDocumentDeltaConnection.mjs.map +1 -0
  168. package/lib/{odspDocumentService.js → odspDocumentService.mjs} +8 -10
  169. package/lib/odspDocumentService.mjs.map +1 -0
  170. package/lib/{odspDocumentServiceFactory.js → odspDocumentServiceFactory.mjs} +3 -4
  171. package/lib/odspDocumentServiceFactory.mjs.map +1 -0
  172. package/lib/{odspDocumentServiceFactoryCore.js → odspDocumentServiceFactoryCore.mjs} +6 -8
  173. package/lib/odspDocumentServiceFactoryCore.mjs.map +1 -0
  174. package/lib/{odspDocumentServiceFactoryWithCodeSplit.js → odspDocumentServiceFactoryWithCodeSplit.mjs} +2 -2
  175. package/lib/odspDocumentServiceFactoryWithCodeSplit.mjs.map +1 -0
  176. package/lib/{odspDocumentStorageManager.js → odspDocumentStorageManager.mjs} +7 -9
  177. package/lib/odspDocumentStorageManager.mjs.map +1 -0
  178. package/lib/{odspDocumentStorageServiceBase.js → odspDocumentStorageServiceBase.mjs} +1 -1
  179. package/lib/odspDocumentStorageServiceBase.mjs.map +1 -0
  180. package/lib/{odspDriverUrlResolver.js → odspDriverUrlResolver.mjs} +7 -11
  181. package/lib/odspDriverUrlResolver.mjs.map +1 -0
  182. package/lib/{odspDriverUrlResolverForShareLink.js → odspDriverUrlResolverForShareLink.mjs} +7 -11
  183. package/lib/odspDriverUrlResolverForShareLink.mjs.map +1 -0
  184. package/lib/{odspError.js → odspError.mjs} +2 -2
  185. package/lib/odspError.mjs.map +1 -0
  186. package/lib/{odspFluidFileLink.js → odspFluidFileLink.mjs} +2 -2
  187. package/lib/odspFluidFileLink.mjs.map +1 -0
  188. package/lib/{odspLocationRedirection.js → odspLocationRedirection.mjs} +2 -2
  189. package/lib/odspLocationRedirection.mjs.map +1 -0
  190. package/lib/{odspPublicUtils.js → odspPublicUtils.mjs} +1 -1
  191. package/lib/odspPublicUtils.mjs.map +1 -0
  192. package/lib/{odspSnapshotParser.js → odspSnapshotParser.mjs} +1 -1
  193. package/lib/odspSnapshotParser.mjs.map +1 -0
  194. package/lib/{odspSummaryUploadManager.js → odspSummaryUploadManager.mjs} +3 -3
  195. package/lib/odspSummaryUploadManager.mjs.map +1 -0
  196. package/lib/{odspUrlHelper.js → odspUrlHelper.mjs} +1 -1
  197. package/lib/odspUrlHelper.mjs.map +1 -0
  198. package/lib/{odspUtils.js → odspUtils.mjs} +3 -3
  199. package/lib/odspUtils.mjs.map +1 -0
  200. package/lib/{opsCaching.js → opsCaching.mjs} +1 -1
  201. package/lib/opsCaching.mjs.map +1 -0
  202. package/lib/packageVersion.d.ts +1 -1
  203. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  204. package/lib/packageVersion.mjs.map +1 -0
  205. package/lib/{prefetchLatestSnapshot.js → prefetchLatestSnapshot.mjs} +3 -3
  206. package/lib/prefetchLatestSnapshot.mjs.map +1 -0
  207. package/lib/{retryErrorsStorageAdapter.js → retryErrorsStorageAdapter.mjs} +2 -2
  208. package/lib/retryErrorsStorageAdapter.mjs.map +1 -0
  209. package/lib/{retryUtils.js → retryUtils.mjs} +2 -2
  210. package/lib/retryUtils.mjs.map +1 -0
  211. package/lib/{socketModule.js → socketModule.mjs} +1 -1
  212. package/lib/socketModule.mjs.map +1 -0
  213. package/lib/{vroom.js → vroom.mjs} +4 -4
  214. package/lib/vroom.mjs.map +1 -0
  215. package/lib/{zipItDataRepresentationUtils.js → zipItDataRepresentationUtils.mjs} +3 -7
  216. package/lib/zipItDataRepresentationUtils.mjs.map +1 -0
  217. package/package.json +21 -21
  218. package/src/odspDocumentService.ts +1 -1
  219. package/src/odspDocumentServiceFactoryCore.ts +1 -1
  220. package/src/odspDocumentStorageManager.ts +1 -1
  221. package/src/packageVersion.ts +1 -1
  222. package/tsc-multi.test.json +4 -0
  223. package/tsconfig.json +5 -3
  224. package/dist/ReadBufferUtils.js.map +0 -1
  225. package/dist/WriteBufferUtils.js.map +0 -1
  226. package/dist/checkUrl.js.map +0 -1
  227. package/dist/compactSnapshotParser.js.map +0 -1
  228. package/dist/compactSnapshotWriter.js.map +0 -1
  229. package/dist/constants.js.map +0 -1
  230. package/dist/contracts.js.map +0 -1
  231. package/dist/contractsPublic.js.map +0 -1
  232. package/dist/createFile.js.map +0 -1
  233. package/dist/createNewContainerOnExistingFile.js.map +0 -1
  234. package/dist/createNewModule.js.map +0 -1
  235. package/dist/createNewUtils.js.map +0 -1
  236. package/dist/createOdspCreateContainerRequest.js.map +0 -1
  237. package/dist/createOdspUrl.js.map +0 -1
  238. package/dist/epochTracker.js.map +0 -1
  239. package/dist/fetch.js.map +0 -1
  240. package/dist/fetchSnapshot.js.map +0 -1
  241. package/dist/getFileLink.js.map +0 -1
  242. package/dist/getQueryString.js.map +0 -1
  243. package/dist/getUrlAndHeadersWithAuth.js.map +0 -1
  244. package/dist/index.js.map +0 -1
  245. package/dist/localOdspDriver/localOdspDeltaStorageService.js.map +0 -1
  246. package/dist/localOdspDriver/localOdspDocumentService.js.map +0 -1
  247. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +0 -1
  248. package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +0 -1
  249. package/dist/odspCache.js.map +0 -1
  250. package/dist/odspDelayLoadedDeltaStream.js.map +0 -1
  251. package/dist/odspDeltaStorageService.js.map +0 -1
  252. package/dist/odspDocumentDeltaConnection.js.map +0 -1
  253. package/dist/odspDocumentService.js.map +0 -1
  254. package/dist/odspDocumentServiceFactory.js.map +0 -1
  255. package/dist/odspDocumentServiceFactoryCore.js.map +0 -1
  256. package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +0 -1
  257. package/dist/odspDocumentStorageManager.js.map +0 -1
  258. package/dist/odspDocumentStorageServiceBase.js.map +0 -1
  259. package/dist/odspDriverUrlResolver.js.map +0 -1
  260. package/dist/odspDriverUrlResolverForShareLink.js.map +0 -1
  261. package/dist/odspError.js.map +0 -1
  262. package/dist/odspFluidFileLink.js.map +0 -1
  263. package/dist/odspLocationRedirection.js.map +0 -1
  264. package/dist/odspPublicUtils.js.map +0 -1
  265. package/dist/odspSnapshotParser.js.map +0 -1
  266. package/dist/odspSummaryUploadManager.js.map +0 -1
  267. package/dist/odspUrlHelper.js.map +0 -1
  268. package/dist/odspUtils.js.map +0 -1
  269. package/dist/opsCaching.js.map +0 -1
  270. package/dist/packageVersion.js.map +0 -1
  271. package/dist/prefetchLatestSnapshot.js.map +0 -1
  272. package/dist/retryErrorsStorageAdapter.js.map +0 -1
  273. package/dist/retryUtils.js.map +0 -1
  274. package/dist/socketModule.js.map +0 -1
  275. package/dist/vroom.js.map +0 -1
  276. package/dist/zipItDataRepresentationUtils.js.map +0 -1
  277. package/lib/WriteBufferUtils.js.map +0 -1
  278. package/lib/checkUrl.js.map +0 -1
  279. package/lib/compactSnapshotParser.js.map +0 -1
  280. package/lib/compactSnapshotWriter.js.map +0 -1
  281. package/lib/constants.js.map +0 -1
  282. package/lib/contracts.js.map +0 -1
  283. package/lib/contractsPublic.js.map +0 -1
  284. package/lib/createFile.js.map +0 -1
  285. package/lib/createNewContainerOnExistingFile.js.map +0 -1
  286. package/lib/createNewModule.js.map +0 -1
  287. package/lib/createNewUtils.js.map +0 -1
  288. package/lib/createOdspCreateContainerRequest.js.map +0 -1
  289. package/lib/createOdspUrl.js.map +0 -1
  290. package/lib/epochTracker.js.map +0 -1
  291. package/lib/fetch.js.map +0 -1
  292. package/lib/fetchSnapshot.js.map +0 -1
  293. package/lib/getFileLink.js.map +0 -1
  294. package/lib/getQueryString.js.map +0 -1
  295. package/lib/getUrlAndHeadersWithAuth.js.map +0 -1
  296. package/lib/index.js.map +0 -1
  297. package/lib/localOdspDriver/localOdspDeltaStorageService.js.map +0 -1
  298. package/lib/localOdspDriver/localOdspDocumentService.js.map +0 -1
  299. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +0 -1
  300. package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +0 -1
  301. package/lib/odspCache.js.map +0 -1
  302. package/lib/odspDelayLoadedDeltaStream.js.map +0 -1
  303. package/lib/odspDeltaStorageService.js.map +0 -1
  304. package/lib/odspDocumentDeltaConnection.js.map +0 -1
  305. package/lib/odspDocumentService.js.map +0 -1
  306. package/lib/odspDocumentServiceFactory.js.map +0 -1
  307. package/lib/odspDocumentServiceFactoryCore.js.map +0 -1
  308. package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +0 -1
  309. package/lib/odspDocumentStorageManager.js.map +0 -1
  310. package/lib/odspDocumentStorageServiceBase.js.map +0 -1
  311. package/lib/odspDriverUrlResolver.js.map +0 -1
  312. package/lib/odspDriverUrlResolverForShareLink.js.map +0 -1
  313. package/lib/odspError.js.map +0 -1
  314. package/lib/odspFluidFileLink.js.map +0 -1
  315. package/lib/odspLocationRedirection.js.map +0 -1
  316. package/lib/odspPublicUtils.js.map +0 -1
  317. package/lib/odspSnapshotParser.js.map +0 -1
  318. package/lib/odspSummaryUploadManager.js.map +0 -1
  319. package/lib/odspUrlHelper.js.map +0 -1
  320. package/lib/odspUtils.js.map +0 -1
  321. package/lib/opsCaching.js.map +0 -1
  322. package/lib/packageVersion.js.map +0 -1
  323. package/lib/prefetchLatestSnapshot.js.map +0 -1
  324. package/lib/retryErrorsStorageAdapter.js.map +0 -1
  325. package/lib/retryUtils.js.map +0 -1
  326. package/lib/socketModule.js.map +0 -1
  327. package/lib/zipItDataRepresentationUtils.js.map +0 -1
  328. package/tsconfig.esnext.json +0 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epochTracker.cjs","sourceRoot":"","sources":["../src/epochTracker.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAClC,2DAA8D;AAC9D,qEAOyC;AACzC,+DAKsC;AACtC,qFASiD;AACjD,2EAAqE;AACrE,+CAMqB;AAErB,+CAAmF;AACnF,2DAA0D;AAC1D,yDAA+D;AAC/D,2EAAiE;AAuBpD,QAAA,YAAY,GAAG,cAAc,CAAC;AAE3C,qCAAqC;AACxB,QAAA,2BAA2B,GAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,eAAe;AAE3F;;;;;;;;;;;;;;;GAeG;AACH,MAAa,YAAY;IAQxB,YACoB,KAAsB,EACtB,SAAqB,EACrB,MAA2B,EAC3B,kBAA4B;QAH5B,UAAK,GAAL,KAAK,CAAiB;QACtB,cAAS,GAAT,SAAS,CAAY;QACrB,WAAM,GAAN,MAAM,CAAqB;QAC3B,uB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AAC,CAAC;IAC9E,CAAC;CACD;AAvHD,gEAuHC;AAUD,SAAgB,yBAAyB,CACxC,iBAAkC,EAClC,kBAAuC,EACvC,SAAqB,EACrB,MAA2B,EAC3B,kBAA4B;IAE5B,MAAM,YAAY,GAAG,IAAI,0BAA0B,CAClD,iBAAiB,EACjB,SAAS,EACT,MAAM,EACN,kBAAkB,CAClB,CAAC;IACF,OAAO;QACN,KAAK,EAAE;YACN,GAAG,kBAAkB;YACrB,cAAc,EAAE,YAAY;SAC5B;QACD,YAAY;KACZ,CAAC;AACH,CAAC;AApBD,8DAoBC","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 { assert, Deferred } from \"@fluidframework/core-utils\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\tnormalizeError,\n\tloggerToMonitoringContext,\n\twrapError,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tThrottlingError,\n\tRateLimiter,\n\tNonRetryableError,\n\tLocationRedirectionError,\n} from \"@fluidframework/driver-utils\";\nimport {\n\tsnapshotKey,\n\tICacheEntry,\n\tIEntry,\n\tIFileEntry,\n\tIPersistedCache,\n\tIOdspError,\n\tIOdspErrorAugmentations,\n\tIOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n\tfetchAndParseAsJSONHelper,\n\tfetchArray,\n\tfetchHelper,\n\tgetOdspResolvedUrl,\n\tIOdspResponse,\n} from \"./odspUtils\";\nimport { IOdspCache, INonPersistentCache, IPersistedFileCache } from \"./odspCache\";\nimport { IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { patchOdspResolvedUrl } from \"./odspLocationRedirection\";\n\n/**\n * @public\n */\nexport type FetchType =\n\t| \"blob\"\n\t| \"createBlob\"\n\t| \"createFile\"\n\t| \"joinSession\"\n\t| \"ops\"\n\t| \"test\"\n\t| \"snapshotTree\"\n\t| \"treesLatest\"\n\t| \"uploadSummary\"\n\t| \"push\"\n\t| \"versions\";\n\n/**\n * @public\n */\nexport type FetchTypeInternal = FetchType | \"cache\";\n\nexport const Odsp409Error = \"Odsp409Error\";\n\n// Must be less than policy of 5 days\nexport const defaultCacheExpiryTimeoutMs: number = 2 * 24 * 60 * 60 * 1000; // 2 days in ms\n\n/**\n * In ODSP, the concept of \"epoch\" refers to binary updates to files. For example, this might include using\n * version restore, or if the user downloads a Fluid file and then uploads it again. These result in the epoch\n * value being incremented.\n *\n * The implications of these binary updates is that the Fluid state is disrupted: the sequence number might\n * go backwards, the data might be inconsistent with the latest state of collaboration, etc. As a result, it's\n * not safe to continue collaboration across an epoch change. We need to detect these epoch changes and\n * error out from the collaboration.\n *\n * This class is a wrapper around fetch calls. It adds epoch to the request made so that the\n * server can match it with its epoch value in order to match the version.\n * It also validates the epoch value received in response of fetch calls. If the epoch does not match,\n * then it also clears all the cached entries for the given container.\n * @public\n */\nexport class EpochTracker implements IPersistedFileCache {\n\tprivate _fluidEpoch: string | undefined;\n\n\tprivate readonly snapshotCacheExpiryTimeoutMs: number;\n\tpublic readonly rateLimiter: RateLimiter;\n\tprivate readonly driverId = uuid();\n\t// This tracks the request number made by the driver instance.\n\tprivate networkCallNumber = 1;\n\tconstructor(\n\t\tprotected readonly cache: IPersistedCache,\n\t\tprotected readonly fileEntry: IFileEntry,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tprotected readonly clientIsSummarizer?: boolean,\n\t) {\n\t\t// Limits the max number of concurrent requests to 24.\n\t\tthis.rateLimiter = new RateLimiter(24);\n\n\t\t// Matches the TestOverride logic for the policy defined in odspDocumentStorageServiceBase.ts\n\t\tthis.snapshotCacheExpiryTimeoutMs = loggerToMonitoringContext(logger).config.getBoolean(\n\t\t\t\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\",\n\t\t)\n\t\t\t? 0\n\t\t\t: defaultCacheExpiryTimeoutMs;\n\t}\n\n\t// public for UT purposes only!\n\tpublic setEpoch(epoch: string, fromCache: boolean, fetchType: FetchTypeInternal) {\n\t\tassert(this._fluidEpoch === undefined, 0x1db /* \"epoch exists\" */);\n\t\tthis._fluidEpoch = epoch;\n\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"EpochLearnedFirstTime\",\n\t\t\tepoch,\n\t\t\tfetchType,\n\t\t\tfromCache,\n\t\t});\n\t}\n\n\tpublic async get(entry: IEntry): Promise<any> {\n\t\ttry {\n\t\t\t// Return undefined so that the ops/snapshots are grabbed from the server instead of the cache\n\t\t\tconst value: IVersionedValueWithEpoch = await this.cache.get(\n\t\t\t\tthis.fileEntryFromEntry(entry),\n\t\t\t);\n\t\t\t// Version mismatch between what the runtime expects and what it recieved.\n\t\t\t// The cached value should not be used\n\t\t\tif (value === undefined || value.version !== persistedCacheValueVersion) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tassert(value.fluidEpoch !== undefined, 0x1dc /* \"all entries have to have epoch\" */);\n\t\t\tif (this._fluidEpoch === undefined) {\n\t\t\t\tthis.setEpoch(value.fluidEpoch, true, \"cache\");\n\t\t\t\t// Epoch mismatch, the cached value is considerably different from what the current state of\n\t\t\t\t// the runtime and should not be used\n\t\t\t} else if (this._fluidEpoch !== value.fluidEpoch) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Expire the cached snapshot if it's older than snapshotCacheExpiryTimeoutMs and immediately\n\t\t\t// expire all old caches that do not have cacheEntryTime\n\t\t\tif (entry.type === snapshotKey) {\n\t\t\t\tconst cacheTime = value.value?.cacheEntryTime;\n\t\t\t\tconst currentTime = Date.now();\n\t\t\t\tif (\n\t\t\t\t\tcacheTime === undefined ||\n\t\t\t\t\tcurrentTime - cacheTime >= this.snapshotCacheExpiryTimeoutMs\n\t\t\t\t) {\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"odspVersionsCacheExpired\",\n\t\t\t\t\t\tduration: currentTime - cacheTime,\n\t\t\t\t\t\tmaxCacheAgeMs: this.snapshotCacheExpiryTimeoutMs,\n\t\t\t\t\t});\n\t\t\t\t\tawait this.removeEntries();\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value.value;\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"cacheFetchError\", type: entry.type }, error);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tpublic async put(entry: IEntry, value: any) {\n\t\tassert(this._fluidEpoch !== undefined, 0x1dd /* \"no epoch\" */);\n\t\t// For snapshots, the value should have the cacheEntryTime.\n\t\t// This will be used to expire snapshots older than snapshotCacheExpiryTimeoutMs.\n\t\tif (entry.type === snapshotKey) {\n\t\t\tvalue.cacheEntryTime = value.cacheEntryTime ?? Date.now();\n\t\t}\n\t\tconst data: IVersionedValueWithEpoch = {\n\t\t\tvalue,\n\t\t\tversion: persistedCacheValueVersion,\n\t\t\tfluidEpoch: this._fluidEpoch,\n\t\t};\n\t\treturn this.cache.put(this.fileEntryFromEntry(entry), data).catch((error) => {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"cachePutError\", type: entry.type }, error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tpublic async removeEntries(): Promise<void> {\n\t\ttry {\n\t\t\treturn await this.cache.removeEntries(this.fileEntry);\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"removeCacheEntries\" }, error);\n\t\t}\n\t}\n\n\tpublic get fluidEpoch() {\n\t\treturn this._fluidEpoch;\n\t}\n\n\tpublic async validateEpoch(epoch: string | undefined, fetchType: FetchType) {\n\t\tassert(epoch !== undefined, 0x584 /* response should contain epoch */);\n\t\ttry {\n\t\t\tthis.validateEpochFromResponse(epoch, fetchType);\n\t\t} catch (error) {\n\t\t\tawait this.checkForEpochError(error, epoch, fetchType);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Api to fetch the response for given request and parse it as json.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetchAndParseAsJSON<T>(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\treturn this.fetchCore<T>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchAndParseAsJSONHelper,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\t/**\n\t * Api to fetch the response for given request and parse it as json.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetch(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t) {\n\t\treturn this.fetchCore<Response>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchHelper,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate async fetchCore<T>(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: any },\n\t\tfetcher: (url: string, fetchOptions: { [index: string]: any }) => Promise<IOdspResponse<T>>,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t) {\n\t\tconst clientCorrelationId = this.formatClientCorrelationId(fetchReason);\n\t\t// Add epoch in fetch request.\n\t\tthis.addEpochInRequest(fetchOptions, addInBody, clientCorrelationId);\n\t\tlet epochFromResponse: string | undefined;\n\t\treturn this.rateLimiter\n\t\t\t.schedule(async () => fetcher(url, fetchOptions))\n\t\t\t.then((response) => {\n\t\t\t\tepochFromResponse = response.headers.get(\"x-fluid-epoch\");\n\t\t\t\tthis.validateEpochFromResponse(epochFromResponse, fetchType);\n\t\t\t\tresponse.propsToLog.XRequestStatsHeader = clientCorrelationId;\n\t\t\t\treturn response;\n\t\t\t})\n\t\t\t.catch(async (error) => {\n\t\t\t\t// Get the server epoch from error in case we don't have it as if undefined we won't be able\n\t\t\t\t// to mark it as epoch error.\n\t\t\t\tif (epochFromResponse === undefined) {\n\t\t\t\t\tepochFromResponse = (error as IOdspError).serverEpoch;\n\t\t\t\t}\n\t\t\t\tawait this.checkForEpochError(error, epochFromResponse, fetchType);\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// If the error is about location redirection, then we need to generate new resolved url with correct\n\t\t\t\t// location info.\n\t\t\t\tif (\n\t\t\t\t\tisFluidError(error) &&\n\t\t\t\t\terror.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError\n\t\t\t\t) {\n\t\t\t\t\tconst redirectLocation = (error as IOdspErrorAugmentations).redirectLocation;\n\t\t\t\t\tif (redirectLocation !== undefined) {\n\t\t\t\t\t\tconst redirectUrl: IOdspResolvedUrl = patchOdspResolvedUrl(\n\t\t\t\t\t\t\tthis.fileEntry.resolvedUrl,\n\t\t\t\t\t\t\tredirectLocation,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst locationRedirectionError = new LocationRedirectionError(\n\t\t\t\t\t\t\terror.message,\n\t\t\t\t\t\t\tredirectUrl,\n\t\t\t\t\t\t\t{ driverVersion, redirectLocation },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlocationRedirectionError.addTelemetryProperties(\n\t\t\t\t\t\t\terror.getTelemetryProperties(),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthrow locationRedirectionError;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tconst fluidError = normalizeError(error, {\n\t\t\t\t\tprops: { XRequestStatsHeader: clientCorrelationId },\n\t\t\t\t});\n\t\t\t\tthrow fluidError;\n\t\t\t});\n\t}\n\n\t/**\n\t * Api to fetch the response as it is for given request.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetchArray(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: any },\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t) {\n\t\treturn this.fetchCore<ArrayBuffer>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchArray,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate addEpochInRequest(\n\t\tfetchOptions: RequestInit,\n\t\taddInBody: boolean,\n\t\tclientCorrelationId: string,\n\t) {\n\t\tconst isClpCompliantApp = getOdspResolvedUrl(this.fileEntry.resolvedUrl).isClpCompliantApp;\n\t\tif (addInBody) {\n\t\t\tconst headers: { [key: string]: string } = {};\n\t\t\theaders[\"X-RequestStats\"] = clientCorrelationId;\n\t\t\tif (this.fluidEpoch !== undefined) {\n\t\t\t\theaders[\"x-fluid-epoch\"] = this.fluidEpoch;\n\t\t\t}\n\t\t\tif (isClpCompliantApp) {\n\t\t\t\theaders[ClpCompliantAppHeader.isClpCompliantApp] = isClpCompliantApp.toString();\n\t\t\t}\n\t\t\tthis.addParamInBody(fetchOptions, headers);\n\t\t} else {\n\t\t\tconst addHeader = (key: string, val: string) => {\n\t\t\t\tfetchOptions.headers = {\n\t\t\t\t\t...fetchOptions.headers,\n\t\t\t\t};\n\t\t\t\tassert(\n\t\t\t\t\tfetchOptions.headers !== undefined,\n\t\t\t\t\t0x282 /* \"Headers should be present now\" */,\n\t\t\t\t);\n\t\t\t\tfetchOptions.headers[key] = val;\n\t\t\t};\n\t\t\taddHeader(\"X-RequestStats\", clientCorrelationId);\n\t\t\tif (this.fluidEpoch !== undefined) {\n\t\t\t\taddHeader(\"x-fluid-epoch\", this.fluidEpoch);\n\t\t\t}\n\t\t\tif (isClpCompliantApp) {\n\t\t\t\taddHeader(ClpCompliantAppHeader.isClpCompliantApp, isClpCompliantApp.toString());\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate addParamInBody(fetchOptions: RequestInit, headers: { [key: string]: string }) {\n\t\t// We use multi part form request for post body where we want to use this.\n\t\t// So extract the form boundary to mark the end of form.\n\t\tconst body = fetchOptions.body;\n\t\tassert(typeof body === \"string\", 0x21d /* \"body is not string\" */);\n\t\tconst splitBody = body.split(\"\\r\\n\");\n\t\tconst firstLine = splitBody.shift();\n\t\tassert(firstLine?.startsWith(\"--\") === true, 0x21e /* \"improper boundary format\" */);\n\t\tconst formParams = [firstLine];\n\t\tObject.entries(headers).forEach(([key, value]) => {\n\t\t\tformParams.push(`${key}: ${value}`);\n\t\t});\n\t\tsplitBody.forEach((value: string) => {\n\t\t\tformParams.push(value);\n\t\t});\n\t\tfetchOptions.body = formParams.join(\"\\r\\n\");\n\t}\n\n\tprivate formatClientCorrelationId(fetchReason?: string) {\n\t\tconst items: string[] = [\n\t\t\t`driverId=${this.driverId}`,\n\t\t\t`RequestNumber=${this.networkCallNumber++}`,\n\t\t\t`driverVersion=${driverVersion}`,\n\t\t\t`isSummarizer=${this.clientIsSummarizer}`,\n\t\t];\n\t\tif (fetchReason !== undefined) {\n\t\t\titems.push(`fetchReason=${fetchReason}`);\n\t\t}\n\t\treturn items.join(\", \");\n\t}\n\n\tprotected validateEpochFromResponse(\n\t\tepochFromResponse: string | undefined,\n\t\tfetchType: FetchTypeInternal,\n\t\tfromCache: boolean = false,\n\t) {\n\t\tconst error = this.checkForEpochErrorCore(epochFromResponse);\n\t\tif (error !== undefined) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (epochFromResponse !== undefined) {\n\t\t\tif (this._fluidEpoch === undefined) {\n\t\t\t\tthis.setEpoch(epochFromResponse, fromCache, fetchType);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async checkForEpochError(\n\t\terror: unknown,\n\t\tepochFromResponse: string | null | undefined,\n\t\tfetchType: FetchTypeInternal,\n\t\tfromCache: boolean = false,\n\t) {\n\t\tif (isFluidError(error) && error.errorType === DriverErrorType.fileOverwrittenInStorage) {\n\t\t\tconst epochError = this.checkForEpochErrorCore(epochFromResponse);\n\t\t\tif (epochError !== undefined) {\n\t\t\t\tepochError.addTelemetryProperties({\n\t\t\t\t\tfromCache,\n\t\t\t\t\tfetchType,\n\t\t\t\t});\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"fileOverwrittenInStorage\" }, epochError);\n\t\t\t\t// If the epoch mismatches, then clear all entries for such file entry from cache.\n\t\t\t\tawait this.removeEntries();\n\t\t\t\tthrow epochError;\n\t\t\t}\n\t\t\t// If it was categorized as epoch error but the epoch returned in response matches with the client epoch\n\t\t\t// then it was coherency 409, so rethrow it as throttling error so that it can retried. Default throttling\n\t\t\t// time is 1s.\n\t\t\tconst newError = wrapError(error, (message: string) => {\n\t\t\t\treturn new ThrottlingError(`Coherency 409: ${message}`, 1 /* retryAfterSeconds */, {\n\t\t\t\t\t[Odsp409Error]: true,\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t});\n\t\t\tthrow newError;\n\t\t}\n\t}\n\n\tprivate checkForEpochErrorCore(epochFromResponse: string | null | undefined) {\n\t\t// If epoch is undefined, then don't compare it because initially for createNew or TreesLatest\n\t\t// initializes this value. Sometimes response does not contain epoch as it is still in\n\t\t// implementation phase at server side. In that case also, don't compare it with our epoch value.\n\t\tif (this.fluidEpoch && epochFromResponse && this.fluidEpoch !== epochFromResponse) {\n\t\t\t// This is similar in nature to how fluidEpochMismatchError (409) is handled.\n\t\t\t// Difference - client detected mismatch, instead of server detecting it.\n\t\t\treturn new NonRetryableError(\n\t\t\t\t\"Epoch mismatch\",\n\t\t\t\tDriverErrorType.fileOverwrittenInStorage,\n\t\t\t\t{ driverVersion, serverEpoch: epochFromResponse, clientEpoch: this.fluidEpoch },\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate fileEntryFromEntry(entry: IEntry): ICacheEntry {\n\t\treturn { ...entry, file: this.fileEntry };\n\t}\n}\n\nexport class EpochTrackerWithRedemption extends EpochTracker {\n\tprivate readonly treesLatestDeferral = new Deferred<void>();\n\n\tconstructor(\n\t\tprotected readonly cache: IPersistedCache,\n\t\tprotected readonly fileEntry: IFileEntry,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tprotected readonly clientIsSummarizer?: boolean,\n\t) {\n\t\tsuper(cache, fileEntry, logger, clientIsSummarizer);\n\t\t// Handles the rejected promise within treesLatestDeferral.\n\t\tthis.treesLatestDeferral.promise.catch(() => {});\n\t}\n\n\tprotected validateEpochFromResponse(\n\t\tepochFromResponse: string | undefined,\n\t\tfetchType: FetchType,\n\t\tfromCache: boolean = false,\n\t) {\n\t\tsuper.validateEpochFromResponse(epochFromResponse, fetchType, fromCache);\n\n\t\t// Any successful call means we have access to a file, i.e. any redemption that was required already happened.\n\t\t// That covers cases of \"treesLatest\" as well as \"getVersions\" or \"createFile\" - all the ways we can start\n\t\t// exploring a file.\n\t\tthis.treesLatestDeferral.resolve();\n\t}\n\n\tpublic async get(entry: IEntry): Promise<any> {\n\t\tlet result = super.get(entry);\n\n\t\t// equivalence of what happens in fetchAndParseAsJSON()\n\t\tif (entry.type === snapshotKey) {\n\t\t\tresult = result\n\t\t\t\t.then((value) => {\n\t\t\t\t\t// If there is nothing in cache, we need to wait for network call to complete (and do redemption)\n\t\t\t\t\t// Otherwise file was redeemed in prior session, so if joinSession failed, we should not retry\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\tthis.treesLatestDeferral.resolve();\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\t\t\treturn value;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.treesLatestDeferral.reject(error);\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic async fetchAndParseAsJSON<T>(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: any },\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\t// Optimize the flow if we know that treesLatestDeferral was already completed by the timer we started\n\t\t// joinSession call. If we did - there is no reason to repeat the call as it will fail with same error.\n\t\tconst completed = this.treesLatestDeferral.isCompleted;\n\n\t\ttry {\n\t\t\treturn await super.fetchAndParseAsJSON<T>(\n\t\t\t\turl,\n\t\t\t\tfetchOptions,\n\t\t\t\tfetchType,\n\t\t\t\taddInBody,\n\t\t\t\tfetchReason,\n\t\t\t);\n\t\t} catch (error: any) {\n\t\t\t// Only handling here treesLatest. If createFile failed, we should never try to do joinSession.\n\t\t\t// Similar, if getVersions failed, we should not do any further storage calls.\n\t\t\t// So treesLatest is the only call that can have parallel joinSession request.\n\t\t\tif (fetchType === \"treesLatest\") {\n\t\t\t\tthis.treesLatestDeferral.reject(error);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfetchType !== \"joinSession\" ||\n\t\t\t\terror.statusCode < 401 ||\n\t\t\t\terror.statusCode > 404 ||\n\t\t\t\tcompleted\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\t// It is joinSession failing with 401..404 error\n\t\t// Repeat after waiting for treeLatest succeeding (or fail if it failed).\n\t\t// No special handling after first call - if file has been deleted, then it's game over.\n\n\t\t// Ensure we have some safety here - we do not want to deadlock if we got logic somewhere wrong.\n\t\t// If we waited too long, we will log error event and proceed with call.\n\t\t// It may result in failure for user, but refreshing document would address it.\n\t\t// Thus we use rather long timeout (not to get these failures as much as possible), but not large enough\n\t\t// to unblock the process.\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{ eventName: \"JoinSessionSyncWait\" },\n\t\t\tasync (event) => {\n\t\t\t\tconst timeoutRes = 51; // anything will work here\n\t\t\t\tlet timer: ReturnType<typeof setTimeout>;\n\t\t\t\tconst timeoutP = new Promise<number>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\t\tresolve(timeoutRes);\n\t\t\t\t\t}, 15000);\n\t\t\t\t});\n\t\t\t\tconst res = await Promise.race([\n\t\t\t\t\ttimeoutP,\n\t\t\t\t\t// cancel timeout to unblock UTs (otherwise Node process does not exit for 15 sec)\n\t\t\t\t\tthis.treesLatestDeferral.promise.finally(() => clearTimeout(timer)),\n\t\t\t\t]);\n\t\t\t\tif (res === timeoutRes) {\n\t\t\t\t\tevent.cancel();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t);\n\t\treturn super.fetchAndParseAsJSON<T>(url, fetchOptions, fetchType, addInBody);\n\t}\n}\n\n/**\n * @public\n */\nexport interface ICacheAndTracker {\n\tcache: IOdspCache;\n\tepochTracker: EpochTracker;\n}\n\nexport function createOdspCacheAndTracker(\n\tpersistedCacheArg: IPersistedCache,\n\tnonpersistentCache: INonPersistentCache,\n\tfileEntry: IFileEntry,\n\tlogger: ITelemetryLoggerExt,\n\tclientIsSummarizer?: boolean,\n): ICacheAndTracker {\n\tconst epochTracker = new EpochTrackerWithRedemption(\n\t\tpersistedCacheArg,\n\t\tfileEntry,\n\t\tlogger,\n\t\tclientIsSummarizer,\n\t);\n\treturn {\n\t\tcache: {\n\t\t\t...nonpersistentCache,\n\t\t\tpersistedCache: epochTracker,\n\t\t},\n\t\tepochTracker,\n\t};\n}\n"]}
@@ -14,4 +14,4 @@ const node_fetch_1 = __importDefault(require("node-fetch"));
14
14
  // in the browser's types from 'lib.dom.d.ts'.
15
15
  const fetch = async (request, config) => (0, node_fetch_1.default)(request, config);
16
16
  exports.fetch = fetch;
17
- //# sourceMappingURL=fetch.js.map
17
+ //# sourceMappingURL=fetch.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.cjs","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,4DAIoB;AAEpB,yFAAyF;AACzF,gGAAgG;AAChG,8CAA8C;AACvC,MAAM,KAAK,GAAG,KAAK,EAAE,OAAoB,EAAE,MAAoB,EAAqB,EAAE,CAC5F,IAAA,oBAAS,EAAC,OAA2B,EAAE,MAA0B,CAAwB,CAAC;AAD9E,QAAA,KAAK,SACyE","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tdefault as nodeFetch,\n\tRequestInfo as FetchRequestInfo,\n\tRequestInit as FetchRequestInit,\n} from \"node-fetch\";\n\n// The only purpose of this helper is to work around the slight misalignments between the\n// Browser's fetch API and the 'node-fetch' package by wrapping the call to the 'node-fetch' API\n// in the browser's types from 'lib.dom.d.ts'.\nexport const fetch = async (request: RequestInfo, config?: RequestInit): Promise<Response> =>\n\tnodeFetch(request as FetchRequestInfo, config as FetchRequestInit) as unknown as Response;\n"]}
@@ -14,13 +14,13 @@ const driver_definitions_1 = require("@fluidframework/driver-definitions");
14
14
  const odsp_driver_definitions_1 = require("@fluidframework/odsp-driver-definitions");
15
15
  const driver_utils_1 = require("@fluidframework/driver-utils");
16
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");
17
+ const contracts_1 = require("./contracts.cjs");
18
+ const getQueryString_1 = require("./getQueryString.cjs");
19
+ const getUrlAndHeadersWithAuth_1 = require("./getUrlAndHeadersWithAuth.cjs");
20
+ const odspUtils_1 = require("./odspUtils.cjs");
21
+ const odspSnapshotParser_1 = require("./odspSnapshotParser.cjs");
22
+ const compactSnapshotParser_1 = require("./compactSnapshotParser.cjs");
23
+ const packageVersion_1 = require("./packageVersion.cjs");
24
24
  /**
25
25
  * Enum to support different types of snapshot formats.
26
26
  * @public
@@ -438,4 +438,4 @@ function getEncodedShareUrl(url) {
438
438
  encodedUrl = "u!".concat(encodedUrl);
439
439
  return encodedUrl;
440
440
  }
441
- //# sourceMappingURL=fetchSnapshot.js.map
441
+ //# sourceMappingURL=fetchSnapshot.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchSnapshot.cjs","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,+CAKqB;AACrB,yDAAkD;AAClD,6EAAsE;AACtE,+CAQqB;AAErB,iEAAiF;AACjF,uEAIiC;AAEjC,yDAA8C;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,MA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Z,aAAa,EACb,IAAI,EACJ,YAAY,CACZ,IAAI,IAAA,uBAAW,EAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;IAErC,OAAO;QACN,YAAY;QACZ,cAAc,EAAE,OAAO;QACvB,UAAU,EAAE,GAAG;KACf,CAAC;AACH,CAAC;AAjED,4CAiEC;AAED,SAAS,wBAAwB,CAAC,eAAiC,EAAE,KAAU;IAC9E,IACC,eAAe,CAAC,aAAa,EAAE,mBAAmB,KAAK,SAAS;QAChE,OAAO,KAAK,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 * @public\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.sendErrorEvent(\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"]}
@@ -9,10 +9,10 @@ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
9
9
  const core_utils_1 = require("@fluidframework/core-utils");
10
10
  const driver_utils_1 = require("@fluidframework/driver-utils");
11
11
  const driver_definitions_1 = require("@fluidframework/driver-definitions");
12
- const getUrlAndHeadersWithAuth_1 = require("./getUrlAndHeadersWithAuth");
13
- const odspUtils_1 = require("./odspUtils");
14
- const packageVersion_1 = require("./packageVersion");
15
- const retryUtils_1 = require("./retryUtils");
12
+ const getUrlAndHeadersWithAuth_1 = require("./getUrlAndHeadersWithAuth.cjs");
13
+ const odspUtils_1 = require("./odspUtils.cjs");
14
+ const packageVersion_1 = require("./packageVersion.cjs");
15
+ const retryUtils_1 = require("./retryUtils.cjs");
16
16
  // Store cached responses for the lifetime of web session as file link remains the same for given file item
17
17
  const fileLinkCache = new Map();
18
18
  /**
@@ -131,4 +131,4 @@ async function getFileItemLite(getToken, odspUrlParts, logger, forceAccessTokenV
131
131
  return fileItem;
132
132
  });
133
133
  }
134
- //# sourceMappingURL=getFileLink.js.map
134
+ //# sourceMappingURL=getFileLink.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFileLink.cjs","sourceRoot":"","sources":["../src/getFileLink.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAAwF;AACxF,2DAAoD;AACpD,+DAA+E;AAC/E,2EAAqE;AAMrE,6EAAsE;AACtE,+CAIqB;AACrB,yDAA+D;AAC/D,iDAAgG;AAEhG,2GAA2G;AAC3G,MAAM,aAAa,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEzD;;;;;;;;;;GAUG;AACI,KAAK,UAAU,WAAW,CAChC,QAAqD,EACrD,YAA2B,EAC3B,MAA2B;IAE3B,MAAM,QAAQ,GAAG,GAAG,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;IAC1F,MAAM,uBAAuB,GAAG,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5D,IAAI,uBAAuB,KAAK,SAAS,EAAE;QAC1C,OAAO,uBAAuB,CAAC;KAC/B;IAED,MAAM,iBAAiB,GAAG,KAAK;QAC9B,IAAI,YAAoB,CAAC;QACzB,IAAI;YACH,IAAI,UAAU,GAAG,CAAC,CAAC;YACnB,YAAY,GAAG,MAAM,IAAA,2BAAY,EAChC,KAAK,IAAI,EAAE,CACV,IAAA,yBAAgD,EAC/C,KAAK,IAAI,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,EA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,sCAAsC,CACtC,CAAC;YACF,MAAM,WAAW,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;YAC/C,MAAM,QAAQ,GAAG,MAAM,IAAA,uBAAW,EAAC,GAAG,EAAE,WAAW,CAAC,CAAC;YACrD,eAAe,GAAG,QAAQ,CAAC,UAAU,CAAC;YAEtC,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACnD,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE;gBAClC,sDAAsD;gBACtD,MAAM,IAAI,gCAAiB,CAC1B,oCAAoC,EACpC,oCAAe,CAAC,uBAAuB,EACvC,EAAE,aAAa,EAAb,2BAAa,EAAE,CACjB,CAAC;aACF;YACD,OAAO,YAAY,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5C,OAAO,QAAQ,CAAC;IACjB,CAAC,CACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { NonRetryableError, runWithRetry } from \"@fluidframework/driver-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n\tIOdspUrlParts,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\ttoInstrumentedOdspTokenFetcher,\n} from \"./odspUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { runWithRetry as runWithRetryForCoherencyAndServiceReadOnlyErrors } from \"./retryUtils\";\n\n// Store cached responses for the lifetime of web session as file link remains the same for given file item\nconst fileLinkCache = new Map<string, Promise<string>>();\n\n/**\n * Returns file link for a file with given drive and item ids.\n * Scope needed: files.readwrite.all.\n * This function keeps retrying if it gets a retriable error or wait for some delay if it gets a\n * throttling error. In future, we are thinking of app allowing to pass some cancel token, with which\n * we would be able to stop retrying.\n * @param getToken - used to fetch access tokens needed to execute operation\n * @param odspUrlParts - object describing file storage identity\n * @param logger - used to log results of operation, including any error\n * @returns Promise which resolves to file link url when successful; otherwise, undefined.\n */\nexport async function getFileLink(\n\tgetToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\todspUrlParts: IOdspUrlParts,\n\tlogger: ITelemetryLoggerExt,\n): Promise<string> {\n\tconst cacheKey = `${odspUrlParts.siteUrl}_${odspUrlParts.driveId}_${odspUrlParts.itemId}`;\n\tconst maybeFileLinkCacheEntry = fileLinkCache.get(cacheKey);\n\tif (maybeFileLinkCacheEntry !== undefined) {\n\t\treturn maybeFileLinkCacheEntry;\n\t}\n\n\tconst fileLinkGenerator = async function () {\n\t\tlet fileLinkCore: string;\n\t\ttry {\n\t\t\tlet retryCount = 0;\n\t\t\tfileLinkCore = await runWithRetry(\n\t\t\t\tasync () =>\n\t\t\t\t\trunWithRetryForCoherencyAndServiceReadOnlyErrors(\n\t\t\t\t\t\tasync () => getFileLinkCore(getToken, odspUrlParts, logger),\n\t\t\t\t\t\t\"getFileLinkCore\",\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t),\n\t\t\t\t\"getShareLink\",\n\t\t\t\tlogger,\n\t\t\t\t{\n\t\t\t\t\tonRetry(delayInMs: number, error: any) {\n\t\t\t\t\t\tretryCount++;\n\t\t\t\t\t\tif (retryCount === 5) {\n\t\t\t\t\t\t\tif (error !== undefined && typeof error === \"object\") {\n\t\t\t\t\t\t\t\terror.canRetry = false;\n\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t} catch (err) {\n\t\t\t// Delete from the cache to permit retrying later.\n\t\t\tfileLinkCache.delete(cacheKey);\n\t\t\tthrow err;\n\t\t}\n\n\t\t// We are guaranteed to run the getFileLinkCore at least once with successful result (which must be a string)\n\t\tassert(\n\t\t\tfileLinkCore !== undefined,\n\t\t\t0x292 /* \"Unexpected undefined result from getFileLinkCore\" */,\n\t\t);\n\t\treturn fileLinkCore;\n\t};\n\tconst fileLink = fileLinkGenerator();\n\tfileLinkCache.set(cacheKey, fileLink);\n\treturn fileLink;\n}\n\nasync function getFileLinkCore(\n\tgetToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\todspUrlParts: IOdspUrlParts,\n\tlogger: ITelemetryLoggerExt,\n): Promise<string> {\n\tconst fileItem = await getFileItemLite(getToken, odspUrlParts, logger, true);\n\n\t// ODSP link requires extra call to return link that is resistant to file being renamed or moved to different folder\n\treturn PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{ eventName: \"odspFileLink\", requestName: \"getSharingInformation\" },\n\t\tasync (event) => {\n\t\t\tlet attempts = 0;\n\t\t\tlet additionalProps;\n\t\t\tconst fileLink = await getWithRetryForTokenRefresh(async (options) => {\n\t\t\t\tattempts++;\n\t\t\t\tconst storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n\t\t\t\t\tlogger,\n\t\t\t\t\todspUrlParts,\n\t\t\t\t\tgetToken,\n\t\t\t\t\ttrue /* throwOnNullToken */,\n\t\t\t\t);\n\t\t\t\tconst storageToken = await storageTokenFetcher(options, \"GetFileLinkCore\");\n\t\t\t\tassert(\n\t\t\t\t\tstorageToken !== null,\n\t\t\t\t\t0x2bb /* \"Instrumented token fetcher with throwOnNullToken = true should never return null\" */,\n\t\t\t\t);\n\n\t\t\t\t// IMPORTANT: In past we were using GetFileByUrl() API to get to the list item that was corresponding\n\t\t\t\t// to the file. This was intentionally replaced with GetFileById() to solve the following issue:\n\t\t\t\t// GetFileByUrl() uses webDavUrl to locate list item. This API does not work for Consumer scenarios\n\t\t\t\t// where webDavUrl is constructed using legacy ODC format for backward compatibility reasons.\n\t\t\t\t// GetFileByUrl() does not understand that format and thus fails. GetFileById() relies on file item\n\t\t\t\t// unique guid (sharepointIds.listItemUniqueId) and it works uniformly across Consumer and Commercial.\n\t\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\t\t`${\n\t\t\t\t\t\todspUrlParts.siteUrl\n\t\t\t\t\t}/_api/web/GetFileById(@a1)/ListItemAllFields/GetSharingInformation?@a1=guid${encodeURIComponent(\n\t\t\t\t\t\t`'${fileItem.sharepointIds.listItemUniqueId}'`,\n\t\t\t\t\t)}`,\n\t\t\t\t\tstorageToken,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t\tconst requestInit = {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"Content-Type\": \"application/json;odata=verbose\",\n\t\t\t\t\t\t\"Accept\": \"application/json;odata=verbose\",\n\t\t\t\t\t\t...headers,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tconst response = await fetchHelper(url, requestInit);\n\t\t\t\tadditionalProps = response.propsToLog;\n\n\t\t\t\tconst sharingInfo = await response.content.json();\n\t\t\t\tconst directUrl = sharingInfo?.d?.directUrl;\n\t\t\t\tif (typeof directUrl !== \"string\") {\n\t\t\t\t\t// This will retry once in getWithRetryForTokenRefresh\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\"Malformed GetSharingInformation response\",\n\t\t\t\t\t\tDriverErrorType.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn directUrl;\n\t\t\t});\n\t\t\tevent.end({ ...additionalProps, attempts });\n\t\t\treturn fileLink;\n\t\t},\n\t);\n}\n\n/**\n * Sharepoint Ids Interface\n */\ninterface IGraphSharepointIds {\n\tlistId: string;\n\tlistItemId: string;\n\tlistItemUniqueId: string;\n\tsiteId: string;\n\tsiteUrl: string;\n\twebId: string;\n}\n\n/**\n * This represents a lite version of file item containing only select file properties\n */\ninterface FileItemLite {\n\twebUrl: string;\n\twebDavUrl: string;\n\tsharepointIds: IGraphSharepointIds;\n}\n\nconst isFileItemLite = (maybeFileItemLite: any): maybeFileItemLite is FileItemLite =>\n\ttypeof maybeFileItemLite.webUrl === \"string\" &&\n\ttypeof maybeFileItemLite.webDavUrl === \"string\" &&\n\ttypeof maybeFileItemLite.sharepointIds === \"object\";\n\nasync function getFileItemLite(\n\tgetToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\todspUrlParts: IOdspUrlParts,\n\tlogger: ITelemetryLoggerExt,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<FileItemLite> {\n\treturn PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{ eventName: \"odspFileLink\", requestName: \"getFileItemLite\" },\n\t\tasync (event) => {\n\t\t\tlet attempts = 0;\n\t\t\tlet additionalProps;\n\t\t\tconst fileItem = await getWithRetryForTokenRefresh(async (options) => {\n\t\t\t\tattempts++;\n\t\t\t\tconst { siteUrl, driveId, itemId } = odspUrlParts;\n\t\t\t\tconst storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n\t\t\t\t\tlogger,\n\t\t\t\t\todspUrlParts,\n\t\t\t\t\tgetToken,\n\t\t\t\t\ttrue /* throwOnNullToken */,\n\t\t\t\t);\n\t\t\t\tconst storageToken = await storageTokenFetcher(options, \"GetFileItemLite\");\n\t\t\t\tassert(\n\t\t\t\t\tstorageToken !== null,\n\t\t\t\t\t0x2bc /* \"Instrumented token fetcher with throwOnNullToken =true should never return null\" */,\n\t\t\t\t);\n\n\t\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\t\t`${siteUrl}/_api/v2.0/drives/${driveId}/items/${itemId}?select=webUrl,webDavUrl,sharepointIds`,\n\t\t\t\t\tstorageToken,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\tconst requestInit = { method: \"GET\", headers };\n\t\t\t\tconst response = await fetchHelper(url, requestInit);\n\t\t\t\tadditionalProps = response.propsToLog;\n\n\t\t\t\tconst responseJson = await response.content.json();\n\t\t\t\tif (!isFileItemLite(responseJson)) {\n\t\t\t\t\t// This will retry once in getWithRetryForTokenRefresh\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\"Malformed getFileItemLite response\",\n\t\t\t\t\t\tDriverErrorType.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn responseJson;\n\t\t\t});\n\t\t\tevent.end({ ...additionalProps, attempts });\n\t\t\treturn fileItem;\n\t\t},\n\t);\n}\n"]}
@@ -16,4 +16,4 @@ function getQueryString(queryParams) {
16
16
  return queryString;
17
17
  }
18
18
  exports.getQueryString = getQueryString;
19
- //# sourceMappingURL=getQueryString.js.map
19
+ //# sourceMappingURL=getQueryString.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getQueryString.cjs","sourceRoot":"","sources":["../src/getQueryString.ts"],"names":[],"mappings":";;;AAMA;;;GAGG;AACH,SAAgB,cAAc,CAC7B,WAAkE;IAElE,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QAC3C,IAAI,WAAW,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;YACnC,MAAM,SAAS,GAAG,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YACjD,WAAW,IAAI,GAAG,SAAS,GAAG,GAAG,IAAI,kBAAkB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;SAC5E;KACD;IAED,OAAO,WAAW,CAAC;AACpB,CAAC;AAZD,wCAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { ISnapshotOptions } from \"@fluidframework/odsp-driver-definitions\";\n\n/**\n * Generates query string from the given query parameters.\n * @param queryParams - Query parameters from which to create a query.\n */\nexport function getQueryString(\n\tqueryParams: { [key: string]: string | number } | ISnapshotOptions,\n): string {\n\tlet queryString = \"\";\n\tfor (const key of Object.keys(queryParams)) {\n\t\tif (queryParams[key] !== undefined) {\n\t\t\tconst startChar = queryString === \"\" ? \"?\" : \"&\";\n\t\t\tqueryString += `${startChar}${key}=${encodeURIComponent(queryParams[key])}`;\n\t\t}\n\t}\n\n\treturn queryString;\n}\n"]}
@@ -39,4 +39,4 @@ token, forceAccessTokenViaAuthorizationHeader) {
39
39
  };
40
40
  }
41
41
  exports.getUrlAndHeadersWithAuth = getUrlAndHeadersWithAuth;
42
- //# sourceMappingURL=getUrlAndHeadersWithAuth.js.map
42
+ //# sourceMappingURL=getUrlAndHeadersWithAuth.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getUrlAndHeadersWithAuth.cjs","sourceRoot":"","sources":["../src/getUrlAndHeadersWithAuth.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,SAAgB,wBAAwB,CACvC,GAAW;AACX,kDAAkD;AAClD,KAAoB,EACpB,sCAA+C;IAE/C,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACjC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;KAC5B;IAED,IAAI,CAAC,sCAAsC,EAAE;QAC5C,4FAA4F;QAC5F,6DAA6D;QAC7D,MAAM,+BAA+B,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACrD,4FAA4F;QAC5F,qCAAqC;QACrC,+BAA+B,CAAC,YAAY,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QACxE,mFAAmF;QACnF,wGAAwG;QACxG,4EAA4E;QAC5E,2GAA2G;QAC3G,0GAA0G;QAC1G,gBAAgB;QAChB,IAAI,+BAA+B,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,EAAE;YAC1D,OAAO;gBACN,OAAO,EAAE,EAAE;gBACX,GAAG,EAAE,+BAA+B,CAAC,IAAI;aACzC,CAAC;SACF;KACD;IAED,OAAO;QACN,OAAO,EAAE;YACR,aAAa,EAAE,UAAU,KAAK,EAAE;SAChC;QACD,GAAG;KACH,CAAC;AACH,CAAC;AArCD,4DAqCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport function getUrlAndHeadersWithAuth(\n\turl: string,\n\t// eslint-disable-next-line @rushstack/no-new-null\n\ttoken: string | null,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n): { url: string; headers: { [index: string]: string } } {\n\tif (!token || token.length === 0) {\n\t\treturn { url, headers: {} };\n\t}\n\n\tif (!forceAccessTokenViaAuthorizationHeader) {\n\t\t// Pass access token via query string: this will make request be treated as 'simple' request\n\t\t// which does not require OPTIONS call as part of CORS check.\n\t\tconst urlWithAccessTokenInQueryString = new URL(url);\n\t\t// IMPORTANT: Do not apply encodeURIComponent to token, param value is automatically encoded\n\t\t// when set via URLSearchParams class\n\t\turlWithAccessTokenInQueryString.searchParams.set(\"access_token\", token);\n\t\t// ODSP APIs have a limitation that the query string cannot exceed 2048 characters.\n\t\t// If the query string exceeds 2048, we have to fall back to sending the access token as a header, which\n\t\t// has a negative performance implication as it adds a performance overhead.\n\t\t// NOTE: URL.search.length value includes '?' symbol and it is unclear whether backend logic which enforces\n\t\t// query length limit accounts for it. This logic errs on side of caution and includes that key in overall\n\t\t// query length.\n\t\tif (urlWithAccessTokenInQueryString.search.length <= 2048) {\n\t\t\treturn {\n\t\t\t\theaders: {},\n\t\t\t\turl: urlWithAccessTokenInQueryString.href,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn {\n\t\theaders: {\n\t\t\tAuthorization: `Bearer ${token}`,\n\t\t},\n\t\turl,\n\t};\n}\n"]}
@@ -6,52 +6,52 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.parseCompactSnapshotResponse = exports.SnapshotFormatSupportType = exports.storeLocatorInOdspUrl = exports.locatorQueryParamName = exports.getLocatorFromOdspUrl = exports.encodeOdspFluidDataStoreLocator = exports.OdspDriverUrlResolverForShareLink = exports.OdspDriverUrlResolver = exports.createOdspCreateContainerRequest = exports.OdspDocumentServiceFactoryWithCodeSplit = exports.OdspDocumentServiceFactoryCore = exports.OdspDocumentServiceFactory = exports.createLocalOdspDocumentServiceFactory = exports.prefetchLatestSnapshot = exports.isSpoUrl = exports.isOdcUrl = exports.isOdcOrigin = exports.getOdspUrlParts = exports.getApiRoot = exports.getHashedDocumentId = exports.createOdspUrl = exports.checkUrl = exports.SharingLinkHeader = exports.ClpCompliantAppHeader = exports.OdcFileSiteOrigin = exports.OdcApiSiteOrigin = void 0;
8
8
  // Constants
9
- var constants_1 = require("./constants");
9
+ var constants_1 = require("./constants.cjs");
10
10
  Object.defineProperty(exports, "OdcApiSiteOrigin", { enumerable: true, get: function () { return constants_1.OdcApiSiteOrigin; } });
11
11
  Object.defineProperty(exports, "OdcFileSiteOrigin", { enumerable: true, get: function () { return constants_1.OdcFileSiteOrigin; } });
12
- var contractsPublic_1 = require("./contractsPublic");
12
+ var contractsPublic_1 = require("./contractsPublic.cjs");
13
13
  Object.defineProperty(exports, "ClpCompliantAppHeader", { enumerable: true, get: function () { return contractsPublic_1.ClpCompliantAppHeader; } });
14
14
  Object.defineProperty(exports, "SharingLinkHeader", { enumerable: true, get: function () { return contractsPublic_1.SharingLinkHeader; } });
15
15
  // public utils
16
- var checkUrl_1 = require("./checkUrl");
16
+ var checkUrl_1 = require("./checkUrl.cjs");
17
17
  Object.defineProperty(exports, "checkUrl", { enumerable: true, get: function () { return checkUrl_1.checkUrl; } });
18
- var createOdspUrl_1 = require("./createOdspUrl");
18
+ var createOdspUrl_1 = require("./createOdspUrl.cjs");
19
19
  Object.defineProperty(exports, "createOdspUrl", { enumerable: true, get: function () { return createOdspUrl_1.createOdspUrl; } });
20
- var odspPublicUtils_1 = require("./odspPublicUtils");
20
+ var odspPublicUtils_1 = require("./odspPublicUtils.cjs");
21
21
  Object.defineProperty(exports, "getHashedDocumentId", { enumerable: true, get: function () { return odspPublicUtils_1.getHashedDocumentId; } });
22
- var odspUrlHelper_1 = require("./odspUrlHelper");
22
+ var odspUrlHelper_1 = require("./odspUrlHelper.cjs");
23
23
  Object.defineProperty(exports, "getApiRoot", { enumerable: true, get: function () { return odspUrlHelper_1.getApiRoot; } });
24
24
  Object.defineProperty(exports, "getOdspUrlParts", { enumerable: true, get: function () { return odspUrlHelper_1.getOdspUrlParts; } });
25
25
  Object.defineProperty(exports, "isOdcOrigin", { enumerable: true, get: function () { return odspUrlHelper_1.isOdcOrigin; } });
26
26
  Object.defineProperty(exports, "isOdcUrl", { enumerable: true, get: function () { return odspUrlHelper_1.isOdcUrl; } });
27
27
  Object.defineProperty(exports, "isSpoUrl", { enumerable: true, get: function () { return odspUrlHelper_1.isSpoUrl; } });
28
28
  // prefetch latest snapshot before container load
29
- var prefetchLatestSnapshot_1 = require("./prefetchLatestSnapshot");
29
+ var prefetchLatestSnapshot_1 = require("./prefetchLatestSnapshot.cjs");
30
30
  Object.defineProperty(exports, "prefetchLatestSnapshot", { enumerable: true, get: function () { return prefetchLatestSnapshot_1.prefetchLatestSnapshot; } });
31
31
  // Factory
32
- var odspDocumentServiceFactory_1 = require("./odspDocumentServiceFactory");
32
+ var odspDocumentServiceFactory_1 = require("./odspDocumentServiceFactory.cjs");
33
33
  Object.defineProperty(exports, "createLocalOdspDocumentServiceFactory", { enumerable: true, get: function () { return odspDocumentServiceFactory_1.createLocalOdspDocumentServiceFactory; } });
34
34
  Object.defineProperty(exports, "OdspDocumentServiceFactory", { enumerable: true, get: function () { return odspDocumentServiceFactory_1.OdspDocumentServiceFactory; } });
35
- var odspDocumentServiceFactoryCore_1 = require("./odspDocumentServiceFactoryCore");
35
+ var odspDocumentServiceFactoryCore_1 = require("./odspDocumentServiceFactoryCore.cjs");
36
36
  Object.defineProperty(exports, "OdspDocumentServiceFactoryCore", { enumerable: true, get: function () { return odspDocumentServiceFactoryCore_1.OdspDocumentServiceFactoryCore; } });
37
- var odspDocumentServiceFactoryWithCodeSplit_1 = require("./odspDocumentServiceFactoryWithCodeSplit");
37
+ var odspDocumentServiceFactoryWithCodeSplit_1 = require("./odspDocumentServiceFactoryWithCodeSplit.cjs");
38
38
  Object.defineProperty(exports, "OdspDocumentServiceFactoryWithCodeSplit", { enumerable: true, get: function () { return odspDocumentServiceFactoryWithCodeSplit_1.OdspDocumentServiceFactoryWithCodeSplit; } });
39
39
  // File creation
40
- var createOdspCreateContainerRequest_1 = require("./createOdspCreateContainerRequest");
40
+ var createOdspCreateContainerRequest_1 = require("./createOdspCreateContainerRequest.cjs");
41
41
  Object.defineProperty(exports, "createOdspCreateContainerRequest", { enumerable: true, get: function () { return createOdspCreateContainerRequest_1.createOdspCreateContainerRequest; } });
42
42
  // URI Resolver functionality, URI management
43
- var odspDriverUrlResolver_1 = require("./odspDriverUrlResolver");
43
+ var odspDriverUrlResolver_1 = require("./odspDriverUrlResolver.cjs");
44
44
  Object.defineProperty(exports, "OdspDriverUrlResolver", { enumerable: true, get: function () { return odspDriverUrlResolver_1.OdspDriverUrlResolver; } });
45
- var odspDriverUrlResolverForShareLink_1 = require("./odspDriverUrlResolverForShareLink");
45
+ var odspDriverUrlResolverForShareLink_1 = require("./odspDriverUrlResolverForShareLink.cjs");
46
46
  Object.defineProperty(exports, "OdspDriverUrlResolverForShareLink", { enumerable: true, get: function () { return odspDriverUrlResolverForShareLink_1.OdspDriverUrlResolverForShareLink; } });
47
47
  // It's used by URL resolve code, but also has some public functions
48
- var odspFluidFileLink_1 = require("./odspFluidFileLink");
48
+ var odspFluidFileLink_1 = require("./odspFluidFileLink.cjs");
49
49
  Object.defineProperty(exports, "encodeOdspFluidDataStoreLocator", { enumerable: true, get: function () { return odspFluidFileLink_1.encodeOdspFluidDataStoreLocator; } });
50
50
  Object.defineProperty(exports, "getLocatorFromOdspUrl", { enumerable: true, get: function () { return odspFluidFileLink_1.getLocatorFromOdspUrl; } });
51
51
  Object.defineProperty(exports, "locatorQueryParamName", { enumerable: true, get: function () { return odspFluidFileLink_1.locatorQueryParamName; } });
52
52
  Object.defineProperty(exports, "storeLocatorInOdspUrl", { enumerable: true, get: function () { return odspFluidFileLink_1.storeLocatorInOdspUrl; } });
53
- var fetchSnapshot_1 = require("./fetchSnapshot");
53
+ var fetchSnapshot_1 = require("./fetchSnapshot.cjs");
54
54
  Object.defineProperty(exports, "SnapshotFormatSupportType", { enumerable: true, get: function () { return fetchSnapshot_1.SnapshotFormatSupportType; } });
55
- var compactSnapshotParser_1 = require("./compactSnapshotParser");
55
+ var compactSnapshotParser_1 = require("./compactSnapshotParser.cjs");
56
56
  Object.defineProperty(exports, "parseCompactSnapshotResponse", { enumerable: true, get: function () { return compactSnapshotParser_1.parseCompactSnapshotResponse; } });
57
- //# sourceMappingURL=index.js.map
57
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,YAAY;AACZ,6CAAkE;AAAzD,6GAAA,gBAAgB,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAE5C,yDAM2B;AAL1B,wHAAA,qBAAqB,OAAA;AAIrB,oHAAA,iBAAiB,OAAA;AAGlB,eAAe;AACf,2CAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,qDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,yDAA2E;AAAlE,sHAAA,mBAAmB,OAAA;AAC5B,qDAA+F;AAAtF,2GAAA,UAAU,OAAA;AAAE,gHAAA,eAAe,OAAA;AAAE,4GAAA,WAAW,OAAA;AAAE,yGAAA,QAAQ,OAAA;AAAE,yGAAA,QAAQ,OAAA;AAErE,iDAAiD;AACjD,uEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAE/B,UAAU;AACV,+EAGsC;AAFrC,mJAAA,qCAAqC,OAAA;AACrC,wIAAA,0BAA0B,OAAA;AAE3B,uFAAkF;AAAzE,gJAAA,8BAA8B,OAAA;AACvC,yGAAoG;AAA3F,kKAAA,uCAAuC,OAAA;AAEhD,gBAAgB;AAChB,2FAAsF;AAA7E,oJAAA,gCAAgC,OAAA;AAEzC,6CAA6C;AAC7C,qEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,6FAG6C;AAF5C,sJAAA,iCAAiC,OAAA;AAIlC,oEAAoE;AACpE,6DAK6B;AAJ5B,oIAAA,+BAA+B,OAAA;AAC/B,0HAAA,qBAAqB,OAAA;AACrB,0HAAA,qBAAqB,OAAA;AACrB,0HAAA,qBAAqB,OAAA;AAWtB,qDAA4D;AAAnD,0HAAA,yBAAyB,OAAA;AAClC,qEAAmG;AAA9D,qIAAA,4BAA4B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// Constants\nexport { OdcApiSiteOrigin, OdcFileSiteOrigin } from \"./constants\";\n\nexport {\n\tClpCompliantAppHeader,\n\tIClpCompliantAppHeader,\n\tISharingLinkHeader,\n\tOdspFluidDataStoreLocator,\n\tSharingLinkHeader,\n} from \"./contractsPublic\";\n\n// public utils\nexport { checkUrl } from \"./checkUrl\";\nexport { createOdspUrl } from \"./createOdspUrl\";\nexport { getHashedDocumentId, ISnapshotContents } from \"./odspPublicUtils\";\nexport { getApiRoot, getOdspUrlParts, isOdcOrigin, isOdcUrl, isSpoUrl } from \"./odspUrlHelper\";\n\n// prefetch latest snapshot before container load\nexport { prefetchLatestSnapshot } from \"./prefetchLatestSnapshot\";\n\n// Factory\nexport {\n\tcreateLocalOdspDocumentServiceFactory,\n\tOdspDocumentServiceFactory,\n} from \"./odspDocumentServiceFactory\";\nexport { OdspDocumentServiceFactoryCore } from \"./odspDocumentServiceFactoryCore\";\nexport { OdspDocumentServiceFactoryWithCodeSplit } from \"./odspDocumentServiceFactoryWithCodeSplit\";\n\n// File creation\nexport { createOdspCreateContainerRequest } from \"./createOdspCreateContainerRequest\";\n\n// URI Resolver functionality, URI management\nexport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nexport {\n\tOdspDriverUrlResolverForShareLink,\n\tShareLinkFetcherProps,\n} from \"./odspDriverUrlResolverForShareLink\";\n\n// It's used by URL resolve code, but also has some public functions\nexport {\n\tencodeOdspFluidDataStoreLocator,\n\tgetLocatorFromOdspUrl,\n\tlocatorQueryParamName,\n\tstoreLocatorInOdspUrl,\n} from \"./odspFluidFileLink\";\n\nexport {\n\tIOdspCache,\n\tIPersistedFileCache,\n\tINonPersistentCache,\n\tIPrefetchSnapshotContents,\n} from \"./odspCache\";\nexport { ICacheAndTracker, type EpochTracker, FetchType, FetchTypeInternal } from \"./epochTracker\";\nexport { IOdspResponse } from \"./odspUtils\";\nexport { SnapshotFormatSupportType } from \"./fetchSnapshot\";\nexport { ISnapshotContentsWithProps, parseCompactSnapshotResponse } from \"./compactSnapshotParser\";\n"]}
@@ -32,4 +32,4 @@ class LocalOdspDeltaStorageService {
32
32
  }
33
33
  }
34
34
  exports.LocalOdspDeltaStorageService = LocalOdspDeltaStorageService;
35
- //# sourceMappingURL=localOdspDeltaStorageService.js.map
35
+ //# sourceMappingURL=localOdspDeltaStorageService.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localOdspDeltaStorageService.cjs","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,+DAAyE;AAEzE,6DAA+D;AAE/D;;GAEG;AACH,MAAa,4BAA4B;IACxC,YACkB,MAA2B,EACpC,WAAwC;QAD/B,WAAM,GAAN,MAAM,CAAqB;QACpC,gBAAW,GAAX,WAAW,CAA6B;IAC9C,CAAC;IAEG,aAAa,CACnB,IAAY,EACZ,EAAsB,EACtB,YAA0B,EAC1B,WAAqB,EACrB,YAAqB;QAErB,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAClC,OAAO,iCAAkB,CAAC;SAC1B;QAED,MAAM,KAAK,GAAG,IAAI,oBAAK,EAA+B,CAAC;QACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CACvC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,cAAc,IAAI,IAAI,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI,EAAE,CAAC,cAAc,GAAG,EAAE,CAAC,CACjF,CAAC;QACF,IAAA,8BAAgB,EAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAExD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,KAAK,IAAI,EAAE;YACjE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;SACtB;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CACzC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,SAAS,IAAI,EAAE,CAAC,cAAc,IAAI,EAAE,CACnD,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC1B,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AAlCD,oEAkCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { IDocumentDeltaStorageService, IStream } from \"@fluidframework/driver-definitions\";\nimport { Queue, emptyMessageStream } from \"@fluidframework/driver-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { validateMessages } from \"@fluidframework/driver-base\";\n\n/**\n * Implementation of IDocumentDeltaStorageService that will return snapshot ops when fetching messages\n */\nexport class LocalOdspDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate snapshotOps: ISequencedDocumentMessage[],\n\t) {}\n\n\tpublic fetchMessages(\n\t\tfrom: number,\n\t\tto: number | undefined,\n\t\t_abortSignal?: AbortSignal,\n\t\t_cachedOnly?: boolean,\n\t\t_fetchReason?: string,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\tif (this.snapshotOps.length === 0) {\n\t\t\treturn emptyMessageStream;\n\t\t}\n\n\t\tconst queue = new Queue<ISequencedDocumentMessage[]>();\n\t\tconst messages = this.snapshotOps.filter(\n\t\t\t(op) => op.sequenceNumber >= from && (to === undefined || op.sequenceNumber < to),\n\t\t);\n\t\tvalidateMessages(\"cached\", messages, from, this.logger);\n\n\t\tif (messages.length === 0 || messages[0].sequenceNumber !== from) {\n\t\t\tthis.snapshotOps = [];\n\t\t}\n\t\tthis.snapshotOps = this.snapshotOps.filter(\n\t\t\t(op) => to !== undefined && op.sequenceNumber >= to,\n\t\t);\n\n\t\tqueue.pushValue(messages);\n\t\tqueue.pushDone();\n\t\treturn queue;\n\t}\n}\n"]}
@@ -6,8 +6,8 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.LocalOdspDocumentService = void 0;
8
8
  const driver_utils_1 = require("@fluidframework/driver-utils");
9
- const localOdspDeltaStorageService_1 = require("./localOdspDeltaStorageService");
10
- const localOdspDocumentStorageManager_1 = require("./localOdspDocumentStorageManager");
9
+ const localOdspDeltaStorageService_1 = require("./localOdspDeltaStorageService.cjs");
10
+ const localOdspDocumentStorageManager_1 = require("./localOdspDocumentStorageManager.cjs");
11
11
  /**
12
12
  * IDocumentService implementation that provides explicit snapshot to the document storage service.
13
13
  */
@@ -38,4 +38,4 @@ class LocalOdspDocumentService {
38
38
  }
39
39
  }
40
40
  exports.LocalOdspDocumentService = LocalOdspDocumentService;
41
- //# sourceMappingURL=localOdspDocumentService.js.map
41
+ //# sourceMappingURL=localOdspDocumentService.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localOdspDocumentService.cjs","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,+DAA0D;AAG1D,qFAA8E;AAC9E,2FAAoF;AAEpF;;GAEG;AACH,MAAa,wBAAwB;IAIpC,YACkB,eAAiC,EACjC,MAA2B,EAC3B,aAAkC;QAFlC,oBAAe,GAAf,eAAe,CAAkB;QACjC,WAAM,GAAN,MAAM,CAAqB;QAC3B,kBAAa,GAAb,aAAa,CAAqB;QAN7C,aAAQ,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAOrC,CAAC;IAEJ,IAAW,WAAW;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,gBAAgB;QAC5B,IAAI,CAAC,cAAc,GAAG,IAAI,iEAA+B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAC3F,OAAO,IAAI,CAAC,cAAc,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,qBAAqB;QACjC,OAAO,IAAI,2DAA4B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IACtF,CAAC;IAEM,oBAAoB,CAAC,OAAgB;QAC3C,MAAM,OAAO,GAAG,IAAI,yBAAU,CAC7B,qEAAqE,CACrE,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC,CAAC;QACvE,MAAM,OAAO,CAAC;IACf,CAAC;IAEM,OAAO,CAAC,MAAY;QAC1B,aAAa;IACd,CAAC;CACD;AAlCD,4DAkCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport { IOdspResolvedUrl } from \"@fluidframework/odsp-driver-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport { LocalOdspDeltaStorageService } from \"./localOdspDeltaStorageService\";\nimport { LocalOdspDocumentStorageService } from \"./localOdspDocumentStorageManager\";\n\n/**\n * IDocumentService implementation that provides explicit snapshot to the document storage service.\n */\nexport class LocalOdspDocumentService implements IDocumentService {\n\tpublic policies = { storageOnly: true };\n\tprivate storageManager?: LocalOdspDocumentStorageService;\n\n\tconstructor(\n\t\tprivate readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly localSnapshot: Uint8Array | string,\n\t) {}\n\n\tpublic get resolvedUrl(): IResolvedUrl {\n\t\treturn this.odspResolvedUrl;\n\t}\n\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\tthis.storageManager = new LocalOdspDocumentStorageService(this.logger, this.localSnapshot);\n\t\treturn this.storageManager;\n\t}\n\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\treturn new LocalOdspDeltaStorageService(this.logger, this.storageManager?.ops ?? []);\n\t}\n\n\tpublic connectToDeltaStream(_client: IClient): never {\n\t\tconst toThrow = new UsageError(\n\t\t\t'\"connectToDeltaStream\" is not supported by LocalOdspDocumentService',\n\t\t);\n\t\tthis.logger.sendErrorEvent({ eventName: \"UnsupportedUsage\" }, toThrow);\n\t\tthrow toThrow;\n\t}\n\n\tpublic dispose(_error?: any): void {\n\t\t// Do nothing\n\t}\n}\n"]}
@@ -6,9 +6,9 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.LocalOdspDocumentServiceFactory = void 0;
8
8
  const driver_utils_1 = require("@fluidframework/driver-utils");
9
- const odspUtils_1 = require("../odspUtils");
10
- const odspDocumentServiceFactoryCore_1 = require("../odspDocumentServiceFactoryCore");
11
- const localOdspDocumentService_1 = require("./localOdspDocumentService");
9
+ const odspUtils_1 = require("../odspUtils.cjs");
10
+ const odspDocumentServiceFactoryCore_1 = require("../odspDocumentServiceFactoryCore.cjs");
11
+ const localOdspDocumentService_1 = require("./localOdspDocumentService.cjs");
12
12
  /**
13
13
  * Factory for creating sharepoint document service with a provided snapshot.
14
14
  * Use if you don't want to connect to any kind of external/internal storages and want to provide
@@ -41,4 +41,4 @@ class LocalOdspDocumentServiceFactory extends odspDocumentServiceFactoryCore_1.O
41
41
  }
42
42
  }
43
43
  exports.LocalOdspDocumentServiceFactory = LocalOdspDocumentServiceFactory;
44
- //# sourceMappingURL=localOdspDocumentServiceFactory.js.map
44
+ //# sourceMappingURL=localOdspDocumentServiceFactory.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localOdspDocumentServiceFactory.cjs","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA0D;AAG1D,gDAAoE;AAEpE,0FAAmF;AACnF,6EAAsE;AAEtE;;;;GAIG;AACH,MAAa,+BAAgC,SAAQ,+DAA8B;IAGlF,YAA6B,aAAkC;QAC9D,KAAK,CACJ,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,uBAAuB,CAAC,EACtE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,CACxE,CAAC;QAJ0B,kBAAa,GAAb,aAAa,CAAqB;IAK/D,CAAC;IAEO,0BAA0B,CAAC,mBAA2B;QAC7D,MAAM,OAAO,GAAG,IAAI,yBAAU,CAC7B,GAAG,mBAAmB,sDAAsD,CAC5E,CAAC;QACF,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC,CAAC;QACxE,MAAM,OAAO,CAAC;IACf,CAAC;IAEM,eAAe,CACrB,iBAA2C,EAC3C,qBAAmC,EACnC,MAA6B,EAC7B,mBAA6B;QAE7B,MAAM,OAAO,GAAG,IAAI,yBAAU,CAC7B,uEAAuE,CACvE,CAAC;QACF,IAAA,4BAAgB,EAAC,MAAM,CAAC,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC,CAAC;QACpF,MAAM,OAAO,CAAC;IACf,CAAC;IAES,KAAK,CAAC,yBAAyB,CACxC,WAAyB,EACzB,UAA4B,EAC5B,mBAAsC,EACtC,mBAA6B;QAE7B,IAAI,mBAAmB,KAAK,SAAS,EAAE;YACtC,MAAM,IAAI,yBAAU,CAAC,6DAA6D,CAAC,CAAC;SACpF;QACD,IAAI,mBAAmB,EAAE;YACxB,MAAM,IAAI,yBAAU,CAAC,6DAA6D,CAAC,CAAC;SACpF;QACD,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;QACzB,OAAO,IAAI,mDAAwB,CAClC,IAAA,8BAAkB,EAAC,WAAW,CAAC,EAC/B,UAAU,EACV,IAAI,CAAC,aAAa,CAClB,CAAC;IACH,CAAC;CACD;AAlDD,0EAkDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentService, IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/core-interfaces\";\nimport { createOdspLogger, getOdspResolvedUrl } from \"../odspUtils\";\nimport { ICacheAndTracker } from \"../epochTracker\";\nimport { OdspDocumentServiceFactoryCore } from \"../odspDocumentServiceFactoryCore\";\nimport { LocalOdspDocumentService } from \"./localOdspDocumentService\";\n\n/**\n * Factory for creating sharepoint document service with a provided snapshot.\n * Use if you don't want to connect to any kind of external/internal storages and want to provide\n * content directly.\n */\nexport class LocalOdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {\n\tprivate logger: ITelemetryLogger | undefined;\n\n\tconstructor(private readonly localSnapshot: Uint8Array | string) {\n\t\tsuper(\n\t\t\t(_options) => this.throwUnsupportedUsageError(\"Getting storage token\"),\n\t\t\t(_options) => this.throwUnsupportedUsageError(\"Getting websocket token\"),\n\t\t);\n\t}\n\n\tprivate throwUnsupportedUsageError(unsupportedFuncName: string): never {\n\t\tconst toThrow = new UsageError(\n\t\t\t`${unsupportedFuncName} is not supported by LocalOdspDocumentServiceFactory`,\n\t\t);\n\t\tthis.logger?.sendErrorEvent({ eventName: \"UnsupportedUsage\" }, toThrow);\n\t\tthrow toThrow;\n\t}\n\n\tpublic createContainer(\n\t\t_createNewSummary: ISummaryTree | undefined,\n\t\t_createNewResolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\t_clientIsSummarizer?: boolean,\n\t): never {\n\t\tconst toThrow = new UsageError(\n\t\t\t'\"createContainer\" is not supported by LocalOdspDocumentServiceFactory',\n\t\t);\n\t\tcreateOdspLogger(logger).sendErrorEvent({ eventName: \"UnsupportedUsage\" }, toThrow);\n\t\tthrow toThrow;\n\t}\n\n\tprotected async createDocumentServiceCore(\n\t\tresolvedUrl: IResolvedUrl,\n\t\todspLogger: ITelemetryLogger,\n\t\t_cacheAndTrackerArg?: ICacheAndTracker,\n\t\t_clientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (_cacheAndTrackerArg !== undefined) {\n\t\t\tthrow new UsageError('Invalid usage. \"_cacheAndTrackerArg\" should not be provided');\n\t\t}\n\t\tif (_clientIsSummarizer) {\n\t\t\tthrow new UsageError('Invalid usage. \"_clientIsSummarizer\" should not be provided');\n\t\t}\n\t\tthis.logger = odspLogger;\n\t\treturn new LocalOdspDocumentService(\n\t\t\tgetOdspResolvedUrl(resolvedUrl),\n\t\t\todspLogger,\n\t\t\tthis.localSnapshot,\n\t\t);\n\t}\n}\n"]}
@@ -8,9 +8,9 @@ exports.LocalOdspDocumentStorageService = void 0;
8
8
  const core_utils_1 = require("@fluidframework/core-utils");
9
9
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
10
10
  const driver_utils_1 = require("@fluidframework/driver-utils");
11
- const odspDocumentStorageServiceBase_1 = require("../odspDocumentStorageServiceBase");
12
- const odspSnapshotParser_1 = require("../odspSnapshotParser");
13
- const compactSnapshotParser_1 = require("../compactSnapshotParser");
11
+ const odspDocumentStorageServiceBase_1 = require("../odspDocumentStorageServiceBase.cjs");
12
+ const odspSnapshotParser_1 = require("../odspSnapshotParser.cjs");
13
+ const compactSnapshotParser_1 = require("../compactSnapshotParser.cjs");
14
14
  /**
15
15
  * ODSP document storage service that works on a provided snapshot for all its processing.
16
16
  * Attempting to use unsupported actions/methods will result in errors being thrown.
@@ -65,4 +65,4 @@ class LocalOdspDocumentStorageService extends odspDocumentStorageServiceBase_1.O
65
65
  }
66
66
  }
67
67
  exports.LocalOdspDocumentStorageService = LocalOdspDocumentStorageService;
68
- //# sourceMappingURL=localOdspDocumentStorageManager.js.map
68
+ //# sourceMappingURL=localOdspDocumentStorageManager.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localOdspDocumentStorageManager.cjs","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentStorageManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,qEAAiG;AAEjG,+DAA0D;AAE1D,0FAAmF;AAGnF,kEAAkF;AAClF,wEAAwE;AAExE;;;GAGG;AACH,MAAa,+BAAgC,SAAQ,+DAA8B;I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C,CAAC,EAAE,CAAC;IACrF,CAAC;IAES,qBAAqB,CAAC,GAAW,EAAE,aAAsB;QAClE,IAAI,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC;IAC/C,CAAC;IAES,oBAAoB,CAAC,OAAe,EAAE,QAAiB;QAChE,IAAI,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC;IAC9C,CAAC;IAEM,wBAAwB,CAAC,QAA0B,EAAE,QAAyB;QACpF,IAAI,CAAC,eAAe,CAAC,0BAA0B,CAAC,CAAC;IAClD,CAAC;IAEM,UAAU,CAAC,KAAsB;QACvC,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC;IAEO,eAAe,CAAC,UAAkB;QACzC,MAAM,OAAO,GAAG,IAAI,yBAAU,CAC7B,IAAI,UAAU,uDAAuD,CACrE,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC,CAAC;QACvE,MAAM,OAAO,CAAC;IACf,CAAC;CACD;AAnED,0EAmEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { ITelemetryLoggerExt, loggerToMonitoringContext } from \"@fluidframework/telemetry-utils\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { OdspDocumentStorageServiceBase } from \"../odspDocumentStorageServiceBase\";\nimport { ISnapshotContents } from \"../odspPublicUtils\";\nimport { IOdspSnapshot } from \"../contracts\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"../odspSnapshotParser\";\nimport { parseCompactSnapshotResponse } from \"../compactSnapshotParser\";\n\n/**\n * ODSP document storage service that works on a provided snapshot for all its processing.\n * Attempting to use unsupported actions/methods will result in errors being thrown.\n */\nexport class LocalOdspDocumentStorageService extends OdspDocumentStorageServiceBase {\n\tprivate snapshotTreeId: string | undefined;\n\n\tconstructor(\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly localSnapshot: Uint8Array | string,\n\t) {\n\t\tsuper(loggerToMonitoringContext(logger).config);\n\t}\n\n\tprivate calledGetVersions = false;\n\n\tpublic async getVersions(\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tblobid: string | null,\n\t\tcount: number,\n\t\t_scenarioName?: string,\n\t): Promise<api.IVersion[]> {\n\t\tassert(blobid === null, 0x342 /* Invalid usage. \"blobid\" should always be null */);\n\t\tassert(count === 1, 0x343 /* Invalid usage. \"count\" should always be 1 */);\n\n\t\t// No reason to re-parse the data since it will never change\n\t\tif (this.calledGetVersions) {\n\t\t\treturn this.getSnapshotVersion();\n\t\t}\n\t\tthis.calledGetVersions = true;\n\n\t\tlet snapshotContents: ISnapshotContents;\n\n\t\tif (typeof this.localSnapshot === \"string\") {\n\t\t\tconst content: IOdspSnapshot = JSON.parse(this.localSnapshot);\n\t\t\tsnapshotContents = convertOdspSnapshotToSnapshotTreeAndBlobs(content);\n\t\t} else {\n\t\t\tsnapshotContents = parseCompactSnapshotResponse(this.localSnapshot, this.logger);\n\t\t}\n\n\t\tthis.snapshotTreeId = this.initializeFromSnapshot(snapshotContents);\n\t\treturn this.getSnapshotVersion();\n\t}\n\n\tprivate getSnapshotVersion(): api.IVersion[] {\n\t\treturn this.snapshotTreeId ? [{ id: this.snapshotTreeId, treeId: undefined! }] : [];\n\t}\n\n\tprotected fetchTreeFromSnapshot(_id: string, _scenarioName?: string): never {\n\t\tthis.throwUsageError(\"fetchTreeFromSnapshot\");\n\t}\n\n\tprotected fetchBlobFromStorage(_blobId: string, _evicted: boolean): never {\n\t\tthis.throwUsageError(\"fetchBlobFromStorage\");\n\t}\n\n\tpublic uploadSummaryWithContext(_summary: api.ISummaryTree, _context: ISummaryContext): never {\n\t\tthis.throwUsageError(\"uploadSummaryWithContext\");\n\t}\n\n\tpublic createBlob(_file: ArrayBufferLike): never {\n\t\tthis.throwUsageError(\"createBlob\");\n\t}\n\n\tprivate throwUsageError(methodName: string): never {\n\t\tconst toThrow = new UsageError(\n\t\t\t`\"${methodName}\" is not supported by LocalOdspDocumentStorageService`,\n\t\t);\n\t\tthis.logger.sendErrorEvent({ eventName: \"UnsupportedUsage\" }, toThrow);\n\t\tthrow toThrow;\n\t}\n}\n"]}
@@ -73,4 +73,4 @@ class NonPersistentCache {
73
73
  }
74
74
  }
75
75
  exports.NonPersistentCache = NonPersistentCache;
76
- //# sourceMappingURL=odspCache.js.map
76
+ //# sourceMappingURL=odspCache.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"odspCache.cjs","sourceRoot":"","sources":["../src/odspCache.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,2DAA0D;AAC1D,qFAQiD;AAajD;;;GAGG;AACH,MAAa,oBAAoB;IAKhC,YAAoC,uBAAuB,IAAI,GAAG,IAAI;QAAlC,yBAAoB,GAApB,oBAAoB,CAAc;QAJrD,UAAK,GAAG,IAAI,GAAG,EAAe,CAAC;QAChD,wGAAwG;QACvF,uBAAkB,GAAG,IAAI,GAAG,EAAyC,CAAC;IAEd,CAAC;IAE1E,KAAK,CAAC,GAAG,CAAC,KAAkB;QAC3B,MAAM,GAAG,GAAG,IAAA,6CAAmB,EAAC,KAAK,CAAC,CAAC;QACvC,+DAA+D;QAC/D,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAkB,EAAE,KAAU;QACvC,MAAM,GAAG,GAAG,IAAA,6CAAmB,EAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3B,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,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yBAAuB;IACnF,YAAY,aAAmC;QAC9C,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAC9E,CAAC;CACD;AAJD,oFAIC;AAsCD,MAAa,kBAAkB;IAA/B;QACiB,qBAAgB,GAAG,IAAI,yBAAY,EAGhD,CAAC;QAEY,iBAAY,GAAG,IAAI,yBAAY,EAA4B,CAAC;QAE5D,gCAA2B,GAAG,IAAI,yBAAY,EAG3D,CAAC;IACL,CAAC;CAAA;AAZD,gDAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { PromiseCache } from \"@fluidframework/core-utils\";\nimport {\n\tIOdspResolvedUrl,\n\tIFileEntry,\n\tIEntry,\n\tIPersistedCache,\n\tICacheEntry,\n\tISocketStorageDiscovery,\n\tgetKeyForCacheEntry,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\n\n/**\n * Similar to IPersistedCache, but exposes cache interface for single file\n * @public\n */\nexport interface IPersistedFileCache {\n\tget(entry: IEntry): Promise<any>;\n\tput(entry: IEntry, value: any): Promise<void>;\n\tremoveEntries(): Promise<void>;\n}\n\n/**\n * Default local-only implementation of IPersistedCache,\n * used if no persisted cache is provided by the host\n */\nexport class LocalPersistentCache implements IPersistedCache {\n\tprivate readonly cache = new Map<string, any>();\n\t// For every document id there will be a single expiration entry inspite of the number of cache entries.\n\tprivate readonly docIdExpirationMap = new Map<string, ReturnType<typeof setTimeout>>();\n\n\tpublic constructor(private readonly snapshotExpiryPolicy = 3600 * 1000) {}\n\n\tasync get(entry: ICacheEntry): Promise<any> {\n\t\tconst key = getKeyForCacheEntry(entry);\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.cache.get(key);\n\t}\n\n\tasync put(entry: ICacheEntry, value: any) {\n\t\tconst key = getKeyForCacheEntry(entry);\n\t\tthis.cache.set(key, value);\n\t\tthis.updateExpirationEntry(entry.file.docId);\n\t}\n\n\tasync removeEntries(file: IFileEntry): Promise<void> {\n\t\tthis.removeDocIdEntriesFromCache(file.docId);\n\t}\n\n\tprivate removeDocIdEntriesFromCache(docId: string) {\n\t\tthis.removeExpirationEntry(docId);\n\t\treturn Array.from(this.cache)\n\t\t\t.filter(([cachekey]) => {\n\t\t\t\tconst docIdFromKey = cachekey.split(\"_\");\n\t\t\t\tif (docIdFromKey[0] === docId) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.map(([cachekey]) => {\n\t\t\t\tthis.cache.delete(cachekey);\n\t\t\t});\n\t}\n\n\tprivate removeExpirationEntry(docId: string) {\n\t\tconst timeout = this.docIdExpirationMap.get(docId);\n\t\tif (timeout !== undefined) {\n\t\t\tclearTimeout(timeout);\n\t\t\tthis.docIdExpirationMap.delete(docId);\n\t\t}\n\t}\n\n\tprivate updateExpirationEntry(docId: string) {\n\t\tthis.removeExpirationEntry(docId);\n\t\tthis.docIdExpirationMap.set(\n\t\t\tdocId,\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.removeDocIdEntriesFromCache(docId);\n\t\t\t}, this.snapshotExpiryPolicy),\n\t\t);\n\t}\n}\nexport class PromiseCacheWithOneHourSlidingExpiry<T> extends PromiseCache<string, T> {\n\tconstructor(removeOnError?: (e: any) => boolean) {\n\t\tsuper({ expiry: { policy: \"sliding\", durationMs: 3600000 }, removeOnError });\n\t}\n}\n\n/**\n * Internal cache interface used within driver only\n * @public\n */\nexport interface INonPersistentCache {\n\t/**\n\t * Cache of joined/joining session info\n\t */\n\treadonly sessionJoinCache: PromiseCache<\n\t\tstring,\n\t\t{ entryTime: number; joinSessionResponse: ISocketStorageDiscovery }\n\t>;\n\n\t/**\n\t * Cache of resolved/resolving file URLs\n\t */\n\treadonly fileUrlCache: PromiseCache<string, IOdspResolvedUrl>;\n\n\t/**\n\t * Used to store the snapshot fetch promise if the prefetch has been made using the prefetchLatestSnapshot api.\n\t * This is then used later to look for the promise during the container load.\n\t */\n\treadonly snapshotPrefetchResultCache: PromiseCache<string, IPrefetchSnapshotContents>;\n}\n\n/**\n * Internal cache interface used within driver only\n * @public\n */\nexport interface IOdspCache extends INonPersistentCache {\n\t/**\n\t * Persisted cache - only serializable content is allowed\n\t */\n\treadonly persistedCache: IPersistedFileCache;\n}\n\nexport class NonPersistentCache implements INonPersistentCache {\n\tpublic readonly sessionJoinCache = new PromiseCache<\n\t\tstring,\n\t\t{ entryTime: number; joinSessionResponse: ISocketStorageDiscovery }\n\t>();\n\n\tpublic readonly fileUrlCache = new PromiseCache<string, IOdspResolvedUrl>();\n\n\tpublic readonly snapshotPrefetchResultCache = new PromiseCache<\n\t\tstring,\n\t\tIPrefetchSnapshotContents\n\t>();\n}\n\n/**\n * @public\n */\nexport interface IPrefetchSnapshotContents extends ISnapshotContents {\n\tfluidEpoch: string;\n\tprefetchStartTime: number;\n}\n"]}
@@ -12,10 +12,10 @@ const driver_definitions_1 = require("@fluidframework/driver-definitions");
12
12
  const driver_utils_1 = require("@fluidframework/driver-utils");
13
13
  const odsp_driver_definitions_1 = require("@fluidframework/odsp-driver-definitions");
14
14
  const odsp_doclib_utils_1 = require("@fluidframework/odsp-doclib-utils");
15
- const odspDocumentDeltaConnection_1 = require("./odspDocumentDeltaConnection");
16
- const odspUtils_1 = require("./odspUtils");
17
- const vroom_1 = require("./vroom");
18
- const packageVersion_1 = require("./packageVersion");
15
+ const odspDocumentDeltaConnection_1 = require("./odspDocumentDeltaConnection.cjs");
16
+ const odspUtils_1 = require("./odspUtils.cjs");
17
+ const vroom_1 = require("./vroom.cjs");
18
+ const packageVersion_1 = require("./packageVersion.cjs");
19
19
  /**
20
20
  * This OdspDelayLoadedDeltaStream is used by OdspDocumentService.ts to delay load the delta connection
21
21
  * as they are not on critical path of loading a container.
@@ -286,4 +286,4 @@ class OdspDelayLoadedDeltaStream {
286
286
  }
287
287
  }
288
288
  exports.OdspDelayLoadedDeltaStream = OdspDelayLoadedDeltaStream;
289
- //# sourceMappingURL=odspDelayLoadedDeltaStream.js.map
289
+ //# sourceMappingURL=odspDelayLoadedDeltaStream.cjs.map