@webiny/app-file-manager 6.6.0-alpha.0 → 6.6.0-alpha.10

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 (170) hide show
  1. package/app.js +8 -0
  2. package/app.js.map +1 -1
  3. package/exports/admin/file-manager.d.ts +9 -0
  4. package/exports/admin/file-manager.js +4 -0
  5. package/features/deleteFile/DeleteFile.test.js.map +1 -1
  6. package/features/fileUploader/FileUploader.test.js.map +1 -1
  7. package/features/listFiles/ListFiles.test.js.map +1 -1
  8. package/features/settings/GetSettings.test.js +1 -0
  9. package/features/settings/GetSettings.test.js.map +1 -1
  10. package/features/settings/GetSettingsGateway.js +1 -0
  11. package/features/settings/GetSettingsGateway.js.map +1 -1
  12. package/features/settings/GetSettingsRepository.d.ts +2 -1
  13. package/features/settings/GetSettingsRepository.js.map +1 -1
  14. package/features/settings/SaveSettingsGateway.d.ts +2 -1
  15. package/features/settings/SaveSettingsGateway.js +1 -0
  16. package/features/settings/SaveSettingsGateway.js.map +1 -1
  17. package/features/settings/abstractions.d.ts +3 -2
  18. package/features/settings/abstractions.js.map +1 -1
  19. package/features/shared/FILE_FIELDS.js +4 -0
  20. package/features/shared/FILE_FIELDS.js.map +1 -1
  21. package/features/shared/FileFieldsProviderWithWcp.d.ts +5 -5
  22. package/features/shared/FileFieldsProviderWithWcp.js +7 -7
  23. package/features/shared/FileFieldsProviderWithWcp.js.map +1 -1
  24. package/features/shared/feature.d.ts +1 -1
  25. package/features/shared/types.d.ts +8 -1
  26. package/features/tags/ListTags.test.js.map +1 -1
  27. package/features/updateFile/UpdateFile.test.js.map +1 -1
  28. package/modules/AiEnrichment/AiImageEnrichmentFailedEventHandler.d.ts +19 -0
  29. package/modules/AiEnrichment/AiImageEnrichmentFailedEventHandler.js +26 -0
  30. package/modules/AiEnrichment/AiImageEnrichmentFailedEventHandler.js.map +1 -0
  31. package/modules/AiEnrichment/ReenrichFileGateway.d.ts +12 -0
  32. package/modules/AiEnrichment/ReenrichFileGateway.js +23 -0
  33. package/modules/AiEnrichment/ReenrichFileGateway.js.map +1 -0
  34. package/modules/AiEnrichment/ReenrichWithAi.d.ts +11 -0
  35. package/modules/AiEnrichment/ReenrichWithAi.js +57 -0
  36. package/modules/AiEnrichment/ReenrichWithAi.js.map +1 -0
  37. package/modules/AiEnrichment/ReenrichWithAiPresenter.d.ts +50 -0
  38. package/modules/AiEnrichment/ReenrichWithAiPresenter.js +114 -0
  39. package/modules/AiEnrichment/ReenrichWithAiPresenter.js.map +1 -0
  40. package/modules/AiEnrichment/StreamingPlaceholder.d.ts +15 -0
  41. package/modules/AiEnrichment/StreamingPlaceholder.js +32 -0
  42. package/modules/AiEnrichment/StreamingPlaceholder.js.map +1 -0
  43. package/modules/AiEnrichment/abstractions.d.ts +70 -0
  44. package/modules/AiEnrichment/abstractions.js +6 -0
  45. package/modules/AiEnrichment/abstractions.js.map +1 -0
  46. package/modules/AiEnrichment/feature.d.ts +3 -1
  47. package/modules/AiEnrichment/feature.js +12 -0
  48. package/modules/AiEnrichment/feature.js.map +1 -1
  49. package/modules/Enterprise/index.js +3 -3
  50. package/modules/Enterprise/index.js.map +1 -1
  51. package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.d.ts +26 -0
  52. package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.js +39 -0
  53. package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.js.map +1 -0
  54. package/modules/HeadlessCms/fieldType/AssetFieldType.d.ts +34 -0
  55. package/modules/HeadlessCms/fieldType/AssetFieldType.js +42 -0
  56. package/modules/HeadlessCms/fieldType/AssetFieldType.js.map +1 -0
  57. package/modules/HeadlessCms/fieldType/AssetFormFieldType.d.ts +21 -0
  58. package/modules/HeadlessCms/fieldType/AssetFormFieldType.js +42 -0
  59. package/modules/HeadlessCms/fieldType/AssetFormFieldType.js.map +1 -0
  60. package/modules/HeadlessCms/fieldType/AssetInputRenderer.d.ts +15 -0
  61. package/modules/HeadlessCms/fieldType/AssetInputRenderer.js +20 -0
  62. package/modules/HeadlessCms/fieldType/AssetInputRenderer.js.map +1 -0
  63. package/modules/HeadlessCms/fieldType/AssetInputsRenderer.d.ts +15 -0
  64. package/modules/HeadlessCms/fieldType/AssetInputsRenderer.js +20 -0
  65. package/modules/HeadlessCms/fieldType/AssetInputsRenderer.js.map +1 -0
  66. package/modules/HeadlessCms/fieldType/FileFieldType.d.ts +1 -0
  67. package/modules/HeadlessCms/fieldType/FileFieldType.js +1 -0
  68. package/modules/HeadlessCms/fieldType/FileFieldType.js.map +1 -1
  69. package/modules/HeadlessCms/fieldType/feature.js +10 -0
  70. package/modules/HeadlessCms/fieldType/feature.js.map +1 -1
  71. package/modules/HeadlessCms/fieldType/isAssetField.d.ts +2 -0
  72. package/modules/HeadlessCms/fieldType/isAssetField.js +4 -0
  73. package/modules/HeadlessCms/fieldType/isAssetField.js.map +1 -0
  74. package/package.json +28 -28
  75. package/presentation/FileActions/FileDetails/EditImage.d.ts +2 -0
  76. package/presentation/FileActions/FileDetails/EditImage.js +39 -0
  77. package/presentation/FileActions/FileDetails/EditImage.js.map +1 -0
  78. package/presentation/FileActions/index.js +8 -0
  79. package/presentation/FileActions/index.js.map +1 -1
  80. package/presentation/FileDetails/FileDetailsPresenter.d.ts +6 -3
  81. package/presentation/FileDetails/FileDetailsPresenter.js +51 -35
  82. package/presentation/FileDetails/FileDetailsPresenter.js.map +1 -1
  83. package/presentation/FileDetails/FileDetailsPresenter.test.js +90 -7
  84. package/presentation/FileDetails/FileDetailsPresenter.test.js.map +1 -1
  85. package/presentation/FileDetails/abstractions.d.ts +2 -0
  86. package/presentation/FileDetails/abstractions.js.map +1 -1
  87. package/presentation/FileDetails/components/Content.d.ts +2 -1
  88. package/presentation/FileDetails/components/Content.js +2 -2
  89. package/presentation/FileDetails/components/Content.js.map +1 -1
  90. package/presentation/FileDetails/components/FileDetailsDrawer.d.ts +2 -2
  91. package/presentation/FileDetails/components/FileDetailsDrawer.js +11 -5
  92. package/presentation/FileDetails/components/FileDetailsDrawer.js.map +1 -1
  93. package/presentation/FileList/FileListDataSource.js +34 -1
  94. package/presentation/FileList/FileListDataSource.js.map +1 -1
  95. package/presentation/FileList/FileListPresenter.test.js +30 -1
  96. package/presentation/FileList/FileListPresenter.test.js.map +1 -1
  97. package/presentation/FileList/FileManagerPresenter.d.ts +1 -0
  98. package/presentation/FileList/FileManagerPresenter.js +13 -4
  99. package/presentation/FileList/FileManagerPresenter.js.map +1 -1
  100. package/presentation/FileList/abstractions.d.ts +1 -0
  101. package/presentation/FileList/abstractions.js.map +1 -1
  102. package/presentation/FileList/components/BulkActions/BulkActionBar.d.ts +2 -2
  103. package/presentation/FileList/components/BulkActions/BulkActionDelete.d.ts +2 -2
  104. package/presentation/FileList/components/BulkActions/BulkActionMove.d.ts +2 -2
  105. package/presentation/FileList/components/Filters/SubFoldersToggle.d.ts +2 -2
  106. package/presentation/FileList/components/Filters/TagsFilter.d.ts +2 -2
  107. package/presentation/FileList/components/Filters/TypeFilter.d.ts +2 -2
  108. package/presentation/FileList/components/Grid/ActionButton.d.ts +1 -1
  109. package/presentation/FileList/components/Grid/ActionButton.js.map +1 -1
  110. package/presentation/FileList/components/Grid/File.d.ts +1 -1
  111. package/presentation/FileList/components/Grid/File.js.map +1 -1
  112. package/presentation/FileList/components/Grid/FileGrid.d.ts +2 -2
  113. package/presentation/FileList/components/Header/FileManagerHeader.d.ts +2 -2
  114. package/presentation/FileList/components/Search/SearchBar.d.ts +2 -2
  115. package/presentation/FileList/components/Table/FileTable.d.ts +2 -2
  116. package/presentation/FileList/components/Upload/UploadProgress.d.ts +2 -2
  117. package/presentation/FileManager/FileManagerBreadcrumbs.d.ts +12 -0
  118. package/presentation/FileManager/FileManagerBreadcrumbs.js +37 -0
  119. package/presentation/FileManager/FileManagerBreadcrumbs.js.map +1 -0
  120. package/presentation/FileManager/FileManagerView.js +40 -8
  121. package/presentation/FileManager/FileManagerView.js.map +1 -1
  122. package/presentation/Settings/SettingsPresenter.js +20 -9
  123. package/presentation/Settings/SettingsPresenter.js.map +1 -1
  124. package/presentation/Settings/SettingsPresenter.test.d.ts +1 -0
  125. package/presentation/Settings/SettingsPresenter.test.js +67 -0
  126. package/presentation/Settings/SettingsPresenter.test.js.map +1 -0
  127. package/presentation/Settings/components/SettingsView.d.ts +2 -2
  128. package/presentation/config/DefaultFileManagerConfig.js +12 -7
  129. package/presentation/config/DefaultFileManagerConfig.js.map +1 -1
  130. package/presentation/config/getThumbnailRenderer.js +1 -1
  131. package/presentation/config/getThumbnailRenderer.js.map +1 -1
  132. package/presentation/config/thumbnailRenderers/CroppedFileImage.d.ts +18 -0
  133. package/presentation/config/thumbnailRenderers/CroppedFileImage.js +66 -0
  134. package/presentation/config/thumbnailRenderers/CroppedFileImage.js.map +1 -0
  135. package/presentation/config/thumbnailRenderers/FilePreviewImageRenderer.js +6 -9
  136. package/presentation/config/thumbnailRenderers/FilePreviewImageRenderer.js.map +1 -1
  137. package/presentation/config/thumbnailRenderers/GridItemImageRenderer.js +6 -9
  138. package/presentation/config/thumbnailRenderers/GridItemImageRenderer.js.map +1 -1
  139. package/presentation/config/thumbnailRenderers/TableItemImageRenderer.js +6 -9
  140. package/presentation/config/thumbnailRenderers/TableItemImageRenderer.js.map +1 -1
  141. package/presentation/fieldRenderers/CmsAssetPickerRenderer.d.ts +22 -0
  142. package/presentation/fieldRenderers/CmsAssetPickerRenderer.js +56 -0
  143. package/presentation/fieldRenderers/CmsAssetPickerRenderer.js.map +1 -0
  144. package/presentation/fieldRenderers/CmsFilePickerRenderer.d.ts +1 -1
  145. package/presentation/fieldRenderers/CmsFilePickerRenderer.js +11 -4
  146. package/presentation/fieldRenderers/CmsFilePickerRenderer.js.map +1 -1
  147. package/presentation/fieldRenderers/CmsImageEditorDialog.d.ts +7 -0
  148. package/presentation/fieldRenderers/CmsImageEditorDialog.js +32 -0
  149. package/presentation/fieldRenderers/CmsImageEditorDialog.js.map +1 -0
  150. package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.d.ts +18 -0
  151. package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.js +88 -0
  152. package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.js.map +1 -0
  153. package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.d.ts +1 -1
  154. package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.js +11 -2
  155. package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.js.map +1 -1
  156. package/presentation/fieldRenderers/CroppedAssetThumb.d.ts +15 -0
  157. package/presentation/fieldRenderers/CroppedAssetThumb.js +25 -0
  158. package/presentation/fieldRenderers/CroppedAssetThumb.js.map +1 -0
  159. package/presentation/fieldRenderers/assetValue.d.ts +10 -0
  160. package/presentation/fieldRenderers/assetValue.js +94 -0
  161. package/presentation/fieldRenderers/assetValue.js.map +1 -0
  162. package/presentation/fieldRenderers/assetValue.test.d.ts +1 -0
  163. package/presentation/fieldRenderers/assetValue.test.js +54 -0
  164. package/presentation/fieldRenderers/assetValue.test.js.map +1 -0
  165. package/presentation/hooks/useCmsImageEditor.d.ts +10 -0
  166. package/presentation/hooks/useCmsImageEditor.js +76 -0
  167. package/presentation/hooks/useCmsImageEditor.js.map +1 -0
  168. package/presentation/hooks/useEditImage.d.ts +14 -0
  169. package/presentation/hooks/useEditImage.js +67 -0
  170. package/presentation/hooks/useEditImage.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"features/shared/FileFieldsProviderWithWcp.js","sources":["../../../src/features/shared/FileFieldsProviderWithWcp.ts"],"sourcesContent":["import { WcpService } from \"@webiny/app-admin/features/wcp/abstractions.js\";\nimport { FileFieldsProvider as Abstraction } from \"./abstractions.js\";\n\nclass FileFieldsProviderWithWcpImpl implements Abstraction.Interface {\n constructor(\n private wcp: WcpService.Interface,\n private decoratee: Abstraction.Interface\n ) {}\n\n async execute(): Promise<string[]> {\n const fields = await this.decoratee.execute();\n\n if (this.wcp.getProject().canUsePrivateFiles()) {\n return [...fields, \"accessControl.type\"];\n }\n\n return fields;\n }\n}\n\nexport const FileFieldsProviderWithWcp = Abstraction.createDecorator({\n decorator: FileFieldsProviderWithWcpImpl,\n dependencies: [WcpService]\n});\n"],"names":["FileFieldsProviderWithWcpImpl","wcp","decoratee","fields","FileFieldsProviderWithWcp","Abstraction","WcpService"],"mappings":";;AAGA,MAAMA;IACF,YACYC,GAAyB,EACzBC,SAAgC,CAC1C;aAFUD,GAAG,GAAHA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAA6B;QAC/B,MAAMC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO;QAE3C,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,kBAAkB,IACxC,OAAO;eAAIA;YAAQ;SAAqB;QAG5C,OAAOA;IACX;AACJ;AAEO,MAAMC,4BAA4BC,mBAAAA,eAA2B,CAAC;IACjE,WAAWL;IACX,cAAc;QAACM;KAAW;AAC9B"}
