@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.
Files changed (250) hide show
  1. package/contants.js +2 -1
  2. package/contants.js.map +1 -1
  3. package/delivery/AssetDelivery/Asset.js +50 -56
  4. package/delivery/AssetDelivery/Asset.js.map +1 -1
  5. package/delivery/AssetDelivery/AssetDeliveryConfig.js +70 -83
  6. package/delivery/AssetDelivery/AssetDeliveryConfig.js.map +1 -1
  7. package/delivery/AssetDelivery/AssetRequest.js +20 -19
  8. package/delivery/AssetDelivery/AssetRequest.js.map +1 -1
  9. package/delivery/AssetDelivery/FilesAssetRequestResolver.js +19 -25
  10. package/delivery/AssetDelivery/FilesAssetRequestResolver.js.map +1 -1
  11. package/delivery/AssetDelivery/NullAssetOutputStrategy.js +5 -4
  12. package/delivery/AssetDelivery/NullAssetOutputStrategy.js.map +1 -1
  13. package/delivery/AssetDelivery/NullAssetReply.js +10 -9
  14. package/delivery/AssetDelivery/NullAssetReply.js.map +1 -1
  15. package/delivery/AssetDelivery/NullAssetResolver.js +5 -4
  16. package/delivery/AssetDelivery/NullAssetResolver.js.map +1 -1
  17. package/delivery/AssetDelivery/NullRequestResolver.js +5 -4
  18. package/delivery/AssetDelivery/NullRequestResolver.js.map +1 -1
  19. package/delivery/AssetDelivery/SetCacheControlHeaders.js +11 -14
  20. package/delivery/AssetDelivery/SetCacheControlHeaders.js.map +1 -1
  21. package/delivery/AssetDelivery/SetResponseHeaders.js +16 -15
  22. package/delivery/AssetDelivery/SetResponseHeaders.js.map +1 -1
  23. package/delivery/AssetDelivery/abstractions/AssetContentsReader.js +0 -3
  24. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js +0 -3
  25. package/delivery/AssetDelivery/abstractions/AssetProcessor.js +0 -3
  26. package/delivery/AssetDelivery/abstractions/AssetReply.js +28 -27
  27. package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -1
  28. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js +0 -3
  29. package/delivery/AssetDelivery/abstractions/AssetResolver.js +0 -3
  30. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js +0 -3
  31. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js +4 -5
  32. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js.map +1 -1
  33. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js +0 -3
  34. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js +15 -14
  35. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +1 -1
  36. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +5 -4
  37. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -1
  38. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +14 -16
  39. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -1
  40. package/delivery/AssetDelivery/privateFiles/PrivateCache.js +18 -17
  41. package/delivery/AssetDelivery/privateFiles/PrivateCache.js.map +1 -1
  42. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +21 -25
  43. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -1
  44. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js +44 -51
  45. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -1
  46. package/delivery/AssetDelivery/privateFiles/PublicCache.js +18 -17
  47. package/delivery/AssetDelivery/privateFiles/PublicCache.js.map +1 -1
  48. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +16 -15
  49. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -1
  50. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +16 -15
  51. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -1
  52. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js +5 -4
  53. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js.map +1 -1
  54. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js +5 -4
  55. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +1 -1
  56. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js +12 -15
  57. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js.map +1 -1
  58. package/delivery/index.js +0 -2
  59. package/delivery/setupAssetDelivery.js +70 -101
  60. package/delivery/setupAssetDelivery.js.map +1 -1
  61. package/domain/file/abstractions.js +2 -5
  62. package/domain/file/abstractions.js.map +1 -1
  63. package/domain/file/errors.js +67 -76
  64. package/domain/file/errors.js.map +1 -1
  65. package/domain/file/file.model.js +57 -49
  66. package/domain/file/file.model.js.map +1 -1
  67. package/domain/file/types.js +0 -3
  68. package/domain/identity/Identity.js +9 -8
  69. package/domain/identity/Identity.js.map +1 -1
  70. package/domain/permissionsSchema.js +26 -15
  71. package/domain/permissionsSchema.js.map +1 -1
  72. package/domain/settings/constants.js +2 -1
  73. package/domain/settings/constants.js.map +1 -1
  74. package/domain/settings/errors.js +22 -24
  75. package/domain/settings/errors.js.map +1 -1
  76. package/domain/settings/types.js +0 -3
  77. package/domain/settings/validation.js +18 -27
  78. package/domain/settings/validation.js.map +1 -1
  79. package/exports/api/file-manager/file.js +0 -2
  80. package/exports/api/file-manager/permissions.js +0 -2
  81. package/exports/api/file-manager/settings.js +0 -2
  82. package/features/FileManagerFeature.js +16 -15
  83. package/features/FileManagerFeature.js.map +1 -1
  84. package/features/file/CreateFile/CreateFileRepository.js +20 -18
  85. package/features/file/CreateFile/CreateFileRepository.js.map +1 -1
  86. package/features/file/CreateFile/CreateFileUseCase.js +68 -75
  87. package/features/file/CreateFile/CreateFileUseCase.js.map +1 -1
  88. package/features/file/CreateFile/abstractions.js +3 -14
  89. package/features/file/CreateFile/abstractions.js.map +1 -1
  90. package/features/file/CreateFile/events.js +17 -26
  91. package/features/file/CreateFile/events.js.map +1 -1
  92. package/features/file/CreateFile/feature.js +7 -6
  93. package/features/file/CreateFile/feature.js.map +1 -1
  94. package/features/file/CreateFile/index.js +0 -2
  95. package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js +15 -17
  96. package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js.map +1 -1
  97. package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js +59 -70
  98. package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js.map +1 -1
  99. package/features/file/CreateFilesInBatch/abstractions.js +3 -14
  100. package/features/file/CreateFilesInBatch/abstractions.js.map +1 -1
  101. package/features/file/CreateFilesInBatch/events.js +17 -26
  102. package/features/file/CreateFilesInBatch/events.js.map +1 -1
  103. package/features/file/CreateFilesInBatch/feature.js +7 -6
  104. package/features/file/CreateFilesInBatch/feature.js.map +1 -1
  105. package/features/file/CreateFilesInBatch/index.js +0 -2
  106. package/features/file/DeleteFile/DeleteFileRepository.js +21 -20
  107. package/features/file/DeleteFile/DeleteFileRepository.js.map +1 -1
  108. package/features/file/DeleteFile/DeleteFileUseCase.js +31 -33
  109. package/features/file/DeleteFile/DeleteFileUseCase.js.map +1 -1
  110. package/features/file/DeleteFile/abstractions.js +3 -14
  111. package/features/file/DeleteFile/abstractions.js.map +1 -1
  112. package/features/file/DeleteFile/events.js +17 -26
  113. package/features/file/DeleteFile/events.js.map +1 -1
  114. package/features/file/DeleteFile/feature.js +7 -6
  115. package/features/file/DeleteFile/feature.js.map +1 -1
  116. package/features/file/DeleteFile/index.js +1 -3
  117. package/features/file/FileUrlGenerator/abstractions.js +2 -2
  118. package/features/file/FileUrlGenerator/abstractions.js.map +1 -1
  119. package/features/file/GetFile/GetFileRepository.js +22 -22
  120. package/features/file/GetFile/GetFileRepository.js.map +1 -1
  121. package/features/file/GetFile/GetFileUseCase.js +19 -21
  122. package/features/file/GetFile/GetFileUseCase.js.map +1 -1
  123. package/features/file/GetFile/abstractions.js +3 -14
  124. package/features/file/GetFile/abstractions.js.map +1 -1
  125. package/features/file/GetFile/feature.js +7 -6
  126. package/features/file/GetFile/feature.js.map +1 -1
  127. package/features/file/GetFile/index.js +0 -2
  128. package/features/file/GetFileContentsById/abstractions.d.ts +20 -0
  129. package/features/file/GetFileContentsById/abstractions.js +5 -0
  130. package/features/file/GetFileContentsById/abstractions.js.map +1 -0
  131. package/features/file/GetFileContentsById/index.d.ts +1 -0
  132. package/features/file/GetFileContentsById/index.js +1 -0
  133. package/features/file/GetFileContentsByKey/abstractions.d.ts +17 -0
  134. package/features/file/GetFileContentsByKey/abstractions.js +5 -0
  135. package/features/file/GetFileContentsByKey/abstractions.js.map +1 -0
  136. package/features/file/GetFileContentsByKey/index.d.ts +1 -0
  137. package/features/file/GetFileContentsByKey/index.js +1 -0
  138. package/features/file/ListFiles/ListFilesRepository.js +42 -40
  139. package/features/file/ListFiles/ListFilesRepository.js.map +1 -1
  140. package/features/file/ListFiles/ListFilesUseCase.js +33 -34
  141. package/features/file/ListFiles/ListFilesUseCase.js.map +1 -1
  142. package/features/file/ListFiles/abstractions.js +3 -14
  143. package/features/file/ListFiles/abstractions.js.map +1 -1
  144. package/features/file/ListFiles/feature.js +7 -6
  145. package/features/file/ListFiles/feature.js.map +1 -1
  146. package/features/file/ListFiles/index.js +0 -2
  147. package/features/file/ListImagesByTagTool/ListImagesByTagTool.js +31 -28
  148. package/features/file/ListImagesByTagTool/ListImagesByTagTool.js.map +1 -1
  149. package/features/file/ListImagesByTagTool/feature.js +6 -5
  150. package/features/file/ListImagesByTagTool/feature.js.map +1 -1
  151. package/features/file/ListTags/ListTagsRepository.js +31 -36
  152. package/features/file/ListTags/ListTagsRepository.js.map +1 -1
  153. package/features/file/ListTags/ListTagsUseCase.js +21 -21
  154. package/features/file/ListTags/ListTagsUseCase.js.map +1 -1
  155. package/features/file/ListTags/abstractions.js +3 -14
  156. package/features/file/ListTags/abstractions.js.map +1 -1
  157. package/features/file/ListTags/feature.js +7 -6
  158. package/features/file/ListTags/feature.js.map +1 -1
  159. package/features/file/ListTags/index.js +0 -2
  160. package/features/file/UpdateFile/UpdateFileRepository.js +26 -28
  161. package/features/file/UpdateFile/UpdateFileRepository.js.map +1 -1
  162. package/features/file/UpdateFile/UpdateFileUseCase.js +57 -65
  163. package/features/file/UpdateFile/UpdateFileUseCase.js.map +1 -1
  164. package/features/file/UpdateFile/abstractions.js +3 -14
  165. package/features/file/UpdateFile/abstractions.js.map +1 -1
  166. package/features/file/UpdateFile/events.js +17 -26
  167. package/features/file/UpdateFile/events.js.map +1 -1
  168. package/features/file/UpdateFile/feature.js +7 -6
  169. package/features/file/UpdateFile/feature.js.map +1 -1
  170. package/features/file/UpdateFile/index.js +1 -3
  171. package/features/file/shared/EntryToFileMapper.js +25 -24
  172. package/features/file/shared/EntryToFileMapper.js.map +1 -1
  173. package/features/file/shared/FileInputToEntryInputMapper.js +29 -28
  174. package/features/file/shared/FileInputToEntryInputMapper.js.map +1 -1
  175. package/features/file/shared/FileToEntryMapper.js +28 -27
  176. package/features/file/shared/FileToEntryMapper.js.map +1 -1
  177. package/features/permissions/abstractions.js +2 -1
  178. package/features/permissions/abstractions.js.map +1 -1
  179. package/features/permissions/feature.js +2 -1
  180. package/features/permissions/feature.js.map +1 -1
  181. package/features/settings/GetSettings/GetSettingsUseCase.js +19 -19
  182. package/features/settings/GetSettings/GetSettingsUseCase.js.map +1 -1
  183. package/features/settings/GetSettings/abstractions.js +2 -7
  184. package/features/settings/GetSettings/abstractions.js.map +1 -1
  185. package/features/settings/GetSettings/feature.js +6 -5
  186. package/features/settings/GetSettings/feature.js.map +1 -1
  187. package/features/settings/SettingsInstaller/SettingsInstaller.js +25 -24
  188. package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -1
  189. package/features/settings/SettingsInstaller/feature.js +6 -5
  190. package/features/settings/SettingsInstaller/feature.js.map +1 -1
  191. package/features/settings/UpdateSettings/UpdateSettingsUseCase.js +41 -48
  192. package/features/settings/UpdateSettings/UpdateSettingsUseCase.js.map +1 -1
  193. package/features/settings/UpdateSettings/abstractions.js +2 -7
  194. package/features/settings/UpdateSettings/abstractions.js.map +1 -1
  195. package/features/settings/UpdateSettings/events.js +17 -26
  196. package/features/settings/UpdateSettings/events.js.map +1 -1
  197. package/features/settings/UpdateSettings/feature.js +6 -5
  198. package/features/settings/UpdateSettings/feature.js.map +1 -1
  199. package/features/settings/UpdateSettings/index.js +0 -2
  200. package/features/shared/abstractions.js +0 -2
  201. package/graphql/baseSchema.js +30 -33
  202. package/graphql/baseSchema.js.map +1 -1
  203. package/graphql/createFilesTypeDefs.js +49 -57
  204. package/graphql/createFilesTypeDefs.js.map +1 -1
  205. package/graphql/filesSchema.js +79 -99
  206. package/graphql/filesSchema.js.map +1 -1
  207. package/graphql/getFileByUrl.js +45 -53
  208. package/graphql/getFileByUrl.js.map +1 -1
  209. package/graphql/index.js +35 -42
  210. package/graphql/index.js.map +1 -1
  211. package/graphql/utils.js +9 -14
  212. package/graphql/utils.js.map +1 -1
  213. package/index.js +19 -30
  214. package/index.js.map +1 -1
  215. package/modelModifier/CmsModelModifier.js +40 -43
  216. package/modelModifier/CmsModelModifier.js.map +1 -1
  217. package/package.json +17 -20
  218. package/types.js +0 -2
  219. package/delivery/AssetDelivery/abstractions/AssetContentsReader.js.map +0 -1
  220. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js.map +0 -1
  221. package/delivery/AssetDelivery/abstractions/AssetProcessor.js.map +0 -1
  222. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js.map +0 -1
  223. package/delivery/AssetDelivery/abstractions/AssetResolver.js.map +0 -1
  224. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js.map +0 -1
  225. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js.map +0 -1
  226. package/delivery/index.js.map +0 -1
  227. package/domain/file/types.js.map +0 -1
  228. package/domain/settings/types.js.map +0 -1
  229. package/exports/api/file-manager/file.js.map +0 -1
  230. package/exports/api/file-manager/permissions.js.map +0 -1
  231. package/exports/api/file-manager/settings.js.map +0 -1
  232. package/features/ai/AiImageEnrichmentAfterCreateHandler.d.ts +0 -11
  233. package/features/ai/AiImageEnrichmentAfterCreateHandler.js +0 -28
  234. package/features/ai/AiImageEnrichmentAfterCreateHandler.js.map +0 -1
  235. package/features/ai/AiImageEnrichmentFeature.d.ts +0 -4
  236. package/features/ai/AiImageEnrichmentFeature.js +0 -12
  237. package/features/ai/AiImageEnrichmentFeature.js.map +0 -1
  238. package/features/file/CreateFile/index.js.map +0 -1
  239. package/features/file/CreateFilesInBatch/index.js.map +0 -1
  240. package/features/file/DeleteFile/index.js.map +0 -1
  241. package/features/file/GetFile/index.js.map +0 -1
  242. package/features/file/ListFiles/index.js.map +0 -1
  243. package/features/file/ListTags/index.js.map +0 -1
  244. package/features/file/UpdateFile/index.js.map +0 -1
  245. package/features/settings/UpdateSettings/index.js.map +0 -1
  246. package/features/shared/abstractions.js.map +0 -1
  247. package/tasks/AiImageEnrichmentTask.d.ts +0 -35
  248. package/tasks/AiImageEnrichmentTask.js +0 -136
  249. package/tasks/AiImageEnrichmentTask.js.map +0 -1
  250. package/types.js.map +0 -1
