@webiny/app-headless-cms 6.5.0-beta.0 → 6.5.0-beta.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 (208) hide show
  1. package/ContentEntriesModule.js +14 -2
  2. package/ContentEntriesModule.js.map +1 -1
  3. package/admin/components/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
  4. package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
  5. package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
  6. package/admin/components/ContentEntries/BulkActions/ActionMove.js.map +1 -1
  7. package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
  8. package/admin/components/ContentEntries/BulkActions/ActionPublish.js.map +1 -1
  9. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
  10. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.js.map +1 -1
  11. package/admin/components/ContentEntries/Filters/RefFieldRenderer.d.ts +2 -0
  12. package/admin/components/ContentEntries/Filters/RefFieldRenderer.js +84 -0
  13. package/admin/components/ContentEntries/Filters/RefFieldRenderer.js.map +1 -0
  14. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.d.ts +2 -0
  15. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js +34 -0
  16. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js.map +1 -0
  17. package/admin/components/ContentEntries/Table/Actions/index.d.ts +1 -0
  18. package/admin/components/ContentEntries/Table/Actions/index.js +1 -0
  19. package/admin/components/ContentModelEditor/ContentModelEditor.js +1 -1
  20. package/admin/components/ContentModelEditor/ContentModelEditor.js.map +1 -1
  21. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.d.ts +2 -0
  22. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js +22 -0
  23. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js.map +1 -0
  24. package/admin/components/FieldEditor/EditFieldDialog.d.ts +2 -2
  25. package/admin/components/FieldEditor/Field.js +4 -4
  26. package/admin/components/FieldEditor/Field.js.map +1 -1
  27. package/features/contentEntry/CmsEntryError.d.ts +10 -0
  28. package/features/contentEntry/CmsEntryError.js +11 -0
  29. package/features/contentEntry/CmsEntryError.js.map +1 -0
  30. package/features/contentEntry/createEntry/CreateEntryGateway.d.ts +0 -1
  31. package/features/contentEntry/createEntry/CreateEntryGateway.js +3 -10
  32. package/features/contentEntry/createEntry/CreateEntryGateway.js.map +1 -1
  33. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.d.ts +3 -1
  34. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js +8 -3
  35. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js.map +1 -1
  36. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.d.ts +14 -0
  37. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js +43 -0
  38. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js.map +1 -0
  39. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.d.ts +15 -0
  40. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js +34 -0
  41. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js.map +1 -0
  42. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.d.ts +11 -0
  43. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js +18 -0
  44. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js.map +1 -0
  45. package/features/contentEntry/duplicateEntry/abstractions.d.ts +26 -0
  46. package/features/contentEntry/duplicateEntry/abstractions.js +7 -0
  47. package/features/contentEntry/duplicateEntry/abstractions.js.map +1 -0
  48. package/features/contentEntry/duplicateEntry/feature.d.ts +3 -0
  49. package/features/contentEntry/duplicateEntry/feature.js +21 -0
  50. package/features/contentEntry/duplicateEntry/feature.js.map +1 -0
  51. package/features/contentEntry/entryValueGateways.test.d.ts +1 -0
  52. package/features/contentEntry/entryValueGateways.test.js +106 -0
  53. package/features/contentEntry/entryValueGateways.test.js.map +1 -0
  54. package/features/contentEntry/feature.js +2 -0
  55. package/features/contentEntry/feature.js.map +1 -1
  56. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.d.ts +0 -1
  57. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js +3 -10
  58. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js.map +1 -1
  59. package/features/contentEntry/updateEntry/UpdateEntryGateway.d.ts +0 -1
  60. package/features/contentEntry/updateEntry/UpdateEntryGateway.js +3 -10
  61. package/features/contentEntry/updateEntry/UpdateEntryGateway.js.map +1 -1
  62. package/features/contentEntry/valueTransformers/EntryDataPreparer.d.ts +9 -0
  63. package/features/contentEntry/valueTransformers/EntryDataPreparer.js +8 -0
  64. package/features/contentEntry/valueTransformers/EntryDataPreparer.js.map +1 -1
  65. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.d.ts +1 -0
  66. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js +113 -0
  67. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js.map +1 -0
  68. package/features/contentEntry/valueTransformers/entryValueFixtures.d.ts +146 -0
  69. package/features/contentEntry/valueTransformers/entryValueFixtures.js +171 -0
  70. package/features/contentEntry/valueTransformers/entryValueFixtures.js.map +1 -0
  71. package/features/formModel/CmsFormModelBuilder.d.ts +9 -1
  72. package/features/formModel/CmsFormModelBuilder.js +26 -15
  73. package/features/formModel/CmsFormModelBuilder.js.map +1 -1
  74. package/features/formModel/CmsFormModelBuilder.test.d.ts +1 -0
  75. package/features/formModel/CmsFormModelBuilder.test.js +252 -0
  76. package/features/formModel/CmsFormModelBuilder.test.js.map +1 -0
  77. package/features/formModel/CmsLayoutMapper.d.ts +8 -1
  78. package/features/formModel/CmsLayoutMapper.js +23 -1
  79. package/features/formModel/CmsLayoutMapper.js.map +1 -1
  80. package/features/formModel/mappers/DynamicZoneFieldMapper.js +4 -0
  81. package/features/formModel/mappers/DynamicZoneFieldMapper.js.map +1 -1
  82. package/features/formModel/mappers/ObjectFieldMapper.js +11 -6
  83. package/features/formModel/mappers/ObjectFieldMapper.js.map +1 -1
  84. package/features/model/exportModels/ExportModelsGateway.d.ts +1 -1
  85. package/features/model/exportModels/ExportModelsGateway.js.map +1 -1
  86. package/features/model/exportModels/ExportModelsUseCase.js +7 -1
  87. package/features/model/exportModels/ExportModelsUseCase.js.map +1 -1
  88. package/features/model/exportModels/abstractions.d.ts +8 -2
  89. package/features/model/exportModels/abstractions.js.map +1 -1
  90. package/package.json +26 -26
  91. package/presentation/cloneContentModel/CloneContentModelPresenter.d.ts +1 -0
  92. package/presentation/cloneContentModel/CloneContentModelPresenter.js +8 -6
  93. package/presentation/cloneContentModel/CloneContentModelPresenter.js.map +1 -1
  94. package/presentation/contentEntries/form/ContentEntryFormPresenter.js +34 -29
  95. package/presentation/contentEntries/form/ContentEntryFormPresenter.js.map +1 -1
  96. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.d.ts +1 -0
  97. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js +210 -0
  98. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js.map +1 -0
  99. package/presentation/contentEntries/form/toFormErrors.d.ts +7 -0
  100. package/presentation/contentEntries/form/toFormErrors.js +49 -0
  101. package/presentation/contentEntries/form/toFormErrors.js.map +1 -0
  102. package/presentation/contentEntries/form/toFormErrors.test.d.ts +1 -0
  103. package/presentation/contentEntries/form/toFormErrors.test.js +175 -0
  104. package/presentation/contentEntries/form/toFormErrors.test.js.map +1 -0
  105. package/presentation/contentEntries/list/ContentEntriesDataSource.d.ts +5 -0
  106. package/presentation/contentEntries/list/ContentEntriesDataSource.js +11 -2
  107. package/presentation/contentEntries/list/ContentEntriesDataSource.js.map +1 -1
  108. package/presentation/contentEntries/list/ContentEntriesPresenter.d.ts +6 -2
  109. package/presentation/contentEntries/list/ContentEntriesPresenter.js +27 -2
  110. package/presentation/contentEntries/list/ContentEntriesPresenter.js.map +1 -1
  111. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +130 -5
  112. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
  113. package/presentation/contentEntries/list/abstractions.d.ts +12 -0
  114. package/presentation/contentEntries/list/abstractions.js.map +1 -1
  115. package/presentation/contentEntries/preview/LivePreviewPresenter.d.ts +12 -1
  116. package/presentation/contentEntries/preview/LivePreviewPresenter.js +48 -5
  117. package/presentation/contentEntries/preview/LivePreviewPresenter.js.map +1 -1
  118. package/presentation/contentEntries/preview/LivePreviewPresenter.test.d.ts +1 -0
  119. package/presentation/contentEntries/preview/LivePreviewPresenter.test.js +81 -0
  120. package/presentation/contentEntries/preview/LivePreviewPresenter.test.js.map +1 -0
  121. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js +1 -1
  122. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js.map +1 -1
  123. package/presentation/contentEntries/preview/PreviewDecorator.js +25 -6
  124. package/presentation/contentEntries/preview/PreviewDecorator.js.map +1 -1
  125. package/presentation/contentEntries/preview/PreviewDomainStatus.d.ts +10 -0
  126. package/presentation/contentEntries/preview/PreviewDomainStatus.js +19 -0
  127. package/presentation/contentEntries/preview/PreviewDomainStatus.js.map +1 -0
  128. package/presentation/contentEntries/preview/PreviewPane.d.ts +10 -1
  129. package/presentation/contentEntries/preview/PreviewPane.js +81 -45
  130. package/presentation/contentEntries/preview/PreviewPane.js.map +1 -1
  131. package/presentation/contentEntries/preview/abstractions.d.ts +8 -0
  132. package/presentation/contentEntries/preview/abstractions.js.map +1 -1
  133. package/presentation/contentEntries/preview/resolvePreviewUrl.d.ts +21 -0
  134. package/presentation/contentEntries/preview/resolvePreviewUrl.js +50 -1
  135. package/presentation/contentEntries/preview/resolvePreviewUrl.js.map +1 -1
  136. package/presentation/contentEntries/preview/resolvePreviewUrl.test.d.ts +1 -0
  137. package/presentation/contentEntries/preview/resolvePreviewUrl.test.js +127 -0
  138. package/presentation/contentEntries/preview/resolvePreviewUrl.test.js.map +1 -0
  139. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js +9 -4
  140. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js.map +1 -1
  141. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.d.ts +1 -0
  142. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js +122 -0
  143. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js.map +1 -0
  144. package/presentation/contentEntries/trashBin/CmsTrashBin.d.ts +2 -2
  145. package/presentation/contentEntries/views/CmsAdvancedSearch.d.ts +2 -2
  146. package/presentation/contentEntries/views/ContentEntriesListLayout.d.ts +2 -2
  147. package/presentation/contentEntries/views/ContentEntryFormView.d.ts +2 -2
  148. package/presentation/contentEntries/views/OlderRevisionAlert.d.ts +2 -2
  149. package/presentation/contentEntries/views/RevisionDrawer.d.ts +2 -2
  150. package/presentation/contentEntries/views/RevisionsList.d.ts +2 -2
  151. package/presentation/contentEntries/views/SingleEntryLayout.d.ts +2 -2
  152. package/presentation/contentEntries/views/Table/Table.d.ts +2 -2
  153. package/presentation/contentEntries/views/actions/CreateNewRevisionButton.d.ts +2 -2
  154. package/presentation/contentEntries/views/actions/DeleteEntryMenuItem.d.ts +2 -2
  155. package/presentation/contentEntries/views/actions/PublishOnlyButton.d.ts +2 -2
  156. package/presentation/contentEntries/views/actions/RevisionSelector.d.ts +2 -2
  157. package/presentation/contentEntries/views/actions/SaveAndPublishButton.d.ts +2 -2
  158. package/presentation/contentEntries/views/actions/SaveContentButton.d.ts +2 -2
  159. package/presentation/contentEntries/views/actions/ShowRevisionListMenuItem.d.ts +2 -2
  160. package/presentation/contentEntries/views/layout/ContentEntryForm.d.ts +12 -12
  161. package/presentation/contentModels/ContentModelsPresenter.d.ts +5 -5
  162. package/presentation/contentModels/ContentModelsPresenter.js +1 -1
  163. package/presentation/contentModels/ContentModelsPresenter.js.map +1 -1
  164. package/presentation/contentModels/abstractions.d.ts +7 -2
  165. package/presentation/contentModels/abstractions.js.map +1 -1
  166. package/presentation/contentModels/components/CloneContentModelDialog.d.ts +2 -2
  167. package/presentation/contentModels/components/ContentModels.d.ts +2 -2
  168. package/presentation/contentModels/components/ContentModelsDataList.d.ts +2 -2
  169. package/presentation/contentModels/components/ContentModelsDataList.js +6 -5
  170. package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
  171. package/presentation/contentModels/components/NewContentModelDialog.d.ts +2 -2
  172. package/presentation/contentModels/components/fullDelete/dialog/Content.js +2 -2
  173. package/presentation/contentModels/components/fullDelete/dialog/Content.js.map +1 -1
  174. package/presentation/contentModels/components/fullDelete/types.js.map +1 -1
  175. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.d.ts +1 -0
  176. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js +133 -0
  177. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js.map +1 -0
  178. package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js +1 -1
  179. package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js.map +1 -1
  180. package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js +1 -1
  181. package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js.map +1 -1
  182. package/presentation/fieldRenderers/ref/components/RefFieldOptions.d.ts +2 -2
  183. package/presentation/fieldRenderers/ref/components/RefFieldOptions.js +3 -2
  184. package/presentation/fieldRenderers/ref/components/RefFieldOptions.js.map +1 -1
  185. package/presentation/importContentModels/ImportContentModelsDialog.d.ts +2 -2
  186. package/presentation/importContentModels/ImportContentModelsPresenter.js +1 -1
  187. package/presentation/importContentModels/ImportContentModelsPresenter.js.map +1 -1
  188. package/presentation/importContentModels/components/DataList.d.ts +2 -2
  189. package/presentation/importContentModels/components/FileUpload.d.ts +2 -2
  190. package/presentation/importContentModels/components/FileUpload.js +1 -1
  191. package/presentation/importContentModels/components/FileUpload.js.map +1 -1
  192. package/presentation/importContentModels/components/Model/DataListModelItem.js +3 -3
  193. package/presentation/importContentModels/components/Model/DataListModelItem.js.map +1 -1
  194. package/presentation/importContentModels/components/Model/DataListModelItemInfo.js +2 -2
  195. package/presentation/importContentModels/components/Model/DataListModelItemInfo.js.map +1 -1
  196. package/presentation/importContentModels/components/Model/DataListModels.d.ts +2 -2
  197. package/presentation/menus/ContentGroupsMenuItems.d.ts +2 -2
  198. package/presentation/modelGroup/ModelGroupPresenter.js +1 -2
  199. package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
  200. package/presentation/modelGroup/components/ContentModelGroups.d.ts +2 -2
  201. package/presentation/modelGroup/components/ContentModelGroupsDataList.d.ts +6 -2
  202. package/presentation/modelGroup/components/ContentModelGroupsForm.d.ts +8 -2
  203. package/presentation/newContentModel/NewContentModelPresenter.d.ts +1 -0
  204. package/presentation/newContentModel/NewContentModelPresenter.js +8 -6
  205. package/presentation/newContentModel/NewContentModelPresenter.js.map +1 -1
  206. package/utils/normalizeIcon.d.ts +4 -0
  207. package/utils/normalizeIcon.js +9 -6
  208. package/utils/normalizeIcon.js.map +1 -1
