@webiny/api-headless-cms-import-export 5.41.0-beta.0
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/LICENSE +21 -0
- package/README.md +15 -0
- package/crud/index.d.ts +2 -0
- package/crud/index.js +125 -0
- package/crud/index.js.map +1 -0
- package/crud/useCases/abortExportContentEntries/AbortExportContentEntriesUseCase.d.ts +11 -0
- package/crud/useCases/abortExportContentEntries/AbortExportContentEntriesUseCase.js +21 -0
- package/crud/useCases/abortExportContentEntries/AbortExportContentEntriesUseCase.js.map +1 -0
- package/crud/useCases/abortExportContentEntries/abstractions/AbortExportContentEntriesUseCase.d.ts +7 -0
- package/crud/useCases/abortExportContentEntries/abstractions/AbortExportContentEntriesUseCase.js +7 -0
- package/crud/useCases/abortExportContentEntries/abstractions/AbortExportContentEntriesUseCase.js.map +1 -0
- package/crud/useCases/abortExportContentEntries/index.d.ts +2 -0
- package/crud/useCases/abortExportContentEntries/index.js +29 -0
- package/crud/useCases/abortExportContentEntries/index.js.map +1 -0
- package/crud/useCases/abortImportFromUrl/AbortImportFromUrlUseCase.d.ts +14 -0
- package/crud/useCases/abortImportFromUrl/AbortImportFromUrlUseCase.js +31 -0
- package/crud/useCases/abortImportFromUrl/AbortImportFromUrlUseCase.js.map +1 -0
- package/crud/useCases/abortImportFromUrl/abstractions/AbortImportFromUrlUseCase.d.ts +7 -0
- package/crud/useCases/abortImportFromUrl/abstractions/AbortImportFromUrlUseCase.js +7 -0
- package/crud/useCases/abortImportFromUrl/abstractions/AbortImportFromUrlUseCase.js.map +1 -0
- package/crud/useCases/abortImportFromUrl/index.d.ts +2 -0
- package/crud/useCases/abortImportFromUrl/index.js +29 -0
- package/crud/useCases/abortImportFromUrl/index.js.map +1 -0
- package/crud/useCases/exportContentEntries/ExportContentEntriesUseCase.d.ts +11 -0
- package/crud/useCases/exportContentEntries/ExportContentEntriesUseCase.js +30 -0
- package/crud/useCases/exportContentEntries/ExportContentEntriesUseCase.js.map +1 -0
- package/crud/useCases/exportContentEntries/abstractions/ExportContentEntriesUseCase.d.ts +12 -0
- package/crud/useCases/exportContentEntries/abstractions/ExportContentEntriesUseCase.js +7 -0
- package/crud/useCases/exportContentEntries/abstractions/ExportContentEntriesUseCase.js.map +1 -0
- package/crud/useCases/exportContentEntries/index.d.ts +2 -0
- package/crud/useCases/exportContentEntries/index.js +29 -0
- package/crud/useCases/exportContentEntries/index.js.map +1 -0
- package/crud/useCases/getExportContentEntries/GetExportContentEntriesUseCase.d.ts +13 -0
- package/crud/useCases/getExportContentEntries/GetExportContentEntriesUseCase.js +52 -0
- package/crud/useCases/getExportContentEntries/GetExportContentEntriesUseCase.js.map +1 -0
- package/crud/useCases/getExportContentEntries/abstractions/GetExportContentEntriesUseCase.d.ts +8 -0
- package/crud/useCases/getExportContentEntries/abstractions/GetExportContentEntriesUseCase.js +7 -0
- package/crud/useCases/getExportContentEntries/abstractions/GetExportContentEntriesUseCase.js.map +1 -0
- package/crud/useCases/getExportContentEntries/index.d.ts +2 -0
- package/crud/useCases/getExportContentEntries/index.js +29 -0
- package/crud/useCases/getExportContentEntries/index.js.map +1 -0
- package/crud/useCases/getImportFromUrl/GetImportFromUrlUseCase.d.ts +11 -0
- package/crud/useCases/getImportFromUrl/GetImportFromUrlUseCase.js +23 -0
- package/crud/useCases/getImportFromUrl/GetImportFromUrlUseCase.js.map +1 -0
- package/crud/useCases/getImportFromUrl/abstractions/GetImportFromUrlUseCase.d.ts +4 -0
- package/crud/useCases/getImportFromUrl/abstractions/GetImportFromUrlUseCase.js +7 -0
- package/crud/useCases/getImportFromUrl/abstractions/GetImportFromUrlUseCase.js.map +1 -0
- package/crud/useCases/getImportFromUrl/index.d.ts +2 -0
- package/crud/useCases/getImportFromUrl/index.js +29 -0
- package/crud/useCases/getImportFromUrl/index.js.map +1 -0
- package/crud/useCases/getValidateImportFromUrl/GetValidateImportFromUrlUseCase.d.ts +10 -0
- package/crud/useCases/getValidateImportFromUrl/GetValidateImportFromUrlUseCase.js +23 -0
- package/crud/useCases/getValidateImportFromUrl/GetValidateImportFromUrlUseCase.js.map +1 -0
- package/crud/useCases/getValidateImportFromUrl/abstractions/GetValidateImportFromUrlUseCase.d.ts +8 -0
- package/crud/useCases/getValidateImportFromUrl/abstractions/GetValidateImportFromUrlUseCase.js +7 -0
- package/crud/useCases/getValidateImportFromUrl/abstractions/GetValidateImportFromUrlUseCase.js.map +1 -0
- package/crud/useCases/getValidateImportFromUrl/index.d.ts +2 -0
- package/crud/useCases/getValidateImportFromUrl/index.js +29 -0
- package/crud/useCases/getValidateImportFromUrl/index.js.map +1 -0
- package/crud/useCases/importFromUrl/ImportFromUrlUseCase.d.ts +14 -0
- package/crud/useCases/importFromUrl/ImportFromUrlUseCase.js +84 -0
- package/crud/useCases/importFromUrl/ImportFromUrlUseCase.js.map +1 -0
- package/crud/useCases/importFromUrl/abstractions/ImportFromUrlUseCase.d.ts +18 -0
- package/crud/useCases/importFromUrl/abstractions/ImportFromUrlUseCase.js +7 -0
- package/crud/useCases/importFromUrl/abstractions/ImportFromUrlUseCase.js.map +1 -0
- package/crud/useCases/importFromUrl/index.d.ts +2 -0
- package/crud/useCases/importFromUrl/index.js +29 -0
- package/crud/useCases/importFromUrl/index.js.map +1 -0
- package/crud/useCases/index.d.ts +9 -0
- package/crud/useCases/index.js +106 -0
- package/crud/useCases/index.js.map +1 -0
- package/crud/useCases/listExportContentEntries/ListExportContentEntriesUseCase.d.ts +10 -0
- package/crud/useCases/listExportContentEntries/ListExportContentEntriesUseCase.js +29 -0
- package/crud/useCases/listExportContentEntries/ListExportContentEntriesUseCase.js.map +1 -0
- package/crud/useCases/listExportContentEntries/abstractions/ListExportContentEntriesUseCase.d.ts +6 -0
- package/crud/useCases/listExportContentEntries/abstractions/ListExportContentEntriesUseCase.js +7 -0
- package/crud/useCases/listExportContentEntries/abstractions/ListExportContentEntriesUseCase.js.map +1 -0
- package/crud/useCases/listExportContentEntries/index.d.ts +2 -0
- package/crud/useCases/listExportContentEntries/index.js +29 -0
- package/crud/useCases/listExportContentEntries/index.js.map +1 -0
- package/crud/useCases/validateImportFromUrl/ValidateImportFromUrlUseCase.d.ts +12 -0
- package/crud/useCases/validateImportFromUrl/ValidateImportFromUrlUseCase.js +80 -0
- package/crud/useCases/validateImportFromUrl/ValidateImportFromUrlUseCase.js.map +1 -0
- package/crud/useCases/validateImportFromUrl/abstractions/ValidateImportFromUrlUseCase.d.ts +13 -0
- package/crud/useCases/validateImportFromUrl/abstractions/ValidateImportFromUrlUseCase.js +7 -0
- package/crud/useCases/validateImportFromUrl/abstractions/ValidateImportFromUrlUseCase.js.map +1 -0
- package/crud/useCases/validateImportFromUrl/index.d.ts +2 -0
- package/crud/useCases/validateImportFromUrl/index.js +29 -0
- package/crud/useCases/validateImportFromUrl/index.js.map +1 -0
- package/crud/useCases/validateImportFromUrlIntegrity/ValidateImportFromUrlIntegrityUseCase.d.ts +10 -0
- package/crud/useCases/validateImportFromUrlIntegrity/ValidateImportFromUrlIntegrityUseCase.js +33 -0
- package/crud/useCases/validateImportFromUrlIntegrity/ValidateImportFromUrlIntegrityUseCase.js.map +1 -0
- package/crud/useCases/validateImportFromUrlIntegrity/abstractions/ValidateImportFromUrlIntegrityUseCase.d.ts +15 -0
- package/crud/useCases/validateImportFromUrlIntegrity/abstractions/ValidateImportFromUrlIntegrityUseCase.js +7 -0
- package/crud/useCases/validateImportFromUrlIntegrity/abstractions/ValidateImportFromUrlIntegrityUseCase.js.map +1 -0
- package/crud/useCases/validateImportFromUrlIntegrity/index.d.ts +2 -0
- package/crud/useCases/validateImportFromUrlIntegrity/index.js +29 -0
- package/crud/useCases/validateImportFromUrlIntegrity/index.js.map +1 -0
- package/crud/utils/convertTaskToExportRecord.d.ts +3 -0
- package/crud/utils/convertTaskToExportRecord.js +22 -0
- package/crud/utils/convertTaskToExportRecord.js.map +1 -0
- package/crud/utils/convertTaskToImportRecord.d.ts +4 -0
- package/crud/utils/convertTaskToImportRecord.js +20 -0
- package/crud/utils/convertTaskToImportRecord.js.map +1 -0
- package/crud/utils/convertTaskToValidateImportFromUrlRecord.d.ts +3 -0
- package/crud/utils/convertTaskToValidateImportFromUrlRecord.js +30 -0
- package/crud/utils/convertTaskToValidateImportFromUrlRecord.js.map +1 -0
- package/crud/utils/makeSureModelsAreIdentical.d.ts +8 -0
- package/crud/utils/makeSureModelsAreIdentical.js +70 -0
- package/crud/utils/makeSureModelsAreIdentical.js.map +1 -0
- package/crud/utils/parseImportUrlData.d.ts +8 -0
- package/crud/utils/parseImportUrlData.js +56 -0
- package/crud/utils/parseImportUrlData.js.map +1 -0
- package/domain/CmsImportExportRecord.d.ts +14 -0
- package/domain/CmsImportExportRecord.js +25 -0
- package/domain/CmsImportExportRecord.js.map +1 -0
- package/domain/CmsImportExportValidateRecord.d.ts +12 -0
- package/domain/CmsImportExportValidateRecord.js +21 -0
- package/domain/CmsImportExportValidateRecord.js.map +1 -0
- package/domain/abstractions/CmsImportExportRecord.d.ts +18 -0
- package/domain/abstractions/CmsImportExportRecord.js +7 -0
- package/domain/abstractions/CmsImportExportRecord.js.map +1 -0
- package/domain/abstractions/CmsImportExportValidateRecord.d.ts +9 -0
- package/domain/abstractions/CmsImportExportValidateRecord.js +7 -0
- package/domain/abstractions/CmsImportExportValidateRecord.js.map +1 -0
- package/domain/index.d.ts +4 -0
- package/domain/index.js +51 -0
- package/domain/index.js.map +1 -0
- package/graphql/index.d.ts +2 -0
- package/graphql/index.js +25 -0
- package/graphql/index.js.map +1 -0
- package/graphql/models.d.ts +3 -0
- package/graphql/models.js +21 -0
- package/graphql/models.js.map +1 -0
- package/graphql/resolvers.d.ts +17 -0
- package/graphql/resolvers.js +159 -0
- package/graphql/resolvers.js.map +1 -0
- package/graphql/security.d.ts +2 -0
- package/graphql/security.js +22 -0
- package/graphql/security.js.map +1 -0
- package/graphql/typeDefs.d.ts +3 -0
- package/graphql/typeDefs.js +169 -0
- package/graphql/typeDefs.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +27 -0
- package/index.js.map +1 -0
- package/package.json +66 -0
- package/tasks/constants.d.ts +13 -0
- package/tasks/constants.js +21 -0
- package/tasks/constants.js.map +1 -0
- package/tasks/domain/ExportContentEntriesController.d.ts +8 -0
- package/tasks/domain/ExportContentEntriesController.js +249 -0
- package/tasks/domain/ExportContentEntriesController.js.map +1 -0
- package/tasks/domain/ImportFromUrlController.d.ts +6 -0
- package/tasks/domain/ImportFromUrlController.js +97 -0
- package/tasks/domain/ImportFromUrlController.js.map +1 -0
- package/tasks/domain/ImportFromUrlDownload.d.ts +6 -0
- package/tasks/domain/ImportFromUrlDownload.js +109 -0
- package/tasks/domain/ImportFromUrlDownload.js.map +1 -0
- package/tasks/domain/abstractions/ExportContentAssets.d.ts +27 -0
- package/tasks/domain/abstractions/ExportContentAssets.js +7 -0
- package/tasks/domain/abstractions/ExportContentAssets.js.map +1 -0
- package/tasks/domain/abstractions/ExportContentEntries.d.ts +29 -0
- package/tasks/domain/abstractions/ExportContentEntries.js +7 -0
- package/tasks/domain/abstractions/ExportContentEntries.js.map +1 -0
- package/tasks/domain/abstractions/ExportContentEntriesController.d.ts +34 -0
- package/tasks/domain/abstractions/ExportContentEntriesController.js +13 -0
- package/tasks/domain/abstractions/ExportContentEntriesController.js.map +1 -0
- package/tasks/domain/abstractions/ImportFromUrlController.d.ts +41 -0
- package/tasks/domain/abstractions/ImportFromUrlController.js +14 -0
- package/tasks/domain/abstractions/ImportFromUrlController.js.map +1 -0
- package/tasks/domain/abstractions/ImportFromUrlDownload.d.ts +15 -0
- package/tasks/domain/abstractions/ImportFromUrlDownload.js +7 -0
- package/tasks/domain/abstractions/ImportFromUrlDownload.js.map +1 -0
- package/tasks/domain/abstractions/ValidateImportFromUrl.d.ts +16 -0
- package/tasks/domain/abstractions/ValidateImportFromUrl.js +7 -0
- package/tasks/domain/abstractions/ValidateImportFromUrl.js.map +1 -0
- package/tasks/domain/createExportContentAssets.d.ts +2 -0
- package/tasks/domain/createExportContentAssets.js +55 -0
- package/tasks/domain/createExportContentAssets.js.map +1 -0
- package/tasks/domain/createExportContentEntries.d.ts +2 -0
- package/tasks/domain/createExportContentEntries.js +56 -0
- package/tasks/domain/createExportContentEntries.js.map +1 -0
- package/tasks/domain/createImportFromUrlProcessAssets.d.ts +3 -0
- package/tasks/domain/createImportFromUrlProcessAssets.js +42 -0
- package/tasks/domain/createImportFromUrlProcessAssets.js.map +1 -0
- package/tasks/domain/createImportFromUrlProcessEntries.d.ts +3 -0
- package/tasks/domain/createImportFromUrlProcessEntries.js +42 -0
- package/tasks/domain/createImportFromUrlProcessEntries.js.map +1 -0
- package/tasks/domain/createValidateImportFromUrl.d.ts +2 -0
- package/tasks/domain/createValidateImportFromUrl.js +30 -0
- package/tasks/domain/createValidateImportFromUrl.js.map +1 -0
- package/tasks/domain/downloadFileFromUrl/DownloadFileFromUrl.d.ts +26 -0
- package/tasks/domain/downloadFileFromUrl/DownloadFileFromUrl.js +79 -0
- package/tasks/domain/downloadFileFromUrl/DownloadFileFromUrl.js.map +1 -0
- package/tasks/domain/downloadFileFromUrl/abstractions/DownloadFileFromUrl.d.ts +19 -0
- package/tasks/domain/downloadFileFromUrl/abstractions/DownloadFileFromUrl.js +7 -0
- package/tasks/domain/downloadFileFromUrl/abstractions/DownloadFileFromUrl.js.map +1 -0
- package/tasks/domain/downloadFileFromUrl/index.d.ts +2 -0
- package/tasks/domain/downloadFileFromUrl/index.js +29 -0
- package/tasks/domain/downloadFileFromUrl/index.js.map +1 -0
- package/tasks/domain/exportContentAssets/ExportContentAssets.d.ts +25 -0
- package/tasks/domain/exportContentAssets/ExportContentAssets.js +164 -0
- package/tasks/domain/exportContentAssets/ExportContentAssets.js.map +1 -0
- package/tasks/domain/exportContentEntries/ExportContentEntries.d.ts +19 -0
- package/tasks/domain/exportContentEntries/ExportContentEntries.js +87 -0
- package/tasks/domain/exportContentEntries/ExportContentEntries.js.map +1 -0
- package/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerDownloadStep.d.ts +7 -0
- package/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerDownloadStep.js +123 -0
- package/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerDownloadStep.js.map +1 -0
- package/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerProcessAssetsStep.d.ts +7 -0
- package/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerProcessAssetsStep.js +123 -0
- package/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerProcessAssetsStep.js.map +1 -0
- package/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerProcessEntriesStep.d.ts +7 -0
- package/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerProcessEntriesStep.js +123 -0
- package/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerProcessEntriesStep.js.map +1 -0
- package/tasks/domain/importFromUrlControllerSteps/abstractions/ImportFromUrlControllerStep.d.ts +6 -0
- package/tasks/domain/importFromUrlControllerSteps/abstractions/ImportFromUrlControllerStep.js +7 -0
- package/tasks/domain/importFromUrlControllerSteps/abstractions/ImportFromUrlControllerStep.js.map +1 -0
- package/tasks/domain/importFromUrlControllerSteps/getChildTasks.d.ts +15 -0
- package/tasks/domain/importFromUrlControllerSteps/getChildTasks.js +92 -0
- package/tasks/domain/importFromUrlControllerSteps/getChildTasks.js.map +1 -0
- package/tasks/domain/importFromUrlProcessAssets/ImportFromUrlProcessAssets.d.ts +19 -0
- package/tasks/domain/importFromUrlProcessAssets/ImportFromUrlProcessAssets.js +265 -0
- package/tasks/domain/importFromUrlProcessAssets/ImportFromUrlProcessAssets.js.map +1 -0
- package/tasks/domain/importFromUrlProcessAssets/abstractions/ImportFromUrlProcessAssets.d.ts +20 -0
- package/tasks/domain/importFromUrlProcessAssets/abstractions/ImportFromUrlProcessAssets.js +7 -0
- package/tasks/domain/importFromUrlProcessAssets/abstractions/ImportFromUrlProcessAssets.js.map +1 -0
- package/tasks/domain/importFromUrlProcessEntries/ImportFromUrlProcessEntries.d.ts +17 -0
- package/tasks/domain/importFromUrlProcessEntries/ImportFromUrlProcessEntries.js +82 -0
- package/tasks/domain/importFromUrlProcessEntries/ImportFromUrlProcessEntries.js.map +1 -0
- package/tasks/domain/importFromUrlProcessEntries/ImportFromUrlProcessEntriesDecompress.d.ts +14 -0
- package/tasks/domain/importFromUrlProcessEntries/ImportFromUrlProcessEntriesDecompress.js +79 -0
- package/tasks/domain/importFromUrlProcessEntries/ImportFromUrlProcessEntriesDecompress.js.map +1 -0
- package/tasks/domain/importFromUrlProcessEntries/ImportFromUrlProcessEntriesInsert.d.ts +22 -0
- package/tasks/domain/importFromUrlProcessEntries/ImportFromUrlProcessEntriesInsert.js +163 -0
- package/tasks/domain/importFromUrlProcessEntries/ImportFromUrlProcessEntriesInsert.js.map +1 -0
- package/tasks/domain/importFromUrlProcessEntries/abstractions/ImportFromUrlProcessEntries.d.ts +46 -0
- package/tasks/domain/importFromUrlProcessEntries/abstractions/ImportFromUrlProcessEntries.js +7 -0
- package/tasks/domain/importFromUrlProcessEntries/abstractions/ImportFromUrlProcessEntries.js.map +1 -0
- package/tasks/domain/importFromUrlProcessEntries/abstractions/ImportFromUrlProcessEntriesDecompress.d.ts +8 -0
- package/tasks/domain/importFromUrlProcessEntries/abstractions/ImportFromUrlProcessEntriesDecompress.js +7 -0
- package/tasks/domain/importFromUrlProcessEntries/abstractions/ImportFromUrlProcessEntriesDecompress.js.map +1 -0
- package/tasks/domain/importFromUrlProcessEntries/abstractions/ImportFromUrlProcessEntriesInsert.d.ts +8 -0
- package/tasks/domain/importFromUrlProcessEntries/abstractions/ImportFromUrlProcessEntriesInsert.js +7 -0
- package/tasks/domain/importFromUrlProcessEntries/abstractions/ImportFromUrlProcessEntriesInsert.js.map +1 -0
- package/tasks/domain/validateImportFromUrl/ValidateImportFromUrl.d.ts +17 -0
- package/tasks/domain/validateImportFromUrl/ValidateImportFromUrl.js +167 -0
- package/tasks/domain/validateImportFromUrl/ValidateImportFromUrl.js.map +1 -0
- package/tasks/exportContentAssets.d.ts +3 -0
- package/tasks/exportContentAssets.js +31 -0
- package/tasks/exportContentAssets.js.map +1 -0
- package/tasks/exportContentEntries.d.ts +3 -0
- package/tasks/exportContentEntries.js +31 -0
- package/tasks/exportContentEntries.js.map +1 -0
- package/tasks/exportContentEntriesController.d.ts +3 -0
- package/tasks/exportContentEntriesController.js +31 -0
- package/tasks/exportContentEntriesController.js.map +1 -0
- package/tasks/importFromUrlController.d.ts +3 -0
- package/tasks/importFromUrlController.js +40 -0
- package/tasks/importFromUrlController.js.map +1 -0
- package/tasks/importFromUrlDownload.d.ts +3 -0
- package/tasks/importFromUrlDownload.js +31 -0
- package/tasks/importFromUrlDownload.js.map +1 -0
- package/tasks/importFromUrlProcessAssets.d.ts +3 -0
- package/tasks/importFromUrlProcessAssets.js +31 -0
- package/tasks/importFromUrlProcessAssets.js.map +1 -0
- package/tasks/importFromUrlProcessEntries.d.ts +3 -0
- package/tasks/importFromUrlProcessEntries.js +31 -0
- package/tasks/importFromUrlProcessEntries.js.map +1 -0
- package/tasks/index.d.ts +8 -0
- package/tasks/index.js +95 -0
- package/tasks/index.js.map +1 -0
- package/tasks/utils/archiver/Archiver.d.ts +11 -0
- package/tasks/utils/archiver/Archiver.js +19 -0
- package/tasks/utils/archiver/Archiver.js.map +1 -0
- package/tasks/utils/archiver/abstractions/Archiver.d.ts +4 -0
- package/tasks/utils/archiver/abstractions/Archiver.js +7 -0
- package/tasks/utils/archiver/abstractions/Archiver.js.map +1 -0
- package/tasks/utils/archiver/index.d.ts +2 -0
- package/tasks/utils/archiver/index.js +29 -0
- package/tasks/utils/archiver/index.js.map +1 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipper.d.ts +21 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipper.js +245 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipper.js.map +1 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteContinueResult.d.ts +8 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteContinueResult.js +17 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteContinueResult.js.map +1 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteContinueWithoutResult.d.ts +6 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteContinueWithoutResult.js +15 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteContinueWithoutResult.js.map +1 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteDoneResult.d.ts +6 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteDoneResult.js +15 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteDoneResult.js.map +1 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteDoneWithoutResult.d.ts +3 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteDoneWithoutResult.js +14 -0
- package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteDoneWithoutResult.js.map +1 -0
- package/tasks/utils/cmsAssetsZipper/PointerStore.d.ts +25 -0
- package/tasks/utils/cmsAssetsZipper/PointerStore.js +63 -0
- package/tasks/utils/cmsAssetsZipper/PointerStore.js.map +1 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipper.d.ts +15 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipper.js +7 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipper.js.map +1 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipperExecuteContinueResult.d.ts +6 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipperExecuteContinueResult.js +7 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipperExecuteContinueResult.js.map +1 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipperExecuteContinueWithoutResult.d.ts +4 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipperExecuteContinueWithoutResult.js +7 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipperExecuteContinueWithoutResult.js.map +1 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipperExecuteDoneResult.d.ts +4 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipperExecuteDoneResult.js +7 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipperExecuteDoneResult.js.map +1 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipperExecuteDoneWithoutResult.d.ts +2 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipperExecuteDoneWithoutResult.js +7 -0
- package/tasks/utils/cmsAssetsZipper/abstractions/CmsAssetsZipperExecuteDoneWithoutResult.js.map +1 -0
- package/tasks/utils/cmsAssetsZipper/index.d.ts +10 -0
- package/tasks/utils/cmsAssetsZipper/index.js +117 -0
- package/tasks/utils/cmsAssetsZipper/index.js.map +1 -0
- package/tasks/utils/cmsEntryFetcher/abstractions/CmsEntryFetcher.d.ts +8 -0
- package/tasks/utils/cmsEntryFetcher/abstractions/CmsEntryFetcher.js +7 -0
- package/tasks/utils/cmsEntryFetcher/abstractions/CmsEntryFetcher.js.map +1 -0
- package/tasks/utils/cmsEntryFetcher/createCmsEntryFetcher.d.ts +2 -0
- package/tasks/utils/cmsEntryFetcher/createCmsEntryFetcher.js +12 -0
- package/tasks/utils/cmsEntryFetcher/createCmsEntryFetcher.js.map +1 -0
- package/tasks/utils/cmsEntryFetcher/index.d.ts +2 -0
- package/tasks/utils/cmsEntryFetcher/index.js +29 -0
- package/tasks/utils/cmsEntryFetcher/index.js.map +1 -0
- package/tasks/utils/cmsEntryZipper/CmsEntryZipper.d.ts +19 -0
- package/tasks/utils/cmsEntryZipper/CmsEntryZipper.js +172 -0
- package/tasks/utils/cmsEntryZipper/CmsEntryZipper.js.map +1 -0
- package/tasks/utils/cmsEntryZipper/CmsEntryZipperExecuteContinueResult.d.ts +7 -0
- package/tasks/utils/cmsEntryZipper/CmsEntryZipperExecuteContinueResult.js +16 -0
- package/tasks/utils/cmsEntryZipper/CmsEntryZipperExecuteContinueResult.js.map +1 -0
- package/tasks/utils/cmsEntryZipper/CmsEntryZipperExecuteDoneResult.d.ts +6 -0
- package/tasks/utils/cmsEntryZipper/CmsEntryZipperExecuteDoneResult.js +15 -0
- package/tasks/utils/cmsEntryZipper/CmsEntryZipperExecuteDoneResult.js.map +1 -0
- package/tasks/utils/cmsEntryZipper/abstractions/CmsEntryZipper.d.ts +15 -0
- package/tasks/utils/cmsEntryZipper/abstractions/CmsEntryZipper.js +7 -0
- package/tasks/utils/cmsEntryZipper/abstractions/CmsEntryZipper.js.map +1 -0
- package/tasks/utils/cmsEntryZipper/abstractions/CmsEntryZipperExecuteContinueResult.d.ts +5 -0
- package/tasks/utils/cmsEntryZipper/abstractions/CmsEntryZipperExecuteContinueResult.js +7 -0
- package/tasks/utils/cmsEntryZipper/abstractions/CmsEntryZipperExecuteContinueResult.js.map +1 -0
- package/tasks/utils/cmsEntryZipper/abstractions/CmsEntryZipperExecuteDoneResult.d.ts +4 -0
- package/tasks/utils/cmsEntryZipper/abstractions/CmsEntryZipperExecuteDoneResult.js +7 -0
- package/tasks/utils/cmsEntryZipper/abstractions/CmsEntryZipperExecuteDoneResult.js.map +1 -0
- package/tasks/utils/cmsEntryZipper/index.d.ts +6 -0
- package/tasks/utils/cmsEntryZipper/index.js +73 -0
- package/tasks/utils/cmsEntryZipper/index.js.map +1 -0
- package/tasks/utils/decompressor/CompressedFileReader.d.ts +14 -0
- package/tasks/utils/decompressor/CompressedFileReader.js +29 -0
- package/tasks/utils/decompressor/CompressedFileReader.js.map +1 -0
- package/tasks/utils/decompressor/Decompressor.d.ts +18 -0
- package/tasks/utils/decompressor/Decompressor.js +95 -0
- package/tasks/utils/decompressor/Decompressor.js.map +1 -0
- package/tasks/utils/decompressor/abstractions/CompressedFileReader.d.ts +4 -0
- package/tasks/utils/decompressor/abstractions/CompressedFileReader.js +7 -0
- package/tasks/utils/decompressor/abstractions/CompressedFileReader.js.map +1 -0
- package/tasks/utils/decompressor/abstractions/Decompressor.d.ts +11 -0
- package/tasks/utils/decompressor/abstractions/Decompressor.js +7 -0
- package/tasks/utils/decompressor/abstractions/Decompressor.js.map +1 -0
- package/tasks/utils/decompressor/index.d.ts +4 -0
- package/tasks/utils/decompressor/index.js +51 -0
- package/tasks/utils/decompressor/index.js.map +1 -0
- package/tasks/utils/deleteFiles/DeleteFiles.d.ts +11 -0
- package/tasks/utils/deleteFiles/DeleteFiles.js +53 -0
- package/tasks/utils/deleteFiles/DeleteFiles.js.map +1 -0
- package/tasks/utils/deleteFiles/abstractions/DeleteFiles.d.ts +8 -0
- package/tasks/utils/deleteFiles/abstractions/DeleteFiles.js +7 -0
- package/tasks/utils/deleteFiles/abstractions/DeleteFiles.js.map +1 -0
- package/tasks/utils/entryAssets/EntryAssets.d.ts +15 -0
- package/tasks/utils/entryAssets/EntryAssets.js +69 -0
- package/tasks/utils/entryAssets/EntryAssets.js.map +1 -0
- package/tasks/utils/entryAssets/EntryAssetsResolver.d.ts +18 -0
- package/tasks/utils/entryAssets/EntryAssetsResolver.js +88 -0
- package/tasks/utils/entryAssets/EntryAssetsResolver.js.map +1 -0
- package/tasks/utils/entryAssets/abstractions/EntryAssets.d.ts +22 -0
- package/tasks/utils/entryAssets/abstractions/EntryAssets.js +7 -0
- package/tasks/utils/entryAssets/abstractions/EntryAssets.js.map +1 -0
- package/tasks/utils/entryAssets/abstractions/EntryAssetsResolver.d.ts +6 -0
- package/tasks/utils/entryAssets/abstractions/EntryAssetsResolver.js +7 -0
- package/tasks/utils/entryAssets/abstractions/EntryAssetsResolver.js.map +1 -0
- package/tasks/utils/entryAssets/index.d.ts +4 -0
- package/tasks/utils/entryAssets/index.js +51 -0
- package/tasks/utils/entryAssets/index.js.map +1 -0
- package/tasks/utils/externalFileFetcher/ExternalFileFetcher.d.ts +18 -0
- package/tasks/utils/externalFileFetcher/ExternalFileFetcher.js +120 -0
- package/tasks/utils/externalFileFetcher/ExternalFileFetcher.js.map +1 -0
- package/tasks/utils/externalFileFetcher/abstractions/ExternalFileFetcher.d.ts +40 -0
- package/tasks/utils/externalFileFetcher/abstractions/ExternalFileFetcher.js +7 -0
- package/tasks/utils/externalFileFetcher/abstractions/ExternalFileFetcher.js.map +1 -0
- package/tasks/utils/externalFileFetcher/index.d.ts +2 -0
- package/tasks/utils/externalFileFetcher/index.js +29 -0
- package/tasks/utils/externalFileFetcher/index.js.map +1 -0
- package/tasks/utils/fileFetcher/FileFetcher.d.ts +18 -0
- package/tasks/utils/fileFetcher/FileFetcher.js +120 -0
- package/tasks/utils/fileFetcher/FileFetcher.js.map +1 -0
- package/tasks/utils/fileFetcher/abstractions/FileFetcher.d.ts +41 -0
- package/tasks/utils/fileFetcher/abstractions/FileFetcher.js +7 -0
- package/tasks/utils/fileFetcher/abstractions/FileFetcher.js.map +1 -0
- package/tasks/utils/fileFetcher/index.d.ts +2 -0
- package/tasks/utils/fileFetcher/index.js +29 -0
- package/tasks/utils/fileFetcher/index.js.map +1 -0
- package/tasks/utils/helpers/cleanChecksum.d.ts +1 -0
- package/tasks/utils/helpers/cleanChecksum.js +12 -0
- package/tasks/utils/helpers/cleanChecksum.js.map +1 -0
- package/tasks/utils/helpers/exportPath.d.ts +2 -0
- package/tasks/utils/helpers/exportPath.js +17 -0
- package/tasks/utils/helpers/exportPath.js.map +1 -0
- package/tasks/utils/helpers/getBackOffSeconds.d.ts +7 -0
- package/tasks/utils/helpers/getBackOffSeconds.js +18 -0
- package/tasks/utils/helpers/getBackOffSeconds.js.map +1 -0
- package/tasks/utils/helpers/getBucket.d.ts +1 -0
- package/tasks/utils/helpers/getBucket.js +17 -0
- package/tasks/utils/helpers/getBucket.js.map +1 -0
- package/tasks/utils/helpers/getFilePath.d.ts +5 -0
- package/tasks/utils/helpers/getFilePath.js +23 -0
- package/tasks/utils/helpers/getFilePath.js.map +1 -0
- package/tasks/utils/helpers/getImportExportFileType.d.ts +14 -0
- package/tasks/utils/helpers/getImportExportFileType.js +41 -0
- package/tasks/utils/helpers/getImportExportFileType.js.map +1 -0
- package/tasks/utils/helpers/importPath.d.ts +2 -0
- package/tasks/utils/helpers/importPath.js +17 -0
- package/tasks/utils/helpers/importPath.js.map +1 -0
- package/tasks/utils/helpers/matchKeyOrAlias.d.ts +10 -0
- package/tasks/utils/helpers/matchKeyOrAlias.js +37 -0
- package/tasks/utils/helpers/matchKeyOrAlias.js.map +1 -0
- package/tasks/utils/helpers/s3Client.d.ts +3 -0
- package/tasks/utils/helpers/s3Client.js +40 -0
- package/tasks/utils/helpers/s3Client.js.map +1 -0
- package/tasks/utils/helpers/sizeSegments.d.ts +5 -0
- package/tasks/utils/helpers/sizeSegments.js +25 -0
- package/tasks/utils/helpers/sizeSegments.js.map +1 -0
- package/tasks/utils/types.d.ts +23 -0
- package/tasks/utils/types.js +7 -0
- package/tasks/utils/types.js.map +1 -0
- package/tasks/utils/uniqueResolver/UniqueResolver.d.ts +6 -0
- package/tasks/utils/uniqueResolver/UniqueResolver.js +23 -0
- package/tasks/utils/uniqueResolver/UniqueResolver.js.map +1 -0
- package/tasks/utils/uniqueResolver/abstractions/UniqueResolver.d.ts +4 -0
- package/tasks/utils/uniqueResolver/abstractions/UniqueResolver.js +7 -0
- package/tasks/utils/uniqueResolver/abstractions/UniqueResolver.js.map +1 -0
- package/tasks/utils/upload/MultipartUploadFactory.d.ts +23 -0
- package/tasks/utils/upload/MultipartUploadFactory.js +111 -0
- package/tasks/utils/upload/MultipartUploadFactory.js.map +1 -0
- package/tasks/utils/upload/Upload.d.ts +36 -0
- package/tasks/utils/upload/Upload.js +70 -0
- package/tasks/utils/upload/Upload.js.map +1 -0
- package/tasks/utils/upload/abstractions/MultipartUploadFactory.d.ts +7 -0
- package/tasks/utils/upload/abstractions/MultipartUploadFactory.js +7 -0
- package/tasks/utils/upload/abstractions/MultipartUploadFactory.js.map +1 -0
- package/tasks/utils/upload/abstractions/MultipartUploadHandler.d.ts +54 -0
- package/tasks/utils/upload/abstractions/MultipartUploadHandler.js +7 -0
- package/tasks/utils/upload/abstractions/MultipartUploadHandler.js.map +1 -0
- package/tasks/utils/upload/abstractions/Upload.d.ts +18 -0
- package/tasks/utils/upload/abstractions/Upload.js +7 -0
- package/tasks/utils/upload/abstractions/Upload.js.map +1 -0
- package/tasks/utils/upload/getContentType.d.ts +1 -0
- package/tasks/utils/upload/getContentType.js +28 -0
- package/tasks/utils/upload/getContentType.js.map +1 -0
- package/tasks/utils/upload/index.d.ts +6 -0
- package/tasks/utils/upload/index.js +73 -0
- package/tasks/utils/upload/index.js.map +1 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandler.d.ts +23 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandler.js +196 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandler.js.map +1 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandlerAbortResult.d.ts +9 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandlerAbortResult.js +20 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandlerAbortResult.js.map +1 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandlerAddResult.d.ts +15 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandlerAddResult.js +26 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandlerAddResult.js.map +1 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandlerCompleteResult.d.ts +9 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandlerCompleteResult.js +20 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandlerCompleteResult.js.map +1 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandlerPauseResult.d.ts +7 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandlerPauseResult.js +19 -0
- package/tasks/utils/upload/multipartUploadHandler/MultipartUploadHandlerPauseResult.js.map +1 -0
- package/tasks/utils/upload/multipartUploadHandler/index.d.ts +5 -0
- package/tasks/utils/upload/multipartUploadHandler/index.js +62 -0
- package/tasks/utils/upload/multipartUploadHandler/index.js.map +1 -0
- package/tasks/utils/urlSigner/UrlSigner.d.ts +20 -0
- package/tasks/utils/urlSigner/UrlSigner.js +40 -0
- package/tasks/utils/urlSigner/UrlSigner.js.map +1 -0
- package/tasks/utils/urlSigner/abstractions/UrlSigner.d.ts +14 -0
- package/tasks/utils/urlSigner/abstractions/UrlSigner.js +7 -0
- package/tasks/utils/urlSigner/abstractions/UrlSigner.js.map +1 -0
- package/tasks/utils/urlSigner/index.d.ts +2 -0
- package/tasks/utils/urlSigner/index.js +29 -0
- package/tasks/utils/urlSigner/index.js.map +1 -0
- package/tasks/utils/zipper/Zipper.d.ts +27 -0
- package/tasks/utils/zipper/Zipper.js +38 -0
- package/tasks/utils/zipper/Zipper.js.map +1 -0
- package/tasks/utils/zipper/abstractions/Zipper.d.ts +25 -0
- package/tasks/utils/zipper/abstractions/Zipper.js +7 -0
- package/tasks/utils/zipper/abstractions/Zipper.js.map +1 -0
- package/tasks/utils/zipper/index.d.ts +2 -0
- package/tasks/utils/zipper/index.js +29 -0
- package/tasks/utils/zipper/index.js.map +1 -0
- package/tasks/validateImportFromUrl.d.ts +3 -0
- package/tasks/validateImportFromUrl.js +31 -0
- package/tasks/validateImportFromUrl.js.map +1 -0
- package/types.d.ts +119 -0
- package/types.js +28 -0
- package/types.js.map +1 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getChildTasks = void 0;
|
|
7
|
+
var _tasks = require("@webiny/tasks");
|
|
8
|
+
const mapServiceStatusToTaskStatus = (task, serviceInfo) => {
|
|
9
|
+
if (!serviceInfo) {
|
|
10
|
+
console.log(`Service info is missing for task ${task.id} (${task.definitionId}).`);
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
if (serviceInfo.status === "RUNNING") {
|
|
14
|
+
return _tasks.TaskDataStatus.RUNNING;
|
|
15
|
+
} else if (serviceInfo.status === "SUCCEEDED") {
|
|
16
|
+
return _tasks.TaskDataStatus.SUCCESS;
|
|
17
|
+
} else if (serviceInfo.status === "FAILED") {
|
|
18
|
+
return _tasks.TaskDataStatus.FAILED;
|
|
19
|
+
} else if (serviceInfo.status === "ABORTED") {
|
|
20
|
+
return _tasks.TaskDataStatus.ABORTED;
|
|
21
|
+
} else if (serviceInfo.status === "TIMED_OUT" || serviceInfo.status === "PENDING_REDRIVE") {
|
|
22
|
+
console.log(`Service status is ${serviceInfo.status} for task ${task.id} (${task.definitionId}).`);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return _tasks.TaskDataStatus.PENDING;
|
|
26
|
+
};
|
|
27
|
+
const getChildTasks = async ({
|
|
28
|
+
context,
|
|
29
|
+
task,
|
|
30
|
+
definition
|
|
31
|
+
}) => {
|
|
32
|
+
const running = [];
|
|
33
|
+
const done = [];
|
|
34
|
+
const invalid = [];
|
|
35
|
+
const aborted = [];
|
|
36
|
+
const failed = [];
|
|
37
|
+
const collection = [];
|
|
38
|
+
const {
|
|
39
|
+
items
|
|
40
|
+
} = await context.tasks.listTasks({
|
|
41
|
+
where: {
|
|
42
|
+
parentId: task.id,
|
|
43
|
+
definitionId: definition
|
|
44
|
+
},
|
|
45
|
+
limit: 100000
|
|
46
|
+
});
|
|
47
|
+
for (const task of items) {
|
|
48
|
+
collection.push(task);
|
|
49
|
+
if (task.taskStatus === _tasks.TaskDataStatus.RUNNING || task.taskStatus === _tasks.TaskDataStatus.PENDING) {
|
|
50
|
+
/**
|
|
51
|
+
* We also need to check the actual status of the service.
|
|
52
|
+
* It can happen that the task is marked as running, but the service is not running.
|
|
53
|
+
*/
|
|
54
|
+
const serviceInfo = await context.tasks.fetchServiceInfo(task);
|
|
55
|
+
const status = mapServiceStatusToTaskStatus(task, serviceInfo);
|
|
56
|
+
if (status === null || !serviceInfo) {
|
|
57
|
+
invalid.push(task.id);
|
|
58
|
+
continue;
|
|
59
|
+
} else if (status !== task.taskStatus) {
|
|
60
|
+
console.error(`Status of the task is not same as the status of the service (task: ${task.taskStatus}, service: ${status} / ${serviceInfo.status}).`);
|
|
61
|
+
invalid.push(task.id);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
running.push(task.id);
|
|
65
|
+
continue;
|
|
66
|
+
} else if (task.taskStatus === _tasks.TaskDataStatus.SUCCESS) {
|
|
67
|
+
done.push(task.id);
|
|
68
|
+
continue;
|
|
69
|
+
} else if (task.taskStatus === _tasks.TaskDataStatus.FAILED) {
|
|
70
|
+
failed.push(task.id);
|
|
71
|
+
continue;
|
|
72
|
+
} else if (task.taskStatus === _tasks.TaskDataStatus.ABORTED) {
|
|
73
|
+
aborted.push(task.id);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Impossible to be in a state not listed above, but just in case.
|
|
78
|
+
*/
|
|
79
|
+
invalid.push(task.id);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
running,
|
|
83
|
+
done,
|
|
84
|
+
invalid,
|
|
85
|
+
aborted,
|
|
86
|
+
failed,
|
|
87
|
+
collection
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
exports.getChildTasks = getChildTasks;
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=getChildTasks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_tasks","require","mapServiceStatusToTaskStatus","task","serviceInfo","console","log","id","definitionId","status","TaskDataStatus","RUNNING","SUCCESS","FAILED","ABORTED","PENDING","getChildTasks","context","definition","running","done","invalid","aborted","failed","collection","items","tasks","listTasks","where","parentId","limit","push","taskStatus","fetchServiceInfo","error","exports"],"sources":["getChildTasks.ts"],"sourcesContent":["import type { ITask, ITaskResponseDoneResultOutput } from \"@webiny/tasks\";\nimport { TaskDataStatus } from \"@webiny/tasks\";\nimport type { Context } from \"~/types\";\nimport { IStepFunctionServiceFetchResult } from \"@webiny/tasks/service/StepFunctionServicePlugin\";\n\nexport interface IGetChildTasksParams {\n context: Context;\n task: ITask;\n definition: string;\n}\n\nconst mapServiceStatusToTaskStatus = (\n task: ITask<any, any>,\n serviceInfo: IStepFunctionServiceFetchResult | null\n) => {\n if (!serviceInfo) {\n console.log(`Service info is missing for task ${task.id} (${task.definitionId}).`);\n return null;\n }\n if (serviceInfo.status === \"RUNNING\") {\n return TaskDataStatus.RUNNING;\n } else if (serviceInfo.status === \"SUCCEEDED\") {\n return TaskDataStatus.SUCCESS;\n } else if (serviceInfo.status === \"FAILED\") {\n return TaskDataStatus.FAILED;\n } else if (serviceInfo.status === \"ABORTED\") {\n return TaskDataStatus.ABORTED;\n } else if (serviceInfo.status === \"TIMED_OUT\" || serviceInfo.status === \"PENDING_REDRIVE\") {\n console.log(\n `Service status is ${serviceInfo.status} for task ${task.id} (${task.definitionId}).`\n );\n return null;\n }\n return TaskDataStatus.PENDING;\n};\n\nexport const getChildTasks = async <I, O extends ITaskResponseDoneResultOutput>({\n context,\n task,\n definition\n}: IGetChildTasksParams) => {\n const running: string[] = [];\n const done: string[] = [];\n const invalid: string[] = [];\n const aborted: string[] = [];\n const failed: string[] = [];\n const collection: ITask<I, O>[] = [];\n\n const { items } = await context.tasks.listTasks<I, O>({\n where: {\n parentId: task.id,\n definitionId: definition\n },\n limit: 100000\n });\n for (const task of items) {\n collection.push(task);\n\n if (\n task.taskStatus === TaskDataStatus.RUNNING ||\n task.taskStatus === TaskDataStatus.PENDING\n ) {\n /**\n * We also need to check the actual status of the service.\n * It can happen that the task is marked as running, but the service is not running.\n */\n const serviceInfo = await context.tasks.fetchServiceInfo(task);\n const status = mapServiceStatusToTaskStatus(task, serviceInfo);\n\n if (status === null || !serviceInfo) {\n invalid.push(task.id);\n continue;\n } else if (status !== task.taskStatus) {\n console.error(\n `Status of the task is not same as the status of the service (task: ${task.taskStatus}, service: ${status} / ${serviceInfo.status}).`\n );\n invalid.push(task.id);\n continue;\n }\n running.push(task.id);\n continue;\n } else if (task.taskStatus === TaskDataStatus.SUCCESS) {\n done.push(task.id);\n continue;\n } else if (task.taskStatus === TaskDataStatus.FAILED) {\n failed.push(task.id);\n continue;\n } else if (task.taskStatus === TaskDataStatus.ABORTED) {\n aborted.push(task.id);\n continue;\n }\n /**\n * Impossible to be in a state not listed above, but just in case.\n */\n invalid.push(task.id);\n }\n return {\n running,\n done,\n invalid,\n aborted,\n failed,\n collection\n };\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAUA,MAAMC,4BAA4B,GAAGA,CACjCC,IAAqB,EACrBC,WAAmD,KAClD;EACD,IAAI,CAACA,WAAW,EAAE;IACdC,OAAO,CAACC,GAAG,CAAE,oCAAmCH,IAAI,CAACI,EAAG,KAAIJ,IAAI,CAACK,YAAa,IAAG,CAAC;IAClF,OAAO,IAAI;EACf;EACA,IAAIJ,WAAW,CAACK,MAAM,KAAK,SAAS,EAAE;IAClC,OAAOC,qBAAc,CAACC,OAAO;EACjC,CAAC,MAAM,IAAIP,WAAW,CAACK,MAAM,KAAK,WAAW,EAAE;IAC3C,OAAOC,qBAAc,CAACE,OAAO;EACjC,CAAC,MAAM,IAAIR,WAAW,CAACK,MAAM,KAAK,QAAQ,EAAE;IACxC,OAAOC,qBAAc,CAACG,MAAM;EAChC,CAAC,MAAM,IAAIT,WAAW,CAACK,MAAM,KAAK,SAAS,EAAE;IACzC,OAAOC,qBAAc,CAACI,OAAO;EACjC,CAAC,MAAM,IAAIV,WAAW,CAACK,MAAM,KAAK,WAAW,IAAIL,WAAW,CAACK,MAAM,KAAK,iBAAiB,EAAE;IACvFJ,OAAO,CAAC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U,EAAE;QACnC3B,OAAO,CAAC6B,KAAK,CACR,sEAAqE/B,IAAI,CAAC6B,UAAW,cAAavB,MAAO,MAAKL,WAAW,CAACK,MAAO,IACtI,CAAC;QACDY,OAAO,CAACU,IAAI,CAAC5B,IAAI,CAACI,EAAE,CAAC;QACrB;MACJ;MACAY,OAAO,CAACY,IAAI,CAAC5B,IAAI,CAACI,EAAE,CAAC;MACrB;IACJ,CAAC,MAAM,IAAIJ,IAAI,CAAC6B,UAAU,KAAKtB,qBAAc,CAACE,OAAO,EAAE;MACnDQ,IAAI,CAACW,IAAI,CAAC5B,IAAI,CAACI,EAAE,CAAC;MAClB;IACJ,CAAC,MAAM,IAAIJ,IAAI,CAAC6B,UAAU,KAAKtB,qBAAc,CAACG,MAAM,EAAE;MAClDU,MAAM,CAACQ,IAAI,CAAC5B,IAAI,CAACI,EAAE,CAAC;MACpB;IACJ,CAAC,MAAM,IAAIJ,IAAI,CAAC6B,UAAU,KAAKtB,qBAAc,CAACI,OAAO,EAAE;MACnDQ,OAAO,CAACS,IAAI,CAAC5B,IAAI,CAACI,EAAE,CAAC;MACrB;IACJ;IACA;AACR;AACA;IACQc,OAAO,CAACU,IAAI,CAAC5B,IAAI,CAACI,EAAE,CAAC;EACzB;EACA,OAAO;IACHY,OAAO;IACPC,IAAI;IACJC,OAAO;IACPC,OAAO;IACPC,MAAM;IACNC;EACJ,CAAC;AACL,CAAC;AAACW,OAAA,CAAAnB,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ITaskResponseResult, ITaskRunParams } from "@webiny/tasks/types";
|
|
2
|
+
import type { IImportFromUrlProcessAssets, IImportFromUrlProcessAssetsInput, IImportFromUrlProcessAssetsOutput } from "./abstractions/ImportFromUrlProcessAssets";
|
|
3
|
+
import { Context } from "../../../types";
|
|
4
|
+
import type { IFileFetcher } from "../../utils/fileFetcher";
|
|
5
|
+
import type { ICompressedFileReader, IDecompressor } from "../../utils/decompressor";
|
|
6
|
+
export interface IImportFromUrlProcessAssetsParams {
|
|
7
|
+
fileFetcher: IFileFetcher;
|
|
8
|
+
reader: ICompressedFileReader;
|
|
9
|
+
decompressor: IDecompressor;
|
|
10
|
+
}
|
|
11
|
+
export declare class ImportFromUrlProcessAssets<C extends Context = Context, I extends IImportFromUrlProcessAssetsInput = IImportFromUrlProcessAssetsInput, O extends IImportFromUrlProcessAssetsOutput = IImportFromUrlProcessAssetsOutput> implements IImportFromUrlProcessAssets<C, I, O> {
|
|
12
|
+
private readonly fileFetcher;
|
|
13
|
+
private readonly reader;
|
|
14
|
+
private readonly decompressor;
|
|
15
|
+
constructor(params: IImportFromUrlProcessAssetsParams);
|
|
16
|
+
run(params: ITaskRunParams<C, I, O>): Promise<ITaskResponseResult<I, O>>;
|
|
17
|
+
private readManifest;
|
|
18
|
+
private takeNextAssetRecord;
|
|
19
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ImportFromUrlProcessAssets = void 0;
|
|
7
|
+
var _types = require("../../../types");
|
|
8
|
+
var _constants = require("../../constants");
|
|
9
|
+
var _getFilePath = require("../../utils/helpers/getFilePath");
|
|
10
|
+
var _error = require("@webiny/error");
|
|
11
|
+
class ImportFromUrlProcessAssets {
|
|
12
|
+
constructor(params) {
|
|
13
|
+
this.fileFetcher = params.fileFetcher;
|
|
14
|
+
this.reader = params.reader;
|
|
15
|
+
this.decompressor = params.decompressor;
|
|
16
|
+
}
|
|
17
|
+
async run(params) {
|
|
18
|
+
const {
|
|
19
|
+
context,
|
|
20
|
+
response,
|
|
21
|
+
input,
|
|
22
|
+
isCloseToTimeout,
|
|
23
|
+
isAborted
|
|
24
|
+
} = params;
|
|
25
|
+
const maxInsertErrors = input.maxInsertErrors || 100;
|
|
26
|
+
if (!input.modelId) {
|
|
27
|
+
return response.error({
|
|
28
|
+
message: `Missing "modelId" in the input.`,
|
|
29
|
+
code: "MISSING_MODEL_ID"
|
|
30
|
+
});
|
|
31
|
+
} else if (!input.file) {
|
|
32
|
+
return response.error({
|
|
33
|
+
message: `No file found in the provided data.`,
|
|
34
|
+
code: "NO_FILE_FOUND"
|
|
35
|
+
});
|
|
36
|
+
} else if (input.file.type !== _types.CmsImportExportFileType.ASSETS) {
|
|
37
|
+
return response.error({
|
|
38
|
+
message: `Invalid file type. Expected "${_types.CmsImportExportFileType.ASSETS}" but got "${input.file.type}".`,
|
|
39
|
+
code: "INVALID_FILE_TYPE"
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const recordExists = async id => {
|
|
43
|
+
try {
|
|
44
|
+
const result = await context.fileManager.getFile(id);
|
|
45
|
+
return !!result;
|
|
46
|
+
} catch (ex) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const result = structuredClone({
|
|
51
|
+
...input,
|
|
52
|
+
errors: []
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Read the compressed archive and get all the file information.
|
|
56
|
+
*/
|
|
57
|
+
const sources = await this.reader.read(result.file.key);
|
|
58
|
+
if (sources.length === 0) {
|
|
59
|
+
return response.error({
|
|
60
|
+
message: `No files found in the compressed archive.`,
|
|
61
|
+
code: "NO_FILES_FOUND"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Read the manifest file.
|
|
67
|
+
* Should not be possible it does not exist, but let's handle it anyway.
|
|
68
|
+
*/
|
|
69
|
+
let manifest;
|
|
70
|
+
try {
|
|
71
|
+
manifest = await this.readManifest(sources, result);
|
|
72
|
+
} catch (ex) {
|
|
73
|
+
console.error(ex);
|
|
74
|
+
return response.error(ex);
|
|
75
|
+
}
|
|
76
|
+
while (true) {
|
|
77
|
+
if (isCloseToTimeout()) {
|
|
78
|
+
return response.continue(result);
|
|
79
|
+
} else if (isAborted()) {
|
|
80
|
+
return response.aborted();
|
|
81
|
+
} else if (result.errors.length > maxInsertErrors) {
|
|
82
|
+
return response.error({
|
|
83
|
+
message: `Too many errors encountered while processing assets.`,
|
|
84
|
+
code: "TOO_MANY_ERRORS",
|
|
85
|
+
data: {
|
|
86
|
+
errors: result.errors
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const record = this.takeNextAssetRecord(manifest, result.lastAsset);
|
|
91
|
+
if (!record) {
|
|
92
|
+
return response.done("No more assets to process");
|
|
93
|
+
}
|
|
94
|
+
result.lastAsset = record.id;
|
|
95
|
+
const source = sources.find(file => file.path === record.key);
|
|
96
|
+
if (!source) {
|
|
97
|
+
result.errors.push({
|
|
98
|
+
file: record.key,
|
|
99
|
+
message: `File not found in the compressed archive.`
|
|
100
|
+
});
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Check if the file exists physically.
|
|
105
|
+
*/
|
|
106
|
+
const existsPhysically = await this.fileFetcher.exists(source.path);
|
|
107
|
+
if (existsPhysically && !input.override) {
|
|
108
|
+
console.log(`Asset "${record.id}" / ${source.path} file already exists. Skipping...`);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Check if the file record already exists.
|
|
113
|
+
*/
|
|
114
|
+
const exists = await recordExists(record.id);
|
|
115
|
+
if (exists && !input.override) {
|
|
116
|
+
console.log(`Asset "${record.id}" / ${source.path} record already exists. Skipping...`);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Upload the file to the S3 bucket, if it does not exist already.
|
|
121
|
+
*/
|
|
122
|
+
if (!existsPhysically) {
|
|
123
|
+
try {
|
|
124
|
+
const file = await this.decompressor.extract({
|
|
125
|
+
source,
|
|
126
|
+
target: record.key
|
|
127
|
+
});
|
|
128
|
+
if (!file?.Key) {
|
|
129
|
+
result.errors.push({
|
|
130
|
+
file: record.key,
|
|
131
|
+
message: `Could not upload the file "${source.path}" to "${record.key}".`
|
|
132
|
+
});
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
} catch (ex) {
|
|
136
|
+
result.errors.push({
|
|
137
|
+
file: record.key,
|
|
138
|
+
message: ex.message
|
|
139
|
+
});
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Update an existing file record.
|
|
145
|
+
*/
|
|
146
|
+
if (exists) {
|
|
147
|
+
try {
|
|
148
|
+
await context.fileManager.updateFile(record.id, {
|
|
149
|
+
...record
|
|
150
|
+
});
|
|
151
|
+
} catch (ex) {
|
|
152
|
+
result.errors.push({
|
|
153
|
+
file: record.key,
|
|
154
|
+
message: ex.message
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Create a new file record.
|
|
161
|
+
*/
|
|
162
|
+
try {
|
|
163
|
+
await context.fileManager.createFile({
|
|
164
|
+
...record,
|
|
165
|
+
id: record.id,
|
|
166
|
+
key: record.key,
|
|
167
|
+
size: record.size,
|
|
168
|
+
type: record.type,
|
|
169
|
+
name: record.name,
|
|
170
|
+
meta: record.meta,
|
|
171
|
+
aliases: record.aliases,
|
|
172
|
+
extensions: record.extensions,
|
|
173
|
+
location: record.location,
|
|
174
|
+
tags: record.tags
|
|
175
|
+
});
|
|
176
|
+
} catch (ex) {
|
|
177
|
+
result.errors.push({
|
|
178
|
+
file: record.key,
|
|
179
|
+
message: ex.message
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async readManifest(sources, input) {
|
|
185
|
+
let manifest = input?.manifest;
|
|
186
|
+
if (!manifest) {
|
|
187
|
+
const extractPath = (0, _getFilePath.getFilePath)(input.file.key);
|
|
188
|
+
const source = sources.find(file => file.path === _constants.MANIFEST_JSON);
|
|
189
|
+
if (!source) {
|
|
190
|
+
throw new _error.WebinyError({
|
|
191
|
+
message: `No manifest file found in the compressed archive.`,
|
|
192
|
+
code: "NO_MANIFEST_FILE"
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
const target = `extracted/${extractPath.path}/${source.path}`;
|
|
196
|
+
try {
|
|
197
|
+
const file = await this.decompressor.extract({
|
|
198
|
+
source,
|
|
199
|
+
target
|
|
200
|
+
});
|
|
201
|
+
if (!file.Key) {
|
|
202
|
+
throw new Error(`Could not upload the file "${source.path}" to "${target}".`);
|
|
203
|
+
}
|
|
204
|
+
manifest = file.Key;
|
|
205
|
+
} catch (ex) {
|
|
206
|
+
throw new _error.WebinyError({
|
|
207
|
+
message: ex.message,
|
|
208
|
+
code: "MANIFEST_DECOMPRESS_FAILED"
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
let file;
|
|
213
|
+
try {
|
|
214
|
+
file = await this.fileFetcher.read(manifest);
|
|
215
|
+
if (!file) {
|
|
216
|
+
throw new _error.WebinyError({
|
|
217
|
+
message: `Could not fetch the manifest file "${manifest}".`,
|
|
218
|
+
code: "MANIFEST_NOT_FOUND"
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
} catch (ex) {
|
|
222
|
+
throw new _error.WebinyError({
|
|
223
|
+
message: ex.message,
|
|
224
|
+
code: "MANIFEST_FETCH_FAILED",
|
|
225
|
+
data: ex
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
let json;
|
|
229
|
+
try {
|
|
230
|
+
json = JSON.parse(file);
|
|
231
|
+
} catch (ex) {
|
|
232
|
+
throw new _error.WebinyError({
|
|
233
|
+
message: ex.message,
|
|
234
|
+
code: "MANIFEST_PARSE_FAILED",
|
|
235
|
+
data: ex
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
if (!json.assets?.length) {
|
|
239
|
+
throw new _error.WebinyError({
|
|
240
|
+
message: `Invalid manifest file "${manifest}". Missing "assets" property.`,
|
|
241
|
+
code: "INVALID_MANIFEST_FILE"
|
|
242
|
+
});
|
|
243
|
+
} else if (!json.size) {
|
|
244
|
+
throw new _error.WebinyError({
|
|
245
|
+
message: `Invalid manifest file "${manifest}". Missing "size" property.`,
|
|
246
|
+
code: "INVALID_MANIFEST_FILE"
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return json;
|
|
250
|
+
}
|
|
251
|
+
takeNextAssetRecord(manifest, lastAsset) {
|
|
252
|
+
if (!lastAsset) {
|
|
253
|
+
return manifest.assets[0];
|
|
254
|
+
}
|
|
255
|
+
const lastIndex = manifest.assets.findIndex(asset => asset.id === lastAsset);
|
|
256
|
+
if (lastIndex === -1) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
const asset = manifest.assets[lastIndex + 1];
|
|
260
|
+
return asset || null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
exports.ImportFromUrlProcessAssets = ImportFromUrlProcessAssets;
|
|
264
|
+
|
|
265
|
+
//# sourceMappingURL=ImportFromUrlProcessAssets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_types","require","_constants","_getFilePath","_error","ImportFromUrlProcessAssets","constructor","params","fileFetcher","reader","decompressor","run","context","response","input","isCloseToTimeout","isAborted","maxInsertErrors","modelId","error","message","code","file","type","CmsImportExportFileType","ASSETS","recordExists","id","result","fileManager","getFile","ex","structuredClone","errors","sources","read","key","length","manifest","readManifest","console","continue","aborted","data","record","takeNextAssetRecord","lastAsset","done","source","find","path","push","existsPhysically","exists","override","log","extract","target","Key","updateFile","createFile","size","name","meta","aliases","extensions","location","tags","extractPath","getFilePath","MANIFEST_JSON","WebinyError","Error","json","JSON","parse","assets","lastIndex","findIndex","asset","exports"],"sources":["ImportFromUrlProcessAssets.ts"],"sourcesContent":["import type { ITaskResponseResult, ITaskRunParams } from \"@webiny/tasks/types\";\nimport type {\n IImportFromUrlProcessAssets,\n IImportFromUrlProcessAssetsInput,\n IImportFromUrlProcessAssetsOutput\n} from \"~/tasks/domain/importFromUrlProcessAssets/abstractions/ImportFromUrlProcessAssets\";\nimport { CmsImportExportFileType, Context } from \"~/types\";\nimport type { IFileFetcher } from \"~/tasks/utils/fileFetcher\";\nimport type {\n ICompressedFileReader,\n IDecompressor,\n IUnzipperFile\n} from \"~/tasks/utils/decompressor\";\nimport { MANIFEST_JSON } from \"~/tasks/constants\";\nimport { getFilePath } from \"~/tasks/utils/helpers/getFilePath\";\nimport { WebinyError } from \"@webiny/error\";\nimport type { ICmsAssetsManifestJson } from \"~/tasks/utils/types\";\nimport type { IResolvedAsset } from \"~/tasks/utils/entryAssets\";\n\nexport interface IImportFromUrlProcessAssetsParams {\n fileFetcher: IFileFetcher;\n reader: ICompressedFileReader;\n decompressor: IDecompressor;\n}\n\nexport class ImportFromUrlProcessAssets<\n C extends Context = Context,\n I extends IImportFromUrlProcessAssetsInput = IImportFromUrlProcessAssetsInput,\n O extends IImportFromUrlProcessAssetsOutput = IImportFromUrlProcessAssetsOutput\n> implements IImportFromUrlProcessAssets<C, I, O>\n{\n private readonly fileFetcher: IFileFetcher;\n private readonly reader: ICompressedFileReader;\n private readonly decompressor: IDecompressor;\n\n public constructor(params: IImportFromUrlProcessAssetsParams) {\n this.fileFetcher = params.fileFetcher;\n this.reader = params.reader;\n this.decompressor = params.decompressor;\n }\n\n public async run(params: ITaskRunParams<C, I, O>): Promise<ITaskResponseResult<I, O>> {\n const { context, response, input, isCloseToTimeout, isAborted } = params;\n\n const maxInsertErrors = input.maxInsertErrors || 100;\n\n if (!input.modelId) {\n return response.error({\n message: `Missing \"modelId\" in the input.`,\n code: \"MISSING_MODEL_ID\"\n });\n } else if (!input.file) {\n return response.error({\n message: `No file found in the provided data.`,\n code: \"NO_FILE_FOUND\"\n });\n } else if (input.file.type !== CmsImportExportFileType.ASSETS) {\n return response.error({\n message: `Invalid file type. Expected \"${CmsImportExportFileType.ASSETS}\" but got \"${input.file.type}\".`,\n code: \"INVALID_FILE_TYPE\"\n });\n }\n\n const recordExists = async (id: string): Promise<boolean> => {\n try {\n const result = await context.fileManager.getFile(id);\n return !!result;\n } catch (ex) {\n return false;\n }\n };\n\n const result = structuredClone({\n ...input,\n errors: []\n });\n /**\n * Read the compressed archive and get all the file information.\n */\n const sources = await this.reader.read(result.file.key);\n if (sources.length === 0) {\n return response.error({\n message: `No files found in the compressed archive.`,\n code: \"NO_FILES_FOUND\"\n });\n }\n\n /**\n * Read the manifest file.\n * Should not be possible it does not exist, but let's handle it anyway.\n */\n let manifest: ICmsAssetsManifestJson;\n try {\n manifest = await this.readManifest(sources, result);\n } catch (ex) {\n console.error(ex);\n return response.error(ex);\n }\n\n while (true) {\n if (isCloseToTimeout()) {\n return response.continue(result);\n } else if (isAborted()) {\n return response.aborted();\n } else if (result.errors.length > maxInsertErrors) {\n return response.error({\n message: `Too many errors encountered while processing assets.`,\n code: \"TOO_MANY_ERRORS\",\n data: {\n errors: result.errors\n }\n });\n }\n const record = this.takeNextAssetRecord(manifest, result.lastAsset);\n if (!record) {\n return response.done(\"No more assets to process\");\n }\n result.lastAsset = record.id;\n const source = sources.find(file => file.path === record.key);\n if (!source) {\n result.errors.push({\n file: record.key,\n message: `File not found in the compressed archive.`\n });\n continue;\n }\n /**\n * Check if the file exists physically.\n */\n const existsPhysically = await this.fileFetcher.exists(source.path);\n if (existsPhysically && !input.override) {\n console.log(\n `Asset \"${record.id}\" / ${source.path} file already exists. Skipping...`\n );\n continue;\n }\n /**\n * Check if the file record already exists.\n */\n const exists = await recordExists(record.id);\n if (exists && !input.override) {\n console.log(\n `Asset \"${record.id}\" / ${source.path} record already exists. Skipping...`\n );\n continue;\n }\n /**\n * Upload the file to the S3 bucket, if it does not exist already.\n */\n if (!existsPhysically) {\n try {\n const file = await this.decompressor.extract({\n source,\n target: record.key\n });\n if (!file?.Key) {\n result.errors.push({\n file: record.key,\n message: `Could not upload the file \"${source.path}\" to \"${record.key}\".`\n });\n continue;\n }\n } catch (ex) {\n result.errors.push({\n file: record.key,\n message: ex.message\n });\n continue;\n }\n }\n /**\n * Update an existing file record.\n */\n if (exists) {\n try {\n await context.fileManager.updateFile(record.id, {\n ...record\n });\n } catch (ex) {\n result.errors.push({\n file: record.key,\n message: ex.message\n });\n }\n continue;\n }\n /**\n * Create a new file record.\n */\n try {\n await context.fileManager.createFile({\n ...record,\n id: record.id,\n key: record.key,\n size: record.size,\n type: record.type,\n name: record.name,\n meta: record.meta,\n aliases: record.aliases,\n extensions: record.extensions,\n location: record.location,\n tags: record.tags\n });\n } catch (ex) {\n result.errors.push({\n file: record.key,\n message: ex.message\n });\n }\n }\n }\n\n private async readManifest(\n sources: IUnzipperFile[],\n input: I\n ): Promise<ICmsAssetsManifestJson> {\n let manifest: string | undefined = input?.manifest;\n\n if (!manifest) {\n const extractPath = getFilePath(input.file.key);\n const source = sources.find(file => file.path === MANIFEST_JSON);\n if (!source) {\n throw new WebinyError({\n message: `No manifest file found in the compressed archive.`,\n code: \"NO_MANIFEST_FILE\"\n });\n }\n const target = `extracted/${extractPath.path}/${source.path}`;\n try {\n const file = await this.decompressor.extract({\n source,\n target\n });\n if (!file.Key) {\n throw new Error(`Could not upload the file \"${source.path}\" to \"${target}\".`);\n }\n manifest = file.Key;\n } catch (ex) {\n throw new WebinyError({\n message: ex.message,\n code: \"MANIFEST_DECOMPRESS_FAILED\"\n });\n }\n }\n\n let file: string | null;\n try {\n file = await this.fileFetcher.read(manifest);\n if (!file) {\n throw new WebinyError({\n message: `Could not fetch the manifest file \"${manifest}\".`,\n code: \"MANIFEST_NOT_FOUND\"\n });\n }\n } catch (ex) {\n throw new WebinyError({\n message: ex.message,\n code: \"MANIFEST_FETCH_FAILED\",\n data: ex\n });\n }\n\n let json: ICmsAssetsManifestJson;\n try {\n json = JSON.parse(file);\n } catch (ex) {\n throw new WebinyError({\n message: ex.message,\n code: \"MANIFEST_PARSE_FAILED\",\n data: ex\n });\n }\n if (!json.assets?.length) {\n throw new WebinyError({\n message: `Invalid manifest file \"${manifest}\". Missing \"assets\" property.`,\n code: \"INVALID_MANIFEST_FILE\"\n });\n } else if (!json.size) {\n throw new WebinyError({\n message: `Invalid manifest file \"${manifest}\". Missing \"size\" property.`,\n code: \"INVALID_MANIFEST_FILE\"\n });\n }\n return json;\n }\n\n private takeNextAssetRecord(\n manifest: ICmsAssetsManifestJson,\n lastAsset: string | undefined\n ): IResolvedAsset | null {\n if (!lastAsset) {\n return manifest.assets[0] as IResolvedAsset;\n }\n const lastIndex = manifest.assets.findIndex(asset => asset.id === lastAsset);\n if (lastIndex === -1) {\n return null;\n }\n const asset = manifest.assets[lastIndex + 1];\n return asset || null;\n }\n}\n"],"mappings":";;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AAOA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAUO,MAAMI,0BAA0B,CAKvC;EAKWC,WAAWA,CAACC,MAAyC,EAAE;IAC1D,IAAI,CAACC,WAAW,GAAGD,MAAM,CAACC,WAAW;IACrC,IAAI,CAACC,MAAM,GAAGF,MAAM,CAACE,MAAM;IAC3B,IAAI,CAACC,YAAY,GAAGH,MAAM,CAACG,YAAY;EAC3C;EAEA,MAAaC,GAAGA,CAACJ,MAA+B,EAAsC;IAClF,MAAM;MAAEK,OAAO;MAAEC,QAAQ;MAAEC,KAAK;MAAEC,gBAAgB;MAAEC;IAAU,CAAC,GAAGT,MAAM;IAExE,MAAMU,eAAe,GAAGH,KAAK,CAACG,eAAe,IAAI,GAAG;IAEpD,IAAI,CAACH,KAAK,CAACI,OAAO,EAAE;MAChB,OAAOL,QAAQ,CAACM,KAAK,CAAC;QAClBC,OAAO,EAAG,iCAAgC;QAC1CC,IAAI,EAAE;MACV,CAAC,CAAC;IACN,CAAC,MAAM,IAAI,CAACP,KAAK,CAACQ,IAAI,EAAE;MACpB,OAAOT,QAAQ,CAACM,KAAK,CAAC;QAClBC,OAAO,EAAG,qCAAoC;QAC9CC,IA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;MACtB,MAAM,IAAIkC,kBAAW,CAAC;QAClBnD,OAAO,EAAG,0BAAyBkB,QAAS,+BAA8B;QAC1EjB,IAAI,EAAE;MACV,CAAC,CAAC;IACN,CAAC,MAAM,IAAI,CAACoD,IAAI,CAACZ,IAAI,EAAE;MACnB,MAAM,IAAIU,kBAAW,CAAC;QAClBnD,OAAO,EAAG,0BAAyBkB,QAAS,6BAA4B;QACxEjB,IAAI,EAAE;MACV,CAAC,CAAC;IACN;IACA,OAAOoD,IAAI;EACf;EAEQ5B,mBAAmBA,CACvBP,QAAgC,EAChCQ,SAA6B,EACR;IACrB,IAAI,CAACA,SAAS,EAAE;MACZ,OAAOR,QAAQ,CAACsC,MAAM,CAAC,CAAC,CAAC;IAC7B;IACA,MAAMC,SAAS,GAAGvC,QAAQ,CAACsC,MAAM,CAACE,SAAS,CAACC,KAAK,IAAIA,KAAK,CAACpD,EAAE,KAAKmB,SAAS,CAAC;IAC5E,IAAI+B,SAAS,KAAK,CAAC,CAAC,EAAE;MAClB,OAAO,IAAI;IACf;IACA,MAAME,KAAK,GAAGzC,QAAQ,CAACsC,MAAM,CAACC,SAAS,GAAG,CAAC,CAAC;IAC5C,OAAOE,KAAK,IAAI,IAAI;EACxB;AACJ;AAACC,OAAA,CAAA3E,0BAAA,GAAAA,0BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ITaskResponseDoneResultOutput, ITaskResponseResult, ITaskRunParams } from "@webiny/tasks";
|
|
2
|
+
import type { Context, ICmsImportExportValidatedValidFile } from "../../../../types";
|
|
3
|
+
export type IImportFromUrlProcessAssetsInputFile = Pick<ICmsImportExportValidatedValidFile, "key" | "type">;
|
|
4
|
+
export interface IImportFromUrlProcessAssetsInputError {
|
|
5
|
+
file: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IImportFromUrlProcessAssetsInput {
|
|
9
|
+
modelId: string;
|
|
10
|
+
file: IImportFromUrlProcessAssetsInputFile;
|
|
11
|
+
maxInsertErrors?: number;
|
|
12
|
+
override?: boolean;
|
|
13
|
+
manifest?: string;
|
|
14
|
+
lastAsset?: string;
|
|
15
|
+
errors?: IImportFromUrlProcessAssetsInputError[];
|
|
16
|
+
}
|
|
17
|
+
export type IImportFromUrlProcessAssetsOutput = ITaskResponseDoneResultOutput;
|
|
18
|
+
export interface IImportFromUrlProcessAssets<C extends Context = Context, I extends IImportFromUrlProcessAssetsInput = IImportFromUrlProcessAssetsInput, O extends IImportFromUrlProcessAssetsOutput = IImportFromUrlProcessAssetsOutput> {
|
|
19
|
+
run(params: ITaskRunParams<C, I, O>): Promise<ITaskResponseResult<I, O>>;
|
|
20
|
+
}
|
package/tasks/domain/importFromUrlProcessAssets/abstractions/ImportFromUrlProcessAssets.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["ImportFromUrlProcessAssets.ts"],"sourcesContent":["import type {\n ITaskResponseDoneResultOutput,\n ITaskResponseResult,\n ITaskRunParams\n} from \"@webiny/tasks\";\nimport type { Context, ICmsImportExportValidatedValidFile } from \"~/types\";\n\nexport type IImportFromUrlProcessAssetsInputFile = Pick<\n ICmsImportExportValidatedValidFile,\n \"key\" | \"type\"\n>;\n\nexport interface IImportFromUrlProcessAssetsInputError {\n file: string;\n message: string;\n}\n\nexport interface IImportFromUrlProcessAssetsInput {\n modelId: string;\n file: IImportFromUrlProcessAssetsInputFile;\n maxInsertErrors?: number;\n override?: boolean;\n manifest?: string;\n lastAsset?: string;\n errors?: IImportFromUrlProcessAssetsInputError[];\n}\n\nexport type IImportFromUrlProcessAssetsOutput = ITaskResponseDoneResultOutput;\n\nexport interface IImportFromUrlProcessAssets<\n C extends Context = Context,\n I extends IImportFromUrlProcessAssetsInput = IImportFromUrlProcessAssetsInput,\n O extends IImportFromUrlProcessAssetsOutput = IImportFromUrlProcessAssetsOutput\n> {\n run(params: ITaskRunParams<C, I, O>): Promise<ITaskResponseResult<I, O>>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Context } from "../../../types";
|
|
2
|
+
import type { IImportFromUrlProcessEntries, IImportFromUrlProcessEntriesInput, IImportFromUrlProcessEntriesOutput } from "./abstractions/ImportFromUrlProcessEntries";
|
|
3
|
+
import type { ITaskResponseResult, ITaskRunParams } from "@webiny/tasks";
|
|
4
|
+
import type { IFileFetcher } from "../../utils/fileFetcher";
|
|
5
|
+
import type { ICompressedFileReader, IDecompressor } from "../../utils/decompressor";
|
|
6
|
+
export interface IImportFromUrlProcessEntriesParams {
|
|
7
|
+
fileFetcher: IFileFetcher;
|
|
8
|
+
reader: ICompressedFileReader;
|
|
9
|
+
decompressor: IDecompressor;
|
|
10
|
+
}
|
|
11
|
+
export declare class ImportFromUrlProcessEntries<C extends Context = Context, I extends IImportFromUrlProcessEntriesInput = IImportFromUrlProcessEntriesInput, O extends IImportFromUrlProcessEntriesOutput = IImportFromUrlProcessEntriesOutput> implements IImportFromUrlProcessEntries<C, I, O> {
|
|
12
|
+
private readonly fileFetcher;
|
|
13
|
+
private readonly reader;
|
|
14
|
+
private readonly decompressor;
|
|
15
|
+
constructor(params: IImportFromUrlProcessEntriesParams);
|
|
16
|
+
run(params: ITaskRunParams<C, I, O>): Promise<ITaskResponseResult<I, O>>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ImportFromUrlProcessEntries = void 0;
|
|
7
|
+
var _types = require("../../../types");
|
|
8
|
+
var _ImportFromUrlProcessEntriesDecompress = require("./ImportFromUrlProcessEntriesDecompress");
|
|
9
|
+
var _ImportFromUrlProcessEntriesInsert = require("./ImportFromUrlProcessEntriesInsert");
|
|
10
|
+
class ImportFromUrlProcessEntries {
|
|
11
|
+
constructor(params) {
|
|
12
|
+
this.fileFetcher = params.fileFetcher;
|
|
13
|
+
this.reader = params.reader;
|
|
14
|
+
this.decompressor = params.decompressor;
|
|
15
|
+
}
|
|
16
|
+
async run(params) {
|
|
17
|
+
const {
|
|
18
|
+
context,
|
|
19
|
+
response,
|
|
20
|
+
input
|
|
21
|
+
} = params;
|
|
22
|
+
if (!input.modelId) {
|
|
23
|
+
return response.error({
|
|
24
|
+
message: `Missing "modelId" in the input.`,
|
|
25
|
+
code: "MISSING_MODEL_ID"
|
|
26
|
+
});
|
|
27
|
+
} else if (!input.file) {
|
|
28
|
+
return response.error({
|
|
29
|
+
message: `No file found in the provided data.`,
|
|
30
|
+
code: "NO_FILE_FOUND"
|
|
31
|
+
});
|
|
32
|
+
} else if (input.file.type !== _types.CmsImportExportFileType.ENTRIES) {
|
|
33
|
+
return response.error({
|
|
34
|
+
message: `Invalid file type. Expected "${_types.CmsImportExportFileType.ENTRIES}" but got "${input.file.type}".`,
|
|
35
|
+
code: "INVALID_FILE_TYPE"
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
let entryManager;
|
|
39
|
+
try {
|
|
40
|
+
entryManager = await context.cms.getEntryManager(input.modelId);
|
|
41
|
+
} catch (ex) {
|
|
42
|
+
return response.error({
|
|
43
|
+
message: `Model "${input.modelId}" not found.`,
|
|
44
|
+
code: "MODEL_NOT_FOUND"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (!input.decompress?.done) {
|
|
48
|
+
try {
|
|
49
|
+
const decompress = new _ImportFromUrlProcessEntriesDecompress.ImportFromUrlProcessEntriesDecompress({
|
|
50
|
+
reader: this.reader,
|
|
51
|
+
decompressor: this.decompressor
|
|
52
|
+
});
|
|
53
|
+
return await decompress.run(params);
|
|
54
|
+
} catch (ex) {
|
|
55
|
+
console.error(ex);
|
|
56
|
+
return response.error({
|
|
57
|
+
message: ex.message,
|
|
58
|
+
code: ex.code || "DECOMPRESS_ERROR",
|
|
59
|
+
data: ex.data,
|
|
60
|
+
stack: ex.stack
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const insert = new _ImportFromUrlProcessEntriesInsert.ImportFromUrlProcessEntriesInsert({
|
|
66
|
+
entryManager,
|
|
67
|
+
fileFetcher: this.fileFetcher
|
|
68
|
+
});
|
|
69
|
+
return await insert.run(params);
|
|
70
|
+
} catch (ex) {
|
|
71
|
+
return response.error({
|
|
72
|
+
message: ex.message,
|
|
73
|
+
code: ex.code || "DECOMPRESS_ERROR",
|
|
74
|
+
data: ex.data,
|
|
75
|
+
stack: ex.stack
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.ImportFromUrlProcessEntries = ImportFromUrlProcessEntries;
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=ImportFromUrlProcessEntries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_types","require","_ImportFromUrlProcessEntriesDecompress","_ImportFromUrlProcessEntriesInsert","ImportFromUrlProcessEntries","constructor","params","fileFetcher","reader","decompressor","run","context","response","input","modelId","error","message","code","file","type","CmsImportExportFileType","ENTRIES","entryManager","cms","getEntryManager","ex","decompress","done","ImportFromUrlProcessEntriesDecompress","console","data","stack","insert","ImportFromUrlProcessEntriesInsert","exports"],"sources":["ImportFromUrlProcessEntries.ts"],"sourcesContent":["import type { Context } from \"~/types\";\nimport { CmsImportExportFileType } from \"~/types\";\nimport type {\n IImportFromUrlProcessEntries,\n IImportFromUrlProcessEntriesInput,\n IImportFromUrlProcessEntriesOutput\n} from \"./abstractions/ImportFromUrlProcessEntries\";\nimport type { ITaskResponseResult, ITaskRunParams } from \"@webiny/tasks\";\nimport type { ICmsEntryManager } from \"@webiny/api-headless-cms/types\";\nimport { ImportFromUrlProcessEntriesDecompress } from \"~/tasks/domain/importFromUrlProcessEntries/ImportFromUrlProcessEntriesDecompress\";\nimport type { IFileFetcher } from \"~/tasks/utils/fileFetcher\";\nimport { ImportFromUrlProcessEntriesInsert } from \"./ImportFromUrlProcessEntriesInsert\";\nimport type { ICompressedFileReader, IDecompressor } from \"~/tasks/utils/decompressor\";\n\nexport interface IImportFromUrlProcessEntriesParams {\n fileFetcher: IFileFetcher;\n reader: ICompressedFileReader;\n decompressor: IDecompressor;\n}\n\nexport class ImportFromUrlProcessEntries<\n C extends Context = Context,\n I extends IImportFromUrlProcessEntriesInput = IImportFromUrlProcessEntriesInput,\n O extends IImportFromUrlProcessEntriesOutput = IImportFromUrlProcessEntriesOutput\n> implements IImportFromUrlProcessEntries<C, I, O>\n{\n private readonly fileFetcher: IFileFetcher;\n private readonly reader: ICompressedFileReader;\n private readonly decompressor: IDecompressor;\n\n public constructor(params: IImportFromUrlProcessEntriesParams) {\n this.fileFetcher = params.fileFetcher;\n this.reader = params.reader;\n this.decompressor = params.decompressor;\n }\n\n public async run(params: ITaskRunParams<C, I, O>): Promise<ITaskResponseResult<I, O>> {\n const { context, response, input } = params;\n\n if (!input.modelId) {\n return response.error({\n message: `Missing \"modelId\" in the input.`,\n code: \"MISSING_MODEL_ID\"\n });\n } else if (!input.file) {\n return response.error({\n message: `No file found in the provided data.`,\n code: \"NO_FILE_FOUND\"\n });\n } else if (input.file.type !== CmsImportExportFileType.ENTRIES) {\n return response.error({\n message: `Invalid file type. Expected \"${CmsImportExportFileType.ENTRIES}\" but got \"${input.file.type}\".`,\n code: \"INVALID_FILE_TYPE\"\n });\n }\n\n let entryManager: ICmsEntryManager;\n try {\n entryManager = await context.cms.getEntryManager(input.modelId);\n } catch (ex) {\n return response.error({\n message: `Model \"${input.modelId}\" not found.`,\n code: \"MODEL_NOT_FOUND\"\n });\n }\n\n if (!input.decompress?.done) {\n try {\n const decompress = new ImportFromUrlProcessEntriesDecompress<C, I, O>({\n reader: this.reader,\n decompressor: this.decompressor\n });\n\n return await decompress.run(params);\n } catch (ex) {\n console.error(ex);\n return response.error({\n message: ex.message,\n code: ex.code || \"DECOMPRESS_ERROR\",\n data: ex.data,\n stack: ex.stack\n });\n }\n }\n\n try {\n const insert = new ImportFromUrlProcessEntriesInsert<C, I, O>({\n entryManager,\n fileFetcher: this.fileFetcher\n });\n return await insert.run(params);\n } catch (ex) {\n return response.error({\n message: ex.message,\n code: ex.code || \"DECOMPRESS_ERROR\",\n data: ex.data,\n stack: ex.stack\n });\n }\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,sCAAA,GAAAD,OAAA;AAEA,IAAAE,kCAAA,GAAAF,OAAA;AASO,MAAMG,2BAA2B,CAKxC;EAKWC,WAAWA,CAACC,MAA0C,EAAE;IAC3D,IAAI,CAACC,WAAW,GAAGD,MAAM,CAACC,WAAW;IACrC,IAAI,CAACC,MAAM,GAAGF,MAAM,CAACE,MAAM;IAC3B,IAAI,CAACC,YAAY,GAAGH,MAAM,CAACG,YAAY;EAC3C;EAEA,MAAaC,GAAGA,CAACJ,MAA+B,EAAsC;IAClF,MAAM;MAAEK,OAAO;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGP,MAAM;IAE3C,IAAI,CAACO,KAAK,CAACC,OAAO,EAAE;MAChB,OAAOF,QAAQ,CAACG,KAAK,CAAC;QAClBC,OAAO,EAAG,iCAAgC;QAC1CC,IAAI,EAAE;MACV,CAAC,CAAC;IACN,CAAC,MAAM,IAAI,CAACJ,KAAK,CAACK,IAAI,EAAE;MACpB,OAAON,QAAQ,CAACG,KAAK,CAAC;QAClBC,OAAO,EAAG,qCAAoC;QAC9CC,IAAI,EAAE;MACV,CAAC,CAAC;IACN,CAAC,MAAM,IAAIJ,KAAK,CAACK,IAAI,CAACC,IAAI,KAAKC,8BAAuB,CAACC,OAAO,EAAE;MAC5D,OAAOT,QAAQ,CAACG,KAAK,CAAC;QAClBC,OAAO,EAAG,gCAA+BI,8BAAuB,CAACC,OAAQ,cAAaR,KAAK,CAACK,IAAI,CAACC,IAAK,IAAG;QACzGF,IAAI,EAAE;MACV,CAAC,CA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E,CAACK,IAAI;QACbC,KAAK,EAAEN,EAAE,CAACM;MACd,CAAC,CAAC;IACN;EACJ;AACJ;AAACG,OAAA,CAAA9B,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ICompressedFileReader, IDecompressor } from "../../utils/decompressor";
|
|
2
|
+
import type { IImportFromUrlProcessEntriesDecompress, IImportFromUrlProcessEntriesDecompressRunParams, IImportFromUrlProcessEntriesDecompressRunResult } from "./abstractions/ImportFromUrlProcessEntriesDecompress";
|
|
3
|
+
import type { IImportFromUrlProcessEntriesInput, IImportFromUrlProcessEntriesOutput } from "./abstractions/ImportFromUrlProcessEntries";
|
|
4
|
+
import type { Context } from "../../../types";
|
|
5
|
+
export interface IImportFromUrlProcessEntriesDecompressParams {
|
|
6
|
+
reader: ICompressedFileReader;
|
|
7
|
+
decompressor: IDecompressor;
|
|
8
|
+
}
|
|
9
|
+
export declare class ImportFromUrlProcessEntriesDecompress<C extends Context = Context, I extends IImportFromUrlProcessEntriesInput = IImportFromUrlProcessEntriesInput, O extends IImportFromUrlProcessEntriesOutput = IImportFromUrlProcessEntriesOutput> implements IImportFromUrlProcessEntriesDecompress<C, I, O> {
|
|
10
|
+
private readonly reader;
|
|
11
|
+
private readonly decompressor;
|
|
12
|
+
constructor(params: IImportFromUrlProcessEntriesDecompressParams);
|
|
13
|
+
run(params: IImportFromUrlProcessEntriesDecompressRunParams<C, I, O>): Promise<IImportFromUrlProcessEntriesDecompressRunResult<I, O>>;
|
|
14
|
+
}
|