@webiny/app-file-manager 0.0.0-unstable.7be00a75a9 → 0.0.0-unstable.7c2def32a7

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 (240) hide show
  1. package/app.js +21 -2
  2. package/app.js.map +1 -1
  3. package/domain/tagsHelpers.d.ts +2 -2
  4. package/domain/types.d.ts +0 -8
  5. package/features/permissions/abstractions.d.ts +2 -2
  6. package/features/permissions/feature.d.ts +3 -3
  7. package/features/shared/FILE_FIELDS.js +4 -0
  8. package/features/shared/FILE_FIELDS.js.map +1 -1
  9. package/features/shared/FileFieldsProviderWithWcp.d.ts +5 -5
  10. package/features/shared/FileFieldsProviderWithWcp.js +7 -7
  11. package/features/shared/FileFieldsProviderWithWcp.js.map +1 -1
  12. package/modules/AiEnrichment/AiImageEnrichmentEventHandler.d.ts +18 -0
  13. package/modules/AiEnrichment/AiImageEnrichmentEventHandler.js +33 -0
  14. package/modules/AiEnrichment/AiImageEnrichmentEventHandler.js.map +1 -0
  15. package/modules/AiEnrichment/AiImageEnrichmentFailedEventHandler.d.ts +19 -0
  16. package/modules/AiEnrichment/AiImageEnrichmentFailedEventHandler.js +26 -0
  17. package/modules/AiEnrichment/AiImageEnrichmentFailedEventHandler.js.map +1 -0
  18. package/modules/AiEnrichment/ReenrichFileGateway.d.ts +12 -0
  19. package/modules/AiEnrichment/ReenrichFileGateway.js +23 -0
  20. package/modules/AiEnrichment/ReenrichFileGateway.js.map +1 -0
  21. package/modules/AiEnrichment/ReenrichWithAi.d.ts +11 -0
  22. package/modules/AiEnrichment/ReenrichWithAi.js +57 -0
  23. package/modules/AiEnrichment/ReenrichWithAi.js.map +1 -0
  24. package/modules/AiEnrichment/ReenrichWithAiPresenter.d.ts +50 -0
  25. package/modules/AiEnrichment/ReenrichWithAiPresenter.js +114 -0
  26. package/modules/AiEnrichment/ReenrichWithAiPresenter.js.map +1 -0
  27. package/modules/AiEnrichment/StreamingPlaceholder.d.ts +15 -0
  28. package/modules/AiEnrichment/StreamingPlaceholder.js +32 -0
  29. package/modules/AiEnrichment/StreamingPlaceholder.js.map +1 -0
  30. package/modules/AiEnrichment/abstractions.d.ts +70 -0
  31. package/modules/AiEnrichment/abstractions.js +6 -0
  32. package/modules/AiEnrichment/abstractions.js.map +1 -0
  33. package/modules/AiEnrichment/feature.d.ts +3 -0
  34. package/modules/AiEnrichment/feature.js +23 -0
  35. package/modules/AiEnrichment/feature.js.map +1 -0
  36. package/modules/AiEnrichment/index.d.ts +2 -0
  37. package/modules/AiEnrichment/index.js +9 -0
  38. package/modules/AiEnrichment/index.js.map +1 -0
  39. package/modules/Enterprise/index.js +3 -3
  40. package/modules/Enterprise/index.js.map +1 -1
  41. package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.d.ts +26 -0
  42. package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.js +39 -0
  43. package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.js.map +1 -0
  44. package/modules/HeadlessCms/fieldType/AssetFieldType.d.ts +34 -0
  45. package/modules/HeadlessCms/fieldType/AssetFieldType.js +42 -0
  46. package/modules/HeadlessCms/fieldType/AssetFieldType.js.map +1 -0
  47. package/modules/HeadlessCms/fieldType/AssetFormFieldType.d.ts +21 -0
  48. package/modules/HeadlessCms/fieldType/AssetFormFieldType.js +42 -0
  49. package/modules/HeadlessCms/fieldType/AssetFormFieldType.js.map +1 -0
  50. package/modules/HeadlessCms/fieldType/AssetInputRenderer.d.ts +15 -0
  51. package/modules/HeadlessCms/fieldType/AssetInputRenderer.js +20 -0
  52. package/modules/HeadlessCms/fieldType/AssetInputRenderer.js.map +1 -0
  53. package/modules/HeadlessCms/fieldType/AssetInputsRenderer.d.ts +15 -0
  54. package/modules/HeadlessCms/fieldType/AssetInputsRenderer.js +20 -0
  55. package/modules/HeadlessCms/fieldType/AssetInputsRenderer.js.map +1 -0
  56. package/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.d.ts +16 -0
  57. package/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.js +33 -0
  58. package/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.js.map +1 -0
  59. package/modules/HeadlessCms/fieldType/FileFieldType.d.ts +25 -0
  60. package/modules/HeadlessCms/fieldType/FileFieldType.js +38 -0
  61. package/modules/HeadlessCms/fieldType/FileFieldType.js.map +1 -0
  62. package/modules/HeadlessCms/fieldType/FileInputRenderer.d.ts +15 -0
  63. package/modules/HeadlessCms/fieldType/FileInputRenderer.js +19 -0
  64. package/modules/HeadlessCms/fieldType/FileInputRenderer.js.map +1 -0
  65. package/modules/HeadlessCms/fieldType/FileInputsRenderer.d.ts +15 -0
  66. package/modules/HeadlessCms/fieldType/FileInputsRenderer.js +19 -0
  67. package/modules/HeadlessCms/fieldType/FileInputsRenderer.js.map +1 -0
  68. package/modules/HeadlessCms/fieldType/feature.d.ts +1 -0
  69. package/modules/HeadlessCms/fieldType/feature.js +27 -0
  70. package/modules/HeadlessCms/fieldType/feature.js.map +1 -0
  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 +25 -35
  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 +89 -6
  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 +6 -4
  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.d.ts +8 -12
  94. package/presentation/FileList/FileListDataSource.js +47 -87
  95. package/presentation/FileList/FileListDataSource.js.map +1 -1
  96. package/presentation/FileList/FileListPresenter.test.js +125 -3
  97. package/presentation/FileList/FileListPresenter.test.js.map +1 -1
  98. package/presentation/FileList/FileManagerPresenter.d.ts +4 -0
  99. package/presentation/FileList/FileManagerPresenter.js +33 -5
  100. package/presentation/FileList/FileManagerPresenter.js.map +1 -1
  101. package/presentation/FileList/abstractions.d.ts +5 -0
  102. package/presentation/FileList/abstractions.js.map +1 -1
  103. package/presentation/FileList/components/BulkActions/BulkActionBar.d.ts +2 -2
  104. package/presentation/FileList/components/BulkActions/BulkActionDelete.d.ts +2 -2
  105. package/presentation/FileList/components/BulkActions/BulkActionMove.d.ts +2 -2
  106. package/presentation/FileList/components/BulkActions/index.d.ts +0 -1
  107. package/presentation/FileList/components/BulkActions/index.js +0 -1
  108. package/presentation/FileList/components/BulkActions/useBulkActionWorker.d.ts +9 -8
  109. package/presentation/FileList/components/BulkActions/useBulkActionWorker.js +3 -9
  110. package/presentation/FileList/components/BulkActions/useBulkActionWorker.js.map +1 -1
  111. package/presentation/FileList/components/Filters/SubFoldersToggle.d.ts +2 -2
  112. package/presentation/FileList/components/Filters/TagsFilter.d.ts +2 -2
  113. package/presentation/FileList/components/Filters/TypeFilter.d.ts +2 -2
  114. package/presentation/FileList/components/Grid/FileGrid.d.ts +2 -2
  115. package/presentation/FileList/components/Grid/FileGrid.js +1 -1
  116. package/presentation/FileList/components/Grid/FileGrid.js.map +1 -1
  117. package/presentation/FileList/components/Grid/FileGrid.test.js +18 -5
  118. package/presentation/FileList/components/Grid/FileGrid.test.js.map +1 -1
  119. package/presentation/FileList/components/Header/FileManagerHeader.d.ts +2 -2
  120. package/presentation/FileList/components/Search/SearchBar.d.ts +2 -2
  121. package/presentation/FileList/components/Table/FileTable.d.ts +2 -2
  122. package/presentation/FileList/components/Table/FileTable.js +1 -1
  123. package/presentation/FileList/components/Table/FileTable.js.map +1 -1
  124. package/presentation/FileList/components/Table/FileTable.test.js +9 -2
  125. package/presentation/FileList/components/Table/FileTable.test.js.map +1 -1
  126. package/presentation/FileList/components/Upload/UploadProgress.d.ts +2 -2
  127. package/presentation/FileManager/FileManagerBreadcrumbs.d.ts +12 -0
  128. package/presentation/FileManager/FileManagerBreadcrumbs.js +37 -0
  129. package/presentation/FileManager/FileManagerBreadcrumbs.js.map +1 -0
  130. package/presentation/FileManager/FileManagerView.js +43 -12
  131. package/presentation/FileManager/FileManagerView.js.map +1 -1
  132. package/presentation/FileManager/RouteParamsSync.d.ts +2 -0
  133. package/presentation/FileManager/RouteParamsSync.js +30 -0
  134. package/presentation/FileManager/RouteParamsSync.js.map +1 -0
  135. package/presentation/Settings/components/SettingsView.d.ts +2 -2
  136. package/presentation/config/DefaultFileManagerConfig.js +13 -11
  137. package/presentation/config/DefaultFileManagerConfig.js.map +1 -1
  138. package/presentation/config/FileManagerViewConfig.d.ts +19 -25
  139. package/presentation/config/configComponents/Browser/BulkAction.d.ts +10 -8
  140. package/presentation/config/configComponents/Browser/BulkAction.js +3 -9
  141. package/presentation/config/configComponents/Browser/BulkAction.js.map +1 -1
  142. package/presentation/config/configComponents/Browser/FileAction.d.ts +2 -1
  143. package/presentation/config/configComponents/Browser/FolderAction.d.ts +2 -1
  144. package/presentation/config/configComponents/Browser/Table/Column.d.ts +9 -8
  145. package/presentation/config/configComponents/Browser/Table/index.d.ts +9 -9
  146. package/presentation/config/configComponents/Browser/index.d.ts +20 -20
  147. package/presentation/config/configComponents/Browser/index.js +0 -8
  148. package/presentation/config/configComponents/Browser/index.js.map +1 -1
  149. package/presentation/config/configComponents/FileDetails/index.d.ts +4 -2
  150. package/presentation/config/thumbnailRenderers/CroppedFileImage.d.ts +18 -0
  151. package/presentation/config/thumbnailRenderers/CroppedFileImage.js +66 -0
  152. package/presentation/config/thumbnailRenderers/CroppedFileImage.js.map +1 -0
  153. package/presentation/config/thumbnailRenderers/FilePreviewImageRenderer.js +6 -9
  154. package/presentation/config/thumbnailRenderers/FilePreviewImageRenderer.js.map +1 -1
  155. package/presentation/config/thumbnailRenderers/GridItemImageRenderer.js +6 -9
  156. package/presentation/config/thumbnailRenderers/GridItemImageRenderer.js.map +1 -1
  157. package/presentation/config/thumbnailRenderers/TableItemImageRenderer.js +6 -9
  158. package/presentation/config/thumbnailRenderers/TableItemImageRenderer.js.map +1 -1
  159. package/presentation/fieldRenderers/CmsAssetPickerRenderer.d.ts +22 -0
  160. package/presentation/fieldRenderers/CmsAssetPickerRenderer.js +56 -0
  161. package/presentation/fieldRenderers/CmsAssetPickerRenderer.js.map +1 -0
  162. package/presentation/fieldRenderers/CmsFilePickerRenderer.d.ts +13 -0
  163. package/presentation/fieldRenderers/CmsFilePickerRenderer.js +36 -0
  164. package/presentation/fieldRenderers/CmsFilePickerRenderer.js.map +1 -0
  165. package/presentation/fieldRenderers/CmsImageEditorDialog.d.ts +7 -0
  166. package/presentation/fieldRenderers/CmsImageEditorDialog.js +32 -0
  167. package/presentation/fieldRenderers/CmsImageEditorDialog.js.map +1 -0
  168. package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.d.ts +18 -0
  169. package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.js +88 -0
  170. package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.js.map +1 -0
  171. package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.d.ts +13 -0
  172. package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.js +60 -0
  173. package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.js.map +1 -0
  174. package/presentation/fieldRenderers/CroppedAssetThumb.d.ts +15 -0
  175. package/presentation/fieldRenderers/CroppedAssetThumb.js +25 -0
  176. package/presentation/fieldRenderers/CroppedAssetThumb.js.map +1 -0
  177. package/presentation/fieldRenderers/assetValue.d.ts +10 -0
  178. package/presentation/fieldRenderers/assetValue.js +94 -0
  179. package/presentation/fieldRenderers/assetValue.js.map +1 -0
  180. package/presentation/fieldRenderers/assetValue.test.js +54 -0
  181. package/presentation/fieldRenderers/assetValue.test.js.map +1 -0
  182. package/presentation/hooks/useCmsImageEditor.d.ts +10 -0
  183. package/presentation/hooks/useCmsImageEditor.js +76 -0
  184. package/presentation/hooks/useCmsImageEditor.js.map +1 -0
  185. package/presentation/hooks/useEditImage.d.ts +14 -0
  186. package/presentation/hooks/useEditImage.js +67 -0
  187. package/presentation/hooks/useEditImage.js.map +1 -0
  188. package/routes.d.ts +1 -0
  189. package/routes.js +2 -1
  190. package/routes.js.map +1 -1
  191. package/modules/HeadlessCms/fileField.d.ts +0 -2
  192. package/modules/HeadlessCms/fileField.js +0 -44
  193. package/modules/HeadlessCms/fileField.js.map +0 -1
  194. package/modules/HeadlessCms/fileRenderer/fileField.d.ts +0 -2
  195. package/modules/HeadlessCms/fileRenderer/fileField.js +0 -53
  196. package/modules/HeadlessCms/fileRenderer/fileField.js.map +0 -1
  197. package/modules/HeadlessCms/fileRenderer/fileFields.d.ts +0 -2
  198. package/modules/HeadlessCms/fileRenderer/fileFields.js +0 -73
  199. package/modules/HeadlessCms/fileRenderer/fileFields.js.map +0 -1
  200. package/modules/HeadlessCms/fileRenderer/utils.d.ts +0 -2
  201. package/modules/HeadlessCms/fileRenderer/utils.js +0 -15
  202. package/modules/HeadlessCms/fileRenderer/utils.js.map +0 -1
  203. package/modules/HeadlessCms/index.d.ts +0 -1
  204. package/modules/HeadlessCms/index.js +0 -14
  205. package/modules/HeadlessCms/index.js.map +0 -1
  206. package/modules/Settings/graphql.d.ts +0 -12
  207. package/modules/Settings/graphql.js +0 -36
  208. package/modules/Settings/graphql.js.map +0 -1
  209. package/modules/Settings/views/FileManagerSettings.d.ts +0 -2
  210. package/modules/Settings/views/FileManagerSettings.js +0 -134
  211. package/modules/Settings/views/FileManagerSettings.js.map +0 -1
  212. package/presentation/FileList/components/BulkActions/BatchEditorDialog/AddOperation.d.ts +0 -7
  213. package/presentation/FileList/components/BulkActions/BatchEditorDialog/AddOperation.js +0 -15
  214. package/presentation/FileList/components/BulkActions/BatchEditorDialog/AddOperation.js.map +0 -1
  215. package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.d.ts +0 -15
  216. package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.js +0 -44
  217. package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.js.map +0 -1
  218. package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.d.ts +0 -15
  219. package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.js +0 -52
  220. package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.js.map +0 -1
  221. package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.d.ts +0 -61
  222. package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.js +0 -111
  223. package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.js.map +0 -1
  224. package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.js +0 -372
  225. package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.js.map +0 -1
  226. package/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.d.ts +0 -8
  227. package/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.js +0 -31
  228. package/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.js.map +0 -1
  229. package/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.d.ts +0 -11
  230. package/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.js +0 -33
  231. package/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.js.map +0 -1
  232. package/presentation/FileList/components/BulkActions/BatchEditorDialog/index.d.ts +0 -1
  233. package/presentation/FileList/components/BulkActions/BatchEditorDialog/index.js +0 -1
  234. package/presentation/FileList/components/BulkActions/BulkActionEdit.d.ts +0 -4
  235. package/presentation/FileList/components/BulkActions/BulkActionEdit.js +0 -105
  236. package/presentation/FileList/components/BulkActions/BulkActionEdit.js.map +0 -1
  237. package/presentation/config/configComponents/Browser/FolderFieldDecorator.d.ts +0 -7
  238. package/presentation/config/configComponents/Browser/FolderFieldDecorator.js +0 -11
  239. package/presentation/config/configComponents/Browser/FolderFieldDecorator.js.map +0 -1
  240. /package/presentation/{FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.d.ts → fieldRenderers/assetValue.test.d.ts} +0 -0
