@fluidframework/odsp-driver 2.0.0-dev-rc.1.0.0.232845 → 2.0.0-dev-rc.2.0.0.246488

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 (617) hide show
  1. package/.eslintrc.cjs +18 -3
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +44 -0
  4. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
  5. package/api-extractor-lint.json +1 -1
  6. package/api-extractor.json +1 -1
  7. package/api-report/odsp-driver.api.md +11 -12
  8. package/dist/ReadBufferUtils.d.ts.map +1 -1
  9. package/dist/ReadBufferUtils.js.map +1 -1
  10. package/dist/WriteBufferUtils.d.ts +1 -1
  11. package/dist/WriteBufferUtils.d.ts.map +1 -1
  12. package/dist/WriteBufferUtils.js +12 -12
  13. package/dist/WriteBufferUtils.js.map +1 -1
  14. package/dist/checkUrl.d.ts.map +1 -1
  15. package/dist/checkUrl.js +5 -3
  16. package/dist/checkUrl.js.map +1 -1
  17. package/dist/compactSnapshotParser.d.ts.map +1 -1
  18. package/dist/compactSnapshotParser.js +87 -69
  19. package/dist/compactSnapshotParser.js.map +1 -1
  20. package/dist/compactSnapshotWriter.d.ts.map +1 -1
  21. package/dist/compactSnapshotWriter.js +25 -19
  22. package/dist/compactSnapshotWriter.js.map +1 -1
  23. package/dist/contracts.d.ts +10 -4
  24. package/dist/contracts.d.ts.map +1 -1
  25. package/dist/contracts.js.map +1 -1
  26. package/dist/createFile.d.ts +3 -3
  27. package/dist/createFile.d.ts.map +1 -1
  28. package/dist/createFile.js +30 -27
  29. package/dist/createFile.js.map +1 -1
  30. package/dist/createNewContainerOnExistingFile.d.ts +2 -2
  31. package/dist/createNewContainerOnExistingFile.d.ts.map +1 -1
  32. package/dist/createNewContainerOnExistingFile.js +14 -14
  33. package/dist/createNewContainerOnExistingFile.js.map +1 -1
  34. package/dist/createNewModule.d.ts +2 -2
  35. package/dist/createNewModule.d.ts.map +1 -1
  36. package/dist/createNewModule.js +4 -4
  37. package/dist/createNewModule.js.map +1 -1
  38. package/dist/createNewUtils.d.ts +2 -2
  39. package/dist/createNewUtils.d.ts.map +1 -1
  40. package/dist/createNewUtils.js +12 -8
  41. package/dist/createNewUtils.js.map +1 -1
  42. package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
  43. package/dist/createOdspCreateContainerRequest.js +6 -2
  44. package/dist/createOdspCreateContainerRequest.js.map +1 -1
  45. package/dist/createOdspUrl.d.ts +1 -1
  46. package/dist/createOdspUrl.d.ts.map +1 -1
  47. package/dist/createOdspUrl.js.map +1 -1
  48. package/dist/epochTracker.d.ts +10 -9
  49. package/dist/epochTracker.d.ts.map +1 -1
  50. package/dist/epochTracker.js +66 -43
  51. package/dist/epochTracker.js.map +1 -1
  52. package/dist/fetchSnapshot.d.ts +11 -8
  53. package/dist/fetchSnapshot.d.ts.map +1 -1
  54. package/dist/fetchSnapshot.js +79 -58
  55. package/dist/fetchSnapshot.js.map +1 -1
  56. package/dist/getFileLink.d.ts.map +1 -1
  57. package/dist/getFileLink.js +24 -17
  58. package/dist/getFileLink.js.map +1 -1
  59. package/dist/getQueryString.d.ts.map +1 -1
  60. package/dist/getQueryString.js +6 -0
  61. package/dist/getQueryString.js.map +1 -1
  62. package/dist/index.d.ts +19 -19
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +44 -44
  65. package/dist/index.js.map +1 -1
  66. package/dist/localOdspDriver/localOdspDocumentService.d.ts +1 -1
  67. package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
  68. package/dist/localOdspDriver/localOdspDocumentService.js +5 -5
  69. package/dist/localOdspDriver/localOdspDocumentService.js.map +1 -1
  70. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +8 -6
  71. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
  72. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js +10 -9
  73. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -1
  74. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts +1 -1
  75. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
  76. package/dist/localOdspDriver/localOdspDocumentStorageManager.js +6 -6
  77. package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -1
  78. package/dist/odsp-driver-alpha.d.ts +27 -12
  79. package/dist/odsp-driver-beta.d.ts +1 -2
  80. package/dist/odsp-driver-public.d.ts +1 -2
  81. package/dist/odsp-driver-untrimmed.d.ts +29 -12
  82. package/dist/odspCache.d.ts +3 -3
  83. package/dist/odspCache.d.ts.map +1 -1
  84. package/dist/odspCache.js +3 -4
  85. package/dist/odspCache.js.map +1 -1
  86. package/dist/odspDelayLoadedDeltaStream.d.ts +7 -5
  87. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  88. package/dist/odspDelayLoadedDeltaStream.js +41 -28
  89. package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
  90. package/dist/odspDeltaStorageService.d.ts +7 -7
  91. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  92. package/dist/odspDeltaStorageService.js +5 -5
  93. package/dist/odspDeltaStorageService.js.map +1 -1
  94. package/dist/odspDocumentDeltaConnection.d.ts +1 -1
  95. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  96. package/dist/odspDocumentDeltaConnection.js +41 -23
  97. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  98. package/dist/odspDocumentService.d.ts +6 -4
  99. package/dist/odspDocumentService.d.ts.map +1 -1
  100. package/dist/odspDocumentService.js +19 -16
  101. package/dist/odspDocumentService.js.map +1 -1
  102. package/dist/odspDocumentServiceFactory.d.ts +6 -1
  103. package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
  104. package/dist/odspDocumentServiceFactory.js +9 -4
  105. package/dist/odspDocumentServiceFactory.js.map +1 -1
  106. package/dist/odspDocumentServiceFactoryCore.d.ts +4 -4
  107. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  108. package/dist/odspDocumentServiceFactoryCore.js +26 -22
  109. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  110. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +1 -1
  111. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
  112. package/dist/odspDocumentServiceFactoryWithCodeSplit.js +2 -2
  113. package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
  114. package/dist/odspDocumentStorageManager.d.ts +15 -9
  115. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  116. package/dist/odspDocumentStorageManager.js +219 -181
  117. package/dist/odspDocumentStorageManager.js.map +1 -1
  118. package/dist/odspDocumentStorageServiceBase.d.ts +2 -4
  119. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  120. package/dist/odspDocumentStorageServiceBase.js +32 -29
  121. package/dist/odspDocumentStorageServiceBase.js.map +1 -1
  122. package/dist/odspDriverUrlResolver.d.ts +5 -1
  123. package/dist/odspDriverUrlResolver.d.ts.map +1 -1
  124. package/dist/odspDriverUrlResolver.js +27 -24
  125. package/dist/odspDriverUrlResolver.js.map +1 -1
  126. package/dist/odspDriverUrlResolverForShareLink.d.ts +17 -6
  127. package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  128. package/dist/odspDriverUrlResolverForShareLink.js +49 -39
  129. package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
  130. package/dist/odspError.d.ts +1 -1
  131. package/dist/odspError.d.ts.map +1 -1
  132. package/dist/odspError.js +5 -5
  133. package/dist/odspError.js.map +1 -1
  134. package/dist/odspFluidFileLink.d.ts +1 -1
  135. package/dist/odspFluidFileLink.d.ts.map +1 -1
  136. package/dist/odspFluidFileLink.js +2 -2
  137. package/dist/odspFluidFileLink.js.map +1 -1
  138. package/dist/odspLocationRedirection.js +2 -2
  139. package/dist/odspLocationRedirection.js.map +1 -1
  140. package/dist/odspPublicUtils.d.ts +3 -0
  141. package/dist/odspPublicUtils.d.ts.map +1 -1
  142. package/dist/odspPublicUtils.js +3 -0
  143. package/dist/odspPublicUtils.js.map +1 -1
  144. package/dist/odspSnapshotParser.d.ts +1 -1
  145. package/dist/odspSnapshotParser.d.ts.map +1 -1
  146. package/dist/odspSnapshotParser.js +3 -2
  147. package/dist/odspSnapshotParser.js.map +1 -1
  148. package/dist/odspSummaryUploadManager.d.ts +1 -1
  149. package/dist/odspSummaryUploadManager.d.ts.map +1 -1
  150. package/dist/odspSummaryUploadManager.js +9 -6
  151. package/dist/odspSummaryUploadManager.js.map +1 -1
  152. package/dist/odspUrlHelper.d.ts.map +1 -1
  153. package/dist/odspUrlHelper.js +1 -2
  154. package/dist/odspUrlHelper.js.map +1 -1
  155. package/dist/odspUtils.d.ts +19 -7
  156. package/dist/odspUtils.d.ts.map +1 -1
  157. package/dist/odspUtils.js +61 -31
  158. package/dist/odspUtils.js.map +1 -1
  159. package/dist/opsCaching.d.ts +1 -1
  160. package/dist/opsCaching.d.ts.map +1 -1
  161. package/dist/opsCaching.js +2 -1
  162. package/dist/opsCaching.js.map +1 -1
  163. package/dist/package.json +3 -0
  164. package/dist/packageVersion.d.ts +1 -1
  165. package/dist/packageVersion.js +1 -1
  166. package/dist/packageVersion.js.map +1 -1
  167. package/dist/prefetchLatestSnapshot.d.ts +2 -2
  168. package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
  169. package/dist/prefetchLatestSnapshot.js +17 -12
  170. package/dist/prefetchLatestSnapshot.js.map +1 -1
  171. package/dist/retryErrorsStorageAdapter.d.ts +0 -1
  172. package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
  173. package/dist/retryErrorsStorageAdapter.js +2 -5
  174. package/dist/retryErrorsStorageAdapter.js.map +1 -1
  175. package/dist/retryUtils.d.ts.map +1 -1
  176. package/dist/retryUtils.js +6 -2
  177. package/dist/retryUtils.js.map +1 -1
  178. package/dist/socketModule.d.ts.map +1 -1
  179. package/dist/socketModule.js +2 -0
  180. package/dist/socketModule.js.map +1 -1
  181. package/dist/tsdoc-metadata.json +1 -1
  182. package/dist/vroom.d.ts +2 -2
  183. package/dist/vroom.d.ts.map +1 -1
  184. package/dist/vroom.js +5 -5
  185. package/dist/vroom.js.map +1 -1
  186. package/dist/zipItDataRepresentationUtils.d.ts +1 -1
  187. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  188. package/dist/zipItDataRepresentationUtils.js +15 -11
  189. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  190. package/lib/{ReadBufferUtils.d.mts → ReadBufferUtils.d.ts} +1 -1
  191. package/lib/ReadBufferUtils.d.ts.map +1 -0
  192. package/lib/{ReadBufferUtils.mjs → ReadBufferUtils.js} +1 -1
  193. package/lib/ReadBufferUtils.js.map +1 -0
  194. package/lib/{WriteBufferUtils.d.mts → WriteBufferUtils.d.ts} +2 -2
  195. package/lib/WriteBufferUtils.d.ts.map +1 -0
  196. package/lib/{WriteBufferUtils.mjs → WriteBufferUtils.js} +2 -2
  197. package/lib/WriteBufferUtils.js.map +1 -0
  198. package/lib/{checkUrl.d.mts → checkUrl.d.ts} +1 -1
  199. package/lib/checkUrl.d.ts.map +1 -0
  200. package/lib/{checkUrl.mjs → checkUrl.js} +5 -3
  201. package/lib/checkUrl.js.map +1 -0
  202. package/lib/{compactSnapshotParser.d.mts → compactSnapshotParser.d.ts} +1 -1
  203. package/lib/compactSnapshotParser.d.ts.map +1 -0
  204. package/lib/{compactSnapshotParser.mjs → compactSnapshotParser.js} +61 -43
  205. package/lib/compactSnapshotParser.js.map +1 -0
  206. package/lib/{compactSnapshotWriter.d.mts → compactSnapshotWriter.d.ts} +1 -1
  207. package/lib/compactSnapshotWriter.d.ts.map +1 -0
  208. package/lib/{compactSnapshotWriter.mjs → compactSnapshotWriter.js} +13 -7
  209. package/lib/compactSnapshotWriter.js.map +1 -0
  210. package/lib/{constants.d.mts → constants.d.ts} +1 -1
  211. package/lib/constants.d.ts.map +1 -0
  212. package/lib/{constants.mjs → constants.js} +1 -1
  213. package/lib/constants.js.map +1 -0
  214. package/lib/{contracts.d.mts → contracts.d.ts} +11 -5
  215. package/lib/contracts.d.ts.map +1 -0
  216. package/lib/{contracts.mjs → contracts.js} +1 -1
  217. package/lib/contracts.js.map +1 -0
  218. package/lib/{contractsPublic.d.mts → contractsPublic.d.ts} +1 -1
  219. package/lib/contractsPublic.d.ts.map +1 -0
  220. package/lib/{contractsPublic.mjs → contractsPublic.js} +1 -1
  221. package/lib/contractsPublic.js.map +1 -0
  222. package/lib/{createFile.d.mts → createFile.d.ts} +4 -4
  223. package/lib/createFile.d.ts.map +1 -0
  224. package/lib/{createFile.mjs → createFile.js} +15 -12
  225. package/lib/createFile.js.map +1 -0
  226. package/lib/{createNewContainerOnExistingFile.d.mts → createNewContainerOnExistingFile.d.ts} +3 -3
  227. package/lib/createNewContainerOnExistingFile.d.ts.map +1 -0
  228. package/lib/{createNewContainerOnExistingFile.mjs → createNewContainerOnExistingFile.js} +7 -7
  229. package/lib/createNewContainerOnExistingFile.js.map +1 -0
  230. package/lib/{createNewModule.mjs → createNewModule.d.ts} +3 -3
  231. package/lib/createNewModule.d.ts.map +1 -0
  232. package/lib/{createNewModule.d.mts → createNewModule.js} +3 -3
  233. package/lib/createNewModule.js.map +1 -0
  234. package/lib/{createNewUtils.d.mts → createNewUtils.d.ts} +3 -3
  235. package/lib/createNewUtils.d.ts.map +1 -0
  236. package/lib/{createNewUtils.mjs → createNewUtils.js} +9 -5
  237. package/lib/createNewUtils.js.map +1 -0
  238. package/lib/{createOdspCreateContainerRequest.d.mts → createOdspCreateContainerRequest.d.ts} +5 -1
  239. package/lib/createOdspCreateContainerRequest.d.ts.map +1 -0
  240. package/lib/{createOdspCreateContainerRequest.mjs → createOdspCreateContainerRequest.js} +6 -2
  241. package/lib/createOdspCreateContainerRequest.js.map +1 -0
  242. package/lib/{createOdspUrl.d.mts → createOdspUrl.d.ts} +2 -2
  243. package/lib/createOdspUrl.d.ts.map +1 -0
  244. package/lib/{createOdspUrl.mjs → createOdspUrl.js} +1 -1
  245. package/lib/createOdspUrl.js.map +1 -0
  246. package/lib/{epochTracker.d.mts → epochTracker.d.ts} +11 -10
  247. package/lib/epochTracker.d.ts.map +1 -0
  248. package/lib/{epochTracker.mjs → epochTracker.js} +56 -33
  249. package/lib/epochTracker.js.map +1 -0
  250. package/lib/{fetch.d.mts → fetch.d.ts} +1 -1
  251. package/lib/fetch.d.ts.map +1 -0
  252. package/lib/{fetch.mjs → fetch.js} +1 -1
  253. package/lib/fetch.js.map +1 -0
  254. package/lib/{fetchSnapshot.d.mts → fetchSnapshot.d.ts} +12 -9
  255. package/lib/fetchSnapshot.d.ts.map +1 -0
  256. package/lib/{fetchSnapshot.mjs → fetchSnapshot.js} +61 -40
  257. package/lib/fetchSnapshot.js.map +1 -0
  258. package/lib/{getFileLink.d.mts → getFileLink.d.ts} +1 -1
  259. package/lib/getFileLink.d.ts.map +1 -0
  260. package/lib/{getFileLink.mjs → getFileLink.js} +14 -7
  261. package/lib/getFileLink.js.map +1 -0
  262. package/lib/{getQueryString.d.mts → getQueryString.d.ts} +5 -1
  263. package/lib/getQueryString.d.ts.map +1 -0
  264. package/lib/{getQueryString.mjs → getQueryString.js} +7 -1
  265. package/lib/getQueryString.js.map +1 -0
  266. package/lib/{getUrlAndHeadersWithAuth.d.mts → getUrlAndHeadersWithAuth.d.ts} +1 -1
  267. package/lib/getUrlAndHeadersWithAuth.d.ts.map +1 -0
  268. package/lib/{getUrlAndHeadersWithAuth.mjs → getUrlAndHeadersWithAuth.js} +1 -1
  269. package/lib/getUrlAndHeadersWithAuth.js.map +1 -0
  270. package/lib/{index.d.mts → index.d.ts} +20 -20
  271. package/lib/index.d.ts.map +1 -0
  272. package/lib/index.js +29 -0
  273. package/lib/index.js.map +1 -0
  274. package/lib/localOdspDriver/{localOdspDeltaStorageService.d.mts → localOdspDeltaStorageService.d.ts} +1 -1
  275. package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
  276. package/lib/localOdspDriver/{localOdspDeltaStorageService.mjs → localOdspDeltaStorageService.js} +1 -1
  277. package/lib/localOdspDriver/localOdspDeltaStorageService.js.map +1 -0
  278. package/lib/localOdspDriver/{localOdspDocumentService.d.mts → localOdspDocumentService.d.ts} +2 -2
  279. package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +1 -0
  280. package/lib/localOdspDriver/{localOdspDocumentService.mjs → localOdspDocumentService.js} +4 -4
  281. package/lib/localOdspDriver/localOdspDocumentService.js.map +1 -0
  282. package/lib/localOdspDriver/{localOdspDocumentServiceFactory.d.mts → localOdspDocumentServiceFactory.d.ts} +9 -7
  283. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -0
  284. package/lib/localOdspDriver/{localOdspDocumentServiceFactory.mjs → localOdspDocumentServiceFactory.js} +9 -8
  285. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -0
  286. package/lib/localOdspDriver/{localOdspDocumentStorageManager.d.mts → localOdspDocumentStorageManager.d.ts} +2 -2
  287. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -0
  288. package/lib/localOdspDriver/{localOdspDocumentStorageManager.mjs → localOdspDocumentStorageManager.js} +4 -4
  289. package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -0
  290. package/lib/{odsp-driver-alpha.d.mts → odsp-driver-alpha.d.ts} +27 -12
  291. package/lib/{odsp-driver-public.d.mts → odsp-driver-beta.d.ts} +1 -2
  292. package/lib/{odsp-driver-beta.d.mts → odsp-driver-public.d.ts} +1 -2
  293. package/lib/{odsp-driver-untrimmed.d.mts → odsp-driver-untrimmed.d.ts} +29 -12
  294. package/lib/{odspCache.d.mts → odspCache.d.ts} +8 -4
  295. package/lib/odspCache.d.ts.map +1 -0
  296. package/lib/{odspCache.mjs → odspCache.js} +6 -3
  297. package/lib/odspCache.js.map +1 -0
  298. package/lib/{odspDelayLoadedDeltaStream.d.mts → odspDelayLoadedDeltaStream.d.ts} +8 -6
  299. package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -0
  300. package/lib/{odspDelayLoadedDeltaStream.mjs → odspDelayLoadedDeltaStream.js} +33 -20
  301. package/lib/odspDelayLoadedDeltaStream.js.map +1 -0
  302. package/lib/{odspDeltaStorageService.d.mts → odspDeltaStorageService.d.ts} +8 -8
  303. package/lib/odspDeltaStorageService.d.ts.map +1 -0
  304. package/lib/{odspDeltaStorageService.mjs → odspDeltaStorageService.js} +5 -5
  305. package/lib/odspDeltaStorageService.js.map +1 -0
  306. package/lib/{odspDocumentDeltaConnection.d.mts → odspDocumentDeltaConnection.d.ts} +2 -2
  307. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -0
  308. package/lib/{odspDocumentDeltaConnection.mjs → odspDocumentDeltaConnection.js} +34 -16
  309. package/lib/odspDocumentDeltaConnection.js.map +1 -0
  310. package/lib/{odspDocumentService.d.mts → odspDocumentService.d.ts} +7 -5
  311. package/lib/odspDocumentService.d.ts.map +1 -0
  312. package/lib/{odspDocumentService.mjs → odspDocumentService.js} +16 -11
  313. package/lib/odspDocumentService.js.map +1 -0
  314. package/lib/{odspDocumentServiceFactory.d.mts → odspDocumentServiceFactory.d.ts} +7 -2
  315. package/lib/odspDocumentServiceFactory.d.ts.map +1 -0
  316. package/lib/{odspDocumentServiceFactory.mjs → odspDocumentServiceFactory.js} +9 -3
  317. package/lib/odspDocumentServiceFactory.js.map +1 -0
  318. package/lib/{odspDocumentServiceFactoryCore.d.mts → odspDocumentServiceFactoryCore.d.ts} +5 -5
  319. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -0
  320. package/lib/{odspDocumentServiceFactoryCore.mjs → odspDocumentServiceFactoryCore.js} +23 -17
  321. package/lib/odspDocumentServiceFactoryCore.js.map +1 -0
  322. package/lib/{odspDocumentServiceFactoryWithCodeSplit.d.mts → odspDocumentServiceFactoryWithCodeSplit.d.ts} +2 -2
  323. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -0
  324. package/lib/{odspDocumentServiceFactoryWithCodeSplit.mjs → odspDocumentServiceFactoryWithCodeSplit.js} +2 -2
  325. package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -0
  326. package/lib/{odspDocumentStorageManager.d.mts → odspDocumentStorageManager.d.ts} +16 -10
  327. package/lib/odspDocumentStorageManager.d.ts.map +1 -0
  328. package/lib/{odspDocumentStorageManager.mjs → odspDocumentStorageManager.js} +207 -167
  329. package/lib/odspDocumentStorageManager.js.map +1 -0
  330. package/lib/{odspDocumentStorageServiceBase.d.mts → odspDocumentStorageServiceBase.d.ts} +3 -5
  331. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -0
  332. package/lib/{odspDocumentStorageServiceBase.mjs → odspDocumentStorageServiceBase.js} +32 -29
  333. package/lib/odspDocumentStorageServiceBase.js.map +1 -0
  334. package/lib/{odspDriverUrlResolver.d.mts → odspDriverUrlResolver.d.ts} +6 -2
  335. package/lib/odspDriverUrlResolver.d.ts.map +1 -0
  336. package/lib/{odspDriverUrlResolver.mjs → odspDriverUrlResolver.js} +24 -17
  337. package/lib/odspDriverUrlResolver.js.map +1 -0
  338. package/lib/{odspDriverUrlResolverForShareLink.d.mts → odspDriverUrlResolverForShareLink.d.ts} +18 -7
  339. package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -0
  340. package/lib/{odspDriverUrlResolverForShareLink.mjs → odspDriverUrlResolverForShareLink.js} +41 -27
  341. package/lib/odspDriverUrlResolverForShareLink.js.map +1 -0
  342. package/lib/{odspError.d.mts → odspError.d.ts} +2 -2
  343. package/lib/odspError.d.ts.map +1 -0
  344. package/lib/{odspError.mjs → odspError.js} +4 -4
  345. package/lib/odspError.js.map +1 -0
  346. package/lib/{odspFluidFileLink.d.mts → odspFluidFileLink.d.ts} +2 -2
  347. package/lib/odspFluidFileLink.d.ts.map +1 -0
  348. package/lib/{odspFluidFileLink.mjs → odspFluidFileLink.js} +2 -2
  349. package/lib/odspFluidFileLink.js.map +1 -0
  350. package/lib/{odspLocationRedirection.d.mts → odspLocationRedirection.d.ts} +1 -1
  351. package/lib/odspLocationRedirection.d.ts.map +1 -0
  352. package/lib/{odspLocationRedirection.mjs → odspLocationRedirection.js} +2 -2
  353. package/lib/odspLocationRedirection.js.map +1 -0
  354. package/lib/{odspPublicUtils.d.mts → odspPublicUtils.d.ts} +4 -1
  355. package/lib/odspPublicUtils.d.ts.map +1 -0
  356. package/lib/{odspPublicUtils.mjs → odspPublicUtils.js} +4 -1
  357. package/lib/odspPublicUtils.js.map +1 -0
  358. package/lib/{odspSnapshotParser.d.mts → odspSnapshotParser.d.ts} +2 -2
  359. package/lib/odspSnapshotParser.d.ts.map +1 -0
  360. package/lib/{odspSnapshotParser.mjs → odspSnapshotParser.js} +4 -3
  361. package/lib/odspSnapshotParser.js.map +1 -0
  362. package/lib/{odspSummaryUploadManager.d.mts → odspSummaryUploadManager.d.ts} +2 -2
  363. package/lib/odspSummaryUploadManager.d.ts.map +1 -0
  364. package/lib/{odspSummaryUploadManager.mjs → odspSummaryUploadManager.js} +8 -5
  365. package/lib/odspSummaryUploadManager.js.map +1 -0
  366. package/lib/{odspUrlHelper.d.mts → odspUrlHelper.d.ts} +1 -1
  367. package/lib/odspUrlHelper.d.ts.map +1 -0
  368. package/lib/{odspUrlHelper.mjs → odspUrlHelper.js} +2 -3
  369. package/lib/odspUrlHelper.js.map +1 -0
  370. package/lib/{odspUtils.d.mts → odspUtils.d.ts} +20 -8
  371. package/lib/odspUtils.d.ts.map +1 -0
  372. package/lib/{odspUtils.mjs → odspUtils.js} +45 -17
  373. package/lib/odspUtils.js.map +1 -0
  374. package/lib/{opsCaching.d.mts → opsCaching.d.ts} +2 -2
  375. package/lib/opsCaching.d.ts.map +1 -0
  376. package/lib/{opsCaching.mjs → opsCaching.js} +3 -2
  377. package/lib/opsCaching.js.map +1 -0
  378. package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
  379. package/lib/packageVersion.d.ts.map +1 -0
  380. package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
  381. package/lib/packageVersion.js.map +1 -0
  382. package/lib/{prefetchLatestSnapshot.d.mts → prefetchLatestSnapshot.d.ts} +3 -3
  383. package/lib/prefetchLatestSnapshot.d.ts.map +1 -0
  384. package/lib/{prefetchLatestSnapshot.mjs → prefetchLatestSnapshot.js} +16 -11
  385. package/lib/prefetchLatestSnapshot.js.map +1 -0
  386. package/lib/{retryErrorsStorageAdapter.d.mts → retryErrorsStorageAdapter.d.ts} +1 -2
  387. package/lib/retryErrorsStorageAdapter.d.ts.map +1 -0
  388. package/lib/{retryErrorsStorageAdapter.mjs → retryErrorsStorageAdapter.js} +2 -5
  389. package/lib/retryErrorsStorageAdapter.js.map +1 -0
  390. package/lib/{retryUtils.d.mts → retryUtils.d.ts} +1 -1
  391. package/lib/retryUtils.d.ts.map +1 -0
  392. package/lib/{retryUtils.mjs → retryUtils.js} +6 -2
  393. package/lib/retryUtils.js.map +1 -0
  394. package/lib/{socketModule.d.mts → socketModule.d.ts} +1 -1
  395. package/lib/socketModule.d.ts.map +1 -0
  396. package/lib/{socketModule.mjs → socketModule.js} +3 -1
  397. package/lib/socketModule.js.map +1 -0
  398. package/lib/test/buildOdspShareLinkReqParams.spec.js +25 -0
  399. package/lib/test/buildOdspShareLinkReqParams.spec.js.map +1 -0
  400. package/lib/test/createNewUtilsTests.spec.js +221 -0
  401. package/lib/test/createNewUtilsTests.spec.js.map +1 -0
  402. package/lib/test/deltaStorageService.spec.js +176 -0
  403. package/lib/test/deltaStorageService.spec.js.map +1 -0
  404. package/lib/test/epochTests.spec.js +340 -0
  405. package/lib/test/epochTests.spec.js.map +1 -0
  406. package/lib/test/epochTestsWithRedemption.spec.js +119 -0
  407. package/lib/test/epochTestsWithRedemption.spec.js.map +1 -0
  408. package/lib/test/fetchSnapshot.spec.js +412 -0
  409. package/lib/test/fetchSnapshot.spec.js.map +1 -0
  410. package/lib/test/getFileLink.spec.js +62 -0
  411. package/lib/test/getFileLink.spec.js.map +1 -0
  412. package/lib/test/getUrlAndHeadersWithAuth.spec.js +66 -0
  413. package/lib/test/getUrlAndHeadersWithAuth.spec.js.map +1 -0
  414. package/lib/test/getVersions.spec.js +284 -0
  415. package/lib/test/getVersions.spec.js.map +1 -0
  416. package/lib/test/joinSessionCacheTests.spec.js +53 -0
  417. package/lib/test/joinSessionCacheTests.spec.js.map +1 -0
  418. package/lib/test/joinSessionPeriodicCall.spec.js +158 -0
  419. package/lib/test/joinSessionPeriodicCall.spec.js.map +1 -0
  420. package/lib/test/jsonSnapshotFormatTests.spec.js +107 -0
  421. package/lib/test/jsonSnapshotFormatTests.spec.js.map +1 -0
  422. package/lib/test/localOdspDriver.spec.js +177 -0
  423. package/lib/test/localOdspDriver.spec.js.map +1 -0
  424. package/lib/test/mockFetch.js +61 -0
  425. package/lib/test/mockFetch.js.map +1 -0
  426. package/lib/test/odspCreateContainer.spec.js +116 -0
  427. package/lib/test/odspCreateContainer.spec.js.map +1 -0
  428. package/lib/test/odspDriverResolverTest.spec.js +289 -0
  429. package/lib/test/odspDriverResolverTest.spec.js.map +1 -0
  430. package/lib/test/odspDriverUrlResolverForShareLink.spec.js +287 -0
  431. package/lib/test/odspDriverUrlResolverForShareLink.spec.js.map +1 -0
  432. package/lib/test/odspError.spec.js +299 -0
  433. package/lib/test/odspError.spec.js.map +1 -0
  434. package/lib/test/opsCaching.spec.js +357 -0
  435. package/lib/test/opsCaching.spec.js.map +1 -0
  436. package/lib/test/prefetchSnapshotTests.spec.js +420 -0
  437. package/lib/test/prefetchSnapshotTests.spec.js.map +1 -0
  438. package/lib/test/snapshotFormatTests.spec.js +218 -0
  439. package/lib/test/snapshotFormatTests.spec.js.map +1 -0
  440. package/lib/test/socketTests/deltaConnectionUpdateTests.spec.js +152 -0
  441. package/lib/test/socketTests/deltaConnectionUpdateTests.spec.js.map +1 -0
  442. package/lib/test/socketTests/socketMock.js +109 -0
  443. package/lib/test/socketTests/socketMock.js.map +1 -0
  444. package/lib/test/socketTests/socketTests.spec.js +256 -0
  445. package/lib/test/socketTests/socketTests.spec.js.map +1 -0
  446. package/lib/test/tokenFetch.spec.js +39 -0
  447. package/lib/test/tokenFetch.spec.js.map +1 -0
  448. package/lib/test/types/validateOdspDriverPrevious.generated.js +96 -0
  449. package/lib/test/types/validateOdspDriverPrevious.generated.js.map +1 -0
  450. package/lib/test/zipItDataRepresentationTests.spec.js +207 -0
  451. package/lib/test/zipItDataRepresentationTests.spec.js.map +1 -0
  452. package/lib/{vroom.d.mts → vroom.d.ts} +3 -3
  453. package/lib/vroom.d.ts.map +1 -0
  454. package/lib/{vroom.mjs → vroom.js} +4 -4
  455. package/lib/vroom.js.map +1 -0
  456. package/lib/{zipItDataRepresentationUtils.d.mts → zipItDataRepresentationUtils.d.ts} +2 -2
  457. package/lib/zipItDataRepresentationUtils.d.ts.map +1 -0
  458. package/lib/{zipItDataRepresentationUtils.mjs → zipItDataRepresentationUtils.js} +17 -9
  459. package/lib/zipItDataRepresentationUtils.js.map +1 -0
  460. package/package.json +90 -31
  461. package/src/ReadBufferUtils.ts +7 -7
  462. package/src/WriteBufferUtils.ts +13 -9
  463. package/src/checkUrl.ts +4 -2
  464. package/src/compactSnapshotParser.ts +87 -52
  465. package/src/compactSnapshotWriter.ts +19 -12
  466. package/src/contracts.ts +16 -4
  467. package/src/createFile.ts +16 -13
  468. package/src/createNewContainerOnExistingFile.ts +8 -8
  469. package/src/createNewModule.ts +2 -2
  470. package/src/createNewUtils.ts +19 -9
  471. package/src/createOdspCreateContainerRequest.ts +2 -1
  472. package/src/createOdspUrl.ts +1 -1
  473. package/src/epochTracker.ts +90 -55
  474. package/src/fetchSnapshot.ts +104 -47
  475. package/src/getFileLink.ts +21 -13
  476. package/src/getQueryString.ts +3 -0
  477. package/src/index.ts +27 -19
  478. package/src/localOdspDriver/localOdspDocumentService.ts +3 -3
  479. package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +12 -11
  480. package/src/localOdspDriver/localOdspDocumentStorageManager.ts +5 -5
  481. package/src/odspCache.ts +13 -9
  482. package/src/odspDelayLoadedDeltaStream.ts +54 -33
  483. package/src/odspDeltaStorageService.ts +17 -16
  484. package/src/odspDocumentDeltaConnection.ts +52 -34
  485. package/src/odspDocumentService.ts +23 -20
  486. package/src/odspDocumentServiceFactory.ts +7 -2
  487. package/src/odspDocumentServiceFactoryCore.ts +25 -18
  488. package/src/odspDocumentServiceFactoryWithCodeSplit.ts +1 -1
  489. package/src/odspDocumentStorageManager.ts +276 -216
  490. package/src/odspDocumentStorageServiceBase.ts +45 -43
  491. package/src/odspDriverUrlResolver.ts +39 -24
  492. package/src/odspDriverUrlResolverForShareLink.ts +51 -31
  493. package/src/odspError.ts +4 -4
  494. package/src/odspFluidFileLink.ts +3 -3
  495. package/src/odspLocationRedirection.ts +1 -1
  496. package/src/odspPublicUtils.ts +3 -0
  497. package/src/odspSnapshotParser.ts +4 -3
  498. package/src/odspSummaryUploadManager.ts +21 -9
  499. package/src/odspUrlHelper.ts +2 -3
  500. package/src/odspUtils.ts +73 -30
  501. package/src/opsCaching.ts +13 -12
  502. package/src/packageVersion.ts +1 -1
  503. package/src/prefetchLatestSnapshot.ts +24 -15
  504. package/src/retryErrorsStorageAdapter.ts +4 -8
  505. package/src/retryUtils.ts +6 -2
  506. package/src/socketModule.ts +2 -0
  507. package/src/vroom.ts +6 -6
  508. package/src/zipItDataRepresentationUtils.ts +63 -35
  509. package/tsconfig.cjs.json +7 -0
  510. package/tsconfig.json +2 -5
  511. package/lib/ReadBufferUtils.d.mts.map +0 -1
  512. package/lib/ReadBufferUtils.mjs.map +0 -1
  513. package/lib/WriteBufferUtils.d.mts.map +0 -1
  514. package/lib/WriteBufferUtils.mjs.map +0 -1
  515. package/lib/checkUrl.d.mts.map +0 -1
  516. package/lib/checkUrl.mjs.map +0 -1
  517. package/lib/compactSnapshotParser.d.mts.map +0 -1
  518. package/lib/compactSnapshotParser.mjs.map +0 -1
  519. package/lib/compactSnapshotWriter.d.mts.map +0 -1
  520. package/lib/compactSnapshotWriter.mjs.map +0 -1
  521. package/lib/constants.d.mts.map +0 -1
  522. package/lib/constants.mjs.map +0 -1
  523. package/lib/contracts.d.mts.map +0 -1
  524. package/lib/contracts.mjs.map +0 -1
  525. package/lib/contractsPublic.d.mts.map +0 -1
  526. package/lib/contractsPublic.mjs.map +0 -1
  527. package/lib/createFile.d.mts.map +0 -1
  528. package/lib/createFile.mjs.map +0 -1
  529. package/lib/createNewContainerOnExistingFile.d.mts.map +0 -1
  530. package/lib/createNewContainerOnExistingFile.mjs.map +0 -1
  531. package/lib/createNewModule.d.mts.map +0 -1
  532. package/lib/createNewModule.mjs.map +0 -1
  533. package/lib/createNewUtils.d.mts.map +0 -1
  534. package/lib/createNewUtils.mjs.map +0 -1
  535. package/lib/createOdspCreateContainerRequest.d.mts.map +0 -1
  536. package/lib/createOdspCreateContainerRequest.mjs.map +0 -1
  537. package/lib/createOdspUrl.d.mts.map +0 -1
  538. package/lib/createOdspUrl.mjs.map +0 -1
  539. package/lib/epochTracker.d.mts.map +0 -1
  540. package/lib/epochTracker.mjs.map +0 -1
  541. package/lib/fetch.d.mts.map +0 -1
  542. package/lib/fetch.mjs.map +0 -1
  543. package/lib/fetchSnapshot.d.mts.map +0 -1
  544. package/lib/fetchSnapshot.mjs.map +0 -1
  545. package/lib/getFileLink.d.mts.map +0 -1
  546. package/lib/getFileLink.mjs.map +0 -1
  547. package/lib/getQueryString.d.mts.map +0 -1
  548. package/lib/getQueryString.mjs.map +0 -1
  549. package/lib/getUrlAndHeadersWithAuth.d.mts.map +0 -1
  550. package/lib/getUrlAndHeadersWithAuth.mjs.map +0 -1
  551. package/lib/index.d.mts.map +0 -1
  552. package/lib/index.mjs +0 -22
  553. package/lib/index.mjs.map +0 -1
  554. package/lib/localOdspDriver/localOdspDeltaStorageService.d.mts.map +0 -1
  555. package/lib/localOdspDriver/localOdspDeltaStorageService.mjs.map +0 -1
  556. package/lib/localOdspDriver/localOdspDocumentService.d.mts.map +0 -1
  557. package/lib/localOdspDriver/localOdspDocumentService.mjs.map +0 -1
  558. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.mts.map +0 -1
  559. package/lib/localOdspDriver/localOdspDocumentServiceFactory.mjs.map +0 -1
  560. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.mts.map +0 -1
  561. package/lib/localOdspDriver/localOdspDocumentStorageManager.mjs.map +0 -1
  562. package/lib/odspCache.d.mts.map +0 -1
  563. package/lib/odspCache.mjs.map +0 -1
  564. package/lib/odspDelayLoadedDeltaStream.d.mts.map +0 -1
  565. package/lib/odspDelayLoadedDeltaStream.mjs.map +0 -1
  566. package/lib/odspDeltaStorageService.d.mts.map +0 -1
  567. package/lib/odspDeltaStorageService.mjs.map +0 -1
  568. package/lib/odspDocumentDeltaConnection.d.mts.map +0 -1
  569. package/lib/odspDocumentDeltaConnection.mjs.map +0 -1
  570. package/lib/odspDocumentService.d.mts.map +0 -1
  571. package/lib/odspDocumentService.mjs.map +0 -1
  572. package/lib/odspDocumentServiceFactory.d.mts.map +0 -1
  573. package/lib/odspDocumentServiceFactory.mjs.map +0 -1
  574. package/lib/odspDocumentServiceFactoryCore.d.mts.map +0 -1
  575. package/lib/odspDocumentServiceFactoryCore.mjs.map +0 -1
  576. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.mts.map +0 -1
  577. package/lib/odspDocumentServiceFactoryWithCodeSplit.mjs.map +0 -1
  578. package/lib/odspDocumentStorageManager.d.mts.map +0 -1
  579. package/lib/odspDocumentStorageManager.mjs.map +0 -1
  580. package/lib/odspDocumentStorageServiceBase.d.mts.map +0 -1
  581. package/lib/odspDocumentStorageServiceBase.mjs.map +0 -1
  582. package/lib/odspDriverUrlResolver.d.mts.map +0 -1
  583. package/lib/odspDriverUrlResolver.mjs.map +0 -1
  584. package/lib/odspDriverUrlResolverForShareLink.d.mts.map +0 -1
  585. package/lib/odspDriverUrlResolverForShareLink.mjs.map +0 -1
  586. package/lib/odspError.d.mts.map +0 -1
  587. package/lib/odspError.mjs.map +0 -1
  588. package/lib/odspFluidFileLink.d.mts.map +0 -1
  589. package/lib/odspFluidFileLink.mjs.map +0 -1
  590. package/lib/odspLocationRedirection.d.mts.map +0 -1
  591. package/lib/odspLocationRedirection.mjs.map +0 -1
  592. package/lib/odspPublicUtils.d.mts.map +0 -1
  593. package/lib/odspPublicUtils.mjs.map +0 -1
  594. package/lib/odspSnapshotParser.d.mts.map +0 -1
  595. package/lib/odspSnapshotParser.mjs.map +0 -1
  596. package/lib/odspSummaryUploadManager.d.mts.map +0 -1
  597. package/lib/odspSummaryUploadManager.mjs.map +0 -1
  598. package/lib/odspUrlHelper.d.mts.map +0 -1
  599. package/lib/odspUrlHelper.mjs.map +0 -1
  600. package/lib/odspUtils.d.mts.map +0 -1
  601. package/lib/odspUtils.mjs.map +0 -1
  602. package/lib/opsCaching.d.mts.map +0 -1
  603. package/lib/opsCaching.mjs.map +0 -1
  604. package/lib/packageVersion.d.mts.map +0 -1
  605. package/lib/packageVersion.mjs.map +0 -1
  606. package/lib/prefetchLatestSnapshot.d.mts.map +0 -1
  607. package/lib/prefetchLatestSnapshot.mjs.map +0 -1
  608. package/lib/retryErrorsStorageAdapter.d.mts.map +0 -1
  609. package/lib/retryErrorsStorageAdapter.mjs.map +0 -1
  610. package/lib/retryUtils.d.mts.map +0 -1
  611. package/lib/retryUtils.mjs.map +0 -1
  612. package/lib/socketModule.d.mts.map +0 -1
  613. package/lib/socketModule.mjs.map +0 -1
  614. package/lib/vroom.d.mts.map +0 -1
  615. package/lib/vroom.mjs.map +0 -1
  616. package/lib/zipItDataRepresentationUtils.d.mts.map +0 -1
  617. package/lib/zipItDataRepresentationUtils.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getUrlAndHeadersWithAuth.spec.js","sourceRoot":"","sources":["../../src/test/getUrlAndHeadersWithAuth.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,E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B,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CACrD,CAAC;QACF,gCAAgC,CAC/B,kBAAkB,EAClB,8BAA8B,EAC9B,wBAAwB,CACvB,kBAAkB,CAAC,IAAI,EACvB,8BAA8B,EAC9B,KAAK,CACL,CACD,CAAC;QAEF,MAAM,6BAA6B,GAAG,aAAa,CAClD,cAAc,GAAG,qBAAqB,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CACxD,CAAC;QACF,gCAAgC,CAC/B,qBAAqB,EACrB,6BAA6B,EAC7B,wBAAwB,CACvB,qBAAqB,CAAC,IAAI,EAC1B,6BAA6B,EAC7B,KAAK,CACL,CACD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yEAAyE,EAAE,KAAK,IAAI,EAAE;QACxF,gCAAgC,CAC/B,gBAAgB,EAChB,UAAU,EACV,wBAAwB,CAAC,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CACjE,CAAC;QAEF,gCAAgC,CAC/B,kBAAkB,EAClB,UAAU,EACV,wBAAwB,CAAC,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CACnE,CAAC;QAEF,gCAAgC,CAC/B,qBAAqB,EACrB,UAAU,EACV,wBAAwB,CAAC,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CACtE,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\nimport { getUrlAndHeadersWithAuth } from \"../getUrlAndHeadersWithAuth.js\";\n\ndescribe(\"getUrlAndHeadersWithAuth\", () => {\n\tconst baseUrl = \"https://contoso.sharepoint.com/_api/v2.1/drives/driveId/items/itemId/opstream\";\n\tconst urlWithoutParams = new URL(baseUrl);\n\tconst urlWithSingleParam = new URL(`${baseUrl}?someParam=someValue`);\n\tconst urlWithMultipleParams = new URL(`${baseUrl}?param1=value1&param2=value2`);\n\t// decrement by 1 to account for '?' character included in query string\n\tconst maxTokenLength = 2048 - \"access_token=\".length - 1;\n\tconst shortToken = generateToken(10);\n\n\tfunction generateToken(length: number): string {\n\t\treturn \"a\".repeat(length);\n\t}\n\n\tit(\"returns original url if token is null\", async () => {\n\t\tconst { url, headers } = getUrlAndHeadersWithAuth(baseUrl, null, false);\n\t\tassert.strictEqual(url, baseUrl, \"Original and returned urls must match\");\n\t\tassert.deepStrictEqual(headers, {}, \"Returned header must be empty\");\n\t});\n\n\tit(\"returns original url if token is empty\", async () => {\n\t\tconst { url, headers } = getUrlAndHeadersWithAuth(baseUrl, \"\", false);\n\t\tassert.strictEqual(url, baseUrl, \"Original and returned urls must match\");\n\t\tassert.deepStrictEqual(headers, {}, \"Returned header must be empty\");\n\t});\n\n\tconst validateTokenEmbeddedIntoQueryString = (\n\t\toriginalUrl: URL,\n\t\ttoken: string,\n\t\tresult: { url: string; headers: { [index: string]: string } },\n\t): void => {\n\t\tconst returnedUrl = new URL(result.url);\n\t\tassert.strictEqual(\n\t\t\treturnedUrl.searchParams.get(\"access_token\"),\n\t\t\ttoken,\n\t\t\t\"Url must contain token in query string\",\n\t\t);\n\t\tassert.deepStrictEqual(result.headers, {}, \"Returned header must be empty\");\n\t\treturnedUrl.searchParams.delete(\"access_token\");\n\t\tassert.strictEqual(\n\t\t\treturnedUrl.href,\n\t\t\toriginalUrl.href,\n\t\t\t\"Returned url must match original url\",\n\t\t);\n\t};\n\n\tconst validateTokenEmbeddedIntoHeaders = (\n\t\toriginalUrl: URL,\n\t\ttoken: string,\n\t\tresult: { url: string; headers: { [index: string]: string } },\n\t): void => {\n\t\tconst returnedUrl = new URL(result.url);\n\t\tassert.strictEqual(\n\t\t\treturnedUrl.searchParams.get(\"access_token\"),\n\t\t\tnull,\n\t\t\t\"Url must not contain token in query string\",\n\t\t);\n\t\tassert.strictEqual(\n\t\t\tresult.headers.Authorization.endsWith(token),\n\t\t\ttrue,\n\t\t\t\"Returned header must contain token\",\n\t\t);\n\t\tassert.strictEqual(\n\t\t\treturnedUrl.href,\n\t\t\toriginalUrl.href,\n\t\t\t\"Returned url must match original url\",\n\t\t);\n\t};\n\n\tit(\"returns url with token embedded as part of query string when overall query string does not exceed 2048 characters\", async () => {\n\t\tvalidateTokenEmbeddedIntoQueryString(\n\t\t\turlWithoutParams,\n\t\t\tshortToken,\n\t\t\tgetUrlAndHeadersWithAuth(urlWithoutParams.href, shortToken, false),\n\t\t);\n\n\t\tvalidateTokenEmbeddedIntoQueryString(\n\t\t\turlWithSingleParam,\n\t\t\tshortToken,\n\t\t\tgetUrlAndHeadersWithAuth(urlWithSingleParam.href, shortToken, false),\n\t\t);\n\n\t\tvalidateTokenEmbeddedIntoQueryString(\n\t\t\turlWithMultipleParams,\n\t\t\tshortToken,\n\t\t\tgetUrlAndHeadersWithAuth(urlWithMultipleParams.href, shortToken, false),\n\t\t);\n\n\t\tconst longTokenForUrlWithoutParams = generateToken(maxTokenLength);\n\t\tvalidateTokenEmbeddedIntoQueryString(\n\t\t\turlWithoutParams,\n\t\t\tlongTokenForUrlWithoutParams,\n\t\t\tgetUrlAndHeadersWithAuth(urlWithoutParams.href, longTokenForUrlWithoutParams, false),\n\t\t);\n\n\t\tconst longTokenForUrlWithSingleParam = generateToken(\n\t\t\tmaxTokenLength - urlWithSingleParam.search.length,\n\t\t);\n\t\tvalidateTokenEmbeddedIntoQueryString(\n\t\t\turlWithSingleParam,\n\t\t\tlongTokenForUrlWithSingleParam,\n\t\t\tgetUrlAndHeadersWithAuth(\n\t\t\t\turlWithSingleParam.href,\n\t\t\t\tlongTokenForUrlWithSingleParam,\n\t\t\t\tfalse,\n\t\t\t),\n\t\t);\n\n\t\tconst longTokenForUrlMultipleParams = generateToken(\n\t\t\tmaxTokenLength - urlWithMultipleParams.search.length,\n\t\t);\n\t\tvalidateTokenEmbeddedIntoQueryString(\n\t\t\turlWithMultipleParams,\n\t\t\tlongTokenForUrlMultipleParams,\n\t\t\tgetUrlAndHeadersWithAuth(\n\t\t\t\turlWithMultipleParams.href,\n\t\t\t\tlongTokenForUrlMultipleParams,\n\t\t\t\tfalse,\n\t\t\t),\n\t\t);\n\t});\n\n\tit(\"returns headers with token embedded in Authorization header when overall query string exceeds 2048 characters\", async () => {\n\t\tconst longTokenForUrlWithoutParams = generateToken(maxTokenLength + 1);\n\t\tvalidateTokenEmbeddedIntoHeaders(\n\t\t\turlWithoutParams,\n\t\t\tlongTokenForUrlWithoutParams,\n\t\t\tgetUrlAndHeadersWithAuth(urlWithoutParams.href, longTokenForUrlWithoutParams, false),\n\t\t);\n\n\t\tconst longTokenForUrlWithSingleParam = generateToken(\n\t\t\tmaxTokenLength - urlWithSingleParam.search.length + 1,\n\t\t);\n\t\tvalidateTokenEmbeddedIntoHeaders(\n\t\t\turlWithSingleParam,\n\t\t\tlongTokenForUrlWithSingleParam,\n\t\t\tgetUrlAndHeadersWithAuth(\n\t\t\t\turlWithSingleParam.href,\n\t\t\t\tlongTokenForUrlWithSingleParam,\n\t\t\t\tfalse,\n\t\t\t),\n\t\t);\n\n\t\tconst longTokenForUrlMultipleParams = generateToken(\n\t\t\tmaxTokenLength - urlWithMultipleParams.search.length + 1,\n\t\t);\n\t\tvalidateTokenEmbeddedIntoHeaders(\n\t\t\turlWithMultipleParams,\n\t\t\tlongTokenForUrlMultipleParams,\n\t\t\tgetUrlAndHeadersWithAuth(\n\t\t\t\turlWithMultipleParams.href,\n\t\t\t\tlongTokenForUrlMultipleParams,\n\t\t\t\tfalse,\n\t\t\t),\n\t\t);\n\t});\n\n\tit(\"returns headers with token embedded in Authorization header when forced\", async () => {\n\t\tvalidateTokenEmbeddedIntoHeaders(\n\t\t\turlWithoutParams,\n\t\t\tshortToken,\n\t\t\tgetUrlAndHeadersWithAuth(urlWithoutParams.href, shortToken, true),\n\t\t);\n\n\t\tvalidateTokenEmbeddedIntoHeaders(\n\t\t\turlWithSingleParam,\n\t\t\tshortToken,\n\t\t\tgetUrlAndHeadersWithAuth(urlWithSingleParam.href, shortToken, true),\n\t\t);\n\n\t\tvalidateTokenEmbeddedIntoHeaders(\n\t\t\turlWithMultipleParams,\n\t\t\tshortToken,\n\t\t\tgetUrlAndHeadersWithAuth(urlWithMultipleParams.href, shortToken, true),\n\t\t);\n\t});\n});\n"]}
