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

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 (661) hide show
  1. package/.eslintrc.js +12 -12
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +162 -0
  4. package/README.md +56 -0
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +2 -2
  7. package/api-report/odsp-driver.api.md +310 -0
  8. package/dist/{ReadBufferUtils.js → ReadBufferUtils.cjs} +16 -9
  9. package/dist/ReadBufferUtils.cjs.map +1 -0
  10. package/dist/ReadBufferUtils.d.ts.map +1 -1
  11. package/dist/{WriteBufferUtils.js → WriteBufferUtils.cjs} +73 -69
  12. package/dist/WriteBufferUtils.cjs.map +1 -0
  13. package/dist/WriteBufferUtils.d.ts +3 -5
  14. package/dist/WriteBufferUtils.d.ts.map +1 -1
  15. package/dist/{checkUrl.js → checkUrl.cjs} +7 -6
  16. package/dist/checkUrl.cjs.map +1 -0
  17. package/dist/checkUrl.d.ts +1 -0
  18. package/dist/checkUrl.d.ts.map +1 -1
  19. package/dist/compactSnapshotParser.cjs +207 -0
  20. package/dist/compactSnapshotParser.cjs.map +1 -0
  21. package/dist/compactSnapshotParser.d.ts +12 -3
  22. package/dist/compactSnapshotParser.d.ts.map +1 -1
  23. package/dist/{compactSnapshotWriter.js → compactSnapshotWriter.cjs} +43 -33
  24. package/dist/compactSnapshotWriter.cjs.map +1 -0
  25. package/dist/compactSnapshotWriter.d.ts +2 -3
  26. package/dist/compactSnapshotWriter.d.ts.map +1 -1
  27. package/dist/{constants.js → constants.cjs} +7 -1
  28. package/dist/constants.cjs.map +1 -0
  29. package/dist/constants.d.ts +6 -0
  30. package/dist/constants.d.ts.map +1 -1
  31. package/dist/{contracts.js → contracts.cjs} +1 -1
  32. package/dist/contracts.cjs.map +1 -0
  33. package/dist/contracts.d.ts +16 -53
  34. package/dist/contracts.d.ts.map +1 -1
  35. package/dist/{contractsPublic.js → contractsPublic.cjs} +9 -3
  36. package/dist/contractsPublic.cjs.map +1 -0
  37. package/dist/contractsPublic.d.ts +15 -0
  38. package/dist/contractsPublic.d.ts.map +1 -1
  39. package/dist/createFile.cjs +177 -0
  40. package/dist/createFile.cjs.map +1 -0
  41. package/dist/createFile.d.ts +6 -10
  42. package/dist/createFile.d.ts.map +1 -1
  43. package/dist/createNewContainerOnExistingFile.cjs +60 -0
  44. package/dist/createNewContainerOnExistingFile.cjs.map +1 -0
  45. package/dist/createNewContainerOnExistingFile.d.ts +22 -0
  46. package/dist/createNewContainerOnExistingFile.d.ts.map +1 -0
  47. package/dist/createNewModule.cjs +12 -0
  48. package/dist/createNewModule.cjs.map +1 -0
  49. package/dist/createNewModule.d.ts +7 -0
  50. package/dist/createNewModule.d.ts.map +1 -0
  51. package/dist/createNewUtils.cjs +203 -0
  52. package/dist/createNewUtils.cjs.map +1 -0
  53. package/dist/createNewUtils.d.ts +16 -0
  54. package/dist/createNewUtils.d.ts.map +1 -1
  55. package/dist/{createOdspCreateContainerRequest.js → createOdspCreateContainerRequest.cjs} +8 -4
  56. package/dist/createOdspCreateContainerRequest.cjs.map +1 -0
  57. package/dist/createOdspCreateContainerRequest.d.ts +5 -3
  58. package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
  59. package/dist/{createOdspUrl.js → createOdspUrl.cjs} +2 -1
  60. package/dist/createOdspUrl.cjs.map +1 -0
  61. package/dist/createOdspUrl.d.ts +1 -0
  62. package/dist/createOdspUrl.d.ts.map +1 -1
  63. package/dist/{epochTracker.js → epochTracker.cjs} +102 -48
  64. package/dist/epochTracker.cjs.map +1 -0
  65. package/dist/epochTracker.d.ts +32 -8
  66. package/dist/epochTracker.d.ts.map +1 -1
  67. package/dist/{fetch.js → fetch.cjs} +1 -1
  68. package/dist/fetch.cjs.map +1 -0
  69. package/dist/fetch.d.ts +1 -1
  70. package/dist/fetch.d.ts.map +1 -1
  71. package/dist/{fetchSnapshot.js → fetchSnapshot.cjs} +192 -176
  72. package/dist/fetchSnapshot.cjs.map +1 -0
  73. package/dist/fetchSnapshot.d.ts +10 -5
  74. package/dist/fetchSnapshot.d.ts.map +1 -1
  75. package/dist/{getFileLink.js → getFileLink.cjs} +52 -41
  76. package/dist/getFileLink.cjs.map +1 -0
  77. package/dist/getFileLink.d.ts +4 -7
  78. package/dist/getFileLink.d.ts.map +1 -1
  79. package/dist/{getQueryString.js → getQueryString.cjs} +1 -1
  80. package/dist/getQueryString.cjs.map +1 -0
  81. package/dist/getQueryString.d.ts.map +1 -1
  82. package/dist/{getUrlAndHeadersWithAuth.js → getUrlAndHeadersWithAuth.cjs} +4 -2
  83. package/dist/getUrlAndHeadersWithAuth.cjs.map +1 -0
  84. package/dist/getUrlAndHeadersWithAuth.d.ts.map +1 -1
  85. package/dist/index.cjs +59 -0
  86. package/dist/index.cjs.map +1 -0
  87. package/dist/index.d.ts +19 -16
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/localOdspDriver/localOdspDeltaStorageService.cjs +35 -0
  90. package/dist/localOdspDriver/localOdspDeltaStorageService.cjs.map +1 -0
  91. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts +17 -0
  92. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
  93. package/dist/localOdspDriver/{localOdspDocumentService.js → localOdspDocumentService.cjs} +7 -5
  94. package/dist/localOdspDriver/localOdspDocumentService.cjs.map +1 -0
  95. package/dist/localOdspDriver/localOdspDocumentService.d.ts +3 -2
  96. package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
  97. package/dist/localOdspDriver/{localOdspDocumentServiceFactory.js → localOdspDocumentServiceFactory.cjs} +9 -10
  98. package/dist/localOdspDriver/localOdspDocumentServiceFactory.cjs.map +1 -0
  99. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +2 -3
  100. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
  101. package/dist/localOdspDriver/{localOdspDocumentStorageManager.js → localOdspDocumentStorageManager.cjs} +13 -11
  102. package/dist/localOdspDriver/localOdspDocumentStorageManager.cjs.map +1 -0
  103. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts +2 -2
  104. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
  105. package/dist/odsp-driver-alpha.d.ts +497 -0
  106. package/dist/odsp-driver-beta.d.ts +159 -0
  107. package/dist/odsp-driver-public.d.ts +159 -0
  108. package/dist/odsp-driver-untrimmed.d.ts +566 -0
  109. package/dist/{odspCache.js → odspCache.cjs} +9 -10
  110. package/dist/odspCache.cjs.map +1 -0
  111. package/dist/odspCache.d.ts +19 -4
  112. package/dist/odspCache.d.ts.map +1 -1
  113. package/dist/odspDelayLoadedDeltaStream.cjs +291 -0
  114. package/dist/odspDelayLoadedDeltaStream.cjs.map +1 -0
  115. package/dist/odspDelayLoadedDeltaStream.d.ts +75 -0
  116. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -0
  117. package/dist/{odspDeltaStorageService.js → odspDeltaStorageService.cjs} +70 -71
  118. package/dist/odspDeltaStorageService.cjs.map +1 -0
  119. package/dist/odspDeltaStorageService.d.ts +8 -6
  120. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  121. package/dist/{odspDocumentDeltaConnection.js → odspDocumentDeltaConnection.cjs} +224 -113
  122. package/dist/odspDocumentDeltaConnection.cjs.map +1 -0
  123. package/dist/odspDocumentDeltaConnection.d.ts +32 -12
  124. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  125. package/dist/odspDocumentService.cjs +225 -0
  126. package/dist/odspDocumentService.cjs.map +1 -0
  127. package/dist/odspDocumentService.d.ts +11 -25
  128. package/dist/odspDocumentService.d.ts.map +1 -1
  129. package/dist/{odspDocumentServiceFactory.js → odspDocumentServiceFactory.cjs} +8 -5
  130. package/dist/odspDocumentServiceFactory.cjs.map +1 -0
  131. package/dist/odspDocumentServiceFactory.d.ts +4 -0
  132. package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
  133. package/dist/odspDocumentServiceFactoryCore.cjs +196 -0
  134. package/dist/odspDocumentServiceFactoryCore.cjs.map +1 -0
  135. package/dist/odspDocumentServiceFactoryCore.d.ts +16 -11
  136. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  137. package/dist/odspDocumentServiceFactoryWithCodeSplit.cjs +20 -0
  138. package/dist/odspDocumentServiceFactoryWithCodeSplit.cjs.map +1 -0
  139. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +5 -0
  140. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
  141. package/dist/odspDocumentStorageManager.cjs +490 -0
  142. package/dist/odspDocumentStorageManager.cjs.map +1 -0
  143. package/dist/odspDocumentStorageManager.d.ts +11 -5
  144. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  145. package/dist/{odspDocumentStorageServiceBase.js → odspDocumentStorageServiceBase.cjs} +32 -34
  146. package/dist/odspDocumentStorageServiceBase.cjs.map +1 -0
  147. package/dist/odspDocumentStorageServiceBase.d.ts +7 -9
  148. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  149. package/dist/{odspDriverUrlResolver.js → odspDriverUrlResolver.cjs} +50 -36
  150. package/dist/odspDriverUrlResolver.cjs.map +1 -0
  151. package/dist/odspDriverUrlResolver.d.ts +12 -0
  152. package/dist/odspDriverUrlResolver.d.ts.map +1 -1
  153. package/dist/{odspDriverUrlResolverForShareLink.js → odspDriverUrlResolverForShareLink.cjs} +37 -26
  154. package/dist/odspDriverUrlResolverForShareLink.cjs.map +1 -0
  155. package/dist/odspDriverUrlResolverForShareLink.d.ts +5 -3
  156. package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  157. package/dist/{odspError.js → odspError.cjs} +7 -3
  158. package/dist/odspError.cjs.map +1 -0
  159. package/dist/odspError.d.ts.map +1 -1
  160. package/dist/{odspFluidFileLink.js → odspFluidFileLink.cjs} +25 -18
  161. package/dist/odspFluidFileLink.cjs.map +1 -0
  162. package/dist/odspFluidFileLink.d.ts +10 -1
  163. package/dist/odspFluidFileLink.d.ts.map +1 -1
  164. package/dist/odspLocationRedirection.cjs +24 -0
  165. package/dist/odspLocationRedirection.cjs.map +1 -0
  166. package/dist/odspLocationRedirection.d.ts +14 -0
  167. package/dist/odspLocationRedirection.d.ts.map +1 -0
  168. package/dist/{odspPublicUtils.js → odspPublicUtils.cjs} +7 -4
  169. package/dist/odspPublicUtils.cjs.map +1 -0
  170. package/dist/odspPublicUtils.d.ts +6 -0
  171. package/dist/odspPublicUtils.d.ts.map +1 -1
  172. package/dist/{odspSnapshotParser.js → odspSnapshotParser.cjs} +11 -12
  173. package/dist/odspSnapshotParser.cjs.map +1 -0
  174. package/dist/odspSnapshotParser.d.ts.map +1 -1
  175. package/dist/{odspSummaryUploadManager.js → odspSummaryUploadManager.cjs} +47 -34
  176. package/dist/odspSummaryUploadManager.cjs.map +1 -0
  177. package/dist/odspSummaryUploadManager.d.ts +7 -4
  178. package/dist/odspSummaryUploadManager.d.ts.map +1 -1
  179. package/dist/{odspUrlHelper.js → odspUrlHelper.cjs} +9 -3
  180. package/dist/odspUrlHelper.cjs.map +1 -0
  181. package/dist/odspUrlHelper.d.ts +5 -0
  182. package/dist/odspUrlHelper.d.ts.map +1 -1
  183. package/dist/{odspUtils.js → odspUtils.cjs} +118 -30
  184. package/dist/odspUtils.cjs.map +1 -0
  185. package/dist/odspUtils.d.ts +35 -6
  186. package/dist/odspUtils.d.ts.map +1 -1
  187. package/dist/{opsCaching.js → opsCaching.cjs} +25 -9
  188. package/dist/opsCaching.cjs.map +1 -0
  189. package/dist/opsCaching.d.ts +3 -3
  190. package/dist/opsCaching.d.ts.map +1 -1
  191. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  192. package/dist/packageVersion.cjs.map +1 -0
  193. package/dist/packageVersion.d.ts +1 -1
  194. package/dist/packageVersion.d.ts.map +1 -1
  195. package/dist/prefetchLatestSnapshot.cjs +100 -0
  196. package/dist/prefetchLatestSnapshot.cjs.map +1 -0
  197. package/dist/prefetchLatestSnapshot.d.ts +12 -7
  198. package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
  199. package/dist/{retryErrorsStorageAdapter.js → retryErrorsStorageAdapter.cjs} +13 -6
  200. package/dist/retryErrorsStorageAdapter.cjs.map +1 -0
  201. package/dist/retryErrorsStorageAdapter.d.ts +5 -4
  202. package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
  203. package/dist/{retryUtils.js → retryUtils.cjs} +30 -14
  204. package/dist/retryUtils.cjs.map +1 -0
  205. package/dist/retryUtils.d.ts +2 -2
  206. package/dist/retryUtils.d.ts.map +1 -1
  207. package/dist/socketModule.cjs +10 -0
  208. package/dist/socketModule.cjs.map +1 -0
  209. package/dist/socketModule.d.ts +7 -0
  210. package/dist/socketModule.d.ts.map +1 -0
  211. package/dist/tsdoc-metadata.json +11 -0
  212. package/dist/{vroom.js → vroom.cjs} +24 -9
  213. package/dist/vroom.cjs.map +1 -0
  214. package/dist/vroom.d.ts +4 -4
  215. package/dist/vroom.d.ts.map +1 -1
  216. package/dist/{zipItDataRepresentationUtils.js → zipItDataRepresentationUtils.cjs} +227 -118
  217. package/dist/zipItDataRepresentationUtils.cjs.map +1 -0
  218. package/dist/zipItDataRepresentationUtils.d.ts +47 -20
  219. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  220. package/lib/ReadBufferUtils.d.mts.map +1 -0
  221. package/lib/{ReadBufferUtils.js → ReadBufferUtils.mjs} +14 -7
  222. package/lib/ReadBufferUtils.mjs.map +1 -0
  223. package/lib/{WriteBufferUtils.d.ts → WriteBufferUtils.d.mts} +3 -5
  224. package/lib/WriteBufferUtils.d.mts.map +1 -0
  225. package/lib/{WriteBufferUtils.js → WriteBufferUtils.mjs} +68 -64
  226. package/lib/WriteBufferUtils.mjs.map +1 -0
  227. package/lib/{checkUrl.d.ts → checkUrl.d.mts} +1 -0
  228. package/lib/checkUrl.d.mts.map +1 -0
  229. package/lib/{checkUrl.js → checkUrl.mjs} +7 -6
  230. package/lib/checkUrl.mjs.map +1 -0
  231. package/lib/compactSnapshotParser.d.mts +24 -0
  232. package/lib/compactSnapshotParser.d.mts.map +1 -0
  233. package/lib/compactSnapshotParser.mjs +203 -0
  234. package/lib/compactSnapshotParser.mjs.map +1 -0
  235. package/lib/{compactSnapshotWriter.d.ts → compactSnapshotWriter.d.mts} +3 -4
  236. package/lib/compactSnapshotWriter.d.mts.map +1 -0
  237. package/lib/{compactSnapshotWriter.js → compactSnapshotWriter.mjs} +41 -31
  238. package/lib/compactSnapshotWriter.mjs.map +1 -0
  239. package/lib/{constants.d.ts → constants.d.mts} +6 -0
  240. package/lib/constants.d.mts.map +1 -0
  241. package/lib/{constants.js → constants.mjs} +7 -1
  242. package/lib/constants.mjs.map +1 -0
  243. package/lib/{contracts.d.ts → contracts.d.mts} +17 -54
  244. package/lib/contracts.d.mts.map +1 -0
  245. package/lib/{contracts.js → contracts.mjs} +1 -1
  246. package/lib/contracts.mjs.map +1 -0
  247. package/lib/{contractsPublic.d.ts → contractsPublic.d.mts} +15 -0
  248. package/lib/contractsPublic.d.mts.map +1 -0
  249. package/lib/{contractsPublic.js → contractsPublic.mjs} +7 -1
  250. package/lib/contractsPublic.mjs.map +1 -0
  251. package/lib/createFile.d.mts +18 -0
  252. package/lib/createFile.d.mts.map +1 -0
  253. package/lib/createFile.mjs +171 -0
  254. package/lib/createFile.mjs.map +1 -0
  255. package/lib/createNewContainerOnExistingFile.d.mts +22 -0
  256. package/lib/createNewContainerOnExistingFile.d.mts.map +1 -0
  257. package/lib/createNewContainerOnExistingFile.mjs +56 -0
  258. package/lib/createNewContainerOnExistingFile.mjs.map +1 -0
  259. package/lib/createNewModule.d.mts +7 -0
  260. package/lib/createNewModule.d.mts.map +1 -0
  261. package/lib/createNewModule.mjs +7 -0
  262. package/lib/createNewModule.mjs.map +1 -0
  263. package/lib/createNewUtils.d.mts +27 -0
  264. package/lib/createNewUtils.d.mts.map +1 -0
  265. package/lib/createNewUtils.mjs +197 -0
  266. package/lib/createNewUtils.mjs.map +1 -0
  267. package/lib/{createOdspCreateContainerRequest.d.ts → createOdspCreateContainerRequest.d.mts} +5 -7
  268. package/lib/createOdspCreateContainerRequest.d.mts.map +1 -0
  269. package/lib/{createOdspCreateContainerRequest.js → createOdspCreateContainerRequest.mjs} +8 -4
  270. package/lib/createOdspCreateContainerRequest.mjs.map +1 -0
  271. package/lib/{createOdspUrl.d.ts → createOdspUrl.d.mts} +2 -1
  272. package/lib/{createOdspUrl.d.ts.map → createOdspUrl.d.mts.map} +1 -1
  273. package/lib/{createOdspUrl.js → createOdspUrl.mjs} +2 -1
  274. package/lib/createOdspUrl.mjs.map +1 -0
  275. package/lib/{epochTracker.d.ts → epochTracker.d.mts} +34 -10
  276. package/lib/epochTracker.d.mts.map +1 -0
  277. package/lib/{epochTracker.js → epochTracker.mjs} +97 -43
  278. package/lib/epochTracker.mjs.map +1 -0
  279. package/lib/{fetch.d.ts → fetch.d.mts} +1 -1
  280. package/lib/{fetch.d.ts.map → fetch.d.mts.map} +1 -1
  281. package/lib/{fetch.js → fetch.mjs} +1 -1
  282. package/lib/fetch.mjs.map +1 -0
  283. package/lib/{fetchSnapshot.d.ts → fetchSnapshot.d.mts} +14 -9
  284. package/lib/fetchSnapshot.d.mts.map +1 -0
  285. package/lib/{fetchSnapshot.js → fetchSnapshot.mjs} +185 -167
  286. package/lib/fetchSnapshot.mjs.map +1 -0
  287. package/lib/{getFileLink.d.ts → getFileLink.d.mts} +4 -7
  288. package/lib/getFileLink.d.mts.map +1 -0
  289. package/lib/{getFileLink.js → getFileLink.mjs} +49 -38
  290. package/lib/getFileLink.mjs.map +1 -0
  291. package/lib/{getQueryString.d.ts → getQueryString.d.mts} +0 -4
  292. package/lib/getQueryString.d.mts.map +1 -0
  293. package/lib/{getQueryString.js → getQueryString.mjs} +1 -1
  294. package/lib/getQueryString.mjs.map +1 -0
  295. package/lib/{getUrlAndHeadersWithAuth.d.ts.map → getUrlAndHeadersWithAuth.d.mts.map} +1 -1
  296. package/lib/{getUrlAndHeadersWithAuth.js → getUrlAndHeadersWithAuth.mjs} +4 -2
  297. package/lib/getUrlAndHeadersWithAuth.mjs.map +1 -0
  298. package/lib/index.d.mts +24 -0
  299. package/lib/index.d.mts.map +1 -0
  300. package/lib/index.mjs +22 -0
  301. package/lib/index.mjs.map +1 -0
  302. package/lib/localOdspDriver/localOdspDeltaStorageService.d.mts +17 -0
  303. package/lib/localOdspDriver/localOdspDeltaStorageService.d.mts.map +1 -0
  304. package/lib/localOdspDriver/localOdspDeltaStorageService.mjs +31 -0
  305. package/lib/localOdspDriver/localOdspDeltaStorageService.mjs.map +1 -0
  306. package/lib/localOdspDriver/{localOdspDocumentService.d.ts → localOdspDocumentService.d.mts} +3 -2
  307. package/lib/localOdspDriver/localOdspDocumentService.d.mts.map +1 -0
  308. package/lib/localOdspDriver/{localOdspDocumentService.js → localOdspDocumentService.mjs} +8 -6
  309. package/lib/localOdspDriver/localOdspDocumentService.mjs.map +1 -0
  310. package/lib/localOdspDriver/{localOdspDocumentServiceFactory.d.ts → localOdspDocumentServiceFactory.d.mts} +4 -5
  311. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.mts.map +1 -0
  312. package/lib/localOdspDriver/{localOdspDocumentServiceFactory.js → localOdspDocumentServiceFactory.mjs} +9 -10
  313. package/lib/localOdspDriver/localOdspDocumentServiceFactory.mjs.map +1 -0
  314. package/lib/localOdspDriver/{localOdspDocumentStorageManager.d.ts → localOdspDocumentStorageManager.d.mts} +3 -3
  315. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.mts.map +1 -0
  316. package/lib/localOdspDriver/{localOdspDocumentStorageManager.js → localOdspDocumentStorageManager.mjs} +11 -9
  317. package/lib/localOdspDriver/localOdspDocumentStorageManager.mjs.map +1 -0
  318. package/lib/odsp-driver-alpha.d.mts +497 -0
  319. package/lib/odsp-driver-beta.d.mts +159 -0
  320. package/lib/odsp-driver-public.d.mts +159 -0
  321. package/lib/odsp-driver-untrimmed.d.mts +566 -0
  322. package/lib/{odspCache.d.ts → odspCache.d.mts} +19 -8
  323. package/lib/odspCache.d.mts.map +1 -0
  324. package/lib/{odspCache.js → odspCache.mjs} +6 -11
  325. package/lib/odspCache.mjs.map +1 -0
  326. package/lib/odspDelayLoadedDeltaStream.d.mts +75 -0
  327. package/lib/odspDelayLoadedDeltaStream.d.mts.map +1 -0
  328. package/lib/odspDelayLoadedDeltaStream.mjs +287 -0
  329. package/lib/odspDelayLoadedDeltaStream.mjs.map +1 -0
  330. package/lib/{odspDeltaStorageService.d.ts → odspDeltaStorageService.d.mts} +9 -7
  331. package/lib/odspDeltaStorageService.d.mts.map +1 -0
  332. package/lib/{odspDeltaStorageService.js → odspDeltaStorageService.mjs} +70 -68
  333. package/lib/odspDeltaStorageService.mjs.map +1 -0
  334. package/lib/{odspDocumentDeltaConnection.d.ts → odspDocumentDeltaConnection.d.mts} +33 -13
  335. package/lib/odspDocumentDeltaConnection.d.mts.map +1 -0
  336. package/lib/{odspDocumentDeltaConnection.js → odspDocumentDeltaConnection.mjs} +214 -103
  337. package/lib/odspDocumentDeltaConnection.mjs.map +1 -0
  338. package/lib/{odspDocumentService.d.ts → odspDocumentService.d.mts} +14 -28
  339. package/lib/odspDocumentService.d.mts.map +1 -0
  340. package/lib/odspDocumentService.mjs +221 -0
  341. package/lib/odspDocumentService.mjs.map +1 -0
  342. package/lib/{odspDocumentServiceFactory.d.ts → odspDocumentServiceFactory.d.mts} +5 -1
  343. package/lib/odspDocumentServiceFactory.d.mts.map +1 -0
  344. package/lib/{odspDocumentServiceFactory.js → odspDocumentServiceFactory.mjs} +8 -6
  345. package/lib/odspDocumentServiceFactory.mjs.map +1 -0
  346. package/lib/{odspDocumentServiceFactoryCore.d.ts → odspDocumentServiceFactoryCore.d.mts} +17 -12
  347. package/lib/odspDocumentServiceFactoryCore.d.mts.map +1 -0
  348. package/lib/odspDocumentServiceFactoryCore.mjs +192 -0
  349. package/lib/odspDocumentServiceFactoryCore.mjs.map +1 -0
  350. package/lib/{odspDocumentServiceFactoryWithCodeSplit.d.ts → odspDocumentServiceFactoryWithCodeSplit.d.mts} +6 -1
  351. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.mts.map +1 -0
  352. package/lib/{odspDocumentServiceFactoryWithCodeSplit.js → odspDocumentServiceFactoryWithCodeSplit.mjs} +8 -3
  353. package/lib/odspDocumentServiceFactoryWithCodeSplit.mjs.map +1 -0
  354. package/lib/{odspDocumentStorageManager.d.ts → odspDocumentStorageManager.d.mts} +17 -11
  355. package/lib/odspDocumentStorageManager.d.mts.map +1 -0
  356. package/lib/odspDocumentStorageManager.mjs +486 -0
  357. package/lib/odspDocumentStorageManager.mjs.map +1 -0
  358. package/lib/{odspDocumentStorageServiceBase.d.ts → odspDocumentStorageServiceBase.d.mts} +8 -10
  359. package/lib/odspDocumentStorageServiceBase.d.mts.map +1 -0
  360. package/lib/{odspDocumentStorageServiceBase.js → odspDocumentStorageServiceBase.mjs} +31 -33
  361. package/lib/odspDocumentStorageServiceBase.mjs.map +1 -0
  362. package/lib/{odspDriverUrlResolver.d.ts → odspDriverUrlResolver.d.mts} +12 -0
  363. package/lib/odspDriverUrlResolver.d.mts.map +1 -0
  364. package/lib/{odspDriverUrlResolver.js → odspDriverUrlResolver.mjs} +50 -40
  365. package/lib/odspDriverUrlResolver.mjs.map +1 -0
  366. package/lib/{odspDriverUrlResolverForShareLink.d.ts → odspDriverUrlResolverForShareLink.d.mts} +6 -4
  367. package/lib/odspDriverUrlResolverForShareLink.d.mts.map +1 -0
  368. package/lib/{odspDriverUrlResolverForShareLink.js → odspDriverUrlResolverForShareLink.mjs} +36 -29
  369. package/lib/odspDriverUrlResolverForShareLink.mjs.map +1 -0
  370. package/lib/{odspError.d.ts → odspError.d.mts} +1 -1
  371. package/lib/odspError.d.mts.map +1 -0
  372. package/lib/{odspError.js → odspError.mjs} +7 -3
  373. package/lib/odspError.mjs.map +1 -0
  374. package/lib/{odspFluidFileLink.d.ts → odspFluidFileLink.d.mts} +11 -2
  375. package/lib/odspFluidFileLink.d.mts.map +1 -0
  376. package/lib/{odspFluidFileLink.js → odspFluidFileLink.mjs} +23 -16
  377. package/lib/odspFluidFileLink.mjs.map +1 -0
  378. package/lib/odspLocationRedirection.d.mts +14 -0
  379. package/lib/odspLocationRedirection.d.mts.map +1 -0
  380. package/lib/odspLocationRedirection.mjs +20 -0
  381. package/lib/odspLocationRedirection.mjs.map +1 -0
  382. package/lib/{odspPublicUtils.d.ts → odspPublicUtils.d.mts} +6 -0
  383. package/lib/odspPublicUtils.d.mts.map +1 -0
  384. package/lib/{odspPublicUtils.js → odspPublicUtils.mjs} +5 -2
  385. package/lib/odspPublicUtils.mjs.map +1 -0
  386. package/lib/{odspSnapshotParser.d.ts → odspSnapshotParser.d.mts} +2 -2
  387. package/lib/odspSnapshotParser.d.mts.map +1 -0
  388. package/lib/{odspSnapshotParser.js → odspSnapshotParser.mjs} +10 -11
  389. package/lib/odspSnapshotParser.mjs.map +1 -0
  390. package/lib/{odspSummaryUploadManager.d.ts → odspSummaryUploadManager.d.mts} +8 -5
  391. package/lib/odspSummaryUploadManager.d.mts.map +1 -0
  392. package/lib/{odspSummaryUploadManager.js → odspSummaryUploadManager.mjs} +41 -32
  393. package/lib/odspSummaryUploadManager.mjs.map +1 -0
  394. package/lib/{odspUrlHelper.d.ts → odspUrlHelper.d.mts} +5 -0
  395. package/lib/odspUrlHelper.d.mts.map +1 -0
  396. package/lib/{odspUrlHelper.js → odspUrlHelper.mjs} +9 -3
  397. package/lib/odspUrlHelper.mjs.map +1 -0
  398. package/lib/{odspUtils.d.ts → odspUtils.d.mts} +36 -7
  399. package/lib/odspUtils.d.mts.map +1 -0
  400. package/lib/{odspUtils.js → odspUtils.mjs} +109 -27
  401. package/lib/odspUtils.mjs.map +1 -0
  402. package/lib/{opsCaching.d.ts → opsCaching.d.mts} +3 -3
  403. package/lib/opsCaching.d.mts.map +1 -0
  404. package/lib/{opsCaching.js → opsCaching.mjs} +23 -7
  405. package/lib/opsCaching.mjs.map +1 -0
  406. package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
  407. package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
  408. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  409. package/lib/packageVersion.mjs.map +1 -0
  410. package/lib/{prefetchLatestSnapshot.d.ts → prefetchLatestSnapshot.d.mts} +13 -8
  411. package/lib/prefetchLatestSnapshot.d.mts.map +1 -0
  412. package/lib/prefetchLatestSnapshot.mjs +96 -0
  413. package/lib/prefetchLatestSnapshot.mjs.map +1 -0
  414. package/lib/{retryErrorsStorageAdapter.d.ts → retryErrorsStorageAdapter.d.mts} +5 -4
  415. package/lib/retryErrorsStorageAdapter.d.mts.map +1 -0
  416. package/lib/{retryErrorsStorageAdapter.js → retryErrorsStorageAdapter.mjs} +13 -6
  417. package/lib/retryErrorsStorageAdapter.mjs.map +1 -0
  418. package/lib/{retryUtils.d.ts → retryUtils.d.mts} +2 -2
  419. package/lib/retryUtils.d.mts.map +1 -0
  420. package/lib/{retryUtils.js → retryUtils.mjs} +27 -11
  421. package/lib/retryUtils.mjs.map +1 -0
  422. package/lib/socketModule.d.mts +7 -0
  423. package/lib/socketModule.d.mts.map +1 -0
  424. package/lib/socketModule.mjs +7 -0
  425. package/lib/socketModule.mjs.map +1 -0
  426. package/lib/{vroom.d.ts → vroom.d.mts} +6 -6
  427. package/lib/vroom.d.mts.map +1 -0
  428. package/lib/{vroom.js → vroom.mjs} +24 -9
  429. package/lib/vroom.mjs.map +1 -0
  430. package/lib/{zipItDataRepresentationUtils.d.ts → zipItDataRepresentationUtils.d.mts} +48 -21
  431. package/lib/zipItDataRepresentationUtils.d.mts.map +1 -0
  432. package/lib/{zipItDataRepresentationUtils.js → zipItDataRepresentationUtils.mjs} +213 -111
  433. package/lib/zipItDataRepresentationUtils.mjs.map +1 -0
  434. package/package.json +89 -69
  435. package/prettier.config.cjs +8 -0
  436. package/src/ReadBufferUtils.ts +51 -44
  437. package/src/WriteBufferUtils.ts +203 -181
  438. package/src/checkUrl.ts +16 -15
  439. package/src/compactSnapshotParser.ts +219 -103
  440. package/src/compactSnapshotWriter.ts +118 -97
  441. package/src/constants.ts +7 -0
  442. package/src/contracts.ts +96 -136
  443. package/src/contractsPublic.ts +31 -16
  444. package/src/createFile.ts +243 -305
  445. package/src/createNewContainerOnExistingFile.ts +93 -0
  446. package/src/createNewModule.ts +7 -0
  447. package/src/createNewUtils.ts +266 -56
  448. package/src/createOdspCreateContainerRequest.ts +22 -18
  449. package/src/createOdspUrl.ts +12 -13
  450. package/src/epochTracker.ts +596 -457
  451. package/src/fetch.ts +4 -4
  452. package/src/fetchSnapshot.ts +583 -508
  453. package/src/getFileLink.ts +194 -155
  454. package/src/getQueryString.ts +11 -9
  455. package/src/getUrlAndHeadersWithAuth.ts +34 -33
  456. package/src/index.ts +42 -18
  457. package/src/localOdspDriver/localOdspDeltaStorageService.ts +49 -0
  458. package/src/localOdspDriver/localOdspDocumentService.ts +40 -38
  459. package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +46 -43
  460. package/src/localOdspDriver/localOdspDocumentStorageManager.ts +55 -50
  461. package/src/odspCache.ts +112 -90
  462. package/src/odspDelayLoadedDeltaStream.ts +459 -0
  463. package/src/odspDeltaStorageService.ts +232 -221
  464. package/src/odspDocumentDeltaConnection.ts +751 -563
  465. package/src/odspDocumentService.ts +324 -523
  466. package/src/odspDocumentServiceFactory.ts +20 -21
  467. package/src/odspDocumentServiceFactoryCore.ts +325 -202
  468. package/src/odspDocumentServiceFactoryWithCodeSplit.ts +20 -20
  469. package/src/odspDocumentStorageManager.ts +730 -534
  470. package/src/odspDocumentStorageServiceBase.ts +279 -254
  471. package/src/odspDriverUrlResolver.ts +230 -188
  472. package/src/odspDriverUrlResolverForShareLink.ts +223 -203
  473. package/src/odspError.ts +27 -19
  474. package/src/odspFluidFileLink.ts +106 -87
  475. package/src/odspLocationRedirection.ts +26 -0
  476. package/src/odspPublicUtils.ts +20 -14
  477. package/src/odspSnapshotParser.ts +53 -46
  478. package/src/odspSummaryUploadManager.ts +243 -218
  479. package/src/odspUrlHelper.ts +81 -71
  480. package/src/odspUtils.ts +401 -259
  481. package/src/opsCaching.ts +214 -193
  482. package/src/packageVersion.ts +1 -1
  483. package/src/prefetchLatestSnapshot.ts +142 -80
  484. package/src/retryErrorsStorageAdapter.ts +92 -77
  485. package/src/retryUtils.ts +80 -57
  486. package/src/socketModule.ts +8 -0
  487. package/src/vroom.ts +92 -83
  488. package/src/zipItDataRepresentationUtils.ts +534 -394
  489. package/tsc-multi.test.json +4 -0
  490. package/tsconfig.json +11 -13
  491. package/.editorconfig +0 -7
  492. package/dist/ReadBufferUtils.js.map +0 -1
  493. package/dist/WriteBufferUtils.js.map +0 -1
  494. package/dist/checkUrl.js.map +0 -1
  495. package/dist/compactSnapshotParser.js +0 -115
  496. package/dist/compactSnapshotParser.js.map +0 -1
  497. package/dist/compactSnapshotWriter.js.map +0 -1
  498. package/dist/constants.js.map +0 -1
  499. package/dist/contracts.js.map +0 -1
  500. package/dist/contractsPublic.js.map +0 -1
  501. package/dist/createFile.js +0 -242
  502. package/dist/createFile.js.map +0 -1
  503. package/dist/createNewUtils.js +0 -67
  504. package/dist/createNewUtils.js.map +0 -1
  505. package/dist/createOdspCreateContainerRequest.js.map +0 -1
  506. package/dist/createOdspUrl.js.map +0 -1
  507. package/dist/epochTracker.js.map +0 -1
  508. package/dist/fetch.js.map +0 -1
  509. package/dist/fetchSnapshot.js.map +0 -1
  510. package/dist/getFileLink.js.map +0 -1
  511. package/dist/getQueryString.js.map +0 -1
  512. package/dist/getSocketIo.d.ts +0 -11
  513. package/dist/getSocketIo.d.ts.map +0 -1
  514. package/dist/getSocketIo.js +0 -20
  515. package/dist/getSocketIo.js.map +0 -1
  516. package/dist/getUrlAndHeadersWithAuth.js.map +0 -1
  517. package/dist/index.js +0 -41
  518. package/dist/index.js.map +0 -1
  519. package/dist/localOdspDriver/localOdspDocumentService.js.map +0 -1
  520. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +0 -1
  521. package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +0 -1
  522. package/dist/odspCache.js.map +0 -1
  523. package/dist/odspDeltaStorageService.js.map +0 -1
  524. package/dist/odspDocumentDeltaConnection.js.map +0 -1
  525. package/dist/odspDocumentService.js +0 -364
  526. package/dist/odspDocumentService.js.map +0 -1
  527. package/dist/odspDocumentServiceFactory.js.map +0 -1
  528. package/dist/odspDocumentServiceFactoryCore.js +0 -118
  529. package/dist/odspDocumentServiceFactoryCore.js.map +0 -1
  530. package/dist/odspDocumentServiceFactoryWithCodeSplit.js +0 -34
  531. package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +0 -1
  532. package/dist/odspDocumentStorageManager.js +0 -356
  533. package/dist/odspDocumentStorageManager.js.map +0 -1
  534. package/dist/odspDocumentStorageServiceBase.js.map +0 -1
  535. package/dist/odspDriverUrlResolver.js.map +0 -1
  536. package/dist/odspDriverUrlResolverForShareLink.js.map +0 -1
  537. package/dist/odspError.js.map +0 -1
  538. package/dist/odspFluidFileLink.js.map +0 -1
  539. package/dist/odspPublicUtils.js.map +0 -1
  540. package/dist/odspSnapshotParser.js.map +0 -1
  541. package/dist/odspSummaryUploadManager.js.map +0 -1
  542. package/dist/odspUrlHelper.js.map +0 -1
  543. package/dist/odspUtils.js.map +0 -1
  544. package/dist/opsCaching.js.map +0 -1
  545. package/dist/packageVersion.js.map +0 -1
  546. package/dist/prefetchLatestSnapshot.js +0 -57
  547. package/dist/prefetchLatestSnapshot.js.map +0 -1
  548. package/dist/retryErrorsStorageAdapter.js.map +0 -1
  549. package/dist/retryUtils.js.map +0 -1
  550. package/dist/vroom.js.map +0 -1
  551. package/dist/zipItDataRepresentationUtils.js.map +0 -1
  552. package/lib/ReadBufferUtils.d.ts.map +0 -1
  553. package/lib/ReadBufferUtils.js.map +0 -1
  554. package/lib/WriteBufferUtils.d.ts.map +0 -1
  555. package/lib/WriteBufferUtils.js.map +0 -1
  556. package/lib/checkUrl.d.ts.map +0 -1
  557. package/lib/checkUrl.js.map +0 -1
  558. package/lib/compactSnapshotParser.d.ts +0 -15
  559. package/lib/compactSnapshotParser.d.ts.map +0 -1
  560. package/lib/compactSnapshotParser.js +0 -111
  561. package/lib/compactSnapshotParser.js.map +0 -1
  562. package/lib/compactSnapshotWriter.d.ts.map +0 -1
  563. package/lib/compactSnapshotWriter.js.map +0 -1
  564. package/lib/constants.d.ts.map +0 -1
  565. package/lib/constants.js.map +0 -1
  566. package/lib/contracts.d.ts.map +0 -1
  567. package/lib/contracts.js.map +0 -1
  568. package/lib/contractsPublic.d.ts.map +0 -1
  569. package/lib/contractsPublic.js.map +0 -1
  570. package/lib/createFile.d.ts +0 -22
  571. package/lib/createFile.d.ts.map +0 -1
  572. package/lib/createFile.js +0 -235
  573. package/lib/createFile.js.map +0 -1
  574. package/lib/createNewUtils.d.ts +0 -11
  575. package/lib/createNewUtils.d.ts.map +0 -1
  576. package/lib/createNewUtils.js +0 -63
  577. package/lib/createNewUtils.js.map +0 -1
  578. package/lib/createOdspCreateContainerRequest.d.ts.map +0 -1
  579. package/lib/createOdspCreateContainerRequest.js.map +0 -1
  580. package/lib/createOdspUrl.js.map +0 -1
  581. package/lib/epochTracker.d.ts.map +0 -1
  582. package/lib/epochTracker.js.map +0 -1
  583. package/lib/fetch.js.map +0 -1
  584. package/lib/fetchSnapshot.d.ts.map +0 -1
  585. package/lib/fetchSnapshot.js.map +0 -1
  586. package/lib/getFileLink.d.ts.map +0 -1
  587. package/lib/getFileLink.js.map +0 -1
  588. package/lib/getQueryString.d.ts.map +0 -1
  589. package/lib/getQueryString.js.map +0 -1
  590. package/lib/getSocketIo.d.ts +0 -11
  591. package/lib/getSocketIo.d.ts.map +0 -1
  592. package/lib/getSocketIo.js +0 -13
  593. package/lib/getSocketIo.js.map +0 -1
  594. package/lib/getUrlAndHeadersWithAuth.js.map +0 -1
  595. package/lib/index.d.ts +0 -21
  596. package/lib/index.d.ts.map +0 -1
  597. package/lib/index.js +0 -29
  598. package/lib/index.js.map +0 -1
  599. package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +0 -1
  600. package/lib/localOdspDriver/localOdspDocumentService.js.map +0 -1
  601. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +0 -1
  602. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +0 -1
  603. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +0 -1
  604. package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +0 -1
  605. package/lib/odspCache.d.ts.map +0 -1
  606. package/lib/odspCache.js.map +0 -1
  607. package/lib/odspDeltaStorageService.d.ts.map +0 -1
  608. package/lib/odspDeltaStorageService.js.map +0 -1
  609. package/lib/odspDocumentDeltaConnection.d.ts.map +0 -1
  610. package/lib/odspDocumentDeltaConnection.js.map +0 -1
  611. package/lib/odspDocumentService.d.ts.map +0 -1
  612. package/lib/odspDocumentService.js +0 -360
  613. package/lib/odspDocumentService.js.map +0 -1
  614. package/lib/odspDocumentServiceFactory.d.ts.map +0 -1
  615. package/lib/odspDocumentServiceFactory.js.map +0 -1
  616. package/lib/odspDocumentServiceFactoryCore.d.ts.map +0 -1
  617. package/lib/odspDocumentServiceFactoryCore.js +0 -114
  618. package/lib/odspDocumentServiceFactoryCore.js.map +0 -1
  619. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +0 -1
  620. package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +0 -1
  621. package/lib/odspDocumentStorageManager.d.ts.map +0 -1
  622. package/lib/odspDocumentStorageManager.js +0 -352
  623. package/lib/odspDocumentStorageManager.js.map +0 -1
  624. package/lib/odspDocumentStorageServiceBase.d.ts.map +0 -1
  625. package/lib/odspDocumentStorageServiceBase.js.map +0 -1
  626. package/lib/odspDriverUrlResolver.d.ts.map +0 -1
  627. package/lib/odspDriverUrlResolver.js.map +0 -1
  628. package/lib/odspDriverUrlResolverForShareLink.d.ts.map +0 -1
  629. package/lib/odspDriverUrlResolverForShareLink.js.map +0 -1
  630. package/lib/odspError.d.ts.map +0 -1
  631. package/lib/odspError.js.map +0 -1
  632. package/lib/odspFluidFileLink.d.ts.map +0 -1
  633. package/lib/odspFluidFileLink.js.map +0 -1
  634. package/lib/odspPublicUtils.d.ts.map +0 -1
  635. package/lib/odspPublicUtils.js.map +0 -1
  636. package/lib/odspSnapshotParser.d.ts.map +0 -1
  637. package/lib/odspSnapshotParser.js.map +0 -1
  638. package/lib/odspSummaryUploadManager.d.ts.map +0 -1
  639. package/lib/odspSummaryUploadManager.js.map +0 -1
  640. package/lib/odspUrlHelper.d.ts.map +0 -1
  641. package/lib/odspUrlHelper.js.map +0 -1
  642. package/lib/odspUtils.d.ts.map +0 -1
  643. package/lib/odspUtils.js.map +0 -1
  644. package/lib/opsCaching.d.ts.map +0 -1
  645. package/lib/opsCaching.js.map +0 -1
  646. package/lib/packageVersion.js.map +0 -1
  647. package/lib/prefetchLatestSnapshot.d.ts.map +0 -1
  648. package/lib/prefetchLatestSnapshot.js +0 -53
  649. package/lib/prefetchLatestSnapshot.js.map +0 -1
  650. package/lib/retryErrorsStorageAdapter.d.ts.map +0 -1
  651. package/lib/retryErrorsStorageAdapter.js.map +0 -1
  652. package/lib/retryUtils.d.ts.map +0 -1
  653. package/lib/retryUtils.js.map +0 -1
  654. package/lib/vroom.d.ts.map +0 -1
  655. package/lib/vroom.js.map +0 -1
  656. package/lib/zipItDataRepresentationUtils.d.ts.map +0 -1
  657. package/lib/zipItDataRepresentationUtils.js.map +0 -1
  658. package/src/getSocketIo.ts +0 -14
  659. package/tsconfig.esnext.json +0 -7
  660. /package/lib/{ReadBufferUtils.d.ts → ReadBufferUtils.d.mts} +0 -0
  661. /package/lib/{getUrlAndHeadersWithAuth.d.ts → getUrlAndHeadersWithAuth.d.mts} +0 -0
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createNewFluidFileFromSummary = exports.createNewEmptyFluidFile = exports.createNewFluidFile = void 0;
8
+ const core_utils_1 = require("@fluidframework/core-utils");
9
+ const driver_utils_1 = require("@fluidframework/driver-utils");
10
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
11
+ const odsp_driver_definitions_1 = require("@fluidframework/odsp-driver-definitions");
12
+ const driver_definitions_1 = require("@fluidframework/driver-definitions");
13
+ const getUrlAndHeadersWithAuth_1 = require("./getUrlAndHeadersWithAuth.cjs");
14
+ const odspUtils_1 = require("./odspUtils.cjs");
15
+ const createOdspUrl_1 = require("./createOdspUrl.cjs");
16
+ const odspUrlHelper_1 = require("./odspUrlHelper.cjs");
17
+ const odspDriverUrlResolver_1 = require("./odspDriverUrlResolver.cjs");
18
+ const createNewUtils_1 = require("./createNewUtils.cjs");
19
+ const retryUtils_1 = require("./retryUtils.cjs");
20
+ const packageVersion_1 = require("./packageVersion.cjs");
21
+ const contractsPublic_1 = require("./contractsPublic.cjs");
22
+ const isInvalidFileName = (fileName) => {
23
+ const invalidCharsRegex = /["*/:<>?\\|]+/g;
24
+ return !!fileName.match(invalidCharsRegex);
25
+ };
26
+ /**
27
+ * Creates a new Fluid file.
28
+ * Returns resolved url
29
+ */
30
+ async function createNewFluidFile(getStorageToken, newFileInfo, logger, createNewSummary, epochTracker, fileEntry, createNewCaching, forceAccessTokenViaAuthorizationHeader, isClpCompliantApp, enableSingleRequestForShareLinkWithCreate, enableShareLinkWithCreate) {
31
+ // Check for valid filename before the request to create file is actually made.
32
+ if (isInvalidFileName(newFileInfo.filename)) {
33
+ throw new driver_utils_1.NonRetryableError(
34
+ // pre-0.58 error message: Invalid filename
35
+ "Invalid filename for createNew", odsp_driver_definitions_1.OdspErrorType.invalidFileNameError, { driverVersion: packageVersion_1.pkgVersion });
36
+ }
37
+ let itemId;
38
+ let summaryHandle = "";
39
+ let shareLinkInfo;
40
+ if (createNewSummary === undefined) {
41
+ itemId = await createNewEmptyFluidFile(getStorageToken, newFileInfo, logger, epochTracker, forceAccessTokenViaAuthorizationHeader);
42
+ }
43
+ else {
44
+ const content = await createNewFluidFileFromSummary(getStorageToken, newFileInfo, logger, createNewSummary, epochTracker, forceAccessTokenViaAuthorizationHeader);
45
+ itemId = content.itemId;
46
+ summaryHandle = content.id;
47
+ shareLinkInfo = extractShareLinkData(newFileInfo.createLinkType, content, enableSingleRequestForShareLinkWithCreate, enableShareLinkWithCreate);
48
+ }
49
+ const odspUrl = (0, createOdspUrl_1.createOdspUrl)({ ...newFileInfo, itemId, dataStorePath: "/" });
50
+ const resolver = new odspDriverUrlResolver_1.OdspDriverUrlResolver();
51
+ const odspResolvedUrl = await resolver.resolve({
52
+ url: odspUrl,
53
+ headers: { [contractsPublic_1.ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },
54
+ });
55
+ fileEntry.docId = odspResolvedUrl.hashedDocumentId;
56
+ fileEntry.resolvedUrl = odspResolvedUrl;
57
+ odspResolvedUrl.shareLinkInfo = shareLinkInfo;
58
+ if (createNewSummary !== undefined && createNewCaching) {
59
+ (0, core_utils_1.assert)(summaryHandle !== undefined, 0x203 /* "Summary handle is undefined" */);
60
+ // converting summary and getting sequence number
61
+ const snapshot = (0, createNewUtils_1.convertCreateNewSummaryTreeToTreeAndBlobs)(createNewSummary, summaryHandle);
62
+ // caching the converted summary
63
+ await epochTracker.put((0, odspUtils_1.createCacheSnapshotKey)(odspResolvedUrl), snapshot);
64
+ }
65
+ return odspResolvedUrl;
66
+ }
67
+ exports.createNewFluidFile = createNewFluidFile;
68
+ /**
69
+ * If user requested creation of a sharing link along with the creation of the file by providing either
70
+ * createLinkType (now deprecated) or createLinkScope in the request parameters, extract and save
71
+ * sharing link information from the response if it is available.
72
+ * In case there was an error in creation of the sharing link, error is provided back in the response,
73
+ * and does not impact the creation of file in ODSP.
74
+ * @param requestedSharingLinkKind - Kind of sharing link requested to be created along with the creation of file.
75
+ * @param response - Response object received from the /snapshot api call
76
+ * @returns Sharing link information received in the response from a successful creation of a file.
77
+ */
78
+ function extractShareLinkData(requestedSharingLinkKind, response, enableSingleRequestForShareLinkWithCreate, enableShareLinkWithCreate) {
79
+ if (!requestedSharingLinkKind) {
80
+ return;
81
+ }
82
+ let shareLinkInfo;
83
+ if (enableSingleRequestForShareLinkWithCreate) {
84
+ const { sharing } = response;
85
+ if (!sharing) {
86
+ return;
87
+ }
88
+ shareLinkInfo = {
89
+ createLink: {
90
+ type: requestedSharingLinkKind,
91
+ link: sharing.sharingLink
92
+ ? {
93
+ scope: sharing.sharingLink.scope,
94
+ role: sharing.sharingLink.type,
95
+ webUrl: sharing.sharingLink.webUrl,
96
+ ...sharing.sharingLink,
97
+ }
98
+ : undefined,
99
+ error: sharing.error,
100
+ shareId: sharing.shareId,
101
+ },
102
+ };
103
+ }
104
+ else if (enableShareLinkWithCreate) {
105
+ const { sharing, sharingLink, sharingLinkErrorReason } = response;
106
+ if (!sharingLink && !sharingLinkErrorReason) {
107
+ return;
108
+ }
109
+ shareLinkInfo = {
110
+ createLink: {
111
+ type: requestedSharingLinkKind,
112
+ link: sharingLink,
113
+ error: sharingLinkErrorReason,
114
+ shareId: sharing?.shareId,
115
+ },
116
+ };
117
+ }
118
+ return shareLinkInfo;
119
+ }
120
+ async function createNewEmptyFluidFile(getStorageToken, newFileInfo, logger, epochTracker, forceAccessTokenViaAuthorizationHeader) {
121
+ const filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : "";
122
+ // add .tmp extension to empty file (host is expected to rename)
123
+ const encodedFilename = encodeURIComponent(`${newFileInfo.filename}.tmp`);
124
+ const initialUrl = `${(0, odspUrlHelper_1.getApiRoot)((0, odspUtils_1.getOrigin)(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:/${filePath}/${encodedFilename}:/content?@name.conflictBehavior=rename&select=id,name,parentReference`;
125
+ return (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
126
+ const storageToken = await getStorageToken(options, "CreateNewFile");
127
+ return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "createNewEmptyFile" }, async (event) => {
128
+ const { url, headers } = (0, getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth)(initialUrl, storageToken, forceAccessTokenViaAuthorizationHeader);
129
+ headers["Content-Type"] = "application/json";
130
+ const fetchResponse = await (0, retryUtils_1.runWithRetry)(async () => epochTracker.fetchAndParseAsJSON(url, {
131
+ body: undefined,
132
+ headers,
133
+ method: "PUT",
134
+ }, "createFile"), "createFile", logger);
135
+ const content = fetchResponse.content;
136
+ if (!content?.id) {
137
+ throw new driver_utils_1.NonRetryableError(
138
+ // pre-0.58 error message: ODSP CreateFile call returned no item ID
139
+ "ODSP CreateFile call returned no item ID (for empty file)", driver_definitions_1.DriverErrorType.incorrectServerResponse, { driverVersion: packageVersion_1.pkgVersion });
140
+ }
141
+ event.end({
142
+ headers: Object.keys(headers).length !== 0 ? true : undefined,
143
+ ...fetchResponse.propsToLog,
144
+ });
145
+ return content.id;
146
+ }, { end: true, cancel: "error" });
147
+ });
148
+ }
149
+ exports.createNewEmptyFluidFile = createNewEmptyFluidFile;
150
+ async function createNewFluidFileFromSummary(getStorageToken, newFileInfo, logger, createNewSummary, epochTracker, forceAccessTokenViaAuthorizationHeader) {
151
+ const filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : "";
152
+ const encodedFilename = encodeURIComponent(newFileInfo.filename);
153
+ const baseUrl = `${(0, odspUrlHelper_1.getApiRoot)((0, odspUtils_1.getOrigin)(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:` +
154
+ `${filePath}/${encodedFilename}`;
155
+ const containerSnapshot = (0, createNewUtils_1.convertSummaryIntoContainerSnapshot)(createNewSummary);
156
+ // Build share link parameter based on the createLinkType provided so that the
157
+ // snapshot api can create and return the share link along with creation of file in the response.
158
+ const createShareLinkParam = (0, odspUtils_1.buildOdspShareLinkReqParams)(newFileInfo.createLinkType);
159
+ const initialUrl = `${baseUrl}:/opStream/snapshots/snapshot${createShareLinkParam ? `?${createShareLinkParam}` : ""}`;
160
+ return (0, createNewUtils_1.createNewFluidContainerCore)({
161
+ containerSnapshot,
162
+ getStorageToken,
163
+ logger,
164
+ initialUrl,
165
+ forceAccessTokenViaAuthorizationHeader,
166
+ epochTracker,
167
+ telemetryName: "CreateNewFile",
168
+ fetchType: "createFile",
169
+ validateResponseCallback: (content) => {
170
+ if (!content?.itemId) {
171
+ throw new driver_utils_1.NonRetryableError("ODSP CreateFile call returned no item ID", driver_definitions_1.DriverErrorType.incorrectServerResponse, { driverVersion: packageVersion_1.pkgVersion });
172
+ }
173
+ },
174
+ });
175
+ }
176
+ exports.createNewFluidFileFromSummary = createNewFluidFileFromSummary;
177
+ //# sourceMappingURL=createFile.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFile.cjs","sourceRoot":"","sources":["../src/createFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,+DAAiE;AAEjE,qEAAwF;AACxF,qFAQiD;AACjD,2EAAqE;AAErE,6EAAsE;AACtE,+CAMqB;AAErB,uDAAgD;AAChD,uDAA6C;AAE7C,uEAAgE;AAChE,yDAI0B;AAC1B,iDAA4C;AAC5C,yDAA+D;AAC/D,2DAA0D;AAE1D,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAW,EAAE;IACvD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;IAC3C,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CACvC,eAAgD,EAChD,WAAyB,EACzB,MAA2B,EAC3B,gBAA0C,EAC1C,YAA0B,EAC1B,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AAM,OAAO,GACZ,GAAG,IAAA,0BAAU,EAAC,IAAA,qBAAS,EAAC,WAAW,CAAC,OAAO,CAAC,CAAC,WAAW,WAAW,CAAC,OAAO,cAAc;QACzF,GAAG,QAAQ,IAAI,eAAe,EAAE,CAAC;IAElC,MAAM,iBAAiB,GAAG,IAAA,oDAAmC,EAAC,gBAAgB,CAAC,CAAC;IAEhF,8EAA8E;IAC9E,iGAAiG;IACjG,MAAM,oBAAoB,GAAG,IAAA,uCAA2B,EAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IACrF,MAAM,UAAU,GAAG,GAAG,OAAO,gCAC5B,oBAAoB,CAAC,CAAC,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC,CAAC,EACrD,EAAE,CAAC;IAEH,OAAO,IAAA,4CAA2B,EAAsB;QACvD,iBAAiB;QACjB,eAAe;QACf,MAAM;QACN,UAAU;QACV,sCAAsC;QACtC,YAAY;QACZ,aAAa,EAAE,eAAe;QAC9B,SAAS,EAAE,YAAY;QACvB,wBAAwB,EAAE,CAAC,OAAO,EAAE,EAAE;YACrC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE;gBACrB,MAAM,IAAI,gCAAiB,CAC1B,0CAA0C,EAC1C,oCAAe,CAAC,uBAAuB,EACvC,EAAE,aAAa,EAAb,2BAAa,EAAE,CACjB,CAAC;aACF;QACF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AA1CD,sEA0CC","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 { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tInstrumentedStorageTokenFetcher,\n\tIOdspResolvedUrl,\n\tOdspErrorType,\n\tShareLinkInfoType,\n\tISharingLinkKind,\n\tShareLinkTypes,\n\tIFileEntry,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { ICreateFileResponse } from \"./contracts\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n\tbuildOdspShareLinkReqParams,\n\tcreateCacheSnapshotKey,\n\tgetWithRetryForTokenRefresh,\n\tINewFileInfo,\n\tgetOrigin,\n} from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nimport {\n\tconvertCreateNewSummaryTreeToTreeAndBlobs,\n\tconvertSummaryIntoContainerSnapshot,\n\tcreateNewFluidContainerCore,\n} from \"./createNewUtils\";\nimport { runWithRetry } from \"./retryUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\n\nconst isInvalidFileName = (fileName: string): boolean => {\n\tconst invalidCharsRegex = /[\"*/:<>?\\\\|]+/g;\n\treturn !!fileName.match(invalidCharsRegex);\n};\n\n/**\n * Creates a new Fluid file.\n * Returns resolved url\n */\nexport async function createNewFluidFile(\n\tgetStorageToken: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree | undefined,\n\tepochTracker: EpochTracker,\n\tfileEntry: IFileEntry,\n\tcreateNewCaching: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tisClpCompliantApp?: boolean,\n\tenableSingleRequestForShareLinkWithCreate?: boolean,\n\tenableShareLinkWithCreate?: boolean,\n): Promise<IOdspResolvedUrl> {\n\t// Check for valid filename before the request to create file is actually made.\n\tif (isInvalidFileName(newFileInfo.filename)) {\n\t\tthrow new NonRetryableError(\n\t\t\t// pre-0.58 error message: Invalid filename\n\t\t\t\"Invalid filename for createNew\",\n\t\t\tOdspErrorType.invalidFileNameError,\n\t\t\t{ driverVersion },\n\t\t);\n\t}\n\n\tlet itemId: string;\n\tlet summaryHandle: string = \"\";\n\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\tif (createNewSummary === undefined) {\n\t\titemId = await createNewEmptyFluidFile(\n\t\t\tgetStorageToken,\n\t\t\tnewFileInfo,\n\t\t\tlogger,\n\t\t\tepochTracker,\n\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t);\n\t} else {\n\t\tconst content = await createNewFluidFileFromSummary(\n\t\t\tgetStorageToken,\n\t\t\tnewFileInfo,\n\t\t\tlogger,\n\t\t\tcreateNewSummary,\n\t\t\tepochTracker,\n\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t);\n\t\titemId = content.itemId;\n\t\tsummaryHandle = content.id;\n\n\t\tshareLinkInfo = extractShareLinkData(\n\t\t\tnewFileInfo.createLinkType,\n\t\t\tcontent,\n\t\t\tenableSingleRequestForShareLinkWithCreate,\n\t\t\tenableShareLinkWithCreate,\n\t\t);\n\t}\n\n\tconst odspUrl = createOdspUrl({ ...newFileInfo, itemId, dataStorePath: \"/\" });\n\tconst resolver = new OdspDriverUrlResolver();\n\tconst odspResolvedUrl = await resolver.resolve({\n\t\turl: odspUrl,\n\t\theaders: { [ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },\n\t});\n\tfileEntry.docId = odspResolvedUrl.hashedDocumentId;\n\tfileEntry.resolvedUrl = odspResolvedUrl;\n\n\todspResolvedUrl.shareLinkInfo = shareLinkInfo;\n\n\tif (createNewSummary !== undefined && createNewCaching) {\n\t\tassert(summaryHandle !== undefined, 0x203 /* \"Summary handle is undefined\" */);\n\t\t// converting summary and getting sequence number\n\t\tconst snapshot: ISnapshotContents = convertCreateNewSummaryTreeToTreeAndBlobs(\n\t\t\tcreateNewSummary,\n\t\t\tsummaryHandle,\n\t\t);\n\t\t// caching the converted summary\n\t\tawait epochTracker.put(createCacheSnapshotKey(odspResolvedUrl), snapshot);\n\t}\n\treturn odspResolvedUrl;\n}\n\n/**\n * If user requested creation of a sharing link along with the creation of the file by providing either\n * createLinkType (now deprecated) or createLinkScope in the request parameters, extract and save\n * sharing link information from the response if it is available.\n * In case there was an error in creation of the sharing link, error is provided back in the response,\n * and does not impact the creation of file in ODSP.\n * @param requestedSharingLinkKind - Kind of sharing link requested to be created along with the creation of file.\n * @param response - Response object received from the /snapshot api call\n * @returns Sharing link information received in the response from a successful creation of a file.\n */\nfunction extractShareLinkData(\n\trequestedSharingLinkKind: ShareLinkTypes | ISharingLinkKind | undefined,\n\tresponse: ICreateFileResponse,\n\tenableSingleRequestForShareLinkWithCreate?: boolean,\n\tenableShareLinkWithCreate?: boolean,\n): ShareLinkInfoType | undefined {\n\tif (!requestedSharingLinkKind) {\n\t\treturn;\n\t}\n\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\tif (enableSingleRequestForShareLinkWithCreate) {\n\t\tconst { sharing } = response;\n\t\tif (!sharing) {\n\t\t\treturn;\n\t\t}\n\t\tshareLinkInfo = {\n\t\t\tcreateLink: {\n\t\t\t\ttype: requestedSharingLinkKind,\n\t\t\t\tlink: sharing.sharingLink\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tscope: sharing.sharingLink.scope,\n\t\t\t\t\t\t\trole: sharing.sharingLink.type,\n\t\t\t\t\t\t\twebUrl: sharing.sharingLink.webUrl,\n\t\t\t\t\t\t\t...sharing.sharingLink,\n\t\t\t\t\t }\n\t\t\t\t\t: undefined,\n\t\t\t\terror: sharing.error,\n\t\t\t\tshareId: sharing.shareId,\n\t\t\t},\n\t\t};\n\t} else if (enableShareLinkWithCreate) {\n\t\tconst { sharing, sharingLink, sharingLinkErrorReason } = response;\n\t\tif (!sharingLink && !sharingLinkErrorReason) {\n\t\t\treturn;\n\t\t}\n\t\tshareLinkInfo = {\n\t\t\tcreateLink: {\n\t\t\t\ttype: requestedSharingLinkKind,\n\t\t\t\tlink: sharingLink,\n\t\t\t\terror: sharingLinkErrorReason,\n\t\t\t\tshareId: sharing?.shareId,\n\t\t\t},\n\t\t};\n\t}\n\treturn shareLinkInfo;\n}\n\nexport async function createNewEmptyFluidFile(\n\tgetStorageToken: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tepochTracker: EpochTracker,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<string> {\n\tconst filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : \"\";\n\t// add .tmp extension to empty file (host is expected to rename)\n\tconst encodedFilename = encodeURIComponent(`${newFileInfo.filename}.tmp`);\n\tconst initialUrl = `${getApiRoot(getOrigin(newFileInfo.siteUrl))}/drives/${\n\t\tnewFileInfo.driveId\n\t}/items/root:/${filePath}/${encodedFilename}:/content?@name.conflictBehavior=rename&select=id,name,parentReference`;\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\tconst storageToken = await getStorageToken(options, \"CreateNewFile\");\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"createNewEmptyFile\" },\n\t\t\tasync (event) => {\n\t\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\t\tinitialUrl,\n\t\t\t\t\tstorageToken,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\theaders[\"Content-Type\"] = \"application/json\";\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<ICreateFileResponse>(\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: undefined,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod: \"PUT\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"createFile\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\"createFile\",\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tconst content = fetchResponse.content;\n\t\t\t\tif (!content?.id) {\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t// pre-0.58 error message: ODSP CreateFile call returned no item ID\n\t\t\t\t\t\t\"ODSP CreateFile call returned no item ID (for empty file)\",\n\t\t\t\t\t\tDriverErrorType.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tevent.end({\n\t\t\t\t\theaders: Object.keys(headers).length !== 0 ? true : undefined,\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\t\t\t\treturn content.id;\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t});\n}\n\nexport async function createNewFluidFileFromSummary(\n\tgetStorageToken: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree,\n\tepochTracker: EpochTracker,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<ICreateFileResponse> {\n\tconst filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : \"\";\n\tconst encodedFilename = encodeURIComponent(newFileInfo.filename);\n\tconst baseUrl =\n\t\t`${getApiRoot(getOrigin(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:` +\n\t\t`${filePath}/${encodedFilename}`;\n\n\tconst containerSnapshot = convertSummaryIntoContainerSnapshot(createNewSummary);\n\n\t// Build share link parameter based on the createLinkType provided so that the\n\t// snapshot api can create and return the share link along with creation of file in the response.\n\tconst createShareLinkParam = buildOdspShareLinkReqParams(newFileInfo.createLinkType);\n\tconst initialUrl = `${baseUrl}:/opStream/snapshots/snapshot${\n\t\tcreateShareLinkParam ? `?${createShareLinkParam}` : \"\"\n\t}`;\n\n\treturn createNewFluidContainerCore<ICreateFileResponse>({\n\t\tcontainerSnapshot,\n\t\tgetStorageToken,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t\tepochTracker,\n\t\ttelemetryName: \"CreateNewFile\",\n\t\tfetchType: \"createFile\",\n\t\tvalidateResponseCallback: (content) => {\n\t\t\tif (!content?.itemId) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"ODSP CreateFile call returned no item ID\",\n\t\t\t\t\tDriverErrorType.incorrectServerResponse,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t});\n}\n"]}
@@ -3,20 +3,16 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { ISummaryTree } from "@fluidframework/protocol-definitions";
6
- import { ITelemetryLogger } from "@fluidframework/common-definitions";
7
- import { IFileEntry, InstrumentedStorageTokenFetcher, IOdspResolvedUrl } from "@fluidframework/odsp-driver-definitions";
8
- import { IOdspSummaryTree, ICreateFileResponse } from "./contracts";
6
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
7
+ import { InstrumentedStorageTokenFetcher, IOdspResolvedUrl, IFileEntry } from "@fluidframework/odsp-driver-definitions";
8
+ import { ICreateFileResponse } from "./contracts";
9
9
  import { INewFileInfo } from "./odspUtils";
