@webiny/api-file-manager 6.3.0 → 6.4.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contants.js +2 -1
- package/contants.js.map +1 -1
- package/delivery/AssetDelivery/Asset.js +50 -56
- package/delivery/AssetDelivery/Asset.js.map +1 -1
- package/delivery/AssetDelivery/AssetDeliveryConfig.js +70 -83
- package/delivery/AssetDelivery/AssetDeliveryConfig.js.map +1 -1
- package/delivery/AssetDelivery/AssetRequest.js +20 -19
- package/delivery/AssetDelivery/AssetRequest.js.map +1 -1
- package/delivery/AssetDelivery/FilesAssetRequestResolver.js +19 -25
- package/delivery/AssetDelivery/FilesAssetRequestResolver.js.map +1 -1
- package/delivery/AssetDelivery/NullAssetOutputStrategy.js +5 -4
- package/delivery/AssetDelivery/NullAssetOutputStrategy.js.map +1 -1
- package/delivery/AssetDelivery/NullAssetReply.js +10 -9
- package/delivery/AssetDelivery/NullAssetReply.js.map +1 -1
- package/delivery/AssetDelivery/NullAssetResolver.js +5 -4
- package/delivery/AssetDelivery/NullAssetResolver.js.map +1 -1
- package/delivery/AssetDelivery/NullRequestResolver.js +5 -4
- package/delivery/AssetDelivery/NullRequestResolver.js.map +1 -1
- package/delivery/AssetDelivery/SetCacheControlHeaders.js +11 -14
- package/delivery/AssetDelivery/SetCacheControlHeaders.js.map +1 -1
- package/delivery/AssetDelivery/SetResponseHeaders.js +16 -15
- package/delivery/AssetDelivery/SetResponseHeaders.js.map +1 -1
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetProcessor.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetReply.js +28 -27
- package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -1
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetResolver.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js +0 -3
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js +4 -5
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js +0 -3
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js +15 -14
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +5 -4
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +14 -16
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/PrivateCache.js +18 -17
- package/delivery/AssetDelivery/privateFiles/PrivateCache.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +21 -25
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js +44 -51
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/PublicCache.js +18 -17
- package/delivery/AssetDelivery/privateFiles/PublicCache.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +16 -15
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +16 -15
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -1
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js +5 -4
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js.map +1 -1
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js +5 -4
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +1 -1
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js +12 -15
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js.map +1 -1
- package/delivery/index.js +0 -2
- package/delivery/setupAssetDelivery.js +70 -101
- package/delivery/setupAssetDelivery.js.map +1 -1
- package/domain/file/abstractions.js +2 -5
- package/domain/file/abstractions.js.map +1 -1
- package/domain/file/errors.js +67 -76
- package/domain/file/errors.js.map +1 -1
- package/domain/file/file.model.js +57 -49
- package/domain/file/file.model.js.map +1 -1
- package/domain/file/types.js +0 -3
- package/domain/identity/Identity.js +9 -8
- package/domain/identity/Identity.js.map +1 -1
- package/domain/permissionsSchema.js +26 -15
- package/domain/permissionsSchema.js.map +1 -1
- package/domain/settings/constants.js +2 -1
- package/domain/settings/constants.js.map +1 -1
- package/domain/settings/errors.js +22 -24
- package/domain/settings/errors.js.map +1 -1
- package/domain/settings/types.js +0 -3
- package/domain/settings/validation.js +18 -27
- package/domain/settings/validation.js.map +1 -1
- package/exports/api/file-manager/file.js +0 -2
- package/exports/api/file-manager/permissions.js +0 -2
- package/exports/api/file-manager/settings.js +0 -2
- package/features/FileManagerFeature.js +16 -15
- package/features/FileManagerFeature.js.map +1 -1
- package/features/file/CreateFile/CreateFileRepository.js +20 -18
- package/features/file/CreateFile/CreateFileRepository.js.map +1 -1
- package/features/file/CreateFile/CreateFileUseCase.js +68 -75
- package/features/file/CreateFile/CreateFileUseCase.js.map +1 -1
- package/features/file/CreateFile/abstractions.js +3 -14
- package/features/file/CreateFile/abstractions.js.map +1 -1
- package/features/file/CreateFile/events.js +17 -26
- package/features/file/CreateFile/events.js.map +1 -1
- package/features/file/CreateFile/feature.js +7 -6
- package/features/file/CreateFile/feature.js.map +1 -1
- package/features/file/CreateFile/index.js +0 -2
- package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js +15 -17
- package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js.map +1 -1
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js +59 -70
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js.map +1 -1
- package/features/file/CreateFilesInBatch/abstractions.js +3 -14
- package/features/file/CreateFilesInBatch/abstractions.js.map +1 -1
- package/features/file/CreateFilesInBatch/events.js +17 -26
- package/features/file/CreateFilesInBatch/events.js.map +1 -1
- package/features/file/CreateFilesInBatch/feature.js +7 -6
- package/features/file/CreateFilesInBatch/feature.js.map +1 -1
- package/features/file/CreateFilesInBatch/index.js +0 -2
- package/features/file/DeleteFile/DeleteFileRepository.js +21 -20
- package/features/file/DeleteFile/DeleteFileRepository.js.map +1 -1
- package/features/file/DeleteFile/DeleteFileUseCase.js +31 -33
- package/features/file/DeleteFile/DeleteFileUseCase.js.map +1 -1
- package/features/file/DeleteFile/abstractions.js +3 -14
- package/features/file/DeleteFile/abstractions.js.map +1 -1
- package/features/file/DeleteFile/events.js +17 -26
- package/features/file/DeleteFile/events.js.map +1 -1
- package/features/file/DeleteFile/feature.js +7 -6
- package/features/file/DeleteFile/feature.js.map +1 -1
- package/features/file/DeleteFile/index.js +1 -3
- package/features/file/FileUrlGenerator/abstractions.js +2 -2
- package/features/file/FileUrlGenerator/abstractions.js.map +1 -1
- package/features/file/GetFile/GetFileRepository.js +22 -22
- package/features/file/GetFile/GetFileRepository.js.map +1 -1
- package/features/file/GetFile/GetFileUseCase.js +19 -21
- package/features/file/GetFile/GetFileUseCase.js.map +1 -1
- package/features/file/GetFile/abstractions.js +3 -14
- package/features/file/GetFile/abstractions.js.map +1 -1
- package/features/file/GetFile/feature.js +7 -6
- package/features/file/GetFile/feature.js.map +1 -1
- package/features/file/GetFile/index.js +0 -2
- package/features/file/GetFileContentsById/abstractions.d.ts +20 -0
- package/features/file/GetFileContentsById/abstractions.js +5 -0
- package/features/file/GetFileContentsById/abstractions.js.map +1 -0
- package/features/file/GetFileContentsById/index.d.ts +1 -0
- package/features/file/GetFileContentsById/index.js +1 -0
- package/features/file/GetFileContentsByKey/abstractions.d.ts +17 -0
- package/features/file/GetFileContentsByKey/abstractions.js +5 -0
- package/features/file/GetFileContentsByKey/abstractions.js.map +1 -0
- package/features/file/GetFileContentsByKey/index.d.ts +1 -0
- package/features/file/GetFileContentsByKey/index.js +1 -0
- package/features/file/ListFiles/ListFilesRepository.js +42 -40
- package/features/file/ListFiles/ListFilesRepository.js.map +1 -1
- package/features/file/ListFiles/ListFilesUseCase.js +33 -34
- package/features/file/ListFiles/ListFilesUseCase.js.map +1 -1
- package/features/file/ListFiles/abstractions.js +3 -14
- package/features/file/ListFiles/abstractions.js.map +1 -1
- package/features/file/ListFiles/feature.js +7 -6
- package/features/file/ListFiles/feature.js.map +1 -1
- package/features/file/ListFiles/index.js +0 -2
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.js +31 -28
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.js.map +1 -1
- package/features/file/ListImagesByTagTool/feature.js +6 -5
- package/features/file/ListImagesByTagTool/feature.js.map +1 -1
- package/features/file/ListTags/ListTagsRepository.js +31 -36
- package/features/file/ListTags/ListTagsRepository.js.map +1 -1
- package/features/file/ListTags/ListTagsUseCase.js +21 -21
- package/features/file/ListTags/ListTagsUseCase.js.map +1 -1
- package/features/file/ListTags/abstractions.js +3 -14
- package/features/file/ListTags/abstractions.js.map +1 -1
- package/features/file/ListTags/feature.js +7 -6
- package/features/file/ListTags/feature.js.map +1 -1
- package/features/file/ListTags/index.js +0 -2
- package/features/file/UpdateFile/UpdateFileRepository.js +26 -28
- package/features/file/UpdateFile/UpdateFileRepository.js.map +1 -1
- package/features/file/UpdateFile/UpdateFileUseCase.js +57 -65
- package/features/file/UpdateFile/UpdateFileUseCase.js.map +1 -1
- package/features/file/UpdateFile/abstractions.js +3 -14
- package/features/file/UpdateFile/abstractions.js.map +1 -1
- package/features/file/UpdateFile/events.js +17 -26
- package/features/file/UpdateFile/events.js.map +1 -1
- package/features/file/UpdateFile/feature.js +7 -6
- package/features/file/UpdateFile/feature.js.map +1 -1
- package/features/file/UpdateFile/index.js +1 -3
- package/features/file/shared/EntryToFileMapper.js +25 -24
- package/features/file/shared/EntryToFileMapper.js.map +1 -1
- package/features/file/shared/FileInputToEntryInputMapper.js +29 -28
- package/features/file/shared/FileInputToEntryInputMapper.js.map +1 -1
- package/features/file/shared/FileToEntryMapper.js +28 -27
- package/features/file/shared/FileToEntryMapper.js.map +1 -1
- package/features/permissions/abstractions.js +2 -1
- package/features/permissions/abstractions.js.map +1 -1
- package/features/permissions/feature.js +2 -1
- package/features/permissions/feature.js.map +1 -1
- package/features/settings/GetSettings/GetSettingsUseCase.js +19 -19
- package/features/settings/GetSettings/GetSettingsUseCase.js.map +1 -1
- package/features/settings/GetSettings/abstractions.js +2 -7
- package/features/settings/GetSettings/abstractions.js.map +1 -1
- package/features/settings/GetSettings/feature.js +6 -5
- package/features/settings/GetSettings/feature.js.map +1 -1
- package/features/settings/SettingsInstaller/SettingsInstaller.js +25 -24
- package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -1
- package/features/settings/SettingsInstaller/feature.js +6 -5
- package/features/settings/SettingsInstaller/feature.js.map +1 -1
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js +41 -48
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js.map +1 -1
- package/features/settings/UpdateSettings/abstractions.js +2 -7
- package/features/settings/UpdateSettings/abstractions.js.map +1 -1
- package/features/settings/UpdateSettings/events.js +17 -26
- package/features/settings/UpdateSettings/events.js.map +1 -1
- package/features/settings/UpdateSettings/feature.js +6 -5
- package/features/settings/UpdateSettings/feature.js.map +1 -1
- package/features/settings/UpdateSettings/index.js +0 -2
- package/features/shared/abstractions.js +0 -2
- package/graphql/baseSchema.js +30 -33
- package/graphql/baseSchema.js.map +1 -1
- package/graphql/createFilesTypeDefs.js +49 -57
- package/graphql/createFilesTypeDefs.js.map +1 -1
- package/graphql/filesSchema.js +79 -99
- package/graphql/filesSchema.js.map +1 -1
- package/graphql/getFileByUrl.js +45 -53
- package/graphql/getFileByUrl.js.map +1 -1
- package/graphql/index.js +35 -42
- package/graphql/index.js.map +1 -1
- package/graphql/utils.js +9 -14
- package/graphql/utils.js.map +1 -1
- package/index.js +19 -30
- package/index.js.map +1 -1
- package/modelModifier/CmsModelModifier.js +40 -43
- package/modelModifier/CmsModelModifier.js.map +1 -1
- package/package.json +17 -20
- package/types.js +0 -2
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetProcessor.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetResolver.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js.map +0 -1
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js.map +0 -1
- package/delivery/index.js.map +0 -1
- package/domain/file/types.js.map +0 -1
- package/domain/settings/types.js.map +0 -1
- package/exports/api/file-manager/file.js.map +0 -1
- package/exports/api/file-manager/permissions.js.map +0 -1
- package/exports/api/file-manager/settings.js.map +0 -1
- package/features/ai/AiImageEnrichmentAfterCreateHandler.d.ts +0 -11
- package/features/ai/AiImageEnrichmentAfterCreateHandler.js +0 -28
- package/features/ai/AiImageEnrichmentAfterCreateHandler.js.map +0 -1
- package/features/ai/AiImageEnrichmentFeature.d.ts +0 -4
- package/features/ai/AiImageEnrichmentFeature.js +0 -12
- package/features/ai/AiImageEnrichmentFeature.js.map +0 -1
- package/features/file/CreateFile/index.js.map +0 -1
- package/features/file/CreateFilesInBatch/index.js.map +0 -1
- package/features/file/DeleteFile/index.js.map +0 -1
- package/features/file/GetFile/index.js.map +0 -1
- package/features/file/ListFiles/index.js.map +0 -1
- package/features/file/ListTags/index.js.map +0 -1
- package/features/file/UpdateFile/index.js.map +0 -1
- package/features/settings/UpdateSettings/index.js.map +0 -1
- package/features/shared/abstractions.js.map +0 -1
- package/tasks/AiImageEnrichmentTask.d.ts +0 -35
- package/tasks/AiImageEnrichmentTask.js +0 -136
- package/tasks/AiImageEnrichmentTask.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** Fetch files from storage with filtering. */
|
|
8
|
-
export const ListFilesRepository = createAbstraction("ListFilesRepository");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* ListFiles use case interface
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/** List files with filtering and pagination. */
|
|
15
|
-
export const ListFilesUseCase = createAbstraction("ListFilesUseCase");
|
|
2
|
+
const ListFilesRepository = createAbstraction("ListFilesRepository");
|
|
3
|
+
const ListFilesUseCase = createAbstraction("ListFilesUseCase");
|
|
4
|
+
export { ListFilesRepository, ListFilesUseCase };
|
|
16
5
|
|
|
17
6
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/file/ListFiles/abstractions.js","sources":["../../../../src/features/file/ListFiles/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport type { File } from \"~/domain/file/types.js\";\nimport { type FilePersistenceError, FileNotAuthorizedError } from \"~/domain/file/errors.js\";\nimport type { CmsEntryMeta } from \"@webiny/api-headless-cms/types\";\n\nexport interface ListFilesInput {\n limit?: number;\n after?: string | null;\n where?: Record<string, any>;\n sort?: Array<`${string}_ASC` | `${string}_DESC`>;\n search?: string;\n}\n\nexport interface ListFilesOutput {\n items: File[];\n meta: CmsEntryMeta;\n}\n\n/**\n * ListFiles repository interface\n */\nexport interface IListFilesRepository {\n execute(input: ListFilesInput): Promise<Result<ListFilesOutput, RepositoryError>>;\n}\n\nexport interface IListFilesRepositoryErrors {\n persistence: FilePersistenceError;\n}\n\ntype RepositoryError = IListFilesRepositoryErrors[keyof IListFilesRepositoryErrors];\n\n/** Fetch files from storage with filtering. */\nexport const ListFilesRepository = createAbstraction<IListFilesRepository>(\"ListFilesRepository\");\n\nexport namespace ListFilesRepository {\n export type Interface = IListFilesRepository;\n export type Error = RepositoryError;\n}\n\n/**\n * ListFiles use case interface\n */\nexport interface IListFilesUseCase {\n execute(input: ListFilesInput): Promise<Result<ListFilesOutput, UseCaseError>>;\n}\n\nexport interface IListFilesUseCaseErrors {\n notAuthorized: FileNotAuthorizedError;\n persistence: FilePersistenceError;\n}\n\ntype UseCaseError = IListFilesUseCaseErrors[keyof IListFilesUseCaseErrors];\n\n/** List files with filtering and pagination. */\nexport const ListFilesUseCase = createAbstraction<IListFilesUseCase>(\"ListFilesUseCase\");\n\nexport namespace ListFilesUseCase {\n export type Interface = IListFilesUseCase;\n export type Error = UseCaseError;\n}\n"],"names":["ListFilesRepository","createAbstraction","ListFilesUseCase"],"mappings":";AAiCO,MAAMA,sBAAsBC,kBAAwC;AAsBpE,MAAMC,mBAAmBD,kBAAqC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { ListFilesRepository } from "./ListFilesRepository.js";
|
|
3
3
|
import { ListFilesUseCase } from "./ListFilesUseCase.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const ListFilesFeature = createFeature({
|
|
5
|
+
name: "FileManager/ListFiles",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(ListFilesUseCase);
|
|
8
|
+
container.register(ListFilesRepository).inSingletonScope();
|
|
9
|
+
}
|
|
10
10
|
});
|
|
11
|
+
export { ListFilesFeature };
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/file/ListFiles/feature.js","sources":["../../../../src/features/file/ListFiles/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListFilesRepository } from \"./ListFilesRepository.js\";\nimport { ListFilesUseCase } from \"./ListFilesUseCase.js\";\n\nexport const ListFilesFeature = createFeature({\n name: \"FileManager/ListFiles\",\n register(container) {\n container.register(ListFilesUseCase);\n container.register(ListFilesRepository).inSingletonScope();\n }\n});\n"],"names":["ListFilesFeature","createFeature","container","ListFilesUseCase","ListFilesRepository"],"mappings":";;;AAIO,MAAMA,mBAAmBC,cAAc;IAC1C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,qBAAqB,gBAAgB;IAC5D;AACJ"}
|
|
@@ -2,38 +2,41 @@ import { z } from "zod";
|
|
|
2
2
|
import { AiSdkTool } from "@webiny/api-core/features/ai/index.js";
|
|
3
3
|
import { ListFilesUseCase } from "../ListFiles/index.js";
|
|
4
4
|
const inputSchema = z.object({
|
|
5
|
-
|
|
5
|
+
tag: z.string().describe("Tag to filter images by")
|
|
6
6
|
});
|
|
7
7
|
class ListImagesByTagToolImpl {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
constructor(listFiles){
|
|
9
|
+
this.listFiles = listFiles;
|
|
10
|
+
this.name = "listImagesByTag";
|
|
11
|
+
this.description = "Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.";
|
|
12
|
+
this.inputSchema = inputSchema;
|
|
13
|
+
}
|
|
14
|
+
async execute(input) {
|
|
15
|
+
console.log("Call images tool", input);
|
|
16
|
+
const result = await this.listFiles.execute({
|
|
17
|
+
where: {
|
|
18
|
+
type_startsWith: "image/",
|
|
19
|
+
tags_in: [
|
|
20
|
+
input.tag
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
limit: 50
|
|
24
|
+
});
|
|
25
|
+
if (result.isFail()) return [];
|
|
26
|
+
return result.value.items.map((file)=>({
|
|
27
|
+
id: file.id,
|
|
28
|
+
name: file.name,
|
|
29
|
+
type: file.type,
|
|
30
|
+
tags: file.tags
|
|
31
|
+
}));
|
|
25
32
|
}
|
|
26
|
-
return result.value.items.map(file => ({
|
|
27
|
-
id: file.id,
|
|
28
|
-
name: file.name,
|
|
29
|
-
type: file.type,
|
|
30
|
-
tags: file.tags
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const ListImagesByTagTool = AiSdkTool.createImplementation({
|
|
35
|
+
implementation: ListImagesByTagToolImpl,
|
|
36
|
+
dependencies: [
|
|
37
|
+
ListFilesUseCase
|
|
38
|
+
]
|
|
37
39
|
});
|
|
40
|
+
export { ListImagesByTagTool };
|
|
38
41
|
|
|
39
42
|
//# sourceMappingURL=ListImagesByTagTool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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;IAMF,YAAoBC,SAAqC,CAAE;aAAvCA,SAAS,GAATA;aALX,IAAI,GAAG;aACP,WAAW,GAChB;aACK,WAAW,GAAGH;IAEqC;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,10 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { ListImagesByTagTool } from "./ListImagesByTagTool.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const ListImagesByTagToolFeature = createFeature({
|
|
4
|
+
name: "AiPowerUps/ListImagesByTagTool",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(ListImagesByTagTool);
|
|
7
|
+
}
|
|
8
8
|
});
|
|
9
|
+
export { ListImagesByTagToolFeature };
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/file/ListImagesByTagTool/feature.js","sources":["../../../../src/features/file/ListImagesByTagTool/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListImagesByTagTool } from \"./ListImagesByTagTool.js\";\n\nexport const ListImagesByTagToolFeature = createFeature({\n name: \"AiPowerUps/ListImagesByTagTool\",\n register(container) {\n container.register(ListImagesByTagTool);\n }\n});\n"],"names":["ListImagesByTagToolFeature","createFeature","container","ListImagesByTagTool"],"mappings":";;AAGO,MAAMA,6BAA6BC,cAAc;IACpD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -1,47 +1,42 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { GetUniqueFieldValuesUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetUniqueFieldValues";
|
|
3
|
-
import { ListTagsRepository
|
|
3
|
+
import { ListTagsRepository } from "./abstractions.js";
|
|
4
4
|
import { FileModel } 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
8
|
+
constructor(getUniqueFieldValues, fileModel, cmsWhereMapper){
|
|
9
|
+
this.getUniqueFieldValues = getUniqueFieldValues;
|
|
10
|
+
this.fileModel = fileModel;
|
|
11
|
+
this.cmsWhereMapper = cmsWhereMapper;
|
|
12
|
+
}
|
|
13
|
+
async execute(input) {
|
|
14
|
+
const result = await this.getUniqueFieldValues.execute(this.fileModel, {
|
|
15
|
+
fieldId: "tags",
|
|
16
|
+
where: this.cmsWhereMapper.map({
|
|
17
|
+
input: {
|
|
18
|
+
...input.where || {},
|
|
19
|
+
latest: true
|
|
20
|
+
},
|
|
21
|
+
fields: this.fileModel.fields
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
if (result.isFail()) return Result.fail(new FilePersistenceError(result.error));
|
|
25
|
+
const tags = result.value.map((uv)=>({
|
|
26
|
+
tag: uv.value,
|
|
27
|
+
count: uv.count
|
|
28
|
+
})).sort((a, b)=>a.tag < b.tag ? -1 : 1).sort((a, b)=>a.count > b.count ? -1 : 1);
|
|
29
|
+
return Result.ok(tags);
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
// Map to TagItem format
|
|
31
|
-
const tags = result.value.map(uv => ({
|
|
32
|
-
tag: uv.value,
|
|
33
|
-
count: uv.count
|
|
34
|
-
}))
|
|
35
|
-
// Sort by tag name alphabetically
|
|
36
|
-
.sort((a, b) => a.tag < b.tag ? -1 : 1)
|
|
37
|
-
// Then sort by count descending (most used first)
|
|
38
|
-
.sort((a, b) => a.count > b.count ? -1 : 1);
|
|
39
|
-
return Result.ok(tags);
|
|
40
|
-
}
|
|
41
31
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
const ListTagsRepository_ListTagsRepository = ListTagsRepository.createImplementation({
|
|
33
|
+
implementation: ListTagsRepositoryImpl,
|
|
34
|
+
dependencies: [
|
|
35
|
+
GetUniqueFieldValuesUseCase,
|
|
36
|
+
FileModel,
|
|
37
|
+
CmsWhereMapper
|
|
38
|
+
]
|
|
45
39
|
});
|
|
40
|
+
export { ListTagsRepository_ListTagsRepository as ListTagsRepository };
|
|
46
41
|
|
|
47
42
|
//# sourceMappingURL=ListTagsRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 { FileModel } 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 fileModel: FileModel.Interface,\n private cmsWhereMapper: CmsWhereMapper.Interface\n ) {}\n\n async execute(input: ListTagsInput): Promise<Result<TagItem[], RepositoryAbstraction.Error>> {\n const result = await this.getUniqueFieldValues.execute(this.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: this.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, FileModel, CmsWhereMapper]\n});\n"],"names":["ListTagsRepositoryImpl","getUniqueFieldValues","fileModel","cmsWhereMapper","input","result","Result","FilePersistenceError","tags","uv","a","b","ListTagsRepository","RepositoryAbstraction","GetUniqueFieldValuesUseCase","FileModel","CmsWhereMapper"],"mappings":";;;;;;AAWA,MAAMA;IACF,YACYC,oBAA2D,EAC3DC,SAA8B,EAC9BC,cAAwC,CAClD;aAHUF,oBAAoB,GAApBA;aACAC,SAAS,GAATA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQC,KAAoB,EAA2D;QACzF,MAAMC,SAAS,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE;YACnE,SAAS;YAGT,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;gBAC3B,OAAO;oBACH,GAAID,MAAM,KAAK,IAAI,CAAC,CAAC;oBACrB,QAAQ;gBACZ;gBACA,QAAQ,IAAI,CAAC,SAAS,CAAC,MAAM;YACjC;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,gBAAgBb;IAChB,cAAc;QAACc;QAA6BC;QAAWC;KAAe;AAC1E"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import {
|
|
2
|
+
import { ListTagsRepository, ListTagsUseCase } from "./abstractions.js";
|
|
3
3
|
import { FileNotAuthorizedError } from "../../../domain/file/errors.js";
|
|
4
4
|
import { FmPermissions } from "../../shared/abstractions.js";
|
|
5
5
|
class ListTagsUseCaseImpl {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
async execute(input) {
|
|
11
|
-
const hasPermission = await this.permissions.canAccess("file");
|
|
12
|
-
if (!hasPermission) {
|
|
13
|
-
return Result.fail(new FileNotAuthorizedError());
|
|
6
|
+
constructor(permissions, repository){
|
|
7
|
+
this.permissions = permissions;
|
|
8
|
+
this.repository = repository;
|
|
14
9
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
async execute(input) {
|
|
11
|
+
const hasPermission = await this.permissions.canAccess("file");
|
|
12
|
+
if (!hasPermission) return Result.fail(new FileNotAuthorizedError());
|
|
13
|
+
const enrichedInput = {
|
|
14
|
+
...input,
|
|
15
|
+
limit: input.limit || 1000000
|
|
16
|
+
};
|
|
17
|
+
const result = await this.repository.execute(enrichedInput);
|
|
18
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
19
|
+
return Result.ok(result.value);
|
|
22
20
|
}
|
|
23
|
-
return Result.ok(result.value);
|
|
24
|
-
}
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const ListTagsUseCase_ListTagsUseCase = ListTagsUseCase.createImplementation({
|
|
23
|
+
implementation: ListTagsUseCaseImpl,
|
|
24
|
+
dependencies: [
|
|
25
|
+
FmPermissions,
|
|
26
|
+
ListTagsRepository
|
|
27
|
+
]
|
|
29
28
|
});
|
|
29
|
+
export { ListTagsUseCase_ListTagsUseCase as ListTagsUseCase };
|
|
30
30
|
|
|
31
31
|
//# sourceMappingURL=ListTagsUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/file/ListTags/ListTagsUseCase.js","sources":["../../../../src/features/file/ListTags/ListTagsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListTagsUseCase as UseCaseAbstraction,\n ListTagsInput,\n TagItem,\n ListTagsRepository\n} from \"./abstractions.js\";\nimport { FileNotAuthorizedError } from \"~/domain/file/errors.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\n\nclass ListTagsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private permissions: FmPermissions.Interface,\n private repository: ListTagsRepository.Interface\n ) {}\n\n async execute(input: ListTagsInput): Promise<Result<TagItem[], UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canAccess(\"file\");\n if (!hasPermission) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n const enrichedInput: ListTagsInput = {\n ...input,\n limit: input.limit || 1000000\n };\n\n const result = await this.repository.execute(enrichedInput);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n return Result.ok(result.value);\n }\n}\n\nexport const ListTagsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListTagsUseCaseImpl,\n dependencies: [FmPermissions, ListTagsRepository]\n});\n"],"names":["ListTagsUseCaseImpl","permissions","repository","input","hasPermission","Result","FileNotAuthorizedError","enrichedInput","result","ListTagsUseCase","UseCaseAbstraction","FmPermissions","ListTagsRepository"],"mappings":";;;;AAUA,MAAMA;IACF,YACYC,WAAoC,EACpCC,UAAwC,CAClD;aAFUD,WAAW,GAAXA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QAAQC,KAAoB,EAAwD;QACtF,MAAMC,gBAAgB,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;QACvD,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,gBAA+B;YACjC,GAAGJ,KAAK;YACR,OAAOA,MAAM,KAAK,IAAI;QAC1B;QAEA,MAAMK,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACD;QAE7C,IAAIC,OAAO,MAAM,IACb,OAAOH,OAAO,IAAI,CAACG,OAAO,KAAK;QAGnC,OAAOH,OAAO,EAAE,CAACG,OAAO,KAAK;IACjC;AACJ;AAEO,MAAMC,kCAAkBC,gBAAAA,oBAAuC,CAAC;IACnE,gBAAgBV;IAChB,cAAc;QAACW;QAAeC;KAAmB;AACrD"}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** Fetch file tags from storage. */
|
|
8
|
-
export const ListTagsRepository = createAbstraction("ListTagsRepository");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* ListTags use case interface
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/** List all file tags. */
|
|
15
|
-
export const ListTagsUseCase = createAbstraction("ListTagsUseCase");
|
|
2
|
+
const ListTagsRepository = createAbstraction("ListTagsRepository");
|
|
3
|
+
const ListTagsUseCase = createAbstraction("ListTagsUseCase");
|
|
4
|
+
export { ListTagsRepository, ListTagsUseCase };
|
|
16
5
|
|
|
17
6
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/file/ListTags/abstractions.js","sources":["../../../../src/features/file/ListTags/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport { type FilePersistenceError, FileNotAuthorizedError } from \"~/domain/file/errors.js\";\n\nexport interface ListTagsInput {\n where?: Record<string, any>;\n after?: string | null;\n limit?: number;\n}\n\nexport interface TagItem {\n tag: string;\n count: number;\n}\n\n/**\n * ListTags repository interface\n */\nexport interface IListTagsRepository {\n execute(input: ListTagsInput): Promise<Result<TagItem[], RepositoryError>>;\n}\n\nexport interface IListTagsRepositoryErrors {\n persistence: FilePersistenceError;\n}\n\ntype RepositoryError = IListTagsRepositoryErrors[keyof IListTagsRepositoryErrors];\n\n/** Fetch file tags from storage. */\nexport const ListTagsRepository = createAbstraction<IListTagsRepository>(\"ListTagsRepository\");\n\nexport namespace ListTagsRepository {\n export type Interface = IListTagsRepository;\n export type Error = RepositoryError;\n}\n\n/**\n * ListTags use case interface\n */\nexport interface IListTagsUseCase {\n execute(input: ListTagsInput): Promise<Result<TagItem[], UseCaseError>>;\n}\n\nexport interface IListTagsUseCaseErrors {\n notAuthorized: FileNotAuthorizedError;\n persistence: FilePersistenceError;\n}\n\ntype UseCaseError = IListTagsUseCaseErrors[keyof IListTagsUseCaseErrors];\n\n/** List all file tags. */\nexport const ListTagsUseCase = createAbstraction<IListTagsUseCase>(\"ListTagsUseCase\");\n\nexport namespace ListTagsUseCase {\n export type Interface = IListTagsUseCase;\n export type Error = UseCaseError;\n}\n"],"names":["ListTagsRepository","createAbstraction","ListTagsUseCase"],"mappings":";AA6BO,MAAMA,qBAAqBC,kBAAuC;AAsBlE,MAAMC,kBAAkBD,kBAAoC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { ListTagsRepository } from "./ListTagsRepository.js";
|
|
3
3
|
import { ListTagsUseCase } from "./ListTagsUseCase.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const ListTagsFeature = createFeature({
|
|
5
|
+
name: "FileManager/ListTags",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(ListTagsUseCase);
|
|
8
|
+
container.register(ListTagsRepository).inSingletonScope();
|
|
9
|
+
}
|
|
10
10
|
});
|
|
11
|
+
export { ListTagsFeature };
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/file/ListTags/feature.js","sources":["../../../../src/features/file/ListTags/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListTagsRepository } from \"./ListTagsRepository.js\";\nimport { ListTagsUseCase } from \"./ListTagsUseCase.js\";\n\nexport const ListTagsFeature = createFeature({\n name: \"FileManager/ListTags\",\n register(container) {\n container.register(ListTagsUseCase);\n container.register(ListTagsRepository).inSingletonScope();\n }\n});\n"],"names":["ListTagsFeature","createFeature","container","ListTagsUseCase","ListTagsRepository"],"mappings":";;;AAIO,MAAMA,kBAAkBC,cAAc;IACzC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,oBAAoB,gBAAgB;IAC3D;AACJ"}
|
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
|
|
3
|
-
import { UpdateFileRepository
|
|
3
|
+
import { UpdateFileRepository } from "./abstractions.js";
|
|
4
4
|
import { FileModel } 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (error.code === "Cms/Entry/NotAuthorized") {
|
|
27
|
-
return Result.fail(new FileNotAuthorizedError());
|
|
28
|
-
}
|
|
29
|
-
return Result.fail(new FilePersistenceError(result.error));
|
|
8
|
+
constructor(updateEntry, fileModel){
|
|
9
|
+
this.updateEntry = updateEntry;
|
|
10
|
+
this.fileModel = fileModel;
|
|
11
|
+
}
|
|
12
|
+
async update(file) {
|
|
13
|
+
const entry = FileToEntryMapper.toEntry(file);
|
|
14
|
+
const id = `${file.id}#0001`;
|
|
15
|
+
const result = await this.updateEntry.execute(this.fileModel, id, {
|
|
16
|
+
wbyAco_location: file.location,
|
|
17
|
+
values: entry.values
|
|
18
|
+
});
|
|
19
|
+
if (result.isFail()) {
|
|
20
|
+
const error = result.error;
|
|
21
|
+
if ("Cms/Entry/NotFound" === error.code) return Result.fail(new FileNotFoundError(id));
|
|
22
|
+
if ("Cms/Entry/NotAuthorized" === error.code) return Result.fail(new FileNotAuthorizedError());
|
|
23
|
+
return Result.fail(new FilePersistenceError(result.error));
|
|
24
|
+
}
|
|
25
|
+
return Result.ok();
|
|
30
26
|
}
|
|
31
|
-
return Result.ok();
|
|
32
|
-
}
|
|
33
27
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
const UpdateFileRepository_UpdateFileRepository = UpdateFileRepository.createImplementation({
|
|
29
|
+
implementation: UpdateFileRepositoryImpl,
|
|
30
|
+
dependencies: [
|
|
31
|
+
UpdateEntryUseCase,
|
|
32
|
+
FileModel
|
|
33
|
+
]
|
|
37
34
|
});
|
|
35
|
+
export { UpdateFileRepository_UpdateFileRepository as UpdateFileRepository };
|
|
38
36
|
|
|
39
37
|
//# sourceMappingURL=UpdateFileRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 { FileModel } 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 fileModel: FileModel.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 result = await this.updateEntry.execute(this.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, FileModel]\n});\n"],"names":["UpdateFileRepositoryImpl","updateEntry","fileModel","file","entry","FileToEntryMapper","id","result","error","Result","FileNotFoundError","FileNotAuthorizedError","FilePersistenceError","UpdateFileRepository","RepositoryAbstraction","UpdateEntryUseCase","FileModel"],"mappings":";;;;;;AAYA,MAAMA;IACF,YACYC,WAAyC,EACzCC,SAA8B,CACxC;aAFUD,WAAW,GAAXA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,OAAOC,IAAU,EAAsD;QACzE,MAAMC,QAAQC,kBAAkB,OAAO,CAACF;QAGxC,MAAMG,KAAK,GAAGH,KAAK,EAAE,CAAC,KAAK,CAAC;QAE5B,MAAMI,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAED,IAAI;YAC9D,iBAAiBH,KAAK,QAAQ;YAC9B,QAAQC,MAAM,MAAM;QACxB;QAEA,IAAIG,OAAO,MAAM,IAAI;YACjB,MAAMC,QAAQD,OAAO,KAAK;YAC1B,IAAIC,AAAe,yBAAfA,MAAM,IAAI,EACV,OAAOC,OAAO,IAAI,CAAC,IAAIC,kBAAkBJ;YAG7C,IAAIE,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,gBAAgBd;IAChB,cAAc;QAACe;QAAoBC;KAAU;AACjD"}
|