@webiny/api-file-manager 6.4.11 → 6.6.0-alpha.1
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/FileManagerAppFeature.d.ts +5 -0
- package/FileManagerAppFeature.js +21 -0
- package/FileManagerAppFeature.js.map +1 -0
- package/delivery/AssetDelivery/AssetRequest.d.ts +1 -1
- package/delivery/AssetDelivery/AssetRequest.js.map +1 -1
- package/delivery/AssetDeliveryRoute.d.ts +23 -0
- package/delivery/AssetDeliveryRoute.js +58 -0
- package/delivery/AssetDeliveryRoute.js.map +1 -0
- package/delivery/setupAssetDelivery.d.ts +1 -1
- package/delivery/setupAssetDelivery.js +1 -66
- package/delivery/setupAssetDelivery.js.map +1 -1
- package/domain/file/abstractions.d.ts +13 -5
- package/domain/file/abstractions.js +2 -2
- package/domain/file/abstractions.js.map +1 -1
- package/domain/file/file.model.d.ts +3 -3
- package/domain/file/file.model.js +10 -6
- package/domain/file/file.model.js.map +1 -1
- package/domain/settings/validation.js +1 -1
- package/domain/settings/validation.js.map +1 -1
- package/exports/api/file-manager/assetDelivery.d.ts +10 -0
- package/exports/api/file-manager/assetDelivery.js +8 -0
- package/exports/api/file-manager/file.d.ts +1 -0
- package/exports/api/file-manager/file.js +1 -0
- package/features/FileManagerFeature.js +6 -0
- package/features/FileManagerFeature.js.map +1 -1
- package/features/assetDelivery/Asset/Asset.d.ts +8 -0
- package/features/assetDelivery/Asset/Asset.js +14 -0
- package/features/assetDelivery/Asset/Asset.js.map +1 -0
- package/features/assetDelivery/Asset/abstractions.d.ts +10 -0
- package/features/assetDelivery/Asset/abstractions.js +5 -0
- package/features/assetDelivery/Asset/abstractions.js.map +1 -0
- package/features/assetDelivery/Asset/index.d.ts +1 -0
- package/features/assetDelivery/Asset/index.js +1 -0
- package/features/assetDelivery/FilesAssetRequestResolver.js +2 -2
- package/features/assetDelivery/FilesAssetRequestResolver.js.map +1 -1
- package/features/assetDelivery/ObjectKey/ObjectKey.d.ts +8 -0
- package/features/assetDelivery/ObjectKey/ObjectKey.js +28 -0
- package/features/assetDelivery/ObjectKey/ObjectKey.js.map +1 -0
- package/features/assetDelivery/ObjectKey/abstractions.d.ts +12 -0
- package/features/assetDelivery/ObjectKey/abstractions.js +5 -0
- package/features/assetDelivery/ObjectKey/abstractions.js.map +1 -0
- package/features/assetDelivery/ObjectKey/index.d.ts +1 -0
- package/features/assetDelivery/ObjectKey/index.js +1 -0
- package/features/assetDelivery/StreamAssetReply/StreamAssetReply.d.ts +8 -0
- package/features/assetDelivery/StreamAssetReply/StreamAssetReply.js +22 -0
- package/features/assetDelivery/StreamAssetReply/StreamAssetReply.js.map +1 -0
- package/features/assetDelivery/StreamAssetReply/abstractions.d.ts +11 -0
- package/features/assetDelivery/StreamAssetReply/abstractions.js +5 -0
- package/features/assetDelivery/StreamAssetReply/abstractions.js.map +1 -0
- package/features/assetDelivery/StreamAssetReply/index.d.ts +1 -0
- package/features/assetDelivery/StreamAssetReply/index.js +1 -0
- package/features/assetDelivery/abstractions/AssetType.d.ts +17 -0
- package/features/assetDelivery/abstractions/AssetType.js +5 -0
- package/features/assetDelivery/abstractions/AssetType.js.map +1 -0
- package/features/assetDelivery/abstractions.d.ts +23 -12
- package/features/assetDelivery/abstractions.js.map +1 -1
- package/features/assetDelivery/assetTypes/image/AssetKeyGenerator.d.ts +12 -0
- package/features/assetDelivery/assetTypes/image/AssetKeyGenerator.js +30 -0
- package/features/assetDelivery/assetTypes/image/AssetKeyGenerator.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/ImageAssetType.d.ts +9 -0
- package/features/assetDelivery/assetTypes/image/ImageAssetType.js +18 -0
- package/features/assetDelivery/assetTypes/image/ImageAssetType.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/ImageAssetTypeHandler.d.ts +5 -0
- package/features/assetDelivery/assetTypes/image/ImageAssetTypeHandler.js +5 -0
- package/features/assetDelivery/assetTypes/image/ImageAssetTypeHandler.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/SharpTransformer.d.ts +18 -0
- package/features/assetDelivery/assetTypes/image/SharpTransformer.js +47 -0
- package/features/assetDelivery/assetTypes/image/SharpTransformer.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/WidthCollection.d.ts +8 -0
- package/features/assetDelivery/assetTypes/image/WidthCollection.js +22 -0
- package/features/assetDelivery/assetTypes/image/WidthCollection.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/imageFormat.d.ts +26 -0
- package/features/assetDelivery/assetTypes/image/imageFormat.js +51 -0
- package/features/assetDelivery/assetTypes/image/imageFormat.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/imageTypes.d.ts +39 -0
- package/features/assetDelivery/assetTypes/image/imageTypes.js +0 -0
- package/features/assetDelivery/assetTypes/image/index.d.ts +5 -0
- package/features/assetDelivery/assetTypes/image/index.js +4 -0
- package/features/assetDelivery/assetTypes/image/normalizeImageOptions.d.ts +6 -0
- package/features/assetDelivery/assetTypes/image/normalizeImageOptions.js +56 -0
- package/features/assetDelivery/assetTypes/image/normalizeImageOptions.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/transformImage.d.ts +59 -0
- package/features/assetDelivery/assetTypes/image/transformImage.js +146 -0
- package/features/assetDelivery/assetTypes/image/transformImage.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/utils.d.ts +26 -0
- package/features/assetDelivery/assetTypes/image/utils.js +47 -0
- package/features/assetDelivery/assetTypes/image/utils.js.map +1 -0
- package/features/assetDelivery/feature.js +13 -7
- package/features/assetDelivery/feature.js.map +1 -1
- package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +2 -2
- package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -1
- package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -1
- package/features/assetDelivery/transformation/CallableContentsReader.d.ts +11 -0
- package/features/assetDelivery/transformation/CallableContentsReader.js +14 -0
- package/features/assetDelivery/transformation/CallableContentsReader.js.map +1 -0
- package/features/assetDelivery/transformation/TransformationAssetProcessor.d.ts +4 -6
- package/features/assetDelivery/transformation/TransformationAssetProcessor.js +13 -11
- package/features/assetDelivery/transformation/TransformationAssetProcessor.js.map +1 -1
- package/features/assetDelivery/transformation/index.d.ts +5 -0
- package/features/assetDelivery/transformation/index.js +4 -0
- package/features/extractMetadata/ExtractMetadataHandler.d.ts +11 -0
- package/features/extractMetadata/ExtractMetadataHandler.js +25 -0
- package/features/extractMetadata/ExtractMetadataHandler.js.map +1 -0
- package/features/extractMetadata/ExtractMetadataInput.d.ts +3 -0
- package/features/extractMetadata/ExtractMetadataInput.js +0 -0
- package/features/file/CreateFile/CreateFileRepository.d.ts +3 -3
- package/features/file/CreateFile/CreateFileRepository.js +6 -5
- package/features/file/CreateFile/CreateFileRepository.js.map +1 -1
- package/features/file/DeleteFile/DeleteFileRepository.d.ts +3 -3
- package/features/file/DeleteFile/DeleteFileRepository.js +6 -5
- package/features/file/DeleteFile/DeleteFileRepository.js.map +1 -1
- package/features/file/FileModelProvider.d.ts +31 -0
- package/features/file/FileModelProvider.js +22 -0
- package/features/file/FileModelProvider.js.map +1 -0
- package/features/file/FileUrlGenerator/FileUrlGenerator.d.ts +14 -0
- package/features/file/FileUrlGenerator/FileUrlGenerator.js +25 -0
- package/features/file/FileUrlGenerator/FileUrlGenerator.js.map +1 -0
- package/features/file/FileUrlGenerator/abstractions.d.ts +3 -3
- package/features/file/FileUrlGenerator/abstractions.js +1 -1
- package/features/file/FileUrlGenerator/abstractions.js.map +1 -1
- package/features/file/FileUrlGenerator/feature.d.ts +4 -0
- package/features/file/FileUrlGenerator/feature.js +11 -0
- package/features/file/FileUrlGenerator/feature.js.map +1 -0
- package/features/file/FileUrlGenerator/index.d.ts +1 -0
- package/features/file/FileUrlGenerator/index.js +1 -0
- package/features/file/GetFile/GetFileRepository.d.ts +3 -3
- package/features/file/GetFile/GetFileRepository.js +6 -5
- package/features/file/GetFile/GetFileRepository.js.map +1 -1
- package/features/file/GetFileByUrl/GetFileByUrlUseCase.d.ts +15 -0
- package/features/file/GetFileByUrl/GetFileByUrlUseCase.js +37 -0
- package/features/file/GetFileByUrl/GetFileByUrlUseCase.js.map +1 -0
- package/features/file/GetFileByUrl/abstractions.d.ts +18 -0
- package/features/file/GetFileByUrl/abstractions.js +5 -0
- package/features/file/GetFileByUrl/abstractions.js.map +1 -0
- package/features/file/GetFileByUrl/feature.d.ts +4 -0
- package/features/file/GetFileByUrl/feature.js +11 -0
- package/features/file/GetFileByUrl/feature.js.map +1 -0
- package/features/file/GetFileByUrl/index.d.ts +1 -0
- package/features/file/GetFileByUrl/index.js +1 -0
- package/features/file/ListFiles/ListFilesRepository.d.ts +3 -3
- package/features/file/ListFiles/ListFilesRepository.js +8 -7
- package/features/file/ListFiles/ListFilesRepository.js.map +1 -1
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.d.ts +5 -0
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.js +5 -0
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.js.map +1 -1
- package/features/file/ListTags/ListTagsRepository.d.ts +3 -3
- package/features/file/ListTags/ListTagsRepository.js +7 -6
- package/features/file/ListTags/ListTagsRepository.js.map +1 -1
- package/features/file/UpdateFile/UpdateFileRepository.d.ts +3 -3
- package/features/file/UpdateFile/UpdateFileRepository.js +6 -5
- package/features/file/UpdateFile/UpdateFileRepository.js.map +1 -1
- package/features/settings/SettingsInstaller/SettingsInstaller.d.ts +3 -1
- package/features/settings/SettingsInstaller/SettingsInstaller.js +7 -4
- package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -1
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js +0 -1
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js.map +1 -1
- package/features/upload/CompleteMultiPartUpload/abstractions.d.ts +12 -0
- package/features/upload/CompleteMultiPartUpload/abstractions.js +5 -0
- package/features/upload/CompleteMultiPartUpload/abstractions.js.map +1 -0
- package/features/upload/CompleteMultiPartUpload/index.d.ts +1 -0
- package/features/upload/CompleteMultiPartUpload/index.js +1 -0
- package/features/upload/CreateMultiPartUpload/abstractions.d.ts +14 -0
- package/features/upload/CreateMultiPartUpload/abstractions.js +5 -0
- package/features/upload/CreateMultiPartUpload/abstractions.js.map +1 -0
- package/features/upload/CreateMultiPartUpload/index.d.ts +1 -0
- package/features/upload/CreateMultiPartUpload/index.js +1 -0
- package/features/upload/GetUploadPayload/abstractions.d.ts +10 -0
- package/features/upload/GetUploadPayload/abstractions.js +5 -0
- package/features/upload/GetUploadPayload/abstractions.js.map +1 -0
- package/features/upload/GetUploadPayload/index.d.ts +1 -0
- package/features/upload/GetUploadPayload/index.js +1 -0
- package/features/upload/ReadFileMetadata/MetadataReader.d.ts +11 -0
- package/features/upload/ReadFileMetadata/MetadataReader.js +21 -0
- package/features/upload/ReadFileMetadata/MetadataReader.js.map +1 -0
- package/features/upload/ReadFileMetadata/abstractions.d.ts +15 -0
- package/features/upload/ReadFileMetadata/abstractions.js +5 -0
- package/features/upload/ReadFileMetadata/abstractions.js.map +1 -0
- package/features/upload/ReadFileMetadata/feature.d.ts +4 -0
- package/features/upload/ReadFileMetadata/feature.js +11 -0
- package/features/upload/ReadFileMetadata/feature.js.map +1 -0
- package/features/upload/ReadFileMetadata/index.d.ts +1 -0
- package/features/upload/ReadFileMetadata/index.js +1 -0
- package/features/upload/WriteFileMetadata/MetadataWriter.d.ts +14 -0
- package/features/upload/WriteFileMetadata/MetadataWriter.js +36 -0
- package/features/upload/WriteFileMetadata/MetadataWriter.js.map +1 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterBatchCreateHandler.d.ts +11 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterBatchCreateHandler.js +20 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterBatchCreateHandler.js.map +1 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterCreateHandler.d.ts +11 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterCreateHandler.js +22 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterCreateHandler.js.map +1 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterUpdateHandler.d.ts +11 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterUpdateHandler.js +22 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterUpdateHandler.js.map +1 -0
- package/features/upload/WriteFileMetadata/abstractions.d.ts +9 -0
- package/features/upload/WriteFileMetadata/abstractions.js +5 -0
- package/features/upload/WriteFileMetadata/abstractions.js.map +1 -0
- package/features/upload/WriteFileMetadata/feature.d.ts +4 -0
- package/features/upload/WriteFileMetadata/feature.js +17 -0
- package/features/upload/WriteFileMetadata/feature.js.map +1 -0
- package/features/upload/index.d.ts +17 -0
- package/features/upload/index.js +10 -0
- package/features/upload/types.d.ts +28 -0
- package/features/upload/types.js +0 -0
- package/features/upload/utils/FileExtension.d.ts +6 -0
- package/features/upload/utils/FileExtension.js +16 -0
- package/features/upload/utils/FileExtension.js.map +1 -0
- package/features/upload/utils/FileKey.d.ts +11 -0
- package/features/upload/utils/FileKey.js +33 -0
- package/features/upload/utils/FileKey.js.map +1 -0
- package/features/upload/utils/FileNormalizer.d.ts +13 -0
- package/features/upload/utils/FileNormalizer.js +41 -0
- package/features/upload/utils/FileNormalizer.js.map +1 -0
- package/features/upload/utils/FileUploadModifier.d.ts +30 -0
- package/features/upload/utils/FileUploadModifier.js +39 -0
- package/features/upload/utils/FileUploadModifier.js.map +1 -0
- package/features/upload/utils/checkPermissions.d.ts +5 -0
- package/features/upload/utils/checkPermissions.js +22 -0
- package/features/upload/utils/checkPermissions.js.map +1 -0
- package/features/upload/utils/createFileNormalizerFromContext.d.ts +3 -0
- package/features/upload/utils/createFileNormalizerFromContext.js +9 -0
- package/features/upload/utils/createFileNormalizerFromContext.js.map +1 -0
- package/features/upload/utils/mimeTypes.d.ts +1 -0
- package/features/upload/utils/mimeTypes.js +9 -0
- package/features/upload/utils/mimeTypes.js.map +1 -0
- package/graphql/FmGraphQLSchema.d.ts +25 -0
- package/graphql/FmGraphQLSchema.js +452 -0
- package/graphql/FmGraphQLSchema.js.map +1 -0
- package/index.d.ts +3 -6
- package/index.js +3 -33
- package/index.js.map +1 -1
- package/package.json +23 -17
- package/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.d.ts +0 -9
- package/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.js +0 -13
- package/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +0 -1
- package/graphql/baseSchema.d.ts +0 -3
- package/graphql/baseSchema.js +0 -100
- package/graphql/baseSchema.js.map +0 -1
- package/graphql/createFilesTypeDefs.d.ts +0 -8
- package/graphql/createFilesTypeDefs.js +0 -191
- package/graphql/createFilesTypeDefs.js.map +0 -1
- package/graphql/filesSchema.d.ts +0 -4
- package/graphql/filesSchema.js +0 -97
- package/graphql/filesSchema.js.map +0 -1
- package/graphql/getFileByUrl.d.ts +0 -3
- package/graphql/getFileByUrl.js +0 -64
- package/graphql/getFileByUrl.js.map +0 -1
- package/graphql/index.d.ts +0 -4
- package/graphql/index.js +0 -48
- package/graphql/index.js.map +0 -1
- package/graphql/utils.d.ts +0 -11
- package/graphql/utils.js +0 -12
- package/graphql/utils.js.map +0 -1
- package/modelModifier/CmsModelModifier.d.ts +0 -26
- package/modelModifier/CmsModelModifier.js +0 -51
- package/modelModifier/CmsModelModifier.js.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js";
|
|
3
3
|
import { ListFilesInput, ListFilesOutput, ListFilesRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
4
|
-
import {
|
|
4
|
+
import { FileModelProvider } from "../../../domain/file/abstractions.js";
|
|
5
5
|
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
6
6
|
import { CmsSortMapper } from "@webiny/api-headless-cms";
|
|
7
7
|
declare class ListFilesRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
8
8
|
private listLatestEntries;
|
|
9
|
-
private
|
|
9
|
+
private fileModelProvider;
|
|
10
10
|
private cmsWhereMapper;
|
|
11
11
|
private cmsSortMapper;
|
|
12
|
-
constructor(listLatestEntries: ListLatestEntriesUseCase.Interface,
|
|
12
|
+
constructor(listLatestEntries: ListLatestEntriesUseCase.Interface, fileModelProvider: FileModelProvider.Interface, cmsWhereMapper: CmsWhereMapper.Interface, cmsSortMapper: CmsSortMapper.Interface);
|
|
13
13
|
execute(input: ListFilesInput): Promise<Result<ListFilesOutput, RepositoryAbstraction.Error>>;
|
|
14
14
|
}
|
|
15
15
|
export declare const ListFilesRepository: typeof ListFilesRepositoryImpl & {
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js";
|
|
3
3
|
import { ListFilesRepository } from "./abstractions.js";
|
|
4
|
-
import {
|
|
4
|
+
import { FileModelProvider } from "../../../domain/file/abstractions.js";
|
|
5
5
|
import { FilePersistenceError } from "../../../domain/file/errors.js";
|
|
6
6
|
import { EntryToFileMapper } from "../shared/EntryToFileMapper.js";
|
|
7
7
|
import { CmsSortMapper, CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
8
8
|
class ListFilesRepositoryImpl {
|
|
9
|
-
constructor(listLatestEntries,
|
|
9
|
+
constructor(listLatestEntries, fileModelProvider, cmsWhereMapper, cmsSortMapper){
|
|
10
10
|
this.listLatestEntries = listLatestEntries;
|
|
11
|
-
this.
|
|
11
|
+
this.fileModelProvider = fileModelProvider;
|
|
12
12
|
this.cmsWhereMapper = cmsWhereMapper;
|
|
13
13
|
this.cmsSortMapper = cmsSortMapper;
|
|
14
14
|
}
|
|
15
15
|
async execute(input) {
|
|
16
|
+
const fileModel = await this.fileModelProvider.get();
|
|
16
17
|
const where = this.cmsWhereMapper.map({
|
|
17
18
|
input: input.where || {},
|
|
18
|
-
fields:
|
|
19
|
+
fields: fileModel.fields
|
|
19
20
|
});
|
|
20
21
|
const sort = this.cmsSortMapper.map({
|
|
21
22
|
input: input.sort,
|
|
22
|
-
fields:
|
|
23
|
+
fields: fileModel.fields
|
|
23
24
|
});
|
|
24
|
-
const result = await this.listLatestEntries.execute(
|
|
25
|
+
const result = await this.listLatestEntries.execute(fileModel, {
|
|
25
26
|
where,
|
|
26
27
|
limit: input.limit || 40,
|
|
27
28
|
after: input.after || void 0,
|
|
@@ -43,7 +44,7 @@ const ListFilesRepository_ListFilesRepository = ListFilesRepository.createImplem
|
|
|
43
44
|
implementation: ListFilesRepositoryImpl,
|
|
44
45
|
dependencies: [
|
|
45
46
|
ListLatestEntriesUseCase,
|
|
46
|
-
|
|
47
|
+
FileModelProvider,
|
|
47
48
|
CmsWhereMapper,
|
|
48
49
|
CmsSortMapper
|
|
49
50
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/file/ListFiles/ListFilesRepository.js","sources":["../../../../src/features/file/ListFiles/ListFilesRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport {\n ListFilesInput,\n ListFilesOutput,\n ListFilesRepository as RepositoryAbstraction\n} from \"./abstractions.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/file/ListFiles/ListFilesRepository.js","sources":["../../../../src/features/file/ListFiles/ListFilesRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport {\n ListFilesInput,\n ListFilesOutput,\n ListFilesRepository as RepositoryAbstraction\n} from \"./abstractions.js\";\nimport { FileModelProvider } from \"~/domain/file/abstractions.js\";\nimport { FilePersistenceError } from \"~/domain/file/errors.js\";\nimport { EntryToFileMapper } from \"../shared/EntryToFileMapper.js\";\nimport { CmsWhereMapper } from \"@webiny/api-headless-cms\";\nimport { CmsSortMapper } from \"@webiny/api-headless-cms\";\nimport { GenericRecord } from \"@webiny/api/types.js\";\n\nclass ListFilesRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private listLatestEntries: ListLatestEntriesUseCase.Interface,\n private fileModelProvider: FileModelProvider.Interface,\n private cmsWhereMapper: CmsWhereMapper.Interface,\n private cmsSortMapper: CmsSortMapper.Interface\n ) {}\n\n async execute(\n input: ListFilesInput\n ): Promise<Result<ListFilesOutput, RepositoryAbstraction.Error>> {\n const fileModel = await this.fileModelProvider.get();\n\n const where = this.cmsWhereMapper.map<GenericRecord>({\n input: input.where || {},\n fields: fileModel.fields\n });\n\n const sort = this.cmsSortMapper.map({\n input: input.sort,\n fields: fileModel.fields\n });\n\n const result = await this.listLatestEntries.execute(fileModel, {\n where,\n limit: input.limit || 40,\n after: input.after || undefined,\n sort: sort || [\"id_DESC\"],\n search: input.search\n });\n\n if (result.isFail()) {\n return Result.fail(new FilePersistenceError(result.error));\n }\n\n const { entries, meta } = result.value;\n\n const files = entries.map(entry => EntryToFileMapper.toFile(entry));\n\n return Result.ok({\n items: files,\n meta\n });\n }\n}\n\nexport const ListFilesRepository = RepositoryAbstraction.createImplementation({\n implementation: ListFilesRepositoryImpl,\n dependencies: [ListLatestEntriesUseCase, FileModelProvider, CmsWhereMapper, CmsSortMapper]\n});\n"],"names":["ListFilesRepositoryImpl","listLatestEntries","fileModelProvider","cmsWhereMapper","cmsSortMapper","input","fileModel","where","sort","result","undefined","Result","FilePersistenceError","entries","meta","files","entry","EntryToFileMapper","ListFilesRepository","RepositoryAbstraction","ListLatestEntriesUseCase","FileModelProvider","CmsWhereMapper","CmsSortMapper"],"mappings":";;;;;;;AAcA,MAAMA;IACF,YACYC,iBAAqD,EACrDC,iBAA8C,EAC9CC,cAAwC,EACxCC,aAAsC,CAChD;aAJUH,iBAAiB,GAAjBA;aACAC,iBAAiB,GAAjBA;aACAC,cAAc,GAAdA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAM,QACFC,KAAqB,EACwC;QAC7D,MAAMC,YAAY,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG;QAElD,MAAMC,QAAQ,IAAI,CAAC,cAAc,CAAC,GAAG,CAAgB;YACjD,OAAOF,MAAM,KAAK,IAAI,CAAC;YACvB,QAAQC,UAAU,MAAM;QAC5B;QAEA,MAAME,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;YAChC,OAAOH,MAAM,IAAI;YACjB,QAAQC,UAAU,MAAM;QAC5B;QAEA,MAAMG,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAACH,WAAW;YAC3DC;YACA,OAAOF,MAAM,KAAK,IAAI;YACtB,OAAOA,MAAM,KAAK,IAAIK;YACtB,MAAMF,QAAQ;gBAAC;aAAU;YACzB,QAAQH,MAAM,MAAM;QACxB;QAEA,IAAII,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAAC,IAAIC,qBAAqBH,OAAO,KAAK;QAG5D,MAAM,EAAEI,OAAO,EAAEC,IAAI,EAAE,GAAGL,OAAO,KAAK;QAEtC,MAAMM,QAAQF,QAAQ,GAAG,CAACG,CAAAA,QAASC,kBAAkB,MAAM,CAACD;QAE5D,OAAOL,OAAO,EAAE,CAAC;YACb,OAAOI;YACPD;QACJ;IACJ;AACJ;AAEO,MAAMI,0CAAsBC,oBAAAA,oBAA0C,CAAC;IAC1E,gBAAgBnB;IAChB,cAAc;QAACoB;QAA0BC;QAAmBC;QAAgBC;KAAc;AAC9F"}
|
|
@@ -14,10 +14,15 @@ interface ImageItem {
|
|
|
14
14
|
declare class ListImagesByTagToolImpl implements IAiSdkTool<Input> {
|
|
15
15
|
private listFiles;
|
|
16
16
|
readonly name = "listImagesByTag";
|
|
17
|
+
readonly title = "List images by tag";
|
|
17
18
|
readonly description = "Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.";
|
|
18
19
|
readonly inputSchema: z.ZodObject<{
|
|
19
20
|
tag: z.ZodString;
|
|
20
21
|
}, z.core.$strip>;
|
|
22
|
+
readonly annotations: {
|
|
23
|
+
readOnlyHint: boolean;
|
|
24
|
+
idempotentHint: boolean;
|
|
25
|
+
};
|
|
21
26
|
constructor(listFiles: ListFilesUseCase.Interface);
|
|
22
27
|
execute(input: Input): Promise<ImageItem[]>;
|
|
23
28
|
}
|
|
@@ -8,8 +8,13 @@ class ListImagesByTagToolImpl {
|
|
|
8
8
|
constructor(listFiles){
|
|
9
9
|
this.listFiles = listFiles;
|
|
10
10
|
this.name = "listImagesByTag";
|
|
11
|
+
this.title = "List images by tag";
|
|
11
12
|
this.description = "Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.";
|
|
12
13
|
this.inputSchema = inputSchema;
|
|
14
|
+
this.annotations = {
|
|
15
|
+
readOnlyHint: true,
|
|
16
|
+
idempotentHint: true
|
|
17
|
+
};
|
|
13
18
|
}
|
|
14
19
|
async execute(input) {
|
|
15
20
|
console.log("Call images tool", input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/file/ListImagesByTagTool/ListImagesByTagTool.js","sources":["../../../../src/features/file/ListImagesByTagTool/ListImagesByTagTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkTool, type IAiSdkTool } from \"@webiny/api-core/features/ai/index.js\";\nimport { ListFilesUseCase } from \"~/features/file/ListFiles/index.js\";\n\nconst inputSchema = z.object({\n tag: z.string().describe(\"Tag to filter images by\")\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface ImageItem {\n id: string;\n name: string;\n type: string;\n tags: string[];\n}\n\nclass ListImagesByTagToolImpl implements IAiSdkTool<Input> {\n readonly name = \"listImagesByTag\";\n readonly description =\n \"Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.\";\n readonly inputSchema = inputSchema;\n\n constructor(private listFiles: ListFilesUseCase.Interface) {}\n\n async execute(input: Input): Promise<ImageItem[]> {\n console.log(\"Call images tool\", input);\n const result = await this.listFiles.execute({\n where: {\n type_startsWith: \"image/\",\n tags_in: [input.tag]\n },\n limit: 50\n });\n\n if (result.isFail()) {\n return [];\n }\n\n return result.value.items.map(file => ({\n id: file.id,\n name: file.name,\n type: file.type,\n tags: file.tags\n }));\n }\n}\n\nexport const ListImagesByTagTool = AiSdkTool.createImplementation({\n implementation: ListImagesByTagToolImpl,\n dependencies: [ListFilesUseCase]\n});\n"],"names":["inputSchema","z","ListImagesByTagToolImpl","listFiles","input","console","result","file","ListImagesByTagTool","AiSdkTool","ListFilesUseCase"],"mappings":";;;AAIA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,KAAKA,EAAE,MAAM,GAAG,QAAQ,CAAC;AAC7B;AAWA,MAAMC;
|
|
1
|
+
{"version":3,"file":"features/file/ListImagesByTagTool/ListImagesByTagTool.js","sources":["../../../../src/features/file/ListImagesByTagTool/ListImagesByTagTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkTool, type IAiSdkTool } from \"@webiny/api-core/features/ai/index.js\";\nimport { ListFilesUseCase } from \"~/features/file/ListFiles/index.js\";\n\nconst inputSchema = z.object({\n tag: z.string().describe(\"Tag to filter images by\")\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface ImageItem {\n id: string;\n name: string;\n type: string;\n tags: string[];\n}\n\nclass ListImagesByTagToolImpl implements IAiSdkTool<Input> {\n readonly name = \"listImagesByTag\";\n readonly title = \"List images by tag\";\n readonly description =\n \"Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: true, idempotentHint: true };\n\n constructor(private listFiles: ListFilesUseCase.Interface) {}\n\n async execute(input: Input): Promise<ImageItem[]> {\n console.log(\"Call images tool\", input);\n const result = await this.listFiles.execute({\n where: {\n type_startsWith: \"image/\",\n tags_in: [input.tag]\n },\n limit: 50\n });\n\n if (result.isFail()) {\n return [];\n }\n\n return result.value.items.map(file => ({\n id: file.id,\n name: file.name,\n type: file.type,\n tags: file.tags\n }));\n }\n}\n\nexport const ListImagesByTagTool = AiSdkTool.createImplementation({\n implementation: ListImagesByTagToolImpl,\n dependencies: [ListFilesUseCase]\n});\n"],"names":["inputSchema","z","ListImagesByTagToolImpl","listFiles","input","console","result","file","ListImagesByTagTool","AiSdkTool","ListFilesUseCase"],"mappings":";;;AAIA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,KAAKA,EAAE,MAAM,GAAG,QAAQ,CAAC;AAC7B;AAWA,MAAMC;IAQF,YAAoBC,SAAqC,CAAE;aAAvCA,SAAS,GAATA;aAPX,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGH;aACd,WAAW,GAAG;YAAE,cAAc;YAAM,gBAAgB;QAAK;IAEN;IAE5D,MAAM,QAAQI,KAAY,EAAwB;QAC9CC,QAAQ,GAAG,CAAC,oBAAoBD;QAChC,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YACxC,OAAO;gBACH,iBAAiB;gBACjB,SAAS;oBAACF,MAAM,GAAG;iBAAC;YACxB;YACA,OAAO;QACX;QAEA,IAAIE,OAAO,MAAM,IACb,OAAO,EAAE;QAGb,OAAOA,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAACC,CAAAA,OAAS;gBACnC,IAAIA,KAAK,EAAE;gBACX,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;YACnB;IACJ;AACJ;AAEO,MAAMC,sBAAsBC,UAAU,oBAAoB,CAAC;IAC9D,gBAAgBP;IAChB,cAAc;QAACQ;KAAiB;AACpC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { GetUniqueFieldValuesUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetUniqueFieldValues";
|
|
3
3
|
import { ListTagsInput, ListTagsRepository as RepositoryAbstraction, TagItem } from "./abstractions.js";
|
|
4
|
-
import {
|
|
4
|
+
import { FileModelProvider } from "../../../domain/file/abstractions.js";
|
|
5
5
|
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
6
6
|
declare class ListTagsRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
7
7
|
private getUniqueFieldValues;
|
|
8
|
-
private
|
|
8
|
+
private fileModelProvider;
|
|
9
9
|
private cmsWhereMapper;
|
|
10
|
-
constructor(getUniqueFieldValues: GetUniqueFieldValuesUseCase.Interface,
|
|
10
|
+
constructor(getUniqueFieldValues: GetUniqueFieldValuesUseCase.Interface, fileModelProvider: FileModelProvider.Interface, cmsWhereMapper: CmsWhereMapper.Interface);
|
|
11
11
|
execute(input: ListTagsInput): Promise<Result<TagItem[], RepositoryAbstraction.Error>>;
|
|
12
12
|
}
|
|
13
13
|
export declare const ListTagsRepository: typeof ListTagsRepositoryImpl & {
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { GetUniqueFieldValuesUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetUniqueFieldValues";
|
|
3
3
|
import { ListTagsRepository } from "./abstractions.js";
|
|
4
|
-
import {
|
|
4
|
+
import { FileModelProvider } from "../../../domain/file/abstractions.js";
|
|
5
5
|
import { FilePersistenceError } from "../../../domain/file/errors.js";
|
|
6
6
|
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
7
7
|
class ListTagsRepositoryImpl {
|
|
8
|
-
constructor(getUniqueFieldValues,
|
|
8
|
+
constructor(getUniqueFieldValues, fileModelProvider, cmsWhereMapper){
|
|
9
9
|
this.getUniqueFieldValues = getUniqueFieldValues;
|
|
10
|
-
this.
|
|
10
|
+
this.fileModelProvider = fileModelProvider;
|
|
11
11
|
this.cmsWhereMapper = cmsWhereMapper;
|
|
12
12
|
}
|
|
13
13
|
async execute(input) {
|
|
14
|
-
const
|
|
14
|
+
const fileModel = await this.fileModelProvider.get();
|
|
15
|
+
const result = await this.getUniqueFieldValues.execute(fileModel, {
|
|
15
16
|
fieldId: "tags",
|
|
16
17
|
where: this.cmsWhereMapper.map({
|
|
17
18
|
input: {
|
|
18
19
|
...input.where || {},
|
|
19
20
|
latest: true
|
|
20
21
|
},
|
|
21
|
-
fields:
|
|
22
|
+
fields: fileModel.fields
|
|
22
23
|
})
|
|
23
24
|
});
|
|
24
25
|
if (result.isFail()) return Result.fail(new FilePersistenceError(result.error));
|
|
@@ -33,7 +34,7 @@ const ListTagsRepository_ListTagsRepository = ListTagsRepository.createImplement
|
|
|
33
34
|
implementation: ListTagsRepositoryImpl,
|
|
34
35
|
dependencies: [
|
|
35
36
|
GetUniqueFieldValuesUseCase,
|
|
36
|
-
|
|
37
|
+
FileModelProvider,
|
|
37
38
|
CmsWhereMapper
|
|
38
39
|
]
|
|
39
40
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/file/ListTags/ListTagsRepository.js","sources":["../../../../src/features/file/ListTags/ListTagsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetUniqueFieldValuesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetUniqueFieldValues\";\nimport {\n ListTagsInput,\n ListTagsRepository as RepositoryAbstraction,\n TagItem\n} from \"./abstractions.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/file/ListTags/ListTagsRepository.js","sources":["../../../../src/features/file/ListTags/ListTagsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetUniqueFieldValuesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetUniqueFieldValues\";\nimport {\n ListTagsInput,\n ListTagsRepository as RepositoryAbstraction,\n TagItem\n} from \"./abstractions.js\";\nimport { FileModelProvider } from \"~/domain/file/abstractions.js\";\nimport { FilePersistenceError } from \"~/domain/file/errors.js\";\nimport { CmsWhereMapper } from \"@webiny/api-headless-cms\";\n\nclass ListTagsRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private getUniqueFieldValues: GetUniqueFieldValuesUseCase.Interface,\n private fileModelProvider: FileModelProvider.Interface,\n private cmsWhereMapper: CmsWhereMapper.Interface\n ) {}\n\n async execute(input: ListTagsInput): Promise<Result<TagItem[], RepositoryAbstraction.Error>> {\n const fileModel = await this.fileModelProvider.get();\n\n const result = await this.getUniqueFieldValues.execute(fileModel, {\n fieldId: \"tags\",\n // TODO fix with proper types\n // @ts-expect-error\n where: this.cmsWhereMapper.map({\n input: {\n ...(input.where || {}),\n latest: true\n },\n fields: fileModel.fields\n })\n });\n\n if (result.isFail()) {\n return Result.fail(new FilePersistenceError(result.error));\n }\n\n // Map to TagItem format\n const tags: TagItem[] = result.value\n .map(uv => ({\n tag: uv.value as string,\n count: uv.count\n }))\n // Sort by tag name alphabetically\n .sort((a, b) => (a.tag < b.tag ? -1 : 1))\n // Then sort by count descending (most used first)\n .sort((a, b) => (a.count > b.count ? -1 : 1));\n\n return Result.ok(tags);\n }\n}\n\nexport const ListTagsRepository = RepositoryAbstraction.createImplementation({\n implementation: ListTagsRepositoryImpl,\n dependencies: [GetUniqueFieldValuesUseCase, FileModelProvider, CmsWhereMapper]\n});\n"],"names":["ListTagsRepositoryImpl","getUniqueFieldValues","fileModelProvider","cmsWhereMapper","input","fileModel","result","Result","FilePersistenceError","tags","uv","a","b","ListTagsRepository","RepositoryAbstraction","GetUniqueFieldValuesUseCase","FileModelProvider","CmsWhereMapper"],"mappings":";;;;;;AAWA,MAAMA;IACF,YACYC,oBAA2D,EAC3DC,iBAA8C,EAC9CC,cAAwC,CAClD;aAHUF,oBAAoB,GAApBA;aACAC,iBAAiB,GAAjBA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQC,KAAoB,EAA2D;QACzF,MAAMC,YAAY,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG;QAElD,MAAMC,SAAS,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAACD,WAAW;YAC9D,SAAS;YAGT,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;gBAC3B,OAAO;oBACH,GAAID,MAAM,KAAK,IAAI,CAAC,CAAC;oBACrB,QAAQ;gBACZ;gBACA,QAAQC,UAAU,MAAM;YAC5B;QACJ;QAEA,IAAIC,OAAO,MAAM,IACb,OAAOC,OAAO,IAAI,CAAC,IAAIC,qBAAqBF,OAAO,KAAK;QAI5D,MAAMG,OAAkBH,OAAO,KAAK,CAC/B,GAAG,CAACI,CAAAA,KAAO;gBACR,KAAKA,GAAG,KAAK;gBACb,OAAOA,GAAG,KAAK;YACnB,IAEC,IAAI,CAAC,CAACC,GAAGC,IAAOD,EAAE,GAAG,GAAGC,EAAE,GAAG,GAAG,KAAK,GAErC,IAAI,CAAC,CAACD,GAAGC,IAAOD,EAAE,KAAK,GAAGC,EAAE,KAAK,GAAG,KAAK;QAE9C,OAAOL,OAAO,EAAE,CAACE;IACrB;AACJ;AAEO,MAAMI,wCAAqBC,mBAAAA,oBAA0C,CAAC;IACzE,gBAAgBd;IAChB,cAAc;QAACe;QAA6BC;QAAmBC;KAAe;AAClF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
|
|
3
3
|
import { UpdateFileRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
4
|
-
import {
|
|
4
|
+
import { FileModelProvider } from "../../../domain/file/abstractions.js";
|
|
5
5
|
import type { File } from "../../../domain/file/types.js";
|
|
6
6
|
declare class UpdateFileRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
7
7
|
private updateEntry;
|
|
8
|
-
private
|
|
9
|
-
constructor(updateEntry: UpdateEntryUseCase.Interface,
|
|
8
|
+
private fileModelProvider;
|
|
9
|
+
constructor(updateEntry: UpdateEntryUseCase.Interface, fileModelProvider: FileModelProvider.Interface);
|
|
10
10
|
update(file: File): Promise<Result<void, RepositoryAbstraction.Error>>;
|
|
11
11
|
}
|
|
12
12
|
export declare const UpdateFileRepository: typeof UpdateFileRepositoryImpl & {
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
|
|
3
3
|
import { UpdateFileRepository } from "./abstractions.js";
|
|
4
|
-
import {
|
|
4
|
+
import { FileModelProvider } from "../../../domain/file/abstractions.js";
|
|
5
5
|
import { FileNotAuthorizedError, FileNotFoundError, FilePersistenceError } from "../../../domain/file/errors.js";
|
|
6
6
|
import { FileToEntryMapper } from "../shared/FileToEntryMapper.js";
|
|
7
7
|
class UpdateFileRepositoryImpl {
|
|
8
|
-
constructor(updateEntry,
|
|
8
|
+
constructor(updateEntry, fileModelProvider){
|
|
9
9
|
this.updateEntry = updateEntry;
|
|
10
|
-
this.
|
|
10
|
+
this.fileModelProvider = fileModelProvider;
|
|
11
11
|
}
|
|
12
12
|
async update(file) {
|
|
13
13
|
const entry = FileToEntryMapper.toEntry(file);
|
|
14
14
|
const id = `${file.id}#0001`;
|
|
15
|
-
const
|
|
15
|
+
const fileModel = await this.fileModelProvider.get();
|
|
16
|
+
const result = await this.updateEntry.execute(fileModel, id, {
|
|
16
17
|
wbyAco_location: file.location,
|
|
17
18
|
values: entry.values
|
|
18
19
|
});
|
|
@@ -29,7 +30,7 @@ const UpdateFileRepository_UpdateFileRepository = UpdateFileRepository.createImp
|
|
|
29
30
|
implementation: UpdateFileRepositoryImpl,
|
|
30
31
|
dependencies: [
|
|
31
32
|
UpdateEntryUseCase,
|
|
32
|
-
|
|
33
|
+
FileModelProvider
|
|
33
34
|
]
|
|
34
35
|
});
|
|
35
36
|
export { UpdateFileRepository_UpdateFileRepository as UpdateFileRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/file/UpdateFile/UpdateFileRepository.js","sources":["../../../../src/features/file/UpdateFile/UpdateFileRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry\";\nimport { UpdateFileRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/file/UpdateFile/UpdateFileRepository.js","sources":["../../../../src/features/file/UpdateFile/UpdateFileRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry\";\nimport { UpdateFileRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { FileModelProvider } from \"~/domain/file/abstractions.js\";\nimport type { File } from \"~/domain/file/types.js\";\nimport {\n FileNotAuthorizedError,\n FileNotFoundError,\n FilePersistenceError\n} from \"~/domain/file/errors.js\";\nimport { FileToEntryMapper } from \"../shared/FileToEntryMapper.js\";\n\nclass UpdateFileRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private updateEntry: UpdateEntryUseCase.Interface,\n private fileModelProvider: FileModelProvider.Interface\n ) {}\n\n async update(file: File): Promise<Result<void, RepositoryAbstraction.Error>> {\n const entry = FileToEntryMapper.toEntry(file);\n\n // Files are not versioned, so we're always updating the same revision\n const id = `${file.id}#0001`;\n\n const fileModel = await this.fileModelProvider.get();\n const result = await this.updateEntry.execute(fileModel, id, {\n wbyAco_location: file.location,\n values: entry.values\n });\n\n if (result.isFail()) {\n const error = result.error;\n if (error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new FileNotFoundError(id));\n }\n\n if (error.code === \"Cms/Entry/NotAuthorized\") {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n return Result.fail(new FilePersistenceError(result.error));\n }\n\n return Result.ok();\n }\n}\n\nexport const UpdateFileRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateFileRepositoryImpl,\n dependencies: [UpdateEntryUseCase, FileModelProvider]\n});\n"],"names":["UpdateFileRepositoryImpl","updateEntry","fileModelProvider","file","entry","FileToEntryMapper","id","fileModel","result","error","Result","FileNotFoundError","FileNotAuthorizedError","FilePersistenceError","UpdateFileRepository","RepositoryAbstraction","UpdateEntryUseCase","FileModelProvider"],"mappings":";;;;;;AAYA,MAAMA;IACF,YACYC,WAAyC,EACzCC,iBAA8C,CACxD;aAFUD,WAAW,GAAXA;aACAC,iBAAiB,GAAjBA;IACT;IAEH,MAAM,OAAOC,IAAU,EAAsD;QACzE,MAAMC,QAAQC,kBAAkB,OAAO,CAACF;QAGxC,MAAMG,KAAK,GAAGH,KAAK,EAAE,CAAC,KAAK,CAAC;QAE5B,MAAMI,YAAY,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG;QAClD,MAAMC,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACD,WAAWD,IAAI;YACzD,iBAAiBH,KAAK,QAAQ;YAC9B,QAAQC,MAAM,MAAM;QACxB;QAEA,IAAII,OAAO,MAAM,IAAI;YACjB,MAAMC,QAAQD,OAAO,KAAK;YAC1B,IAAIC,AAAe,yBAAfA,MAAM,IAAI,EACV,OAAOC,OAAO,IAAI,CAAC,IAAIC,kBAAkBL;YAG7C,IAAIG,AAAe,8BAAfA,MAAM,IAAI,EACV,OAAOC,OAAO,IAAI,CAAC,IAAIE;YAG3B,OAAOF,OAAO,IAAI,CAAC,IAAIG,qBAAqBL,OAAO,KAAK;QAC5D;QAEA,OAAOE,OAAO,EAAE;IACpB;AACJ;AAEO,MAAMI,4CAAuBC,qBAAAA,oBAA0C,CAAC;IAC3E,gBAAgBf;IAChB,cAAc;QAACgB;QAAoBC;KAAkB;AACzD"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { AppInstaller } from "@webiny/api-core/features/tenancy/InstallTenant/index.js";
|
|
2
2
|
import { UpdateSettingsUseCase } from "../../../features/settings/UpdateSettings/abstractions.js";
|
|
3
3
|
import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
4
|
+
import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
|
|
4
5
|
declare class SettingsInstallerImpl implements AppInstaller.Interface {
|
|
5
6
|
private updateSettings;
|
|
6
7
|
private keyValueStore;
|
|
8
|
+
private buildParams;
|
|
7
9
|
readonly alwaysRun = true;
|
|
8
10
|
readonly appName = "FileManager";
|
|
9
11
|
readonly dependsOn: never[];
|
|
10
|
-
constructor(updateSettings: UpdateSettingsUseCase.Interface, keyValueStore: KeyValueStore.Interface);
|
|
12
|
+
constructor(updateSettings: UpdateSettingsUseCase.Interface, keyValueStore: KeyValueStore.Interface, buildParams: BuildParams.Interface);
|
|
11
13
|
install(): Promise<void>;
|
|
12
14
|
uninstall(): Promise<void>;
|
|
13
15
|
}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { ServiceDiscovery } from "@webiny/api";
|
|
1
|
+
import { ServiceDiscovery } from "@webiny/api-core/features/serviceDiscovery/index.js";
|
|
2
2
|
import { createImplementation } from "@webiny/feature/api";
|
|
3
3
|
import { AppInstaller } from "@webiny/api-core/features/tenancy/InstallTenant/index.js";
|
|
4
4
|
import { FILE_MANAGER_GENERAL_SETTINGS } from "../../../domain/settings/constants.js";
|
|
5
5
|
import { UpdateSettingsUseCase } from "../UpdateSettings/abstractions.js";
|
|
6
6
|
import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
7
|
+
import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
|
|
7
8
|
class SettingsInstallerImpl {
|
|
8
|
-
constructor(updateSettings, keyValueStore){
|
|
9
|
+
constructor(updateSettings, keyValueStore, buildParams){
|
|
9
10
|
this.updateSettings = updateSettings;
|
|
10
11
|
this.keyValueStore = keyValueStore;
|
|
12
|
+
this.buildParams = buildParams;
|
|
11
13
|
this.alwaysRun = true;
|
|
12
14
|
this.appName = "FileManager";
|
|
13
15
|
this.dependsOn = [];
|
|
14
16
|
}
|
|
15
17
|
async install() {
|
|
16
18
|
const manifest = await ServiceDiscovery.load();
|
|
17
|
-
const domain = manifest?.api?.cloudfront.
|
|
19
|
+
const domain = manifest?.api?.cloudfront?.domain ?? this.buildParams.get("WEBINY_API_URL") ?? "";
|
|
18
20
|
await this.updateSettings.execute({
|
|
19
21
|
srcPrefix: `${domain}/files`
|
|
20
22
|
});
|
|
@@ -28,7 +30,8 @@ const SettingsInstaller = createImplementation({
|
|
|
28
30
|
implementation: SettingsInstallerImpl,
|
|
29
31
|
dependencies: [
|
|
30
32
|
UpdateSettingsUseCase,
|
|
31
|
-
KeyValueStore
|
|
33
|
+
KeyValueStore,
|
|
34
|
+
BuildParams
|
|
32
35
|
]
|
|
33
36
|
});
|
|
34
37
|
export { SettingsInstaller };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/settings/SettingsInstaller/SettingsInstaller.js","sources":["../../../../src/features/settings/SettingsInstaller/SettingsInstaller.ts"],"sourcesContent":["import { ServiceDiscovery } from \"@webiny/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { AppInstaller } from \"@webiny/api-core/features/tenancy/InstallTenant/index.js\";\nimport { FILE_MANAGER_GENERAL_SETTINGS } from \"~/domain/settings/constants.js\";\nimport { UpdateSettingsUseCase } from \"~/features/settings/UpdateSettings/abstractions.js\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\n\nclass SettingsInstallerImpl implements AppInstaller.Interface {\n readonly alwaysRun = true;\n readonly appName = \"FileManager\";\n readonly dependsOn = [];\n\n constructor(\n private updateSettings: UpdateSettingsUseCase.Interface,\n private keyValueStore: KeyValueStore.Interface\n ) {}\n\n async install(): Promise<void> {\n // TODO: move this to api-core with a proper abstraction\n const manifest = await ServiceDiscovery.load();\n\n // If no records in the database, `manifest` object is empty POJO.\n // That's why the heavy `?.` usage.\n
|
|
1
|
+
{"version":3,"file":"features/settings/SettingsInstaller/SettingsInstaller.js","sources":["../../../../src/features/settings/SettingsInstaller/SettingsInstaller.ts"],"sourcesContent":["import { ServiceDiscovery } from \"@webiny/api-core/features/serviceDiscovery/index.js\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { AppInstaller } from \"@webiny/api-core/features/tenancy/InstallTenant/index.js\";\nimport { FILE_MANAGER_GENERAL_SETTINGS } from \"~/domain/settings/constants.js\";\nimport { UpdateSettingsUseCase } from \"~/features/settings/UpdateSettings/abstractions.js\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { BuildParams } from \"@webiny/api-core/features/buildParams/index.js\";\n\nclass SettingsInstallerImpl implements AppInstaller.Interface {\n readonly alwaysRun = true;\n readonly appName = \"FileManager\";\n readonly dependsOn = [];\n\n constructor(\n private updateSettings: UpdateSettingsUseCase.Interface,\n private keyValueStore: KeyValueStore.Interface,\n private buildParams: BuildParams.Interface\n ) {}\n\n async install(): Promise<void> {\n // TODO: move this to api-core with a proper abstraction\n const manifest = await ServiceDiscovery.load();\n\n // If no records in the database, `manifest` object is empty POJO.\n // That's why the heavy `?.` usage.\n //\n // The AWS hosting type serves files from a CloudFront domain (in the manifest). The self-hosted\n // (server) hosting type has no CloudFront — files are served by the api's own `/files/*` route — so\n // fall back to the configured API origin, read from the WEBINY_API_URL build param (baked by\n // Infra.ApiUrl), not a process.env read.\n const domain =\n manifest?.api?.cloudfront?.domain ??\n this.buildParams.get<string>(\"WEBINY_API_URL\") ??\n \"\";\n\n await this.updateSettings.execute({\n srcPrefix: `${domain}/files`\n });\n }\n\n async uninstall(): Promise<void> {\n await this.keyValueStore.delete(FILE_MANAGER_GENERAL_SETTINGS);\n }\n}\n\nexport const SettingsInstaller = createImplementation({\n abstraction: AppInstaller,\n implementation: SettingsInstallerImpl,\n dependencies: [UpdateSettingsUseCase, KeyValueStore, BuildParams]\n});\n"],"names":["SettingsInstallerImpl","updateSettings","keyValueStore","buildParams","manifest","ServiceDiscovery","domain","FILE_MANAGER_GENERAL_SETTINGS","SettingsInstaller","createImplementation","AppInstaller","UpdateSettingsUseCase","KeyValueStore","BuildParams"],"mappings":";;;;;;;AAQA,MAAMA;IAKF,YACYC,cAA+C,EAC/CC,aAAsC,EACtCC,WAAkC,CAC5C;aAHUF,cAAc,GAAdA;aACAC,aAAa,GAAbA;aACAC,WAAW,GAAXA;aAPH,SAAS,GAAG;aACZ,OAAO,GAAG;aACV,SAAS,GAAG,EAAE;IAMpB;IAEH,MAAM,UAAyB;QAE3B,MAAMC,WAAW,MAAMC,iBAAiB,IAAI;QAS5C,MAAMC,SACFF,UAAU,KAAK,YAAY,UAC3B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAS,qBAC7B;QAEJ,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;YAC9B,WAAW,GAAGE,OAAO,MAAM,CAAC;QAChC;IACJ;IAEA,MAAM,YAA2B;QAC7B,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAACC;IACpC;AACJ;AAEO,MAAMC,oBAAoBC,qBAAqB;IAClD,aAAaC;IACb,gBAAgBV;IAChB,cAAc;QAACW;QAAuBC;QAAeC;KAAY;AACrE"}
|
|
@@ -22,7 +22,6 @@ class UpdateSettingsUseCaseImpl {
|
|
|
22
22
|
}
|
|
23
23
|
const validatedInput = validationResult.data;
|
|
24
24
|
const existingResult = await this.getSettings.execute();
|
|
25
|
-
if (existingResult.isFail()) return existingResult;
|
|
26
25
|
const existing = existingResult.value;
|
|
27
26
|
const updatedSettings = {
|
|
28
27
|
...existing,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/settings/UpdateSettings/UpdateSettingsUseCase.js","sources":["../../../../src/features/settings/UpdateSettings/UpdateSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { UpdateSettingsUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { GetSettingsUseCase } from \"../GetSettings/abstractions.js\";\nimport type { FileManagerSettings } from \"~/domain/settings/types.js\";\nimport type { UpdateSettingsInput } from \"~/domain/settings/types.js\";\nimport { SettingsUpdateError } from \"~/domain/settings/errors.js\";\nimport { SettingsValidationError } from \"~/domain/settings/errors.js\";\nimport { FILE_MANAGER_GENERAL_SETTINGS } from \"~/domain/settings/constants.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { SettingsBeforeUpdateEvent, SettingsAfterUpdateEvent } from \"./events.js\";\nimport { updateSettingsValidation } from \"~/domain/settings/validation.js\";\nimport { createZodError } from \"@webiny/utils\";\n\nclass UpdateSettingsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private keyValueStore: KeyValueStore.Interface,\n private getSettings: GetSettingsUseCase.Interface,\n private eventPublisher: EventPublisher.Interface\n ) {}\n\n async execute(\n input: UpdateSettingsInput\n ): Promise<Result<FileManagerSettings, UseCaseAbstraction.Error>> {\n // Validate input\n const validationResult = await updateSettingsValidation.safeParseAsync(input);\n if (!validationResult.success) {\n const zodError = createZodError(validationResult.error);\n return Result.fail(new SettingsValidationError(zodError.data!.invalidFields));\n }\n\n const validatedInput = validationResult.data;\n\n // Get existing settings to merge with new data\n const existingResult = await this.getSettings.execute();\n
|
|
1
|
+
{"version":3,"file":"features/settings/UpdateSettings/UpdateSettingsUseCase.js","sources":["../../../../src/features/settings/UpdateSettings/UpdateSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { UpdateSettingsUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { GetSettingsUseCase } from \"../GetSettings/abstractions.js\";\nimport type { FileManagerSettings } from \"~/domain/settings/types.js\";\nimport type { UpdateSettingsInput } from \"~/domain/settings/types.js\";\nimport { SettingsUpdateError } from \"~/domain/settings/errors.js\";\nimport { SettingsValidationError } from \"~/domain/settings/errors.js\";\nimport { FILE_MANAGER_GENERAL_SETTINGS } from \"~/domain/settings/constants.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { SettingsBeforeUpdateEvent, SettingsAfterUpdateEvent } from \"./events.js\";\nimport { updateSettingsValidation } from \"~/domain/settings/validation.js\";\nimport { createZodError } from \"@webiny/utils\";\n\nclass UpdateSettingsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private keyValueStore: KeyValueStore.Interface,\n private getSettings: GetSettingsUseCase.Interface,\n private eventPublisher: EventPublisher.Interface\n ) {}\n\n async execute(\n input: UpdateSettingsInput\n ): Promise<Result<FileManagerSettings, UseCaseAbstraction.Error>> {\n // Validate input\n const validationResult = await updateSettingsValidation.safeParseAsync(input);\n if (!validationResult.success) {\n const zodError = createZodError(validationResult.error);\n return Result.fail(new SettingsValidationError(zodError.data!.invalidFields));\n }\n\n const validatedInput = validationResult.data;\n\n // Get existing settings to merge with new data\n const existingResult = await this.getSettings.execute();\n const existing = existingResult.value;\n\n // Prepare merged settings\n const updatedSettings: FileManagerSettings = {\n ...existing,\n ...validatedInput\n };\n\n // Publish BeforeUpdate event\n await this.eventPublisher.publish(\n new SettingsBeforeUpdateEvent({\n original: existing,\n settings: updatedSettings,\n input: validatedInput\n })\n );\n\n const result = await this.keyValueStore.set(FILE_MANAGER_GENERAL_SETTINGS, updatedSettings);\n\n if (result.isFail()) {\n return Result.fail(new SettingsUpdateError(result.error));\n }\n\n // Publish AfterUpdate event\n await this.eventPublisher.publish(\n new SettingsAfterUpdateEvent({\n original: existing,\n settings: updatedSettings,\n input: validatedInput\n })\n );\n\n return Result.ok(updatedSettings);\n }\n}\n\nexport const UpdateSettingsUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateSettingsUseCaseImpl,\n dependencies: [KeyValueStore, GetSettingsUseCase, EventPublisher]\n});\n"],"names":["UpdateSettingsUseCaseImpl","keyValueStore","getSettings","eventPublisher","input","validationResult","updateSettingsValidation","zodError","createZodError","Result","SettingsValidationError","validatedInput","existingResult","existing","updatedSettings","SettingsBeforeUpdateEvent","result","FILE_MANAGER_GENERAL_SETTINGS","SettingsUpdateError","SettingsAfterUpdateEvent","UpdateSettingsUseCase","UseCaseAbstraction","KeyValueStore","GetSettingsUseCase","EventPublisher"],"mappings":";;;;;;;;;;AAcA,MAAMA;IACF,YACYC,aAAsC,EACtCC,WAAyC,EACzCC,cAAwC,CAClD;aAHUF,aAAa,GAAbA;aACAC,WAAW,GAAXA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QACFC,KAA0B,EACoC;QAE9D,MAAMC,mBAAmB,MAAMC,yBAAyB,cAAc,CAACF;QACvE,IAAI,CAACC,iBAAiB,OAAO,EAAE;YAC3B,MAAME,WAAWC,eAAeH,iBAAiB,KAAK;YACtD,OAAOI,OAAO,IAAI,CAAC,IAAIC,wBAAwBH,SAAS,IAAI,CAAE,aAAa;QAC/E;QAEA,MAAMI,iBAAiBN,iBAAiB,IAAI;QAG5C,MAAMO,iBAAiB,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO;QACrD,MAAMC,WAAWD,eAAe,KAAK;QAGrC,MAAME,kBAAuC;YACzC,GAAGD,QAAQ;YACX,GAAGF,cAAc;QACrB;QAGA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAII,0BAA0B;YAC1B,UAAUF;YACV,UAAUC;YACV,OAAOH;QACX;QAGJ,MAAMK,SAAS,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAACC,+BAA+BH;QAE3E,IAAIE,OAAO,MAAM,IACb,OAAOP,OAAO,IAAI,CAAC,IAAIS,oBAAoBF,OAAO,KAAK;QAI3D,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIG,yBAAyB;YACzB,UAAUN;YACV,UAAUC;YACV,OAAOH;QACX;QAGJ,OAAOF,OAAO,EAAE,CAACK;IACrB;AACJ;AAEO,MAAMM,8CAAwBC,sBAAAA,oBAAuC,CAAC;IACzE,gBAAgBrB;IAChB,cAAc;QAACsB;QAAeC;QAAoBC;KAAe;AACrE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ICompleteMultiPartUploadParams {
|
|
2
|
+
fileKey: string;
|
|
3
|
+
uploadId: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ICompleteMultiPartUploadUseCase {
|
|
6
|
+
execute(params: ICompleteMultiPartUploadParams): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const CompleteMultiPartUploadUseCase: import("@webiny/di").Abstraction<ICompleteMultiPartUploadUseCase>;
|
|
9
|
+
export declare namespace CompleteMultiPartUploadUseCase {
|
|
10
|
+
type Interface = ICompleteMultiPartUploadUseCase;
|
|
11
|
+
type Params = ICompleteMultiPartUploadParams;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/upload/CompleteMultiPartUpload/abstractions.js","sources":["../../../../src/features/upload/CompleteMultiPartUpload/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface ICompleteMultiPartUploadParams {\n fileKey: string;\n uploadId: string;\n}\n\nexport interface ICompleteMultiPartUploadUseCase {\n execute(params: ICompleteMultiPartUploadParams): Promise<void>;\n}\n\nexport const CompleteMultiPartUploadUseCase = createAbstraction<ICompleteMultiPartUploadUseCase>(\n \"CompleteMultiPartUploadUseCase\"\n);\n\nexport namespace CompleteMultiPartUploadUseCase {\n export type Interface = ICompleteMultiPartUploadUseCase;\n export type Params = ICompleteMultiPartUploadParams;\n}\n"],"names":["CompleteMultiPartUploadUseCase","createAbstraction"],"mappings":";AAWO,MAAMA,iCAAiCC,kBAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CompleteMultiPartUploadUseCase } from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CompleteMultiPartUploadUseCase } from "./abstractions.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FileData } from "../../../features/upload/types.js";
|
|
2
|
+
import type { CreateMultiPartUploadResult } from "../../../features/upload/types.js";
|
|
3
|
+
export interface ICreateMultiPartUploadParams {
|
|
4
|
+
file: FileData;
|
|
5
|
+
numberOfParts: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ICreateMultiPartUploadUseCase {
|
|
8
|
+
execute(params: ICreateMultiPartUploadParams): Promise<CreateMultiPartUploadResult>;
|
|
9
|
+
}
|
|
10
|
+
export declare const CreateMultiPartUploadUseCase: import("@webiny/di").Abstraction<ICreateMultiPartUploadUseCase>;
|
|
11
|
+
export declare namespace CreateMultiPartUploadUseCase {
|
|
12
|
+
type Interface = ICreateMultiPartUploadUseCase;
|
|
13
|
+
type Params = ICreateMultiPartUploadParams;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/upload/CreateMultiPartUpload/abstractions.js","sources":["../../../../src/features/upload/CreateMultiPartUpload/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { FileData } from \"~/features/upload/types.js\";\nimport type { CreateMultiPartUploadResult } from \"~/features/upload/types.js\";\n\nexport interface ICreateMultiPartUploadParams {\n file: FileData;\n numberOfParts: number;\n}\n\nexport interface ICreateMultiPartUploadUseCase {\n execute(params: ICreateMultiPartUploadParams): Promise<CreateMultiPartUploadResult>;\n}\n\nexport const CreateMultiPartUploadUseCase = createAbstraction<ICreateMultiPartUploadUseCase>(\n \"CreateMultiPartUploadUseCase\"\n);\n\nexport namespace CreateMultiPartUploadUseCase {\n export type Interface = ICreateMultiPartUploadUseCase;\n export type Params = ICreateMultiPartUploadParams;\n}\n"],"names":["CreateMultiPartUploadUseCase","createAbstraction"],"mappings":";AAaO,MAAMA,+BAA+BC,kBACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CreateMultiPartUploadUseCase } from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CreateMultiPartUploadUseCase } from "./abstractions.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FileData } from "../../../features/upload/types.js";
|
|
2
|
+
import type { UploadPayloadResponse } from "../../../features/upload/types.js";
|
|
3
|
+
import type { FileManagerSettings } from "../../../domain/settings/types.js";
|
|
4
|
+
export interface IGetUploadPayloadUseCase {
|
|
5
|
+
execute(file: FileData, settings: FileManagerSettings): Promise<UploadPayloadResponse>;
|
|
6
|
+
}
|
|
7
|
+
export declare const GetUploadPayloadUseCase: import("@webiny/di").Abstraction<IGetUploadPayloadUseCase>;
|
|
8
|
+
export declare namespace GetUploadPayloadUseCase {
|
|
9
|
+
type Interface = IGetUploadPayloadUseCase;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/upload/GetUploadPayload/abstractions.js","sources":["../../../../src/features/upload/GetUploadPayload/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { FileData } from \"~/features/upload/types.js\";\nimport type { UploadPayloadResponse } from \"~/features/upload/types.js\";\nimport type { FileManagerSettings } from \"~/domain/settings/types.js\";\n\nexport interface IGetUploadPayloadUseCase {\n execute(file: FileData, settings: FileManagerSettings): Promise<UploadPayloadResponse>;\n}\n\nexport const GetUploadPayloadUseCase =\n createAbstraction<IGetUploadPayloadUseCase>(\"GetUploadPayloadUseCase\");\n\nexport namespace GetUploadPayloadUseCase {\n export type Interface = IGetUploadPayloadUseCase;\n}\n"],"names":["GetUploadPayloadUseCase","createAbstraction"],"mappings":";AASO,MAAMA,0BACTC,kBAA4C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GetUploadPayloadUseCase } from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GetUploadPayloadUseCase } from "./abstractions.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GlobalKeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
2
|
+
import { type IMetadataReader, type AssetMetadata } from "./abstractions.js";
|
|
3
|
+
declare class MetadataReaderImpl implements IMetadataReader {
|
|
4
|
+
private readonly keyValueStore;
|
|
5
|
+
constructor(keyValueStore: GlobalKeyValueStore.Interface);
|
|
6
|
+
read(fileId: string): Promise<AssetMetadata | undefined>;
|
|
7
|
+
}
|
|
8
|
+
export declare const MetadataReader: typeof MetadataReaderImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<IMetadataReader>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GlobalKeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
2
|
+
import { MetadataReader } from "./abstractions.js";
|
|
3
|
+
class MetadataReaderImpl {
|
|
4
|
+
constructor(keyValueStore){
|
|
5
|
+
this.keyValueStore = keyValueStore;
|
|
6
|
+
}
|
|
7
|
+
async read(fileId) {
|
|
8
|
+
const result = await this.keyValueStore.get(`FileManager/File/${fileId}/Metadata`);
|
|
9
|
+
if (result.isFail()) return;
|
|
10
|
+
return result.value;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const MetadataReader_MetadataReader = MetadataReader.createImplementation({
|
|
14
|
+
implementation: MetadataReaderImpl,
|
|
15
|
+
dependencies: [
|
|
16
|
+
GlobalKeyValueStore
|
|
17
|
+
]
|
|
18
|
+
});
|
|
19
|
+
export { MetadataReader_MetadataReader as MetadataReader };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=MetadataReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/upload/ReadFileMetadata/MetadataReader.js","sources":["../../../../src/features/upload/ReadFileMetadata/MetadataReader.ts"],"sourcesContent":["import { GlobalKeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport {\n MetadataReader as MetadataReaderAbstraction,\n type IMetadataReader,\n type AssetMetadata\n} from \"./abstractions.js\";\n\nclass MetadataReaderImpl implements IMetadataReader {\n private readonly keyValueStore: GlobalKeyValueStore.Interface;\n\n public constructor(keyValueStore: GlobalKeyValueStore.Interface) {\n this.keyValueStore = keyValueStore;\n }\n\n public async read(fileId: string): Promise<AssetMetadata | undefined> {\n const result = await this.keyValueStore.get<AssetMetadata>(\n `FileManager/File/${fileId}/Metadata`\n );\n\n if (result.isFail()) {\n return undefined;\n }\n\n return result.value;\n }\n}\n\nexport const MetadataReader = MetadataReaderAbstraction.createImplementation({\n implementation: MetadataReaderImpl,\n dependencies: [GlobalKeyValueStore]\n});\n"],"names":["MetadataReaderImpl","keyValueStore","fileId","result","MetadataReader","MetadataReaderAbstraction","GlobalKeyValueStore"],"mappings":";;AAOA,MAAMA;IAGF,YAAmBC,aAA4C,CAAE;QAC7D,IAAI,CAAC,aAAa,GAAGA;IACzB;IAEA,MAAa,KAAKC,MAAc,EAAsC;QAClE,MAAMC,SAAS,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CACvC,CAAC,iBAAiB,EAAED,OAAO,SAAS,CAAC;QAGzC,IAAIC,OAAO,MAAM,IACb;QAGJ,OAAOA,OAAO,KAAK;IACvB;AACJ;AAEO,MAAMC,gCAAiBC,eAAAA,oBAA8C,CAAC;IACzE,gBAAgBL;IAChB,cAAc;QAACM;KAAoB;AACvC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface AssetMetadata {
|
|
2
|
+
id: string;
|
|
3
|
+
tenant: string;
|
|
4
|
+
size: number;
|
|
5
|
+
contentType: string;
|
|
6
|
+
bucketKey: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IMetadataReader {
|
|
9
|
+
read(fileId: string): Promise<AssetMetadata | undefined>;
|
|
10
|
+
}
|
|
11
|
+
export declare const MetadataReader: import("@webiny/di").Abstraction<IMetadataReader>;
|
|
12
|
+
export declare namespace MetadataReader {
|
|
13
|
+
type Interface = IMetadataReader;
|
|
14
|
+
type Metadata = AssetMetadata;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/upload/ReadFileMetadata/abstractions.js","sources":["../../../../src/features/upload/ReadFileMetadata/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface AssetMetadata {\n id: string;\n tenant: string;\n size: number;\n contentType: string;\n bucketKey: string;\n}\n\nexport interface IMetadataReader {\n read(fileId: string): Promise<AssetMetadata | undefined>;\n}\n\nexport const MetadataReader = createAbstraction<IMetadataReader>(\n \"FileManager/Upload/MetadataReader\"\n);\n\nexport namespace MetadataReader {\n export type Interface = IMetadataReader;\n export type Metadata = AssetMetadata;\n}\n"],"names":["MetadataReader","createAbstraction"],"mappings":";AAcO,MAAMA,iBAAiBC,kBAC1B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { MetadataReader } from "./MetadataReader.js";
|
|
3
|
+
const ReadFileMetadataFeature = createFeature({
|
|
4
|
+
name: "FileManager/ReadFileMetadata",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(MetadataReader);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { ReadFileMetadataFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/upload/ReadFileMetadata/feature.js","sources":["../../../../src/features/upload/ReadFileMetadata/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { MetadataReader } from \"./MetadataReader.js\";\n\nexport const ReadFileMetadataFeature = createFeature({\n name: \"FileManager/ReadFileMetadata\",\n register(container) {\n container.register(MetadataReader);\n }\n});\n"],"names":["ReadFileMetadataFeature","createFeature","container","MetadataReader"],"mappings":";;AAGO,MAAMA,0BAA0BC,cAAc;IACjD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MetadataReader } from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MetadataReader } from "./abstractions.js";
|