@@ -19,6 +19,28 @@ function mapCmsLayout(cmsLayout, layoutBuilder, idToFieldId) {
19
19
  }
20
20
  return nodes;
21
21
  }
22
+ function collectFieldIds(layout, idToFieldId) {
23
+ const fieldIds = new Set();
24
+ for (const row of layout)for (const cell of row)if ("string" == typeof cell) {
25
+ const fieldId = idToFieldId.get(cell);
26
+ if (fieldId) fieldIds.add(fieldId);
27
+ } else if (isLayoutField(cell) && "tabs" === cell.type) {
28
+ const tabsField = cell;
29
+ for (const tab of tabsField.tabs)for (const id of collectFieldIds(tab.layout, idToFieldId))fieldIds.add(id);
30
+ }
31
+ return fieldIds;
32
+ }
33
+ function mapCmsNestedLayout(cmsLayout, fields) {
34
+ if (!cmsLayout || 0 === cmsLayout.length) return;
35
+ const idToFieldId = new Map();
36
+ for (const field of fields)idToFieldId.set(field.id, field.fieldId);
37
+ const fieldIdsInLayout = collectFieldIds(cmsLayout, idToFieldId);
38
+ return (layoutBuilder)=>{
39
+ const nodes = mapCmsLayout(cmsLayout, layoutBuilder, idToFieldId);
40
+ for (const field of fields)if (!fieldIdsInLayout.has(field.fieldId)) nodes.push(layoutBuilder.row(field.fieldId));
41
+ return nodes;
42
+ };
43
+ }
22
44
  function mapLayoutField(field, layoutBuilder, idToFieldId) {
23
45
  switch(field.type){
24
46
  case "separator":
@@ -83,6 +105,6 @@ function mapAlert(field, layoutBuilder) {
83
105
  })));
84
106
  return builder;
85
107
  }
86
- export { mapCmsLayout };
108
+ export { collectFieldIds, mapCmsLayout, mapCmsNestedLayout };
87
109
 
88
110
  //# sourceMappingURL=CmsLayoutMapper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features/formModel/CmsLayoutMapper.js","sources":["../../../src/features/formModel/CmsLayoutMapper.ts"],"sourcesContent":["import {\n isLayoutField,\n type CmsEditorFieldsLayout,\n type CmsLayoutField,\n type CmsSeparatorLayoutField,\n type CmsTabLayoutField,\n type CmsAlertLayoutField\n} from \"~/types.js\";\nimport type {\n ILayoutBuilder,\n ILayoutNodeBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\n\nexport function mapCmsLayout(\n cmsLayout: CmsEditorFieldsLayout,\n layoutBuilder: ILayoutBuilder,\n idToFieldId: Map<string, string>\n): ILayoutNodeBuilder[] {\n const nodes: ILayoutNodeBuilder[] = [];\n\n for (const row of cmsLayout) {\n if (row.length === 0) {\n continue;\n }\n\n const firstCell = row[0];\n\n if (row.length === 1 && isLayoutField(firstCell)) {\n const layoutField = firstCell as CmsLayoutField;\n const node = mapLayoutField(layoutField, layoutBuilder, idToFieldId);\n if (node) {\n nodes.push(node);\n }\n continue;\n }\n\n const fieldIds: string[] = [];\n for (const cell of row) {\n if (typeof cell === \"string\") {\n const fieldId = idToFieldId.get(cell);\n if (fieldId) {\n fieldIds.push(fieldId);\n }\n }\n }\n\n if (fieldIds.length > 0) {\n nodes.push(layoutBuilder.row(...fieldIds));\n }\n }\n\n return nodes;\n}\n\nfunction mapLayoutField(\n field: CmsLayoutField,\n layoutBuilder: ILayoutBuilder,\n idToFieldId: Map<string, string>\n): ILayoutNodeBuilder | null {\n switch (field.type) {\n case \"separator\":\n return mapSeparator(field as CmsSeparatorLayoutField, layoutBuilder);\n\n case \"tabs\":\n return mapTabs(field as CmsTabLayoutField, layoutBuilder, idToFieldId);\n\n case \"alert\":\n return mapAlert(field as CmsAlertLayoutField, layoutBuilder);\n\n default:\n return null;\n }\n}\n\nfunction mapSeparator(\n field: CmsSeparatorLayoutField,\n layoutBuilder: ILayoutBuilder\n): ILayoutNodeBuilder {\n const builder = layoutBuilder.separator();\n if (field.label) {\n builder.title(field.label);\n }\n if (field.description) {\n builder.description(field.description);\n }\n if (field.rules) {\n builder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n return builder;\n}\n\nfunction mapTabs(\n field: CmsTabLayoutField,\n layoutBuilder: ILayoutBuilder,\n idToFieldId: Map<string, string>\n): ILayoutNodeBuilder {\n const tabsBuilder = layoutBuilder.tabs(field.id);\n\n for (const tab of field.tabs) {\n tabsBuilder.tab(tab.id, t => {\n t.label(tab.label);\n if (tab.icon) {\n t.icon({ type: \"icon\", name: tab.icon });\n }\n t.layout(l => mapCmsLayout(tab.layout, l, idToFieldId));\n if (tab.rules) {\n t.rules(\n tab.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n });\n }\n\n if (field.rules) {\n tabsBuilder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n\n return tabsBuilder;\n}\n\nfunction mapAlert(field: CmsAlertLayoutField, layoutBuilder: ILayoutBuilder): ILayoutNodeBuilder {\n const builder = layoutBuilder.alert();\n if (field.label) {\n builder.message(field.label);\n }\n if (field.alertType) {\n builder.alertType(field.alertType);\n }\n if (field.rules) {\n builder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n return builder;\n}\n"],"names":["mapCmsLayout","cmsLayout","layoutBuilder","idToFieldId","nodes","row","firstCell","isLayoutField","layoutField","node","mapLayoutField","fieldIds","cell","fieldId","field","mapSeparator","mapTabs","mapAlert","builder","r","tabsBuilder","tab","t","l"],"mappings":";AAaO,SAASA,aACZC,SAAgC,EAChCC,aAA6B,EAC7BC,WAAgC;IAEhC,MAAMC,QAA8B,EAAE;IAEtC,KAAK,MAAMC,OAAOJ,UAAW;QACzB,IAAII,AAAe,MAAfA,IAAI,MAAM,EACV;QAGJ,MAAMC,YAAYD,GAAG,CAAC,EAAE;QAExB,IAAIA,AAAe,MAAfA,IAAI,MAAM,IAAUE,cAAcD,YAAY;YAC9C,MAAME,cAAcF;YACpB,MAAMG,OAAOC,eAAeF,aAAaN,eAAeC;YACxD,IAAIM,MACAL,MAAM,IAAI,CAACK;YAEf;QACJ;QAEA,MAAME,WAAqB,EAAE;QAC7B,KAAK,MAAMC,QAAQP,IACf,IAAI,AAAgB,YAAhB,OAAOO,MAAmB;YAC1B,MAAMC,UAAUV,YAAY,GAAG,CAACS;YAChC,IAAIC,SACAF,SAAS,IAAI,CAACE;QAEtB;QAGJ,IAAIF,SAAS,MAAM,GAAG,GAClBP,MAAM,IAAI,CAACF,cAAc,GAAG,IAAIS;IAExC;IAEA,OAAOP;AACX;AAEA,SAASM,eACLI,KAAqB,EACrBZ,aAA6B,EAC7BC,WAAgC;IAEhC,OAAQW,MAAM,IAAI;QACd,KAAK;YACD,OAAOC,aAAaD,OAAkCZ;QAE1D,KAAK;YACD,OAAOc,QAAQF,OAA4BZ,eAAeC;QAE9D,K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AAM,KAAK,CAAC,GAAG,CAACK,CAAAA,IAAM;YAClB,MAAMA,EAAE,IAAI;YACZ,QAAQA,EAAE,MAAM;YAChB,UAAUA,EAAE,QAAQ;YACpB,OAAOA,EAAE,KAAK,IAAI;YAClB,QAAQA,EAAE,MAAM;QACpB;IAIR,OAAOC;AACX;AAEA,SAASH,SAASH,KAA0B,EAAEZ,aAA6B;IACvE,MAAMgB,UAAUhB,cAAc,KAAK;IACnC,IAAIY,MAAM,KAAK,EACXI,QAAQ,OAAO,CAACJ,MAAM,KAAK;IAE/B,IAAIA,MAAM,SAAS,EACfI,QAAQ,SAAS,CAACJ,MAAM,SAAS;IAErC,IAAIA,MAAM,KAAK,EACXI,QAAQ,KAAK,CACTJ,MAAM,KAAK,CAAC,GAAG,CAACK,CAAAA,IAAM;YAClB,MAAMA,EAAE,IAAI;YACZ,QAAQA,EAAE,MAAM;YAChB,UAAUA,EAAE,QAAQ;YACpB,OAAOA,EAAE,KAAK,IAAI;YAClB,QAAQA,EAAE,MAAM;QACpB;IAGR,OAAOD;AACX"}
