@fluidframework/odsp-driver 2.0.0-dev-rc.1.0.0.232845 → 2.0.0-dev-rc.2.0.0.246488
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +18 -3
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +44 -0
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor-lint.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/odsp-driver.api.md +11 -12
- package/dist/ReadBufferUtils.d.ts.map +1 -1
- package/dist/ReadBufferUtils.js.map +1 -1
- package/dist/WriteBufferUtils.d.ts +1 -1
- package/dist/WriteBufferUtils.d.ts.map +1 -1
- package/dist/WriteBufferUtils.js +12 -12
- package/dist/WriteBufferUtils.js.map +1 -1
- package/dist/checkUrl.d.ts.map +1 -1
- package/dist/checkUrl.js +5 -3
- package/dist/checkUrl.js.map +1 -1
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +87 -69
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/compactSnapshotWriter.d.ts.map +1 -1
- package/dist/compactSnapshotWriter.js +25 -19
- package/dist/compactSnapshotWriter.js.map +1 -1
- package/dist/contracts.d.ts +10 -4
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/createFile.d.ts +3 -3
- package/dist/createFile.d.ts.map +1 -1
- package/dist/createFile.js +30 -27
- package/dist/createFile.js.map +1 -1
- package/dist/createNewContainerOnExistingFile.d.ts +2 -2
- package/dist/createNewContainerOnExistingFile.d.ts.map +1 -1
- package/dist/createNewContainerOnExistingFile.js +14 -14
- package/dist/createNewContainerOnExistingFile.js.map +1 -1
- package/dist/createNewModule.d.ts +2 -2
- package/dist/createNewModule.d.ts.map +1 -1
- package/dist/createNewModule.js +4 -4
- package/dist/createNewModule.js.map +1 -1
- package/dist/createNewUtils.d.ts +2 -2
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +12 -8
- package/dist/createNewUtils.js.map +1 -1
- package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/dist/createOdspCreateContainerRequest.js +6 -2
- package/dist/createOdspCreateContainerRequest.js.map +1 -1
- package/dist/createOdspUrl.d.ts +1 -1
- package/dist/createOdspUrl.d.ts.map +1 -1
- package/dist/createOdspUrl.js.map +1 -1
- package/dist/epochTracker.d.ts +10 -9
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +66 -43
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetchSnapshot.d.ts +11 -8
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +79 -58
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/getFileLink.d.ts.map +1 -1
- package/dist/getFileLink.js +24 -17
- package/dist/getFileLink.js.map +1 -1
- package/dist/getQueryString.d.ts.map +1 -1
- package/dist/getQueryString.js +6 -0
- package/dist/getQueryString.js.map +1 -1
- package/dist/index.d.ts +19 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -44
- package/dist/index.js.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentService.d.ts +1 -1
- package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentService.js +5 -5
- package/dist/localOdspDriver/localOdspDocumentService.js.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +8 -6
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.js +10 -9
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts +1 -1
- package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentStorageManager.js +6 -6
- package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -1
- package/dist/odsp-driver-alpha.d.ts +27 -12
- package/dist/odsp-driver-beta.d.ts +1 -2
- package/dist/odsp-driver-public.d.ts +1 -2
- package/dist/odsp-driver-untrimmed.d.ts +29 -12
- package/dist/odspCache.d.ts +3 -3
- package/dist/odspCache.d.ts.map +1 -1
- package/dist/odspCache.js +3 -4
- package/dist/odspCache.js.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.d.ts +7 -5
- package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.js +41 -28
- package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
- package/dist/odspDeltaStorageService.d.ts +7 -7
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/odspDeltaStorageService.js +5 -5
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +41 -23
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentService.d.ts +6 -4
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/odspDocumentService.js +19 -16
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactory.d.ts +6 -1
- package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactory.js +9 -4
- package/dist/odspDocumentServiceFactory.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts +4 -4
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +26 -22
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +1 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.js +2 -2
- package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +15 -9
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +219 -181
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts +2 -4
- package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/dist/odspDocumentStorageServiceBase.js +32 -29
- package/dist/odspDocumentStorageServiceBase.js.map +1 -1
- package/dist/odspDriverUrlResolver.d.ts +5 -1
- package/dist/odspDriverUrlResolver.d.ts.map +1 -1
- package/dist/odspDriverUrlResolver.js +27 -24
- package/dist/odspDriverUrlResolver.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts +17 -6
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +49 -39
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspError.d.ts +1 -1
- package/dist/odspError.d.ts.map +1 -1
- package/dist/odspError.js +5 -5
- package/dist/odspError.js.map +1 -1
- package/dist/odspFluidFileLink.d.ts +1 -1
- package/dist/odspFluidFileLink.d.ts.map +1 -1
- package/dist/odspFluidFileLink.js +2 -2
- package/dist/odspFluidFileLink.js.map +1 -1
- package/dist/odspLocationRedirection.js +2 -2
- package/dist/odspLocationRedirection.js.map +1 -1
- package/dist/odspPublicUtils.d.ts +3 -0
- package/dist/odspPublicUtils.d.ts.map +1 -1
- package/dist/odspPublicUtils.js +3 -0
- package/dist/odspPublicUtils.js.map +1 -1
- package/dist/odspSnapshotParser.d.ts +1 -1
- package/dist/odspSnapshotParser.d.ts.map +1 -1
- package/dist/odspSnapshotParser.js +3 -2
- package/dist/odspSnapshotParser.js.map +1 -1
- package/dist/odspSummaryUploadManager.d.ts +1 -1
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/odspSummaryUploadManager.js +9 -6
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/odspUrlHelper.d.ts.map +1 -1
- package/dist/odspUrlHelper.js +1 -2
- package/dist/odspUrlHelper.js.map +1 -1
- package/dist/odspUtils.d.ts +19 -7
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +61 -31
- package/dist/odspUtils.js.map +1 -1
- package/dist/opsCaching.d.ts +1 -1
- package/dist/opsCaching.d.ts.map +1 -1
- package/dist/opsCaching.js +2 -1
- package/dist/opsCaching.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/prefetchLatestSnapshot.d.ts +2 -2
- package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
- package/dist/prefetchLatestSnapshot.js +17 -12
- package/dist/prefetchLatestSnapshot.js.map +1 -1
- package/dist/retryErrorsStorageAdapter.d.ts +0 -1
- package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/dist/retryErrorsStorageAdapter.js +2 -5
- package/dist/retryErrorsStorageAdapter.js.map +1 -1
- package/dist/retryUtils.d.ts.map +1 -1
- package/dist/retryUtils.js +6 -2
- package/dist/retryUtils.js.map +1 -1
- package/dist/socketModule.d.ts.map +1 -1
- package/dist/socketModule.js +2 -0
- package/dist/socketModule.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/vroom.d.ts +2 -2
- package/dist/vroom.d.ts.map +1 -1
- package/dist/vroom.js +5 -5
- package/dist/vroom.js.map +1 -1
- package/dist/zipItDataRepresentationUtils.d.ts +1 -1
- package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/dist/zipItDataRepresentationUtils.js +15 -11
- package/dist/zipItDataRepresentationUtils.js.map +1 -1
- package/lib/{ReadBufferUtils.d.mts → ReadBufferUtils.d.ts} +1 -1
- package/lib/ReadBufferUtils.d.ts.map +1 -0
- package/lib/{ReadBufferUtils.mjs → ReadBufferUtils.js} +1 -1
- package/lib/ReadBufferUtils.js.map +1 -0
- package/lib/{WriteBufferUtils.d.mts → WriteBufferUtils.d.ts} +2 -2
- package/lib/WriteBufferUtils.d.ts.map +1 -0
- package/lib/{WriteBufferUtils.mjs → WriteBufferUtils.js} +2 -2
- package/lib/WriteBufferUtils.js.map +1 -0
- package/lib/{checkUrl.d.mts → checkUrl.d.ts} +1 -1
- package/lib/checkUrl.d.ts.map +1 -0
- package/lib/{checkUrl.mjs → checkUrl.js} +5 -3
- package/lib/checkUrl.js.map +1 -0
- package/lib/{compactSnapshotParser.d.mts → compactSnapshotParser.d.ts} +1 -1
- package/lib/compactSnapshotParser.d.ts.map +1 -0
- package/lib/{compactSnapshotParser.mjs → compactSnapshotParser.js} +61 -43
- package/lib/compactSnapshotParser.js.map +1 -0
- package/lib/{compactSnapshotWriter.d.mts → compactSnapshotWriter.d.ts} +1 -1
- package/lib/compactSnapshotWriter.d.ts.map +1 -0
- package/lib/{compactSnapshotWriter.mjs → compactSnapshotWriter.js} +13 -7
- package/lib/compactSnapshotWriter.js.map +1 -0
- package/lib/{constants.d.mts → constants.d.ts} +1 -1
- package/lib/constants.d.ts.map +1 -0
- package/lib/{constants.mjs → constants.js} +1 -1
- package/lib/constants.js.map +1 -0
- package/lib/{contracts.d.mts → contracts.d.ts} +11 -5
- package/lib/contracts.d.ts.map +1 -0
- package/lib/{contracts.mjs → contracts.js} +1 -1
- package/lib/contracts.js.map +1 -0
- package/lib/{contractsPublic.d.mts → contractsPublic.d.ts} +1 -1
- package/lib/contractsPublic.d.ts.map +1 -0
- package/lib/{contractsPublic.mjs → contractsPublic.js} +1 -1
- package/lib/contractsPublic.js.map +1 -0
- package/lib/{createFile.d.mts → createFile.d.ts} +4 -4
- package/lib/createFile.d.ts.map +1 -0
- package/lib/{createFile.mjs → createFile.js} +15 -12
- package/lib/createFile.js.map +1 -0
- package/lib/{createNewContainerOnExistingFile.d.mts → createNewContainerOnExistingFile.d.ts} +3 -3
- package/lib/createNewContainerOnExistingFile.d.ts.map +1 -0
- package/lib/{createNewContainerOnExistingFile.mjs → createNewContainerOnExistingFile.js} +7 -7
- package/lib/createNewContainerOnExistingFile.js.map +1 -0
- package/lib/{createNewModule.mjs → createNewModule.d.ts} +3 -3
- package/lib/createNewModule.d.ts.map +1 -0
- package/lib/{createNewModule.d.mts → createNewModule.js} +3 -3
- package/lib/createNewModule.js.map +1 -0
- package/lib/{createNewUtils.d.mts → createNewUtils.d.ts} +3 -3
- package/lib/createNewUtils.d.ts.map +1 -0
- package/lib/{createNewUtils.mjs → createNewUtils.js} +9 -5
- package/lib/createNewUtils.js.map +1 -0
- package/lib/{createOdspCreateContainerRequest.d.mts → createOdspCreateContainerRequest.d.ts} +5 -1
- package/lib/createOdspCreateContainerRequest.d.ts.map +1 -0
- package/lib/{createOdspCreateContainerRequest.mjs → createOdspCreateContainerRequest.js} +6 -2
- package/lib/createOdspCreateContainerRequest.js.map +1 -0
- package/lib/{createOdspUrl.d.mts → createOdspUrl.d.ts} +2 -2
- package/lib/createOdspUrl.d.ts.map +1 -0
- package/lib/{createOdspUrl.mjs → createOdspUrl.js} +1 -1
- package/lib/createOdspUrl.js.map +1 -0
- package/lib/{epochTracker.d.mts → epochTracker.d.ts} +11 -10
- package/lib/epochTracker.d.ts.map +1 -0
- package/lib/{epochTracker.mjs → epochTracker.js} +56 -33
- package/lib/epochTracker.js.map +1 -0
- package/lib/{fetch.d.mts → fetch.d.ts} +1 -1
- package/lib/fetch.d.ts.map +1 -0
- package/lib/{fetch.mjs → fetch.js} +1 -1
- package/lib/fetch.js.map +1 -0
- package/lib/{fetchSnapshot.d.mts → fetchSnapshot.d.ts} +12 -9
- package/lib/fetchSnapshot.d.ts.map +1 -0
- package/lib/{fetchSnapshot.mjs → fetchSnapshot.js} +61 -40
- package/lib/fetchSnapshot.js.map +1 -0
- package/lib/{getFileLink.d.mts → getFileLink.d.ts} +1 -1
- package/lib/getFileLink.d.ts.map +1 -0
- package/lib/{getFileLink.mjs → getFileLink.js} +14 -7
- package/lib/getFileLink.js.map +1 -0
- package/lib/{getQueryString.d.mts → getQueryString.d.ts} +5 -1
- package/lib/getQueryString.d.ts.map +1 -0
- package/lib/{getQueryString.mjs → getQueryString.js} +7 -1
- package/lib/getQueryString.js.map +1 -0
- package/lib/{getUrlAndHeadersWithAuth.d.mts → getUrlAndHeadersWithAuth.d.ts} +1 -1
- package/lib/getUrlAndHeadersWithAuth.d.ts.map +1 -0
- package/lib/{getUrlAndHeadersWithAuth.mjs → getUrlAndHeadersWithAuth.js} +1 -1
- package/lib/getUrlAndHeadersWithAuth.js.map +1 -0
- package/lib/{index.d.mts → index.d.ts} +20 -20
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +29 -0
- package/lib/index.js.map +1 -0
- package/lib/localOdspDriver/{localOdspDeltaStorageService.d.mts → localOdspDeltaStorageService.d.ts} +1 -1
- package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
- package/lib/localOdspDriver/{localOdspDeltaStorageService.mjs → localOdspDeltaStorageService.js} +1 -1
- package/lib/localOdspDriver/localOdspDeltaStorageService.js.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentService.d.mts → localOdspDocumentService.d.ts} +2 -2
- package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentService.mjs → localOdspDocumentService.js} +4 -4
- package/lib/localOdspDriver/localOdspDocumentService.js.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentServiceFactory.d.mts → localOdspDocumentServiceFactory.d.ts} +9 -7
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentServiceFactory.mjs → localOdspDocumentServiceFactory.js} +9 -8
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentStorageManager.d.mts → localOdspDocumentStorageManager.d.ts} +2 -2
- package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentStorageManager.mjs → localOdspDocumentStorageManager.js} +4 -4
- package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -0
- package/lib/{odsp-driver-alpha.d.mts → odsp-driver-alpha.d.ts} +27 -12
- package/lib/{odsp-driver-public.d.mts → odsp-driver-beta.d.ts} +1 -2
- package/lib/{odsp-driver-beta.d.mts → odsp-driver-public.d.ts} +1 -2
- package/lib/{odsp-driver-untrimmed.d.mts → odsp-driver-untrimmed.d.ts} +29 -12
- package/lib/{odspCache.d.mts → odspCache.d.ts} +8 -4
- package/lib/odspCache.d.ts.map +1 -0
- package/lib/{odspCache.mjs → odspCache.js} +6 -3
- package/lib/odspCache.js.map +1 -0
- package/lib/{odspDelayLoadedDeltaStream.d.mts → odspDelayLoadedDeltaStream.d.ts} +8 -6
- package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -0
- package/lib/{odspDelayLoadedDeltaStream.mjs → odspDelayLoadedDeltaStream.js} +33 -20
- package/lib/odspDelayLoadedDeltaStream.js.map +1 -0
- package/lib/{odspDeltaStorageService.d.mts → odspDeltaStorageService.d.ts} +8 -8
- package/lib/odspDeltaStorageService.d.ts.map +1 -0
- package/lib/{odspDeltaStorageService.mjs → odspDeltaStorageService.js} +5 -5
- package/lib/odspDeltaStorageService.js.map +1 -0
- package/lib/{odspDocumentDeltaConnection.d.mts → odspDocumentDeltaConnection.d.ts} +2 -2
- package/lib/odspDocumentDeltaConnection.d.ts.map +1 -0
- package/lib/{odspDocumentDeltaConnection.mjs → odspDocumentDeltaConnection.js} +34 -16
- package/lib/odspDocumentDeltaConnection.js.map +1 -0
- package/lib/{odspDocumentService.d.mts → odspDocumentService.d.ts} +7 -5
- package/lib/odspDocumentService.d.ts.map +1 -0
- package/lib/{odspDocumentService.mjs → odspDocumentService.js} +16 -11
- package/lib/odspDocumentService.js.map +1 -0
- package/lib/{odspDocumentServiceFactory.d.mts → odspDocumentServiceFactory.d.ts} +7 -2
- package/lib/odspDocumentServiceFactory.d.ts.map +1 -0
- package/lib/{odspDocumentServiceFactory.mjs → odspDocumentServiceFactory.js} +9 -3
- package/lib/odspDocumentServiceFactory.js.map +1 -0
- package/lib/{odspDocumentServiceFactoryCore.d.mts → odspDocumentServiceFactoryCore.d.ts} +5 -5
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -0
- package/lib/{odspDocumentServiceFactoryCore.mjs → odspDocumentServiceFactoryCore.js} +23 -17
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -0
- package/lib/{odspDocumentServiceFactoryWithCodeSplit.d.mts → odspDocumentServiceFactoryWithCodeSplit.d.ts} +2 -2
- package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -0
- package/lib/{odspDocumentServiceFactoryWithCodeSplit.mjs → odspDocumentServiceFactoryWithCodeSplit.js} +2 -2
- package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -0
- package/lib/{odspDocumentStorageManager.d.mts → odspDocumentStorageManager.d.ts} +16 -10
- package/lib/odspDocumentStorageManager.d.ts.map +1 -0
- package/lib/{odspDocumentStorageManager.mjs → odspDocumentStorageManager.js} +207 -167
- package/lib/odspDocumentStorageManager.js.map +1 -0
- package/lib/{odspDocumentStorageServiceBase.d.mts → odspDocumentStorageServiceBase.d.ts} +3 -5
- package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -0
- package/lib/{odspDocumentStorageServiceBase.mjs → odspDocumentStorageServiceBase.js} +32 -29
- package/lib/odspDocumentStorageServiceBase.js.map +1 -0
- package/lib/{odspDriverUrlResolver.d.mts → odspDriverUrlResolver.d.ts} +6 -2
- package/lib/odspDriverUrlResolver.d.ts.map +1 -0
- package/lib/{odspDriverUrlResolver.mjs → odspDriverUrlResolver.js} +24 -17
- package/lib/odspDriverUrlResolver.js.map +1 -0
- package/lib/{odspDriverUrlResolverForShareLink.d.mts → odspDriverUrlResolverForShareLink.d.ts} +18 -7
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -0
- package/lib/{odspDriverUrlResolverForShareLink.mjs → odspDriverUrlResolverForShareLink.js} +41 -27
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -0
- package/lib/{odspError.d.mts → odspError.d.ts} +2 -2
- package/lib/odspError.d.ts.map +1 -0
- package/lib/{odspError.mjs → odspError.js} +4 -4
- package/lib/odspError.js.map +1 -0
- package/lib/{odspFluidFileLink.d.mts → odspFluidFileLink.d.ts} +2 -2
- package/lib/odspFluidFileLink.d.ts.map +1 -0
- package/lib/{odspFluidFileLink.mjs → odspFluidFileLink.js} +2 -2
- package/lib/odspFluidFileLink.js.map +1 -0
- package/lib/{odspLocationRedirection.d.mts → odspLocationRedirection.d.ts} +1 -1
- package/lib/odspLocationRedirection.d.ts.map +1 -0
- package/lib/{odspLocationRedirection.mjs → odspLocationRedirection.js} +2 -2
- package/lib/odspLocationRedirection.js.map +1 -0
- package/lib/{odspPublicUtils.d.mts → odspPublicUtils.d.ts} +4 -1
- package/lib/odspPublicUtils.d.ts.map +1 -0
- package/lib/{odspPublicUtils.mjs → odspPublicUtils.js} +4 -1
- package/lib/odspPublicUtils.js.map +1 -0
- package/lib/{odspSnapshotParser.d.mts → odspSnapshotParser.d.ts} +2 -2
- package/lib/odspSnapshotParser.d.ts.map +1 -0
- package/lib/{odspSnapshotParser.mjs → odspSnapshotParser.js} +4 -3
- package/lib/odspSnapshotParser.js.map +1 -0
- package/lib/{odspSummaryUploadManager.d.mts → odspSummaryUploadManager.d.ts} +2 -2
- package/lib/odspSummaryUploadManager.d.ts.map +1 -0
- package/lib/{odspSummaryUploadManager.mjs → odspSummaryUploadManager.js} +8 -5
- package/lib/odspSummaryUploadManager.js.map +1 -0
- package/lib/{odspUrlHelper.d.mts → odspUrlHelper.d.ts} +1 -1
- package/lib/odspUrlHelper.d.ts.map +1 -0
- package/lib/{odspUrlHelper.mjs → odspUrlHelper.js} +2 -3
- package/lib/odspUrlHelper.js.map +1 -0
- package/lib/{odspUtils.d.mts → odspUtils.d.ts} +20 -8
- package/lib/odspUtils.d.ts.map +1 -0
- package/lib/{odspUtils.mjs → odspUtils.js} +45 -17
- package/lib/odspUtils.js.map +1 -0
- package/lib/{opsCaching.d.mts → opsCaching.d.ts} +2 -2
- package/lib/opsCaching.d.ts.map +1 -0
- package/lib/{opsCaching.mjs → opsCaching.js} +3 -2
- package/lib/opsCaching.js.map +1 -0
- package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
- package/lib/packageVersion.js.map +1 -0
- package/lib/{prefetchLatestSnapshot.d.mts → prefetchLatestSnapshot.d.ts} +3 -3
- package/lib/prefetchLatestSnapshot.d.ts.map +1 -0
- package/lib/{prefetchLatestSnapshot.mjs → prefetchLatestSnapshot.js} +16 -11
- package/lib/prefetchLatestSnapshot.js.map +1 -0
- package/lib/{retryErrorsStorageAdapter.d.mts → retryErrorsStorageAdapter.d.ts} +1 -2
- package/lib/retryErrorsStorageAdapter.d.ts.map +1 -0
- package/lib/{retryErrorsStorageAdapter.mjs → retryErrorsStorageAdapter.js} +2 -5
- package/lib/retryErrorsStorageAdapter.js.map +1 -0
- package/lib/{retryUtils.d.mts → retryUtils.d.ts} +1 -1
- package/lib/retryUtils.d.ts.map +1 -0
- package/lib/{retryUtils.mjs → retryUtils.js} +6 -2
- package/lib/retryUtils.js.map +1 -0
- package/lib/{socketModule.d.mts → socketModule.d.ts} +1 -1
- package/lib/socketModule.d.ts.map +1 -0
- package/lib/{socketModule.mjs → socketModule.js} +3 -1
- package/lib/socketModule.js.map +1 -0
- package/lib/test/buildOdspShareLinkReqParams.spec.js +25 -0
- package/lib/test/buildOdspShareLinkReqParams.spec.js.map +1 -0
- package/lib/test/createNewUtilsTests.spec.js +221 -0
- package/lib/test/createNewUtilsTests.spec.js.map +1 -0
- package/lib/test/deltaStorageService.spec.js +176 -0
- package/lib/test/deltaStorageService.spec.js.map +1 -0
- package/lib/test/epochTests.spec.js +340 -0
- package/lib/test/epochTests.spec.js.map +1 -0
- package/lib/test/epochTestsWithRedemption.spec.js +119 -0
- package/lib/test/epochTestsWithRedemption.spec.js.map +1 -0
- package/lib/test/fetchSnapshot.spec.js +412 -0
- package/lib/test/fetchSnapshot.spec.js.map +1 -0
- package/lib/test/getFileLink.spec.js +62 -0
- package/lib/test/getFileLink.spec.js.map +1 -0
- package/lib/test/getUrlAndHeadersWithAuth.spec.js +66 -0
- package/lib/test/getUrlAndHeadersWithAuth.spec.js.map +1 -0
- package/lib/test/getVersions.spec.js +284 -0
- package/lib/test/getVersions.spec.js.map +1 -0
- package/lib/test/joinSessionCacheTests.spec.js +53 -0
- package/lib/test/joinSessionCacheTests.spec.js.map +1 -0
- package/lib/test/joinSessionPeriodicCall.spec.js +158 -0
- package/lib/test/joinSessionPeriodicCall.spec.js.map +1 -0
- package/lib/test/jsonSnapshotFormatTests.spec.js +107 -0
- package/lib/test/jsonSnapshotFormatTests.spec.js.map +1 -0
- package/lib/test/localOdspDriver.spec.js +177 -0
- package/lib/test/localOdspDriver.spec.js.map +1 -0
- package/lib/test/mockFetch.js +61 -0
- package/lib/test/mockFetch.js.map +1 -0
- package/lib/test/odspCreateContainer.spec.js +116 -0
- package/lib/test/odspCreateContainer.spec.js.map +1 -0
- package/lib/test/odspDriverResolverTest.spec.js +289 -0
- package/lib/test/odspDriverResolverTest.spec.js.map +1 -0
- package/lib/test/odspDriverUrlResolverForShareLink.spec.js +287 -0
- package/lib/test/odspDriverUrlResolverForShareLink.spec.js.map +1 -0
- package/lib/test/odspError.spec.js +299 -0
- package/lib/test/odspError.spec.js.map +1 -0
- package/lib/test/opsCaching.spec.js +357 -0
- package/lib/test/opsCaching.spec.js.map +1 -0
- package/lib/test/prefetchSnapshotTests.spec.js +420 -0
- package/lib/test/prefetchSnapshotTests.spec.js.map +1 -0
- package/lib/test/snapshotFormatTests.spec.js +218 -0
- package/lib/test/snapshotFormatTests.spec.js.map +1 -0
- package/lib/test/socketTests/deltaConnectionUpdateTests.spec.js +152 -0
- package/lib/test/socketTests/deltaConnectionUpdateTests.spec.js.map +1 -0
- package/lib/test/socketTests/socketMock.js +109 -0
- package/lib/test/socketTests/socketMock.js.map +1 -0
- package/lib/test/socketTests/socketTests.spec.js +256 -0
- package/lib/test/socketTests/socketTests.spec.js.map +1 -0
- package/lib/test/tokenFetch.spec.js +39 -0
- package/lib/test/tokenFetch.spec.js.map +1 -0
- package/lib/test/types/validateOdspDriverPrevious.generated.js +96 -0
- package/lib/test/types/validateOdspDriverPrevious.generated.js.map +1 -0
- package/lib/test/zipItDataRepresentationTests.spec.js +207 -0
- package/lib/test/zipItDataRepresentationTests.spec.js.map +1 -0
- package/lib/{vroom.d.mts → vroom.d.ts} +3 -3
- package/lib/vroom.d.ts.map +1 -0
- package/lib/{vroom.mjs → vroom.js} +4 -4
- package/lib/vroom.js.map +1 -0
- package/lib/{zipItDataRepresentationUtils.d.mts → zipItDataRepresentationUtils.d.ts} +2 -2
- package/lib/zipItDataRepresentationUtils.d.ts.map +1 -0
- package/lib/{zipItDataRepresentationUtils.mjs → zipItDataRepresentationUtils.js} +17 -9
- package/lib/zipItDataRepresentationUtils.js.map +1 -0
- package/package.json +90 -31
- package/src/ReadBufferUtils.ts +7 -7
- package/src/WriteBufferUtils.ts +13 -9
- package/src/checkUrl.ts +4 -2
- package/src/compactSnapshotParser.ts +87 -52
- package/src/compactSnapshotWriter.ts +19 -12
- package/src/contracts.ts +16 -4
- package/src/createFile.ts +16 -13
- package/src/createNewContainerOnExistingFile.ts +8 -8
- package/src/createNewModule.ts +2 -2
- package/src/createNewUtils.ts +19 -9
- package/src/createOdspCreateContainerRequest.ts +2 -1
- package/src/createOdspUrl.ts +1 -1
- package/src/epochTracker.ts +90 -55
- package/src/fetchSnapshot.ts +104 -47
- package/src/getFileLink.ts +21 -13
- package/src/getQueryString.ts +3 -0
- package/src/index.ts +27 -19
- package/src/localOdspDriver/localOdspDocumentService.ts +3 -3
- package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +12 -11
- package/src/localOdspDriver/localOdspDocumentStorageManager.ts +5 -5
- package/src/odspCache.ts +13 -9
- package/src/odspDelayLoadedDeltaStream.ts +54 -33
- package/src/odspDeltaStorageService.ts +17 -16
- package/src/odspDocumentDeltaConnection.ts +52 -34
- package/src/odspDocumentService.ts +23 -20
- package/src/odspDocumentServiceFactory.ts +7 -2
- package/src/odspDocumentServiceFactoryCore.ts +25 -18
- package/src/odspDocumentServiceFactoryWithCodeSplit.ts +1 -1
- package/src/odspDocumentStorageManager.ts +276 -216
- package/src/odspDocumentStorageServiceBase.ts +45 -43
- package/src/odspDriverUrlResolver.ts +39 -24
- package/src/odspDriverUrlResolverForShareLink.ts +51 -31
- package/src/odspError.ts +4 -4
- package/src/odspFluidFileLink.ts +3 -3
- package/src/odspLocationRedirection.ts +1 -1
- package/src/odspPublicUtils.ts +3 -0
- package/src/odspSnapshotParser.ts +4 -3
- package/src/odspSummaryUploadManager.ts +21 -9
- package/src/odspUrlHelper.ts +2 -3
- package/src/odspUtils.ts +73 -30
- package/src/opsCaching.ts +13 -12
- package/src/packageVersion.ts +1 -1
- package/src/prefetchLatestSnapshot.ts +24 -15
- package/src/retryErrorsStorageAdapter.ts +4 -8
- package/src/retryUtils.ts +6 -2
- package/src/socketModule.ts +2 -0
- package/src/vroom.ts +6 -6
- package/src/zipItDataRepresentationUtils.ts +63 -35
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +2 -5
- package/lib/ReadBufferUtils.d.mts.map +0 -1
- package/lib/ReadBufferUtils.mjs.map +0 -1
- package/lib/WriteBufferUtils.d.mts.map +0 -1
- package/lib/WriteBufferUtils.mjs.map +0 -1
- package/lib/checkUrl.d.mts.map +0 -1
- package/lib/checkUrl.mjs.map +0 -1
- package/lib/compactSnapshotParser.d.mts.map +0 -1
- package/lib/compactSnapshotParser.mjs.map +0 -1
- package/lib/compactSnapshotWriter.d.mts.map +0 -1
- package/lib/compactSnapshotWriter.mjs.map +0 -1
- package/lib/constants.d.mts.map +0 -1
- package/lib/constants.mjs.map +0 -1
- package/lib/contracts.d.mts.map +0 -1
- package/lib/contracts.mjs.map +0 -1
- package/lib/contractsPublic.d.mts.map +0 -1
- package/lib/contractsPublic.mjs.map +0 -1
- package/lib/createFile.d.mts.map +0 -1
- package/lib/createFile.mjs.map +0 -1
- package/lib/createNewContainerOnExistingFile.d.mts.map +0 -1
- package/lib/createNewContainerOnExistingFile.mjs.map +0 -1
- package/lib/createNewModule.d.mts.map +0 -1
- package/lib/createNewModule.mjs.map +0 -1
- package/lib/createNewUtils.d.mts.map +0 -1
- package/lib/createNewUtils.mjs.map +0 -1
- package/lib/createOdspCreateContainerRequest.d.mts.map +0 -1
- package/lib/createOdspCreateContainerRequest.mjs.map +0 -1
- package/lib/createOdspUrl.d.mts.map +0 -1
- package/lib/createOdspUrl.mjs.map +0 -1
- package/lib/epochTracker.d.mts.map +0 -1
- package/lib/epochTracker.mjs.map +0 -1
- package/lib/fetch.d.mts.map +0 -1
- package/lib/fetch.mjs.map +0 -1
- package/lib/fetchSnapshot.d.mts.map +0 -1
- package/lib/fetchSnapshot.mjs.map +0 -1
- package/lib/getFileLink.d.mts.map +0 -1
- package/lib/getFileLink.mjs.map +0 -1
- package/lib/getQueryString.d.mts.map +0 -1
- package/lib/getQueryString.mjs.map +0 -1
- package/lib/getUrlAndHeadersWithAuth.d.mts.map +0 -1
- package/lib/getUrlAndHeadersWithAuth.mjs.map +0 -1
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs +0 -22
- package/lib/index.mjs.map +0 -1
- package/lib/localOdspDriver/localOdspDeltaStorageService.d.mts.map +0 -1
- package/lib/localOdspDriver/localOdspDeltaStorageService.mjs.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentService.d.mts.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentService.mjs.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.mts.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.mjs.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentStorageManager.d.mts.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentStorageManager.mjs.map +0 -1
- package/lib/odspCache.d.mts.map +0 -1
- package/lib/odspCache.mjs.map +0 -1
- package/lib/odspDelayLoadedDeltaStream.d.mts.map +0 -1
- package/lib/odspDelayLoadedDeltaStream.mjs.map +0 -1
- package/lib/odspDeltaStorageService.d.mts.map +0 -1
- package/lib/odspDeltaStorageService.mjs.map +0 -1
- package/lib/odspDocumentDeltaConnection.d.mts.map +0 -1
- package/lib/odspDocumentDeltaConnection.mjs.map +0 -1
- package/lib/odspDocumentService.d.mts.map +0 -1
- package/lib/odspDocumentService.mjs.map +0 -1
- package/lib/odspDocumentServiceFactory.d.mts.map +0 -1
- package/lib/odspDocumentServiceFactory.mjs.map +0 -1
- package/lib/odspDocumentServiceFactoryCore.d.mts.map +0 -1
- package/lib/odspDocumentServiceFactoryCore.mjs.map +0 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.d.mts.map +0 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.mjs.map +0 -1
- package/lib/odspDocumentStorageManager.d.mts.map +0 -1
- package/lib/odspDocumentStorageManager.mjs.map +0 -1
- package/lib/odspDocumentStorageServiceBase.d.mts.map +0 -1
- package/lib/odspDocumentStorageServiceBase.mjs.map +0 -1
- package/lib/odspDriverUrlResolver.d.mts.map +0 -1
- package/lib/odspDriverUrlResolver.mjs.map +0 -1
- package/lib/odspDriverUrlResolverForShareLink.d.mts.map +0 -1
- package/lib/odspDriverUrlResolverForShareLink.mjs.map +0 -1
- package/lib/odspError.d.mts.map +0 -1
- package/lib/odspError.mjs.map +0 -1
- package/lib/odspFluidFileLink.d.mts.map +0 -1
- package/lib/odspFluidFileLink.mjs.map +0 -1
- package/lib/odspLocationRedirection.d.mts.map +0 -1
- package/lib/odspLocationRedirection.mjs.map +0 -1
- package/lib/odspPublicUtils.d.mts.map +0 -1
- package/lib/odspPublicUtils.mjs.map +0 -1
- package/lib/odspSnapshotParser.d.mts.map +0 -1
- package/lib/odspSnapshotParser.mjs.map +0 -1
- package/lib/odspSummaryUploadManager.d.mts.map +0 -1
- package/lib/odspSummaryUploadManager.mjs.map +0 -1
- package/lib/odspUrlHelper.d.mts.map +0 -1
- package/lib/odspUrlHelper.mjs.map +0 -1
- package/lib/odspUtils.d.mts.map +0 -1
- package/lib/odspUtils.mjs.map +0 -1
- package/lib/opsCaching.d.mts.map +0 -1
- package/lib/opsCaching.mjs.map +0 -1
- package/lib/packageVersion.d.mts.map +0 -1
- package/lib/packageVersion.mjs.map +0 -1
- package/lib/prefetchLatestSnapshot.d.mts.map +0 -1
- package/lib/prefetchLatestSnapshot.mjs.map +0 -1
- package/lib/retryErrorsStorageAdapter.d.mts.map +0 -1
- package/lib/retryErrorsStorageAdapter.mjs.map +0 -1
- package/lib/retryUtils.d.mts.map +0 -1
- package/lib/retryUtils.mjs.map +0 -1
- package/lib/socketModule.d.mts.map +0 -1
- package/lib/socketModule.mjs.map +0 -1
- package/lib/vroom.d.mts.map +0 -1
- package/lib/vroom.mjs.map +0 -1
- package/lib/zipItDataRepresentationUtils.d.mts.map +0 -1
- package/lib/zipItDataRepresentationUtils.mjs.map +0 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
// eslint-disable-next-line unicorn/prefer-node-protocol
|
|
6
|
+
import { strict as assert } from "assert";
|
|
7
|
+
import { convertOdspSnapshotToSnapshotTreeAndBlobs } from "../odspSnapshotParser.js";
|
|
8
|
+
const snapshotTree = {
|
|
9
|
+
id: "bBzkVAgAHAAAA",
|
|
10
|
+
trees: [
|
|
11
|
+
{
|
|
12
|
+
id: "bBzkVAgAHAAAA",
|
|
13
|
+
sequenceNumber: 1,
|
|
14
|
+
entries: [
|
|
15
|
+
{
|
|
16
|
+
path: ".protocol",
|
|
17
|
+
type: "tree",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: "bARA4itsHfCA5XZQaYhmASYpj",
|
|
21
|
+
path: ".protocol/quorumMembers",
|
|
22
|
+
type: "blob",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
path: ".app",
|
|
26
|
+
type: "tree",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
path: ".app/.channels",
|
|
30
|
+
type: "tree",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
path: ".app/.channels/23c54bd8-ef53-42fa-a898-413de4c6f0f2",
|
|
34
|
+
type: "tree",
|
|
35
|
+
unreferenced: true,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "bARDoHhrwJMLoGao2yx8mD7nz",
|
|
39
|
+
path: ".app/.channels/23c54bd8-ef53-42fa-a898-413de4c6f0f2/.attributes",
|
|
40
|
+
type: "blob",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
path: ".app/.channels/23c54bd8-ef53-42fa-a898-413de4c6f0f2/d65a4af3-0bf8-4052-8442-a898651ad9b8",
|
|
44
|
+
type: "tree",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
blobs: [
|
|
50
|
+
{
|
|
51
|
+
id: "bARA4itsHfCA5XZQaYhmASYpj",
|
|
52
|
+
content: " \n",
|
|
53
|
+
size: 4,
|
|
54
|
+
encoding: undefined,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "bARDoHhrwJMLoGao2yx8mD7nz",
|
|
58
|
+
content: "KR \n",
|
|
59
|
+
size: 5,
|
|
60
|
+
encoding: undefined,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
ops: [
|
|
64
|
+
{
|
|
65
|
+
sequenceNumber: 2,
|
|
66
|
+
op: {
|
|
67
|
+
clientId: "38777331-8149-4d15-b734-cd8110295ab6",
|
|
68
|
+
clientSequenceNumber: 2,
|
|
69
|
+
contents: null,
|
|
70
|
+
metadata: {},
|
|
71
|
+
minimumSequenceNumber: 136505,
|
|
72
|
+
referenceSequenceNumber: 136505,
|
|
73
|
+
sequenceNumber: 2,
|
|
74
|
+
timestamp: 1657840275913,
|
|
75
|
+
type: "op",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
sequenceNumber: 3,
|
|
80
|
+
op: {
|
|
81
|
+
clientId: "38777331-8149-4d15-b734-cd8110295ab6",
|
|
82
|
+
clientSequenceNumber: -1,
|
|
83
|
+
contents: null,
|
|
84
|
+
minimumSequenceNumber: 136505,
|
|
85
|
+
referenceSequenceNumber: -1,
|
|
86
|
+
sequenceNumber: 3,
|
|
87
|
+
timestamp: 1657840275922,
|
|
88
|
+
type: "join",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
};
|
|
93
|
+
describe("JSON Snapshot Format Conversion Tests", () => {
|
|
94
|
+
it("Conversion test", async () => {
|
|
95
|
+
const result = convertOdspSnapshotToSnapshotTreeAndBlobs(snapshotTree);
|
|
96
|
+
assert(result.sequenceNumber === 1, "Seq number should match");
|
|
97
|
+
assert(result.latestSequenceNumber === 3, "Latest sequence number should match");
|
|
98
|
+
assert((result.snapshotTree.id = snapshotTree.id), "Snapshot id should match");
|
|
99
|
+
assert(result.ops.length === 2, "2 ops should be there");
|
|
100
|
+
assert(result.blobContents.size === 2, "2 blobs should be there");
|
|
101
|
+
assert(Object.keys(result.snapshotTree.trees).length === 2, "2 trees should be there");
|
|
102
|
+
const shouldBeEmptyTree = result.snapshotTree.trees[".app"]?.trees[".channels"]?.trees["23c54bd8-ef53-42fa-a898-413de4c6f0f2"]?.trees["d65a4af3-0bf8-4052-8442-a898651ad9b8"];
|
|
103
|
+
const emptyTree = { blobs: {}, trees: {}, unreferenced: undefined, groupId: undefined };
|
|
104
|
+
assert.deepStrictEqual(shouldBeEmptyTree, emptyTree, "Tree should have no blobs and trees");
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=jsonSnapshotFormatTests.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonSnapshotFormatTests.spec.js","sourceRoot":"","sources":["../../src/test/jsonSnapshotFormatTests.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wDAAwD;AACxD,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,yCAAyC,EAAE,MAAM,0BAA0B,CAAC;AAErF,MAAM,YAAY,GAAkB;IACnC,EAAE,EAAE,eAAe;IACnB,KAAK,EAAE;QACN;YACC,EAAE,EAAE,eAAe;YACnB,cAAc,EAAE,CAAC;YACjB,OAAO,EAAE;gBACR;oBACC,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,MAAM;iBACZ;gBACD;oBACC,EAAE,EAAE,2BAA2B;oBAC/B,IAAI,EAAE,yBAAyB;oBAC/B,IAAI,EAAE,MAAM;iBACZ;gBACD;oBACC,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,MAAM;iBACZ;gBACD;oBACC,IAAI,EAAE,gBAAgB;oBACtB,IAAI,EAAE,MAAM;iBACZ;gBACD;oBACC,IAAI,EAAE,qDAAqD;oBAC3D,IAAI,EAAE,MAAM;oBACZ,YAAY,EAAE,IAAI;iBAClB;gBACD;oBACC,EAAE,EAAE,2BAA2B;oBAC/B,IAAI,EAAE,iEAAiE;oBACvE,IAAI,EAAE,MAAM;iBACZ;gBACD;oBACC,IAAI,EAAE,0FAA0F;oBAChG,IAAI,EAAE,MAAM;iBACZ;aACD;SACD;KACD;IACD,KAAK,EAAE;QACN;YACC,EAAE,EAAE,2BAA2B;YAC/B,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,CAAC;YACP,QAAQ,EAAE,SAAS;SACnB;QACD;YACC,EAAE,EAAE,2BAA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AC,YAAY,CAAC,IAAI,KAAK,CAAC,EAAE,yBAAyB,CAAC,CAAC;QAClE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,yBAAyB,CAAC,CAAC;QACvF,MAAM,iBAAiB,GACtB,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,EAAE,KAAK,CAC3D,sCAAsC,CACtC,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAClD,MAAM,SAAS,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;QACxF,MAAM,CAAC,eAAe,CAAC,iBAAiB,EAAE,SAAS,EAAE,qCAAqC,CAAC,CAAC;IAC7F,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\n// eslint-disable-next-line unicorn/prefer-node-protocol\nimport { strict as assert } from \"assert\";\nimport { IOdspSnapshot } from \"../contracts.js\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"../odspSnapshotParser.js\";\n\nconst snapshotTree: IOdspSnapshot = {\n\tid: \"bBzkVAgAHAAAA\",\n\ttrees: [\n\t\t{\n\t\t\tid: \"bBzkVAgAHAAAA\",\n\t\t\tsequenceNumber: 1,\n\t\t\tentries: [\n\t\t\t\t{\n\t\t\t\t\tpath: \".protocol\",\n\t\t\t\t\ttype: \"tree\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"bARA4itsHfCA5XZQaYhmASYpj\",\n\t\t\t\t\tpath: \".protocol/quorumMembers\",\n\t\t\t\t\ttype: \"blob\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tpath: \".app\",\n\t\t\t\t\ttype: \"tree\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tpath: \".app/.channels\",\n\t\t\t\t\ttype: \"tree\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tpath: \".app/.channels/23c54bd8-ef53-42fa-a898-413de4c6f0f2\",\n\t\t\t\t\ttype: \"tree\",\n\t\t\t\t\tunreferenced: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"bARDoHhrwJMLoGao2yx8mD7nz\",\n\t\t\t\t\tpath: \".app/.channels/23c54bd8-ef53-42fa-a898-413de4c6f0f2/.attributes\",\n\t\t\t\t\ttype: \"blob\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tpath: \".app/.channels/23c54bd8-ef53-42fa-a898-413de4c6f0f2/d65a4af3-0bf8-4052-8442-a898651ad9b8\",\n\t\t\t\t\ttype: \"tree\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n\tblobs: [\n\t\t{\n\t\t\tid: \"bARA4itsHfCA5XZQaYhmASYpj\",\n\t\t\tcontent: \" \\n\",\n\t\t\tsize: 4,\n\t\t\tencoding: undefined,\n\t\t},\n\t\t{\n\t\t\tid: \"bARDoHhrwJMLoGao2yx8mD7nz\",\n\t\t\tcontent: \"KR \\n\",\n\t\t\tsize: 5,\n\t\t\tencoding: undefined,\n\t\t},\n\t],\n\tops: [\n\t\t{\n\t\t\tsequenceNumber: 2,\n\t\t\top: {\n\t\t\t\tclientId: \"38777331-8149-4d15-b734-cd8110295ab6\",\n\t\t\t\tclientSequenceNumber: 2,\n\t\t\t\tcontents: null,\n\t\t\t\tmetadata: {},\n\t\t\t\tminimumSequenceNumber: 136505,\n\t\t\t\treferenceSequenceNumber: 136505,\n\t\t\t\tsequenceNumber: 2,\n\t\t\t\ttimestamp: 1657840275913,\n\t\t\t\ttype: \"op\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tsequenceNumber: 3,\n\t\t\top: {\n\t\t\t\tclientId: \"38777331-8149-4d15-b734-cd8110295ab6\",\n\t\t\t\tclientSequenceNumber: -1,\n\t\t\t\tcontents: null,\n\t\t\t\tminimumSequenceNumber: 136505,\n\t\t\t\treferenceSequenceNumber: -1,\n\t\t\t\tsequenceNumber: 3,\n\t\t\t\ttimestamp: 1657840275922,\n\t\t\t\ttype: \"join\",\n\t\t\t},\n\t\t},\n\t],\n};\n\ndescribe(\"JSON Snapshot Format Conversion Tests\", () => {\n\tit(\"Conversion test\", async () => {\n\t\tconst result = convertOdspSnapshotToSnapshotTreeAndBlobs(snapshotTree);\n\t\tassert(result.sequenceNumber === 1, \"Seq number should match\");\n\t\tassert(result.latestSequenceNumber === 3, \"Latest sequence number should match\");\n\t\tassert((result.snapshotTree.id = snapshotTree.id), \"Snapshot id should match\");\n\t\tassert(result.ops.length === 2, \"2 ops should be there\");\n\t\tassert(result.blobContents.size === 2, \"2 blobs should be there\");\n\t\tassert(Object.keys(result.snapshotTree.trees).length === 2, \"2 trees should be there\");\n\t\tconst shouldBeEmptyTree =\n\t\t\tresult.snapshotTree.trees[\".app\"]?.trees[\".channels\"]?.trees[\n\t\t\t\t\"23c54bd8-ef53-42fa-a898-413de4c6f0f2\"\n\t\t\t]?.trees[\"d65a4af3-0bf8-4052-8442-a898651ad9b8\"];\n\t\tconst emptyTree = { blobs: {}, trees: {}, unreferenced: undefined, groupId: undefined };\n\t\tassert.deepStrictEqual(shouldBeEmptyTree, emptyTree, \"Tree should have no blobs and trees\");\n\t});\n});\n"]}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import { strict as assert } from "node:assert";
|
|
7
|
+
import { OdspErrorTypes } from "@fluidframework/odsp-driver-definitions";
|
|
8
|
+
import { SummaryType, } from "@fluidframework/protocol-definitions";
|
|
9
|
+
import { MockLogger } from "@fluidframework/telemetry-utils";
|
|
10
|
+
/* eslint-disable import/no-internal-modules */
|
|
11
|
+
import { LocalOdspDocumentServiceFactory } from "../localOdspDriver/localOdspDocumentServiceFactory.js";
|
|
12
|
+
import { LocalOdspDocumentService } from "../localOdspDriver/localOdspDocumentService.js";
|
|
13
|
+
import { LocalOdspDocumentStorageService } from "../localOdspDriver/localOdspDocumentStorageManager.js";
|
|
14
|
+
/* eslint-enable import/no-internal-modules */
|
|
15
|
+
describe("Local Odsp driver", () => {
|
|
16
|
+
// TODO: add end-to-end test
|
|
17
|
+
const fakeOdspResolvedUrl = {
|
|
18
|
+
type: "fluid",
|
|
19
|
+
odspResolvedUrl: true,
|
|
20
|
+
id: "1",
|
|
21
|
+
siteUrl: "fakeUrl",
|
|
22
|
+
driveId: "1",
|
|
23
|
+
itemId: "1",
|
|
24
|
+
url: "fakeUrl",
|
|
25
|
+
hashedDocumentId: "1",
|
|
26
|
+
endpoints: {
|
|
27
|
+
snapshotStorageUrl: "fakeUrl",
|
|
28
|
+
attachmentPOSTStorageUrl: "fakeUrl",
|
|
29
|
+
attachmentGETStorageUrl: "fakeUrl",
|
|
30
|
+
deltaStorageUrl: "fakeUrl",
|
|
31
|
+
},
|
|
32
|
+
tokens: {},
|
|
33
|
+
fileName: "fakeName",
|
|
34
|
+
summarizer: false,
|
|
35
|
+
fileVersion: "1",
|
|
36
|
+
};
|
|
37
|
+
const localSnapshot = fs.readFileSync(`${__dirname}/../../src/test/localSnapshots/localSnapshot1.json`, { encoding: "utf8" });
|
|
38
|
+
async function assertThrowsUsageError(fn) {
|
|
39
|
+
await assert.rejects(fn, (e) => e.errorType === OdspErrorTypes.usageError);
|
|
40
|
+
}
|
|
41
|
+
describe("Local Odsp document service factory", () => {
|
|
42
|
+
it("Can use a real snapshot", () => {
|
|
43
|
+
assert.doesNotThrow(() => new LocalOdspDocumentServiceFactory(localSnapshot));
|
|
44
|
+
});
|
|
45
|
+
it("createContainer throws error", async () => {
|
|
46
|
+
await assertThrowsUsageError(async () => new LocalOdspDocumentServiceFactory("sample data").createContainer(undefined, fakeOdspResolvedUrl));
|
|
47
|
+
});
|
|
48
|
+
describe("createDocumentService", () => {
|
|
49
|
+
it("clientIsSummarizer should be undefined or false", async () => {
|
|
50
|
+
const factory = new LocalOdspDocumentServiceFactory("sample data");
|
|
51
|
+
await assert.doesNotReject(async () => {
|
|
52
|
+
await factory.createDocumentService(fakeOdspResolvedUrl);
|
|
53
|
+
});
|
|
54
|
+
await assert.doesNotReject(async () => {
|
|
55
|
+
await factory.createDocumentService(fakeOdspResolvedUrl, undefined, undefined);
|
|
56
|
+
});
|
|
57
|
+
await factory.createDocumentService(fakeOdspResolvedUrl, undefined, false);
|
|
58
|
+
await assert.rejects(async () => {
|
|
59
|
+
await factory.createDocumentService(fakeOdspResolvedUrl, undefined, true);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
it("resolvedUrl must be IOdspResolvedUrl", async () => {
|
|
63
|
+
const factory = new LocalOdspDocumentServiceFactory("sample data");
|
|
64
|
+
await assert.doesNotReject(async () => factory.createDocumentService(fakeOdspResolvedUrl));
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe("Local Odsp document service", () => {
|
|
69
|
+
async function readAll(stream) {
|
|
70
|
+
const ops = [];
|
|
71
|
+
// eslint-disable-next-line no-constant-condition
|
|
72
|
+
while (true) {
|
|
73
|
+
const result = await stream.read();
|
|
74
|
+
if (result.done) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
ops.push(...result.value);
|
|
78
|
+
}
|
|
79
|
+
return ops;
|
|
80
|
+
}
|
|
81
|
+
it("Can use a real snapshot", () => {
|
|
82
|
+
assert.doesNotThrow(() => new LocalOdspDocumentService(fakeOdspResolvedUrl, new MockLogger().toTelemetryLogger(), localSnapshot));
|
|
83
|
+
});
|
|
84
|
+
it("Can get resolvedUrl", () => {
|
|
85
|
+
const resolvedUrl = fakeOdspResolvedUrl;
|
|
86
|
+
const service = new LocalOdspDocumentService(resolvedUrl, new MockLogger().toTelemetryLogger(), localSnapshot);
|
|
87
|
+
assert.strictEqual(service.resolvedUrl, resolvedUrl);
|
|
88
|
+
});
|
|
89
|
+
it("Delta storage service returns no messages", async () => {
|
|
90
|
+
const service = new LocalOdspDocumentService(fakeOdspResolvedUrl, new MockLogger().toTelemetryLogger(), localSnapshot);
|
|
91
|
+
// Load snapshot
|
|
92
|
+
const storage = await service.connectToStorage();
|
|
93
|
+
await storage.getVersions(null, 1);
|
|
94
|
+
const deltaStorageService = await service.connectToDeltaStorage();
|
|
95
|
+
const allOps = await readAll(deltaStorageService.fetchMessages(0, undefined));
|
|
96
|
+
assert.strictEqual(allOps.length, 0, "There should be no messages");
|
|
97
|
+
});
|
|
98
|
+
it("Delta storage service returns trailing ops", async () => {
|
|
99
|
+
const snapshotWithTrailingOps = fs.readFileSync(`${__dirname}/../../src/test/localSnapshots/localSnapshot2.json`, { encoding: "utf8" });
|
|
100
|
+
const service = new LocalOdspDocumentService(fakeOdspResolvedUrl, new MockLogger().toTelemetryLogger(), snapshotWithTrailingOps);
|
|
101
|
+
// Load snapshot
|
|
102
|
+
const storage = await service.connectToStorage();
|
|
103
|
+
await storage.getVersions(null, 1);
|
|
104
|
+
const deltaStorageService = await service.connectToDeltaStorage();
|
|
105
|
+
const allOps = await readAll(deltaStorageService.fetchMessages(179, undefined));
|
|
106
|
+
assert.strictEqual(allOps.length, 13, "There should be 13 messages");
|
|
107
|
+
});
|
|
108
|
+
it("connectToDeltaStream throws error", async () => {
|
|
109
|
+
const mockLogger = new MockLogger();
|
|
110
|
+
const service = new LocalOdspDocumentService(fakeOdspResolvedUrl, mockLogger.toTelemetryLogger(), localSnapshot);
|
|
111
|
+
const client = {
|
|
112
|
+
mode: "read",
|
|
113
|
+
details: { capabilities: { interactive: true } },
|
|
114
|
+
permission: [],
|
|
115
|
+
user: { id: "id" },
|
|
116
|
+
scopes: [],
|
|
117
|
+
};
|
|
118
|
+
await assertThrowsUsageError(async () => service.connectToDeltaStream(client));
|
|
119
|
+
mockLogger.assertMatch([{ eventName: "UnsupportedUsage" }], "Expected log not present");
|
|
120
|
+
});
|
|
121
|
+
it("Dispose does not throw", () => {
|
|
122
|
+
const service = new LocalOdspDocumentService(fakeOdspResolvedUrl, new MockLogger().toTelemetryLogger(), localSnapshot);
|
|
123
|
+
assert.doesNotThrow(() => service.dispose());
|
|
124
|
+
assert.doesNotThrow(() => service.dispose(null));
|
|
125
|
+
assert.doesNotThrow(() => service.dispose(undefined));
|
|
126
|
+
assert.doesNotThrow(() => service.dispose(new Error("I am an error")));
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
describe("Local Odsp document storage service", () => {
|
|
130
|
+
it("Can use a real snapshot", () => {
|
|
131
|
+
assert.doesNotThrow(() => new LocalOdspDocumentStorageService(new MockLogger().toTelemetryLogger(), localSnapshot));
|
|
132
|
+
});
|
|
133
|
+
it("uploadSummaryWithContext throws error", async () => {
|
|
134
|
+
const mockLogger = new MockLogger();
|
|
135
|
+
await assertThrowsUsageError(async () => new LocalOdspDocumentStorageService(mockLogger.toTelemetryLogger(), "sample data").uploadSummaryWithContext({
|
|
136
|
+
type: SummaryType.Tree,
|
|
137
|
+
tree: {},
|
|
138
|
+
}, {
|
|
139
|
+
proposalHandle: undefined,
|
|
140
|
+
ackHandle: undefined,
|
|
141
|
+
referenceSequenceNumber: 1,
|
|
142
|
+
}));
|
|
143
|
+
mockLogger.assertMatch([{ eventName: "UnsupportedUsage" }], "Expected log not present");
|
|
144
|
+
});
|
|
145
|
+
it("createBlob throws error", async () => {
|
|
146
|
+
const mockLogger = new MockLogger();
|
|
147
|
+
const storageService = new LocalOdspDocumentStorageService(mockLogger.toTelemetryLogger(), "sample data");
|
|
148
|
+
await assertThrowsUsageError(async () => storageService.createBlob(new ArrayBuffer(0)));
|
|
149
|
+
mockLogger.assertMatch([{ eventName: "UnsupportedUsage" }], "Expected log not present");
|
|
150
|
+
});
|
|
151
|
+
describe("getVersions", () => {
|
|
152
|
+
const snapshotVersion = [{ id: "bBwAAAAAHAAAA", treeId: undefined }];
|
|
153
|
+
it("blobid should always be null", async () => {
|
|
154
|
+
const storageService = new LocalOdspDocumentStorageService(new MockLogger().toTelemetryLogger(), localSnapshot);
|
|
155
|
+
await assert.rejects(async () => storageService.getVersions("", 1));
|
|
156
|
+
await assert.rejects(async () => storageService.getVersions("1", 1));
|
|
157
|
+
});
|
|
158
|
+
it("count should always be 1", async () => {
|
|
159
|
+
const storageService = new LocalOdspDocumentStorageService(new MockLogger().toTelemetryLogger(), localSnapshot);
|
|
160
|
+
await assert.rejects(async () => storageService.getVersions(null, -1));
|
|
161
|
+
await assert.rejects(async () => storageService.getVersions(null, 0));
|
|
162
|
+
await assert.rejects(async () => storageService.getVersions(null, 2));
|
|
163
|
+
});
|
|
164
|
+
it("Retrieves snapshot version from JSON snapshot", async () => {
|
|
165
|
+
const storageService = new LocalOdspDocumentStorageService(new MockLogger().toTelemetryLogger(), localSnapshot);
|
|
166
|
+
assert.deepStrictEqual(await storageService.getVersions(null, 1), snapshotVersion);
|
|
167
|
+
});
|
|
168
|
+
it("Calling multiple times", async () => {
|
|
169
|
+
const storageService = new LocalOdspDocumentStorageService(new MockLogger().toTelemetryLogger(), localSnapshot);
|
|
170
|
+
for (let i = 0; i < 3; i++) {
|
|
171
|
+
assert.deepStrictEqual(await storageService.getVersions(null, 1), snapshotVersion);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
//# sourceMappingURL=localOdspDriver.spec.js.map
|
|
@@ -0,0 +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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ACpC,aAAa,CACb,CAAC;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 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"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import assert from "node:assert";
|
|
6
|
+
import { stub } from "sinon";
|
|
7
|
+
import * as fetchModule from "node-fetch";
|
|
8
|
+
export const createResponse = async (headers, response, status) => ({
|
|
9
|
+
ok: response !== undefined,
|
|
10
|
+
status,
|
|
11
|
+
text: async () => JSON.stringify(response),
|
|
12
|
+
arrayBuffer: async () => response,
|
|
13
|
+
headers: headers ? new fetchModule.Headers(headers) : new fetchModule.Headers(),
|
|
14
|
+
json: async () => response,
|
|
15
|
+
});
|
|
16
|
+
export const okResponse = async (headers, response) => createResponse(headers, response, 200);
|
|
17
|
+
export const notFound = async (headers = {}) => createResponse(headers, undefined, 404);
|
|
18
|
+
export async function mockFetchMultiple(callback, responses, type = "single") {
|
|
19
|
+
const fetchStub = stub(fetchModule, "default");
|
|
20
|
+
fetchStub.callsFake(async () => {
|
|
21
|
+
if (type === "external") {
|
|
22
|
+
fetchStub.restore();
|
|
23
|
+
}
|
|
24
|
+
const cb = responses.shift();
|
|
25
|
+
assert(cb !== undefined, "the end");
|
|
26
|
+
return cb();
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
return await callback();
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
if (type !== "internal") {
|
|
33
|
+
fetchStub.restore();
|
|
34
|
+
}
|
|
35
|
+
assert(responses.length === 0, "all responses used");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export async function mockFetchSingle(callback, responseType, type = "single") {
|
|
39
|
+
return mockFetchMultiple(callback, [responseType], type);
|
|
40
|
+
}
|
|
41
|
+
export async function mockFetchOk(callback, response = {}, headers = {}) {
|
|
42
|
+
return mockFetchSingle(callback, async () => okResponse(headers, response));
|
|
43
|
+
}
|
|
44
|
+
export async function mockFetchError(callback, response, type = "single") {
|
|
45
|
+
const fetchStub = stub(fetchModule, "default");
|
|
46
|
+
fetchStub.callsFake(async () => {
|
|
47
|
+
if (type === "external") {
|
|
48
|
+
fetchStub.restore();
|
|
49
|
+
}
|
|
50
|
+
throw response;
|
|
51
|
+
});
|
|
52
|
+
try {
|
|
53
|
+
return await callback();
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
if (type !== "internal") {
|
|
57
|
+
fetchStub.restore();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=mockFetch.js.map
|
|
@@ -0,0 +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;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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 { 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"]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { strict as assert } from "node:assert";
|
|
6
|
+
import { MockLogger, isFluidError } from "@fluidframework/telemetry-utils";
|
|
7
|
+
import { SummaryType } from "@fluidframework/protocol-definitions";
|
|
8
|
+
import { OdspErrorTypes } from "@fluidframework/odsp-driver-definitions";
|
|
9
|
+
import { OdspDriverUrlResolver } from "../odspDriverUrlResolver.js";
|
|
10
|
+
import { OdspDocumentServiceFactory } from "../odspDocumentServiceFactory.js";
|
|
11
|
+
import { getOdspResolvedUrl } from "../odspUtils.js";
|
|
12
|
+
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";
|
|
16
|
+
describe("Odsp Create Container Test", () => {
|
|
17
|
+
const siteUrl = "https://www.localhost.xxx";
|
|
18
|
+
const driveId = "driveId";
|
|
19
|
+
const filePath = "path";
|
|
20
|
+
const fileName = "fileName";
|
|
21
|
+
const logger = new MockLogger();
|
|
22
|
+
let resolver;
|
|
23
|
+
let request;
|
|
24
|
+
const itemId = "fakeItemId";
|
|
25
|
+
const expectedResponse = {
|
|
26
|
+
context: "http://sp.devinstall/_api/v2.1/$metadata#",
|
|
27
|
+
sequenceNumber: 1,
|
|
28
|
+
sha: "shaxxshaxx",
|
|
29
|
+
itemUrl: `http://fake.microsoft.com/_api/v2.1/drives/${driveId}/items/${itemId}`,
|
|
30
|
+
driveId,
|
|
31
|
+
itemId,
|
|
32
|
+
id: "fakeSummaryHandle",
|
|
33
|
+
};
|
|
34
|
+
const odspDocumentServiceFactory = new OdspDocumentServiceFactory(async (_options) => "token", async (_options) => "token", new LocalPersistentCache(2000), { snapshotOptions: { timeout: 2000 } });
|
|
35
|
+
const createSummary = (putAppTree, putProtocolTree) => {
|
|
36
|
+
const summary = {
|
|
37
|
+
type: SummaryType.Tree,
|
|
38
|
+
tree: {},
|
|
39
|
+
};
|
|
40
|
+
if (putAppTree) {
|
|
41
|
+
summary.tree[".app"] = {
|
|
42
|
+
type: SummaryType.Tree,
|
|
43
|
+
tree: {},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (putProtocolTree) {
|
|
47
|
+
summary.tree[".protocol"] = {
|
|
48
|
+
type: SummaryType.Tree,
|
|
49
|
+
tree: {
|
|
50
|
+
attributes: {
|
|
51
|
+
type: SummaryType.Blob,
|
|
52
|
+
content: JSON.stringify({
|
|
53
|
+
branch: "",
|
|
54
|
+
minimumSequenceNumber: 0,
|
|
55
|
+
sequenceNumber: 0,
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return summary;
|
|
62
|
+
};
|
|
63
|
+
const createService = async (summary, resolved) => odspDocumentServiceFactory.createContainer(summary, resolved, logger);
|
|
64
|
+
beforeEach(() => {
|
|
65
|
+
resolver = new OdspDriverUrlResolver();
|
|
66
|
+
request = createOdspCreateContainerRequest(siteUrl, driveId, filePath, fileName);
|
|
67
|
+
});
|
|
68
|
+
afterEach(() => {
|
|
69
|
+
logger.assertMatchNone([{ category: "error" }]);
|
|
70
|
+
});
|
|
71
|
+
it("Check Document Service Successfully", async () => {
|
|
72
|
+
const resolved = await resolver.resolve(request);
|
|
73
|
+
const docID = await getHashedDocumentId(driveId, itemId);
|
|
74
|
+
const summary = createSummary(true, true);
|
|
75
|
+
const docService = await mockFetchOk(async () => odspDocumentServiceFactory.createContainer(summary, resolved, logger), expectedResponse, { "x-fluid-epoch": "epoch1" });
|
|
76
|
+
const finalResolverUrl = getOdspResolvedUrl(docService.resolvedUrl);
|
|
77
|
+
assert.strictEqual(finalResolverUrl.driveId, driveId, "Drive Id should match");
|
|
78
|
+
assert.strictEqual(finalResolverUrl.itemId, itemId, "ItemId should match");
|
|
79
|
+
assert.strictEqual(finalResolverUrl.siteUrl, siteUrl, "SiteUrl should match");
|
|
80
|
+
assert.strictEqual(finalResolverUrl.hashedDocumentId, docID, "DocId should match");
|
|
81
|
+
const url = `https://placeholder/placeholder/${docID}/`;
|
|
82
|
+
const snapshotUrl = `${siteUrl}/_api/v2.1/drives/${driveId}/items/${itemId}/opStream/snapshots`;
|
|
83
|
+
assert.strictEqual(finalResolverUrl.url, url, "Url should match");
|
|
84
|
+
assert.strictEqual(finalResolverUrl.endpoints.snapshotStorageUrl, snapshotUrl, "Snapshot url should match");
|
|
85
|
+
});
|
|
86
|
+
it("No App Summary", async () => {
|
|
87
|
+
const resolved = await resolver.resolve(request);
|
|
88
|
+
const summary = createSummary(false, true);
|
|
89
|
+
await assert.rejects(createService(summary, resolved), "Doc service should not be created because there was no app summary");
|
|
90
|
+
});
|
|
91
|
+
it("No protocol Summary", async () => {
|
|
92
|
+
const resolved = await resolver.resolve(request);
|
|
93
|
+
const summary = createSummary(true, false);
|
|
94
|
+
await assert.rejects(createService(summary, resolved), "Doc service should not be created because there was no protocol summary");
|
|
95
|
+
});
|
|
96
|
+
it("No item id in response from server", async () => {
|
|
97
|
+
const resolved = await resolver.resolve(request);
|
|
98
|
+
const summary = createSummary(true, true);
|
|
99
|
+
try {
|
|
100
|
+
await mockFetchMultiple(async () => createService(summary, resolved), [
|
|
101
|
+
// Due to retry logic in getWithRetryForTokenRefresh() for OdspErrorTypes.incorrectServerResponse
|
|
102
|
+
// Need to mock two calls
|
|
103
|
+
async () => okResponse({}, {}),
|
|
104
|
+
async () => okResponse({}, {}),
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
assert(isFluidError(error), "Error should be IFluidError");
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
110
|
+
assert.strictEqual(error.statusCode, undefined, "Wrong error code");
|
|
111
|
+
assert.strictEqual(error.errorType, OdspErrorTypes.incorrectServerResponse, "Error type should be correct");
|
|
112
|
+
assert.strictEqual(error.message, "ODSP CreateFile call returned no item ID", "Message should be correct");
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=odspCreateContainer.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"odspCreateContainer.spec.js","sourceRoot":"","sources":["../../src/test/odspCreateContainer.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAgB,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,cAAc,EAAoB,MAAM,yCAAyC,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5E,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC3C,MAAM,OAAO,GAAG,2BAA2B,CAAC;IAC5C,MAAM,OAAO,GAAG,SAAS,CAAC;IAC1B,MAAM,QAAQ,GAAG,MAAM,CAAC;IACxB,MAAM,QAAQ,GAAG,UAAU,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;IAChC,IAAI,QAA+B,CAAC;IACpC,IAAI,OAAiB,CA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Aa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE1C,IAAI;YACH,MAAM,iBAAiB,CACtB,KAAK,IAAI,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC5C;gBACC,iGAAiG;gBACjG,yBAAyB;gBACzB,KAAK,IAAqB,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC;gBAC/C,KAAK,IAAqB,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC;aAC/C,CACD,CAAC;SACF;QAAC,OAAO,KAAc,EAAE;YACxB,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,6BAA6B,CAAC,CAAC;YAC3D,0GAA0G;YAC1G,MAAM,CAAC,WAAW,CAAE,KAAa,CAAC,UAAU,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;YAC7E,MAAM,CAAC,WAAW,CACjB,KAAK,CAAC,SAAS,EACf,cAAc,CAAC,uBAAuB,EACtC,8BAA8B,CAC9B,CAAC;YACF,MAAM,CAAC,WAAW,CACjB,KAAK,CAAC,OAAO,EACb,0CAA0C,EAC1C,2BAA2B,CAC3B,CAAC;SACF;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 { IDocumentService } from \"@fluidframework/driver-definitions\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { MockLogger, isFluidError } from \"@fluidframework/telemetry-utils\";\nimport { ISummaryTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { OdspErrorTypes, IOdspResolvedUrl } from \"@fluidframework/odsp-driver-definitions\";\nimport { OdspDriverUrlResolver } from \"../odspDriverUrlResolver.js\";\nimport { OdspDocumentServiceFactory } from \"../odspDocumentServiceFactory.js\";\nimport { getOdspResolvedUrl } from \"../odspUtils.js\";\nimport { getHashedDocumentId } from \"../odspPublicUtils.js\";\nimport { LocalPersistentCache } from \"../odspCache.js\";\nimport { createOdspCreateContainerRequest } from \"../createOdspCreateContainerRequest.js\";\nimport { mockFetchOk, mockFetchMultiple, okResponse } from \"./mockFetch.js\";\n\ndescribe(\"Odsp Create Container Test\", () => {\n\tconst siteUrl = \"https://www.localhost.xxx\";\n\tconst driveId = \"driveId\";\n\tconst filePath = \"path\";\n\tconst fileName = \"fileName\";\n\tconst logger = new MockLogger();\n\tlet resolver: OdspDriverUrlResolver;\n\tlet request: IRequest;\n\n\tconst itemId = \"fakeItemId\";\n\tconst expectedResponse = {\n\t\tcontext: \"http://sp.devinstall/_api/v2.1/$metadata#\",\n\t\tsequenceNumber: 1,\n\t\tsha: \"shaxxshaxx\",\n\t\titemUrl: `http://fake.microsoft.com/_api/v2.1/drives/${driveId}/items/${itemId}`,\n\t\tdriveId,\n\t\titemId,\n\t\tid: \"fakeSummaryHandle\",\n\t};\n\n\tconst odspDocumentServiceFactory = new OdspDocumentServiceFactory(\n\t\tasync (_options) => \"token\",\n\t\tasync (_options) => \"token\",\n\t\tnew LocalPersistentCache(2000),\n\t\t{ snapshotOptions: { timeout: 2000 } },\n\t);\n\n\tconst createSummary = (putAppTree: boolean, putProtocolTree: boolean): ISummaryTree => {\n\t\tconst summary: ISummaryTree = {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: {},\n\t\t};\n\t\tif (putAppTree) {\n\t\t\tsummary.tree[\".app\"] = {\n\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\ttree: {},\n\t\t\t};\n\t\t}\n\t\tif (putProtocolTree) {\n\t\t\tsummary.tree[\".protocol\"] = {\n\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\ttree: {\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\t\t\tcontent: JSON.stringify({\n\t\t\t\t\t\t\tbranch: \"\",\n\t\t\t\t\t\t\tminimumSequenceNumber: 0,\n\t\t\t\t\t\t\tsequenceNumber: 0,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\treturn summary;\n\t};\n\n\tconst createService = async (\n\t\tsummary: ISummaryTree,\n\t\tresolved: IOdspResolvedUrl,\n\t): Promise<IDocumentService> =>\n\t\todspDocumentServiceFactory.createContainer(summary, resolved, logger);\n\n\tbeforeEach(() => {\n\t\tresolver = new OdspDriverUrlResolver();\n\t\trequest = createOdspCreateContainerRequest(siteUrl, driveId, filePath, fileName);\n\t});\n\tafterEach(() => {\n\t\tlogger.assertMatchNone([{ category: \"error\" }]);\n\t});\n\n\tit(\"Check Document Service Successfully\", async () => {\n\t\tconst resolved = await resolver.resolve(request);\n\t\tconst docID = await getHashedDocumentId(driveId, itemId);\n\t\tconst summary = createSummary(true, true);\n\t\tconst docService = await mockFetchOk(\n\t\t\tasync () => odspDocumentServiceFactory.createContainer(summary, resolved, logger),\n\t\t\texpectedResponse,\n\t\t\t{ \"x-fluid-epoch\": \"epoch1\" },\n\t\t);\n\t\tconst finalResolverUrl = getOdspResolvedUrl(docService.resolvedUrl);\n\t\tassert.strictEqual(finalResolverUrl.driveId, driveId, \"Drive Id should match\");\n\t\tassert.strictEqual(finalResolverUrl.itemId, itemId, \"ItemId should match\");\n\t\tassert.strictEqual(finalResolverUrl.siteUrl, siteUrl, \"SiteUrl should match\");\n\t\tassert.strictEqual(finalResolverUrl.hashedDocumentId, docID, \"DocId should match\");\n\n\t\tconst url = `https://placeholder/placeholder/${docID}/`;\n\t\tconst snapshotUrl = `${siteUrl}/_api/v2.1/drives/${driveId}/items/${itemId}/opStream/snapshots`;\n\t\tassert.strictEqual(finalResolverUrl.url, url, \"Url should match\");\n\t\tassert.strictEqual(\n\t\t\tfinalResolverUrl.endpoints.snapshotStorageUrl,\n\t\t\tsnapshotUrl,\n\t\t\t\"Snapshot url should match\",\n\t\t);\n\t});\n\n\tit(\"No App Summary\", async () => {\n\t\tconst resolved = await resolver.resolve(request);\n\t\tconst summary = createSummary(false, true);\n\t\tawait assert.rejects(\n\t\t\tcreateService(summary, resolved),\n\t\t\t\"Doc service should not be created because there was no app summary\",\n\t\t);\n\t});\n\n\tit(\"No protocol Summary\", async () => {\n\t\tconst resolved = await resolver.resolve(request);\n\t\tconst summary = createSummary(true, false);\n\t\tawait assert.rejects(\n\t\t\tcreateService(summary, resolved),\n\t\t\t\"Doc service should not be created because there was no protocol summary\",\n\t\t);\n\t});\n\n\tit(\"No item id in response from server\", async () => {\n\t\tconst resolved = await resolver.resolve(request);\n\t\tconst summary = createSummary(true, true);\n\n\t\ttry {\n\t\t\tawait mockFetchMultiple(\n\t\t\t\tasync () => createService(summary, resolved),\n\t\t\t\t[\n\t\t\t\t\t// Due to retry logic in getWithRetryForTokenRefresh() for OdspErrorTypes.incorrectServerResponse\n\t\t\t\t\t// Need to mock two calls\n\t\t\t\t\tasync (): Promise<object> => okResponse({}, {}),\n\t\t\t\t\tasync (): Promise<object> => okResponse({}, {}),\n\t\t\t\t],\n\t\t\t);\n\t\t} catch (error: unknown) {\n\t\t\tassert(isFluidError(error), \"Error should be IFluidError\");\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tassert.strictEqual((error as any).statusCode, undefined, \"Wrong error code\");\n\t\t\tassert.strictEqual(\n\t\t\t\terror.errorType,\n\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\"Error type should be correct\",\n\t\t\t);\n\t\t\tassert.strictEqual(\n\t\t\t\terror.message,\n\t\t\t\t\"ODSP CreateFile call returned no item ID\",\n\t\t\t\t\"Message should be correct\",\n\t\t\t);\n\t\t}\n\t});\n});\n"]}
|