10
10
  import { EpochTracker } from "./epochTracker";
11
11
  /**
12
12
  * Creates a new Fluid file.
13
13
  * Returns resolved url
14
14
  */
15
- export declare function createNewFluidFile(getStorageToken: InstrumentedStorageTokenFetcher, newFileInfo: INewFileInfo, logger: ITelemetryLogger, createNewSummary: ISummaryTree | undefined, epochTracker: EpochTracker, fileEntry: IFileEntry, createNewCaching: boolean, forceAccessTokenViaAuthorizationHeader: boolean, isClpCompliantApp?: boolean): Promise<IOdspResolvedUrl>;
16
- export declare function createNewEmptyFluidFile(getStorageToken: InstrumentedStorageTokenFetcher, newFileInfo: INewFileInfo, logger: ITelemetryLogger, epochTracker: EpochTracker, forceAccessTokenViaAuthorizationHeader: boolean): Promise<string>;
17
- export declare function createNewFluidFileFromSummary(getStorageToken: InstrumentedStorageTokenFetcher, newFileInfo: INewFileInfo, logger: ITelemetryLogger, createNewSummary: ISummaryTree, epochTracker: EpochTracker, forceAccessTokenViaAuthorizationHeader: boolean): Promise<ICreateFileResponse>;
18
- /**
19
- * Converts a summary tree to ODSP tree
20
- */
21
- export declare function convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree;
15
+ export declare function createNewFluidFile(getStorageToken: InstrumentedStorageTokenFetcher, newFileInfo: INewFileInfo, logger: ITelemetryLoggerExt, createNewSummary: ISummaryTree | undefined, epochTracker: EpochTracker, fileEntry: IFileEntry, createNewCaching: boolean, forceAccessTokenViaAuthorizationHeader: boolean, isClpCompliantApp?: boolean, enableSingleRequestForShareLinkWithCreate?: boolean, enableShareLinkWithCreate?: boolean): Promise<IOdspResolvedUrl>;
16
+ export declare function createNewEmptyFluidFile(getStorageToken: InstrumentedStorageTokenFetcher, newFileInfo: INewFileInfo, logger: ITelemetryLoggerExt, epochTracker: EpochTracker, forceAccessTokenViaAuthorizationHeader: boolean): Promise<string>;
17
+ export declare function createNewFluidFileFromSummary(getStorageToken: InstrumentedStorageTokenFetcher, newFileInfo: INewFileInfo, logger: ITelemetryLoggerExt, createNewSummary: ISummaryTree, epochTracker: EpochTracker, forceAccessTokenViaAuthorizationHeader: boolean): Promise<ICreateFileResponse>;
22
18
  //# sourceMappingURL=createFile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createFile.d.ts","sourceRoot":"","sources":["../src/createFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAe,YAAY,EAAgB,MAAM,sCAAsC,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EACH,UAAU,EACV,+BAA+B,EAC/B,gBAAgB,EAEnB,MAAM,yCAAyC,CAAC;AAEjD,O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,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAIN,YAAY,EAEZ,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAgB9C;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,eAAe,EAAE,+BAA+B,EAChD,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,mBAAmB,EAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,UAAU,EACrB,gBAAgB,EAAE,OAAO,EACzB,sCAAsC,EAAE,OAAO,EAC/C,iBAAiB,CAAC,EAAE,OAAO,EAC3B,yCAAyC,CAAC,EAAE,OAAO,EACnD,yBAAyB,CAAC,EAAE,OAAO,GACjC,OAAO,CAAC,gBAAgB,CAAC,CAgE3B;AA2DD,wBAAsB,uBAAuB,CAC5C,eAAe,EAAE,+BAA+B,EAChD,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,mBAAmB,EAC3B,YAAY,EAAE,YAAY,EAC1B,sCAAsC,EAAE,OAAO,GAC7C,OAAO,CAAC,MAAM,CAAC,CAuDjB;AAED,wBAAsB,6BAA6B,CAClD,eAAe,EAAE,+BAA+B,EAChD,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,mBAAmB,EAC3B,gBAAgB,EAAE,YAAY,EAC9B,YAAY,EAAE,YAAY,EAC1B,sCAAsC,EAAE,OAAO,GAC7C,OAAO,CAAC,mBAAmB,CAAC,CAmC9B"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createNewContainerOnExistingFile = void 0;
