@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
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/odspDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGN,yBAAyB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAatE,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAGzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,M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AC,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;SACxE;QAED,MAAM,CAAC,uBAAuB,EAAE,CAAC;IAClC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent } from \"@fluidframework/core-interfaces\";\nimport {\n\tITelemetryLoggerExt,\n\tIFluidErrorBase,\n\tloggerToMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { performance, TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert, Deferred } from \"@fluidframework/core-utils\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base\";\nimport { IAnyDriverError } from \"@fluidframework/driver-definitions\";\nimport { OdspError } from \"@fluidframework/odsp-driver-definitions\";\nimport {\n\tIClient,\n\tIConnect,\n\tIDocumentMessage,\n\tINack,\n\tISentSignalMessage,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { Socket } from \"socket.io-client\";\nimport { v4 as uuid } from \"uuid\";\nimport { createGenericNetworkError } from \"@fluidframework/driver-utils\";\nimport { IOdspSocketError, IGetOpsResponse, IFlushOpsResponse } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { errorObjectFromSocketError } from \"./odspError\";\nimport { SocketIOClientStatic } from \"./socketModule\";\nimport { pkgVersion } from \"./packageVersion\";\n\nconst protocolVersions = [\"^0.4.0\", \"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\nconst feature_get_ops = \"api_get_ops\";\nconst feature_flush_ops = \"api_flush_ops\";\nconst feature_submit_signals_v2 = \"submit_signals_v2\";\n\nexport interface FlushResult {\n\tlastPersistedSequenceNumber?: number;\n\tretryAfter?: number;\n}\n\n// How long to wait before disconnecting the socket after the last reference is removed\n// This allows reconnection after receiving a nack to be smooth\nconst socketReferenceBufferTime = 2000;\n\ninterface ISocketEvents extends IEvent {\n\t(\n\t\tevent: \"disconnect\",\n\t\tlistener: (error: IFluidErrorBase & OdspError, clientId?: string) => void,\n\t);\n}\n\nclass SocketReference extends TypedEventEmitter<ISocketEvents> {\n\tprivate references: number = 1;\n\tprivate delayDeleteTimeout: ReturnType<typeof setTimeout> | undefined;\n\tprivate _socket: Socket | undefined;\n\n\t// When making decisions about socket reuse, we do not reuse disconnected socket.\n\t// But we want to differentiate the following case from disconnected case:\n\t// Socket that never connected and never failed, it's in \"attempting to connect\" mode\n\t// such sockets should be reused, despite socket.disconnected === true\n\tprivate isPendingInitialConnection = true;\n\n\t// Map of all existing socket io sockets. [url, tenantId, documentId] -> socket\n\tprivate static readonly socketIoSockets: Map<string, SocketReference> = new Map();\n\n\tpublic static find(key: string, logger: ITelemetryLoggerExt) {\n\t\tconst socketReference = SocketReference.socketIoSockets.get(key);\n\n\t\t// Verify the socket is healthy before reusing it\n\t\tif (socketReference?.disconnected) {\n\t\t\t// The socket is in a bad state. fully remove the reference\n\t\t\tsocketReference.closeSocket();\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (socketReference) {\n\t\t\t// Clear the pending deletion if there is one\n\t\t\tsocketReference.clearTimer();\n\t\t\tsocketReference.references++;\n\t\t}\n\n\t\treturn socketReference;\n\t}\n\n\t/**\n\t * Removes a reference for the given key\n\t * Once the ref count hits 0, the socket is disconnected and removed\n\t */\n\tpublic removeSocketIoReference() {\n\t\tassert(this.references > 0, 0x09f /* \"No more socketIO refs to remove!\" */);\n\t\tthis.references--;\n\n\t\t// see comment in disconnected() getter\n\t\tthis.isPendingInitialConnection = false;\n\n\t\tif (this.disconnected) {\n\t\t\tthis.closeSocket();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.references === 0 && this.delayDeleteTimeout === undefined) {\n\t\t\tthis.delayDeleteTimeout = setTimeout(() => {\n\t\t\t\t// We should not get here with active users.\n\t\t\t\tassert(\n\t\t\t\t\tthis.references === 0,\n\t\t\t\t\t0x0a0 /* \"Unexpected socketIO references on timeout\" */,\n\t\t\t\t);\n\t\t\t\tthis.closeSocket();\n\t\t\t}, socketReferenceBufferTime);\n\t\t}\n\t}\n\n\tpublic get socket() {\n\t\tif (!this._socket) {\n\t\t\tthrow new Error(`Invalid socket for key \"${this.key}`);\n\t\t}\n\t\treturn this._socket;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly key: string,\n\t\tsocket: Socket,\n\t) {\n\t\tsuper();\n\n\t\tthis._socket = socket;\n\t\tassert(!SocketReference.socketIoSockets.has(key), 0x220 /* \"socket key collision\" */);\n\t\tSocketReference.socketIoSockets.set(key, this);\n\n\t\t// Server sends this event when it wants to disconnect a particular client in which case the client id would\n\t\t// be present or if it wants to disconnect all the clients. The server always closes the socket in case all\n\t\t// clients needs to be disconnected. So fully remove the socket reference in this case.\n\t\tsocket.on(\"server_disconnect\", this.serverDisconnectEventHandler);\n\t}\n\n\tprivate readonly serverDisconnectEventHandler = (\n\t\tsocketError: IOdspSocketError,\n\t\tclientId?: string,\n\t) => {\n\t\t// Treat all errors as recoverable, and rely on joinSession / reconnection flow to\n\t\t// filter out retryable vs. non-retryable cases.\n\t\tconst error = errorObjectFromSocketError(socketError, \"server_disconnect\");\n\t\terror.addTelemetryProperties({ disconnectClientId: clientId });\n\t\terror.canRetry = true;\n\n\t\t// see comment in disconnected() getter\n\t\t// Setting it here to ensure socket reuse does not happen if new request to connect\n\t\t// comes in from \"disconnect\" listener below, before we close socket.\n\t\tthis.isPendingInitialConnection = false;\n\n\t\tif (clientId === undefined) {\n\t\t\t// We could first raise \"disconnect\" event, but that may result in socket reuse due to\n\t\t\t// new connection comming in. So, it's better to have more explicit flow to make it impossible.\n\t\t\tthis.closeSocket(error);\n\t\t} else {\n\t\t\tthis.emit(\"disconnect\", error, clientId);\n\t\t}\n\t};\n\n\tprivate clearTimer() {\n\t\tif (this.delayDeleteTimeout !== undefined) {\n\t\t\tclearTimeout(this.delayDeleteTimeout);\n\t\t\tthis.delayDeleteTimeout = undefined;\n\t\t}\n\t}\n\n\tpublic closeSocket(error?: IAnyDriverError) {\n\t\tif (!this._socket) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._socket.off(\"server_disconnect\", this.serverDisconnectEventHandler);\n\t\tthis.clearTimer();\n\n\t\tassert(\n\t\t\tSocketReference.socketIoSockets.get(this.key) === this,\n\t\t\t0x0a1 /* \"Socket reference set unexpectedly does not point to this socket!\" */,\n\t\t);\n\n\t\t// First, remove socket to ensure no socket reuse is possible.\n\t\tSocketReference.socketIoSockets.delete(this.key);\n\n\t\t// Block access to socket. From now on, calls like flush() or requestOps()\n\t\t// Disconnect flow should be synchronous and result in system fully forgetting about this connection / socket.\n\t\tconst socket = this._socket;\n\t\tthis._socket = undefined;\n\n\t\t// Let all connections know they need to go through disconnect flow.\n\t\tthis.emit(\n\t\t\t\"disconnect\",\n\t\t\terror ??\n\t\t\t\tcreateGenericNetworkError(\n\t\t\t\t\t\"Socket closed without error\",\n\t\t\t\t\t{ canRetry: true },\n\t\t\t\t\t{ driverVersion: pkgVersion },\n\t\t\t\t),\n\t\t\tundefined /* clientId */,\n\t\t);\n\n\t\t// We should not have any users now, assuming synchronous disconnect flow in response to\n\t\t// \"disconnect\" event\n\t\tassert(\n\t\t\tthis.references === 0,\n\t\t\t0x412 /* Nobody should be connected to this socket at this point! */,\n\t\t);\n\n\t\tsocket.disconnect();\n\t}\n\n\tpublic get disconnected() {\n\t\tif (this._socket === undefined) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.socket.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// We have a socket that is not connected. Possible cases:\n\t\t// 1) It was connected some time ago and lost connection. We do not want to reuse it.\n\t\t// 2) It failed to connect (was never connected).\n\t\t// 3) It was just created and never had a chance to connect - connection is in process.\n\t\t// We have to differentiate 1 from 2-3 (specifically 1 & 3) in order to be able to reuse socket in #3.\n\t\t// We will use the fact that socket had some activity. I.e. if socket disconnected, or client stopped using\n\t\t// socket, then removeSocketIoReference() will be called for it, and it will be the indiction that it's not #3.\n\t\treturn !this.isPendingInitialConnection;\n\t}\n}\n\n/**\n * Represents a connection to a stream of delta updates\n */\nexport class OdspDocumentDeltaConnection extends DocumentDeltaConnection {\n\t/**\n\t * Create a OdspDocumentDeltaConnection\n\t * If url #1 fails to connect, will try url #2 if applicable.\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param documentId - document ID\n\t * @param token - authorization token for storage service\n\t * @param client - information about the client\n\t * @param mode - mode of the client\n\t * @param url - websocket URL\n\t * @param telemetryLogger - optional telemetry logger\n\t * @param timeoutMs - time limit on making the connection\n\t * @param epochTracker - track epoch changes\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\ttoken: string | null,\n\t\tclient: IClient,\n\t\turl: string,\n\t\ttelemetryLogger: ITelemetryLoggerExt,\n\t\ttimeoutMs: number,\n\t\tepochTracker: EpochTracker,\n\t\tsocketReferenceKeyPrefix: string | undefined,\n\t): Promise<OdspDocumentDeltaConnection> {\n\t\tconst mc = loggerToMonitoringContext(telemetryLogger);\n\n\t\t// enable multiplexing when the websocket url does not include the tenant/document id\n\t\tconst parsedUrl = new URL(url);\n\t\tconst enableMultiplexing =\n\t\t\t!parsedUrl.searchParams.has(\"documentId\") && !parsedUrl.searchParams.has(\"tenantId\");\n\n\t\t// do not include the specific tenant/doc id in the ref key when multiplexing\n\t\t// this will allow multiple documents to share the same websocket connection\n\t\tconst key = socketReferenceKeyPrefix ? `${socketReferenceKeyPrefix},${url}` : url;\n\t\tconst socketReferenceKey = enableMultiplexing ? key : `${key},${tenantId},${documentId}`;\n\n\t\tconst socketReference = OdspDocumentDeltaConnection.getOrCreateSocketIoReference(\n\t\t\ttimeoutMs,\n\t\t\tsocketReferenceKey,\n\t\t\turl,\n\t\t\tenableMultiplexing,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\ttelemetryLogger,\n\t\t);\n\n\t\tconst socket = socketReference.socket;\n\t\tconst connectionId = uuid();\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid: documentId,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: protocolVersions,\n\t\t\tdriverVersion: pkgVersion,\n\t\t\tnonce: connectionId,\n\t\t\tepoch: epochTracker.fluidEpoch,\n\t\t\trelayUserAgent: [client.details.environment, ` driverVersion:${pkgVersion}`].join(\";\"),\n\t\t};\n\n\t\tconnectMessage.supportedFeatures = {\n\t\t\t[feature_submit_signals_v2]: true,\n\t\t};\n\n\t\t// Reference to this client supporting get_ops flow.\n\t\tif (mc.config.getBoolean(\"Fluid.Driver.Odsp.GetOpsEnabled\") !== false) {\n\t\t\tconnectMessage.supportedFeatures[feature_get_ops] = true;\n\t\t}\n\n\t\tconst deltaConnection = new OdspDocumentDeltaConnection(\n\t\t\tsocket,\n\t\t\tdocumentId,\n\t\t\tsocketReference,\n\t\t\ttelemetryLogger,\n\t\t\tenableMultiplexing,\n\t\t\tconnectionId,\n\t\t);\n\n\t\ttry {\n\t\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\t\tawait epochTracker.validateEpoch(deltaConnection.details.epoch, \"push\");\n\t\t} catch (errorObject: any) {\n\t\t\tif (errorObject !== null && typeof errorObject === \"object\") {\n\t\t\t\t// We have to special-case error types here in terms of what is re-triable.\n\t\t\t\t// These errors have to re-retried, we just need new joinSession result to connect to right server:\n\t\t\t\t// 400: Invalid tenant or document id. The WebSocket is connected to a different document\n\t\t\t\t// Document is full (with retryAfter)\n\t\t\t\t// 404: Invalid document. The document \\\"local/w1-...\\\" does not exist\n\t\t\t\t// But this has to stay not-retriable:\n\t\t\t\t// 406: Unsupported client protocol. This path is the only gatekeeper, have to fail!\n\t\t\t\t// 409: Epoch Version Mismatch. Client epoch and server epoch does not match, so app needs\n\t\t\t\t// to be refreshed.\n\t\t\t\t// This one is fine either way\n\t\t\t\t// 401/403: Code will retry once with new token either way, then it becomes fatal - on this path\n\t\t\t\t// and on join Session path.\n\t\t\t\t// 501: (Fluid not enabled): this is fine either way, as joinSession is gatekeeper\n\t\t\t\tif (errorObject.statusCode === 400 || errorObject.statusCode === 404) {\n\t\t\t\t\terrorObject.canRetry = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow errorObject;\n\t\t}\n\n\t\treturn deltaConnection;\n\t}\n\n\tprivate socketReference: SocketReference | undefined;\n\n\tprivate readonly requestOpsNoncePrefix: string;\n\tprivate pushCallCounter = 0;\n\tprivate readonly getOpsMap: Map<string, { start: number; from: number; to: number }> =\n\t\tnew Map();\n\tprivate flushOpNonce: string | undefined;\n\tprivate flushDeferred: Deferred<FlushResult> | undefined;\n\tprivate connectionNotYetDisposedTimeout: ReturnType<typeof setTimeout> | undefined;\n\n\t/**\n\t * Error raising for socket.io issues\n\t */\n\tprotected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {\n\t\t// Note: we suspect the incoming error object is either:\n\t\t// - a socketError: add it to the OdspError object for driver to be able to parse it and reason over it.\n\t\t// - anything else: let base class handle it\n\t\treturn canRetry && Number.isInteger(error?.code) && typeof error?.message === \"string\"\n\t\t\t? errorObjectFromSocketError(error as IOdspSocketError, handler)\n\t\t\t: super.createErrorObject(handler, error, canRetry);\n\t}\n\n\t/**\n\t * Gets or create a socket io connection for the given key\n\t */\n\tprivate static getOrCreateSocketIoReference(\n\t\ttimeoutMs: number,\n\t\tkey: string,\n\t\turl: string,\n\t\tenableMultiplexing: boolean,\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\tlogger: ITelemetryLoggerExt,\n\t): SocketReference {\n\t\tconst existingSocketReference = SocketReference.find(key, logger);\n\t\tif (existingSocketReference) {\n\t\t\treturn existingSocketReference;\n\t\t}\n\n\t\tconst query = enableMultiplexing ? undefined : { documentId, tenantId };\n\n\t\tconst socket = SocketIOClientStatic(url, {\n\t\t\tmultiplex: false, // Don't rely on socket.io built-in multiplexing\n\t\t\tquery,\n\t\t\treconnection: false,\n\t\t\ttransports: [\"websocket\"],\n\t\t\ttimeout: timeoutMs,\n\t\t});\n\n\t\treturn new SocketReference(key, socket);\n\t}\n\n\t/**\n\t * @param socket - websocket to be used\n\t * @param documentId - ID of the document\n\t * @param details - details of the websocket connection\n\t * @param socketReferenceKey - socket reference key\n\t * @param enableMultiplexing - If the websocket is multiplexing multiple documents\n\t */\n\tprivate constructor(\n\t\tsocket: Socket,\n\t\tdocumentId: string,\n\t\tsocketReference: SocketReference,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly enableMultiplexing?: boolean,\n\t\tconnectionId?: string,\n\t) {\n\t\tsuper(socket, documentId, logger, false, connectionId);\n\t\tthis.socketReference = socketReference;\n\t\tthis.requestOpsNoncePrefix = `${uuid()}-`;\n\t}\n\n\t/**\n\t * Retrieves ops from PUSH\n\t * @param from - inclusive\n\t * @param to - exclusive\n\t * @returns ops retrieved\n\t */\n\tpublic requestOps(from: number, to: number) {\n\t\tassert(!this.socketReference?.disconnected, 0x413 /* non-active socket */);\n\n\t\t// Given that to is exclusive, we should be asking for at least something!\n\t\tassert(to > from, 0x272 /* \"empty request\" */);\n\n\t\t// PUSH may disable this functionality\n\t\t// back-compat: remove cast to any once latest version of IConnected is consumed\n\t\tif ((this.details as any).supportedFeatures?.[feature_get_ops] !== true) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pushCallCounter++;\n\t\tconst nonce = `${this.requestOpsNoncePrefix}${this.pushCallCounter}`;\n\t\tconst start = performance.now();\n\n\t\t// We may keep keep accumulating memory for nothing, if we are not getting responses.\n\t\t// Note that we should not have overlapping requests, as DeltaManager allows only one\n\t\t// outstanding request to storage, and that's the only way to get here.\n\t\t// But requests could be cancelled, and thus overlapping requests might be in the picture\n\t\t// If it happens, we do not care about stale requests.\n\t\t// So track some number of requests, but log if we get too many in flight - that likely\n\t\t// indicates an error somewhere.\n\t\tif (this.getOpsMap.size >= 5) {\n\t\t\tlet time = start;\n\t\t\tlet key: string | undefined;\n\t\t\tfor (const [keyCandidate, value] of this.getOpsMap.entries()) {\n\t\t\t\tif (value.start <= time || key === undefined) {\n\t\t\t\t\ttime = value.start;\n\t\t\t\t\tkey = keyCandidate;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst payloadToDelete = this.getOpsMap.get(key!)!;\n\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\teventName: \"GetOpsTooMany\",\n\t\t\t\tnonce,\n\t\t\t\tfrom: payloadToDelete.from,\n\t\t\t\tto: payloadToDelete.to,\n\t\t\t\tlength: payloadToDelete.to - payloadToDelete.from,\n\t\t\t\tduration: performance.now() - payloadToDelete.start,\n\t\t\t});\n\t\t\tthis.getOpsMap.delete(key!);\n\t\t}\n\t\tthis.getOpsMap.set(nonce, {\n\t\t\tstart,\n\t\t\tfrom,\n\t\t\tto,\n\t\t});\n\t\tthis.socket.emit(\"get_ops\", this.clientId, {\n\t\t\tnonce,\n\t\t\tfrom,\n\t\t\tto: to - 1,\n\t\t});\n\t}\n\n\tpublic async flush(): Promise<FlushResult> {\n\t\tassert(!this.socketReference?.disconnected, 0x414 /* non-active socket */);\n\n\t\t// back-compat: remove cast to any once latest version of IConnected is consumed\n\t\tif ((this.details as any).supportedFeatures?.[feature_flush_ops] !== true) {\n\t\t\t// Once single-commit summary is enabled end-to-end, flush support is a must!\n\t\t\t// The only alternative is change in design where SPO fetches ops from PUSH OR\n\t\t\t// summary includes required ops and SPO has some validation mechanism to ensure\n\t\t\t// they are not forged by client.\n\t\t\t// If design changes, we can reconsider it, but right now it's non-recoverable failure.\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"FlushOpsNotSupported\" });\n\t\t\tthrow new Error(\n\t\t\t\t\"flush() API is not supported by PUSH, required for single-commit summaries\",\n\t\t\t);\n\t\t}\n\n\t\tthis.pushCallCounter++;\n\t\tconst nonce = `${this.requestOpsNoncePrefix}${this.pushCallCounter}`;\n\t\t// There should be only one flush ops in flight, kicked out by upload summary workflow\n\t\t// That said, it could timeout and request could be repeated, so theoretically we can\n\t\t// get overlapping requests, but it should be very rare\n\t\tif (this.flushDeferred !== undefined) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"FlushOpsTooMany\" });\n\t\t\tthis.flushDeferred.reject(\n\t\t\t\t\"process involving flush() was cancelled OR unsupported concurrency\",\n\t\t\t);\n\t\t}\n\t\tthis.socket.emit(\"flush_ops\", this.clientId, { nonce });\n\n\t\tthis.flushOpNonce = nonce;\n\t\tthis.flushDeferred = new Deferred<FlushResult>();\n\t\treturn this.flushDeferred.promise;\n\t}\n\n\tprotected disconnectHandler = (error: IFluidErrorBase & OdspError, clientId?: string) => {\n\t\tif (clientId === undefined || clientId === this.clientId) {\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"ServerDisconnect\",\n\t\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\tthis.disconnect(error);\n\t\t}\n\t};\n\n\tprotected async initialize(connectMessage: IConnect, timeout: number) {\n\t\tassert(!this.socketReference?.disconnected, 0x415 /* non-active socket */);\n\n\t\tif (this.enableMultiplexing) {\n\t\t\t// multiplex compatible early handlers\n\t\t\tthis.earlyOpHandler = (\n\t\t\t\tmessageDocumentId: string,\n\t\t\t\tmsgs: ISequencedDocumentMessage[],\n\t\t\t) => {\n\t\t\t\tif (this.documentId === messageDocumentId) {\n\t\t\t\t\tthis.queuedMessages.push(...msgs);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.earlySignalHandler = (\n\t\t\t\tmsg: ISignalMessage | ISignalMessage[],\n\t\t\t\tmessageDocumentId?: string,\n\t\t\t) => {\n\t\t\t\tif (messageDocumentId === undefined || messageDocumentId === this.documentId) {\n\t\t\t\t\tif (Array.isArray(msg)) {\n\t\t\t\t\t\tthis.queuedSignals.push(...msg);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.queuedSignals.push(msg);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tthis.socketReference!.on(\"disconnect\", this.disconnectHandler);\n\n\t\tthis.addTrackedListener(\"get_ops_response\", (result: IGetOpsResponse) => {\n\t\t\tconst messages = result.messages;\n\t\t\tconst data = this.getOpsMap.get(result.nonce);\n\t\t\t// Due to socket multiplexing, this client may not have asked for any data\n\t\t\t// If so, there it most likely does not need these ops (otherwise it already asked for them)\n\t\t\t// Also we may have deleted entry in this.getOpsMap due to too many requests and too slow response.\n\t\t\t// But not processing such result may push us into infinite loop of fast requests and dropping all responses\n\t\t\tif (data !== undefined || result.nonce.startsWith(this.requestOpsNoncePrefix)) {\n\t\t\t\tthis.getOpsMap.delete(result.nonce);\n\t\t\t\tconst common = {\n\t\t\t\t\teventName: \"GetOps\",\n\t\t\t\t\t// We need nonce only to pair with GetOpsTooMany events, i.e. when record was deleted\n\t\t\t\t\tnonce: data === undefined ? result.nonce : undefined,\n\t\t\t\t\tcode: result.code,\n\t\t\t\t\tfrom: data?.from,\n\t\t\t\t\tto: data?.to,\n\t\t\t\t\tduration: data === undefined ? undefined : performance.now() - data.start,\n\t\t\t\t};\n\t\t\t\tif (messages !== undefined && messages.length > 0) {\n\t\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\t\t...common,\n\t\t\t\t\t\tfirst: messages[0].sequenceNumber,\n\t\t\t\t\t\tlast: messages[messages.length - 1].sequenceNumber,\n\t\t\t\t\t\tlength: messages.length,\n\t\t\t\t\t});\n\t\t\t\t\tthis.emit(\"op\", this.documentId, messages);\n\t\t\t\t} else {\n\t\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\t\t...common,\n\t\t\t\t\t\tlength: 0,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.addTrackedListener(\"flush_ops_response\", (result: IFlushOpsResponse) => {\n\t\t\tif (this.flushOpNonce === result.nonce) {\n\t\t\t\tconst seq = result.lastPersistedSequenceNumber;\n\t\t\t\tlet category: \"generic\" | \"error\" = \"generic\";\n\t\t\t\tif (result.lastPersistedSequenceNumber === undefined || result.code !== 200) {\n\t\t\t\t\tswitch (result.code) {\n\t\t\t\t\t\tcase 409:\n\t\t\t\t\t\tcase 429:\n\t\t\t\t\t\t\tcategory = \"error\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 204:\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tcategory = \"error\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"FlushResult\",\n\t\t\t\t\tcode: result.code,\n\t\t\t\t\tsequenceNumber: seq,\n\t\t\t\t\tcategory,\n\t\t\t\t});\n\t\t\t\tthis.flushDeferred!.resolve(result);\n\t\t\t\tthis.flushDeferred = undefined;\n\t\t\t\tthis.flushOpNonce = undefined;\n\t\t\t}\n\t\t});\n\n\t\tawait super.initialize(connectMessage, timeout).finally(() => {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"ConnectionAttemptInfo\",\n\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t});\n\t\t});\n\t}\n\n\tprotected addTrackedListener(event: string, listener: (...args: any[]) => void) {\n\t\t// override some event listeners in order to support multiple documents/clients over the same websocket\n\t\tswitch (event) {\n\t\t\tcase \"op\":\n\t\t\t\t// per document op handling\n\t\t\t\tsuper.addTrackedListener(\n\t\t\t\t\tevent,\n\t\t\t\t\t(documentId: string, msgs: ISequencedDocumentMessage[]) => {\n\t\t\t\t\t\tif (!this.enableMultiplexing || this.documentId === documentId) {\n\t\t\t\t\t\t\tlistener(documentId, msgs);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase \"signal\":\n\t\t\t\t// per document signal handling\n\t\t\t\tsuper.addTrackedListener(\n\t\t\t\t\tevent,\n\t\t\t\t\t(msg: ISignalMessage | ISignalMessage[], documentId?: string) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!this.enableMultiplexing ||\n\t\t\t\t\t\t\t!documentId ||\n\t\t\t\t\t\t\tdocumentId === this.documentId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tlistener(msg, documentId);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase \"nack\":\n\t\t\t\t// per client / document nack handling\n\t\t\t\tsuper.addTrackedListener(event, (clientIdOrDocumentId: string, nacks: INack[]) => {\n\t\t\t\t\tconst handle =\n\t\t\t\t\t\tclientIdOrDocumentId.length === 0 ||\n\t\t\t\t\t\tclientIdOrDocumentId === this.documentId ||\n\t\t\t\t\t\tclientIdOrDocumentId === this.clientId;\n\t\t\t\t\tconst { code, type, message, retryAfter } = nacks[0]?.content ?? {};\n\t\t\t\t\tconst { clientSequenceNumber, referenceSequenceNumber } =\n\t\t\t\t\t\tnacks[0]?.operation ?? {};\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"ServerNack\",\n\t\t\t\t\t\tcode,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tretryAfterSeconds: retryAfter,\n\t\t\t\t\t\tclientId: this.clientId,\n\t\t\t\t\t\thandle,\n\t\t\t\t\t\tclientSequenceNumber,\n\t\t\t\t\t\treferenceSequenceNumber,\n\t\t\t\t\t\topType: nacks[0]?.operation?.type,\n\t\t\t\t\t});\n\t\t\t\t\tif (handle) {\n\t\t\t\t\t\tthis.emit(\"nack\", clientIdOrDocumentId, nacks);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tsuper.addTrackedListener(event, listener);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tpublic get disposed() {\n\t\tif (!(this._disposed || this.socket.connected)) {\n\t\t\t// Send error event if this connection is not yet disposed after socket is disconnected for 15s.\n\t\t\tif (this.connectionNotYetDisposedTimeout === undefined) {\n\t\t\t\tthis.connectionNotYetDisposedTimeout = setTimeout(() => {\n\t\t\t\t\tif (!this._disposed) {\n\t\t\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\t\t\teventName: \"ConnectionNotYetDisposed\",\n\t\t\t\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}, 15000);\n\t\t\t}\n\t\t}\n\t\treturn this._disposed;\n\t}\n\n\t/**\n\t * Returns true in case the connection is not yet disposed and the socket is also connected. The expectation is\n\t * that it will be called only after connection is fully established. i.e. there should no way to submit an op\n\t * while we are connecting, as connection object is not exposed to Loader layer until connection is established.\n\t */\n\tprivate get connected(): boolean {\n\t\treturn !this.disposed && this.socket.connected;\n\t}\n\n\tprotected emitMessages(type: string, messages: IDocumentMessage[][]) {\n\t\t// Only submit the op/signals if we are connected.\n\t\tif (this.connected) {\n\t\t\tthis.socket.emit(type, this.clientId, messages);\n\t\t}\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t * @param message - delta operation to submit\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t}\n\n\t/**\n\t * Submits a new signal to the server\n\t *\n\t * @param content - Content of the signal.\n\t * @param targetClientId - When specified, the signal is only sent to the provided client id.\n\t */\n\tpublic submitSignal(content: IDocumentMessage, targetClientId?: string): void {\n\t\tconst signal: ISentSignalMessage = {\n\t\t\tcontent,\n\t\t\ttargetClientId,\n\t\t};\n\n\t\t// back-compat: the typing for this method and emitMessages is incorrect, will be fixed in a future PR\n\t\tthis.emitMessages(\"submitSignal\", [signal] as any);\n\t}\n\n\t/**\n\t * Critical path where we need to also close the socket for an error.\n\t * @param error - Error causing the socket to close.\n\t */\n\tprotected closeSocketCore(error: IAnyDriverError) {\n\t\tconst socket = this.socketReference;\n\t\tassert(socket !== undefined, 0x416 /* reentrancy not supported in close socket */);\n\t\tsocket.closeSocket(error);\n\t\tassert(\n\t\t\tthis.socketReference === undefined,\n\t\t\t0x417 /* disconnect flow did not work correctly */,\n\t\t);\n\t}\n\n\t/**\n\t * Disconnect from the websocket\n\t */\n\tprotected disconnectCore() {\n\t\tconst socket = this.socketReference;\n\t\tassert(socket !== undefined, 0x0a2 /* \"reentrancy not supported!\" */);\n\t\tthis.socketReference = undefined;\n\n\t\tsocket.off(\"disconnect\", this.disconnectHandler);\n\t\tif (this.hasDetails) {\n\t\t\t// tell the server we are disconnecting this client from the document\n\t\t\tthis.socket.emit(\"disconnect_document\", this.clientId, this.documentId);\n\t\t}\n\n\t\tsocket.removeSocketIoReference();\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspDocumentService.js","sourceRoot":"","sources":["../src/odspDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,4BAA4B,GAE5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAmBpD,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,y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AAI,CAAC,SAAS,GAAG,IAAI,QAAQ,CAC5B,SAAS,EACT,IAAI,CAAC,EAAE,CAAC,MAAM;QACd,SAAS;QACT;YACC,KAAK,EAAE,KAAK,EAAE,GAAW,EAAE,OAAe,EAAE,EAAE;gBAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;YACnE,CAAC;YACD,IAAI,EAAE,KAAK,EAAE,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC;YAC9E,MAAM,EAAE,GAAG,EAAE;gBACZ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAC3D,CAAC;SACD,EACD,SAAS,EACT,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,gBAAgB,IAAI,IAAI,EACpD,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,eAAe,IAAI,IAAI,CACnD,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,mHAAmH;IACnH,8EAA8E;IACpE,WAAW,CAAC,GAAgC;QACrD,2CAA2C;QAC3C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE;YACxD,OAAO;SACP;QAED,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryLoggerExt,\n\tcreateChildMonitoringContext,\n\tMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIResolvedUrl,\n\tIDocumentStorageService,\n\tIDocumentServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport { IClient, ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIOdspResolvedUrl,\n\tTokenFetchOptions,\n\tIEntry,\n\tHostStoragePolicy,\n\tInstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { HostStoragePolicyInternal } from \"./contracts\";\nimport { IOdspCache } from \"./odspCache\";\nimport { OdspDeltaStorageService, OdspDeltaStorageWithCache } from \"./odspDeltaStorageService\";\nimport { OdspDocumentStorageService } from \"./odspDocumentStorageManager\";\nimport { getOdspResolvedUrl } from \"./odspUtils\";\nimport { isOdcOrigin } from \"./odspUrlHelper\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { OpsCache } from \"./opsCaching\";\nimport { RetryErrorsStorageAdapter } from \"./retryErrorsStorageAdapter\";\nimport type { OdspDelayLoadedDeltaStream } from \"./odspDelayLoadedDeltaStream\";\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients\n */\nexport class OdspDocumentService implements IDocumentService {\n\tprivate readonly _policies: IDocumentServicePolicies;\n\n\t// Promise to load socket module only once.\n\tprivate socketModuleP: Promise<OdspDelayLoadedDeltaStream> | undefined;\n\n\tprivate odspDelayLoadedDeltaStream: OdspDelayLoadedDeltaStream | undefined;\n\n\tprivate odspSocketModuleLoaded: boolean = false;\n\n\t/**\n\t * @param resolvedUrl - resolved url identifying document that will be managed by returned service instance.\n\t * @param getStorageToken - function that can provide the storage token. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param logger - a logger that can capture performance and diagnostic information\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - This host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by returned service instance.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tpublic static async create(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tgetStorageToken: InstrumentedStorageTokenFetcher,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tgetWebsocketToken: ((options: TokenFetchOptions) => Promise<string | null>) | undefined,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tcache: IOdspCache,\n\t\thostPolicy: HostStoragePolicy,\n\t\tepochTracker: EpochTracker,\n\t\tsocketReferenceKeyPrefix?: string,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn new OdspDocumentService(\n\t\t\tgetOdspResolvedUrl(resolvedUrl),\n\t\t\tgetStorageToken,\n\t\t\tgetWebsocketToken,\n\t\t\tlogger,\n\t\t\tcache,\n\t\t\thostPolicy,\n\t\t\tepochTracker,\n\t\t\tsocketReferenceKeyPrefix,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n\n\tprivate storageManager?: OdspDocumentStorageService;\n\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate readonly hostPolicy: HostStoragePolicyInternal;\n\n\tprivate _opsCache?: OpsCache;\n\n\t/**\n\t * @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.\n\t * @param getStorageToken - function that can provide the storage token. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param logger - a logger that can capture performance and diagnostic information\n\t * @param socketIoClientFactory - A factory that returns a promise to the socket io library required by the driver\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by this service instance.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tprivate constructor(\n\t\tpublic readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tprivate readonly getStorageToken: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| ((options: TokenFetchOptions) => Promise<string | null>)\n\t\t\t| undefined,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly cache: IOdspCache,\n\t\thostPolicy: HostStoragePolicy,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly socketReferenceKeyPrefix?: string,\n\t\tprivate readonly clientIsSummarizer?: boolean,\n\t) {\n\t\tthis._policies = {\n\t\t\t// load in storage-only mode if a file version is specified\n\t\t\tstorageOnly: odspResolvedUrl.fileVersion !== undefined,\n\t\t\tsummarizeProtocolTree: true,\n\t\t};\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\todc: isOdcOrigin(\n\t\t\t\t\t\tnew URL(this.odspResolvedUrl.endpoints.snapshotStorageUrl).origin,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tthis.hostPolicy = hostPolicy;\n\t\tif (this.clientIsSummarizer) {\n\t\t\tthis.hostPolicy = { ...this.hostPolicy, summarizerClient: true };\n\t\t}\n\t}\n\n\tpublic get resolvedUrl(): IResolvedUrl {\n\t\treturn this.odspResolvedUrl;\n\t}\n\tpublic get policies() {\n\t\treturn this._policies;\n\t}\n\n\t/**\n\t * Connects to a storage endpoint for snapshot service.\n\t *\n\t * @returns returns the document storage service for sharepoint driver.\n\t */\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\tif (!this.storageManager) {\n\t\t\tthis.storageManager = new OdspDocumentStorageService(\n\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\tthis.getStorageToken,\n\t\t\t\tthis.mc.logger,\n\t\t\t\ttrue,\n\t\t\t\tthis.cache,\n\t\t\t\tthis.hostPolicy,\n\t\t\t\tthis.epochTracker,\n\t\t\t\t// flushCallback\n\t\t\t\tasync () => {\n\t\t\t\t\tconst currentConnection =\n\t\t\t\t\t\tthis.odspDelayLoadedDeltaStream?.currentDeltaConnection;\n\t\t\t\t\tif (currentConnection !== undefined && !currentConnection.disposed) {\n\t\t\t\t\t\treturn currentConnection.flush();\n\t\t\t\t\t}\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Disconnected while uploading summary (attempt to perform flush())\",\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\treturn this.odspDelayLoadedDeltaStream?.relayServiceTenantAndSessionId;\n\t\t\t\t},\n\t\t\t\tthis.mc.config.getNumber(\"Fluid.Driver.Odsp.snapshotFormatFetchType\"),\n\t\t\t);\n\t\t}\n\n\t\treturn new RetryErrorsStorageAdapter(this.storageManager, this.mc.logger);\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint for getting ops between a range.\n\t *\n\t * @returns returns the document delta storage service for sharepoint driver.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\tconst snapshotOps = this.storageManager?.ops ?? [];\n\t\tconst service = new OdspDeltaStorageService(\n\t\t\tthis.odspResolvedUrl.endpoints.deltaStorageUrl,\n\t\t\tthis.getStorageToken,\n\t\t\tthis.epochTracker,\n\t\t\tthis.mc.logger,\n\t\t);\n\n\t\t// batch size, please see issue #5211 for data around batch sizing\n\t\tconst batchSize = this.hostPolicy.opsBatchSize ?? 5000;\n\t\tconst concurrency = this.hostPolicy.concurrentOpsBatches ?? 1;\n\t\treturn new OdspDeltaStorageWithCache(\n\t\t\tsnapshotOps,\n\t\t\tthis.mc.logger,\n\t\t\tbatchSize,\n\t\t\tconcurrency,\n\t\t\t// Get Ops from storage callback.\n\t\t\tasync (from, to, telemetryProps, fetchReason) =>\n\t\t\t\tservice.get(from, to, telemetryProps, fetchReason),\n\t\t\t// Get cachedOps Callback.\n\t\t\tasync (from, to) => {\n\t\t\t\tconst res = await this.opsCache?.get(from, to);\n\t\t\t\treturn (res as ISequencedDocumentMessage[]) ?? [];\n\t\t\t},\n\t\t\t// Ops requestFromSocket Callback.\n\t\t\t(from, to) => {\n\t\t\t\tconst currentConnection = this.odspDelayLoadedDeltaStream?.currentDeltaConnection;\n\t\t\t\tif (currentConnection !== undefined && !currentConnection.disposed) {\n\t\t\t\t\tcurrentConnection.requestOps(from, to);\n\t\t\t\t}\n\t\t\t},\n\t\t\t(ops: ISequencedDocumentMessage[]) => this.opsReceived(ops),\n\t\t\t() => this.storageManager,\n\t\t);\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for onedrive/sharepoint driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tif (this.socketModuleP === undefined) {\n\t\t\tthis.socketModuleP = this.getDelayLoadedDeltaStream();\n\t\t}\n\t\treturn this.socketModuleP\n\t\t\t.then(async (m) => {\n\t\t\t\tthis.odspSocketModuleLoaded = true;\n\t\t\t\treturn m.connectToDeltaStream(client);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// Setting undefined in case someone tries to recover from module failure by calling again.\n\t\t\t\tthis.socketModuleP = undefined;\n\t\t\t\tthis.odspSocketModuleLoaded = false;\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * This dynamically imports the module for loading the delta connection. In many cases the delta stream, is not\n\t * required during the critical load flow. So this way we don't have to bundle this in the initial bundle and can\n\t * import this later on when required.\n\t * @returns The delta stream object.\n\t */\n\tprivate async getDelayLoadedDeltaStream() {\n\t\tassert(this.odspSocketModuleLoaded === false, 0x507 /* Should be loaded only once */);\n\t\tconst module = await import(\n\t\t\t/* webpackChunkName: \"socketModule\" */ \"./odspDelayLoadedDeltaStream\"\n\t\t)\n\t\t\t.then((m) => {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({ eventName: \"SocketModuleLoaded\" });\n\t\t\t\treturn m;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"SocketModuleLoadFailed\" }, error);\n\t\t\t\tthrow error;\n\t\t\t});\n\t\tthis.odspDelayLoadedDeltaStream = new module.OdspDelayLoadedDeltaStream(\n\t\t\tthis.odspResolvedUrl,\n\t\t\tthis._policies,\n\t\t\tthis.getStorageToken,\n\t\t\tthis.getWebsocketToken,\n\t\t\tthis.mc,\n\t\t\tthis.cache,\n\t\t\tthis.hostPolicy,\n\t\t\tthis.epochTracker,\n\t\t\t(ops: ISequencedDocumentMessage[]) => this.opsReceived(ops),\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t);\n\t\treturn this.odspDelayLoadedDeltaStream;\n\t}\n\n\tpublic dispose(error?: any) {\n\t\t// Error might indicate mismatch between client & server knowledge about file\n\t\t// (DriverErrorType.fileOverwrittenInStorage).\n\t\t// For example, file might have been overwritten in storage without generating new epoch\n\t\t// In such case client cached info is stale and has to be removed.\n\t\tif (error !== undefined) {\n\t\t\tthis.epochTracker.removeEntries().catch(() => {});\n\t\t} else {\n\t\t\tthis._opsCache?.flushOps();\n\t\t}\n\t\tthis._opsCache?.dispose();\n\t\t// Only need to dipose this, if it is already loaded.\n\t\tthis.odspDelayLoadedDeltaStream?.dispose();\n\t}\n\n\tprotected get opsCache() {\n\t\tif (this._opsCache) {\n\t\t\treturn this._opsCache;\n\t\t}\n\n\t\tconst seqNumber = this.storageManager?.snapshotSequenceNumber;\n\t\tconst batchSize = this.hostPolicy.opsCaching?.batchSize ?? 100;\n\t\tif (seqNumber === undefined || batchSize < 1) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst opsKey: Omit<IEntry, \"key\"> = {\n\t\t\ttype: \"ops\",\n\t\t};\n\t\tthis._opsCache = new OpsCache(\n\t\t\tseqNumber,\n\t\t\tthis.mc.logger,\n\t\t\t// ICache\n\t\t\t{\n\t\t\t\twrite: async (key: string, opsData: string) => {\n\t\t\t\t\treturn this.cache.persistedCache.put({ ...opsKey, key }, opsData);\n\t\t\t\t},\n\t\t\t\tread: async (key: string) => this.cache.persistedCache.get({ ...opsKey, key }),\n\t\t\t\tremove: () => {\n\t\t\t\t\tthis.cache.persistedCache.removeEntries().catch(() => {});\n\t\t\t\t},\n\t\t\t},\n\t\t\tbatchSize,\n\t\t\tthis.hostPolicy.opsCaching?.timerGranularity ?? 5000,\n\t\t\tthis.hostPolicy.opsCaching?.totalOpsToCache ?? 5000,\n\t\t);\n\t\treturn this._opsCache;\n\t}\n\n\t// Called whenever re receive ops through any channel for this document (snapshot, delta connection, delta storage)\n\t// We use it to notify caching layer of how stale is snapshot stored in cache.\n\tprotected opsReceived(ops: ISequencedDocumentMessage[]) {\n\t\t// No need for two clients to save same ops\n\t\tif (ops.length === 0 || this.odspResolvedUrl.summarizer) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.opsCache?.addOps(ops);\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspDocumentServiceFactory.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,sDAAsD;AACtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,mDAAmD,CAAC;AAEpG;;;;GAIG;AACH,MAAM,OAAO,0BAA2B,SAAQ,8BAA8B;IAC7E,YACC,eAA4D,EAC5D,iBAA0E,EAC1E,cAAgC,EAChC,UAA8B;QAE9B,KAAK,CAAC,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;IACvE,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,qCAAqC,CACpD,aAAkC;IAElC,OAAO,IAAI,+BAA+B,CAAC,aAAa,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentServiceFactory } from \"@fluidframework/driver-definitions\";\nimport {\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n\tIPersistedCache,\n\tHostStoragePolicy,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { OdspDocumentServiceFactoryCore } from \"./odspDocumentServiceFactoryCore\";\n// eslint-disable-next-line import/no-internal-modules\nimport { LocalOdspDocumentServiceFactory } from \"./localOdspDriver/localOdspDocumentServiceFactory\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n * @public\n */\nexport class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {\n\tconstructor(\n\t\tgetStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tgetWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n\t\tpersistedCache?: IPersistedCache,\n\t\thostPolicy?: HostStoragePolicy,\n\t) {\n\t\tsuper(getStorageToken, getWebsocketToken, persistedCache, hostPolicy);\n\t}\n}\n\n/**\n * @public\n */\nexport function createLocalOdspDocumentServiceFactory(\n\tlocalSnapshot: Uint8Array | string,\n): IDocumentServiceFactory {\n\treturn new LocalOdspDocumentServiceFactory(localSnapshot);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspDocumentServiceFactoryCore.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACN,mCAAmC,EACnC,+BAA+B,GAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAQN,gBAAgB,EAChB,eAAe,EACf,cAAc,GAId,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAuB,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA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B,CAAC,MAAM,CAChC,WAAW,EACX,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,eAAe,CAAC,KAAK,EACrB,IAAI,CAAC,UAAU,EACf,eAAe,CAAC,YAAY,EAC5B,IAAI,CAAC,wBAAwB,EAC7B,kBAAkB,CAClB,CAAC;IACH,CAAC;CACD;AAED;;GAEG;AACH,SAAS,oBAAoB,CAC5B,UAA6B,EAC7B,YAA6B;IAE7B,kGAAkG;IAClG,IAAI,oBAAmE,CAAC;IACxE,IAAI,UAAU,CAAC,yCAAyC,EAAE;QACzD,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC5D,MAAM,cAAc,GAAG,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,eAAe,IAAI,gBAAgB,CAAC,eAAe,CAAC,EAAE;YACzD,oBAAoB,GAAG;gBACtB,KAAK,EAAE,gBAAgB,CAAC,eAAe,CAAC;gBACxC,GAAG,CAAC,cAAc,IAAI,eAAe,CAAC,cAAc,CAAC;oBACpD,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,cAAc,CAAC,EAAE;oBAC3C,CAAC,CAAC,EAAE,CAAC;aACN,CAAC;SACF;KACD;SAAM,IAAI,UAAU,CAAC,yBAAyB,EAAE;QAChD,MAAM,cAAc,GAAG,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,cAAc,IAAI,cAAc,CAAC,cAAc,CAAC,EAAE;YACrD,oBAAoB,GAAG,cAAc,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;SAC5D;KACD;IACD,OAAO,oBAAoB,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/core-interfaces\";\nimport {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport {\n\tTokenFetchOptions,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n\tIPersistedCache,\n\tHostStoragePolicy,\n\tIFileEntry,\n\tIOdspUrlParts,\n\tSharingLinkScope,\n\tSharingLinkRole,\n\tShareLinkTypes,\n\tISharingLinkKind,\n\tISocketStorageDiscovery,\n\tIRelaySessionAwareDriverFactory,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport { INonPersistentCache, LocalPersistentCache, NonPersistentCache } from \"./odspCache\";\nimport { createOdspCacheAndTracker, ICacheAndTracker } from \"./epochTracker\";\nimport { OdspDocumentService } from \"./odspDocumentService\";\nimport {\n\tINewFileInfo,\n\tgetOdspResolvedUrl,\n\tcreateOdspLogger,\n\ttoInstrumentedOdspTokenFetcher,\n\tIExistingFileInfo,\n\tisNewFileInfo,\n\tgetJoinSessionCacheKey,\n} from \"./odspUtils\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n *\n * This constructor should be used by environments that support dynamic imports and that wish\n * to leverage code splitting as a means to keep bundles as small as possible.\n * @public\n */\nexport class OdspDocumentServiceFactoryCore\n\timplements IDocumentServiceFactory, IRelaySessionAwareDriverFactory\n{\n\tprivate readonly nonPersistentCache: INonPersistentCache = new NonPersistentCache();\n\tprivate readonly socketReferenceKeyPrefix?: string;\n\n\tpublic get snapshotPrefetchResultCache() {\n\t\treturn this.nonPersistentCache.snapshotPrefetchResultCache;\n\t}\n\n\tpublic get IRelaySessionAwareDriverFactory() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * This function would return info about relay service session only if this factory established (or attempted to\n\t * establish) connection very recently. Otherwise, it will return undefined.\n\t * @param resolvedUrl - resolved url for container\n\t * @returns The current join session response stored in cache. `undefined` if not present.\n\t */\n\tpublic async getRelayServiceSessionInfo(\n\t\tresolvedUrl: IResolvedUrl,\n\t): Promise<ISocketStorageDiscovery | undefined> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst joinSessionResponse = await this.nonPersistentCache.sessionJoinCache.get(\n\t\t\tgetJoinSessionCacheKey(odspResolvedUrl),\n\t\t);\n\t\treturn joinSessionResponse?.joinSessionResponse;\n\t}\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tcreateNewResolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tlet odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tlet fileInfo: INewFileInfo | IExistingFileInfo;\n\t\tlet createShareLinkParam: ShareLinkTypes | ISharingLinkKind | undefined;\n\t\tif (odspResolvedUrl.itemId) {\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"Existing\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\titemId: odspResolvedUrl.itemId,\n\t\t\t};\n\t\t} else if (odspResolvedUrl.fileName) {\n\t\t\tconst [, queryString] = odspResolvedUrl.url.split(\"?\");\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tif (filePath === undefined || filePath === null) {\n\t\t\t\tthrow new Error(\"File path should be provided!!\");\n\t\t\t}\n\t\t\tcreateShareLinkParam = getSharingLinkParams(this.hostPolicy, searchParams);\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"New\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\tfilePath,\n\t\t\t\tfilename: odspResolvedUrl.fileName,\n\t\t\t\tcreateLinkType: createShareLinkParam,\n\t\t\t};\n\t\t} else {\n\t\t\tthrow new Error(\"A new or existing file must be specified to create container!\");\n\t\t}\n\n\t\tif (isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(\n\t\t\t\tcreateNewSummary.tree[\".protocol\"],\n\t\t\t);\n\t\t\tif (documentAttributes?.sequenceNumber !== 0) {\n\t\t\t\tthrow new Error(\"Seq number in detached ODSP container should be 0\");\n\t\t\t}\n\t\t}\n\n\t\tconst odspLogger = createOdspLogger(logger);\n\n\t\tconst fileEntry: IFileEntry = {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t};\n\t\tconst cacheAndTracker = createOdspCacheAndTracker(\n\t\t\tthis.persistedCache,\n\t\t\tthis.nonPersistentCache,\n\t\t\tfileEntry,\n\t\t\todspLogger,\n\t\t\tclientIsSummarizer,\n\t\t);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\todspLogger,\n\t\t\t{\n\t\t\t\teventName: \"CreateNew\",\n\t\t\t\tisWithSummaryUpload: true,\n\t\t\t\tcreateShareLinkParam: createShareLinkParam\n\t\t\t\t\t? JSON.stringify(createShareLinkParam)\n\t\t\t\t\t: undefined,\n\t\t\t\tenableShareLinkWithCreate: this.hostPolicy.enableShareLinkWithCreate,\n\t\t\t\tenableSingleRequestForShareLinkWithCreate:\n\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst getStorageToken = toInstrumentedOdspTokenFetcher(\n\t\t\t\t\todspLogger,\n\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\tthis.getStorageToken,\n\t\t\t\t\ttrue /* throwOnNullToken */,\n\t\t\t\t);\n\t\t\t\t// We can delay load this module as this path will not be executed in load flows and create flow\n\t\t\t\t// while only happens once in lifetime of a document happens in the background after creation of\n\t\t\t\t// detached container.\n\t\t\t\tconst module = await import(\n\t\t\t\t\t/* webpackChunkName: \"createNewModule\" */ \"./createNewModule\"\n\t\t\t\t)\n\t\t\t\t\t.then((m) => {\n\t\t\t\t\t\todspLogger.sendTelemetryEvent({ eventName: \"createNewModuleLoaded\" });\n\t\t\t\t\t\treturn m;\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error) => {\n\t\t\t\t\t\todspLogger.sendErrorEvent(\n\t\t\t\t\t\t\t{ eventName: \"createNewModuleLoadFailed\" },\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t});\n\t\t\t\todspResolvedUrl = isNewFileInfo(fileInfo)\n\t\t\t\t\t? await module.createNewFluidFile(\n\t\t\t\t\t\t\tgetStorageToken,\n\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions\n\t\t\t\t\t\t\t\t?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t\t\t\t\tthis.hostPolicy.enableShareLinkWithCreate,\n\t\t\t\t\t )\n\t\t\t\t\t: await module.createNewContainerOnExistingFile(\n\t\t\t\t\t\t\tgetStorageToken,\n\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions\n\t\t\t\t\t\t\t\t?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t );\n\t\t\t\tconst docService = this.createDocumentServiceCore(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\todspLogger,\n\t\t\t\t\tcacheAndTracker,\n\t\t\t\t\tclientIsSummarizer,\n\t\t\t\t);\n\t\t\t\tevent.end({\n\t\t\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t\t\t});\n\t\t\t\treturn docService;\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * @param getStorageToken - function that can provide the storage token for a given site. This is\n\t * is also referred to as the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param persistedCache - PersistedCache provided by host for use in this session.\n\t * @param hostPolicy - Policy for storage provided by host.\n\t */\n\tconstructor(\n\t\tprivate readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tprivate readonly getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n\t\tprotected persistedCache: IPersistedCache = new LocalPersistentCache(),\n\t\tprivate readonly hostPolicy: HostStoragePolicy = {},\n\t) {\n\t\tif (this.hostPolicy.isolateSocketCache === true) {\n\t\t\t// create the key to separate the socket reuse cache\n\t\t\tthis.socketReferenceKeyPrefix = uuid();\n\t\t}\n\t\t// Set enableRedeemFallback by default as true.\n\t\tthis.hostPolicy.enableRedeemFallback = this.hostPolicy.enableRedeemFallback ?? true;\n\t\tthis.hostPolicy.sessionOptions = {\n\t\t\tforceAccessTokenViaAuthorizationHeader: true,\n\t\t\t...this.hostPolicy.sessionOptions,\n\t\t};\n\t}\n\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn this.createDocumentServiceCore(\n\t\t\tresolvedUrl,\n\t\t\tcreateOdspLogger(logger),\n\t\t\tundefined,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n\n\tprotected async createDocumentServiceCore(\n\t\tresolvedUrl: IResolvedUrl,\n\t\todspLogger: ITelemetryLogger,\n\t\tcacheAndTrackerArg?: ICacheAndTracker,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\t\tconst cacheAndTracker =\n\t\t\tcacheAndTrackerArg ??\n\t\t\tcreateOdspCacheAndTracker(\n\t\t\t\tthis.persistedCache,\n\t\t\t\tthis.nonPersistentCache,\n\t\t\t\t{ resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId },\n\t\t\t\todspLogger,\n\t\t\t\tclientIsSummarizer,\n\t\t\t);\n\n\t\tconst storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n\t\t\todspLogger,\n\t\t\tresolvedUrlData,\n\t\t\tthis.getStorageToken,\n\t\t\ttrue /* throwOnNullToken */,\n\t\t);\n\n\t\tconst webSocketTokenFetcher =\n\t\t\tthis.getWebsocketToken === undefined\n\t\t\t\t? undefined\n\t\t\t\t: async (options: TokenFetchOptions) =>\n\t\t\t\t\t\ttoInstrumentedOdspTokenFetcher(\n\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\t\t\tthis.getWebsocketToken!,\n\t\t\t\t\t\t\tfalse /* throwOnNullToken */,\n\t\t\t\t\t\t)(options, \"GetWebsocketToken\");\n\n\t\treturn OdspDocumentService.create(\n\t\t\tresolvedUrl,\n\t\t\tstorageTokenFetcher,\n\t\t\twebSocketTokenFetcher,\n\t\t\todspLogger,\n\t\t\tcacheAndTracker.cache,\n\t\t\tthis.hostPolicy,\n\t\t\tcacheAndTracker.epochTracker,\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n}\n\n/**\n * Extract the sharing link kind from the resolved URL's query paramerters\n */\nfunction getSharingLinkParams(\n\thostPolicy: HostStoragePolicy,\n\tsearchParams: URLSearchParams,\n): ShareLinkTypes | ISharingLinkKind | undefined {\n\t// extract request parameters for creation of sharing link (if provided) if the feature is enabled\n\tlet createShareLinkParam: ShareLinkTypes | ISharingLinkKind | undefined;\n\tif (hostPolicy.enableSingleRequestForShareLinkWithCreate) {\n\t\tconst createLinkScope = searchParams.get(\"createLinkScope\");\n\t\tconst createLinkRole = searchParams.get(\"createLinkRole\");\n\t\tif (createLinkScope && SharingLinkScope[createLinkScope]) {\n\t\t\tcreateShareLinkParam = {\n\t\t\t\tscope: SharingLinkScope[createLinkScope],\n\t\t\t\t...(createLinkRole && SharingLinkRole[createLinkRole]\n\t\t\t\t\t? { role: SharingLinkRole[createLinkRole] }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t}\n\t} else if (hostPolicy.enableShareLinkWithCreate) {\n\t\tconst createLinkType = searchParams.get(\"createLinkType\");\n\t\tif (createLinkType && ShareLinkTypes[createLinkType]) {\n\t\t\tcreateShareLinkParam = ShareLinkTypes[createLinkType || \"\"];\n\t\t}\n\t}\n\treturn createShareLinkParam;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspDocumentServiceFactoryWithCodeSplit.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryWithCodeSplit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF;;;;GAIG;AACH,MAAM,OAAO,uCACZ,SAAQ,8BAA8B;IAGtC,YACC,eAA4D,EAC5D,iBAA0E,EAC1E,cAAgC,EAChC,UAA8B;QAE9B,KAAK,CAAC,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;IACvE,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentServiceFactory } from \"@fluidframework/driver-definitions\";\nimport {\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n\tIPersistedCache,\n\tHostStoragePolicy,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { OdspDocumentServiceFactoryCore } from \"./odspDocumentServiceFactoryCore\";\n\n/**\n * @deprecated This is deprecated in favour of OdspDocumentServiceFactory as the socket io is now loaded inside the\n * other dynamically imported module.\n * @public\n */\nexport class OdspDocumentServiceFactoryWithCodeSplit\n\textends OdspDocumentServiceFactoryCore\n\timplements IDocumentServiceFactory\n{\n\tconstructor(\n\t\tgetStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tgetWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n\t\tpersistedCache?: IPersistedCache,\n\t\thostPolicy?: HostStoragePolicy,\n\t) {\n\t\tsuper(getStorageToken, getWebsocketToken, persistedCache, hostPolicy);\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspDocumentStorageManager.js","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,aAAa,EAEb,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,gBAAgB,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,WAA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,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tgenerateStack,\n\tITelemetryLoggerExt,\n\tloggerToMonitoringContext,\n\tnormalizeError,\n\toverwriteStack,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { assert, delay } from \"@fluidframework/core-utils\";\nimport { LogLevel } from \"@fluidframework/core-interfaces\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { promiseRaceWithWinner } from \"@fluidframework/driver-base\";\nimport { ISummaryContext, DriverErrorType, FetchSource } from \"@fluidframework/driver-definitions\";\nimport { RateLimiter, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport {\n\tIOdspResolvedUrl,\n\tISnapshotOptions,\n\tOdspErrorType,\n\tInstrumentedStorageTokenFetcher,\n\tgetKeyForCacheEntry,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport {\n\tIDocumentStorageGetVersionsResponse,\n\tHostStoragePolicyInternal,\n\tIVersionedValueWithEpoch,\n\tISnapshotCachedEntry,\n} from \"./contracts\";\nimport {\n\tdownloadSnapshot,\n\tevalBlobsAndTrees,\n\tfetchSnapshot,\n\tfetchSnapshotWithRedeem,\n\tSnapshotFormatSupportType,\n} from \"./fetchSnapshot\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { IOdspCache, IPrefetchSnapshotContents } from \"./odspCache\";\nimport { createCacheSnapshotKey, getWithRetryForTokenRefresh } from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { EpochTracker } from \"./epochTracker\";\nimport type { OdspSummaryUploadManager } from \"./odspSummaryUploadManager\";\nimport { FlushResult } from \"./odspDocumentDeltaConnection\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { OdspDocumentStorageServiceBase } from \"./odspDocumentStorageServiceBase\";\n\nexport const defaultSummarizerCacheExpiryTimeout: number = 60 * 1000; // 60 seconds.\n\ninterface GetVersionsTelemetryProps {\n\tcacheEntryAge?: number;\n\tcacheSummarizerExpired?: boolean;\n}\n\nexport class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {\n\tprivate odspSummaryModuleLoaded: boolean = false;\n\tprivate summaryModuleP: Promise<OdspSummaryUploadManager> | undefined;\n\tprivate odspSummaryUploadManager: OdspSummaryUploadManager | undefined;\n\n\tprivate firstVersionCall = true;\n\tprivate _isFirstSnapshotFromNetwork: boolean | undefined;\n\tprivate readonly documentId: string;\n\tprivate readonly snapshotUrl: string | undefined;\n\tprivate readonly attachmentPOSTUrl: string | undefined;\n\tprivate readonly attachmentGETUrl: string | undefined;\n\t// Driver specified limits for snapshot size and time.\n\t/**\n\t * NOTE: While commit cfff6e3 added restrictions to prevent large payloads, snapshot failures will continue to\n\t * happen until blob request throttling is implemented. Until then, as a temporary fix we set arbitrarily large\n\t * snapshot size and timeout limits so that such failures are unlikely to occur.\n\t */\n\tprivate readonly maxSnapshotSizeLimit = 500000000; // 500 MB\n\tprivate readonly maxSnapshotFetchTimeout = 120000; // 2 min\n\n\t// limits the amount of parallel \"attachment\" blob uploads\n\tprivate readonly createBlobRateLimiter = new RateLimiter(1);\n\n\tconstructor(\n\t\tprivate readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tprivate readonly getStorageToken: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly fetchFullSnapshot: boolean,\n\t\tprivate readonly cache: IOdspCache,\n\t\tprivate readonly hostPolicy: HostStoragePolicyInternal,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly flushCallback: () => Promise<FlushResult>,\n\t\tprivate readonly relayServiceTenantAndSessionId: () => string | undefined,\n\t\tprivate readonly snapshotFormatFetchType?: SnapshotFormatSupportType,\n\t) {\n\t\tsuper(loggerToMonitoringContext(logger).config);\n\n\t\tthis.documentId = this.odspResolvedUrl.hashedDocumentId;\n\t\tthis.snapshotUrl = this.odspResolvedUrl.endpoints.snapshotStorageUrl;\n\t\tthis.attachmentPOSTUrl = this.odspResolvedUrl.endpoints.attachmentPOSTStorageUrl;\n\t\tthis.attachmentGETUrl = this.odspResolvedUrl.endpoints.attachmentGETStorageUrl;\n\t}\n\n\tpublic get isFirstSnapshotFromNetwork() {\n\t\treturn this._isFirstSnapshotFromNetwork;\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse> {\n\t\tthis.checkAttachmentPOSTUrl();\n\n\t\tconst response = await getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst storageToken = await this.getStorageToken(options, \"CreateBlob\");\n\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\t`${this.attachmentPOSTUrl}/content`,\n\t\t\t\tstorageToken,\n\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t);\n\t\t\theaders[\"Content-Type\"] = \"application/octet-stream\";\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"createBlob\",\n\t\t\t\t\tsize: file.byteLength,\n\t\t\t\t\twaitQueueLength: this.createBlobRateLimiter.waitQueueLength,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tconst res = await this.createBlobRateLimiter.schedule(async () =>\n\t\t\t\t\t\tthis.epochTracker.fetchAndParseAsJSON<api.ICreateBlobResponse>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: file,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"createBlob\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\tblobId: res.content.id,\n\t\t\t\t\t\t...res.propsToLog,\n\t\t\t\t\t});\n\t\t\t\t\treturn res;\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\n\t\treturn response.content;\n\t}\n\n\tprotected async fetchBlobFromStorage(blobId: string, evicted: boolean): Promise<ArrayBuffer> {\n\t\tthis.checkAttachmentGETUrl();\n\n\t\tconst blob = await getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst storageToken = await this.getStorageToken(options, \"GetBlob\");\n\t\t\tconst unAuthedUrl = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;\n\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\tunAuthedUrl,\n\t\t\t\tstorageToken,\n\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t);\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"readDataBlob\",\n\t\t\t\t\tblobId,\n\t\t\t\t\tevicted,\n\t\t\t\t\theaders: Object.keys(headers).length !== 0 ? true : undefined,\n\t\t\t\t\twaitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tconst res = await this.epochTracker.fetchArray(url, { headers }, \"blob\");\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\twaitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n\t\t\t\t\t\t...res.propsToLog,\n\t\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\t});\n\t\t\t\t\tconst cacheControl = res.headers.get(\"cache-control\");\n\t\t\t\t\tif (\n\t\t\t\t\t\tcacheControl === undefined ||\n\t\t\t\t\t\t!(cacheControl.includes(\"private\") || cacheControl.includes(\"public\"))\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\t\t\teventName: \"NonCacheableBlob\",\n\t\t\t\t\t\t\tcacheControl,\n\t\t\t\t\t\t\tblobId,\n\t\t\t\t\t\t\t...res.propsToLog,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn res.content;\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t\tthis.blobCache.setBlob(blobId, blob);\n\t\treturn blob;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: api.IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<api.ISnapshotTree | null> {\n\t\tif (!this.snapshotUrl) {\n\t\t\treturn null;\n\t\t}\n\t\treturn super.getSnapshotTree(version, scenarioName);\n\t}\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\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<api.IVersion[]> {\n\t\t// Regular load workflow uses blobId === documentID to indicate \"latest\".\n\t\tif (blobid !== this.documentId && blobid) {\n\t\t\t// FluidFetch & FluidDebugger tools use empty sting to query for versions\n\t\t\t// In such case we need to make a call against SPO to give full picture to the tool.\n\t\t\t// Otherwise, each commit calls getVersions but odsp doesn't have a history for each commit\n\t\t\t// return the blobid as is\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: blobid,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// Can't really make a call if we do not have URL\n\t\tif (!this.snapshotUrl) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// If count is one, we can use the trees/latest API, which returns the latest version and trees in a single request for better performance\n\t\tif (count === 1 && (blobid === null || blobid === this.documentId)) {\n\t\t\tconst hostSnapshotOptions = this.hostPolicy.snapshotOptions;\n\t\t\tconst odspSnapshotCacheValue: ISnapshotContents = await PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{ eventName: \"ObtainSnapshot\", fetchSource },\n\t\t\t\tasync (event: PerformanceEvent) => {\n\t\t\t\t\tconst props: GetVersionsTelemetryProps = {};\n\t\t\t\t\tlet cacheLookupTimeInSerialFetch = 0;\n\t\t\t\t\tlet retrievedSnapshot:\n\t\t\t\t\t\t| ISnapshotContents\n\t\t\t\t\t\t| IPrefetchSnapshotContents\n\t\t\t\t\t\t| undefined;\n\n\t\t\t\t\tlet method: string;\n\t\t\t\t\tlet prefetchWaitStartTime: number = performance.now();\n\t\t\t\t\tif (fetchSource === FetchSource.noCache) {\n\t\t\t\t\t\tretrievedSnapshot = await this.fetchSnapshot(\n\t\t\t\t\t\t\thostSnapshotOptions,\n\t\t\t\t\t\t\tscenarioName,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tmethod = \"networkOnly\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Here's the logic to grab the persistent cache snapshot implemented by the host\n\t\t\t\t\t\t// Epoch tracker is responsible for communicating with the persistent cache, handling epochs and cache versions\n\t\t\t\t\t\tconst cachedSnapshotP: Promise<ISnapshotContents | undefined> =\n\t\t\t\t\t\t\tthis.epochTracker\n\t\t\t\t\t\t\t\t.get(createCacheSnapshotKey(this.odspResolvedUrl))\n\t\t\t\t\t\t\t\t.then(async (snapshotCachedEntry: ISnapshotCachedEntry) => {\n\t\t\t\t\t\t\t\t\tif (snapshotCachedEntry !== undefined) {\n\t\t\t\t\t\t\t\t\t\t// If the cached entry does not contain the entry time, then assign it a default of 30 days old.\n\t\t\t\t\t\t\t\t\t\tconst age =\n\t\t\t\t\t\t\t\t\t\t\tDate.now() -\n\t\t\t\t\t\t\t\t\t\t\t(snapshotCachedEntry.cacheEntryTime ??\n\t\t\t\t\t\t\t\t\t\t\t\tDate.now() - 30 * 24 * 60 * 60 * 1000);\n\n\t\t\t\t\t\t\t\t\t\t// In order to decrease the number of times we have to execute a snapshot refresh,\n\t\t\t\t\t\t\t\t\t\t// if this is the summarizer and we have a cache entry but it is past the defaultSummarizerCacheExpiryTimeout,\n\t\t\t\t\t\t\t\t\t\t// force the network retrieval instead as there might be a more recent snapshot available.\n\t\t\t\t\t\t\t\t\t\t// See: https://github.com/microsoft/FluidFramework/issues/8995 for additional information.\n\t\t\t\t\t\t\t\t\t\tif (this.hostPolicy.summarizerClient) {\n\t\t\t\t\t\t\t\t\t\t\tif (age > defaultSummarizerCacheExpiryTimeout) {\n\t\t\t\t\t\t\t\t\t\t\t\tprops.cacheSummarizerExpired = true;\n\t\t\t\t\t\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\tprops.cacheSummarizerExpired = false;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t// Record the cache age\n\t\t\t\t\t\t\t\t\t\tprops.cacheEntryAge = age;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn snapshotCachedEntry;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t// Based on the concurrentSnapshotFetch policy:\n\t\t\t\t\t\t// Either retrieve both the network and cache snapshots concurrently and pick the first to return,\n\t\t\t\t\t\t// or grab the cache value and then the network value if the cache value returns undefined.\n\t\t\t\t\t\t// For summarizer which could call this during refreshing of summary parent, always use the cache\n\t\t\t\t\t\t// first. Also for other clients, if it is not critical path which is determined by firstVersionCall,\n\t\t\t\t\t\t// then also check the cache first.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis.firstVersionCall &&\n\t\t\t\t\t\t\tthis.hostPolicy.concurrentSnapshotFetch &&\n\t\t\t\t\t\t\t!this.hostPolicy.summarizerClient\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst networkSnapshotP = this.fetchSnapshot(\n\t\t\t\t\t\t\t\thostSnapshotOptions,\n\t\t\t\t\t\t\t\tscenarioName,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Ensure that failures on both paths are ignored initially.\n\t\t\t\t\t\t\t// I.e. if cache fails for some reason, we will proceed with network result.\n\t\t\t\t\t\t\t// And vice versa - if (for example) client is offline and network request fails first, we\n\t\t\t\t\t\t\t// do want to attempt to succeed with cached data!\n\t\t\t\t\t\t\tconst promiseRaceWinner = await promiseRaceWithWinner([\n\t\t\t\t\t\t\t\tcachedSnapshotP.catch(() => undefined),\n\t\t\t\t\t\t\t\tnetworkSnapshotP.catch(() => undefined),\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\tretrievedSnapshot = promiseRaceWinner.value;\n\t\t\t\t\t\t\tmethod = promiseRaceWinner.index === 0 ? \"cache\" : \"network\";\n\n\t\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\t\t// if network failed -> wait for cache ( then return network failure)\n\t\t\t\t\t\t\t\t// If cache returned empty or failed -> wait for network (success of failure)\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tif (promiseRaceWinner.index === 1) {\n\t\t\t\t\t\t\t\t\t\tretrievedSnapshot = await cachedSnapshotP;\n\t\t\t\t\t\t\t\t\t\tmethod = \"cache\";\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\t\t\t\tretrievedSnapshot = await networkSnapshotP;\n\t\t\t\t\t\t\t\t\t\tmethod = \"network\";\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} catch (err: unknown) {\n\t\t\t\t\t\t\t\t\t// The call stacks of any errors thrown by cached snapshot or network snapshot aren't very useful:\n\t\t\t\t\t\t\t\t\t// they get truncated at this stack frame due to the promise race and how v8 tracks async stack traces--\n\t\t\t\t\t\t\t\t\t// see https://v8.dev/docs/stack-trace-api#async-stack-traces and the \"zero-cost async stack traces\" document\n\t\t\t\t\t\t\t\t\t// linked there. https://v8.dev/blog/fast-async#await-under-the-hood may also be helpful for context on internals.\n\t\t\t\t\t\t\t\t\t// Regenerating the stack at this level provides more information for logged errors.\n\t\t\t\t\t\t\t\t\t// Once FF uses an ES2021 target, we could convert the above promise race to use `Promise.any` + AggregateError and\n\t\t\t\t\t\t\t\t\t// get similar quality stacks with less hand-crafted code.\n\t\t\t\t\t\t\t\t\tconst innerStack = (err as Error).stack;\n\t\t\t\t\t\t\t\t\tconst normalizedError = normalizeError(err);\n\t\t\t\t\t\t\t\t\tnormalizedError.addTelemetryProperties({ innerStack });\n\n\t\t\t\t\t\t\t\t\tconst newStack = `<<STACK TRUNCATED: see innerStack property>> \\n${generateStack()}`;\n\t\t\t\t\t\t\t\t\toverwriteStack(normalizedError, newStack);\n\n\t\t\t\t\t\t\t\t\tthrow normalizedError;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Note: There's a race condition here - another caller may come past the undefined check\n\t\t\t\t\t\t\t// while the first caller is awaiting later async code in this block.\n\t\t\t\t\t\t\tconst startTime = performance.now();\n\t\t\t\t\t\t\tretrievedSnapshot = await cachedSnapshotP;\n\t\t\t\t\t\t\tcacheLookupTimeInSerialFetch = performance.now() - startTime;\n\t\t\t\t\t\t\tmethod = retrievedSnapshot !== undefined ? \"cache\" : \"network\";\n\n\t\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\t\tprefetchWaitStartTime = performance.now();\n\t\t\t\t\t\t\t\tretrievedSnapshot = await this.fetchSnapshot(\n\t\t\t\t\t\t\t\t\thostSnapshotOptions,\n\t\t\t\t\t\t\t\t\tscenarioName,\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}\n\t\t\t\t\tif (method === \"network\") {\n\t\t\t\t\t\tprops.cacheEntryAge = undefined;\n\t\t\t\t\t}\n\t\t\t\t\tif (this.firstVersionCall) {\n\t\t\t\t\t\tthis._isFirstSnapshotFromNetwork = method === \"cache\" ? false : true;\n\t\t\t\t\t}\n\t\t\t\t\tconst prefetchStartTime: number | undefined = (\n\t\t\t\t\t\tretrievedSnapshot as IPrefetchSnapshotContents\n\t\t\t\t\t).prefetchStartTime;\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\tavoidPrefetchSnapshotCache: this.hostPolicy.avoidPrefetchSnapshotCache,\n\t\t\t\t\t\t...evalBlobsAndTrees(retrievedSnapshot),\n\t\t\t\t\t\tcacheLookupTimeInSerialFetch,\n\t\t\t\t\t\tprefetchSavedDuration:\n\t\t\t\t\t\t\tprefetchStartTime !== undefined && method !== \"cache\"\n\t\t\t\t\t\t\t\t? prefetchWaitStartTime - prefetchStartTime\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t});\n\t\t\t\t\treturn retrievedSnapshot;\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tconst stTime = performance.now();\n\t\t\t// Don't override ops which were fetched during initial load, since we could still need them.\n\t\t\tconst id = this.initializeFromSnapshot(odspSnapshotCacheValue, this.firstVersionCall);\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"SnapshotInitializeTime\",\n\t\t\t\t\tduration: performance.now() - stTime,\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\tLogLevel.verbose,\n\t\t\t);\n\t\t\tthis.firstVersionCall = false;\n\n\t\t\treturn id ? [{ id, treeId: undefined! }] : [];\n\t\t}\n\n\t\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst storageToken = await this.getStorageToken(options, \"GetVersions\");\n\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\t`${this.snapshotUrl}/versions?top=${count}`,\n\t\t\t\tstorageToken,\n\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t);\n\n\t\t\t// Fetch the latest snapshot versions for the document\n\t\t\tconst response = await PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"getVersions\",\n\t\t\t\t\theaders: Object.keys(headers).length !== 0 ? true : undefined,\n\t\t\t\t},\n\t\t\t\tasync () =>\n\t\t\t\t\tthis.epochTracker.fetchAndParseAsJSON<IDocumentStorageGetVersionsResponse>(\n\t\t\t\t\t\turl,\n\t\t\t\t\t\t{ headers },\n\t\t\t\t\t\t\"versions\",\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tscenarioName,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tconst versionsResponse = response.content;\n\t\t\tif (!versionsResponse) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"No response from /versions endpoint\",\n\t\t\t\t\tDriverErrorType.genericNetworkError,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!Array.isArray(versionsResponse.value)) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"Incorrect response from /versions endpoint, expected an array\",\n\t\t\t\t\tDriverErrorType.genericNetworkError,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn versionsResponse.value.map((version) => {\n\t\t\t\treturn {\n\t\t\t\t\tid: version.id,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate async fetchSnapshot(\n\t\thostSnapshotOptions: ISnapshotOptions | undefined,\n\t\tscenarioName?: string,\n\t) {\n\t\treturn this.fetchSnapshotCore(hostSnapshotOptions, scenarioName).catch((error) => {\n\t\t\t// Issue #5895:\n\t\t\t// If we are offline, this error is retryable. But that means that RetriableDocumentStorageService\n\t\t\t// will run in circles calling getSnapshotTree, which would result in OdspDocumentStorageService class\n\t\t\t// going getVersions / individual blob download path. This path is very slow, and will not work with\n\t\t\t// delay-loaded data stores and ODSP storage deleting old snapshots and blobs.\n\t\t\tif (typeof error === \"object\" && error !== null) {\n\t\t\t\terror.canRetry = false;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tprivate async fetchSnapshotCore(\n\t\thostSnapshotOptions: ISnapshotOptions | undefined,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotContents | IPrefetchSnapshotContents> {\n\t\t// Don't look into cache, if the host specifically tells us so.\n\t\tif (!this.hostPolicy.avoidPrefetchSnapshotCache) {\n\t\t\tconst prefetchCacheKey = getKeyForCacheEntry(\n\t\t\t\tcreateCacheSnapshotKey(this.odspResolvedUrl),\n\t\t\t);\n\t\t\tconst result = await this.cache.snapshotPrefetchResultCache\n\t\t\t\t?.get(prefetchCacheKey)\n\t\t\t\t?.then(async (response) => {\n\t\t\t\t\t// Remove it from cache once used.\n\t\t\t\t\tthis.cache.snapshotPrefetchResultCache.remove(prefetchCacheKey);\n\t\t\t\t\t// Validate the epoch from the prefetched snapshot result.\n\t\t\t\t\tawait this.epochTracker.validateEpoch(response.fluidEpoch, \"treesLatest\");\n\t\t\t\t\treturn response;\n\t\t\t\t})\n\t\t\t\t.catch(async (err) => {\n\t\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"PrefetchSnapshotError\",\n\t\t\t\t\t\t\tconcurrentSnapshotFetch: this.hostPolicy.concurrentSnapshotFetch,\n\t\t\t\t\t\t},\n\t\t\t\t\t\terr,\n\t\t\t\t\t);\n\t\t\t\t\treturn undefined;\n\t\t\t\t});\n\t\t\t// If the prefetch call, is successful, then return the contents otherwise as backup for now, just\n\t\t\t// proceed with the old snapshot fetch flow.\n\t\t\tif (result !== undefined) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t\tconst snapshotOptions: ISnapshotOptions = {\n\t\t\tmds: this.maxSnapshotSizeLimit,\n\t\t\t...hostSnapshotOptions,\n\t\t\ttimeout: hostSnapshotOptions?.timeout\n\t\t\t\t? Math.min(hostSnapshotOptions.timeout, this.maxSnapshotFetchTimeout)\n\t\t\t\t: this.maxSnapshotFetchTimeout,\n\t\t};\n\n\t\t// No limit on size of snapshot or time to fetch, as otherwise we fail all clients to summarize\n\t\tif (this.hostPolicy.summarizerClient) {\n\t\t\tsnapshotOptions.mds = undefined;\n\t\t\tsnapshotOptions.timeout = undefined;\n\t\t}\n\n\t\tconst snapshotDownloader = async (\n\t\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\t\tstorageToken: string,\n\t\t\toptions: ISnapshotOptions | undefined,\n\t\t\tcontroller?: AbortController,\n\t\t) => {\n\t\t\treturn downloadSnapshot(\n\t\t\t\tfinalOdspResolvedUrl,\n\t\t\t\tstorageToken,\n\t\t\t\tthis.logger,\n\t\t\t\toptions,\n\t\t\t\tthis.snapshotFormatFetchType,\n\t\t\t\tcontroller,\n\t\t\t\tthis.epochTracker,\n\t\t\t\tscenarioName,\n\t\t\t);\n\t\t};\n\t\tconst putInCache = async (valueWithEpoch: IVersionedValueWithEpoch) => {\n\t\t\treturn this.cache.persistedCache.put(\n\t\t\t\tcreateCacheSnapshotKey(this.odspResolvedUrl),\n\t\t\t\t// Epoch tracker will add the epoch and version to the value here. So just send value to cache.\n\t\t\t\tvalueWithEpoch.value,\n\t\t\t);\n\t\t};\n\t\tconst removeEntries = async () => this.cache.persistedCache.removeEntries();\n\t\ttry {\n\t\t\tconst odspSnapshot = await fetchSnapshotWithRedeem(\n\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\tthis.getStorageToken,\n\t\t\t\tsnapshotOptions,\n\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\tthis.logger,\n\t\t\t\tsnapshotDownloader,\n\t\t\t\tputInCache,\n\t\t\t\tremoveEntries,\n\t\t\t\tthis.hostPolicy.enableRedeemFallback,\n\t\t\t);\n\t\t\treturn odspSnapshot;\n\t\t} catch (error: any) {\n\t\t\tconst errorType = error.errorType;\n\t\t\t// If the snapshot size is too big and the host specified the size limitation(specified in hostSnapshotOptions), then don't try to fetch the snapshot again.\n\t\t\tif (\n\t\t\t\terrorType === OdspErrorType.snapshotTooBig &&\n\t\t\t\thostSnapshotOptions?.mds !== undefined &&\n\t\t\t\tthis.hostPolicy.summarizerClient !== true\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\t// If the first snapshot request was with blobs and we either timed out or the size was too big, then try to fetch without blobs.\n\t\t\tif (\n\t\t\t\t(errorType === OdspErrorType.snapshotTooBig ||\n\t\t\t\t\terrorType === OdspErrorType.fetchTimeout) &&\n\t\t\t\tsnapshotOptions.blobs\n\t\t\t) {\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"TreeLatest_SecondCall\",\n\t\t\t\t\terrorType,\n\t\t\t\t});\n\t\t\t\tconst snapshotOptionsWithoutBlobs: ISnapshotOptions = {\n\t\t\t\t\t...snapshotOptions,\n\t\t\t\t\tblobs: 0,\n\t\t\t\t\tmds: undefined,\n\t\t\t\t\ttimeout: undefined,\n\t\t\t\t};\n\t\t\t\tconst odspSnapshot = await fetchSnapshotWithRedeem(\n\t\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\t\tthis.getStorageToken,\n\t\t\t\t\tsnapshotOptionsWithoutBlobs,\n\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t\tremoveEntries,\n\t\t\t\t\tthis.hostPolicy.enableRedeemFallback,\n\t\t\t\t);\n\t\t\t\treturn odspSnapshot;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: api.ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tthis.checkSnapshotUrl();\n\n\t\t// Set the module promise right away, so as to not call it twice.\n\t\tif (this.summaryModuleP === undefined) {\n\t\t\tthis.summaryModuleP = this.getDelayLoadedSummaryManager();\n\t\t}\n\n\t\t// Enable flushing only if we have single commit summary and this is not the initial summary for an empty file\n\t\tif (\".protocol\" in summary.tree && context.ackHandle !== undefined) {\n\t\t\tlet retry = 1;\n\t\t\tfor (;;) {\n\t\t\t\tconst result = await this.flushCallback();\n\t\t\t\tconst seq = result.lastPersistedSequenceNumber;\n\t\t\t\tif (seq !== undefined && seq >= context.referenceSequenceNumber) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (retry > 3) {\n\t\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\t\teventName: \"FlushFailure\",\n\t\t\t\t\t\t...result,\n\t\t\t\t\t\tretry,\n\t\t\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"FlushExtraCall\",\n\t\t\t\t\t...result,\n\t\t\t\t\tretry,\n\t\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t\t});\n\n\t\t\t\tretry++;\n\t\t\t\tawait delay(1000 * (result.retryAfter ?? 1));\n\t\t\t}\n\t\t}\n\n\t\tif (!this.odspSummaryUploadManager) {\n\t\t\tthis.odspSummaryUploadManager = await this.summaryModuleP\n\t\t\t\t.then(async (m) => {\n\t\t\t\t\tthis.odspSummaryModuleLoaded = true;\n\t\t\t\t\treturn m;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.odspSummaryModuleLoaded = false;\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t}\n\n\t\tassert(\n\t\t\tthis.odspSummaryUploadManager !== undefined,\n\t\t\t0x56e /* summary upload manager should have been initialized */,\n\t\t);\n\t\tconst id = await this.odspSummaryUploadManager.writeSummaryTree(summary, context);\n\t\treturn id;\n\t}\n\n\tprivate async getDelayLoadedSummaryManager() {\n\t\tassert(this.odspSummaryModuleLoaded === false, 0x56f /* Should be loaded only once */);\n\t\tconst module = await import(\n\t\t\t/* webpackChunkName: \"summaryModule\" */ \"./odspSummaryUploadManager\"\n\t\t)\n\t\t\t.then((m) => {\n\t\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"SummaryModuleLoaded\" });\n\t\t\t\treturn m;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"SummaryModuleLoadFailed\" }, error);\n\t\t\t\tthrow error;\n\t\t\t});\n\t\tthis.odspSummaryUploadManager = new module.OdspSummaryUploadManager(\n\t\t\tthis.odspResolvedUrl.endpoints.snapshotStorageUrl,\n\t\t\tthis.getStorageToken,\n\t\t\tthis.logger,\n\t\t\tthis.epochTracker,\n\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\tthis.relayServiceTenantAndSessionId,\n\t\t);\n\t\treturn this.odspSummaryUploadManager;\n\t}\n\n\tprivate checkSnapshotUrl() {\n\t\tif (!this.snapshotUrl) {\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"Method failed because no snapshot url was available\",\n\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t{ driverVersion },\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate checkAttachmentPOSTUrl() {\n\t\tif (!this.attachmentPOSTUrl) {\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"Method failed because no attachment POST url was available\",\n\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t{ driverVersion },\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate checkAttachmentGETUrl() {\n\t\tif (!this.attachmentGETUrl) {\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"Method failed because no attachment GET url was available\",\n\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t{ driverVersion },\n\t\t\t);\n\t\t}\n\t}\n\n\tprotected async fetchTreeFromSnapshot(\n\t\tid: string,\n\t\tscenarioName?: string,\n\t): Promise<api.ISnapshotTree | undefined> {\n\t\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst storageToken = await this.getStorageToken(options, \"ReadCommit\");\n\t\t\tconst snapshotDownloader = async (\n\t\t\t\turl: string,\n\t\t\t\tfetchOptions: { [index: string]: any },\n\t\t\t) => {\n\t\t\t\treturn this.epochTracker.fetchAndParseAsJSON(\n\t\t\t\t\turl,\n\t\t\t\t\tfetchOptions,\n\t\t\t\t\t\"snapshotTree\",\n\t\t\t\t\tundefined,\n\t\t\t\t\tscenarioName,\n\t\t\t\t);\n\t\t\t};\n\t\t\tconst snapshot = await fetchSnapshot(\n\t\t\t\tthis.snapshotUrl!,\n\t\t\t\tstorageToken,\n\t\t\t\tid,\n\t\t\t\tthis.fetchFullSnapshot,\n\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\tthis.logger,\n\t\t\t\tsnapshotDownloader,\n\t\t\t);\n\t\t\tlet treeId = \"\";\n\t\t\tif (snapshot.snapshotTree) {\n\t\t\t\tassert(\n\t\t\t\t\tsnapshot.snapshotTree.id !== undefined,\n\t\t\t\t\t0x222 /* \"Root tree should contain the id!!\" */,\n\t\t\t\t);\n\t\t\t\ttreeId = snapshot.snapshotTree.id;\n\t\t\t\tthis.setRootTree(treeId, snapshot.snapshotTree);\n\t\t\t}\n\t\t\tif (snapshot.blobs) {\n\t\t\t\tthis.initBlobsCache(snapshot.blobs);\n\t\t\t}\n\t\t\t// If the version id doesn't match with the id of the tree, then use the id of first tree which in that case\n\t\t\t// will be the actual id of tree to be fetched.\n\t\t\treturn this.commitCache.get(id) ?? this.commitCache.get(treeId);\n\t\t});\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspDocumentStorageServiceBase.js","sourceRoot":"","sources":["../src/odspDocumentStorageServiceBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAIN,mBAAmB,GAGnB,MAAM,oCAAoC,CAAC;AAK5C,MAAM,sBAAsB,GAAe,SAAS,CAAC,CAAC,yCAAyC;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X,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n\tLoaderCachingPolicy,\n\tFiveDaysMs,\n\tFetchSource,\n} from \"@fluidframework/driver-definitions\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IConfigProvider } from \"@fluidframework/telemetry-utils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\n\nconst maximumCacheDurationMs: FiveDaysMs = 432000000; // 5 * 24 * 60 * 60 * 1000 = 5 days in ms\n\nclass BlobCache {\n\t// Save the timeout so we can cancel and reschedule it as needed\n\tprivate blobCacheTimeout: ReturnType<typeof setTimeout> | undefined;\n\t// If the defer flag is set when the timeout fires, we'll reschedule rather than clear immediately\n\t// This deferral approach is used (rather than clearing/resetting the timer) as current calling patterns trigger\n\t// too many calls to setTimeout/clearTimeout.\n\tprivate deferBlobCacheClear: boolean = false;\n\n\tprivate readonly _blobCache: Map<string, ArrayBuffer> = new Map();\n\n\t// Tracks all blob IDs evicted from cache\n\tprivate readonly blobsEvicted: Set<string> = new Set();\n\n\t// Initial time-out to purge data from cache\n\t// If this time out is very small, then we purge blobs from cache too soon and that results in a lot of\n\t// requests to storage, which brings down perf and may trip protection limits causing 429s\n\tprivate blobCacheTimeoutDuration = 2 * 60 * 1000;\n\n\t// SPO does not keep old snapshots around for long, so we are running chances of not\n\t// being able to rehydrate data store / DDS in the future if we purge anything (and with blob de-duping,\n\t// even if blob read by runtime, it could be read again in the future)\n\t// So for now, purging is disabled.\n\tprivate readonly purgeEnabled = false;\n\n\tpublic get value() {\n\t\treturn this._blobCache;\n\t}\n\n\tpublic addBlobs(blobs: Map<string, ArrayBuffer>) {\n\t\tblobs.forEach((value, blobId) => {\n\t\t\tthis._blobCache.set(blobId, value);\n\t\t});\n\t\t// Reset the timer on cache set\n\t\tthis.scheduleClearBlobsCache();\n\t}\n\n\t/**\n\t * Schedule a timer for clearing the blob cache or defer the current one.\n\t */\n\tprivate scheduleClearBlobsCache() {\n\t\tif (this.blobCacheTimeout !== undefined) {\n\t\t\t// If we already have an outstanding timer, just signal that we should defer the clear\n\t\t\tthis.deferBlobCacheClear = true;\n\t\t} else if (this.purgeEnabled) {\n\t\t\t// If we don't have an outstanding timer, set a timer\n\t\t\t// When the timer runs out, we'll decide whether to proceed with the cache clear or reset the timer\n\t\t\tconst clearCacheOrDefer = () => {\n\t\t\t\tthis.blobCacheTimeout = undefined;\n\t\t\t\tif (this.deferBlobCacheClear) {\n\t\t\t\t\tthis.deferBlobCacheClear = false;\n\t\t\t\t\tthis.scheduleClearBlobsCache();\n\t\t\t\t} else {\n\t\t\t\t\t// NOTE: Slightly better algorithm here would be to purge either only big blobs,\n\t\t\t\t\t// or sort them by size and purge enough big blobs to leave only 256Kb of small blobs in cache\n\t\t\t\t\t// Purging is optimizing memory footprint. But count controls potential number of storage requests\n\t\t\t\t\t// We want to optimize both - memory footprint and number of future requests to storage.\n\t\t\t\t\t// Note that Container can realize data store or DDS on-demand at any point in time, so we do not\n\t\t\t\t\t// control when blobs will be used.\n\t\t\t\t\tthis._blobCache.forEach((_, blobId) => this.blobsEvicted.add(blobId));\n\t\t\t\t\tthis._blobCache.clear();\n\t\t\t\t}\n\t\t\t};\n\t\t\tthis.blobCacheTimeout = setTimeout(clearCacheOrDefer, this.blobCacheTimeoutDuration);\n\t\t\t// any future storage reads that get into the cache should be cleared from cache rather quickly -\n\t\t\t// there is not much value in keeping them longer\n\t\t\tthis.blobCacheTimeoutDuration = 10 * 1000;\n\t\t}\n\t}\n\n\tpublic getBlob(blobId: string) {\n\t\t// Reset the timer on attempted cache read\n\t\tthis.scheduleClearBlobsCache();\n\t\tconst blobContent = this._blobCache.get(blobId);\n\t\tconst evicted = this.blobsEvicted.has(blobId);\n\t\treturn { blobContent, evicted };\n\t}\n\n\tpublic setBlob(blobId: string, blob: ArrayBuffer) {\n\t\t// This API is called as result of cache miss and reading blob from storage.\n\t\t// Runtime never reads same blob twice.\n\t\t// The only reason we may get read request for same blob is blob de-duping in summaries.\n\t\t// Note that the bigger the size, the less likely blobs are the same, so there is very little benefit of caching big blobs.\n\t\t// Images are the only exception - user may insert same image twice. But we currently do not de-dup them - only snapshot\n\t\t// blobs are de-duped.\n\t\tconst size = blob.byteLength;\n\t\tif (size < 256 * 1024) {\n\t\t\t// Reset the timer on cache set\n\t\t\tthis.scheduleClearBlobsCache();\n\t\t\treturn this._blobCache.set(blobId, blob);\n\t\t} else {\n\t\t\t// we evicted it here by not caching.\n\t\t\tthis.blobsEvicted.add(blobId);\n\t\t}\n\t}\n}\n\nexport abstract class OdspDocumentStorageServiceBase implements IDocumentStorageService {\n\treadonly policies: IDocumentStorageServicePolicies;\n\n\tconstructor(config: IConfigProvider) {\n\t\t// We circumvent the restrictions on the policy only when using this TestOverride setting,\n\t\t// which also applies to the code that reads from the cache in epochTracker.ts\n\t\t// This may result in files created for testing being unusable in production sessions,\n\t\t// due to the GC code guarding against this policy changing over the lifetime of a file.\n\t\tconst maximumCacheDurationMsInEffect = (\n\t\t\tconfig.getBoolean(\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\")\n\t\t\t\t? 0\n\t\t\t\t: maximumCacheDurationMs\n\t\t) as FiveDaysMs;\n\n\t\tthis.policies = {\n\t\t\t// By default, ODSP tells the container not to prefetch/cache.\n\t\t\tcaching: LoaderCachingPolicy.NoCaching,\n\t\t\tmaximumCacheDurationMs: maximumCacheDurationMsInEffect,\n\t\t};\n\t}\n\tprotected readonly commitCache: Map<string, api.ISnapshotTree> = new Map();\n\n\tprivate readonly attributesBlobHandles: Set<string> = new Set();\n\n\tprivate _ops: api.ISequencedDocumentMessage[] | undefined;\n\n\tprivate _snapshotSequenceNumber: number | undefined;\n\n\tprotected readonly blobCache = new BlobCache();\n\n\tpublic set ops(ops: api.ISequencedDocumentMessage[] | undefined) {\n\t\tassert(this._ops === undefined, 0x0a5 /* \"Trying to set ops when they are already set!\" */);\n\t\tthis._ops = ops;\n\t}\n\n\tpublic get ops(): api.ISequencedDocumentMessage[] | undefined {\n\t\treturn this._ops;\n\t}\n\n\tpublic get snapshotSequenceNumber() {\n\t\treturn this._snapshotSequenceNumber;\n\t}\n\n\tpublic readonly repositoryUrl = \"\";\n\n\tpublic abstract createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;\n\n\tprivate async readBlobCore(blobId: string): Promise<ArrayBuffer> {\n\t\tconst { blobContent, evicted } = this.blobCache.getBlob(blobId);\n\t\treturn blobContent ?? this.fetchBlobFromStorage(blobId, evicted);\n\t}\n\n\tprotected abstract fetchBlobFromStorage(blobId: string, evicted: boolean): Promise<ArrayBuffer>;\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.readBlobCore(blobId);\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: api.IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<api.ISnapshotTree | null> {\n\t\tlet id: string;\n\t\tif (!version?.id) {\n\t\t\tconst versions = await this.getVersions(null, 1, scenarioName);\n\t\t\tif (!versions || versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tid = versions[0].id;\n\t\t} else {\n\t\t\tid = version.id;\n\t\t}\n\n\t\tconst snapshotTree = await this.readTree(id, scenarioName);\n\t\tif (!snapshotTree) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (snapshotTree.blobs) {\n\t\t\tconst attributesBlob = snapshotTree.blobs.attributes;\n\t\t\tif (attributesBlob) {\n\t\t\t\tthis.attributesBlobHandles.add(attributesBlob);\n\t\t\t}\n\t\t}\n\n\t\t// When we upload the container snapshot, we upload appTree in \".app\" and protocol tree in \".protocol\"\n\t\t// So when we request the snapshot we get \".app\" as tree and not as commit node as in the case just above.\n\t\tconst appTree = snapshotTree.trees[\".app\"];\n\t\tconst protocolTree = snapshotTree.trees[\".protocol\"];\n\n\t\treturn this.combineProtocolAndAppSnapshotTree(appTree, protocolTree);\n\t}\n\n\tpublic abstract getVersions(\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tblobid: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<api.IVersion[]>;\n\n\tpublic abstract uploadSummaryWithContext(\n\t\tsummary: api.ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string>;\n\n\tpublic async downloadSummary(commit: api.ISummaryHandle): Promise<api.ISummaryTree> {\n\t\tthrow new Error(\"Not implemented yet\");\n\t}\n\n\tprotected setRootTree(id: string, tree: api.ISnapshotTree) {\n\t\tthis.commitCache.set(id, tree);\n\t}\n\n\tprotected initBlobsCache(blobs: Map<string, ArrayBuffer>) {\n\t\tthis.blobCache.addBlobs(blobs);\n\t}\n\n\tprivate async readTree(id: string, scenarioName?: string): Promise<api.ISnapshotTree | null> {\n\t\tlet tree = this.commitCache.get(id);\n\t\tif (!tree) {\n\t\t\ttree = await this.fetchTreeFromSnapshot(id, scenarioName);\n\t\t}\n\n\t\treturn tree ?? null;\n\t}\n\n\tprotected abstract fetchTreeFromSnapshot(\n\t\tid: string,\n\t\tscenarioName?: string,\n\t): Promise<api.ISnapshotTree | undefined>;\n\n\tprivate combineProtocolAndAppSnapshotTree(\n\t\thierarchicalAppTree: api.ISnapshotTree,\n\t\thierarchicalProtocolTree: api.ISnapshotTree,\n\t) {\n\t\tconst summarySnapshotTree: api.ISnapshotTree = {\n\t\t\tblobs: {\n\t\t\t\t...hierarchicalAppTree.blobs,\n\t\t\t},\n\t\t\ttrees: {\n\t\t\t\t...hierarchicalAppTree.trees,\n\t\t\t\t// the app tree could have a .protocol\n\t\t\t\t// in that case we want to server protocol to override it\n\t\t\t\t\".protocol\": hierarchicalProtocolTree,\n\t\t\t},\n\t\t};\n\n\t\treturn summarySnapshotTree;\n\t}\n\n\tprotected initializeFromSnapshot(\n\t\todspSnapshotCacheValue: ISnapshotContents,\n\t\tcacheOps: boolean = true,\n\t): string | undefined {\n\t\tthis._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;\n\t\tconst { snapshotTree, blobs, ops } = odspSnapshotCacheValue;\n\n\t\t// id should be undefined in case of just ops in snapshot.\n\t\tlet id: string | undefined;\n\t\tif (snapshotTree) {\n\t\t\tid = snapshotTree.id;\n\t\t\tassert(id !== undefined, 0x221 /* \"Root tree should contain the id\" */);\n\t\t\tthis.setRootTree(id, snapshotTree);\n\t\t}\n\n\t\tif (blobs) {\n\t\t\tthis.initBlobsCache(blobs);\n\t\t}\n\n\t\tif (cacheOps) {\n\t\t\tthis.ops = ops;\n\t\t}\n\t\treturn id;\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspDriverUrlResolver.js","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EACN,eAAe,EACf,YAAY,GAIZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEN,cAAc,GAEd,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,SAAS,UAAU,CAAC,OAAe,EAAE,OAAe,EAAE,MAAc,EAAE,WAAoB;IACzF,MAAM,UAAU,GAAG,IAAI,G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AM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;KACnD;IAED,OAAO;QACN,OAAO;QACP,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC;QACpC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC;QAClC,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC;QAC9B,oBAAoB,EAAE,oBAAoB;YACzC,CAAC,CAAC,kBAAkB,CAAC,oBAAoB,CAAC;YAC1C,CAAC,CAAC,SAAS;QACZ,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;KACtE,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tDriverErrorType,\n\tDriverHeader,\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tIOdspResolvedUrl,\n\tShareLinkTypes,\n\tShareLinkInfoType,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { getOdspResolvedUrl } from \"./odspUtils\";\nimport { getHashedDocumentId } from \"./odspPublicUtils\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\nimport { pkgVersion } from \"./packageVersion\";\n\nfunction getUrlBase(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n\tconst siteOrigin = new URL(siteUrl).origin;\n\tconst version = fileVersion ? `versions/${fileVersion}/` : \"\";\n\treturn `${getApiRoot(siteOrigin)}/drives/${driveId}/items/${itemId}/${version}`;\n}\n\nfunction getSnapshotUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/snapshots`;\n}\n\nfunction getAttachmentPOSTUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n) {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachment`;\n}\n\nfunction getAttachmentGETUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n) {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachments`;\n}\n\nfunction getDeltaStorageUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n) {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream`;\n}\n\n/**\n * Utility that enables us to handle paths provided with a beginning slash.\n * For example if a value of '/id1/id2' is provided, id1/id2 is returned.\n */\nfunction removeBeginningSlash(str: string): string {\n\tif (str.startsWith(\"/\")) {\n\t\treturn str.substr(1);\n\t}\n\n\treturn str;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`\n * @public\n */\nexport class OdspDriverUrlResolver implements IUrlResolver {\n\tconstructor() {}\n\n\tpublic async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n\t\tif (request.headers?.[DriverHeader.createNew]) {\n\t\t\tconst [siteURL, queryString] = request.url.split(\"?\");\n\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\tconst fileName = request.headers[DriverHeader.createNew].fileName;\n\t\t\tconst driveID = searchParams.get(\"driveId\");\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tconst packageName = searchParams.get(\"containerPackageName\");\n\t\t\tconst createLinkType = searchParams.get(\"createLinkType\");\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- false positive\n\t\t\tif (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"Proper new file params should be there!!\",\n\t\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t\t{ driverVersion: pkgVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\t\t\tif (createLinkType && createLinkType in ShareLinkTypes) {\n\t\t\t\tshareLinkInfo = {\n\t\t\t\t\tcreateLink: {\n\t\t\t\t\t\ttype: ShareLinkTypes[createLinkType],\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tendpoints: {\n\t\t\t\t\tsnapshotStorageUrl: \"\",\n\t\t\t\t\tattachmentGETStorageUrl: \"\",\n\t\t\t\t\tattachmentPOSTStorageUrl: \"\",\n\t\t\t\t\tdeltaStorageUrl: \"\",\n\t\t\t\t},\n\t\t\t\ttokens: {},\n\t\t\t\ttype: \"fluid\",\n\t\t\t\todspResolvedUrl: true,\n\t\t\t\tid: \"odspCreateNew\",\n\t\t\t\turl: `fluid-odsp://${siteURL}?${queryString}&version=null`,\n\t\t\t\tsiteUrl: siteURL,\n\t\t\t\thashedDocumentId: \"\",\n\t\t\t\tdriveId: driveID,\n\t\t\t\titemId: \"\",\n\t\t\t\tfileName,\n\t\t\t\tsummarizer: false,\n\t\t\t\tcodeHint: {\n\t\t\t\t\tcontainerPackageName: packageName ?? undefined,\n\t\t\t\t},\n\t\t\t\tfileVersion: undefined,\n\t\t\t\tshareLinkInfo,\n\t\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t\t};\n\t\t}\n\t\tconst { siteUrl, driveId, itemId, path, containerPackageName, fileVersion } = decodeOdspUrl(\n\t\t\trequest.url,\n\t\t);\n\t\tconst hashedDocumentId = await getHashedDocumentId(driveId, itemId);\n\t\tassert(!hashedDocumentId.includes(\"/\"), 0x0a8 /* \"Docid should not contain slashes!!\" */);\n\n\t\tconst documentUrl = `fluid-odsp://placeholder/placeholder/${hashedDocumentId}/${removeBeginningSlash(\n\t\t\tpath,\n\t\t)}`;\n\n\t\tconst summarizer = !!request.headers?.[DriverHeader.summarizingClient];\n\t\treturn {\n\t\t\ttype: \"fluid\",\n\t\t\todspResolvedUrl: true,\n\t\t\tendpoints: {\n\t\t\t\tsnapshotStorageUrl: getSnapshotUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tattachmentPOSTStorageUrl: getAttachmentPOSTUrl(\n\t\t\t\t\tsiteUrl,\n\t\t\t\t\tdriveId,\n\t\t\t\t\titemId,\n\t\t\t\t\tfileVersion,\n\t\t\t\t),\n\t\t\t\tattachmentGETStorageUrl: getAttachmentGETUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tdeltaStorageUrl: getDeltaStorageUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t},\n\t\t\tid: hashedDocumentId,\n\t\t\ttokens: {},\n\t\t\turl: documentUrl,\n\t\t\thashedDocumentId,\n\t\t\tsiteUrl,\n\t\t\tdriveId,\n\t\t\titemId,\n\t\t\tdataStorePath: path,\n\t\t\tfileName: \"\",\n\t\t\tsummarizer,\n\t\t\tcodeHint: {\n\t\t\t\tcontainerPackageName,\n\t\t\t},\n\t\t\tfileVersion,\n\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t};\n\t}\n\n\t/**\n\t * Requests a driver + data store storage URL.\n\t * @param resolvedUrl - The driver resolved URL.\n\t * @param relativeUrl - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @param packageInfoSource - optional, represents container package information to be included in url.\n\t */\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\tlet dataStorePath = relativeUrl;\n\t\tif (relativeUrl === \"\" && odspResolvedUrl.dataStorePath !== undefined) {\n\t\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\t\tdataStorePath = odspResolvedUrl.dataStorePath;\n\t\t}\n\t\tif (dataStorePath.startsWith(\"/\")) {\n\t\t\tdataStorePath = dataStorePath.substr(1);\n\t\t}\n\n\t\t// back-compat: GitHub #9653\n\t\tconst isFluidPackage = (pkg: any) =>\n\t\t\ttypeof pkg === \"object\" &&\n\t\t\ttypeof pkg?.name === \"string\" &&\n\t\t\ttypeof pkg?.fluid === \"object\";\n\t\tlet containerPackageName;\n\t\tif (packageInfoSource && \"name\" in packageInfoSource) {\n\t\t\tcontainerPackageName = packageInfoSource.name;\n\t\t\t// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n\t\t} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t\t} else {\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t\t}\n\t\tcontainerPackageName =\n\t\t\tcontainerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n\t\treturn createOdspUrl({\n\t\t\t...odspResolvedUrl,\n\t\t\tcontainerPackageName,\n\t\t\tdataStorePath,\n\t\t});\n\t}\n}\n\nfunction decodeOdspUrl(url: string): {\n\tsiteUrl: string;\n\tdriveId: string;\n\titemId: string;\n\tpath: string;\n\tcontainerPackageName?: string;\n\tfileVersion?: string;\n} {\n\tconst [siteUrl, queryString] = url.split(\"?\");\n\n\tconst searchParams = new URLSearchParams(queryString);\n\n\tconst driveId = searchParams.get(\"driveId\");\n\tconst itemId = searchParams.get(\"itemId\");\n\tconst path = searchParams.get(\"path\");\n\tconst containerPackageName = searchParams.get(\"containerPackageName\");\n\tconst fileVersion = searchParams.get(\"fileVersion\");\n\n\tif (driveId === null) {\n\t\tthrow new Error(\"ODSP URL did not contain a drive id\");\n\t}\n\n\tif (itemId === null) {\n\t\tthrow new Error(\"ODSP Url did not contain an item id\");\n\t}\n\n\tif (path === null) {\n\t\tthrow new Error(\"ODSP Url did not contain a path\");\n\t}\n\n\treturn {\n\t\tsiteUrl,\n\t\tdriveId: decodeURIComponent(driveId),\n\t\titemId: decodeURIComponent(itemId),\n\t\tpath: decodeURIComponent(path),\n\t\tcontainerPackageName: containerPackageName\n\t\t\t? decodeURIComponent(containerPackageName)\n\t\t\t: undefined,\n\t\tfileVersion: fileVersion ? decodeURIComponent(fileVersion) : undefined,\n\t};\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspDriverUrlResolverForShareLink.js","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAc1D,OAAO,EACN,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA6B,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAiB5C;;;;;GAKG;AACH,MAAM,OAAO,iCAAiC;IAK7C;;;;;;;;;;;OAWG;IACH,YACC,qBAAyD,EACzD,MAA6B,EACZ,OAAgB,EAChB,UAGe;QAJf,YAAO,GAAP,OAAO,CAAS;QAChB,eAAU,GAAV,UAAU,CAGK;QAtBhB,qBAAgB,GAAG,IAAI,YAAY,EAAkB,CAAC;QAwBtE,IAAI,CAAC,MAAM,GAAG,gB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AU,EAAE,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;QAE9E,qBAAqB,CAAC,YAAY,EAAE;YACnC,OAAO,EAAE,eAAe,CAAC,OAAO;YAChC,OAAO,EAAE,eAAe,CAAC,OAAO;YAChC,MAAM,EAAE,eAAe,CAAC,MAAM;YAC9B,aAAa,EAAE,mBAAmB;YAClC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,oBAAoB;YACpB,WAAW,EAAE,eAAe,CAAC,WAAW;YACxC,OAAO;SACP,CAAC,CAAC;QAEH,OAAO,YAAY,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,iBAAiB,CAAC,OAAe,EAAE,UAAqC;QACrF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAE7B,qBAAqB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAEvC,OAAO,GAAG,CAAC,IAAI,CAAC;IACjB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,cAAc,CAAC,OAAkC;QAC9D,OAAO,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACD","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 { ITelemetryBaseLogger, IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIOdspResolvedUrl,\n\tIdentityType,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport {\n\tgetLocatorFromOdspUrl,\n\tstoreLocatorInOdspUrl,\n\tencodeOdspFluidDataStoreLocator,\n\tlocatorQueryParamName,\n} from \"./odspFluidFileLink\";\nimport { OdspFluidDataStoreLocator, SharingLinkHeader } from \"./contractsPublic\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nimport { getOdspResolvedUrl, createOdspLogger } from \"./odspUtils\";\nimport { getFileLink } from \"./getFileLink\";\n\n/**\n * Properties passed to the code responsible for fetching share link for a file.\n * @public\n */\nexport interface ShareLinkFetcherProps {\n\t/**\n\t * Callback method that is used to fetch access token necessary to call API that produces share link\n\t */\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>;\n\t/**\n\t * Identity type determining the shape of share link as it differs for Enterprise and Consumer users.\n\t */\n\tidentityType: IdentityType;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.\n * This resolver also handles share links and try to generate one for the use by the app.\n * @public\n */\nexport class OdspDriverUrlResolverForShareLink implements IUrlResolver {\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate readonly sharingLinkCache = new PromiseCache<string, string>();\n\tprivate readonly shareLinkFetcherProps: ShareLinkFetcherProps | undefined;\n\n\t/**\n\t * Creates url resolver instance\n\t * @param shareLinkFetcherProps - properties used when fetching share link.\n\t * Can be set as 'undefined' for cases where share link is not needed. Currently, only\n\t * getAbsoluteUrl() method requires share link.\n\t * @param logger - logger object that is used as telemetry sink\n\t * @param appName - application name hint that is encoded with url produced by getAbsoluteUrl() method.\n\t * This hint is used by link handling logic which determines which app to redirect to when user\n\t * navigates directly to the link.\n\t * @param getContext - callback function which is used to get context for given resolved url. If context\n\t * is returned then it will be embedded into url returned by getAbsoluteUrl() method.\n\t */\n\tpublic constructor(\n\t\tshareLinkFetcherProps?: ShareLinkFetcherProps | undefined,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tprivate readonly appName?: string,\n\t\tprivate readonly getContext?: (\n\t\t\tresolvedUrl: IOdspResolvedUrl,\n\t\t\tdataStorePath: string,\n\t\t) => Promise<string | undefined>,\n\t) {\n\t\tthis.logger = createOdspLogger(logger);\n\t\tif (shareLinkFetcherProps) {\n\t\t\tthis.shareLinkFetcherProps = {\n\t\t\t\t...shareLinkFetcherProps,\n\t\t\t\ttokenFetcher: shareLinkFetcherProps.tokenFetcher,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Takes an already generated data store url (from requestUrl) and appends a path to the\n\t * existing data store information.\n\t */\n\tpublic appendDataStorePath(requestUrl: URL, pathToAppend: string): string | undefined {\n\t\tconst fluidInfo = getLocatorFromOdspUrl(requestUrl);\n\n\t\tif (!fluidInfo) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst parsingUrl = new URL(\n\t\t\tfluidInfo.dataStorePath,\n\t\t\t`${requestUrl.protocol}//${requestUrl.hostname}`,\n\t\t);\n\t\t// Determine if the caller is passing a query parameter or path since processing will be different.\n\t\tif (pathToAppend.startsWith(\"/?\") || pathToAppend.startsWith(\"?\")) {\n\t\t\tconst queryParams = new URLSearchParams(pathToAppend);\n\t\t\tqueryParams.forEach((value: string, key: string) => {\n\t\t\t\tparsingUrl.searchParams.append(key, value);\n\t\t\t});\n\t\t\tfluidInfo.dataStorePath = `${parsingUrl.pathname}${parsingUrl.search}`;\n\t\t} else {\n\t\t\tfluidInfo.dataStorePath = `${parsingUrl.pathname}${\n\t\t\t\tparsingUrl.pathname.endsWith(\"/\") || pathToAppend.startsWith(\"/\") ? \"\" : \"/\"\n\t\t\t}${pathToAppend}/${parsingUrl.search}`;\n\t\t}\n\t\tstoreLocatorInOdspUrl(requestUrl, fluidInfo);\n\n\t\treturn requestUrl.href;\n\t}\n\n\tprivate getKey(resolvedUrl: IOdspResolvedUrl): string {\n\t\treturn `${resolvedUrl.siteUrl},${resolvedUrl.driveId},${resolvedUrl.itemId}`;\n\t}\n\n\t/**\n\t * Resolves request URL into driver details\n\t */\n\tpublic async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n\t\tconst requestToBeResolved = { headers: request.headers, url: request.url };\n\t\tconst isSharingLinkToRedeem =\n\t\t\trequestToBeResolved.headers?.[SharingLinkHeader.isSharingLinkToRedeem];\n\t\ttry {\n\t\t\tconst url = new URL(request.url);\n\n\t\t\tconst odspFluidInfo = getLocatorFromOdspUrl(url);\n\t\t\tif (odspFluidInfo) {\n\t\t\t\trequestToBeResolved.url = createOdspUrl(odspFluidInfo);\n\t\t\t}\n\t\t} catch {\n\t\t\t// If the locator throws some error, then try to resolve the request as it is.\n\t\t}\n\n\t\tconst odspResolvedUrl = await new OdspDriverUrlResolver().resolve(requestToBeResolved);\n\n\t\tif (isSharingLinkToRedeem) {\n\t\t\t// We need to remove the nav param if set by host when setting the sharelink as otherwise the shareLinkId\n\t\t\t// when redeeming the share link during the redeem fallback for trees latest call becomes greater than\n\t\t\t// the eligible length.\n\t\t\todspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo ?? {}, {\n\t\t\t\tsharingLinkToRedeem: this.removeNavParam(request.url),\n\t\t\t});\n\t\t}\n\t\tif (odspResolvedUrl.itemId) {\n\t\t\t// Kick start the sharing link request if we don't have it already as a performance optimization.\n\t\t\t// For detached create new, we don't have an item id yet and therefore cannot generate a share link\n\t\t\tthis.getShareLinkPromise(odspResolvedUrl).catch(() => {});\n\t\t}\n\t\treturn odspResolvedUrl;\n\t}\n\n\tprivate removeNavParam(link: string): string {\n\t\tconst url = new URL(link);\n\t\tconst params = new URLSearchParams(url.search);\n\t\tparams.delete(locatorQueryParamName);\n\t\turl.search = params.toString();\n\t\treturn url.href;\n\t}\n\n\tprivate async getShareLinkPromise(resolvedUrl: IOdspResolvedUrl): Promise<string> {\n\t\tif (this.shareLinkFetcherProps === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Failed to get share link because share link fetcher props are missing\",\n\t\t\t);\n\t\t}\n\n\t\tif (!(resolvedUrl.siteUrl && resolvedUrl.driveId && resolvedUrl.itemId)) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Failed to get share link because necessary information is missing \" +\n\t\t\t\t\t\"(e.g. siteUrl, driveId or itemId)\",\n\t\t\t);\n\t\t}\n\n\t\tconst key = this.getKey(resolvedUrl);\n\t\tconst cachedLinkPromise = this.sharingLinkCache.get(key);\n\t\tif (cachedLinkPromise) {\n\t\t\treturn cachedLinkPromise;\n\t\t}\n\t\tconst newLinkPromise = getFileLink(\n\t\t\tthis.shareLinkFetcherProps.tokenFetcher,\n\t\t\tresolvedUrl,\n\t\t\tthis.logger,\n\t\t).catch((error) => {\n\t\t\t// This should imply that error is a non-retriable error.\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"FluidFileUrlError\" }, error);\n\t\t\tthis.sharingLinkCache.remove(key);\n\t\t\tthrow error;\n\t\t});\n\t\tthis.sharingLinkCache.add(key, async () => newLinkPromise);\n\t\treturn newLinkPromise;\n\t}\n\n\t/**\n\t * Requests a driver + data store storage URL. Note that this method requires share link to be fetched\n\t * and it will throw in case share link fetcher props were not specified when instance was created.\n\t * @param resolvedUrl - The driver resolved URL\n\t * @param dataStorePath - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @param packageInfoSource - optional, represents container package information to be included in url.\n\t */\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tdataStorePath: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\tconst shareLink = await this.getShareLinkPromise(odspResolvedUrl);\n\t\tconst shareLinkUrl = new URL(shareLink);\n\n\t\tlet actualDataStorePath = dataStorePath;\n\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\tif (dataStorePath === \"\" && odspResolvedUrl.dataStorePath !== undefined) {\n\t\t\tactualDataStorePath = odspResolvedUrl.dataStorePath;\n\t\t}\n\n\t\t// back-compat: GitHub #9653\n\t\tconst isFluidPackage = (pkg: any) =>\n\t\t\ttypeof pkg === \"object\" &&\n\t\t\ttypeof pkg?.name === \"string\" &&\n\t\t\ttypeof pkg?.fluid === \"object\";\n\t\tlet containerPackageName;\n\t\tif (packageInfoSource && \"name\" in packageInfoSource) {\n\t\t\tcontainerPackageName = packageInfoSource.name;\n\t\t\t// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n\t\t} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t\t} else {\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t\t}\n\t\tcontainerPackageName =\n\t\t\tcontainerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n\t\tconst context = await this.getContext?.(odspResolvedUrl, actualDataStorePath);\n\n\t\tstoreLocatorInOdspUrl(shareLinkUrl, {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t\tdataStorePath: actualDataStorePath,\n\t\t\tappName: this.appName,\n\t\t\tcontainerPackageName,\n\t\t\tfileVersion: odspResolvedUrl.fileVersion,\n\t\t\tcontext,\n\t\t});\n\n\t\treturn shareLinkUrl.href;\n\t}\n\n\t/**\n\t * Crafts a supported document/driver URL\n\t */\n\tpublic static createDocumentUrl(baseUrl: string, driverInfo: OdspFluidDataStoreLocator) {\n\t\tconst url = new URL(baseUrl);\n\n\t\tstoreLocatorInOdspUrl(url, driverInfo);\n\n\t\treturn url.href;\n\t}\n\n\t/**\n\t * Crafts a supported data store nav param\n\t * @deprecated encodeOdspFluidDataStoreLocator should be used instead\n\t */\n\tpublic static createNavParam(locator: OdspFluidDataStoreLocator) {\n\t\treturn encodeOdspFluidDataStoreLocator(locator);\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspError.js","sourceRoot":"","sources":["../src/odspError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAmB,MAAM,iCAAiC,CAAC;AAEvF,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACzC,WAA6B,EAC7B,OAAe;IAEf,0DAA0D;IAC1D,IAAI;QACH,iDAAiD;QACjD,MAAM,OAAO,GAAG,sBAAsB,OAAO,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;QACzE,MAAM,KAAK,GAAG,sBAAsB,CACnC,OAAO,EACP,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,UAAU,EACtB,SAAS,EAAE,6BAA6B;QACxC,WAAW,CAAC,KAAK;YAChB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,EAAE,mBAAmB,EAAE,CAAC;YACrE,CAAC,CAAC,SAAS,CACZ,CAAC;QAEF,KAAK,CAAC,sBAAsB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3E,OAAO,KAAK,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACf,OAAO,IAAI,iBAAiB,CAC3B,4CAA4C,EAC5C,eAAe,CAAC,+BAA+B,EAC/C,EAAE,aAAa,EAAE,CACjB,CAAC;KACF;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createOdspNetworkError } from \"@fluidframework/odsp-doclib-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { OdspError } from \"@fluidframework/odsp-driver-definitions\";\nimport { getCircularReplacer, IFluidErrorBase } from \"@fluidframework/telemetry-utils\";\nimport { IOdspSocketError } from \"./contracts\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * Returns network error based on error object from ODSP socket (IOdspSocketError)\n */\nexport function errorObjectFromSocketError(\n\tsocketError: IOdspSocketError,\n\thandler: string,\n): IFluidErrorBase & OdspError {\n\t// Make sure we always return something, and do not throw.\n\ttry {\n\t\t// pre-0.58 error message prefix: OdspSocketError\n\t\tconst message = `ODSP socket error (${handler}): ${socketError.message}`;\n\t\tconst error = createOdspNetworkError(\n\t\t\tmessage,\n\t\t\tsocketError.code,\n\t\t\tsocketError.retryAfter,\n\t\t\tundefined, // response from http request\n\t\t\tsocketError.error\n\t\t\t\t? JSON.stringify({ error: socketError.error }, getCircularReplacer())\n\t\t\t\t: undefined, // responseText\n\t\t);\n\n\t\terror.addTelemetryProperties({ odspError: true, relayServiceError: true });\n\t\treturn error;\n\t} catch (error) {\n\t\treturn new NonRetryableError(\n\t\t\t\"Internal error: errorObjectFromSocketError\",\n\t\t\tDriverErrorType.fileNotFoundOrAccessDeniedError,\n\t\t\t{ driverVersion },\n\t\t);\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspFluidFileLink.js","sourceRoot":"","sources":["../src/odspFluidFileLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,uBAAuB,GAAG,OAAO,CAAC;AACxC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,sBAAsB,GAAG,GAAG,CA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I,GAAG,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;KAC3C;IAAC,MAAM;QACP,0DAA0D;KAC1D;IAED,IAAI,CAAC,OAAO,EAAE;QACb,OAAO,SAAS,CAAC;KACjB;IAED,OAAO;QACN,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,OAAO;QACP,MAAM;QACN,aAAa;QACb,OAAO;QACP,oBAAoB;QACpB,WAAW;QACX,OAAO;KACP,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAQ,EAAE,OAAkC;IACjF,MAAM,mBAAmB,GAAG,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACrE,0GAA0G;IAC1G,qCAAqC;IACrC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACpC,GAAQ,EACR,wBAAiC,IAAI;IAErC,mGAAmG;IACnG,MAAM,mBAAmB,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACxE,IAAI,CAAC,mBAAmB,EAAE;QACzB,OAAO,SAAS,CAAC;KACjB;IAED,qGAAqG;IACrG,oFAAoF;IACpF,MAAM,aAAa,GAClB,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;IAEhF,OAAO,+BAA+B,CACrC,mBAAmB,EACnB,aAAa,EACb,qBAAqB,CACrB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromBase64ToUtf8, fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { OdspFluidDataStoreLocator } from \"./contractsPublic\";\nimport { OdcFileSiteOrigin, OdcApiSiteOrigin } from \"./constants\";\n\nconst fluidSignature = \"1\";\nconst fluidSignatureParamName = \"fluid\";\nconst sitePathParamName = \"s\";\nconst driveIdParamName = \"d\";\nconst itemIdParamName = \"f\";\nconst dataStorePathParamName = \"c\";\nconst appNameParamName = \"a\";\nconst containerPackageNameParamName = \"p\";\nconst fileVersionParamName = \"v\";\nconst additionalContextParamName = \"x\";\n\n/**\n * Transforms given Fluid data store locator into string that can be embedded into url\n * @param locator - describes Fluid data store locator info to be encoded\n * @returns string representing encoded Fluid data store locator info\n * @public\n */\nexport function encodeOdspFluidDataStoreLocator(locator: OdspFluidDataStoreLocator): string {\n\tconst siteUrl = new URL(locator.siteUrl);\n\tconst sitePath = encodeURIComponent(siteUrl.pathname);\n\tconst driveId = encodeURIComponent(locator.driveId);\n\tconst itemId = encodeURIComponent(locator.itemId);\n\tconst dataStorePath = encodeURIComponent(locator.dataStorePath);\n\n\tlet locatorSerialized = `${sitePathParamName}=${sitePath}&${driveIdParamName}=${driveId}&${itemIdParamName}=${itemId}&${dataStorePathParamName}=${dataStorePath}&${fluidSignatureParamName}=${fluidSignature}`;\n\tif (locator.appName) {\n\t\tlocatorSerialized += `&${appNameParamName}=${encodeURIComponent(locator.appName)}`;\n\t}\n\tif (locator.containerPackageName) {\n\t\tlocatorSerialized += `&${containerPackageNameParamName}=${encodeURIComponent(\n\t\t\tlocator.containerPackageName,\n\t\t)}`;\n\t}\n\tif (locator.fileVersion) {\n\t\tlocatorSerialized += `&${fileVersionParamName}=${encodeURIComponent(locator.fileVersion)}`;\n\t}\n\tif (locator.context) {\n\t\tlocatorSerialized += `&${additionalContextParamName}=${encodeURIComponent(\n\t\t\tlocator.context,\n\t\t)}`;\n\t}\n\n\treturn fromUtf8ToBase64(locatorSerialized);\n}\n\n/**\n * Decodes given encoded value representing Fluid data store locator extracted from ODSP Fluid file link\n * @param encodedLocatorValue - encoded Fluid data store locator value which was produced by\n * {@link encodeOdspFluidDataStoreLocator} function\n * @param siteOriginUrl - site origin that will be appended to encoded relative path to form absolute file url\n * @param requireFluidSignature - flag representing if the Fluid signature is expected in the url, default true\n * @returns object representing Fluid data store location in ODSP terms\n */\nfunction decodeOdspFluidDataStoreLocator(\n\tencodedLocatorValue: string,\n\tsiteOriginUrl: string,\n\trequireFluidSignature: boolean = true,\n): OdspFluidDataStoreLocator | undefined {\n\tconst locatorInfo = new URLSearchParams(fromBase64ToUtf8(encodedLocatorValue));\n\n\tconst signatureValue = locatorInfo.get(fluidSignatureParamName);\n\tif (requireFluidSignature && signatureValue !== \"1\") {\n\t\treturn undefined;\n\t}\n\n\tconst sitePath = locatorInfo.get(sitePathParamName);\n\tconst driveId = locatorInfo.get(driveIdParamName);\n\tconst itemId = locatorInfo.get(itemIdParamName);\n\tconst dataStorePath = locatorInfo.get(dataStorePathParamName);\n\tconst appName = locatorInfo.get(appNameParamName) ?? undefined;\n\tconst containerPackageName = locatorInfo.get(containerPackageNameParamName) ?? undefined;\n\tconst fileVersion = locatorInfo.get(fileVersionParamName) ?? undefined;\n\tconst context = locatorInfo.get(additionalContextParamName) ?? undefined;\n\t// \"\" is a valid value for dataStorePath so simply check for absence of the param;\n\t// file storage locator params must be present and non-empty\n\tif (!sitePath || !driveId || !itemId || dataStorePath === null) {\n\t\treturn undefined;\n\t}\n\n\tlet siteUrl: URL | undefined;\n\ttry {\n\t\tsiteUrl = new URL(sitePath, siteOriginUrl);\n\t} catch {\n\t\t// Ignore failure to parse url as input might be malformed\n\t}\n\n\tif (!siteUrl) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tsiteUrl: siteUrl.href,\n\t\tdriveId,\n\t\titemId,\n\t\tdataStorePath,\n\t\tappName,\n\t\tcontainerPackageName,\n\t\tfileVersion,\n\t\tcontext,\n\t};\n}\n\n/**\n * This parameter is provided by host in the resolve request and it contains information about the file\n * like driveId, itemId, siteUrl, datastorePath, packageName etc.\n * @public\n */\nexport const locatorQueryParamName = \"nav\";\n\n/**\n * Embeds Fluid data store locator data into given ODSP url\n * @param url - file url in ODSP format (can be either canonical or share link)\n * @param locator - object representing Fluid data store location in ODSP terms\n * @public\n */\nexport function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocator) {\n\tconst encodedLocatorValue = encodeOdspFluidDataStoreLocator(locator);\n\t// IMPORTANT: Do not apply encodeURIComponent to encodedLocatorValue, param value is automatically encoded\n\t// when set via URLSearchParams class\n\turl.searchParams.set(locatorQueryParamName, encodedLocatorValue);\n}\n\n/**\n * Extract ODSP Fluid data store locator object from given ODSP url. This extracts things like\n * driveId, ItemId, siteUrl etc from a url where these are encoded in nav query param.\n * @param url - ODSP url representing Fluid file link\n * @param requireFluidSignature - flag representing if the Fluid signature is expected in the url, default true\n * @returns object representing Fluid data store location in ODSP terms\n * @public\n */\nexport function getLocatorFromOdspUrl(\n\turl: URL,\n\trequireFluidSignature: boolean = true,\n): OdspFluidDataStoreLocator | undefined {\n\t// NOTE: No need to apply decodeURIComponent when accessing query params via URLSearchParams class.\n\tconst encodedLocatorValue = url.searchParams.get(locatorQueryParamName);\n\tif (!encodedLocatorValue) {\n\t\treturn undefined;\n\t}\n\n\t// IMPORTANT: ODC deviates from ODSP in that its file link origin is different from vroom api origin.\n\t// The following code passes vroom api origin as site origin instead of file origin.\n\tconst siteOriginUrl =\n\t\turl.origin.toLowerCase() === OdcFileSiteOrigin ? OdcApiSiteOrigin : url.origin;\n\n\treturn decodeOdspFluidDataStoreLocator(\n\t\tencodedLocatorValue,\n\t\tsiteOriginUrl,\n\t\trequireFluidSignature,\n\t);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspLocationRedirection.js","sourceRoot":"","sources":["../src/odspLocationRedirection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CACnC,WAAyB,EACzB,gBAAwB;IAExB,MAAM,eAAe,GAAG,EAAE,GAAG,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;IAC/D,0DAA0D;IAC1D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC;IACvD,MAAM,UAAU,GAAG,GAAG,aAAa,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IAClF,eAAe,CAAC,OAAO,GAAG,UAAU,CAAC;IACrC,OAAO,eAAe,CAAC;AACxB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport { IOdspResolvedUrl } from \"@fluidframework/odsp-driver-definitions\";\nimport { getOdspResolvedUrl } from \"./odspUtils\";\n\n/**\n * It takes a resolved url with old siteUrl and creates a new resolved url with updated site url domain.\n * @param resolvedUrl - Previous odsp resolved url with older site url.\n * @param redirectLocation - Url at which the network call has to be made. It contains new site info.\n * @returns The resolved url after patching the correct siteUrl.\n */\nexport function patchOdspResolvedUrl(\n\tresolvedUrl: IResolvedUrl,\n\tredirectLocation: string,\n): IOdspResolvedUrl {\n\tconst odspResolvedUrl = { ...getOdspResolvedUrl(resolvedUrl) };\n\t// Generate the new SiteUrl from the redirection location.\n\tconst newSiteDomain = new URL(redirectLocation).origin;\n\tconst newSiteUrl = `${newSiteDomain}${new URL(odspResolvedUrl.siteUrl).pathname}`;\n\todspResolvedUrl.siteUrl = newSiteUrl;\n\treturn odspResolvedUrl;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspPublicUtils.js","sourceRoot":"","sources":["../src/odspPublicUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGnE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAe,EAAE,MAAc;IACxE,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,OAAO,IAAI,MAAM,EAAE,CAAC,CAAC;IACtD,OAAO,kBAAkB,CAAC,MAAM,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AACxE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { hashFile, IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\n/**\n * @public\n */\nexport async function getHashedDocumentId(driveId: string, itemId: string): Promise<string> {\n\tconst buffer = IsoBuffer.from(`${driveId}_${itemId}`);\n\treturn encodeURIComponent(await hashFile(buffer, \"SHA-256\", \"base64\"));\n}\n\n/**\n * @public\n */\nexport interface ISnapshotContents {\n\tsnapshotTree: ISnapshotTree;\n\tblobs: Map<string, ArrayBuffer>;\n\tops: ISequencedDocumentMessage[];\n\n\t/**\n\t * Sequence number of the snapshot\n\t */\n\tsequenceNumber: number | undefined;\n\n\t/**\n\t * Sequence number for the latest op/snapshot for the file in ODSP\n\t */\n\tlatestSequenceNumber: number | undefined;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspSnapshotParser.js","sourceRoot":"","sources":["../src/odspSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAKpD;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,QAA6B;IACpD,MAAM,MAAM,GAA0C,EAAE,CAAC;IACzD,2FAA2F;IAC3F,MAAM,IAAI,GAAsB,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAA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nC,MAAM,CACL,IAAI,CAAC,QAAQ,KAAK,QAAQ,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EACzD,KAAK,CAAC,mCAAmC,CACzC,CAAC;YACF,sBAAsB,CAAC,GAAG,CACzB,IAAI,CAAC,EAAE,EACP,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,CACrD,CAAC;QACH,CAAC,CAAC,CAAC;KACH;IAED,MAAM,cAAc,GAAG,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;IAE7D,MAAM,GAAG,GAAsB;QAC9B,KAAK,EAAE,sBAAsB;QAC7B,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE;QAC/C,cAAc;QACd,YAAY,EAAE,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACnD,oBAAoB,EACnB,YAAY,CAAC,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC;YAC9C,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,cAAc;YAC9D,CAAC,CAAC,cAAc;KAClB,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IOdspSnapshot, IOdspSnapshotCommit } from \"./contracts\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\n\n/**\n * Build a tree hierarchy base on a flat tree\n *\n * @param flatTree - a flat tree\n * @param blobsShaToPathCache - Map with blobs sha as keys and values as path of the blob.\n * @returns the hierarchical tree\n */\nfunction buildHierarchy(flatTree: IOdspSnapshotCommit): api.ISnapshotTree {\n\tconst lookup: { [path: string]: api.ISnapshotTree } = {};\n\t// id is required for root tree as it will be used to determine the version we loaded from.\n\tconst root: api.ISnapshotTree = { id: flatTree.id, blobs: {}, trees: {} };\n\tlookup[\"\"] = root;\n\n\tfor (const entry of flatTree.entries) {\n\t\tconst lastIndex = entry.path.lastIndexOf(\"/\");\n\t\tconst entryPathDir = entry.path.slice(0, Math.max(0, lastIndex));\n\t\tconst entryPathBase = entry.path.slice(lastIndex + 1);\n\n\t\t// ODSP snapshots are created breadth-first so we can assume we see tree nodes prior to their contents\n\t\tconst node = lookup[entryPathDir];\n\n\t\t// Add in either the blob or tree\n\t\tif (entry.type === \"tree\") {\n\t\t\tconst newTree: api.ISnapshotTree = {\n\t\t\t\tblobs: {},\n\t\t\t\ttrees: {},\n\t\t\t\tunreferenced: entry.unreferenced,\n\t\t\t};\n\t\t\tnode.trees[decodeURIComponent(entryPathBase)] = newTree;\n\t\t\tlookup[entry.path] = newTree;\n\t\t} else if (entry.type === \"blob\") {\n\t\t\tnode.blobs[decodeURIComponent(entryPathBase)] = entry.id;\n\t\t}\n\t}\n\n\treturn root;\n}\n\n/**\n * Converts existing IOdspSnapshot to snapshot tree, blob array and ops\n * @param odspSnapshot - snapshot\n */\nexport function convertOdspSnapshotToSnapshotTreeAndBlobs(\n\todspSnapshot: IOdspSnapshot,\n): ISnapshotContents {\n\tconst blobsWithBufferContent = new Map<string, ArrayBuffer>();\n\tif (odspSnapshot.blobs) {\n\t\todspSnapshot.blobs.forEach((blob) => {\n\t\t\tassert(\n\t\t\t\tblob.encoding === \"base64\" || blob.encoding === undefined,\n\t\t\t\t0x0a4 /* Unexpected blob encoding type */,\n\t\t\t);\n\t\t\tblobsWithBufferContent.set(\n\t\t\t\tblob.id,\n\t\t\t\tstringToBuffer(blob.content, blob.encoding ?? \"utf8\"),\n\t\t\t);\n\t\t});\n\t}\n\n\tconst sequenceNumber = odspSnapshot?.trees[0].sequenceNumber;\n\n\tconst val: ISnapshotContents = {\n\t\tblobs: blobsWithBufferContent,\n\t\tops: odspSnapshot.ops?.map((op) => op.op) ?? [],\n\t\tsequenceNumber,\n\t\tsnapshotTree: buildHierarchy(odspSnapshot.trees[0]),\n\t\tlatestSequenceNumber:\n\t\t\todspSnapshot.ops && odspSnapshot.ops.length > 0\n\t\t\t\t? odspSnapshot.ops[odspSnapshot.ops.length - 1].sequenceNumber\n\t\t\t\t: sequenceNumber,\n\t};\n\treturn val;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"odspSummaryUploadManager.js","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAE5D,OAAO,EAEN,yBAAyB,EAEzB,gBAAgB,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAU/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IAKpC,YACkB,WAAmB,EACnB,eAAgD,EACjE,MAA2B,EACV,YAA0B,EAC1B,sCAA+C,EAC/C,8BAAwD;QALxD,gBAAW,GAAX,WAAW,CAAQ;QACnB,oBAAe,GAAf,eAAe,CAAiC;QAEhD,iBAAY,GAAZ,YAAY,CAAc;QAC1B,2CAAsC,GAAtC,sCAAsC,CAAS;QAC/C,mCAA8B,GAA9B,8BAA8B,CAA0B;QAEzE,IAAI,CAA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AkB,aAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;iBAC/E;aACD;YAED,MAAM,SAAS,GAA8B;gBAC5C,IAAI,EAAE,kBAAkB,CAAC,GAAG,CAAC;gBAC7B,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC;aAC/B,CAAC;YAEF,IAAI,KAA2B,CAAC;YAEhC,IAAI,KAAK,EAAE;gBACV,MAAM,CACL,EAAE,KAAK,SAAS,EAChB,KAAK,CAAC,iEAAiE,CACvE,CAAC;gBACF,KAAK,GAAG;oBACP,KAAK;oBACL,GAAG,SAAS;oBACZ,YAAY;iBACZ,CAAC;aACF;iBAAM,IAAI,EAAE,EAAE;gBACd,KAAK,GAAG;oBACP,GAAG,SAAS;oBACZ,EAAE;iBACF,CAAC;aACF;iBAAM;gBACN,MAAM,IAAI,KAAK,CAAC,0BAA0B,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;aAChE;YAED,YAAY,CAAC,OAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAClC;QAED,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IAChC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport {\n\tITelemetryLoggerExt,\n\tloggerToMonitoringContext,\n\tMonitoringContext,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport { isCombinedAppAndProtocolSummary } from \"@fluidframework/driver-utils\";\nimport {\n\tIOdspSummaryPayload,\n\tIWriteSummaryResponse,\n\tIOdspSummaryTree,\n\tIOdspSummaryTreeBaseEntry,\n\tOdspSummaryTreeEntry,\n\tOdspSummaryTreeValue,\n} from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/**\n * This class manages a summary upload. When it receives a call to upload summary, it converts the summary tree into\n * a snapshot tree and then uploads that to the server.\n */\nexport class OdspSummaryUploadManager {\n\t// Last proposed handle of the uploaded app summary.\n\tprivate lastSummaryProposalHandle: string | undefined;\n\tprivate readonly mc: MonitoringContext;\n\n\tconstructor(\n\t\tprivate readonly snapshotUrl: string,\n\t\tprivate readonly getStorageToken: InstrumentedStorageTokenFetcher,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly forceAccessTokenViaAuthorizationHeader: boolean,\n\t\tprivate readonly relayServiceTenantAndSessionId: () => string | undefined,\n\t) {\n\t\tthis.mc = loggerToMonitoringContext(logger);\n\t}\n\n\tpublic async writeSummaryTree(tree: api.ISummaryTree, context: ISummaryContext) {\n\t\t// If the last proposed handle is not the proposed handle of the acked summary(could happen when the last summary get nacked),\n\t\t// then re-initialize the caches with the previous ones else just update the previous caches with the caches from acked summary.\n\t\t// Don't bother logging if lastSummaryProposalHandle hasn't been set before; only log on a positive mismatch.\n\t\tif (\n\t\t\tthis.lastSummaryProposalHandle !== undefined &&\n\t\t\tthis.lastSummaryProposalHandle !== context.proposalHandle\n\t\t) {\n\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"LastSummaryProposedHandleMismatch\",\n\t\t\t\tackedSummaryProposedHandle: context.proposalHandle,\n\t\t\t\tlastSummaryProposalHandle: this.lastSummaryProposalHandle,\n\t\t\t});\n\t\t}\n\t\tconst result = await this.writeSummaryTreeCore(\n\t\t\tcontext.ackHandle,\n\t\t\tcontext.referenceSequenceNumber,\n\t\t\ttree,\n\t\t);\n\t\tconst id = result ? result.id : undefined;\n\t\tif (!result || !id) {\n\t\t\tthrow new Error(`Failed to write summary tree`);\n\t\t}\n\t\tthis.lastSummaryProposalHandle = id;\n\t\treturn id;\n\t}\n\n\tprivate async writeSummaryTreeCore(\n\t\tparentHandle: string | undefined,\n\t\treferenceSequenceNumber: number,\n\t\ttree: api.ISummaryTree,\n\t): Promise<IWriteSummaryResponse> {\n\t\tconst containsProtocolTree = isCombinedAppAndProtocolSummary(tree);\n\t\tconst { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(\n\t\t\tparentHandle,\n\t\t\ttree,\n\t\t\t\".app\",\n\t\t);\n\t\tconst snapshot: IOdspSummaryPayload = {\n\t\t\tentries: snapshotTree.entries!,\n\t\t\tmessage: \"app\",\n\t\t\tsequenceNumber: referenceSequenceNumber,\n\t\t\t// no ack handle implies this is initial summary after empty file creation.\n\t\t\t// send container payload so server will use it without a summary op\n\t\t\ttype: containsProtocolTree || parentHandle === undefined ? \"container\" : \"channel\",\n\t\t};\n\n\t\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst storageToken = await this.getStorageToken(options, \"WriteSummaryTree\");\n\n\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\t`${this.snapshotUrl}/snapshot`,\n\t\t\t\tstorageToken,\n\t\t\t\tthis.forceAccessTokenViaAuthorizationHeader,\n\t\t\t);\n\t\t\theaders[\"Content-Type\"] = \"application/json\";\n\t\t\tconst relayServiceTenantAndSessionId = this.relayServiceTenantAndSessionId();\n\t\t\t// This would be undefined in case of summary is uploaded in detached container with attachment\n\t\t\t// blobs flow where summary is uploaded without connecting to push.\n\t\t\tif (relayServiceTenantAndSessionId !== undefined) {\n\t\t\t\theaders[\"If-Match\"] = `fluid:sessionid=${relayServiceTenantAndSessionId}${\n\t\t\t\t\tparentHandle ? `;containerid=${parentHandle}` : \"\"\n\t\t\t\t}`;\n\t\t\t}\n\n\t\t\tconst postBody = JSON.stringify(snapshot);\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.mc.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"uploadSummary\",\n\t\t\t\t\tattempt: options.refresh ? 2 : 1,\n\t\t\t\t\thasClaims: !!options.claims,\n\t\t\t\t\thasTenantId: !!options.tenantId,\n\t\t\t\t\theaders: Object.keys(headers).length !== 0 ? true : undefined,\n\t\t\t\t\tblobs,\n\t\t\t\t\tsize: postBody.length,\n\t\t\t\t\treferenceSequenceNumber,\n\t\t\t\t\ttype: snapshot.type,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\tconst response =\n\t\t\t\t\t\tawait this.epochTracker.fetchAndParseAsJSON<IWriteSummaryResponse>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: postBody,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"uploadSummary\",\n\t\t\t\t\t\t);\n\t\t\t\t\treturn response.content;\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}\n\n\t/**\n\t * Following are the goals of this function:\n\t *\n\t * a. Converts the summary tree to a snapshot/odsp tree to be uploaded. Always upload full snapshot tree.\n\t *\n\t * @param parentHandle - Handle of the last uploaded summary or detach new summary.\n\t * @param tree - Summary Tree which will be converted to snapshot tree to be uploaded.\n\t * @param rootNodeName - Root node name of the summary tree.\n\t * @param path - Current path of node which is getting evaluated.\n\t * @param markUnreferencedNodes - True if we should mark unreferenced nodes.\n\t */\n\tprivate async convertSummaryToSnapshotTree(\n\t\tparentHandle: string | undefined,\n\t\ttree: api.ISummaryTree,\n\t\trootNodeName: string,\n\t\tmarkUnreferencedNodes: boolean = this.mc.config.getBoolean(\n\t\t\t\"Fluid.Driver.Odsp.MarkUnreferencedNodes\",\n\t\t) ?? true,\n\t) {\n\t\tconst snapshotTree: IOdspSummaryTree = {\n\t\t\ttype: \"tree\",\n\t\t\tentries: [] as OdspSummaryTreeEntry[],\n\t\t};\n\n\t\tlet blobs = 0;\n\t\tconst keys = Object.keys(tree.tree);\n\t\tfor (const key of keys) {\n\t\t\tconst summaryObject = tree.tree[key];\n\n\t\t\tlet id: string | undefined;\n\t\t\tlet value: OdspSummaryTreeValue | undefined;\n\n\t\t\t// Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n\t\t\t// property is not present, the tree entry is considered referenced. If the property is present and is\n\t\t\t// true (which is the only value it can have), the tree entry is considered unreferenced.\n\t\t\tlet unreferenced: true | undefined;\n\t\t\tswitch (summaryObject.type) {\n\t\t\t\tcase api.SummaryType.Tree: {\n\t\t\t\t\tconst result = await this.convertSummaryToSnapshotTree(\n\t\t\t\t\t\tparentHandle,\n\t\t\t\t\t\tsummaryObject,\n\t\t\t\t\t\trootNodeName,\n\t\t\t\t\t);\n\t\t\t\t\tvalue = result.snapshotTree;\n\t\t\t\t\tunreferenced = markUnreferencedNodes ? summaryObject.unreferenced : undefined;\n\t\t\t\t\tblobs += result.blobs;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase api.SummaryType.Blob: {\n\t\t\t\t\tvalue =\n\t\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\ttype: \"blob\",\n\t\t\t\t\t\t\t\t\tcontent: summaryObject.content,\n\t\t\t\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\ttype: \"blob\",\n\t\t\t\t\t\t\t\t\tcontent: Uint8ArrayToString(summaryObject.content, \"base64\"),\n\t\t\t\t\t\t\t\t\tencoding: \"base64\",\n\t\t\t\t\t\t\t };\n\t\t\t\t\tblobs++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase api.SummaryType.Handle: {\n\t\t\t\t\tif (!parentHandle) {\n\t\t\t\t\t\tthrow Error(\"Parent summary does not exist to reference by handle.\");\n\t\t\t\t\t}\n\t\t\t\t\tlet handlePath = summaryObject.handle;\n\t\t\t\t\tif (handlePath.length > 0 && !handlePath.startsWith(\"/\")) {\n\t\t\t\t\t\thandlePath = `/${handlePath}`;\n\t\t\t\t\t}\n\t\t\t\t\tconst pathKey = `${rootNodeName}${handlePath}`;\n\t\t\t\t\tid = `${parentHandle}/${pathKey}`;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase api.SummaryType.Attachment: {\n\t\t\t\t\tid = summaryObject.id;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(summaryObject, `Unknown type: ${(summaryObject as any).type}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst baseEntry: IOdspSummaryTreeBaseEntry = {\n\t\t\t\tpath: encodeURIComponent(key),\n\t\t\t\ttype: getGitType(summaryObject),\n\t\t\t};\n\n\t\t\tlet entry: OdspSummaryTreeEntry;\n\n\t\t\tif (value) {\n\t\t\t\tassert(\n\t\t\t\t\tid === undefined,\n\t\t\t\t\t0x0ad /* \"Snapshot entry has both a tree value and a referenced id!\" */,\n\t\t\t\t);\n\t\t\t\tentry = {\n\t\t\t\t\tvalue,\n\t\t\t\t\t...baseEntry,\n\t\t\t\t\tunreferenced,\n\t\t\t\t};\n\t\t\t} else if (id) {\n\t\t\t\tentry = {\n\t\t\t\t\t...baseEntry,\n\t\t\t\t\tid,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tthrow new Error(`Invalid tree entry for ${summaryObject.type}`);\n\t\t\t}\n\n\t\t\tsnapshotTree.entries!.push(entry);\n\t\t}\n\n\t\treturn { snapshotTree, blobs };\n\t}\n}\n"]}