@webiny/api-file-manager 0.0.0-unstable.b14eaecf38 → 0.0.0-unstable.b9b64acb6d
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/README.md +7 -13
- package/contants.d.ts +1 -0
- package/contants.js +3 -0
- package/contants.js.map +1 -0
- package/delivery/AssetDelivery/Asset.d.ts +28 -0
- package/delivery/AssetDelivery/Asset.js +59 -0
- package/delivery/AssetDelivery/Asset.js.map +1 -0
- package/delivery/AssetDelivery/AssetDeliveryConfig.d.ts +65 -0
- package/delivery/AssetDelivery/AssetDeliveryConfig.js +94 -0
- package/delivery/AssetDelivery/AssetDeliveryConfig.js.map +1 -0
- package/delivery/AssetDelivery/AssetRequest.d.ts +25 -0
- package/delivery/AssetDelivery/AssetRequest.js +22 -0
- package/delivery/AssetDelivery/AssetRequest.js.map +1 -0
- package/delivery/AssetDelivery/FilesAssetRequestResolver.d.ts +6 -0
- package/delivery/AssetDelivery/FilesAssetRequestResolver.js +30 -0
- package/delivery/AssetDelivery/FilesAssetRequestResolver.js.map +1 -0
- package/delivery/AssetDelivery/NullAssetOutputStrategy.d.ts +4 -0
- package/delivery/AssetDelivery/NullAssetOutputStrategy.js +8 -0
- package/delivery/AssetDelivery/NullAssetOutputStrategy.js.map +1 -0
- package/delivery/AssetDelivery/NullAssetReply.d.ts +4 -0
- package/delivery/AssetDelivery/NullAssetReply.js +13 -0
- package/delivery/AssetDelivery/NullAssetReply.js.map +1 -0
- package/delivery/AssetDelivery/NullAssetResolver.d.ts +5 -0
- package/delivery/AssetDelivery/NullAssetResolver.js +7 -0
- package/delivery/AssetDelivery/NullAssetResolver.js.map +1 -0
- package/delivery/AssetDelivery/NullRequestResolver.d.ts +4 -0
- package/delivery/AssetDelivery/NullRequestResolver.js +7 -0
- package/delivery/AssetDelivery/NullRequestResolver.js.map +1 -0
- package/delivery/AssetDelivery/SetCacheControlHeaders.d.ts +8 -0
- package/delivery/AssetDelivery/SetCacheControlHeaders.js +18 -0
- package/delivery/AssetDelivery/SetCacheControlHeaders.js.map +1 -0
- package/delivery/AssetDelivery/SetResponseHeaders.d.ts +18 -0
- package/delivery/AssetDelivery/SetResponseHeaders.js +18 -0
- package/delivery/AssetDelivery/SetResponseHeaders.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.d.ts +4 -0
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.js +3 -0
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.d.ts +4 -0
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js +3 -0
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetProcessor.d.ts +4 -0
- package/delivery/AssetDelivery/abstractions/AssetProcessor.js +3 -0
- package/delivery/AssetDelivery/abstractions/AssetProcessor.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetReply.d.ts +25 -0
- package/delivery/AssetDelivery/abstractions/AssetReply.js +31 -0
- package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.d.ts +5 -0
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js +3 -0
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetResolver.d.ts +4 -0
- package/delivery/AssetDelivery/abstractions/AssetResolver.js +3 -0
- package/delivery/AssetDelivery/abstractions/AssetResolver.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.d.ts +4 -0
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js +3 -0
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js.map +1 -0
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.d.ts +2 -0
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js +8 -0
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.d.ts +4 -0
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js +3 -0
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.d.ts +4 -0
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js +19 -0
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.d.ts +4 -0
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +8 -0
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.d.ts +8 -0
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +20 -0
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/PrivateCache.d.ts +6 -0
- package/delivery/AssetDelivery/privateFiles/PrivateCache.js +21 -0
- package/delivery/AssetDelivery/privateFiles/PrivateCache.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.d.ts +8 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +30 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.d.ts +13 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js +63 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/PublicCache.d.ts +6 -0
- package/delivery/AssetDelivery/privateFiles/PublicCache.js +21 -0
- package/delivery/AssetDelivery/privateFiles/PublicCache.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.d.ts +7 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +20 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.d.ts +7 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +20 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -0
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.d.ts +4 -0
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js +7 -0
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js.map +1 -0
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.d.ts +4 -0
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js +7 -0
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +1 -0
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.d.ts +6 -0
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js +19 -0
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js.map +1 -0
- package/delivery/index.d.ts +16 -0
- package/delivery/index.js +12 -0
- package/delivery/index.js.map +1 -0
- package/delivery/setupAssetDelivery.d.ts +2 -0
- package/delivery/setupAssetDelivery.js +114 -0
- package/delivery/setupAssetDelivery.js.map +1 -0
- package/domain/file/abstractions.d.ts +9 -0
- package/domain/file/abstractions.js +8 -0
- package/domain/file/abstractions.js.map +1 -0
- package/domain/file/errors.d.ts +59 -0
- package/domain/file/errors.js +89 -0
- package/domain/file/errors.js.map +1 -0
- package/domain/file/file.model.d.ts +12 -0
- package/domain/file/file.model.js +56 -0
- package/domain/file/file.model.js.map +1 -0
- package/domain/file/types.d.ts +51 -0
- package/domain/file/types.js +3 -0
- package/domain/file/types.js.map +1 -0
- package/domain/identity/Identity.d.ts +9 -0
- package/domain/identity/Identity.js +11 -0
- package/domain/identity/Identity.js.map +1 -0
- package/domain/settings/constants.d.ts +1 -0
- package/domain/settings/constants.js +3 -0
- package/domain/settings/constants.js.map +1 -0
- package/domain/settings/errors.d.ts +18 -0
- package/domain/settings/errors.js +30 -0
- package/domain/settings/errors.js.map +1 -0
- package/domain/settings/types.d.ts +10 -0
- package/domain/settings/types.js +3 -0
- package/domain/settings/types.js.map +1 -0
- package/domain/settings/validation.d.ts +14 -0
- package/domain/settings/validation.js +36 -0
- package/domain/settings/validation.js.map +1 -0
- package/features/FileManagerFeature.d.ts +1 -0
- package/features/FileManagerFeature.js +28 -0
- package/features/FileManagerFeature.js.map +1 -0
- package/features/file/CreateFile/CreateFileRepository.d.ts +15 -0
- package/features/file/CreateFile/CreateFileRepository.js +30 -0
- package/features/file/CreateFile/CreateFileRepository.js.map +1 -0
- package/features/file/CreateFile/CreateFileUseCase.d.ts +21 -0
- package/features/file/CreateFile/CreateFileUseCase.js +89 -0
- package/features/file/CreateFile/CreateFileUseCase.js.map +1 -0
- package/features/file/CreateFile/abstractions.d.ts +57 -0
- package/features/file/CreateFile/abstractions.js +15 -0
- package/features/file/CreateFile/abstractions.js.map +1 -0
- package/features/file/CreateFile/events.d.ts +29 -0
- package/features/file/CreateFile/events.js +28 -0
- package/features/file/CreateFile/events.js.map +1 -0
- package/features/file/CreateFile/feature.d.ts +1 -0
- package/features/file/CreateFile/feature.js +12 -0
- package/features/file/CreateFile/feature.js.map +1 -0
- package/features/file/CreateFile/index.d.ts +2 -0
- package/features/file/CreateFile/index.js +4 -0
- package/features/file/CreateFile/index.js.map +1 -0
- package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.d.ts +13 -0
- package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js +24 -0
- package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js.map +1 -0
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.d.ts +19 -0
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js +84 -0
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js.map +1 -0
- package/features/file/CreateFilesInBatch/abstractions.d.ts +40 -0
- package/features/file/CreateFilesInBatch/abstractions.js +15 -0
- package/features/file/CreateFilesInBatch/abstractions.js.map +1 -0
- package/features/file/CreateFilesInBatch/events.d.ts +29 -0
- package/features/file/CreateFilesInBatch/events.js +28 -0
- package/features/file/CreateFilesInBatch/events.js.map +1 -0
- package/features/file/CreateFilesInBatch/feature.d.ts +1 -0
- package/features/file/CreateFilesInBatch/feature.js +12 -0
- package/features/file/CreateFilesInBatch/feature.js.map +1 -0
- package/features/file/CreateFilesInBatch/index.d.ts +1 -0
- package/features/file/CreateFilesInBatch/index.js +3 -0
- package/features/file/CreateFilesInBatch/index.js.map +1 -0
- package/features/file/DeleteFile/DeleteFileRepository.d.ts +15 -0
- package/features/file/DeleteFile/DeleteFileRepository.js +30 -0
- package/features/file/DeleteFile/DeleteFileRepository.js.map +1 -0
- package/features/file/DeleteFile/DeleteFileUseCase.d.ts +17 -0
- package/features/file/DeleteFile/DeleteFileUseCase.js +45 -0
- package/features/file/DeleteFile/DeleteFileUseCase.js.map +1 -0
- package/features/file/DeleteFile/abstractions.d.ts +37 -0
- package/features/file/DeleteFile/abstractions.js +15 -0
- package/features/file/DeleteFile/abstractions.js.map +1 -0
- package/features/file/DeleteFile/events.d.ts +27 -0
- package/features/file/DeleteFile/events.js +28 -0
- package/features/file/DeleteFile/events.js.map +1 -0
- package/features/file/DeleteFile/feature.d.ts +1 -0
- package/features/file/DeleteFile/feature.js +12 -0
- package/features/file/DeleteFile/feature.js.map +1 -0
- package/features/file/DeleteFile/index.d.ts +2 -0
- package/features/file/DeleteFile/index.js +4 -0
- package/features/file/DeleteFile/index.js.map +1 -0
- package/features/file/FileUrlGenerator/abstractions.d.ts +8 -0
- package/features/file/FileUrlGenerator/abstractions.js +4 -0
- package/features/file/FileUrlGenerator/abstractions.js.map +1 -0
- package/features/file/GetFile/GetFileRepository.d.ts +15 -0
- package/features/file/GetFile/GetFileRepository.js +33 -0
- package/features/file/GetFile/GetFileRepository.js.map +1 -0
- package/features/file/GetFile/GetFileUseCase.d.ts +14 -0
- package/features/file/GetFile/GetFileUseCase.js +31 -0
- package/features/file/GetFile/GetFileUseCase.js.map +1 -0
- package/features/file/GetFile/abstractions.d.ts +38 -0
- package/features/file/GetFile/abstractions.js +15 -0
- package/features/file/GetFile/abstractions.js.map +1 -0
- package/features/file/GetFile/feature.d.ts +1 -0
- package/features/file/GetFile/feature.js +12 -0
- package/features/file/GetFile/feature.js.map +1 -0
- package/features/file/GetFile/index.d.ts +1 -0
- package/features/file/GetFile/index.js +3 -0
- package/features/file/GetFile/index.js.map +1 -0
- package/features/file/ListFiles/ListFilesRepository.d.ts +18 -0
- package/features/file/ListFiles/ListFilesRepository.js +51 -0
- package/features/file/ListFiles/ListFilesRepository.js.map +1 -0
- package/features/file/ListFiles/ListFilesUseCase.d.ts +15 -0
- package/features/file/ListFiles/ListFilesUseCase.js +45 -0
- package/features/file/ListFiles/ListFilesUseCase.js.map +1 -0
- package/features/file/ListFiles/abstractions.d.ts +47 -0
- package/features/file/ListFiles/abstractions.js +15 -0
- package/features/file/ListFiles/abstractions.js.map +1 -0
- package/features/file/ListFiles/feature.d.ts +1 -0
- package/features/file/ListFiles/feature.js +12 -0
- package/features/file/ListFiles/feature.js.map +1 -0
- package/features/file/ListFiles/index.d.ts +1 -0
- package/features/file/ListFiles/index.js +3 -0
- package/features/file/ListFiles/index.js.map +1 -0
- package/features/file/ListTags/ListTagsRepository.d.ts +16 -0
- package/features/file/ListTags/ListTagsRepository.js +47 -0
- package/features/file/ListTags/ListTagsRepository.js.map +1 -0
- package/features/file/ListTags/ListTagsUseCase.d.ts +13 -0
- package/features/file/ListTags/ListTagsUseCase.js +31 -0
- package/features/file/ListTags/ListTagsUseCase.js.map +1 -0
- package/features/file/ListTags/abstractions.d.ts +43 -0
- package/features/file/ListTags/abstractions.js +15 -0
- package/features/file/ListTags/abstractions.js.map +1 -0
- package/features/file/ListTags/feature.d.ts +1 -0
- package/features/file/ListTags/feature.js +12 -0
- package/features/file/ListTags/feature.js.map +1 -0
- package/features/file/ListTags/index.d.ts +1 -0
- package/features/file/ListTags/index.js +3 -0
- package/features/file/ListTags/index.js.map +1 -0
- package/features/file/UpdateFile/UpdateFileRepository.d.ts +15 -0
- package/features/file/UpdateFile/UpdateFileRepository.js +39 -0
- package/features/file/UpdateFile/UpdateFileRepository.js.map +1 -0
- package/features/file/UpdateFile/UpdateFileUseCase.d.ts +20 -0
- package/features/file/UpdateFile/UpdateFileUseCase.js +78 -0
- package/features/file/UpdateFile/UpdateFileUseCase.js.map +1 -0
- package/features/file/UpdateFile/abstractions.d.ts +53 -0
- package/features/file/UpdateFile/abstractions.js +15 -0
- package/features/file/UpdateFile/abstractions.js.map +1 -0
- package/features/file/UpdateFile/events.d.ts +32 -0
- package/features/file/UpdateFile/events.js +28 -0
- package/features/file/UpdateFile/events.js.map +1 -0
- package/features/file/UpdateFile/feature.d.ts +1 -0
- package/features/file/UpdateFile/feature.js +12 -0
- package/features/file/UpdateFile/feature.js.map +1 -0
- package/features/file/UpdateFile/index.d.ts +2 -0
- package/features/file/UpdateFile/index.js +4 -0
- package/features/file/UpdateFile/index.js.map +1 -0
- package/features/file/shared/EntryToFileMapper.d.ts +5 -0
- package/features/file/shared/EntryToFileMapper.js +26 -0
- package/features/file/shared/EntryToFileMapper.js.map +1 -0
- package/features/file/shared/FileInputToEntryInputMapper.d.ts +5 -0
- package/features/file/shared/FileInputToEntryInputMapper.js +30 -0
- package/features/file/shared/FileInputToEntryInputMapper.js.map +1 -0
- package/features/file/shared/FileToEntryMapper.d.ts +5 -0
- package/features/file/shared/FileToEntryMapper.js +29 -0
- package/features/file/shared/FileToEntryMapper.js.map +1 -0
- package/features/settings/GetSettings/GetSettingsUseCase.d.ts +13 -0
- package/features/settings/GetSettings/GetSettingsUseCase.js +28 -0
- package/features/settings/GetSettings/GetSettingsUseCase.js.map +1 -0
- package/features/settings/GetSettings/abstractions.d.ts +17 -0
- package/features/settings/GetSettings/abstractions.js +9 -0
- package/features/settings/GetSettings/abstractions.js.map +1 -0
- package/features/settings/GetSettings/feature.d.ts +1 -0
- package/features/settings/GetSettings/feature.js +10 -0
- package/features/settings/GetSettings/feature.js.map +1 -0
- package/features/settings/SettingsInstaller/SettingsInstaller.d.ts +15 -0
- package/features/settings/SettingsInstaller/SettingsInstaller.js +35 -0
- package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -0
- package/features/settings/SettingsInstaller/feature.d.ts +1 -0
- package/features/settings/SettingsInstaller/feature.js +10 -0
- package/features/settings/SettingsInstaller/feature.js.map +1 -0
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.d.ts +18 -0
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js +62 -0
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js.map +1 -0
- package/features/settings/UpdateSettings/abstractions.d.ts +22 -0
- package/features/settings/UpdateSettings/abstractions.js +9 -0
- package/features/settings/UpdateSettings/abstractions.js.map +1 -0
- package/features/settings/UpdateSettings/events.d.ts +32 -0
- package/features/settings/UpdateSettings/events.js +28 -0
- package/features/settings/UpdateSettings/events.js.map +1 -0
- package/features/settings/UpdateSettings/feature.d.ts +1 -0
- package/features/settings/UpdateSettings/feature.js +10 -0
- package/features/settings/UpdateSettings/feature.js.map +1 -0
- package/features/settings/UpdateSettings/index.d.ts +2 -0
- package/features/settings/UpdateSettings/index.js +4 -0
- package/features/settings/UpdateSettings/index.js.map +1 -0
- package/features/shared/abstractions.d.ts +1 -0
- package/features/shared/abstractions.js +3 -0
- package/features/shared/abstractions.js.map +1 -0
- package/graphql/baseSchema.d.ts +3 -0
- package/graphql/baseSchema.js +103 -0
- package/graphql/baseSchema.js.map +1 -0
- package/graphql/createFilesTypeDefs.d.ts +7 -0
- package/graphql/createFilesTypeDefs.js +199 -0
- package/graphql/createFilesTypeDefs.js.map +1 -0
- package/graphql/filesSchema.d.ts +4 -0
- package/graphql/filesSchema.js +116 -0
- package/graphql/filesSchema.js.map +1 -0
- package/graphql/getFileByUrl.d.ts +3 -0
- package/graphql/getFileByUrl.js +69 -0
- package/graphql/getFileByUrl.js.map +1 -0
- package/graphql/index.d.ts +3 -2
- package/graphql/index.js +51 -286
- package/graphql/index.js.map +1 -1
- package/graphql/utils.d.ts +11 -0
- package/graphql/utils.js +17 -0
- package/graphql/utils.js.map +1 -0
- package/index.d.ts +6 -5
- package/index.js +32 -63
- package/index.js.map +1 -1
- package/modelModifier/CmsModelModifier.d.ts +26 -0
- package/modelModifier/CmsModelModifier.js +54 -0
- package/modelModifier/CmsModelModifier.js.map +1 -0
- package/package.json +26 -37
- package/permissions/schema.d.ts +73 -0
- package/permissions/schema.js +20 -0
- package/permissions/schema.js.map +1 -0
- package/types.d.ts +1 -355
- package/types.js +2 -26
- package/types.js.map +1 -1
- package/createFileManager/checkBasePermissions.d.ts +0 -5
- package/createFileManager/checkBasePermissions.js +0 -24
- package/createFileManager/checkBasePermissions.js.map +0 -1
- package/createFileManager/files.crud.d.ts +0 -3
- package/createFileManager/files.crud.js +0 -318
- package/createFileManager/files.crud.js.map +0 -1
- package/createFileManager/filevalidation.disabled.d.ts +0 -0
- package/createFileManager/filevalidation.disabled.js +0 -55
- package/createFileManager/filevalidation.disabled.js.map +0 -1
- package/createFileManager/index.d.ts +0 -13
- package/createFileManager/index.js +0 -20
- package/createFileManager/index.js.map +0 -1
- package/createFileManager/settings.crud.d.ts +0 -3
- package/createFileManager/settings.crud.js +0 -91
- package/createFileManager/settings.crud.js.map +0 -1
- package/createFileManager/system.crud.d.ts +0 -3
- package/createFileManager/system.crud.js +0 -86
- package/createFileManager/system.crud.js.map +0 -1
- package/handlers/download/byAlias.d.ts +0 -6
- package/handlers/download/byAlias.js +0 -89
- package/handlers/download/byAlias.js.map +0 -1
- package/handlers/download/byExactKey.d.ts +0 -2
- package/handlers/download/byExactKey.js +0 -57
- package/handlers/download/byExactKey.js.map +0 -1
- package/handlers/download/extractFileInformation.d.ts +0 -9
- package/handlers/download/extractFileInformation.js +0 -20
- package/handlers/download/extractFileInformation.js.map +0 -1
- package/handlers/download/getS3Object.d.ts +0 -10
- package/handlers/download/getS3Object.js +0 -57
- package/handlers/download/getS3Object.js.map +0 -1
- package/handlers/download/index.d.ts +0 -2
- package/handlers/download/index.js +0 -27
- package/handlers/download/index.js.map +0 -1
- package/handlers/manage/index.d.ts +0 -5
- package/handlers/manage/index.js +0 -55
- package/handlers/manage/index.js.map +0 -1
- package/handlers/transform/index.d.ts +0 -2
- package/handlers/transform/index.js +0 -89
- package/handlers/transform/index.js.map +0 -1
- package/handlers/transform/legacyUtils.d.ts +0 -17
- package/handlers/transform/legacyUtils.js +0 -42
- package/handlers/transform/legacyUtils.js.map +0 -1
- package/handlers/transform/loaders/imageLoader.d.ts +0 -30
- package/handlers/transform/loaders/imageLoader.js +0 -94
- package/handlers/transform/loaders/imageLoader.js.map +0 -1
- package/handlers/transform/loaders/index.d.ts +0 -8
- package/handlers/transform/loaders/index.js +0 -10
- package/handlers/transform/loaders/index.js.map +0 -1
- package/handlers/transform/loaders/sanitizeImageTransformations.d.ts +0 -11
- package/handlers/transform/loaders/sanitizeImageTransformations.js +0 -45
- package/handlers/transform/loaders/sanitizeImageTransformations.js.map +0 -1
- package/handlers/transform/managers/imageManager.d.ts +0 -15
- package/handlers/transform/managers/imageManager.js +0 -74
- package/handlers/transform/managers/imageManager.js.map +0 -1
- package/handlers/transform/managers/index.d.ts +0 -5
- package/handlers/transform/managers/index.js +0 -10
- package/handlers/transform/managers/index.js.map +0 -1
- package/handlers/transform/optimizeImage.d.ts +0 -3
- package/handlers/transform/optimizeImage.js +0 -42
- package/handlers/transform/optimizeImage.js.map +0 -1
- package/handlers/transform/transformImage.d.ts +0 -10
- package/handlers/transform/transformImage.js +0 -25
- package/handlers/transform/transformImage.js.map +0 -1
- package/handlers/transform/utils.d.ts +0 -12
- package/handlers/transform/utils.js +0 -36
- package/handlers/transform/utils.js.map +0 -1
- package/handlers/types.d.ts +0 -8
- package/handlers/types.js +0 -5
- package/handlers/types.js.map +0 -1
- package/handlers/utils/getEnvironment.d.ts +0 -5
- package/handlers/utils/getEnvironment.js +0 -11
- package/handlers/utils/getEnvironment.js.map +0 -1
- package/handlers/utils/getObjectParams.d.ts +0 -9
- package/handlers/utils/getObjectParams.js +0 -21
- package/handlers/utils/getObjectParams.js.map +0 -1
- package/handlers/utils/index.d.ts +0 -2
- package/handlers/utils/index.js +0 -20
- package/handlers/utils/index.js.map +0 -1
- package/plugins/FilePhysicalStoragePlugin.d.ts +0 -21
- package/plugins/FilePhysicalStoragePlugin.js +0 -31
- package/plugins/FilePhysicalStoragePlugin.js.map +0 -1
- package/plugins/FileStorageTransformPlugin.d.ts +0 -34
- package/plugins/FileStorageTransformPlugin.js +0 -40
- package/plugins/FileStorageTransformPlugin.js.map +0 -1
- package/plugins/crud/files/validation.d.ts +0 -3
- package/plugins/crud/files/validation.js +0 -41
- package/plugins/crud/files/validation.js.map +0 -1
- package/plugins/crud/files.crud.d.ts +0 -4
- package/plugins/crud/files.crud.js +0 -431
- package/plugins/crud/files.crud.js.map +0 -1
- package/plugins/crud/settings.crud.d.ts +0 -5
- package/plugins/crud/settings.crud.js +0 -116
- package/plugins/crud/settings.crud.js.map +0 -1
- package/plugins/crud/system.crud.d.ts +0 -4
- package/plugins/crud/system.crud.js +0 -153
- package/plugins/crud/system.crud.js.map +0 -1
- package/plugins/crud/utils/checkBasePermissions.d.ts +0 -5
- package/plugins/crud/utils/checkBasePermissions.js +0 -33
- package/plugins/crud/utils/checkBasePermissions.js.map +0 -1
- package/plugins/crud/utils/createFileModel.d.ts +0 -5
- package/plugins/crud/utils/createFileModel.js +0 -77
- package/plugins/crud/utils/createFileModel.js.map +0 -1
- package/plugins/crud/utils/lifecycleEvents.d.ts +0 -6
- package/plugins/crud/utils/lifecycleEvents.js +0 -38
- package/plugins/crud/utils/lifecycleEvents.js.map +0 -1
- package/plugins/definitions/FilePhysicalStoragePlugin.d.ts +0 -21
- package/plugins/definitions/FilePhysicalStoragePlugin.js +0 -42
- package/plugins/definitions/FilePhysicalStoragePlugin.js.map +0 -1
- package/plugins/definitions/FilePlugin.d.ts +0 -136
- package/plugins/definitions/FilePlugin.js +0 -70
- package/plugins/definitions/FilePlugin.js.map +0 -1
- package/plugins/definitions/FileStorageTransformPlugin.d.ts +0 -34
- package/plugins/definitions/FileStorageTransformPlugin.js +0 -51
- package/plugins/definitions/FileStorageTransformPlugin.js.map +0 -1
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/definitions/InstallationPlugin.d.ts +0 -19
- package/plugins/definitions/InstallationPlugin.js +0 -42
- package/plugins/definitions/InstallationPlugin.js.map +0 -1
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/graphql.d.ts +0 -4
- package/plugins/graphql.js +0 -290
- package/plugins/graphql.js.map +0 -1
- package/plugins/index.d.ts +0 -2
- package/plugins/index.js +0 -27
- package/plugins/index.js.map +0 -1
- package/plugins/storage/FileStorage.d.ts +0 -30
- package/plugins/storage/FileStorage.js +0 -103
- package/plugins/storage/FileStorage.js.map +0 -1
- package/plugins/storage/index.d.ts +0 -4
- package/plugins/storage/index.js +0 -26
- package/plugins/storage/index.js.map +0 -1
- package/storage/FileStorage.d.ts +0 -32
- package/storage/FileStorage.js +0 -86
- package/storage/FileStorage.js.map +0 -1
- package/types/file.d.ts +0 -33
- package/types/file.js +0 -5
- package/types/file.js.map +0 -1
- package/types/file.lifecycle.d.ts +0 -40
- package/types/file.lifecycle.js +0 -5
- package/types/file.lifecycle.js.map +0 -1
- package/utils.d.ts +0 -4
- package/utils.js +0 -16
- package/utils.js.map +0 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { renderFields } from "@webiny/api-headless-cms/utils/renderFields.js";
|
|
2
|
+
import { renderInputFields } from "@webiny/api-headless-cms/utils/renderInputFields.js";
|
|
3
|
+
import { renderListFilterFields } from "@webiny/api-headless-cms/utils/renderListFilterFields.js";
|
|
4
|
+
const removeFieldRequiredValidation = field => {
|
|
5
|
+
if (field.validation) {
|
|
6
|
+
field.validation = field.validation.filter(validation => validation.name !== "required");
|
|
7
|
+
}
|
|
8
|
+
if (field.listValidation) {
|
|
9
|
+
field.listValidation = field.listValidation.filter(v => v.name !== "required");
|
|
10
|
+
}
|
|
11
|
+
return field;
|
|
12
|
+
};
|
|
13
|
+
const createUpdateFields = fields => {
|
|
14
|
+
return fields.reduce((collection, field) => {
|
|
15
|
+
collection.push(removeFieldRequiredValidation({
|
|
16
|
+
...field
|
|
17
|
+
}));
|
|
18
|
+
return collection;
|
|
19
|
+
}, []);
|
|
20
|
+
};
|
|
21
|
+
export const createFilesTypeDefs = params => {
|
|
22
|
+
const {
|
|
23
|
+
model,
|
|
24
|
+
models,
|
|
25
|
+
plugins: fieldTypePlugins
|
|
26
|
+
} = params;
|
|
27
|
+
const {
|
|
28
|
+
fields
|
|
29
|
+
} = model;
|
|
30
|
+
const fieldTypes = renderFields({
|
|
31
|
+
models,
|
|
32
|
+
model,
|
|
33
|
+
fields,
|
|
34
|
+
type: "manage",
|
|
35
|
+
fieldTypePlugins
|
|
36
|
+
});
|
|
37
|
+
const inputCreateFields = renderInputFields({
|
|
38
|
+
models,
|
|
39
|
+
model,
|
|
40
|
+
fields,
|
|
41
|
+
fieldTypePlugins
|
|
42
|
+
});
|
|
43
|
+
const inputUpdateFields = renderInputFields({
|
|
44
|
+
models,
|
|
45
|
+
model,
|
|
46
|
+
fields: createUpdateFields(fields),
|
|
47
|
+
fieldTypePlugins
|
|
48
|
+
});
|
|
49
|
+
const listFilterFieldsRender = renderListFilterFields({
|
|
50
|
+
model,
|
|
51
|
+
fields: model.fields,
|
|
52
|
+
type: "manage",
|
|
53
|
+
fieldTypePlugins,
|
|
54
|
+
excludeFields: ["entryId", "status"]
|
|
55
|
+
});
|
|
56
|
+
return /* GraphQL */`
|
|
57
|
+
type FmFile_Location {
|
|
58
|
+
folderId: ID!
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
input FmFile_LocationInput {
|
|
62
|
+
folderId: ID!
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
input FmFile_LocationWhereInput {
|
|
66
|
+
folderId: ID
|
|
67
|
+
folderId_in: [ID!]
|
|
68
|
+
folderId_not: ID
|
|
69
|
+
folderId_not_in: [ID!]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
${fieldTypes.map(f => f.typeDefs).join("\n")}
|
|
73
|
+
|
|
74
|
+
type FmFile {
|
|
75
|
+
id: ID!
|
|
76
|
+
createdOn: DateTime!
|
|
77
|
+
modifiedOn: DateTime
|
|
78
|
+
savedOn: DateTime!
|
|
79
|
+
createdBy: FmCreatedBy!
|
|
80
|
+
modifiedBy: FmCreatedBy
|
|
81
|
+
savedBy: FmCreatedBy!
|
|
82
|
+
location: FmFile_Location!
|
|
83
|
+
src: String
|
|
84
|
+
${fieldTypes.map(f => f.fields).join("\n")}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
${inputCreateFields.map(f => f.typeDefs).join("\n")}
|
|
88
|
+
|
|
89
|
+
input FmCreatedByInput {
|
|
90
|
+
id: ID!
|
|
91
|
+
displayName: String!
|
|
92
|
+
type: String!
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
input FmFileCreateInput {
|
|
96
|
+
id: ID!
|
|
97
|
+
createdOn: DateTime
|
|
98
|
+
modifiedOn: DateTime
|
|
99
|
+
savedOn: DateTime
|
|
100
|
+
createdBy: FmCreatedByInput
|
|
101
|
+
modifiedBy: FmCreatedByInput
|
|
102
|
+
savedBy: FmCreatedByInput
|
|
103
|
+
location: FmFile_LocationInput
|
|
104
|
+
${inputCreateFields.map(f => f.fields).join("\n")}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
input FmFileUpdateInput {
|
|
108
|
+
createdOn: DateTime
|
|
109
|
+
modifiedOn: DateTime
|
|
110
|
+
savedOn: DateTime
|
|
111
|
+
createdBy: FmCreatedByInput
|
|
112
|
+
modifiedBy: FmCreatedByInput
|
|
113
|
+
savedBy: FmCreatedByInput
|
|
114
|
+
location: FmFile_LocationInput
|
|
115
|
+
${inputUpdateFields.map(f => f.fields).join("\n")}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type FmFileResponse {
|
|
119
|
+
data: FmFile
|
|
120
|
+
error: FmError
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
input FmFileListWhereInput {
|
|
124
|
+
${listFilterFieldsRender.allFiltersAsString()}
|
|
125
|
+
location: FmFile_LocationWhereInput
|
|
126
|
+
AND: [FmFileListWhereInput!]
|
|
127
|
+
OR: [FmFileListWhereInput!]
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
type FmFileListResponse {
|
|
131
|
+
data: [FmFile!]
|
|
132
|
+
error: FmError
|
|
133
|
+
meta: FmListMeta
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
enum FmFileListSorter {
|
|
137
|
+
savedOn_ASC
|
|
138
|
+
savedOn_DESC
|
|
139
|
+
createdOn_ASC
|
|
140
|
+
createdOn_DESC
|
|
141
|
+
name_ASC
|
|
142
|
+
name_DESC
|
|
143
|
+
key_ASC
|
|
144
|
+
key_DESC
|
|
145
|
+
type_ASC
|
|
146
|
+
type_DESC
|
|
147
|
+
size_ASC
|
|
148
|
+
size_DESC
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
input FmTagsListWhereInput {
|
|
152
|
+
createdBy: String
|
|
153
|
+
tags_startsWith: String
|
|
154
|
+
tags_not_startsWith: String
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
type FmTag {
|
|
158
|
+
tag: String!
|
|
159
|
+
count: Number!
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
type FmTagsListResponse {
|
|
163
|
+
data: [FmTag!]
|
|
164
|
+
error: FmError
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
type FmCreateFilesResponse {
|
|
168
|
+
data: [FmFile!]
|
|
169
|
+
error: FmError
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
type FmFileModelResponse {
|
|
173
|
+
data: JSON
|
|
174
|
+
error: FmError
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
extend type FmQuery {
|
|
178
|
+
getFileModel: FmFileModelResponse!
|
|
179
|
+
getFile(id: ID!): FmFileResponse!
|
|
180
|
+
listFiles(
|
|
181
|
+
search: String
|
|
182
|
+
where: FmFileListWhereInput
|
|
183
|
+
limit: Int
|
|
184
|
+
after: String
|
|
185
|
+
sort: [FmFileListSorter!]
|
|
186
|
+
): FmFileListResponse!
|
|
187
|
+
listTags(where: FmTagsListWhereInput): FmTagsListResponse!
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
extend type FmMutation {
|
|
191
|
+
createFile(data: FmFileCreateInput!): FmFileResponse!
|
|
192
|
+
createFiles(data: [FmFileCreateInput!]!): FmCreateFilesResponse!
|
|
193
|
+
updateFile(id: ID!, data: FmFileUpdateInput!): FmFileResponse!
|
|
194
|
+
deleteFile(id: ID!): FmBooleanResponse!
|
|
195
|
+
}
|
|
196
|
+
`;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
//# sourceMappingURL=createFilesTypeDefs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["renderFields","renderInputFields","renderListFilterFields","removeFieldRequiredValidation","field","validation","filter","name","listValidation","v","createUpdateFields","fields","reduce","collection","push","createFilesTypeDefs","params","model","models","plugins","fieldTypePlugins","fieldTypes","type","inputCreateFields","inputUpdateFields","listFilterFieldsRender","excludeFields","map","f","typeDefs","join","allFiltersAsString"],"sources":["createFilesTypeDefs.ts"],"sourcesContent":["import type {\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields.js\";\nimport { renderInputFields } from \"@webiny/api-headless-cms/utils/renderInputFields.js\";\nimport { renderListFilterFields } from \"@webiny/api-headless-cms/utils/renderListFilterFields.js\";\n\nexport interface CreateFilesTypeDefsParams {\n model: CmsModel;\n models: CmsModel[];\n plugins: CmsFieldTypePlugins;\n}\n\nconst removeFieldRequiredValidation = (field: CmsModelField) => {\n if (field.validation) {\n field.validation = field.validation.filter(validation => validation.name !== \"required\");\n }\n if (field.listValidation) {\n field.listValidation = field.listValidation.filter(v => v.name !== \"required\");\n }\n return field;\n};\n\nconst createUpdateFields = (fields: CmsModelField[]): CmsModelField[] => {\n return fields.reduce<CmsModelField[]>((collection, field) => {\n collection.push(removeFieldRequiredValidation({ ...field }));\n return collection;\n }, []);\n};\n\nexport const createFilesTypeDefs = (params: CreateFilesTypeDefsParams): string => {\n const { model, models, plugins: fieldTypePlugins } = params;\n const { fields } = model;\n\n const fieldTypes = renderFields({\n models,\n model,\n fields,\n type: \"manage\",\n fieldTypePlugins\n });\n const inputCreateFields = renderInputFields({\n models,\n model,\n fields,\n fieldTypePlugins\n });\n const inputUpdateFields = renderInputFields({\n models,\n model,\n fields: createUpdateFields(fields),\n fieldTypePlugins\n });\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins,\n excludeFields: [\"entryId\", \"status\"]\n });\n\n return /* GraphQL */ `\n type FmFile_Location {\n folderId: ID!\n }\n\n input FmFile_LocationInput {\n folderId: ID!\n }\n\n input FmFile_LocationWhereInput {\n folderId: ID\n folderId_in: [ID!]\n folderId_not: ID\n folderId_not_in: [ID!]\n }\n \n ${fieldTypes.map(f => f.typeDefs).join(\"\\n\")}\n\n type FmFile {\n id: ID!\n createdOn: DateTime!\n modifiedOn: DateTime\n savedOn: DateTime!\n createdBy: FmCreatedBy!\n modifiedBy: FmCreatedBy\n savedBy: FmCreatedBy!\n location: FmFile_Location!\n src: String\n ${fieldTypes.map(f => f.fields).join(\"\\n\")}\n }\n\n ${inputCreateFields.map(f => f.typeDefs).join(\"\\n\")}\n \n input FmCreatedByInput {\n id: ID!\n displayName: String!\n type: String!\n }\n\n input FmFileCreateInput {\n id: ID!\n createdOn: DateTime\n modifiedOn: DateTime\n savedOn: DateTime\n createdBy: FmCreatedByInput\n modifiedBy: FmCreatedByInput\n savedBy: FmCreatedByInput\n location: FmFile_LocationInput\n ${inputCreateFields.map(f => f.fields).join(\"\\n\")}\n }\n\n input FmFileUpdateInput {\n createdOn: DateTime\n modifiedOn: DateTime\n savedOn: DateTime\n createdBy: FmCreatedByInput\n modifiedBy: FmCreatedByInput\n savedBy: FmCreatedByInput\n location: FmFile_LocationInput\n ${inputUpdateFields.map(f => f.fields).join(\"\\n\")}\n }\n\n type FmFileResponse {\n data: FmFile\n error: FmError\n }\n\n input FmFileListWhereInput {\n ${listFilterFieldsRender.allFiltersAsString()}\n location: FmFile_LocationWhereInput\n AND: [FmFileListWhereInput!]\n OR: [FmFileListWhereInput!]\n }\n\n type FmFileListResponse {\n data: [FmFile!]\n error: FmError\n meta: FmListMeta\n }\n\n enum FmFileListSorter {\n savedOn_ASC\n savedOn_DESC\n createdOn_ASC\n createdOn_DESC\n name_ASC\n name_DESC\n key_ASC\n key_DESC\n type_ASC\n type_DESC\n size_ASC\n size_DESC\n }\n\n input FmTagsListWhereInput {\n createdBy: String\n tags_startsWith: String\n tags_not_startsWith: String\n }\n\n type FmTag {\n tag: String!\n count: Number!\n }\n\n type FmTagsListResponse {\n data: [FmTag!]\n error: FmError\n }\n\n type FmCreateFilesResponse {\n data: [FmFile!]\n error: FmError\n }\n \n type FmFileModelResponse {\n data: JSON\n error: FmError\n }\n\n extend type FmQuery {\n getFileModel: FmFileModelResponse!\n getFile(id: ID!): FmFileResponse!\n listFiles(\n search: String\n where: FmFileListWhereInput\n limit: Int\n after: String\n sort: [FmFileListSorter!]\n ): FmFileListResponse!\n listTags(where: FmTagsListWhereInput): FmTagsListResponse!\n }\n\n extend type FmMutation {\n createFile(data: FmFileCreateInput!): FmFileResponse!\n createFiles(data: [FmFileCreateInput!]!): FmCreateFilesResponse!\n updateFile(id: ID!, data: FmFileUpdateInput!): FmFileResponse!\n deleteFile(id: ID!): FmBooleanResponse!\n }\n `;\n};\n"],"mappings":"AAKA,SAASA,YAAY,QAAQ,gDAAgD;AAC7E,SAASC,iBAAiB,QAAQ,qDAAqD;AACvF,SAASC,sBAAsB,QAAQ,0DAA0D;AAQjG,MAAMC,6BAA6B,GAAIC,KAAoB,IAAK;EAC5D,IAAIA,KAAK,CAACC,UAAU,EAAE;IAClBD,KAAK,CAACC,UAAU,GAAGD,KAAK,CAACC,UAAU,CAACC,MAAM,CAACD,UAAU,IAAIA,UAAU,CAACE,IAAI,KAAK,UAAU,CAAC;EAC5F;EACA,IAAIH,KAAK,CAACI,cAAc,EAAE;IACtBJ,KAAK,CAACI,cAAc,GAAGJ,KAAK,CAACI,cAAc,CAACF,MAAM,CAACG,CAAC,IAAIA,CAAC,CAACF,IAAI,KAAK,UAAU,CAAC;EAClF;EACA,OAAOH,KAAK;AAChB,CAAC;AAED,MAAMM,kBAAkB,GAAIC,MAAuB,IAAsB;EACrE,OAAOA,MAAM,CAACC,MAAM,CAAkB,CAACC,UAAU,EAAET,KAAK,KAAK;IACzDS,UAAU,CAACC,IAAI,CAACX,6BAA6B,CAAC;MAAE,GAAGC;IAA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C,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcP,iBAAiB,CAACI,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACjB,MAAM,CAAC,CAACmB,IAAI,CAAC,IAAI,CAAC;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcN,iBAAiB,CAACG,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACjB,MAAM,CAAC,CAACmB,IAAI,CAAC,IAAI,CAAC;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcL,sBAAsB,CAACM,kBAAkB,CAAC,CAAC;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
|
|
2
|
+
import type { CreateFilesTypeDefsParams } from "../graphql/createFilesTypeDefs.js";
|
|
3
|
+
import type { ApiCoreContext } from "@webiny/api-core/types/core.js";
|
|
4
|
+
export declare const createFilesSchema: (params: CreateFilesTypeDefsParams) => GraphQLSchemaPlugin<ApiCoreContext>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { ErrorResponse, GraphQLSchemaPlugin, ListResponse, Response } from "@webiny/handler-graphql";
|
|
2
|
+
import { emptyResolver, resolve } from "./utils.js";
|
|
3
|
+
import { createFilesTypeDefs } from "./createFilesTypeDefs.js";
|
|
4
|
+
import NotAuthorizedResponse from "@webiny/api-core/graphql/security/NotAuthorizedResponse.js";
|
|
5
|
+
import { GetFileUseCase } from "../features/file/GetFile/abstractions.js";
|
|
6
|
+
import { ListFilesUseCase } from "../features/file/ListFiles/abstractions.js";
|
|
7
|
+
import { ListTagsUseCase } from "../features/file/ListTags/abstractions.js";
|
|
8
|
+
import { CreateFileUseCase } from "../features/file/CreateFile/abstractions.js";
|
|
9
|
+
import { CreateFilesInBatchUseCase } from "../features/file/CreateFilesInBatch/abstractions.js";
|
|
10
|
+
import { UpdateFileUseCase } from "../features/file/UpdateFile/abstractions.js";
|
|
11
|
+
import { DeleteFileUseCase } from "../features/file/DeleteFile/abstractions.js";
|
|
12
|
+
import { GetSettingsUseCase } from "../features/settings/GetSettings/abstractions.js";
|
|
13
|
+
import { FileModel } from "../domain/file/abstractions.js";
|
|
14
|
+
export const createFilesSchema = params => {
|
|
15
|
+
const fileManagerGraphQL = new GraphQLSchemaPlugin({
|
|
16
|
+
typeDefs: createFilesTypeDefs(params),
|
|
17
|
+
resolvers: {
|
|
18
|
+
Query: {
|
|
19
|
+
fileManager: emptyResolver
|
|
20
|
+
},
|
|
21
|
+
Mutation: {
|
|
22
|
+
fileManager: emptyResolver
|
|
23
|
+
},
|
|
24
|
+
FmFile: {
|
|
25
|
+
async src(file, _, context) {
|
|
26
|
+
// TODO: create `FileUrlGenerator` service to use here
|
|
27
|
+
const getSettings = context.container.resolve(GetSettingsUseCase);
|
|
28
|
+
const result = await getSettings.execute();
|
|
29
|
+
const settings = result.value;
|
|
30
|
+
return (settings?.srcPrefix || "") + file.key;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
FmQuery: {
|
|
34
|
+
getFileModel(_, __, context) {
|
|
35
|
+
const identity = context.security.getIdentity();
|
|
36
|
+
if (!identity) {
|
|
37
|
+
return new NotAuthorizedResponse();
|
|
38
|
+
}
|
|
39
|
+
return resolve(async () => {
|
|
40
|
+
return context.container.resolve(FileModel);
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
async getFile(_, args, context) {
|
|
44
|
+
const getFile = context.container.resolve(GetFileUseCase);
|
|
45
|
+
const result = await getFile.execute(args.id);
|
|
46
|
+
if (result.isFail()) {
|
|
47
|
+
return new ErrorResponse(result.error);
|
|
48
|
+
}
|
|
49
|
+
return new Response(result.value);
|
|
50
|
+
},
|
|
51
|
+
async listFiles(_, args, context) {
|
|
52
|
+
const listFiles = context.container.resolve(ListFilesUseCase);
|
|
53
|
+
const result = await listFiles.execute(args);
|
|
54
|
+
if (result.isFail()) {
|
|
55
|
+
return new ErrorResponse(result.error);
|
|
56
|
+
}
|
|
57
|
+
return new ListResponse(result.value.items, result.value.meta);
|
|
58
|
+
},
|
|
59
|
+
async listTags(_, args, context) {
|
|
60
|
+
const listTags = context.container.resolve(ListTagsUseCase);
|
|
61
|
+
const result = await listTags.execute(args || {});
|
|
62
|
+
if (result.isFail()) {
|
|
63
|
+
return new ErrorResponse(result.error);
|
|
64
|
+
}
|
|
65
|
+
return new Response(result.value);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
FmMutation: {
|
|
69
|
+
async createFile(_, args, context) {
|
|
70
|
+
const createFile = context.container.resolve(CreateFileUseCase);
|
|
71
|
+
const result = await createFile.execute(args.data);
|
|
72
|
+
if (result.isFail()) {
|
|
73
|
+
return new ErrorResponse(result.error);
|
|
74
|
+
}
|
|
75
|
+
return new Response(result.value);
|
|
76
|
+
},
|
|
77
|
+
async createFiles(_, args, context) {
|
|
78
|
+
const createFilesInBatch = context.container.resolve(CreateFilesInBatchUseCase);
|
|
79
|
+
const result = await createFilesInBatch.execute({
|
|
80
|
+
files: args.data,
|
|
81
|
+
meta: args.meta
|
|
82
|
+
});
|
|
83
|
+
if (result.isFail()) {
|
|
84
|
+
return new ErrorResponse(result.error);
|
|
85
|
+
}
|
|
86
|
+
return new Response(result.value);
|
|
87
|
+
},
|
|
88
|
+
async updateFile(_, args, context) {
|
|
89
|
+
const updateFile = context.container.resolve(UpdateFileUseCase);
|
|
90
|
+
const result = await updateFile.execute({
|
|
91
|
+
id: args.id,
|
|
92
|
+
...args.data
|
|
93
|
+
});
|
|
94
|
+
if (result.isFail()) {
|
|
95
|
+
return new ErrorResponse(result.error);
|
|
96
|
+
}
|
|
97
|
+
return new Response(result.value);
|
|
98
|
+
},
|
|
99
|
+
async deleteFile(_, args, context) {
|
|
100
|
+
const deleteFile = context.container.resolve(DeleteFileUseCase);
|
|
101
|
+
const result = await deleteFile.execute(args.id);
|
|
102
|
+
if (result.isFail()) {
|
|
103
|
+
return new ErrorResponse(result.error);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// TODO: deletion from Cloud storage should be implemented in the `api-file-manager-s3` as an event handler
|
|
107
|
+
return new Response(true);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
fileManagerGraphQL.name = "fm.graphql.files";
|
|
113
|
+
return fileManagerGraphQL;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=filesSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ErrorResponse","GraphQLSchemaPlugin","ListResponse","Response","emptyResolver","resolve","createFilesTypeDefs","NotAuthorizedResponse","GetFileUseCase","ListFilesUseCase","ListTagsUseCase","CreateFileUseCase","CreateFilesInBatchUseCase","UpdateFileUseCase","DeleteFileUseCase","GetSettingsUseCase","FileModel","createFilesSchema","params","fileManagerGraphQL","typeDefs","resolvers","Query","fileManager","Mutation","FmFile","src","file","_","context","getSettings","container","result","execute","settings","value","srcPrefix","key","FmQuery","getFileModel","__","identity","security","getIdentity","getFile","args","id","isFail","error","listFiles","items","meta","listTags","FmMutation","createFile","data","createFiles","createFilesInBatch","files","updateFile","deleteFile","name"],"sources":["filesSchema.ts"],"sourcesContent":["import {\n ErrorResponse,\n GraphQLSchemaPlugin,\n ListResponse,\n Response\n} from \"@webiny/handler-graphql\";\nimport { emptyResolver, resolve } from \"./utils.js\";\nimport type { CreateFilesTypeDefsParams } from \"~/graphql/createFilesTypeDefs.js\";\nimport { createFilesTypeDefs } from \"~/graphql/createFilesTypeDefs.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { GetFileUseCase } from \"~/features/file/GetFile/abstractions.js\";\nimport { ListFilesUseCase } from \"~/features/file/ListFiles/abstractions.js\";\nimport { ListTagsUseCase } from \"~/features/file/ListTags/abstractions.js\";\nimport { CreateFileUseCase } from \"~/features/file/CreateFile/abstractions.js\";\nimport { CreateFilesInBatchUseCase } from \"~/features/file/CreateFilesInBatch/abstractions.js\";\nimport { UpdateFileUseCase } from \"~/features/file/UpdateFile/abstractions.js\";\nimport { DeleteFileUseCase } from \"~/features/file/DeleteFile/abstractions.js\";\nimport { GetSettingsUseCase } from \"~/features/settings/GetSettings/abstractions.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { FileModel } from \"~/domain/file/abstractions.js\";\n\nexport const createFilesSchema = (params: CreateFilesTypeDefsParams) => {\n const fileManagerGraphQL = new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: createFilesTypeDefs(params),\n resolvers: {\n Query: {\n fileManager: emptyResolver\n },\n Mutation: {\n fileManager: emptyResolver\n },\n FmFile: {\n async src(file, _, context) {\n // TODO: create `FileUrlGenerator` service to use here\n const getSettings = context.container.resolve(GetSettingsUseCase);\n const result = await getSettings.execute();\n const settings = result.value;\n return (settings?.srcPrefix || \"\") + file.key;\n }\n },\n FmQuery: {\n getFileModel(_, __, context) {\n const identity = context.security.getIdentity();\n if (!identity) {\n return new NotAuthorizedResponse();\n }\n\n return resolve(async () => {\n return context.container.resolve(FileModel);\n });\n },\n async getFile(_, args: any, context) {\n const getFile = context.container.resolve(GetFileUseCase);\n const result = await getFile.execute(args.id);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async listFiles(_, args, context) {\n const listFiles = context.container.resolve(ListFilesUseCase);\n const result = await listFiles.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new ListResponse(result.value.items, result.value.meta);\n },\n async listTags(_, args: any, context) {\n const listTags = context.container.resolve(ListTagsUseCase);\n const result = await listTags.execute(args || {});\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n }\n },\n FmMutation: {\n async createFile(_, args: any, context) {\n const createFile = context.container.resolve(CreateFileUseCase);\n const result = await createFile.execute(args.data);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async createFiles(_, args: any, context) {\n const createFilesInBatch = context.container.resolve(CreateFilesInBatchUseCase);\n const result = await createFilesInBatch.execute({\n files: args.data,\n meta: args.meta\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async updateFile(_, args: any, context) {\n const updateFile = context.container.resolve(UpdateFileUseCase);\n const result = await updateFile.execute({\n id: args.id,\n ...args.data\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async deleteFile(_, args: any, context) {\n const deleteFile = context.container.resolve(DeleteFileUseCase);\n const result = await deleteFile.execute(args.id);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n // TODO: deletion from Cloud storage should be implemented in the `api-file-manager-s3` as an event handler\n return new Response(true);\n }\n }\n }\n });\n fileManagerGraphQL.name = \"fm.graphql.files\";\n\n return fileManagerGraphQL;\n};\n"],"mappings":"AAAA,SACIA,aAAa,EACbC,mBAAmB,EACnBC,YAAY,EACZC,QAAQ,QACL,yBAAyB;AAChC,SAASC,aAAa,EAAEC,OAAO;AAE/B,SAASC,mBAAmB;AAC5B,OAAOC,qBAAqB,MAA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;YACX,GAAGD,IAAI,CAACU;UACZ,CAAC,CAAC;UAEF,IAAIvB,MAAM,CAACe,MAAM,CAAC,CAAC,EAAE;YACjB,OAAO,IAAI/C,aAAa,CAACgC,MAAM,CAACgB,KAAK,CAAC;UAC1C;UAEA,OAAO,IAAI7C,QAAQ,CAAC6B,MAAM,CAACG,KAAK,CAAC;QACrC,CAAC;QACD,MAAMyB,UAAUA,CAAChC,CAAC,EAAEiB,IAAS,EAAEhB,OAAO,EAAE;UACpC,MAAM+B,UAAU,GAAG/B,OAAO,CAACE,SAAS,CAAC1B,OAAO,CAACS,iBAAiB,CAAC;UAC/D,MAAMkB,MAAM,GAAG,MAAM4B,UAAU,CAAC3B,OAAO,CAACY,IAAI,CAACC,EAAE,CAAC;UAEhD,IAAId,MAAM,CAACe,MAAM,CAAC,CAAC,EAAE;YACjB,OAAO,IAAI/C,aAAa,CAACgC,MAAM,CAACgB,KAAK,CAAC;UAC1C;;UAEA;UACA,OAAO,IAAI7C,QAAQ,CAAC,IAAI,CAAC;QAC7B;MACJ;IACJ;EACJ,CAAC,CAAC;EACFgB,kBAAkB,CAAC0C,IAAI,GAAG,kBAAkB;EAE5C,OAAO1C,kBAAkB;AAC7B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ErrorResponse, GraphQLSchemaPlugin } from "@webiny/handler-graphql";
|
|
2
|
+
import { Response, NotFoundResponse } from "@webiny/handler-graphql";
|
|
3
|
+
import { NotAuthorizedError } from "@webiny/api-core/features/security/shared/index.js";
|
|
4
|
+
import { ListFilesUseCase } from "../features/file/ListFiles/index.js";
|
|
5
|
+
export const getFileByUrl = () => {
|
|
6
|
+
const fileManagerGraphQL = new GraphQLSchemaPlugin({
|
|
7
|
+
typeDefs: /* GraphQL */`
|
|
8
|
+
extend type FmQuery {
|
|
9
|
+
getFileByUrl(url: String!): FmFileResponse
|
|
10
|
+
}
|
|
11
|
+
`,
|
|
12
|
+
resolvers: {
|
|
13
|
+
FmQuery: {
|
|
14
|
+
async getFileByUrl(_, args, context) {
|
|
15
|
+
const {
|
|
16
|
+
url
|
|
17
|
+
} = args;
|
|
18
|
+
const useCase = new SecureGetFileByUrl(context.security, new GetFileByUrlUseCase(context.container.resolve(ListFilesUseCase)));
|
|
19
|
+
try {
|
|
20
|
+
const file = await useCase.execute(url);
|
|
21
|
+
if (file) {
|
|
22
|
+
return new Response(file);
|
|
23
|
+
}
|
|
24
|
+
return new NotFoundResponse("File not found!");
|
|
25
|
+
} catch (error) {
|
|
26
|
+
return new ErrorResponse(error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
fileManagerGraphQL.name = "fm.graphql.getFileByUrl";
|
|
33
|
+
return fileManagerGraphQL;
|
|
34
|
+
};
|
|
35
|
+
class GetFileByUrlUseCase {
|
|
36
|
+
constructor(listFiles) {
|
|
37
|
+
this.listFiles = listFiles;
|
|
38
|
+
}
|
|
39
|
+
async execute(url) {
|
|
40
|
+
const {
|
|
41
|
+
pathname
|
|
42
|
+
} = new URL(url);
|
|
43
|
+
const query = pathname.replace("/files/", "").replace("/private/", "");
|
|
44
|
+
const filesResult = await this.listFiles.execute({
|
|
45
|
+
where: {
|
|
46
|
+
key: query
|
|
47
|
+
},
|
|
48
|
+
limit: 1
|
|
49
|
+
});
|
|
50
|
+
const files = filesResult.value.items;
|
|
51
|
+
return files.length ? files[0] : undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
class SecureGetFileByUrl {
|
|
55
|
+
constructor(security, useCase) {
|
|
56
|
+
this.security = security;
|
|
57
|
+
this.useCase = useCase;
|
|
58
|
+
}
|
|
59
|
+
execute(url) {
|
|
60
|
+
if (!this.security.getIdentity()) {
|
|
61
|
+
throw new NotAuthorizedError({
|
|
62
|
+
message: "You're not authorized to edit this file!"
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return this.useCase.execute(url);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=getFileByUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ErrorResponse","GraphQLSchemaPlugin","Response","NotFoundResponse","NotAuthorizedError","ListFilesUseCase","getFileByUrl","fileManagerGraphQL","typeDefs","resolvers","FmQuery","_","args","context","url","useCase","SecureGetFileByUrl","security","GetFileByUrlUseCase","container","resolve","file","execute","error","name","constructor","listFiles","pathname","URL","query","replace","filesResult","where","key","limit","files","value","items","length","undefined","getIdentity","message"],"sources":["getFileByUrl.ts"],"sourcesContent":["import { ErrorResponse, GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { Response, NotFoundResponse } from \"@webiny/handler-graphql\";\nimport type { File } from \"~/domain/file/types.js\";\nimport type { Security } from \"@webiny/api-core/types/security.js\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/index.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { ListFilesUseCase } from \"~/features/file/ListFiles/index.js\";\n\nexport const getFileByUrl = () => {\n const fileManagerGraphQL = new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n extend type FmQuery {\n getFileByUrl(url: String!): FmFileResponse\n }\n `,\n resolvers: {\n FmQuery: {\n async getFileByUrl(_, args, context) {\n const { url } = args as { url: string };\n const useCase = new SecureGetFileByUrl(\n context.security,\n new GetFileByUrlUseCase(context.container.resolve(ListFilesUseCase))\n );\n try {\n const file = await useCase.execute(url);\n if (file) {\n return new Response(file);\n }\n return new NotFoundResponse(\"File not found!\");\n } catch (error) {\n return new ErrorResponse(error);\n }\n }\n }\n }\n });\n fileManagerGraphQL.name = \"fm.graphql.getFileByUrl\";\n\n return fileManagerGraphQL;\n};\n\ninterface IGetFileByUrl {\n execute(url: string): Promise<File | undefined>;\n}\n\nclass GetFileByUrlUseCase implements IGetFileByUrl {\n constructor(private listFiles: ListFilesUseCase.Interface) {}\n\n async execute(url: string): Promise<File | undefined> {\n const { pathname } = new URL(url);\n const query = pathname.replace(\"/files/\", \"\").replace(\"/private/\", \"\");\n\n const filesResult = await this.listFiles.execute({\n where: {\n key: query\n },\n limit: 1\n });\n\n const files = filesResult.value.items;\n\n return files.length ? files[0] : undefined;\n }\n}\n\nclass SecureGetFileByUrl implements IGetFileByUrl {\n private security: Security;\n private useCase: IGetFileByUrl;\n\n constructor(security: Security, useCase: IGetFileByUrl) {\n this.security = security;\n this.useCase = useCase;\n }\n\n execute(url: string): Promise<File | undefined> {\n if (!this.security.getIdentity()) {\n throw new NotAuthorizedError({ message: \"You're not authorized to edit this file!\" });\n }\n\n return this.useCase.execute(url);\n }\n}\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,mBAAmB,QAAQ,yBAAyB;AAC5E,SAASC,QAAQ,EAAEC,gBAAgB,QAAQ,yBAAyB;AAGpE,SAASC,kBAAkB,QAAQ,oDAAoD;AAEvF,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAMC,kBAAkB,GAAG,IAAIN,mBAAmB,CAAiB;IAC/DO,QAAQ,EAAE,aAAc;AAChC;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACPC,OAAO,EAAE;QACL,MAAMJ,YAAYA,CAACK,CAAC,EAAEC,IAAI,EAAEC,OAAO,EAAE;UACjC,MAAM;YAAEC;UAAI,CAAC,GAAGF,IAAuB;UACvC,MAAMG,OAAO,GAAG,IAAIC,kBAAkB,CAClCH,OAAO,CAACI,QAAQ,EAChB,IAAIC,mBAAmB,CAACL,OAAO,CAACM,SAAS,CAACC,OAAO,CAACf,gBAAgB,CAAC,CACvE,CAAC;UACD,IAAI;YACA,MAAMgB,IAAI,GAAG,MAAMN,OAAO,CAACO,OAAO,CAACR,GAAG,CAAC;YACvC,IAAIO,IAAI,EAAE;cACN,OAAO,IAAInB,QAAQ,CAACmB,IAAI,CAAC;YAC7B;YACA,O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zF;IAEA,OAAO,IAAI,CAAC1B,OAAO,CAACO,OAAO,CAACR,GAAG,CAAC;EACpC;AACJ","ignoreList":[]}
|
package/graphql/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ContextPlugin } from "@webiny/api";
|
|
2
|
+
import type { ApiCoreContext } from "@webiny/api-core/types/core.js";
|
|
1
3
|
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
|
|
2
|
-
|
|
3
|
-
export declare const createGraphQLSchemaPlugin: () => GraphQLSchemaPlugin<FileManagerContext>;
|
|
4
|
+
export declare const createGraphQLSchemaPlugin: () => (GraphQLSchemaPlugin<ApiCoreContext> | ContextPlugin<ApiCoreContext>)[];
|