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

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 (353) hide show
  1. package/dist/WriteBufferUtils.d.ts.map +1 -1
  2. package/dist/WriteBufferUtils.js.map +1 -1
  3. package/dist/compactSnapshotParser.d.ts +1 -1
  4. package/dist/compactSnapshotParser.d.ts.map +1 -1
  5. package/dist/compactSnapshotParser.js +1 -1
  6. package/dist/compactSnapshotParser.js.map +1 -1
  7. package/dist/compactSnapshotWriter.d.ts.map +1 -1
  8. package/dist/compactSnapshotWriter.js +1 -1
  9. package/dist/compactSnapshotWriter.js.map +1 -1
  10. package/dist/contracts.d.ts +2 -2
  11. package/dist/contracts.d.ts.map +1 -1
  12. package/dist/contracts.js.map +1 -1
  13. package/dist/createFile.d.ts +2 -2
  14. package/dist/createFile.d.ts.map +1 -1
  15. package/dist/createFile.js +7 -7
  16. package/dist/createFile.js.map +1 -1
  17. package/dist/createNewContainerOnExistingFile.d.ts +2 -2
  18. package/dist/createNewContainerOnExistingFile.d.ts.map +1 -1
  19. package/dist/createNewContainerOnExistingFile.js +4 -4
  20. package/dist/createNewContainerOnExistingFile.js.map +1 -1
  21. package/dist/createNewUtils.d.ts +2 -2
  22. package/dist/createNewUtils.d.ts.map +1 -1
  23. package/dist/createNewUtils.js +4 -4
  24. package/dist/createNewUtils.js.map +1 -1
  25. package/dist/epochTracker.d.ts +3 -3
  26. package/dist/epochTracker.d.ts.map +1 -1
  27. package/dist/epochTracker.js +4 -4
  28. package/dist/epochTracker.js.map +1 -1
  29. package/dist/fetch.js.map +1 -1
  30. package/dist/fetchSnapshot.d.ts +2 -2
  31. package/dist/fetchSnapshot.d.ts.map +1 -1
  32. package/dist/fetchSnapshot.js +5 -5
  33. package/dist/fetchSnapshot.js.map +1 -1
  34. package/dist/getFileLink.d.ts +1 -1
  35. package/dist/getFileLink.d.ts.map +1 -1
  36. package/dist/getFileLink.js +1 -1
  37. package/dist/getFileLink.js.map +1 -1
  38. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts +1 -1
  39. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -1
  40. package/dist/localOdspDriver/localOdspDeltaStorageService.js +1 -1
  41. package/dist/localOdspDriver/localOdspDeltaStorageService.js.map +1 -1
  42. package/dist/localOdspDriver/localOdspDocumentService.d.ts +1 -1
  43. package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
  44. package/dist/localOdspDriver/localOdspDocumentService.js.map +1 -1
  45. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +1 -1
  46. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
  47. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js +1 -1
  48. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -1
  49. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts +1 -1
  50. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
  51. package/dist/localOdspDriver/localOdspDocumentStorageManager.js +2 -2
  52. package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -1
  53. package/dist/odspCache.d.ts +1 -1
  54. package/dist/odspCache.d.ts.map +1 -1
  55. package/dist/odspCache.js.map +1 -1
  56. package/dist/odspDelayLoadedDeltaStream.d.ts +4 -4
  57. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  58. package/dist/odspDelayLoadedDeltaStream.js +11 -6
  59. package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
  60. package/dist/odspDeltaStorageService.d.ts +3 -3
  61. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  62. package/dist/odspDeltaStorageService.js +3 -3
  63. package/dist/odspDeltaStorageService.js.map +1 -1
  64. package/dist/odspDocumentDeltaConnection.d.ts +5 -4
  65. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  66. package/dist/odspDocumentDeltaConnection.js +3 -5
  67. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  68. package/dist/odspDocumentService.d.ts +4 -4
  69. package/dist/odspDocumentService.d.ts.map +1 -1
  70. package/dist/odspDocumentService.js +2 -2
  71. package/dist/odspDocumentService.js.map +1 -1
  72. package/dist/odspDocumentServiceFactory.d.ts +1 -1
  73. package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
  74. package/dist/odspDocumentServiceFactory.js +1 -1
  75. package/dist/odspDocumentServiceFactory.js.map +1 -1
  76. package/dist/odspDocumentServiceFactoryCore.d.ts +2 -2
  77. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  78. package/dist/odspDocumentServiceFactoryCore.js +2 -2
  79. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  80. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +1 -1
  81. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
  82. package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
  83. package/dist/odspDocumentStorageManager.d.ts +4 -4
  84. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  85. package/dist/odspDocumentStorageManager.js +3 -3
  86. package/dist/odspDocumentStorageManager.js.map +1 -1
  87. package/dist/odspDocumentStorageServiceBase.d.ts +1 -1
  88. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  89. package/dist/odspDocumentStorageServiceBase.js.map +1 -1
  90. package/dist/odspDriverUrlResolver.d.ts.map +1 -1
  91. package/dist/odspDriverUrlResolver.js +3 -3
  92. package/dist/odspDriverUrlResolver.js.map +1 -1
  93. package/dist/odspDriverUrlResolverForShareLink.d.ts +1 -1
  94. package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  95. package/dist/odspDriverUrlResolverForShareLink.js +2 -2
  96. package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
  97. package/dist/odspError.d.ts.map +1 -1
  98. package/dist/odspError.js +1 -1
  99. package/dist/odspError.js.map +1 -1
  100. package/dist/odspFluidFileLink.d.ts.map +1 -1
  101. package/dist/odspFluidFileLink.js.map +1 -1
  102. package/dist/odspPublicUtils.js.map +1 -1
  103. package/dist/odspSnapshotParser.d.ts.map +1 -1
  104. package/dist/odspSnapshotParser.js.map +1 -1
  105. package/dist/odspSummaryUploadManager.d.ts +1 -1
  106. package/dist/odspSummaryUploadManager.d.ts.map +1 -1
  107. package/dist/odspSummaryUploadManager.js +1 -1
  108. package/dist/odspSummaryUploadManager.js.map +1 -1
  109. package/dist/odspUtils.d.ts +2 -2
  110. package/dist/odspUtils.d.ts.map +1 -1
  111. package/dist/odspUtils.js +2 -2
  112. package/dist/odspUtils.js.map +1 -1
  113. package/dist/opsCaching.d.ts.map +1 -1
  114. package/dist/opsCaching.js.map +1 -1
  115. package/dist/packageVersion.d.ts +1 -1
  116. package/dist/packageVersion.js +1 -1
  117. package/dist/packageVersion.js.map +1 -1
  118. package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
  119. package/dist/prefetchLatestSnapshot.js +1 -1
  120. package/dist/prefetchLatestSnapshot.js.map +1 -1
  121. package/dist/retryErrorsStorageAdapter.d.ts +2 -2
  122. package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
  123. package/dist/retryErrorsStorageAdapter.js.map +1 -1
  124. package/dist/retryUtils.d.ts.map +1 -1
  125. package/dist/retryUtils.js.map +1 -1
  126. package/dist/vroom.d.ts +2 -2
  127. package/dist/vroom.d.ts.map +1 -1
  128. package/dist/vroom.js +2 -2
  129. package/dist/vroom.js.map +1 -1
  130. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  131. package/dist/zipItDataRepresentationUtils.js +1 -1
  132. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  133. package/lib/WriteBufferUtils.d.ts.map +1 -1
  134. package/lib/WriteBufferUtils.js +1 -1
  135. package/lib/WriteBufferUtils.js.map +1 -1
  136. package/lib/compactSnapshotParser.d.ts +1 -1
  137. package/lib/compactSnapshotParser.d.ts.map +1 -1
  138. package/lib/compactSnapshotParser.js +1 -1
  139. package/lib/compactSnapshotParser.js.map +1 -1
  140. package/lib/compactSnapshotWriter.d.ts.map +1 -1
  141. package/lib/compactSnapshotWriter.js +2 -2
  142. package/lib/compactSnapshotWriter.js.map +1 -1
  143. package/lib/contracts.d.ts +2 -2
  144. package/lib/contracts.d.ts.map +1 -1
  145. package/lib/contracts.js.map +1 -1
  146. package/lib/createFile.d.ts +2 -2
  147. package/lib/createFile.d.ts.map +1 -1
  148. package/lib/createFile.js +7 -7
  149. package/lib/createFile.js.map +1 -1
  150. package/lib/createNewContainerOnExistingFile.d.ts +2 -2
  151. package/lib/createNewContainerOnExistingFile.d.ts.map +1 -1
  152. package/lib/createNewContainerOnExistingFile.js +4 -4
  153. package/lib/createNewContainerOnExistingFile.js.map +1 -1
  154. package/lib/createNewUtils.d.ts +2 -2
  155. package/lib/createNewUtils.d.ts.map +1 -1
  156. package/lib/createNewUtils.js +5 -5
  157. package/lib/createNewUtils.js.map +1 -1
  158. package/lib/epochTracker.d.ts +3 -3
  159. package/lib/epochTracker.d.ts.map +1 -1
  160. package/lib/epochTracker.js +6 -6
  161. package/lib/epochTracker.js.map +1 -1
  162. package/lib/fetch.js.map +1 -1
  163. package/lib/fetchSnapshot.d.ts +2 -2
  164. package/lib/fetchSnapshot.d.ts.map +1 -1
  165. package/lib/fetchSnapshot.js +6 -6
  166. package/lib/fetchSnapshot.js.map +1 -1
  167. package/lib/getFileLink.d.ts +1 -1
  168. package/lib/getFileLink.d.ts.map +1 -1
  169. package/lib/getFileLink.js +1 -1
  170. package/lib/getFileLink.js.map +1 -1
  171. package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts +1 -1
  172. package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -1
  173. package/lib/localOdspDriver/localOdspDeltaStorageService.js +1 -1
  174. package/lib/localOdspDriver/localOdspDeltaStorageService.js.map +1 -1
  175. package/lib/localOdspDriver/localOdspDocumentService.d.ts +1 -1
  176. package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
  177. package/lib/localOdspDriver/localOdspDocumentService.js.map +1 -1
  178. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts +1 -1
  179. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
  180. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js +1 -1
  181. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -1
  182. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts +1 -1
  183. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
  184. package/lib/localOdspDriver/localOdspDocumentStorageManager.js +2 -2
  185. package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -1
  186. package/lib/odspCache.d.ts +1 -1
  187. package/lib/odspCache.d.ts.map +1 -1
  188. package/lib/odspCache.js.map +1 -1
  189. package/lib/odspDelayLoadedDeltaStream.d.ts +4 -4
  190. package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  191. package/lib/odspDelayLoadedDeltaStream.js +11 -6
  192. package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
  193. package/lib/odspDeltaStorageService.d.ts +3 -3
  194. package/lib/odspDeltaStorageService.d.ts.map +1 -1
  195. package/lib/odspDeltaStorageService.js +3 -3
  196. package/lib/odspDeltaStorageService.js.map +1 -1
  197. package/lib/odspDocumentDeltaConnection.d.ts +5 -4
  198. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  199. package/lib/odspDocumentDeltaConnection.js +4 -6
  200. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  201. package/lib/odspDocumentService.d.ts +4 -4
  202. package/lib/odspDocumentService.d.ts.map +1 -1
  203. package/lib/odspDocumentService.js +2 -2
  204. package/lib/odspDocumentService.js.map +1 -1
  205. package/lib/odspDocumentServiceFactory.d.ts +1 -1
  206. package/lib/odspDocumentServiceFactory.d.ts.map +1 -1
  207. package/lib/odspDocumentServiceFactory.js +1 -1
  208. package/lib/odspDocumentServiceFactory.js.map +1 -1
  209. package/lib/odspDocumentServiceFactoryCore.d.ts +2 -2
  210. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  211. package/lib/odspDocumentServiceFactoryCore.js +4 -4
  212. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  213. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts +1 -1
  214. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
  215. package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
  216. package/lib/odspDocumentStorageManager.d.ts +4 -4
  217. package/lib/odspDocumentStorageManager.d.ts.map +1 -1
  218. package/lib/odspDocumentStorageManager.js +4 -4
  219. package/lib/odspDocumentStorageManager.js.map +1 -1
  220. package/lib/odspDocumentStorageServiceBase.d.ts +1 -1
  221. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
  222. package/lib/odspDocumentStorageServiceBase.js.map +1 -1
  223. package/lib/odspDriverUrlResolver.d.ts.map +1 -1
  224. package/lib/odspDriverUrlResolver.js +3 -3
  225. package/lib/odspDriverUrlResolver.js.map +1 -1
  226. package/lib/odspDriverUrlResolverForShareLink.d.ts +1 -1
  227. package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  228. package/lib/odspDriverUrlResolverForShareLink.js +3 -3
  229. package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
  230. package/lib/odspError.d.ts.map +1 -1
  231. package/lib/odspError.js +1 -1
  232. package/lib/odspError.js.map +1 -1
  233. package/lib/odspFluidFileLink.d.ts.map +1 -1
  234. package/lib/odspFluidFileLink.js +1 -1
  235. package/lib/odspFluidFileLink.js.map +1 -1
  236. package/lib/odspPublicUtils.js +1 -1
  237. package/lib/odspPublicUtils.js.map +1 -1
  238. package/lib/odspSnapshotParser.d.ts.map +1 -1
  239. package/lib/odspSnapshotParser.js.map +1 -1
  240. package/lib/odspSummaryUploadManager.d.ts +1 -1
  241. package/lib/odspSummaryUploadManager.d.ts.map +1 -1
  242. package/lib/odspSummaryUploadManager.js +2 -2
  243. package/lib/odspSummaryUploadManager.js.map +1 -1
  244. package/lib/odspUtils.d.ts +2 -2
  245. package/lib/odspUtils.d.ts.map +1 -1
  246. package/lib/odspUtils.js +3 -3
  247. package/lib/odspUtils.js.map +1 -1
  248. package/lib/opsCaching.d.ts.map +1 -1
  249. package/lib/opsCaching.js.map +1 -1
  250. package/lib/packageVersion.d.ts +1 -1
  251. package/lib/packageVersion.js +1 -1
  252. package/lib/packageVersion.js.map +1 -1
  253. package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
  254. package/lib/prefetchLatestSnapshot.js +2 -2
  255. package/lib/prefetchLatestSnapshot.js.map +1 -1
  256. package/lib/retryErrorsStorageAdapter.d.ts +2 -2
  257. package/lib/retryErrorsStorageAdapter.d.ts.map +1 -1
  258. package/lib/retryErrorsStorageAdapter.js.map +1 -1
  259. package/lib/retryUtils.d.ts.map +1 -1
  260. package/lib/retryUtils.js.map +1 -1
  261. package/lib/test/createNewUtilsTests.spec.js +3 -3
  262. package/lib/test/createNewUtilsTests.spec.js.map +1 -1
  263. package/lib/test/deltaStorageService.spec.js +2 -2
  264. package/lib/test/deltaStorageService.spec.js.map +1 -1
  265. package/lib/test/epochTests.spec.js +2 -2
  266. package/lib/test/epochTests.spec.js.map +1 -1
  267. package/lib/test/epochTestsWithRedemption.spec.js +2 -2
  268. package/lib/test/epochTestsWithRedemption.spec.js.map +1 -1
  269. package/lib/test/fetchSnapshot.spec.js +8 -8
  270. package/lib/test/fetchSnapshot.spec.js.map +1 -1
  271. package/lib/test/getFileLink.spec.js +1 -1
  272. package/lib/test/getFileLink.spec.js.map +1 -1
  273. package/lib/test/getVersions.spec.js +6 -6
  274. package/lib/test/getVersions.spec.js.map +1 -1
  275. package/lib/test/joinSessionCacheTests.spec.js +117 -1
  276. package/lib/test/joinSessionCacheTests.spec.js.map +1 -1
  277. package/lib/test/joinSessionPeriodicCall.spec.js +3 -3
  278. package/lib/test/joinSessionPeriodicCall.spec.js.map +1 -1
  279. package/lib/test/localOdspDriver.spec.js +2 -2
  280. package/lib/test/localOdspDriver.spec.js.map +1 -1
  281. package/lib/test/mockFetch.js +1 -1
  282. package/lib/test/mockFetch.js.map +1 -1
  283. package/lib/test/odspCreateContainer.spec.js +7 -7
  284. package/lib/test/odspCreateContainer.spec.js.map +1 -1
  285. package/lib/test/odspDriverResolverTest.spec.js +2 -2
  286. package/lib/test/odspDriverResolverTest.spec.js.map +1 -1
  287. package/lib/test/odspDriverUrlResolverForShareLink.spec.js +4 -4
  288. package/lib/test/odspDriverUrlResolverForShareLink.spec.js.map +1 -1
  289. package/lib/test/odspError.spec.js +2 -2
  290. package/lib/test/odspError.spec.js.map +1 -1
  291. package/lib/test/opsCaching.spec.js +1 -1
  292. package/lib/test/opsCaching.spec.js.map +1 -1
  293. package/lib/test/prefetchSnapshotTests.spec.js +8 -8
  294. package/lib/test/prefetchSnapshotTests.spec.js.map +1 -1
  295. package/lib/test/snapshotFormatTests.spec.js.map +1 -1
  296. package/lib/test/socketTests/deltaConnectionUpdateTests.spec.js +4 -4
  297. package/lib/test/socketTests/deltaConnectionUpdateTests.spec.js.map +1 -1
  298. package/lib/test/socketTests/socketMock.js +6 -2
  299. package/lib/test/socketTests/socketMock.js.map +1 -1
  300. package/lib/test/socketTests/socketTests.spec.js +4 -4
  301. package/lib/test/socketTests/socketTests.spec.js.map +1 -1
  302. package/lib/test/tokenFetch.spec.js +1 -1
  303. package/lib/test/tokenFetch.spec.js.map +1 -1
  304. package/lib/test/zipItDataRepresentationTests.spec.js +1 -1
  305. package/lib/test/zipItDataRepresentationTests.spec.js.map +1 -1
  306. package/lib/vroom.d.ts +2 -2
  307. package/lib/vroom.d.ts.map +1 -1
  308. package/lib/vroom.js +2 -2
  309. package/lib/vroom.js.map +1 -1
  310. package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
  311. package/lib/zipItDataRepresentationUtils.js +1 -1
  312. package/lib/zipItDataRepresentationUtils.js.map +1 -1
  313. package/package.json +19 -16
  314. package/src/WriteBufferUtils.ts +2 -2
  315. package/src/compactSnapshotParser.ts +6 -6
  316. package/src/compactSnapshotWriter.ts +4 -4
  317. package/src/contracts.ts +2 -2
  318. package/src/createFile.ts +18 -18
  319. package/src/createNewContainerOnExistingFile.ts +10 -10
  320. package/src/createNewUtils.ts +13 -13
  321. package/src/epochTracker.ts +21 -21
  322. package/src/fetch.ts +1 -1
  323. package/src/fetchSnapshot.ts +24 -24
  324. package/src/getFileLink.ts +1 -1
  325. package/src/localOdspDriver/localOdspDeltaStorageService.ts +2 -2
  326. package/src/localOdspDriver/localOdspDocumentService.ts +1 -1
  327. package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +2 -2
  328. package/src/localOdspDriver/localOdspDocumentStorageManager.ts +3 -3
  329. package/src/odspCache.ts +4 -4
  330. package/src/odspDelayLoadedDeltaStream.ts +26 -22
  331. package/src/odspDeltaStorageService.ts +6 -6
  332. package/src/odspDocumentDeltaConnection.ts +17 -14
  333. package/src/odspDocumentService.ts +15 -15
  334. package/src/odspDocumentServiceFactory.ts +3 -3
  335. package/src/odspDocumentServiceFactoryCore.ts +14 -14
  336. package/src/odspDocumentServiceFactoryWithCodeSplit.ts +2 -2
  337. package/src/odspDocumentStorageManager.ts +22 -22
  338. package/src/odspDocumentStorageServiceBase.ts +4 -4
  339. package/src/odspDriverUrlResolver.ts +4 -4
  340. package/src/odspDriverUrlResolverForShareLink.ts +8 -8
  341. package/src/odspError.ts +2 -2
  342. package/src/odspFluidFileLink.ts +1 -1
  343. package/src/odspPublicUtils.ts +1 -1
  344. package/src/odspSnapshotParser.ts +1 -1
  345. package/src/odspSummaryUploadManager.ts +4 -4
  346. package/src/odspUtils.ts +25 -25
  347. package/src/opsCaching.ts +1 -1
  348. package/src/packageVersion.ts +1 -1
  349. package/src/prefetchLatestSnapshot.ts +12 -12
  350. package/src/retryErrorsStorageAdapter.ts +2 -2
  351. package/src/retryUtils.ts +1 -1
  352. package/src/vroom.ts +6 -6
  353. package/src/zipItDataRepresentationUtils.ts +2 -2