1
+ {"version":3,"file":"features/formModel/CmsLayoutMapper.js","sources":["../../../src/features/formModel/CmsLayoutMapper.ts"],"sourcesContent":["import {\n isLayoutField,\n type CmsEditorFieldsLayout,\n type CmsLayoutField,\n type CmsModelField,\n type CmsSeparatorLayoutField,\n type CmsTabLayoutField,\n type CmsAlertLayoutField\n} from \"~/types.js\";\nimport type {\n ILayoutBuilder,\n ILayoutNodeBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\n\nexport function mapCmsLayout(\n cmsLayout: CmsEditorFieldsLayout,\n layoutBuilder: ILayoutBuilder,\n idToFieldId: Map<string, string>\n): ILayoutNodeBuilder[] {\n const nodes: ILayoutNodeBuilder[] = [];\n\n for (const row of cmsLayout) {\n if (row.length === 0) {\n continue;\n }\n\n const firstCell = row[0];\n\n if (row.length === 1 && isLayoutField(firstCell)) {\n const layoutField = firstCell as CmsLayoutField;\n const node = mapLayoutField(layoutField, layoutBuilder, idToFieldId);\n if (node) {\n nodes.push(node);\n }\n continue;\n }\n\n const fieldIds: string[] = [];\n for (const cell of row) {\n if (typeof cell === \"string\") {\n const fieldId = idToFieldId.get(cell);\n if (fieldId) {\n fieldIds.push(fieldId);\n }\n }\n }\n\n if (fieldIds.length > 0) {\n nodes.push(layoutBuilder.row(...fieldIds));\n }\n }\n\n return nodes;\n}\n\nexport function collectFieldIds(\n layout: CmsEditorFieldsLayout,\n idToFieldId: Map<string, string>\n): Set<string> {\n const fieldIds = new Set<string>();\n\n for (const row of layout) {\n for (const cell of row) {\n if (typeof cell === \"string\") {\n const fieldId = idToFieldId.get(cell);\n if (fieldId) {\n fieldIds.add(fieldId);\n }\n } else if (isLayoutField(cell) && cell.type === \"tabs\") {\n const tabsField = cell as { tabs: Array<{ layout: CmsEditorFieldsLayout }> };\n for (const tab of tabsField.tabs) {\n for (const id of collectFieldIds(tab.layout, idToFieldId)) {\n fieldIds.add(id);\n }\n }\n }\n }\n }\n\n return fieldIds;\n}\n\n/**\n * Maps the layout stored on an object field or a dynamic zone template. Returns `undefined`\n * when there is no layout, so the form falls back to one row per child. Children missing\n * from the layout get a row of their own at the end, so a stale layout can't hide them.\n */\nexport function mapCmsNestedLayout(\n cmsLayout: CmsEditorFieldsLayout | undefined,\n fields: CmsModelField[]\n): ((layoutBuilder: ILayoutBuilder) => ILayoutNodeBuilder[]) | undefined {\n if (!cmsLayout || cmsLayout.length === 0) {\n return undefined;\n }\n\n const idToFieldId = new Map<string, string>();\n for (const field of fields) {\n idToFieldId.set(field.id, field.fieldId);\n }\n\n const fieldIdsInLayout = collectFieldIds(cmsLayout, idToFieldId);\n\n return layoutBuilder => {\n const nodes = mapCmsLayout(cmsLayout, layoutBuilder, idToFieldId);\n for (const field of fields) {\n if (!fieldIdsInLayout.has(field.fieldId)) {\n nodes.push(layoutBuilder.row(field.fieldId));\n }\n }\n return nodes;\n };\n}\n\nfunction mapLayoutField(\n field: CmsLayoutField,\n layoutBuilder: ILayoutBuilder,\n idToFieldId: Map<string, string>\n): ILayoutNodeBuilder | null {\n switch (field.type) {\n case \"separator\":\n return mapSeparator(field as CmsSeparatorLayoutField, layoutBuilder);\n\n case \"tabs\":\n return mapTabs(field as CmsTabLayoutField, layoutBuilder, idToFieldId);\n\n case \"alert\":\n return mapAlert(field as CmsAlertLayoutField, layoutBuilder);\n\n default:\n return null;\n }\n}\n\nfunction mapSeparator(\n field: CmsSeparatorLayoutField,\n layoutBuilder: ILayoutBuilder\n): ILayoutNodeBuilder {\n const builder = layoutBuilder.separator();\n if (field.label) {\n builder.title(field.label);\n }\n if (field.description) {\n builder.description(field.description);\n }\n if (field.rules) {\n builder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n return builder;\n}\n\nfunction mapTabs(\n field: CmsTabLayoutField,\n layoutBuilder: ILayoutBuilder,\n idToFieldId: Map<string, string>\n): ILayoutNodeBuilder {\n const tabsBuilder = layoutBuilder.tabs(field.id);\n\n for (const tab of field.tabs) {\n tabsBuilder.tab(tab.id, t => {\n t.label(tab.label);\n if (tab.icon) {\n t.icon({ type: \"icon\", name: tab.icon });\n }\n t.layout(l => mapCmsLayout(tab.layout, l, idToFieldId));\n if (tab.rules) {\n t.rules(\n tab.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n });\n }\n\n if (field.rules) {\n tabsBuilder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n\n return tabsBuilder;\n}\n\nfunction mapAlert(field: CmsAlertLayoutField, layoutBuilder: ILayoutBuilder): ILayoutNodeBuilder {\n const builder = layoutBuilder.alert();\n if (field.label) {\n builder.message(field.label);\n }\n if (field.alertType) {\n builder.alertType(field.alertType);\n }\n if (field.rules) {\n builder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n return builder;\n}\n"],"names":["mapCmsLayout","cmsLayout","layoutBuilder","idToFieldId","nodes","row","firstCell","isLayoutField","layoutField","node","mapLayoutField","fieldIds","cell","fieldId","collectFieldIds","layout","Set","tabsField","tab","id","mapCmsNestedLayout","fields","Map","field","fieldIdsInLayout","mapSeparator","mapTabs","mapAlert","builder","r","tabsBuilder","t","l"],"mappings":";AAcO,SAASA,aACZC,SAAgC,EAChCC,aAA6B,EAC7BC,WAAgC;IAEhC,MAAMC,QAA8B,EAAE;IAEtC,KAAK,MAAMC,OAAOJ,UAAW;QACzB,IAAII,AAAe,MAAfA,IAAI,MAAM,EACV;QAGJ,MAAMC,YAAYD,GAAG,CAAC,EAAE;QAExB,IAAIA,AAAe,MAAfA,IAAI,MAAM,IAAUE,cAAcD,YAAY;YAC9C,MAAME,cAAcF;YACpB,MAAMG,OAAOC,eAAeF,aAAaN,eAAeC;YACxD,IAAIM,MACAL,MAAM,IAAI,CAACK;YAEf;QACJ;QAEA,MAAME,WAAqB,EAAE;QAC7B,KAAK,MAAMC,QAAQP,IACf,IAAI,AAAgB,YAAhB,OAAOO,MAAmB;YAC1B,MAAMC,UAAUV,YAAY,GAAG,CAACS;YAChC,IAAIC,SACAF,SAAS,IAAI,CAACE;QAEtB;QAGJ,IAAIF,SAAS,MAAM,GAAG,GAClBP,MAAM,IAAI,CAACF,cAAc,GAAG,IAAIS;IAExC;IAEA,OAAOP;AACX;AAEO,SAASU,gBACZC,MAA6B,EAC7BZ,WAAgC;IAEhC,MAAMQ,WAAW,IAAIK;IAErB,KAAK,MAAMX,OAAOU,OACd,KAAK,MAAMH,QAAQP,IACf,IAAI,AAAgB,YAAhB,OAAOO,MAAmB;QAC1B,MAAMC,UAAUV,YAAY,GAAG,CAACS;QAChC,IAAIC,SACAF,S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O,CAACL,MAAM,KAAK;IAE/B,IAAIA,MAAM,SAAS,EACfK,QAAQ,SAAS,CAACL,MAAM,SAAS;IAErC,IAAIA,MAAM,KAAK,EACXK,QAAQ,KAAK,CACTL,MAAM,KAAK,CAAC,GAAG,CAACM,CAAAA,IAAM;YAClB,MAAMA,EAAE,IAAI;YACZ,QAAQA,EAAE,MAAM;YAChB,UAAUA,EAAE,QAAQ;YACpB,OAAOA,EAAE,KAAK,IAAI;YAClB,QAAQA,EAAE,MAAM;QACpB;IAGR,OAAOD;AACX"}
@@ -1,4 +1,5 @@
1
1
  import { applyFieldProps } from "./applyFieldProps.js";
