@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
package/dist/createFile.d.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
6
6
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
7
7
|
import { InstrumentedStorageTokenFetcher, IOdspResolvedUrl, IFileEntry } from "@fluidframework/odsp-driver-definitions";
|
|
8
|
-
import { ICreateFileResponse } from "./contracts";
|
|
9
|
-
import { INewFileInfo } from "./odspUtils";
|
|
10
|
-
import { EpochTracker } from "./epochTracker";
|
|
8
|
+
import { ICreateFileResponse } from "./contracts.js";
|
|
9
|
+
import { INewFileInfo } from "./odspUtils.js";
|
|
10
|
+
import { EpochTracker } from "./epochTracker.js";
|
|
11
11
|
/**
|
|
12
12
|
* Creates a new Fluid file.
|
|
13
13
|
* Returns resolved url
|
package/dist/createFile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFile.d.ts","sourceRoot":"","sources":["../src/createFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAAC;AACxF,OAAO,EACN,+BAA+B,EAC/B,gBAAgB,EAGhB,UAAU,EACV,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createFile.d.ts","sourceRoot":"","sources":["../src/createFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAAC;AACxF,OAAO,EACN,+BAA+B,EAC/B,gBAAgB,EAGhB,UAAU,EACV,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAIN,YAAY,EAEZ,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAgBjD;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,eAAe,EAAE,+BAA+B,EAChD,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,mBAAmB,EAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,UAAU,EACrB,gBAAgB,EAAE,OAAO,EACzB,sCAAsC,EAAE,OAAO,EAC/C,iBAAiB,CAAC,EAAE,OAAO,EAC3B,yCAAyC,CAAC,EAAE,OAAO,GACjD,OAAO,CAAC,gBAAgB,CAAC,CA2D3B;AA2CD,wBAAsB,uBAAuB,CAC5C,eAAe,EAAE,+BAA+B,EAChD,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,mBAAmB,EAC3B,YAAY,EAAE,YAAY,EAC1B,sCAAsC,EAAE,OAAO,GAC7C,OAAO,CAAC,MAAM,CAAC,CAuDjB;AAED,wBAAsB,6BAA6B,CAClD,eAAe,EAAE,+BAA+B,EAChD,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,mBAAmB,EAC3B,gBAAgB,EAAE,YAAY,EAC9B,YAAY,EAAE,YAAY,EAC1B,sCAAsC,EAAE,OAAO,GAC7C,OAAO,CAAC,mBAAmB,CAAC,CAmC9B"}
|
package/dist/createFile.js
CHANGED
|
@@ -9,18 +9,18 @@ const core_utils_1 = require("@fluidframework/core-utils");
|
|
|
9
9
|
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
10
10
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
11
11
|
const odsp_driver_definitions_1 = require("@fluidframework/odsp-driver-definitions");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
12
|
+
const getUrlAndHeadersWithAuth_js_1 = require("./getUrlAndHeadersWithAuth.js");
|
|
13
|
+
const odspUtils_js_1 = require("./odspUtils.js");
|
|
14
|
+
const createOdspUrl_js_1 = require("./createOdspUrl.js");
|
|
15
|
+
const odspUrlHelper_js_1 = require("./odspUrlHelper.js");
|
|
16
|
+
const odspDriverUrlResolver_js_1 = require("./odspDriverUrlResolver.js");
|
|
17
|
+
const createNewUtils_js_1 = require("./createNewUtils.js");
|
|
18
|
+
const retryUtils_js_1 = require("./retryUtils.js");
|
|
19
|
+
const packageVersion_js_1 = require("./packageVersion.js");
|
|
20
|
+
const contractsPublic_js_1 = require("./contractsPublic.js");
|
|
21
21
|
const isInvalidFileName = (fileName) => {
|
|
22
22
|
const invalidCharsRegex = /["*/:<>?\\|]+/g;
|
|
23
|
-
return
|
|
23
|
+
return invalidCharsRegex.test(fileName);
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
26
|
* Creates a new Fluid file.
|
|
@@ -31,7 +31,7 @@ async function createNewFluidFile(getStorageToken, newFileInfo, logger, createNe
|
|
|
31
31
|
if (isInvalidFileName(newFileInfo.filename)) {
|
|
32
32
|
throw new driver_utils_1.NonRetryableError(
|
|
33
33
|
// pre-0.58 error message: Invalid filename
|
|
34
|
-
"Invalid filename for createNew", odsp_driver_definitions_1.OdspErrorTypes.invalidFileNameError, { driverVersion:
|
|
34
|
+
"Invalid filename for createNew", odsp_driver_definitions_1.OdspErrorTypes.invalidFileNameError, { driverVersion: packageVersion_js_1.pkgVersion });
|
|
35
35
|
}
|
|
36
36
|
let itemId;
|
|
37
37
|
let summaryHandle = "";
|
|
@@ -45,11 +45,11 @@ async function createNewFluidFile(getStorageToken, newFileInfo, logger, createNe
|
|
|
45
45
|
summaryHandle = content.id;
|
|
46
46
|
shareLinkInfo = extractShareLinkData(content, enableSingleRequestForShareLinkWithCreate);
|
|
47
47
|
}
|
|
48
|
-
const odspUrl = (0,
|
|
49
|
-
const resolver = new
|
|
48
|
+
const odspUrl = (0, createOdspUrl_js_1.createOdspUrl)({ ...newFileInfo, itemId, dataStorePath: "/" });
|
|
49
|
+
const resolver = new odspDriverUrlResolver_js_1.OdspDriverUrlResolver();
|
|
50
50
|
const odspResolvedUrl = await resolver.resolve({
|
|
51
51
|
url: odspUrl,
|
|
52
|
-
headers: { [
|
|
52
|
+
headers: { [contractsPublic_js_1.ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },
|
|
53
53
|
});
|
|
54
54
|
fileEntry.docId = odspResolvedUrl.hashedDocumentId;
|
|
55
55
|
fileEntry.resolvedUrl = odspResolvedUrl;
|
|
@@ -57,9 +57,9 @@ async function createNewFluidFile(getStorageToken, newFileInfo, logger, createNe
|
|
|
57
57
|
if (createNewSummary !== undefined && createNewCaching) {
|
|
58
58
|
(0, core_utils_1.assert)(summaryHandle !== undefined, 0x203 /* "Summary handle is undefined" */);
|
|
59
59
|
// converting summary and getting sequence number
|
|
60
|
-
const snapshot = (0,
|
|
60
|
+
const snapshot = (0, createNewUtils_js_1.convertCreateNewSummaryTreeToTreeAndBlobs)(createNewSummary, summaryHandle);
|
|
61
61
|
// caching the converted summary
|
|
62
|
-
await epochTracker.put((0,
|
|
62
|
+
await epochTracker.put((0, odspUtils_js_1.createCacheSnapshotKey)(odspResolvedUrl), snapshot);
|
|
63
63
|
}
|
|
64
64
|
return odspResolvedUrl;
|
|
65
65
|
}
|
|
@@ -77,10 +77,12 @@ exports.createNewFluidFile = createNewFluidFile;
|
|
|
77
77
|
function extractShareLinkData(response, enableSingleRequestForShareLinkWithCreate) {
|
|
78
78
|
let shareLinkInfo;
|
|
79
79
|
if (enableSingleRequestForShareLinkWithCreate) {
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
80
81
|
const { sharing } = response;
|
|
81
82
|
if (!sharing) {
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
85
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
|
|
84
86
|
shareLinkInfo = {
|
|
85
87
|
createLink: {
|
|
86
88
|
link: sharing.sharingLink
|
|
@@ -95,6 +97,7 @@ function extractShareLinkData(response, enableSingleRequestForShareLinkWithCreat
|
|
|
95
97
|
shareId: sharing.shareId,
|
|
96
98
|
},
|
|
97
99
|
};
|
|
100
|
+
/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
|
|
98
101
|
}
|
|
99
102
|
return shareLinkInfo;
|
|
100
103
|
}
|
|
@@ -102,13 +105,13 @@ async function createNewEmptyFluidFile(getStorageToken, newFileInfo, logger, epo
|
|
|
102
105
|
const filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : "";
|
|
103
106
|
// add .tmp extension to empty file (host is expected to rename)
|
|
104
107
|
const encodedFilename = encodeURIComponent(`${newFileInfo.filename}.tmp`);
|
|
105
|
-
const initialUrl = `${(0,
|
|
106
|
-
return (0,
|
|
108
|
+
const initialUrl = `${(0, odspUrlHelper_js_1.getApiRoot)((0, odspUtils_js_1.getOrigin)(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:/${filePath}/${encodedFilename}:/content?@name.conflictBehavior=rename&select=id,name,parentReference`;
|
|
109
|
+
return (0, odspUtils_js_1.getWithRetryForTokenRefresh)(async (options) => {
|
|
107
110
|
const storageToken = await getStorageToken(options, "CreateNewFile");
|
|
108
111
|
return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "createNewEmptyFile" }, async (event) => {
|
|
109
|
-
const { url, headers } = (0,
|
|
112
|
+
const { url, headers } = (0, getUrlAndHeadersWithAuth_js_1.getUrlAndHeadersWithAuth)(initialUrl, storageToken, forceAccessTokenViaAuthorizationHeader);
|
|
110
113
|
headers["Content-Type"] = "application/json";
|
|
111
|
-
const fetchResponse = await (0,
|
|
114
|
+
const fetchResponse = await (0, retryUtils_js_1.runWithRetry)(async () => epochTracker.fetchAndParseAsJSON(url, {
|
|
112
115
|
body: undefined,
|
|
113
116
|
headers,
|
|
114
117
|
method: "PUT",
|
|
@@ -117,10 +120,10 @@ async function createNewEmptyFluidFile(getStorageToken, newFileInfo, logger, epo
|
|
|
117
120
|
if (!content?.id) {
|
|
118
121
|
throw new driver_utils_1.NonRetryableError(
|
|
119
122
|
// pre-0.58 error message: ODSP CreateFile call returned no item ID
|
|
120
|
-
"ODSP CreateFile call returned no item ID (for empty file)", odsp_driver_definitions_1.OdspErrorTypes.incorrectServerResponse, { driverVersion:
|
|
123
|
+
"ODSP CreateFile call returned no item ID (for empty file)", odsp_driver_definitions_1.OdspErrorTypes.incorrectServerResponse, { driverVersion: packageVersion_js_1.pkgVersion });
|
|
121
124
|
}
|
|
122
125
|
event.end({
|
|
123
|
-
headers: Object.keys(headers).length
|
|
126
|
+
headers: Object.keys(headers).length > 0 ? true : undefined,
|
|
124
127
|
...fetchResponse.propsToLog,
|
|
125
128
|
});
|
|
126
129
|
return content.id;
|
|
@@ -131,14 +134,14 @@ exports.createNewEmptyFluidFile = createNewEmptyFluidFile;
|
|
|
131
134
|
async function createNewFluidFileFromSummary(getStorageToken, newFileInfo, logger, createNewSummary, epochTracker, forceAccessTokenViaAuthorizationHeader) {
|
|
132
135
|
const filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : "";
|
|
133
136
|
const encodedFilename = encodeURIComponent(newFileInfo.filename);
|
|
134
|
-
const baseUrl = `${(0,
|
|
137
|
+
const baseUrl = `${(0, odspUrlHelper_js_1.getApiRoot)((0, odspUtils_js_1.getOrigin)(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:` +
|
|
135
138
|
`${filePath}/${encodedFilename}`;
|
|
136
|
-
const containerSnapshot = (0,
|
|
139
|
+
const containerSnapshot = (0, createNewUtils_js_1.convertSummaryIntoContainerSnapshot)(createNewSummary);
|
|
137
140
|
// Build share link parameter based on the createLinkType provided so that the
|
|
138
141
|
// snapshot api can create and return the share link along with creation of file in the response.
|
|
139
|
-
const createShareLinkParam = (0,
|
|
142
|
+
const createShareLinkParam = (0, odspUtils_js_1.buildOdspShareLinkReqParams)(newFileInfo.createLinkType);
|
|
140
143
|
const initialUrl = `${baseUrl}:/opStream/snapshots/snapshot${createShareLinkParam ? `?${createShareLinkParam}` : ""}`;
|
|
141
|
-
return (0,
|
|
144
|
+
return (0, createNewUtils_js_1.createNewFluidContainerCore)({
|
|
142
145
|
containerSnapshot,
|
|
143
146
|
getStorageToken,
|
|
144
147
|
logger,
|
|
@@ -149,7 +152,7 @@ async function createNewFluidFileFromSummary(getStorageToken, newFileInfo, logge
|
|
|
149
152
|
fetchType: "createFile",
|
|
150
153
|
validateResponseCallback: (content) => {
|
|
151
154
|
if (!content?.itemId) {
|
|
152
|
-
throw new driver_utils_1.NonRetryableError("ODSP CreateFile call returned no item ID", odsp_driver_definitions_1.OdspErrorTypes.incorrectServerResponse, { driverVersion:
|
|
155
|
+
throw new driver_utils_1.NonRetryableError("ODSP CreateFile call returned no item ID", odsp_driver_definitions_1.OdspErrorTypes.incorrectServerResponse, { driverVersion: packageVersion_js_1.pkgVersion });
|
|
153
156
|
}
|
|
154
157
|
},
|
|
155
158
|
});
|
package/dist/createFile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFile.js","sourceRoot":"","sources":["../src/createFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,+DAAiE;AAEjE,qEAAwF;AACxF,qFAMiD;AAGjD,yEAAsE;AACtE,2CAMqB;AACrB,mDAAgD;AAChD,mDAA6C;AAE7C,mEAAgE;AAChE,qDAI0B;AAC1B,6CAA4C;AAC5C,qDAA+D;AAC/D,uDAA0D;AAE1D,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAW,EAAE;IACvD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;IAC3C,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CACvC,eAAgD,EAChD,WAAyB,EACzB,MAA2B,EAC3B,gBAA0C,EAC1C,YAA0B,EAC1B,SAAqB,EACrB,gBAAyB,EACzB,sCAA+C,EAC/C,iBAA2B,EAC3B,yCAAmD;IAEnD,+EAA+E;IAC/E,IAAI,iBAAiB,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE;QAC5C,MAAM,IAAI,gCAAiB;QAC1B,2CAA2C;QAC3C,gCAAgC,EAChC,wCAAc,CAAC,oBAAoB,EACnC,EAAE,aAAa,EAAb,2BAAa,EAAE,CACjB,CAAC;KACF;IAED,IAAI,MAAc,CAAC;IACnB,IAAI,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,CAAC;aACF;QACF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AA1CD,sEA0CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tInstrumentedStorageTokenFetcher,\n\tIOdspResolvedUrl,\n\tOdspErrorTypes,\n\tShareLinkInfoType,\n\tIFileEntry,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshot } from \"@fluidframework/driver-definitions\";\nimport { ICreateFileResponse } from \"./contracts\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n\tbuildOdspShareLinkReqParams,\n\tcreateCacheSnapshotKey,\n\tgetWithRetryForTokenRefresh,\n\tINewFileInfo,\n\tgetOrigin,\n} from \"./odspUtils\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nimport {\n\tconvertCreateNewSummaryTreeToTreeAndBlobs,\n\tconvertSummaryIntoContainerSnapshot,\n\tcreateNewFluidContainerCore,\n} from \"./createNewUtils\";\nimport { runWithRetry } from \"./retryUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\n\nconst isInvalidFileName = (fileName: string): boolean => {\n\tconst invalidCharsRegex = /[\"*/:<>?\\\\|]+/g;\n\treturn !!fileName.match(invalidCharsRegex);\n};\n\n/**\n * Creates a new Fluid file.\n * Returns resolved url\n */\nexport async function createNewFluidFile(\n\tgetStorageToken: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree | undefined,\n\tepochTracker: EpochTracker,\n\tfileEntry: IFileEntry,\n\tcreateNewCaching: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tisClpCompliantApp?: boolean,\n\tenableSingleRequestForShareLinkWithCreate?: boolean,\n): Promise<IOdspResolvedUrl> {\n\t// Check for valid filename before the request to create file is actually made.\n\tif (isInvalidFileName(newFileInfo.filename)) {\n\t\tthrow new NonRetryableError(\n\t\t\t// pre-0.58 error message: Invalid filename\n\t\t\t\"Invalid filename for createNew\",\n\t\t\tOdspErrorTypes.invalidFileNameError,\n\t\t\t{ driverVersion },\n\t\t);\n\t}\n\n\tlet itemId: string;\n\tlet summaryHandle: string = \"\";\n\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\tif (createNewSummary === undefined) {\n\t\titemId = await createNewEmptyFluidFile(\n\t\t\tgetStorageToken,\n\t\t\tnewFileInfo,\n\t\t\tlogger,\n\t\t\tepochTracker,\n\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t);\n\t} else {\n\t\tconst content = await createNewFluidFileFromSummary(\n\t\t\tgetStorageToken,\n\t\t\tnewFileInfo,\n\t\t\tlogger,\n\t\t\tcreateNewSummary,\n\t\t\tepochTracker,\n\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t);\n\t\titemId = content.itemId;\n\t\tsummaryHandle = content.id;\n\n\t\tshareLinkInfo = extractShareLinkData(content, enableSingleRequestForShareLinkWithCreate);\n\t}\n\n\tconst odspUrl = createOdspUrl({ ...newFileInfo, itemId, dataStorePath: \"/\" });\n\tconst resolver = new OdspDriverUrlResolver();\n\tconst odspResolvedUrl = await resolver.resolve({\n\t\turl: odspUrl,\n\t\theaders: { [ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },\n\t});\n\tfileEntry.docId = odspResolvedUrl.hashedDocumentId;\n\tfileEntry.resolvedUrl = odspResolvedUrl;\n\n\todspResolvedUrl.shareLinkInfo = shareLinkInfo;\n\n\tif (createNewSummary !== undefined && createNewCaching) {\n\t\tassert(summaryHandle !== undefined, 0x203 /* \"Summary handle is undefined\" */);\n\t\t// converting summary and getting sequence number\n\t\tconst snapshot: ISnapshot = convertCreateNewSummaryTreeToTreeAndBlobs(\n\t\t\tcreateNewSummary,\n\t\t\tsummaryHandle,\n\t\t);\n\t\t// caching the converted summary\n\t\tawait epochTracker.put(createCacheSnapshotKey(odspResolvedUrl), snapshot);\n\t}\n\treturn odspResolvedUrl;\n}\n\n/**\n * If user requested creation of a sharing link along with the creation of the file by providing\n * createLinkScope in the request parameters then extract and save the sharing link information from\n * the response if it is available.\n * In case there was an error in creation of the sharing link, error is provided back in the response,\n * and does not impact the creation of file in ODSP.\n * @param requestedSharingLinkKind - Kind of sharing link requested to be created along with the creation of file.\n * @param response - Response object received from the /snapshot api call\n * @returns Sharing link information received in the response from a successful creation of a file.\n */\nfunction extractShareLinkData(\n\tresponse: ICreateFileResponse,\n\tenableSingleRequestForShareLinkWithCreate?: boolean,\n): ShareLinkInfoType | undefined {\n\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\tif (enableSingleRequestForShareLinkWithCreate) {\n\t\tconst { sharing } = response;\n\t\tif (!sharing) {\n\t\t\treturn;\n\t\t}\n\t\tshareLinkInfo = {\n\t\t\tcreateLink: {\n\t\t\t\tlink: sharing.sharingLink\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tscope: sharing.sharingLink.scope,\n\t\t\t\t\t\t\trole: sharing.sharingLink.type,\n\t\t\t\t\t\t\twebUrl: sharing.sharingLink.webUrl,\n\t\t\t\t\t\t\t...sharing.sharingLink,\n\t\t\t\t\t }\n\t\t\t\t\t: undefined,\n\t\t\t\terror: sharing.error,\n\t\t\t\tshareId: sharing.shareId,\n\t\t\t},\n\t\t};\n\t}\n\treturn shareLinkInfo;\n}\n\nexport async function createNewEmptyFluidFile(\n\tgetStorageToken: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tepochTracker: EpochTracker,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<string> {\n\tconst filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : \"\";\n\t// add .tmp extension to empty file (host is expected to rename)\n\tconst encodedFilename = encodeURIComponent(`${newFileInfo.filename}.tmp`);\n\tconst initialUrl = `${getApiRoot(getOrigin(newFileInfo.siteUrl))}/drives/${\n\t\tnewFileInfo.driveId\n\t}/items/root:/${filePath}/${encodedFilename}:/content?@name.conflictBehavior=rename&select=id,name,parentReference`;\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\tconst storageToken = await getStorageToken(options, \"CreateNewFile\");\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"createNewEmptyFile\" },\n\t\t\tasync (event) => {\n\t\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\t\tinitialUrl,\n\t\t\t\t\tstorageToken,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\theaders[\"Content-Type\"] = \"application/json\";\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<ICreateFileResponse>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: undefined,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod: \"PUT\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"createFile\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\"createFile\",\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tconst content = fetchResponse.content;\n\t\t\t\tif (!content?.id) {\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t// pre-0.58 error message: ODSP CreateFile call returned no item ID\n\t\t\t\t\t\t\"ODSP CreateFile call returned no item ID (for empty file)\",\n\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tevent.end({\n\t\t\t\t\theaders: Object.keys(headers).length !== 0 ? true : undefined,\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\t\t\t\treturn content.id;\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t});\n}\n\nexport async function createNewFluidFileFromSummary(\n\tgetStorageToken: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree,\n\tepochTracker: EpochTracker,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<ICreateFileResponse> {\n\tconst filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : \"\";\n\tconst encodedFilename = encodeURIComponent(newFileInfo.filename);\n\tconst baseUrl =\n\t\t`${getApiRoot(getOrigin(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:` +\n\t\t`${filePath}/${encodedFilename}`;\n\n\tconst containerSnapshot = convertSummaryIntoContainerSnapshot(createNewSummary);\n\n\t// Build share link parameter based on the createLinkType provided so that the\n\t// snapshot api can create and return the share link along with creation of file in the response.\n\tconst createShareLinkParam = buildOdspShareLinkReqParams(newFileInfo.createLinkType);\n\tconst initialUrl = `${baseUrl}:/opStream/snapshots/snapshot${\n\t\tcreateShareLinkParam ? `?${createShareLinkParam}` : \"\"\n\t}`;\n\n\treturn createNewFluidContainerCore<ICreateFileResponse>({\n\t\tcontainerSnapshot,\n\t\tgetStorageToken,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t\tepochTracker,\n\t\ttelemetryName: \"CreateNewFile\",\n\t\tfetchType: \"createFile\",\n\t\tvalidateResponseCallback: (content) => {\n\t\t\tif (!content?.itemId) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"ODSP CreateFile call returned no item ID\",\n\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createFile.js","sourceRoot":"","sources":["../src/createFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,+DAAiE;AAEjE,qEAAwF;AACxF,qFAMiD;AAGjD,+EAAyE;AACzE,iDAMwB;AACxB,yDAAmD;AACnD,yDAAgD;AAEhD,yEAAmE;AACnE,2DAI6B;AAC7B,mDAA+C;AAC/C,2DAAkE;AAClE,6DAA6D;AAE7D,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAW,EAAE;IACvD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;IAC3C,OAAO,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CACvC,eAAgD,EAChD,WAAyB,EACzB,MAA2B,EAC3B,gBAA0C,EAC1C,YAA0B,EAC1B,SAAqB,EACrB,gBAAyB,EACzB,sCAA+C,EAC/C,iBAA2B,EAC3B,yCAAmD;IAEnD,+EAA+E;IAC/E,IAAI,iBAAiB,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE;QAC5C,MAAM,IAAI,gCAAiB;QAC1B,2CAA2C;QAC3C,gCAAgC,EAChC,wCAAc,CAAC,oBAAoB,EACnC,EAAE,aAAa,EAAb,8BAAa,EAAE,CACjB,CAAC;KACF;IAED,IAAI,MAAc,CAAC;IACnB,IAAI,aAAa,GAAW,EAAE,CAAC;IAC/B,IAAI,aAA4C,CAAC;IACjD,IAAI,gBAAgB,KAAK,SAAS,EAAE;QACnC,MAAM,GAAG,MAAM,uBAAuB,CACrC,eAAe,EACf,WAAW,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poration and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tInstrumentedStorageTokenFetcher,\n\tIOdspResolvedUrl,\n\tOdspErrorTypes,\n\tShareLinkInfoType,\n\tIFileEntry,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshot } from \"@fluidframework/driver-definitions\";\nimport { ICreateFileResponse } from \"./contracts.js\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport {\n\tbuildOdspShareLinkReqParams,\n\tcreateCacheSnapshotKey,\n\tgetWithRetryForTokenRefresh,\n\tINewFileInfo,\n\tgetOrigin,\n} from \"./odspUtils.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver.js\";\nimport {\n\tconvertCreateNewSummaryTreeToTreeAndBlobs,\n\tconvertSummaryIntoContainerSnapshot,\n\tcreateNewFluidContainerCore,\n} from \"./createNewUtils.js\";\nimport { runWithRetry } from \"./retryUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\n\nconst isInvalidFileName = (fileName: string): boolean => {\n\tconst invalidCharsRegex = /[\"*/:<>?\\\\|]+/g;\n\treturn invalidCharsRegex.test(fileName);\n};\n\n/**\n * Creates a new Fluid file.\n * Returns resolved url\n */\nexport async function createNewFluidFile(\n\tgetStorageToken: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree | undefined,\n\tepochTracker: EpochTracker,\n\tfileEntry: IFileEntry,\n\tcreateNewCaching: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tisClpCompliantApp?: boolean,\n\tenableSingleRequestForShareLinkWithCreate?: boolean,\n): Promise<IOdspResolvedUrl> {\n\t// Check for valid filename before the request to create file is actually made.\n\tif (isInvalidFileName(newFileInfo.filename)) {\n\t\tthrow new NonRetryableError(\n\t\t\t// pre-0.58 error message: Invalid filename\n\t\t\t\"Invalid filename for createNew\",\n\t\t\tOdspErrorTypes.invalidFileNameError,\n\t\t\t{ driverVersion },\n\t\t);\n\t}\n\n\tlet itemId: string;\n\tlet summaryHandle: string = \"\";\n\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\tif (createNewSummary === undefined) {\n\t\titemId = await createNewEmptyFluidFile(\n\t\t\tgetStorageToken,\n\t\t\tnewFileInfo,\n\t\t\tlogger,\n\t\t\tepochTracker,\n\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t);\n\t} else {\n\t\tconst content = await createNewFluidFileFromSummary(\n\t\t\tgetStorageToken,\n\t\t\tnewFileInfo,\n\t\t\tlogger,\n\t\t\tcreateNewSummary,\n\t\t\tepochTracker,\n\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t);\n\t\titemId = content.itemId;\n\t\tsummaryHandle = content.id;\n\n\t\tshareLinkInfo = extractShareLinkData(content, enableSingleRequestForShareLinkWithCreate);\n\t}\n\n\tconst odspUrl = createOdspUrl({ ...newFileInfo, itemId, dataStorePath: \"/\" });\n\tconst resolver = new OdspDriverUrlResolver();\n\tconst odspResolvedUrl = await resolver.resolve({\n\t\turl: odspUrl,\n\t\theaders: { [ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },\n\t});\n\tfileEntry.docId = odspResolvedUrl.hashedDocumentId;\n\tfileEntry.resolvedUrl = odspResolvedUrl;\n\n\todspResolvedUrl.shareLinkInfo = shareLinkInfo;\n\n\tif (createNewSummary !== undefined && createNewCaching) {\n\t\tassert(summaryHandle !== undefined, 0x203 /* \"Summary handle is undefined\" */);\n\t\t// converting summary and getting sequence number\n\t\tconst snapshot: ISnapshot = convertCreateNewSummaryTreeToTreeAndBlobs(\n\t\t\tcreateNewSummary,\n\t\t\tsummaryHandle,\n\t\t);\n\t\t// caching the converted summary\n\t\tawait epochTracker.put(createCacheSnapshotKey(odspResolvedUrl), snapshot);\n\t}\n\treturn odspResolvedUrl;\n}\n\n/**\n * If user requested creation of a sharing link along with the creation of the file by providing\n * createLinkScope in the request parameters then extract and save the sharing link information from\n * the response if it is available.\n * In case there was an error in creation of the sharing link, error is provided back in the response,\n * and does not impact the creation of file in ODSP.\n * @param requestedSharingLinkKind - Kind of sharing link requested to be created along with the creation of file.\n * @param response - Response object received from the /snapshot api call\n * @returns Sharing link information received in the response from a successful creation of a file.\n */\nfunction extractShareLinkData(\n\tresponse: ICreateFileResponse,\n\tenableSingleRequestForShareLinkWithCreate?: boolean,\n): ShareLinkInfoType | undefined {\n\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\tif (enableSingleRequestForShareLinkWithCreate) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\tconst { sharing } = response;\n\t\tif (!sharing) {\n\t\t\treturn;\n\t\t}\n\t\t/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */\n\t\tshareLinkInfo = {\n\t\t\tcreateLink: {\n\t\t\t\tlink: sharing.sharingLink\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tscope: sharing.sharingLink.scope,\n\t\t\t\t\t\t\trole: sharing.sharingLink.type,\n\t\t\t\t\t\t\twebUrl: sharing.sharingLink.webUrl,\n\t\t\t\t\t\t\t...sharing.sharingLink,\n\t\t\t\t\t }\n\t\t\t\t\t: undefined,\n\t\t\t\terror: sharing.error,\n\t\t\t\tshareId: sharing.shareId,\n\t\t\t},\n\t\t};\n\t\t/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */\n\t}\n\treturn shareLinkInfo;\n}\n\nexport async function createNewEmptyFluidFile(\n\tgetStorageToken: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tepochTracker: EpochTracker,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<string> {\n\tconst filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : \"\";\n\t// add .tmp extension to empty file (host is expected to rename)\n\tconst encodedFilename = encodeURIComponent(`${newFileInfo.filename}.tmp`);\n\tconst initialUrl = `${getApiRoot(getOrigin(newFileInfo.siteUrl))}/drives/${\n\t\tnewFileInfo.driveId\n\t}/items/root:/${filePath}/${encodedFilename}:/content?@name.conflictBehavior=rename&select=id,name,parentReference`;\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\tconst storageToken = await getStorageToken(options, \"CreateNewFile\");\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"createNewEmptyFile\" },\n\t\t\tasync (event) => {\n\t\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\t\tinitialUrl,\n\t\t\t\t\tstorageToken,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\theaders[\"Content-Type\"] = \"application/json\";\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<ICreateFileResponse>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: undefined,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod: \"PUT\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"createFile\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\"createFile\",\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tconst content = fetchResponse.content;\n\t\t\t\tif (!content?.id) {\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t// pre-0.58 error message: ODSP CreateFile call returned no item ID\n\t\t\t\t\t\t\"ODSP CreateFile call returned no item ID (for empty file)\",\n\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tevent.end({\n\t\t\t\t\theaders: Object.keys(headers).length > 0 ? true : undefined,\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\t\t\t\treturn content.id;\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t});\n}\n\nexport async function createNewFluidFileFromSummary(\n\tgetStorageToken: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree,\n\tepochTracker: EpochTracker,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<ICreateFileResponse> {\n\tconst filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : \"\";\n\tconst encodedFilename = encodeURIComponent(newFileInfo.filename);\n\tconst baseUrl =\n\t\t`${getApiRoot(getOrigin(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:` +\n\t\t`${filePath}/${encodedFilename}`;\n\n\tconst containerSnapshot = convertSummaryIntoContainerSnapshot(createNewSummary);\n\n\t// Build share link parameter based on the createLinkType provided so that the\n\t// snapshot api can create and return the share link along with creation of file in the response.\n\tconst createShareLinkParam = buildOdspShareLinkReqParams(newFileInfo.createLinkType);\n\tconst initialUrl = `${baseUrl}:/opStream/snapshots/snapshot${\n\t\tcreateShareLinkParam ? `?${createShareLinkParam}` : \"\"\n\t}`;\n\n\treturn createNewFluidContainerCore<ICreateFileResponse>({\n\t\tcontainerSnapshot,\n\t\tgetStorageToken,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t\tepochTracker,\n\t\ttelemetryName: \"CreateNewFile\",\n\t\tfetchType: \"createFile\",\n\t\tvalidateResponseCallback: (content) => {\n\t\t\tif (!content?.itemId) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"ODSP CreateFile call returned no item ID\",\n\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t});\n}\n"]}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
6
6
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
7
7
|
import { IFileEntry, InstrumentedStorageTokenFetcher, IOdspResolvedUrl } from "@fluidframework/odsp-driver-definitions";
|
|
8
|
-
import { IExistingFileInfo } from "./odspUtils";
|
|
9
|
-
import { EpochTracker } from "./epochTracker";
|
|
8
|
+
import { IExistingFileInfo } from "./odspUtils.js";
|
|
9
|
+
import { EpochTracker } from "./epochTracker.js";
|
|
10
10
|
/**
|
|
11
11
|
* Creates a new Fluid container on an existing file.
|
|
12
12
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewContainerOnExistingFile.d.ts","sourceRoot":"","sources":["../src/createNewContainerOnExistingFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EACN,UAAU,EACV,+BAA+B,EAC/B,gBAAgB,EAChB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAqC,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createNewContainerOnExistingFile.d.ts","sourceRoot":"","sources":["../src/createNewContainerOnExistingFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EACN,UAAU,EACV,+BAA+B,EAC/B,gBAAgB,EAChB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAqC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGtF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD;;;;;;;;;;GAUG;AACH,wBAAsB,gCAAgC,CACrD,eAAe,EAAE,+BAA+B,EAChD,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,mBAAmB,EAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,UAAU,EACrB,gBAAgB,EAAE,OAAO,EACzB,sCAAsC,EAAE,OAAO,EAC/C,iBAAiB,CAAC,EAAE,OAAO,GACzB,OAAO,CAAC,gBAAgB,CAAC,CA4C3B"}
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.createNewContainerOnExistingFile = void 0;
|
|
8
8
|
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
9
|
+
const odspUtils_js_1 = require("./odspUtils.js");
|
|
10
|
+
const createOdspUrl_js_1 = require("./createOdspUrl.js");
|
|
11
|
+
const odspUrlHelper_js_1 = require("./odspUrlHelper.js");
|
|
12
|
+
const odspDriverUrlResolver_js_1 = require("./odspDriverUrlResolver.js");
|
|
13
|
+
const createNewUtils_js_1 = require("./createNewUtils.js");
|
|
14
|
+
const contractsPublic_js_1 = require("./contractsPublic.js");
|
|
15
15
|
/**
|
|
16
16
|
* Creates a new Fluid container on an existing file.
|
|
17
17
|
*
|
|
@@ -27,10 +27,10 @@ async function createNewContainerOnExistingFile(getStorageToken, fileInfo, logge
|
|
|
27
27
|
if (createNewSummary === undefined) {
|
|
28
28
|
throw new driver_utils_1.UsageError("createNewSummary must exist to create a new container");
|
|
29
29
|
}
|
|
30
|
-
const baseUrl = `${(0,
|
|
31
|
-
const containerSnapshot = (0,
|
|
30
|
+
const baseUrl = `${(0, odspUrlHelper_js_1.getApiRoot)((0, odspUtils_js_1.getOrigin)(fileInfo.siteUrl))}/drives/${fileInfo.driveId}/items/${fileInfo.itemId}`;
|
|
31
|
+
const containerSnapshot = (0, createNewUtils_js_1.convertSummaryIntoContainerSnapshot)(createNewSummary);
|
|
32
32
|
const initialUrl = `${baseUrl}/opStream/snapshots/snapshot`;
|
|
33
|
-
const { id: summaryHandle } = await (0,
|
|
33
|
+
const { id: summaryHandle } = await (0, createNewUtils_js_1.createNewFluidContainerCore)({
|
|
34
34
|
containerSnapshot,
|
|
35
35
|
getStorageToken,
|
|
36
36
|
logger,
|
|
@@ -40,19 +40,19 @@ async function createNewContainerOnExistingFile(getStorageToken, fileInfo, logge
|
|
|
40
40
|
telemetryName: "CreateNewContainerOnExistingFile",
|
|
41
41
|
fetchType: "uploadSummary",
|
|
42
42
|
});
|
|
43
|
-
const odspUrl = (0,
|
|
44
|
-
const resolver = new
|
|
43
|
+
const odspUrl = (0, createOdspUrl_js_1.createOdspUrl)({ ...fileInfo, dataStorePath: "/" });
|
|
44
|
+
const resolver = new odspDriverUrlResolver_js_1.OdspDriverUrlResolver();
|
|
45
45
|
const odspResolvedUrl = await resolver.resolve({
|
|
46
46
|
url: odspUrl,
|
|
47
|
-
headers: { [
|
|
47
|
+
headers: { [contractsPublic_js_1.ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },
|
|
48
48
|
});
|
|
49
49
|
fileEntry.docId = odspResolvedUrl.hashedDocumentId;
|
|
50
50
|
fileEntry.resolvedUrl = odspResolvedUrl;
|
|
51
51
|
if (createNewCaching) {
|
|
52
52
|
// converting summary and getting sequence number
|
|
53
|
-
const snapshot = (0,
|
|
53
|
+
const snapshot = (0, createNewUtils_js_1.convertCreateNewSummaryTreeToTreeAndBlobs)(createNewSummary, summaryHandle);
|
|
54
54
|
// caching the converted summary
|
|
55
|
-
await epochTracker.put((0,
|
|
55
|
+
await epochTracker.put((0, odspUtils_js_1.createCacheSnapshotKey)(odspResolvedUrl), snapshot);
|
|
56
56
|
}
|
|
57
57
|
return odspResolvedUrl;
|
|
58
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewContainerOnExistingFile.js","sourceRoot":"","sources":["../src/createNewContainerOnExistingFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,+DAA0D;AAQ1D,
|
|
1
|
+
{"version":3,"file":"createNewContainerOnExistingFile.js","sourceRoot":"","sources":["../src/createNewContainerOnExistingFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,+DAA0D;AAQ1D,iDAAsF;AACtF,yDAAmD;AACnD,yDAAgD;AAEhD,yEAAmE;AACnE,2DAI6B;AAC7B,6DAA6D;AAE7D;;;;;;;;;;GAUG;AACI,KAAK,UAAU,gCAAgC,CACrD,eAAgD,EAChD,QAA2B,EAC3B,MAA2B,EAC3B,gBAA0C,EAC1C,YAA0B,EAC1B,SAAqB,EACrB,gBAAyB,EACzB,sCAA+C,EAC/C,iBAA2B;IAE3B,IAAI,gBAAgB,KAAK,SAAS,EAAE;QACnC,MAAM,IAAI,yBAAU,CAAC,uDAAuD,CAAC,CAAC;KAC9E;IAED,MAAM,OAAO,GAAG,GAAG,IAAA,6BAAU,EAAC,IAAA,wBAAS,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,WAAW,QAAQ,CAAC,OAAO,UACpF,QAAQ,CAAC,MACV,EAAE,CAAC;IAEH,MAAM,iBAAiB,GAAG,IAAA,uDAAmC,EAAC,gBAAgB,CAAC,CAAC;IAEhF,MAAM,UAAU,GAAG,GAAG,OAAO,8BAA8B,CAAC;IAE5D,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,GAAG,MAAM,IAAA,+CAA2B,EAAwB;QACtF,iBAAiB;QACjB,eAAe;QACf,MAAM;QACN,UAAU;QACV,sCAAsC;QACtC,YAAY;QACZ,aAAa,EAAE,kCAAkC;QACjD,SAAS,EAAE,eAAe;KAC1B,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAA,gCAAa,EAAC,EAAE,GAAG,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,IAAI,gDAAqB,EAAE,CAAC;IAC7C,MAAM,eAAe,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC;QAC9C,GAAG,EAAE,OAAO;QACZ,OAAO,EAAE,EAAE,CAAC,0CAAqB,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,EAAE;KACzE,CAAC,CAAC;IACH,SAAS,CAAC,KAAK,GAAG,eAAe,CAAC,gBAAgB,CAAC;IACnD,SAAS,CAAC,WAAW,GAAG,eAAe,CAAC;IAExC,IAAI,gBAAgB,EAAE;QACrB,iDAAiD;QACjD,MAAM,QAAQ,GAAc,IAAA,6DAAyC,EACpE,gBAAgB,EAChB,aAAa,CACb,CAAC;QACF,gCAAgC;QAChC,MAAM,YAAY,CAAC,GAAG,CAAC,IAAA,qCAAsB,EAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,CAAC;KAC1E;IAED,OAAO,eAAe,CAAC;AACxB,CAAC;AAtDD,4EAsDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport { ISnapshot } from \"@fluidframework/driver-definitions\";\nimport {\n\tIFileEntry,\n\tInstrumentedStorageTokenFetcher,\n\tIOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { IWriteSummaryResponse } from \"./contracts.js\";\nimport { createCacheSnapshotKey, getOrigin, IExistingFileInfo } from \"./odspUtils.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver.js\";\nimport {\n\tconvertCreateNewSummaryTreeToTreeAndBlobs,\n\tconvertSummaryIntoContainerSnapshot,\n\tcreateNewFluidContainerCore,\n} from \"./createNewUtils.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\n\n/**\n * Creates a new Fluid container on an existing file.\n *\n * @remarks This requires service's capability to manage Fluid container inside an existing file.\n *\n * @example\n *\n * This enables a scenario where Fluid data is not stored as a standalone file but in a way that is managed\n * by an existing file. For example, SharePoint Pages is able to store Fluid container in an\n * \"alternative file partition\" where the main File stub is an ASPX page.\n */\nexport async function createNewContainerOnExistingFile(\n\tgetStorageToken: InstrumentedStorageTokenFetcher,\n\tfileInfo: IExistingFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree | undefined,\n\tepochTracker: EpochTracker,\n\tfileEntry: IFileEntry,\n\tcreateNewCaching: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tisClpCompliantApp?: boolean,\n): Promise<IOdspResolvedUrl> {\n\tif (createNewSummary === undefined) {\n\t\tthrow new UsageError(\"createNewSummary must exist to create a new container\");\n\t}\n\n\tconst baseUrl = `${getApiRoot(getOrigin(fileInfo.siteUrl))}/drives/${fileInfo.driveId}/items/${\n\t\tfileInfo.itemId\n\t}`;\n\n\tconst containerSnapshot = convertSummaryIntoContainerSnapshot(createNewSummary);\n\n\tconst initialUrl = `${baseUrl}/opStream/snapshots/snapshot`;\n\n\tconst { id: summaryHandle } = await createNewFluidContainerCore<IWriteSummaryResponse>({\n\t\tcontainerSnapshot,\n\t\tgetStorageToken,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t\tepochTracker,\n\t\ttelemetryName: \"CreateNewContainerOnExistingFile\",\n\t\tfetchType: \"uploadSummary\",\n\t});\n\n\tconst odspUrl = createOdspUrl({ ...fileInfo, dataStorePath: \"/\" });\n\tconst resolver = new OdspDriverUrlResolver();\n\tconst odspResolvedUrl = await resolver.resolve({\n\t\turl: odspUrl,\n\t\theaders: { [ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },\n\t});\n\tfileEntry.docId = odspResolvedUrl.hashedDocumentId;\n\tfileEntry.resolvedUrl = odspResolvedUrl;\n\n\tif (createNewCaching) {\n\t\t// converting summary and getting sequence number\n\t\tconst snapshot: ISnapshot = convertCreateNewSummaryTreeToTreeAndBlobs(\n\t\t\tcreateNewSummary,\n\t\t\tsummaryHandle,\n\t\t);\n\t\t// caching the converted summary\n\t\tawait epochTracker.put(createCacheSnapshotKey(odspResolvedUrl), snapshot);\n\t}\n\n\treturn odspResolvedUrl;\n}\n"]}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { createNewFluidFile } from "./createFile";
|
|
6
|
-
export { createNewContainerOnExistingFile } from "./createNewContainerOnExistingFile";
|
|
5
|
+
export { createNewFluidFile } from "./createFile.js";
|
|
6
|
+
export { createNewContainerOnExistingFile } from "./createNewContainerOnExistingFile.js";
|
|
7
7
|
//# sourceMappingURL=createNewModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewModule.d.ts","sourceRoot":"","sources":["../src/createNewModule.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createNewModule.d.ts","sourceRoot":"","sources":["../src/createNewModule.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC"}
|
package/dist/createNewModule.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.createNewContainerOnExistingFile = exports.createNewFluidFile = void 0;
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "createNewFluidFile", { enumerable: true, get: function () { return
|
|
10
|
-
var
|
|
11
|
-
Object.defineProperty(exports, "createNewContainerOnExistingFile", { enumerable: true, get: function () { return
|
|
8
|
+
var createFile_js_1 = require("./createFile.js");
|
|
9
|
+
Object.defineProperty(exports, "createNewFluidFile", { enumerable: true, get: function () { return createFile_js_1.createNewFluidFile; } });
|
|
10
|
+
var createNewContainerOnExistingFile_js_1 = require("./createNewContainerOnExistingFile.js");
|
|
11
|
+
Object.defineProperty(exports, "createNewContainerOnExistingFile", { enumerable: true, get: function () { return createNewContainerOnExistingFile_js_1.createNewContainerOnExistingFile; } });
|
|
12
12
|
//# sourceMappingURL=createNewModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewModule.js","sourceRoot":"","sources":["../src/createNewModule.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"createNewModule.js","sourceRoot":"","sources":["../src/createNewModule.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAAqD;AAA5C,mHAAA,kBAAkB,OAAA;AAC3B,6FAAyF;AAAhF,uJAAA,gCAAgC,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { createNewFluidFile } from \"./createFile.js\";\nexport { createNewContainerOnExistingFile } from \"./createNewContainerOnExistingFile.js\";\n"]}
|
package/dist/createNewUtils.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
|
6
6
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
7
7
|
import { InstrumentedStorageTokenFetcher } from "@fluidframework/odsp-driver-definitions";
|
|
8
8
|
import { ISnapshot } from "@fluidframework/driver-definitions";
|
|
9
|
-
import { IOdspSummaryPayload } from "./contracts";
|
|
10
|
-
import { EpochTracker, FetchType } from "./epochTracker";
|
|
9
|
+
import { IOdspSummaryPayload } from "./contracts.js";
|
|
10
|
+
import { EpochTracker, FetchType } from "./epochTracker.js";
|
|
11
11
|
/**
|
|
12
12
|
* Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs
|
|
13
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEN,YAAY,
|
|
1
|
+
{"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEN,YAAY,EAIZ,MAAM,sCAAsC,CAAC;AAQ9C,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAAC;AACxF,OAAO,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EACN,mBAAmB,EAInB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAI5D;;GAEG;AACH,wBAAgB,yCAAyC,CACxD,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,GACZ,SAAS,CAiBX;AAiDD,wBAAgB,mCAAmC,CAClD,gBAAgB,EAAE,YAAY,GAC5B,mBAAmB,CA2BrB;AAgED,wBAAsB,2BAA2B,CAAC,CAAC,EAAE,IAAI,EAAE;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC;IACvC,eAAe,EAAE,+BAA+B,CAAC;IACjD,MAAM,EAAE,mBAAmB,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,sCAAsC,EAAE,OAAO,CAAC;IAChD,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,wBAAwB,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;CAChD,GAAG,OAAO,CAAC,CAAC,CAAC,CAmFb"}
|
package/dist/createNewUtils.js
CHANGED
|
@@ -12,9 +12,9 @@ const client_utils_1 = require("@fluid-internal/client-utils");
|
|
|
12
12
|
const core_utils_1 = require("@fluidframework/core-utils");
|
|
13
13
|
const protocol_base_1 = require("@fluidframework/protocol-base");
|
|
14
14
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
15
|
+
const odspUtils_js_1 = require("./odspUtils.js");
|
|
16
|
+
const getUrlAndHeadersWithAuth_js_1 = require("./getUrlAndHeadersWithAuth.js");
|
|
17
|
+
const retryUtils_js_1 = require("./retryUtils.js");
|
|
18
18
|
/**
|
|
19
19
|
* Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs
|
|
20
20
|
*/
|
|
@@ -41,6 +41,7 @@ function convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobs) {
|
|
|
41
41
|
blobs: {},
|
|
42
42
|
trees: {},
|
|
43
43
|
unreferenced: summary.unreferenced,
|
|
44
|
+
groupId: summary.groupId,
|
|
44
45
|
};
|
|
45
46
|
const keys = Object.keys(summary.tree);
|
|
46
47
|
for (const key of keys) {
|
|
@@ -115,10 +116,12 @@ function convertSummaryToSnapshotTreeForCreateNew(summary) {
|
|
|
115
116
|
// property is not present, the tree entry is considered referenced. If the property is present and is true,
|
|
116
117
|
// the tree entry is considered unreferenced.
|
|
117
118
|
let unreferenced;
|
|
119
|
+
let groupId;
|
|
118
120
|
switch (summaryObject.type) {
|
|
119
121
|
case protocol_definitions_1.SummaryType.Tree: {
|
|
120
122
|
value = convertSummaryToSnapshotTreeForCreateNew(summaryObject);
|
|
121
123
|
unreferenced = summaryObject.unreferenced;
|
|
124
|
+
groupId = summaryObject.groupId;
|
|
122
125
|
break;
|
|
123
126
|
}
|
|
124
127
|
case protocol_definitions_1.SummaryType.Blob: {
|
|
@@ -145,6 +148,7 @@ function convertSummaryToSnapshotTreeForCreateNew(summary) {
|
|
|
145
148
|
type: (0, protocol_base_1.getGitType)(summaryObject),
|
|
146
149
|
value,
|
|
147
150
|
unreferenced,
|
|
151
|
+
groupId,
|
|
148
152
|
};
|
|
149
153
|
snapshotTree.entries?.push(entry);
|
|
150
154
|
}
|
|
@@ -152,7 +156,7 @@ function convertSummaryToSnapshotTreeForCreateNew(summary) {
|
|
|
152
156
|
}
|
|
153
157
|
async function createNewFluidContainerCore(args) {
|
|
154
158
|
const { containerSnapshot, getStorageToken, logger, initialUrl, forceAccessTokenViaAuthorizationHeader, epochTracker, telemetryName, fetchType, validateResponseCallback, } = args;
|
|
155
|
-
return (0,
|
|
159
|
+
return (0, odspUtils_js_1.getWithRetryForTokenRefresh)(async (options) => {
|
|
156
160
|
const storageToken = await getStorageToken(options, telemetryName);
|
|
157
161
|
return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: telemetryName }, async (event) => {
|
|
158
162
|
const snapshotBody = JSON.stringify(containerSnapshot);
|
|
@@ -167,7 +171,7 @@ async function createNewFluidContainerCore(args) {
|
|
|
167
171
|
postBody += `_post: 1\r\n`;
|
|
168
172
|
postBody += `\r\n${snapshotBody}\r\n`;
|
|
169
173
|
postBody += `\r\n--${formBoundary}--`;
|
|
170
|
-
if (postBody.length <=
|
|
174
|
+
if (postBody.length <= odspUtils_js_1.maxUmpPostBodySize) {
|
|
171
175
|
const urlObj = new URL(initialUrl);
|
|
172
176
|
urlObj.searchParams.set("ump", "1");
|
|
173
177
|
url = urlObj.href;
|
|
@@ -177,7 +181,7 @@ async function createNewFluidContainerCore(args) {
|
|
|
177
181
|
addInBody = true;
|
|
178
182
|
}
|
|
179
183
|
else {
|
|
180
|
-
const parts = (0,
|
|
184
|
+
const parts = (0, getUrlAndHeadersWithAuth_js_1.getUrlAndHeadersWithAuth)(initialUrl, storageToken, forceAccessTokenViaAuthorizationHeader);
|
|
181
185
|
url = parts.url;
|
|
182
186
|
headers = {
|
|
183
187
|
...parts.headers,
|
|
@@ -185,14 +189,14 @@ async function createNewFluidContainerCore(args) {
|
|
|
185
189
|
};
|
|
186
190
|
postBody = snapshotBody;
|
|
187
191
|
}
|
|
188
|
-
const fetchResponse = await (0,
|
|
192
|
+
const fetchResponse = await (0, retryUtils_js_1.runWithRetry)(async () => epochTracker.fetchAndParseAsJSON(url, {
|
|
189
193
|
body: postBody,
|
|
190
194
|
headers,
|
|
191
195
|
method: "POST",
|
|
192
196
|
}, fetchType, addInBody), telemetryName, logger);
|
|
193
197
|
validateResponseCallback?.(fetchResponse.content);
|
|
194
198
|
event.end({
|
|
195
|
-
headers: Object.keys(headers).length
|
|
199
|
+
headers: Object.keys(headers).length > 0 ? true : undefined,
|
|
196
200
|
attempts: options.refresh ? 2 : 1,
|
|
197
201
|
...fetchResponse.propsToLog,
|
|
198
202
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAClC,+EAK8C;AAC9C,+DAGsC;AACtC,+DAAkF;AAClF,2DAA6D;AAC7D,iEAA2D;AAC3D,qEAAwF;AASxF,2CAA8E;AAE9E,yEAAsE;AACtE,6CAA4C;AAE5C;;GAEG;AACH,SAAgB,yCAAyC,CACxD,OAAqB,EACrB,MAAc;IAEd,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,WAA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O,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;gBAC7D,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjC,GAAG,aAAa,CAAC,UAAU;aAC3B,CAAC,CAAC;YAEH,OAAO,aAAa,CAAC,OAAO,CAAC;QAC9B,CAAC,CACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC;AA7FD,kEA6FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tISummaryBlob,\n\tISummaryTree,\n\tSummaryType,\n\tISnapshotTree,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { stringToBuffer, Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport { unreachableCase } from \"@fluidframework/core-utils\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshot } from \"@fluidframework/driver-definitions\";\nimport {\n\tIOdspSummaryPayload,\n\tIOdspSummaryTree,\n\tOdspSummaryTreeEntry,\n\tOdspSummaryTreeValue,\n} from \"./contracts\";\nimport { getWithRetryForTokenRefresh, maxUmpPostBodySize } from \"./odspUtils\";\nimport { EpochTracker, FetchType } from \"./epochTracker\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { runWithRetry } from \"./retryUtils\";\n\n/**\n * Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs\n */\nexport function convertCreateNewSummaryTreeToTreeAndBlobs(\n\tsummary: ISummaryTree,\n\ttreeId: string,\n): ISnapshot {\n\tconst protocolSummary = summary.tree[\".protocol\"] as ISummaryTree;\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tconst blobContents = new Map<string, ArrayBuffer>();\n\tconst snapshotTree = convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobContents);\n\tsnapshotTree.id = treeId;\n\tconst snapshotTreeValue: ISnapshot = {\n\t\tsnapshotTree,\n\t\tblobContents,\n\t\tops: [],\n\t\tsequenceNumber,\n\t\tlatestSequenceNumber: sequenceNumber,\n\t\tsnapshotFormatV: 1,\n\t};\n\n\treturn snapshotTreeValue;\n}\n\nfunction convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\tsummary: ISummaryTree,\n\tblobs: Map<string, ArrayBuffer>,\n) {\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tunreferenced: summary.unreferenced,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] = convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\tblobs,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tblobs.set(blobId, contentBuffer);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tthrow new Error(`No ${summaryObject.type} should be present for detached summary!`);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\nexport function convertSummaryIntoContainerSnapshot(createNewSummary: ISummaryTree) {\n\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\tthrow new Error(\"App and protocol summary required for create new path!!\");\n\t}\n\tconst appSummary = createNewSummary.tree[\".app\"];\n\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst attributesSummaryBlob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent: JSON.stringify(documentAttributes),\n\t};\n\tprotocolSummary.tree.attributes = attributesSummaryBlob;\n\tconst convertedCreateNewSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\tconst snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);\n\tconst snapshot: IOdspSummaryPayload = {\n\t\tentries: snapshotTree.entries ?? [],\n\t\tmessage: \"app\",\n\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\ttype: \"container\",\n\t};\n\treturn snapshot;\n}\n\n/**\n * Converts a summary tree to ODSP tree\n */\nfunction convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {\n\tconst snapshotTree: IOdspSummaryTree = {\n\t\ttype: \"tree\",\n\t\tentries: [],\n\t};\n\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tlet value: OdspSummaryTreeValue;\n\t\t// Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n\t\t// property is not present, the tree entry is considered referenced. If the property is present and is true,\n\t\t// the tree entry is considered unreferenced.\n\t\tlet unreferenced: true | undefined;\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tvalue = convertSummaryToSnapshotTreeForCreateNew(summaryObject);\n\t\t\t\tunreferenced = summaryObject.unreferenced;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst content =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? summaryObject.content\n\t\t\t\t\t\t: Uint8ArrayToString(summaryObject.content, \"base64\");\n\t\t\t\tconst encoding = typeof summaryObject.content === \"string\" ? \"utf-8\" : \"base64\";\n\n\t\t\t\tvalue = {\n\t\t\t\t\ttype: \"blob\",\n\t\t\t\t\tcontent,\n\t\t\t\t\tencoding,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"No handle should be present for first summary!!\");\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unknown tree type ${summaryObject.type}`);\n\t\t\t}\n\t\t}\n\n\t\tconst entry: OdspSummaryTreeEntry = {\n\t\t\tpath: encodeURIComponent(key),\n\t\t\ttype: getGitType(summaryObject),\n\t\t\tvalue,\n\t\t\tunreferenced,\n\t\t};\n\t\tsnapshotTree.entries?.push(entry);\n\t}\n\n\treturn snapshotTree;\n}\n\nexport async function createNewFluidContainerCore<T>(args: {\n\tcontainerSnapshot: IOdspSummaryPayload;\n\tgetStorageToken: InstrumentedStorageTokenFetcher;\n\tlogger: ITelemetryLoggerExt;\n\tinitialUrl: string;\n\tforceAccessTokenViaAuthorizationHeader: boolean;\n\tepochTracker: EpochTracker;\n\ttelemetryName: string;\n\tfetchType: FetchType;\n\tvalidateResponseCallback?: (content: T) => void;\n}): Promise<T> {\n\tconst {\n\t\tcontainerSnapshot,\n\t\tgetStorageToken,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t\tepochTracker,\n\t\ttelemetryName,\n\t\tfetchType,\n\t\tvalidateResponseCallback,\n\t} = args;\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\tconst storageToken = await getStorageToken(options, telemetryName);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: telemetryName },\n\t\t\tasync (event) => {\n\t\t\t\tconst snapshotBody = JSON.stringify(containerSnapshot);\n\t\t\t\tlet url: string;\n\t\t\t\tlet headers: { [index: string]: string };\n\t\t\t\tlet addInBody = false;\n\t\t\t\tconst formBoundary = uuid();\n\t\t\t\tlet postBody = `--${formBoundary}\\r\\n`;\n\t\t\t\tpostBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n\t\t\t\tpostBody += `X-HTTP-Method-Override: POST\\r\\n`;\n\t\t\t\tpostBody += `Content-Type: application/json\\r\\n`;\n\t\t\t\tpostBody += `_post: 1\\r\\n`;\n\t\t\t\tpostBody += `\\r\\n${snapshotBody}\\r\\n`;\n\t\t\t\tpostBody += `\\r\\n--${formBoundary}--`;\n\n\t\t\t\tif (postBody.length <= maxUmpPostBodySize) {\n\t\t\t\t\tconst urlObj = new URL(initialUrl);\n\t\t\t\t\turlObj.searchParams.set(\"ump\", \"1\");\n\t\t\t\t\turl = urlObj.href;\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t\t};\n\t\t\t\t\taddInBody = true;\n\t\t\t\t} else {\n\t\t\t\t\tconst parts = getUrlAndHeadersWithAuth(\n\t\t\t\t\t\tinitialUrl,\n\t\t\t\t\t\tstorageToken,\n\t\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t);\n\t\t\t\t\turl = parts.url;\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t...parts.headers,\n\t\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t};\n\t\t\t\t\tpostBody = snapshotBody;\n\t\t\t\t}\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<T>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: postBody,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tfetchType,\n\t\t\t\t\t\t\taddInBody,\n\t\t\t\t\t\t),\n\t\t\t\t\ttelemetryName,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tvalidateResponseCallback?.(fetchResponse.content);\n\n\t\t\t\tevent.end({\n\t\t\t\t\theaders: Object.keys(headers).length !== 0 ? true : undefined,\n\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\n\t\t\t\treturn fetchResponse.content;\n\t\t\t},\n\t\t);\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAClC,+EAM8C;AAC9C,+DAGsC;AACtC,+DAAkF;AAClF,2DAA6D;AAC7D,iEAA2D;AAC3D,qEAAwF;AASxF,iDAAiF;AAEjF,+EAAyE;AACzE,mDAA+C;AAE/C;;GAEG;AACH,SAAgB,yCAAyC,CACxD,OAAqB,EACrB,MAAc;IAEd,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAiB,CAAC;IAClE,MAAM,kBAAkB,GAAG,IAAA,kDAAmC,EAAC,eAAe,CAAC,CAAC;IAChF,MAAM,cAAc,GAAG,kBAAkB,CAAC,cAAc,CAAC;IACzD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAuB,CAAC;IACpD,MAAM,YAAY,GAAG,6CAA6C,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC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CAAC,CAAC,CAAC,CAAC,CAAC;gBACjC,GAAG,aAAa,CAAC,UAAU;aAC3B,CAAC,CAAC;YAEH,OAAO,aAAa,CAAC,OAAO,CAAC;QAC9B,CAAC,CACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC;AA7FD,kEA6FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tISummaryBlob,\n\tISummaryTree,\n\tSummaryType,\n\tISnapshotTree,\n\ttype SummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { stringToBuffer, Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport { unreachableCase } from \"@fluidframework/core-utils\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshot } from \"@fluidframework/driver-definitions\";\nimport {\n\tIOdspSummaryPayload,\n\tIOdspSummaryTree,\n\tOdspSummaryTreeEntry,\n\tOdspSummaryTreeValue,\n} from \"./contracts.js\";\nimport { getWithRetryForTokenRefresh, maxUmpPostBodySize } from \"./odspUtils.js\";\nimport { EpochTracker, FetchType } from \"./epochTracker.js\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { runWithRetry } from \"./retryUtils.js\";\n\n/**\n * Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs\n */\nexport function convertCreateNewSummaryTreeToTreeAndBlobs(\n\tsummary: ISummaryTree,\n\ttreeId: string,\n): ISnapshot {\n\tconst protocolSummary = summary.tree[\".protocol\"] as ISummaryTree;\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tconst blobContents = new Map<string, ArrayBuffer>();\n\tconst snapshotTree = convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobContents);\n\tsnapshotTree.id = treeId;\n\tconst snapshotTreeValue: ISnapshot = {\n\t\tsnapshotTree,\n\t\tblobContents,\n\t\tops: [],\n\t\tsequenceNumber,\n\t\tlatestSequenceNumber: sequenceNumber,\n\t\tsnapshotFormatV: 1,\n\t};\n\n\treturn snapshotTreeValue;\n}\n\nfunction convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\tsummary: ISummaryTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISnapshotTree {\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tunreferenced: summary.unreferenced,\n\t\tgroupId: summary.groupId,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] = convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\tblobs,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tblobs.set(blobId, contentBuffer);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tthrow new Error(`No ${summaryObject.type} should be present for detached summary!`);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\t`Unknown tree type ${(summaryObject as SummaryObject).type}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\nexport function convertSummaryIntoContainerSnapshot(\n\tcreateNewSummary: ISummaryTree,\n): IOdspSummaryPayload {\n\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\tthrow new Error(\"App and protocol summary required for create new path!!\");\n\t}\n\tconst appSummary = createNewSummary.tree[\".app\"];\n\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst attributesSummaryBlob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent: JSON.stringify(documentAttributes),\n\t};\n\tprotocolSummary.tree.attributes = attributesSummaryBlob;\n\tconst convertedCreateNewSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\tconst snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);\n\tconst snapshot: IOdspSummaryPayload = {\n\t\tentries: snapshotTree.entries ?? [],\n\t\tmessage: \"app\",\n\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\ttype: \"container\",\n\t};\n\treturn snapshot;\n}\n\n/**\n * Converts a summary tree to ODSP tree\n */\nfunction convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {\n\tconst snapshotTree: IOdspSummaryTree = {\n\t\ttype: \"tree\",\n\t\tentries: [],\n\t};\n\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tlet value: OdspSummaryTreeValue;\n\t\t// Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n\t\t// property is not present, the tree entry is considered referenced. If the property is present and is true,\n\t\t// the tree entry is considered unreferenced.\n\t\tlet unreferenced: true | undefined;\n\t\tlet groupId: string | undefined;\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tvalue = convertSummaryToSnapshotTreeForCreateNew(summaryObject);\n\t\t\t\tunreferenced = summaryObject.unreferenced;\n\t\t\t\tgroupId = summaryObject.groupId;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst content =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? summaryObject.content\n\t\t\t\t\t\t: Uint8ArrayToString(summaryObject.content, \"base64\");\n\t\t\t\tconst encoding = typeof summaryObject.content === \"string\" ? \"utf-8\" : \"base64\";\n\n\t\t\t\tvalue = {\n\t\t\t\t\ttype: \"blob\",\n\t\t\t\t\tcontent,\n\t\t\t\t\tencoding,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"No handle should be present for first summary!!\");\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unknown tree type ${summaryObject.type}`);\n\t\t\t}\n\t\t}\n\n\t\tconst entry: OdspSummaryTreeEntry = {\n\t\t\tpath: encodeURIComponent(key),\n\t\t\ttype: getGitType(summaryObject),\n\t\t\tvalue,\n\t\t\tunreferenced,\n\t\t\tgroupId,\n\t\t};\n\t\tsnapshotTree.entries?.push(entry);\n\t}\n\n\treturn snapshotTree;\n}\n\nexport async function createNewFluidContainerCore<T>(args: {\n\tcontainerSnapshot: IOdspSummaryPayload;\n\tgetStorageToken: InstrumentedStorageTokenFetcher;\n\tlogger: ITelemetryLoggerExt;\n\tinitialUrl: string;\n\tforceAccessTokenViaAuthorizationHeader: boolean;\n\tepochTracker: EpochTracker;\n\ttelemetryName: string;\n\tfetchType: FetchType;\n\tvalidateResponseCallback?: (content: T) => void;\n}): Promise<T> {\n\tconst {\n\t\tcontainerSnapshot,\n\t\tgetStorageToken,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t\tepochTracker,\n\t\ttelemetryName,\n\t\tfetchType,\n\t\tvalidateResponseCallback,\n\t} = args;\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\tconst storageToken = await getStorageToken(options, telemetryName);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: telemetryName },\n\t\t\tasync (event) => {\n\t\t\t\tconst snapshotBody = JSON.stringify(containerSnapshot);\n\t\t\t\tlet url: string;\n\t\t\t\tlet headers: { [index: string]: string };\n\t\t\t\tlet addInBody = false;\n\t\t\t\tconst formBoundary = uuid();\n\t\t\t\tlet postBody = `--${formBoundary}\\r\\n`;\n\t\t\t\tpostBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n\t\t\t\tpostBody += `X-HTTP-Method-Override: POST\\r\\n`;\n\t\t\t\tpostBody += `Content-Type: application/json\\r\\n`;\n\t\t\t\tpostBody += `_post: 1\\r\\n`;\n\t\t\t\tpostBody += `\\r\\n${snapshotBody}\\r\\n`;\n\t\t\t\tpostBody += `\\r\\n--${formBoundary}--`;\n\n\t\t\t\tif (postBody.length <= maxUmpPostBodySize) {\n\t\t\t\t\tconst urlObj = new URL(initialUrl);\n\t\t\t\t\turlObj.searchParams.set(\"ump\", \"1\");\n\t\t\t\t\turl = urlObj.href;\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t\t};\n\t\t\t\t\taddInBody = true;\n\t\t\t\t} else {\n\t\t\t\t\tconst parts = getUrlAndHeadersWithAuth(\n\t\t\t\t\t\tinitialUrl,\n\t\t\t\t\t\tstorageToken,\n\t\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t);\n\t\t\t\t\turl = parts.url;\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t...parts.headers,\n\t\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t};\n\t\t\t\t\tpostBody = snapshotBody;\n\t\t\t\t}\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<T>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: postBody,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tfetchType,\n\t\t\t\t\t\t\taddInBody,\n\t\t\t\t\t\t),\n\t\t\t\t\ttelemetryName,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tvalidateResponseCallback?.(fetchResponse.content);\n\n\t\t\t\tevent.end({\n\t\t\t\t\theaders: Object.keys(headers).length > 0 ? true : undefined,\n\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\n\t\t\t\treturn fetchResponse.content;\n\t\t\t},\n\t\t);\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOdspCreateContainerRequest.d.ts","sourceRoot":"","sources":["../src/createOdspCreateContainerRequest.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"createOdspCreateContainerRequest.d.ts","sourceRoot":"","sources":["../src/createOdspCreateContainerRequest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAG3E;;;;;;;;;GASG;AACH,wBAAgB,gCAAgC,CAC/C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE,gBAAgB,GACpC,QAAQ,CAaV"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
7
|
exports.createOdspCreateContainerRequest = void 0;
|
|
4
8
|
const driver_definitions_1 = require("@fluidframework/driver-definitions");
|
|
5
|
-
const
|
|
9
|
+
const odspUtils_js_1 = require("./odspUtils.js");
|
|
6
10
|
/**
|
|
7
11
|
* Create the request object with url and headers for creating a new file on OneDrive Sharepoint
|
|
8
12
|
* @param siteUrl - Base url for OneDrive
|
|
@@ -14,7 +18,7 @@ const odspUtils_1 = require("./odspUtils");
|
|
|
14
18
|
* @alpha
|
|
15
19
|
*/
|
|
16
20
|
function createOdspCreateContainerRequest(siteUrl, driveId, filePath, fileName, createShareLinkType) {
|
|
17
|
-
const shareLinkRequestParams = (0,
|
|
21
|
+
const shareLinkRequestParams = (0, odspUtils_js_1.buildOdspShareLinkReqParams)(createShareLinkType);
|
|
18
22
|
const createNewRequest = {
|
|
19
23
|
url: `${siteUrl}?driveId=${encodeURIComponent(driveId)}&path=${encodeURIComponent(filePath)}${shareLinkRequestParams ? `&${shareLinkRequestParams}` : ""}`,
|
|
20
24
|
headers: {
|