@webiny/app-headless-cms 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 (527) hide show
  1. package/ContentEntriesModule.js +23 -6
  2. package/ContentEntriesModule.js.map +1 -1
  3. package/HeadlessCMS.js +7 -2
  4. package/HeadlessCMS.js.map +1 -1
  5. package/admin/RoutesConfig.js +19 -2
  6. package/admin/RoutesConfig.js.map +1 -1
  7. package/admin/components/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
  8. package/admin/components/ContentEntries/BulkActions/ActionDelete.js +2 -1
  9. package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
  10. package/admin/components/ContentEntries/BulkActions/ActionDelete.test.d.ts +1 -0
  11. package/admin/components/ContentEntries/BulkActions/ActionDelete.test.js +125 -0
  12. package/admin/components/ContentEntries/BulkActions/ActionDelete.test.js.map +1 -0
  13. package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
  14. package/admin/components/ContentEntries/BulkActions/ActionMove.js.map +1 -1
  15. package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
  16. package/admin/components/ContentEntries/BulkActions/ActionPublish.js.map +1 -1
  17. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
  18. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.js.map +1 -1
  19. package/admin/components/ContentEntries/Filters/RefFieldRenderer.d.ts +2 -0
  20. package/admin/components/ContentEntries/Filters/RefFieldRenderer.js +85 -0
  21. package/admin/components/ContentEntries/Filters/RefFieldRenderer.js.map +1 -0
  22. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.d.ts +2 -0
  23. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js +34 -0
  24. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js.map +1 -0
  25. package/admin/components/ContentEntries/Table/Actions/index.d.ts +1 -0
  26. package/admin/components/ContentEntries/Table/Actions/index.js +1 -0
  27. package/admin/components/ContentEntries/Table/Cells/CellLive.js +9 -2
  28. package/admin/components/ContentEntries/Table/Cells/CellLive.js.map +1 -1
  29. package/admin/components/ContentModelEditor/ContentModelEditor.js +1 -1
  30. package/admin/components/ContentModelEditor/ContentModelEditor.js.map +1 -1
  31. package/admin/components/ContentModelEditor/ContentModelEditorProvider.js +1 -0
  32. package/admin/components/ContentModelEditor/ContentModelEditorProvider.js.map +1 -1
  33. package/admin/components/ContentModelEditor/FieldsSidebar.js +12 -2
  34. package/admin/components/ContentModelEditor/FieldsSidebar.js.map +1 -1
  35. package/admin/components/ContentModelEditor/evaluateExpression.d.ts +1 -1
  36. package/admin/components/ContentModelEditor/evaluateExpression.js +10 -0
  37. package/admin/components/ContentModelEditor/evaluateExpression.js.map +1 -1
  38. package/admin/components/ContentModelEditor/operatorOptions.js +12 -0
  39. package/admin/components/ContentModelEditor/operatorOptions.js.map +1 -1
  40. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.d.ts +2 -0
  41. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js +22 -0
  42. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js.map +1 -0
  43. package/admin/components/Dialogs/EditRevisionNoteDialog.d.ts +2 -0
  44. package/admin/components/Dialogs/EditRevisionNoteDialog.js +33 -0
  45. package/admin/components/Dialogs/EditRevisionNoteDialog.js.map +1 -0
  46. package/admin/components/Dialogs/PublishEntryConfirmDialog.d.ts +26 -1
  47. package/admin/components/Dialogs/PublishEntryConfirmDialog.js +4 -3
  48. package/admin/components/Dialogs/PublishEntryConfirmDialog.js.map +1 -1
  49. package/admin/components/Dialogs/UnpublishEntryConfirmDialog.d.ts +26 -1
  50. package/admin/components/Dialogs/UnpublishEntryConfirmDialog.js +4 -3
  51. package/admin/components/Dialogs/UnpublishEntryConfirmDialog.js.map +1 -1
  52. package/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/PermissionsEditor.js +3 -3
  53. package/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/PermissionsEditor.js.map +1 -1
  54. package/admin/components/FieldEditor/EditFieldDialog.d.ts +2 -2
  55. package/admin/components/FieldEditor/EditFieldDialog.js +5 -2
  56. package/admin/components/FieldEditor/EditFieldDialog.js.map +1 -1
  57. package/admin/components/FieldEditor/Field.js +5 -5
  58. package/admin/components/FieldEditor/Field.js.map +1 -1
  59. package/admin/components/FieldEditor/FieldEditor.js +2 -2
  60. package/admin/components/FieldEditor/FieldEditor.js.map +1 -1
  61. package/admin/components/FieldEditor/FieldEditorContext.d.ts +1 -1
  62. package/admin/components/FieldEditor/FieldEditorContext.js +6 -1
  63. package/admin/components/FieldEditor/FieldEditorContext.js.map +1 -1
  64. package/admin/components/LexicalCmsEditor/LexicalEditor.js +10 -6
  65. package/admin/components/LexicalCmsEditor/LexicalEditor.js.map +1 -1
  66. package/admin/components/LexicalCmsEditor/TypographyDropDown.js +3 -2
  67. package/admin/components/LexicalCmsEditor/TypographyDropDown.js.map +1 -1
  68. package/admin/components/ModelFieldProvider/ModelFieldContext.d.ts +1 -0
  69. package/admin/config/contentEntries/editor/ContentEntryEditorConfig.d.ts +60 -2
  70. package/admin/config/contentEntries/editor/ContentEntryEditorConfig.js +18 -5
  71. package/admin/config/contentEntries/editor/ContentEntryEditorConfig.js.map +1 -1
  72. package/admin/config/contentEntries/editor/NewEntryWizard.d.ts +8 -1
  73. package/admin/config/contentEntries/editor/NewEntryWizard.js +20 -5
  74. package/admin/config/contentEntries/editor/NewEntryWizard.js.map +1 -1
  75. package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.d.ts +38 -0
  76. package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.js +23 -0
  77. package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.js.map +1 -0
  78. package/admin/config/contentEntries/list/Browser/index.d.ts +21 -0
  79. package/admin/config/contentEntries/list/Browser/index.js +2 -0
  80. package/admin/config/contentEntries/list/Browser/index.js.map +1 -1
  81. package/admin/config/contentEntries/list/ContentEntryListConfig.d.ts +39 -0
  82. package/admin/config/contentEntries/list/ContentEntryListConfig.js +2 -1
  83. package/admin/config/contentEntries/list/ContentEntryListConfig.js.map +1 -1
  84. package/admin/graphql/contentModels.d.ts +2 -2
  85. package/admin/graphql/contentModels.js +3 -1
  86. package/admin/graphql/contentModels.js.map +1 -1
  87. package/admin/hooks/usePermission.js +6 -34
  88. package/admin/hooks/usePermission.js.map +1 -1
  89. package/admin/plugins/editor/defaultBar/Name/Name.d.ts +0 -5
  90. package/admin/plugins/editor/defaultBar/Name/Name.js +0 -2
  91. package/admin/plugins/editor/defaultBar/Name/Name.js.map +1 -1
  92. package/admin/plugins/editor/formSettings/components/GeneralSettings.js +8 -1
  93. package/admin/plugins/editor/formSettings/components/GeneralSettings.js.map +1 -1
  94. package/domain/permissions/checkCmsPermission.d.ts +14 -0
  95. package/domain/permissions/checkCmsPermission.js +20 -0
  96. package/domain/permissions/checkCmsPermission.js.map +1 -0
  97. package/domain/permissions/hasAccessForModel.d.ts +11 -0
  98. package/domain/permissions/hasAccessForModel.js +20 -0
  99. package/domain/permissions/hasAccessForModel.js.map +1 -0
  100. package/domain/permissions/isModelAllowed.d.ts +2 -0
  101. package/domain/permissions/isModelAllowed.js +11 -0
  102. package/domain/permissions/isModelAllowed.js.map +1 -0
  103. package/exports/admin/cms/entry/editor.d.ts +1 -0
  104. package/exports/admin/cms/entry/editor.js +1 -0
  105. package/exports/admin/cms/entry/list.d.ts +2 -0
  106. package/exports/admin/cms/entry/list.js +2 -0
  107. package/exports/admin/cms.d.ts +2 -0
  108. package/exports/admin/cms.js +2 -0
  109. package/features/contentEntry/CmsEntryError.d.ts +10 -0
  110. package/features/contentEntry/CmsEntryError.js +11 -0
  111. package/features/contentEntry/CmsEntryError.js.map +1 -0
  112. package/features/contentEntry/EntryGraphQLFields.js +1 -1
  113. package/features/contentEntry/EntryGraphQLFields.js.map +1 -1
  114. package/features/contentEntry/bulkAction/BulkActionGateway.js +6 -1
  115. package/features/contentEntry/bulkAction/BulkActionGateway.js.map +1 -1
  116. package/features/contentEntry/bulkAction/BulkActionGateway.test.d.ts +1 -0
  117. package/features/contentEntry/bulkAction/BulkActionGateway.test.js +134 -0
  118. package/features/contentEntry/bulkAction/BulkActionGateway.test.js.map +1 -0
  119. package/features/contentEntry/createEntry/CreateEntryGateway.d.ts +0 -1
  120. package/features/contentEntry/createEntry/CreateEntryGateway.js +3 -10
  121. package/features/contentEntry/createEntry/CreateEntryGateway.js.map +1 -1
  122. package/features/contentEntry/createEntry/CreateEntryRepository.d.ts +3 -1
  123. package/features/contentEntry/createEntry/CreateEntryRepository.js +10 -2
  124. package/features/contentEntry/createEntry/CreateEntryRepository.js.map +1 -1
  125. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.d.ts +3 -1
  126. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js +8 -3
  127. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js.map +1 -1
  128. package/features/contentEntry/deleteEntry/DeleteEntryGateway.js +6 -1
  129. package/features/contentEntry/deleteEntry/DeleteEntryGateway.js.map +1 -1
  130. package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.d.ts +1 -0
  131. package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.js +116 -0
  132. package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.js.map +1 -0
  133. package/features/contentEntry/deleteEntry/DeleteEntryRepository.d.ts +3 -1
  134. package/features/contentEntry/deleteEntry/DeleteEntryRepository.js +12 -2
  135. package/features/contentEntry/deleteEntry/DeleteEntryRepository.js.map +1 -1
  136. package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.js +6 -1
  137. package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.js.map +1 -1
  138. package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.d.ts +1 -0
  139. package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.js +112 -0
  140. package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.js.map +1 -0
  141. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.d.ts +14 -0
  142. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js +43 -0
  143. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js.map +1 -0
  144. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.d.ts +15 -0
  145. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js +34 -0
  146. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js.map +1 -0
  147. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.d.ts +11 -0
  148. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js +18 -0
  149. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js.map +1 -0
  150. package/features/contentEntry/duplicateEntry/abstractions.d.ts +26 -0
  151. package/features/contentEntry/duplicateEntry/abstractions.js +7 -0
  152. package/features/contentEntry/duplicateEntry/abstractions.js.map +1 -0
  153. package/features/contentEntry/duplicateEntry/feature.d.ts +3 -0
  154. package/features/contentEntry/duplicateEntry/feature.js +21 -0
  155. package/features/contentEntry/duplicateEntry/feature.js.map +1 -0
  156. package/features/contentEntry/entryValueGateways.test.d.ts +1 -0
  157. package/features/contentEntry/entryValueGateways.test.js +106 -0
  158. package/features/contentEntry/entryValueGateways.test.js.map +1 -0
  159. package/features/contentEntry/feature.js +4 -2
  160. package/features/contentEntry/feature.js.map +1 -1
  161. package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.js +6 -1
  162. package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.js.map +1 -1
  163. package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.d.ts +1 -0
  164. package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.js +130 -0
  165. package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.js.map +1 -0
  166. package/features/contentEntry/refTypes.d.ts +7 -0
  167. package/features/contentEntry/refTypes.js.map +1 -1
  168. package/features/contentEntry/referenceTitles/ReferenceTitles.d.ts +18 -0
  169. package/features/contentEntry/referenceTitles/ReferenceTitles.js +58 -0
  170. package/features/contentEntry/referenceTitles/ReferenceTitles.js.map +1 -0
  171. package/features/contentEntry/referenceTitles/ReferenceTitles.test.d.ts +1 -0
  172. package/features/contentEntry/referenceTitles/ReferenceTitles.test.js +173 -0
  173. package/features/contentEntry/referenceTitles/ReferenceTitles.test.js.map +1 -0
  174. package/features/contentEntry/referenceTitles/RememberTitlesDecorators.d.ts +22 -0
  175. package/features/contentEntry/referenceTitles/RememberTitlesDecorators.js +40 -0
  176. package/features/contentEntry/referenceTitles/RememberTitlesDecorators.js.map +1 -0
  177. package/features/contentEntry/referenceTitles/abstractions.d.ts +16 -0
  178. package/features/contentEntry/referenceTitles/abstractions.js +5 -0
  179. package/features/contentEntry/referenceTitles/abstractions.js.map +1 -0
  180. package/features/contentEntry/referenceTitles/feature.d.ts +3 -0
  181. package/features/contentEntry/referenceTitles/feature.js +20 -0
  182. package/features/contentEntry/referenceTitles/feature.js.map +1 -0
  183. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.d.ts +0 -1
  184. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js +3 -10
  185. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js.map +1 -1
  186. package/features/contentEntry/updateEntry/UpdateEntryGateway.d.ts +0 -1
  187. package/features/contentEntry/updateEntry/UpdateEntryGateway.js +3 -10
  188. package/features/contentEntry/updateEntry/UpdateEntryGateway.js.map +1 -1
  189. package/features/contentEntry/updateEntry/UpdateEntryRepository.d.ts +3 -1
  190. package/features/contentEntry/updateEntry/UpdateEntryRepository.js +10 -2
  191. package/features/contentEntry/updateEntry/UpdateEntryRepository.js.map +1 -1
  192. package/features/contentEntry/valueTransformers/DynamicZoneValueTransformer.js +7 -2
  193. package/features/contentEntry/valueTransformers/DynamicZoneValueTransformer.js.map +1 -1
  194. package/features/contentEntry/valueTransformers/EntryDataPreparer.d.ts +9 -0
  195. package/features/contentEntry/valueTransformers/EntryDataPreparer.js +8 -0
  196. package/features/contentEntry/valueTransformers/EntryDataPreparer.js.map +1 -1
  197. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.d.ts +1 -0
  198. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js +113 -0
  199. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js.map +1 -0
  200. package/features/contentEntry/valueTransformers/ObjectValueTransformer.js +16 -2
  201. package/features/contentEntry/valueTransformers/ObjectValueTransformer.js.map +1 -1
  202. package/features/contentEntry/valueTransformers/entryValueFixtures.d.ts +146 -0
  203. package/features/contentEntry/valueTransformers/entryValueFixtures.js +171 -0
  204. package/features/contentEntry/valueTransformers/entryValueFixtures.js.map +1 -0
  205. package/features/formModel/CmsFormModelBuilder.d.ts +9 -1
  206. package/features/formModel/CmsFormModelBuilder.js +26 -15
  207. package/features/formModel/CmsFormModelBuilder.js.map +1 -1
  208. package/features/formModel/CmsFormModelBuilder.test.d.ts +1 -0
  209. package/features/formModel/CmsFormModelBuilder.test.js +465 -0
  210. package/features/formModel/CmsFormModelBuilder.test.js.map +1 -0
  211. package/features/formModel/CmsLayoutMapper.d.ts +8 -1
  212. package/features/formModel/CmsLayoutMapper.js +27 -5
  213. package/features/formModel/CmsLayoutMapper.js.map +1 -1
  214. package/features/formModel/CmsRefFieldValueFormatter.d.ts +12 -0
  215. package/features/formModel/CmsRefFieldValueFormatter.js +29 -0
  216. package/features/formModel/CmsRefFieldValueFormatter.js.map +1 -0
  217. package/features/formModel/CmsValidationMapper.d.ts +9 -0
  218. package/features/formModel/CmsValidationMapper.js +25 -19
  219. package/features/formModel/CmsValidationMapper.js.map +1 -1
  220. package/features/formModel/feature.js +2 -2
  221. package/features/formModel/feature.js.map +1 -1
  222. package/features/formModel/mappers/AssetFieldMapper.d.ts +12 -0
  223. package/features/formModel/mappers/AssetFieldMapper.js +13 -0
  224. package/features/formModel/mappers/AssetFieldMapper.js.map +1 -0
  225. package/features/formModel/mappers/DateTimeFieldMapper.js +3 -0
  226. package/features/formModel/mappers/DateTimeFieldMapper.js.map +1 -1
  227. package/features/formModel/mappers/DynamicZoneFieldMapper.js +8 -2
  228. package/features/formModel/mappers/DynamicZoneFieldMapper.js.map +1 -1
  229. package/features/formModel/mappers/ObjectFieldMapper.js +12 -5
  230. package/features/formModel/mappers/ObjectFieldMapper.js.map +1 -1
  231. package/features/formModel/mappers/applyFieldProps.js +2 -1
  232. package/features/formModel/mappers/applyFieldProps.js.map +1 -1
  233. package/features/formModel/mappers/applyFieldProps.test.d.ts +1 -0
  234. package/features/formModel/mappers/applyFieldProps.test.js +59 -0
  235. package/features/formModel/mappers/applyFieldProps.test.js.map +1 -0
  236. package/features/formModel/mappers/index.js +2 -0
  237. package/features/formModel/mappers/index.js.map +1 -1
  238. package/features/model/deleteModel/DeleteModelGateway.js +6 -1
  239. package/features/model/deleteModel/DeleteModelGateway.js.map +1 -1
  240. package/features/model/deleteModel/DeleteModelGateway.test.d.ts +1 -0
  241. package/features/model/deleteModel/DeleteModelGateway.test.js +71 -0
  242. package/features/model/deleteModel/DeleteModelGateway.test.js.map +1 -0
  243. package/features/model/exportModels/ExportModelsGateway.d.ts +1 -1
  244. package/features/model/exportModels/ExportModelsGateway.js.map +1 -1
  245. package/features/model/exportModels/ExportModelsUseCase.js +7 -1
  246. package/features/model/exportModels/ExportModelsUseCase.js.map +1 -1
  247. package/features/model/exportModels/abstractions.d.ts +8 -2
  248. package/features/model/exportModels/abstractions.js.map +1 -1
  249. package/features/model/updateModel/UpdateModelGateway.js +1 -0
  250. package/features/model/updateModel/UpdateModelGateway.js.map +1 -1
  251. package/index.d.ts +1 -1
  252. package/index.js +1 -1
  253. package/package.json +30 -28
  254. package/presentation/cloneContentModel/CloneContentModelPresenter.d.ts +1 -0
  255. package/presentation/cloneContentModel/CloneContentModelPresenter.js +8 -6
  256. package/presentation/cloneContentModel/CloneContentModelPresenter.js.map +1 -1
  257. package/presentation/contentEntries/bulkActions/BulkDeletePresenter.d.ts +1 -1
  258. package/presentation/contentEntries/bulkActions/BulkDeletePresenter.js +6 -1
  259. package/presentation/contentEntries/bulkActions/BulkDeletePresenter.js.map +1 -1
  260. package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.d.ts +1 -0
  261. package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.js +124 -0
  262. package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.js.map +1 -0
  263. package/presentation/contentEntries/bulkActions/abstractions.d.ts +1 -1
  264. package/presentation/contentEntries/bulkActions/abstractions.js.map +1 -1
  265. package/presentation/contentEntries/form/ContentEntryFormPresenter.d.ts +2 -0
  266. package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.d.ts +1 -0
  267. package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.js +107 -0
  268. package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.js.map +1 -0
  269. package/presentation/contentEntries/form/ContentEntryFormPresenter.js +47 -30
  270. package/presentation/contentEntries/form/ContentEntryFormPresenter.js.map +1 -1
  271. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.d.ts +1 -0
  272. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js +244 -0
  273. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js.map +1 -0
  274. package/presentation/contentEntries/form/abstractions.d.ts +1 -0
  275. package/presentation/contentEntries/form/abstractions.js.map +1 -1
  276. package/presentation/contentEntries/form/getFieldBuilders.test.js +4 -2
  277. package/presentation/contentEntries/form/getFieldBuilders.test.js.map +1 -1
  278. package/presentation/contentEntries/form/toFormErrors.d.ts +7 -0
  279. package/presentation/contentEntries/form/toFormErrors.js +49 -0
  280. package/presentation/contentEntries/form/toFormErrors.js.map +1 -0
  281. package/presentation/contentEntries/form/toFormErrors.test.d.ts +1 -0
  282. package/presentation/contentEntries/form/toFormErrors.test.js +175 -0
  283. package/presentation/contentEntries/form/toFormErrors.test.js.map +1 -0
  284. package/presentation/contentEntries/list/ContentEntriesDataSource.d.ts +5 -0
  285. package/presentation/contentEntries/list/ContentEntriesDataSource.js +16 -4
  286. package/presentation/contentEntries/list/ContentEntriesDataSource.js.map +1 -1
  287. package/presentation/contentEntries/list/ContentEntriesPresenter.d.ts +6 -2
  288. package/presentation/contentEntries/list/ContentEntriesPresenter.js +27 -2
  289. package/presentation/contentEntries/list/ContentEntriesPresenter.js.map +1 -1
  290. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +134 -5
  291. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
  292. package/presentation/contentEntries/list/abstractions.d.ts +12 -0
  293. package/presentation/contentEntries/list/abstractions.js.map +1 -1
  294. package/presentation/contentEntries/preview/ComponentDiscoveryIframe.d.ts +7 -0
  295. package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js +47 -0
  296. package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js.map +1 -0
  297. package/presentation/contentEntries/preview/LivePreviewPresenter.d.ts +25 -0
  298. package/presentation/contentEntries/preview/LivePreviewPresenter.js +76 -0
  299. package/presentation/contentEntries/preview/LivePreviewPresenter.js.map +1 -0
  300. package/presentation/contentEntries/preview/LivePreviewPresenter.test.d.ts +1 -0
  301. package/presentation/contentEntries/preview/LivePreviewPresenter.test.js +81 -0
  302. package/presentation/contentEntries/preview/LivePreviewPresenter.test.js.map +1 -0
  303. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.d.ts +2 -0
  304. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js +30 -0
  305. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js.map +1 -0
  306. package/presentation/contentEntries/preview/PreviewComponentsContext.d.ts +15 -0
  307. package/presentation/contentEntries/preview/PreviewComponentsContext.js +43 -0
  308. package/presentation/contentEntries/preview/PreviewComponentsContext.js.map +1 -0
  309. package/presentation/contentEntries/preview/PreviewDecorator.d.ts +2 -0
  310. package/presentation/contentEntries/preview/PreviewDecorator.js +68 -0
  311. package/presentation/contentEntries/preview/PreviewDecorator.js.map +1 -0
  312. package/presentation/contentEntries/preview/PreviewDomainStatus.d.ts +10 -0
  313. package/presentation/contentEntries/preview/PreviewDomainStatus.js +19 -0
  314. package/presentation/contentEntries/preview/PreviewDomainStatus.js.map +1 -0
  315. package/presentation/contentEntries/preview/PreviewPane.d.ts +18 -0
  316. package/presentation/contentEntries/preview/PreviewPane.js +217 -0
  317. package/presentation/contentEntries/preview/PreviewPane.js.map +1 -0
  318. package/presentation/contentEntries/preview/abstractions.d.ts +24 -0
  319. package/presentation/contentEntries/preview/abstractions.js +5 -0
  320. package/presentation/contentEntries/preview/abstractions.js.map +1 -0
  321. package/presentation/contentEntries/preview/feature.d.ts +3 -0
  322. package/presentation/contentEntries/preview/feature.js +17 -0
  323. package/presentation/contentEntries/preview/feature.js.map +1 -0
  324. package/presentation/contentEntries/preview/resolvePreviewUrl.d.ts +26 -0
  325. package/presentation/contentEntries/preview/resolvePreviewUrl.js +81 -0
  326. package/presentation/contentEntries/preview/resolvePreviewUrl.js.map +1 -0
  327. package/presentation/contentEntries/preview/resolvePreviewUrl.test.d.ts +1 -0
  328. package/presentation/contentEntries/preview/resolvePreviewUrl.test.js +127 -0
  329. package/presentation/contentEntries/preview/resolvePreviewUrl.test.js.map +1 -0
  330. package/presentation/contentEntries/preview/useLivePreviewPresenter.d.ts +1 -0
  331. package/presentation/contentEntries/preview/useLivePreviewPresenter.js +8 -0
  332. package/presentation/contentEntries/preview/useLivePreviewPresenter.js.map +1 -0
  333. package/presentation/contentEntries/revisionsList/RevisionsListPresenter.d.ts +21 -2
  334. package/presentation/contentEntries/revisionsList/RevisionsListPresenter.js +143 -6
  335. package/presentation/contentEntries/revisionsList/RevisionsListPresenter.js.map +1 -1
  336. package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.d.ts +1 -0
  337. package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.js +384 -0
  338. package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.js.map +1 -0
  339. package/presentation/contentEntries/revisionsList/abstractions.d.ts +16 -0
  340. package/presentation/contentEntries/revisionsList/abstractions.js.map +1 -1
  341. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js +9 -4
  342. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js.map +1 -1
  343. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.d.ts +1 -0
  344. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js +122 -0
  345. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js.map +1 -0
  346. package/presentation/contentEntries/trashBin/CmsTrashBin.d.ts +2 -2
  347. package/presentation/contentEntries/views/CmsAdvancedSearch.d.ts +2 -2
  348. package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.d.ts +13 -0
  349. package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.js +54 -0
  350. package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.js.map +1 -0
  351. package/presentation/contentEntries/views/ContentEntriesListLayout.d.ts +2 -2
  352. package/presentation/contentEntries/views/ContentEntriesListLayout.js +4 -2
  353. package/presentation/contentEntries/views/ContentEntriesListLayout.js.map +1 -1
  354. package/presentation/contentEntries/views/ContentEntriesView.js +2 -0
  355. package/presentation/contentEntries/views/ContentEntriesView.js.map +1 -1
  356. package/presentation/contentEntries/views/ContentEntryFormView.d.ts +2 -2
  357. package/presentation/contentEntries/views/ContentEntryFormView.js +8 -6
  358. package/presentation/contentEntries/views/ContentEntryFormView.js.map +1 -1
  359. package/presentation/contentEntries/views/OlderRevisionAlert.d.ts +4 -0
  360. package/presentation/contentEntries/views/OlderRevisionAlert.js +43 -0
  361. package/presentation/contentEntries/views/OlderRevisionAlert.js.map +1 -0
  362. package/presentation/contentEntries/views/RevisionDrawer.d.ts +2 -2
  363. package/presentation/contentEntries/views/RevisionDrawer.js +4 -0
  364. package/presentation/contentEntries/views/RevisionDrawer.js.map +1 -1
  365. package/presentation/contentEntries/views/RevisionListItem.d.ts +3 -3
  366. package/presentation/contentEntries/views/RevisionListItem.js +82 -14
  367. package/presentation/contentEntries/views/RevisionListItem.js.map +1 -1
  368. package/presentation/contentEntries/views/RevisionsList.d.ts +2 -2
  369. package/presentation/contentEntries/views/RevisionsList.js +3 -3
  370. package/presentation/contentEntries/views/RevisionsList.js.map +1 -1
  371. package/presentation/contentEntries/views/SingleEntryLayout.d.ts +2 -2
  372. package/presentation/contentEntries/views/Table/Table.d.ts +2 -2
  373. package/presentation/contentEntries/views/actions/CreateNewRevisionButton.d.ts +2 -2
  374. package/presentation/contentEntries/views/actions/CreateNewRevisionButton.js +11 -0
  375. package/presentation/contentEntries/views/actions/CreateNewRevisionButton.js.map +1 -1
  376. package/presentation/contentEntries/views/actions/DeleteEntryMenuItem.d.ts +2 -2
  377. package/presentation/contentEntries/views/actions/PublishOnlyButton.d.ts +2 -2
  378. package/presentation/contentEntries/views/actions/RevisionSelector.d.ts +2 -2
  379. package/presentation/contentEntries/views/actions/SaveAndPublishButton.d.ts +2 -2
  380. package/presentation/contentEntries/views/actions/SaveContentButton.d.ts +2 -2
  381. package/presentation/contentEntries/views/actions/ShowRevisionListMenuItem.d.ts +2 -2
  382. package/presentation/contentEntries/views/layout/ContentEntryForm.d.ts +12 -12
  383. package/presentation/contentEntries/views/layout/ContentEntryFormContent.d.ts +10 -6
  384. package/presentation/contentEntries/views/layout/ContentEntryFormContent.js +7 -2
  385. package/presentation/contentEntries/views/layout/ContentEntryFormContent.js.map +1 -1
  386. package/presentation/contentModels/ContentModelsPresenter.d.ts +5 -5
  387. package/presentation/contentModels/ContentModelsPresenter.js +1 -1
  388. package/presentation/contentModels/ContentModelsPresenter.js.map +1 -1
  389. package/presentation/contentModels/abstractions.d.ts +7 -2
  390. package/presentation/contentModels/abstractions.js.map +1 -1
  391. package/presentation/contentModels/components/CloneContentModelDialog.d.ts +2 -2
  392. package/presentation/contentModels/components/ContentModels.d.ts +2 -2
  393. package/presentation/contentModels/components/ContentModelsDataList.d.ts +2 -2
  394. package/presentation/contentModels/components/ContentModelsDataList.js +6 -5
  395. package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
  396. package/presentation/contentModels/components/NewContentModelDialog.d.ts +2 -2
  397. package/presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.js +8 -3
  398. package/presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.js.map +1 -1
  399. package/presentation/contentModels/components/fullDelete/dialog/Content.js +7 -2
  400. package/presentation/contentModels/components/fullDelete/dialog/Content.js.map +1 -1
  401. package/presentation/contentModels/components/fullDelete/dialog/Content.test.d.ts +1 -0
  402. package/presentation/contentModels/components/fullDelete/dialog/Content.test.js +54 -0
  403. package/presentation/contentModels/components/fullDelete/dialog/Content.test.js.map +1 -0
  404. package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.d.ts +25 -0
  405. package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.js +9 -0
  406. package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.js.map +1 -0
  407. package/presentation/contentModels/components/fullDelete/types.js.map +1 -1
  408. package/presentation/fieldEditor/FieldEditorPresenter.js +1 -1
  409. package/presentation/fieldEditor/FieldEditorPresenter.js.map +1 -1
  410. package/presentation/fieldEditor/groups/AppearanceGroup.js +12 -0
  411. package/presentation/fieldEditor/groups/AppearanceGroup.js.map +1 -1
  412. package/presentation/fieldEditor/groups/GeneralGroup.d.ts +5 -5
  413. package/presentation/fieldEditor/groups/GeneralGroup.js +5 -1
  414. package/presentation/fieldEditor/groups/GeneralGroup.js.map +1 -1
  415. package/presentation/fieldEditor/groups/GeneralGroup.test.d.ts +1 -0
  416. package/presentation/fieldEditor/groups/GeneralGroup.test.js +68 -0
  417. package/presentation/fieldEditor/groups/GeneralGroup.test.js.map +1 -0
  418. package/presentation/fieldEditor/groups/ValidationsGroup.d.ts +2 -0
  419. package/presentation/fieldEditor/groups/ValidationsGroup.js +21 -7
  420. package/presentation/fieldEditor/groups/ValidationsGroup.js.map +1 -1
  421. package/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js +3 -3
  422. package/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js.map +1 -1
  423. package/presentation/fieldEditor/renderers/CmsValidatorsRenderer.js +2 -2
  424. package/presentation/fieldEditor/renderers/CmsValidatorsRenderer.js.map +1 -1
  425. package/presentation/fieldRenderers/feature.js +2 -1
  426. package/presentation/fieldRenderers/feature.js.map +1 -1
  427. package/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js +8 -0
  428. package/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js.map +1 -1
  429. package/presentation/fieldRenderers/ref/CmsRefDetailedSingleRenderer.js +8 -0
  430. package/presentation/fieldRenderers/ref/CmsRefDetailedSingleRenderer.js.map +1 -1
  431. package/presentation/fieldRenderers/ref/CmsRefInputRenderer.js +1 -0
  432. package/presentation/fieldRenderers/ref/CmsRefInputRenderer.js.map +1 -1
  433. package/presentation/fieldRenderers/ref/CmsRefInputsRenderer.js +1 -0
  434. package/presentation/fieldRenderers/ref/CmsRefInputsRenderer.js.map +1 -1
  435. package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.d.ts +1 -0
  436. package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.js +8 -2
  437. package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.js.map +1 -1
  438. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.d.ts +1 -0
  439. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js +185 -0
  440. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js.map +1 -0
  441. package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js +1 -1
  442. package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js.map +1 -1
  443. package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js +1 -1
  444. package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js.map +1 -1
  445. package/presentation/fieldRenderers/ref/components/EditEntryDrawer.d.ts +10 -0
  446. package/presentation/fieldRenderers/ref/components/EditEntryDrawer.js +94 -0
  447. package/presentation/fieldRenderers/ref/components/EditEntryDrawer.js.map +1 -0
  448. package/presentation/fieldRenderers/ref/components/EntryCard.d.ts +2 -0
  449. package/presentation/fieldRenderers/ref/components/EntryCard.js +13 -3
  450. package/presentation/fieldRenderers/ref/components/EntryCard.js.map +1 -1
  451. package/presentation/fieldRenderers/ref/components/RefFieldOptions.d.ts +2 -2
  452. package/presentation/fieldRenderers/ref/components/RefFieldOptions.js +3 -2
  453. package/presentation/fieldRenderers/ref/components/RefFieldOptions.js.map +1 -1
  454. package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.d.ts +2 -1
  455. package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.js +6 -0
  456. package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.js.map +1 -1
  457. package/presentation/fieldRenderers/ref/detailed/abstractions.d.ts +2 -1
  458. package/presentation/fieldRenderers/ref/detailed/abstractions.js.map +1 -1
  459. package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.d.ts +13 -0
  460. package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.js +25 -0
  461. package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.js.map +1 -0
  462. package/presentation/fieldRenderers/ref/editEntry/abstractions.d.ts +10 -0
  463. package/presentation/fieldRenderers/ref/editEntry/abstractions.js +5 -0
  464. package/presentation/fieldRenderers/ref/editEntry/abstractions.js.map +1 -0
  465. package/presentation/fieldRenderers/ref/editEntry/feature.d.ts +3 -0
  466. package/presentation/fieldRenderers/ref/editEntry/feature.js +17 -0
  467. package/presentation/fieldRenderers/ref/editEntry/feature.js.map +1 -0
  468. package/presentation/fieldTypes/abstractions.d.ts +12 -0
  469. package/presentation/fieldTypes/abstractions.js.map +1 -1
  470. package/presentation/fieldTypes/renderers/common/SelectBoxRenderer.js +1 -1
  471. package/presentation/fieldTypes/renderers/common/SelectBoxRenderer.js.map +1 -1
  472. package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.d.ts +15 -0
  473. package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.js +19 -0
  474. package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.js.map +1 -0
  475. package/presentation/fieldTypes/renderers/dynamicZone/DynamicZoneRenderer.js +6 -2
  476. package/presentation/fieldTypes/renderers/dynamicZone/DynamicZoneRenderer.js.map +1 -1
  477. package/presentation/fieldTypes/renderers/index.d.ts +1 -0
  478. package/presentation/fieldTypes/renderers/index.js +1 -0
  479. package/presentation/fieldTypes/renderers/object/ObjectAccordionRenderer.js +2 -0
  480. package/presentation/fieldTypes/renderers/object/ObjectAccordionRenderer.js.map +1 -1
  481. package/presentation/fieldTypes/renderers/object/ObjectsAccordionRenderer.js +6 -0
  482. package/presentation/fieldTypes/renderers/object/ObjectsAccordionRenderer.js.map +1 -1
  483. package/presentation/fieldTypes/types/DynamicZoneFieldType.d.ts +3 -6
  484. package/presentation/fieldTypes/types/DynamicZoneFieldType.js +2 -12
  485. package/presentation/fieldTypes/types/DynamicZoneFieldType.js.map +1 -1
  486. package/presentation/fieldTypes/types/dynamicZone/TemplateDialog.js +25 -3
  487. package/presentation/fieldTypes/types/dynamicZone/TemplateDialog.js.map +1 -1
  488. package/presentation/fieldValidators/abstractions.d.ts +7 -0
  489. package/presentation/fieldValidators/abstractions.js.map +1 -1
  490. package/presentation/fieldValidators/validators/DateGteValidator.d.ts +6 -0
  491. package/presentation/fieldValidators/validators/DateGteValidator.js +17 -25
  492. package/presentation/fieldValidators/validators/DateGteValidator.js.map +1 -1
  493. package/presentation/fieldValidators/validators/DateLteValidator.d.ts +6 -0
  494. package/presentation/fieldValidators/validators/DateLteValidator.js +17 -25
  495. package/presentation/fieldValidators/validators/DateLteValidator.js.map +1 -1
  496. package/presentation/fieldValidators/validators/dateLimitSettings.d.ts +20 -0
  497. package/presentation/fieldValidators/validators/dateLimitSettings.js +124 -0
  498. package/presentation/fieldValidators/validators/dateLimitSettings.js.map +1 -0
  499. package/presentation/fieldValidators/validators/dateLimitSettings.test.d.ts +1 -0
  500. package/presentation/fieldValidators/validators/dateLimitSettings.test.js +111 -0
  501. package/presentation/fieldValidators/validators/dateLimitSettings.test.js.map +1 -0
  502. package/presentation/importContentModels/ImportContentModelsDialog.d.ts +2 -2
  503. package/presentation/importContentModels/ImportContentModelsPresenter.js +1 -1
  504. package/presentation/importContentModels/ImportContentModelsPresenter.js.map +1 -1
  505. package/presentation/importContentModels/components/DataList.d.ts +2 -2
  506. package/presentation/importContentModels/components/FileUpload.d.ts +2 -2
  507. package/presentation/importContentModels/components/Model/DataListModelItem.js +3 -3
  508. package/presentation/importContentModels/components/Model/DataListModelItem.js.map +1 -1
  509. package/presentation/importContentModels/components/Model/DataListModelItemInfo.js +2 -2
  510. package/presentation/importContentModels/components/Model/DataListModelItemInfo.js.map +1 -1
  511. package/presentation/importContentModels/components/Model/DataListModels.d.ts +2 -2
  512. package/presentation/menus/ContentGroupsMenuItems.d.ts +2 -2
  513. package/presentation/modelGroup/ModelGroupPresenter.d.ts +3 -1
  514. package/presentation/modelGroup/ModelGroupPresenter.js +8 -11
  515. package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
  516. package/presentation/modelGroup/components/ContentModelGroups.d.ts +2 -2
  517. package/presentation/modelGroup/components/ContentModelGroupsDataList.d.ts +6 -2
  518. package/presentation/modelGroup/components/ContentModelGroupsForm.d.ts +8 -2
  519. package/presentation/newContentModel/NewContentModelPresenter.d.ts +1 -0
  520. package/presentation/newContentModel/NewContentModelPresenter.js +8 -6
  521. package/presentation/newContentModel/NewContentModelPresenter.js.map +1 -1
  522. package/utils/normalizeIcon.d.ts +4 -0
  523. package/utils/normalizeIcon.js +9 -6
  524. package/utils/normalizeIcon.js.map +1 -1
  525. package/features/formModel/CmsAccessControlRuleEvaluator.d.ts +0 -9
  526. package/features/formModel/CmsAccessControlRuleEvaluator.js +0 -16
  527. package/features/formModel/CmsAccessControlRuleEvaluator.js.map +0 -1