@@ -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,MAAM,WAAW,EAAEA,AAAe,WAAfA,MAAM,IAAI;gBAI9D,IAAIA,AAAe,WAAfA,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,CAAC;gBAGhB,IAAIA,AAAe,YAAfA,MAAM,IAAI,EACV,IAAI,CAAC,IAAI,CAACA,MAAM,OAAO;YAE/B;QACJ,EAAE,OAAOC,KAAK;YAEV,IAAIA,eAAeC,gBAAgBD,AAAa,iBAAbA,IAAI,IAAI,EACvC;YAEJ,IAAI,CAAC,IAAI,CAACA,eAAeE,QAAQF,IAAI,OAAO,GAAGG,OAAOH;QAC1D;IACJ;IAEA,SAAS;QACL,IAAI,AAAgB,YAAhB,IAAI,CAAC,MAAM,EACX;QAUJ,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAC5B;YAAE,MAAM,IAAI,CAAC,IAAI;YAAE,aAAa,IAAI,CAAC,WAAW;QAAC,GACjD;YAAE,OAAO;QAAK;QAElB,IAAI,CAAC,OAAO,CAAC;QAIb,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;YACtB,OAAO;YACP,aAAa;QACjB;IACJ;IAEA,QAAQI,IAAa,EAAE;QACnB,IAAI,CAACA,MACD,IAAI,CAAC,KAAK;QAEd,IAAI,CAAC,IAAI,GAAGA;IAChB;IAMA,UAAU;QACN,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,IAAI,GAAG,EAAE;QACd,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,KAAK,GAAG;IACjB;IAGQ,WAA4B;QAChC,IAAI,CAAC,KAAK;QAEV,MAAMN,aAAa,IAAIO;QACvB,IAAI,CAAC,UAAU,GAAGP;QAElB,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,IAAI,GAAG,EAAE;QACd,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,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"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Mirrors the server-sent event payloads emitted by the api-side `AiImageEnrichmentStreamRoute`
3
+ * (see `streamEvents.ts` in `@webiny/ai-powerups`). Duplicated rather than imported: the admin app
4
+ * must not depend on an api-side package. Keep the two in sync.
5
+ */
6
+ export interface EnrichmentStreamStartEvent {
7
+ type: "start";
8
+ fileId: string;
9
+ model: string;
10
+ }
11
+ export interface EnrichmentStreamPartialEvent {
12
+ type: "partial";
13
+ tags: string[];
14
+ description: string;
15
+ }
16
+ export interface EnrichmentStreamDoneEvent {
17
+ type: "done";
18
+ fileId: string;
19
+ tags: string[];
20
+ description: string;
21
+ }
22
+ export interface EnrichmentStreamErrorEvent {
23
+ type: "error";
24
+ message: string;
25
+ }
26
+ export type EnrichmentStreamEvent = EnrichmentStreamStartEvent | EnrichmentStreamPartialEvent | EnrichmentStreamDoneEvent | EnrichmentStreamErrorEvent;
27
+ export interface IReenrichFileOptions {
28
+ signal?: AbortSignal;
29
+ }
30
+ export interface IReenrichFileGateway {
31
+ /**
32
+ * Re-runs AI enrichment for a file, yielding progress events as they arrive.
33
+ *
34
+ * Failures the server detects before streaming starts (unknown file, non-image, no provider,
35
+ * license) reject instead of yielding an `error` event — they come back as HTTP status codes.
36
+ */
37
+ execute(fileId: string, options?: IReenrichFileOptions): AsyncGenerator<EnrichmentStreamEvent>;
38
+ }
39
+ export declare const ReenrichFileGateway: import("@webiny/di").Abstraction<IReenrichFileGateway>;
40
+ export declare namespace ReenrichFileGateway {
41
+ type Interface = IReenrichFileGateway;
42
+ type Event = EnrichmentStreamEvent;
43
+ }
44
+ export interface IReenrichWithAiViewModel {
45
+ open: boolean;
46
+ /** What the dialog says under its title: the error when there is one, else the status. */
47
+ message: string;
48
+ tags: string[];
49
+ description: string;
50
+ /** The proposal is complete, so it can be accepted. */
51
+ canSave: boolean;
52
+ /** The model is still producing output, so empty fields are pending rather than absent. */
53
+ loading: boolean;
54
+ }
55
+ export interface IReenrichWithAiPresenter {
56
+ readonly vm: IReenrichWithAiViewModel;
57
+ start(fileId: string): Promise<void>;
58
+ /**
59
+ * Accept the proposal: drop the values into the file details form and close. Nothing is written
60
+ * — the user saves the file with Update, the same as for a hand-typed edit.
61
+ */
62
+ accept(): void;
63
+ setOpen(open: boolean): void;
64
+ dispose(): void;
65
+ }
66
+ export declare const ReenrichWithAiPresenter: import("@webiny/di").Abstraction<IReenrichWithAiPresenter>;
67
+ export declare namespace ReenrichWithAiPresenter {
68
+ type Interface = IReenrichWithAiPresenter;
69
+ type ViewModel = IReenrichWithAiViewModel;
70
+ }
@@ -0,0 +1,6 @@
1
+ import { createAbstraction } from "@webiny/feature/admin";
2
+ const ReenrichFileGateway = createAbstraction("ReenrichFileGateway");
3
+ const ReenrichWithAiPresenter = createAbstraction("FileManager/ReenrichWithAiPresenter");
4
+ export { ReenrichFileGateway, ReenrichWithAiPresenter };
5
+
6
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules/AiEnrichment/abstractions.js","sources":["../../../src/modules/AiEnrichment/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\n\n/**\n * Mirrors the server-sent event payloads emitted by the api-side `AiImageEnrichmentStreamRoute`\n * (see `streamEvents.ts` in `@webiny/ai-powerups`). Duplicated rather than imported: the admin app\n * must not depend on an api-side package. Keep the two in sync.\n */\nexport interface EnrichmentStreamStartEvent {\n type: \"start\";\n fileId: string;\n model: string;\n}\n\nexport interface EnrichmentStreamPartialEvent {\n type: \"partial\";\n tags: string[];\n description: string;\n}\n\nexport interface EnrichmentStreamDoneEvent {\n type: \"done\";\n fileId: string;\n tags: string[];\n description: string;\n}\n\nexport interface EnrichmentStreamErrorEvent {\n type: \"error\";\n message: string;\n}\n\nexport type EnrichmentStreamEvent =\n | EnrichmentStreamStartEvent\n | EnrichmentStreamPartialEvent\n | EnrichmentStreamDoneEvent\n | EnrichmentStreamErrorEvent;\n\nexport interface IReenrichFileOptions {\n signal?: AbortSignal;\n}\n\nexport interface IReenrichFileGateway {\n /**\n * Re-runs AI enrichment for a file, yielding progress events as they arrive.\n *\n * Failures the server detects before streaming starts (unknown file, non-image, no provider,\n * license) reject instead of yielding an `error` event — they come back as HTTP status codes.\n */\n execute(fileId: string, options?: IReenrichFileOptions): AsyncGenerator<EnrichmentStreamEvent>;\n}\n\nexport const ReenrichFileGateway = createAbstraction<IReenrichFileGateway>(\"ReenrichFileGateway\");\n\nexport namespace ReenrichFileGateway {\n export type Interface = IReenrichFileGateway;\n export type Event = EnrichmentStreamEvent;\n}\n\nexport interface IReenrichWithAiViewModel {\n open: boolean;\n /** What the dialog says under its title: the error when there is one, else the status. */\n message: string;\n tags: string[];\n description: string;\n /** The proposal is complete, so it can be accepted. */\n canSave: boolean;\n /** The model is still producing output, so empty fields are pending rather than absent. */\n loading: boolean;\n}\n\nexport interface IReenrichWithAiPresenter {\n readonly vm: IReenrichWithAiViewModel;\n start(fileId: string): Promise<void>;\n /**\n * Accept the proposal: drop the values into the file details form and close. Nothing is written\n * — the user saves the file with Update, the same as for a hand-typed edit.\n */\n accept(): void;\n setOpen(open: boolean): void;\n dispose(): void;\n}\n\nexport const ReenrichWithAiPresenter = createAbstraction<IReenrichWithAiPresenter>(\n \"FileManager/ReenrichWithAiPresenter\"\n);\n\nexport namespace ReenrichWithAiPresenter {\n export type Interface = IReenrichWithAiPresenter;\n export type ViewModel = IReenrichWithAiViewModel;\n}\n"],"names":["ReenrichFileGateway","createAbstraction","ReenrichWithAiPresenter"],"mappings":";AAmDO,MAAMA,sBAAsBC,kBAAwC;AA+BpE,MAAMC,0BAA0BD,kBACnC"}
@@ -0,0 +1,3 @@
1
+ export declare const AiEnrichmentFeature: import("@webiny/feature/admin").FeatureDefinition<{
2
+ presenter: import("./abstractions.js").IReenrichWithAiPresenter;
3
+ }, []>;
@@ -0,0 +1,23 @@
1
+ import { createFeature } from "@webiny/feature/admin";
2
+ import { AiImageEnrichmentEventHandler } from "./AiImageEnrichmentEventHandler.js";
3
+ import { AiImageEnrichmentFailedEventHandler } from "./AiImageEnrichmentFailedEventHandler.js";
4
+ import { ReenrichFileGateway } from "./ReenrichFileGateway.js";
5
+ import { ReenrichWithAiPresenter } from "./ReenrichWithAiPresenter.js";
6
+ import { ReenrichWithAiPresenter as external_abstractions_js_ReenrichWithAiPresenter } from "./abstractions.js";
7
+ const AiEnrichmentFeature = createFeature({
8
+ name: "FileManager/AiEnrichment",
9
+ register (container) {
10
+ container.register(AiImageEnrichmentEventHandler);
11
+ container.register(AiImageEnrichmentFailedEventHandler);
12
+ container.register(ReenrichFileGateway).inSingletonScope();
13
+ container.register(ReenrichWithAiPresenter).inContainerScope();
14
+ },
15
+ resolve (container) {
16
+ return {
17
+ presenter: container.resolve(external_abstractions_js_ReenrichWithAiPresenter)
18
+ };
19
+ }
20
+ });
21
+ export { AiEnrichmentFeature };
22
+
23
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules/AiEnrichment/feature.js","sources":["../../../src/modules/AiEnrichment/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { AiImageEnrichmentEventHandler } from \"./AiImageEnrichmentEventHandler.js\";\nimport { AiImageEnrichmentFailedEventHandler } from \"./AiImageEnrichmentFailedEventHandler.js\";\nimport { ReenrichFileGateway } from \"./ReenrichFileGateway.js\";\nimport { ReenrichWithAiPresenter } from \"./ReenrichWithAiPresenter.js\";\nimport { ReenrichWithAiPresenter as PresenterAbstraction } from \"./abstractions.js\";\n\nexport const AiEnrichmentFeature = createFeature({\n name: \"FileManager/AiEnrichment\",\n register(container) {\n container.register(AiImageEnrichmentEventHandler);\n container.register(AiImageEnrichmentFailedEventHandler);\n container.register(ReenrichFileGateway).inSingletonScope();\n // One per container, so the dialog's state survives re-renders of the view that reads it. Not\n // a singleton: the presenter reads FileDetailsPresenter, which only the File Manager view's\n // child container registers, and a container-scoped instance is built from that child.\n container.register(ReenrichWithAiPresenter).inContainerScope();\n },\n resolve(container) {\n return {\n presenter: container.resolve(PresenterAbstraction)\n };\n }\n});\n"],"names":["AiEnrichmentFeature","createFeature","container","AiImageEnrichmentEventHandler","AiImageEnrichmentFailedEventHandler","ReenrichFileGateway","ReenrichWithAiPresenter","PresenterAbstraction"],"mappings":";;;;;;AAOO,MAAMA,sBAAsBC,cAAc;IAC7C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG,qBAAqB,gBAAgB;QAIxDH,UAAU,QAAQ,CAACI,yBAAyB,gBAAgB;IAChE;IACA,SAAQJ,SAAS;QACb,OAAO;YACH,WAAWA,UAAU,OAAO,CAACK;QACjC;IACJ;AACJ"}
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const AiEnrichmentModule: () => React.JSX.Element;
@@ -0,0 +1,9 @@
1
+ import react from "react";
2
+ import { RegisterFeature } from "@webiny/app-admin";
3
+ import { AiEnrichmentFeature } from "./feature.js";
4
+ const AiEnrichmentModule = ()=>/*#__PURE__*/ react.createElement(RegisterFeature, {
5
+ feature: AiEnrichmentFeature
6
+ });
7
+ export { AiEnrichmentModule };
8
+
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules/AiEnrichment/index.js","sources":["../../../src/modules/AiEnrichment/index.tsx"],"sourcesContent":["import React from \"react\";\nimport { RegisterFeature } from \"@webiny/app-admin\";\nimport { AiEnrichmentFeature } from \"./feature.js\";\n\nexport const AiEnrichmentModule = () => {\n return <RegisterFeature feature={AiEnrichmentFeature} />;\n};\n"],"names":["AiEnrichmentModule","RegisterFeature","AiEnrichmentFeature"],"mappings":";;;AAIO,MAAMA,qBAAqB,IACvB,WAAP,GAAO,oBAACC,iBAAeA;QAAC,SAASC"}
@@ -1,4 +1,4 @@
1
- import { useWcp } from "@webiny/app-admin";
1
+ import { useFeatureFlags } from "@webiny/app-admin";
2
2
  import react from "react";
