@fluidframework/odsp-driver 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +12 -12
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +162 -0
- package/README.md +56 -0
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/odsp-driver.api.md +310 -0
- package/dist/{ReadBufferUtils.js → ReadBufferUtils.cjs} +16 -9
- package/dist/ReadBufferUtils.cjs.map +1 -0
- package/dist/ReadBufferUtils.d.ts.map +1 -1
- package/dist/{WriteBufferUtils.js → WriteBufferUtils.cjs} +73 -69
- package/dist/WriteBufferUtils.cjs.map +1 -0
- package/dist/WriteBufferUtils.d.ts +3 -5
- package/dist/WriteBufferUtils.d.ts.map +1 -1
- package/dist/{checkUrl.js → checkUrl.cjs} +7 -6
- package/dist/checkUrl.cjs.map +1 -0
- package/dist/checkUrl.d.ts +1 -0
- package/dist/checkUrl.d.ts.map +1 -1
- package/dist/compactSnapshotParser.cjs +207 -0
- package/dist/compactSnapshotParser.cjs.map +1 -0
- package/dist/compactSnapshotParser.d.ts +12 -3
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/{compactSnapshotWriter.js → compactSnapshotWriter.cjs} +43 -33
- package/dist/compactSnapshotWriter.cjs.map +1 -0
- package/dist/compactSnapshotWriter.d.ts +2 -3
- package/dist/compactSnapshotWriter.d.ts.map +1 -1
- package/dist/{constants.js → constants.cjs} +7 -1
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/{contracts.js → contracts.cjs} +1 -1
- package/dist/contracts.cjs.map +1 -0
- package/dist/contracts.d.ts +16 -53
- package/dist/contracts.d.ts.map +1 -1
- package/dist/{contractsPublic.js → contractsPublic.cjs} +9 -3
- package/dist/contractsPublic.cjs.map +1 -0
- package/dist/contractsPublic.d.ts +15 -0
- package/dist/contractsPublic.d.ts.map +1 -1
- package/dist/createFile.cjs +177 -0
- package/dist/createFile.cjs.map +1 -0
- package/dist/createFile.d.ts +6 -10
- package/dist/createFile.d.ts.map +1 -1
- package/dist/createNewContainerOnExistingFile.cjs +60 -0
- package/dist/createNewContainerOnExistingFile.cjs.map +1 -0
- package/dist/createNewContainerOnExistingFile.d.ts +22 -0
- package/dist/createNewContainerOnExistingFile.d.ts.map +1 -0
- package/dist/createNewModule.cjs +12 -0
- package/dist/createNewModule.cjs.map +1 -0
- package/dist/createNewModule.d.ts +7 -0
- package/dist/createNewModule.d.ts.map +1 -0
- package/dist/createNewUtils.cjs +203 -0
- package/dist/createNewUtils.cjs.map +1 -0
- package/dist/createNewUtils.d.ts +16 -0
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/{createOdspCreateContainerRequest.js → createOdspCreateContainerRequest.cjs} +8 -4
- package/dist/createOdspCreateContainerRequest.cjs.map +1 -0
- package/dist/createOdspCreateContainerRequest.d.ts +5 -3
- package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/dist/{createOdspUrl.js → createOdspUrl.cjs} +2 -1
- package/dist/createOdspUrl.cjs.map +1 -0
- package/dist/createOdspUrl.d.ts +1 -0
- package/dist/createOdspUrl.d.ts.map +1 -1
- package/dist/{epochTracker.js → epochTracker.cjs} +102 -48
- package/dist/epochTracker.cjs.map +1 -0
- package/dist/epochTracker.d.ts +32 -8
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/{fetch.js → fetch.cjs} +1 -1
- package/dist/fetch.cjs.map +1 -0
- package/dist/fetch.d.ts +1 -1
- package/dist/fetch.d.ts.map +1 -1
- package/dist/{fetchSnapshot.js → fetchSnapshot.cjs} +192 -176
- package/dist/fetchSnapshot.cjs.map +1 -0
- package/dist/fetchSnapshot.d.ts +10 -5
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/{getFileLink.js → getFileLink.cjs} +52 -41
- package/dist/getFileLink.cjs.map +1 -0
- package/dist/getFileLink.d.ts +4 -7
- package/dist/getFileLink.d.ts.map +1 -1
- package/dist/{getQueryString.js → getQueryString.cjs} +1 -1
- package/dist/getQueryString.cjs.map +1 -0
- package/dist/getQueryString.d.ts.map +1 -1
- package/dist/{getUrlAndHeadersWithAuth.js → getUrlAndHeadersWithAuth.cjs} +4 -2
- package/dist/getUrlAndHeadersWithAuth.cjs.map +1 -0
- package/dist/getUrlAndHeadersWithAuth.d.ts.map +1 -1
- package/dist/index.cjs +59 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/localOdspDriver/localOdspDeltaStorageService.cjs +35 -0
- package/dist/localOdspDriver/localOdspDeltaStorageService.cjs.map +1 -0
- package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts +17 -0
- package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
- package/dist/localOdspDriver/{localOdspDocumentService.js → localOdspDocumentService.cjs} +7 -5
- package/dist/localOdspDriver/localOdspDocumentService.cjs.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentService.d.ts +3 -2
- package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
- package/dist/localOdspDriver/{localOdspDocumentServiceFactory.js → localOdspDocumentServiceFactory.cjs} +9 -10
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.cjs.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +2 -3
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/localOdspDriver/{localOdspDocumentStorageManager.js → localOdspDocumentStorageManager.cjs} +13 -11
- package/dist/localOdspDriver/localOdspDocumentStorageManager.cjs.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts +2 -2
- package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odsp-driver-alpha.d.ts +497 -0
- package/dist/odsp-driver-beta.d.ts +159 -0
- package/dist/odsp-driver-public.d.ts +159 -0
- package/dist/odsp-driver-untrimmed.d.ts +566 -0
- package/dist/{odspCache.js → odspCache.cjs} +9 -10
- package/dist/odspCache.cjs.map +1 -0
- package/dist/odspCache.d.ts +19 -4
- package/dist/odspCache.d.ts.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.cjs +291 -0
- package/dist/odspDelayLoadedDeltaStream.cjs.map +1 -0
- package/dist/odspDelayLoadedDeltaStream.d.ts +75 -0
- package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -0
- package/dist/{odspDeltaStorageService.js → odspDeltaStorageService.cjs} +70 -71
- package/dist/odspDeltaStorageService.cjs.map +1 -0
- package/dist/odspDeltaStorageService.d.ts +8 -6
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/{odspDocumentDeltaConnection.js → odspDocumentDeltaConnection.cjs} +224 -113
- package/dist/odspDocumentDeltaConnection.cjs.map +1 -0
- package/dist/odspDocumentDeltaConnection.d.ts +32 -12
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentService.cjs +225 -0
- package/dist/odspDocumentService.cjs.map +1 -0
- package/dist/odspDocumentService.d.ts +11 -25
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/{odspDocumentServiceFactory.js → odspDocumentServiceFactory.cjs} +8 -5
- package/dist/odspDocumentServiceFactory.cjs.map +1 -0
- package/dist/odspDocumentServiceFactory.d.ts +4 -0
- package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.cjs +196 -0
- package/dist/odspDocumentServiceFactoryCore.cjs.map +1 -0
- package/dist/odspDocumentServiceFactoryCore.d.ts +16 -11
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.cjs +20 -0
- package/dist/odspDocumentServiceFactoryWithCodeSplit.cjs.map +1 -0
- package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +5 -0
- package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.cjs +490 -0
- package/dist/odspDocumentStorageManager.cjs.map +1 -0
- package/dist/odspDocumentStorageManager.d.ts +11 -5
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/{odspDocumentStorageServiceBase.js → odspDocumentStorageServiceBase.cjs} +32 -34
- package/dist/odspDocumentStorageServiceBase.cjs.map +1 -0
- package/dist/odspDocumentStorageServiceBase.d.ts +7 -9
- package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/dist/{odspDriverUrlResolver.js → odspDriverUrlResolver.cjs} +50 -36
- package/dist/odspDriverUrlResolver.cjs.map +1 -0
- package/dist/odspDriverUrlResolver.d.ts +12 -0
- package/dist/odspDriverUrlResolver.d.ts.map +1 -1
- package/dist/{odspDriverUrlResolverForShareLink.js → odspDriverUrlResolverForShareLink.cjs} +37 -26
- package/dist/odspDriverUrlResolverForShareLink.cjs.map +1 -0
- package/dist/odspDriverUrlResolverForShareLink.d.ts +5 -3
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/{odspError.js → odspError.cjs} +7 -3
- package/dist/odspError.cjs.map +1 -0
- package/dist/odspError.d.ts.map +1 -1
- package/dist/{odspFluidFileLink.js → odspFluidFileLink.cjs} +25 -18
- package/dist/odspFluidFileLink.cjs.map +1 -0
- package/dist/odspFluidFileLink.d.ts +10 -1
- package/dist/odspFluidFileLink.d.ts.map +1 -1
- package/dist/odspLocationRedirection.cjs +24 -0
- package/dist/odspLocationRedirection.cjs.map +1 -0
- package/dist/odspLocationRedirection.d.ts +14 -0
- package/dist/odspLocationRedirection.d.ts.map +1 -0
- package/dist/{odspPublicUtils.js → odspPublicUtils.cjs} +7 -4
- package/dist/odspPublicUtils.cjs.map +1 -0
- package/dist/odspPublicUtils.d.ts +6 -0
- package/dist/odspPublicUtils.d.ts.map +1 -1
- package/dist/{odspSnapshotParser.js → odspSnapshotParser.cjs} +11 -12
- package/dist/odspSnapshotParser.cjs.map +1 -0
- package/dist/odspSnapshotParser.d.ts.map +1 -1
- package/dist/{odspSummaryUploadManager.js → odspSummaryUploadManager.cjs} +47 -34
- package/dist/odspSummaryUploadManager.cjs.map +1 -0
- package/dist/odspSummaryUploadManager.d.ts +7 -4
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/{odspUrlHelper.js → odspUrlHelper.cjs} +9 -3
- package/dist/odspUrlHelper.cjs.map +1 -0
- package/dist/odspUrlHelper.d.ts +5 -0
- package/dist/odspUrlHelper.d.ts.map +1 -1
- package/dist/{odspUtils.js → odspUtils.cjs} +118 -30
- package/dist/odspUtils.cjs.map +1 -0
- package/dist/odspUtils.d.ts +35 -6
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/{opsCaching.js → opsCaching.cjs} +25 -9
- package/dist/opsCaching.cjs.map +1 -0
- package/dist/opsCaching.d.ts +3 -3
- package/dist/opsCaching.d.ts.map +1 -1
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/prefetchLatestSnapshot.cjs +100 -0
- package/dist/prefetchLatestSnapshot.cjs.map +1 -0
- package/dist/prefetchLatestSnapshot.d.ts +12 -7
- package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
- package/dist/{retryErrorsStorageAdapter.js → retryErrorsStorageAdapter.cjs} +13 -6
- package/dist/retryErrorsStorageAdapter.cjs.map +1 -0
- package/dist/retryErrorsStorageAdapter.d.ts +5 -4
- package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/dist/{retryUtils.js → retryUtils.cjs} +30 -14
- package/dist/retryUtils.cjs.map +1 -0
- package/dist/retryUtils.d.ts +2 -2
- package/dist/retryUtils.d.ts.map +1 -1
- package/dist/socketModule.cjs +10 -0
- package/dist/socketModule.cjs.map +1 -0
- package/dist/socketModule.d.ts +7 -0
- package/dist/socketModule.d.ts.map +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/{vroom.js → vroom.cjs} +24 -9
- package/dist/vroom.cjs.map +1 -0
- package/dist/vroom.d.ts +4 -4
- package/dist/vroom.d.ts.map +1 -1
- package/dist/{zipItDataRepresentationUtils.js → zipItDataRepresentationUtils.cjs} +227 -118
- package/dist/zipItDataRepresentationUtils.cjs.map +1 -0
- package/dist/zipItDataRepresentationUtils.d.ts +47 -20
- package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/lib/ReadBufferUtils.d.mts.map +1 -0
- package/lib/{ReadBufferUtils.js → ReadBufferUtils.mjs} +14 -7
- package/lib/ReadBufferUtils.mjs.map +1 -0
- package/lib/{WriteBufferUtils.d.ts → WriteBufferUtils.d.mts} +3 -5
- package/lib/WriteBufferUtils.d.mts.map +1 -0
- package/lib/{WriteBufferUtils.js → WriteBufferUtils.mjs} +68 -64
- package/lib/WriteBufferUtils.mjs.map +1 -0
- package/lib/{checkUrl.d.ts → checkUrl.d.mts} +1 -0
- package/lib/checkUrl.d.mts.map +1 -0
- package/lib/{checkUrl.js → checkUrl.mjs} +7 -6
- package/lib/checkUrl.mjs.map +1 -0
- package/lib/compactSnapshotParser.d.mts +24 -0
- package/lib/compactSnapshotParser.d.mts.map +1 -0
- package/lib/compactSnapshotParser.mjs +203 -0
- package/lib/compactSnapshotParser.mjs.map +1 -0
- package/lib/{compactSnapshotWriter.d.ts → compactSnapshotWriter.d.mts} +3 -4
- package/lib/compactSnapshotWriter.d.mts.map +1 -0
- package/lib/{compactSnapshotWriter.js → compactSnapshotWriter.mjs} +41 -31
- package/lib/compactSnapshotWriter.mjs.map +1 -0
- package/lib/{constants.d.ts → constants.d.mts} +6 -0
- package/lib/constants.d.mts.map +1 -0
- package/lib/{constants.js → constants.mjs} +7 -1
- package/lib/constants.mjs.map +1 -0
- package/lib/{contracts.d.ts → contracts.d.mts} +17 -54
- package/lib/contracts.d.mts.map +1 -0
- package/lib/{contracts.js → contracts.mjs} +1 -1
- package/lib/contracts.mjs.map +1 -0
- package/lib/{contractsPublic.d.ts → contractsPublic.d.mts} +15 -0
- package/lib/contractsPublic.d.mts.map +1 -0
- package/lib/{contractsPublic.js → contractsPublic.mjs} +7 -1
- package/lib/contractsPublic.mjs.map +1 -0
- package/lib/createFile.d.mts +18 -0
- package/lib/createFile.d.mts.map +1 -0
- package/lib/createFile.mjs +171 -0
- package/lib/createFile.mjs.map +1 -0
- package/lib/createNewContainerOnExistingFile.d.mts +22 -0
- package/lib/createNewContainerOnExistingFile.d.mts.map +1 -0
- package/lib/createNewContainerOnExistingFile.mjs +56 -0
- package/lib/createNewContainerOnExistingFile.mjs.map +1 -0
- package/lib/createNewModule.d.mts +7 -0
- package/lib/createNewModule.d.mts.map +1 -0
- package/lib/createNewModule.mjs +7 -0
- package/lib/createNewModule.mjs.map +1 -0
- package/lib/createNewUtils.d.mts +27 -0
- package/lib/createNewUtils.d.mts.map +1 -0
- package/lib/createNewUtils.mjs +197 -0
- package/lib/createNewUtils.mjs.map +1 -0
- package/lib/{createOdspCreateContainerRequest.d.ts → createOdspCreateContainerRequest.d.mts} +5 -7
- package/lib/createOdspCreateContainerRequest.d.mts.map +1 -0
- package/lib/{createOdspCreateContainerRequest.js → createOdspCreateContainerRequest.mjs} +8 -4
- package/lib/createOdspCreateContainerRequest.mjs.map +1 -0
- package/lib/{createOdspUrl.d.ts → createOdspUrl.d.mts} +2 -1
- package/lib/{createOdspUrl.d.ts.map → createOdspUrl.d.mts.map} +1 -1
- package/lib/{createOdspUrl.js → createOdspUrl.mjs} +2 -1
- package/lib/createOdspUrl.mjs.map +1 -0
- package/lib/{epochTracker.d.ts → epochTracker.d.mts} +34 -10
- package/lib/epochTracker.d.mts.map +1 -0
- package/lib/{epochTracker.js → epochTracker.mjs} +97 -43
- package/lib/epochTracker.mjs.map +1 -0
- package/lib/{fetch.d.ts → fetch.d.mts} +1 -1
- package/lib/{fetch.d.ts.map → fetch.d.mts.map} +1 -1
- package/lib/{fetch.js → fetch.mjs} +1 -1
- package/lib/fetch.mjs.map +1 -0
- package/lib/{fetchSnapshot.d.ts → fetchSnapshot.d.mts} +14 -9
- package/lib/fetchSnapshot.d.mts.map +1 -0
- package/lib/{fetchSnapshot.js → fetchSnapshot.mjs} +185 -167
- package/lib/fetchSnapshot.mjs.map +1 -0
- package/lib/{getFileLink.d.ts → getFileLink.d.mts} +4 -7
- package/lib/getFileLink.d.mts.map +1 -0
- package/lib/{getFileLink.js → getFileLink.mjs} +49 -38
- package/lib/getFileLink.mjs.map +1 -0
- package/lib/{getQueryString.d.ts → getQueryString.d.mts} +0 -4
- package/lib/getQueryString.d.mts.map +1 -0
- package/lib/{getQueryString.js → getQueryString.mjs} +1 -1
- package/lib/getQueryString.mjs.map +1 -0
- package/lib/{getUrlAndHeadersWithAuth.d.ts.map → getUrlAndHeadersWithAuth.d.mts.map} +1 -1
- package/lib/{getUrlAndHeadersWithAuth.js → getUrlAndHeadersWithAuth.mjs} +4 -2
- package/lib/getUrlAndHeadersWithAuth.mjs.map +1 -0
- package/lib/index.d.mts +24 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +22 -0
- package/lib/index.mjs.map +1 -0
- package/lib/localOdspDriver/localOdspDeltaStorageService.d.mts +17 -0
- package/lib/localOdspDriver/localOdspDeltaStorageService.d.mts.map +1 -0
- package/lib/localOdspDriver/localOdspDeltaStorageService.mjs +31 -0
- package/lib/localOdspDriver/localOdspDeltaStorageService.mjs.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentService.d.ts → localOdspDocumentService.d.mts} +3 -2
- package/lib/localOdspDriver/localOdspDocumentService.d.mts.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentService.js → localOdspDocumentService.mjs} +8 -6
- package/lib/localOdspDriver/localOdspDocumentService.mjs.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentServiceFactory.d.ts → localOdspDocumentServiceFactory.d.mts} +4 -5
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.mts.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentServiceFactory.js → localOdspDocumentServiceFactory.mjs} +9 -10
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.mjs.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentStorageManager.d.ts → localOdspDocumentStorageManager.d.mts} +3 -3
- package/lib/localOdspDriver/localOdspDocumentStorageManager.d.mts.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentStorageManager.js → localOdspDocumentStorageManager.mjs} +11 -9
- package/lib/localOdspDriver/localOdspDocumentStorageManager.mjs.map +1 -0
- package/lib/odsp-driver-alpha.d.mts +497 -0
- package/lib/odsp-driver-beta.d.mts +159 -0
- package/lib/odsp-driver-public.d.mts +159 -0
- package/lib/odsp-driver-untrimmed.d.mts +566 -0
- package/lib/{odspCache.d.ts → odspCache.d.mts} +19 -8
- package/lib/odspCache.d.mts.map +1 -0
- package/lib/{odspCache.js → odspCache.mjs} +6 -11
- package/lib/odspCache.mjs.map +1 -0
- package/lib/odspDelayLoadedDeltaStream.d.mts +75 -0
- package/lib/odspDelayLoadedDeltaStream.d.mts.map +1 -0
- package/lib/odspDelayLoadedDeltaStream.mjs +287 -0
- package/lib/odspDelayLoadedDeltaStream.mjs.map +1 -0
- package/lib/{odspDeltaStorageService.d.ts → odspDeltaStorageService.d.mts} +9 -7
- package/lib/odspDeltaStorageService.d.mts.map +1 -0
- package/lib/{odspDeltaStorageService.js → odspDeltaStorageService.mjs} +70 -68
- package/lib/odspDeltaStorageService.mjs.map +1 -0
- package/lib/{odspDocumentDeltaConnection.d.ts → odspDocumentDeltaConnection.d.mts} +33 -13
- package/lib/odspDocumentDeltaConnection.d.mts.map +1 -0
- package/lib/{odspDocumentDeltaConnection.js → odspDocumentDeltaConnection.mjs} +214 -103
- package/lib/odspDocumentDeltaConnection.mjs.map +1 -0
- package/lib/{odspDocumentService.d.ts → odspDocumentService.d.mts} +14 -28
- package/lib/odspDocumentService.d.mts.map +1 -0
- package/lib/odspDocumentService.mjs +221 -0
- package/lib/odspDocumentService.mjs.map +1 -0
- package/lib/{odspDocumentServiceFactory.d.ts → odspDocumentServiceFactory.d.mts} +5 -1
- package/lib/odspDocumentServiceFactory.d.mts.map +1 -0
- package/lib/{odspDocumentServiceFactory.js → odspDocumentServiceFactory.mjs} +8 -6
- package/lib/odspDocumentServiceFactory.mjs.map +1 -0
- package/lib/{odspDocumentServiceFactoryCore.d.ts → odspDocumentServiceFactoryCore.d.mts} +17 -12
- package/lib/odspDocumentServiceFactoryCore.d.mts.map +1 -0
- package/lib/odspDocumentServiceFactoryCore.mjs +192 -0
- package/lib/odspDocumentServiceFactoryCore.mjs.map +1 -0
- package/lib/{odspDocumentServiceFactoryWithCodeSplit.d.ts → odspDocumentServiceFactoryWithCodeSplit.d.mts} +6 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.d.mts.map +1 -0
- package/lib/{odspDocumentServiceFactoryWithCodeSplit.js → odspDocumentServiceFactoryWithCodeSplit.mjs} +8 -3
- package/lib/odspDocumentServiceFactoryWithCodeSplit.mjs.map +1 -0
- package/lib/{odspDocumentStorageManager.d.ts → odspDocumentStorageManager.d.mts} +17 -11
- package/lib/odspDocumentStorageManager.d.mts.map +1 -0
- package/lib/odspDocumentStorageManager.mjs +486 -0
- package/lib/odspDocumentStorageManager.mjs.map +1 -0
- package/lib/{odspDocumentStorageServiceBase.d.ts → odspDocumentStorageServiceBase.d.mts} +8 -10
- package/lib/odspDocumentStorageServiceBase.d.mts.map +1 -0
- package/lib/{odspDocumentStorageServiceBase.js → odspDocumentStorageServiceBase.mjs} +31 -33
- package/lib/odspDocumentStorageServiceBase.mjs.map +1 -0
- package/lib/{odspDriverUrlResolver.d.ts → odspDriverUrlResolver.d.mts} +12 -0
- package/lib/odspDriverUrlResolver.d.mts.map +1 -0
- package/lib/{odspDriverUrlResolver.js → odspDriverUrlResolver.mjs} +50 -40
- package/lib/odspDriverUrlResolver.mjs.map +1 -0
- package/lib/{odspDriverUrlResolverForShareLink.d.ts → odspDriverUrlResolverForShareLink.d.mts} +6 -4
- package/lib/odspDriverUrlResolverForShareLink.d.mts.map +1 -0
- package/lib/{odspDriverUrlResolverForShareLink.js → odspDriverUrlResolverForShareLink.mjs} +36 -29
- package/lib/odspDriverUrlResolverForShareLink.mjs.map +1 -0
- package/lib/{odspError.d.ts → odspError.d.mts} +1 -1
- package/lib/odspError.d.mts.map +1 -0
- package/lib/{odspError.js → odspError.mjs} +7 -3
- package/lib/odspError.mjs.map +1 -0
- package/lib/{odspFluidFileLink.d.ts → odspFluidFileLink.d.mts} +11 -2
- package/lib/odspFluidFileLink.d.mts.map +1 -0
- package/lib/{odspFluidFileLink.js → odspFluidFileLink.mjs} +23 -16
- package/lib/odspFluidFileLink.mjs.map +1 -0
- package/lib/odspLocationRedirection.d.mts +14 -0
- package/lib/odspLocationRedirection.d.mts.map +1 -0
- package/lib/odspLocationRedirection.mjs +20 -0
- package/lib/odspLocationRedirection.mjs.map +1 -0
- package/lib/{odspPublicUtils.d.ts → odspPublicUtils.d.mts} +6 -0
- package/lib/odspPublicUtils.d.mts.map +1 -0
- package/lib/{odspPublicUtils.js → odspPublicUtils.mjs} +5 -2
- package/lib/odspPublicUtils.mjs.map +1 -0
- package/lib/{odspSnapshotParser.d.ts → odspSnapshotParser.d.mts} +2 -2
- package/lib/odspSnapshotParser.d.mts.map +1 -0
- package/lib/{odspSnapshotParser.js → odspSnapshotParser.mjs} +10 -11
- package/lib/odspSnapshotParser.mjs.map +1 -0
- package/lib/{odspSummaryUploadManager.d.ts → odspSummaryUploadManager.d.mts} +8 -5
- package/lib/odspSummaryUploadManager.d.mts.map +1 -0
- package/lib/{odspSummaryUploadManager.js → odspSummaryUploadManager.mjs} +41 -32
- package/lib/odspSummaryUploadManager.mjs.map +1 -0
- package/lib/{odspUrlHelper.d.ts → odspUrlHelper.d.mts} +5 -0
- package/lib/odspUrlHelper.d.mts.map +1 -0
- package/lib/{odspUrlHelper.js → odspUrlHelper.mjs} +9 -3
- package/lib/odspUrlHelper.mjs.map +1 -0
- package/lib/{odspUtils.d.ts → odspUtils.d.mts} +36 -7
- package/lib/odspUtils.d.mts.map +1 -0
- package/lib/{odspUtils.js → odspUtils.mjs} +109 -27
- package/lib/odspUtils.mjs.map +1 -0
- package/lib/{opsCaching.d.ts → opsCaching.d.mts} +3 -3
- package/lib/opsCaching.d.mts.map +1 -0
- package/lib/{opsCaching.js → opsCaching.mjs} +23 -7
- package/lib/opsCaching.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/{prefetchLatestSnapshot.d.ts → prefetchLatestSnapshot.d.mts} +13 -8
- package/lib/prefetchLatestSnapshot.d.mts.map +1 -0
- package/lib/prefetchLatestSnapshot.mjs +96 -0
- package/lib/prefetchLatestSnapshot.mjs.map +1 -0
- package/lib/{retryErrorsStorageAdapter.d.ts → retryErrorsStorageAdapter.d.mts} +5 -4
- package/lib/retryErrorsStorageAdapter.d.mts.map +1 -0
- package/lib/{retryErrorsStorageAdapter.js → retryErrorsStorageAdapter.mjs} +13 -6
- package/lib/retryErrorsStorageAdapter.mjs.map +1 -0
- package/lib/{retryUtils.d.ts → retryUtils.d.mts} +2 -2
- package/lib/retryUtils.d.mts.map +1 -0
- package/lib/{retryUtils.js → retryUtils.mjs} +27 -11
- package/lib/retryUtils.mjs.map +1 -0
- package/lib/socketModule.d.mts +7 -0
- package/lib/socketModule.d.mts.map +1 -0
- package/lib/socketModule.mjs +7 -0
- package/lib/socketModule.mjs.map +1 -0
- package/lib/{vroom.d.ts → vroom.d.mts} +6 -6
- package/lib/vroom.d.mts.map +1 -0
- package/lib/{vroom.js → vroom.mjs} +24 -9
- package/lib/vroom.mjs.map +1 -0
- package/lib/{zipItDataRepresentationUtils.d.ts → zipItDataRepresentationUtils.d.mts} +48 -21
- package/lib/zipItDataRepresentationUtils.d.mts.map +1 -0
- package/lib/{zipItDataRepresentationUtils.js → zipItDataRepresentationUtils.mjs} +213 -111
- package/lib/zipItDataRepresentationUtils.mjs.map +1 -0
- package/package.json +89 -69
- package/prettier.config.cjs +8 -0
- package/src/ReadBufferUtils.ts +51 -44
- package/src/WriteBufferUtils.ts +203 -181
- package/src/checkUrl.ts +16 -15
- package/src/compactSnapshotParser.ts +219 -103
- package/src/compactSnapshotWriter.ts +118 -97
- package/src/constants.ts +7 -0
- package/src/contracts.ts +96 -136
- package/src/contractsPublic.ts +31 -16
- package/src/createFile.ts +243 -305
- package/src/createNewContainerOnExistingFile.ts +93 -0
- package/src/createNewModule.ts +7 -0
- package/src/createNewUtils.ts +266 -56
- package/src/createOdspCreateContainerRequest.ts +22 -18
- package/src/createOdspUrl.ts +12 -13
- package/src/epochTracker.ts +596 -457
- package/src/fetch.ts +4 -4
- package/src/fetchSnapshot.ts +583 -508
- package/src/getFileLink.ts +194 -155
- package/src/getQueryString.ts +11 -9
- package/src/getUrlAndHeadersWithAuth.ts +34 -33
- package/src/index.ts +42 -18
- package/src/localOdspDriver/localOdspDeltaStorageService.ts +49 -0
- package/src/localOdspDriver/localOdspDocumentService.ts +40 -38
- package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +46 -43
- package/src/localOdspDriver/localOdspDocumentStorageManager.ts +55 -50
- package/src/odspCache.ts +112 -90
- package/src/odspDelayLoadedDeltaStream.ts +459 -0
- package/src/odspDeltaStorageService.ts +232 -221
- package/src/odspDocumentDeltaConnection.ts +751 -563
- package/src/odspDocumentService.ts +324 -523
- package/src/odspDocumentServiceFactory.ts +20 -21
- package/src/odspDocumentServiceFactoryCore.ts +325 -202
- package/src/odspDocumentServiceFactoryWithCodeSplit.ts +20 -20
- package/src/odspDocumentStorageManager.ts +730 -534
- package/src/odspDocumentStorageServiceBase.ts +279 -254
- package/src/odspDriverUrlResolver.ts +230 -188
- package/src/odspDriverUrlResolverForShareLink.ts +223 -203
- package/src/odspError.ts +27 -19
- package/src/odspFluidFileLink.ts +106 -87
- package/src/odspLocationRedirection.ts +26 -0
- package/src/odspPublicUtils.ts +20 -14
- package/src/odspSnapshotParser.ts +53 -46
- package/src/odspSummaryUploadManager.ts +243 -218
- package/src/odspUrlHelper.ts +81 -71
- package/src/odspUtils.ts +401 -259
- package/src/opsCaching.ts +214 -193
- package/src/packageVersion.ts +1 -1
- package/src/prefetchLatestSnapshot.ts +142 -80
- package/src/retryErrorsStorageAdapter.ts +92 -77
- package/src/retryUtils.ts +80 -57
- package/src/socketModule.ts +8 -0
- package/src/vroom.ts +92 -83
- package/src/zipItDataRepresentationUtils.ts +534 -394
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +11 -13
- package/.editorconfig +0 -7
- package/dist/ReadBufferUtils.js.map +0 -1
- package/dist/WriteBufferUtils.js.map +0 -1
- package/dist/checkUrl.js.map +0 -1
- package/dist/compactSnapshotParser.js +0 -115
- package/dist/compactSnapshotParser.js.map +0 -1
- package/dist/compactSnapshotWriter.js.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/contracts.js.map +0 -1
- package/dist/contractsPublic.js.map +0 -1
- package/dist/createFile.js +0 -242
- package/dist/createFile.js.map +0 -1
- package/dist/createNewUtils.js +0 -67
- package/dist/createNewUtils.js.map +0 -1
- package/dist/createOdspCreateContainerRequest.js.map +0 -1
- package/dist/createOdspUrl.js.map +0 -1
- package/dist/epochTracker.js.map +0 -1
- package/dist/fetch.js.map +0 -1
- package/dist/fetchSnapshot.js.map +0 -1
- package/dist/getFileLink.js.map +0 -1
- package/dist/getQueryString.js.map +0 -1
- package/dist/getSocketIo.d.ts +0 -11
- package/dist/getSocketIo.d.ts.map +0 -1
- package/dist/getSocketIo.js +0 -20
- package/dist/getSocketIo.js.map +0 -1
- package/dist/getUrlAndHeadersWithAuth.js.map +0 -1
- package/dist/index.js +0 -41
- package/dist/index.js.map +0 -1
- package/dist/localOdspDriver/localOdspDocumentService.js.map +0 -1
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +0 -1
- package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +0 -1
- package/dist/odspCache.js.map +0 -1
- package/dist/odspDeltaStorageService.js.map +0 -1
- package/dist/odspDocumentDeltaConnection.js.map +0 -1
- package/dist/odspDocumentService.js +0 -364
- package/dist/odspDocumentService.js.map +0 -1
- package/dist/odspDocumentServiceFactory.js.map +0 -1
- package/dist/odspDocumentServiceFactoryCore.js +0 -118
- package/dist/odspDocumentServiceFactoryCore.js.map +0 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.js +0 -34
- package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +0 -1
- package/dist/odspDocumentStorageManager.js +0 -356
- package/dist/odspDocumentStorageManager.js.map +0 -1
- package/dist/odspDocumentStorageServiceBase.js.map +0 -1
- package/dist/odspDriverUrlResolver.js.map +0 -1
- package/dist/odspDriverUrlResolverForShareLink.js.map +0 -1
- package/dist/odspError.js.map +0 -1
- package/dist/odspFluidFileLink.js.map +0 -1
- package/dist/odspPublicUtils.js.map +0 -1
- package/dist/odspSnapshotParser.js.map +0 -1
- package/dist/odspSummaryUploadManager.js.map +0 -1
- package/dist/odspUrlHelper.js.map +0 -1
- package/dist/odspUtils.js.map +0 -1
- package/dist/opsCaching.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/prefetchLatestSnapshot.js +0 -57
- package/dist/prefetchLatestSnapshot.js.map +0 -1
- package/dist/retryErrorsStorageAdapter.js.map +0 -1
- package/dist/retryUtils.js.map +0 -1
- package/dist/vroom.js.map +0 -1
- package/dist/zipItDataRepresentationUtils.js.map +0 -1
- package/lib/ReadBufferUtils.d.ts.map +0 -1
- package/lib/ReadBufferUtils.js.map +0 -1
- package/lib/WriteBufferUtils.d.ts.map +0 -1
- package/lib/WriteBufferUtils.js.map +0 -1
- package/lib/checkUrl.d.ts.map +0 -1
- package/lib/checkUrl.js.map +0 -1
- package/lib/compactSnapshotParser.d.ts +0 -15
- package/lib/compactSnapshotParser.d.ts.map +0 -1
- package/lib/compactSnapshotParser.js +0 -111
- package/lib/compactSnapshotParser.js.map +0 -1
- package/lib/compactSnapshotWriter.d.ts.map +0 -1
- package/lib/compactSnapshotWriter.js.map +0 -1
- package/lib/constants.d.ts.map +0 -1
- package/lib/constants.js.map +0 -1
- package/lib/contracts.d.ts.map +0 -1
- package/lib/contracts.js.map +0 -1
- package/lib/contractsPublic.d.ts.map +0 -1
- package/lib/contractsPublic.js.map +0 -1
- package/lib/createFile.d.ts +0 -22
- package/lib/createFile.d.ts.map +0 -1
- package/lib/createFile.js +0 -235
- package/lib/createFile.js.map +0 -1
- package/lib/createNewUtils.d.ts +0 -11
- package/lib/createNewUtils.d.ts.map +0 -1
- package/lib/createNewUtils.js +0 -63
- package/lib/createNewUtils.js.map +0 -1
- package/lib/createOdspCreateContainerRequest.d.ts.map +0 -1
- package/lib/createOdspCreateContainerRequest.js.map +0 -1
- package/lib/createOdspUrl.js.map +0 -1
- package/lib/epochTracker.d.ts.map +0 -1
- package/lib/epochTracker.js.map +0 -1
- package/lib/fetch.js.map +0 -1
- package/lib/fetchSnapshot.d.ts.map +0 -1
- package/lib/fetchSnapshot.js.map +0 -1
- package/lib/getFileLink.d.ts.map +0 -1
- package/lib/getFileLink.js.map +0 -1
- package/lib/getQueryString.d.ts.map +0 -1
- package/lib/getQueryString.js.map +0 -1
- package/lib/getSocketIo.d.ts +0 -11
- package/lib/getSocketIo.d.ts.map +0 -1
- package/lib/getSocketIo.js +0 -13
- package/lib/getSocketIo.js.map +0 -1
- package/lib/getUrlAndHeadersWithAuth.js.map +0 -1
- package/lib/index.d.ts +0 -21
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -29
- package/lib/index.js.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentService.js.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +0 -1
- package/lib/odspCache.d.ts.map +0 -1
- package/lib/odspCache.js.map +0 -1
- package/lib/odspDeltaStorageService.d.ts.map +0 -1
- package/lib/odspDeltaStorageService.js.map +0 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +0 -1
- package/lib/odspDocumentDeltaConnection.js.map +0 -1
- package/lib/odspDocumentService.d.ts.map +0 -1
- package/lib/odspDocumentService.js +0 -360
- package/lib/odspDocumentService.js.map +0 -1
- package/lib/odspDocumentServiceFactory.d.ts.map +0 -1
- package/lib/odspDocumentServiceFactory.js.map +0 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +0 -1
- package/lib/odspDocumentServiceFactoryCore.js +0 -114
- package/lib/odspDocumentServiceFactoryCore.js.map +0 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +0 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +0 -1
- package/lib/odspDocumentStorageManager.d.ts.map +0 -1
- package/lib/odspDocumentStorageManager.js +0 -352
- package/lib/odspDocumentStorageManager.js.map +0 -1
- package/lib/odspDocumentStorageServiceBase.d.ts.map +0 -1
- package/lib/odspDocumentStorageServiceBase.js.map +0 -1
- package/lib/odspDriverUrlResolver.d.ts.map +0 -1
- package/lib/odspDriverUrlResolver.js.map +0 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +0 -1
- package/lib/odspDriverUrlResolverForShareLink.js.map +0 -1
- package/lib/odspError.d.ts.map +0 -1
- package/lib/odspError.js.map +0 -1
- package/lib/odspFluidFileLink.d.ts.map +0 -1
- package/lib/odspFluidFileLink.js.map +0 -1
- package/lib/odspPublicUtils.d.ts.map +0 -1
- package/lib/odspPublicUtils.js.map +0 -1
- package/lib/odspSnapshotParser.d.ts.map +0 -1
- package/lib/odspSnapshotParser.js.map +0 -1
- package/lib/odspSummaryUploadManager.d.ts.map +0 -1
- package/lib/odspSummaryUploadManager.js.map +0 -1
- package/lib/odspUrlHelper.d.ts.map +0 -1
- package/lib/odspUrlHelper.js.map +0 -1
- package/lib/odspUtils.d.ts.map +0 -1
- package/lib/odspUtils.js.map +0 -1
- package/lib/opsCaching.d.ts.map +0 -1
- package/lib/opsCaching.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/prefetchLatestSnapshot.d.ts.map +0 -1
- package/lib/prefetchLatestSnapshot.js +0 -53
- package/lib/prefetchLatestSnapshot.js.map +0 -1
- package/lib/retryErrorsStorageAdapter.d.ts.map +0 -1
- package/lib/retryErrorsStorageAdapter.js.map +0 -1
- package/lib/retryUtils.d.ts.map +0 -1
- package/lib/retryUtils.js.map +0 -1
- package/lib/vroom.d.ts.map +0 -1
- package/lib/vroom.js.map +0 -1
- package/lib/zipItDataRepresentationUtils.d.ts.map +0 -1
- package/lib/zipItDataRepresentationUtils.js.map +0 -1
- package/src/getSocketIo.ts +0 -14
- package/tsconfig.esnext.json +0 -7
- /package/lib/{ReadBufferUtils.d.ts → ReadBufferUtils.d.mts} +0 -0
- /package/lib/{getUrlAndHeadersWithAuth.d.ts → getUrlAndHeadersWithAuth.d.mts} +0 -0
|
@@ -3,23 +3,34 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { v4 as uuid } from "uuid";
|
|
6
|
-
import { assert, Deferred } from "@fluidframework/
|
|
7
|
-
import {
|
|
6
|
+
import { assert, Deferred } from "@fluidframework/core-utils";
|
|
7
|
+
import { PerformanceEvent, isFluidError, normalizeError, loggerToMonitoringContext, wrapError, } from "@fluidframework/telemetry-utils";
|
|
8
|
+
import { ThrottlingError, RateLimiter, NonRetryableError, LocationRedirectionError, } from "@fluidframework/driver-utils";
|
|
8
9
|
import { snapshotKey, } from "@fluidframework/odsp-driver-definitions";
|
|
9
10
|
import { DriverErrorType } from "@fluidframework/driver-definitions";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import { fetchAndParseAsJSONHelper, fetchArray, fetchHelper, getOdspResolvedUrl, } from "./odspUtils.mjs";
|
|
12
|
+
import { persistedCacheValueVersion } from "./contracts.mjs";
|
|
13
|
+
import { ClpCompliantAppHeader } from "./contractsPublic.mjs";
|
|
14
|
+
import { pkgVersion as driverVersion } from "./packageVersion.mjs";
|
|
15
|
+
import { patchOdspResolvedUrl } from "./odspLocationRedirection.mjs";
|
|
15
16
|
export const Odsp409Error = "Odsp409Error";
|
|
16
|
-
//
|
|
17
|
-
export const defaultCacheExpiryTimeoutMs = 2 * 24 * 60 * 60 * 1000;
|
|
17
|
+
// Must be less than policy of 5 days
|
|
18
|
+
export const defaultCacheExpiryTimeoutMs = 2 * 24 * 60 * 60 * 1000; // 2 days in ms
|
|
18
19
|
/**
|
|
20
|
+
* In ODSP, the concept of "epoch" refers to binary updates to files. For example, this might include using
|
|
21
|
+
* version restore, or if the user downloads a Fluid file and then uploads it again. These result in the epoch
|
|
22
|
+
* value being incremented.
|
|
23
|
+
*
|
|
24
|
+
* The implications of these binary updates is that the Fluid state is disrupted: the sequence number might
|
|
25
|
+
* go backwards, the data might be inconsistent with the latest state of collaboration, etc. As a result, it's
|
|
26
|
+
* not safe to continue collaboration across an epoch change. We need to detect these epoch changes and
|
|
27
|
+
* error out from the collaboration.
|
|
28
|
+
*
|
|
19
29
|
* This class is a wrapper around fetch calls. It adds epoch to the request made so that the
|
|
20
30
|
* server can match it with its epoch value in order to match the version.
|
|
21
31
|
* It also validates the epoch value received in response of fetch calls. If the epoch does not match,
|
|
22
32
|
* then it also clears all the cached entries for the given container.
|
|
33
|
+
* @alpha
|
|
23
34
|
*/
|
|
24
35
|
export class EpochTracker {
|
|
25
36
|
constructor(cache, fileEntry, logger, clientIsSummarizer) {
|
|
@@ -32,6 +43,10 @@ export class EpochTracker {
|
|
|
32
43
|
this.networkCallNumber = 1;
|
|
33
44
|
// Limits the max number of concurrent requests to 24.
|
|
34
45
|
this.rateLimiter = new RateLimiter(24);
|
|
46
|
+
// Matches the TestOverride logic for the policy defined in odspDocumentStorageServiceBase.ts
|
|
47
|
+
this.snapshotCacheExpiryTimeoutMs = loggerToMonitoringContext(logger).config.getBoolean("Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache")
|
|
48
|
+
? 0
|
|
49
|
+
: defaultCacheExpiryTimeoutMs;
|
|
35
50
|
}
|
|
36
51
|
// public for UT purposes only!
|
|
37
52
|
setEpoch(epoch, fromCache, fetchType) {
|
|
@@ -45,7 +60,6 @@ export class EpochTracker {
|
|
|
45
60
|
});
|
|
46
61
|
}
|
|
47
62
|
async get(entry) {
|
|
48
|
-
var _a;
|
|
49
63
|
try {
|
|
50
64
|
// Return undefined so that the ops/snapshots are grabbed from the server instead of the cache
|
|
51
65
|
const value = await this.cache.get(this.fileEntryFromEntry(entry));
|
|
@@ -63,16 +77,17 @@ export class EpochTracker {
|
|
|
63
77
|
else if (this._fluidEpoch !== value.fluidEpoch) {
|
|
64
78
|
return undefined;
|
|
65
79
|
}
|
|
66
|
-
// Expire the cached snapshot if it's older than
|
|
80
|
+
// Expire the cached snapshot if it's older than snapshotCacheExpiryTimeoutMs and immediately
|
|
67
81
|
// expire all old caches that do not have cacheEntryTime
|
|
68
82
|
if (entry.type === snapshotKey) {
|
|
69
|
-
const cacheTime =
|
|
83
|
+
const cacheTime = value.value?.cacheEntryTime;
|
|
70
84
|
const currentTime = Date.now();
|
|
71
|
-
if (cacheTime === undefined ||
|
|
85
|
+
if (cacheTime === undefined ||
|
|
86
|
+
currentTime - cacheTime >= this.snapshotCacheExpiryTimeoutMs) {
|
|
72
87
|
this.logger.sendTelemetryEvent({
|
|
73
88
|
eventName: "odspVersionsCacheExpired",
|
|
74
89
|
duration: currentTime - cacheTime,
|
|
75
|
-
maxCacheAgeMs:
|
|
90
|
+
maxCacheAgeMs: this.snapshotCacheExpiryTimeoutMs,
|
|
76
91
|
});
|
|
77
92
|
await this.removeEntries();
|
|
78
93
|
return undefined;
|
|
@@ -87,20 +102,18 @@ export class EpochTracker {
|
|
|
87
102
|
}
|
|
88
103
|
}
|
|
89
104
|
async put(entry, value) {
|
|
90
|
-
var _a;
|
|
91
105
|
assert(this._fluidEpoch !== undefined, 0x1dd /* "no epoch" */);
|
|
92
|
-
// For snapshots, the value should have the cacheEntryTime.
|
|
93
|
-
// than
|
|
106
|
+
// For snapshots, the value should have the cacheEntryTime.
|
|
107
|
+
// This will be used to expire snapshots older than snapshotCacheExpiryTimeoutMs.
|
|
94
108
|
if (entry.type === snapshotKey) {
|
|
95
|
-
value.cacheEntryTime =
|
|
109
|
+
value.cacheEntryTime = value.cacheEntryTime ?? Date.now();
|
|
96
110
|
}
|
|
97
111
|
const data = {
|
|
98
112
|
value,
|
|
99
113
|
version: persistedCacheValueVersion,
|
|
100
114
|
fluidEpoch: this._fluidEpoch,
|
|
101
115
|
};
|
|
102
|
-
return this.cache.put(this.fileEntryFromEntry(entry), data)
|
|
103
|
-
.catch((error) => {
|
|
116
|
+
return this.cache.put(this.fileEntryFromEntry(entry), data).catch((error) => {
|
|
104
117
|
this.logger.sendErrorEvent({ eventName: "cachePutError", type: entry.type }, error);
|
|
105
118
|
throw error;
|
|
106
119
|
});
|
|
@@ -116,14 +129,13 @@ export class EpochTracker {
|
|
|
116
129
|
get fluidEpoch() {
|
|
117
130
|
return this._fluidEpoch;
|
|
118
131
|
}
|
|
119
|
-
async
|
|
120
|
-
|
|
121
|
-
assert(epoch !== undefined, 0x09d /* "Connection details should contain epoch" */);
|
|
132
|
+
async validateEpoch(epoch, fetchType) {
|
|
133
|
+
assert(epoch !== undefined, 0x584 /* response should contain epoch */);
|
|
122
134
|
try {
|
|
123
|
-
this.validateEpochFromResponse(epoch,
|
|
135
|
+
this.validateEpochFromResponse(epoch, fetchType);
|
|
124
136
|
}
|
|
125
137
|
catch (error) {
|
|
126
|
-
await this.checkForEpochError(error, epoch,
|
|
138
|
+
await this.checkForEpochError(error, epoch, fetchType);
|
|
127
139
|
throw error;
|
|
128
140
|
}
|
|
129
141
|
}
|
|
@@ -154,12 +166,15 @@ export class EpochTracker {
|
|
|
154
166
|
// Add epoch in fetch request.
|
|
155
167
|
this.addEpochInRequest(fetchOptions, addInBody, clientCorrelationId);
|
|
156
168
|
let epochFromResponse;
|
|
157
|
-
return this.rateLimiter
|
|
169
|
+
return this.rateLimiter
|
|
170
|
+
.schedule(async () => fetcher(url, fetchOptions))
|
|
171
|
+
.then((response) => {
|
|
158
172
|
epochFromResponse = response.headers.get("x-fluid-epoch");
|
|
159
173
|
this.validateEpochFromResponse(epochFromResponse, fetchType);
|
|
160
174
|
response.propsToLog.XRequestStatsHeader = clientCorrelationId;
|
|
161
175
|
return response;
|
|
162
|
-
})
|
|
176
|
+
})
|
|
177
|
+
.catch(async (error) => {
|
|
163
178
|
// Get the server epoch from error in case we don't have it as if undefined we won't be able
|
|
164
179
|
// to mark it as epoch error.
|
|
165
180
|
if (epochFromResponse === undefined) {
|
|
@@ -167,8 +182,26 @@ export class EpochTracker {
|
|
|
167
182
|
}
|
|
168
183
|
await this.checkForEpochError(error, epochFromResponse, fetchType);
|
|
169
184
|
throw error;
|
|
170
|
-
})
|
|
171
|
-
|
|
185
|
+
})
|
|
186
|
+
.catch((error) => {
|
|
187
|
+
// If the error is about location redirection, then we need to generate new resolved url with correct
|
|
188
|
+
// location info.
|
|
189
|
+
if (isFluidError(error) &&
|
|
190
|
+
error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError) {
|
|
191
|
+
const redirectLocation = error.redirectLocation;
|
|
192
|
+
if (redirectLocation !== undefined) {
|
|
193
|
+
const redirectUrl = patchOdspResolvedUrl(this.fileEntry.resolvedUrl, redirectLocation);
|
|
194
|
+
const locationRedirectionError = new LocationRedirectionError(error.message, redirectUrl, { driverVersion, redirectLocation });
|
|
195
|
+
locationRedirectionError.addTelemetryProperties(error.getTelemetryProperties());
|
|
196
|
+
throw locationRedirectionError;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
throw error;
|
|
200
|
+
})
|
|
201
|
+
.catch((error) => {
|
|
202
|
+
const fluidError = normalizeError(error, {
|
|
203
|
+
props: { XRequestStatsHeader: clientCorrelationId },
|
|
204
|
+
});
|
|
172
205
|
throw fluidError;
|
|
173
206
|
});
|
|
174
207
|
}
|
|
@@ -198,7 +231,9 @@ export class EpochTracker {
|
|
|
198
231
|
}
|
|
199
232
|
else {
|
|
200
233
|
const addHeader = (key, val) => {
|
|
201
|
-
fetchOptions.headers =
|
|
234
|
+
fetchOptions.headers = {
|
|
235
|
+
...fetchOptions.headers,
|
|
236
|
+
};
|
|
202
237
|
assert(fetchOptions.headers !== undefined, 0x282 /* "Headers should be present now" */);
|
|
203
238
|
fetchOptions.headers[key] = val;
|
|
204
239
|
};
|
|
@@ -218,7 +253,7 @@ export class EpochTracker {
|
|
|
218
253
|
assert(typeof body === "string", 0x21d /* "body is not string" */);
|
|
219
254
|
const splitBody = body.split("\r\n");
|
|
220
255
|
const firstLine = splitBody.shift();
|
|
221
|
-
assert(
|
|
256
|
+
assert(firstLine?.startsWith("--") === true, 0x21e /* "improper boundary format" */);
|
|
222
257
|
const formParams = [firstLine];
|
|
223
258
|
Object.entries(headers).forEach(([key, value]) => {
|
|
224
259
|
formParams.push(`${key}: ${value}`);
|
|
@@ -257,7 +292,6 @@ export class EpochTracker {
|
|
|
257
292
|
if (epochError !== undefined) {
|
|
258
293
|
epochError.addTelemetryProperties({
|
|
259
294
|
fromCache,
|
|
260
|
-
clientEpoch: this.fluidEpoch,
|
|
261
295
|
fetchType,
|
|
262
296
|
});
|
|
263
297
|
this.logger.sendErrorEvent({ eventName: "fileOverwrittenInStorage" }, epochError);
|
|
@@ -268,27 +302,39 @@ export class EpochTracker {
|
|
|
268
302
|
// If it was categorized as epoch error but the epoch returned in response matches with the client epoch
|
|
269
303
|
// then it was coherency 409, so rethrow it as throttling error so that it can retried. Default throttling
|
|
270
304
|
// time is 1s.
|
|
271
|
-
|
|
305
|
+
const newError = wrapError(error, (message) => {
|
|
306
|
+
return new ThrottlingError(`Coherency 409: ${message}`, 1 /* retryAfterSeconds */, {
|
|
307
|
+
[Odsp409Error]: true,
|
|
308
|
+
driverVersion,
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
throw newError;
|
|
272
312
|
}
|
|
273
313
|
}
|
|
274
314
|
checkForEpochErrorCore(epochFromResponse) {
|
|
275
315
|
// If epoch is undefined, then don't compare it because initially for createNew or TreesLatest
|
|
276
316
|
// initializes this value. Sometimes response does not contain epoch as it is still in
|
|
277
317
|
// implementation phase at server side. In that case also, don't compare it with our epoch value.
|
|
278
|
-
if (this.fluidEpoch && epochFromResponse &&
|
|
318
|
+
if (this.fluidEpoch && epochFromResponse && this.fluidEpoch !== epochFromResponse) {
|
|
279
319
|
// This is similar in nature to how fluidEpochMismatchError (409) is handled.
|
|
280
320
|
// Difference - client detected mismatch, instead of server detecting it.
|
|
281
|
-
return new NonRetryableError("Epoch mismatch", DriverErrorType.fileOverwrittenInStorage, { driverVersion });
|
|
321
|
+
return new NonRetryableError("Epoch mismatch", DriverErrorType.fileOverwrittenInStorage, { driverVersion, serverEpoch: epochFromResponse, clientEpoch: this.fluidEpoch });
|
|
282
322
|
}
|
|
283
323
|
}
|
|
284
324
|
fileEntryFromEntry(entry) {
|
|
285
|
-
return
|
|
325
|
+
return { ...entry, file: this.fileEntry };
|
|
286
326
|
}
|
|
287
327
|
}
|
|
288
328
|
export class EpochTrackerWithRedemption extends EpochTracker {
|
|
289
|
-
constructor() {
|
|
290
|
-
super(
|
|
329
|
+
constructor(cache, fileEntry, logger, clientIsSummarizer) {
|
|
330
|
+
super(cache, fileEntry, logger, clientIsSummarizer);
|
|
331
|
+
this.cache = cache;
|
|
332
|
+
this.fileEntry = fileEntry;
|
|
333
|
+
this.logger = logger;
|
|
334
|
+
this.clientIsSummarizer = clientIsSummarizer;
|
|
291
335
|
this.treesLatestDeferral = new Deferred();
|
|
336
|
+
// Handles the rejected promise within treesLatestDeferral.
|
|
337
|
+
this.treesLatestDeferral.promise.catch(() => { });
|
|
292
338
|
}
|
|
293
339
|
validateEpochFromResponse(epochFromResponse, fetchType, fromCache = false) {
|
|
294
340
|
super.validateEpochFromResponse(epochFromResponse, fetchType, fromCache);
|
|
@@ -332,7 +378,10 @@ export class EpochTrackerWithRedemption extends EpochTracker {
|
|
|
332
378
|
if (fetchType === "treesLatest") {
|
|
333
379
|
this.treesLatestDeferral.reject(error);
|
|
334
380
|
}
|
|
335
|
-
if (fetchType !== "joinSession" ||
|
|
381
|
+
if (fetchType !== "joinSession" ||
|
|
382
|
+
error.statusCode < 401 ||
|
|
383
|
+
error.statusCode > 404 ||
|
|
384
|
+
completed) {
|
|
336
385
|
throw error;
|
|
337
386
|
}
|
|
338
387
|
}
|
|
@@ -348,12 +397,14 @@ export class EpochTrackerWithRedemption extends EpochTracker {
|
|
|
348
397
|
const timeoutRes = 51; // anything will work here
|
|
349
398
|
let timer;
|
|
350
399
|
const timeoutP = new Promise((resolve) => {
|
|
351
|
-
timer = setTimeout(() => {
|
|
400
|
+
timer = setTimeout(() => {
|
|
401
|
+
resolve(timeoutRes);
|
|
402
|
+
}, 15000);
|
|
352
403
|
});
|
|
353
404
|
const res = await Promise.race([
|
|
354
405
|
timeoutP,
|
|
355
406
|
// cancel timeout to unblock UTs (otherwise Node process does not exit for 15 sec)
|
|
356
|
-
this.treesLatestDeferral.promise.finally(() => clearTimeout(timer))
|
|
407
|
+
this.treesLatestDeferral.promise.finally(() => clearTimeout(timer)),
|
|
357
408
|
]);
|
|
358
409
|
if (res === timeoutRes) {
|
|
359
410
|
event.cancel();
|
|
@@ -365,8 +416,11 @@ export class EpochTrackerWithRedemption extends EpochTracker {
|
|
|
365
416
|
export function createOdspCacheAndTracker(persistedCacheArg, nonpersistentCache, fileEntry, logger, clientIsSummarizer) {
|
|
366
417
|
const epochTracker = new EpochTrackerWithRedemption(persistedCacheArg, fileEntry, logger, clientIsSummarizer);
|
|
367
418
|
return {
|
|
368
|
-
cache:
|
|
419
|
+
cache: {
|
|
420
|
+
...nonpersistentCache,
|
|
421
|
+
persistedCache: epochTracker,
|
|
422
|
+
},
|
|
369
423
|
epochTracker,
|
|
370
424
|
};
|
|
371
425
|
}
|
|
372
|
-
//# sourceMappingURL=epochTracker.
|
|
426
|
+
//# sourceMappingURL=epochTracker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"epochTracker.mjs","sourceRoot":"","sources":["../src/epochTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM;OAC1B,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,4BAA4B;OACtD,EAEN,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,yBAAyB,EACzB,SAAS,GACT,MAAM,iCAAiC;OACjC,EACN,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,wBAAwB,GACxB,MAAM,8BAA8B;OAC9B,EACN,WAAW,GAQX,MAAM,yCAAyC;OACzC,EAAE,eAAe,EAAE,MAAM,oCAAoC;OAC7D,EACN,yBAAyB,EACzB,UAAU,EACV,WAAW,EACX,kBAAkB,GAElB;OAEM,EAA4B,0BAA0B,EAAE;OACxD,EAAE,qBAAqB,EAAE;OACzB,EAAE,UAAU,IAAI,aAAa,EAAE;OAC/B,EAAE,oBAAoB,EAAE;AAuB/B,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,qCAAqC;AACrC,MAAM,CAAC,MAAM,2BAA2B,GAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,eAAe;AAE3F;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,YAAY;IAQxB,YACoB,KAAsB,EAC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ACD;AAUD,MAAM,UAAU,yBAAyB,CACxC,iBAAkC,EAClC,kBAAuC,EACvC,SAAqB,EACrB,MAA2B,EAC3B,kBAA4B;IAE5B,MAAM,YAAY,GAAG,IAAI,0BAA0B,CAClD,iBAAiB,EACjB,SAAS,EACT,MAAM,EACN,kBAAkB,CAClB,CAAC;IACF,OAAO;QACN,KAAK,EAAE;YACN,GAAG,kBAAkB;YACrB,cAAc,EAAE,YAAY;SAC5B;QACD,YAAY;KACZ,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { assert, Deferred } from \"@fluidframework/core-utils\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\tnormalizeError,\n\tloggerToMonitoringContext,\n\twrapError,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tThrottlingError,\n\tRateLimiter,\n\tNonRetryableError,\n\tLocationRedirectionError,\n} from \"@fluidframework/driver-utils\";\nimport {\n\tsnapshotKey,\n\tICacheEntry,\n\tIEntry,\n\tIFileEntry,\n\tIPersistedCache,\n\tIOdspError,\n\tIOdspErrorAugmentations,\n\tIOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n\tfetchAndParseAsJSONHelper,\n\tfetchArray,\n\tfetchHelper,\n\tgetOdspResolvedUrl,\n\tIOdspResponse,\n} from \"./odspUtils\";\nimport { IOdspCache, INonPersistentCache, IPersistedFileCache } from \"./odspCache\";\nimport { IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { patchOdspResolvedUrl } from \"./odspLocationRedirection\";\n\n/**\n * @alpha\n */\nexport type FetchType =\n\t| \"blob\"\n\t| \"createBlob\"\n\t| \"createFile\"\n\t| \"joinSession\"\n\t| \"ops\"\n\t| \"test\"\n\t| \"snapshotTree\"\n\t| \"treesLatest\"\n\t| \"uploadSummary\"\n\t| \"push\"\n\t| \"versions\";\n\n/**\n * @alpha\n */\nexport type FetchTypeInternal = FetchType | \"cache\";\n\nexport const Odsp409Error = \"Odsp409Error\";\n\n// Must be less than policy of 5 days\nexport const defaultCacheExpiryTimeoutMs: number = 2 * 24 * 60 * 60 * 1000; // 2 days in ms\n\n/**\n * In ODSP, the concept of \"epoch\" refers to binary updates to files. For example, this might include using\n * version restore, or if the user downloads a Fluid file and then uploads it again. These result in the epoch\n * value being incremented.\n *\n * The implications of these binary updates is that the Fluid state is disrupted: the sequence number might\n * go backwards, the data might be inconsistent with the latest state of collaboration, etc. As a result, it's\n * not safe to continue collaboration across an epoch change. We need to detect these epoch changes and\n * error out from the collaboration.\n *\n * This class is a wrapper around fetch calls. It adds epoch to the request made so that the\n * server can match it with its epoch value in order to match the version.\n * It also validates the epoch value received in response of fetch calls. If the epoch does not match,\n * then it also clears all the cached entries for the given container.\n * @alpha\n */\nexport class EpochTracker implements IPersistedFileCache {\n\tprivate _fluidEpoch: string | undefined;\n\n\tprivate readonly snapshotCacheExpiryTimeoutMs: number;\n\tpublic readonly rateLimiter: RateLimiter;\n\tprivate readonly driverId = uuid();\n\t// This tracks the request number made by the driver instance.\n\tprivate networkCallNumber = 1;\n\tconstructor(\n\t\tprotected readonly cache: IPersistedCache,\n\t\tprotected readonly fileEntry: IFileEntry,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tprotected readonly clientIsSummarizer?: boolean,\n\t) {\n\t\t// Limits the max number of concurrent requests to 24.\n\t\tthis.rateLimiter = new RateLimiter(24);\n\n\t\t// Matches the TestOverride logic for the policy defined in odspDocumentStorageServiceBase.ts\n\t\tthis.snapshotCacheExpiryTimeoutMs = loggerToMonitoringContext(logger).config.getBoolean(\n\t\t\t\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\",\n\t\t)\n\t\t\t? 0\n\t\t\t: defaultCacheExpiryTimeoutMs;\n\t}\n\n\t// public for UT purposes only!\n\tpublic setEpoch(epoch: string, fromCache: boolean, fetchType: FetchTypeInternal) {\n\t\tassert(this._fluidEpoch === undefined, 0x1db /* \"epoch exists\" */);\n\t\tthis._fluidEpoch = epoch;\n\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"EpochLearnedFirstTime\",\n\t\t\tepoch,\n\t\t\tfetchType,\n\t\t\tfromCache,\n\t\t});\n\t}\n\n\tpublic async get(entry: IEntry): Promise<any> {\n\t\ttry {\n\t\t\t// Return undefined so that the ops/snapshots are grabbed from the server instead of the cache\n\t\t\tconst value: IVersionedValueWithEpoch = await this.cache.get(\n\t\t\t\tthis.fileEntryFromEntry(entry),\n\t\t\t);\n\t\t\t// Version mismatch between what the runtime expects and what it recieved.\n\t\t\t// The cached value should not be used\n\t\t\tif (value === undefined || value.version !== persistedCacheValueVersion) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tassert(value.fluidEpoch !== undefined, 0x1dc /* \"all entries have to have epoch\" */);\n\t\t\tif (this._fluidEpoch === undefined) {\n\t\t\t\tthis.setEpoch(value.fluidEpoch, true, \"cache\");\n\t\t\t\t// Epoch mismatch, the cached value is considerably different from what the current state of\n\t\t\t\t// the runtime and should not be used\n\t\t\t} else if (this._fluidEpoch !== value.fluidEpoch) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Expire the cached snapshot if it's older than snapshotCacheExpiryTimeoutMs and immediately\n\t\t\t// expire all old caches that do not have cacheEntryTime\n\t\t\tif (entry.type === snapshotKey) {\n\t\t\t\tconst cacheTime = value.value?.cacheEntryTime;\n\t\t\t\tconst currentTime = Date.now();\n\t\t\t\tif (\n\t\t\t\t\tcacheTime === undefined ||\n\t\t\t\t\tcurrentTime - cacheTime >= this.snapshotCacheExpiryTimeoutMs\n\t\t\t\t) {\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"odspVersionsCacheExpired\",\n\t\t\t\t\t\tduration: currentTime - cacheTime,\n\t\t\t\t\t\tmaxCacheAgeMs: this.snapshotCacheExpiryTimeoutMs,\n\t\t\t\t\t});\n\t\t\t\t\tawait this.removeEntries();\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value.value;\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"cacheFetchError\", type: entry.type }, error);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tpublic async put(entry: IEntry, value: any) {\n\t\tassert(this._fluidEpoch !== undefined, 0x1dd /* \"no epoch\" */);\n\t\t// For snapshots, the value should have the cacheEntryTime.\n\t\t// This will be used to expire snapshots older than snapshotCacheExpiryTimeoutMs.\n\t\tif (entry.type === snapshotKey) {\n\t\t\tvalue.cacheEntryTime = value.cacheEntryTime ?? Date.now();\n\t\t}\n\t\tconst data: IVersionedValueWithEpoch = {\n\t\t\tvalue,\n\t\t\tversion: persistedCacheValueVersion,\n\t\t\tfluidEpoch: this._fluidEpoch,\n\t\t};\n\t\treturn this.cache.put(this.fileEntryFromEntry(entry), data).catch((error) => {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"cachePutError\", type: entry.type }, error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tpublic async removeEntries(): Promise<void> {\n\t\ttry {\n\t\t\treturn await this.cache.removeEntries(this.fileEntry);\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"removeCacheEntries\" }, error);\n\t\t}\n\t}\n\n\tpublic get fluidEpoch() {\n\t\treturn this._fluidEpoch;\n\t}\n\n\tpublic async validateEpoch(epoch: string | undefined, fetchType: FetchType) {\n\t\tassert(epoch !== undefined, 0x584 /* response should contain epoch */);\n\t\ttry {\n\t\t\tthis.validateEpochFromResponse(epoch, fetchType);\n\t\t} catch (error) {\n\t\t\tawait this.checkForEpochError(error, epoch, fetchType);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Api to fetch the response for given request and parse it as json.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetchAndParseAsJSON<T>(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\treturn this.fetchCore<T>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchAndParseAsJSONHelper,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\t/**\n\t * Api to fetch the response for given request and parse it as json.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetch(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t) {\n\t\treturn this.fetchCore<Response>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchHelper,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate async fetchCore<T>(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: any },\n\t\tfetcher: (url: string, fetchOptions: { [index: string]: any }) => Promise<IOdspResponse<T>>,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t) {\n\t\tconst clientCorrelationId = this.formatClientCorrelationId(fetchReason);\n\t\t// Add epoch in fetch request.\n\t\tthis.addEpochInRequest(fetchOptions, addInBody, clientCorrelationId);\n\t\tlet epochFromResponse: string | undefined;\n\t\treturn this.rateLimiter\n\t\t\t.schedule(async () => fetcher(url, fetchOptions))\n\t\t\t.then((response) => {\n\t\t\t\tepochFromResponse = response.headers.get(\"x-fluid-epoch\");\n\t\t\t\tthis.validateEpochFromResponse(epochFromResponse, fetchType);\n\t\t\t\tresponse.propsToLog.XRequestStatsHeader = clientCorrelationId;\n\t\t\t\treturn response;\n\t\t\t})\n\t\t\t.catch(async (error) => {\n\t\t\t\t// Get the server epoch from error in case we don't have it as if undefined we won't be able\n\t\t\t\t// to mark it as epoch error.\n\t\t\t\tif (epochFromResponse === undefined) {\n\t\t\t\t\tepochFromResponse = (error as IOdspError).serverEpoch;\n\t\t\t\t}\n\t\t\t\tawait this.checkForEpochError(error, epochFromResponse, fetchType);\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// If the error is about location redirection, then we need to generate new resolved url with correct\n\t\t\t\t// location info.\n\t\t\t\tif (\n\t\t\t\t\tisFluidError(error) &&\n\t\t\t\t\terror.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError\n\t\t\t\t) {\n\t\t\t\t\tconst redirectLocation = (error as IOdspErrorAugmentations).redirectLocation;\n\t\t\t\t\tif (redirectLocation !== undefined) {\n\t\t\t\t\t\tconst redirectUrl: IOdspResolvedUrl = patchOdspResolvedUrl(\n\t\t\t\t\t\t\tthis.fileEntry.resolvedUrl,\n\t\t\t\t\t\t\tredirectLocation,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst locationRedirectionError = new LocationRedirectionError(\n\t\t\t\t\t\t\terror.message,\n\t\t\t\t\t\t\tredirectUrl,\n\t\t\t\t\t\t\t{ driverVersion, redirectLocation },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlocationRedirectionError.addTelemetryProperties(\n\t\t\t\t\t\t\terror.getTelemetryProperties(),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthrow locationRedirectionError;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tconst fluidError = normalizeError(error, {\n\t\t\t\t\tprops: { XRequestStatsHeader: clientCorrelationId },\n\t\t\t\t});\n\t\t\t\tthrow fluidError;\n\t\t\t});\n\t}\n\n\t/**\n\t * Api to fetch the response as it is for given request.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetchArray(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: any },\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t) {\n\t\treturn this.fetchCore<ArrayBuffer>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchArray,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate addEpochInRequest(\n\t\tfetchOptions: RequestInit,\n\t\taddInBody: boolean,\n\t\tclientCorrelationId: string,\n\t) {\n\t\tconst isClpCompliantApp = getOdspResolvedUrl(this.fileEntry.resolvedUrl).isClpCompliantApp;\n\t\tif (addInBody) {\n\t\t\tconst headers: { [key: string]: string } = {};\n\t\t\theaders[\"X-RequestStats\"] = clientCorrelationId;\n\t\t\tif (this.fluidEpoch !== undefined) {\n\t\t\t\theaders[\"x-fluid-epoch\"] = this.fluidEpoch;\n\t\t\t}\n\t\t\tif (isClpCompliantApp) {\n\t\t\t\theaders[ClpCompliantAppHeader.isClpCompliantApp] = isClpCompliantApp.toString();\n\t\t\t}\n\t\t\tthis.addParamInBody(fetchOptions, headers);\n\t\t} else {\n\t\t\tconst addHeader = (key: string, val: string) => {\n\t\t\t\tfetchOptions.headers = {\n\t\t\t\t\t...fetchOptions.headers,\n\t\t\t\t};\n\t\t\t\tassert(\n\t\t\t\t\tfetchOptions.headers !== undefined,\n\t\t\t\t\t0x282 /* \"Headers should be present now\" */,\n\t\t\t\t);\n\t\t\t\tfetchOptions.headers[key] = val;\n\t\t\t};\n\t\t\taddHeader(\"X-RequestStats\", clientCorrelationId);\n\t\t\tif (this.fluidEpoch !== undefined) {\n\t\t\t\taddHeader(\"x-fluid-epoch\", this.fluidEpoch);\n\t\t\t}\n\t\t\tif (isClpCompliantApp) {\n\t\t\t\taddHeader(ClpCompliantAppHeader.isClpCompliantApp, isClpCompliantApp.toString());\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate addParamInBody(fetchOptions: RequestInit, headers: { [key: string]: string }) {\n\t\t// We use multi part form request for post body where we want to use this.\n\t\t// So extract the form boundary to mark the end of form.\n\t\tconst body = fetchOptions.body;\n\t\tassert(typeof body === \"string\", 0x21d /* \"body is not string\" */);\n\t\tconst splitBody = body.split(\"\\r\\n\");\n\t\tconst firstLine = splitBody.shift();\n\t\tassert(firstLine?.startsWith(\"--\") === true, 0x21e /* \"improper boundary format\" */);\n\t\tconst formParams = [firstLine];\n\t\tObject.entries(headers).forEach(([key, value]) => {\n\t\t\tformParams.push(`${key}: ${value}`);\n\t\t});\n\t\tsplitBody.forEach((value: string) => {\n\t\t\tformParams.push(value);\n\t\t});\n\t\tfetchOptions.body = formParams.join(\"\\r\\n\");\n\t}\n\n\tprivate formatClientCorrelationId(fetchReason?: string) {\n\t\tconst items: string[] = [\n\t\t\t`driverId=${this.driverId}`,\n\t\t\t`RequestNumber=${this.networkCallNumber++}`,\n\t\t\t`driverVersion=${driverVersion}`,\n\t\t\t`isSummarizer=${this.clientIsSummarizer}`,\n\t\t];\n\t\tif (fetchReason !== undefined) {\n\t\t\titems.push(`fetchReason=${fetchReason}`);\n\t\t}\n\t\treturn items.join(\", \");\n\t}\n\n\tprotected validateEpochFromResponse(\n\t\tepochFromResponse: string | undefined,\n\t\tfetchType: FetchTypeInternal,\n\t\tfromCache: boolean = false,\n\t) {\n\t\tconst error = this.checkForEpochErrorCore(epochFromResponse);\n\t\tif (error !== undefined) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (epochFromResponse !== undefined) {\n\t\t\tif (this._fluidEpoch === undefined) {\n\t\t\t\tthis.setEpoch(epochFromResponse, fromCache, fetchType);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async checkForEpochError(\n\t\terror: unknown,\n\t\tepochFromResponse: string | null | undefined,\n\t\tfetchType: FetchTypeInternal,\n\t\tfromCache: boolean = false,\n\t) {\n\t\tif (isFluidError(error) && error.errorType === DriverErrorType.fileOverwrittenInStorage) {\n\t\t\tconst epochError = this.checkForEpochErrorCore(epochFromResponse);\n\t\t\tif (epochError !== undefined) {\n\t\t\t\tepochError.addTelemetryProperties({\n\t\t\t\t\tfromCache,\n\t\t\t\t\tfetchType,\n\t\t\t\t});\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"fileOverwrittenInStorage\" }, epochError);\n\t\t\t\t// If the epoch mismatches, then clear all entries for such file entry from cache.\n\t\t\t\tawait this.removeEntries();\n\t\t\t\tthrow epochError;\n\t\t\t}\n\t\t\t// If it was categorized as epoch error but the epoch returned in response matches with the client epoch\n\t\t\t// then it was coherency 409, so rethrow it as throttling error so that it can retried. Default throttling\n\t\t\t// time is 1s.\n\t\t\tconst newError = wrapError(error, (message: string) => {\n\t\t\t\treturn new ThrottlingError(`Coherency 409: ${message}`, 1 /* retryAfterSeconds */, {\n\t\t\t\t\t[Odsp409Error]: true,\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t});\n\t\t\tthrow newError;\n\t\t}\n\t}\n\n\tprivate checkForEpochErrorCore(epochFromResponse: string | null | undefined) {\n\t\t// If epoch is undefined, then don't compare it because initially for createNew or TreesLatest\n\t\t// initializes this value. Sometimes response does not contain epoch as it is still in\n\t\t// implementation phase at server side. In that case also, don't compare it with our epoch value.\n\t\tif (this.fluidEpoch && epochFromResponse && this.fluidEpoch !== epochFromResponse) {\n\t\t\t// This is similar in nature to how fluidEpochMismatchError (409) is handled.\n\t\t\t// Difference - client detected mismatch, instead of server detecting it.\n\t\t\treturn new NonRetryableError(\n\t\t\t\t\"Epoch mismatch\",\n\t\t\t\tDriverErrorType.fileOverwrittenInStorage,\n\t\t\t\t{ driverVersion, serverEpoch: epochFromResponse, clientEpoch: this.fluidEpoch },\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate fileEntryFromEntry(entry: IEntry): ICacheEntry {\n\t\treturn { ...entry, file: this.fileEntry };\n\t}\n}\n\nexport class EpochTrackerWithRedemption extends EpochTracker {\n\tprivate readonly treesLatestDeferral = new Deferred<void>();\n\n\tconstructor(\n\t\tprotected readonly cache: IPersistedCache,\n\t\tprotected readonly fileEntry: IFileEntry,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tprotected readonly clientIsSummarizer?: boolean,\n\t) {\n\t\tsuper(cache, fileEntry, logger, clientIsSummarizer);\n\t\t// Handles the rejected promise within treesLatestDeferral.\n\t\tthis.treesLatestDeferral.promise.catch(() => {});\n\t}\n\n\tprotected validateEpochFromResponse(\n\t\tepochFromResponse: string | undefined,\n\t\tfetchType: FetchType,\n\t\tfromCache: boolean = false,\n\t) {\n\t\tsuper.validateEpochFromResponse(epochFromResponse, fetchType, fromCache);\n\n\t\t// Any successful call means we have access to a file, i.e. any redemption that was required already happened.\n\t\t// That covers cases of \"treesLatest\" as well as \"getVersions\" or \"createFile\" - all the ways we can start\n\t\t// exploring a file.\n\t\tthis.treesLatestDeferral.resolve();\n\t}\n\n\tpublic async get(entry: IEntry): Promise<any> {\n\t\tlet result = super.get(entry);\n\n\t\t// equivalence of what happens in fetchAndParseAsJSON()\n\t\tif (entry.type === snapshotKey) {\n\t\t\tresult = result\n\t\t\t\t.then((value) => {\n\t\t\t\t\t// If there is nothing in cache, we need to wait for network call to complete (and do redemption)\n\t\t\t\t\t// Otherwise file was redeemed in prior session, so if joinSession failed, we should not retry\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\tthis.treesLatestDeferral.resolve();\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\t\t\treturn value;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.treesLatestDeferral.reject(error);\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic async fetchAndParseAsJSON<T>(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: any },\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\t// Optimize the flow if we know that treesLatestDeferral was already completed by the timer we started\n\t\t// joinSession call. If we did - there is no reason to repeat the call as it will fail with same error.\n\t\tconst completed = this.treesLatestDeferral.isCompleted;\n\n\t\ttry {\n\t\t\treturn await super.fetchAndParseAsJSON<T>(\n\t\t\t\turl,\n\t\t\t\tfetchOptions,\n\t\t\t\tfetchType,\n\t\t\t\taddInBody,\n\t\t\t\tfetchReason,\n\t\t\t);\n\t\t} catch (error: any) {\n\t\t\t// Only handling here treesLatest. If createFile failed, we should never try to do joinSession.\n\t\t\t// Similar, if getVersions failed, we should not do any further storage calls.\n\t\t\t// So treesLatest is the only call that can have parallel joinSession request.\n\t\t\tif (fetchType === \"treesLatest\") {\n\t\t\t\tthis.treesLatestDeferral.reject(error);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfetchType !== \"joinSession\" ||\n\t\t\t\terror.statusCode < 401 ||\n\t\t\t\terror.statusCode > 404 ||\n\t\t\t\tcompleted\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\t// It is joinSession failing with 401..404 error\n\t\t// Repeat after waiting for treeLatest succeeding (or fail if it failed).\n\t\t// No special handling after first call - if file has been deleted, then it's game over.\n\n\t\t// Ensure we have some safety here - we do not want to deadlock if we got logic somewhere wrong.\n\t\t// If we waited too long, we will log error event and proceed with call.\n\t\t// It may result in failure for user, but refreshing document would address it.\n\t\t// Thus we use rather long timeout (not to get these failures as much as possible), but not large enough\n\t\t// to unblock the process.\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{ eventName: \"JoinSessionSyncWait\" },\n\t\t\tasync (event) => {\n\t\t\t\tconst timeoutRes = 51; // anything will work here\n\t\t\t\tlet timer: ReturnType<typeof setTimeout>;\n\t\t\t\tconst timeoutP = new Promise<number>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\t\tresolve(timeoutRes);\n\t\t\t\t\t}, 15000);\n\t\t\t\t});\n\t\t\t\tconst res = await Promise.race([\n\t\t\t\t\ttimeoutP,\n\t\t\t\t\t// cancel timeout to unblock UTs (otherwise Node process does not exit for 15 sec)\n\t\t\t\t\tthis.treesLatestDeferral.promise.finally(() => clearTimeout(timer)),\n\t\t\t\t]);\n\t\t\t\tif (res === timeoutRes) {\n\t\t\t\t\tevent.cancel();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t);\n\t\treturn super.fetchAndParseAsJSON<T>(url, fetchOptions, fetchType, addInBody);\n\t}\n}\n\n/**\n * @alpha\n */\nexport interface ICacheAndTracker {\n\tcache: IOdspCache;\n\tepochTracker: EpochTracker;\n}\n\nexport function createOdspCacheAndTracker(\n\tpersistedCacheArg: IPersistedCache,\n\tnonpersistentCache: INonPersistentCache,\n\tfileEntry: IFileEntry,\n\tlogger: ITelemetryLoggerExt,\n\tclientIsSummarizer?: boolean,\n): ICacheAndTracker {\n\tconst epochTracker = new EpochTrackerWithRedemption(\n\t\tpersistedCacheArg,\n\t\tfileEntry,\n\t\tlogger,\n\t\tclientIsSummarizer,\n\t);\n\treturn {\n\t\tcache: {\n\t\t\t...nonpersistentCache,\n\t\t\tpersistedCache: epochTracker,\n\t\t},\n\t\tepochTracker,\n\t};\n}\n"]}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export declare const fetch: (request: RequestInfo, config?: RequestInit
|
|
5
|
+
export declare const fetch: (request: RequestInfo, config?: RequestInit) => Promise<Response>;
|
|
6
6
|
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,eAAO,MAAM,KAAK,YAAmB,WAAW,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,eAAO,MAAM,KAAK,YAAmB,WAAW,WAAW,WAAW,KAAG,QAAQ,QAAQ,CACC,CAAC"}
|
|
@@ -7,4 +7,4 @@ import { default as nodeFetch, } from "node-fetch";
|
|
|
7
7
|
// Browser's fetch API and the 'node-fetch' package by wrapping the call to the 'node-fetch' API
|
|
8
8
|
// in the browser's types from 'lib.dom.d.ts'.
|
|
9
9
|
export const fetch = async (request, config) => nodeFetch(request, config);
|
|
10
|
-
//# sourceMappingURL=fetch.
|
|
10
|
+
//# sourceMappingURL=fetch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.mjs","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EACN,OAAO,IAAI,SAAS,GAGpB,MAAM,YAAY;AAEnB,yFAAyF;AACzF,gGAAgG;AAChG,8CAA8C;AAC9C,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EAAE,OAAoB,EAAE,MAAoB,EAAqB,EAAE,CAC5F,SAAS,CAAC,OAA2B,EAAE,MAA0B,CAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tdefault as nodeFetch,\n\tRequestInfo as FetchRequestInfo,\n\tRequestInit as FetchRequestInit,\n} from \"node-fetch\";\n\n// The only purpose of this helper is to work around the slight misalignments between the\n// Browser's fetch API and the 'node-fetch' package by wrapping the call to the 'node-fetch' API\n// in the browser's types from 'lib.dom.d.ts'.\nexport const fetch = async (request: RequestInfo, config?: RequestInit): Promise<Response> =>\n\tnodeFetch(request as FetchRequestInfo, config as FetchRequestInit) as unknown as Response;\n"]}
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
5
|
+
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
7
6
|
import { IOdspResolvedUrl, ISnapshotOptions, InstrumentedStorageTokenFetcher } from "@fluidframework/odsp-driver-definitions";
|
|
8
|
-
import { IOdspSnapshot, IVersionedValueWithEpoch } from "./contracts";
|
|
9
|
-
import { IOdspResponse } from "./odspUtils";
|
|
10
|
-
import { ISnapshotContents } from "./odspPublicUtils";
|
|
11
|
-
import { EpochTracker } from "./epochTracker";
|
|
7
|
+
import { IOdspSnapshot, IVersionedValueWithEpoch } from "./contracts.mjs";
|
|
8
|
+
import { IOdspResponse } from "./odspUtils.mjs";
|
|
9
|
+
import { ISnapshotContents } from "./odspPublicUtils.mjs";
|
|
10
|
+
import { EpochTracker } from "./epochTracker.mjs";
|
|
12
11
|
/**
|
|
13
12
|
* Enum to support different types of snapshot formats.
|
|
13
|
+
* @alpha
|
|
14
14
|
*/
|
|
15
15
|
export declare enum SnapshotFormatSupportType {
|
|
16
16
|
Json = 0,
|
|
@@ -27,10 +27,10 @@ export declare enum SnapshotFormatSupportType {
|
|
|
27
27
|
* @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header
|
|
28
28
|
* @returns A promise of the snapshot and the status code of the response
|
|
29
29
|
*/
|
|
30
|
-
export declare function fetchSnapshot(snapshotUrl: string, token: string | null, versionId: string, fetchFullSnapshot: boolean, forceAccessTokenViaAuthorizationHeader: boolean, logger:
|
|
30
|
+
export declare function fetchSnapshot(snapshotUrl: string, token: string | null, versionId: string, fetchFullSnapshot: boolean, forceAccessTokenViaAuthorizationHeader: boolean, logger: ITelemetryLoggerExt, snapshotDownloader: (url: string, fetchOptions: {
|
|
31
31
|
[index: string]: any;
|
|
32
32
|
}) => Promise<IOdspResponse<unknown>>): Promise<ISnapshotContents>;
|
|
33
|
-
export declare function fetchSnapshotWithRedeem(odspResolvedUrl: IOdspResolvedUrl, storageTokenFetcher: InstrumentedStorageTokenFetcher, snapshotOptions: ISnapshotOptions | undefined, forceAccessTokenViaAuthorizationHeader: boolean, logger:
|
|
33
|
+
export declare function fetchSnapshotWithRedeem(odspResolvedUrl: IOdspResolvedUrl, storageTokenFetcher: InstrumentedStorageTokenFetcher, snapshotOptions: ISnapshotOptions | undefined, forceAccessTokenViaAuthorizationHeader: boolean, logger: ITelemetryLoggerExt, snapshotDownloader: (finalOdspResolvedUrl: IOdspResolvedUrl, storageToken: string, snapshotOptions: ISnapshotOptions | undefined, controller?: AbortController) => Promise<ISnapshotRequestAndResponseOptions>, putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>, removeEntries: () => Promise<void>, enableRedeemFallback?: boolean): Promise<ISnapshotContents>;
|
|
34
34
|
export interface ISnapshotRequestAndResponseOptions {
|
|
35
35
|
odspResponse: IOdspResponse<Response>;
|
|
36
36
|
requestUrl: string;
|
|
@@ -38,6 +38,11 @@ export interface ISnapshotRequestAndResponseOptions {
|
|
|
38
38
|
[index: string]: any;
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
+
export declare function evalBlobsAndTrees(snapshot: ISnapshotContents): {
|
|
42
|
+
trees: number;
|
|
43
|
+
numBlobs: number;
|
|
44
|
+
encodedBlobsSize: number;
|
|
45
|
+
};
|
|
41
46
|
export declare function validateBlobsAndTrees(snapshot: IOdspSnapshot): void;
|
|
42
47
|
/**
|
|
43
48
|
* This function fetches the snapshot and parse it according to what is mentioned in response headers.
|
|
@@ -50,5 +55,5 @@ export declare function validateBlobsAndTrees(snapshot: IOdspSnapshot): void;
|
|
|
50
55
|
* @param epochTracker - epoch tracker used to add/validate epoch in the network call.
|
|
51
56
|
* @returns fetched snapshot.
|
|
52
57
|
*/
|
|
53
|
-
export declare function downloadSnapshot(odspResolvedUrl: IOdspResolvedUrl, storageToken: string, logger:
|
|
58
|
+
export declare function downloadSnapshot(odspResolvedUrl: IOdspResolvedUrl, storageToken: string, logger: ITelemetryLoggerExt, snapshotOptions: ISnapshotOptions | undefined, snapshotFormatFetchType?: SnapshotFormatSupportType, controller?: AbortController, epochTracker?: EpochTracker, scenarioName?: string): Promise<ISnapshotRequestAndResponseOptions>;
|
|
54
59
|
//# sourceMappingURL=fetchSnapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchSnapshot.d.ts","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAGI,EACN,mBAAmB,EAInB,MAAM,iCAAiC;OAKjC,EACN,gBAAgB,EAChB,gBAAgB,EAEhB,+BAA+B,EAC/B,MAAM,yCAAyC;OAQzC,EACN,aAAa,EAEb,wBAAwB,EAExB;OAGM,EAKN,aAAa,EAGb;OACM,EAAE,iBAAiB,EAAE;OAOrB,EAAE,YAAY,EAAE;AAGvB;;;GAGG;AACH,oBAAY,yBAAyB;IACpC,IAAI,IAAI;IACR,MAAM,IAAI;IACV,aAAa,IAAI;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAClC,WAAW,EAAE,MAAM,EAEnB,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,OAAO,EAC1B,sCAAsC,EAAE,OAAO,EAC/C,M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