@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
package/app.js CHANGED
@@ -25,6 +25,8 @@ import { FileModelProviderFeature } from "./features/fileModel/index.js";
25
25
  import { FileFieldTypeFeature } from "./modules/HeadlessCms/fieldType/feature.js";
26
26
  import { CmsFilePickerRenderer } from "./presentation/fieldRenderers/CmsFilePickerRenderer.js";
27
27
  import { CmsMultiFilePickerRenderer } from "./presentation/fieldRenderers/CmsMultiFilePickerRenderer.js";
28
+ import { CmsAssetPickerRenderer } from "./presentation/fieldRenderers/CmsAssetPickerRenderer.js";
29
+ import { CmsMultiAssetPickerRenderer } from "./presentation/fieldRenderers/CmsMultiAssetPickerRenderer.js";
28
30
  const FileManager = ()=>/*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(RegisterFeature, {
29
31
  feature: FileModelProviderFeature
30
32
  }), /*#__PURE__*/ react.createElement(RegisterFeature, {
@@ -60,6 +62,12 @@ const FileManager = ()=>/*#__PURE__*/ react.createElement(react.Fragment, null,
60
62
  }), /*#__PURE__*/ react.createElement(AdminConfig.Form.FieldRenderer, {
61
63
  name: "cmsMultiFilePicker",
62
64
  component: CmsMultiFilePickerRenderer
65
+ }), /*#__PURE__*/ react.createElement(AdminConfig.Form.FieldRenderer, {
66
+ name: "cmsAssetPicker",
67
+ component: CmsAssetPickerRenderer
68
+ }), /*#__PURE__*/ react.createElement(AdminConfig.Form.FieldRenderer, {
69
+ name: "cmsMultiAssetPicker",
70
+ component: CmsMultiAssetPickerRenderer
63
71
  })), /*#__PURE__*/ react.createElement(FileManagerRoutes, null), /*#__PURE__*/ react.createElement(SettingsModule, null), /*#__PURE__*/ react.createElement(FileManagerRendererDecorator, null), /*#__PURE__*/ react.createElement(DefaultFileManagerConfig, null), /*#__PURE__*/ react.createElement(RegisterFeature, {
64
72
  feature: FileFieldTypeFeature
65
73
  }), /*#__PURE__*/ react.createElement(EnterpriseModule, null), /*#__PURE__*/ react.createElement(AiEnrichmentModule, null), /*#__PURE__*/ react.createElement(SecurityPermissions, null), /*#__PURE__*/ react.createElement(FileUrlFormatterModule, null));