1
+ {"version":3,"file":"features/shared/FileFieldsProviderWithWcp.js","sources":["../../../src/features/shared/FileFieldsProviderWithWcp.ts"],"sourcesContent":["import { FeatureFlagsService } from \"@webiny/app-admin/features/featureFlags/abstractions.js\";\nimport { FileFieldsProvider as Abstraction } from \"./abstractions.js\";\n\nclass FileFieldsProviderWithFeatureFlagsImpl implements Abstraction.Interface {\n constructor(\n private featureFlagsService: FeatureFlagsService.Interface,\n private decoratee: Abstraction.Interface\n ) {}\n\n async execute(): Promise<string[]> {\n const fields = await this.decoratee.execute();\n\n if (\n this.featureFlagsService.getFlags().isEnabled(\"advancedAccessControlLayer.privateFiles\")\n ) {\n return [...fields, \"accessControl.type\"];\n }\n\n return fields;\n }\n}\n\nexport const FileFieldsProviderWithWcp = Abstraction.createDecorator({\n decorator: FileFieldsProviderWithFeatureFlagsImpl,\n dependencies: [FeatureFlagsService]\n});\n"],"names":["FileFieldsProviderWithFeatureFlagsImpl","featureFlagsService","decoratee","fields","FileFieldsProviderWithWcp","Abstraction","FeatureFlagsService"],"mappings":";;AAGA,MAAMA;IACF,YACYC,mBAAkD,EAClDC,SAAgC,CAC1C;aAFUD,mBAAmB,GAAnBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAA6B;QAC/B,MAAMC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO;QAE3C,IACI,IAAI,CAAC,mBAAmB,CAAC,QAAQ,GAAG,SAAS,CAAC,4CAE9C,OAAO;eAAIA;YAAQ;SAAqB;QAG5C,OAAOA;IACX;AACJ;AAEO,MAAMC,4BAA4BC,mBAAAA,eAA2B,CAAC;IACjE,WAAWL;IACX,cAAc;QAACM;KAAoB;AACvC"}
@@ -1,5 +1,5 @@
1
1
  import type { FmFile } from "./types.js";
2
2
  export declare const SharedCacheFeature: import("@webiny/feature/admin").FeatureDefinition<{
3
- cache: import("@webiny/app-admin/features/listCache/ListCache.js").IListCache<FmFile>;
3
+ cache: import("@webiny/app-admin/exports/admin.js").IListCache<FmFile>;
4
4
  fileFieldsProvider: import("./abstractions.js").IFileFieldsProvider;
5
5
  }, []>;
@@ -1,11 +1,18 @@
1
1
  export type { FmFile, FmIdentity, FmLocation, FmTag, FmListMeta, FmFileListWhereInput, FmFileListSorter, FmTagsListWhereInput, UploadProgress, PresignedPostPayload, PresignedPostPayloadResponse, ListFilesParams } from "@webiny/sdk";
2
2
  import type { FmFile } from "@webiny/sdk";
3
3
  import type { UploadProgress } from "@webiny/sdk";