@@ -1,17 +1,6 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
-
3
- /**
4
- * ListFiles repository interface
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,"names":["createAbstraction","ListFilesRepository","ListFilesUseCase"],"sources":["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"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAmBvD;AACA;AACA;;AAWA;AACA,OAAO,MAAMC,mBAAmB,GAAGD,iBAAiB,CAAuB,qBAAqB,CAAC;;AAOjG;AACA;AACA;;AAYA;AACA,OAAO,MAAME,gBAAgB,GAAGF,iBAAiB,CAAoB,kBAAkB,CAAC","ignoreList":[]}
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
- export const ListFilesFeature = createFeature({
5
- name: "FileManager/ListFiles",
6
- register(container) {
7
- container.register(ListFilesUseCase);
8
- container.register(ListFilesRepository).inSingletonScope();
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,"names":["createFeature","ListFilesRepository","ListFilesUseCase","ListFilesFeature","name","register","container","inSingletonScope"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,mBAAmB;AAC5B,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,gBAAgB,GAAGH,aAAa,CAAC;EAC1CI,IAAI,EAAE,uBAAuB;EAC7BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,gBAAgB,CAAC;IACpCI,SAAS,CAACD,QAAQ,CAACJ,mBAAmB,CAAC,CAACM,gBAAgB,CAAC,CAAC;EAC9D;AACJ,CAAC,CAAC","ignoreList":[]}
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"}
@@ -1,3 +1 @@
1
1
  export { ListFilesUseCase } from "./abstractions.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -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
- tag: z.string().describe("Tag to filter images by")
5
+ tag: z.string().describe("Tag to filter images by")
6
6
  });
7
7
  class ListImagesByTagToolImpl {
8
- name = "listImagesByTag";
9
- description = "Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.";
10
- inputSchema = inputSchema;
11
- constructor(listFiles) {
12
- this.listFiles = listFiles;
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: [input.tag]
20
- },
21
- limit: 50
22
- });
23
- if (result.isFail()) {
24
- return [];
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
- export const ListImagesByTagTool = AiSdkTool.createImplementation({
35
- implementation: ListImagesByTagToolImpl,
36
- dependencies: [ListFilesUseCase]
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,"names":["z","AiSdkTool","ListFilesUseCase","inputSchema","object","tag","string","describe","ListImagesByTagToolImpl","name","description","constructor","listFiles","execute","input","console","log","result","where","type_startsWith","tags_in","limit","isFail","value","items","map","file","id","type","tags","ListImagesByTagTool","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AACvB,SAASC,SAAS,QAAyB,uCAAuC;AAClF,SAASC,gBAAgB;AAEzB,MAAMC,WAAW,GAAGH,CAAC,CAACI,MAAM,CAAC;EACzBC,GAAG,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,yBAAyB;AACtD,CAAC,CAAC;AAWF,MAAMC,uBAAuB,CAA8B;EAC9CC,IAAI,GAAG,iBAAiB;EACxBC,WAAW,GAChB,0GAA0G;EACrGP,WAAW,GAAGA,WAAW;EAElCQ,WAAWA,CAASC,SAAqC,EAAE;IAAA,KAAvCA,SAAqC,GAArCA,SAAqC;EAAG;EAE5D,MAAMC,OAAOA,CAACC,KAAY,EAAwB;IAC9CC,OAAO,CAACC,GAAG,CAAC,kBAAkB,EAAEF,KAAK,CAAC;IACtC,MAAMG,MAAM,GAAG,MAAM,IAAI,CAACL,SAAS,CAACC,OAAO,CAAC;MACxCK,KAAK,EAAE;QACHC,eAAe,EAAE,QAAQ;QACzBC,OAAO,EAAE,CAACN,KAAK,CAACT,GAAG;MACvB,CAAC;MACDgB,KAAK,EAAE;IACX,CAAC,CAAC;IAEF,IAAIJ,MAAM,CAACK,MAAM,CAAC,CAAC,EAAE;MACjB,OAAO,EAAE;IACb;IAEA,OAAOL,MAAM,CAACM,KAAK,CAACC,KAAK,CAACC,GAAG,CAACC,IAAI,KAAK;MACnCC,EAAE,EAAED,IAAI,CAACC,EAAE;MACXlB,IAAI,EAAEiB,IAAI,CAACjB,IAAI;MACfmB,IAAI,EAAEF,IAAI,CAACE,IAAI;MACfC,IAAI,EAAEH,IAAI,CAACG;IACf,CAAC,CAAC,CAAC;EACP;AACJ;AAEA,OAAO,MAAMC,mBAAmB,GAAG7B,SAAS,CAAC8B,oBAAoB,CAAC;EAC9DC,cAAc,EAAExB,uBAAuB;EACvCyB,YAAY,EAAE,CAAC/B,gBAAgB;AACnC,CAAC,CAAC","ignoreList":[]}
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
- export const ListImagesByTagToolFeature = createFeature({
4
- name: "AiPowerUps/ListImagesByTagTool",
5
- register(container) {
6
- container.register(ListImagesByTagTool);
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,"names":["createFeature","ListImagesByTagTool","ListImagesByTagToolFeature","name","register","container"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,mBAAmB;AAE5B,OAAO,MAAMC,0BAA0B,GAAGF,aAAa,CAAC;EACpDG,IAAI,EAAE,gCAAgC;EACtCC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,mBAAmB,CAAC;EAC3C;AACJ,CAAC,CAAC","ignoreList":[]}
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 as RepositoryAbstraction } from "./abstractions.js";
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
- 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
- // TODO fix with proper types
17
- // @ts-expect-error
18
- where: this.cmsWhereMapper.map({
19
- input: {
20
- ...(input.where || {}),
21
- latest: true
22
- },
23
- fields: this.fileModel.fields
24
- })
25
- });
26
- if (result.isFail()) {
27
- return Result.fail(new FilePersistenceError(result.error));
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
- export const ListTagsRepository = RepositoryAbstraction.createImplementation({
43
- implementation: ListTagsRepositoryImpl,
44
- dependencies: [GetUniqueFieldValuesUseCase, FileModel, CmsWhereMapper]
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,"names":["Result","GetUniqueFieldValuesUseCase","ListTagsRepository","RepositoryAbstraction","FileModel","FilePersistenceError","CmsWhereMapper","ListTagsRepositoryImpl","constructor","getUniqueFieldValues","fileModel","cmsWhereMapper","execute","input","result","fieldId","where","map","latest","fields","isFail","fail","error","tags","value","uv","tag","count","sort","a","b","ok","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,2BAA2B,QAAQ,qEAAqE;AACjH,SAEIC,kBAAkB,IAAIC,qBAAqB;AAG/C,SAASC,SAAS;AAClB,SAASC,oBAAoB;AAC7B,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,MAAMC,sBAAsB,CAA4C;EACpEC,WAAWA,CACCC,oBAA2D,EAC3DC,SAA8B,EAC9BC,cAAwC,EAClD;IAAA,KAHUF,oBAA2D,GAA3DA,oBAA2D;IAAA,KAC3DC,SAA8B,GAA9BA,SAA8B;IAAA,KAC9BC,cAAwC,GAAxCA,cAAwC;EACjD;EAEH,MAAMC,OAAOA,CAACC,KAAoB,EAA2D;IACzF,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACL,oBAAoB,CAACG,OAAO,CAAC,IAAI,CAACF,SAAS,EAAE;MACnEK,OAAO,EAAE,MAAM;MACf;MACA;MACAC,KAAK,EAAE,IAAI,CAACL,cAAc,CAACM,GAAG,CAAC;QAC3BJ,KAAK,EAAE;UACH,IAAIA,KAAK,CAACG,KAAK,IAAI,CAAC,CAAC,CAAC;UACtBE,MAAM,EAAE;QACZ,CAAC;QACDC,MAAM,EAAE,IAAI,CAACT,SAAS,CAACS;MAC3B,CAAC;IACL,CAAC,CAAC;IAEF,IAAIL,MAAM,CAACM,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOpB,MAAM,CAACqB,IAAI,CAAC,IAAIhB,oBAAoB,CAACS,MAAM,CAACQ,KAAK,CAAC,CAAC;IAC9D;;IAEA;IACA,MAAMC,IAAe,GAAGT,MAAM,CAACU,KAAK,CAC/BP,GAAG,CAACQ,EAAE,KAAK;MACRC,GAAG,EAAED,EAAE,CAACD,KAAe;MACvBG,KAAK,EAAEF,EAAE,CAACE;IACd,CAAC,CAAC;IACF;IAAA,CACCC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAMD,CAAC,CAACH,GAAG,GAAGI,CAAC,CAACJ,GAAG,GAAG,CAAC,CAAC,GAAG,CAAE;IACxC;IAAA,CACCE,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAMD,CAAC,CAACF,KAAK,GAAGG,CAAC,CAACH,KAAK,GAAG,CAAC,CAAC,GAAG,CAAE,CAAC;IAEjD,OAAO3B,MAAM,CAAC+B,EAAE,CAACR,IAAI,CAAC;EAC1B;AACJ;AAEA,OAAO,MAAMrB,kBAAkB,GAAGC,qBAAqB,CAAC6B,oBAAoB,CAAC;EACzEC,cAAc,EAAE1B,sBAAsB;EACtC2B,YAAY,EAAE,CAACjC,2BAA2B,EAAEG,SAAS,EAAEE,cAAc;AACzE,CAAC,CAAC","ignoreList":[]}
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 { ListTagsUseCase as UseCaseAbstraction, ListTagsRepository } from "./abstractions.js";
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
- constructor(permissions, repository) {
7
- this.permissions = permissions;
8
- this.repository = repository;
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
- const enrichedInput = {
16
- ...input,
17
- limit: input.limit || 1000000
18
- };
19
- const result = await this.repository.execute(enrichedInput);
20
- if (result.isFail()) {
21
- return Result.fail(result.error);
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
- export const ListTagsUseCase = UseCaseAbstraction.createImplementation({
27
- implementation: ListTagsUseCaseImpl,
28
- dependencies: [FmPermissions, ListTagsRepository]
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,"names":["Result","ListTagsUseCase","UseCaseAbstraction","ListTagsRepository","FileNotAuthorizedError","FmPermissions","ListTagsUseCaseImpl","constructor","permissions","repository","execute","input","hasPermission","canAccess","fail","enrichedInput","limit","result","isFail","error","ok","value","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,eAAe,IAAIC,kBAAkB,EAGrCC,kBAAkB;AAEtB,SAASC,sBAAsB;AAC/B,SAASC,aAAa;AAEtB,MAAMC,mBAAmB,CAAyC;EAC9DC,WAAWA,CACCC,WAAoC,EACpCC,UAAwC,EAClD;IAAA,KAFUD,WAAoC,GAApCA,WAAoC;IAAA,KACpCC,UAAwC,GAAxCA,UAAwC;EACjD;EAEH,MAAMC,OAAOA,CAACC,KAAoB,EAAwD;IACtF,MAAMC,aAAa,GAAG,MAAM,IAAI,CAACJ,WAAW,CAACK,SAAS,CAAC,MAAM,CAAC;IAC9D,IAAI,CAACD,aAAa,EAAE;MAChB,OAAOZ,MAAM,CAACc,IAAI,CAAC,IAAIV,sBAAsB,CAAC,CAAC,CAAC;IACpD;IAEA,MAAMW,aAA4B,GAAG;MACjC,GAAGJ,KAAK;MACRK,KAAK,EAAEL,KAAK,CAACK,KAAK,IAAI;IAC1B,CAAC;IAED,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACR,UAAU,CAACC,OAAO,CAACK,aAAa,CAAC;IAE3D,IAAIE,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOlB,MAAM,CAACc,IAAI,CAACG,MAAM,CAACE,KAAK,CAAC;IACpC;IAEA,OAAOnB,MAAM,CAACoB,EAAE,CAACH,MAAM,CAACI,KAAK,CAAC;EAClC;AACJ;AAEA,OAAO,MAAMpB,eAAe,GAAGC,kBAAkB,CAACoB,oBAAoB,CAAC;EACnEC,cAAc,EAAEjB,mBAAmB;EACnCkB,YAAY,EAAE,CAACnB,aAAa,EAAEF,kBAAkB;AACpD,CAAC,CAAC","ignoreList":[]}
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
- * ListTags repository interface
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,"names":["createAbstraction","ListTagsRepository","ListTagsUseCase"],"sources":["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"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAevD;AACA;AACA;;AAWA;AACA,OAAO,MAAMC,kBAAkB,GAAGD,iBAAiB,CAAsB,oBAAoB,CAAC;;AAO9F;AACA;AACA;;AAYA;AACA,OAAO,MAAME,eAAe,GAAGF,iBAAiB,CAAmB,iBAAiB,CAAC","ignoreList":[]}
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
- export const ListTagsFeature = createFeature({
5
- name: "FileManager/ListTags",
6
- register(container) {
7
- container.register(ListTagsUseCase);
8
- container.register(ListTagsRepository).inSingletonScope();
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,"names":["createFeature","ListTagsRepository","ListTagsUseCase","ListTagsFeature","name","register","container","inSingletonScope"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,kBAAkB;AAC3B,SAASC,eAAe;AAExB,OAAO,MAAMC,eAAe,GAAGH,aAAa,CAAC;EACzCI,IAAI,EAAE,sBAAsB;EAC5BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,eAAe,CAAC;IACnCI,SAAS,CAACD,QAAQ,CAACJ,kBAAkB,CAAC,CAACM,gBAAgB,CAAC,CAAC;EAC7D;AACJ,CAAC,CAAC","ignoreList":[]}
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,3 +1 @@
1
1
  export { ListTagsUseCase } from "./abstractions.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -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 as RepositoryAbstraction } from "./abstractions.js";
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
- constructor(updateEntry, fileModel) {
9
- this.updateEntry = updateEntry;
10
- this.fileModel = fileModel;
11
- }
12
- async update(file) {
13
- const entry = FileToEntryMapper.toEntry(file);
14
-
15
- // Files are not versioned, so we're always updating the same revision
16
- const id = `${file.id}#0001`;
17
- const result = await this.updateEntry.execute(this.fileModel, id, {
18
- wbyAco_location: file.location,
19
- values: entry.values
20
- });
21
- if (result.isFail()) {
22
- const error = result.error;
23
- if (error.code === "Cms/Entry/NotFound") {
24
- return Result.fail(new FileNotFoundError(id));
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
- export const UpdateFileRepository = RepositoryAbstraction.createImplementation({
35
- implementation: UpdateFileRepositoryImpl,
36
- dependencies: [UpdateEntryUseCase, FileModel]
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,"names":["Result","UpdateEntryUseCase","UpdateFileRepository","RepositoryAbstraction","FileModel","FileNotAuthorizedError","FileNotFoundError","FilePersistenceError","FileToEntryMapper","UpdateFileRepositoryImpl","constructor","updateEntry","fileModel","update","file","entry","toEntry","id","result","execute","wbyAco_location","location","values","isFail","error","code","fail","ok","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,kBAAkB,QAAQ,4DAA4D;AAC/F,SAASC,oBAAoB,IAAIC,qBAAqB;AACtD,SAASC,SAAS;AAElB,SACIC,sBAAsB,EACtBC,iBAAiB,EACjBC,oBAAoB;AAExB,SAASC,iBAAiB;AAE1B,MAAMC,wBAAwB,CAA4C;EACtEC,WAAWA,CACCC,WAAyC,EACzCC,SAA8B,EACxC;IAAA,KAFUD,WAAyC,GAAzCA,WAAyC;IAAA,KACzCC,SAA8B,GAA9BA,SAA8B;EACvC;EAEH,MAAMC,MAAMA,CAACC,IAAU,EAAsD;IACzE,MAAMC,KAAK,GAAGP,iBAAiB,CAACQ,OAAO,CAACF,IAAI,CAAC;;IAE7C;IACA,MAAMG,EAAE,GAAG,GAAGH,IAAI,CAACG,EAAE,OAAO;IAE5B,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACP,WAAW,CAACQ,OAAO,CAAC,IAAI,CAACP,SAAS,EAAEK,EAAE,EAAE;MAC9DG,eAAe,EAAEN,IAAI,CAACO,QAAQ;MAC9BC,MAAM,EAAEP,KAAK,CAACO;IAClB,CAAC,CAAC;IAEF,IAAIJ,MAAM,CAACK,MAAM,CAAC,CAAC,EAAE;MACjB,MAAMC,KAAK,GAAGN,MAAM,CAACM,KAAK;MAC1B,IAAIA,KAAK,CAACC,IAAI,KAAK,oBAAoB,EAAE;QACrC,OAAOzB,MAAM,CAAC0B,IAAI,CAAC,IAAIpB,iBAAiB,CAACW,EAAE,CAAC,CAAC;MACjD;MAEA,IAAIO,KAAK,CAACC,IAAI,KAAK,yBAAyB,EAAE;QAC1C,OAAOzB,MAAM,CAAC0B,IAAI,CAAC,IAAIrB,sBAAsB,CAAC,CAAC,CAAC;MACpD;MAEA,OAAOL,MAAM,CAAC0B,IAAI,CAAC,IAAInB,oBAAoB,CAACW,MAAM,CAACM,KAAK,CAAC,CAAC;IAC9D;IAEA,OAAOxB,MAAM,CAAC2B,EAAE,CAAC,CAAC;EACtB;AACJ;AAEA,OAAO,MAAMzB,oBAAoB,GAAGC,qBAAqB,CAACyB,oBAAoB,CAAC;EAC3EC,cAAc,EAAEpB,wBAAwB;EACxCqB,YAAY,EAAE,CAAC7B,kBAAkB,EAAEG,SAAS;AAChD,CAAC,CAAC","ignoreList":[]}
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"}