@@ -1 +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,CAAC;AACpE,OAAO,EACN,0BAA0B,EAC1B,mCAAmC,GACnC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE3E,MAAM,kBAAkB,GAAG,GAAyB,EAAE,CAAC,IAAI,oBAAoB,EAAE,CAAC;AAElF,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACzC,MAAM,OAAO,GAAG,6CAA6C,CAAC;IAC9D,MAAM,OAAO,GAAG,SAAS,CAAC;IAC1B,MAAM,MAAM,GAAG,QAAQ,CAAC;IACxB,MAAM,QAAQ,GAAG,MAAM,CAAC;IACxB,IAAI,YAA0B,CAAC;IAC/B,IAAI,UAAgC,CAAC;IACrC,IA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,UAAU,CAAC,GAAG,CACnB,UAAU,EACV,qBAAqB,CAAC,mCAAmC,CAAC,CAC1D,CAAC;YAEF,MAAM,OAAO,GAAG,MAAM,eAAe,CACpC,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,EACxC,KAAK,IAAI,EAAE,CACV,cAAc,CACb,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,EAAE,EACjE,YAAY,EACZ,GAAG,CACH,CACF,CAAC;YACF,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,mBAAmB,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;YACrC,MAAM,UAAU,GAAgB;gBAC/B,GAAG,EAAE,EAAE;gBACP,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE;aAC9C,CAAC;YACF,MAAM,UAAU,CAAC,GAAG,CACnB,UAAU,EACV,qBAAqB,CAAC,mCAAmC,GAAG,IAAI,CAAC,CACjE,CAAC;YAEF,MAAM,CAAC,QAAQ,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"]}
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;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EAGN,sBAAsB,GACtB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAIN,0BAA0B,GAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YA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U;gBAChB,IAAI,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE;aAC9C,CAAC;YACF,MAAM,UAAU,CAAC,GAAG,CACnB,UAAU,EACV,qBAAqB,CAAC,mCAAmC,GAAG,IAAI,CAAC,CACjE,CAAC;YAEF,MAAM,CAAC,QAAQ,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 { delay } from \"@fluidframework/core-utils\";\nimport { ISnapshot } from \"@fluidframework/driver-definitions\";\nimport {\n\tICacheEntry,\n\tIOdspResolvedUrl,\n\tmaximumCacheDurationMs,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils\";\nimport {\n\tHostStoragePolicyInternal,\n\tIOdspSnapshot,\n\tIVersionedValueWithEpoch,\n\tpersistedCacheValueVersion,\n} from \"../contracts.js\";\nimport { createOdspUrl } from \"../createOdspUrl.js\";\nimport { EpochTracker } from \"../epochTracker.js\";\nimport { LocalPersistentCache, NonPersistentCache } from \"../odspCache.js\";\nimport {\n\tOdspDocumentStorageService,\n\tdefaultSummarizerCacheExpiryTimeout,\n} from \"../odspDocumentStorageManager.js\";\nimport { OdspDriverUrlResolver } from \"../odspDriverUrlResolver.js\";\nimport { getHashedDocumentId } from \"../odspPublicUtils.js\";\nimport { INewFileInfo } from \"../odspUtils.js\";\nimport { createResponse, mockFetchSingle, notFound } 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"]}
@@ -3,12 +3,22 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { strict as assert } from "node:assert";
6
+ import { createOdspNetworkError } from "@fluidframework/odsp-doclib-utils/internal";
7
+ import { MockLogger } from "@fluidframework/telemetry-utils";
8
+ import { stub } from "sinon";
9
+ import { createOdspUrl } from "../createOdspUrl.js";
6
10
  import { OdspDocumentServiceFactory } from "../odspDocumentServiceFactory.js";