@@ -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 ? String(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 ? String(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 ? String(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 ? String(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","String","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,KAAK;YACD,OAAOc,SAASH,OAA8BZ;QAElD;YACI,OAAO;IACf;AACJ;AAEA,SAASa,aACLD,KAA8B,EAC9BZ,aAA6B;IAE7B,MAAMgB,UAAUhB,cAAc,SAAS;IACvC,IAAIY,MAAM,KAAK,EACXI,QAAQ,KAAK,CAACJ,MAAM,KAAK;IAE7B,IAAIA,MAAM,WAAW,EACj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,KAAK,GAAWC,OAAOD,EAAE,KAAK,IAAI;YAC3C,QAAQA,EAAE,MAAM;QACpB;IAIR,OAAOE;AACX;AAEA,SAASJ,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,AAAW,QAAXA,EAAE,KAAK,GAAWC,OAAOD,EAAE,KAAK,IAAI;YAC3C,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,SAAS,GAAG,CAACE;IAErB,OAAO,IAAIN,cAAcK,SAASA,AAAc,WAAdA,KAAK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AACL,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"}
@@ -0,0 +1,12 @@
1
+ import { FieldValueFormatter, type IFieldVM } from "@webiny/app-admin/features/formModel/abstractions.js";
2
+ import { ReferenceTitles } from "../../features/contentEntry/referenceTitles/abstractions.js";
3
+ declare class CmsRefFieldValueFormatterImpl implements FieldValueFormatter.Interface {
4
+ private titles;
5
+ readonly type = "ref";
6
+ constructor(titles: ReferenceTitles.Interface);
7
+ format(field: IFieldVM): string | undefined;
8
+ }
9
+ export declare const CmsRefFieldValueFormatter: typeof CmsRefFieldValueFormatterImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/app-admin/features/formModel").IFieldValueFormatter>;
11
+ };
12
+ export {};
@@ -0,0 +1,29 @@
1
+ import { FieldValueFormatter } from "@webiny/app-admin/features/formModel/abstractions.js";
2
+ import { ReferenceTitles } from "../contentEntry/referenceTitles/abstractions.js";
3
+ function isReference(value) {
4
+ const ref = value;
5
+ return "string" == typeof ref?.id && "string" == typeof ref?.modelId;
6
+ }
7
+ class CmsRefFieldValueFormatterImpl {
8
+ constructor(titles){
9
+ this.titles = titles;
10
+ this.type = "ref";
11
+ }
12
+ format(field) {
13
+ const values = Array.isArray(field.value) ? field.value : [
14
+ field.value
15
+ ];
16
+ const titles = values.filter(isReference).map((ref)=>this.titles.getTitle(ref));
17
+ if (titles.some((title)=>void 0 === title)) return;
18
+ return titles.filter(Boolean).join(", ");
19
+ }
20
+ }
21
+ const CmsRefFieldValueFormatter = FieldValueFormatter.createImplementation({
22
+ implementation: CmsRefFieldValueFormatterImpl,
23
+ dependencies: [
24
+ ReferenceTitles
25
+ ]
26
+ });
27
+ export { CmsRefFieldValueFormatter };
28
+
29
+ //# sourceMappingURL=CmsRefFieldValueFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/formModel/CmsRefFieldValueFormatter.js","sources":["../../../src/features/formModel/CmsRefFieldValueFormatter.ts"],"sourcesContent":["import {\n FieldValueFormatter,\n type IFieldVM\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { ReferenceTitles } from \"~/features/contentEntry/referenceTitles/abstractions.js\";\nimport type { CmsReferenceValue } from \"~/features/contentEntry/refTypes.js\";\n\nfunction isReference(value: unknown): value is CmsReferenceValue {\n const ref = value as CmsReferenceValue | null;\n return typeof ref?.id === \"string\" && typeof ref?.modelId === \"string\";\n}\n\nclass CmsRefFieldValueFormatterImpl implements FieldValueFormatter.Interface {\n readonly type = \"ref\";\n\n constructor(private titles: ReferenceTitles.Interface) {}\n\n format(field: IFieldVM): string | undefined {\n const values = Array.isArray(field.value) ? field.value : [field.value];\n const titles = values.filter(isReference).map(ref => this.titles.getTitle(ref));\n // Show nothing until every title is in, rather than a list that fills in one at a time.\n if (titles.some(title => title === undefined)) {\n return undefined;\n }\n return titles.filter(Boolean).join(\", \");\n }\n}\n\nexport const CmsRefFieldValueFormatter = FieldValueFormatter.createImplementation({\n implementation: CmsRefFieldValueFormatterImpl,\n dependencies: [ReferenceTitles]\n});\n"],"names":["isReference","value","ref","CmsRefFieldValueFormatterImpl","titles","field","values","Array","title","undefined","Boolean","CmsRefFieldValueFormatter","FieldValueFormatter","ReferenceTitles"],"mappings":";;AAOA,SAASA,YAAYC,KAAc;IAC/B,MAAMC,MAAMD;IACZ,OAAO,AAAmB,YAAnB,OAAOC,KAAK,MAAmB,AAAwB,YAAxB,OAAOA,KAAK;AACtD;AAEA,MAAMC;IAGF,YAAoBC,MAAiC,CAAE;aAAnCA,MAAM,GAANA;aAFX,IAAI,GAAG;IAEwC;IAExD,OAAOC,KAAe,EAAsB;QACxC,MAAMC,SAASC,MAAM,OAAO,CAACF,MAAM,KAAK,IAAIA,MAAM,KAAK,GAAG;YAACA,MAAM,KAAK;SAAC;QACvE,MAAMD,SAASE,OAAO,MAAM,CAACN,aAAa,GAAG,CAACE,CAAAA,MAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAACA;QAE1E,IAAIE,OAAO,IAAI,CAACI,CAAAA,QAASA,AAAUC,WAAVD,QACrB;QAEJ,OAAOJ,OAAO,MAAM,CAACM,SAAS,IAAI,CAAC;IACvC;AACJ;AAEO,MAAMC,4BAA4BC,oBAAoB,oBAAoB,CAAC;IAC9E,gBAAgBT;IAChB,cAAc;QAACU;KAAgB;AACnC"}
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import type { DateBound } from "@webiny/utils";
2
3
  import type { CmsModelFieldValidator } from "../../types.js";
3
4
  export declare function mapCmsValidators(validators: (CmsModelFieldValidator | {
4
5
  name: string;
@@ -7,6 +8,14 @@ export declare function mapCmsValidators(validators: (CmsModelFieldValidator | {
7
8
  requiredMessage?: string;
8
9
  schema: z.ZodTypeAny | undefined;
9
10
  };
11
+ /** The `dateGte`/`dateLte` validators, as limits for the `datetime()` builder. */
12
+ export declare function mapCmsDateLimits(validators: (CmsModelFieldValidator | {
13
+ name: string;
14
+ })[] | undefined): {
15
+ name: "dateGte" | "dateLte";
16
+ bound: DateBound;
17
+ message?: string;
18
+ }[];
10
19
  export declare function mapCmsListValidators(validators: (CmsModelFieldValidator | {
11
20
  name: string;
12
21
  })[] | undefined): {
@@ -44,31 +44,37 @@ function mapCmsValidators(validators) {
44
44
  case "in":
45
45
  if (Array.isArray(settings.values) && settings.values.length > 0) schemas.push(z["enum"](settings.values));
46
46
  break;
47
- case "dateGte":
48
- if (null != settings.value) {
49
- const minDate = settings.value;
50
- schemas.push(z.string().refine((val)=>val >= minDate, {
51
- message: msg || `Must be on or after ${minDate}`
52
- }));
53
- }
54
- break;
55
- case "dateLte":
56
- if (null != settings.value) {
57
- const maxDate = settings.value;
58
- schemas.push(z.string().refine((val)=>val <= maxDate, {
59
- message: msg || `Must be on or before ${maxDate}`
60
- }));
61
- }
62
- break;
63
47
  }
64
48
  }
65
- const schema = 0 === schemas.length ? void 0 : 1 === schemas.length ? schemas[0] : z.intersection(schemas[0], schemas.slice(1).reduce((acc, s)=>z.intersection(acc, s), schemas[0]));
49
+ const schema = 0 === schemas.length ? void 0 : schemas.slice(1).reduce((acc, s)=>z.intersection(acc, s), schemas[0]);
66
50
  return {
67
51
  required,
68
52
  requiredMessage,
69
- schema: schemas.length <= 1 ? schema : void 0
53
+ schema
70
54
  };
71
55
  }
56
+ function mapCmsDateLimits(validators) {
57
+ const limits = [];
58
+ for (const v of validators || []){
59
+ const validator = v;
60
+ if ("dateGte" !== validator.name && "dateLte" !== validator.name) continue;
61
+ const settings = validator.settings || {};
62
+ const message = interpolateMessage(validator.message, settings);
63
+ if ("string" == typeof settings.expression) limits.push({
64
+ name: validator.name,
65
+ bound: {
66
+ expression: settings.expression
67
+ },
68
+ message
69
+ });
70
+ else if (null != settings.value) limits.push({
71
+ name: validator.name,
72
+ bound: String(settings.value),
73
+ message
74
+ });
75
+ }
76
+ return limits;
77
+ }
72
78
  function mapCmsListValidators(validators) {
73
79
  if (!validators || 0 === validators.length) return {
74
80
  required: false,
@@ -101,6 +107,6 @@ function mapCmsListValidators(validators) {
101
107
  schema: hasConstraints ? arraySchema : void 0
102
108
  };
103
109
  }
104
- export { mapCmsListValidators, mapCmsValidators };
110
+ export { mapCmsDateLimits, mapCmsListValidators, mapCmsValidators };
105
111
 
106
112
  //# sourceMappingURL=CmsValidationMapper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features/formModel/CmsValidationMapper.js","sources":["../../../src/features/formModel/CmsValidationMapper.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { CmsModelFieldValidator } from \"~/types.js\";\n\nfunction interpolateMessage(\n message: string | undefined,\n settings: Record<string, unknown>\n): string | undefined {\n if (!message) {\n return undefined;\n }\n return message.replace(/\\{(\\w+)}/g, (match, key) => {\n const val = settings[key];\n return val != null ? String(val) : match;\n });\n}\n\nexport function mapCmsValidators(\n validators: (CmsModelFieldValidator | { name: string })[] | undefined\n): { required: boolean; requiredMessage?: string; schema: z.ZodTypeAny | undefined } {\n if (!validators || validators.length === 0) {\n return { required: false, schema: undefined };\n }\n\n let required = false;\n let requiredMessage: string | undefined;\n const schemas: z.ZodTypeAny[] = [];\n\n for (const v of validators) {\n const validator = v as CmsModelFieldValidator;\n const settings = validator.settings || {};\n\n const msg = interpolateMessage(validator.message, settings);\n\n switch (validator.name) {\n case \"required\":\n required = true;\n requiredMessage = msg;\n break;\n\n case \"minLength\":\n if (settings.value != null) {\n schemas.push(z.string().min(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"maxLength\":\n if (settings.value != null) {\n schemas.push(z.string().max(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"pattern\":\n if (settings.regex) {\n const flags = settings.flags || \"\";\n schemas.push(\n z.string().regex(new RegExp(settings.regex, flags), msg || undefined)\n );\n }\n break;\n\n case \"gte\":\n if (settings.value != null) {\n schemas.push(z.number().gte(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"lte\":\n if (settings.value != null) {\n schemas.push(z.number().lte(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"in\":\n if (Array.isArray(settings.values) && settings.values.length > 0) {\n schemas.push(z.enum(settings.values as [string, ...string[]]));\n }\n break;\n\n case \"dateGte\":\n if (settings.value != null) {\n const minDate = settings.value;\n schemas.push(\n z.string().refine(val => val >= minDate, {\n message: msg || `Must be on or after ${minDate}`\n })\n );\n }\n break;\n\n case \"dateLte\":\n if (settings.value != null) {\n const maxDate = settings.value;\n schemas.push(\n z.string().refine(val => val <= maxDate, {\n message: msg || `Must be on or before ${maxDate}`\n })\n );\n }\n break;\n }\n }\n\n const schema =\n schemas.length === 0\n ? undefined\n : schemas.length === 1\n ? schemas[0]\n : z.intersection(\n schemas[0],\n schemas.slice(1).reduce((acc, s) => z.intersection(acc, s), schemas[0])\n );\n\n return { required, requiredMessage, schema: schemas.length <= 1 ? schema : undefined };\n}\n\nexport function mapCmsListValidators(\n validators: (CmsModelFieldValidator | { name: string })[] | undefined\n): { required: boolean; requiredMessage?: string; schema: z.ZodTypeAny | undefined } {\n if (!validators || validators.length === 0) {\n return { required: false, schema: undefined };\n }\n\n let required = false;\n let requiredMessage: string | undefined;\n let arraySchema = z.array(z.unknown());\n\n for (const v of validators) {\n const validator = v as CmsModelFieldValidator;\n const settings = validator.settings || {};\n const msg = interpolateMessage(validator.message, settings);\n\n switch (validator.name) {\n case \"required\":\n required = true;\n requiredMessage = msg;\n break;\n\n case \"minLength\":\n if (settings.value != null) {\n arraySchema = arraySchema.min(\n Number(settings.value),\n msg || undefined\n ) as typeof arraySchema;\n }\n break;\n\n case \"maxLength\":\n if (settings.value != null) {\n arraySchema = arraySchema.max(\n Number(settings.value),\n msg || undefined\n ) as typeof arraySchema;\n }\n break;\n }\n }\n\n const hasConstraints = validators.some(\n v =>\n (v as CmsModelFieldValidator).name === \"minLength\" ||\n (v as CmsModelFieldValidator).name === \"maxLength\"\n );\n\n return {\n required,\n requiredMessage,\n schema: hasConstraints ? arraySchema : undefined\n };\n}\n"],"names":["interpolateMessage","message","settings","match","key","val","String","mapCmsValidators","validators","undefined","required","requiredMessage","schemas","v","validator","msg","z","Number","flags","RegExp","Array","minDate","maxDate","schema","acc","s","mapCmsListValidators","arraySchema","hasConstraints"],"mappings":";AAGA,SAASA,mBACLC,OAA2B,EAC3BC,QAAiC;IAEjC,IAAI,CAACD,SACD;IAEJ,OAAOA,QAAQ,OAAO,CAAC,aAAa,CAACE,OAAOC;QACxC,MAAMC,MAAMH,QAAQ,CAACE,IAAI;QACzB,OAAOC,AAAO,QAAPA,MAAcC,OAAOD,OAAOF;IACvC;AACJ;AAEO,SAASI,iBACZC,UAAqE;IAErE,IAAI,CAACA,cAAcA,AAAsB,MAAtBA,WAAW,MAAM,EAChC,OAAO;QAA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AC;QACxC,MAAMC,MAAMf,mBAAmBc,UAAU,OAAO,EAAEZ;QAElD,OAAQY,UAAU,IAAI;YAClB,KAAK;gBACDJ,WAAW;gBACXC,kBAAkBI;gBAClB;YAEJ,KAAK;gBACD,IAAIb,AAAkB,QAAlBA,SAAS,KAAK,EACdyB,cAAcA,YAAY,GAAG,CACzBV,OAAOf,SAAS,KAAK,GACrBa,OAAON;gBAGf;YAEJ,KAAK;gBACD,IAAIP,AAAkB,QAAlBA,SAAS,KAAK,EACdyB,cAAcA,YAAY,GAAG,CACzBV,OAAOf,SAAS,KAAK,GACrBa,OAAON;gBAGf;QACR;IACJ;IAEA,MAAMmB,iBAAiBpB,WAAW,IAAI,CAClCK,CAAAA,IACKA,AAAsC,gBAAtCA,EAA6B,IAAI,IACjCA,AAAsC,gBAAtCA,EAA6B,IAAI;IAG1C,OAAO;QACHH;QACAC;QACA,QAAQiB,iBAAiBD,cAAclB;IAC3C;AACJ"}
1
+ {"version":3,"file":"features/formModel/CmsValidationMapper.js","sources":["../../../src/features/formModel/CmsValidationMapper.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { DateBound } from \"@webiny/utils\";\nimport type { CmsModelFieldValidator } from \"~/types.js\";\n\nfunction interpolateMessage(\n message: string | undefined,\n settings: Record<string, unknown>\n): string | undefined {\n if (!message) {\n return undefined;\n }\n return message.replace(/\\{(\\w+)}/g, (match, key) => {\n const val = settings[key];\n return val != null ? String(val) : match;\n });\n}\n\nexport function mapCmsValidators(\n validators: (CmsModelFieldValidator | { name: string })[] | undefined\n): { required: boolean; requiredMessage?: string; schema: z.ZodTypeAny | undefined } {\n if (!validators || validators.length === 0) {\n return { required: false, schema: undefined };\n }\n\n let required = false;\n let requiredMessage: string | undefined;\n const schemas: z.ZodTypeAny[] = [];\n\n for (const v of validators) {\n const validator = v as CmsModelFieldValidator;\n const settings = validator.settings || {};\n\n const msg = interpolateMessage(validator.message, settings);\n\n switch (validator.name) {\n case \"required\":\n required = true;\n requiredMessage = msg;\n break;\n\n case \"minLength\":\n if (settings.value != null) {\n schemas.push(z.string().min(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"maxLength\":\n if (settings.value != null) {\n schemas.push(z.string().max(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"pattern\":\n if (settings.regex) {\n const flags = settings.flags || \"\";\n schemas.push(\n z.string().regex(new RegExp(settings.regex, flags), msg || undefined)\n );\n }\n break;\n\n case \"gte\":\n if (settings.value != null) {\n schemas.push(z.number().gte(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"lte\":\n if (settings.value != null) {\n schemas.push(z.number().lte(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"in\":\n if (Array.isArray(settings.values) && settings.values.length > 0) {\n schemas.push(z.enum(settings.values as [string, ...string[]]));\n }\n break;\n\n // \"dateGte\" and \"dateLte\" are applied by `DateTimeFieldMapper`, through the\n // `datetime()` builder, which also hands the limits to the field's picker.\n }\n }\n\n const schema =\n schemas.length === 0\n ? undefined\n : schemas.slice(1).reduce<z.ZodTypeAny>((acc, s) => z.intersection(acc, s), schemas[0]);\n\n return { required, requiredMessage, schema };\n}\n\n/** The `dateGte`/`dateLte` validators, as limits for the `datetime()` builder. */\nexport function mapCmsDateLimits(\n validators: (CmsModelFieldValidator | { name: string })[] | undefined\n): { name: \"dateGte\" | \"dateLte\"; bound: DateBound; message?: string }[] {\n const limits: { name: \"dateGte\" | \"dateLte\"; bound: DateBound; message?: string }[] = [];\n for (const v of validators || []) {\n const validator = v as CmsModelFieldValidator;\n if (validator.name !== \"dateGte\" && validator.name !== \"dateLte\") {\n continue;\n }\n const settings = validator.settings || {};\n const message = interpolateMessage(validator.message, settings);\n if (typeof settings.expression === \"string\") {\n limits.push({\n name: validator.name,\n bound: { expression: settings.expression },\n message\n });\n } else if (settings.value != null) {\n limits.push({ name: validator.name, bound: String(settings.value), message });\n }\n }\n return limits;\n}\n\nexport function mapCmsListValidators(\n validators: (CmsModelFieldValidator | { name: string })[] | undefined\n): { required: boolean; requiredMessage?: string; schema: z.ZodTypeAny | undefined } {\n if (!validators || validators.length === 0) {\n return { required: false, schema: undefined };\n }\n\n let required = false;\n let requiredMessage: string | undefined;\n let arraySchema = z.array(z.unknown());\n\n for (const v of validators) {\n const validator = v as CmsModelFieldValidator;\n const settings = validator.settings || {};\n const msg = interpolateMessage(validator.message, settings);\n\n switch (validator.name) {\n case \"required\":\n required = true;\n requiredMessage = msg;\n break;\n\n case \"minLength\":\n if (settings.value != null) {\n arraySchema = arraySchema.min(\n Number(settings.value),\n msg || undefined\n ) as typeof arraySchema;\n }\n break;\n\n case \"maxLength\":\n if (settings.value != null) {\n arraySchema = arraySchema.max(\n Number(settings.value),\n msg || undefined\n ) as typeof arraySchema;\n }\n break;\n }\n }\n\n const hasConstraints = validators.some(\n v =>\n (v as CmsModelFieldValidator).name === \"minLength\" ||\n (v as CmsModelFieldValidator).name === \"maxLength\"\n );\n\n return {\n required,\n requiredMessage,\n schema: hasConstraints ? arraySchema : undefined\n };\n}\n"],"names":["interpolateMessage","message","settings","match","key","val","String","mapCmsValidators","validators","undefined","required","requiredMessage","schemas","v","validator","msg","z","Number","flags","RegExp","Array","schema","acc","s","mapCmsDateLimits","limits","mapCmsListValidators","arraySchema","hasConstraints"],"mappings":";AAIA,SAASA,mBACLC,OAA2B,EAC3BC,QAAiC;IAEjC,IAAI,CAACD,SACD;IAEJ,OAAOA,QAAQ,OAAO,CAAC,aAAa,CAACE,OAAOC;QACxC,MAAMC,MAAMH,QAAQ,CAACE,IAAI;QACzB,OAAOC,AAAO,QAAPA,MAAcC,OAAOD,OAAOF;IACvC;AACJ;AAEO,SAASI,iBACZC,UAAqE;IAErE,IAAI,CAACA,cAAcA,AAAsB,MAAtBA,WAAW,MAAM,EAChC,OAAO;QAAE,UAAU;QAAO,QAAQC;IAAU;IAGhD,IAAIC,WAAW;IACf,IAAIC;IACJ,MAAMC,UAA0B,EAAE;IAElC,KAAK,MAAMC,KAAKL,WAAY;QACxB,MAAMM,YAAYD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AIb,AAAkB,QAAlBA,SAAS,KAAK,EACdyB,cAAcA,YAAY,GAAG,CACzBV,OAAOf,SAAS,KAAK,GACrBa,OAAON;gBAGf;YAEJ,KAAK;gBACD,IAAIP,AAAkB,QAAlBA,SAAS,KAAK,EACdyB,cAAcA,YAAY,GAAG,CACzBV,OAAOf,SAAS,KAAK,GACrBa,OAAON;gBAGf;QACR;IACJ;IAEA,MAAMmB,iBAAiBpB,WAAW,IAAI,CAClCK,CAAAA,IACKA,AAAsC,gBAAtCA,EAA6B,IAAI,IACjCA,AAAsC,gBAAtCA,EAA6B,IAAI;IAG1C,OAAO;QACHH;QACAC;QACA,QAAQiB,iBAAiBD,cAAclB;IAC3C;AACJ"}
@@ -2,13 +2,13 @@ import { createFeature } from "@webiny/feature/admin";
2
2
  import { CmsFormModelBuilder } from "./abstractions.js";
3
3
  import { CmsFormModelBuilder as external_CmsFormModelBuilder_js_CmsFormModelBuilder } from "./CmsFormModelBuilder.js";
4
4
  import { CmsRefFieldType } from "./CmsRefFieldType.js";
5
- import { CmsAccessControlRuleEvaluator } from "./CmsAccessControlRuleEvaluator.js";
5
+ import { CmsRefFieldValueFormatter } from "./CmsRefFieldValueFormatter.js";
6
6
  const CmsFormModelFeature = createFeature({
7
7
  name: "CmsFormModel",
8
8
  register (container) {
9
9
  container.register(external_CmsFormModelBuilder_js_CmsFormModelBuilder).inSingletonScope();
10
10
  container.register(CmsRefFieldType);
11
- container.register(CmsAccessControlRuleEvaluator);
11
+ container.register(CmsRefFieldValueFormatter);
12
12
  },
13
13
  resolve (container) {
14
14
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"features/formModel/feature.js","sources":["../../../src/features/formModel/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { CmsFormModelBuilder as CmsFormModelBuilderAbstraction } from \"./abstractions.js\";\nimport { CmsFormModelBuilder } from \"./CmsFormModelBuilder.js\";\nimport { CmsRefFieldType } from \"./CmsRefFieldType.js\";\nimport { CmsAccessControlRuleEvaluator } from \"./CmsAccessControlRuleEvaluator.js\";\n\nexport const CmsFormModelFeature = createFeature({\n name: \"CmsFormModel\",\n register(container) {\n container.register(CmsFormModelBuilder).inSingletonScope();\n container.register(CmsRefFieldType);\n container.register(CmsAccessControlRuleEvaluator);\n },\n resolve(container) {\n return {\n builder: container.resolve(CmsFormModelBuilderAbstraction)\n };\n }\n});\n"],"names":["CmsFormModelFeature","createFeature","container","CmsFormModelBuilder","CmsRefFieldType","CmsAccessControlRuleEvaluator","CmsFormModelBuilderAbstraction"],"mappings":";;;;;AAMO,MAAMA,sBAAsBC,cAAc;IAC7C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,qDAAqB,gBAAgB;QACxDD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;IACvB;IACA,SAAQH,SAAS;QACb,OAAO;YACH,SAASA,UAAU,OAAO,CAACI;QAC/B;IACJ;AACJ"}
1
+ {"version":3,"file":"features/formModel/feature.js","sources":["../../../src/features/formModel/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { CmsFormModelBuilder as CmsFormModelBuilderAbstraction } from \"./abstractions.js\";\nimport { CmsFormModelBuilder } from \"./CmsFormModelBuilder.js\";\nimport { CmsRefFieldType } from \"./CmsRefFieldType.js\";\nimport { CmsRefFieldValueFormatter } from \"./CmsRefFieldValueFormatter.js\";\n\nexport const CmsFormModelFeature = createFeature({\n name: \"CmsFormModel\",\n register(container) {\n container.register(CmsFormModelBuilder).inSingletonScope();\n container.register(CmsRefFieldType);\n container.register(CmsRefFieldValueFormatter);\n },\n resolve(container) {\n return {\n builder: container.resolve(CmsFormModelBuilderAbstraction)\n };\n }\n});\n"],"names":["CmsFormModelFeature","createFeature","container","CmsFormModelBuilder","CmsRefFieldType","CmsRefFieldValueFormatter","CmsFormModelBuilderAbstraction"],"mappings":";;;;;AAMO,MAAMA,sBAAsBC,cAAc;IAC7C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,qDAAqB,gBAAgB;QACxDD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;IACvB;IACA,SAAQH,SAAS;QACb,OAAO;YACH,SAASA,UAAU,OAAO,CAACI;QAC/B;IACJ;AACJ"}
@@ -0,0 +1,12 @@
1
+ import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from "../abstractions.js";
2
+ import type { IFieldBuilderRegistry } from "@webiny/app-admin/features/formModel/abstractions.js";
3
+ import type { CmsModelField } from "../../../types.js";
4
+ declare module "@webiny/app-admin/features/formModel/abstractions.js" {
5
+ interface IFieldBuilderRegistry {
6
+ asset(): IFieldBuilder<"asset">;
7
+ }
8
+ }
9
+ export declare class AssetFieldMapper implements ICmsFieldTypeMapper {
10
+ readonly type = "asset";
11
+ map(field: CmsModelField, registry: IFieldBuilderRegistry, context: ICmsFieldMapperContext): import("@webiny/app-admin/index.js").IFieldBuilder<string, false, unknown>;
12
+ }
@@ -0,0 +1,13 @@
1
+ import { applyFieldProps } from "./applyFieldProps.js";
2
+ class AssetFieldMapper {
3
+ map(field, registry, context) {
4
+ const builder = registry.asset();
5
+ return applyFieldProps(builder, field, context.rendererMap);
6
+ }
7
+ constructor(){
8
+ this.type = "asset";
9
+ }
10
+ }
11
+ export { AssetFieldMapper };
12
+
13
+ //# sourceMappingURL=AssetFieldMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/formModel/mappers/AssetFieldMapper.js","sources":["../../../../src/features/formModel/mappers/AssetFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type { IFieldBuilderRegistry } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\n\ndeclare module \"@webiny/app-admin/features/formModel/abstractions.js\" {\n interface IFieldBuilderRegistry {\n asset(): IFieldBuilder<\"asset\">;\n }\n}\n\nexport class AssetFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"asset\";\n\n map(field: CmsModelField, registry: IFieldBuilderRegistry, context: ICmsFieldMapperContext) {\n const builder = registry.asset();\n return applyFieldProps(builder, field, context.rendererMap);\n }\n}\n"],"names":["AssetFieldMapper","field","registry","context","builder","applyFieldProps"],"mappings":";AAWO,MAAMA;IAGT,IAAIC,KAAoB,EAAEC,QAA+B,EAAEC,OAA+B,EAAE;QACxF,MAAMC,UAAUF,SAAS,KAAK;QAC9B,OAAOG,gBAAgBD,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aALS,IAAI,GAAG;;AAMpB"}
@@ -1,4 +1,5 @@
1
1
  import { applyFieldProps } from "./applyFieldProps.js";
2
+ import { mapCmsDateLimits } from "../CmsValidationMapper.js";
2
3
  class DateTimeFieldMapper {
3
4
  map(field, registry, context) {
4
5
  const builder = registry.datetime();
@@ -18,6 +19,8 @@ class DateTimeFieldMapper {
18
19
  builder.withoutTimezone();
19
20
  break;
20
21
  }
22
+ for (const limit of mapCmsDateLimits(field.validation))if ("dateGte" === limit.name) builder.dateGte(limit.bound, limit.message);
23
+ else builder.dateLte(limit.bound, limit.message);
21
24
  return builder;
22
25
  }
23
26
  constructor(){
@@ -1 +1 @@
1
- {"version":3,"file":"features/formModel/mappers/DateTimeFieldMapper.js","sources":["../../../../src/features/formModel/mappers/DateTimeFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type { IFieldBuilderRegistry } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\n\nexport class DateTimeFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"datetime\";\n\n map(field: CmsModelField, registry: IFieldBuilderRegistry, context: ICmsFieldMapperContext) {\n const builder = registry.datetime();\n applyFieldProps(builder, field, context.rendererMap);\n\n const subtype = field.settings?.type as string | undefined;\n switch (subtype) {\n case \"date\":\n builder.dateOnly();\n break;\n case \"time\":\n builder.timeOnly();\n break;\n case \"dateTimeWithTimezone\":\n builder.withTimezone();\n break;\n case \"dateTimeWithoutTimezone\":\n builder.withoutTimezone();\n break;\n }\n\n return builder;\n }\n}\n"],"names":["DateTimeFieldMapper","field","registry","context","builder","applyFieldProps","subtype"],"mappings":";AAKO,MAAMA;IAGT,IAAIC,KAAoB,EAAEC,QAA+B,EAAEC,OAA+B,EAAE;QACxF,MAAMC,UAAUF,SAAS,QAAQ;QACjCG,gBAAgBD,SAASH,OAAOE,QAAQ,WAAW;QAEnD,MAAMG,UAAUL,MAAM,QAAQ,EAAE;QAChC,OAAQK;YACJ,KAAK;gBACDF,QAAQ,QAAQ;gBAChB;YACJ,KAAK;gBACDA,QAAQ,QAAQ;gBAChB;YACJ,KAAK;gBACDA,QAAQ,YAAY;gBACpB;YACJ,KAAK;gBACDA,QAAQ,eAAe;gBACvB;QACR;QAEA,OAAOA;IACX;;aAvBS,IAAI,GAAG;;AAwBpB"}
1
+ {"version":3,"file":"features/formModel/mappers/DateTimeFieldMapper.js","sources":["../../../../src/features/formModel/mappers/DateTimeFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type { IFieldBuilderRegistry } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport { mapCmsDateLimits } from \"../CmsValidationMapper.js\";\n\nexport class DateTimeFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"datetime\";\n\n map(field: CmsModelField, registry: IFieldBuilderRegistry, context: ICmsFieldMapperContext) {\n const builder = registry.datetime();\n applyFieldProps(builder, field, context.rendererMap);\n\n const subtype = field.settings?.type as string | undefined;\n switch (subtype) {\n case \"date\":\n builder.dateOnly();\n break;\n case \"time\":\n builder.timeOnly();\n break;\n case \"dateTimeWithTimezone\":\n builder.withTimezone();\n break;\n case \"dateTimeWithoutTimezone\":\n builder.withoutTimezone();\n break;\n }\n\n for (const limit of mapCmsDateLimits(field.validation)) {\n if (limit.name === \"dateGte\") {\n builder.dateGte(limit.bound, limit.message);\n } else {\n builder.dateLte(limit.bound, limit.message);\n }\n }\n\n return builder;\n }\n}\n"],"names":["DateTimeFieldMapper","field","registry","context","builder","applyFieldProps","subtype","limit","mapCmsDateLimits"],"mappings":";;AAMO,MAAMA;IAGT,IAAIC,KAAoB,EAAEC,QAA+B,EAAEC,OAA+B,EAAE;QACxF,MAAMC,UAAUF,SAAS,QAAQ;QACjCG,gBAAgBD,SAASH,OAAOE,QAAQ,WAAW;QAEnD,MAAMG,UAAUL,MAAM,QAAQ,EAAE;QAChC,OAAQK;YACJ,KAAK;gBACDF,QAAQ,QAAQ;gBAChB;YACJ,KAAK;gBACDA,QAAQ,QAAQ;gBAChB;YACJ,KAAK;gBACDA,QAAQ,YAAY;gBACpB;YACJ,KAAK;gBACDA,QAAQ,eAAe;gBACvB;QACR;QAEA,KAAK,MAAMG,SAASC,iBAAiBP,MAAM,UAAU,EACjD,IAAIM,AAAe,cAAfA,MAAM,IAAI,EACVH,QAAQ,OAAO,CAACG,MAAM,KAAK,EAAEA,MAAM,OAAO;aAE1CH,QAAQ,OAAO,CAACG,MAAM,KAAK,EAAEA,MAAM,OAAO;QAIlD,OAAOH;IACX;;aA/BS,IAAI,GAAG;;AAgCpB"}
@@ -1,10 +1,13 @@
1
1
  import { applyFieldProps } from "./applyFieldProps.js";
2
+ import { mapCmsNestedLayout } from "../CmsLayoutMapper.js";
3
+ import { generateAlphaNumericLowerCaseId } from "@webiny/utils/generateId";
2
4
  class DynamicZoneFieldMapper {
3
5
  map(field, registry, context) {
4
6
  const builder = registry.object();
5
7
  const templates = field.settings?.templates;
6
8
  if (templates) for (const template of templates)builder.template(template.id, (t)=>{
7
9
  t.label(template.name);
10
+ if (template.description) t.description(template.description);
8
11
  if (template.icon) {
9
12
  const icon = template.icon;
10
13
  if ("object" == typeof icon && "name" in icon) t.icon(icon);
@@ -13,11 +16,14 @@ class DynamicZoneFieldMapper {
13
16
  name: icon
14
17
  });
15
18
  }
16
- if (template.fields && template.fields.length > 0) t.fields((childRegistry)=>{
19
+ t.fields((childRegistry)=>{
17
20
  const result = {};
18
- for (const child of template.fields)result[child.fieldId] = context.mapField(child, childRegistry);
21
+ result["_id"] = childRegistry.text().hidden().defaultValue(()=>generateAlphaNumericLowerCaseId(12)).cloneValue(()=>generateAlphaNumericLowerCaseId(12));
22
+ if (template.fields && template.fields.length > 0) for (const child of template.fields)result[child.fieldId] = context.mapField(child, childRegistry);
19
23
  return result;
20
24
  });
25
+ const layout = mapCmsNestedLayout(template.layout, template.fields ?? []);
26
+ if (layout) t.layout(layout);
21
27
  });
22
28
  return applyFieldProps(builder, field, context.rendererMap);
23
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\";\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 if (template.fields && template.fields.length > 0) {\n t.fields(childRegistry => {\n const result: Record<string, IFieldBuilder> = {};\n for (const child of template.fields) {\n result[child.fieldId] = context.mapField(child, childRegistry);\n }\n return result;\n });\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","child","applyFieldProps"],"mappings":";AAUO,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;YACA,IAAIF,SAAS,MAAM,IAAIA,SAAS,MAAM,CAAC,MAAM,GAAG,GAC5CC,EAAE,MAAM,CAACE,CAAAA;gBACL,MAAMC,SAAwC,CAAC;gBAC/C,KAAK,MAAMC,SAASL,SAAS,MAAM,CAC/BI,MAAM,CAACC,MAAM,OAAO,CAAC,GAAGR,QAAQ,QAAQ,CAACQ,OAAOF;gBAEpD,OAAOC;YACX;QAER;QAIR,OAAOE,gBAAgBR,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aApCS,IAAI,GAAG;;AAqCpB"}
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,13 +1,20 @@
1
1
  import { applyFieldProps } from "./applyFieldProps.js";
2
+ import { mapCmsNestedLayout } from "../CmsLayoutMapper.js";
3
+ import { generateAlphaNumericLowerCaseId } from "@webiny/utils/generateId";
2
4
  class ObjectFieldMapper {
3
5
  map(field, registry, context) {
4
6
  const builder = registry.object();
5
7
  const childFields = field.settings?.fields;
6
- if (childFields && childFields.length > 0) builder.fields((childRegistry)=>{
7
- const result = {};
8
- for (const child of childFields)result[child.fieldId] = context.mapField(child, childRegistry);
9
- return result;
10
- });
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
+ }
11
18
  return applyFieldProps(builder, field, context.rendererMap);
12
19
  }
13
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\";\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 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","child","applyFieldProps"],"mappings":";AASO,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/C,KAAK,MAAMC,SAASH,YAChBE,MAAM,CAACC,MAAM,OAAO,CAAC,GAAGL,QAAQ,QAAQ,CAACK,OAAOF;YAEpD,OAAOC;QACX;QAGJ,OAAOE,gBAAgBL,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aArBS,IAAI,GAAG;;AAsBpB"}
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"}
@@ -9,6 +9,7 @@ function applyFieldProps(builder, field, rendererMap) {
9
9
  if (Array.isArray(field.tags)) builder.tags(field.tags);
10
10
  if (field.settings?.defaultValue != null) builder.defaultValue(field.settings.defaultValue);
11
11
  if (field.list) builder.list();
12
+ if (field.disabled) builder.disabled(true);
12
13
  if (field.predefinedValues?.enabled && field.predefinedValues.values) {
13
14
  const optionsBuilder = builder;
14
15
  if ("function" == typeof optionsBuilder.options) optionsBuilder.options(field.predefinedValues.values.map((v)=>({
@@ -38,7 +39,7 @@ function applyFieldProps(builder, field, rendererMap) {
38
39
  type: r.type,
39
40
  target: r.target,
40
41
  operator: r.operator,
41
- value: null != r.value ? String(r.value) : null,
42
+ value: r.value ?? null,
42
43
  action: r.action
43
44
  })));
44
45
  if (field.tags && field.tags.length > 0) builder.tags(field.tags);
@@ -1 +1 @@
1
- {"version":3,"file":"features/formModel/mappers/applyFieldProps.js","sources":["../../../../src/features/formModel/mappers/applyFieldProps.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { IFieldBuilder } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { mapCmsValidators, mapCmsListValidators } from \"../CmsValidationMapper.js\";\n\nexport function applyFieldProps(\n builder: IFieldBuilder,\n field: CmsModelField,\n rendererMap: Map<string, string>\n): IFieldBuilder {\n if (field.label) {\n builder.label(field.label);\n }\n if (field.help) {\n builder.help(String(field.help));\n }\n if (field.description) {\n builder.description(String(field.description));\n }\n if (field.note) {\n builder.note(String(field.note));\n }\n if (field.placeholder) {\n builder.placeholder(field.placeholder);\n }\n\n if (Array.isArray(field.tags)) {\n builder.tags(field.tags);\n }\n\n if (field.settings?.defaultValue != null) {\n builder.defaultValue(field.settings.defaultValue);\n }\n\n if (field.list) {\n builder.list();\n }\n\n if (field.predefinedValues?.enabled && field.predefinedValues.values) {\n const optionsBuilder = builder as any;\n if (typeof optionsBuilder.options === \"function\") {\n optionsBuilder.options(\n field.predefinedValues.values.map(\n (v: { label: string; value: string; selected?: boolean }) => ({\n label: v.label,\n value: v.value\n })\n )\n );\n }\n }\n\n if (field.list) {\n const itemResult = mapCmsValidators(field.validation);\n const listResult = mapCmsListValidators(field.listValidation);\n\n if (itemResult.required || listResult.required) {\n builder.required(itemResult.requiredMessage || listResult.requiredMessage);\n }\n\n const itemSchema = itemResult.schema ? z.array(itemResult.schema) : null;\n const listSchema = listResult.schema;\n\n if (itemSchema && listSchema) {\n builder.schema(z.intersection(itemSchema, listSchema));\n } else if (itemSchema) {\n builder.schema(itemSchema);\n } else if (listSchema) {\n builder.schema(listSchema);\n }\n } else {\n const { required, requiredMessage, schema } = mapCmsValidators(field.validation);\n if (required) {\n builder.required(requiredMessage);\n }\n if (schema) {\n builder.schema(schema);\n }\n }\n\n if (field.renderer && typeof field.renderer === \"object\") {\n const mappedRenderer = rendererMap.get(field.renderer.name);\n if (mappedRenderer) {\n builder.renderer(mappedRenderer as any, field.renderer.settings);\n }\n }\n\n if (field.rules && field.rules.length > 0) {\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 ? String(r.value) : null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n\n if (field.tags && field.tags.length > 0) {\n builder.tags(field.tags);\n }\n\n return builder;\n}\n"],"names":["applyFieldProps","builder","field","rendererMap","String","Array","optionsBuilder","v","itemResult","mapCmsValidators","listResult","mapCmsListValidators","itemSchema","z","listSchema","required","requiredMessage","schema","mappedRenderer","r"],"mappings":";;AAKO,SAASA,gBACZC,OAAsB,EACtBC,KAAoB,EACpBC,WAAgC;IAEhC,IAAID,MAAM,KAAK,EACXD,QAAQ,KAAK,CAACC,MAAM,KAAK;IAE7B,IAAIA,MAAM,IAAI,EACVD,QAAQ,IAAI,CAACG,OAAOF,MAAM,IAAI;IAElC,IAAIA,MAAM,WAAW,EACjBD,QAAQ,WAAW,CAACG,OAAOF,MAAM,WAAW;IAEhD,IAAIA,MAAM,IAAI,EACVD,QAAQ,IAAI,CAACG,OAAOF,MAAM,IAAI;IAElC,IAAIA,MAAM,WAAW,EACjBD,QAAQ,WAAW,CAACC,MAAM,WAA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0B,YAA1B,OAAOA,MAAM,QAAQ,EAAe;QACtD,MAAMgB,iBAAiBf,YAAY,GAAG,CAACD,MAAM,QAAQ,CAAC,IAAI;QAC1D,IAAIgB,gBACAjB,QAAQ,QAAQ,CAACiB,gBAAuBhB,MAAM,QAAQ,CAAC,QAAQ;IAEvE;IAEA,IAAIA,MAAM,KAAK,IAAIA,MAAM,KAAK,CAAC,MAAM,GAAG,GACpCD,QAAQ,KAAK,CACTC,MAAM,KAAK,CAAC,GAAG,CAACiB,CAAAA,IAAM;YAClB,MAAMA,EAAE,IAAI;YACZ,QAAQA,EAAE,MAAM;YAChB,UAAUA,EAAE,QAAQ;YACpB,OAAOA,AAAW,QAAXA,EAAE,KAAK,GAAWf,OAAOe,EAAE,KAAK,IAAI;YAC3C,QAAQA,EAAE,MAAM;QACpB;IAIR,IAAIjB,MAAM,IAAI,IAAIA,MAAM,IAAI,CAAC,MAAM,GAAG,GAClCD,QAAQ,IAAI,CAACC,MAAM,IAAI;IAG3B,OAAOD;AACX"}
1
+ {"version":3,"file":"features/formModel/mappers/applyFieldProps.js","sources":["../../../../src/features/formModel/mappers/applyFieldProps.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { IFieldBuilder } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { mapCmsValidators, mapCmsListValidators } from \"../CmsValidationMapper.js\";\n\nexport function applyFieldProps(\n builder: IFieldBuilder,\n field: CmsModelField,\n rendererMap: Map<string, string>\n): IFieldBuilder {\n if (field.label) {\n builder.label(field.label);\n }\n if (field.help) {\n builder.help(String(field.help));\n }\n if (field.description) {\n builder.description(String(field.description));\n }\n if (field.note) {\n builder.note(String(field.note));\n }\n if (field.placeholder) {\n builder.placeholder(field.placeholder);\n }\n\n if (Array.isArray(field.tags)) {\n builder.tags(field.tags);\n }\n\n if (field.settings?.defaultValue != null) {\n builder.defaultValue(field.settings.defaultValue);\n }\n\n if (field.list) {\n builder.list();\n }\n\n if (field.disabled) {\n builder.disabled(true);\n }\n\n if (field.predefinedValues?.enabled && field.predefinedValues.values) {\n const optionsBuilder = builder as any;\n if (typeof optionsBuilder.options === \"function\") {\n optionsBuilder.options(\n field.predefinedValues.values.map(\n (v: { label: string; value: string; selected?: boolean }) => ({\n label: v.label,\n value: v.value\n })\n )\n );\n }\n }\n\n if (field.list) {\n const itemResult = mapCmsValidators(field.validation);\n const listResult = mapCmsListValidators(field.listValidation);\n\n if (itemResult.required || listResult.required) {\n builder.required(itemResult.requiredMessage || listResult.requiredMessage);\n }\n\n const itemSchema = itemResult.schema ? z.array(itemResult.schema) : null;\n const listSchema = listResult.schema;\n\n if (itemSchema && listSchema) {\n builder.schema(z.intersection(itemSchema, listSchema));\n } else if (itemSchema) {\n builder.schema(itemSchema);\n } else if (listSchema) {\n builder.schema(listSchema);\n }\n } else {\n const { required, requiredMessage, schema } = mapCmsValidators(field.validation);\n if (required) {\n builder.required(requiredMessage);\n }\n if (schema) {\n builder.schema(schema);\n }\n }\n\n if (field.renderer && typeof field.renderer === \"object\") {\n const mappedRenderer = rendererMap.get(field.renderer.name);\n if (mappedRenderer) {\n builder.renderer(mappedRenderer as any, field.renderer.settings);\n }\n }\n\n if (field.rules && field.rules.length > 0) {\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\n if (field.tags && field.tags.length > 0) {\n builder.tags(field.tags);\n }\n\n return builder;\n}\n"],"names":["applyFieldProps","builder","field","rendererMap","String","Array","optionsBuilder","v","itemResult","mapCmsValidators","listResult","mapCmsListValidators","itemSchema","z","listSchema","required","requiredMessage","schema","mappedRenderer","r"],"mappings":";;AAKO,SAASA,gBACZC,OAAsB,EACtBC,KAAoB,EACpBC,WAAgC;IAEhC,IAAID,MAAM,KAAK,EACXD,QAAQ,KAAK,CAACC,MAAM,KAAK;IAE7B,IAAIA,MAAM,IAAI,EACVD,QAAQ,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YACPX,QAAQ,MAAM,CAACW;aACZ,IAAIE,YACPb,QAAQ,MAAM,CAACa;IAEvB,OAAO;QACH,MAAM,EAAEC,QAAQ,EAAEC,eAAe,EAAEC,MAAM,EAAE,GAAGR,iBAAiBP,MAAM,UAAU;QAC/E,IAAIa,UACAd,QAAQ,QAAQ,CAACe;QAErB,IAAIC,QACAhB,QAAQ,MAAM,CAACgB;IAEvB;IAEA,IAAIf,MAAM,QAAQ,IAAI,AAA0B,YAA1B,OAAOA,MAAM,QAAQ,EAAe;QACtD,MAAMgB,iBAAiBf,YAAY,GAAG,CAACD,MAAM,QAAQ,CAAC,IAAI;QAC1D,IAAIgB,gBACAjB,QAAQ,QAAQ,CAACiB,gBAAuBhB,MAAM,QAAQ,CAAC,QAAQ;IAEvE;IAEA,IAAIA,MAAM,KAAK,IAAIA,MAAM,KAAK,CAAC,MAAM,GAAG,GACpCD,QAAQ,KAAK,CACTC,MAAM,KAAK,CAAC,GAAG,CAACiB,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,IAAIjB,MAAM,IAAI,IAAIA,MAAM,IAAI,CAAC,MAAM,GAAG,GAClCD,QAAQ,IAAI,CAACC,MAAM,IAAI;IAG3B,OAAOD;AACX"}
@@ -0,0 +1,59 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { Container } from "@webiny/di";
3
+ import { FormModelFeature } from "@webiny/app-admin/features/formModel/feature.js";
4
+ import { IdentityContextFeature } from "@webiny/app-admin/features/security/IdentityContext/feature.js";
5
+ import { FormModelFactory } from "@webiny/app-admin/features/formModel/abstractions.js";
6
+ import { applyFieldProps } from "./applyFieldProps.js";
7
+ const createField = (overrides)=>({
8
+ id: "externalId",
9
+ fieldId: "externalId",
10
+ storageId: "text@externalId",
11
+ type: "text",
12
+ label: "External ID",
13
+ renderer: {
14
+ name: "text-input"
15
+ },
16
+ validation: [],
17
+ listValidation: [],
18
+ ...overrides
19
+ });
20
+ const buildForm = (field)=>{
21
+ const container = new Container();
22
+ IdentityContextFeature.register(container);
23
+ FormModelFeature.register(container);
24
+ return container.resolve(FormModelFactory).create({
25
+ fields: (registry)=>({
26
+ [field.fieldId]: applyFieldProps(registry.text(), field, new Map())
27
+ })
28
+ });
29
+ };
30
+ describe("applyFieldProps disabled", ()=>{
31
+ it("disables the form field when the model field is disabled", ()=>{
32
+ const form = buildForm(createField({
33
+ disabled: true
34
+ }));
35
+ expect(form.field("externalId").disabled).toBe(true);
36
+ });
37
+ it("leaves the field editable when disabled is false or absent", ()=>{
38
+ expect(buildForm(createField({
39
+ disabled: false
40
+ })).field("externalId").disabled).toBe(false);
41
+ expect(buildForm(createField({})).field("externalId").disabled).toBe(false);
42
+ });
43
+ it("keeps the field visible", ()=>{
44
+ const form = buildForm(createField({
45
+ disabled: true
46
+ }));
47
+ expect(form.field("externalId").visible).toBe(true);
48
+ });
49
+ it("does not stop the field from holding a value", ()=>{
50
+ const form = buildForm(createField({
51
+ disabled: true
52
+ }));
53
+ form.field("externalId").setValue("abc-123");
54
+ expect(form.field("externalId").getValue()).toBe("abc-123");
55
+ expect(form.field("externalId").disabled).toBe(true);
56
+ });
57
+ });
58
+
59
+ //# sourceMappingURL=applyFieldProps.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/formModel/mappers/applyFieldProps.test.js","sources":["../../../../src/features/formModel/mappers/applyFieldProps.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { FormModelFeature } from \"@webiny/app-admin/features/formModel/feature.js\";\nimport { IdentityContextFeature } from \"@webiny/app-admin/features/security/IdentityContext/feature.js\";\nimport { FormModelFactory } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport type { CmsModelField } from \"~/types.js\";\n\nconst createField = (overrides: Partial<CmsModelField>): CmsModelField =>\n ({\n id: \"externalId\",\n fieldId: \"externalId\",\n storageId: \"text@externalId\",\n type: \"text\",\n label: \"External ID\",\n renderer: { name: \"text-input\" },\n validation: [],\n listValidation: [],\n ...overrides\n }) as CmsModelField;\n\n/**\n * Builds a one-field form the way CmsFormModelBuilder does, so we assert on the\n * field the entry form actually renders rather than on the builder in isolation.\n */\nconst buildForm = (field: CmsModelField) => {\n const container = new Container();\n IdentityContextFeature.register(container);\n FormModelFeature.register(container);\n\n return container.resolve(FormModelFactory).create({\n fields: registry => ({\n [field.fieldId]: applyFieldProps(registry.text(), field, new Map())\n })\n });\n};\n\ndescribe(\"applyFieldProps disabled\", () => {\n it(\"disables the form field when the model field is disabled\", () => {\n const form = buildForm(createField({ disabled: true }));\n\n expect(form.field(\"externalId\").disabled).toBe(true);\n });\n\n it(\"leaves the field editable when disabled is false or absent\", () => {\n expect(buildForm(createField({ disabled: false })).field(\"externalId\").disabled).toBe(\n false\n );\n expect(buildForm(createField({})).field(\"externalId\").disabled).toBe(false);\n });\n\n it(\"keeps the field visible\", () => {\n const form = buildForm(createField({ disabled: true }));\n\n expect(form.field(\"externalId\").visible).toBe(true);\n });\n\n it(\"does not stop the field from holding a value\", () => {\n const form = buildForm(createField({ disabled: true }));\n form.field(\"externalId\").setValue(\"abc-123\");\n\n expect(form.field(\"externalId\").getValue()).toBe(\"abc-123\");\n expect(form.field(\"externalId\").disabled).toBe(true);\n });\n});\n"],"names":["createField","overrides","buildForm","field","container","Container","IdentityContextFeature","FormModelFeature","FormModelFactory","registry","applyFieldProps","Map","describe","it","form","expect"],"mappings":";;;;;;AAQA,MAAMA,cAAc,CAACC,YAChB;QACG,IAAI;QACJ,SAAS;QACT,WAAW;QACX,MAAM;QACN,OAAO;QACP,UAAU;YAAE,MAAM;QAAa;QAC/B,YAAY,EAAE;QACd,gBAAgB,EAAE;QAClB,GAAGA,SAAS;IAChB;AAMJ,MAAMC,YAAY,CAACC;IACf,MAAMC,YAAY,IAAIC;IACtBC,uBAAuB,QAAQ,CAACF;IAChCG,iBAAiB,QAAQ,CAACH;IAE1B,OAAOA,UAAU,OAAO,CAACI,kBAAkB,MAAM,CAAC;QAC9C,QAAQC,CAAAA,WAAa;gBACjB,CAACN,MAAM,OAAO,CAAC,EAAEO,gBAAgBD,SAAS,IAAI,IAAIN,OAAO,IAAIQ;YACjE;IACJ;AACJ;AAEAC,SAAS,4BAA4B;IACjCC,GAAG,4DAA4D;QAC3D,MAAMC,OAAOZ,UAAUF,YAAY;YAAE,UAAU;QAAK;QAEpDe,OAAOD,KAAK,KAAK,CAAC,cAAc,QAAQ,EAAE,IAAI,CAAC;IACnD;IAEAD,GAAG,8DAA8D;QAC7DE,OAAOb,UAAUF,YAAY;YAAE,UAAU;QAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,EAAE,IAAI,CACjF;QAEJe,OAAOb,UAAUF,YAAY,CAAC,IAAI,KAAK,CAAC,cAAc,QAAQ,EAAE,IAAI,CAAC;IACzE;IAEAa,GAAG,2BAA2B;QAC1B,MAAMC,OAAOZ,UAAUF,YAAY;YAAE,UAAU;QAAK;QAEpDe,OAAOD,KAAK,KAAK,CAAC,cAAc,OAAO,EAAE,IAAI,CAAC;IAClD;IAEAD,GAAG,gDAAgD;QAC/C,MAAMC,OAAOZ,UAAUF,YAAY;YAAE,UAAU;QAAK;QACpDc,KAAK,KAAK,CAAC,cAAc,QAAQ,CAAC;QAElCC,OAAOD,KAAK,KAAK,CAAC,cAAc,QAAQ,IAAI,IAAI,CAAC;QACjDC,OAAOD,KAAK,KAAK,CAAC,cAAc,QAAQ,EAAE,IAAI,CAAC;IACnD;AACJ"}
@@ -3,6 +3,7 @@ import { NumberFieldMapper } from "./NumberFieldMapper.js";
3
3
  import { BooleanFieldMapper } from "./BooleanFieldMapper.js";
4
4
  import { DateTimeFieldMapper } from "./DateTimeFieldMapper.js";
5
5
  import { FileFieldMapper } from "./FileFieldMapper.js";
6
+ import { AssetFieldMapper } from "./AssetFieldMapper.js";
6
7
  import { RichTextFieldMapper } from "./RichTextFieldMapper.js";
7
8
  import { ObjectFieldMapper } from "./ObjectFieldMapper.js";
8
9
  import { DynamicZoneFieldMapper } from "./DynamicZoneFieldMapper.js";
@@ -16,6 +17,7 @@ function createBuiltInMappers() {
16
17
  new BooleanFieldMapper(),
17
18
  new DateTimeFieldMapper(),
18
19
  new FileFieldMapper(),
20
+ new AssetFieldMapper(),
19
21
  new RichTextFieldMapper(),
20
22
  new ObjectFieldMapper(),
21
23
  new DynamicZoneFieldMapper(),
@@ -1 +1 @@
1
- {"version":3,"file":"features/formModel/mappers/index.js","sources":["../../../../src/features/formModel/mappers/index.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper } from \"../abstractions.js\";\nimport { TextFieldMapper, LongTextFieldMapper, JsonFieldMapper } from \"./TextFieldMapper.js\";\nimport { NumberFieldMapper } from \"./NumberFieldMapper.js\";\nimport { BooleanFieldMapper } from \"./BooleanFieldMapper.js\";\nimport { DateTimeFieldMapper } from \"./DateTimeFieldMapper.js\";\nimport { FileFieldMapper } from \"./FileFieldMapper.js\";\nimport { RichTextFieldMapper } from \"./RichTextFieldMapper.js\";\nimport { ObjectFieldMapper } from \"./ObjectFieldMapper.js\";\nimport { DynamicZoneFieldMapper } from \"./DynamicZoneFieldMapper.js\";\nimport { RefFieldMapper } from \"./RefFieldMapper.js\";\n\nexport function createBuiltInMappers(): ICmsFieldTypeMapper[] {\n return [\n new TextFieldMapper(),\n new LongTextFieldMapper(),\n new JsonFieldMapper(),\n new NumberFieldMapper(),\n new BooleanFieldMapper(),\n new DateTimeFieldMapper(),\n new FileFieldMapper(),\n new RichTextFieldMapper(),\n new ObjectFieldMapper(),\n new DynamicZoneFieldMapper(),\n new RefFieldMapper()\n ];\n}\n"],"names":["createBuiltInMappers","TextFieldMapper","LongTextFieldMapper","JsonFieldMapper","NumberFieldMapper","BooleanFieldMapper","DateTimeFieldMapper","FileFieldMapper","RichTextFieldMapper","ObjectFieldMapper","DynamicZoneFieldMapper","RefFieldMapper"],"mappings":";;;;;;;;;AAWO,SAASA;IACZ,OAAO;QACH,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;KACP;AACL"}
1
+ {"version":3,"file":"features/formModel/mappers/index.js","sources":["../../../../src/features/formModel/mappers/index.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper } from \"../abstractions.js\";\nimport { TextFieldMapper, LongTextFieldMapper, JsonFieldMapper } from \"./TextFieldMapper.js\";\nimport { NumberFieldMapper } from \"./NumberFieldMapper.js\";\nimport { BooleanFieldMapper } from \"./BooleanFieldMapper.js\";\nimport { DateTimeFieldMapper } from \"./DateTimeFieldMapper.js\";\nimport { FileFieldMapper } from \"./FileFieldMapper.js\";\nimport { AssetFieldMapper } from \"./AssetFieldMapper.js\";\nimport { RichTextFieldMapper } from \"./RichTextFieldMapper.js\";\nimport { ObjectFieldMapper } from \"./ObjectFieldMapper.js\";\nimport { DynamicZoneFieldMapper } from \"./DynamicZoneFieldMapper.js\";\nimport { RefFieldMapper } from \"./RefFieldMapper.js\";\n\nexport function createBuiltInMappers(): ICmsFieldTypeMapper[] {\n return [\n new TextFieldMapper(),\n new LongTextFieldMapper(),\n new JsonFieldMapper(),\n new NumberFieldMapper(),\n new BooleanFieldMapper(),\n new DateTimeFieldMapper(),\n new FileFieldMapper(),\n new AssetFieldMapper(),\n new RichTextFieldMapper(),\n new ObjectFieldMapper(),\n new DynamicZoneFieldMapper(),\n new RefFieldMapper()\n ];\n}\n"],"names":["createBuiltInMappers","TextFieldMapper","LongTextFieldMapper","JsonFieldMapper","NumberFieldMapper","BooleanFieldMapper","DateTimeFieldMapper","FileFieldMapper","AssetFieldMapper","RichTextFieldMapper","ObjectFieldMapper","DynamicZoneFieldMapper","RefFieldMapper"],"mappings":";;;;;;;;;;AAYO,SAASA;IACZ,OAAO;QACH,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC;KACP;AACL"}
@@ -1,3 +1,4 @@
1
+ import { GraphQLOperationError } from "@webiny/app/errors/index.js";
1
2
  import { CmsGraphQLClient } from "../../graphQLClient/abstractions.js";
2
3
  import { DeleteModelGateway } from "./abstractions.js";
3
4
  const FULLY_DELETE_CONTENT_MODEL = `
@@ -30,7 +31,11 @@ class DeleteModelGatewayImpl {
30
31
  }
31
32
  });
32
33
  const { data: result, error } = response.fullyDeleteModel;
33
- if (!result) throw new Error(error?.message || "Could not delete content model");
34
+ if (!result) throw new GraphQLOperationError({
35
+ message: error?.message || "Could not delete content model",
36
+ code: error?.code,
37
+ data: error?.data
38
+ });
34
39
  return result;
35
40
  }
36
41
  }