@@ -0,0 +1,284 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { strict as assert } from "node:assert";
6
+ import { maximumCacheDurationMs, } from "@fluidframework/odsp-driver-definitions";
7
+ import { createChildLogger } from "@fluidframework/telemetry-utils";
8
+ import { delay } from "@fluidframework/core-utils";
9
+ import { EpochTracker } from "../epochTracker.js";
10
+ import { persistedCacheValueVersion, } from "../contracts.js";
11
+ import { LocalPersistentCache, NonPersistentCache } from "../odspCache.js";
12
+ import { createOdspUrl } from "../createOdspUrl.js";
13
+ import { getHashedDocumentId } from "../odspPublicUtils.js";
14
+ import { OdspDriverUrlResolver } from "../odspDriverUrlResolver.js";
15
+ import { OdspDocumentStorageService, defaultSummarizerCacheExpiryTimeout, } from "../odspDocumentStorageManager.js";
16
+ import { mockFetchSingle, notFound, createResponse } from "./mockFetch.js";
17
+ const createUtLocalCache = () => new LocalPersistentCache();
18
+ describe("Tests for snapshot fetch", () => {
19
+ const siteUrl = "https://microsoft.sharepoint-df.com/siteUrl";
20
+ const driveId = "driveId";
21
+ const itemId = "itemId";
22
+ const filePath = "path";
23
+ let epochTracker;
24
+ let localCache;
25
+ let hashedDocumentId;
26
+ let service;
27
+ const resolvedUrl = {
28
+ siteUrl,
29
+ driveId,
30
+ itemId,
31
+ odspResolvedUrl: true,
32
+ };
33
+ const newFileParams = {
34
+ type: "New",
35
+ driveId,
36
+ siteUrl: "https://www.localhost.xxx",
37
+ filePath,
38
+ filename: "filename",
39
+ };
40
+ function GetHostStoragePolicyInternal(isSummarizer = false) {
41
+ return {
42
+ snapshotOptions: { timeout: 2000 },
43
+ summarizerClient: isSummarizer,
44
+ fetchBinarySnapshotFormat: false,
45
+ // for testing both network and cache fetch
46
+ concurrentSnapshotFetch: true,
47
+ };
48
+ }
49
+ const resolver = new OdspDriverUrlResolver();
50
+ const nonPersistentCache = new NonPersistentCache();
51
+ const logger = createChildLogger();
52
+ const odspUrl = createOdspUrl({ ...newFileParams, itemId, dataStorePath: "/" });
53
+ const odspSnapshot = {
54
+ id: "id",
55
+ trees: [
56
+ {
57
+ entries: [{ path: "path", type: "tree" }],
58
+ id: "id",
59
+ sequenceNumber: 1,
60
+ },
61
+ ],
62
+ blobs: [],
63
+ };
64
+ const content = {
65
+ snapshotTree: {
66
+ id: "id",
67
+ blobs: {},
68
+ trees: {},
69
+ },
70
+ blobContents: new Map(),
71
+ ops: [],
72
+ sequenceNumber: 0,
73
+ latestSequenceNumber: 0,
74
+ snapshotFormatV: 1,
75
+ };
76
+ const value = {
77
+ value: { ...content, cacheEntryTime: Date.now() },
78
+ fluidEpoch: "epoch1",
79
+ version: persistedCacheValueVersion,
80
+ };
81
+ // Set the cacheEntryTime to anything greater than the current maxCacheAge
82
+ function valueWithExpiredCache(cacheExpiryTimeoutMs) {
83
+ const versionedValue = {
84
+ value: { ...content, cacheEntryTime: Date.now() - cacheExpiryTimeoutMs - 1000 },
85
+ fluidEpoch: "epoch1",
86
+ version: persistedCacheValueVersion,
87
+ };
88
+ return versionedValue;
89
+ }
90
+ const expectedVersion = [{ id: "id", treeId: undefined }];
91
+ before(async () => {
92
+ hashedDocumentId = await getHashedDocumentId(driveId, itemId);
93
+ });
94
+ describe("Tests for caching of different file versions", () => {
95
+ beforeEach(async () => {
96
+ localCache = createUtLocalCache();
97
+ const resolvedUrlWithFileVersion = {
98
+ siteUrl,
99
+ driveId,
100
+ itemId,
101
+ odspResolvedUrl: true,
102
+ fileVersion: "2",
103
+ type: "fluid",
104
+ url: "",
105
+ hashedDocumentId,
106
+ endpoints: {
107
+ snapshotStorageUrl: "fake",
108
+ attachmentPOSTStorageUrl: "",
109
+ attachmentGETStorageUrl: "",
110
+ deltaStorageUrl: "",
111
+ },
112
+ tokens: {},
113
+ fileName: "",
114
+ summarizer: false,
115
+ id: "id",
116
+ };
117
+ epochTracker = new EpochTracker(localCache, {
118
+ docId: hashedDocumentId,
119
+ resolvedUrl,
120
+ }, createChildLogger());
121
+ service = new OdspDocumentStorageService(resolvedUrlWithFileVersion, async (_options) => "token", logger, true, { ...nonPersistentCache, persistedCache: epochTracker }, GetHostStoragePolicyInternal(), epochTracker, async () => {
122
+ return {};
123
+ }, () => "tenantid/id", undefined);
124
+ });
125
+ afterEach(async () => {
126
+ await epochTracker.removeEntries().catch(() => { });
127
+ });
128
+ it("should not fetch from cache with the same snapshot", async () => {
129
+ const latestContent = {
130
+ snapshotTree: {
131
+ id: "WrongId",
132
+ blobs: {},
133
+ trees: {},
134
+ },
135
+ blobContents: new Map(),
136
+ ops: [],
137
+ sequenceNumber: 0,
138
+ latestSequenceNumber: 0,
139
+ snapshotFormatV: 1,
140
+ };
141
+ const latestValue = {
142
+ value: { ...latestContent, cacheEntryTime: Date.now() },
143
+ fluidEpoch: "epoch1",
144
+ version: persistedCacheValueVersion,
145
+ };
146
+ const cacheEntry = {
147
+ key: "",
148
+ type: "snapshot",
149
+ file: { docId: hashedDocumentId, resolvedUrl },
150
+ };
151
+ await localCache.put(cacheEntry, latestValue);
152
+ const version = await mockFetchSingle(async () => service.getVersions(null, 1), async () => {
153
+ await delay(50); // insure cache response is faster
154
+ return createResponse({ "x-fluid-epoch": "epoch1", "content-type": "application/json" }, odspSnapshot, 200);
155
+ });
156
+ assert.deepStrictEqual(version, expectedVersion, "incorrect version");
157
+ });
158
+ });
159
+ describe("Tests for regular snapshot fetch", () => {
160
+ beforeEach(async () => {
161
+ localCache = createUtLocalCache();
162
+ // use null logger here as we expect errors
163
+ epochTracker = new EpochTracker(localCache, {
164
+ docId: hashedDocumentId,
165
+ resolvedUrl,
166
+ }, createChildLogger());
167
+ const resolved = await resolver.resolve({ url: odspUrl });
168
+ service = new OdspDocumentStorageService(resolved, async (_options) => "token", logger, true, { ...nonPersistentCache, persistedCache: epochTracker }, GetHostStoragePolicyInternal(), epochTracker, async () => {
169
+ return {};
170
+ }, () => "tenantid/id", undefined);
171
+ });
172
+ afterEach(async () => {
173
+ await epochTracker.removeEntries().catch(() => { });
174
+ });
175
+ it("cache fetch throws and network fetch succeeds", async () => {
176
+ // overwriting get() to make cache fetch throw
177
+ localCache.get = async () => {
178
+ throw new Error("testing");
179
+ };
180
+ const version = await mockFetchSingle(async () => service.getVersions(null, 1), async () => createResponse({ "x-fluid-epoch": "epoch1", "content-type": "application/json" }, odspSnapshot, 200));
181
+ assert.deepStrictEqual(version, expectedVersion, "incorrect version");
182
+ });
183
+ it("cache fetch succeeds and network fetch succeeds", async () => {
184
+ const cacheEntry = {
185
+ key: "",
186
+ type: "snapshot",
187
+ file: { docId: hashedDocumentId, resolvedUrl },
188
+ };
189
+ await localCache.put(cacheEntry, value);
190
+ const version = await mockFetchSingle(async () => service.getVersions(null, 1), async () => createResponse({ "x-fluid-epoch": "epoch1" }, odspSnapshot, 200));
191
+ assert.deepStrictEqual(version, expectedVersion, "incorrect version");
192
+ });
193
+ it("cache fetch throws and network fetch throws", async () => {
194
+ // overwriting get() to make cache fetch throw
195
+ localCache.get = async () => {
196
+ throw new Error("testing");
197
+ };
198
+ await assert.rejects(async () => {
199
+ await mockFetchSingle(async () => service.getVersions(null, 1),
200
+ // 404 response expected so network fetch throws
201
+ notFound);
202
+ }, /404/, "Expected 404 error to be thrown");
203
+ });
204
+ it("cache fetch succeeds and network fetch throws", async () => {
205
+ const cacheEntry = {
206
+ key: "",
207
+ type: "snapshot",
208
+ file: { docId: hashedDocumentId, resolvedUrl },
209
+ };
210
+ await localCache.put(cacheEntry, value);
211
+ const version = await mockFetchSingle(async () => service.getVersions(null, 1),
212
+ // 404 response expected so network fetch throws
213
+ notFound);
214
+ assert.deepStrictEqual(version, expectedVersion, "incorrect version");
215
+ });
216
+ it("empty cache and network fetch throws", async () => {
217
+ await assert.rejects(async () => {
218
+ await mockFetchSingle(async () => service.getVersions(null, 1),
219
+ // 404 response expected so network fetch throws
220
+ notFound);
221
+ }, /404/, "Expected 404 error to be thrown");
222
+ });
223
+ it("cache expires and network fetch succeeds", async () => {
224
+ const cacheEntry = {
225
+ key: "",
226
+ type: "snapshot",
227
+ file: { docId: hashedDocumentId, resolvedUrl },
228
+ };
229
+ await localCache.put(cacheEntry, valueWithExpiredCache(maximumCacheDurationMs));
230
+ const version = await mockFetchSingle(async () => service.getVersions(null, 1), async () => createResponse({ "x-fluid-epoch": "epoch1", "content-type": "application/json" }, odspSnapshot, 200));
231
+ assert.deepStrictEqual(version, expectedVersion, "incorrect version");
232
+ });
233
+ it("cache expires and network fetch throws", async () => {
234
+ const cacheEntry = {
235
+ key: "",
236
+ type: "snapshot",
237
+ file: { docId: hashedDocumentId, resolvedUrl },
238
+ };
239
+ await localCache.put(cacheEntry, valueWithExpiredCache(maximumCacheDurationMs));
240
+ await assert.rejects(async () => {
241
+ await mockFetchSingle(async () => service.getVersions(null, 1),
242
+ // 404 response expected so network fetch throws
243
+ notFound);
244
+ }, /404/, "Expected 404 error to be thrown");
245
+ });
246
+ });
247
+ describe("Tests for snapshot fetch as Summarizer", () => {
248
+ beforeEach(async () => {
249
+ localCache = createUtLocalCache();
250
+ // use null logger here as we expect errors
251
+ epochTracker = new EpochTracker(localCache, {
252
+ docId: hashedDocumentId,
253
+ resolvedUrl,
254
+ }, createChildLogger());
255
+ const resolved = await resolver.resolve({ url: odspUrl });
256
+ service = new OdspDocumentStorageService(resolved, async (_options) => "token", logger, true, { ...nonPersistentCache, persistedCache: epochTracker }, GetHostStoragePolicyInternal(true /* isSummarizer */), epochTracker, async () => {
257
+ return {};
258
+ }, () => "tenantid/id");
259
+ });
260
+ afterEach(async () => {
261
+ await epochTracker.removeEntries().catch(() => { });
262
+ });
263
+ it("cache expires and network fetch succeeds", async () => {
264
+ const cacheEntry = {
265
+ key: "",
266
+ type: "snapshot",
267
+ file: { docId: hashedDocumentId, resolvedUrl },
268
+ };
269
+ await localCache.put(cacheEntry, valueWithExpiredCache(defaultSummarizerCacheExpiryTimeout));
270
+ const version = await mockFetchSingle(async () => service.getVersions(null, 1), async () => createResponse({ "x-fluid-epoch": "epoch1", "content-type": "application/json" }, odspSnapshot, 200));
271
+ assert.deepStrictEqual(version, expectedVersion, "incorrect version");
272
+ });
273
+ it("cache fetch succeeds", async () => {
274
+ const cacheEntry = {
275
+ key: "",
276
+ type: "snapshot",
277
+ file: { docId: hashedDocumentId, resolvedUrl },
278
+ };
279
+ await localCache.put(cacheEntry, valueWithExpiredCache(defaultSummarizerCacheExpiryTimeout - 5000));
280
+ assert.notEqual(cacheEntry, undefined, "Cache should have been restored");
281
+ });
282
+ });
283
+ });
284
+ //# sourceMappingURL=getVersions.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getVersions.spec.js","sourceRoot":"","sources":["../../src/test/getVersions.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAGN,sBAAsB,GACtB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAIN,0BAA0B,GAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAA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CAAC,UAAU,EAAE,SAAS,EAAE,iCAAiC,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\nimport { ISnapshot } from \"@fluidframework/driver-definitions\";\nimport {\n\tIOdspResolvedUrl,\n\tICacheEntry,\n\tmaximumCacheDurationMs,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { delay } from \"@fluidframework/core-utils\";\nimport { EpochTracker } from \"../epochTracker.js\";\nimport {\n\tIOdspSnapshot,\n\tHostStoragePolicyInternal,\n\tIVersionedValueWithEpoch,\n\tpersistedCacheValueVersion,\n} from \"../contracts.js\";\nimport { LocalPersistentCache, NonPersistentCache } from \"../odspCache.js\";\nimport { INewFileInfo } from \"../odspUtils.js\";\nimport { createOdspUrl } from \"../createOdspUrl.js\";\nimport { getHashedDocumentId } from \"../odspPublicUtils.js\";\nimport { OdspDriverUrlResolver } from \"../odspDriverUrlResolver.js\";\nimport {\n\tOdspDocumentStorageService,\n\tdefaultSummarizerCacheExpiryTimeout,\n} from \"../odspDocumentStorageManager.js\";\nimport { mockFetchSingle, notFound, createResponse } from \"./mockFetch.js\";\n\nconst createUtLocalCache = (): LocalPersistentCache => new LocalPersistentCache();\n\ndescribe(\"Tests for snapshot fetch\", () => {\n\tconst siteUrl = \"https://microsoft.sharepoint-df.com/siteUrl\";\n\tconst driveId = \"driveId\";\n\tconst itemId = \"itemId\";\n\tconst filePath = \"path\";\n\tlet epochTracker: EpochTracker;\n\tlet localCache: LocalPersistentCache;\n\tlet hashedDocumentId: string;\n\tlet service: OdspDocumentStorageService;\n\n\tconst resolvedUrl = {\n\t\tsiteUrl,\n\t\tdriveId,\n\t\titemId,\n\t\todspResolvedUrl: true,\n\t} as unknown as IOdspResolvedUrl;\n\n\tconst newFileParams: INewFileInfo = {\n\t\ttype: \"New\",\n\t\tdriveId,\n\t\tsiteUrl: \"https://www.localhost.xxx\",\n\t\tfilePath,\n\t\tfilename: \"filename\",\n\t};\n\n\tfunction GetHostStoragePolicyInternal(\n\t\tisSummarizer: boolean = false,\n\t): HostStoragePolicyInternal {\n\t\treturn {\n\t\t\tsnapshotOptions: { timeout: 2000 },\n\t\t\tsummarizerClient: isSummarizer,\n\t\t\tfetchBinarySnapshotFormat: false,\n\t\t\t// for testing both network and cache fetch\n\t\t\tconcurrentSnapshotFetch: true,\n\t\t};\n\t}\n\tconst resolver = new OdspDriverUrlResolver();\n\tconst nonPersistentCache = new NonPersistentCache();\n\tconst logger = createChildLogger();\n\tconst odspUrl = createOdspUrl({ ...newFileParams, itemId, dataStorePath: \"/\" });\n\n\tconst odspSnapshot: IOdspSnapshot = {\n\t\tid: \"id\",\n\t\ttrees: [\n\t\t\t{\n\t\t\t\tentries: [{ path: \"path\", type: \"tree\" }],\n\t\t\t\tid: \"id\",\n\t\t\t\tsequenceNumber: 1,\n\t\t\t},\n\t\t],\n\t\tblobs: [],\n\t};\n\n\tconst content: ISnapshot = {\n\t\tsnapshotTree: {\n\t\t\tid: \"id\",\n\t\t\tblobs: {},\n\t\t\ttrees: {},\n\t\t},\n\t\tblobContents: new Map(),\n\t\tops: [],\n\t\tsequenceNumber: 0,\n\t\tlatestSequenceNumber: 0,\n\t\tsnapshotFormatV: 1,\n\t};\n\n\tconst value: IVersionedValueWithEpoch = {\n\t\tvalue: { ...content, cacheEntryTime: Date.now() },\n\t\tfluidEpoch: \"epoch1\",\n\t\tversion: persistedCacheValueVersion,\n\t};\n\n\t// Set the cacheEntryTime to anything greater than the current maxCacheAge\n\tfunction valueWithExpiredCache(cacheExpiryTimeoutMs: number): IVersionedValueWithEpoch {\n\t\tconst versionedValue: IVersionedValueWithEpoch = {\n\t\t\tvalue: { ...content, cacheEntryTime: Date.now() - cacheExpiryTimeoutMs - 1000 },\n\t\t\tfluidEpoch: \"epoch1\",\n\t\t\tversion: persistedCacheValueVersion,\n\t\t};\n\t\treturn versionedValue;\n\t}\n\tconst expectedVersion = [{ id: \"id\", treeId: undefined! }];\n\n\tbefore(async () => {\n\t\thashedDocumentId = await getHashedDocumentId(driveId, itemId);\n\t});\n\n\tdescribe(\"Tests for caching of different file versions\", () => {\n\t\tbeforeEach(async () => {\n\t\t\tlocalCache = createUtLocalCache();\n\t\t\tconst resolvedUrlWithFileVersion: IOdspResolvedUrl = {\n\t\t\t\tsiteUrl,\n\t\t\t\tdriveId,\n\t\t\t\titemId,\n\t\t\t\todspResolvedUrl: true,\n\t\t\t\tfileVersion: \"2\",\n\t\t\t\ttype: \"fluid\",\n\t\t\t\turl: \"\",\n\t\t\t\thashedDocumentId,\n\t\t\t\tendpoints: {\n\t\t\t\t\tsnapshotStorageUrl: \"fake\",\n\t\t\t\t\tattachmentPOSTStorageUrl: \"\",\n\t\t\t\t\tattachmentGETStorageUrl: \"\",\n\t\t\t\t\tdeltaStorageUrl: \"\",\n\t\t\t\t},\n\t\t\t\ttokens: {},\n\t\t\t\tfileName: \"\",\n\t\t\t\tsummarizer: false,\n\t\t\t\tid: \"id\",\n\t\t\t};\n\n\t\t\tepochTracker = new EpochTracker(\n\t\t\t\tlocalCache,\n\t\t\t\t{\n\t\t\t\t\tdocId: hashedDocumentId,\n\t\t\t\t\tresolvedUrl,\n\t\t\t\t},\n\t\t\t\tcreateChildLogger(),\n\t\t\t);\n\n\t\t\tservice = new OdspDocumentStorageService(\n\t\t\t\tresolvedUrlWithFileVersion,\n\t\t\t\tasync (_options) => \"token\",\n\t\t\t\tlogger,\n\t\t\t\ttrue,\n\t\t\t\t{ ...nonPersistentCache, persistedCache: epochTracker },\n\t\t\t\tGetHostStoragePolicyInternal(),\n\t\t\t\tepochTracker,\n\t\t\t\tasync () => {\n\t\t\t\t\treturn {};\n\t\t\t\t},\n\t\t\t\t() => \"tenantid/id\",\n\t\t\t\tundefined,\n\t\t\t);\n\t\t});\n\n\t\tafterEach(async () => {\n\t\t\tawait epochTracker.removeEntries().catch(() => {});\n\t\t});\n\n\t\tit(\"should not fetch from cache with the same snapshot\", async () => {\n\t\t\tconst latestContent: ISnapshot = {\n\t\t\t\tsnapshotTree: {\n\t\t\t\t\tid: \"WrongId\",\n\t\t\t\t\tblobs: {},\n\t\t\t\t\ttrees: {},\n\t\t\t\t},\n\t\t\t\tblobContents: new Map(),\n\t\t\t\tops: [],\n\t\t\t\tsequenceNumber: 0,\n\t\t\t\tlatestSequenceNumber: 0,\n\t\t\t\tsnapshotFormatV: 1,\n\t\t\t};\n\n\t\t\tconst latestValue: IVersionedValueWithEpoch = {\n\t\t\t\tvalue: { ...latestContent, cacheEntryTime: Date.now() },\n\t\t\t\tfluidEpoch: \"epoch1\",\n\t\t\t\tversion: persistedCacheValueVersion,\n\t\t\t};\n\n\t\t\tconst cacheEntry: ICacheEntry = {\n\t\t\t\tkey: \"\",\n\t\t\t\ttype: \"snapshot\",\n\t\t\t\tfile: { docId: hashedDocumentId, resolvedUrl },\n\t\t\t};\n\n\t\t\tawait localCache.put(cacheEntry, latestValue);\n\n\t\t\tconst version = await mockFetchSingle(\n\t\t\t\tasync () => service.getVersions(null, 1),\n\t\t\t\tasync () => {\n\t\t\t\t\tawait delay(50); // insure cache response is faster\n\t\t\t\t\treturn createResponse(\n\t\t\t\t\t\t{ \"x-fluid-epoch\": \"epoch1\", \"content-type\": \"application/json\" },\n\t\t\t\t\t\todspSnapshot,\n\t\t\t\t\t\t200,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tassert.deepStrictEqual(version, expectedVersion, \"incorrect version\");\n\t\t});\n\t});\n\n\tdescribe(\"Tests for regular snapshot fetch\", () => {\n\t\tbeforeEach(async () => {\n\t\t\tlocalCache = createUtLocalCache();\n\t\t\t// use null logger here as we expect errors\n\t\t\tepochTracker = new EpochTracker(\n\t\t\t\tlocalCache,\n\t\t\t\t{\n\t\t\t\t\tdocId: hashedDocumentId,\n\t\t\t\t\tresolvedUrl,\n\t\t\t\t},\n\t\t\t\tcreateChildLogger(),\n\t\t\t);\n\n\t\t\tconst resolved = await resolver.resolve({ url: odspUrl });\n\t\t\tservice = new OdspDocumentStorageService(\n\t\t\t\tresolved,\n\t\t\t\tasync (_options) => \"token\",\n\t\t\t\tlogger,\n\t\t\t\ttrue,\n\t\t\t\t{ ...nonPersistentCache, persistedCache: epochTracker },\n\t\t\t\tGetHostStoragePolicyInternal(),\n\t\t\t\tepochTracker,\n\t\t\t\tasync () => {\n\t\t\t\t\treturn {};\n\t\t\t\t},\n\t\t\t\t() => \"tenantid/id\",\n\t\t\t\tundefined,\n\t\t\t);\n\t\t});\n\n\t\tafterEach(async () => {\n\t\t\tawait epochTracker.removeEntries().catch(() => {});\n\t\t});\n\n\t\tit(\"cache fetch throws and network fetch succeeds\", async () => {\n\t\t\t// overwriting get() to make cache fetch throw\n\t\t\tlocalCache.get = async (): Promise<void> => {\n\t\t\t\tthrow new Error(\"testing\");\n\t\t\t};\n\n\t\t\tconst version = await mockFetchSingle(\n\t\t\t\tasync () => service.getVersions(null, 1),\n\t\t\t\tasync () =>\n\t\t\t\t\tcreateResponse(\n\t\t\t\t\t\t{ \"x-fluid-epoch\": \"epoch1\", \"content-type\": \"application/json\" },\n\t\t\t\t\t\todspSnapshot,\n\t\t\t\t\t\t200,\n\t\t\t\t\t),\n\t\t\t);\n\n\t\t\tassert.deepStrictEqual(version, expectedVersion, \"incorrect version\");\n\t\t});\n\n\t\tit(\"cache fetch succeeds and network fetch succeeds\", async () => {\n\t\t\tconst cacheEntry: ICacheEntry = {\n\t\t\t\tkey: \"\",\n\t\t\t\ttype: \"snapshot\",\n\t\t\t\tfile: { docId: hashedDocumentId, resolvedUrl },\n\t\t\t};\n\t\t\tawait localCache.put(cacheEntry, value);\n\n\t\t\tconst version = await mockFetchSingle(\n\t\t\t\tasync () => service.getVersions(null, 1),\n\t\t\t\tasync () => createResponse({ \"x-fluid-epoch\": \"epoch1\" }, odspSnapshot, 200),\n\t\t\t);\n\t\t\tassert.deepStrictEqual(version, expectedVersion, \"incorrect version\");\n\t\t});\n\n\t\tit(\"cache fetch throws and network fetch throws\", async () => {\n\t\t\t// overwriting get() to make cache fetch throw\n\t\t\tlocalCache.get = async (): Promise<void> => {\n\t\t\t\tthrow new Error(\"testing\");\n\t\t\t};\n\n\t\t\tawait assert.rejects(\n\t\t\t\tasync () => {\n\t\t\t\t\tawait mockFetchSingle(\n\t\t\t\t\t\tasync () => service.getVersions(null, 1),\n\t\t\t\t\t\t// 404 response expected so network fetch throws\n\t\t\t\t\t\tnotFound,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t/404/,\n\t\t\t\t\"Expected 404 error to be thrown\",\n\t\t\t);\n\t\t});\n\n\t\tit(\"cache fetch succeeds and network fetch throws\", async () => {\n\t\t\tconst cacheEntry: ICacheEntry = {\n\t\t\t\tkey: \"\",\n\t\t\t\ttype: \"snapshot\",\n\t\t\t\tfile: { docId: hashedDocumentId, resolvedUrl },\n\t\t\t};\n\t\t\tawait localCache.put(cacheEntry, value);\n\n\t\t\tconst version = await mockFetchSingle(\n\t\t\t\tasync () => service.getVersions(null, 1),\n\t\t\t\t// 404 response expected so network fetch throws\n\t\t\t\tnotFound,\n\t\t\t);\n\t\t\tassert.deepStrictEqual(version, expectedVersion, \"incorrect version\");\n\t\t});\n\n\t\tit(\"empty cache and network fetch throws\", async () => {\n\t\t\tawait assert.rejects(\n\t\t\t\tasync () => {\n\t\t\t\t\tawait mockFetchSingle(\n\t\t\t\t\t\tasync () => service.getVersions(null, 1),\n\t\t\t\t\t\t// 404 response expected so network fetch throws\n\t\t\t\t\t\tnotFound,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t/404/,\n\t\t\t\t\"Expected 404 error to be thrown\",\n\t\t\t);\n\t\t});\n\n\t\tit(\"cache expires and network fetch succeeds\", async () => {\n\t\t\tconst cacheEntry: ICacheEntry = {\n\t\t\t\tkey: \"\",\n\t\t\t\ttype: \"snapshot\",\n\t\t\t\tfile: { docId: hashedDocumentId, resolvedUrl },\n\t\t\t};\n\t\t\tawait localCache.put(cacheEntry, valueWithExpiredCache(maximumCacheDurationMs));\n\n\t\t\tconst version = await mockFetchSingle(\n\t\t\t\tasync () => service.getVersions(null, 1),\n\t\t\t\tasync () =>\n\t\t\t\t\tcreateResponse(\n\t\t\t\t\t\t{ \"x-fluid-epoch\": \"epoch1\", \"content-type\": \"application/json\" },\n\t\t\t\t\t\todspSnapshot,\n\t\t\t\t\t\t200,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tassert.deepStrictEqual(version, expectedVersion, \"incorrect version\");\n\t\t});\n\n\t\tit(\"cache expires and network fetch throws\", async () => {\n\t\t\tconst cacheEntry: ICacheEntry = {\n\t\t\t\tkey: \"\",\n\t\t\t\ttype: \"snapshot\",\n\t\t\t\tfile: { docId: hashedDocumentId, resolvedUrl },\n\t\t\t};\n\t\t\tawait localCache.put(cacheEntry, valueWithExpiredCache(maximumCacheDurationMs));\n\n\t\t\tawait assert.rejects(\n\t\t\t\tasync () => {\n\t\t\t\t\tawait mockFetchSingle(\n\t\t\t\t\t\tasync () => service.getVersions(null, 1),\n\t\t\t\t\t\t// 404 response expected so network fetch throws\n\t\t\t\t\t\tnotFound,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t/404/,\n\t\t\t\t\"Expected 404 error to be thrown\",\n\t\t\t);\n\t\t});\n\t});\n\tdescribe(\"Tests for snapshot fetch as Summarizer\", () => {\n\t\tbeforeEach(async () => {\n\t\t\tlocalCache = createUtLocalCache();\n\t\t\t// use null logger here as we expect errors\n\t\t\tepochTracker = new EpochTracker(\n\t\t\t\tlocalCache,\n\t\t\t\t{\n\t\t\t\t\tdocId: hashedDocumentId,\n\t\t\t\t\tresolvedUrl,\n\t\t\t\t},\n\t\t\t\tcreateChildLogger(),\n\t\t\t);\n\n\t\t\tconst resolved = await resolver.resolve({ url: odspUrl });\n\t\t\tservice = new OdspDocumentStorageService(\n\t\t\t\tresolved,\n\t\t\t\tasync (_options) => \"token\",\n\t\t\t\tlogger,\n\t\t\t\ttrue,\n\t\t\t\t{ ...nonPersistentCache, persistedCache: epochTracker },\n\t\t\t\tGetHostStoragePolicyInternal(true /* isSummarizer */),\n\t\t\t\tepochTracker,\n\t\t\t\tasync () => {\n\t\t\t\t\treturn {};\n\t\t\t\t},\n\t\t\t\t() => \"tenantid/id\",\n\t\t\t);\n\t\t});\n\n\t\tafterEach(async () => {\n\t\t\tawait epochTracker.removeEntries().catch(() => {});\n\t\t});\n\n\t\tit(\"cache expires and network fetch succeeds\", async () => {\n\t\t\tconst cacheEntry: ICacheEntry = {\n\t\t\t\tkey: \"\",\n\t\t\t\ttype: \"snapshot\",\n\t\t\t\tfile: { docId: hashedDocumentId, resolvedUrl },\n\t\t\t};\n\t\t\tawait localCache.put(\n\t\t\t\tcacheEntry,\n\t\t\t\tvalueWithExpiredCache(defaultSummarizerCacheExpiryTimeout),\n\t\t\t);\n\n\t\t\tconst version = await mockFetchSingle(\n\t\t\t\tasync () => service.getVersions(null, 1),\n\t\t\t\tasync () =>\n\t\t\t\t\tcreateResponse(\n\t\t\t\t\t\t{ \"x-fluid-epoch\": \"epoch1\", \"content-type\": \"application/json\" },\n\t\t\t\t\t\todspSnapshot,\n\t\t\t\t\t\t200,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tassert.deepStrictEqual(version, expectedVersion, \"incorrect version\");\n\t\t});\n\n\t\tit(\"cache fetch succeeds\", async () => {\n\t\t\tconst cacheEntry: ICacheEntry = {\n\t\t\t\tkey: \"\",\n\t\t\t\ttype: \"snapshot\",\n\t\t\t\tfile: { docId: hashedDocumentId, resolvedUrl },\n\t\t\t};\n\t\t\tawait localCache.put(\n\t\t\t\tcacheEntry,\n\t\t\t\tvalueWithExpiredCache(defaultSummarizerCacheExpiryTimeout - 5000),\n\t\t\t);\n\n\t\t\tassert.notEqual(cacheEntry, undefined, \"Cache should have been restored\");\n\t\t});\n\t});\n});\n"]}
@@ -0,0 +1,53 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { strict as assert } from "node:assert";
6
+ import { OdspDocumentServiceFactory } from "../odspDocumentServiceFactory.js";
7
+ import { getJoinSessionCacheKey } from "../odspUtils.js";
8
+ describe("expose joinSessionInfo Tests", () => {
9
+ const siteUrl = "https://www.localhost.xxx";
10
+ const driveId = "driveId";
11
+ const itemId = "itemId";
12
+ const resolvedUrl = {
13
+ siteUrl,
14
+ driveId,
15
+ itemId,
16
+ odspResolvedUrl: true,
17
+ };
18
+ const joinSessionResponse = {
19
+ deltaStorageUrl: "https://fake/deltaStorageUrl",
20
+ deltaStreamSocketUrl: "https://localhost:3001",
21
+ id: "id",
22
+ tenantId: "tenantId",
23
+ snapshotStorageUrl: "https://fake/snapshotStorageUrl",
24
+ refreshSessionDurationSeconds: 100,
25
+ };
26
+ const odspDocumentServiceFactory = new OdspDocumentServiceFactory(async (_options) => "token", async (_options) => "token");
27
+ it("Response missing in join session cache", async () => {
28
+ const info = await odspDocumentServiceFactory.getRelayServiceSessionInfo(resolvedUrl);
29
+ assert(info === undefined, "no cached response");
30
+ });
31
+ it("Response present in join session cache", async () => {
32
+ // eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
33
+ odspDocumentServiceFactory["nonPersistentCache"].sessionJoinCache.add(getJoinSessionCacheKey(resolvedUrl), async () => {
34
+ return { entryTime: Date.now(), joinSessionResponse };
35
+ });
36
+ const info = await odspDocumentServiceFactory.getRelayServiceSessionInfo(resolvedUrl);
37
+ assert.deepStrictEqual(info, joinSessionResponse, "cached response should be present");
38
+ });
39
+ it("should throw error is resolved url is not odspResolvedUrl", async () => {
40
+ let failed = false;
41
+ try {
42
+ await odspDocumentServiceFactory.getRelayServiceSessionInfo({
43
+ ...resolvedUrl,
44
+ odspResolvedUrl: false,
45
+ });
46
+ }
47
+ catch {
48
+ failed = true;
49
+ }
50
+ assert(failed, "resolved url not correct");
51
+ });
52
+ });
53
+ //# sourceMappingURL=joinSessionCacheTests.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"joinSessionCacheTests.spec.js","sourceRoot":"","sources":["../../src/test/joinSessionCacheTests.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC7C,MAAM,OAAO,GAAG,2BAA2B,CAAC;IAC5C,MAAM,OAAO,GAAG,SAAS,CAAC;IAC1B,MAAM,MAAM,GAAG,QAAQ,CAAC;IAExB,MAAM,WAAW,GAAG;QACnB,OAAO;QACP,OAAO;QACP,MAAM;QACN,eAAe,EAAE,IAAI;KACU,CAAC;IAEjC,MAAM,mBAAmB,GAA4B;QACpD,eAAe,EAAE,8BAA8B;QAC/C,oBAAoB,EAAE,wBAAwB;QAC9C,EAAE,EAAE,IAAI;QACR,QAAQ,EAAE,UAAU;QACpB,kBAAkB,EAAE,iCAAiC;QACrD,6BAA6B,EAAE,GAAG;KAClC,CAAC;IACF,MAAM,0BAA0B,GAAG,IAAI,0BAA0B,CAChE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,OAAO,EAC3B,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,OAAO,CAC3B,CAAC;IAEF,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACvD,MAAM,IAAI,GAAG,MAAM,0BAA0B,CAAC,0BAA0B,CAAC,WAAW,CAAC,CAAC;QACtF,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,oBAAoB,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACvD,0IAA0I;QAC1I,0BAA0B,CAAC,oBAAoB,CAAC,CAAC,gBAAgB,CAAC,GAAG,CACpE,sBAAsB,CAAC,WAAW,CAAC,EACnC,KAAK,IAAI,EAAE;YACV,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,mBAAmB,EAAE,CAAC;QACvD,CAAC,CACD,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,0BAA0B,CAAC,0BAA0B,CAAC,WAAW,CAAC,CAAC;QACtF,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,mBAAmB,EAAE,mCAAmC,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;QAC1E,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI;YACH,MAAM,0BAA0B,CAAC,0BAA0B,CAAC;gBAC3D,GAAG,WAAW;gBACd,eAAe,EAAE,KAAK;aACK,CAAC,CAAC;SAC9B;QAAC,MAAM;YACP,MAAM,GAAG,IAAI,CAAC;SACd;QACD,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\nimport type { IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport { IOdspResolvedUrl, ISocketStorageDiscovery } from \"@fluidframework/odsp-driver-definitions\";\nimport { OdspDocumentServiceFactory } from \"../odspDocumentServiceFactory.js\";\nimport { getJoinSessionCacheKey } from \"../odspUtils.js\";\n\ndescribe(\"expose joinSessionInfo Tests\", () => {\n\tconst siteUrl = \"https://www.localhost.xxx\";\n\tconst driveId = \"driveId\";\n\tconst itemId = \"itemId\";\n\n\tconst resolvedUrl = {\n\t\tsiteUrl,\n\t\tdriveId,\n\t\titemId,\n\t\todspResolvedUrl: true,\n\t} as unknown as IOdspResolvedUrl;\n\n\tconst joinSessionResponse: ISocketStorageDiscovery = {\n\t\tdeltaStorageUrl: \"https://fake/deltaStorageUrl\",\n\t\tdeltaStreamSocketUrl: \"https://localhost:3001\",\n\t\tid: \"id\",\n\t\ttenantId: \"tenantId\",\n\t\tsnapshotStorageUrl: \"https://fake/snapshotStorageUrl\",\n\t\trefreshSessionDurationSeconds: 100,\n\t};\n\tconst odspDocumentServiceFactory = new OdspDocumentServiceFactory(\n\t\tasync (_options) => \"token\",\n\t\tasync (_options) => \"token\",\n\t);\n\n\tit(\"Response missing in join session cache\", async () => {\n\t\tconst info = await odspDocumentServiceFactory.getRelayServiceSessionInfo(resolvedUrl);\n\t\tassert(info === undefined, \"no cached response\");\n\t});\n\n\tit(\"Response present in join session cache\", async () => {\n\t\t// eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\todspDocumentServiceFactory[\"nonPersistentCache\"].sessionJoinCache.add(\n\t\t\tgetJoinSessionCacheKey(resolvedUrl),\n\t\t\tasync () => {\n\t\t\t\treturn { entryTime: Date.now(), joinSessionResponse };\n\t\t\t},\n\t\t);\n\t\tconst info = await odspDocumentServiceFactory.getRelayServiceSessionInfo(resolvedUrl);\n\t\tassert.deepStrictEqual(info, joinSessionResponse, \"cached response should be present\");\n\t});\n\n\tit(\"should throw error is resolved url is not odspResolvedUrl\", async () => {\n\t\tlet failed = false;\n\t\ttry {\n\t\t\tawait odspDocumentServiceFactory.getRelayServiceSessionInfo({\n\t\t\t\t...resolvedUrl,\n\t\t\t\todspResolvedUrl: false,\n\t\t\t} as unknown as IResolvedUrl);\n\t\t} catch {\n\t\t\tfailed = true;\n\t\t}\n\t\tassert(failed, \"resolved url not correct\");\n\t});\n});\n"]}
@@ -0,0 +1,158 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { strict as assert } from "node:assert";
6
+ import { MockLogger } from "@fluidframework/telemetry-utils";
7
+ import { stub, useFakeTimers } from "sinon";
8
+ import * as odspDocumentDeltaConnection from "../odspDocumentDeltaConnection.js";
9
+ import * as joinSession from "../vroom.js";
10
+ import { OdspDocumentServiceFactory } from "../odspDocumentServiceFactory.js";
11
+ import { LocalPersistentCache } from "../odspCache.js";
12
+ import { createOdspUrl } from "../createOdspUrl.js";
13
+ import { OdspDriverUrlResolver } from "../odspDriverUrlResolver.js";
14
+ describe("joinSessions Tests", () => {
15
+ let clock;
16
+ const siteUrl = "https://www.localhost.xxx";
17
+ const driveId = "driveId";
18
+ const resolver = new OdspDriverUrlResolver();
19
+ const itemId = "itemId";
20
+ let service;
21
+ let logger;
22
+ const client = {
23
+ mode: "read",
24
+ details: { capabilities: { interactive: true } },
25
+ permission: [],
26
+ user: { id: "id" },
27
+ scopes: [],
28
+ };
29
+ let deltaConnection;
30
+ const joinSessionResponse = {
31
+ deltaStorageUrl: "https://fake/deltaStorageUrl",
32
+ deltaStreamSocketUrl: "https://localhost:3001",
33
+ id: "id",
34
+ tenantId: "tenantId",
35
+ snapshotStorageUrl: "https://fake/snapshotStorageUrl",
36
+ refreshSessionDurationSeconds: 100,
37
+ };
38
+ let odspDocumentServiceFactory;
39
+ // Stash the real setTimeout because sinon fake timers will hijack it.
40
+ const realSetTimeout = setTimeout;
41
+ // function to yield control in the Javascript event loop.
42
+ async function yieldEventLoop() {
43
+ await new Promise((resolve) => {
44
+ realSetTimeout(resolve, 0);
45
+ });
46
+ }
47
+ async function tickClock(tickValue) {
48
+ clock.tick(tickValue);
49
+ // Yield the event loop because the outbound op will be processed asynchronously.
50
+ await yieldEventLoop();
51
+ }
52
+ function addJoinSessionStub(time) {
53
+ joinSessionResponse.refreshSessionDurationSeconds = time;
54
+ const joinSessionStub = stub(joinSession, "fetchJoinSession").callsFake(async () => joinSessionResponse);
55
+ return joinSessionStub;
56
+ }
57
+ before(async () => {
58
+ clock = useFakeTimers();
59
+ });
60
+ beforeEach(async () => {
61
+ odspDocumentServiceFactory = new OdspDocumentServiceFactory(async (_options) => "token", async (_options) => "token", new LocalPersistentCache(2000), { snapshotOptions: { timeout: 2000 } });
62
+ const locator = { driveId, itemId, siteUrl, dataStorePath: "/" };
63
+ const request = createOdspUrl(locator);
64
+ const resolvedUrl = await resolver.resolve({ url: request });
65
+ logger = new MockLogger();
66
+ service = (await odspDocumentServiceFactory.createDocumentService(resolvedUrl, logger));
67
+ deltaConnection = {
68
+ clientId: "clientId",
69
+ existing: true,
70
+ initialClients: [],
71
+ initialMessages: [],
72
+ initialSignals: [],
73
+ version: "1.0",
74
+ mode: "write",
75
+ claims: {
76
+ documentId: "docId",
77
+ exp: 0,
78
+ iat: 0,
79
+ scopes: [],
80
+ tenantId: "ten",
81
+ ver: "ver",
82
+ user: {
83
+ id: "id",
84
+ },
85
+ },
86
+ serviceConfiguration: {
87
+ blockSize: 100,
88
+ maxMessageSize: 16000,
89
+ summary: {
90
+ minIdleTime: 0,
91
+ maxIdleTime: 0,
92
+ maxAckWaitTime: 0,
93
+ maxOps: 100,
94
+ maxTime: 10,
95
+ },
96
+ },
97
+ dispose: () => { },
98
+ disposed: false,
99
+ submit: () => { },
100
+ submitSignal: () => { },
101
+ on: () => { },
102
+ once: () => { },
103
+ };
104
+ });
105
+ it("Check periodic join session call", async () => {
106
+ const createDeltaConnectionStub = stub(odspDocumentDeltaConnection.OdspDocumentDeltaConnection, "create").callsFake(async () => deltaConnection);
107
+ let joinSessionStub = addJoinSessionStub(100);
108
+ await service.connectToDeltaStream(client);
109
+ createDeltaConnectionStub.restore();
110
+ joinSessionStub.restore();
111
+ assert(joinSessionStub.calledOnce, "Should called once on first try");
112
+ // Prepare second response.
113
+ joinSessionStub = addJoinSessionStub(90);
114
+ // Tick 70 seconds so as to get second response.
115
+ await tickClock(70000 - 1);
116
+ assert(joinSessionStub.notCalled, "Should not be called in 69 sec");
117
+ await tickClock(1);
118
+ assert(joinSessionStub.calledOnce, "Should called once on second try");
119
+ joinSessionStub.restore();
120
+ // Prepare third response.
121
+ joinSessionStub = addJoinSessionStub(30);
122
+ // Tick 60 seconds so as to get third response.
123
+ await tickClock(50000);
124
+ assert(joinSessionStub.notCalled, "Should not be called in 50 sec");
125
+ await tickClock(10000);
126
+ assert(joinSessionStub.calledOnce, "Should called once on third try");
127
+ joinSessionStub.restore();
128
+ // Prepare fourth response.
129
+ joinSessionStub = addJoinSessionStub(40);
130
+ // Since last refresh seconds is less than 30 sec, we should not have
131
+ // scheduled the refresh.
132
+ await tickClock(100000);
133
+ assert(joinSessionStub.notCalled, "Should not be called ever");
134
+ joinSessionStub.restore();
135
+ });
136
+ it("Check periodic join session call does not lead to duplicate refresh", async () => {
137
+ const createDeltaConnectionStub = stub(odspDocumentDeltaConnection.OdspDocumentDeltaConnection, "create").callsFake(async () => deltaConnection);
138
+ let joinSessionStub = addJoinSessionStub(100);
139
+ await service.connectToDeltaStream(client);
140
+ createDeltaConnectionStub.restore();
141
+ joinSessionStub.restore();
142
+ assert(joinSessionStub.calledOnce, "Should called once on first try");
143
+ // Prepare second response.
144
+ joinSessionStub = addJoinSessionStub(90);
145
+ // Tick 70 seconds so as to get second response.
146
+ await tickClock(70000);
147
+ assert(joinSessionStub.calledOnce, "Should called once on second try");
148
+ joinSessionStub.restore();
149
+ logger.assertMatchNone([{ eventName: "OdspDriver:DuplicateJoinSessionRefresh" }], "No duplicate join session should be there");
150
+ });
151
+ afterEach(() => {
152
+ clock.reset();
153
+ });
154
+ after(() => {
155
+ clock.restore();
156
+ });
157
+ });
158
+ //# sourceMappingURL=joinSessionPeriodicCall.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"joinSessionPeriodicCall.spec.js","sourceRoot":"","sources":["../../src/test/joinSessionPeriodicCall.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAE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K,IAAI,EAAE;QACpF,MAAM,yBAAyB,GAAG,IAAI,CACrC,2BAA2B,CAAC,2BAA2B,EACvD,QAAQ,CACR,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,eAA8C,CAAC,CAAC;QACxE,IAAI,eAAe,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC9C,MAAM,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC3C,yBAAyB,CAAC,OAAO,EAAE,CAAC;QACpC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC1B,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,iCAAiC,CAAC,CAAC;QAEtE,2BAA2B;QAC3B,eAAe,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAC;QACzC,gDAAgD;QAChD,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;QACvB,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,kCAAkC,CAAC,CAAC;QACvE,eAAe,CAAC,OAAO,EAAE,CAAC;QAC1B,MAAM,CAAC,eAAe,CACrB,CAAC,EAAE,SAAS,EAAE,wCAAwC,EAAE,CAAC,EACzD,2CAA2C,CAC3C,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACd,KAAK,CAAC,KAAK,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,GAAG,EAAE;QACV,KAAK,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport { ISocketStorageDiscovery } from \"@fluidframework/odsp-driver-definitions\";\nimport { MockLogger } from \"@fluidframework/telemetry-utils\";\nimport { stub, useFakeTimers, SinonFakeTimers, SinonStub } from \"sinon\";\nimport * as odspDocumentDeltaConnection from \"../odspDocumentDeltaConnection.js\";\nimport * as joinSession from \"../vroom.js\";\nimport { OdspDocumentServiceFactory } from \"../odspDocumentServiceFactory.js\";\nimport { LocalPersistentCache } from \"../odspCache.js\";\nimport { OdspFluidDataStoreLocator } from \"../contractsPublic.js\";\nimport { createOdspUrl } from \"../createOdspUrl.js\";\nimport { OdspDriverUrlResolver } from \"../odspDriverUrlResolver.js\";\nimport { OdspDocumentService } from \"../odspDocumentService.js\";\nimport { OdspDocumentDeltaConnection } from \"../odspDocumentDeltaConnection.js\";\n\ndescribe(\"joinSessions Tests\", () => {\n\tlet clock: SinonFakeTimers;\n\tconst siteUrl = \"https://www.localhost.xxx\";\n\tconst driveId = \"driveId\";\n\tconst resolver = new OdspDriverUrlResolver();\n\tconst itemId = \"itemId\";\n\tlet service: OdspDocumentService;\n\tlet logger: MockLogger;\n\tconst client: IClient = {\n\t\tmode: \"read\",\n\t\tdetails: { capabilities: { interactive: true } },\n\t\tpermission: [],\n\t\tuser: { id: \"id\" },\n\t\tscopes: [],\n\t};\n\tlet deltaConnection;\n\tconst joinSessionResponse: ISocketStorageDiscovery = {\n\t\tdeltaStorageUrl: \"https://fake/deltaStorageUrl\",\n\t\tdeltaStreamSocketUrl: \"https://localhost:3001\",\n\t\tid: \"id\",\n\t\ttenantId: \"tenantId\",\n\t\tsnapshotStorageUrl: \"https://fake/snapshotStorageUrl\",\n\t\trefreshSessionDurationSeconds: 100,\n\t};\n\tlet odspDocumentServiceFactory: OdspDocumentServiceFactory;\n\n\t// Stash the real setTimeout because sinon fake timers will hijack it.\n\tconst realSetTimeout = setTimeout;\n\n\t// function to yield control in the Javascript event loop.\n\tasync function yieldEventLoop(): Promise<void> {\n\t\tawait new Promise<void>((resolve) => {\n\t\t\trealSetTimeout(resolve, 0);\n\t\t});\n\t}\n\n\tasync function tickClock(tickValue: number): Promise<void> {\n\t\tclock.tick(tickValue);\n\n\t\t// Yield the event loop because the outbound op will be processed asynchronously.\n\t\tawait yieldEventLoop();\n\t}\n\n\tfunction addJoinSessionStub(time: number): SinonStub {\n\t\tjoinSessionResponse.refreshSessionDurationSeconds = time;\n\t\tconst joinSessionStub = stub(joinSession, \"fetchJoinSession\").callsFake(\n\t\t\tasync () => joinSessionResponse,\n\t\t);\n\t\treturn joinSessionStub;\n\t}\n\n\tbefore(async () => {\n\t\tclock = useFakeTimers();\n\t});\n\n\tbeforeEach(async () => {\n\t\todspDocumentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (_options) => \"token\",\n\t\t\tasync (_options) => \"token\",\n\t\t\tnew LocalPersistentCache(2000),\n\t\t\t{ snapshotOptions: { timeout: 2000 } },\n\t\t);\n\t\tconst locator: OdspFluidDataStoreLocator = { driveId, itemId, siteUrl, dataStorePath: \"/\" };\n\t\tconst request = createOdspUrl(locator);\n\t\tconst resolvedUrl = await resolver.resolve({ url: request });\n\t\tlogger = new MockLogger();\n\t\tservice = (await odspDocumentServiceFactory.createDocumentService(\n\t\t\tresolvedUrl,\n\t\t\tlogger,\n\t\t)) as OdspDocumentService;\n\n\t\tdeltaConnection = {\n\t\t\tclientId: \"clientId\",\n\t\t\texisting: true,\n\t\t\tinitialClients: [],\n\t\t\tinitialMessages: [],\n\t\t\tinitialSignals: [],\n\t\t\tversion: \"1.0\",\n\t\t\tmode: \"write\",\n\t\t\tclaims: {\n\t\t\t\tdocumentId: \"docId\",\n\t\t\t\texp: 0,\n\t\t\t\tiat: 0,\n\t\t\t\tscopes: [],\n\t\t\t\ttenantId: \"ten\",\n\t\t\t\tver: \"ver\",\n\t\t\t\tuser: {\n\t\t\t\t\tid: \"id\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tserviceConfiguration: {\n\t\t\t\tblockSize: 100,\n\t\t\t\tmaxMessageSize: 16000,\n\t\t\t\tsummary: {\n\t\t\t\t\tminIdleTime: 0,\n\t\t\t\t\tmaxIdleTime: 0,\n\t\t\t\t\tmaxAckWaitTime: 0,\n\t\t\t\t\tmaxOps: 100,\n\t\t\t\t\tmaxTime: 10,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdispose: (): void => {},\n\t\t\tdisposed: false,\n\t\t\tsubmit: (): void => {},\n\t\t\tsubmitSignal: (): void => {},\n\t\t\ton: (): void => {},\n\t\t\tonce: (): void => {},\n\t\t};\n\t});\n\n\tit(\"Check periodic join session call\", async () => {\n\t\tconst createDeltaConnectionStub = stub(\n\t\t\todspDocumentDeltaConnection.OdspDocumentDeltaConnection,\n\t\t\t\"create\",\n\t\t).callsFake(async () => deltaConnection as OdspDocumentDeltaConnection);\n\t\tlet joinSessionStub = addJoinSessionStub(100);\n\t\tawait service.connectToDeltaStream(client);\n\t\tcreateDeltaConnectionStub.restore();\n\t\tjoinSessionStub.restore();\n\t\tassert(joinSessionStub.calledOnce, \"Should called once on first try\");\n\n\t\t// Prepare second response.\n\t\tjoinSessionStub = addJoinSessionStub(90);\n\t\t// Tick 70 seconds so as to get second response.\n\t\tawait tickClock(70000 - 1);\n\t\tassert(joinSessionStub.notCalled, \"Should not be called in 69 sec\");\n\t\tawait tickClock(1);\n\t\tassert(joinSessionStub.calledOnce, \"Should called once on second try\");\n\t\tjoinSessionStub.restore();\n\n\t\t// Prepare third response.\n\t\tjoinSessionStub = addJoinSessionStub(30);\n\t\t// Tick 60 seconds so as to get third response.\n\t\tawait tickClock(50000);\n\t\tassert(joinSessionStub.notCalled, \"Should not be called in 50 sec\");\n\t\tawait tickClock(10000);\n\t\tassert(joinSessionStub.calledOnce, \"Should called once on third try\");\n\t\tjoinSessionStub.restore();\n\n\t\t// Prepare fourth response.\n\t\tjoinSessionStub = addJoinSessionStub(40);\n\t\t// Since last refresh seconds is less than 30 sec, we should not have\n\t\t// scheduled the refresh.\n\t\tawait tickClock(100000);\n\t\tassert(joinSessionStub.notCalled, \"Should not be called ever\");\n\t\tjoinSessionStub.restore();\n\t});\n\n\tit(\"Check periodic join session call does not lead to duplicate refresh\", async () => {\n\t\tconst createDeltaConnectionStub = stub(\n\t\t\todspDocumentDeltaConnection.OdspDocumentDeltaConnection,\n\t\t\t\"create\",\n\t\t).callsFake(async () => deltaConnection as OdspDocumentDeltaConnection);\n\t\tlet joinSessionStub = addJoinSessionStub(100);\n\t\tawait service.connectToDeltaStream(client);\n\t\tcreateDeltaConnectionStub.restore();\n\t\tjoinSessionStub.restore();\n\t\tassert(joinSessionStub.calledOnce, \"Should called once on first try\");\n\n\t\t// Prepare second response.\n\t\tjoinSessionStub = addJoinSessionStub(90);\n\t\t// Tick 70 seconds so as to get second response.\n\t\tawait tickClock(70000);\n\t\tassert(joinSessionStub.calledOnce, \"Should called once on second try\");\n\t\tjoinSessionStub.restore();\n\t\tlogger.assertMatchNone(\n\t\t\t[{ eventName: \"OdspDriver:DuplicateJoinSessionRefresh\" }],\n\t\t\t\"No duplicate join session should be there\",\n\t\t);\n\t});\n\n\tafterEach(() => {\n\t\tclock.reset();\n\t});\n\n\tafter(() => {\n\t\tclock.restore();\n\t});\n});\n"]}