4
- export interface FmSettings {
4
+ export interface FmSettingsInput {
5
5
  uploadMinFileSize: string;
6
6
  uploadMaxFileSize: string;
7
+ /** A custom file delivery URL. Empty means "use the default". */
7
8
  srcPrefix: string;
8
9
  }
10
+ export interface FmSettings extends FmSettingsInput {
11
+ /** The file delivery URL in effect: the custom one, or the default when none is set. */
12
+ srcPrefix: string;
13
+ /** The file delivery URL used when no custom one is set: the API's public URL plus `/files/`. */
14
+ defaultSrcPrefix: string;
15
+ }
9
16
  export interface UploadJob {
10
17
  id: string;
11
18
  fileName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"features/tags/ListTags.test.js","sources":["../../../src/features/tags/ListTags.test.ts"],"sourcesContent":["import { describe, it, expect, vi, beforeEach } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport {\n ListTagsUseCase as UseCaseAbstraction,\n ListTagsRepository as RepositoryAbstraction,\n ListTagsGateway as GatewayAbstraction,\n type IListTagsGateway,\n type ListTagsGatewayParams,\n type ListTagsGatewayResult\n} from \"./abstractions.js\";\nimport { ListTagsUseCase } from \"./ListTagsUseCase.js\";\nimport { ListTagsRepository } from \"./ListTagsRepository.js\";\nimport type { FmTag } from \"../shared/types.js\";\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction createTags(count: number): FmTag[] {\n return Array.from({ length: count }, (_, i) => ({\n tag: `tag-${i}`,\n count: (i + 1) * 10\n }));\n}\n\ntype MockGateway = IListTagsGateway & { execute: ReturnType<typeof vi.fn> };\n\nfunction createMockGateway(tags: FmTag[] = createTags(3)): MockGateway {\n const execute = vi.fn<(params: ListTagsGatewayParams) => Promise<ListTagsGatewayResult>>();\n execute.mockResolvedValue(tags);\n return { execute };\n}\n\nfunction createContainer(mockGateway: MockGateway) {\n const container = new Container();\n\n // Register the mock gateway instance.\n container.registerInstance(GatewayAbstraction, mockGateway);\n\n // Register the real repository and use case.\n container.register(ListTagsRepository).inSingletonScope();\n container.register(ListTagsUseCase);\n\n return container;\n}\n\n// ---------------------------------------------------------------------------\n// Tests\n// ---------------------------------------------------------------------------\n\ndescribe(\"ListTags Feature\", () => {\n let mockGateway: MockGateway;\n let container: Container;\n\n beforeEach(() => {\n mockGateway = createMockGateway();\n container = createContainer(mockGateway);\n });\n\n // -----------------------------------------------------------------------\n // UseCase invokes gateway with correct params.\n // -----------------------------------------------------------------------\n\n it(\"should call gateway with the provided where params\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute({\n where: { tags_startsWith: \"image:\" }\n });\n\n expect(mockGateway.execute).toHaveBeenCalledWith({\n where: { tags_startsWith: \"image:\" }\n });\n });\n\n it(\"should call gateway with undefined where when not provided\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute();\n\n expect(mockGateway.execute).toHaveBeenCalledWith({\n where: undefined\n });\n });\n\n // -----------------------------------------------------------------------\n // UseCase returns tags.\n // -----------------------------------------------------------------------\n\n it(\"should return tags from the gateway\", async () => {\n const tags = createTags(5);\n mockGateway.execute.mockResolvedValue(tags);\n\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute();\n\n expect(result).toEqual(tags);\n });\n\n // -----------------------------------------------------------------------\n // Repository caches tags as MobX observable state.\n // -----------------------------------------------------------------------\n\n it(\"should cache tags in the repository after fetch\", async () => {\n const tags = createTags(3);\n mockGateway.execute.mockResolvedValue(tags);\n\n const repository = container.resolve(RepositoryAbstraction);\n\n // Initially empty.\n expect(repository.tags).toEqual([]);\n\n await repository.execute({});\n\n // Tags should be cached.\n expect(repository.tags).toEqual(tags);\n });\n\n // -----------------------------------------------------------------------\n // Repository refreshes tags on subsequent calls.\n // -----------------------------------------------------------------------\n\n it(\"should update cached tags on subsequent fetches\", async () => {\n const initialTags = createTags(2);\n const updatedTags = [\n { tag: \"tag-0\", count: 15 },\n { tag: \"tag-1\", count: 25 },\n { tag: \"tag-2\", count: 5 }\n ];\n\n mockGateway.execute.mockResolvedValueOnce(initialTags).mockResolvedValueOnce(updatedTags);\n\n const repository = container.resolve(RepositoryAbstraction);\n\n // First fetch.\n await repository.execute({});\n expect(repository.tags).toEqual(initialTags);\n\n // Second fetch (simulating refresh after file tag update).\n await repository.execute({});\n expect(repository.tags).toEqual(updatedTags);\n });\n\n // -----------------------------------------------------------------------\n // Gateway error propagation.\n // -----------------------------------------------------------------------\n\n it(\"should propagate gateway errors\", async () => {\n mockGateway.execute.mockRejectedValue(new Error(\"Network error\"));\n\n const useCase = container.resolve(UseCaseAbstraction);\n\n await expect(useCase.execute()).rejects.toThrow(\"Network error\");\n });\n\n // -----------------------------------------------------------------------\n // Filtering with where params.\n // -----------------------------------------------------------------------\n\n it(\"should support filtering by createdBy\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute({\n where: { createdBy: \"user-1\" }\n });\n\n expect(mockGateway.execute).toHaveBeenCalledWith({\n where: { createdBy: \"user-1\" }\n });\n });\n\n it(\"should support filtering with tags_not_startsWith\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute({\n where: { tags_not_startsWith: \"scope:\" }\n });\n\n expect(mockGateway.execute).toHaveBeenCalledWith({\n where: { tags_not_startsWith: \"scope:\" }\n });\n });\n});\n"],"names":["createTags","count","Array","_","i","createMockGateway","tags","execute","vi","createContainer","mockGateway","container","Container","GatewayAbstraction","ListTagsRepository","ListTagsUseCase","describe","beforeEach","it","useCase","UseCaseAbstraction","expect","undefined","result","repository","RepositoryAbstraction","initialTags","updatedTags","Error"],"mappings":";;;;;AAkBA,SAASA,WAAWC,KAAa;IAC7B,OAAOC,MAAM,IAAI,CAAC;QAAE,QAAQD;IAAM,GAAG,CAACE,GAAGC,IAAO;YAC5C,KAAK,CAAC,IAAI,EAAEA,GAAG;YACf,OAAQA,AAAAA,CAAAA,IAAI,KAAK;QACrB;AACJ;AAIA,SAASC,kBAAkBC,OAAgBN,WAAW,EAAE;IACpD,MAAMO,UAAUC,GAAG,EAAE;IACrBD,QAAQ,iBAAiB,CAACD;IAC1B,OAAO;QAAEC;IAAQ;AACrB;AAEA,SAASE,gBAAgBC,WAAwB;IAC7C,MAAMC,YAAY,IAAIC;IAGtBD,UAAU,gBAAgB,CAACE,iBAAoBH;IAG/CC,UAAU,QAAQ,CAACG,mDAAoB,gBAAgB;IACvDH,UAAU,QAAQ,CAACI;IAEnB,OAAOJ;AACX;AAMAK,SAAS,oBAAoB;IACzB,IAAIN;IACJ,IAAIC;IAEJM,WAAW;QACPP,cAAcL;QACdM,YAAYF,gBAAgBC;IAChC;IAMAQ,GAAG,sDAAsD;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E;QAGhC,MAAMF,WAAW,OAAO,CAAC,CAAC;QAC1BH,OAAOG,WAAW,IAAI,EAAE,OAAO,CAACG;IACpC;IAMAT,GAAG,mCAAmC;QAClCR,YAAY,OAAO,CAAC,iBAAiB,CAAC,IAAIkB,MAAM;QAEhD,MAAMT,UAAUR,UAAU,OAAO,CAACS;QAElC,MAAMC,OAAOF,QAAQ,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IACpD;IAMAD,GAAG,yCAAyC;QACxC,MAAMC,UAAUR,UAAU,OAAO,CAACS;QAElC,MAAMD,QAAQ,OAAO,CAAC;YAClB,OAAO;gBAAE,WAAW;YAAS;QACjC;QAEAE,OAAOX,YAAY,OAAO,EAAE,oBAAoB,CAAC;YAC7C,OAAO;gBAAE,WAAW;YAAS;QACjC;IACJ;IAEAQ,GAAG,qDAAqD;QACpD,MAAMC,UAAUR,UAAU,OAAO,CAACS;QAElC,MAAMD,QAAQ,OAAO,CAAC;YAClB,OAAO;gBAAE,qBAAqB;YAAS;QAC3C;QAEAE,OAAOX,YAAY,OAAO,EAAE,oBAAoB,CAAC;YAC7C,OAAO;gBAAE,qBAAqB;YAAS;QAC3C;IACJ;AACJ"}
1
+ {"version":3,"file":"features/tags/ListTags.test.js","sources":["../../../src/features/tags/ListTags.test.ts"],"sourcesContent":["import { describe, it, expect, vi, beforeEach } from \"vitest\";\nimport type { Mock } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport {\n ListTagsUseCase as UseCaseAbstraction,\n ListTagsRepository as RepositoryAbstraction,\n ListTagsGateway as GatewayAbstraction,\n type IListTagsGateway,\n type ListTagsGatewayParams,\n type ListTagsGatewayResult\n} from \"./abstractions.js\";\nimport { ListTagsUseCase } from \"./ListTagsUseCase.js\";\nimport { ListTagsRepository } from \"./ListTagsRepository.js\";\nimport type { FmTag } from \"../shared/types.js\";\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction createTags(count: number): FmTag[] {\n return Array.from({ length: count }, (_, i) => ({\n tag: `tag-${i}`,\n count: (i + 1) * 10\n }));\n}\n\ntype MockGateway = IListTagsGateway & { execute: Mock };\n\nfunction createMockGateway(tags: FmTag[] = createTags(3)): MockGateway {\n const execute = vi.fn<(params: ListTagsGatewayParams) => Promise<ListTagsGatewayResult>>();\n execute.mockResolvedValue(tags);\n return { execute };\n}\n\nfunction createContainer(mockGateway: MockGateway) {\n const container = new Container();\n\n // Register the mock gateway instance.\n container.registerInstance(GatewayAbstraction, mockGateway);\n\n // Register the real repository and use case.\n container.register(ListTagsRepository).inSingletonScope();\n container.register(ListTagsUseCase);\n\n return container;\n}\n\n// ---------------------------------------------------------------------------\n// Tests\n// ---------------------------------------------------------------------------\n\ndescribe(\"ListTags Feature\", () => {\n let mockGateway: MockGateway;\n let container: Container;\n\n beforeEach(() => {\n mockGateway = createMockGateway();\n container = createContainer(mockGateway);\n });\n\n // -----------------------------------------------------------------------\n // UseCase invokes gateway with correct params.\n // -----------------------------------------------------------------------\n\n it(\"should call gateway with the provided where params\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute({\n where: { tags_startsWith: \"image:\" }\n });\n\n expect(mockGateway.execute).toHaveBeenCalledWith({\n where: { tags_startsWith: \"image:\" }\n });\n });\n\n it(\"should call gateway with undefined where when not provided\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute();\n\n expect(mockGateway.execute).toHaveBeenCalledWith({\n where: undefined\n });\n });\n\n // -----------------------------------------------------------------------\n // UseCase returns tags.\n // -----------------------------------------------------------------------\n\n it(\"should return tags from the gateway\", async () => {\n const tags = createTags(5);\n mockGateway.execute.mockResolvedValue(tags);\n\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute();\n\n expect(result).toEqual(tags);\n });\n\n // -----------------------------------------------------------------------\n // Repository caches tags as MobX observable state.\n // -----------------------------------------------------------------------\n\n it(\"should cache tags in the repository after fetch\", async () => {\n const tags = createTags(3);\n mockGateway.execute.mockResolvedValue(tags);\n\n const repository = container.resolve(RepositoryAbstraction);\n\n // Initially empty.\n expect(repository.tags).toEqual([]);\n\n await repository.execute({});\n\n // Tags should be cached.\n expect(repository.tags).toEqual(tags);\n });\n\n // -----------------------------------------------------------------------\n // Repository refreshes tags on subsequent calls.\n // -----------------------------------------------------------------------\n\n it(\"should update cached tags on subsequent fetches\", async () => {\n const initialTags = createTags(2);\n const updatedTags = [\n { tag: \"tag-0\", count: 15 },\n { tag: \"tag-1\", count: 25 },\n { tag: \"tag-2\", count: 5 }\n ];\n\n mockGateway.execute.mockResolvedValueOnce(initialTags).mockResolvedValueOnce(updatedTags);\n\n const repository = container.resolve(RepositoryAbstraction);\n\n // First fetch.\n await repository.execute({});\n expect(repository.tags).toEqual(initialTags);\n\n // Second fetch (simulating refresh after file tag update).\n await repository.execute({});\n expect(repository.tags).toEqual(updatedTags);\n });\n\n // -----------------------------------------------------------------------\n // Gateway error propagation.\n // -----------------------------------------------------------------------\n\n it(\"should propagate gateway errors\", async () => {\n mockGateway.execute.mockRejectedValue(new Error(\"Network error\"));\n\n const useCase = container.resolve(UseCaseAbstraction);\n\n await expect(useCase.execute()).rejects.toThrow(\"Network error\");\n });\n\n // -----------------------------------------------------------------------\n // Filtering with where params.\n // -----------------------------------------------------------------------\n\n it(\"should support filtering by createdBy\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute({\n where: { createdBy: \"user-1\" }\n });\n\n expect(mockGateway.execute).toHaveBeenCalledWith({\n where: { createdBy: \"user-1\" }\n });\n });\n\n it(\"should support filtering with tags_not_startsWith\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute({\n where: { tags_not_startsWith: \"scope:\" }\n });\n\n expect(mockGateway.execute).toHaveBeenCalledWith({\n where: { tags_not_startsWith: \"scope:\" }\n });\n });\n});\n"],"names":["createTags","count","Array","_","i","createMockGateway","tags","execute","vi","createContainer","mockGateway","container","Container","GatewayAbstraction","ListTagsRepository","ListTagsUseCase","describe","beforeEach","it","useCase","UseCaseAbstraction","expect","undefined","result","repository","RepositoryAbstraction","initialTags","updatedTags","Error"],"mappings":";;;;;AAmBA,SAASA,WAAWC,KAAa;IAC7B,OAAOC,MAAM,IAAI,CAAC;QAAE,QAAQD;IAAM,GAAG,CAACE,GAAGC,IAAO;YAC5C,KAAK,CAAC,IAAI,EAAEA,GAAG;YACf,OAAQA,AAAAA,CAAAA,IAAI,KAAK;QACrB;AACJ;AAIA,SAASC,kBAAkBC,OAAgBN,WAAW,EAAE;IACpD,MAAMO,UAAUC,GAAG,EAAE;IACrBD,QAAQ,iBAAiB,CAACD;IAC1B,OAAO;QAAEC;IAAQ;AACrB;AAEA,SAASE,gBAAgBC,WAAwB;IAC7C,MAAMC,YAAY,IAAIC;IAGtBD,UAAU,gBAAgB,CAACE,iBAAoBH;IAG/CC,UAAU,QAAQ,CAACG,mDAAoB,gBAAgB;IACvDH,UAAU,QAAQ,CAACI;IAEnB,OAAOJ;AACX;AAMAK,SAAS,oBAAoB;IACzB,IAAIN;IACJ,IAAIC;IAEJM,WAAW;QACPP,cAAcL;QACdM,YAAYF,gBAAgBC;IAChC;IAMAQ,GAAG,sDAAsD;QACrD,MAAMC,UAAUR,UAAU,OAAO,CAACS;QAElC,MAAMD,QAAQ,OAAO,CAAC;YAClB,OAAO;gBAAE,iBAAiB;YAAS;QACvC;QAEAE,OAAOX,YAAY,OAAO,EAAE,oBAAoB,CAAC;YAC7C,OAAO;gBAAE,iBAAiB;YAAS;QACvC;IACJ;IAEAQ,GAAG,8DAA8D;QAC7D,MAAMC,UAAUR,UAAU,OAAO,CAACS;QAElC,MAAMD,QAAQ,OAAO;QAErBE,OAAOX,YAAY,OAAO,EAAE,oBAAoB,CAAC;YAC7C,OAAOY;QACX;IACJ;IAMAJ,GAAG,uCAAuC;QACtC,MAAMZ,OAAON,WAAW;QACxBU,YAAY,OAAO,CAAC,iBAAiB,CAACJ;QAEtC,MAAMa,UAAUR,UAAU,OAAO,CAACS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ACJ;IAEAQ,GAAG,qDAAqD;QACpD,MAAMC,UAAUR,UAAU,OAAO,CAACS;QAElC,MAAMD,QAAQ,OAAO,CAAC;YAClB,OAAO;gBAAE,qBAAqB;YAAS;QAC3C;QAEAE,OAAOX,YAAY,OAAO,EAAE,oBAAoB,CAAC;YAC7C,OAAO;gBAAE,qBAAqB;YAAS;QAC3C;IACJ;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"features/updateFile/UpdateFile.test.js","sources":["../../../src/features/updateFile/UpdateFile.test.ts"],"sourcesContent":["import { describe, it, expect, vi, beforeEach } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { ListCache } from \"@webiny/app-admin/features/listCache/index.js\";\nimport { FilesListCache } from \"../shared/abstractions.js\";\nimport { FileFieldsProvider } from \"../shared/FileFieldsProvider.js\";\nimport {\n UpdateFileUseCase as UseCaseAbstraction,\n UpdateFileGateway as GatewayAbstraction,\n type IUpdateFileGateway,\n type UpdateFileGatewayParams\n} from \"./abstractions.js\";\nimport { UpdateFileUseCase } from \"./UpdateFileUseCase.js\";\nimport { UpdateFileRepository } from \"./UpdateFileRepository.js\";\nimport type { FmFile } from \"../shared/types.js\";\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction createFile(overrides: Partial<FmFile> = {}): FmFile {\n return {\n id: \"file-1\",\n name: \"photo.jpg\",\n key: \"files/photo.jpg\",\n src: \"https://cdn.example.com/files/photo.jpg\",\n type: \"image/jpeg\",\n size: 204800,\n metadata: {},\n tags: [\"photo\"],\n createdOn: \"2025-01-01T00:00:00Z\",\n savedOn: \"2025-01-01T00:00:00Z\",\n createdBy: { id: \"user-1\", displayName: \"Test User\", type: \"admin\" },\n savedBy: { id: \"user-1\", displayName: \"Test User\", type: \"admin\" },\n location: { folderId: \"root\" },\n ...overrides\n };\n}\n\ntype MockGateway = IUpdateFileGateway & { execute: ReturnType<typeof vi.fn> };\n\nfunction createMockGateway(file: FmFile = createFile()): MockGateway {\n const execute = vi.fn<(params: UpdateFileGatewayParams) => Promise<FmFile>>();\n execute.mockResolvedValue(file);\n return { execute };\n}\n\nfunction createContainer(mockGateway: MockGateway) {\n const container = new Container();\n const cache = new ListCache<FmFile>();\n\n // Register the mock gateway instance.\n container.registerInstance(GatewayAbstraction, mockGateway);\n\n // Register the shared cache instance.\n container.registerInstance(FilesListCache, cache);\n\n // Register the file fields provider.\n container.register(FileFieldsProvider).inSingletonScope();\n\n // Register the real repository and use case.\n container.register(UpdateFileRepository).inSingletonScope();\n container.register(UpdateFileUseCase);\n\n return { container, cache };\n}\n\n// ---------------------------------------------------------------------------\n// Tests\n// ---------------------------------------------------------------------------\n\ndescribe(\"UpdateFile Feature\", () => {\n let mockGateway: MockGateway;\n let cache: ListCache<FmFile>;\n let container: Container;\n\n beforeEach(() => {\n mockGateway = createMockGateway();\n const result = createContainer(mockGateway);\n container = result.container;\n cache = result.cache as ListCache<FmFile>;\n });\n\n // -----------------------------------------------------------------------\n // Metadata update.\n // -----------------------------------------------------------------------\n\n it(\"should call gateway with file ID and changed fields\", async () => {\n const updated = createFile({ name: \"renamed.jpg\", tags: [\"photo\", \"landscape\"] });\n mockGateway.execute.mockResolvedValue(updated);\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({\n id: \"file-1\",\n data: { name: \"renamed.jpg\", tags: [\"photo\", \"landscape\"] }\n });\n\n expect(mockGateway.execute).toHaveBeenCalledTimes(1);\n const callArgs = mockGateway.execute.mock.calls[0][0];\n expect(callArgs.id).toBe(\"file-1\");\n expect(callArgs.data.name).toBe(\"renamed.jpg\");\n expect(callArgs.data.tags).toEqual([\"photo\", \"landscape\"]);\n });\n\n it(\"should return success result with the updated file\", async () => {\n const updated = createFile({ name: \"renamed.jpg\" });\n mockGateway.execute.mockResolvedValue(updated);\n\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute({\n id: \"file-1\",\n data: { name: \"renamed.jpg\" }\n });\n\n expect(result.success).toBe(true);\n if (result.success) {\n expect(result.file).toEqual(updated);\n }\n });\n\n it(\"should pass accessControl through to the gateway\", async () => {\n const updated = createFile({\n accessControl: { type: \"private-authenticated\" }\n });\n mockGateway.execute.mockResolvedValue(updated);\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({\n id: \"file-1\",\n data: { accessControl: { type: \"private-authenticated\" } }\n });\n\n const callArgs = mockGateway.execute.mock.calls[0][0];\n expect(callArgs.data.accessControl).toEqual({ type: \"private-authenticated\" });\n });\n\n it(\"should pass metadata through to the gateway\", async () => {\n const updated = createFile({\n metadata: { image: { width: 800, height: 600 } }\n });\n mockGateway.execute.mockResolvedValue(updated);\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({\n id: \"file-1\",\n data: { metadata: { image: { width: 800, height: 600 } } }\n });\n\n const callArgs = mockGateway.execute.mock.calls[0][0];\n expect(callArgs.data.metadata).toEqual({ image: { width: 800, height: 600 } });\n });\n\n // -----------------------------------------------------------------------\n // Move file (location.folderId change) updates cache correctly.\n // -----------------------------------------------------------------------\n\n it(\"should update the cached file when location.folderId changes\", async () => {\n // Seed the cache with the original file.\n const original = createFile({ id: \"file-move\", location: { folderId: \"folder-a\" } });\n cache.addItems([original]);\n\n const moved = createFile({ id: \"file-move\", location: { folderId: \"folder-b\" } });\n mockGateway.execute.mockResolvedValue(moved);\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({\n id: \"file-move\",\n data: { location: { folderId: \"folder-b\" } }\n });\n\n const cached = cache.getItem(f => f.id === \"file-move\");\n expect(cached).toBeDefined();\n expect(cached!.location.folderId).toBe(\"folder-b\");\n });\n\n it(\"should only update the matching file in cache, leaving others untouched\", async () => {\n // Seed cache with two files.\n const fileA = createFile({ id: \"file-a\", name: \"a.jpg\" });\n const fileB = createFile({ id: \"file-b\", name: \"b.jpg\" });\n cache.addItems([fileA, fileB]);\n\n const updatedA = createFile({ id: \"file-a\", name: \"a-renamed.jpg\" });\n mockGateway.execute.mockResolvedValue(updatedA);\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({\n id: \"file-a\",\n data: { name: \"a-renamed.jpg\" }\n });\n\n // file-a should be updated.\n const cachedA = cache.getItem(f => f.id === \"file-a\");\n expect(cachedA!.name).toBe(\"a-renamed.jpg\");\n\n // file-b should remain unchanged.\n const cachedB = cache.getItem(f => f.id === \"file-b\");\n expect(cachedB!.name).toBe(\"b.jpg\");\n });\n\n // -----------------------------------------------------------------------\n // Error handling.\n // -----------------------------------------------------------------------\n\n it(\"should return error result when gateway throws\", async () => {\n mockGateway.execute.mockRejectedValue(new Error(\"Update failed\"));\n\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute({\n id: \"file-1\",\n data: { name: \"renamed.jpg\" }\n });\n\n expect(result.success).toBe(false);\n if (!result.success) {\n expect(result.error.code).toBe(\"UPDATE_FILE_ERROR\");\n expect(result.error.message).toBe(\"Update failed\");\n }\n });\n\n it(\"should not update cache when gateway throws\", async () => {\n // Seed cache with the original file.\n const original = createFile({ id: \"file-err\", name: \"original.jpg\" });\n cache.addItems([original]);\n\n mockGateway.execute.mockRejectedValue(new Error(\"Update failed\"));\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({\n id: \"file-err\",\n data: { name: \"should-not-apply.jpg\" }\n });\n\n // Cache should still have the original file unchanged.\n const cached = cache.getItem(f => f.id === \"file-err\");\n expect(cached!.name).toBe(\"original.jpg\");\n });\n});\n"],"names":["createFile","overrides","createMockGateway","file","execute","vi","createContainer","mockGateway","container","Container","cache","ListCache","GatewayAbstraction","FilesListCache","FileFieldsProvider","UpdateFileRepository","UpdateFileUseCase","describe","beforeEach","result","it","updated","useCase","UseCaseAbstraction","expect","callArgs","original","moved","cached","f","fileA","fileB","updatedA","cachedA","cachedB","Error"],"mappings":";;;;;;;;AAmBA,SAASA,WAAWC,YAA6B,CAAC,CAAC;IAC/C,OAAO;QACH,IAAI;QACJ,MAAM;QACN,KAAK;QACL,KAAK;QACL,MA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;AACJ"}
1
+ {"version":3,"file":"features/updateFile/UpdateFile.test.js","sources":["../../../src/features/updateFile/UpdateFile.test.ts"],"sourcesContent":["import { describe, it, expect, vi, beforeEach } from \"vitest\";\nimport type { Mock } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { ListCache } from \"@webiny/app-admin/features/listCache/index.js\";\nimport { FilesListCache } from \"../shared/abstractions.js\";\nimport { FileFieldsProvider } from \"../shared/FileFieldsProvider.js\";\nimport {\n UpdateFileUseCase as UseCaseAbstraction,\n UpdateFileGateway as GatewayAbstraction,\n type IUpdateFileGateway,\n type UpdateFileGatewayParams\n} from \"./abstractions.js\";\nimport { UpdateFileUseCase } from \"./UpdateFileUseCase.js\";\nimport { UpdateFileRepository } from \"./UpdateFileRepository.js\";\nimport type { FmFile } from \"../shared/types.js\";\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction createFile(overrides: Partial<FmFile> = {}): FmFile {\n return {\n id: \"file-1\",\n name: \"photo.jpg\",\n key: \"files/photo.jpg\",\n src: \"https://cdn.example.com/files/photo.jpg\",\n type: \"image/jpeg\",\n size: 204800,\n metadata: {},\n tags: [\"photo\"],\n createdOn: \"2025-01-01T00:00:00Z\",\n savedOn: \"2025-01-01T00:00:00Z\",\n createdBy: { id: \"user-1\", displayName: \"Test User\", type: \"admin\" },\n savedBy: { id: \"user-1\", displayName: \"Test User\", type: \"admin\" },\n location: { folderId: \"root\" },\n ...overrides\n };\n}\n\ntype MockGateway = IUpdateFileGateway & { execute: Mock };\n\nfunction createMockGateway(file: FmFile = createFile()): MockGateway {\n const execute = vi.fn<(params: UpdateFileGatewayParams) => Promise<FmFile>>();\n execute.mockResolvedValue(file);\n return { execute };\n}\n\nfunction createContainer(mockGateway: MockGateway) {\n const container = new Container();\n const cache = new ListCache<FmFile>();\n\n // Register the mock gateway instance.\n container.registerInstance(GatewayAbstraction, mockGateway);\n\n // Register the shared cache instance.\n container.registerInstance(FilesListCache, cache);\n\n // Register the file fields provider.\n container.register(FileFieldsProvider).inSingletonScope();\n\n // Register the real repository and use case.\n container.register(UpdateFileRepository).inSingletonScope();\n container.register(UpdateFileUseCase);\n\n return { container, cache };\n}\n\n// ---------------------------------------------------------------------------\n// Tests\n// ---------------------------------------------------------------------------\n\ndescribe(\"UpdateFile Feature\", () => {\n let mockGateway: MockGateway;\n let cache: ListCache<FmFile>;\n let container: Container;\n\n beforeEach(() => {\n mockGateway = createMockGateway();\n const result = createContainer(mockGateway);\n container = result.container;\n cache = result.cache as ListCache<FmFile>;\n });\n\n // -----------------------------------------------------------------------\n // Metadata update.\n // -----------------------------------------------------------------------\n\n it(\"should call gateway with file ID and changed fields\", async () => {\n const updated = createFile({ name: \"renamed.jpg\", tags: [\"photo\", \"landscape\"] });\n mockGateway.execute.mockResolvedValue(updated);\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({\n id: \"file-1\",\n data: { name: \"renamed.jpg\", tags: [\"photo\", \"landscape\"] }\n });\n\n expect(mockGateway.execute).toHaveBeenCalledTimes(1);\n const callArgs = mockGateway.execute.mock.calls[0][0];\n expect(callArgs.id).toBe(\"file-1\");\n expect(callArgs.data.name).toBe(\"renamed.jpg\");\n expect(callArgs.data.tags).toEqual([\"photo\", \"landscape\"]);\n });\n\n it(\"should return success result with the updated file\", async () => {\n const updated = createFile({ name: \"renamed.jpg\" });\n mockGateway.execute.mockResolvedValue(updated);\n\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute({\n id: \"file-1\",\n data: { name: \"renamed.jpg\" }\n });\n\n expect(result.success).toBe(true);\n if (result.success) {\n expect(result.file).toEqual(updated);\n }\n });\n\n it(\"should pass accessControl through to the gateway\", async () => {\n const updated = createFile({\n accessControl: { type: \"private-authenticated\" }\n });\n mockGateway.execute.mockResolvedValue(updated);\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({\n id: \"file-1\",\n data: { accessControl: { type: \"private-authenticated\" } }\n });\n\n const callArgs = mockGateway.execute.mock.calls[0][0];\n expect(callArgs.data.accessControl).toEqual({ type: \"private-authenticated\" });\n });\n\n it(\"should pass metadata through to the gateway\", async () => {\n const updated = createFile({\n metadata: { image: { width: 800, height: 600 } }\n });\n mockGateway.execute.mockResolvedValue(updated);\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({\n id: \"file-1\",\n data: { metadata: { image: { width: 800, height: 600 } } }\n });\n\n const callArgs = mockGateway.execute.mock.calls[0][0];\n expect(callArgs.data.metadata).toEqual({ image: { width: 800, height: 600 } });\n });\n\n // -----------------------------------------------------------------------\n // Move file (location.folderId change) updates cache correctly.\n // -----------------------------------------------------------------------\n\n it(\"should update the cached file when location.folderId changes\", async () => {\n // Seed the cache with the original file.\n const original = createFile({ id: \"file-move\", location: { folderId: \"folder-a\" } });\n cache.addItems([original]);\n\n const moved = createFile({ id: \"file-move\", location: { folderId: \"folder-b\" } });\n mockGateway.execute.mockResolvedValue(moved);\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({\n id: \"file-move\",\n data: { location: { folderId: \"folder-b\" } }\n });\n\n const cached = cache.getItem(f => f.id === \"file-move\");\n expect(cached).toBeDefined();\n expect(cached!.location.folderId).toBe(\"folder-b\");\n });\n\n it(\"should only update the matching file in cache, leaving others untouched\", async () => {\n // Seed cache with two files.\n const fileA = createFile({ id: \"file-a\", name: \"a.jpg\" });\n const fileB = createFile({ id: \"file-b\", name: \"b.jpg\" });\n cache.addItems([fileA, fileB]);\n\n const updatedA = createFile({ id: \"file-a\", name: \"a-renamed.jpg\" });\n mockGateway.execute.mockResolvedValue(updatedA);\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({\n id: \"file-a\",\n data: { name: \"a-renamed.jpg\" }\n });\n\n // file-a should be updated.\n const cachedA = cache.getItem(f => f.id === \"file-a\");\n expect(cachedA!.name).toBe(\"a-renamed.jpg\");\n\n // file-b should remain unchanged.\n const cachedB = cache.getItem(f => f.id === \"file-b\");\n expect(cachedB!.name).toBe(\"b.jpg\");\n });\n\n // -----------------------------------------------------------------------\n // Error handling.\n // -----------------------------------------------------------------------\n\n it(\"should return error result when gateway throws\", async () => {\n mockGateway.execute.mockRejectedValue(new Error(\"Update failed\"));\n\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute({\n id: \"file-1\",\n data: { name: \"renamed.jpg\" }\n });\n\n expect(result.success).toBe(false);\n if (!result.success) {\n expect(result.error.code).toBe(\"UPDATE_FILE_ERROR\");\n expect(result.error.message).toBe(\"Update failed\");\n }\n });\n\n it(\"should not update cache when gateway throws\", async () => {\n // Seed cache with the original file.\n const original = createFile({ id: \"file-err\", name: \"original.jpg\" });\n cache.addItems([original]);\n\n mockGateway.execute.mockRejectedValue(new Error(\"Update failed\"));\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({\n id: \"file-err\",\n data: { name: \"should-not-apply.jpg\" }\n });\n\n // Cache should still have the original file unchanged.\n const cached = cache.getItem(f => f.id === \"file-err\");\n expect(cached!.name).toBe(\"original.jpg\");\n });\n});\n"],"names":["createFile","overrides","createMockGateway","file","execute","vi","createContainer","mockGateway","container","Container","cache","ListCache","GatewayAbstraction","FilesListCache","FileFieldsProvider","UpdateFileRepository","UpdateFileUseCase","describe","beforeEach","result","it","updated","useCase","UseCaseAbstraction","expect","callArgs","original","moved","cached","f","fileA","fileB","updatedA","cachedA","cachedB","Error"],"mappings":";;;;;;;;AAoBA,SAASA,WAAWC,YAA6B,CAAC,CAAC;IAC/C,OAAO;QACH,IAAI;QACJ,MAAM;QACN,KAAK;QACL,KAAK;QACL,MAAM;QACN,MAAM;QACN,UAAU,CAAC;QACX,MAAM;YAAC;SAAQ;QACf,WAAW;QACX,SAAS;QACT,WAAW;YAAE,IAAI;YAAU,aAAa;YAAa,MAAM;QAAQ;QACnE,SAAS;YAAE,IAAI;YAAU,aAAa;YAAa,MAAM;QAAQ;QACjE,UAAU;YAAE,UAAU;QAAO;QAC7B,GAAGA,SAAS;IA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AAI,CAAC;QAG3B,MAAMC,UAAUxB,MAAM,OAAO,CAACmB,CAAAA,IAAKA,AAAS,aAATA,EAAE,EAAE;QACvCL,OAAOU,QAAS,IAAI,EAAE,IAAI,CAAC;IAC/B;IAMAd,GAAG,kDAAkD;QACjDb,YAAY,OAAO,CAAC,iBAAiB,CAAC,IAAI4B,MAAM;QAEhD,MAAMb,UAAUd,UAAU,OAAO,CAACe;QAClC,MAAMJ,SAAS,MAAMG,QAAQ,OAAO,CAAC;YACjC,IAAI;YACJ,MAAM;gBAAE,MAAM;YAAc;QAChC;QAEAE,OAAOL,OAAO,OAAO,EAAE,IAAI,CAAC;QAC5B,IAAI,CAACA,OAAO,OAAO,EAAE;YACjBK,OAAOL,OAAO,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;YAC/BK,OAAOL,OAAO,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;QACtC;IACJ;IAEAC,GAAG,+CAA+C;QAE9C,MAAMM,WAAW1B,WAAW;YAAE,IAAI;YAAY,MAAM;QAAe;QACnEU,MAAM,QAAQ,CAAC;YAACgB;SAAS;QAEzBnB,YAAY,OAAO,CAAC,iBAAiB,CAAC,IAAI4B,MAAM;QAEhD,MAAMb,UAAUd,UAAU,OAAO,CAACe;QAClC,MAAMD,QAAQ,OAAO,CAAC;YAClB,IAAI;YACJ,MAAM;gBAAE,MAAM;YAAuB;QACzC;QAGA,MAAMM,SAASlB,MAAM,OAAO,CAACmB,CAAAA,IAAKA,AAAS,eAATA,EAAE,EAAE;QACtCL,OAAOI,OAAQ,IAAI,EAAE,IAAI,CAAC;IAC9B;AACJ"}
@@ -0,0 +1,19 @@
1
+ import { WebsocketEventHandler } from "@webiny/app-websockets";
2
+ import { Notifications } from "@webiny/app-admin/features/notifications/abstractions.js";
3
+ /**
4
+ * Reacts to the `fm.file.enrichment.failed` websocket message, which the upload-time enrichment
5
+ * task sends when it fails for a reason someone has to fix (no Vision model, a missing key, the
6
+ * provider rejecting the request). Switched off and non-image uploads never send it.
7
+ *
8
+ * Without this the failure only reached the API log, and from the File Manager it looked exactly
9
+ * like enrichment never having run.
10
+ */
11
+ declare class AiImageEnrichmentFailedEventHandlerImpl implements WebsocketEventHandler.Interface {
12
+ private notifications;
13
+ constructor(notifications: Notifications.Interface);
14
+ handle(event: WebsocketEventHandler.Event): Promise<void>;
15
+ }
16
+ export declare const AiImageEnrichmentFailedEventHandler: typeof AiImageEnrichmentFailedEventHandlerImpl & {
17
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/app/features/eventPublisher").IEventHandler<import("@webiny/app-websockets").WebsocketEvent>>;
18
+ };
19
+ export {};
@@ -0,0 +1,26 @@
1
+ import { WebsocketEventHandler } from "@webiny/app-websockets";
2
+ import { Notifications } from "@webiny/app-admin/features/notifications/abstractions.js";
3
+ const FILE_ENRICHMENT_FAILED_ACTION = "fm.file.enrichment.failed";
4
+ class AiImageEnrichmentFailedEventHandlerImpl {
5
+ constructor(notifications){
6
+ this.notifications = notifications;
7
+ }
8
+ async handle(event) {
9
+ if (event.payload.action !== FILE_ENRICHMENT_FAILED_ACTION) return;
10
+ const payload = event.payload;
11
+ const { message } = payload.data;
12
+ this.notifications.warning({
13
+ title: "Image enrichment failed",
14
+ description: message
15
+ });
16
+ }
17
+ }
18
+ const AiImageEnrichmentFailedEventHandler = WebsocketEventHandler.createImplementation({
19
+ implementation: AiImageEnrichmentFailedEventHandlerImpl,
20
+ dependencies: [
21
+ Notifications
22
+ ]
23
+ });
24
+ export { AiImageEnrichmentFailedEventHandler };
25
+
26
+ //# sourceMappingURL=AiImageEnrichmentFailedEventHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules/AiEnrichment/AiImageEnrichmentFailedEventHandler.js","sources":["../../../src/modules/AiEnrichment/AiImageEnrichmentFailedEventHandler.ts"],"sourcesContent":["import { WebsocketEventHandler } from \"@webiny/app-websockets\";\nimport { Notifications } from \"@webiny/app-admin/features/notifications/abstractions.js\";\n\nconst FILE_ENRICHMENT_FAILED_ACTION = \"fm.file.enrichment.failed\";\n\ninterface FileEnrichmentFailedData {\n id: string;\n message: string;\n}\n\n/**\n * Reacts to the `fm.file.enrichment.failed` websocket message, which the upload-time enrichment\n * task sends when it fails for a reason someone has to fix (no Vision model, a missing key, the\n * provider rejecting the request). Switched off and non-image uploads never send it.\n *\n * Without this the failure only reached the API log, and from the File Manager it looked exactly\n * like enrichment never having run.\n */\nclass AiImageEnrichmentFailedEventHandlerImpl implements WebsocketEventHandler.Interface {\n constructor(private notifications: Notifications.Interface) {}\n\n async handle(event: WebsocketEventHandler.Event): Promise<void> {\n if (event.payload.action !== FILE_ENRICHMENT_FAILED_ACTION) {\n return;\n }\n\n const payload = event.payload as unknown as { data: FileEnrichmentFailedData };\n const { message } = payload.data;\n\n this.notifications.warning({\n title: \"Image enrichment failed\",\n description: message\n });\n }\n}\n\nexport const AiImageEnrichmentFailedEventHandler = WebsocketEventHandler.createImplementation({\n implementation: AiImageEnrichmentFailedEventHandlerImpl,\n dependencies: [Notifications]\n});\n"],"names":["FILE_ENRICHMENT_FAILED_ACTION","AiImageEnrichmentFailedEventHandlerImpl","notifications","event","payload","message","AiImageEnrichmentFailedEventHandler","WebsocketEventHandler","Notifications"],"mappings":";;AAGA,MAAMA,gCAAgC;AAetC,MAAMC;IACF,YAAoBC,aAAsC,CAAE;aAAxCA,aAAa,GAAbA;IAAyC;IAE7D,MAAM,OAAOC,KAAkC,EAAiB;QAC5D,IAAIA,MAAM,OAAO,CAAC,MAAM,KAAKH,+BACzB;QAGJ,MAAMI,UAAUD,MAAM,OAAO;QAC7B,MAAM,EAAEE,OAAO,EAAE,GAAGD,QAAQ,IAAI;QAEhC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;YACvB,OAAO;YACP,aAAaC;QACjB;IACJ;AACJ;AAEO,MAAMC,sCAAsCC,sBAAsB,oBAAoB,CAAC;IAC1F,gBAAgBN;IAChB,cAAc;QAACO;KAAc;AACjC"}
@@ -0,0 +1,12 @@
1
+ import { ApiStreamClient } from "@webiny/app/exports/admin.js";
2
+ import { ReenrichFileGateway as GatewayAbstraction } from "./abstractions.js";
3
+ import type { EnrichmentStreamEvent, IReenrichFileOptions } from "./abstractions.js";
4
+ declare class ReenrichFileGatewayImpl implements GatewayAbstraction.Interface {
5
+ private client;
6
+ constructor(client: ApiStreamClient.Interface);
7
+ execute(fileId: string, options?: IReenrichFileOptions): AsyncGenerator<EnrichmentStreamEvent>;
8
+ }
9
+ export declare const ReenrichFileGateway: typeof ReenrichFileGatewayImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IReenrichFileGateway>;
11
+ };
12
+ export {};
@@ -0,0 +1,23 @@
1
+ import { ApiStreamClient, readServerSentEvents } from "@webiny/app/exports/admin.js";
2
+ import { ReenrichFileGateway } from "./abstractions.js";
3
+ class ReenrichFileGatewayImpl {
4
+ constructor(client){
5
+ this.client = client;
6
+ }
7
+ async *execute(fileId, options = {}) {
8
+ const response = await this.client.execute({
9
+ path: `/stream/fm/files/${encodeURIComponent(fileId)}/enrich`,
10
+ signal: options.signal
11
+ });
12
+ yield* readServerSentEvents(response);
13
+ }
14
+ }
15
+ const ReenrichFileGateway_ReenrichFileGateway = ReenrichFileGateway.createImplementation({
16
+ implementation: ReenrichFileGatewayImpl,
17
+ dependencies: [
18
+ ApiStreamClient
19
+ ]
20
+ });
21
+ export { ReenrichFileGateway_ReenrichFileGateway as ReenrichFileGateway };
22
+
23
+ //# sourceMappingURL=ReenrichFileGateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules/AiEnrichment/ReenrichFileGateway.js","sources":["../../../src/modules/AiEnrichment/ReenrichFileGateway.ts"],"sourcesContent":["import { ApiStreamClient, readServerSentEvents } from \"@webiny/app/exports/admin.js\";\nimport { ReenrichFileGateway as GatewayAbstraction } from \"./abstractions.js\";\nimport type { EnrichmentStreamEvent, IReenrichFileOptions } from \"./abstractions.js\";\n\nclass ReenrichFileGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: ApiStreamClient.Interface) {}\n\n async *execute(\n fileId: string,\n options: IReenrichFileOptions = {}\n ): AsyncGenerator<EnrichmentStreamEvent> {\n const response = await this.client.execute({\n path: `/stream/fm/files/${encodeURIComponent(fileId)}/enrich`,\n signal: options.signal\n });\n\n yield* readServerSentEvents<EnrichmentStreamEvent>(response);\n }\n}\n\nexport const ReenrichFileGateway = GatewayAbstraction.createImplementation({\n implementation: ReenrichFileGatewayImpl,\n dependencies: [ApiStreamClient]\n});\n"],"names":["ReenrichFileGatewayImpl","client","fileId","options","response","encodeURIComponent","readServerSentEvents","ReenrichFileGateway","GatewayAbstraction","ApiStreamClient"],"mappings":";;AAIA,MAAMA;IACF,YAAoBC,MAAiC,CAAE;aAAnCA,MAAM,GAANA;IAAoC;IAExD,OAAO,QACHC,MAAc,EACdC,UAAgC,CAAC,CAAC,EACG;QACrC,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YACvC,MAAM,CAAC,iBAAiB,EAAEC,mBAAmBH,QAAQ,OAAO,CAAC;YAC7D,QAAQC,QAAQ,MAAM;QAC1B;QAEA,OAAOG,qBAA4CF;IACvD;AACJ;AAEO,MAAMG,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBR;IAChB,cAAc;QAACS;KAAgB;AACnC"}
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ /**
3
+ * Test-bed for HTTP response streaming: re-runs AI enrichment for the open file and renders the
4
+ * model's output as it arrives, rather than waiting for the whole response.
5
+ *
6
+ * The stream only PROPOSES. Save drops the values into the file details form as pending edits; the
7
+ * file is written when the user presses Update in the drawer, exactly as for a hand-typed edit.
8
+ */
9
+ export declare const ReenrichWithAi: (() => React.JSX.Element) & React.NamedExoticComponent<unknown> & {
10
+ readonly type: () => React.JSX.Element;
11
+ };
@@ -0,0 +1,57 @@
1
+ import react, { useEffect } from "react";
2
+ import { ReactComponent } from "@webiny/icons/auto_awesome.svg";
3
+ import { Dialog } from "@webiny/admin-ui";
4
+ import { createReactiveComponent } from "@webiny/app-admin";
5
+ import { useFeature } from "@webiny/app";
6
+ import { FileManagerViewConfig, useFile } from "../../index.js";
7
+ import { AiEnrichmentFeature } from "./feature.js";
8
+ import { StreamingPlaceholder } from "./StreamingPlaceholder.js";
9
+ const { FileDetails: FileDetails } = FileManagerViewConfig;
10
+ const ReenrichWithAi_ReenrichWithAi = createReactiveComponent(function() {
11
+ const { file } = useFile();
12
+ const { presenter } = useFeature(AiEnrichmentFeature);
13
+ const { vm } = presenter;
14
+ useEffect(()=>()=>presenter.dispose(), [
15
+ presenter
16
+ ]);
17
+ return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(FileDetails.Action.Button, {
18
+ label: "Re-enrich with AI",
19
+ icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
20
+ onAction: ()=>presenter.start(file.id),
21
+ "data-testid": "fm.file-details.action.reenrich-with-ai"
22
+ }), /*#__PURE__*/ react.createElement(Dialog, {
23
+ open: vm.open,
24
+ onOpenChange: (open)=>presenter.setOpen(open),
25
+ title: "Re-enrich with AI",
26
+ description: vm.message,
27
+ actions: /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Dialog.CancelAction, null), /*#__PURE__*/ react.createElement(Dialog.ConfirmAction, {
28
+ text: "Apply",
29
+ onClick: ()=>presenter.accept(),
30
+ disabled: !vm.canSave
31
+ }))
32
+ }, /*#__PURE__*/ react.createElement("div", {
33
+ className: "flex flex-col gap-md"
34
+ }, /*#__PURE__*/ react.createElement("div", null, /*#__PURE__*/ react.createElement("div", {
35
+ className: "text-sm font-semibold mb-xs"
36
+ }, "Tags"), /*#__PURE__*/ react.createElement("div", {
37
+ className: "min-h-[48px]"
38
+ }, vm.tags.length ? /*#__PURE__*/ react.createElement("div", {
39
+ className: "flex flex-wrap gap-xs"
40
+ }, vm.tags.map((tag)=>/*#__PURE__*/ react.createElement("span", {
41
+ key: tag,
42
+ className: "text-sm px-sm py-xxs rounded bg-neutral-dimmed"
43
+ }, tag))) : /*#__PURE__*/ react.createElement(StreamingPlaceholder, {
44
+ loading: vm.loading,
45
+ variant: "chips"
46
+ }))), /*#__PURE__*/ react.createElement("div", null, /*#__PURE__*/ react.createElement("div", {
47
+ className: "text-sm font-semibold mb-xs"
48
+ }, "Description"), /*#__PURE__*/ react.createElement("div", {
49
+ className: "text-sm min-h-[4lh]"
50
+ }, vm.description ? vm.description : /*#__PURE__*/ react.createElement(StreamingPlaceholder, {
51
+ loading: vm.loading,
52
+ variant: "text"
53
+ }))))));
54
+ });
55
+ export { ReenrichWithAi_ReenrichWithAi as ReenrichWithAi };
56
+
57
+ //# sourceMappingURL=ReenrichWithAi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules/AiEnrichment/ReenrichWithAi.js","sources":["../../../src/modules/AiEnrichment/ReenrichWithAi.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { ReactComponent as AiIcon } from \"@webiny/icons/auto_awesome.svg\";\nimport { Dialog } from \"@webiny/admin-ui\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { useFeature } from \"@webiny/app\";\nimport { FileManagerViewConfig, useFile } from \"~/index.js\";\nimport { AiEnrichmentFeature } from \"./feature.js\";\nimport { StreamingPlaceholder } from \"./StreamingPlaceholder.js\";\n\nconst { FileDetails } = FileManagerViewConfig;\n\n/**\n * Test-bed for HTTP response streaming: re-runs AI enrichment for the open file and renders the\n * model's output as it arrives, rather than waiting for the whole response.\n *\n * The stream only PROPOSES. Save drops the values into the file details form as pending edits; the\n * file is written when the user presses Update in the drawer, exactly as for a hand-typed edit.\n */\nexport const ReenrichWithAi = createReactiveComponent(function ReenrichWithAi() {\n const { file } = useFile();\n const { presenter } = useFeature(AiEnrichmentFeature);\n const { vm } = presenter;\n\n // Abandon an in-flight stream when this view goes away, so the read loop doesn't keep running\n // against a component that no longer exists.\n useEffect(() => {\n return () => presenter.dispose();\n }, [presenter]);\n\n return (\n <>\n <FileDetails.Action.Button\n label={\"Re-enrich with AI\"}\n icon={<AiIcon />}\n onAction={() => presenter.start(file.id)}\n data-testid={\"fm.file-details.action.reenrich-with-ai\"}\n />\n <Dialog\n open={vm.open}\n onOpenChange={open => presenter.setOpen(open)}\n title={\"Re-enrich with AI\"}\n description={vm.message}\n actions={\n <>\n <Dialog.CancelAction />\n <Dialog.ConfirmAction\n text={\"Apply\"}\n onClick={() => presenter.accept()}\n disabled={!vm.canSave}\n />\n </>\n }\n >\n <div className={\"flex flex-col gap-md\"}>\n {/*\n * Each value box reserves its space so the dialog doesn't resize while the model\n * streams, and the footer buttons don't slide out from under the pointer.\n *\n * On the value boxes rather than once on the body: tags and description grow\n * independently, so a single body minimum would still let wrapping tags shove the\n * description down. The reservations cover what this prompt (\"up to 5 tags and one\n * short sentence\") actually produces — two rows of chips, four lines of text.\n * Beyond that the dialog grows, which beats clipping.\n */}\n <div>\n <div className={\"text-sm font-semibold mb-xs\"}>{\"Tags\"}</div>\n <div className={\"min-h-[48px]\"}>\n {vm.tags.length ? (\n <div className={\"flex flex-wrap gap-xs\"}>\n {vm.tags.map(tag => (\n <span\n key={tag}\n className={\n \"text-sm px-sm py-xxs rounded bg-neutral-dimmed\"\n }\n >\n {tag}\n </span>\n ))}\n </div>\n ) : (\n <StreamingPlaceholder loading={vm.loading} variant={\"chips\"} />\n )}\n </div>\n </div>\n <div>\n <div className={\"text-sm font-semibold mb-xs\"}>{\"Description\"}</div>\n {/*\n * `lh` is the line-height unit, so four lines stays four lines if the type\n * scale changes. Browsers without it simply ignore the minimum.\n */}\n <div className={\"text-sm min-h-[4lh]\"}>\n {vm.description ? (\n vm.description\n ) : (\n <StreamingPlaceholder loading={vm.loading} variant={\"text\"} />\n )}\n </div>\n </div>\n </div>\n </Dialog>\n </>\n );\n});\n"],"names":["FileDetails","FileManagerViewConfig","ReenrichWithAi","createReactiveComponent","file","useFile","presenter","useFeature","AiEnrichmentFeature","vm","useEffect","A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QAAE,SAAS;;AAQpF"}
@@ -0,0 +1,50 @@
1
+ import { Notifications } from "@webiny/app-admin/features/notifications/abstractions.js";
2
+ import { FileDetailsPresenter } from "../../presentation/FileDetails/abstractions.js";
3
+ import type { IReenrichFileGateway, IReenrichWithAiPresenter, IReenrichWithAiViewModel } from "./abstractions.js";
4
+ declare class ReenrichWithAiPresenterImpl implements IReenrichWithAiPresenter {
5
+ private gateway;
6
+ private fileDetails;
7
+ private notifications;
8
+ private open;
9
+ private status;
10
+ private tags;
11
+ private description;
12
+ private error;
13
+ /**
14
+ * Not observable state — nothing renders from it. It exists so an in-flight stream can be
15
+ * abandoned when the dialog closes or the view goes away; a streaming response stays open for as
16
+ * long as the producer runs, so without this the read loop would outlive its reader.
17
+ */
18
+ private controller;
19
+ constructor(gateway: IReenrichFileGateway, fileDetails: FileDetailsPresenter.Interface, notifications: Notifications.Interface);
20
+ get vm(): IReenrichWithAiViewModel;
21
+ start(fileId: string): Promise<void>;
22
+ accept(): void;
23
+ setOpen(open: boolean): void;
24
+ /**
25
+ * Called when the view unmounts. Resets, not just aborts: the presenter is a DI singleton, so a
26
+ * left-over `open` would pop the dialog straight back up the next time the view mounts.
27
+ */
28
+ dispose(): void;
29
+ /** Aborts any previous run, clears the last result, and opens the dialog on a fresh one. */
30
+ private beginRun;
31
+ /**
32
+ * Merges one streamed value into the displayed proposal.
33
+ *
34
+ * The model streams the tag array CHARACTER by character, so the last entry of a partial value is
35
+ * usually a half-written word — "webiny" arrives as "web", "webi", "webiny". While the stream is
36
+ * running that trailing entry is dropped, so a chip appears only once its text is settled; the
37
+ * `done` value is complete and used whole.
38
+ *
39
+ * Do NOT accumulate across partials instead of replacing. Every prefix differs from the last, so
40
+ * "keep everything seen" turns one tag into a chip per keystroke.
41
+ */
42
+ private applyOutput;
43
+ private finish;
44
+ private fail;
45
+ private abort;
46
+ }
47
+ export declare const ReenrichWithAiPresenter: typeof ReenrichWithAiPresenterImpl & {
48
+ __abstraction: import("@webiny/di").Abstraction<IReenrichWithAiPresenter>;
49
+ };
50
+ export {};
@@ -0,0 +1,114 @@
1
+ import { makeAutoObservable } from "mobx";
2
+ import { Notifications } from "@webiny/app-admin/features/notifications/abstractions.js";
3
+ import { FileDetailsPresenter } from "../../presentation/FileDetails/abstractions.js";
4
+ import { ReenrichFileGateway, ReenrichWithAiPresenter } from "./abstractions.js";
5
+ const STATUS_LABEL = {
6
+ idle: "",
7
+ running: "Analyzing image…",
8
+ ready: "Applying fills in the form below. Press Update to save the file.",
9
+ error: "Failed."
10
+ };
11
+ class ReenrichWithAiPresenterImpl {
12
+ constructor(gateway, fileDetails, notifications){
13
+ this.gateway = gateway;
14
+ this.fileDetails = fileDetails;
15
+ this.notifications = notifications;
16
+ this.open = false;
17
+ this.status = "idle";
18
+ this.tags = [];
19
+ this.description = "";
20
+ this.error = null;
21
+ this.controller = null;
22
+ makeAutoObservable(this, {
23
+ controller: false
24
+ });
25
+ }
26
+ get vm() {
27
+ return {
28
+ open: this.open,
29
+ message: this.error ?? STATUS_LABEL[this.status],
30
+ tags: this.tags,
31
+ description: this.description,
32
+ canSave: "ready" === this.status,
33
+ loading: "running" === this.status
34
+ };
35
+ }
36
+ async start(fileId) {
37
+ const controller = this.beginRun();
38
+ try {
39
+ for await (const event of this.gateway.execute(fileId, {
40
+ signal: controller.signal
41
+ })){
42
+ if ("partial" === event.type || "done" === event.type) this.applyOutput(event.tags, event.description, "done" === event.type);
43
+ if ("done" === event.type) this.finish("ready");
44
+ if ("error" === event.type) this.fail(event.message);
45
+ }
46
+ } catch (err) {
47
+ if (err instanceof DOMException && "AbortError" === err.name) return;
48
+ this.fail(err instanceof Error ? err.message : String(err));
49
+ }
50
+ }
51
+ accept() {
52
+ if ("ready" !== this.status) return;
53
+ this.fileDetails.vm.form.setData({
54
+ tags: this.tags,
55
+ description: this.description
56
+ }, {
57
+ dirty: true
58
+ });
59
+ this.setOpen(false);
60
+ this.notifications.notify({
61
+ title: "Suggestion applied",
62
+ description: "Press Update to save the new tags and description."
63
+ });
64
+ }
65
+ setOpen(open) {
66
+ if (!open) this.abort();
67
+ this.open = open;
68
+ }
69
+ dispose() {
70
+ this.abort();
71
+ this.open = false;
72
+ this.status = "idle";
73
+ this.tags = [];
74
+ this.description = "";
75
+ this.error = null;
76
+ }
77
+ beginRun() {
78
+ this.abort();
79
+ const controller = new AbortController();
80
+ this.controller = controller;
81
+ this.open = true;
82
+ this.status = "running";
83
+ this.tags = [];
84
+ this.description = "";
85
+ this.error = null;
86
+ return controller;
87
+ }
88
+ applyOutput(tags, description, final) {
89
+ this.tags = final ? tags : tags.slice(0, -1);
90
+ this.description = description;
91
+ }
92
+ finish(status) {
93
+ this.status = status;
94
+ }
95
+ fail(message) {
96
+ this.error = message;
97
+ this.status = "error";
98
+ }
99
+ abort() {
100
+ this.controller?.abort();
101
+ this.controller = null;
102
+ }
103
+ }
104
+ const ReenrichWithAiPresenter_ReenrichWithAiPresenter = ReenrichWithAiPresenter.createImplementation({
105
+ implementation: ReenrichWithAiPresenterImpl,
106
+ dependencies: [
107
+ ReenrichFileGateway,
108
+ FileDetailsPresenter,
109
+ Notifications
110
+ ]
111
+ });
112
+ export { ReenrichWithAiPresenter_ReenrichWithAiPresenter as ReenrichWithAiPresenter };
113
+
114
+ //# sourceMappingURL=ReenrichWithAiPresenter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules/AiEnrichment/ReenrichWithAiPresenter.js","sources":["../../../src/modules/AiEnrichment/ReenrichWithAiPresenter.ts"],"sourcesContent":["import { makeAutoObservable } from \"mobx\";\nimport { Notifications } from \"@webiny/app-admin/features/notifications/abstractions.js\";\nimport { FileDetailsPresenter } from \"~/presentation/FileDetails/abstractions.js\";\nimport {\n ReenrichFileGateway,\n ReenrichWithAiPresenter as PresenterAbstraction\n} from \"./abstractions.js\";\nimport type {\n IReenrichFileGateway,\n IReenrichWithAiPresenter,\n IReenrichWithAiViewModel\n} from \"./abstractions.js\";\n\ntype Status = \"idle\" | \"running\" | \"ready\" | \"error\";\n\nconst STATUS_LABEL: Record<Status, string> = {\n idle: \"\",\n running: \"Analyzing image…\",\n // Says what Apply does AND does not do. Applying only fills the form in — the file is written by\n // the drawer's Update button, and nothing else on screen says so.\n ready: \"Applying fills in the form below. Press Update to save the file.\",\n error: \"Failed.\"\n};\n\nclass ReenrichWithAiPresenterImpl implements IReenrichWithAiPresenter {\n private open = false;\n private status: Status = \"idle\";\n private tags: string[] = [];\n private description = \"\";\n private error: string | null = null;\n\n /**\n * Not observable state — nothing renders from it. It exists so an in-flight stream can be\n * abandoned when the dialog closes or the view goes away; a streaming response stays open for as\n * long as the producer runs, so without this the read loop would outlive its reader.\n */\n private controller: AbortController | null = null;\n\n constructor(\n private gateway: IReenrichFileGateway,\n private fileDetails: FileDetailsPresenter.Interface,\n private notifications: Notifications.Interface\n ) {\n // The second type parameter is what lets a PRIVATE field appear in the annotation map.\n makeAutoObservable<ReenrichWithAiPresenterImpl, \"controller\">(this, { controller: false });\n }\n\n get vm(): IReenrichWithAiViewModel {\n return {\n open: this.open,\n message: this.error ?? STATUS_LABEL[this.status],\n tags: this.tags,\n description: this.description,\n canSave: this.status === \"ready\",\n loading: this.status === \"running\"\n };\n }\n\n async start(fileId: string) {\n const controller = this.beginRun();\n\n try {\n for await (const event of this.gateway.execute(fileId, {\n signal: controller.signal\n })) {\n if (event.type === \"partial\" || event.type === \"done\") {\n this.applyOutput(event.tags, event.description, event.type === \"done\");\n }\n\n // Nothing is written yet — the route only proposes. The user accepts with save().\n if (event.type === \"done\") {\n this.finish(\"ready\");\n }\n\n if (event.type === \"error\") {\n this.fail(event.message);\n }\n }\n } catch (err) {\n // An abort is this presenter's own doing, not a failure to report.\n if (err instanceof DOMException && err.name === \"AbortError\") {\n return;\n }\n this.fail(err instanceof Error ? err.message : String(err));\n }\n }\n\n accept() {\n if (this.status !== \"ready\") {\n return;\n }\n\n // Through the form's own `setData` rather than a method on FileDetailsPresenter: the drawer\n // has no business knowing that AI enrichment exists, and every future feature that fills in\n // fields would otherwise add one more method to it.\n //\n // `dirty: true` skips the baseline snapshot, so the form stays dirty and Update has something\n // to save. setData merges — it only touches the keys passed — so Name and Access Control keep\n // whatever the user has typed.\n this.fileDetails.vm.form.setData(\n { tags: this.tags, description: this.description },\n { dirty: true }\n );\n this.setOpen(false);\n\n // The dialog is gone the moment it is accepted, so the reminder has to outlive it. `notify`\n // rather than `success`: nothing has been saved yet, and a green tick would say it had.\n this.notifications.notify({\n title: \"Suggestion applied\",\n description: \"Press Update to save the new tags and description.\"\n });\n }\n\n setOpen(open: boolean) {\n if (!open) {\n this.abort();\n }\n this.open = open;\n }\n\n /**\n * Called when the view unmounts. Resets, not just aborts: the presenter is a DI singleton, so a\n * left-over `open` would pop the dialog straight back up the next time the view mounts.\n */\n dispose() {\n this.abort();\n this.open = false;\n this.status = \"idle\";\n this.tags = [];\n this.description = \"\";\n this.error = null;\n }\n\n /** Aborts any previous run, clears the last result, and opens the dialog on a fresh one. */\n private beginRun(): AbortController {\n this.abort();\n\n const controller = new AbortController();\n this.controller = controller;\n\n this.open = true;\n this.status = \"running\";\n this.tags = [];\n this.description = \"\";\n this.error = null;\n\n return controller;\n }\n\n /**\n * Merges one streamed value into the displayed proposal.\n *\n * The model streams the tag array CHARACTER by character, so the last entry of a partial value is\n * usually a half-written word — \"webiny\" arrives as \"web\", \"webi\", \"webiny\". While the stream is\n * running that trailing entry is dropped, so a chip appears only once its text is settled; the\n * `done` value is complete and used whole.\n *\n * Do NOT accumulate across partials instead of replacing. Every prefix differs from the last, so\n * \"keep everything seen\" turns one tag into a chip per keystroke.\n */\n private applyOutput(tags: string[], description: string, final: boolean) {\n this.tags = final ? tags : tags.slice(0, -1);\n this.description = description;\n }\n\n private finish(status: Status) {\n this.status = status;\n }\n\n private fail(message: string) {\n this.error = message;\n this.status = \"error\";\n }\n\n private abort() {\n this.controller?.abort();\n this.controller = null;\n }\n}\n\nexport const ReenrichWithAiPresenter = PresenterAbstraction.createImplementation({\n implementation: ReenrichWithAiPresenterImpl,\n dependencies: [ReenrichFileGateway, FileDetailsPresenter, Notifications]\n});\n"],"names":["STATUS_LABEL","ReenrichWithAiPresenterImpl","gateway","fileDetails","notifications","makeAutoObservable","fileId","controller","event","err","DOMException","Error","String","open","AbortController","tags","description","final","status","message","ReenrichWithAiPresenter","PresenterAbstraction","ReenrichFileGateway","FileDetailsPresenter","Notifications"],"mappings":";;;;AAeA,MAAMA,eAAuC;IACzC,MAAM;IACN,SAAS;IAGT,OAAO;IACP,OAAO;AACX;AAEA,MAAMC;IAcF,YACYC,OAA6B,EAC7BC,WAA2C,EAC3CC,aAAsC,CAChD;aAHUF,OAAO,GAAPA;aACAC,WAAW,GAAXA;aACAC,aAAa,GAAbA;aAhBJ,IAAI,GAAG;aACP,MAAM,GAAW;aACjB,IAAI,GAAa,EAAE;aACnB,WAAW,GAAG;aACd,KAAK,GAAkB;QAM9B,KACO,UAAU,GAA2B;QAQzCC,mBAA8D,IAAI,EAAE;YAAE,YAAY;QAAM;IAC5F;IAEA,IAAI,KAA+B;QAC/B,OAAO;YACH,MAAM,IAAI,CAAC,IAAI;YACf,SAAS,IAAI,CAAC,KAAK,IAAIL,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;YAChD,MAAM,IAAI,CAAC,IAAI;YACf,aAAa,IAAI,CAAC,WAAW;YAC7B,SAAS,AAAgB,YAAhB,IAAI,CAAC,MAAM;YACpB,SAAS,AAAgB,cAAhB,IAAI,CAAC,MAAM;QACxB;IACJ;IAEA,MAAM,MAAMM,MAAc,EAAE;QACxB,MAAMC,aAAa,IAAI,CAAC,QAAQ;QAEhC,IAAI;YACA,WAAW,MAAMC,SAAS,IAAI,CAAC,OAAO,CAAC,OAAO,CAACF,QAAQ;gBACnD,QAAQC,WAAW,MAAM;YAC7B,GAAI;gBACA,IAAIC,AAAe,cAAfA,MAAM,IAAI,IAAkBA,AAAe,WAAfA,MAAM,IAAI,EACtC,IAAI,CAAC,WAAW,CAACA,MAAM,IAAI,EAAEA,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CAAC,KAAK,GAAG;QAEb,OAAOA;IACX;IAaQ,YAAYQ,IAAc,EAAEC,WAAmB,EAAEC,KAAc,EAAE;QACrE,IAAI,CAAC,IAAI,GAAGA,QAAQF,OAAOA,KAAK,KAAK,CAAC,GAAG;QACzC,IAAI,CAAC,WAAW,GAAGC;IACvB;IAEQ,OAAOE,MAAc,EAAE;QAC3B,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEQ,KAAKC,OAAe,EAAE;QAC1B,IAAI,CAAC,KAAK,GAAGA;QACb,IAAI,CAAC,MAAM,GAAG;IAClB;IAEQ,QAAQ;QACZ,IAAI,CAAC,UAAU,EAAE;QACjB,IAAI,CAAC,UAAU,GAAG;IACtB;AACJ;AAEO,MAAMC,kDAA0BC,wBAAAA,oBAAyC,CAAC;IAC7E,gBAAgBpB;IAChB,cAAc;QAACqB;QAAqBC;QAAsBC;KAAc;AAC5E"}
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ export type StreamingPlaceholderVariant = "chips" | "text";
3
+ export interface StreamingPlaceholderProps {
4
+ /** While the producer is still running, an empty field is pending — not empty. */
5
+ loading: boolean;
6
+ variant: StreamingPlaceholderVariant;
7
+ }
8
+ /**
9
+ * Stands in for a field that has no content yet: skeleton bars while a stream is running, and a dash
10
+ * once it has stopped and the field genuinely came back empty.
11
+ *
12
+ * The bar widths and layout live here rather than in props, so a caller says what KIND of content is
13
+ * coming and nothing more.
14
+ */
15
+ export declare const StreamingPlaceholder: ({ loading, variant }: StreamingPlaceholderProps) => React.JSX.Element;
@@ -0,0 +1,32 @@
1
+ import react from "react";
2
+ import { Skeleton, cn } from "@webiny/admin-ui";
3
+ const WIDTHS = {
4
+ chips: [
5
+ "w-16",
6
+ "w-24",
7
+ "w-20",
8
+ "w-14"
9
+ ],
10
+ text: [
11
+ "w-full",
12
+ "w-full",
13
+ "w-3/4"
14
+ ]
15
+ };
16
+ const StreamingPlaceholder = ({ loading, variant })=>{
17
+ if (!loading) return /*#__PURE__*/ react.createElement("div", {
18
+ className: "text-sm text-neutral-strong"
19
+ }, "—");
20
+ const chips = "chips" === variant;
21
+ return /*#__PURE__*/ react.createElement("div", {
22
+ className: chips ? "flex flex-wrap gap-xs" : "flex flex-col gap-xs"
23
+ }, WIDTHS[variant].map((width)=>/*#__PURE__*/ react.createElement(Skeleton, {
24
+ key: width,
25
+ type: "text",
26
+ size: "sm",
27
+ className: cn(width, chips && "rounded")
28
+ })));
29
+ };
30
+ export { StreamingPlaceholder };
31
+
32
+ //# sourceMappingURL=StreamingPlaceholder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules/AiEnrichment/StreamingPlaceholder.js","sources":["../../../src/modules/AiEnrichment/StreamingPlaceholder.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn, Skeleton } from \"@webiny/admin-ui\";\n\n// Uneven on purpose: equal-length bars read as a table, not as content still arriving.\nconst WIDTHS: Record<StreamingPlaceholderVariant, string[]> = {\n chips: [\"w-16\", \"w-24\", \"w-20\", \"w-14\"],\n text: [\"w-full\", \"w-full\", \"w-3/4\"]\n};\n\nexport type StreamingPlaceholderVariant = \"chips\" | \"text\";\n\nexport interface StreamingPlaceholderProps {\n /** While the producer is still running, an empty field is pending — not empty. */\n loading: boolean;\n variant: StreamingPlaceholderVariant;\n}\n\n/**\n * Stands in for a field that has no content yet: skeleton bars while a stream is running, and a dash\n * once it has stopped and the field genuinely came back empty.\n *\n * The bar widths and layout live here rather than in props, so a caller says what KIND of content is\n * coming and nothing more.\n */\nexport const StreamingPlaceholder = ({ loading, variant }: StreamingPlaceholderProps) => {\n if (!loading) {\n return <div className={\"text-sm text-neutral-strong\"}>{\"—\"}</div>;\n }\n\n const chips = variant === \"chips\";\n\n return (\n <div className={chips ? \"flex flex-wrap gap-xs\" : \"flex flex-col gap-xs\"}>\n {WIDTHS[variant].map(width => (\n <Skeleton\n key={width}\n type={\"text\"}\n size={\"sm\"}\n className={cn(width, chips && \"rounded\")}\n />\n ))}\n </div>\n );\n};\n"],"names":["WIDTHS","StreamingPlaceholder","loading","variant","chips","width","Skeleton","cn"],"mappings":";;AAIA,MAAMA,SAAwD;IAC1D,OAAO;QAAC;QAAQ;QAAQ;QAAQ;KAAO;IACvC,MAAM;QAAC;QAAU;QAAU;KAAQ;AACvC;AAiBO,MAAMC,uBAAuB,CAAC,EAAEC,OAAO,EAAEC,OAAO,EAA6B;IAChF,IAAI,CAACD,SACD,OAAO,WAAP,GAAO,oBAAC;QAAI,WAAW;OAAgC;IAG3D,MAAME,QAAQD,AAAY,YAAZA;IAEd,OAAO,WAAP,GACI,oBAAC;QAAI,WAAWC,QAAQ,0BAA0B;OAC7CJ,MAAM,CAACG,QAAQ,CAAC,GAAG,CAACE,CAAAA,QAAAA,WAAAA,GACjB,oBAACC,UAAQA;YACL,KAAKD;YACL,MAAM;YACN,MAAM;YACN,WAAWE,GAAGF,OAAOD,SAAS;;AAKlD"}