8
+ const driver_utils_1 = require("@fluidframework/driver-utils");
9
+ const odspUtils_1 = require("./odspUtils.cjs");
10
+ const createOdspUrl_1 = require("./createOdspUrl.cjs");
11
+ const odspUrlHelper_1 = require("./odspUrlHelper.cjs");
12
+ const odspDriverUrlResolver_1 = require("./odspDriverUrlResolver.cjs");
13
+ const createNewUtils_1 = require("./createNewUtils.cjs");
14
+ const contractsPublic_1 = require("./contractsPublic.cjs");
15
+ /**
16
+ * Creates a new Fluid container on an existing file.
17
+ *
18
+ * @remarks This requires service's capability to manage Fluid container inside an existing file.
19
+ *
20
+ * @example
21
+ *
22
+ * This enables a scenario where Fluid data is not stored as a standalone file but in a way that is managed
23
+ * by an existing file. For example, SharePoint Pages is able to store Fluid container in an
24
+ * "alternative file partition" where the main File stub is an ASPX page.
25
+ */
26
+ async function createNewContainerOnExistingFile(getStorageToken, fileInfo, logger, createNewSummary, epochTracker, fileEntry, createNewCaching, forceAccessTokenViaAuthorizationHeader, isClpCompliantApp) {
27
+ if (createNewSummary === undefined) {
28
+ throw new driver_utils_1.UsageError("createNewSummary must exist to create a new container");
29
+ }
30
+ const baseUrl = `${(0, odspUrlHelper_1.getApiRoot)((0, odspUtils_1.getOrigin)(fileInfo.siteUrl))}/drives/${fileInfo.driveId}/items/${fileInfo.itemId}`;
31
+ const containerSnapshot = (0, createNewUtils_1.convertSummaryIntoContainerSnapshot)(createNewSummary);
32
+ const initialUrl = `${baseUrl}/opStream/snapshots/snapshot`;
33
+ const { id: summaryHandle } = await (0, createNewUtils_1.createNewFluidContainerCore)({
34
+ containerSnapshot,
35
+ getStorageToken,
36
+ logger,
37
+ initialUrl,
38
+ forceAccessTokenViaAuthorizationHeader,
39
+ epochTracker,
40
+ telemetryName: "CreateNewContainerOnExistingFile",
41
+ fetchType: "uploadSummary",
42
+ });
43
+ const odspUrl = (0, createOdspUrl_1.createOdspUrl)({ ...fileInfo, dataStorePath: "/" });
44
+ const resolver = new odspDriverUrlResolver_1.OdspDriverUrlResolver();
45
+ const odspResolvedUrl = await resolver.resolve({
46
+ url: odspUrl,
47
+ headers: { [contractsPublic_1.ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },
48
+ });
49
+ fileEntry.docId = odspResolvedUrl.hashedDocumentId;
50
+ fileEntry.resolvedUrl = odspResolvedUrl;
51
+ if (createNewCaching) {
52
+ // converting summary and getting sequence number
53
+ const snapshot = (0, createNewUtils_1.convertCreateNewSummaryTreeToTreeAndBlobs)(createNewSummary, summaryHandle);
54
+ // caching the converted summary
55
+ await epochTracker.put((0, odspUtils_1.createCacheSnapshotKey)(odspResolvedUrl), snapshot);
56
+ }
57
+ return odspResolvedUrl;
58
+ }
59
+ exports.createNewContainerOnExistingFile = createNewContainerOnExistingFile;
60
+ //# sourceMappingURL=createNewContainerOnExistingFile.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createNewContainerOnExistingFile.cjs","sourceRoot":"","sources":["../src/createNewContainerOnExistingFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,+DAA0D;AAO1D,+CAAmF;AAEnF,uDAAgD;AAChD,uDAA6C;AAE7C,uEAAgE;AAChE,yDAI0B;AAC1B,2DAA0D;AAE1D;;;;;;;;;;GAUG;AACI,KAAK,UAAU,gCAAgC,CACrD,eAAgD,EAChD,QAA2B,EAC3B,MAA2B,EAC3B,gBAA0C,EAC1C,YAA0B,EAC1B,SAAqB,EACrB,gBAAyB,EACzB,sCAA+C,EAC/C,iBAA2B;IAE3B,IAAI,gBAAgB,KAAK,SAAS,EAAE;QACnC,MAAM,IAAI,yBAAU,CAAC,uDAAuD,CAAC,CAAC;KAC9E;IAED,MAAM,OAAO,GAAG,GAAG,IAAA,0BAAU,EAAC,IAAA,qBAAS,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,WAAW,QAAQ,CAAC,OAAO,UACpF,QAAQ,CAAC,MACV,EAAE,CAAC;IAEH,MAAM,iBAAiB,GAAG,IAAA,oDAAmC,EAAC,gBAAgB,CAAC,CAAC;IAEhF,MAAM,UAAU,GAAG,GAAG,OAAO,8BAA8B,CAAC;IAE5D,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,GAAG,MAAM,IAAA,4CAA2B,EAAwB;QACtF,iBAAiB;QACjB,eAAe;QACf,MAAM;QACN,UAAU;QACV,sCAAsC;QACtC,YAAY;QACZ,aAAa,EAAE,kCAAkC;QACjD,SAAS,EAAE,eAAe;KAC1B,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAA,6BAAa,EAAC,EAAE,GAAG,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,IAAI,6CAAqB,EAAE,CAAC;IAC7C,MAAM,eAAe,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC;QAC9C,GAAG,EAAE,OAAO;QACZ,OAAO,EAAE,EAAE,CAAC,uCAAqB,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,EAAE;KACzE,CAAC,CAAC;IACH,SAAS,CAAC,KAAK,GAAG,eAAe,CAAC,gBAAgB,CAAC;IACnD,SAAS,CAAC,WAAW,GAAG,eAAe,CAAC;IAExC,IAAI,gBAAgB,EAAE;QACrB,iDAAiD;QACjD,MAAM,QAAQ,GAAsB,IAAA,0DAAyC,EAC5E,gBAAgB,EAChB,aAAa,CACb,CAAC;QACF,gCAAgC;QAChC,MAAM,YAAY,CAAC,GAAG,CAAC,IAAA,kCAAsB,EAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,CAAC;KAC1E;IAED,OAAO,eAAe,CAAC;AACxB,CAAC;AAtDD,4EAsDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport {\n\tIFileEntry,\n\tInstrumentedStorageTokenFetcher,\n\tIOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { IWriteSummaryResponse } from \"./contracts\";\nimport { createCacheSnapshotKey, getOrigin, IExistingFileInfo } from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nimport {\n\tconvertCreateNewSummaryTreeToTreeAndBlobs,\n\tconvertSummaryIntoContainerSnapshot,\n\tcreateNewFluidContainerCore,\n} from \"./createNewUtils\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\n\n/**\n * Creates a new Fluid container on an existing file.\n *\n * @remarks This requires service's capability to manage Fluid container inside an existing file.\n *\n * @example\n *\n * This enables a scenario where Fluid data is not stored as a standalone file but in a way that is managed\n * by an existing file. For example, SharePoint Pages is able to store Fluid container in an\n * \"alternative file partition\" where the main File stub is an ASPX page.\n */\nexport async function createNewContainerOnExistingFile(\n\tgetStorageToken: InstrumentedStorageTokenFetcher,\n\tfileInfo: IExistingFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree | undefined,\n\tepochTracker: EpochTracker,\n\tfileEntry: IFileEntry,\n\tcreateNewCaching: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tisClpCompliantApp?: boolean,\n): Promise<IOdspResolvedUrl> {\n\tif (createNewSummary === undefined) {\n\t\tthrow new UsageError(\"createNewSummary must exist to create a new container\");\n\t}\n\n\tconst baseUrl = `${getApiRoot(getOrigin(fileInfo.siteUrl))}/drives/${fileInfo.driveId}/items/${\n\t\tfileInfo.itemId\n\t}`;\n\n\tconst containerSnapshot = convertSummaryIntoContainerSnapshot(createNewSummary);\n\n\tconst initialUrl = `${baseUrl}/opStream/snapshots/snapshot`;\n\n\tconst { id: summaryHandle } = await createNewFluidContainerCore<IWriteSummaryResponse>({\n\t\tcontainerSnapshot,\n\t\tgetStorageToken,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t\tepochTracker,\n\t\ttelemetryName: \"CreateNewContainerOnExistingFile\",\n\t\tfetchType: \"uploadSummary\",\n\t});\n\n\tconst odspUrl = createOdspUrl({ ...fileInfo, dataStorePath: \"/\" });\n\tconst resolver = new OdspDriverUrlResolver();\n\tconst odspResolvedUrl = await resolver.resolve({\n\t\turl: odspUrl,\n\t\theaders: { [ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },\n\t});\n\tfileEntry.docId = odspResolvedUrl.hashedDocumentId;\n\tfileEntry.resolvedUrl = odspResolvedUrl;\n\n\tif (createNewCaching) {\n\t\t// converting summary and getting sequence number\n\t\tconst snapshot: ISnapshotContents = convertCreateNewSummaryTreeToTreeAndBlobs(\n\t\t\tcreateNewSummary,\n\t\t\tsummaryHandle,\n\t\t);\n\t\t// caching the converted summary\n\t\tawait epochTracker.put(createCacheSnapshotKey(odspResolvedUrl), snapshot);\n\t}\n\n\treturn odspResolvedUrl;\n}\n"]}
@@ -0,0 +1,22 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ISummaryTree } from "@fluidframework/protocol-definitions";
6
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
7
+ import { IFileEntry, InstrumentedStorageTokenFetcher, IOdspResolvedUrl } from "@fluidframework/odsp-driver-definitions";
8
+ import { IExistingFileInfo } from "./odspUtils";
9
+ import { EpochTracker } from "./epochTracker";
10
+ /**
11
+ * Creates a new Fluid container on an existing file.
12
+ *
13
+ * @remarks This requires service's capability to manage Fluid container inside an existing file.
14
+ *
15
+ * @example
16
+ *
17
+ * This enables a scenario where Fluid data is not stored as a standalone file but in a way that is managed
18
+ * by an existing file. For example, SharePoint Pages is able to store Fluid container in an
19
+ * "alternative file partition" where the main File stub is an ASPX page.
20
+ */
21
+ export declare function createNewContainerOnExistingFile(getStorageToken: InstrumentedStorageTokenFetcher, fileInfo: IExistingFileInfo, logger: ITelemetryLoggerExt, createNewSummary: ISummaryTree | undefined, epochTracker: EpochTracker, fileEntry: IFileEntry, createNewCaching: boolean, forceAccessTokenViaAuthorizationHeader: boolean, isClpCompliantApp?: boolean): Promise<IOdspResolvedUrl>;
22
+ //# sourceMappingURL=createNewContainerOnExistingFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createNewContainerOnExistingFile.d.ts","sourceRoot":"","sources":["../src/createNewContainerOnExistingFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EACN,UAAU,EACV,+BAA+B,EAC/B,gBAAgB,EAChB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAqC,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAInF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAS9C;;;;;;;;;;GAUG;AACH,wBAAsB,gCAAgC,CACrD,eAAe,EAAE,+BAA+B,EAChD,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,mBAAmB,EAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,UAAU,EACrB,gBAAgB,EAAE,OAAO,EACzB,sCAAsC,EAAE,OAAO,EAC/C,iBAAiB,CAAC,EAAE,OAAO,GACzB,OAAO,CAAC,gBAAgB,CAAC,CA4C3B"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createNewContainerOnExistingFile = exports.createNewFluidFile = void 0;
8
+ var createFile_1 = require("./createFile.cjs");
9
+ Object.defineProperty(exports, "createNewFluidFile", { enumerable: true, get: function () { return createFile_1.createNewFluidFile; } });
10
+ var createNewContainerOnExistingFile_1 = require("./createNewContainerOnExistingFile.cjs");
11
+ Object.defineProperty(exports, "createNewContainerOnExistingFile", { enumerable: true, get: function () { return createNewContainerOnExistingFile_1.createNewContainerOnExistingFile; } });
12
+ //# sourceMappingURL=createNewModule.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createNewModule.cjs","sourceRoot":"","sources":["../src/createNewModule.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAkD;AAAzC,gHAAA,kBAAkB,OAAA;AAC3B,2FAAsF;AAA7E,oJAAA,gCAAgC,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { createNewFluidFile } from \"./createFile\";\nexport { createNewContainerOnExistingFile } from \"./createNewContainerOnExistingFile\";\n"]}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { createNewFluidFile } from "./createFile";
6
+ export { createNewContainerOnExistingFile } from "./createNewContainerOnExistingFile";
7
+ //# sourceMappingURL=createNewModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createNewModule.d.ts","sourceRoot":"","sources":["../src/createNewModule.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC"}
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createNewFluidContainerCore = exports.convertSummaryIntoContainerSnapshot = exports.convertCreateNewSummaryTreeToTreeAndBlobs = void 0;
8
+ const uuid_1 = require("uuid");
9
+ const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
10
+ const driver_utils_1 = require("@fluidframework/driver-utils");
11
+ const client_utils_1 = require("@fluid-internal/client-utils");
12
+ const core_utils_1 = require("@fluidframework/core-utils");
13
+ const protocol_base_1 = require("@fluidframework/protocol-base");
14
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
15
+ const odspUtils_1 = require("./odspUtils.cjs");
16
+ const getUrlAndHeadersWithAuth_1 = require("./getUrlAndHeadersWithAuth.cjs");
17
+ const retryUtils_1 = require("./retryUtils.cjs");
18
+ /**
19
+ * Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs
20
+ */
21
+ function convertCreateNewSummaryTreeToTreeAndBlobs(summary, treeId) {
22
+ const protocolSummary = summary.tree[".protocol"];
23
+ const documentAttributes = (0, driver_utils_1.getDocAttributesFromProtocolSummary)(protocolSummary);
24
+ const sequenceNumber = documentAttributes.sequenceNumber;
25
+ const blobs = new Map();
26
+ const snapshotTree = convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobs);
27
+ snapshotTree.id = treeId;
28
+ const snapshotTreeValue = {
29
+ snapshotTree,
30
+ blobs,
31
+ ops: [],
32
+ sequenceNumber,
33
+ latestSequenceNumber: sequenceNumber,
34
+ };
35
+ return snapshotTreeValue;
36
+ }
37
+ exports.convertCreateNewSummaryTreeToTreeAndBlobs = convertCreateNewSummaryTreeToTreeAndBlobs;
38
+ function convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobs) {
39
+ const treeNode = {
40
+ blobs: {},
41
+ trees: {},
42
+ unreferenced: summary.unreferenced,
43
+ };
44
+ const keys = Object.keys(summary.tree);
45
+ for (const key of keys) {
46
+ const summaryObject = summary.tree[key];
47
+ switch (summaryObject.type) {
48
+ case protocol_definitions_1.SummaryType.Tree: {
49
+ treeNode.trees[key] = convertCreateNewSummaryTreeToTreeAndBlobsCore(summaryObject, blobs);
50
+ break;
51
+ }
52
+ case protocol_definitions_1.SummaryType.Blob: {
53
+ const contentBuffer = typeof summaryObject.content === "string"
54
+ ? (0, client_utils_1.stringToBuffer)(summaryObject.content, "utf8")
55
+ : summaryObject.content;
56
+ const blobId = (0, uuid_1.v4)();
57
+ treeNode.blobs[key] = blobId;
58
+ blobs.set(blobId, contentBuffer);
59
+ break;
60
+ }
61
+ case protocol_definitions_1.SummaryType.Handle:
62
+ case protocol_definitions_1.SummaryType.Attachment: {
63
+ throw new Error(`No ${summaryObject.type} should be present for detached summary!`);
64
+ }
65
+ default: {
66
+ (0, core_utils_1.unreachableCase)(summaryObject, `Unknown tree type ${summaryObject.type}`);
67
+ }
68
+ }
69
+ }
70
+ return treeNode;
71
+ }
72
+ function convertSummaryIntoContainerSnapshot(createNewSummary) {
73
+ if (!(0, driver_utils_1.isCombinedAppAndProtocolSummary)(createNewSummary)) {
74
+ throw new Error("App and protocol summary required for create new path!!");
75
+ }
76
+ const appSummary = createNewSummary.tree[".app"];
77
+ const protocolSummary = createNewSummary.tree[".protocol"];
78
+ const documentAttributes = (0, driver_utils_1.getDocAttributesFromProtocolSummary)(protocolSummary);
79
+ const attributesSummaryBlob = {
80
+ type: protocol_definitions_1.SummaryType.Blob,
81
+ content: JSON.stringify(documentAttributes),
82
+ };
83
+ protocolSummary.tree.attributes = attributesSummaryBlob;
84
+ const convertedCreateNewSummary = {
85
+ type: protocol_definitions_1.SummaryType.Tree,
86
+ tree: {
87
+ ".protocol": protocolSummary,
88
+ ".app": appSummary,
89
+ },
90
+ };
91
+ const snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);
92
+ const snapshot = {
93
+ entries: snapshotTree.entries ?? [],
94
+ message: "app",
95
+ sequenceNumber: documentAttributes.sequenceNumber,
96
+ type: "container",
97
+ };
98
+ return snapshot;
99
+ }
100
+ exports.convertSummaryIntoContainerSnapshot = convertSummaryIntoContainerSnapshot;
101
+ /**
102
+ * Converts a summary tree to ODSP tree
103
+ */
104
+ function convertSummaryToSnapshotTreeForCreateNew(summary) {
105
+ const snapshotTree = {
106
+ type: "tree",
107
+ entries: [],
108
+ };
109
+ const keys = Object.keys(summary.tree);
110
+ for (const key of keys) {
111
+ const summaryObject = summary.tree[key];
112
+ let value;
113
+ // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the
114
+ // property is not present, the tree entry is considered referenced. If the property is present and is true,
115
+ // the tree entry is considered unreferenced.
116
+ let unreferenced;
117
+ switch (summaryObject.type) {
118
+ case protocol_definitions_1.SummaryType.Tree: {
119
+ value = convertSummaryToSnapshotTreeForCreateNew(summaryObject);
120
+ unreferenced = summaryObject.unreferenced;
121
+ break;
122
+ }
123
+ case protocol_definitions_1.SummaryType.Blob: {
124
+ const content = typeof summaryObject.content === "string"
125
+ ? summaryObject.content
126
+ : (0, client_utils_1.Uint8ArrayToString)(summaryObject.content, "base64");
127
+ const encoding = typeof summaryObject.content === "string" ? "utf-8" : "base64";
128
+ value = {
129
+ type: "blob",
130
+ content,
131
+ encoding,
132
+ };
133
+ break;
134
+ }
135
+ case protocol_definitions_1.SummaryType.Handle: {
136
+ throw new Error("No handle should be present for first summary!!");
137
+ }
138
+ default: {
139
+ throw new Error(`Unknown tree type ${summaryObject.type}`);
140
+ }
141
+ }
142
+ const entry = {
143
+ path: encodeURIComponent(key),
144
+ type: (0, protocol_base_1.getGitType)(summaryObject),
145
+ value,
146
+ unreferenced,
147
+ };
148
+ snapshotTree.entries?.push(entry);
149
+ }
150
+ return snapshotTree;
151
+ }
152
+ async function createNewFluidContainerCore(args) {
153
+ const { containerSnapshot, getStorageToken, logger, initialUrl, forceAccessTokenViaAuthorizationHeader, epochTracker, telemetryName, fetchType, validateResponseCallback, } = args;
154
+ return (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
155
+ const storageToken = await getStorageToken(options, telemetryName);
156
+ return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: telemetryName }, async (event) => {
157
+ const snapshotBody = JSON.stringify(containerSnapshot);
158
+ let url;
159
+ let headers;
160
+ let addInBody = false;
161
+ const formBoundary = (0, uuid_1.v4)();
162
+ let postBody = `--${formBoundary}\r\n`;
163
+ postBody += `Authorization: Bearer ${storageToken}\r\n`;
164
+ postBody += `X-HTTP-Method-Override: POST\r\n`;
165
+ postBody += `Content-Type: application/json\r\n`;
166
+ postBody += `_post: 1\r\n`;
167
+ postBody += `\r\n${snapshotBody}\r\n`;
168
+ postBody += `\r\n--${formBoundary}--`;
169
+ if (postBody.length <= odspUtils_1.maxUmpPostBodySize) {
170
+ const urlObj = new URL(initialUrl);
171
+ urlObj.searchParams.set("ump", "1");
172
+ url = urlObj.href;
173
+ headers = {
174
+ "Content-Type": `multipart/form-data;boundary=${formBoundary}`,
175
+ };
176
+ addInBody = true;
177
+ }
178
+ else {
179
+ const parts = (0, getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth)(initialUrl, storageToken, forceAccessTokenViaAuthorizationHeader);
180
+ url = parts.url;
181
+ headers = {
182
+ ...parts.headers,
183
+ "Content-Type": "application/json",
184
+ };
185
+ postBody = snapshotBody;
186
+ }
187
+ const fetchResponse = await (0, retryUtils_1.runWithRetry)(async () => epochTracker.fetchAndParseAsJSON(url, {
188
+ body: postBody,
189
+ headers,
190
+ method: "POST",
191
+ }, fetchType, addInBody), telemetryName, logger);
192
+ validateResponseCallback?.(fetchResponse.content);
193
+ event.end({
194
+ headers: Object.keys(headers).length !== 0 ? true : undefined,
195
+ attempts: options.refresh ? 2 : 1,
196
+ ...fetchResponse.propsToLog,
197
+ });
198
+ return fetchResponse.content;
199
+ });
200
+ });
201
+ }
202
+ exports.createNewFluidContainerCore = createNewFluidContainerCore;
203
+ //# sourceMappingURL=createNewUtils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createNewUtils.cjs","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAClC,+EAK8C;AAC9C,+DAGsC;AACtC,+DAAkF;AAClF,2DAA6D;AAC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ACF,aAAa,EACb,MAAM,CACN,CAAC;YAEF,wBAAwB,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAElD,KAAK,CAAC,GAAG,CAAC;gBACT,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;gBAC7D,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjC,GAAG,aAAa,CAAC,UAAU;aAC3B,CAAC,CAAC;YAEH,OAAO,aAAa,CAAC,OAAO,CAAC;QAC9B,CAAC,CACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC;AA7FD,kEA6FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tISummaryBlob,\n\tISummaryTree,\n\tSummaryType,\n\tISnapshotTree,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { stringToBuffer, Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport { unreachableCase } from \"@fluidframework/core-utils\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport {\n\tIOdspSummaryPayload,\n\tIOdspSummaryTree,\n\tOdspSummaryTreeEntry,\n\tOdspSummaryTreeValue,\n} from \"./contracts\";\nimport { getWithRetryForTokenRefresh, maxUmpPostBodySize } from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { EpochTracker, FetchType } from \"./epochTracker\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { runWithRetry } from \"./retryUtils\";\n\n/**\n * Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs\n */\nexport function convertCreateNewSummaryTreeToTreeAndBlobs(\n\tsummary: ISummaryTree,\n\ttreeId: string,\n): ISnapshotContents {\n\tconst protocolSummary = summary.tree[\".protocol\"] as ISummaryTree;\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tconst blobs = new Map<string, ArrayBuffer>();\n\tconst snapshotTree = convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobs);\n\tsnapshotTree.id = treeId;\n\tconst snapshotTreeValue: ISnapshotContents = {\n\t\tsnapshotTree,\n\t\tblobs,\n\t\tops: [],\n\t\tsequenceNumber,\n\t\tlatestSequenceNumber: sequenceNumber,\n\t};\n\n\treturn snapshotTreeValue;\n}\n\nfunction convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\tsummary: ISummaryTree,\n\tblobs: Map<string, ArrayBuffer>,\n) {\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tunreferenced: summary.unreferenced,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] = convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\tblobs,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tblobs.set(blobId, contentBuffer);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tthrow new Error(`No ${summaryObject.type} should be present for detached summary!`);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\nexport function convertSummaryIntoContainerSnapshot(createNewSummary: ISummaryTree) {\n\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\tthrow new Error(\"App and protocol summary required for create new path!!\");\n\t}\n\tconst appSummary = createNewSummary.tree[\".app\"];\n\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst attributesSummaryBlob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent: JSON.stringify(documentAttributes),\n\t};\n\tprotocolSummary.tree.attributes = attributesSummaryBlob;\n\tconst convertedCreateNewSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\tconst snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);\n\tconst snapshot: IOdspSummaryPayload = {\n\t\tentries: snapshotTree.entries ?? [],\n\t\tmessage: \"app\",\n\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\ttype: \"container\",\n\t};\n\treturn snapshot;\n}\n\n/**\n * Converts a summary tree to ODSP tree\n */\nfunction convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {\n\tconst snapshotTree: IOdspSummaryTree = {\n\t\ttype: \"tree\",\n\t\tentries: [],\n\t};\n\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tlet value: OdspSummaryTreeValue;\n\t\t// Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n\t\t// property is not present, the tree entry is considered referenced. If the property is present and is true,\n\t\t// the tree entry is considered unreferenced.\n\t\tlet unreferenced: true | undefined;\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tvalue = convertSummaryToSnapshotTreeForCreateNew(summaryObject);\n\t\t\t\tunreferenced = summaryObject.unreferenced;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst content =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? summaryObject.content\n\t\t\t\t\t\t: Uint8ArrayToString(summaryObject.content, \"base64\");\n\t\t\t\tconst encoding = typeof summaryObject.content === \"string\" ? \"utf-8\" : \"base64\";\n\n\t\t\t\tvalue = {\n\t\t\t\t\ttype: \"blob\",\n\t\t\t\t\tcontent,\n\t\t\t\t\tencoding,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"No handle should be present for first summary!!\");\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unknown tree type ${summaryObject.type}`);\n\t\t\t}\n\t\t}\n\n\t\tconst entry: OdspSummaryTreeEntry = {\n\t\t\tpath: encodeURIComponent(key),\n\t\t\ttype: getGitType(summaryObject),\n\t\t\tvalue,\n\t\t\tunreferenced,\n\t\t};\n\t\tsnapshotTree.entries?.push(entry);\n\t}\n\n\treturn snapshotTree;\n}\n\nexport async function createNewFluidContainerCore<T>(args: {\n\tcontainerSnapshot: IOdspSummaryPayload;\n\tgetStorageToken: InstrumentedStorageTokenFetcher;\n\tlogger: ITelemetryLoggerExt;\n\tinitialUrl: string;\n\tforceAccessTokenViaAuthorizationHeader: boolean;\n\tepochTracker: EpochTracker;\n\ttelemetryName: string;\n\tfetchType: FetchType;\n\tvalidateResponseCallback?: (content: T) => void;\n}): Promise<T> {\n\tconst {\n\t\tcontainerSnapshot,\n\t\tgetStorageToken,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t\tepochTracker,\n\t\ttelemetryName,\n\t\tfetchType,\n\t\tvalidateResponseCallback,\n\t} = args;\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\tconst storageToken = await getStorageToken(options, telemetryName);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: telemetryName },\n\t\t\tasync (event) => {\n\t\t\t\tconst snapshotBody = JSON.stringify(containerSnapshot);\n\t\t\t\tlet url: string;\n\t\t\t\tlet headers: { [index: string]: string };\n\t\t\t\tlet addInBody = false;\n\t\t\t\tconst formBoundary = uuid();\n\t\t\t\tlet postBody = `--${formBoundary}\\r\\n`;\n\t\t\t\tpostBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n\t\t\t\tpostBody += `X-HTTP-Method-Override: POST\\r\\n`;\n\t\t\t\tpostBody += `Content-Type: application/json\\r\\n`;\n\t\t\t\tpostBody += `_post: 1\\r\\n`;\n\t\t\t\tpostBody += `\\r\\n${snapshotBody}\\r\\n`;\n\t\t\t\tpostBody += `\\r\\n--${formBoundary}--`;\n\n\t\t\t\tif (postBody.length <= maxUmpPostBodySize) {\n\t\t\t\t\tconst urlObj = new URL(initialUrl);\n\t\t\t\t\turlObj.searchParams.set(\"ump\", \"1\");\n\t\t\t\t\turl = urlObj.href;\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t\t};\n\t\t\t\t\taddInBody = true;\n\t\t\t\t} else {\n\t\t\t\t\tconst parts = getUrlAndHeadersWithAuth(\n\t\t\t\t\t\tinitialUrl,\n\t\t\t\t\t\tstorageToken,\n\t\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t);\n\t\t\t\t\turl = parts.url;\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t...parts.headers,\n\t\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t};\n\t\t\t\t\tpostBody = snapshotBody;\n\t\t\t\t}\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<T>(\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\tfetchType,\n\t\t\t\t\t\t\taddInBody,\n\t\t\t\t\t\t),\n\t\t\t\t\ttelemetryName,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tvalidateResponseCallback?.(fetchResponse.content);\n\n\t\t\t\tevent.end({\n\t\t\t\t\theaders: Object.keys(headers).length !== 0 ? true : undefined,\n\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\n\t\t\t\treturn fetchResponse.content;\n\t\t\t},\n\t\t);\n\t});\n}\n"]}