package/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sources":["../src/app.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdminConfig, RegisterFeature } from \"@webiny/app-admin\";\nimport { FolderTreeFieldRenderer } from \"@webiny/app-aco/presentation/folderTree/FolderTreeFieldRenderer.js\";\nimport { SettingsModule } from \"~/modules/Settings/index.js\";\nimport { FileModelModule } from \"~/modules/FileModelModule.js\";\nimport { DefaultFileManagerConfig } from \"~/presentation/config/DefaultFileManagerConfig.js\";\nimport { EnterpriseModule } from \"~/modules/Enterprise/index.js\";\nimport { AiEnrichmentModule } from \"~/modules/AiEnrichment/index.js\";\nimport { SecurityPermissions } from \"./modules/SecurityPermissions.js\";\nimport { FileUrlFormatterModule } from \"./modules/FileUrlFormatter.js\";\nimport { FmPermissionsFeature } from \"~/features/permissions/feature.js\";\nimport { GetFileFeature } from \"~/features/getFile/feature.js\";\nimport { ResolveImageToolFeature } from \"~/features/resolveImageTool/feature.js\";\nimport { ListFilesFeature } from \"~/features/listFiles/index.js\";\nimport { UpdateFileFeature } from \"~/features/updateFile/index.js\";\nimport { DeleteFileFeature } from \"~/features/deleteFile/index.js\";\nimport { FileUploaderFeature } from \"~/features/fileUploader/index.js\";\nimport { ListTagsFeature } from \"~/features/tags/index.js\";\nimport { GetSettingsFeature } from \"~/features/settings/index.js\";\nimport { SharedCacheFeature } from \"~/features/shared/index.js\";\nimport { FileManagerPresenterFeature } from \"~/presentation/FileList/index.js\";\nimport { FileManagerRoutes } from \"~/modules/FileManagerRoutes.js\";\nimport { FileManagerRendererDecorator } from \"~/presentation/FileManager/FileManagerRenderer.js\";\nimport { FileModelProviderFeature } from \"~/features/fileModel/index.js\";\nimport { FileFieldTypeFeature } from \"~/modules/HeadlessCms/fieldType/feature.js\";\nimport { CmsFilePickerRenderer } from \"~/presentation/fieldRenderers/CmsFilePickerRenderer.js\";\nimport { CmsMultiFilePickerRenderer } from \"~/presentation/fieldRenderers/CmsMultiFilePickerRenderer.js\";\n\nexport const FileManager = () => {\n return (\n <>\n {/* Headless features. */}\n <RegisterFeature feature={FileModelProviderFeature} />\n <RegisterFeature feature={SharedCacheFeature} />\n <RegisterFeature feature={ListFilesFeature} />\n <RegisterFeature feature={GetFileFeature} />\n <RegisterFeature feature={UpdateFileFeature} />\n <RegisterFeature feature={DeleteFileFeature} />\n <RegisterFeature feature={FileUploaderFeature} />\n <RegisterFeature feature={ListTagsFeature} />\n <RegisterFeature feature={GetSettingsFeature} />\n <RegisterFeature feature={FmPermissionsFeature} />\n <RegisterFeature feature={GetFileFeature} />\n <RegisterFeature feature={ResolveImageToolFeature} />\n <FileModelModule />\n {/* Presentation features. */}\n <RegisterFeature feature={FileManagerPresenterFeature} />\n {/* Field renderers. */}\n <AdminConfig>\n <AdminConfig.Form.FieldRenderer\n name={\"folderTree\"}\n component={FolderTreeFieldRenderer}\n />\n <AdminConfig.Form.FieldRenderer\n name={\"cmsFilePicker\"}\n component={CmsFilePickerRenderer}\n />\n <AdminConfig.Form.FieldRenderer\n name={\"cmsMultiFilePicker\"}\n component={CmsMultiFilePickerRenderer}\n />\n </AdminConfig>\n {/* Legacy modules. */}\n <FileManagerRoutes />\n <SettingsModule />\n <FileManagerRendererDecorator />\n <DefaultFileManagerConfig />\n <RegisterFeature feature={FileFieldTypeFeature} />\n <EnterpriseModule />\n <AiEnrichmentModule />\n <SecurityPermissions />\n <FileUrlFormatterModule />\n </>\n );\n};\n"],"names":["FileManager","RegisterFeature","FileModelProviderFeature","SharedCacheFeature","ListFilesFeature","GetFileFeature","UpdateFileFeature","DeleteFileFeature","FileUploaderFeature","ListTagsFeature","GetSettingsFeature","FmPermissionsFeature","ResolveImageToolFeature","FileModelModule","FileManagerPresenterFeature","AdminConfig","FolderTreeFieldRenderer","CmsFilePickerRenderer","CmsMultiFilePickerRenderer","FileManagerRoutes","SettingsModule","FileManagerRendererDecorator","DefaultFileManagerConfig","FileFieldTypeFeature","EnterpriseModule","AiEnrichmentModule","SecurityPermissions","FileUrlFormatterModule"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAMA,cAAc,IAChB,WAAP,GACI,wDAEI,oBAACC,iBAAeA;QAAC,SAASC;sBAC1B,oBAACD,iBAAeA;QAAC,SAASE;sBAC1B,oBAACF,iBAAeA;QAAC,SAASG;sBAC1B,oBAACH,iBAAeA;QAAC,SAASI;sBAC1B,oBAACJ,iBAAeA;QAAC,SAASK;sBAC1B,oBAACL,iBAAeA;QAAC,SAASM;sBAC1B,oBAACN,iBAAeA;QAAC,SAASO;sBAC1B,oBAACP,iBAAeA;QAAC,SAASQ;sBAC1B,oBAACR,iBAAeA;QAAC,SAASS;sBAC1B,oBAACT,iBAAeA;QAAC,SAASU;sBAC1B,oBAACV,iBAAeA;QAAC,SAASI;sBAC1B,oBAACJ,iBAAeA;QAAC,SAASW;sBAC1B,oBAACC,iBAAeA,OAAAA,WAAAA,GAEhB,oBAACZ,iBAAeA;QAAC,SAASa;sBAE1B,oBAACC,aAAWA,MAAAA,WAAAA,GACR,oBAACA,YAAY,IAAI,CAAC,aAAa;QAC3B,MAAM;QACN,WAAWC;sBAEf,oBAACD,YAAY,IAAI,CAAC,aAAa;QAC3B,MAAM;QACN,WAAWE;sBAEf,oBAACF,YAAY,IAAI,CAAC,aAAa;QAC3B,MAAM;QACN,WAAWG;uBAInB,oBAACC,mBAAiBA,OAAAA,WAAAA,GAClB,oBAACC,gBAAcA,OAAAA,WAAAA,GACf,oBAACC,8BAA4BA,OAAAA,WAAAA,GAC7B,oBAACC,0BAAwBA,OAAAA,WAAAA,GACzB,oBAACrB,iBAAeA;QAAC,SAASsB;sBAC1B,oBAACC,kBAAgBA,OAAAA,WAAAA,GACjB,oBAACC,oBAAkBA,OAAAA,WAAAA,GACnB,oBAACC,qBAAmBA,OAAAA,WAAAA,GACpB,oBAACC,wBAAsBA"}
1
+ {"version":3,"file":"app.js","sources":["../src/app.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdminConfig, RegisterFeature } from \"@webiny/app-admin\";\nimport { FolderTreeFieldRenderer } from \"@webiny/app-aco/presentation/folderTree/FolderTreeFieldRenderer.js\";\nimport { SettingsModule } from \"~/modules/Settings/index.js\";\nimport { FileModelModule } from \"~/modules/FileModelModule.js\";\nimport { DefaultFileManagerConfig } from \"~/presentation/config/DefaultFileManagerConfig.js\";\nimport { EnterpriseModule } from \"~/modules/Enterprise/index.js\";\nimport { AiEnrichmentModule } from \"~/modules/AiEnrichment/index.js\";\nimport { SecurityPermissions } from \"./modules/SecurityPermissions.js\";\nimport { FileUrlFormatterModule } from \"./modules/FileUrlFormatter.js\";\nimport { FmPermissionsFeature } from \"~/features/permissions/feature.js\";\nimport { GetFileFeature } from \"~/features/getFile/feature.js\";\nimport { ResolveImageToolFeature } from \"~/features/resolveImageTool/feature.js\";\nimport { ListFilesFeature } from \"~/features/listFiles/index.js\";\nimport { UpdateFileFeature } from \"~/features/updateFile/index.js\";\nimport { DeleteFileFeature } from \"~/features/deleteFile/index.js\";\nimport { FileUploaderFeature } from \"~/features/fileUploader/index.js\";\nimport { ListTagsFeature } from \"~/features/tags/index.js\";\nimport { GetSettingsFeature } from \"~/features/settings/index.js\";\nimport { SharedCacheFeature } from \"~/features/shared/index.js\";\nimport { FileManagerPresenterFeature } from \"~/presentation/FileList/index.js\";\nimport { FileManagerRoutes } from \"~/modules/FileManagerRoutes.js\";\nimport { FileManagerRendererDecorator } from \"~/presentation/FileManager/FileManagerRenderer.js\";\nimport { FileModelProviderFeature } from \"~/features/fileModel/index.js\";\nimport { FileFieldTypeFeature } from \"~/modules/HeadlessCms/fieldType/feature.js\";\nimport { CmsFilePickerRenderer } from \"~/presentation/fieldRenderers/CmsFilePickerRenderer.js\";\nimport { CmsMultiFilePickerRenderer } from \"~/presentation/fieldRenderers/CmsMultiFilePickerRenderer.js\";\nimport { CmsAssetPickerRenderer } from \"~/presentation/fieldRenderers/CmsAssetPickerRenderer.js\";\nimport { CmsMultiAssetPickerRenderer } from \"~/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.js\";\n\nexport const FileManager = () => {\n return (\n <>\n {/* Headless features. */}\n <RegisterFeature feature={FileModelProviderFeature} />\n <RegisterFeature feature={SharedCacheFeature} />\n <RegisterFeature feature={ListFilesFeature} />\n <RegisterFeature feature={GetFileFeature} />\n <RegisterFeature feature={UpdateFileFeature} />\n <RegisterFeature feature={DeleteFileFeature} />\n <RegisterFeature feature={FileUploaderFeature} />\n <RegisterFeature feature={ListTagsFeature} />\n <RegisterFeature feature={GetSettingsFeature} />\n <RegisterFeature feature={FmPermissionsFeature} />\n <RegisterFeature feature={GetFileFeature} />\n <RegisterFeature feature={ResolveImageToolFeature} />\n <FileModelModule />\n {/* Presentation features. */}\n <RegisterFeature feature={FileManagerPresenterFeature} />\n {/* Field renderers. */}\n <AdminConfig>\n <AdminConfig.Form.FieldRenderer\n name={\"folderTree\"}\n component={FolderTreeFieldRenderer}\n />\n <AdminConfig.Form.FieldRenderer\n name={\"cmsFilePicker\"}\n component={CmsFilePickerRenderer}\n />\n <AdminConfig.Form.FieldRenderer\n name={\"cmsMultiFilePicker\"}\n component={CmsMultiFilePickerRenderer}\n />\n <AdminConfig.Form.FieldRenderer\n name={\"cmsAssetPicker\"}\n component={CmsAssetPickerRenderer}\n />\n <AdminConfig.Form.FieldRenderer\n name={\"cmsMultiAssetPicker\"}\n component={CmsMultiAssetPickerRenderer}\n />\n </AdminConfig>\n {/* Legacy modules. */}\n <FileManagerRoutes />\n <SettingsModule />\n <FileManagerRendererDecorator />\n <DefaultFileManagerConfig />\n <RegisterFeature feature={FileFieldTypeFeature} />\n <EnterpriseModule />\n <AiEnrichmentModule />\n <SecurityPermissions />\n <FileUrlFormatterModule />\n </>\n );\n};\n"],"names":["FileManager","RegisterFeature","FileModelProviderFeature","SharedCacheFeature","ListFilesFeature","GetFileFeature","UpdateFileFeature","DeleteFileFeature","FileUploaderFeature","ListTagsFeature","GetSettingsFeature","FmPermissionsFeature","ResolveImageToolFeature","FileModelModule","FileManagerPresenterFeature","AdminConfig","FolderTreeFieldRenderer","CmsFilePickerRenderer","CmsMultiFilePickerRenderer","CmsAssetPickerRenderer","CmsMultiAssetPickerRenderer","FileManagerRoutes","SettingsModule","FileManagerRendererDecorator","DefaultFileManagerConfig","FileFieldTypeFeature","EnterpriseModule","AiEnrichmentModule","SecurityPermissions","FileUrlFormatterModule"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BO,MAAMA,cAAc,IAChB,WAAP,GACI,wDAEI,oBAACC,iBAAeA;QAAC,SAASC;sBAC1B,oBAACD,iBAAeA;QAAC,SAASE;sBAC1B,oBAACF,iBAAeA;QAAC,SAASG;sBAC1B,oBAACH,iBAAeA;QAAC,SAASI;sBAC1B,oBAACJ,iBAAeA;QAAC,SAASK;sBAC1B,oBAACL,iBAAeA;QAAC,SAASM;sBAC1B,oBAACN,iBAAeA;QAAC,SAASO;sBAC1B,oBAACP,iBAAeA;QAAC,SAASQ;sBAC1B,oBAACR,iBAAeA;QAAC,SAASS;sBAC1B,oBAACT,iBAAeA;QAAC,SAASU;sBAC1B,oBAACV,iBAAeA;QAAC,SAASI;sBAC1B,oBAACJ,iBAAeA;QAAC,SAASW;sBAC1B,oBAACC,iBAAeA,OAAAA,WAAAA,GAEhB,oBAACZ,iBAAeA;QAAC,SAASa;sBAE1B,oBAACC,aAAWA,MAAAA,WAAAA,GACR,oBAACA,YAAY,IAAI,CAAC,aAAa;QAC3B,MAAM;QACN,WAAWC;sBAEf,oBAACD,YAAY,IAAI,CAAC,aAAa;QAC3B,MAAM;QACN,WAAWE;sBAEf,oBAACF,YAAY,IAAI,CAAC,aAAa;QAC3B,MAAM;QACN,WAAWG;sBAEf,oBAACH,YAAY,IAAI,CAAC,aAAa;QAC3B,MAAM;QACN,WAAWI;sBAEf,oBAACJ,YAAY,IAAI,CAAC,aAAa;QAC3B,MAAM;QACN,WAAWK;uBAInB,oBAACC,mBAAiBA,OAAAA,WAAAA,GAClB,oBAACC,gBAAcA,OAAAA,WAAAA,GACf,oBAACC,8BAA4BA,OAAAA,WAAAA,GAC7B,oBAACC,0BAAwBA,OAAAA,WAAAA,GACzB,oBAACvB,iBAAeA;QAAC,SAASwB;sBAC1B,oBAACC,kBAAgBA,OAAAA,WAAAA,GACjB,oBAACC,oBAAkBA,OAAAA,WAAAA,GACnB,oBAACC,qBAAmBA,OAAAA,WAAAA,GACpB,oBAACC,wBAAsBA"}
@@ -0,0 +1,9 @@
1
+ export { ListFilesGateway } from "../../features/listFiles/abstractions.js";
2
+ export type { ListFilesGatewayParams, ListFilesGatewayResult } from "../../features/listFiles/abstractions.js";
3
+ export { ListTagsGateway } from "../../features/tags/abstractions.js";
4
+ export type { ListTagsGatewayParams, ListTagsGatewayResult } from "../../features/tags/abstractions.js";
5
+ export { UpdateFileGateway } from "../../features/updateFile/abstractions.js";
6
+ export type { UpdateFileGatewayParams } from "../../features/updateFile/abstractions.js";
7
+ export { FileUploader } from "../../features/fileUploader/abstractions.js";
8
+ export type { UploadFileData, BatchUploadOptions, FileUploaderViewModel } from "../../features/fileUploader/abstractions.js";
9
+ export type { FmFile, FmTag } from "../../features/shared/types.js";
@@ -0,0 +1,4 @@
1
+ export { ListFilesGateway } from "../../features/listFiles/abstractions.js";
2
+ export { ListTagsGateway } from "../../features/tags/abstractions.js";
3
+ export { UpdateFileGateway } from "../../features/updateFile/abstractions.js";
4
+ export { FileUploader } from "../../features/fileUploader/abstractions.js";
@@ -1 +1 @@
1
- {"version":3,"file":"features/deleteFile/DeleteFile.test.js","sources":["../../../src/features/deleteFile/DeleteFile.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 {\n DeleteFileUseCase as UseCaseAbstraction,\n DeleteFileGateway as GatewayAbstraction,\n type IDeleteFileGateway,\n type DeleteFileGatewayParams\n} from \"./abstractions.js\";\nimport { DeleteFileUseCase } from \"./DeleteFileUseCase.js\";\nimport { DeleteFileRepository } from \"./DeleteFileRepository.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 = IDeleteFileGateway & { execute: ReturnType<typeof vi.fn> };\n\nfunction createMockGateway(): MockGateway {\n const execute = vi.fn<(params: DeleteFileGatewayParams) => Promise<boolean>>();\n execute.mockResolvedValue(true);\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 real repository and use case.\n container.register(DeleteFileRepository).inSingletonScope();\n container.register(DeleteFileUseCase);\n\n return { container, cache };\n}\n\n// ---------------------------------------------------------------------------\n// Tests\n// ---------------------------------------------------------------------------\n\ndescribe(\"DeleteFile 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 // Successful deletion.\n // -----------------------------------------------------------------------\n\n it(\"should call gateway with the file ID\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({ id: \"file-1\" });\n\n expect(mockGateway.execute).toHaveBeenCalledTimes(1);\n expect(mockGateway.execute).toHaveBeenCalledWith({ id: \"file-1\" });\n });\n\n it(\"should return success result on successful deletion\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute({ id: \"file-1\" });\n\n expect(result.success).toBe(true);\n });\n\n it(\"should remove the file from cache after successful deletion\", async () => {\n // Seed the cache with the file.\n const file = createFile({ id: \"file-del\" });\n cache.addItems([file]);\n expect(cache.getItem(f => f.id === \"file-del\")).toBeDefined();\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({ id: \"file-del\" });\n\n expect(cache.getItem(f => f.id === \"file-del\")).toBeUndefined();\n });\n\n it(\"should only remove the target file, 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 useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({ id: \"file-a\" });\n\n // file-a should be removed.\n expect(cache.getItem(f => f.id === \"file-a\")).toBeUndefined();\n\n // file-b should remain.\n expect(cache.getItem(f => f.id === \"file-b\")).toBeDefined();\n expect(cache.getItem(f => f.id === \"file-b\")!.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(\"Delete failed\"));\n\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute({ id: \"file-1\" });\n\n expect(result.success).toBe(false);\n if (!result.success) {\n expect(result.error.code).toBe(\"DELETE_FILE_ERROR\");\n expect(result.error.message).toBe(\"Delete failed\");\n }\n });\n\n it(\"should not remove file from cache when gateway throws\", async () => {\n // Seed cache with the file.\n const file = createFile({ id: \"file-err\", name: \"keep-me.jpg\" });\n cache.addItems([file]);\n\n mockGateway.execute.mockRejectedValue(new Error(\"Delete failed\"));\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({ id: \"file-err\" });\n\n // Cache should still have the file.\n const cached = cache.getItem(f => f.id === \"file-err\");\n expect(cached).toBeDefined();\n expect(cached!.name).toBe(\"keep-me.jpg\");\n });\n});\n"],"names":["createFile","overrides","createMockGateway","execute","vi","createContainer","mockGateway","container","Container","cache","ListCache","GatewayAbstraction","FilesListCache","DeleteFileRepository","DeleteFileUseCase","describe","beforeEach","result","it","useCase","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,OAAO,CAAC;YAAE,IAAI;QAAS;QAEpDE,OAAOJ,OAAO,OAAO,EAAE,IAAI,CAAC;QAC5B,IAAI,CAACA,OAAO,OAAO,EAAE;YACjBI,OAAOJ,OAAO,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;YAC/BI,OAAOJ,OAAO,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;QACtC;IACJ;IAEAC,GAAG,yDAAyD;QAExD,MAAMI,OAAOtB,WAAW;YAAE,IAAI;YAAY,MAAM;QAAc;QAC9DS,MAAM,QAAQ,CAAC;YAACa;SAAK;QAErBhB,YAAY,OAAO,CAAC,iBAAiB,CAAC,IAAIoB,MAAM;QAEhD,MAAMP,UAAUZ,UAAU,OAAO,CAACa;QAClC,MAAMD,QAAQ,OAAO,CAAC;YAAE,IAAI;QAAW;QAGvC,MAAMQ,SAASlB,MAAM,OAAO,CAACc,CAAAA,IAAKA,AAAS,eAATA,EAAE,EAAE;QACtCF,OAAOM,QAAQ,WAAW;QAC1BN,OAAOM,OAAQ,IAAI,EAAE,IAAI,CAAC;IAC9B;AACJ"}
1
+ {"version":3,"file":"features/deleteFile/DeleteFile.test.js","sources":["../../../src/features/deleteFile/DeleteFile.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 {\n DeleteFileUseCase as UseCaseAbstraction,\n DeleteFileGateway as GatewayAbstraction,\n type IDeleteFileGateway,\n type DeleteFileGatewayParams\n} from \"./abstractions.js\";\nimport { DeleteFileUseCase } from \"./DeleteFileUseCase.js\";\nimport { DeleteFileRepository } from \"./DeleteFileRepository.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 = IDeleteFileGateway & { execute: Mock };\n\nfunction createMockGateway(): MockGateway {\n const execute = vi.fn<(params: DeleteFileGatewayParams) => Promise<boolean>>();\n execute.mockResolvedValue(true);\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 real repository and use case.\n container.register(DeleteFileRepository).inSingletonScope();\n container.register(DeleteFileUseCase);\n\n return { container, cache };\n}\n\n// ---------------------------------------------------------------------------\n// Tests\n// ---------------------------------------------------------------------------\n\ndescribe(\"DeleteFile 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 // Successful deletion.\n // -----------------------------------------------------------------------\n\n it(\"should call gateway with the file ID\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({ id: \"file-1\" });\n\n expect(mockGateway.execute).toHaveBeenCalledTimes(1);\n expect(mockGateway.execute).toHaveBeenCalledWith({ id: \"file-1\" });\n });\n\n it(\"should return success result on successful deletion\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute({ id: \"file-1\" });\n\n expect(result.success).toBe(true);\n });\n\n it(\"should remove the file from cache after successful deletion\", async () => {\n // Seed the cache with the file.\n const file = createFile({ id: \"file-del\" });\n cache.addItems([file]);\n expect(cache.getItem(f => f.id === \"file-del\")).toBeDefined();\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({ id: \"file-del\" });\n\n expect(cache.getItem(f => f.id === \"file-del\")).toBeUndefined();\n });\n\n it(\"should only remove the target file, 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 useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({ id: \"file-a\" });\n\n // file-a should be removed.\n expect(cache.getItem(f => f.id === \"file-a\")).toBeUndefined();\n\n // file-b should remain.\n expect(cache.getItem(f => f.id === \"file-b\")).toBeDefined();\n expect(cache.getItem(f => f.id === \"file-b\")!.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(\"Delete failed\"));\n\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute({ id: \"file-1\" });\n\n expect(result.success).toBe(false);\n if (!result.success) {\n expect(result.error.code).toBe(\"DELETE_FILE_ERROR\");\n expect(result.error.message).toBe(\"Delete failed\");\n }\n });\n\n it(\"should not remove file from cache when gateway throws\", async () => {\n // Seed cache with the file.\n const file = createFile({ id: \"file-err\", name: \"keep-me.jpg\" });\n cache.addItems([file]);\n\n mockGateway.execute.mockRejectedValue(new Error(\"Delete failed\"));\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({ id: \"file-err\" });\n\n // Cache should still have the file.\n const cached = cache.getItem(f => f.id === \"file-err\");\n expect(cached).toBeDefined();\n expect(cached!.name).toBe(\"keep-me.jpg\");\n });\n});\n"],"names":["createFile","overrides","createMockGateway","execute","vi","createContainer","mockGateway","container","Container","cache","ListCache","GatewayAbstraction","FilesListCache","DeleteFileRepository","DeleteFileUseCase","describe","beforeEach","result","it","useCase","UseCaseAbstraction","expect","file","f","fileA","fileB","Error","cached"],"mappings":";;;;;;;AAmBA,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;IAChB;AACJ;AAIA,SAASC;IACL,MAAMC,UAAUC,GAAG,EAAE;IACrBD,QAAQ,iBAAiB,CAAC;IAC1B,OAAO;QAAEA;IAAQ;AACrB;AAEA,SAASE,gBAAgBC,WAAwB;IAC7C,MAAMC,YAAY,IAAIC;IACtB,MAAMC,QAAQ,IAAIC;IAGlBH,UAAU,gBAAgB,CAACI,mBAAoBL;IAG/CC,UAAU,gBAAgB,CAACK,gBAAgBH;IAG3CF,UAAU,QAAQ,CAACM,sBAAsB,gBAAgB;IACzDN,UAAU,QAAQ,CAACO;IAEnB,OAAO;QAAEP;QAAWE;IAAM;AAC9B;AAMAM,SAAS,sBAAsB;IAC3B,IAAIT;IACJ,IAAIG;IACJ,IAAIF;IAEJS,WAAW;QACPV,cAAcJ;QACd,MAAMe,SAASZ,gBAAgBC;QAC/BC,YAAYU,OAAO,SAAS;QAC5BR,QAAQQ,OAAO,KAAK;IACxB;IAMAC,GAAG,wCAAwC;QACvC,MAAMC,UAAUZ,UAAU,OAAO,CAACa;QAClC,MAAMD,QAAQ,OAAO,CAAC;YAAE,IAAI;QAAS;QAErCE,OAAOf,YAAY,OAAO,EAAE,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,YAAY,OAAO,CAAC,iBAAiB,CAAC,IAAIoB,MAAM;QAEhD,MAAMP,UAAUZ,UAAU,OAAO,CAACa;QAClC,MAAMH,SAAS,MAAME,QAAQ,OAAO,CAAC;YAAE,IAAI;QAAS;QAEpDE,OAAOJ,OAAO,OAAO,EAAE,IAAI,CAAC;QAC5B,IAAI,CAACA,OAAO,OAAO,EAAE;YACjBI,OAAOJ,OAAO,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;YAC/BI,OAAOJ,OAAO,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;QACtC;IACJ;IAEAC,GAAG,yDAAyD;QAExD,MAAMI,OAAOtB,WAAW;YAAE,IAAI;YAAY,MAAM;QAAc;QAC9DS,MAAM,QAAQ,CAAC;YAACa;SAAK;QAErBhB,YAAY,OAAO,CAAC,iBAAiB,CAAC,IAAIoB,MAAM;QAEhD,MAAMP,UAAUZ,UAAU,OAAO,CAACa;QAClC,MAAMD,QAAQ,OAAO,CAAC;YAAE,IAAI;QAAW;QAGvC,MAAMQ,SAASlB,MAAM,OAAO,CAACc,CAAAA,IAAKA,AAAS,eAATA,EAAE,EAAE;QACtCF,OAAOM,QAAQ,WAAW;QAC1BN,OAAOM,OAAQ,IAAI,EAAE,IAAI,CAAC;IAC9B;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"features/fileUploader/FileUploader.test.js","sources":["../../../src/features/fileUploader/FileUploader.test.ts"],"sourcesContent":["import { describe, it, expect, vi, beforeEach } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { Result } from \"@webiny/sdk\";\nimport { ListCache } from \"@webiny/app-admin/features/listCache/index.js\";\nimport { WebinySdk } from \"@webiny/app-admin/features/webinySdk/abstractions.js\";\nimport { FilesListCache } from \"../shared/abstractions.js\";\nimport { FileFieldsProvider } from \"../shared/FileFieldsProvider.js\";\nimport { FileUploader as Abstraction } from \"./abstractions.js\";\nimport { FileUploader } from \"./FileUploader.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: [],\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\nfunction createBrowserFile(name: string, size = 1024): File {\n const content = new Uint8Array(size);\n return new File([content], name, { type: \"image/jpeg\" });\n}\n\ninterface MockSdk {\n fileManager: {\n createFile: ReturnType<typeof vi.fn>;\n createFiles: ReturnType<typeof vi.fn>;\n };\n}\n\nfunction createMockSdk(): MockSdk {\n return {\n fileManager: {\n createFile: vi.fn(),\n createFiles: vi.fn()\n }\n };\n}\n\nfunction createContainer(mockSdk: MockSdk) {\n const container = new Container();\n const cache = new ListCache<FmFile>();\n\n container.registerInstance(WebinySdk, mockSdk as any);\n container.registerInstance(FilesListCache, cache);\n container.register(FileFieldsProvider).inSingletonScope();\n container.register(FileUploader).inSingletonScope();\n\n return { container, cache };\n}\n\n// ---------------------------------------------------------------------------\n// Tests\n// ---------------------------------------------------------------------------\n\ndescribe(\"FileUploader Feature\", () => {\n let mockSdk: MockSdk;\n let cache: ListCache<FmFile>;\n let container: Container;\n\n beforeEach(() => {\n mockSdk = createMockSdk();\n const result = createContainer(mockSdk);\n container = result.container;\n cache = result.cache as ListCache<FmFile>;\n });\n\n // -----------------------------------------------------------------------\n // Single file upload.\n // -----------------------------------------------------------------------\n\n it(\"should call SDK createFile with correct params for single upload\", async () => {\n const file = createBrowserFile(\"photo.jpg\", 2048);\n const created = createFile({ id: \"new-1\", name: \"photo.jpg\" });\n mockSdk.fileManager.createFile.mockResolvedValue(Result.ok(created));\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file, { name: \"photo.jpg\", type: \"image/jpeg\" });\n\n expect(mockSdk.fileManager.createFile).toHaveBeenCalledTimes(1);\n const callArgs = mockSdk.fileManager.createFile.mock.calls[0][0];\n expect(callArgs.file).toBe(file);\n expect(callArgs.data.name).toBe(\"photo.jpg\");\n expect(callArgs.data.type).toBe(\"image/jpeg\");\n expect(callArgs.fields).toBeDefined();\n expect(callArgs.onProgress).toBeTypeOf(\"function\");\n });\n\n it(\"should update job progress via onProgress callback\", async () => {\n const file = createBrowserFile(\"photo.jpg\", 2048);\n const created = createFile({ id: \"new-1\" });\n\n mockSdk.fileManager.createFile.mockImplementation(async (params: any) => {\n // Simulate progress callbacks.\n params.onProgress({ sent: 1024, total: 2048, percentage: 50 });\n params.onProgress({ sent: 2048, total: 2048, percentage: 100 });\n return Result.ok(created);\n });\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file, { name: \"photo.jpg\", type: \"image/jpeg\" });\n\n // After completion, job should be completed.\n expect(uploader.vm.jobs).toHaveLength(1);\n expect(uploader.vm.jobs[0].status).toBe(\"completed\");\n expect(uploader.vm.jobs[0].progress.percentage).toBe(100);\n });\n\n it(\"should update cache on successful single upload\", async () => {\n const file = createBrowserFile(\"photo.jpg\");\n const created = createFile({ id: \"uploaded-1\", name: \"photo.jpg\" });\n mockSdk.fileManager.createFile.mockResolvedValue(Result.ok(created));\n\n expect(cache.hasItems()).toBe(false);\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file, { name: \"photo.jpg\", type: \"image/jpeg\" });\n\n expect(cache.hasItems()).toBe(true);\n expect(cache.getItem(f => f.id === \"uploaded-1\")).toEqual(created);\n });\n\n it(\"should mark job as failed when SDK returns error\", async () => {\n const file = createBrowserFile(\"photo.jpg\");\n mockSdk.fileManager.createFile.mockResolvedValue(Result.fail(new Error(\"Upload failed\")));\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file, { name: \"photo.jpg\", type: \"image/jpeg\" });\n\n expect(uploader.vm.jobs).toHaveLength(1);\n expect(uploader.vm.jobs[0].status).toBe(\"failed\");\n expect(uploader.vm.jobs[0].error).toBe(\"Upload failed\");\n expect(cache.hasItems()).toBe(false);\n });\n\n // -----------------------------------------------------------------------\n // Batch upload.\n // -----------------------------------------------------------------------\n\n it(\"should call SDK createFiles with correct params for batch upload\", async () => {\n const file1 = createBrowserFile(\"a.jpg\", 1024);\n const file2 = createBrowserFile(\"b.jpg\", 2048);\n const created1 = createFile({ id: \"batch-1\", name: \"a.jpg\" });\n const created2 = createFile({ id: \"batch-2\", name: \"b.jpg\" });\n\n mockSdk.fileManager.createFiles.mockResolvedValue(\n Result.ok({ successful: [created1, created2], failed: [] })\n );\n\n const uploader = container.resolve(Abstraction);\n await uploader.uploadMany(\n [\n { file: file1, data: { name: \"a.jpg\", type: \"image/jpeg\" } },\n { file: file2, data: { name: \"b.jpg\", type: \"image/jpeg\" } }\n ],\n { concurrency: 2, strategy: \"continue\" }\n );\n\n expect(mockSdk.fileManager.createFiles).toHaveBeenCalledTimes(1);\n const callArgs = mockSdk.fileManager.createFiles.mock.calls[0][0];\n expect(callArgs.files).toHaveLength(2);\n expect(callArgs.concurrency).toBe(2);\n expect(callArgs.strategy).toBe(\"continue\");\n });\n\n it(\"should update cache with all successful files from batch\", async () => {\n const file1 = createBrowserFile(\"a.jpg\");\n const file2 = createBrowserFile(\"b.jpg\");\n const created1 = createFile({ id: \"batch-1\", name: \"a.jpg\" });\n const created2 = createFile({ id: \"batch-2\", name: \"b.jpg\" });\n\n mockSdk.fileManager.createFiles.mockResolvedValue(\n Result.ok({ successful: [created1, created2], failed: [] })\n );\n\n const uploader = container.resolve(Abstraction);\n await uploader.uploadMany([\n { file: file1, data: { name: \"a.jpg\", type: \"image/jpeg\" } },\n { file: file2, data: { name: \"b.jpg\", type: \"image/jpeg\" } }\n ]);\n\n expect(cache.count()).toBe(2);\n expect(cache.getItem(f => f.id === \"batch-1\")).toBeDefined();\n expect(cache.getItem(f => f.id === \"batch-2\")).toBeDefined();\n });\n\n it(\"should track per-file progress in batch upload\", async () => {\n const file1 = createBrowserFile(\"a.jpg\", 1024);\n const file2 = createBrowserFile(\"b.jpg\", 2048);\n const created1 = createFile({ id: \"batch-1\", name: \"a.jpg\" });\n const created2 = createFile({ id: \"batch-2\", name: \"b.jpg\" });\n\n mockSdk.fileManager.createFiles.mockImplementation(async (params: any) => {\n // Simulate per-file progress.\n params.files[0].onProgress({ sent: 1024, total: 1024, percentage: 100 });\n params.files[1].onProgress({ sent: 1024, total: 2048, percentage: 50 });\n params.files[1].onProgress({ sent: 2048, total: 2048, percentage: 100 });\n return Result.ok({ successful: [created1, created2], failed: [] });\n });\n\n const uploader = container.resolve(Abstraction);\n await uploader.uploadMany([\n { file: file1, data: { name: \"a.jpg\", type: \"image/jpeg\" } },\n { file: file2, data: { name: \"b.jpg\", type: \"image/jpeg\" } }\n ]);\n\n expect(uploader.vm.jobs).toHaveLength(2);\n expect(uploader.vm.completedCount).toBe(2);\n });\n\n it(\"should handle partial failures in batch upload (continue strategy)\", async () => {\n const file1 = createBrowserFile(\"a.jpg\");\n const file2 = createBrowserFile(\"b.jpg\");\n const created1 = createFile({ id: \"batch-ok\", name: \"a.jpg\" });\n\n mockSdk.fileManager.createFiles.mockResolvedValue(\n Result.ok({\n successful: [created1],\n failed: [{ data: { name: \"b.jpg\" }, error: new Error(\"b.jpg failed\") }]\n })\n );\n\n const uploader = container.resolve(Abstraction);\n await uploader.uploadMany(\n [\n { file: file1, data: { name: \"a.jpg\", type: \"image/jpeg\" } },\n { file: file2, data: { name: \"b.jpg\", type: \"image/jpeg\" } }\n ],\n { strategy: \"continue\" }\n );\n\n expect(uploader.vm.completedCount).toBe(1);\n expect(uploader.vm.failedCount).toBe(1);\n // Only the successful file should be in cache.\n expect(cache.count()).toBe(1);\n expect(cache.getItem(f => f.id === \"batch-ok\")).toBeDefined();\n });\n\n // -----------------------------------------------------------------------\n // Abort.\n // -----------------------------------------------------------------------\n\n it(\"should pass AbortController signal to SDK for single upload\", async () => {\n const file = createBrowserFile(\"photo.jpg\");\n const created = createFile({ id: \"abort-1\" });\n mockSdk.fileManager.createFile.mockResolvedValue(Result.ok(created));\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file, { name: \"photo.jpg\", type: \"image/jpeg\" });\n\n // Verify signal was passed.\n const callArgs = mockSdk.fileManager.createFile.mock.calls[0][0];\n expect(callArgs.signal).toBeInstanceOf(AbortSignal);\n });\n\n it(\"should pass AbortController signal to SDK for batch upload\", async () => {\n const file = createBrowserFile(\"photo.jpg\");\n const created = createFile({ id: \"abort-batch\" });\n mockSdk.fileManager.createFiles.mockResolvedValue(\n Result.ok({ successful: [created], failed: [] })\n );\n\n const uploader = container.resolve(Abstraction);\n await uploader.uploadMany([{ file, data: { name: \"photo.jpg\", type: \"image/jpeg\" } }]);\n\n const callArgs = mockSdk.fileManager.createFiles.mock.calls[0][0];\n expect(callArgs.signal).toBeInstanceOf(AbortSignal);\n });\n\n // -----------------------------------------------------------------------\n // Clear.\n // -----------------------------------------------------------------------\n\n it(\"should remove completed and failed jobs on clear\", async () => {\n const file1 = createBrowserFile(\"ok.jpg\");\n const file2 = createBrowserFile(\"fail.jpg\");\n\n // First upload succeeds.\n mockSdk.fileManager.createFile.mockResolvedValueOnce(\n Result.ok(createFile({ id: \"ok-1\", name: \"ok.jpg\" }))\n );\n // Second upload fails.\n mockSdk.fileManager.createFile.mockResolvedValueOnce(Result.fail(new Error(\"fail\")));\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file1, { name: \"ok.jpg\", type: \"image/jpeg\" });\n await uploader.upload(file2, { name: \"fail.jpg\", type: \"image/jpeg\" });\n\n expect(uploader.vm.jobs).toHaveLength(2);\n expect(uploader.vm.completedCount).toBe(1);\n expect(uploader.vm.failedCount).toBe(1);\n\n uploader.clear();\n\n expect(uploader.vm.jobs).toHaveLength(0);\n });\n\n // -----------------------------------------------------------------------\n // ViewModel computed properties.\n // -----------------------------------------------------------------------\n\n it(\"should compute overall progress from all jobs\", async () => {\n const file1 = createBrowserFile(\"a.jpg\", 1000);\n const file2 = createBrowserFile(\"b.jpg\", 3000);\n const created1 = createFile({ id: \"p-1\", name: \"a.jpg\" });\n const created2 = createFile({ id: \"p-2\", name: \"b.jpg\" });\n\n mockSdk.fileManager.createFile\n .mockResolvedValueOnce(Result.ok(created1))\n .mockResolvedValueOnce(Result.ok(created2));\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file1, { name: \"a.jpg\", type: \"image/jpeg\" });\n await uploader.upload(file2, { name: \"b.jpg\", type: \"image/jpeg\" });\n\n // Both completed — overall should be 100%.\n expect(uploader.vm.isUploading).toBe(false);\n expect(uploader.vm.overallProgress.percentage).toBe(100);\n });\n\n it(\"should report isUploading as false when no jobs exist\", () => {\n const uploader = container.resolve(Abstraction);\n expect(uploader.vm.isUploading).toBe(false);\n expect(uploader.vm.jobs).toHaveLength(0);\n expect(uploader.vm.overallProgress.percentage).toBe(0);\n });\n});\n"],"names":["createFile","overrides","createBrowserFile","name","size","content","Uint8Array","File","createMockSdk","vi","createContainer","mockSdk","container","Container","cache","ListCache","WebinySdk","FilesListCache","FileFieldsProvider","FileUploader","describe","beforeEach","result","it","file","created","Result","uploader","Abstraction","expect","callArgs","params","f","Error","file1","file2","created1","created2","AbortSignal"],"mappings":";;;;;;;;;AAeA,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,EAAE;QACR,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;IAChB;AACJ;AAEA,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e,OAAO,EAAE,CAACU,WAChC,qBAAqB,CAACV,OAAO,EAAE,CAACW;QAErC,MAAMV,WAAWf,UAAU,OAAO,CAACgB;QACnC,MAAMD,SAAS,MAAM,CAACO,OAAO;YAAE,MAAM;YAAS,MAAM;QAAa;QACjE,MAAMP,SAAS,MAAM,CAACQ,OAAO;YAAE,MAAM;YAAS,MAAM;QAAa;QAGjEN,OAAOF,SAAS,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;QACrCE,OAAOF,SAAS,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC;IACxD;IAEAJ,GAAG,yDAAyD;QACxD,MAAMI,WAAWf,UAAU,OAAO,CAACgB;QACnCC,OAAOF,SAAS,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;QACrCE,OAAOF,SAAS,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC;QACtCE,OAAOF,SAAS,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC;IACxD;AACJ"}
1
+ {"version":3,"file":"features/fileUploader/FileUploader.test.js","sources":["../../../src/features/fileUploader/FileUploader.test.ts"],"sourcesContent":["import { describe, it, expect, vi, beforeEach } from \"vitest\";\nimport type { Mock } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { Result } from \"@webiny/sdk\";\nimport { ListCache } from \"@webiny/app-admin/features/listCache/index.js\";\nimport { WebinySdk } from \"@webiny/app-admin/features/webinySdk/abstractions.js\";\nimport { FilesListCache } from \"../shared/abstractions.js\";\nimport { FileFieldsProvider } from \"../shared/FileFieldsProvider.js\";\nimport { FileUploader as Abstraction } from \"./abstractions.js\";\nimport { FileUploader } from \"./FileUploader.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: [],\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\nfunction createBrowserFile(name: string, size = 1024): File {\n const content = new Uint8Array(size);\n return new File([content], name, { type: \"image/jpeg\" });\n}\n\ninterface MockSdk {\n fileManager: {\n createFile: Mock;\n createFiles: Mock;\n };\n}\n\nfunction createMockSdk(): MockSdk {\n return {\n fileManager: {\n createFile: vi.fn(),\n createFiles: vi.fn()\n }\n };\n}\n\nfunction createContainer(mockSdk: MockSdk) {\n const container = new Container();\n const cache = new ListCache<FmFile>();\n\n container.registerInstance(WebinySdk, mockSdk as any);\n container.registerInstance(FilesListCache, cache);\n container.register(FileFieldsProvider).inSingletonScope();\n container.register(FileUploader).inSingletonScope();\n\n return { container, cache };\n}\n\n// ---------------------------------------------------------------------------\n// Tests\n// ---------------------------------------------------------------------------\n\ndescribe(\"FileUploader Feature\", () => {\n let mockSdk: MockSdk;\n let cache: ListCache<FmFile>;\n let container: Container;\n\n beforeEach(() => {\n mockSdk = createMockSdk();\n const result = createContainer(mockSdk);\n container = result.container;\n cache = result.cache as ListCache<FmFile>;\n });\n\n // -----------------------------------------------------------------------\n // Single file upload.\n // -----------------------------------------------------------------------\n\n it(\"should call SDK createFile with correct params for single upload\", async () => {\n const file = createBrowserFile(\"photo.jpg\", 2048);\n const created = createFile({ id: \"new-1\", name: \"photo.jpg\" });\n mockSdk.fileManager.createFile.mockResolvedValue(Result.ok(created));\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file, { name: \"photo.jpg\", type: \"image/jpeg\" });\n\n expect(mockSdk.fileManager.createFile).toHaveBeenCalledTimes(1);\n const callArgs = mockSdk.fileManager.createFile.mock.calls[0][0];\n expect(callArgs.file).toBe(file);\n expect(callArgs.data.name).toBe(\"photo.jpg\");\n expect(callArgs.data.type).toBe(\"image/jpeg\");\n expect(callArgs.fields).toBeDefined();\n expect(callArgs.onProgress).toBeTypeOf(\"function\");\n });\n\n it(\"should update job progress via onProgress callback\", async () => {\n const file = createBrowserFile(\"photo.jpg\", 2048);\n const created = createFile({ id: \"new-1\" });\n\n mockSdk.fileManager.createFile.mockImplementation(async (params: any) => {\n // Simulate progress callbacks.\n params.onProgress({ sent: 1024, total: 2048, percentage: 50 });\n params.onProgress({ sent: 2048, total: 2048, percentage: 100 });\n return Result.ok(created);\n });\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file, { name: \"photo.jpg\", type: \"image/jpeg\" });\n\n // After completion, job should be completed.\n expect(uploader.vm.jobs).toHaveLength(1);\n expect(uploader.vm.jobs[0].status).toBe(\"completed\");\n expect(uploader.vm.jobs[0].progress.percentage).toBe(100);\n });\n\n it(\"should update cache on successful single upload\", async () => {\n const file = createBrowserFile(\"photo.jpg\");\n const created = createFile({ id: \"uploaded-1\", name: \"photo.jpg\" });\n mockSdk.fileManager.createFile.mockResolvedValue(Result.ok(created));\n\n expect(cache.hasItems()).toBe(false);\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file, { name: \"photo.jpg\", type: \"image/jpeg\" });\n\n expect(cache.hasItems()).toBe(true);\n expect(cache.getItem(f => f.id === \"uploaded-1\")).toEqual(created);\n });\n\n it(\"should mark job as failed when SDK returns error\", async () => {\n const file = createBrowserFile(\"photo.jpg\");\n mockSdk.fileManager.createFile.mockResolvedValue(Result.fail(new Error(\"Upload failed\")));\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file, { name: \"photo.jpg\", type: \"image/jpeg\" });\n\n expect(uploader.vm.jobs).toHaveLength(1);\n expect(uploader.vm.jobs[0].status).toBe(\"failed\");\n expect(uploader.vm.jobs[0].error).toBe(\"Upload failed\");\n expect(cache.hasItems()).toBe(false);\n });\n\n // -----------------------------------------------------------------------\n // Batch upload.\n // -----------------------------------------------------------------------\n\n it(\"should call SDK createFiles with correct params for batch upload\", async () => {\n const file1 = createBrowserFile(\"a.jpg\", 1024);\n const file2 = createBrowserFile(\"b.jpg\", 2048);\n const created1 = createFile({ id: \"batch-1\", name: \"a.jpg\" });\n const created2 = createFile({ id: \"batch-2\", name: \"b.jpg\" });\n\n mockSdk.fileManager.createFiles.mockResolvedValue(\n Result.ok({ successful: [created1, created2], failed: [] })\n );\n\n const uploader = container.resolve(Abstraction);\n await uploader.uploadMany(\n [\n { file: file1, data: { name: \"a.jpg\", type: \"image/jpeg\" } },\n { file: file2, data: { name: \"b.jpg\", type: \"image/jpeg\" } }\n ],\n { concurrency: 2, strategy: \"continue\" }\n );\n\n expect(mockSdk.fileManager.createFiles).toHaveBeenCalledTimes(1);\n const callArgs = mockSdk.fileManager.createFiles.mock.calls[0][0];\n expect(callArgs.files).toHaveLength(2);\n expect(callArgs.concurrency).toBe(2);\n expect(callArgs.strategy).toBe(\"continue\");\n });\n\n it(\"should update cache with all successful files from batch\", async () => {\n const file1 = createBrowserFile(\"a.jpg\");\n const file2 = createBrowserFile(\"b.jpg\");\n const created1 = createFile({ id: \"batch-1\", name: \"a.jpg\" });\n const created2 = createFile({ id: \"batch-2\", name: \"b.jpg\" });\n\n mockSdk.fileManager.createFiles.mockResolvedValue(\n Result.ok({ successful: [created1, created2], failed: [] })\n );\n\n const uploader = container.resolve(Abstraction);\n await uploader.uploadMany([\n { file: file1, data: { name: \"a.jpg\", type: \"image/jpeg\" } },\n { file: file2, data: { name: \"b.jpg\", type: \"image/jpeg\" } }\n ]);\n\n expect(cache.count()).toBe(2);\n expect(cache.getItem(f => f.id === \"batch-1\")).toBeDefined();\n expect(cache.getItem(f => f.id === \"batch-2\")).toBeDefined();\n });\n\n it(\"should track per-file progress in batch upload\", async () => {\n const file1 = createBrowserFile(\"a.jpg\", 1024);\n const file2 = createBrowserFile(\"b.jpg\", 2048);\n const created1 = createFile({ id: \"batch-1\", name: \"a.jpg\" });\n const created2 = createFile({ id: \"batch-2\", name: \"b.jpg\" });\n\n mockSdk.fileManager.createFiles.mockImplementation(async (params: any) => {\n // Simulate per-file progress.\n params.files[0].onProgress({ sent: 1024, total: 1024, percentage: 100 });\n params.files[1].onProgress({ sent: 1024, total: 2048, percentage: 50 });\n params.files[1].onProgress({ sent: 2048, total: 2048, percentage: 100 });\n return Result.ok({ successful: [created1, created2], failed: [] });\n });\n\n const uploader = container.resolve(Abstraction);\n await uploader.uploadMany([\n { file: file1, data: { name: \"a.jpg\", type: \"image/jpeg\" } },\n { file: file2, data: { name: \"b.jpg\", type: \"image/jpeg\" } }\n ]);\n\n expect(uploader.vm.jobs).toHaveLength(2);\n expect(uploader.vm.completedCount).toBe(2);\n });\n\n it(\"should handle partial failures in batch upload (continue strategy)\", async () => {\n const file1 = createBrowserFile(\"a.jpg\");\n const file2 = createBrowserFile(\"b.jpg\");\n const created1 = createFile({ id: \"batch-ok\", name: \"a.jpg\" });\n\n mockSdk.fileManager.createFiles.mockResolvedValue(\n Result.ok({\n successful: [created1],\n failed: [{ data: { name: \"b.jpg\" }, error: new Error(\"b.jpg failed\") }]\n })\n );\n\n const uploader = container.resolve(Abstraction);\n await uploader.uploadMany(\n [\n { file: file1, data: { name: \"a.jpg\", type: \"image/jpeg\" } },\n { file: file2, data: { name: \"b.jpg\", type: \"image/jpeg\" } }\n ],\n { strategy: \"continue\" }\n );\n\n expect(uploader.vm.completedCount).toBe(1);\n expect(uploader.vm.failedCount).toBe(1);\n // Only the successful file should be in cache.\n expect(cache.count()).toBe(1);\n expect(cache.getItem(f => f.id === \"batch-ok\")).toBeDefined();\n });\n\n // -----------------------------------------------------------------------\n // Abort.\n // -----------------------------------------------------------------------\n\n it(\"should pass AbortController signal to SDK for single upload\", async () => {\n const file = createBrowserFile(\"photo.jpg\");\n const created = createFile({ id: \"abort-1\" });\n mockSdk.fileManager.createFile.mockResolvedValue(Result.ok(created));\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file, { name: \"photo.jpg\", type: \"image/jpeg\" });\n\n // Verify signal was passed.\n const callArgs = mockSdk.fileManager.createFile.mock.calls[0][0];\n expect(callArgs.signal).toBeInstanceOf(AbortSignal);\n });\n\n it(\"should pass AbortController signal to SDK for batch upload\", async () => {\n const file = createBrowserFile(\"photo.jpg\");\n const created = createFile({ id: \"abort-batch\" });\n mockSdk.fileManager.createFiles.mockResolvedValue(\n Result.ok({ successful: [created], failed: [] })\n );\n\n const uploader = container.resolve(Abstraction);\n await uploader.uploadMany([{ file, data: { name: \"photo.jpg\", type: \"image/jpeg\" } }]);\n\n const callArgs = mockSdk.fileManager.createFiles.mock.calls[0][0];\n expect(callArgs.signal).toBeInstanceOf(AbortSignal);\n });\n\n // -----------------------------------------------------------------------\n // Clear.\n // -----------------------------------------------------------------------\n\n it(\"should remove completed and failed jobs on clear\", async () => {\n const file1 = createBrowserFile(\"ok.jpg\");\n const file2 = createBrowserFile(\"fail.jpg\");\n\n // First upload succeeds.\n mockSdk.fileManager.createFile.mockResolvedValueOnce(\n Result.ok(createFile({ id: \"ok-1\", name: \"ok.jpg\" }))\n );\n // Second upload fails.\n mockSdk.fileManager.createFile.mockResolvedValueOnce(Result.fail(new Error(\"fail\")));\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file1, { name: \"ok.jpg\", type: \"image/jpeg\" });\n await uploader.upload(file2, { name: \"fail.jpg\", type: \"image/jpeg\" });\n\n expect(uploader.vm.jobs).toHaveLength(2);\n expect(uploader.vm.completedCount).toBe(1);\n expect(uploader.vm.failedCount).toBe(1);\n\n uploader.clear();\n\n expect(uploader.vm.jobs).toHaveLength(0);\n });\n\n // -----------------------------------------------------------------------\n // ViewModel computed properties.\n // -----------------------------------------------------------------------\n\n it(\"should compute overall progress from all jobs\", async () => {\n const file1 = createBrowserFile(\"a.jpg\", 1000);\n const file2 = createBrowserFile(\"b.jpg\", 3000);\n const created1 = createFile({ id: \"p-1\", name: \"a.jpg\" });\n const created2 = createFile({ id: \"p-2\", name: \"b.jpg\" });\n\n mockSdk.fileManager.createFile\n .mockResolvedValueOnce(Result.ok(created1))\n .mockResolvedValueOnce(Result.ok(created2));\n\n const uploader = container.resolve(Abstraction);\n await uploader.upload(file1, { name: \"a.jpg\", type: \"image/jpeg\" });\n await uploader.upload(file2, { name: \"b.jpg\", type: \"image/jpeg\" });\n\n // Both completed — overall should be 100%.\n expect(uploader.vm.isUploading).toBe(false);\n expect(uploader.vm.overallProgress.percentage).toBe(100);\n });\n\n it(\"should report isUploading as false when no jobs exist\", () => {\n const uploader = container.resolve(Abstraction);\n expect(uploader.vm.isUploading).toBe(false);\n expect(uploader.vm.jobs).toHaveLength(0);\n expect(uploader.vm.overallProgress.percentage).toBe(0);\n });\n});\n"],"names":["createFile","overrides","createBrowserFile","name","size","content","Uint8Array","File","createMockSdk","vi","createContainer","mockSdk","container","Container","cache","ListCache","WebinySdk","FilesListCache","FileFieldsProvider","FileUploader","describe","beforeEach","result","it","file","created","Result","uploader","Abstraction","expect","callArgs","params","f","Error","file1","file2","created1","created2","AbortSignal"],"mappings":";;;;;;;;;AAgBA,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,EAAE;QACR,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;IAChB;AACJ;AAEA,SAASC,kBAAkBC,IAAY,EAAEC,OAAO,IAAI;IAChD,MAAMC,UAAU,IAAIC,WAAWF;IAC/B,OAAO,IAAIG,KAAK;QAACF;KAAQ,EAAEF,MAAM;QAAE,MAAM;IAAa;AAC1D;AASA,SAASK;IACL,OAAO;QACH,aAAa;YACT,YAA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ACQ,OAAO;YAAE,MAAM;YAAS,MAAM;QAAa;QAGjEN,OAAOF,SAAS,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;QACrCE,OAAOF,SAAS,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC;IACxD;IAEAJ,GAAG,yDAAyD;QACxD,MAAMI,WAAWf,UAAU,OAAO,CAACgB;QACnCC,OAAOF,SAAS,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;QACrCE,OAAOF,SAAS,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC;QACtCE,OAAOF,SAAS,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC;IACxD;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"features/listFiles/ListFiles.test.js","sources":["../../../src/features/listFiles/ListFiles.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 {\n ListFilesUseCase as UseCaseAbstraction,\n ListFilesGateway as GatewayAbstraction,\n type IListFilesGateway,\n type ListFilesGatewayParams,\n type ListFilesGatewayResult\n} from \"./abstractions.js\";\nimport { ListFilesUseCase } from \"./ListFilesUseCase.js\";\nimport { ListFilesRepository } from \"./ListFilesRepository.js\";\nimport type { FmFile } from \"../shared/types.js\";\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction createFile(index: number): FmFile {\n return {\n id: `file-${index}`,\n name: `File ${index}`,\n key: `files/file-${index}.txt`,\n src: `https://cdn.example.com/files/file-${index}.txt`,\n type: \"text/plain\",\n size: index * 100,\n metadata: {},\n tags: [],\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 };\n}\n\nfunction createFiles(count: number): FmFile[] {\n return Array.from({ length: count }, (_, i) => createFile(i));\n}\n\ntype MockGateway = IListFilesGateway & { execute: ReturnType<typeof vi.fn> };\n\nfunction createMockGateway(\n files: FmFile[] = createFiles(3),\n meta = { cursor: null as string | null, hasMoreItems: false, totalCount: files.length }\n): MockGateway {\n const execute = vi.fn<(params: ListFilesGatewayParams) => Promise<ListFilesGatewayResult>>();\n execute.mockResolvedValue({ data: files, meta });\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 real repository and use case.\n container.register(ListFilesRepository).inSingletonScope();\n container.register(ListFilesUseCase);\n\n return { container, cache };\n}\n\n// ---------------------------------------------------------------------------\n// Tests\n// ---------------------------------------------------------------------------\n\ndescribe(\"ListFiles 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 // UseCase invokes gateway with correct params.\n // -----------------------------------------------------------------------\n\n it(\"should call gateway with the provided params\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute({\n search: \"hello\",\n where: { type_in: [\"image/png\"] },\n sort: [\"name_ASC\"],\n limit: 10,\n after: \"cursor-abc\"\n });\n\n expect(mockGateway.execute).toHaveBeenCalledWith({\n search: \"hello\",\n where: { type_in: [\"image/png\"] },\n sort: [\"name_ASC\"],\n limit: 10,\n after: \"cursor-abc\"\n });\n });\n\n it(\"should call gateway with undefined optional params when not provided\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute({});\n\n expect(mockGateway.execute).toHaveBeenCalledWith({\n search: undefined,\n where: undefined,\n sort: undefined,\n limit: undefined,\n after: undefined\n });\n });\n\n // -----------------------------------------------------------------------\n // UseCase returns files and meta.\n // -----------------------------------------------------------------------\n\n it(\"should return files and meta from the gateway\", async () => {\n const files = createFiles(5);\n const meta = { cursor: \"next-cursor\", hasMoreItems: true, totalCount: 10 };\n mockGateway.execute.mockResolvedValue({ data: files, meta });\n\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute({});\n\n expect(result.data).toEqual(files);\n expect(result.meta).toEqual(meta);\n });\n\n // -----------------------------------------------------------------------\n // Repository updates FilesListCache after fetch.\n // -----------------------------------------------------------------------\n\n it(\"should populate FilesListCache after fetch\", async () => {\n const files = createFiles(3);\n mockGateway.execute.mockResolvedValue({\n data: files,\n meta: { cursor: null, hasMoreItems: false, totalCount: 3 }\n });\n\n expect(cache.hasItems()).toBe(false);\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({});\n\n expect(cache.hasItems()).toBe(true);\n expect(cache.getItems()).toEqual(files);\n });\n\n // -----------------------------------------------------------------------\n // Cursor-based pagination.\n // -----------------------------------------------------------------------\n\n it(\"should support cursor-based pagination\", async () => {\n const page1 = createFiles(3);\n const page2 = [createFile(3), createFile(4)];\n\n mockGateway.execute\n .mockResolvedValueOnce({\n data: page1,\n meta: { cursor: \"page2-cursor\", hasMoreItems: true, totalCount: 5 }\n })\n .mockResolvedValueOnce({\n data: page2,\n meta: { cursor: null, hasMoreItems: false, totalCount: 5 }\n });\n\n const useCase = container.resolve(UseCaseAbstraction);\n\n // First page.\n const result1 = await useCase.execute({ limit: 3 });\n expect(result1.data).toEqual(page1);\n expect(result1.meta.cursor).toBe(\"page2-cursor\");\n expect(result1.meta.hasMoreItems).toBe(true);\n\n // Second page using cursor.\n const result2 = await useCase.execute({ limit: 3, after: \"page2-cursor\" });\n expect(result2.data).toEqual(page2);\n expect(result2.meta.cursor).toBeNull();\n expect(result2.meta.hasMoreItems).toBe(false);\n\n // Cache should contain all files from both pages.\n expect(cache.count()).toBe(5);\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"],"names":["createFile","index","createFiles","count","Array","_","i","createMockGateway","files","meta","execute","vi","createContainer","mockGateway","container","Container","cache","ListCache","GatewayAbstraction","FilesListCache","ListFilesRepository","ListFilesUseCase","describe","beforeEach","result","it","useCase","UseCaseAbstraction","expect","undefined","page1","page2","result1","result2","Error"],"mappings":";;;;;;;AAmBA,SAASA,WAAWC,KAAa;IAC7B,OAAO;QACH,IAAI,CAAC,KAAK,EAAEA,OAAO;QACnB,MAAM,CAAC,KAAK,EAAEA,OAAO;QACrB,KAAK,CAAC,WAAW,EAAEA,MAAM,IAAI,CAAC;QAC9B,KAAK,CAAC,mCAAmC,EAAEA,MAAM,IAAI,CAAC;QACtD,MAAM;QACN,MAAMA,AAAQ,MAARA;QACN,UAAU,CAAC;QACX,MAAM,EAAE;QACR,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;IACjC;AACJ;AAEA,SAASC,YAAYC,KAAa;IAC9B,OAAOC,MAAM,IAAI,CAAC;QAAE,QAAQD;IAAM,GAAG,CAACE,GAAGC,IAAMN,WAAWM;AAC9D;AAIA,SAASC,kBACLC,QAAkBN,YAAY,EAAE,EAChCO,OAAO;IAAE,QAAQ;IAAuB,cAAc;IAAO,YAAYD,MAAM,MAAM;AAAC,CAAC;IAEvF,MAAME,UAAUC,GAAG,EAAE;IACrBD,QAAQ,iBAAiB,CAAC;QAAE,MAAMF;QAAOC;IAAK;IAC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U,MAAMP,QAAQ,OAAO,CAAC;YAAE,OAAO;YAAG,OAAO;QAAe;QACxEE,OAAOK,QAAQ,IAAI,EAAE,OAAO,CAACF;QAC7BH,OAAOK,QAAQ,IAAI,CAAC,MAAM,EAAE,QAAQ;QACpCL,OAAOK,QAAQ,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC;QAGvCL,OAAOZ,MAAM,KAAK,IAAI,IAAI,CAAC;IAC/B;IAMAS,GAAG,mCAAmC;QAClCZ,YAAY,OAAO,CAAC,iBAAiB,CAAC,IAAIqB,MAAM;QAEhD,MAAMR,UAAUZ,UAAU,OAAO,CAACa;QAElC,MAAMC,OAAOF,QAAQ,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC;IACtD;AACJ"}
1
+ {"version":3,"file":"features/listFiles/ListFiles.test.js","sources":["../../../src/features/listFiles/ListFiles.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 {\n ListFilesUseCase as UseCaseAbstraction,\n ListFilesGateway as GatewayAbstraction,\n type IListFilesGateway,\n type ListFilesGatewayParams,\n type ListFilesGatewayResult\n} from \"./abstractions.js\";\nimport { ListFilesUseCase } from \"./ListFilesUseCase.js\";\nimport { ListFilesRepository } from \"./ListFilesRepository.js\";\nimport type { FmFile } from \"../shared/types.js\";\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction createFile(index: number): FmFile {\n return {\n id: `file-${index}`,\n name: `File ${index}`,\n key: `files/file-${index}.txt`,\n src: `https://cdn.example.com/files/file-${index}.txt`,\n type: \"text/plain\",\n size: index * 100,\n metadata: {},\n tags: [],\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 };\n}\n\nfunction createFiles(count: number): FmFile[] {\n return Array.from({ length: count }, (_, i) => createFile(i));\n}\n\ntype MockGateway = IListFilesGateway & { execute: Mock };\n\nfunction createMockGateway(\n files: FmFile[] = createFiles(3),\n meta = { cursor: null as string | null, hasMoreItems: false, totalCount: files.length }\n): MockGateway {\n const execute = vi.fn<(params: ListFilesGatewayParams) => Promise<ListFilesGatewayResult>>();\n execute.mockResolvedValue({ data: files, meta });\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 real repository and use case.\n container.register(ListFilesRepository).inSingletonScope();\n container.register(ListFilesUseCase);\n\n return { container, cache };\n}\n\n// ---------------------------------------------------------------------------\n// Tests\n// ---------------------------------------------------------------------------\n\ndescribe(\"ListFiles 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 // UseCase invokes gateway with correct params.\n // -----------------------------------------------------------------------\n\n it(\"should call gateway with the provided params\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute({\n search: \"hello\",\n where: { type_in: [\"image/png\"] },\n sort: [\"name_ASC\"],\n limit: 10,\n after: \"cursor-abc\"\n });\n\n expect(mockGateway.execute).toHaveBeenCalledWith({\n search: \"hello\",\n where: { type_in: [\"image/png\"] },\n sort: [\"name_ASC\"],\n limit: 10,\n after: \"cursor-abc\"\n });\n });\n\n it(\"should call gateway with undefined optional params when not provided\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute({});\n\n expect(mockGateway.execute).toHaveBeenCalledWith({\n search: undefined,\n where: undefined,\n sort: undefined,\n limit: undefined,\n after: undefined\n });\n });\n\n // -----------------------------------------------------------------------\n // UseCase returns files and meta.\n // -----------------------------------------------------------------------\n\n it(\"should return files and meta from the gateway\", async () => {\n const files = createFiles(5);\n const meta = { cursor: \"next-cursor\", hasMoreItems: true, totalCount: 10 };\n mockGateway.execute.mockResolvedValue({ data: files, meta });\n\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute({});\n\n expect(result.data).toEqual(files);\n expect(result.meta).toEqual(meta);\n });\n\n // -----------------------------------------------------------------------\n // Repository updates FilesListCache after fetch.\n // -----------------------------------------------------------------------\n\n it(\"should populate FilesListCache after fetch\", async () => {\n const files = createFiles(3);\n mockGateway.execute.mockResolvedValue({\n data: files,\n meta: { cursor: null, hasMoreItems: false, totalCount: 3 }\n });\n\n expect(cache.hasItems()).toBe(false);\n\n const useCase = container.resolve(UseCaseAbstraction);\n await useCase.execute({});\n\n expect(cache.hasItems()).toBe(true);\n expect(cache.getItems()).toEqual(files);\n });\n\n // -----------------------------------------------------------------------\n // Cursor-based pagination.\n // -----------------------------------------------------------------------\n\n it(\"should support cursor-based pagination\", async () => {\n const page1 = createFiles(3);\n const page2 = [createFile(3), createFile(4)];\n\n mockGateway.execute\n .mockResolvedValueOnce({\n data: page1,\n meta: { cursor: \"page2-cursor\", hasMoreItems: true, totalCount: 5 }\n })\n .mockResolvedValueOnce({\n data: page2,\n meta: { cursor: null, hasMoreItems: false, totalCount: 5 }\n });\n\n const useCase = container.resolve(UseCaseAbstraction);\n\n // First page.\n const result1 = await useCase.execute({ limit: 3 });\n expect(result1.data).toEqual(page1);\n expect(result1.meta.cursor).toBe(\"page2-cursor\");\n expect(result1.meta.hasMoreItems).toBe(true);\n\n // Second page using cursor.\n const result2 = await useCase.execute({ limit: 3, after: \"page2-cursor\" });\n expect(result2.data).toEqual(page2);\n expect(result2.meta.cursor).toBeNull();\n expect(result2.meta.hasMoreItems).toBe(false);\n\n // Cache should contain all files from both pages.\n expect(cache.count()).toBe(5);\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"],"names":["createFile","index","createFiles","count","Array","_","i","createMockGateway","files","meta","execute","vi","createContainer","mockGateway","container","Container","cache","ListCache","GatewayAbstraction","FilesListCache","ListFilesRepository","ListFilesUseCase","describe","beforeEach","result","it","useCase","UseCaseAbstraction","expect","undefined","page1","page2","result1","result2","Error"],"mappings":";;;;;;;AAoBA,SAASA,WAAWC,KAAa;IAC7B,OAAO;QACH,IAAI,CAAC,KAAK,EAAEA,OAAO;QACnB,MAAM,CAAC,KAAK,EAAEA,OAAO;QACrB,KAAK,CAAC,WAAW,EAAEA,MAAM,IAAI,CAAC;QAC9B,KAAK,CAAC,mCAAmC,EAAEA,MAAM,IAAI,CAAC;QACtD,MAAM;QACN,MAAMA,AAAQ,MAARA;QACN,UAAU,CAAC;QACX,MAAM,EAAE;QACR,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;IACjC;AACJ;AAEA,SAASC,YAAYC,KAAa;IAC9B,OAAOC,MAAM,IAAI,CAAC;QAAE,QAAQD;IAAM,GAAG,CAACE,GAAGC,IAAMN,WAAWM;AAC9D;AAIA,SAASC,kBACLC,QAAkBN,YAAY,EAAE,EAChCO,OAAO;IAAE,QAAQ;IAAuB,cAAc;IAAO,YAAYD,MAAM,MAAM;AAAC,CAAC;IAEvF,MAAME,UAAUC,GAAG,EAAE;IACrBD,QAAQ,iBA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AAY,EAAE,IAAI,CAAC;QAGvC,MAAMC,UAAU,MAAMP,QAAQ,OAAO,CAAC;YAAE,OAAO;YAAG,OAAO;QAAe;QACxEE,OAAOK,QAAQ,IAAI,EAAE,OAAO,CAACF;QAC7BH,OAAOK,QAAQ,IAAI,CAAC,MAAM,EAAE,QAAQ;QACpCL,OAAOK,QAAQ,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC;QAGvCL,OAAOZ,MAAM,KAAK,IAAI,IAAI,CAAC;IAC/B;IAMAS,GAAG,mCAAmC;QAClCZ,YAAY,OAAO,CAAC,iBAAiB,CAAC,IAAIqB,MAAM;QAEhD,MAAMR,UAAUZ,UAAU,OAAO,CAACa;QAElC,MAAMC,OAAOF,QAAQ,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC;IACtD;AACJ"}
@@ -8,6 +8,7 @@ function createSettings(overrides) {
8
8
  uploadMinFileSize: "0",
9
9
  uploadMaxFileSize: "26214400",
10
10
  srcPrefix: "https://cdn.example.com/files/",
11
+ defaultSrcPrefix: "https://api.example.com/files/",
11
12
  ...overrides
12
13
  };
13
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/settings/GetSettings.test.js","sources":["../../../src/features/settings/GetSettings.test.ts"],"sourcesContent":["import { describe, it, expect, vi, beforeEach } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport {\n GetSettingsUseCase as UseCaseAbstraction,\n GetSettingsRepository as RepositoryAbstraction,\n GetSettingsGateway as GatewayAbstraction,\n SaveSettingsGateway as SaveGatewayAbstraction,\n type IGetSettingsGateway,\n type ISaveSettingsGateway\n} from \"./abstractions.js\";\nimport { GetSettingsUseCase } from \"./GetSettingsUseCase.js\";\nimport { GetSettingsRepository } from \"./GetSettingsRepository.js\";\nimport type { FmSettings } from \"../shared/types.js\";\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction createSettings(overrides?: Partial<FmSettings>): FmSettings {\n return {\n uploadMinFileSize: \"0\",\n uploadMaxFileSize: \"26214400\",\n srcPrefix: \"https://cdn.example.com/files/\",\n ...overrides\n };\n}\n\ntype MockGateway = IGetSettingsGateway & { execute: ReturnType<typeof vi.fn> };\n\nfunction createMockGateway(settings: FmSettings = createSettings()): MockGateway {\n const execute = vi.fn<() => Promise<FmSettings>>();\n execute.mockResolvedValue(settings);\n return { execute };\n}\n\ntype MockSaveGateway = ISaveSettingsGateway & { execute: ReturnType<typeof vi.fn> };\n\nfunction createMockSaveGateway(): MockSaveGateway {\n const execute = vi.fn<(data: FmSettings) => Promise<FmSettings>>();\n execute.mockImplementation(async (data: FmSettings) => data);\n return { execute };\n}\n\nfunction createContainer(mockGateway: MockGateway) {\n const container = new Container();\n\n // Register the mock gateway instances.\n container.registerInstance(GatewayAbstraction, mockGateway);\n container.registerInstance(SaveGatewayAbstraction, createMockSaveGateway());\n\n // Register the real repository and use case.\n container.register(GetSettingsRepository).inSingletonScope();\n container.register(GetSettingsUseCase);\n\n return container;\n}\n\n// ---------------------------------------------------------------------------\n// Tests\n// ---------------------------------------------------------------------------\n\ndescribe(\"GetSettings 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.\n // -----------------------------------------------------------------------\n\n it(\"should call gateway to retrieve settings\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute();\n\n expect(mockGateway.execute).toHaveBeenCalledTimes(1);\n });\n\n // -----------------------------------------------------------------------\n // UseCase returns settings.\n // -----------------------------------------------------------------------\n\n it(\"should return settings from the gateway\", async () => {\n const settings = createSettings({ srcPrefix: \"https://custom.cdn/files/\" });\n mockGateway.execute.mockResolvedValue(settings);\n\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute();\n\n expect(result).toEqual(settings);\n });\n\n // -----------------------------------------------------------------------\n // Repository caches settings as MobX observable state.\n // -----------------------------------------------------------------------\n\n it(\"should cache settings in the repository after fetch\", async () => {\n const settings = createSettings();\n mockGateway.execute.mockResolvedValue(settings);\n\n const repository = container.resolve(RepositoryAbstraction);\n\n // Initially null.\n expect(repository.settings).toBeNull();\n\n await repository.execute();\n\n // Settings should be cached.\n expect(repository.settings).toEqual(settings);\n });\n\n // -----------------------------------------------------------------------\n // Repository updates cached settings on subsequent calls.\n // -----------------------------------------------------------------------\n\n it(\"should update cached settings on subsequent fetches\", async () => {\n const initial = createSettings({ uploadMaxFileSize: \"26214400\" });\n const updated = createSettings({ uploadMaxFileSize: \"52428800\" });\n\n mockGateway.execute.mockResolvedValueOnce(initial).mockResolvedValueOnce(updated);\n\n const repository = container.resolve(RepositoryAbstraction);\n\n // First fetch.\n await repository.execute();\n expect(repository.settings).toEqual(initial);\n\n // Second fetch.\n await repository.execute();\n expect(repository.settings).toEqual(updated);\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 // Repository settings remain null on error.\n // -----------------------------------------------------------------------\n\n it(\"should not update cached settings when gateway throws\", async () => {\n mockGateway.execute.mockRejectedValue(new Error(\"Server error\"));\n\n const repository = container.resolve(RepositoryAbstraction);\n\n await expect(repository.execute()).rejects.toThrow(\"Server error\");\n\n // Settings should remain null.\n expect(repository.settings).toBeNull();\n });\n});\n"],"names":["createSettings","overrides","createMockGateway","settings","execute","vi","createMockSaveGateway","data","createContainer","mockGateway","container","Container","GatewayAbstraction","SaveGatewayAbstraction","GetSettingsRepository","GetSettingsUseCase","describe","beforeEach","it","useCase","UseCaseAbstraction","expect","result","repository","RepositoryAbstraction","initial","updated","Error"],"mappings":";;;;;AAkBA,SAASA,eAAeC,SAA+B;IACnD,OAAO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OE,WAAW,QAAQ,EAAE,OAAO,CAACpB;IACxC;IAMAe,GAAG,uDAAuD;QACtD,MAAMO,UAAUzB,eAAe;YAAE,mBAAmB;QAAW;QAC/D,MAAM0B,UAAU1B,eAAe;YAAE,mBAAmB;QAAW;QAE/DS,YAAY,OAAO,CAAC,qBAAqB,CAACgB,SAAS,qBAAqB,CAACC;QAEzE,MAAMH,aAAab,UAAU,OAAO,CAACc;QAGrC,MAAMD,WAAW,OAAO;QACxBF,OAAOE,WAAW,QAAQ,EAAE,OAAO,CAACE;QAGpC,MAAMF,WAAW,OAAO;QACxBF,OAAOE,WAAW,QAAQ,EAAE,OAAO,CAACG;IACxC;IAMAR,GAAG,mCAAmC;QAClCT,YAAY,OAAO,CAAC,iBAAiB,CAAC,IAAIkB,MAAM;QAEhD,MAAMR,UAAUT,UAAU,OAAO,CAACU;QAElC,MAAMC,OAAOF,QAAQ,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IACpD;IAMAD,GAAG,yDAAyD;QACxDT,YAAY,OAAO,CAAC,iBAAiB,CAAC,IAAIkB,MAAM;QAEhD,MAAMJ,aAAab,UAAU,OAAO,CAACc;QAErC,MAAMH,OAAOE,WAAW,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;QAGnDF,OAAOE,WAAW,QAAQ,EAAE,QAAQ;IACxC;AACJ"}
1
+ {"version":3,"file":"features/settings/GetSettings.test.js","sources":["../../../src/features/settings/GetSettings.test.ts"],"sourcesContent":["import { describe, it, expect, vi, beforeEach } from \"vitest\";\nimport type { Mock } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport {\n GetSettingsUseCase as UseCaseAbstraction,\n GetSettingsRepository as RepositoryAbstraction,\n GetSettingsGateway as GatewayAbstraction,\n SaveSettingsGateway as SaveGatewayAbstraction,\n type IGetSettingsGateway,\n type ISaveSettingsGateway\n} from \"./abstractions.js\";\nimport { GetSettingsUseCase } from \"./GetSettingsUseCase.js\";\nimport { GetSettingsRepository } from \"./GetSettingsRepository.js\";\nimport type { FmSettings } from \"../shared/types.js\";\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction createSettings(overrides?: Partial<FmSettings>): FmSettings {\n return {\n uploadMinFileSize: \"0\",\n uploadMaxFileSize: \"26214400\",\n srcPrefix: \"https://cdn.example.com/files/\",\n defaultSrcPrefix: \"https://api.example.com/files/\",\n ...overrides\n };\n}\n\ntype MockGateway = IGetSettingsGateway & { execute: Mock };\n\nfunction createMockGateway(settings: FmSettings = createSettings()): MockGateway {\n const execute = vi.fn<() => Promise<FmSettings>>();\n execute.mockResolvedValue(settings);\n return { execute };\n}\n\ntype MockSaveGateway = ISaveSettingsGateway & { execute: Mock };\n\nfunction createMockSaveGateway(): MockSaveGateway {\n const execute = vi.fn<(data: FmSettings) => Promise<FmSettings>>();\n execute.mockImplementation(async (data: FmSettings) => data);\n return { execute };\n}\n\nfunction createContainer(mockGateway: MockGateway) {\n const container = new Container();\n\n // Register the mock gateway instances.\n container.registerInstance(GatewayAbstraction, mockGateway);\n container.registerInstance(SaveGatewayAbstraction, createMockSaveGateway());\n\n // Register the real repository and use case.\n container.register(GetSettingsRepository).inSingletonScope();\n container.register(GetSettingsUseCase);\n\n return container;\n}\n\n// ---------------------------------------------------------------------------\n// Tests\n// ---------------------------------------------------------------------------\n\ndescribe(\"GetSettings 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.\n // -----------------------------------------------------------------------\n\n it(\"should call gateway to retrieve settings\", async () => {\n const useCase = container.resolve(UseCaseAbstraction);\n\n await useCase.execute();\n\n expect(mockGateway.execute).toHaveBeenCalledTimes(1);\n });\n\n // -----------------------------------------------------------------------\n // UseCase returns settings.\n // -----------------------------------------------------------------------\n\n it(\"should return settings from the gateway\", async () => {\n const settings = createSettings({ srcPrefix: \"https://custom.cdn/files/\" });\n mockGateway.execute.mockResolvedValue(settings);\n\n const useCase = container.resolve(UseCaseAbstraction);\n const result = await useCase.execute();\n\n expect(result).toEqual(settings);\n });\n\n // -----------------------------------------------------------------------\n // Repository caches settings as MobX observable state.\n // -----------------------------------------------------------------------\n\n it(\"should cache settings in the repository after fetch\", async () => {\n const settings = createSettings();\n mockGateway.execute.mockResolvedValue(settings);\n\n const repository = container.resolve(RepositoryAbstraction);\n\n // Initially null.\n expect(repository.settings).toBeNull();\n\n await repository.execute();\n\n // Settings should be cached.\n expect(repository.settings).toEqual(settings);\n });\n\n // -----------------------------------------------------------------------\n // Repository updates cached settings on subsequent calls.\n // -----------------------------------------------------------------------\n\n it(\"should update cached settings on subsequent fetches\", async () => {\n const initial = createSettings({ uploadMaxFileSize: \"26214400\" });\n const updated = createSettings({ uploadMaxFileSize: \"52428800\" });\n\n mockGateway.execute.mockResolvedValueOnce(initial).mockResolvedValueOnce(updated);\n\n const repository = container.resolve(RepositoryAbstraction);\n\n // First fetch.\n await repository.execute();\n expect(repository.settings).toEqual(initial);\n\n // Second fetch.\n await repository.execute();\n expect(repository.settings).toEqual(updated);\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 // Repository settings remain null on error.\n // -----------------------------------------------------------------------\n\n it(\"should not update cached settings when gateway throws\", async () => {\n mockGateway.execute.mockRejectedValue(new Error(\"Server error\"));\n\n const repository = container.resolve(RepositoryAbstraction);\n\n await expect(repository.execute()).rejects.toThrow(\"Server error\");\n\n // Settings should remain null.\n expect(repository.settings).toBeNull();\n });\n});\n"],"names":["createSettings","overrides","createMockGateway","settings","execute","vi","createMockSaveGateway","data","createContainer","mockGateway","container","Container","GatewayAbstraction","SaveGatewayAbstraction","GetSettingsRepository","GetSettingsUseCase","describe","beforeEach","it","useCase","UseCaseAbstraction","expect","result","repository","RepositoryAbstraction","initial","updated","Error"],"mappings":";;;;;AAmBA,SAASA,eAAeC,SAA+B;IACnD,OAAO;QACH,mBAAmB;QACnB,mBAAmB;QACnB,WAAW;QACX,kBAAkB;QAClB,GAAGA,SAAS;IAChB;AACJ;AAIA,SAASC,kBAAkBC,WAAuBH,gBAAgB;IAC9D,MAAMI,UAAUC,GAAG,EAAE;IACrBD,QAAQ,iBAAiB,CAACD;IAC1B,OAAO;QAAEC;IAAQ;AACrB;AAIA,SAASE;IACL,MAAMF,UAAUC,GAAG,EAAE;IACrBD,QAAQ,kBAAkB,CAAC,OAAOG,OAAqBA;IACvD,OAAO;QAAEH;IAAQ;AACrB;AAEA,SAASI,gBAAgBC,WAAwB;IAC7C,MAAMC,YAAY,IAAIC;IAGtBD,UAAU,gBAAgB,CAACE,oBAAoBH;IAC/CC,UAAU,gBAAgB,CAACG,qBAAwBP;IAGnDI,UAAU,QAAQ,CAACI,yDAAuB,gBAAgB;IAC1DJ,UAAU,QAAQ,CAACK;IAEnB,OAAOL;AACX;AAMAM,SAAS,uBAAuB;IAC5B,IAAIP;IACJ,IAAIC;IAEJO,WAAW;QACPR,cAAcP;QACdQ,YAAYF,gBAAgBC;IAChC;IAMAS,GAAG,4CAA4C;QAC3C,MAAMC,UAAUT,UAAU,OAAO,CAACU;QAElC,MAAMD,QAAQ,OAAO;QAErBE,OAAOZ,YAAY,OAAO,EAAE,qBAAqB,CAAC;IACtD;IAMAS,GAAG,2CAA2C;QAC1C,MAAMf,WAAWH,eAAe;YAAE,WAAW;QAA4B;QACzES,YAAY,OAAO,CAAC,iBAAiB,CAACN;QAEtC,MAAMgB,UAAUT,UAAU,OAAO,CAACU;QAClC,MAAME,SAAS,MAAMH,QAAQ,OAAO;QAEpCE,OAAOC,QAAQ,OAAO,CAACnB;IAC3B;IAMAe,GAAG,uDAAuD;QACtD,MAAMf,WAAWH;QACjBS,YAAY,OAAO,CAAC,iBAAiB,CAACN;QAEtC,MAAMoB,aAAab,UAAU,OAAO,CAACc;QAGrCH,OAAOE,WAAW,QAAQ,EAAE,QAAQ;QAEpC,MAAMA,WAAW,OAAO;QAGxBF,OAAOE,WAAW,QAAQ,EAAE,OAAO,CAACpB;IACxC;IAMAe,GAAG,uDAAuD;QACtD,MAAMO,UAAUzB,eAAe;YAAE,mBAAmB;QAAW;QAC/D,MAAM0B,UAAU1B,eAAe;YAAE,mBAAmB;QAAW;QAE/DS,YAAY,OAAO,CAAC,qBAAqB,CAACgB,SAAS,qBAAqB,CAACC;QAEzE,MAAMH,aAAab,UAAU,OAAO,CAACc;QAGrC,MAAMD,WAAW,OAAO;QACxBF,OAAOE,WAAW,QAAQ,EAAE,OAAO,CAACE;QAGpC,MAAMF,WAAW,OAAO;QACxBF,OAAOE,WAAW,QAAQ,EAAE,OAAO,CAACG;IACxC;IAMAR,GAAG,mCAAmC;QAClCT,YAAY,OAAO,CAAC,iBAAiB,CAAC,IAAIkB,MAAM;QAEhD,MAAMR,UAAUT,UAAU,OAAO,CAACU;QAElC,MAAMC,OAAOF,QAAQ,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IACpD;IAMAD,GAAG,yDAAyD;QACxDT,YAAY,OAAO,CAAC,iBAAiB,CAAC,IAAIkB,MAAM;QAEhD,MAAMJ,aAAab,UAAU,OAAO,CAACc;QAErC,MAAMH,OAAOE,WAAW,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;QAGnDF,OAAOE,WAAW,QAAQ,EAAE,QAAQ;IACxC;AACJ"}
@@ -6,6 +6,7 @@ const GET_SETTINGS = `
6
6
  getSettings {
7
7
  data {
8
8
  srcPrefix
9
+ defaultSrcPrefix
9
10
  uploadMinFileSize
10
11
  uploadMaxFileSize
11
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/settings/GetSettingsGateway.js","sources":["../../../src/features/settings/GetSettingsGateway.ts"],"sourcesContent":["import { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient/index.js\";\nimport type { FmSettings } from \"../shared/types.js\";\nimport { GetSettingsGateway as GatewayAbstraction } from \"./abstractions.js\";\n\nconst GET_SETTINGS = /* GraphQL */ `\n query GetFileManagerSettings {\n fileManager {\n getSettings {\n data {\n srcPrefix\n uploadMinFileSize\n uploadMaxFileSize\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n\ninterface GetSettingsResponse {\n fileManager: {\n getSettings: {\n data: FmSettings | null;\n error: { code: string; message: string; data: unknown } | null;\n };\n };\n}\n\nclass GetSettingsGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: MainGraphQLClient.Interface) {}\n\n async execute(): Promise<FmSettings> {\n const response = await this.client.execute<GetSettingsResponse>({\n query: GET_SETTINGS\n });\n\n const { data, error } = response.fileManager.getSettings;\n\n if (error) {\n throw new Error(error.message);\n }\n\n if (!data) {\n throw new Error(\"No settings data returned.\");\n }\n\n return data;\n }\n}\n\nexport const GetSettingsGateway = GatewayAbstraction.createImplementation({\n implementation: GetSettingsGatewayImpl,\n dependencies: [MainGraphQLClient]\n});\n"],"names":["GET_SETTINGS","GetSettingsGatewayImpl","client","response","data","error","Error","GetSettingsGateway","GatewayAbstraction","MainGraphQLClient"],"mappings":";;AAIA,MAAMA,eAA6B,CAAC;;;;;;;;;;;;;;;;;AAiBpC,CAAC;AAWD,MAAMC;IACF,YAAoBC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAE1D,MAAM,UAA+B;QACjC,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAsB;YAC5D,OAAOH;QACX;QAEA,MAAM,EAAEI,IAAI,EAAEC,KAAK,EAAE,GAAGF,SAAS,WAAW,CAAC,WAAW;QAExD,IAAIE,OACA,MAAM,IAAIC,MAAMD,MAAM,OAAO;QAGjC,IAAI,CAACD,MACD,MAAM,IAAIE,MAAM;QAGpB,OAAOF;IACX;AACJ;AAEO,MAAMG,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBP;IAChB,cAAc;QAACQ;KAAkB;AACrC"}
1
+ {"version":3,"file":"features/settings/GetSettingsGateway.js","sources":["../../../src/features/settings/GetSettingsGateway.ts"],"sourcesContent":["import { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient/index.js\";\nimport type { FmSettings } from \"../shared/types.js\";\nimport { GetSettingsGateway as GatewayAbstraction } from \"./abstractions.js\";\n\nconst GET_SETTINGS = /* GraphQL */ `\n query GetFileManagerSettings {\n fileManager {\n getSettings {\n data {\n srcPrefix\n defaultSrcPrefix\n uploadMinFileSize\n uploadMaxFileSize\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n\ninterface GetSettingsResponse {\n fileManager: {\n getSettings: {\n data: FmSettings | null;\n error: { code: string; message: string; data: unknown } | null;\n };\n };\n}\n\nclass GetSettingsGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: MainGraphQLClient.Interface) {}\n\n async execute(): Promise<FmSettings> {\n const response = await this.client.execute<GetSettingsResponse>({\n query: GET_SETTINGS\n });\n\n const { data, error } = response.fileManager.getSettings;\n\n if (error) {\n throw new Error(error.message);\n }\n\n if (!data) {\n throw new Error(\"No settings data returned.\");\n }\n\n return data;\n }\n}\n\nexport const GetSettingsGateway = GatewayAbstraction.createImplementation({\n implementation: GetSettingsGatewayImpl,\n dependencies: [MainGraphQLClient]\n});\n"],"names":["GET_SETTINGS","GetSettingsGatewayImpl","client","response","data","error","Error","GetSettingsGateway","GatewayAbstraction","MainGraphQLClient"],"mappings":";;AAIA,MAAMA,eAA6B,CAAC;;;;;;;;;;;;;;;;;;AAkBpC,CAAC;AAWD,MAAMC;IACF,YAAoBC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAE1D,MAAM,UAA+B;QACjC,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAsB;YAC5D,OAAOH;QACX;QAEA,MAAM,EAAEI,IAAI,EAAEC,KAAK,EAAE,GAAGF,SAAS,WAAW,CAAC,WAAW;QAExD,IAAIE,OACA,MAAM,IAAIC,MAAMD,MAAM,OAAO;QAGjC,IAAI,CAACD,MACD,MAAM,IAAIE,MAAM;QAGpB,OAAOF;IACX;AACJ;AAEO,MAAMG,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBP;IAChB,cAAc;QAACQ;KAAkB;AACrC"}
@@ -1,4 +1,5 @@
1
1
  import type { FmSettings } from "../shared/types.js";
2
+ import type { FmSettingsInput } from "../shared/types.js";
2
3
  import { GetSettingsRepository as RepositoryAbstraction, GetSettingsGateway, SaveSettingsGateway } from "./abstractions.js";
3
4
  declare class GetSettingsRepositoryImpl implements RepositoryAbstraction.Interface {
4
5
  private gateway;
@@ -6,7 +7,7 @@ declare class GetSettingsRepositoryImpl implements RepositoryAbstraction.Interfa
6
7
  settings: FmSettings | null;
7
8
  constructor(gateway: GetSettingsGateway.Interface, saveGateway: SaveSettingsGateway.Interface);
8
9
  execute(): Promise<FmSettings>;
9
- save(data: FmSettings): Promise<FmSettings>;
10
+ save(data: FmSettingsInput): Promise<FmSettings>;
10
11
  }
11
12
  export declare const GetSettingsRepository: typeof GetSettingsRepositoryImpl & {
12
13
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetSettingsRepository>;
@@ -1 +1 @@
1
- {"version":3,"file":"features/settings/GetSettingsRepository.js","sources":["../../../src/features/settings/GetSettingsRepository.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport type { FmSettings } from \"../shared/types.js\";\nimport {\n GetSettingsRepository as RepositoryAbstraction,\n GetSettingsGateway,\n SaveSettingsGateway\n} from \"./abstractions.js\";\n\nclass GetSettingsRepositoryImpl implements RepositoryAbstraction.Interface {\n settings: FmSettings | null = null;\n\n constructor(\n private gateway: GetSettingsGateway.Interface,\n private saveGateway: SaveSettingsGateway.Interface\n ) {\n makeAutoObservable(this);\n }\n\n async execute(): Promise<FmSettings> {\n const result = await this.gateway.execute();\n\n runInAction(() => {\n this.settings = result;\n });\n\n return result;\n }\n\n async save(data: FmSettings): Promise<FmSettings> {\n const result = await this.saveGateway.execute(data);\n\n runInAction(() => {\n this.settings = result;\n });\n\n return result;\n }\n}\n\nexport const GetSettingsRepository = RepositoryAbstraction.createImplementation({\n implementation: GetSettingsRepositoryImpl,\n dependencies: [GetSettingsGateway, SaveSettingsGateway]\n});\n"],"names":["GetSettingsRepositoryImpl","gateway","saveGateway","makeAutoObservable","result","runInAction","data","GetSettingsRepository","RepositoryAbstraction","GetSettingsGateway","SaveSettingsGateway"],"mappings":";;AAQA,MAAMA;IAGF,YACYC,OAAqC,EACrCC,WAA0C,CACpD;aAFUD,OAAO,GAAPA;aACAC,WAAW,GAAXA;aAJZ,QAAQ,GAAsB;QAM1BC,mBAAmB,IAAI;IAC3B;IAEA,MAAM,UAA+B;QACjC,MAAMC,SAAS,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO;QAEzCC,YAAY;YACR,IAAI,CAAC,QAAQ,GAAGD;QACpB;QAEA,OAAOA;IACX;IAEA,MAAM,KAAKE,IAAgB,EAAuB;QAC9C,MAAMF,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACE;QAE9CD,YAAY;YACR,IAAI,CAAC,QAAQ,GAAGD;QACpB;QAEA,OAAOA;IACX;AACJ;AAEO,MAAMG,8CAAwBC,sBAAAA,oBAA0C,CAAC;IAC5E,gBAAgBR;IAChB,cAAc;QAACS;QAAoBC;KAAoB;AAC3D"}
1
+ {"version":3,"file":"features/settings/GetSettingsRepository.js","sources":["../../../src/features/settings/GetSettingsRepository.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport type { FmSettings } from \"../shared/types.js\";\nimport type { FmSettingsInput } from \"../shared/types.js\";\nimport {\n GetSettingsRepository as RepositoryAbstraction,\n GetSettingsGateway,\n SaveSettingsGateway\n} from \"./abstractions.js\";\n\nclass GetSettingsRepositoryImpl implements RepositoryAbstraction.Interface {\n settings: FmSettings | null = null;\n\n constructor(\n private gateway: GetSettingsGateway.Interface,\n private saveGateway: SaveSettingsGateway.Interface\n ) {\n makeAutoObservable(this);\n }\n\n async execute(): Promise<FmSettings> {\n const result = await this.gateway.execute();\n\n runInAction(() => {\n this.settings = result;\n });\n\n return result;\n }\n\n async save(data: FmSettingsInput): Promise<FmSettings> {\n const result = await this.saveGateway.execute(data);\n\n runInAction(() => {\n this.settings = result;\n });\n\n return result;\n }\n}\n\nexport const GetSettingsRepository = RepositoryAbstraction.createImplementation({\n implementation: GetSettingsRepositoryImpl,\n dependencies: [GetSettingsGateway, SaveSettingsGateway]\n});\n"],"names":["GetSettingsRepositoryImpl","gateway","saveGateway","makeAutoObservable","result","runInAction","data","GetSettingsRepository","RepositoryAbstraction","GetSettingsGateway","SaveSettingsGateway"],"mappings":";;AASA,MAAMA;IAGF,YACYC,OAAqC,EACrCC,WAA0C,CACpD;aAFUD,OAAO,GAAPA;aACAC,WAAW,GAAXA;aAJZ,QAAQ,GAAsB;QAM1BC,mBAAmB,IAAI;IAC3B;IAEA,MAAM,UAA+B;QACjC,MAAMC,SAAS,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO;QAEzCC,YAAY;YACR,IAAI,CAAC,QAAQ,GAAGD;QACpB;QAEA,OAAOA;IACX;IAEA,MAAM,KAAKE,IAAqB,EAAuB;QACnD,MAAMF,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACE;QAE9CD,YAAY;YACR,IAAI,CAAC,QAAQ,GAAGD;QACpB;QAEA,OAAOA;IACX;AACJ;AAEO,MAAMG,8CAAwBC,sBAAAA,oBAA0C,CAAC;IAC5E,gBAAgBR;IAChB,cAAc;QAACS;QAAoBC;KAAoB;AAC3D"}
@@ -1,10 +1,11 @@
1
1
  import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient/index.js";
2
2
  import type { FmSettings } from "../shared/types.js";
3
+ import type { FmSettingsInput } from "../shared/types.js";
3
4
  import { SaveSettingsGateway as GatewayAbstraction } from "./abstractions.js";
4
5
  declare class SaveSettingsGatewayImpl implements GatewayAbstraction.Interface {
5
6
  private client;
6
7
  constructor(client: MainGraphQLClient.Interface);
7
- execute(data: FmSettings): Promise<FmSettings>;
8
+ execute(data: FmSettingsInput): Promise<FmSettings>;
8
9
  }
9
10
  export declare const SaveSettingsGateway: typeof SaveSettingsGatewayImpl & {
10
11
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ISaveSettingsGateway>;
@@ -6,6 +6,7 @@ const UPDATE_SETTINGS = `
6
6
  updateSettings(data: $data) {
7
7
  data {
8
8
  srcPrefix
9
+ defaultSrcPrefix
9
10
  uploadMinFileSize
10
11
  uploadMaxFileSize
11
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/settings/SaveSettingsGateway.js","sources":["../../../src/features/settings/SaveSettingsGateway.ts"],"sourcesContent":["import { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient/index.js\";\nimport type { FmSettings } from \"../shared/types.js\";\nimport { SaveSettingsGateway as GatewayAbstraction } from \"./abstractions.js\";\n\nconst UPDATE_SETTINGS = /* GraphQL */ `\n mutation UpdateFileManagerSettings($data: FmSettingsInput) {\n fileManager {\n updateSettings(data: $data) {\n data {\n srcPrefix\n uploadMinFileSize\n uploadMaxFileSize\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n\ninterface UpdateSettingsResponse {\n fileManager: {\n updateSettings: {\n data: FmSettings | null;\n error: { code: string; message: string; data: unknown } | null;\n };\n };\n}\n\nclass SaveSettingsGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: MainGraphQLClient.Interface) {}\n\n async execute(data: FmSettings): Promise<FmSettings> {\n const response = await this.client.execute<UpdateSettingsResponse>({\n query: UPDATE_SETTINGS,\n variables: {\n data: {\n uploadMinFileSize: parseFloat(data.uploadMinFileSize),\n uploadMaxFileSize: parseFloat(data.uploadMaxFileSize),\n srcPrefix: data.srcPrefix\n }\n }\n });\n\n const { data: result, error } = response.fileManager.updateSettings;\n\n if (error) {\n throw new Error(error.message);\n }\n\n if (!result) {\n throw new Error(\"No settings data returned.\");\n }\n\n return result;\n }\n}\n\nexport const SaveSettingsGateway = GatewayAbstraction.createImplementation({\n implementation: SaveSettingsGatewayImpl,\n dependencies: [MainGraphQLClient]\n});\n"],"names":["UPDATE_SETTINGS","SaveSettingsGatewayImpl","client","data","response","parseFloat","result","error","Error","SaveSettingsGateway","GatewayAbstraction","MainGraphQLClient"],"mappings":";;AAIA,MAAMA,kBAAgC,CAAC;;;;;;;;;;;;;;;;;AAiBvC,CAAC;AAWD,MAAMC;IACF,YAAoBC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAE1D,MAAM,QAAQC,IAAgB,EAAuB;QACjD,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAyB;YAC/D,OAAOJ;YACP,WAAW;gBACP,MAAM;oBACF,mBAAmBK,WAAWF,KAAK,iBAAiB;oBACpD,mBAAmBE,WAAWF,KAAK,iBAAiB;oBACpD,WAAWA,KAAK,SAAS;gBAC7B;YACJ;QACJ;QAEA,MAAM,EAAE,MAAMG,MAAM,EAAEC,KAAK,EAAE,GAAGH,SAAS,WAAW,CAAC,cAAc;QAEnE,IAAIG,OACA,MAAM,IAAIC,MAAMD,MAAM,OAAO;QAGjC,IAAI,CAACD,QACD,MAAM,IAAIE,MAAM;QAGpB,OAAOF;IACX;AACJ;AAEO,MAAMG,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBT;IAChB,cAAc;QAACU;KAAkB;AACrC"}
1
+ {"version":3,"file":"features/settings/SaveSettingsGateway.js","sources":["../../../src/features/settings/SaveSettingsGateway.ts"],"sourcesContent":["import { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient/index.js\";\nimport type { FmSettings } from \"../shared/types.js\";\nimport type { FmSettingsInput } from \"../shared/types.js\";\nimport { SaveSettingsGateway as GatewayAbstraction } from \"./abstractions.js\";\n\nconst UPDATE_SETTINGS = /* GraphQL */ `\n mutation UpdateFileManagerSettings($data: FmSettingsInput) {\n fileManager {\n updateSettings(data: $data) {\n data {\n srcPrefix\n defaultSrcPrefix\n uploadMinFileSize\n uploadMaxFileSize\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n\ninterface UpdateSettingsResponse {\n fileManager: {\n updateSettings: {\n data: FmSettings | null;\n error: { code: string; message: string; data: unknown } | null;\n };\n };\n}\n\nclass SaveSettingsGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: MainGraphQLClient.Interface) {}\n\n async execute(data: FmSettingsInput): Promise<FmSettings> {\n const response = await this.client.execute<UpdateSettingsResponse>({\n query: UPDATE_SETTINGS,\n variables: {\n data: {\n uploadMinFileSize: parseFloat(data.uploadMinFileSize),\n uploadMaxFileSize: parseFloat(data.uploadMaxFileSize),\n srcPrefix: data.srcPrefix\n }\n }\n });\n\n const { data: result, error } = response.fileManager.updateSettings;\n\n if (error) {\n throw new Error(error.message);\n }\n\n if (!result) {\n throw new Error(\"No settings data returned.\");\n }\n\n return result;\n }\n}\n\nexport const SaveSettingsGateway = GatewayAbstraction.createImplementation({\n implementation: SaveSettingsGatewayImpl,\n dependencies: [MainGraphQLClient]\n});\n"],"names":["UPDATE_SETTINGS","SaveSettingsGatewayImpl","client","data","response","parseFloat","result","error","Error","SaveSettingsGateway","GatewayAbstraction","MainGraphQLClient"],"mappings":";;AAKA,MAAMA,kBAAgC,CAAC;;;;;;;;;;;;;;;;;;AAkBvC,CAAC;AAWD,MAAMC;IACF,YAAoBC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAE1D,MAAM,QAAQC,IAAqB,EAAuB;QACtD,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAyB;YAC/D,OAAOJ;YACP,WAAW;gBACP,MAAM;oBACF,mBAAmBK,WAAWF,KAAK,iBAAiB;oBACpD,mBAAmBE,WAAWF,KAAK,iBAAiB;oBACpD,WAAWA,KAAK,SAAS;gBAC7B;YACJ;QACJ;QAEA,MAAM,EAAE,MAAMG,MAAM,EAAEC,KAAK,EAAE,GAAGH,SAAS,WAAW,CAAC,cAAc;QAEnE,IAAIG,OACA,MAAM,IAAIC,MAAMD,MAAM,OAAO;QAGjC,IAAI,CAACD,QACD,MAAM,IAAIE,MAAM;QAGpB,OAAOF;IACX;AACJ;AAEO,MAAMG,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBT;IAChB,cAAc;QAACU;KAAkB;AACrC"}
@@ -1,4 +1,5 @@
1
1
  import type { FmSettings } from "../shared/types.js";
2
+ import type { FmSettingsInput } from "../shared/types.js";
2
3
  export interface IGetSettingsGateway {
3
4
  execute(): Promise<FmSettings>;
4
5
  }
@@ -7,7 +8,7 @@ export declare namespace GetSettingsGateway {
7
8
  type Interface = IGetSettingsGateway;
8
9
  }
9
10
  export interface ISaveSettingsGateway {
10
- execute(data: FmSettings): Promise<FmSettings>;
11
+ execute(data: FmSettingsInput): Promise<FmSettings>;
11
12
  }
12
13
  export declare const SaveSettingsGateway: import("@webiny/di").Abstraction<ISaveSettingsGateway>;
13
14
  export declare namespace SaveSettingsGateway {
@@ -15,7 +16,7 @@ export declare namespace SaveSettingsGateway {
15
16
  }
16
17
  export interface IGetSettingsRepository {
17
18
  execute(): Promise<FmSettings>;
18
- save(data: FmSettings): Promise<FmSettings>;
19
+ save(data: FmSettingsInput): Promise<FmSettings>;
19
20
  readonly settings: FmSettings | null;
20
21
  }
21
22
  export declare const GetSettingsRepository: import("@webiny/di").Abstraction<IGetSettingsRepository>;
@@ -1 +1 @@
1
- {"version":3,"file":"features/settings/abstractions.js","sources":["../../../src/features/settings/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { FmSettings } from \"../shared/types.js\";\n\n// Gateway — performs the GraphQL call to retrieve settings.\nexport interface IGetSettingsGateway {\n execute(): Promise<FmSettings>;\n}\n\nexport const GetSettingsGateway = createAbstraction<IGetSettingsGateway>(\"GetSettingsGateway\");\n\nexport namespace GetSettingsGateway {\n export type Interface = IGetSettingsGateway;\n}\n\n// Gateway — performs the GraphQL mutation to save settings.\nexport interface ISaveSettingsGateway {\n execute(data: FmSettings): Promise<FmSettings>;\n}\n\nexport const SaveSettingsGateway = createAbstraction<ISaveSettingsGateway>(\"SaveSettingsGateway\");\n\nexport namespace SaveSettingsGateway {\n export type Interface = ISaveSettingsGateway;\n}\n\n// Repository — caches settings as MobX observable state.\nexport interface IGetSettingsRepository {\n execute(): Promise<FmSettings>;\n save(data: FmSettings): Promise<FmSettings>;\n readonly settings: FmSettings | null;\n}\n\nexport const GetSettingsRepository =\n createAbstraction<IGetSettingsRepository>(\"GetSettingsRepository\");\n\nexport namespace GetSettingsRepository {\n export type Interface = IGetSettingsRepository;\n}\n\n// UseCase — orchestrates a single get-settings operation.\nexport interface IGetSettingsUseCase {\n execute(): Promise<FmSettings>;\n}\n\nexport const GetSettingsUseCase = createAbstraction<IGetSettingsUseCase>(\"GetSettingsUseCase\");\n\nexport namespace GetSettingsUseCase {\n export type Interface = IGetSettingsUseCase;\n}\n"],"names":["GetSettingsGateway","createAbstraction","SaveSettingsGateway","GetSettingsRepository","GetSettingsUseCase"],"mappings":";AAQO,MAAMA,qBAAqBC,kBAAuC;AAWlE,MAAMC,sBAAsBD,kBAAwC;AAapE,MAAME,wBACTF,kBAA0C;AAWvC,MAAMG,qBAAqBH,kBAAuC"}
1
+ {"version":3,"file":"features/settings/abstractions.js","sources":["../../../src/features/settings/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { FmSettings } from \"../shared/types.js\";\nimport type { FmSettingsInput } from \"../shared/types.js\";\n\n// Gateway — performs the GraphQL call to retrieve settings.\nexport interface IGetSettingsGateway {\n execute(): Promise<FmSettings>;\n}\n\nexport const GetSettingsGateway = createAbstraction<IGetSettingsGateway>(\"GetSettingsGateway\");\n\nexport namespace GetSettingsGateway {\n export type Interface = IGetSettingsGateway;\n}\n\n// Gateway — performs the GraphQL mutation to save settings.\nexport interface ISaveSettingsGateway {\n execute(data: FmSettingsInput): Promise<FmSettings>;\n}\n\nexport const SaveSettingsGateway = createAbstraction<ISaveSettingsGateway>(\"SaveSettingsGateway\");\n\nexport namespace SaveSettingsGateway {\n export type Interface = ISaveSettingsGateway;\n}\n\n// Repository — caches settings as MobX observable state.\nexport interface IGetSettingsRepository {\n execute(): Promise<FmSettings>;\n save(data: FmSettingsInput): Promise<FmSettings>;\n readonly settings: FmSettings | null;\n}\n\nexport const GetSettingsRepository =\n createAbstraction<IGetSettingsRepository>(\"GetSettingsRepository\");\n\nexport namespace GetSettingsRepository {\n export type Interface = IGetSettingsRepository;\n}\n\n// UseCase — orchestrates a single get-settings operation.\nexport interface IGetSettingsUseCase {\n execute(): Promise<FmSettings>;\n}\n\nexport const GetSettingsUseCase = createAbstraction<IGetSettingsUseCase>(\"GetSettingsUseCase\");\n\nexport namespace GetSettingsUseCase {\n export type Interface = IGetSettingsUseCase;\n}\n"],"names":["GetSettingsGateway","createAbstraction","SaveSettingsGateway","GetSettingsRepository","GetSettingsUseCase"],"mappings":";AASO,MAAMA,qBAAqBC,kBAAuC;AAWlE,MAAMC,sBAAsBD,kBAAwC;AAapE,MAAME,wBACTF,kBAA0C;AAWvC,MAAMG,qBAAqBH,kBAAuC"}
@@ -24,6 +24,10 @@ const FILE_FIELDS = [
24
24
  "metadata.image.height",
25
25
  "metadata.image.format",
26
26
  "metadata.image.orientation",
27
+ "metadata.image.crop",
28
+ "metadata.image.focalPoint",
29
+ "metadata.image.alt",
30
+ "metadata.image.caption",
27
31
  "metadata.exif",
28
32
  "metadata.iptc"
29
33
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"features/shared/FILE_FIELDS.js","sources":["../../../src/features/shared/FILE_FIELDS.ts"],"sourcesContent":["export const FILE_FIELDS = [\n \"id\",\n \"name\",\n \"description\",\n \"key\",\n \"src\",\n \"type\",\n \"size\",\n \"tags\",\n \"createdOn\",\n \"savedOn\",\n \"modifiedOn\",\n \"createdBy.id\",\n \"createdBy.displayName\",\n \"createdBy.type\",\n \"savedBy.id\",\n \"savedBy.displayName\",\n \"savedBy.type\",\n \"modifiedBy.id\",\n \"modifiedBy.displayName\",\n \"modifiedBy.type\",\n \"location.folderId\",\n \"metadata.image.width\",\n \"metadata.image.height\",\n \"metadata.image.format\",\n \"metadata.image.orientation\",\n \"metadata.exif\",\n \"metadata.iptc\"\n];\n"],"names":["FILE_FIELDS"],"mappings":"AAAO,MAAMA,cAAc;IACvB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH"}
1
+ {"version":3,"file":"features/shared/FILE_FIELDS.js","sources":["../../../src/features/shared/FILE_FIELDS.ts"],"sourcesContent":["export const FILE_FIELDS = [\n \"id\",\n \"name\",\n \"description\",\n \"key\",\n \"src\",\n \"type\",\n \"size\",\n \"tags\",\n \"createdOn\",\n \"savedOn\",\n \"modifiedOn\",\n \"createdBy.id\",\n \"createdBy.displayName\",\n \"createdBy.type\",\n \"savedBy.id\",\n \"savedBy.displayName\",\n \"savedBy.type\",\n \"modifiedBy.id\",\n \"modifiedBy.displayName\",\n \"modifiedBy.type\",\n \"location.folderId\",\n \"metadata.image.width\",\n \"metadata.image.height\",\n \"metadata.image.format\",\n \"metadata.image.orientation\",\n \"metadata.image.crop\",\n \"metadata.image.focalPoint\",\n \"metadata.image.alt\",\n \"metadata.image.caption\",\n \"metadata.exif\",\n \"metadata.iptc\"\n];\n"],"names":["FILE_FIELDS"],"mappings":"AAAO,MAAMA,cAAc;IACvB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH"}
@@ -1,12 +1,12 @@
1
- import { WcpService } from "@webiny/app-admin/features/wcp/abstractions.js";
1
+ import { FeatureFlagsService } from "@webiny/app-admin/features/featureFlags/abstractions.js";
2
2
  import { FileFieldsProvider as Abstraction } from "./abstractions.js";
3
- declare class FileFieldsProviderWithWcpImpl implements Abstraction.Interface {
4
- private wcp;
3
+ declare class FileFieldsProviderWithFeatureFlagsImpl implements Abstraction.Interface {
4
+ private featureFlagsService;
5
5
  private decoratee;
6
- constructor(wcp: WcpService.Interface, decoratee: Abstraction.Interface);
6
+ constructor(featureFlagsService: FeatureFlagsService.Interface, decoratee: Abstraction.Interface);
7
7
  execute(): Promise<string[]>;
8
8
  }
9
- export declare const FileFieldsProviderWithWcp: typeof FileFieldsProviderWithWcpImpl & {
9
+ export declare const FileFieldsProviderWithWcp: typeof FileFieldsProviderWithFeatureFlagsImpl & {
10
10
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IFileFieldsProvider>;
11
11
  };
12
12
  export {};
@@ -1,13 +1,13 @@
1
- import { WcpService } from "@webiny/app-admin/features/wcp/abstractions.js";
1
+ import { FeatureFlagsService } from "@webiny/app-admin/features/featureFlags/abstractions.js";
2
2
  import { FileFieldsProvider } from "./abstractions.js";
3
- class FileFieldsProviderWithWcpImpl {
4
- constructor(wcp, decoratee){
5
- this.wcp = wcp;
3
+ class FileFieldsProviderWithFeatureFlagsImpl {
4
+ constructor(featureFlagsService, decoratee){
5
+ this.featureFlagsService = featureFlagsService;
6
6
  this.decoratee = decoratee;
7
7
  }
8
8
  async execute() {
9
9
  const fields = await this.decoratee.execute();
10
- if (this.wcp.getProject().canUsePrivateFiles()) return [
10
+ if (this.featureFlagsService.getFlags().isEnabled("advancedAccessControlLayer.privateFiles")) return [
11
11
  ...fields,
12
12
  "accessControl.type"
13
13
  ];
@@ -15,9 +15,9 @@ class FileFieldsProviderWithWcpImpl {
15
15
  }
16
16
  }
17
17
  const FileFieldsProviderWithWcp = FileFieldsProvider.createDecorator({
18
- decorator: FileFieldsProviderWithWcpImpl,
18
+ decorator: FileFieldsProviderWithFeatureFlagsImpl,
19
19
  dependencies: [
20
- WcpService
20
+ FeatureFlagsService
21
21
  ]
22
22
  });
23
23
  export { FileFieldsProviderWithWcp };