3
3
  import { FileManagerViewConfig } from "../../index.js";
4
4
  import { THREAT_SCAN } from "./constants.js";
@@ -21,8 +21,8 @@ const DisableTableCellWhileThreatScanInProgress = Table.Column.createDecorator((
21
21
  return /*#__PURE__*/ react.createElement(Original, props);
22
22
  });
23
23
  const EnterpriseModule = ()=>{
24
- const wcp = useWcp();
25
- if (!wcp.canUseFileManagerThreatDetection()) return null;
24
+ const featureFlags = useFeatureFlags();
25
+ if (!featureFlags.isEnabled("fileManager.threatDetection")) return null;
26
26
  return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(DisableFileWhileThreatScanInProgress, null), /*#__PURE__*/ react.createElement(DisableTableCellWhileThreatScanInProgress, null), /*#__PURE__*/ react.createElement(FileManagerViewConfig, null, /*#__PURE__*/ react.createElement(HandleWebsocketMessages, null)));
27
27
  };
28
28
  export { EnterpriseModule };
@@ -1 +1 @@
1
- {"version":3,"file":"modules/Enterprise/index.js","sources":["../../../src/modules/Enterprise/index.tsx"],"sourcesContent":["import { useWcp } from \"@webiny/app-admin\";\nimport React from \"react\";\nimport { FileManagerViewConfig } from \"~/index.js\";\nimport { THREAT_SCAN } from \"~/modules/Enterprise/constants.js\";\nimport { ThreatScanInProgressFileBody } from \"./components/ThreatScanInProgressFileBody.js\";\nimport { ThreatScanInProgressTableCell } from \"./components/ThreatScanInProgressTableCell.js\";\nimport { HandleWebsocketMessages } from \"./HandleWebsocketMessages.js\";\n\nconst { Grid, Table } = FileManagerViewConfig.Browser;\n\nconst DisableFileWhileThreatScanInProgress = Grid.Item.createDecorator(Original => {\n return function Item(props) {\n if (props.file.tags.includes(THREAT_SCAN.IN_PROGRESS)) {\n return <Original {...props} fileBody={<ThreatScanInProgressFileBody />} />;\n }\n return <Original {...props} />;\n };\n});\n\nconst DisableTableCellWhileThreatScanInProgress = Table.Column.createDecorator(Original => {\n return function TableCellActionsWhileThreatScanInProgress(props) {\n if (props.cell) {\n return (\n <Original\n {...props}\n cell={\n <ThreatScanInProgressTableCell>{props.cell}</ThreatScanInProgressTableCell>\n }\n />\n );\n }\n\n return <Original {...props} />;\n };\n});\n\nexport const EnterpriseModule = () => {\n const wcp = useWcp();\n\n if (!wcp.canUseFileManagerThreatDetection()) {\n return null;\n }\n\n return (\n <>\n <DisableFileWhileThreatScanInProgress />\n <DisableTableCellWhileThreatScanInProgress />\n <FileManagerViewConfig>\n <HandleWebsocketMessages />\n </FileManagerViewConfig>\n </>\n );\n};\n"],"names":["Grid","Table","FileManagerViewConfig","DisableFileWhileThreatScanInProgress","Original","props","THREAT_SCAN","ThreatScanInProgressFileBody","DisableTableCellWhileThreatScanInProgress","ThreatScanInProgressTableCell","EnterpriseModule","wcp","useWcp","HandleWebsocketMessages"],"mappings":";;;;;;;AAQA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,OAAAA,KAAK,EAAE,GAAGC,sBAAsB,OAAO;AAErD,MAAMC,uCAAuCH,KAAK,IAAI,CAAC,eAAe,CAACI,CAAAA,WAC5D,SAAcC,KAAK;QACtB,IAAIA,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAACC,YAAY,WAAW,GAChD,OAAO,WAAP,GAAO,oBAACF,UAAAA;YAAU,GAAGC,KAAK;YAAE,wBAAU,oBAACE,8BAA4BA;;QAEvE,OAAO,WAAP,GAAO,oBAACH,UAAaC;IACzB;AAGJ,MAAMG,4CAA4CP,MAAM,MAAM,CAAC,eAAe,CAACG,CAAAA,WACpE,SAAmDC,KAAK;QAC3D,IAAIA,MAAM,IAAI,EACV,OAAO,WAAP,GACI,oBAACD,UAAAA;YACI,GAAGC,KAAK;YACT,oBACI,oBAACI,+BAA6BA,MAAEJ,MAAM,IAAI;;QAM1D,OAAO,WAAP,GAAO,oBAACD,UAAaC;IACzB;AAGG,MAAMK,mBAAmB;IAC5B,MAAMC,MAAMC;IAEZ,IAAI,CAACD,IAAI,gCAAgC,IACrC,OAAO;IAGX,OAAO,WAAP,GACI,wDACI,oBAACR,sCAAoCA,OAAAA,WAAAA,GACrC,oBAACK,2CAAyCA,OAAAA,WAAAA,GAC1C,oBAACN,uBAAqBA,MAAAA,WAAAA,GAClB,oBAACW,yBAAuBA;AAIxC"}
1
+ {"version":3,"file":"modules/Enterprise/index.js","sources":["../../../src/modules/Enterprise/index.tsx"],"sourcesContent":["import { useFeatureFlags } from \"@webiny/app-admin\";\nimport React from \"react\";\nimport { FileManagerViewConfig } from \"~/index.js\";\nimport { THREAT_SCAN } from \"~/modules/Enterprise/constants.js\";\nimport { ThreatScanInProgressFileBody } from \"./components/ThreatScanInProgressFileBody.js\";\nimport { ThreatScanInProgressTableCell } from \"./components/ThreatScanInProgressTableCell.js\";\nimport { HandleWebsocketMessages } from \"./HandleWebsocketMessages.js\";\n\nconst { Grid, Table } = FileManagerViewConfig.Browser;\n\nconst DisableFileWhileThreatScanInProgress = Grid.Item.createDecorator(Original => {\n return function Item(props) {\n if (props.file.tags.includes(THREAT_SCAN.IN_PROGRESS)) {\n return <Original {...props} fileBody={<ThreatScanInProgressFileBody />} />;\n }\n return <Original {...props} />;\n };\n});\n\nconst DisableTableCellWhileThreatScanInProgress = Table.Column.createDecorator(Original => {\n return function TableCellActionsWhileThreatScanInProgress(props) {\n if (props.cell) {\n return (\n <Original\n {...props}\n cell={\n <ThreatScanInProgressTableCell>{props.cell}</ThreatScanInProgressTableCell>\n }\n />\n );\n }\n\n return <Original {...props} />;\n };\n});\n\nexport const EnterpriseModule = () => {\n const featureFlags = useFeatureFlags();\n\n if (!featureFlags.isEnabled(\"fileManager.threatDetection\")) {\n return null;\n }\n\n return (\n <>\n <DisableFileWhileThreatScanInProgress />\n <DisableTableCellWhileThreatScanInProgress />\n <FileManagerViewConfig>\n <HandleWebsocketMessages />\n </FileManagerViewConfig>\n </>\n );\n};\n"],"names":["Grid","Table","FileManagerViewConfig","DisableFileWhileThreatScanInProgress","Original","props","THREAT_SCAN","ThreatScanInProgressFileBody","DisableTableCellWhileThreatScanInProgress","ThreatScanInProgressTableCell","EnterpriseModule","featureFlags","useFeatureFlags","HandleWebsocketMessages"],"mappings":";;;;;;;AAQA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,OAAAA,KAAK,EAAE,GAAGC,sBAAsB,OAAO;AAErD,MAAMC,uCAAuCH,KAAK,IAAI,CAAC,eAAe,CAACI,CAAAA,WAC5D,SAAcC,KAAK;QACtB,IAAIA,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAACC,YAAY,WAAW,GAChD,OAAO,WAAP,GAAO,oBAACF,UAAAA;YAAU,GAAGC,KAAK;YAAE,wBAAU,oBAACE,8BAA4BA;;QAEvE,OAAO,WAAP,GAAO,oBAACH,UAAaC;IACzB;AAGJ,MAAMG,4CAA4CP,MAAM,MAAM,CAAC,eAAe,CAACG,CAAAA,WACpE,SAAmDC,KAAK;QAC3D,IAAIA,MAAM,IAAI,EACV,OAAO,WAAP,GACI,oBAACD,UAAAA;YACI,GAAGC,KAAK;YACT,oBACI,oBAACI,+BAA6BA,MAAEJ,MAAM,IAAI;;QAM1D,OAAO,WAAP,GAAO,oBAACD,UAAaC;IACzB;AAGG,MAAMK,mBAAmB;IAC5B,MAAMC,eAAeC;IAErB,IAAI,CAACD,aAAa,SAAS,CAAC,gCACxB,OAAO;IAGX,OAAO,WAAP,GACI,wDACI,oBAACR,sCAAoCA,OAAAA,WAAAA,GACrC,oBAACK,2CAAyCA,OAAAA,WAAAA,GAC1C,oBAACN,uBAAqBA,MAAAA,WAAAA,GAClB,oBAACW,yBAAuBA;AAIxC"}
@@ -0,0 +1,26 @@
1
+ import { CmsFieldEditorGroupModifier } from "@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js";
2
+ import type { ICmsFieldEditorFormBuilder, ICmsFieldEditorContext } from "@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js";
3
+ import type { CmsModelField } from "@webiny/app-headless-cms-common/types/index.js";
4
+ /**
5
+ * Adds Asset-specific options to the field settings form in the content-model
6
+ * editor: an "Images only" toggle (parity with the File field) and an optional
7
+ * "Accepted file types" list. Both are honored by the asset picker renderers
8
+ * (`settings.imagesOnly` / `settings.accept`).
9
+ *
10
+ * Applies to the Asset field, which the editor resolves to the `"asset"` field
11
+ * type via `matches()` even though it is stored as an `object`.
12
+ */
13
+ declare class AssetFieldSettingsModifierImpl implements CmsFieldEditorGroupModifier.Interface {
14
+ group: string;
15
+ shouldApply(context: ICmsFieldEditorContext): boolean;
16
+ modifyForm(form: ICmsFieldEditorFormBuilder): void;
17
+ mapToForm(field: CmsModelField): {
18
+ imagesOnly: boolean;
19
+ accept: any;
20
+ };
21
+ mapFromForm(formData: Record<string, any>, field: CmsModelField): void;
22
+ }
23
+ export declare const AssetFieldSettingsModifier: typeof AssetFieldSettingsModifierImpl & {
24
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js").ICmsFieldEditorGroupModifier>;
25
+ };
26
+ export {};
@@ -0,0 +1,39 @@
1
+ import { CmsFieldEditorGroupModifier } from "@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js";
2
+ class AssetFieldSettingsModifierImpl {
3
+ shouldApply(context) {
4
+ return "asset" === context.fieldType.type;
5
+ }
6
+ modifyForm(form) {
7
+ form.fields((fields)=>({
8
+ imagesOnly: fields.boolean().label("Images only").description("Allow only images to be selected").renderer("switch").defaultValue(false),
9
+ accept: fields.text().list().label("Accepted file types").description("MIME types or extensions to allow (e.g. image/png, application/pdf). Leave empty to allow all.").renderer("tags").defaultValue([])
10
+ }));
11
+ form.layout((layout)=>[
12
+ layout.row("imagesOnly"),
13
+ layout.row("accept")
14
+ ]);
15
+ }
16
+ mapToForm(field) {
17
+ return {
18
+ imagesOnly: field.settings?.imagesOnly ?? false,
19
+ accept: field.settings?.accept ?? []
20
+ };
21
+ }
22
+ mapFromForm(formData, field) {
23
+ if (!field.settings) field.settings = {};
24
+ field.settings.imagesOnly = formData.imagesOnly;
25
+ const accept = Array.isArray(formData.accept) ? formData.accept.filter((t)=>"string" == typeof t && t.trim().length > 0) : [];
26
+ if (accept.length > 0) field.settings.accept = accept;
27
+ else delete field.settings.accept;
28
+ }
29
+ constructor(){
30
+ this.group = "general";
31
+ }
32
+ }
33
+ const AssetFieldSettingsModifier = CmsFieldEditorGroupModifier.createImplementation({
34
+ implementation: AssetFieldSettingsModifierImpl,
35
+ dependencies: []
36
+ });
37
+ export { AssetFieldSettingsModifier };
38
+
39
+ //# sourceMappingURL=AssetFieldSettingsModifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.js","sources":["../../../../src/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.ts"],"sourcesContent":["import { CmsFieldEditorGroupModifier } from \"@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js\";\nimport type {\n ICmsFieldEditorFormBuilder,\n ICmsFieldEditorContext\n} from \"@webiny/app-headless-cms/presentation/fieldEditor/abstractions.js\";\nimport type { CmsModelField } from \"@webiny/app-headless-cms-common/types/index.js\";\n\n/**\n * Adds Asset-specific options to the field settings form in the content-model\n * editor: an \"Images only\" toggle (parity with the File field) and an optional\n * \"Accepted file types\" list. Both are honored by the asset picker renderers\n * (`settings.imagesOnly` / `settings.accept`).\n *\n * Applies to the Asset field, which the editor resolves to the `\"asset\"` field\n * type via `matches()` even though it is stored as an `object`.\n */\nclass AssetFieldSettingsModifierImpl implements CmsFieldEditorGroupModifier.Interface {\n group = \"general\";\n\n shouldApply(context: ICmsFieldEditorContext) {\n return context.fieldType.type === \"asset\";\n }\n\n modifyForm(form: ICmsFieldEditorFormBuilder) {\n form.fields(fields => ({\n imagesOnly: fields\n .boolean()\n .label(\"Images only\")\n .description(\"Allow only images to be selected\")\n .renderer(\"switch\")\n .defaultValue(false),\n accept: fields\n .text()\n .list()\n .label(\"Accepted file types\")\n .description(\n \"MIME types or extensions to allow (e.g. image/png, application/pdf). Leave empty to allow all.\"\n )\n .renderer(\"tags\")\n .defaultValue([])\n }));\n form.layout(layout => [layout.row(\"imagesOnly\"), layout.row(\"accept\")]);\n }\n\n mapToForm(field: CmsModelField) {\n return {\n imagesOnly: field.settings?.imagesOnly ?? false,\n accept: field.settings?.accept ?? []\n };\n }\n\n mapFromForm(formData: Record<string, any>, field: CmsModelField) {\n if (!field.settings) {\n field.settings = {};\n }\n field.settings.imagesOnly = formData.imagesOnly;\n const accept = Array.isArray(formData.accept)\n ? formData.accept.filter((t: unknown) => typeof t === \"string\" && t.trim().length > 0)\n : [];\n if (accept.length > 0) {\n field.settings.accept = accept;\n } else {\n delete field.settings.accept;\n }\n }\n}\n\nexport const AssetFieldSettingsModifier = CmsFieldEditorGroupModifier.createImplementation({\n implementation: AssetFieldSettingsModifierImpl,\n dependencies: []\n});\n"],"names":["AssetFieldSettingsModifierImpl","context","form","fields","layout","field","formData","accept","Array","t","AssetFieldSettingsModifier","CmsFieldEditorGroupModifier"],"mappings":";AAgBA,MAAMA;IAGF,YAAYC,OAA+B,EAAE;QACzC,OAAOA,AAA2B,YAA3BA,QAAQ,SAAS,CAAC,IAAI;IACjC;IAEA,WAAWC,IAAgC,EAAE;QACzCA,KAAK,MAAM,CAACC,CAAAA,SAAW;gBACnB,YAAYA,OACP,OAAO,GACP,KAAK,CAAC,eACN,WAAW,CAAC,oCACZ,QAAQ,CAAC,UACT,YAAY,CAAC;gBAClB,QAAQA,OACH,IAAI,GACJ,IAAI,GACJ,KAAK,CAAC,uBACN,WAAW,CACR,kGAEH,QAAQ,CAAC,QACT,YAAY,CAAC,EAAE;YACxB;QACAD,KAAK,MAAM,CAACE,CAAAA,SAAU;gBAACA,OAAO,GAAG,CAAC;gBAAeA,OAAO,GAAG,CAAC;aAAU;IAC1E;IAEA,UAAUC,KAAoB,EAAE;QAC5B,OAAO;YACH,YAAYA,MAAM,QAAQ,EAAE,cAAc;YAC1C,QAAQA,MAAM,QAAQ,EAAE,UAAU,EAAE;QACxC;IACJ;IAEA,YAAYC,QAA6B,EAAED,KAAoB,EAAE;QAC7D,IAAI,CAACA,MAAM,QAAQ,EACfA,MAAM,QAAQ,GAAG,CAAC;QAEtBA,MAAM,QAAQ,CAAC,UAAU,GAAGC,SAAS,UAAU;QAC/C,MAAMC,SAASC,MAAM,OAAO,CAACF,SAAS,MAAM,IACtCA,SAAS,MAAM,CAAC,MAAM,CAAC,CAACG,IAAe,AAAa,YAAb,OAAOA,KAAkBA,EAAE,IAAI,GAAG,MAAM,GAAG,KAClF,EAAE;QACR,IAAIF,OAAO,MAAM,GAAG,GAChBF,MAAM,QAAQ,CAAC,MAAM,GAAGE;aAExB,OAAOF,MAAM,QAAQ,CAAC,MAAM;IAEpC;;aA/CA,KAAK,GAAG;;AAgDZ;AAEO,MAAMK,6BAA6BC,4BAA4B,oBAAoB,CAAC;IACvF,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,34 @@
1
+ import React from "react";
2
+ import { CmsFieldType } from "@webiny/app-headless-cms/presentation/fieldTypes/abstractions.js";
3
+ import type { CmsModelField } from "@webiny/app-headless-cms-common/types/index.js";
4
+ /**
5
+ * Palette entry for the Asset field. It is stored as an `object` field (so it reuses
6
+ * the object GraphQL/storage machinery); `createField()` therefore emits `type:
7
+ * "object"` with the asset renderer, and the API normalizer stamps the canonical
8
+ * nested schema on save. `matches()` lets the field editor resolve this descriptor
9
+ * for an asset field even though its stored type is `object`.
10
+ */
11
+ declare class AssetFieldTypeImpl implements CmsFieldType.Interface {
12
+ type: string;
13
+ label: string;
14
+ description: string;
15
+ icon: React.JSX.Element;
16
+ allowList: boolean;
17
+ listLabel: string;
18
+ allowPredefinedValues: boolean;
19
+ validators: string[];
20
+ listValidators: string[];
21
+ matches(field: CmsModelField): boolean;
22
+ createField(): {
23
+ type: string;
24
+ validation: never[];
25
+ renderer: {
26
+ name: string;
27
+ };
28
+ settings: {};
29
+ };
30
+ }
31
+ export declare const AssetFieldType: typeof AssetFieldTypeImpl & {
32
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/app-headless-cms/presentation/fieldTypes/abstractions.js").ICmsFieldType>;
33
+ };
34
+ export {};
@@ -0,0 +1,42 @@
1
+ import react from "react";
2
+ import { ReactComponent } from "@webiny/icons/collections.svg";
3
+ import { CmsFieldType } from "@webiny/app-headless-cms/presentation/fieldTypes/abstractions.js";
4
+ import { isAssetField } from "./isAssetField.js";
5
+ class AssetFieldTypeImpl {
6
+ matches(field) {
7
+ return isAssetField(field);
8
+ }
9
+ createField() {
10
+ return {
11
+ type: "asset",
12
+ validation: [],
13
+ renderer: {
14
+ name: "asset-input"
15
+ },
16
+ settings: {}
17
+ };
18
+ }
19
+ constructor(){
20
+ this.type = "asset";
21
+ this.label = "Asset";
22
+ this.description = "Images, videos, and documents — with per-usage cropping and focal point.";
23
+ this.icon = /*#__PURE__*/ react.createElement(ReactComponent, null);
24
+ this.allowList = true;
25
+ this.listLabel = "Use as a list of assets or a gallery";
26
+ this.allowPredefinedValues = false;
27
+ this.validators = [
28
+ "required"
29
+ ];
30
+ this.listValidators = [
31
+ "minLength",
32
+ "maxLength"
33
+ ];
34
+ }
35
+ }
36
+ const AssetFieldType = CmsFieldType.createImplementation({
37
+ implementation: AssetFieldTypeImpl,
38
+ dependencies: []
39
+ });
40
+ export { AssetFieldType };
41
+
42
+ //# sourceMappingURL=AssetFieldType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules/HeadlessCms/fieldType/AssetFieldType.js","sources":["../../../../src/modules/HeadlessCms/fieldType/AssetFieldType.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as AssetIcon } from \"@webiny/icons/collections.svg\";\nimport { CmsFieldType } from \"@webiny/app-headless-cms/presentation/fieldTypes/abstractions.js\";\nimport type { CmsModelField } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport { isAssetField } from \"./isAssetField.js\";\n\n/**\n * Palette entry for the Asset field. It is stored as an `object` field (so it reuses\n * the object GraphQL/storage machinery); `createField()` therefore emits `type:\n * \"object\"` with the asset renderer, and the API normalizer stamps the canonical\n * nested schema on save. `matches()` lets the field editor resolve this descriptor\n * for an asset field even though its stored type is `object`.\n */\nclass AssetFieldTypeImpl implements CmsFieldType.Interface {\n type = \"asset\";\n label = \"Asset\";\n description = \"Images, videos, and documents — with per-usage cropping and focal point.\";\n icon = <AssetIcon />;\n allowList = true;\n listLabel = \"Use as a list of assets or a gallery\";\n allowPredefinedValues = false;\n validators = [\"required\"];\n listValidators = [\"minLength\", \"maxLength\"];\n\n matches(field: CmsModelField) {\n return isAssetField(field);\n }\n\n createField() {\n return {\n type: \"asset\",\n validation: [],\n renderer: { name: \"asset-input\" },\n settings: {}\n };\n }\n}\n\nexport const AssetFieldType = CmsFieldType.createImplementation({\n implementation: AssetFieldTypeImpl,\n dependencies: []\n});\n"],"names":["AssetFieldTypeImpl","field","isAssetField","AssetIcon","AssetFieldType","CmsFieldType"],"mappings":";;;;AAaA,MAAMA;IAWF,QAAQC,KAAoB,EAAE;QAC1B,OAAOC,aAAaD;IACxB;IAEA,cAAc;QACV,OAAO;YACH,MAAM;YACN,YAAY,EAAE;YACd,UAAU;gBAAE,MAAM;YAAc;YAChC,UAAU,CAAC;QACf;IACJ;;aArBA,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAAG;aACd,IAAI,GAAG,WAAP,GAAO,oBAACE,gBAASA;aACjB,SAAS,GAAG;aACZ,SAAS,GAAG;aACZ,qBAAqB,GAAG;aACxB,UAAU,GAAG;YAAC;SAAW;aACzB,cAAc,GAAG;YAAC;YAAa;SAAY;;AAc/C;AAEO,MAAMC,iBAAiBC,aAAa,oBAAoB,CAAC;IAC5D,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,21 @@
1
+ import { type IFieldTypeFactory } from "@webiny/app-admin/features/formModel/abstractions.js";
2
+ import { FieldBuilder } from "@webiny/app-admin/features/formModel/FieldBuilder.js";
3
+ export declare class AssetFieldBuilder extends FieldBuilder<"asset"> {
4
+ constructor();
5
+ list(): this;
6
+ imagesOnly(): this;
7
+ accept(mimeTypes: string[]): this;
8
+ }
9
+ declare class AssetFieldTypeFactory implements IFieldTypeFactory {
10
+ readonly type = "asset";
11
+ create(): AssetFieldBuilder;
12
+ }
13
+ export declare const AssetFormFieldType: typeof AssetFieldTypeFactory & {
14
+ __abstraction: import("@webiny/di").Abstraction<IFieldTypeFactory>;
15
+ };
16
+ declare module "@webiny/app-admin/features/formModel/abstractions.js" {
17
+ interface IFieldBuilderRegistry {
18
+ asset(): AssetFieldBuilder;
19
+ }
20
+ }
21
+ export {};
@@ -0,0 +1,42 @@
1
+ import { FieldType } from "@webiny/app-admin/features/formModel/abstractions.js";
2
+ import { FieldBuilder } from "@webiny/app-admin/features/formModel/FieldBuilder.js";
3
+ class AssetFieldBuilder extends FieldBuilder {
4
+ constructor(){
5
+ super("asset");
6
+ this._config.renderer = "cmsAssetPicker";
7
+ }
8
+ list() {
9
+ super.list();
10
+ if ("cmsAssetPicker" === this._config.renderer) this._config.renderer = "cmsMultiAssetPicker";
11
+ return this;
12
+ }
13
+ imagesOnly() {
14
+ this._config.rendererSettings = {
15
+ ...this._config.rendererSettings,
16
+ imagesOnly: true
17
+ };
18
+ return this;
19
+ }
20
+ accept(mimeTypes) {
21
+ this._config.rendererSettings = {
22
+ ...this._config.rendererSettings,
23
+ accept: mimeTypes
24
+ };
25
+ return this;
26
+ }
27
+ }
28
+ class AssetFieldTypeFactory {
29
+ create() {
30
+ return new AssetFieldBuilder();
31
+ }
32
+ constructor(){
33
+ this.type = "asset";
34
+ }
35
+ }
36
+ const AssetFormFieldType = FieldType.createImplementation({
37
+ implementation: AssetFieldTypeFactory,
38
+ dependencies: []
39
+ });
40
+ export { AssetFieldBuilder, AssetFormFieldType };
41
+
42
+ //# sourceMappingURL=AssetFormFieldType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules/HeadlessCms/fieldType/AssetFormFieldType.js","sources":["../../../../src/modules/HeadlessCms/fieldType/AssetFormFieldType.ts"],"sourcesContent":["import {\n FieldType,\n type IFieldTypeFactory\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { FieldBuilder } from \"@webiny/app-admin/features/formModel/FieldBuilder.js\";\n\nexport class AssetFieldBuilder extends FieldBuilder<\"asset\"> {\n constructor() {\n super(\"asset\");\n this._config.renderer = \"cmsAssetPicker\";\n }\n\n override list(): this {\n super.list();\n if (this._config.renderer === \"cmsAssetPicker\") {\n this._config.renderer = \"cmsMultiAssetPicker\";\n }\n return this;\n }\n\n imagesOnly(): this {\n this._config.rendererSettings = { ...this._config.rendererSettings, imagesOnly: true };\n return this;\n }\n\n accept(mimeTypes: string[]): this {\n this._config.rendererSettings = { ...this._config.rendererSettings, accept: mimeTypes };\n return this;\n }\n}\n\nclass AssetFieldTypeFactory implements IFieldTypeFactory {\n readonly type = \"asset\";\n create() {\n return new AssetFieldBuilder();\n }\n}\n\nexport const AssetFormFieldType = FieldType.createImplementation({\n implementation: AssetFieldTypeFactory,\n dependencies: []\n});\n\ndeclare module \"@webiny/app-admin/features/formModel/abstractions.js\" {\n interface IFieldBuilderRegistry {\n asset(): AssetFieldBuilder;\n }\n}\n"],"names":["AssetFieldBuilder","FieldBuilder","mimeTypes","AssetFieldTypeFactory","AssetFormFieldType","FieldType"],"mappings":";;AAMO,MAAMA,0BAA0BC;IACnC,aAAc;QACV,KAAK,CAAC;QACN,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG;IAC5B;IAES,OAAa;QAClB,KAAK,CAAC;QACN,IAAI,AAA0B,qBAA1B,IAAI,CAAC,OAAO,CAAC,QAAQ,EACrB,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG;QAE5B,OAAO,IAAI;IACf;IAEA,aAAmB;QACf,IAAI,CAAC,OAAO,CAAC,gBAAgB,GAAG;YAAE,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB;YAAE,YAAY;QAAK;QACrF,OAAO,IAAI;IACf;IAEA,OAAOC,SAAmB,EAAQ;QAC9B,IAAI,CAAC,OAAO,CAAC,gBAAgB,GAAG;YAAE,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB;YAAE,QAAQA;QAAU;QACtF,OAAO,IAAI;IACf;AACJ;AAEA,MAAMC;IAEF,SAAS;QACL,OAAO,IAAIH;IACf;;aAHS,IAAI,GAAG;;AAIpB;AAEO,MAAMI,qBAAqBC,UAAU,oBAAoB,CAAC;IAC7D,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,15 @@
1
+ import { CmsFieldRenderer } from "@webiny/app-headless-cms/presentation/fieldRenderers/abstractions.js";
2
+ import type { CmsModelField } from "@webiny/app-headless-cms-common/types/index.js";
3
+ declare class AssetInputRendererImpl implements CmsFieldRenderer.Interface {
4
+ rendererName: string;
5
+ formRenderer: string;
6
+ name: string;
7
+ description: string;
8
+ canUse({ field }: {
9
+ field: CmsModelField;
10
+ }): boolean;
11
+ }
12
+ export declare const AssetInputRenderer: typeof AssetInputRendererImpl & {
13
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/app-headless-cms/presentation/fieldRenderers/abstractions.js").ICmsFieldRenderer>;
14
+ };
15
+ export {};