2
+ import { mapCmsNestedLayout } from "../CmsLayoutMapper.js";
2
3
  import { generateAlphaNumericLowerCaseId } from "@webiny/utils/generateId";
3
4
  class DynamicZoneFieldMapper {
4
5
  map(field, registry, context) {
@@ -6,6 +7,7 @@ class DynamicZoneFieldMapper {
6
7
  const templates = field.settings?.templates;
7
8
  if (templates) for (const template of templates)builder.template(template.id, (t)=>{
8
9
  t.label(template.name);
10
+ if (template.description) t.description(template.description);
9
11
  if (template.icon) {
10
12
  const icon = template.icon;
11
13
  if ("object" == typeof icon && "name" in icon) t.icon(icon);
@@ -20,6 +22,8 @@ class DynamicZoneFieldMapper {
20
22
  if (template.fields && template.fields.length > 0) for (const child of template.fields)result[child.fieldId] = context.mapField(child, childRegistry);
21
23
  return result;
22
24
  });
25
+ const layout = mapCmsNestedLayout(template.layout, template.fields ?? []);
26
+ if (layout) t.layout(layout);
23
27
  });
24
28
  return applyFieldProps(builder, field, context.rendererMap);
25
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/formModel/mappers/DynamicZoneFieldMapper.js","sources":["../../../../src/features/formModel/mappers/DynamicZoneFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type {\n IFieldBuilder,\n IFieldBuilderRegistry,\n IObjectFieldBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField, CmsDynamicZoneTemplate } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport type { ITemplateIcon } from \"@webiny/app-admin/features/formModel/index.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils/generateId\";\n\nexport class DynamicZoneFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"dynamicZone\";\n\n map(\n field: CmsModelField,\n registry: IFieldBuilderRegistry,\n context: ICmsFieldMapperContext\n ): IFieldBuilder {\n const builder = registry.object() as IObjectFieldBuilder;\n\n const templates = field.settings?.templates as CmsDynamicZoneTemplate[] | undefined;\n if (templates) {\n for (const template of templates) {\n builder.template(template.id, t => {\n t.label(template.name);\n if (template.icon) {\n const icon = template.icon;\n if (typeof icon === \"object\" && \"name\" in icon) {\n t.icon(icon as ITemplateIcon);\n } else if (typeof icon === \"string\") {\n t.icon({ type: \"icon\", name: icon });\n }\n }\n t.fields(childRegistry => {\n const result: Record<string, IFieldBuilder> = {};\n result[\"_id\"] = childRegistry\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericLowerCaseId(12))\n .cloneValue(() => generateAlphaNumericLowerCaseId(12));\n if (template.fields && template.fields.length > 0) {\n for (const child of template.fields) {\n result[child.fieldId] = context.mapField(child, childRegistry);\n }\n }\n return result;\n });\n });\n }\n }\n\n return applyFieldProps(builder, field, context.rendererMap);\n }\n}\n"],"names":["DynamicZoneFieldMapper","field","registry","context","builder","templates","template","t","icon","childRegistry","result","generateAlphaNumericLowerCaseId","child","applyFieldProps"],"mappings":";;AAWO,MAAMA;IAGT,IACIC,KAAoB,EACpBC,QAA+B,EAC/BC,OAA+B,EAClB;QACb,MAAMC,UAAUF,SAAS,MAAM;QAE/B,MAAMG,YAAYJ,MAAM,QAAQ,EAAE;QAClC,IAAII,WACA,KAAK,MAAMC,YAAYD,UACnBD,QAAQ,QAAQ,CAACE,SAAS,EAAE,EAAEC,CAAAA;YAC1BA,EAAE,KAAK,CAACD,SAAS,IAAI;YACrB,IAAIA,SAAS,IAAI,EAAE;gBACf,MAAME,OAAOF,SAAS,IAAI;gBAC1B,IAAI,AAAgB,YAAhB,OAAOE,QAAqB,UAAUA,MACtCD,EAAE,IAAI,CAACC;qBACJ,IAAI,AAAgB,YAAhB,OAAOA,MACdD,EAAE,IAAI,CAAC;oBAAE,MAAM;oBAAQ,MAAMC;gBAAK;YAE1C;YACAD,EAAE,MAAM,CAACE,CAAAA;gBACL,MAAMC,SAAwC,CAAC;gBAC/CA,MAAM,CAAC,MAAM,GAAGD,cACX,IAAI,GACJ,MAAM,GACN,YAAY,CAAC,IAAME,gCAAgC,KACnD,UAAU,CAAC,IAAMA,gCAAgC;gBACtD,IAAIL,SAAS,MAAM,IAAIA,SAAS,MAAM,CAAC,MAAM,GAAG,GAC5C,KAAK,MAAMM,SAASN,SAAS,MAAM,CAC/BI,MAAM,CAACE,MAAM,OAAO,CAAC,GAAGT,QAAQ,QAAQ,CAACS,OAAOH;gBAGxD,OAAOC;YACX;QACJ;QAIR,OAAOG,gBAAgBT,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aAzCS,IAAI,GAAG;;AA0CpB"}
1
+ {"version":3,"file":"features/formModel/mappers/DynamicZoneFieldMapper.js","sources":["../../../../src/features/formModel/mappers/DynamicZoneFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type {\n IFieldBuilder,\n IFieldBuilderRegistry,\n IObjectFieldBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField, CmsDynamicZoneTemplate } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport { mapCmsNestedLayout } from \"../CmsLayoutMapper.js\";\nimport type { ITemplateIcon } from \"@webiny/app-admin/features/formModel/index.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils/generateId\";\n\nexport class DynamicZoneFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"dynamicZone\";\n\n map(\n field: CmsModelField,\n registry: IFieldBuilderRegistry,\n context: ICmsFieldMapperContext\n ): IFieldBuilder {\n const builder = registry.object() as IObjectFieldBuilder;\n\n const templates = field.settings?.templates as CmsDynamicZoneTemplate[] | undefined;\n if (templates) {\n for (const template of templates) {\n builder.template(template.id, t => {\n t.label(template.name);\n if (template.description) {\n t.description(template.description);\n }\n if (template.icon) {\n const icon = template.icon;\n if (typeof icon === \"object\" && \"name\" in icon) {\n t.icon(icon as ITemplateIcon);\n } else if (typeof icon === \"string\") {\n t.icon({ type: \"icon\", name: icon });\n }\n }\n t.fields(childRegistry => {\n const result: Record<string, IFieldBuilder> = {};\n result[\"_id\"] = childRegistry\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericLowerCaseId(12))\n .cloneValue(() => generateAlphaNumericLowerCaseId(12));\n if (template.fields && template.fields.length > 0) {\n for (const child of template.fields) {\n result[child.fieldId] = context.mapField(child, childRegistry);\n }\n }\n return result;\n });\n const layout = mapCmsNestedLayout(template.layout, template.fields ?? []);\n if (layout) {\n t.layout(layout);\n }\n });\n }\n }\n\n return applyFieldProps(builder, field, context.rendererMap);\n }\n}\n"],"names":["DynamicZoneFieldMapper","field","registry","context","builder","templates","template","t","icon","childRegistry","result","generateAlphaNumericLowerCaseId","child","layout","mapCmsNestedLayout","applyFieldProps"],"mappings":";;;AAYO,MAAMA;IAGT,IACIC,KAAoB,EACpBC,QAA+B,EAC/BC,OAA+B,EAClB;QACb,MAAMC,UAAUF,SAAS,MAAM;QAE/B,MAAMG,YAAYJ,MAAM,QAAQ,EAAE;QAClC,IAAII,WACA,KAAK,MAAMC,YAAYD,UACnBD,QAAQ,QAAQ,CAACE,SAAS,EAAE,EAAEC,CAAAA;YAC1BA,EAAE,KAAK,CAACD,SAAS,IAAI;YACrB,IAAIA,SAAS,WAAW,EACpBC,EAAE,WAAW,CAACD,SAAS,WAAW;YAEtC,IAAIA,SAAS,IAAI,EAAE;gBACf,MAAME,OAAOF,SAAS,IAAI;gBAC1B,IAAI,AAAgB,YAAhB,OAAOE,QAAqB,UAAUA,MACtCD,EAAE,IAAI,CAACC;qBACJ,IAAI,AAAgB,YAAhB,OAAOA,MACdD,EAAE,IAAI,CAAC;oBAAE,MAAM;oBAAQ,MAAMC;gBAAK;YAE1C;YACAD,EAAE,MAAM,CAACE,CAAAA;gBACL,MAAMC,SAAwC,CAAC;gBAC/CA,MAAM,CAAC,MAAM,GAAGD,cACX,IAAI,GACJ,MAAM,GACN,YAAY,CAAC,IAAME,gCAAgC,KACnD,UAAU,CAAC,IAAMA,gCAAgC;gBACtD,IAAIL,SAAS,MAAM,IAAIA,SAAS,MAAM,CAAC,MAAM,GAAG,GAC5C,KAAK,MAAMM,SAASN,SAAS,MAAM,CAC/BI,MAAM,CAACE,MAAM,OAAO,CAAC,GAAGT,QAAQ,QAAQ,CAACS,OAAOH;gBAGxD,OAAOC;YACX;YACA,MAAMG,SAASC,mBAAmBR,SAAS,MAAM,EAAEA,SAAS,MAAM,IAAI,EAAE;YACxE,IAAIO,QACAN,EAAE,MAAM,CAACM;QAEjB;QAIR,OAAOE,gBAAgBX,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aAhDS,IAAI,GAAG;;AAiDpB"}
@@ -1,15 +1,20 @@
1
1
  import { applyFieldProps } from "./applyFieldProps.js";
2
+ import { mapCmsNestedLayout } from "../CmsLayoutMapper.js";
2
3
  import { generateAlphaNumericLowerCaseId } from "@webiny/utils/generateId";
3
4
  class ObjectFieldMapper {
4
5
  map(field, registry, context) {
5
6
  const builder = registry.object();
6
7
  const childFields = field.settings?.fields;
7
- if (childFields && childFields.length > 0) builder.fields((childRegistry)=>{
8
- const result = {};
9
- result["_id"] = childRegistry.text().hidden().defaultValue(()=>generateAlphaNumericLowerCaseId(12)).cloneValue(()=>generateAlphaNumericLowerCaseId(12));
10
- for (const child of childFields)result[child.fieldId] = context.mapField(child, childRegistry);
11
- return result;
12
- });
8
+ if (childFields && childFields.length > 0) {
9
+ builder.fields((childRegistry)=>{
10
+ const result = {};
11
+ result["_id"] = childRegistry.text().hidden().defaultValue(()=>generateAlphaNumericLowerCaseId(12)).cloneValue(()=>generateAlphaNumericLowerCaseId(12));
12
+ for (const child of childFields)result[child.fieldId] = context.mapField(child, childRegistry);
13
+ return result;
14
+ });
15
+ const layout = mapCmsNestedLayout(field.settings?.layout, childFields);
16
+ if (layout) builder.layout(layout);
17
+ }
13
18
  return applyFieldProps(builder, field, context.rendererMap);
14
19
  }
15
20
  constructor(){
@@ -1 +1 @@
1
- {"version":3,"file":"features/formModel/mappers/ObjectFieldMapper.js","sources":["../../../../src/features/formModel/mappers/ObjectFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type {\n IFieldBuilder,\n IFieldBuilderRegistry,\n IObjectFieldBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils/generateId\";\n\nexport class ObjectFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"object\";\n\n map(\n field: CmsModelField,\n registry: IFieldBuilderRegistry,\n context: ICmsFieldMapperContext\n ): IFieldBuilder {\n const builder = registry.object() as IObjectFieldBuilder;\n\n const childFields = field.settings?.fields;\n if (childFields && childFields.length > 0) {\n builder.fields(childRegistry => {\n const result: Record<string, IFieldBuilder> = {};\n result[\"_id\"] = childRegistry\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericLowerCaseId(12))\n .cloneValue(() => generateAlphaNumericLowerCaseId(12));\n for (const child of childFields) {\n result[child.fieldId] = context.mapField(child, childRegistry);\n }\n return result;\n });\n }\n\n return applyFieldProps(builder, field, context.rendererMap);\n }\n}\n"],"names":["ObjectFieldMapper","field","registry","context","builder","childFields","childRegistry","result","generateAlphaNumericLowerCaseId","child","applyFieldProps"],"mappings":";;AAUO,MAAMA;IAGT,IACIC,KAAoB,EACpBC,QAA+B,EAC/BC,OAA+B,EAClB;QACb,MAAMC,UAAUF,SAAS,MAAM;QAE/B,MAAMG,cAAcJ,MAAM,QAAQ,EAAE;QACpC,IAAII,eAAeA,YAAY,MAAM,GAAG,GACpCD,QAAQ,MAAM,CAACE,CAAAA;YACX,MAAMC,SAAwC,CAAC;YAC/CA,MAAM,CAAC,MAAM,GAAGD,cACX,IAAI,GACJ,MAAM,GACN,YAAY,CAAC,IAAME,gCAAgC,KACnD,UAAU,CAAC,IAAMA,gCAAgC;YACtD,KAAK,MAAMC,SAASJ,YAChBE,MAAM,CAACE,MAAM,OAAO,CAAC,GAAGN,QAAQ,QAAQ,CAACM,OAAOH;YAEpD,OAAOC;QACX;QAGJ,OAAOG,gBAAgBN,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aA1BS,IAAI,GAAG;;AA2BpB"}
1
+ {"version":3,"file":"features/formModel/mappers/ObjectFieldMapper.js","sources":["../../../../src/features/formModel/mappers/ObjectFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type {\n IFieldBuilder,\n IFieldBuilderRegistry,\n IObjectFieldBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport { mapCmsNestedLayout } from \"../CmsLayoutMapper.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils/generateId\";\n\nexport class ObjectFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"object\";\n\n map(\n field: CmsModelField,\n registry: IFieldBuilderRegistry,\n context: ICmsFieldMapperContext\n ): IFieldBuilder {\n const builder = registry.object() as IObjectFieldBuilder;\n\n const childFields = field.settings?.fields;\n if (childFields && childFields.length > 0) {\n builder.fields(childRegistry => {\n const result: Record<string, IFieldBuilder> = {};\n result[\"_id\"] = childRegistry\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericLowerCaseId(12))\n .cloneValue(() => generateAlphaNumericLowerCaseId(12));\n for (const child of childFields) {\n result[child.fieldId] = context.mapField(child, childRegistry);\n }\n return result;\n });\n\n const layout = mapCmsNestedLayout(field.settings?.layout, childFields);\n if (layout) {\n builder.layout(layout);\n }\n }\n\n return applyFieldProps(builder, field, context.rendererMap);\n }\n}\n"],"names":["ObjectFieldMapper","field","registry","context","builder","childFields","childRegistry","result","generateAlphaNumericLowerCaseId","child","layout","mapCmsNestedLayout","applyFieldProps"],"mappings":";;;AAWO,MAAMA;IAGT,IACIC,KAAoB,EACpBC,QAA+B,EAC/BC,OAA+B,EAClB;QACb,MAAMC,UAAUF,SAAS,MAAM;QAE/B,MAAMG,cAAcJ,MAAM,QAAQ,EAAE;QACpC,IAAII,eAAeA,YAAY,MAAM,GAAG,GAAG;YACvCD,QAAQ,MAAM,CAACE,CAAAA;gBACX,MAAMC,SAAwC,CAAC;gBAC/CA,MAAM,CAAC,MAAM,GAAGD,cACX,IAAI,GACJ,MAAM,GACN,YAAY,CAAC,IAAME,gCAAgC,KACnD,UAAU,CAAC,IAAMA,gCAAgC;gBACtD,KAAK,MAAMC,SAASJ,YAChBE,MAAM,CAACE,MAAM,OAAO,CAAC,GAAGN,QAAQ,QAAQ,CAACM,OAAOH;gBAEpD,OAAOC;YACX;YAEA,MAAMG,SAASC,mBAAmBV,MAAM,QAAQ,EAAE,QAAQI;YAC1D,IAAIK,QACAN,QAAQ,MAAM,CAACM;QAEvB;QAEA,OAAOE,gBAAgBR,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aA/BS,IAAI,GAAG;;AAgCpB"}
@@ -3,7 +3,7 @@ import { ExportModelsGateway as GatewayAbstraction } from "./abstractions.js";
3
3
  declare class ExportModelsGatewayImpl implements GatewayAbstraction.Interface {
4
4
  private client;
5
5
  constructor(client: CmsGraphQLClient.Interface);
6
- execute(models?: string[]): Promise<any>;
6
+ execute(models?: string[]): Promise<string>;
7
7
  }
8
8
  export declare const ExportModelsGateway: typeof ExportModelsGatewayImpl & {
9
9
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IExportModelsGateway>;
@@ -1 +1 @@
1
- {"version":3,"file":"features/model/exportModels/ExportModelsGateway.js","sources":["../../../../src/features/model/exportModels/ExportModelsGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsErrorResponse } from \"~/types.js\";\nimport { ExportModelsGateway as GatewayAbstraction } from \"./abstractions.js\";\n\ninterface ExportModelsResponse {\n exportStructure: {\n data: any;\n error: CmsErrorResponse | null;\n };\n}\n\ninterface ExportModelsVariables {\n models?: string[];\n}\n\nconst CMS_EXPORT_STRUCTURE_QUERY = /* GraphQL */ `\n query CmsExportStructure($models: [String!]) {\n exportStructure(models: $models) {\n data\n error {\n message\n code\n data\n }\n }\n }\n`;\n\nclass ExportModelsGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: CmsGraphQLClient.Interface) {}\n\n async execute(models?: string[]) {\n const response = await this.client.execute<ExportModelsResponse, ExportModelsVariables>({\n query: CMS_EXPORT_STRUCTURE_QUERY,\n variables: { models }\n });\n\n const { data, error } = response.exportStructure;\n\n if (error) {\n throw new Error(error.message);\n }\n\n return data;\n }\n}\n\nexport const ExportModelsGateway = GatewayAbstraction.createImplementation({\n implementation: ExportModelsGatewayImpl,\n dependencies: [CmsGraphQLClient]\n});\n"],"names":["CMS_EXPORT_STRUCTURE_QUERY","ExportModelsGatewayImpl","client","models","response","data","error","Error","ExportModelsGateway","GatewayAbstraction","CmsGraphQLClient"],"mappings":";;AAeA,MAAMA,6BAA2C,CAAC;;;;;;;;;;;AAWlD,CAAC;AAED,MAAMC;IACF,YAAoBC,MAAkC,CAAE;aAApCA,MAAM,GAANA;IAAqC;IAEzD,MAAM,QAAQC,MAAiB,EAAE;QAC7B,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA8C;YACpF,OAAOJ;YACP,WAAW;gBAAEG;YAAO;QACxB;QAEA,MAAM,EAAEE,IAAI,EAAEC,KAAK,EAAE,GAAGF,SAAS,eAAe;QAEhD,IAAIE,OACA,MAAM,IAAIC,MAAMD,MAAM,OAAO;QAGjC,OAAOD;IACX;AACJ;AAEO,MAAMG,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBR;IAChB,cAAc;QAACS;KAAiB;AACpC"}
1
+ {"version":3,"file":"features/model/exportModels/ExportModelsGateway.js","sources":["../../../../src/features/model/exportModels/ExportModelsGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsErrorResponse } from \"~/types.js\";\nimport { ExportModelsGateway as GatewayAbstraction } from \"./abstractions.js\";\n\ninterface ExportModelsResponse {\n exportStructure: {\n data: string;\n error: CmsErrorResponse | null;\n };\n}\n\ninterface ExportModelsVariables {\n models?: string[];\n}\n\nconst CMS_EXPORT_STRUCTURE_QUERY = /* GraphQL */ `\n query CmsExportStructure($models: [String!]) {\n exportStructure(models: $models) {\n data\n error {\n message\n code\n data\n }\n }\n }\n`;\n\nclass ExportModelsGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: CmsGraphQLClient.Interface) {}\n\n async execute(models?: string[]) {\n const response = await this.client.execute<ExportModelsResponse, ExportModelsVariables>({\n query: CMS_EXPORT_STRUCTURE_QUERY,\n variables: { models }\n });\n\n const { data, error } = response.exportStructure;\n\n if (error) {\n throw new Error(error.message);\n }\n\n return data;\n }\n}\n\nexport const ExportModelsGateway = GatewayAbstraction.createImplementation({\n implementation: ExportModelsGatewayImpl,\n dependencies: [CmsGraphQLClient]\n});\n"],"names":["CMS_EXPORT_STRUCTURE_QUERY","ExportModelsGatewayImpl","client","models","response","data","error","Error","ExportModelsGateway","GatewayAbstraction","CmsGraphQLClient"],"mappings":";;AAeA,MAAMA,6BAA2C,CAAC;;;;;;;;;;;AAWlD,CAAC;AAED,MAAMC;IACF,YAAoBC,MAAkC,CAAE;aAApCA,MAAM,GAANA;IAAqC;IAEzD,MAAM,QAAQC,MAAiB,EAAE;QAC7B,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA8C;YACpF,OAAOJ;YACP,WAAW;gBAAEG;YAAO;QACxB;QAEA,MAAM,EAAEE,IAAI,EAAEC,KAAK,EAAE,GAAGF,SAAS,eAAe;QAEhD,IAAIE,OACA,MAAM,IAAIC,MAAMD,MAAM,OAAO;QAGjC,OAAOD;IACX;AACJ;AAEO,MAAMG,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBR;IAChB,cAAc;QAACS;KAAiB;AACpC"}
@@ -4,7 +4,13 @@ class ExportModelsUseCaseImpl {
4
4
  this.gateway = gateway;
5
5
  }
6
6
  async execute(models) {
7
- return this.gateway.execute(models);
7
+ const result = await this.gateway.execute(models);
8
+ try {
9
+ return JSON.parse(result);
10
+ } catch (ex) {
11
+ console.error(ex);
12
+ return null;
13
+ }
8
14
  }
9
15
  }
10
16
  const ExportModelsUseCase_ExportModelsUseCase = ExportModelsUseCase.createImplementation({
@@ -1 +1 @@
1
- {"version":3,"file":"features/model/exportModels/ExportModelsUseCase.js","sources":["../../../../src/features/model/exportModels/ExportModelsUseCase.ts"],"sourcesContent":["import { ExportModelsUseCase as UseCaseAbstraction, ExportModelsGateway } from \"./abstractions.js\";\n\nclass ExportModelsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(private gateway: ExportModelsGateway.Interface) {}\n\n async execute(models?: string[]) {\n return this.gateway.execute(models);\n }\n}\n\nexport const ExportModelsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ExportModelsUseCaseImpl,\n dependencies: [ExportModelsGateway]\n});\n"],"names":["ExportModelsUseCaseImpl","gateway","models","ExportModelsUseCase","UseCaseAbstraction","ExportModelsGateway"],"mappings":";AAEA,MAAMA;IACF,YAAoBC,OAAsC,CAAE;aAAxCA,OAAO,GAAPA;IAAyC;IAE7D,MAAM,QAAQC,MAAiB,EAAE;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAACA;IAChC;AACJ;AAEO,MAAMC,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBJ;IAChB,cAAc;QAACK;KAAoB;AACvC"}
1
+ {"version":3,"file":"features/model/exportModels/ExportModelsUseCase.js","sources":["../../../../src/features/model/exportModels/ExportModelsUseCase.ts"],"sourcesContent":["import { ExportModelsUseCase as UseCaseAbstraction, ExportModelsGateway } from \"./abstractions.js\";\n\nclass ExportModelsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(private gateway: ExportModelsGateway.Interface) {}\n\n async execute(models?: string[]) {\n const result = await this.gateway.execute(models);\n try {\n return JSON.parse(result);\n } catch (ex) {\n console.error(ex);\n return null;\n }\n }\n}\n\nexport const ExportModelsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ExportModelsUseCaseImpl,\n dependencies: [ExportModelsGateway]\n});\n"],"names":["ExportModelsUseCaseImpl","gateway","models","result","JSON","ex","console","ExportModelsUseCase","UseCaseAbstraction","ExportModelsGateway"],"mappings":";AAEA,MAAMA;IACF,YAAoBC,OAAsC,CAAE;aAAxCA,OAAO,GAAPA;IAAyC;IAE7D,MAAM,QAAQC,MAAiB,EAAE;QAC7B,MAAMC,SAAS,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAACD;QAC1C,IAAI;YACA,OAAOE,KAAK,KAAK,CAACD;QACtB,EAAE,OAAOE,IAAI;YACTC,QAAQ,KAAK,CAACD;YACd,OAAO;QACX;IACJ;AACJ;AAEO,MAAME,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBR;IAChB,cAAc;QAACS;KAAoB;AACvC"}
@@ -1,14 +1,20 @@
1
+ import type { CmsModel, CmsGroup } from "../../../types.js";
1
2
  export interface IExportModelsGateway {
2
- execute(models?: string[]): Promise<any>;
3
+ execute(models?: string[]): Promise<string>;
4
+ }
5
+ export interface IExportModelsUseCaseResponse {
6
+ models: CmsModel[];
7
+ groups: CmsGroup[];
3
8
  }
4
9
  export declare const ExportModelsGateway: import("@webiny/di").Abstraction<IExportModelsGateway>;
5
10
  export declare namespace ExportModelsGateway {
6
11
  type Interface = IExportModelsGateway;
7
12
  }
8
13
  export interface IExportModelsUseCase {
9
- execute(models?: string[]): Promise<any>;
14
+ execute(models?: string[]): Promise<IExportModelsUseCaseResponse | null>;
10
15
  }
11
16
  export declare const ExportModelsUseCase: import("@webiny/di").Abstraction<IExportModelsUseCase>;
12
17
  export declare namespace ExportModelsUseCase {
13
18
  type Interface = IExportModelsUseCase;
19
+ type Response = IExportModelsUseCaseResponse;
14
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/model/exportModels/abstractions.js","sources":["../../../../src/features/model/exportModels/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\n\nexport interface IExportModelsGateway {\n execute(models?: string[]): Promise<any>;\n}\n\nexport const ExportModelsGateway = createAbstraction<IExportModelsGateway>(\"ExportModelsGateway\");\n\nexport namespace ExportModelsGateway {\n export type Interface = IExportModelsGateway;\n}\n\nexport interface IExportModelsUseCase {\n execute(models?: string[]): Promise<any>;\n}\n\nexport const ExportModelsUseCase = createAbstraction<IExportModelsUseCase>(\"ExportModelsUseCase\");\n\nexport namespace ExportModelsUseCase {\n export type Interface = IExportModelsUseCase;\n}\n"],"names":["ExportModelsGateway","createAbstraction","ExportModelsUseCase"],"mappings":";AAMO,MAAMA,sBAAsBC,kBAAwC;AAUpE,MAAMC,sBAAsBD,kBAAwC"}
1
+ {"version":3,"file":"features/model/exportModels/abstractions.js","sources":["../../../../src/features/model/exportModels/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { CmsModel, CmsGroup } from \"~/types.js\";\n\nexport interface IExportModelsGateway {\n execute(models?: string[]): Promise<string>;\n}\n\nexport interface IExportModelsUseCaseResponse {\n models: CmsModel[];\n groups: CmsGroup[];\n}\n\nexport const ExportModelsGateway = createAbstraction<IExportModelsGateway>(\"ExportModelsGateway\");\n\nexport namespace ExportModelsGateway {\n export type Interface = IExportModelsGateway;\n}\n\nexport interface IExportModelsUseCase {\n execute(models?: string[]): Promise<IExportModelsUseCaseResponse | null>;\n}\n\nexport const ExportModelsUseCase = createAbstraction<IExportModelsUseCase>(\"ExportModelsUseCase\");\n\nexport namespace ExportModelsUseCase {\n export type Interface = IExportModelsUseCase;\n export type Response = IExportModelsUseCaseResponse;\n}\n"],"names":["ExportModelsGateway","createAbstraction","ExportModelsUseCase"],"mappings":";AAYO,MAAMA,sBAAsBC,kBAAwC;AAUpE,MAAMC,sBAAsBD,kBAAwC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app-headless-cms",
3
- "version": "6.5.0-beta.0",
3
+ "version": "6.5.0-beta.10",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -26,33 +26,33 @@
26
26
  "@fortawesome/free-regular-svg-icons": "7.3.1",
27
27
  "@fortawesome/free-solid-svg-icons": "7.3.1",
28
28
  "@fortawesome/react-fontawesome": "3.5.0",
29
- "@lexical/utils": "0.48.0",
29
+ "@lexical/utils": "0.52.0",
30
30
  "@types/react": "18.3.31",
31
- "@webiny/admin-ui": "6.5.0-beta.0",
32
- "@webiny/app": "6.5.0-beta.0",
33
- "@webiny/app-aco": "6.5.0-beta.0",
34
- "@webiny/app-admin": "6.5.0-beta.0",
35
- "@webiny/app-graphql-playground": "6.5.0-beta.0",
36
- "@webiny/app-headless-cms-common": "6.5.0-beta.0",
37
- "@webiny/cms-sdk": "6.5.0-beta.0",
38
- "@webiny/di": "1.0.2",
39
- "@webiny/feature": "6.5.0-beta.0",
40
- "@webiny/form": "6.5.0-beta.0",
41
- "@webiny/frontend-settings": "6.5.0-beta.0",
42
- "@webiny/icons": "6.5.0-beta.0",
43
- "@webiny/lexical-editor": "6.5.0-beta.0",
44
- "@webiny/lexical-nodes": "6.5.0-beta.0",
45
- "@webiny/plugins": "6.5.0-beta.0",
46
- "@webiny/react-composition": "6.5.0-beta.0",
47
- "@webiny/react-properties": "6.5.0-beta.0",
48
- "@webiny/utils": "6.5.0-beta.0",
49
- "@webiny/validation": "6.5.0-beta.0",
31
+ "@webiny/admin-ui": "6.5.0-beta.10",
32
+ "@webiny/app": "6.5.0-beta.10",
33
+ "@webiny/app-aco": "6.5.0-beta.10",
34
+ "@webiny/app-admin": "6.5.0-beta.10",
35
+ "@webiny/app-graphql-playground": "6.5.0-beta.10",
36
+ "@webiny/app-headless-cms-common": "6.5.0-beta.10",
37
+ "@webiny/cms-sdk": "6.5.0-beta.10",
38
+ "@webiny/di": "1.1.0",
39
+ "@webiny/feature": "6.5.0-beta.10",
40
+ "@webiny/form": "6.5.0-beta.10",
41
+ "@webiny/frontend-settings": "6.5.0-beta.10",
42
+ "@webiny/icons": "6.5.0-beta.10",
43
+ "@webiny/lexical-editor": "6.5.0-beta.10",
44
+ "@webiny/lexical-nodes": "6.5.0-beta.10",
45
+ "@webiny/plugins": "6.5.0-beta.10",
46
+ "@webiny/react-composition": "6.5.0-beta.10",
47
+ "@webiny/react-properties": "6.5.0-beta.10",
48
+ "@webiny/utils": "6.5.0-beta.10",
49
+ "@webiny/validation": "6.5.0-beta.10",
50
50
  "dot-prop-immutable": "2.1.1",
51
51
  "graphql": "16.14.2",
52
52
  "graphql-tag": "2.12.7",
53
53
  "lodash": "4.18.1",
54
- "mobx": "6.16.1",
55
- "mobx-react-lite": "4.1.1",
54
+ "mobx": "7.0.6",
55
+ "mobx-react-lite": "5.1.0",
56
56
  "react": "18.3.1",
57
57
  "react-dnd": "16.0.1",
58
58
  "react-dnd-html5-backend": "16.0.1",
@@ -60,13 +60,13 @@
60
60
  "react-helmet": "6.1.0",
61
61
  "slugify": "1.6.9",
62
62
  "use-deep-compare-effect": "1.8.1",
63
- "zod": "4.4.3"
63
+ "zod": "4.6.5"
64
64
  },
65
65
  "devDependencies": {
66
- "@webiny/build-tools": "6.5.0-beta.0",
66
+ "@webiny/build-tools": "6.5.0-beta.10",
67
67
  "rimraf": "6.1.3",
68
68
  "typescript": "7.0.2",
69
- "vitest": "4.1.10"
69
+ "vitest": "5.0.3"
70
70
  },
71
71
  "publishConfig": {
72
72
  "access": "public"
@@ -17,6 +17,7 @@ declare class CloneContentModelPresenterImpl implements ICloneContentModelPresen
17
17
  private sourceModel;
18
18
  constructor(formModelFactory: FormModelFactory.Interface, listModelGroupsUseCase: ListModelGroupsUseCase.Interface, cloneModelUseCase: CloneModelUseCase.Interface, groupsCache: ModelGroupsCache.Interface, modelsCache: ModelsCache.Interface);
19
19
  get vm(): ICloneContentModelPresenterViewModel;
20
+ private get groupOptions();
20
21
  init(sourceModel: CmsModel): Promise<void>;
21
22
  save(): Promise<CmsModel | null>;
22
23
  reset(): void;
@@ -26,18 +26,20 @@ class CloneContentModelPresenterImpl {
26
26
  });
27
27
  }
28
28
  get vm() {
29
- const groups = this.groupsCache.getItems().map((g)=>({
30
- value: g.slug,
31
- label: g.name
32
- }));
33
29
  return {
34
30
  loading: this.loading,
35
31
  saving: this.saving,
36
- groups,
32
+ groups: this.groupOptions,
37
33
  models: this.modelsCache.getItems(),
38
34
  form: this.form.vm
39
35
  };
40
36
  }
37
+ get groupOptions() {
38
+ return this.groupsCache.getItems().map((group)=>({
39
+ value: group.slug,
40
+ label: group.name
41
+ }));
42
+ }
41
43
  async init(sourceModel) {
42
44
  this.sourceModel = sourceModel;
43
45
  try {
@@ -91,7 +93,7 @@ class CloneContentModelPresenterImpl {
91
93
  name: fields.text().label("Name").required("Name is required."),
92
94
  singularApiName: fields.text().label("Singular API Name").required("Singular API Name is required."),
93
95
  pluralApiName: fields.text().label("Plural API Name").required("Plural API Name is required."),
94
- group: fields.text().label("Content model group").required("Group is required."),
96
+ group: fields.text().label("Content model group").required("Group is required.").options(()=>this.groupOptions),
95
97
  icon: fields.text().label("Icon").renderer("cmsIconPicker"),
96
98
  description: fields.text().label("Description").renderer("textarea")
97
99
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"presentation/cloneContentModel/CloneContentModelPresenter.js","sources":["../../../src/presentation/cloneContentModel/CloneContentModelPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction, computed } from \"mobx\";\nimport { FormModelFactory } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { IFormModel } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModel } from \"~/types.js\";\nimport { ListModelGroupsUseCase } from \"~/features/modelGroup/listModelGroups/abstractions.js\";\nimport { CloneModelUseCase } from \"~/features/model/cloneModel/abstractions.js\";\nimport { ModelGroupsCache } from \"~/features/modelGroup/abstractions.js\";\nimport { ModelsCache } from \"~/features/model/abstractions.js\";\nimport {\n CloneContentModelPresenter as Abstraction,\n type ICloneContentModelPresenter,\n type ICloneContentModelPresenterViewModel\n} from \"./abstractions.js\";\n\nclass CloneContentModelPresenterImpl implements ICloneContentModelPresenter {\n private loading = true;\n private saving = false;\n private form: IFormModel;\n private sourceModel: CmsModel | null = null;\n\n constructor(\n private formModelFactory: FormModelFactory.Interface,\n private listModelGroupsUseCase: ListModelGroupsUseCase.Interface,\n private cloneModelUseCase: CloneModelUseCase.Interface,\n private groupsCache: ModelGroupsCache.Interface,\n private modelsCache: ModelsCache.Interface\n ) {\n this.form = this.buildForm();\n makeAutoObservable<\n CloneContentModelPresenterImpl,\n | \"formModelFactory\"\n | \"listModelGroupsUseCase\"\n | \"cloneModelUseCase\"\n | \"groupsCache\"\n | \"modelsCache\"\n >(this, {\n formModelFactory: false,\n listModelGroupsUseCase: false,\n cloneModelUseCase: false,\n groupsCache: false,\n modelsCache: false,\n vm: computed\n });\n }\n\n get vm(): ICloneContentModelPresenterViewModel {\n const groups = this.groupsCache.getItems().map(g => ({\n value: g.slug,\n label: g.name\n }));\n\n return {\n loading: this.loading,\n saving: this.saving,\n groups,\n models: this.modelsCache.getItems(),\n form: this.form.vm\n };\n }\n\n async init(sourceModel: CmsModel): Promise<void> {\n this.sourceModel = sourceModel;\n\n try {\n await this.listModelGroupsUseCase.execute();\n } finally {\n runInAction(() => {\n this.loading = false;\n this.form = this.buildForm();\n this.form.setData({\n name: sourceModel.name,\n group: sourceModel.group\n });\n });\n }\n }\n\n async save(): Promise<CmsModel | null> {\n if (!this.sourceModel) {\n return null;\n }\n\n const data = await this.form.submit<Record<string, any>>();\n if (!data) {\n return null;\n }\n\n runInAction(() => {\n this.saving = true;\n });\n\n try {\n const model = await this.cloneModelUseCase.execute({\n modelId: this.sourceModel.modelId,\n data: {\n name: data.name as string,\n singularApiName: data.singularApiName as string | undefined,\n pluralApiName: data.pluralApiName as string | undefined,\n group: data.group as string | undefined,\n icon: data.icon as string | undefined,\n description: data.description as string | undefined\n }\n });\n\n return model;\n } catch {\n return null;\n } finally {\n runInAction(() => {\n this.saving = false;\n });\n }\n }\n\n reset(): void {\n this.sourceModel = null;\n this.form = this.buildForm();\n }\n\n private buildForm(): IFormModel {\n return this.formModelFactory.create({\n fields: fields => ({\n name: fields.text().label(\"Name\").required(\"Name is required.\"),\n singularApiName: fields\n .text()\n .label(\"Singular API Name\")\n .required(\"Singular API Name is required.\"),\n pluralApiName: fields\n .text()\n .label(\"Plural API Name\")\n .required(\"Plural API Name is required.\"),\n group: fields.text().label(\"Content model group\").required(\"Group is required.\"),\n icon: fields.text().label(\"Icon\").renderer(\"cmsIconPicker\"),\n description: fields.text().label(\"Description\").renderer(\"textarea\")\n }),\n layout: layout => [\n layout.row(\"name\"),\n layout.row(\"singularApiName\"),\n layout.row(\"pluralApiName\"),\n layout.row(\"group\"),\n layout.row(\"icon\"),\n layout.row(\"description\")\n ]\n });\n }\n}\n\nexport const CloneContentModelPresenter = Abstraction.createImplementation({\n implementation: CloneContentModelPresenterImpl,\n dependencies: [\n FormModelFactory,\n ListModelGroupsUseCase,\n CloneModelUseCase,\n ModelGroupsCache,\n ModelsCache\n ]\n});\n"],"names":["CloneContentModelPresenterImpl","formModelFactory","listModelGroupsUseCase","cloneModelUseCase","groupsCache","modelsCache","makeAutoObservable","computed","groups","g","sourceModel","runInAction","data","model","fields","layout","CloneContentModelPresenter","Abstraction","FormModelFactory","ListModelGroupsUseCase","CloneModelUseCase","ModelGroupsCache","ModelsCache"],"mappings":";;;;;;;AAcA,MAAMA;IAMF,YACYC,gBAA4C,EAC5CC,sBAAwD,EACxDC,iBAA8C,EAC9CC,WAAuC,EACvCC,WAAkC,CAC5C;aALUJ,gBAAgB,GAAhBA;aACAC,sBAAsB,GAAtBA;aACAC,iBAAiB,GAAjBA;aACAC,WAAW,GAAXA;aACAC,WAAW,GAAXA;aAVJ,OAAO,GAAG;aACV,MAAM,GAAG;aAET,WAAW,GAAoB;QASnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS;QAC1BC,mBAOE,IAAI,EAAE;YACJ,kBAAkB;YAClB,wBAAwB;YACxB,mBAAmB;YACnB,aAAa;YACb,aAAa;YACb,IAAIC;QACR;IACJ;IAEA,IAAI,KAA2C;QAC3C,MAAMC,SAAS,IAAI,CAAC,WAAW,CAAC,QAAQ,GAAG,GAAG,CAACC,CAAAA,IAAM;gBACjD,OAAOA,EAAE,IAAI;gBACb,OAAOA,EAAE,IAAI;YACjB;QAEA,OAAO;YACH,SAAS,IAAI,CAAC,OAAO;YACrB,QAAQ,IAAI,CAAC,MAAM;YACnBD;YACA,QAAQ,IAAI,CAAC,WAAW,CAAC,QAAQ;YACjC,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE;QACtB;IACJ;IAEA,MAAM,KAAKE,WAAqB,EAAiB;QAC7C,IAAI,CAAC,WAAW,GAAGA;QAEnB,IAAI;YACA,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO;QAC7C,SAAU;YACNC,YAAY;gBACR,IAAI,CAAC,OAAO,GAAG;gBACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS;gBAC1B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;oBACd,MAAMD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,CAAC,eAAe,QAAQ,CAAC;gBAC7D;YACA,QAAQC,CAAAA,SAAU;oBACdA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;iBACd;QACL;IACJ;AACJ;AAEO,MAAMC,wDAA6BC,2BAAAA,oBAAgC,CAAC;IACvE,gBAAgBjB;IAChB,cAAc;QACVkB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"presentation/cloneContentModel/CloneContentModelPresenter.js","sources":["../../../src/presentation/cloneContentModel/CloneContentModelPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction, computed } from \"mobx\";\nimport { FormModelFactory } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { IFormModel } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModel } from \"~/types.js\";\nimport { ListModelGroupsUseCase } from \"~/features/modelGroup/listModelGroups/abstractions.js\";\nimport { CloneModelUseCase } from \"~/features/model/cloneModel/abstractions.js\";\nimport { ModelGroupsCache } from \"~/features/modelGroup/abstractions.js\";\nimport { ModelsCache } from \"~/features/model/abstractions.js\";\nimport {\n CloneContentModelPresenter as Abstraction,\n type ICloneContentModelPresenter,\n type ICloneContentModelPresenterViewModel\n} from \"./abstractions.js\";\n\nclass CloneContentModelPresenterImpl implements ICloneContentModelPresenter {\n private loading = true;\n private saving = false;\n private form: IFormModel;\n private sourceModel: CmsModel | null = null;\n\n constructor(\n private formModelFactory: FormModelFactory.Interface,\n private listModelGroupsUseCase: ListModelGroupsUseCase.Interface,\n private cloneModelUseCase: CloneModelUseCase.Interface,\n private groupsCache: ModelGroupsCache.Interface,\n private modelsCache: ModelsCache.Interface\n ) {\n this.form = this.buildForm();\n makeAutoObservable<\n CloneContentModelPresenterImpl,\n | \"formModelFactory\"\n | \"listModelGroupsUseCase\"\n | \"cloneModelUseCase\"\n | \"groupsCache\"\n | \"modelsCache\"\n >(this, {\n formModelFactory: false,\n listModelGroupsUseCase: false,\n cloneModelUseCase: false,\n groupsCache: false,\n modelsCache: false,\n vm: computed\n });\n }\n\n get vm(): ICloneContentModelPresenterViewModel {\n return {\n loading: this.loading,\n saving: this.saving,\n groups: this.groupOptions,\n models: this.modelsCache.getItems(),\n form: this.form.vm\n };\n }\n\n private get groupOptions() {\n return this.groupsCache.getItems().map(group => ({\n value: group.slug,\n label: group.name\n }));\n }\n\n async init(sourceModel: CmsModel): Promise<void> {\n this.sourceModel = sourceModel;\n\n try {\n await this.listModelGroupsUseCase.execute();\n } finally {\n runInAction(() => {\n this.loading = false;\n this.form = this.buildForm();\n this.form.setData({\n name: sourceModel.name,\n group: sourceModel.group\n });\n });\n }\n }\n\n async save(): Promise<CmsModel | null> {\n if (!this.sourceModel) {\n return null;\n }\n\n const data = await this.form.submit<Record<string, any>>();\n if (!data) {\n return null;\n }\n\n runInAction(() => {\n this.saving = true;\n });\n\n try {\n const model = await this.cloneModelUseCase.execute({\n modelId: this.sourceModel.modelId,\n data: {\n name: data.name as string,\n singularApiName: data.singularApiName as string | undefined,\n pluralApiName: data.pluralApiName as string | undefined,\n group: data.group as string | undefined,\n icon: data.icon as string | undefined,\n description: data.description as string | undefined\n }\n });\n\n return model;\n } catch {\n return null;\n } finally {\n runInAction(() => {\n this.saving = false;\n });\n }\n }\n\n reset(): void {\n this.sourceModel = null;\n this.form = this.buildForm();\n }\n\n private buildForm(): IFormModel {\n return this.formModelFactory.create({\n fields: fields => ({\n name: fields.text().label(\"Name\").required(\"Name is required.\"),\n singularApiName: fields\n .text()\n .label(\"Singular API Name\")\n .required(\"Singular API Name is required.\"),\n pluralApiName: fields\n .text()\n .label(\"Plural API Name\")\n .required(\"Plural API Name is required.\"),\n group: fields\n .text()\n .label(\"Content model group\")\n .required(\"Group is required.\")\n /*\n * Options turn the text field into a select. The groups arrive after the form\n * is built, so they have to be read through a callback.\n */\n .options(() => this.groupOptions),\n icon: fields.text().label(\"Icon\").renderer(\"cmsIconPicker\"),\n description: fields.text().label(\"Description\").renderer(\"textarea\")\n }),\n layout: layout => [\n layout.row(\"name\"),\n layout.row(\"singularApiName\"),\n layout.row(\"pluralApiName\"),\n layout.row(\"group\"),\n layout.row(\"icon\"),\n layout.row(\"description\")\n ]\n });\n }\n}\n\nexport const CloneContentModelPresenter = Abstraction.createImplementation({\n implementation: CloneContentModelPresenterImpl,\n dependencies: [\n FormModelFactory,\n ListModelGroupsUseCase,\n CloneModelUseCase,\n ModelGroupsCache,\n ModelsCache\n ]\n});\n"],"names":["CloneContentModelPresenterImpl","formModelFactory","listModelGroupsUseCase","cloneModelUseCase","groupsCache","modelsCache","makeAutoObservable","computed","group","sourceModel","runInAction","data","model","fields","layout","CloneContentModelPresenter","Abstraction","FormModelFactory","ListModelGroupsUseCase","CloneModelUseCase","ModelGroupsCache","ModelsCache"],"mappings":";;;;;;;AAcA,MAAMA;IAMF,YACYC,gBAA4C,EAC5CC,sBAAwD,EACxDC,iBAA8C,EAC9CC,WAAuC,EACvCC,WAAkC,CAC5C;aALUJ,gBAAgB,GAAhBA;aACAC,sBAAsB,GAAtBA;aACAC,iBAAiB,GAAjBA;aACAC,WAAW,GAAXA;aACAC,WAAW,GAAXA;aAVJ,OAAO,GAAG;aACV,MAAM,GAAG;aAET,WAAW,GAAoB;QASnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS;QAC1BC,mBAOE,IAAI,EAAE;YACJ,kBAAkB;YAClB,wBAAwB;YACxB,mBAAmB;YACnB,aAAa;YACb,aAAa;YACb,IAAIC;QACR;IACJ;IAEA,IAAI,KAA2C;QAC3C,OAAO;YACH,SAAS,IAAI,CAAC,OAAO;YACrB,QAAQ,IAAI,CAAC,MAAM;YACnB,QAAQ,IAAI,CAAC,YAAY;YACzB,QAAQ,IAAI,CAAC,WAAW,CAAC,QAAQ;YACjC,MAAM,IAAI,CAAC,IAAI,CAAC,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C9B;IAEQ,YAAwB;QAC5B,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC;YAChC,QAAQG,CAAAA,SAAW;oBACf,MAAMA,OAAO,IAAI,GAAG,KAAK,CAAC,QAAQ,QAAQ,CAAC;oBAC3C,iBAAiBA,OACZ,IAAI,GACJ,KAAK,CAAC,qBACN,QAAQ,CAAC;oBACd,eAAeA,OACV,IAAI,GACJ,KAAK,CAAC,mBACN,QAAQ,CAAC;oBACd,OAAOA,OACF,IAAI,GACJ,KAAK,CAAC,uBACN,QAAQ,CAAC,sBAKT,OAAO,CAAC,IAAM,IAAI,CAAC,YAAY;oBACpC,MAAMA,OAAO,IAAI,GAAG,KAAK,CAAC,QAAQ,QAAQ,CAAC;oBAC3C,aAAaA,OAAO,IAAI,GAAG,KAAK,CAAC,eAAe,QAAQ,CAAC;gBAC7D;YACA,QAAQC,CAAAA,SAAU;oBACdA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;iBACd;QACL;IACJ;AACJ;AAEO,MAAMC,wDAA6BC,2BAAAA,oBAAgC,CAAC;IACvE,gBAAgBhB;IAChB,cAAc;QACViB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -13,7 +13,9 @@ import { CmsModelContext } from "../../../features/contentEntry/abstractions.js"
13
13
  import { ContentEntryFormModelModifier, ContentEntryFormPresenter } from "./abstractions.js";
14
14
  import { TRASH_ENTRY_DIALOG } from "../list/ContentEntriesPresenter.js";
15
15
  import { CreateRevisionFromUseCase } from "../../../features/contentEntry/createRevisionFrom/abstractions.js";
16
+ import { toFormErrors } from "./toFormErrors.js";
16
17
  const PUBLISH_ENTRY_DIALOG = "publish-entry";
18
+ const SAVING = "Saving...";
17
19
  class ContentEntryFormPresenterImpl {
18
20
  constructor(formModelFactory, cmsFormModelBuilder, confirmation, modelAccessor, getEntryUseCase, createEntryUseCase, createRevisionFromUseCase, updateEntryUseCase, publishEntryUseCase, unpublishEntryUseCase, deleteEntryUseCase, updateRevisionDescriptionUseCase, formModelModifiers){
19
21
  this.formModelFactory = formModelFactory;
@@ -78,52 +80,55 @@ class ContentEntryFormPresenterImpl {
78
80
  }
79
81
  async saveRevision(options) {
80
82
  if (!this.form) return false;
83
+ const form = this.form;
84
+ const model = this.model;
85
+ const isCurrent = ()=>this.form === form && this.model.modelId === model.modelId;
81
86
  const skipValidation = options?.skipValidation ?? true;
82
- const data = await this.form.submit({
87
+ const data = await form.submit({
83
88
  skipValidation
84
89
  });
85
- if (!data) return false;
90
+ if (!data || !isCurrent()) return false;
91
+ const entry = this.entry;
92
+ const folderId = this.folderId;
86
93
  runInAction(()=>{
87
- this.loading = "Saving...";
94
+ this.loading = SAVING;
88
95
  });
89
96
  try {
90
- if (this.entry) {
91
- const entry = await this.saveEntry({
92
- entry: this.entry,
93
- data,
94
- skipValidation
95
- });
96
- runInAction(()=>{
97
- this.entry = entry;
98
- this.form.setData(entry.values);
99
- this.form.reset();
100
- });
101
- } else {
97
+ let savedEntry;
98
+ if (entry) savedEntry = await this.saveEntry({
99
+ model,
100
+ entry,
101
+ data,
102
+ skipValidation
103
+ });
104
+ else {
102
105
  const createData = {
103
106
  values: data
104
107
  };
105
- if (this.folderId) createData.wbyAco_location = {
106
- folderId: this.folderId
108
+ if (folderId) createData.wbyAco_location = {
109
+ folderId
107
110
  };
108
- const entry = await this.createEntryUseCase.execute({
109
- model: this.model,
111
+ savedEntry = await this.createEntryUseCase.execute({
112
+ model,
110
113
  data: createData,
111
114
  options: {
112
115
  skipValidation
113
116
  }
114
117
  });
115
- runInAction(()=>{
116
- this.entry = entry;
117
- this.form.setData(entry.values);
118
- this.form.reset();
119
- });
120
118
  }
119
+ if (!isCurrent()) return false;
120
+ runInAction(()=>{
121
+ this.entry = savedEntry;
122
+ form.setData(savedEntry.values);
123
+ form.reset();
124
+ });
121
125
  return true;
122
- } catch {
126
+ } catch (error) {
127
+ if (isCurrent()) form.setErrors(toFormErrors(error, model));
123
128
  return false;
124
129
  } finally{
125
130
  runInAction(()=>{
126
- this.loading = null;
131
+ if (this.loading === SAVING) this.loading = null;
127
132
  });
128
133
  }
129
134
  }
@@ -253,9 +258,9 @@ class ContentEntryFormPresenterImpl {
253
258
  this.form.reset();
254
259
  }
255
260
  async saveEntry(params) {
256
- const { entry, data, skipValidation } = params;
261
+ const { model, entry, data, skipValidation } = params;
257
262
  if (entry.meta.locked) return await this.createRevisionFromUseCase.execute({
258
- model: this.model,
263
+ model,
259
264
  revisionId: entry.id,
260
265
  data: {
261
266
  values: data
@@ -265,7 +270,7 @@ class ContentEntryFormPresenterImpl {
265
270
  }
266
271
  });
267
272
  return await this.updateEntryUseCase.execute({
268
- model: this.model,
273
+ model,
269
274
  revisionId: entry.id,
270
275
  data: {
271
276
  values: data