11
+ import { OdspDriverUrlResolver } from "../odspDriverUrlResolver.js";
7
12
  import { getJoinSessionCacheKey } from "../odspUtils.js";
13
+ import * as socketModule from "../socketModule.js";
14
+ import * as joinSession from "../vroom.js";
15
+ // eslint-disable-next-line import/no-internal-modules
16
+ import { ClientSocketMock } from "./socketTests/socketMock.js";
8
17
  describe("expose joinSessionInfo Tests", () => {
9
18
  const siteUrl = "https://www.localhost.xxx";
10
19
  const driveId = "driveId";
11
20
  const itemId = "itemId";
21
+ let socket;
12
22
  const resolvedUrl = {
13
23
  siteUrl,
14
24
  driveId,
@@ -21,9 +31,27 @@ describe("expose joinSessionInfo Tests", () => {
21
31
  id: "id",
22
32
  tenantId: "tenantId",
23
33
  snapshotStorageUrl: "https://fake/snapshotStorageUrl",
24
- refreshSessionDurationSeconds: 100,
34
+ socketToken: "token",
35
+ refreshSessionDurationSeconds: 5,
25
36
  };
26
37
  const odspDocumentServiceFactory = new OdspDocumentServiceFactory(async (_options) => "token", async (_options) => "token");
38
+ function addJoinSessionStub() {
39
+ const joinSessionStub = stub(joinSession, "fetchJoinSession").callsFake(async () => joinSessionResponse);
40
+ return joinSessionStub;
41
+ }
42
+ async function mockSocket(_response, callback) {
43
+ const getSocketCreationStub = stub(socketModule, "SocketIOClientStatic");
44
+ getSocketCreationStub.returns(_response);
45
+ try {
46
+ return await callback();
47
+ }
48
+ finally {
49
+ getSocketCreationStub.restore();
50
+ }
51
+ }
52
+ afterEach(() => {
53
+ socket?.close();
54
+ });
27
55
  it("Response missing in join session cache", async () => {
28
56
  const info = await odspDocumentServiceFactory.getRelayServiceSessionInfo(resolvedUrl);
29
57
  assert(info === undefined, "no cached response");
@@ -49,5 +77,93 @@ describe("expose joinSessionInfo Tests", () => {
49
77
  }
50
78
  assert(failed, "resolved url not correct");
51
79
  });
80
+ it("Error of type connect_document_error should clear joinSession info from cache", async () => {
81
+ // joinSession stub will be internally invoked by connectToDeltaStream below so mocking it here.
82
+ const joinSessionStub = addJoinSessionStub();
83
+ // Setup for mocking socket a error when connectToDeltaStream gets executed below
84
+ const resolver = new OdspDriverUrlResolver();
85
+ const odspResolvedUrl = await resolver.resolve({
86
+ url: createOdspUrl({ driveId, itemId, siteUrl, dataStorePath: "/" }),
87
+ });
88
+ const service = await odspDocumentServiceFactory.createDocumentService(odspResolvedUrl, new MockLogger().toTelemetryLogger());
89
+ const errorToThrow = createOdspNetworkError("TestError", 429);
90
+ const errorFromEvent = "connect_document_error";
91
+ socket = new ClientSocketMock({
92
+ connect_document: { eventToEmit: errorFromEvent, errorToThrow },
93
+ });
94
+ const client = {
95
+ mode: "read",
96
+ details: { capabilities: { interactive: true } },
97
+ permission: [],
98
+ user: { id: "id" },
99
+ scopes: [],
100
+ };
101
+ // Save a mock joinSession response in nonPersistenCache to test with later.
102
+ const cacheKey = getJoinSessionCacheKey(odspResolvedUrl);
103
+ // eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
104
+ odspDocumentServiceFactory["nonPersistentCache"].sessionJoinCache.add(getJoinSessionCacheKey(odspResolvedUrl), async () => {
105
+ return { entryTime: Date.now(), joinSessionResponse };
106
+ });
107
+ try {
108
+ await mockSocket(socket, async () => service.connectToDeltaStream(client));
109
+ }
110
+ catch (error) {
111
+ assert(
112
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
113
+ error.errorFrom === errorFromEvent, `errorFrom param with value as '${errorFromEvent}' should be available`);
114
+ const info = await odspDocumentServiceFactory.getRelayServiceSessionInfo(odspResolvedUrl);
115
+ assert(info === undefined, `joinSession cache should get cleared when '${errorFromEvent}' occurs`);
116
+ }
117
+ finally {
118
+ // reset nonPersistenCache changes from the test
119
+ // eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
120
+ odspDocumentServiceFactory["nonPersistentCache"].sessionJoinCache.remove(cacheKey);
121
+ joinSessionStub.restore();
122
+ }
123
+ });
124
+ it("Socket errors should not result in clearing of joinSession info from cache", async () => {
125
+ // joinSession stub will be internally invoked by connectToDeltaStream below so mocking it here.
126
+ const joinSessionStub = addJoinSessionStub();
127
+ // Setup for mocking socket a error when connectToDeltaStream gets executed below
128
+ const resolver = new OdspDriverUrlResolver();
129
+ const odspResolvedUrl = await resolver.resolve({
130
+ url: createOdspUrl({ driveId, itemId, siteUrl, dataStorePath: "/" }),
131
+ });
132
+ const service = await odspDocumentServiceFactory.createDocumentService(odspResolvedUrl, new MockLogger().toTelemetryLogger());
133
+ const errorToThrow = createOdspNetworkError("TestSocketError", 401);
134
+ const errorFromEvent = "connect_error";
135
+ socket = new ClientSocketMock({
136
+ connect_document: { eventToEmit: errorFromEvent, errorToThrow },
137
+ });
138
+ const client = {
139
+ mode: "read",
140
+ details: { capabilities: { interactive: true } },
141
+ permission: [],
142
+ user: { id: "id" },
143
+ scopes: [],
144
+ };
145
+ // Save a mock joinSession response in nonPersistenCache to test with later.
146
+ const cacheKey = getJoinSessionCacheKey(odspResolvedUrl);
147
+ // eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
148
+ odspDocumentServiceFactory["nonPersistentCache"].sessionJoinCache.add(cacheKey, async () => {
149
+ return { entryTime: Date.now(), joinSessionResponse };
150
+ });
151
+ try {
152
+ await mockSocket(socket, async () => service.connectToDeltaStream(client));
153
+ }
154
+ catch (error) {
155
+ assert(
156
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
157
+ error.errorFrom === errorFromEvent, `errorFrom param with value as ${errorFromEvent} should be present`);
158
+ const info = await odspDocumentServiceFactory.getRelayServiceSessionInfo(odspResolvedUrl);
159
+ assert(info === joinSessionResponse, `joinSession cache should not get cleared when '${errorFromEvent}' occurs`);
160
+ }
161
+ finally {
162
+ // reset nonPersistenCache changes from the test
163
+ // eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
164
+ odspDocumentServiceFactory["nonPersistentCache"].sessionJoinCache.remove(cacheKey);
165
+ joinSessionStub.restore();
166
+ }
167
+ });
52
168
  });
53
169
  //# sourceMappingURL=joinSessionCacheTests.spec.js.map
@@ -1 +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,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;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"]}
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;AAE/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAGpF,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAkB,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,WAAW,MAAM,aAAa,CAAC;AAC3C,sDAAsD;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,QAAQ,CAAC,8BAA8B,E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AAM,EAAE,EAAE;SACV,CAAC;QAEF,4EAA4E;QAC5E,MAAM,QAAQ,GAAG,sBAAsB,CAAC,eAAe,CAAC,CAAC;QACzD,0IAA0I;QAC1I,0BAA0B,CAAC,oBAAoB,CAAC,CAAC,gBAAgB,CAAC,GAAG,CACpE,QAAQ,EACR,KAAK,IAAI,EAAE;YACV,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,mBAAmB,EAAE,CAAC;QACvD,CAAC,CACD,CAAC;QAEF,IAAI;YACH,MAAM,UAAU,CAAC,MAA2B,EAAE,KAAK,IAAI,EAAE,CACxD,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CACpC,CAAC;SACF;QAAC,OAAO,KAAK,EAAE;YACf,MAAM;YACL,0GAA0G;YACzG,KAAa,CAAC,SAAS,KAAK,cAAc,EAC3C,iCAAiC,cAAc,oBAAoB,CACnE,CAAC;YAEF,MAAM,IAAI,GACT,MAAM,0BAA0B,CAAC,0BAA0B,CAAC,eAAe,CAAC,CAAC;YAC9E,MAAM,CACL,IAAI,KAAK,mBAAmB,EAC5B,kDAAkD,cAAc,UAAU,CAC1E,CAAC;SACF;gBAAS;YACT,gDAAgD;YAChD,0IAA0I;YAC1I,0BAA0B,CAAC,oBAAoB,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACnF,eAAe,CAAC,OAAO,EAAE,CAAC;SAC1B;IACF,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 { createOdspNetworkError } from \"@fluidframework/odsp-doclib-utils/internal\";\nimport { IOdspResolvedUrl, ISocketStorageDiscovery } from \"@fluidframework/odsp-driver-definitions\";\nimport type { IClient } from \"@fluidframework/protocol-definitions\";\nimport { MockLogger } from \"@fluidframework/telemetry-utils\";\nimport { type SinonStub, stub } from \"sinon\";\nimport { Socket } from \"socket.io-client\";\nimport { createOdspUrl } from \"../createOdspUrl.js\";\nimport { OdspDocumentServiceFactory } from \"../odspDocumentServiceFactory.js\";\nimport { OdspDriverUrlResolver } from \"../odspDriverUrlResolver.js\";\nimport { getJoinSessionCacheKey } from \"../odspUtils.js\";\nimport * as socketModule from \"../socketModule.js\";\nimport * as joinSession from \"../vroom.js\";\n// eslint-disable-next-line import/no-internal-modules\nimport { ClientSocketMock } from \"./socketTests/socketMock.js\";\n\ndescribe(\"expose joinSessionInfo Tests\", () => {\n\tconst siteUrl = \"https://www.localhost.xxx\";\n\tconst driveId = \"driveId\";\n\tconst itemId = \"itemId\";\n\tlet socket: ClientSocketMock | undefined;\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\tsocketToken: \"token\", // providing socket token here so that the tests can bypass the need for token fetcher callback\n\t\trefreshSessionDurationSeconds: 5,\n\t};\n\tconst odspDocumentServiceFactory = new OdspDocumentServiceFactory(\n\t\tasync (_options) => \"token\",\n\t\tasync (_options) => \"token\",\n\t);\n\n\tfunction addJoinSessionStub(): SinonStub {\n\t\tconst joinSessionStub = stub(joinSession, \"fetchJoinSession\").callsFake(\n\t\t\tasync () => joinSessionResponse,\n\t\t);\n\t\treturn joinSessionStub;\n\t}\n\n\tasync function mockSocket<T>(_response: Socket, callback: () => Promise<T>): Promise<T> {\n\t\tconst getSocketCreationStub = stub(socketModule, \"SocketIOClientStatic\");\n\t\tgetSocketCreationStub.returns(_response);\n\t\ttry {\n\t\t\treturn await callback();\n\t\t} finally {\n\t\t\tgetSocketCreationStub.restore();\n\t\t}\n\t}\n\n\tafterEach(() => {\n\t\tsocket?.close();\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\tit(\"Error of type connect_document_error should clear joinSession info from cache\", async () => {\n\t\t// joinSession stub will be internally invoked by connectToDeltaStream below so mocking it here.\n\t\tconst joinSessionStub = addJoinSessionStub();\n\n\t\t// Setup for mocking socket a error when connectToDeltaStream gets executed below\n\t\tconst resolver = new OdspDriverUrlResolver();\n\t\tconst odspResolvedUrl = await resolver.resolve({\n\t\t\turl: createOdspUrl({ driveId, itemId, siteUrl, dataStorePath: \"/\" }),\n\t\t});\n\t\tconst service = await odspDocumentServiceFactory.createDocumentService(\n\t\t\todspResolvedUrl,\n\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t);\n\t\tconst errorToThrow = createOdspNetworkError(\"TestError\", 429);\n\t\tconst errorFromEvent = \"connect_document_error\";\n\t\tsocket = new ClientSocketMock({\n\t\t\tconnect_document: { eventToEmit: errorFromEvent, errorToThrow },\n\t\t});\n\t\tconst client: IClient = {\n\t\t\tmode: \"read\",\n\t\t\tdetails: { capabilities: { interactive: true } },\n\t\t\tpermission: [],\n\t\t\tuser: { id: \"id\" },\n\t\t\tscopes: [],\n\t\t};\n\n\t\t// Save a mock joinSession response in nonPersistenCache to test with later.\n\t\tconst cacheKey = getJoinSessionCacheKey(odspResolvedUrl);\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(odspResolvedUrl),\n\t\t\tasync () => {\n\t\t\t\treturn { entryTime: Date.now(), joinSessionResponse };\n\t\t\t},\n\t\t);\n\n\t\ttry {\n\t\t\tawait mockSocket(socket as unknown as Socket, async () =>\n\t\t\t\tservice.connectToDeltaStream(client),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tassert(\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\t\t(error as any).errorFrom === errorFromEvent,\n\t\t\t\t`errorFrom param with value as '${errorFromEvent}' should be available`,\n\t\t\t);\n\n\t\t\tconst info =\n\t\t\t\tawait odspDocumentServiceFactory.getRelayServiceSessionInfo(odspResolvedUrl);\n\t\t\tassert(\n\t\t\t\tinfo === undefined,\n\t\t\t\t`joinSession cache should get cleared when '${errorFromEvent}' occurs`,\n\t\t\t);\n\t\t} finally {\n\t\t\t// reset nonPersistenCache changes from the test\n\t\t\t// eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\todspDocumentServiceFactory[\"nonPersistentCache\"].sessionJoinCache.remove(cacheKey);\n\t\t\tjoinSessionStub.restore();\n\t\t}\n\t});\n\n\tit(\"Socket errors should not result in clearing of joinSession info from cache\", async () => {\n\t\t// joinSession stub will be internally invoked by connectToDeltaStream below so mocking it here.\n\t\tconst joinSessionStub = addJoinSessionStub();\n\n\t\t// Setup for mocking socket a error when connectToDeltaStream gets executed below\n\t\tconst resolver = new OdspDriverUrlResolver();\n\t\tconst odspResolvedUrl = await resolver.resolve({\n\t\t\turl: createOdspUrl({ driveId, itemId, siteUrl, dataStorePath: \"/\" }),\n\t\t});\n\t\tconst service = await odspDocumentServiceFactory.createDocumentService(\n\t\t\todspResolvedUrl,\n\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t);\n\t\tconst errorToThrow = createOdspNetworkError(\"TestSocketError\", 401);\n\t\tconst errorFromEvent = \"connect_error\";\n\t\tsocket = new ClientSocketMock({\n\t\t\tconnect_document: { eventToEmit: errorFromEvent, errorToThrow },\n\t\t});\n\t\tconst client: IClient = {\n\t\t\tmode: \"read\",\n\t\t\tdetails: { capabilities: { interactive: true } },\n\t\t\tpermission: [],\n\t\t\tuser: { id: \"id\" },\n\t\t\tscopes: [],\n\t\t};\n\n\t\t// Save a mock joinSession response in nonPersistenCache to test with later.\n\t\tconst cacheKey = getJoinSessionCacheKey(odspResolvedUrl);\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\tcacheKey,\n\t\t\tasync () => {\n\t\t\t\treturn { entryTime: Date.now(), joinSessionResponse };\n\t\t\t},\n\t\t);\n\n\t\ttry {\n\t\t\tawait mockSocket(socket as unknown as Socket, async () =>\n\t\t\t\tservice.connectToDeltaStream(client),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tassert(\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\t\t(error as any).errorFrom === errorFromEvent,\n\t\t\t\t`errorFrom param with value as ${errorFromEvent} should be present`,\n\t\t\t);\n\n\t\t\tconst info =\n\t\t\t\tawait odspDocumentServiceFactory.getRelayServiceSessionInfo(odspResolvedUrl);\n\t\t\tassert(\n\t\t\t\tinfo === joinSessionResponse,\n\t\t\t\t`joinSession cache should not get cleared when '${errorFromEvent}' occurs`,\n\t\t\t);\n\t\t} finally {\n\t\t\t// reset nonPersistenCache changes from the test\n\t\t\t// eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\todspDocumentServiceFactory[\"nonPersistentCache\"].sessionJoinCache.remove(cacheKey);\n\t\t\tjoinSessionStub.restore();\n\t\t}\n\t});\n});\n"]}
@@ -5,12 +5,12 @@
5
5
  import { strict as assert } from "node:assert";
6
6
  import { MockLogger } from "@fluidframework/telemetry-utils";
7
7
  import { stub, useFakeTimers } from "sinon";
8
+ import { createOdspUrl } from "../createOdspUrl.js";
9
+ import { LocalPersistentCache } from "../odspCache.js";
8
10
  import * as odspDocumentDeltaConnection from "../odspDocumentDeltaConnection.js";
9
- import * as joinSession from "../vroom.js";
10
11
  import { OdspDocumentServiceFactory } from "../odspDocumentServiceFactory.js";
11
- import { LocalPersistentCache } from "../odspCache.js";
12
- import { createOdspUrl } from "../createOdspUrl.js";
13
12
  import { OdspDriverUrlResolver } from "../odspDriverUrlResolver.js";
13
+ import * as joinSession from "../vroom.js";
14
14
  describe("joinSessions Tests", () => {
15
15
  let clock;
16
16
  const siteUrl = "https://www.localhost.xxx";
@@ -1 +1 @@
1
- {"version":3,"file":"joinSessionPeriodicCall.spec.js","sourceRoot":"","sources":["../../src/test/joinSessionPeriodicCall.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,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I,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"]}
1
+ {"version":3,"file":"joinSessionPeriodicCall.spec.js","sourceRoot":"","sources":["../../src/test/joinSessionPeriodicCall.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAA8B,IAAI,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,2BAA2B,MAAM,mCAAmC,CAAC;AAGjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,WAAW,MAAM,aAAa,CAAC;AAE3C,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IACnC,IAAI,KAAsB,CAAC;IAC3B,MAAM,O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AC,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 { ISocketStorageDiscovery } from \"@fluidframework/odsp-driver-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport { MockLogger } from \"@fluidframework/telemetry-utils\";\nimport { SinonFakeTimers, SinonStub, stub, useFakeTimers } from \"sinon\";\nimport { OdspFluidDataStoreLocator } from \"../contractsPublic.js\";\nimport { createOdspUrl } from \"../createOdspUrl.js\";\nimport { LocalPersistentCache } from \"../odspCache.js\";\nimport * as odspDocumentDeltaConnection from \"../odspDocumentDeltaConnection.js\";\nimport { OdspDocumentDeltaConnection } from \"../odspDocumentDeltaConnection.js\";\nimport { OdspDocumentService } from \"../odspDocumentService.js\";\nimport { OdspDocumentServiceFactory } from \"../odspDocumentServiceFactory.js\";\nimport { OdspDriverUrlResolver } from \"../odspDriverUrlResolver.js\";\nimport * as joinSession from \"../vroom.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"]}
@@ -2,14 +2,14 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import fs from "node:fs";
6
5
  import { strict as assert } from "node:assert";
6
+ import fs from "node:fs";
7
7
  import { OdspErrorTypes } from "@fluidframework/odsp-driver-definitions";
8
8
  import { SummaryType, } from "@fluidframework/protocol-definitions";
9
9
  import { MockLogger } from "@fluidframework/telemetry-utils";
10
10
  /* eslint-disable import/no-internal-modules */
11
- import { LocalOdspDocumentServiceFactory } from "../localOdspDriver/localOdspDocumentServiceFactory.js";
12
11
  import { LocalOdspDocumentService } from "../localOdspDriver/localOdspDocumentService.js";
12
+ import { LocalOdspDocumentServiceFactory } from "../localOdspDriver/localOdspDocumentServiceFactory.js";
13
13
  import { LocalOdspDocumentStorageService } from "../localOdspDriver/localOdspDocumentStorageManager.js";
14
14
  /* eslint-enable import/no-internal-modules */
15
15
  describe("Local Odsp driver", () => {
@@ -1 +1 @@
1
- {"version":3,"file":"localOdspDriver.spec.js","sourceRoot":"","sources":["../../src/test/localOdspDriver.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAoB,MAAM,yCAAyC,CAAC;AAC3F,OAAO,EAGN,WAAW,GACX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,+CAA+C;AAC/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,uDAAuD,CAAC;AACxG,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,EAAE,+BAA+B,EAAE,MAAM,uDAAuD,CAAC;AACxG,8CAA8C;AAE9C,QAAQ,CAAC,mBAAmB,EAAE,GAAG,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AM,CAAC,eAAe,CACrB,MAAM,cAAc,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,EACzC,eAAe,CACf,CAAC;iBACF;YACF,CAAC,CAAC,CAAC;QACJ,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 fs from \"node:fs\";\nimport { strict as assert } from \"node:assert\";\nimport { DriverError, IStream } from \"@fluidframework/driver-definitions\";\nimport { OdspErrorTypes, IOdspResolvedUrl } from \"@fluidframework/odsp-driver-definitions\";\nimport {\n\tIClient,\n\tISequencedDocumentMessage,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport { MockLogger } from \"@fluidframework/telemetry-utils\";\n/* eslint-disable import/no-internal-modules */\nimport { LocalOdspDocumentServiceFactory } from \"../localOdspDriver/localOdspDocumentServiceFactory.js\";\nimport { LocalOdspDocumentService } from \"../localOdspDriver/localOdspDocumentService.js\";\nimport { LocalOdspDocumentStorageService } from \"../localOdspDriver/localOdspDocumentStorageManager.js\";\n/* eslint-enable import/no-internal-modules */\n\ndescribe(\"Local Odsp driver\", () => {\n\t// TODO: add end-to-end test\n\n\tconst fakeOdspResolvedUrl: IOdspResolvedUrl = {\n\t\ttype: \"fluid\",\n\t\todspResolvedUrl: true,\n\t\tid: \"1\",\n\t\tsiteUrl: \"fakeUrl\",\n\t\tdriveId: \"1\",\n\t\titemId: \"1\",\n\t\turl: \"fakeUrl\",\n\t\thashedDocumentId: \"1\",\n\t\tendpoints: {\n\t\t\tsnapshotStorageUrl: \"fakeUrl\",\n\t\t\tattachmentPOSTStorageUrl: \"fakeUrl\",\n\t\t\tattachmentGETStorageUrl: \"fakeUrl\",\n\t\t\tdeltaStorageUrl: \"fakeUrl\",\n\t\t},\n\t\ttokens: {},\n\t\tfileName: \"fakeName\",\n\t\tsummarizer: false,\n\t\tfileVersion: \"1\",\n\t};\n\n\tconst localSnapshot = fs.readFileSync(\n\t\t`${__dirname}/../../src/test/localSnapshots/localSnapshot1.json`,\n\t\t{ encoding: \"utf8\" },\n\t);\n\n\tasync function assertThrowsUsageError(fn: () => Promise<unknown>): Promise<void> {\n\t\tawait assert.rejects(fn, (e: DriverError) => e.errorType === OdspErrorTypes.usageError);\n\t}\n\n\tdescribe(\"Local Odsp document service factory\", () => {\n\t\tit(\"Can use a real snapshot\", () => {\n\t\t\tassert.doesNotThrow(() => new LocalOdspDocumentServiceFactory(localSnapshot));\n\t\t});\n\n\t\tit(\"createContainer throws error\", async () => {\n\t\t\tawait assertThrowsUsageError(async () =>\n\t\t\t\tnew LocalOdspDocumentServiceFactory(\"sample data\").createContainer(\n\t\t\t\t\tundefined,\n\t\t\t\t\tfakeOdspResolvedUrl,\n\t\t\t\t),\n\t\t\t);\n\t\t});\n\n\t\tdescribe(\"createDocumentService\", () => {\n\t\t\tit(\"clientIsSummarizer should be undefined or false\", async () => {\n\t\t\t\tconst factory = new LocalOdspDocumentServiceFactory(\"sample data\");\n\t\t\t\tawait assert.doesNotReject(async () => {\n\t\t\t\t\tawait factory.createDocumentService(fakeOdspResolvedUrl);\n\t\t\t\t});\n\t\t\t\tawait assert.doesNotReject(async () => {\n\t\t\t\t\tawait factory.createDocumentService(fakeOdspResolvedUrl, undefined, undefined);\n\t\t\t\t});\n\t\t\t\tawait factory.createDocumentService(fakeOdspResolvedUrl, undefined, false);\n\t\t\t\tawait assert.rejects(async () => {\n\t\t\t\t\tawait factory.createDocumentService(fakeOdspResolvedUrl, undefined, true);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tit(\"resolvedUrl must be IOdspResolvedUrl\", async () => {\n\t\t\t\tconst factory = new LocalOdspDocumentServiceFactory(\"sample data\");\n\t\t\t\tawait assert.doesNotReject(async () =>\n\t\t\t\t\tfactory.createDocumentService(fakeOdspResolvedUrl),\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe(\"Local Odsp document service\", () => {\n\t\tasync function readAll(\n\t\t\tstream: IStream<ISequencedDocumentMessage[]>,\n\t\t): Promise<ISequencedDocumentMessage[]> {\n\t\t\tconst ops: ISequencedDocumentMessage[] = [];\n\t\t\t// eslint-disable-next-line no-constant-condition\n\t\t\twhile (true) {\n\t\t\t\tconst result = await stream.read();\n\t\t\t\tif (result.done) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tops.push(...result.value);\n\t\t\t}\n\t\t\treturn ops;\n\t\t}\n\n\t\tit(\"Can use a real snapshot\", () => {\n\t\t\tassert.doesNotThrow(\n\t\t\t\t() =>\n\t\t\t\t\tnew LocalOdspDocumentService(\n\t\t\t\t\t\tfakeOdspResolvedUrl,\n\t\t\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\t\t\tlocalSnapshot,\n\t\t\t\t\t),\n\t\t\t);\n\t\t});\n\n\t\tit(\"Can get resolvedUrl\", () => {\n\t\t\tconst resolvedUrl = fakeOdspResolvedUrl;\n\t\t\tconst service = new LocalOdspDocumentService(\n\t\t\t\tresolvedUrl,\n\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\tlocalSnapshot,\n\t\t\t);\n\t\t\tassert.strictEqual(service.resolvedUrl, resolvedUrl);\n\t\t});\n\n\t\tit(\"Delta storage service returns no messages\", async () => {\n\t\t\tconst service = new LocalOdspDocumentService(\n\t\t\t\tfakeOdspResolvedUrl,\n\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\tlocalSnapshot,\n\t\t\t);\n\n\t\t\t// Load snapshot\n\t\t\tconst storage = await service.connectToStorage();\n\t\t\tawait storage.getVersions(null, 1);\n\n\t\t\tconst deltaStorageService = await service.connectToDeltaStorage();\n\n\t\t\tconst allOps = await readAll(deltaStorageService.fetchMessages(0, undefined));\n\t\t\tassert.strictEqual(allOps.length, 0, \"There should be no messages\");\n\t\t});\n\n\t\tit(\"Delta storage service returns trailing ops\", async () => {\n\t\t\tconst snapshotWithTrailingOps = fs.readFileSync(\n\t\t\t\t`${__dirname}/../../src/test/localSnapshots/localSnapshot2.json`,\n\t\t\t\t{ encoding: \"utf8\" },\n\t\t\t);\n\t\t\tconst service = new LocalOdspDocumentService(\n\t\t\t\tfakeOdspResolvedUrl,\n\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\tsnapshotWithTrailingOps,\n\t\t\t);\n\n\t\t\t// Load snapshot\n\t\t\tconst storage = await service.connectToStorage();\n\t\t\tawait storage.getVersions(null, 1);\n\n\t\t\tconst deltaStorageService = await service.connectToDeltaStorage();\n\n\t\t\tconst allOps = await readAll(deltaStorageService.fetchMessages(179, undefined));\n\t\t\tassert.strictEqual(allOps.length, 13, \"There should be 13 messages\");\n\t\t});\n\n\t\tit(\"connectToDeltaStream throws error\", async () => {\n\t\t\tconst mockLogger = new MockLogger();\n\t\t\tconst service = new LocalOdspDocumentService(\n\t\t\t\tfakeOdspResolvedUrl,\n\t\t\t\tmockLogger.toTelemetryLogger(),\n\t\t\t\tlocalSnapshot,\n\t\t\t);\n\n\t\t\tconst client: IClient = {\n\t\t\t\tmode: \"read\",\n\t\t\t\tdetails: { capabilities: { interactive: true } },\n\t\t\t\tpermission: [],\n\t\t\t\tuser: { id: \"id\" },\n\t\t\t\tscopes: [],\n\t\t\t};\n\n\t\t\tawait assertThrowsUsageError(async () => service.connectToDeltaStream(client));\n\t\t\tmockLogger.assertMatch([{ eventName: \"UnsupportedUsage\" }], \"Expected log not present\");\n\t\t});\n\n\t\tit(\"Dispose does not throw\", () => {\n\t\t\tconst service = new LocalOdspDocumentService(\n\t\t\t\tfakeOdspResolvedUrl,\n\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\tlocalSnapshot,\n\t\t\t);\n\t\t\tassert.doesNotThrow(() => service.dispose());\n\t\t\tassert.doesNotThrow(() => service.dispose(null));\n\t\t\tassert.doesNotThrow(() => service.dispose(undefined));\n\t\t\tassert.doesNotThrow(() => service.dispose(new Error(\"I am an error\")));\n\t\t});\n\t});\n\n\tdescribe(\"Local Odsp document storage service\", () => {\n\t\tit(\"Can use a real snapshot\", () => {\n\t\t\tassert.doesNotThrow(\n\t\t\t\t() =>\n\t\t\t\t\tnew LocalOdspDocumentStorageService(\n\t\t\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\t\t\tlocalSnapshot,\n\t\t\t\t\t),\n\t\t\t);\n\t\t});\n\n\t\tit(\"uploadSummaryWithContext throws error\", async () => {\n\t\t\tconst mockLogger = new MockLogger();\n\n\t\t\tawait assertThrowsUsageError(async () =>\n\t\t\t\tnew LocalOdspDocumentStorageService(\n\t\t\t\t\tmockLogger.toTelemetryLogger(),\n\t\t\t\t\t\"sample data\",\n\t\t\t\t).uploadSummaryWithContext(\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\t\t\ttree: {},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tproposalHandle: undefined,\n\t\t\t\t\t\tackHandle: undefined,\n\t\t\t\t\t\treferenceSequenceNumber: 1,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t);\n\t\t\tmockLogger.assertMatch([{ eventName: \"UnsupportedUsage\" }], \"Expected log not present\");\n\t\t});\n\n\t\tit(\"createBlob throws error\", async () => {\n\t\t\tconst mockLogger = new MockLogger();\n\t\t\tconst storageService = new LocalOdspDocumentStorageService(\n\t\t\t\tmockLogger.toTelemetryLogger(),\n\t\t\t\t\"sample data\",\n\t\t\t);\n\n\t\t\tawait assertThrowsUsageError(async () => storageService.createBlob(new ArrayBuffer(0)));\n\t\t\tmockLogger.assertMatch([{ eventName: \"UnsupportedUsage\" }], \"Expected log not present\");\n\t\t});\n\n\t\tdescribe(\"getVersions\", () => {\n\t\t\tconst snapshotVersion = [{ id: \"bBwAAAAAHAAAA\", treeId: undefined! }];\n\n\t\t\tit(\"blobid should always be null\", async () => {\n\t\t\t\tconst storageService = new LocalOdspDocumentStorageService(\n\t\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\t\tlocalSnapshot,\n\t\t\t\t);\n\t\t\t\tawait assert.rejects(async () => storageService.getVersions(\"\", 1));\n\t\t\t\tawait assert.rejects(async () => storageService.getVersions(\"1\", 1));\n\t\t\t});\n\n\t\t\tit(\"count should always be 1\", async () => {\n\t\t\t\tconst storageService = new LocalOdspDocumentStorageService(\n\t\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\t\tlocalSnapshot,\n\t\t\t\t);\n\t\t\t\tawait assert.rejects(async () => storageService.getVersions(null, -1));\n\t\t\t\tawait assert.rejects(async () => storageService.getVersions(null, 0));\n\t\t\t\tawait assert.rejects(async () => storageService.getVersions(null, 2));\n\t\t\t});\n\n\t\t\tit(\"Retrieves snapshot version from JSON snapshot\", async () => {\n\t\t\t\tconst storageService = new LocalOdspDocumentStorageService(\n\t\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\t\tlocalSnapshot,\n\t\t\t\t);\n\t\t\t\tassert.deepStrictEqual(await storageService.getVersions(null, 1), snapshotVersion);\n\t\t\t});\n\n\t\t\tit(\"Calling multiple times\", async () => {\n\t\t\t\tconst storageService = new LocalOdspDocumentStorageService(\n\t\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\t\tlocalSnapshot,\n\t\t\t\t);\n\t\t\t\tfor (let i = 0; i < 3; i++) {\n\t\t\t\t\tassert.deepStrictEqual(\n\t\t\t\t\t\tawait storageService.getVersions(null, 1),\n\t\t\t\t\t\tsnapshotVersion,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t});\n});\n"]}
1
+ {"version":3,"file":"localOdspDriver.spec.js","sourceRoot":"","sources":["../../src/test/localOdspDriver.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,SAAS,CAAC;A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;gBACF,MAAM,CAAC,eAAe,CAAC,MAAM,cAAc,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;YACpF,CAAC,CAAC,CAAC;YAEH,EAAE,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;gBACvC,MAAM,cAAc,GAAG,IAAI,+BAA+B,CACzD,IAAI,UAAU,EAAE,CAAC,iBAAiB,EAAE,EACpC,aAAa,CACb,CAAC;gBACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;oBAC3B,MAAM,CAAC,eAAe,CACrB,MAAM,cAAc,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,EACzC,eAAe,CACf,CAAC;iBACF;YACF,CAAC,CAAC,CAAC;QACJ,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 fs from \"node:fs\";\nimport { DriverError, IStream } from \"@fluidframework/driver-definitions\";\nimport { IOdspResolvedUrl, OdspErrorTypes } from \"@fluidframework/odsp-driver-definitions\";\nimport {\n\tIClient,\n\tISequencedDocumentMessage,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport { MockLogger } from \"@fluidframework/telemetry-utils\";\n\n/* eslint-disable import/no-internal-modules */\nimport { LocalOdspDocumentService } from \"../localOdspDriver/localOdspDocumentService.js\";\nimport { LocalOdspDocumentServiceFactory } from \"../localOdspDriver/localOdspDocumentServiceFactory.js\";\nimport { LocalOdspDocumentStorageService } from \"../localOdspDriver/localOdspDocumentStorageManager.js\";\n/* eslint-enable import/no-internal-modules */\n\ndescribe(\"Local Odsp driver\", () => {\n\t// TODO: add end-to-end test\n\n\tconst fakeOdspResolvedUrl: IOdspResolvedUrl = {\n\t\ttype: \"fluid\",\n\t\todspResolvedUrl: true,\n\t\tid: \"1\",\n\t\tsiteUrl: \"fakeUrl\",\n\t\tdriveId: \"1\",\n\t\titemId: \"1\",\n\t\turl: \"fakeUrl\",\n\t\thashedDocumentId: \"1\",\n\t\tendpoints: {\n\t\t\tsnapshotStorageUrl: \"fakeUrl\",\n\t\t\tattachmentPOSTStorageUrl: \"fakeUrl\",\n\t\t\tattachmentGETStorageUrl: \"fakeUrl\",\n\t\t\tdeltaStorageUrl: \"fakeUrl\",\n\t\t},\n\t\ttokens: {},\n\t\tfileName: \"fakeName\",\n\t\tsummarizer: false,\n\t\tfileVersion: \"1\",\n\t};\n\n\tconst localSnapshot = fs.readFileSync(\n\t\t`${__dirname}/../../src/test/localSnapshots/localSnapshot1.json`,\n\t\t{ encoding: \"utf8\" },\n\t);\n\n\tasync function assertThrowsUsageError(fn: () => Promise<unknown>): Promise<void> {\n\t\tawait assert.rejects(fn, (e: DriverError) => e.errorType === OdspErrorTypes.usageError);\n\t}\n\n\tdescribe(\"Local Odsp document service factory\", () => {\n\t\tit(\"Can use a real snapshot\", () => {\n\t\t\tassert.doesNotThrow(() => new LocalOdspDocumentServiceFactory(localSnapshot));\n\t\t});\n\n\t\tit(\"createContainer throws error\", async () => {\n\t\t\tawait assertThrowsUsageError(async () =>\n\t\t\t\tnew LocalOdspDocumentServiceFactory(\"sample data\").createContainer(\n\t\t\t\t\tundefined,\n\t\t\t\t\tfakeOdspResolvedUrl,\n\t\t\t\t),\n\t\t\t);\n\t\t});\n\n\t\tdescribe(\"createDocumentService\", () => {\n\t\t\tit(\"clientIsSummarizer should be undefined or false\", async () => {\n\t\t\t\tconst factory = new LocalOdspDocumentServiceFactory(\"sample data\");\n\t\t\t\tawait assert.doesNotReject(async () => {\n\t\t\t\t\tawait factory.createDocumentService(fakeOdspResolvedUrl);\n\t\t\t\t});\n\t\t\t\tawait assert.doesNotReject(async () => {\n\t\t\t\t\tawait factory.createDocumentService(fakeOdspResolvedUrl, undefined, undefined);\n\t\t\t\t});\n\t\t\t\tawait factory.createDocumentService(fakeOdspResolvedUrl, undefined, false);\n\t\t\t\tawait assert.rejects(async () => {\n\t\t\t\t\tawait factory.createDocumentService(fakeOdspResolvedUrl, undefined, true);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tit(\"resolvedUrl must be IOdspResolvedUrl\", async () => {\n\t\t\t\tconst factory = new LocalOdspDocumentServiceFactory(\"sample data\");\n\t\t\t\tawait assert.doesNotReject(async () =>\n\t\t\t\t\tfactory.createDocumentService(fakeOdspResolvedUrl),\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe(\"Local Odsp document service\", () => {\n\t\tasync function readAll(\n\t\t\tstream: IStream<ISequencedDocumentMessage[]>,\n\t\t): Promise<ISequencedDocumentMessage[]> {\n\t\t\tconst ops: ISequencedDocumentMessage[] = [];\n\t\t\t// eslint-disable-next-line no-constant-condition\n\t\t\twhile (true) {\n\t\t\t\tconst result = await stream.read();\n\t\t\t\tif (result.done) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tops.push(...result.value);\n\t\t\t}\n\t\t\treturn ops;\n\t\t}\n\n\t\tit(\"Can use a real snapshot\", () => {\n\t\t\tassert.doesNotThrow(\n\t\t\t\t() =>\n\t\t\t\t\tnew LocalOdspDocumentService(\n\t\t\t\t\t\tfakeOdspResolvedUrl,\n\t\t\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\t\t\tlocalSnapshot,\n\t\t\t\t\t),\n\t\t\t);\n\t\t});\n\n\t\tit(\"Can get resolvedUrl\", () => {\n\t\t\tconst resolvedUrl = fakeOdspResolvedUrl;\n\t\t\tconst service = new LocalOdspDocumentService(\n\t\t\t\tresolvedUrl,\n\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\tlocalSnapshot,\n\t\t\t);\n\t\t\tassert.strictEqual(service.resolvedUrl, resolvedUrl);\n\t\t});\n\n\t\tit(\"Delta storage service returns no messages\", async () => {\n\t\t\tconst service = new LocalOdspDocumentService(\n\t\t\t\tfakeOdspResolvedUrl,\n\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\tlocalSnapshot,\n\t\t\t);\n\n\t\t\t// Load snapshot\n\t\t\tconst storage = await service.connectToStorage();\n\t\t\tawait storage.getVersions(null, 1);\n\n\t\t\tconst deltaStorageService = await service.connectToDeltaStorage();\n\n\t\t\tconst allOps = await readAll(deltaStorageService.fetchMessages(0, undefined));\n\t\t\tassert.strictEqual(allOps.length, 0, \"There should be no messages\");\n\t\t});\n\n\t\tit(\"Delta storage service returns trailing ops\", async () => {\n\t\t\tconst snapshotWithTrailingOps = fs.readFileSync(\n\t\t\t\t`${__dirname}/../../src/test/localSnapshots/localSnapshot2.json`,\n\t\t\t\t{ encoding: \"utf8\" },\n\t\t\t);\n\t\t\tconst service = new LocalOdspDocumentService(\n\t\t\t\tfakeOdspResolvedUrl,\n\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\tsnapshotWithTrailingOps,\n\t\t\t);\n\n\t\t\t// Load snapshot\n\t\t\tconst storage = await service.connectToStorage();\n\t\t\tawait storage.getVersions(null, 1);\n\n\t\t\tconst deltaStorageService = await service.connectToDeltaStorage();\n\n\t\t\tconst allOps = await readAll(deltaStorageService.fetchMessages(179, undefined));\n\t\t\tassert.strictEqual(allOps.length, 13, \"There should be 13 messages\");\n\t\t});\n\n\t\tit(\"connectToDeltaStream throws error\", async () => {\n\t\t\tconst mockLogger = new MockLogger();\n\t\t\tconst service = new LocalOdspDocumentService(\n\t\t\t\tfakeOdspResolvedUrl,\n\t\t\t\tmockLogger.toTelemetryLogger(),\n\t\t\t\tlocalSnapshot,\n\t\t\t);\n\n\t\t\tconst client: IClient = {\n\t\t\t\tmode: \"read\",\n\t\t\t\tdetails: { capabilities: { interactive: true } },\n\t\t\t\tpermission: [],\n\t\t\t\tuser: { id: \"id\" },\n\t\t\t\tscopes: [],\n\t\t\t};\n\n\t\t\tawait assertThrowsUsageError(async () => service.connectToDeltaStream(client));\n\t\t\tmockLogger.assertMatch([{ eventName: \"UnsupportedUsage\" }], \"Expected log not present\");\n\t\t});\n\n\t\tit(\"Dispose does not throw\", () => {\n\t\t\tconst service = new LocalOdspDocumentService(\n\t\t\t\tfakeOdspResolvedUrl,\n\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\tlocalSnapshot,\n\t\t\t);\n\t\t\tassert.doesNotThrow(() => service.dispose());\n\t\t\tassert.doesNotThrow(() => service.dispose(null));\n\t\t\tassert.doesNotThrow(() => service.dispose(undefined));\n\t\t\tassert.doesNotThrow(() => service.dispose(new Error(\"I am an error\")));\n\t\t});\n\t});\n\n\tdescribe(\"Local Odsp document storage service\", () => {\n\t\tit(\"Can use a real snapshot\", () => {\n\t\t\tassert.doesNotThrow(\n\t\t\t\t() =>\n\t\t\t\t\tnew LocalOdspDocumentStorageService(\n\t\t\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\t\t\tlocalSnapshot,\n\t\t\t\t\t),\n\t\t\t);\n\t\t});\n\n\t\tit(\"uploadSummaryWithContext throws error\", async () => {\n\t\t\tconst mockLogger = new MockLogger();\n\n\t\t\tawait assertThrowsUsageError(async () =>\n\t\t\t\tnew LocalOdspDocumentStorageService(\n\t\t\t\t\tmockLogger.toTelemetryLogger(),\n\t\t\t\t\t\"sample data\",\n\t\t\t\t).uploadSummaryWithContext(\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\t\t\ttree: {},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tproposalHandle: undefined,\n\t\t\t\t\t\tackHandle: undefined,\n\t\t\t\t\t\treferenceSequenceNumber: 1,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t);\n\t\t\tmockLogger.assertMatch([{ eventName: \"UnsupportedUsage\" }], \"Expected log not present\");\n\t\t});\n\n\t\tit(\"createBlob throws error\", async () => {\n\t\t\tconst mockLogger = new MockLogger();\n\t\t\tconst storageService = new LocalOdspDocumentStorageService(\n\t\t\t\tmockLogger.toTelemetryLogger(),\n\t\t\t\t\"sample data\",\n\t\t\t);\n\n\t\t\tawait assertThrowsUsageError(async () => storageService.createBlob(new ArrayBuffer(0)));\n\t\t\tmockLogger.assertMatch([{ eventName: \"UnsupportedUsage\" }], \"Expected log not present\");\n\t\t});\n\n\t\tdescribe(\"getVersions\", () => {\n\t\t\tconst snapshotVersion = [{ id: \"bBwAAAAAHAAAA\", treeId: undefined! }];\n\n\t\t\tit(\"blobid should always be null\", async () => {\n\t\t\t\tconst storageService = new LocalOdspDocumentStorageService(\n\t\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\t\tlocalSnapshot,\n\t\t\t\t);\n\t\t\t\tawait assert.rejects(async () => storageService.getVersions(\"\", 1));\n\t\t\t\tawait assert.rejects(async () => storageService.getVersions(\"1\", 1));\n\t\t\t});\n\n\t\t\tit(\"count should always be 1\", async () => {\n\t\t\t\tconst storageService = new LocalOdspDocumentStorageService(\n\t\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\t\tlocalSnapshot,\n\t\t\t\t);\n\t\t\t\tawait assert.rejects(async () => storageService.getVersions(null, -1));\n\t\t\t\tawait assert.rejects(async () => storageService.getVersions(null, 0));\n\t\t\t\tawait assert.rejects(async () => storageService.getVersions(null, 2));\n\t\t\t});\n\n\t\t\tit(\"Retrieves snapshot version from JSON snapshot\", async () => {\n\t\t\t\tconst storageService = new LocalOdspDocumentStorageService(\n\t\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\t\tlocalSnapshot,\n\t\t\t\t);\n\t\t\t\tassert.deepStrictEqual(await storageService.getVersions(null, 1), snapshotVersion);\n\t\t\t});\n\n\t\t\tit(\"Calling multiple times\", async () => {\n\t\t\t\tconst storageService = new LocalOdspDocumentStorageService(\n\t\t\t\t\tnew MockLogger().toTelemetryLogger(),\n\t\t\t\t\tlocalSnapshot,\n\t\t\t\t);\n\t\t\t\tfor (let i = 0; i < 3; i++) {\n\t\t\t\t\tassert.deepStrictEqual(\n\t\t\t\t\t\tawait storageService.getVersions(null, 1),\n\t\t\t\t\t\tsnapshotVersion,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t});\n});\n"]}
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import assert from "node:assert";
6
- import { stub } from "sinon";
7
6
  import * as fetchModule from "node-fetch";
7
+ import { stub } from "sinon";
8
8
  export const createResponse = async (headers, response, status) => ({
9
9
  ok: response !== undefined,
10
10
  status,
@@ -1 +1 @@
1
- {"version":3,"file":"mockFetch.js","sourceRoot":"","sources":["../../src/test/mockFetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,WAAW,MAAM,YAAY,CAAC;AAc1C,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAClC,OAAkC,EAClC,QAAiB,EACjB,MAAc,EACU,EAAE,CAAC,CAAC;IAC5B,EAAE,EAAE,QAAQ,KAAK,SAAS;IAC1B,MAAM;IACN,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;IAC1C,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ;IACjC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE;IAC/E,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ;CAC1B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAC9B,OAAkC,EAClC,QAAgB,EACQ,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAA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,CAAC,KAAK,UAAU,cAAc,CACnC,QAA0B,EAC1B,QAAe,EACf,OAAsB,QAAQ;IAE9B,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAC/C,SAAS,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,IAAI,IAAI,KAAK,UAAU,EAAE;YACxB,SAAS,CAAC,OAAO,EAAE,CAAC;SACpB;QACD,MAAM,QAAQ,CAAC;IAChB,CAAC,CAAC,CAAC;IACH,IAAI;QACH,OAAO,MAAM,QAAQ,EAAE,CAAC;KACxB;YAAS;QACT,IAAI,IAAI,KAAK,UAAU,EAAE;YACxB,SAAS,CAAC,OAAO,EAAE,CAAC;SACpB;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport assert from \"node:assert\";\nimport { stub } from \"sinon\";\nimport * as fetchModule from \"node-fetch\";\n\n/**\n * Mock response returned by {@link createResponse}.\n */\nexport interface MockResponse {\n\tok: boolean;\n\tstatus: number;\n\ttext: () => Promise<string>;\n\tarrayBuffer: () => Promise<unknown>;\n\theaders: fetchModule.Headers;\n\tjson: () => Promise<unknown>;\n}\n\nexport const createResponse = async (\n\theaders: { [key: string]: string },\n\tresponse: unknown,\n\tstatus: number,\n): Promise<MockResponse> => ({\n\tok: response !== undefined,\n\tstatus,\n\ttext: async () => JSON.stringify(response),\n\tarrayBuffer: async () => response,\n\theaders: headers ? new fetchModule.Headers(headers) : new fetchModule.Headers(),\n\tjson: async () => response,\n});\n\nexport const okResponse = async (\n\theaders: { [key: string]: string },\n\tresponse: object,\n): Promise<MockResponse> => createResponse(headers, response, 200);\nexport const notFound = async (headers: { [key: string]: string } = {}): Promise<MockResponse> =>\n\tcreateResponse(headers, undefined, 404);\n\nexport type FetchCallType = \"internal\" | \"external\" | \"single\";\n\nexport async function mockFetchMultiple<T>(\n\tcallback: () => Promise<T>,\n\tresponses: (() => Promise<object>)[],\n\ttype: FetchCallType = \"single\",\n): Promise<T> {\n\tconst fetchStub = stub(fetchModule, \"default\");\n\tfetchStub.callsFake(async () => {\n\t\tif (type === \"external\") {\n\t\t\tfetchStub.restore();\n\t\t}\n\t\tconst cb = responses.shift();\n\t\tassert(cb !== undefined, \"the end\");\n\t\treturn cb() as Promise<fetchModule.Response>;\n\t});\n\ttry {\n\t\treturn await callback();\n\t} finally {\n\t\tif (type !== \"internal\") {\n\t\t\tfetchStub.restore();\n\t\t}\n\t\tassert(responses.length === 0, \"all responses used\");\n\t}\n}\n\nexport async function mockFetchSingle<T>(\n\tcallback: () => Promise<T>,\n\tresponseType: () => Promise<object>,\n\ttype: FetchCallType = \"single\",\n): Promise<T> {\n\treturn mockFetchMultiple(callback, [responseType], type);\n}\n\nexport async function mockFetchOk<T>(\n\tcallback: () => Promise<T>,\n\tresponse = {},\n\theaders: { [key: string]: string } = {},\n): Promise<T> {\n\treturn mockFetchSingle(callback, async () => okResponse(headers, response));\n}\n\nexport async function mockFetchError<T>(\n\tcallback: () => Promise<T>,\n\tresponse: Error,\n\ttype: FetchCallType = \"single\",\n): Promise<T> {\n\tconst fetchStub = stub(fetchModule, \"default\");\n\tfetchStub.callsFake(async () => {\n\t\tif (type === \"external\") {\n\t\t\tfetchStub.restore();\n\t\t}\n\t\tthrow response;\n\t});\n\ttry {\n\t\treturn await callback();\n\t} finally {\n\t\tif (type !== \"internal\") {\n\t\t\tfetchStub.restore();\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"mockFetch.js","sourceRoot":"","sources":["../../src/test/mockFetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,WAAW,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAc7B,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAClC,OAAkC,EAClC,QAAiB,EACjB,MAA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AE;YACxB,SAAS,CAAC,OAAO,EAAE,CAAC;SACpB;QACD,MAAM,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,oBAAoB,CAAC,CAAC;KACrD;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,QAA0B,EAC1B,YAAmC,EACnC,OAAsB,QAAQ;IAE9B,OAAO,iBAAiB,CAAC,QAAQ,EAAE,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAChC,QAA0B,EAC1B,QAAQ,GAAG,EAAE,EACb,UAAqC,EAAE;IAEvC,OAAO,eAAe,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,QAA0B,EAC1B,QAAe,EACf,OAAsB,QAAQ;IAE9B,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAC/C,SAAS,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,IAAI,IAAI,KAAK,UAAU,EAAE;YACxB,SAAS,CAAC,OAAO,EAAE,CAAC;SACpB;QACD,MAAM,QAAQ,CAAC;IAChB,CAAC,CAAC,CAAC;IACH,IAAI;QACH,OAAO,MAAM,QAAQ,EAAE,CAAC;KACxB;YAAS;QACT,IAAI,IAAI,KAAK,UAAU,EAAE;YACxB,SAAS,CAAC,OAAO,EAAE,CAAC;SACpB;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport assert from \"node:assert\";\nimport * as fetchModule from \"node-fetch\";\nimport { stub } from \"sinon\";\n\n/**\n * Mock response returned by {@link createResponse}.\n */\nexport interface MockResponse {\n\tok: boolean;\n\tstatus: number;\n\ttext: () => Promise<string>;\n\tarrayBuffer: () => Promise<unknown>;\n\theaders: fetchModule.Headers;\n\tjson: () => Promise<unknown>;\n}\n\nexport const createResponse = async (\n\theaders: { [key: string]: string },\n\tresponse: unknown,\n\tstatus: number,\n): Promise<MockResponse> => ({\n\tok: response !== undefined,\n\tstatus,\n\ttext: async () => JSON.stringify(response),\n\tarrayBuffer: async () => response,\n\theaders: headers ? new fetchModule.Headers(headers) : new fetchModule.Headers(),\n\tjson: async () => response,\n});\n\nexport const okResponse = async (\n\theaders: { [key: string]: string },\n\tresponse: object,\n): Promise<MockResponse> => createResponse(headers, response, 200);\nexport const notFound = async (headers: { [key: string]: string } = {}): Promise<MockResponse> =>\n\tcreateResponse(headers, undefined, 404);\n\nexport type FetchCallType = \"internal\" | \"external\" | \"single\";\n\nexport async function mockFetchMultiple<T>(\n\tcallback: () => Promise<T>,\n\tresponses: (() => Promise<object>)[],\n\ttype: FetchCallType = \"single\",\n): Promise<T> {\n\tconst fetchStub = stub(fetchModule, \"default\");\n\tfetchStub.callsFake(async () => {\n\t\tif (type === \"external\") {\n\t\t\tfetchStub.restore();\n\t\t}\n\t\tconst cb = responses.shift();\n\t\tassert(cb !== undefined, \"the end\");\n\t\treturn cb() as Promise<fetchModule.Response>;\n\t});\n\ttry {\n\t\treturn await callback();\n\t} finally {\n\t\tif (type !== \"internal\") {\n\t\t\tfetchStub.restore();\n\t\t}\n\t\tassert(responses.length === 0, \"all responses used\");\n\t}\n}\n\nexport async function mockFetchSingle<T>(\n\tcallback: () => Promise<T>,\n\tresponseType: () => Promise<object>,\n\ttype: FetchCallType = \"single\",\n): Promise<T> {\n\treturn mockFetchMultiple(callback, [responseType], type);\n}\n\nexport async function mockFetchOk<T>(\n\tcallback: () => Promise<T>,\n\tresponse = {},\n\theaders: { [key: string]: string } = {},\n): Promise<T> {\n\treturn mockFetchSingle(callback, async () => okResponse(headers, response));\n}\n\nexport async function mockFetchError<T>(\n\tcallback: () => Promise<T>,\n\tresponse: Error,\n\ttype: FetchCallType = \"single\",\n): Promise<T> {\n\tconst fetchStub = stub(fetchModule, \"default\");\n\tfetchStub.callsFake(async () => {\n\t\tif (type === \"external\") {\n\t\t\tfetchStub.restore();\n\t\t}\n\t\tthrow response;\n\t});\n\ttry {\n\t\treturn await callback();\n\t} finally {\n\t\tif (type !== \"internal\") {\n\t\t\tfetchStub.restore();\n\t\t}\n\t}\n}\n"]}
@@ -3,16 +3,16 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { strict as assert } from "node:assert";
6
- import { MockLogger, isFluidError } from "@fluidframework/telemetry-utils";
7
- import { SummaryType } from "@fluidframework/protocol-definitions";
8
6
  import { OdspErrorTypes } from "@fluidframework/odsp-driver-definitions";
9
- import { OdspDriverUrlResolver } from "../odspDriverUrlResolver.js";
7
+ import { SummaryType } from "@fluidframework/protocol-definitions";
8
+ import { MockLogger, isFluidError } from "@fluidframework/telemetry-utils";
9
+ import { createOdspCreateContainerRequest } from "../createOdspCreateContainerRequest.js";
10
+ import { LocalPersistentCache } from "../odspCache.js";
10
11
  import { OdspDocumentServiceFactory } from "../odspDocumentServiceFactory.js";
11
- import { getOdspResolvedUrl } from "../odspUtils.js";
12
+ import { OdspDriverUrlResolver } from "../odspDriverUrlResolver.js";
12
13
  import { getHashedDocumentId } from "../odspPublicUtils.js";
13
- import { LocalPersistentCache } from "../odspCache.js";
14
- import { createOdspCreateContainerRequest } from "../createOdspCreateContainerRequest.js";
15
- import { mockFetchOk, mockFetchMultiple, okResponse } from "./mockFetch.js";
14
+ import { getOdspResolvedUrl } from "../odspUtils.js";
15
+ import { mockFetchMultiple, mockFetchOk, okResponse } from "./mockFetch.js";
16
16
  describe("Odsp Create Container Test", () => {
17
17
  const siteUrl = "https://www.localhost.xxx";
18
18
  const driveId = "driveId";