@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
@@ -0,0 +1,244 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { Container } from "@webiny/di";
3
+ import { FormModelFactory } from "@webiny/app-admin/features/formModel/abstractions.js";
4
+ import { Confirmation } from "@webiny/app-admin/features/confirmation/abstractions.js";
5
+ import { GetEntryUseCase } from "../../../features/contentEntry/getEntry/abstractions.js";
6
+ import { CreateEntryUseCase } from "../../../features/contentEntry/createEntry/abstractions.js";
7
+ import { UpdateEntryUseCase } from "../../../features/contentEntry/updateEntry/abstractions.js";
8
+ import { PublishEntryUseCase } from "../../../features/contentEntry/publishEntry/abstractions.js";
9
+ import { UnpublishEntryUseCase } from "../../../features/contentEntry/unpublishEntry/abstractions.js";
10
+ import { DeleteEntryUseCase } from "../../../features/contentEntry/deleteEntry/abstractions.js";
11
+ import { UpdateRevisionDescriptionUseCase } from "../../../features/contentEntry/updateRevisionDescription/abstractions.js";
12
+ import { CreateRevisionFromUseCase } from "../../../features/contentEntry/createRevisionFrom/abstractions.js";
13
+ import { CmsFormModelBuilder } from "../../../features/formModel/abstractions.js";
14
+ import { CmsModelContext } from "../../../features/contentEntry/abstractions.js";
15
+ import { ContentEntryFormPresenter } from "./abstractions.js";
16
+ import { ContentEntryFormPresenter as external_ContentEntryFormPresenter_js_ContentEntryFormPresenter } from "./ContentEntryFormPresenter.js";
17
+ const createFakeForm = (validation)=>({
18
+ vm: {},
19
+ isDirty: false,
20
+ submit: vi.fn(async ()=>validation ? validation : {
21
+ title: "Draft"
22
+ }),
23
+ setData: vi.fn(),
24
+ reset: vi.fn(),
25
+ setErrors: vi.fn()
26
+ });
27
+ const deferred = ()=>{
28
+ let resolve;
29
+ let reject;
30
+ const promise = new Promise((res, rej)=>{
31
+ resolve = res;
32
+ reject = rej;
33
+ });
34
+ return {
35
+ promise,
36
+ resolve,
37
+ reject
38
+ };
39
+ };
40
+ const createEntry = (entryId)=>({
41
+ id: `${entryId}#0001`,
42
+ entryId,
43
+ meta: {
44
+ locked: false,
45
+ status: "draft",
46
+ title: entryId
47
+ },
48
+ values: {
49
+ title: entryId
50
+ }
51
+ });
52
+ const setup = ()=>{
53
+ const forms = [];
54
+ const create = deferred();
55
+ const update = deferred();
56
+ let nextValidation;
57
+ const pendingLoads = new Map();
58
+ const createExecute = vi.fn(()=>create.promise);
59
+ const updateExecute = vi.fn(()=>update.promise);
60
+ const container = new Container();
61
+ container.registerInstance(FormModelFactory, {
62
+ create: ()=>{
63
+ const form = createFakeForm(nextValidation);
64
+ nextValidation = void 0;
65
+ forms.push(form);
66
+ return form;
67
+ }
68
+ });
69
+ container.registerInstance(CmsFormModelBuilder, {
70
+ build: ()=>({})
71
+ });
72
+ container.registerInstance(CmsModelContext, {
73
+ getModel: ()=>({
74
+ modelId: "article",
75
+ fields: []
76
+ })
77
+ });
78
+ container.registerInstance(CreateEntryUseCase, {
79
+ execute: createExecute
80
+ });
81
+ container.registerInstance(UpdateEntryUseCase, {
82
+ execute: updateExecute
83
+ });
84
+ container.registerInstance(GetEntryUseCase, {
85
+ execute: async ({ id })=>pendingLoads.get(id) ?? createEntry(id)
86
+ });
87
+ for (const abstraction of [
88
+ Confirmation,
89
+ CreateRevisionFromUseCase,
90
+ PublishEntryUseCase,
91
+ UnpublishEntryUseCase,
92
+ DeleteEntryUseCase,
93
+ UpdateRevisionDescriptionUseCase
94
+ ])container.registerInstance(abstraction, {});
95
+ container.register(external_ContentEntryFormPresenter_js_ContentEntryFormPresenter);
96
+ return {
97
+ presenter: container.resolve(ContentEntryFormPresenter),
98
+ forms,
99
+ create,
100
+ createExecute,
101
+ update,
102
+ updateExecute,
103
+ pendingLoads,
104
+ slowValidation: ()=>{
105
+ const validation = deferred();
106
+ nextValidation = validation.promise;
107
+ return validation;
108
+ }
109
+ };
110
+ };
111
+ describe("ContentEntryFormPresenter.saveRevision", ()=>{
112
+ it("puts a rejected save's errors on the form", async ()=>{
113
+ const { presenter, forms, create } = setup();
114
+ presenter.newEntry();
115
+ const saving = presenter.saveRevision();
116
+ create.reject(new Error("Value must be unique."));
117
+ await expect(saving).resolves.toBe(false);
118
+ expect(forms[0].setErrors).toHaveBeenCalledTimes(1);
119
+ });
120
+ it("creates a new entry in the folder it was started in", async ()=>{
121
+ const { presenter, create, createExecute } = setup();
122
+ presenter.setFolderId("folder-1");
123
+ presenter.newEntry();
124
+ const saving = presenter.saveRevision();
125
+ create.resolve(createEntry("A"));
126
+ await expect(saving).resolves.toBe(true);
127
+ expect(createExecute).toHaveBeenCalledWith(expect.objectContaining({
128
+ data: {
129
+ values: {
130
+ title: "Draft"
131
+ },
132
+ wbyAco_location: {
133
+ folderId: "folder-1"
134
+ }
135
+ }
136
+ }));
137
+ });
138
+ it("does not carry the folder over to an entry started after a reset", async ()=>{
139
+ const { presenter, create, createExecute } = setup();
140
+ presenter.setFolderId("folder-1");
141
+ presenter.reset();
142
+ presenter.newEntry();
143
+ const saving = presenter.saveRevision();
144
+ create.resolve(createEntry("A"));
145
+ await expect(saving).resolves.toBe(true);
146
+ expect(createExecute).toHaveBeenCalledWith(expect.objectContaining({
147
+ data: {
148
+ values: {
149
+ title: "Draft"
150
+ }
151
+ }
152
+ }));
153
+ });
154
+ it("returns false instead of throwing when the form was reset mid-save", async ()=>{
155
+ const { presenter, create, createExecute } = setup();
156
+ presenter.newEntry();
157
+ const saving = presenter.saveRevision();
158
+ await vi.waitFor(()=>expect(createExecute).toHaveBeenCalled());
159
+ presenter.reset();
160
+ create.reject(new Error("Value must be unique."));
161
+ await expect(saving).resolves.toBe(false);
162
+ expect(presenter.vm.loading).toBe(null);
163
+ });
164
+ it("leaves a form built after the save started alone", async ()=>{
165
+ const { presenter, forms, create, createExecute } = setup();
166
+ presenter.newEntry();
167
+ const saving = presenter.saveRevision();
168
+ await vi.waitFor(()=>expect(createExecute).toHaveBeenCalled());
169
+ presenter.newEntry();
170
+ create.reject(new Error("Value must be unique."));
171
+ await expect(saving).resolves.toBe(false);
172
+ expect(forms).toHaveLength(2);
173
+ expect(forms[0].setErrors).not.toHaveBeenCalled();
174
+ expect(forms[1].setErrors).not.toHaveBeenCalled();
175
+ });
176
+ it("saves the open entry and puts the saved values on the form", async ()=>{
177
+ const { presenter, forms, update, updateExecute } = setup();
178
+ await presenter.loadRevision("A");
179
+ const saving = presenter.saveRevision();
180
+ await vi.waitFor(()=>expect(updateExecute).toHaveBeenCalled());
181
+ update.resolve(createEntry("A"));
182
+ await expect(saving).resolves.toBe(true);
183
+ expect(updateExecute).toHaveBeenCalledWith(expect.objectContaining({
184
+ revisionId: "A#0001",
185
+ data: {
186
+ values: {
187
+ title: "Draft"
188
+ }
189
+ }
190
+ }));
191
+ expect(forms[0].setData).toHaveBeenLastCalledWith({
192
+ title: "A"
193
+ });
194
+ });
195
+ it("does not write to an entry opened while the form was validating", async ()=>{
196
+ const { presenter, update, updateExecute, slowValidation } = setup();
197
+ const validation = slowValidation();
198
+ await presenter.loadRevision("A");
199
+ const saving = presenter.saveRevision();
200
+ await presenter.loadRevision("B");
201
+ validation.resolve({
202
+ title: "Values typed into A"
203
+ });
204
+ update.resolve(createEntry("B"));
205
+ await expect(saving).resolves.toBe(false);
206
+ expect(updateExecute).not.toHaveBeenCalled();
207
+ expect(presenter.vm.entry?.entryId).toBe("B");
208
+ });
209
+ it("keeps a write on its entry and reports false when another entry was opened", async ()=>{
210
+ const { presenter, forms, update, updateExecute } = setup();
211
+ await presenter.loadRevision("A");
212
+ const saving = presenter.saveRevision();
213
+ await vi.waitFor(()=>expect(updateExecute).toHaveBeenCalled());
214
+ await presenter.loadRevision("B");
215
+ update.resolve(createEntry("A"));
216
+ await expect(saving).resolves.toBe(false);
217
+ expect(updateExecute).toHaveBeenCalledTimes(1);
218
+ expect(updateExecute).toHaveBeenCalledWith(expect.objectContaining({
219
+ revisionId: "A#0001"
220
+ }));
221
+ expect(presenter.vm.entry?.entryId).toBe("B");
222
+ expect(forms[1].setData).toHaveBeenCalledTimes(1);
223
+ expect(forms[1].setData).toHaveBeenCalledWith({
224
+ title: "B"
225
+ });
226
+ });
227
+ it("does not clear the loading message of an entry being opened", async ()=>{
228
+ const { presenter, update, updateExecute, pendingLoads } = setup();
229
+ await presenter.loadRevision("A");
230
+ const saving = presenter.saveRevision();
231
+ await vi.waitFor(()=>expect(updateExecute).toHaveBeenCalled());
232
+ const loadB = deferred();
233
+ pendingLoads.set("B", loadB.promise);
234
+ const loading = presenter.loadRevision("B");
235
+ update.resolve(createEntry("A"));
236
+ await expect(saving).resolves.toBe(true);
237
+ expect(presenter.vm.loading).toBe("Loading entry...");
238
+ loadB.resolve(createEntry("B"));
239
+ await loading;
240
+ expect(presenter.vm.loading).toBe(null);
241
+ });
242
+ });
243
+
244
+ //# sourceMappingURL=ContentEntryFormPresenter.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presentation/contentEntries/form/ContentEntryFormPresenter.test.js","sources":["../../../../src/presentation/contentEntries/form/ContentEntryFormPresenter.test.ts"],"sourcesContent":["// @vitest-environment jsdom\nimport { describe, it, expect, vi } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { FormModelFactory } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { Confirmation } from \"@webiny/app-admin/features/confirmation/abstractions.js\";\nimport { GetEntryUseCase } from \"~/features/contentEntry/getEntry/abstractions.js\";\nimport { CreateEntryUseCase } from \"~/features/contentEntry/createEntry/abstractions.js\";\nimport { UpdateEntryUseCase } from \"~/features/contentEntry/updateEntry/abstractions.js\";\nimport { PublishEntryUseCase } from \"~/features/contentEntry/publishEntry/abstractions.js\";\nimport { UnpublishEntryUseCase } from \"~/features/contentEntry/unpublishEntry/abstractions.js\";\nimport { DeleteEntryUseCase } from \"~/features/contentEntry/deleteEntry/abstractions.js\";\nimport { UpdateRevisionDescriptionUseCase } from \"~/features/contentEntry/updateRevisionDescription/abstractions.js\";\nimport { CreateRevisionFromUseCase } from \"~/features/contentEntry/createRevisionFrom/abstractions.js\";\nimport { CmsFormModelBuilder } from \"~/features/formModel/abstractions.js\";\nimport { CmsModelContext } from \"~/features/contentEntry/abstractions.js\";\nimport { ContentEntryFormPresenter as Abstraction } from \"./abstractions.js\";\nimport { ContentEntryFormPresenter } from \"./ContentEntryFormPresenter.js\";\n\nconst createFakeForm = (validation?: Promise<unknown>) => ({\n vm: {},\n isDirty: false,\n submit: vi.fn(async () => (validation ? validation : { title: \"Draft\" })),\n setData: vi.fn(),\n reset: vi.fn(),\n setErrors: vi.fn()\n});\n\n/** A promise the test settles by hand, so it can act while a save is still in flight. */\nconst deferred = <T>() => {\n let resolve!: (value: T) => void;\n let reject!: (reason: unknown) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n};\n\nconst createEntry = (entryId: string) => ({\n id: `${entryId}#0001`,\n entryId,\n meta: { locked: false, status: \"draft\", title: entryId },\n values: { title: entryId }\n});\n\nconst setup = () => {\n const forms: ReturnType<typeof createFakeForm>[] = [];\n const create = deferred<any>();\n const update = deferred<any>();\n /** When set, the next form built validates only once the test resolves this. */\n let nextValidation: Promise<unknown> | undefined;\n /** Entries whose load the test settles by hand. */\n const pendingLoads = new Map<string, Promise<any>>();\n\n const createExecute = vi.fn(() => create.promise);\n const updateExecute = vi.fn(() => update.promise);\n\n const container = new Container();\n container.registerInstance(FormModelFactory, {\n create: () => {\n const form = createFakeForm(nextValidation);\n nextValidation = undefined;\n forms.push(form);\n return form;\n }\n } as unknown as FormModelFactory.Interface);\n container.registerInstance(CmsFormModelBuilder, {\n build: () => ({})\n } as unknown as CmsFormModelBuilder.Interface);\n container.registerInstance(CmsModelContext, {\n getModel: () => ({ modelId: \"article\", fields: [] })\n } as unknown as CmsModelContext.Interface);\n container.registerInstance(CreateEntryUseCase, {\n execute: createExecute\n } as unknown as CreateEntryUseCase.Interface);\n container.registerInstance(UpdateEntryUseCase, {\n execute: updateExecute\n } as unknown as UpdateEntryUseCase.Interface);\n container.registerInstance(GetEntryUseCase, {\n execute: async ({ id }: { id: string }) => pendingLoads.get(id) ?? createEntry(id)\n } as unknown as GetEntryUseCase.Interface);\n\n // Not reached by the paths these tests exercise.\n for (const abstraction of [\n Confirmation,\n CreateRevisionFromUseCase,\n PublishEntryUseCase,\n UnpublishEntryUseCase,\n DeleteEntryUseCase,\n UpdateRevisionDescriptionUseCase\n ]) {\n container.registerInstance(abstraction as any, {});\n }\n container.register(ContentEntryFormPresenter);\n\n return {\n presenter: container.resolve(Abstraction),\n forms,\n create,\n createExecute,\n update,\n updateExecute,\n pendingLoads,\n slowValidation: () => {\n const validation = deferred<unknown>();\n nextValidation = validation.promise;\n return validation;\n }\n };\n};\n\ndescribe(\"ContentEntryFormPresenter.saveRevision\", () => {\n it(\"puts a rejected save's errors on the form\", async () => {\n const { presenter, forms, create } = setup();\n presenter.newEntry();\n\n const saving = presenter.saveRevision();\n create.reject(new Error(\"Value must be unique.\"));\n\n await expect(saving).resolves.toBe(false);\n expect(forms[0].setErrors).toHaveBeenCalledTimes(1);\n });\n\n it(\"creates a new entry in the folder it was started in\", async () => {\n const { presenter, create, createExecute } = setup();\n presenter.setFolderId(\"folder-1\");\n presenter.newEntry();\n\n const saving = presenter.saveRevision();\n create.resolve(createEntry(\"A\"));\n\n await expect(saving).resolves.toBe(true);\n expect(createExecute).toHaveBeenCalledWith(\n expect.objectContaining({\n data: { values: { title: \"Draft\" }, wbyAco_location: { folderId: \"folder-1\" } }\n })\n );\n });\n\n it(\"does not carry the folder over to an entry started after a reset\", async () => {\n const { presenter, create, createExecute } = setup();\n presenter.setFolderId(\"folder-1\");\n presenter.reset();\n presenter.newEntry();\n\n const saving = presenter.saveRevision();\n create.resolve(createEntry(\"A\"));\n\n await expect(saving).resolves.toBe(true);\n expect(createExecute).toHaveBeenCalledWith(\n expect.objectContaining({ data: { values: { title: \"Draft\" } } })\n );\n });\n\n it(\"returns false instead of throwing when the form was reset mid-save\", async () => {\n const { presenter, create, createExecute } = setup();\n presenter.newEntry();\n\n const saving = presenter.saveRevision();\n await vi.waitFor(() => expect(createExecute).toHaveBeenCalled());\n presenter.reset();\n create.reject(new Error(\"Value must be unique.\"));\n\n await expect(saving).resolves.toBe(false);\n expect(presenter.vm.loading).toBe(null);\n });\n\n it(\"leaves a form built after the save started alone\", async () => {\n const { presenter, forms, create, createExecute } = setup();\n presenter.newEntry();\n\n const saving = presenter.saveRevision();\n await vi.waitFor(() => expect(createExecute).toHaveBeenCalled());\n presenter.newEntry();\n create.reject(new Error(\"Value must be unique.\"));\n\n await expect(saving).resolves.toBe(false);\n expect(forms).toHaveLength(2);\n expect(forms[0].setErrors).not.toHaveBeenCalled();\n expect(forms[1].setErrors).not.toHaveBeenCalled();\n });\n\n it(\"saves the open entry and puts the saved values on the form\", async () => {\n const { presenter, forms, update, updateExecute } = setup();\n await presenter.loadRevision(\"A\");\n\n const saving = presenter.saveRevision();\n await vi.waitFor(() => expect(updateExecute).toHaveBeenCalled());\n update.resolve(createEntry(\"A\"));\n\n await expect(saving).resolves.toBe(true);\n expect(updateExecute).toHaveBeenCalledWith(\n expect.objectContaining({ revisionId: \"A#0001\", data: { values: { title: \"Draft\" } } })\n );\n expect(forms[0].setData).toHaveBeenLastCalledWith({ title: \"A\" });\n });\n\n it(\"does not write to an entry opened while the form was validating\", async () => {\n const { presenter, update, updateExecute, slowValidation } = setup();\n const validation = slowValidation();\n await presenter.loadRevision(\"A\");\n\n const saving = presenter.saveRevision();\n await presenter.loadRevision(\"B\");\n validation.resolve({ title: \"Values typed into A\" });\n // Settled up front, so a write that wrongly goes out finishes instead of hanging.\n update.resolve(createEntry(\"B\"));\n\n await expect(saving).resolves.toBe(false);\n expect(updateExecute).not.toHaveBeenCalled();\n expect(presenter.vm.entry?.entryId).toBe(\"B\");\n });\n\n it(\"keeps a write on its entry and reports false when another entry was opened\", async () => {\n const { presenter, forms, update, updateExecute } = setup();\n await presenter.loadRevision(\"A\");\n\n const saving = presenter.saveRevision();\n await vi.waitFor(() => expect(updateExecute).toHaveBeenCalled());\n await presenter.loadRevision(\"B\");\n update.resolve(createEntry(\"A\"));\n\n // False, so \"Save & Publish\" does not go on to publish B.\n await expect(saving).resolves.toBe(false);\n expect(updateExecute).toHaveBeenCalledTimes(1);\n expect(updateExecute).toHaveBeenCalledWith(\n expect.objectContaining({ revisionId: \"A#0001\" })\n );\n expect(presenter.vm.entry?.entryId).toBe(\"B\");\n expect(forms[1].setData).toHaveBeenCalledTimes(1);\n expect(forms[1].setData).toHaveBeenCalledWith({ title: \"B\" });\n });\n\n it(\"does not clear the loading message of an entry being opened\", async () => {\n const { presenter, update, updateExecute, pendingLoads } = setup();\n await presenter.loadRevision(\"A\");\n\n const saving = presenter.saveRevision();\n await vi.waitFor(() => expect(updateExecute).toHaveBeenCalled());\n\n const loadB = deferred<any>();\n pendingLoads.set(\"B\", loadB.promise);\n const loading = presenter.loadRevision(\"B\");\n update.resolve(createEntry(\"A\"));\n\n // A's form is still on screen, because B hasn't loaded yet.\n await expect(saving).resolves.toBe(true);\n expect(presenter.vm.loading).toBe(\"Loading entry...\");\n\n loadB.resolve(createEntry(\"B\"));\n await loading;\n expect(presenter.vm.loading).toBe(null);\n });\n});\n"],"names":["createFakeForm","validation","vi","deferred","resolve","reject","promise","Promise","res","rej","createEntry","entryId","setup","forms","create","update","nextValidation","pendingLoads","Map","createExecute","updateExecute","container","Container","FormModelFactory","form","undefined","CmsFormModelBuilder","CmsModelContext","CreateEntryUseCase","UpdateEntryUseCase","GetEntryUseCase","id","abstraction","Confirmation","CreateRevisionFromUseCase","PublishEntryUseCase","UnpublishEntryUseCase","DeleteEntryUseCase","UpdateRevisionDescriptionUseCase","ContentEntryFormPresenter","Abstraction","describe","it","presenter","saving","Error","expect","slowValidation","loadB","loading"],"mappings":";;;;;;;;;;;;;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
  newEntry(initialValues?: Record<string, unknown>): void;
30
+ patchEntryMeta(meta: Partial<CmsContentEntry["meta"]>): void;
30
31
  reset(): void;
31
32
  }
32
33
  export declare const ContentEntryFormPresenter: import("@webiny/di").Abstraction<IContentEntryFormPresenter>;
@@ -1 +1 @@
1
- {"version":3,"file":"presentation/contentEntries/form/abstractions.js","sources":["../../../../src/presentation/contentEntries/form/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport { FormModel } from \"@webiny/app-admin\";\nimport type { IFormModel } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsContentEntry, CmsContentEntryStatusType } from \"~/types.js\";\nimport type { CmsModel } from \"~/types.js\";\n\nexport interface IContentEntryFormViewModel {\n loading: string | null;\n entry: CmsContentEntry | null;\n canCreateNewRevision: boolean;\n model: CmsModel;\n form: FormModel.FormVM | null;\n status: CmsContentEntryStatusType | undefined;\n canSave: boolean;\n canPublish: boolean;\n canUnpublish: boolean;\n canDelete: boolean;\n isNewEntry: boolean;\n isDirty: boolean;\n}\n\nexport interface IContentEntryFormPresenter {\n vm: IContentEntryFormViewModel;\n loadRevision(id: string): Promise<void>;\n saveRevision(options?: { skipValidation?: boolean }): Promise<boolean>;\n publishRevision(): Promise<boolean>;\n unpublishRevision(): Promise<boolean>;\n deleteEntry(): Promise<boolean>;\n setFolderId(folderId: string | null): void;\n newEntry(initialValues?: Record<string, unknown>): void;\n reset(): void;\n}\n\nexport const ContentEntryFormPresenter = createAbstraction<IContentEntryFormPresenter>(\n \"ContentEntryFormPresenter\"\n);\n\nexport namespace ContentEntryFormPresenter {\n export type Interface = IContentEntryFormPresenter;\n export type ViewModel = IContentEntryFormViewModel;\n}\n\nexport interface IContentEntryFormModelModifier {\n modifyForm(form: IFormModel, model: CmsModel): void;\n}\n\nexport const ContentEntryFormModelModifier = createAbstraction<IContentEntryFormModelModifier>(\n \"ContentEntryFormModelModifier\"\n);\n\nexport namespace ContentEntryFormModelModifier {\n export type Interface = IContentEntryFormModelModifier;\n}\n"],"names":["ContentEntryFormPresenter","createAbstraction","ContentEntryFormModelModifier"],"mappings":";AAiCO,MAAMA,4BAA4BC,kBACrC;AAYG,MAAMC,gCAAgCD,kBACzC"}
1
+ {"version":3,"file":"presentation/contentEntries/form/abstractions.js","sources":["../../../../src/presentation/contentEntries/form/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport { FormModel } from \"@webiny/app-admin\";\nimport type { IFormModel } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsContentEntry, CmsContentEntryStatusType } from \"~/types.js\";\nimport type { CmsModel } from \"~/types.js\";\n\nexport interface IContentEntryFormViewModel {\n loading: string | null;\n entry: CmsContentEntry | null;\n canCreateNewRevision: boolean;\n model: CmsModel;\n form: FormModel.FormVM | null;\n status: CmsContentEntryStatusType | undefined;\n canSave: boolean;\n canPublish: boolean;\n canUnpublish: boolean;\n canDelete: boolean;\n isNewEntry: boolean;\n isDirty: boolean;\n}\n\nexport interface IContentEntryFormPresenter {\n vm: IContentEntryFormViewModel;\n loadRevision(id: string): Promise<void>;\n saveRevision(options?: { skipValidation?: boolean }): Promise<boolean>;\n publishRevision(): Promise<boolean>;\n unpublishRevision(): Promise<boolean>;\n deleteEntry(): Promise<boolean>;\n setFolderId(folderId: string | null): void;\n newEntry(initialValues?: Record<string, unknown>): void;\n patchEntryMeta(meta: Partial<CmsContentEntry[\"meta\"]>): void;\n reset(): void;\n}\n\nexport const ContentEntryFormPresenter = createAbstraction<IContentEntryFormPresenter>(\n \"ContentEntryFormPresenter\"\n);\n\nexport namespace ContentEntryFormPresenter {\n export type Interface = IContentEntryFormPresenter;\n export type ViewModel = IContentEntryFormViewModel;\n}\n\nexport interface IContentEntryFormModelModifier {\n modifyForm(form: IFormModel, model: CmsModel): void;\n}\n\nexport const ContentEntryFormModelModifier = createAbstraction<IContentEntryFormModelModifier>(\n \"ContentEntryFormModelModifier\"\n);\n\nexport namespace ContentEntryFormModelModifier {\n export type Interface = IContentEntryFormModelModifier;\n}\n"],"names":["ContentEntryFormPresenter","createAbstraction","ContentEntryFormModelModifier"],"mappings":";AAkCO,MAAMA,4BAA4BC,kBACrC;AAYG,MAAMC,gCAAgCD,kBACzC"}
@@ -1,6 +1,7 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import { Container } from "@webiny/di";
3
3
  import { FormModelFeature } from "@webiny/app-admin/features/formModel/feature.js";
4
+ import { IdentityContextFeature } from "@webiny/app-admin/features/security/IdentityContext/feature.js";
4
5
  import { FormModelFactory } from "@webiny/app-admin/features/formModel/abstractions.js";
5
6
  import { CmsFormModelBuilder } from "../../../features/formModel/abstractions.js";
6
7
  import { CmsFormModelFeature } from "../../../features/formModel/feature.js";
@@ -189,6 +190,7 @@ const model = {
189
190
  };
190
191
  function createCmsForm() {
191
192
  const container = new Container();
193
+ IdentityContextFeature.register(container);
192
194
  FormModelFeature.register(container);
193
195
  CmsFormModelFeature.register(container);
194
196
  const builder = container.resolve(CmsFormModelBuilder);
@@ -206,7 +208,7 @@ describe("getFieldBuilders with CMS model", ()=>{
206
208
  tags: builder.getTags()
207
209
  });
208
210
  });
209
- expect(visited.length).toBe(7);
211
+ expect(visited.length).toBe(9);
210
212
  });
211
213
  it("traverse should find builders tagged 'uuid'", ()=>{
212
214
  const form = createCmsForm();
@@ -265,7 +267,7 @@ describe("getFieldBuilders with CMS model", ()=>{
265
267
  form.traverse((builder)=>{
266
268
  if ("text" === builder.getType()) textBuilders.push(builder.getName());
267
269
  });
268
- expect(textBuilders.length).toBe(5);
270
+ expect(textBuilders.length).toBe(7);
269
271
  });
270
272
  it("should combine getName, getType, and getTags for precise filtering", ()=>{
271
273
  const form = createCmsForm();
@@ -1 +1 @@
1
- {"version":3,"file":"presentation/contentEntries/form/getFieldBuilders.test.js","sources":["../../../../src/presentation/contentEntries/form/getFieldBuilders.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 { FormModelFactory } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { CmsFormModelBuilder } from \"~/features/formModel/abstractions.js\";\nimport { CmsFormModelFeature } from \"~/features/formModel/feature.js\";\n\nconst model = {\n modelId: \"test\",\n fields: [\n {\n id: \"textSingle\",\n fieldId: \"textSingle\",\n type: \"text\",\n label: \"Text\",\n tags: [],\n list: false,\n renderer: { name: \"text-input\", settings: {} },\n validation: [],\n listValidation: [],\n settings: {},\n predefinedValues: { enabled: false, values: [] }\n },\n {\n id: \"objectMultiple\",\n fieldId: \"objectMultiple\",\n type: \"object\",\n label: \"Object Multiple\",\n tags: [],\n list: true,\n renderer: { name: \"objects-accordion\", settings: {} },\n validation: [],\n listValidation: [],\n predefinedValues: { enabled: false, values: [] },\n settings: {\n fields: [\n {\n id: \"uuid\",\n fieldId: \"uuid\",\n type: \"text\",\n label: \"UUID\",\n tags: [\"uuid\"],\n list: false,\n renderer: { name: \"text-input\", settings: null },\n validation: [],\n listValidation: [],\n settings: {},\n predefinedValues: { enabled: false, values: [] }\n },\n {\n id: \"name\",\n fieldId: \"name\",\n type: \"text\",\n label: \"Name\",\n tags: [],\n list: false,\n renderer: { name: \"text-input\", settings: null },\n validation: [],\n listValidation: [],\n settings: {},\n predefinedValues: { enabled: false, values: [] }\n }\n ],\n layout: [[\"uuid\"], [\"name\"]]\n }\n },\n {\n id: \"dynamicZoneList\",\n fieldId: \"dynamicZoneList\",\n type: \"dynamicZone\",\n label: \"DZ List\",\n tags: [],\n list: true,\n renderer: { name: \"dynamicZone\", settings: {} },\n validation: [],\n listValidation: [],\n predefinedValues: { enabled: false, values: [] },\n settings: {\n templates: [\n {\n id: \"textBlock\",\n name: \"Text Block\",\n gqlTypeName: \"TextBlock\",\n fields: [\n {\n id: \"uuid\",\n fieldId: \"uuid\",\n type: \"text\",\n label: \"UUID\",\n tags: [\"uuid\"],\n list: false,\n renderer: { name: \"text-input\", settings: null },\n validation: [],\n listValidation: [],\n settings: {},\n predefinedValues: { enabled: false, values: [] }\n },\n {\n id: \"title\",\n fieldId: \"title\",\n type: \"text\",\n label: \"Title\",\n tags: [],\n list: false,\n renderer: { name: \"text-input\", settings: null },\n validation: [],\n listValidation: [],\n settings: {},\n predefinedValues: { enabled: false, values: [] }\n }\n ],\n layout: [[\"uuid\"], [\"title\"]],\n validation: []\n }\n ]\n }\n }\n ],\n layout: [[\"textSingle\"], [\"objectMultiple\"], [\"dynamicZoneList\"]]\n} as any;\n\nfunction createCmsForm() {\n const container = new Container();\n FormModelFeature.register(container);\n CmsFormModelFeature.register(container);\n\n const builder = container.resolve(CmsFormModelBuilder);\n const config = builder.build(model);\n const factory = container.resolve(FormModelFactory);\n return factory.create(config);\n}\n\ndescribe(\"getFieldBuilders with CMS model\", () => {\n it(\"traverse should visit all builders including nested\", () => {\n const form = createCmsForm();\n const visited: Array<{ fieldType: string; tags: string[] }> = [];\n form.traverse(builder => {\n visited.push({ fieldType: builder.getType(), tags: builder.getTags() });\n });\n // top-level: textSingle, objectMultiple, dynamicZoneList = 3\n // objectMultiple children: uuid, name = 2\n // dynamicZoneList template \"textBlock\" children: uuid, title = 2\n // Total = 7\n expect(visited.length).toBe(7);\n });\n\n it(\"traverse should find builders tagged 'uuid'\", () => {\n const form = createCmsForm();\n const uuidBuilders: any[] = [];\n form.traverse(builder => {\n if (builder.getTags().includes(\"uuid\")) {\n uuidBuilders.push(builder);\n }\n });\n // objectMultiple.uuid + dynamicZoneList.textBlock.uuid = 2\n expect(uuidBuilders.length).toBe(2);\n });\n\n it(\"traverse should allow modifying builders with defaultValue and cloneValue\", () => {\n const form = createCmsForm();\n let count = 0;\n form.traverse(builder => {\n if (builder.getTags().includes(\"uuid\")) {\n builder.defaultValue(() => String(Date.now()));\n builder.cloneValue(() => String(Date.now()));\n count++;\n }\n });\n expect(count).toBe(2);\n });\n\n it(\"getName should return the field name for all builders\", () => {\n const form = createCmsForm();\n const names: string[] = [];\n form.traverse(builder => {\n names.push(builder.getName());\n });\n expect(names).toContain(\"textSingle\");\n expect(names).toContain(\"objectMultiple\");\n expect(names).toContain(\"dynamicZoneList\");\n expect(names).toContain(\"uuid\");\n expect(names).toContain(\"name\");\n expect(names).toContain(\"title\");\n });\n\n it(\"getType should return the field type\", () => {\n const form = createCmsForm();\n const types: Record<string, string> = {};\n form.traverse(builder => {\n types[builder.getName()] = builder.getType();\n });\n expect(types[\"textSingle\"]).toBe(\"text\");\n expect(types[\"objectMultiple\"]).toBe(\"object\");\n expect(types[\"uuid\"]).toBe(\"text\");\n });\n\n it(\"should find builders by name using traverse\", () => {\n const form = createCmsForm();\n const matched: string[] = [];\n form.traverse(builder => {\n if (builder.getName() === \"uuid\") {\n matched.push(builder.getName());\n }\n });\n expect(matched.length).toBe(2);\n });\n\n it(\"should find builders by type using traverse\", () => {\n const form = createCmsForm();\n const textBuilders: string[] = [];\n form.traverse(builder => {\n if (builder.getType() === \"text\") {\n textBuilders.push(builder.getName());\n }\n });\n // textSingle + objectMultiple.uuid + objectMultiple.name + dz.textBlock.uuid + dz.textBlock.title = 5\n expect(textBuilders.length).toBe(5);\n });\n\n it(\"should combine getName, getType, and getTags for precise filtering\", () => {\n const form = createCmsForm();\n const matched: string[] = [];\n form.traverse(builder => {\n if (\n builder.getType() === \"text\" &&\n builder.getName() === \"uuid\" &&\n builder.getTags().includes(\"uuid\")\n ) {\n matched.push(builder.getName());\n }\n });\n expect(matched.length).toBe(2);\n });\n});\n"],"names":["model","createCmsForm","container","Container","FormModelFeature","CmsFormModelFeature","builder","CmsFormModelBuilder","config","factory","FormModelFactory","describe","it","form","visited","expect","uuidBuilders","count","String","Date","names","types","matched","textBuilders"],"mappings":";;;;;;AAOA,MAAMA,QAAQ;IACV,SAAS;IACT,QAAQ;QACJ;YACI,IAAI;YACJ,SAAS;YACT,MAAM;YACN,OAAO;YACP,MAAM,EAAE;YACR,MAAM;YACN,UAAU;gBAAE,MAAM;gBAAc,UAAU,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OAAOM,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;IAC/B;IAEAT,GAAG,+CAA+C;QAC9C,MAAMC,OAAOZ;QACb,MAAMqB,UAAoB,EAAE;QAC5BT,KAAK,QAAQ,CAACP,CAAAA;YACV,IAAIA,AAAsB,WAAtBA,QAAQ,OAAO,IACfgB,QAAQ,IAAI,CAAChB,QAAQ,OAAO;QAEpC;QACAS,OAAOO,QAAQ,MAAM,EAAE,IAAI,CAAC;IAChC;IAEAV,GAAG,+CAA+C;QAC9C,MAAMC,OAAOZ;QACb,MAAMsB,eAAyB,EAAE;QACjCV,KAAK,QAAQ,CAACP,CAAAA;YACV,IAAIA,AAAsB,WAAtBA,QAAQ,OAAO,IACfiB,aAAa,IAAI,CAACjB,QAAQ,OAAO;QAEzC;QAEAS,OAAOQ,aAAa,MAAM,EAAE,IAAI,CAAC;IACrC;IAEAX,GAAG,sEAAsE;QACrE,MAAMC,OAAOZ;QACb,MAAMqB,UAAoB,EAAE;QAC5BT,KAAK,QAAQ,CAACP,CAAAA;YACV,IACIA,AAAsB,WAAtBA,QAAQ,OAAO,MACfA,AAAsB,WAAtBA,QAAQ,OAAO,MACfA,QAAQ,OAAO,GAAG,QAAQ,CAAC,SAE3BgB,QAAQ,IAAI,CAAChB,QAAQ,OAAO;QAEpC;QACAS,OAAOO,QAAQ,MAAM,EAAE,IAAI,CAAC;IAChC;AACJ"}
1
+ {"version":3,"file":"presentation/contentEntries/form/getFieldBuilders.test.js","sources":["../../../../src/presentation/contentEntries/form/getFieldBuilders.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 { CmsFormModelBuilder } from \"~/features/formModel/abstractions.js\";\nimport { CmsFormModelFeature } from \"~/features/formModel/feature.js\";\n\nconst model = {\n modelId: \"test\",\n fields: [\n {\n id: \"textSingle\",\n fieldId: \"textSingle\",\n type: \"text\",\n label: \"Text\",\n tags: [],\n list: false,\n renderer: { name: \"text-input\", settings: {} },\n validation: [],\n listValidation: [],\n settings: {},\n predefinedValues: { enabled: false, values: [] }\n },\n {\n id: \"objectMultiple\",\n fieldId: \"objectMultiple\",\n type: \"object\",\n label: \"Object Multiple\",\n tags: [],\n list: true,\n renderer: { name: \"objects-accordion\", settings: {} },\n validation: [],\n listValidation: [],\n predefinedValues: { enabled: false, values: [] },\n settings: {\n fields: [\n {\n id: \"uuid\",\n fieldId: \"uuid\",\n type: \"text\",\n label: \"UUID\",\n tags: [\"uuid\"],\n list: false,\n renderer: { name: \"text-input\", settings: null },\n validation: [],\n listValidation: [],\n settings: {},\n predefinedValues: { enabled: false, values: [] }\n },\n {\n id: \"name\",\n fieldId: \"name\",\n type: \"text\",\n label: \"Name\",\n tags: [],\n list: false,\n renderer: { name: \"text-input\", settings: null },\n validation: [],\n listValidation: [],\n settings: {},\n predefinedValues: { enabled: false, values: [] }\n }\n ],\n layout: [[\"uuid\"], [\"name\"]]\n }\n },\n {\n id: \"dynamicZoneList\",\n fieldId: \"dynamicZoneList\",\n type: \"dynamicZone\",\n label: \"DZ List\",\n tags: [],\n list: true,\n renderer: { name: \"dynamicZone\", settings: {} },\n validation: [],\n listValidation: [],\n predefinedValues: { enabled: false, values: [] },\n settings: {\n templates: [\n {\n id: \"textBlock\",\n name: \"Text Block\",\n gqlTypeName: \"TextBlock\",\n fields: [\n {\n id: \"uuid\",\n fieldId: \"uuid\",\n type: \"text\",\n label: \"UUID\",\n tags: [\"uuid\"],\n list: false,\n renderer: { name: \"text-input\", settings: null },\n validation: [],\n listValidation: [],\n settings: {},\n predefinedValues: { enabled: false, values: [] }\n },\n {\n id: \"title\",\n fieldId: \"title\",\n type: \"text\",\n label: \"Title\",\n tags: [],\n list: false,\n renderer: { name: \"text-input\", settings: null },\n validation: [],\n listValidation: [],\n settings: {},\n predefinedValues: { enabled: false, values: [] }\n }\n ],\n layout: [[\"uuid\"], [\"title\"]],\n validation: []\n }\n ]\n }\n }\n ],\n layout: [[\"textSingle\"], [\"objectMultiple\"], [\"dynamicZoneList\"]]\n} as any;\n\nfunction createCmsForm() {\n const container = new Container();\n IdentityContextFeature.register(container);\n FormModelFeature.register(container);\n CmsFormModelFeature.register(container);\n\n const builder = container.resolve(CmsFormModelBuilder);\n const config = builder.build(model);\n const factory = container.resolve(FormModelFactory);\n return factory.create(config);\n}\n\ndescribe(\"getFieldBuilders with CMS model\", () => {\n it(\"traverse should visit all builders including nested\", () => {\n const form = createCmsForm();\n const visited: Array<{ fieldType: string; tags: string[] }> = [];\n form.traverse(builder => {\n visited.push({ fieldType: builder.getType(), tags: builder.getTags() });\n });\n // top-level: textSingle, objectMultiple, dynamicZoneList = 3\n // objectMultiple children: _id, uuid, name = 3\n // dynamicZoneList template \"textBlock\" children: _id, uuid, title = 3\n // Total = 9\n expect(visited.length).toBe(9);\n });\n\n it(\"traverse should find builders tagged 'uuid'\", () => {\n const form = createCmsForm();\n const uuidBuilders: any[] = [];\n form.traverse(builder => {\n if (builder.getTags().includes(\"uuid\")) {\n uuidBuilders.push(builder);\n }\n });\n // objectMultiple.uuid + dynamicZoneList.textBlock.uuid = 2\n expect(uuidBuilders.length).toBe(2);\n });\n\n it(\"traverse should allow modifying builders with defaultValue and cloneValue\", () => {\n const form = createCmsForm();\n let count = 0;\n form.traverse(builder => {\n if (builder.getTags().includes(\"uuid\")) {\n builder.defaultValue(() => String(Date.now()));\n builder.cloneValue(() => String(Date.now()));\n count++;\n }\n });\n expect(count).toBe(2);\n });\n\n it(\"getName should return the field name for all builders\", () => {\n const form = createCmsForm();\n const names: string[] = [];\n form.traverse(builder => {\n names.push(builder.getName());\n });\n expect(names).toContain(\"textSingle\");\n expect(names).toContain(\"objectMultiple\");\n expect(names).toContain(\"dynamicZoneList\");\n expect(names).toContain(\"uuid\");\n expect(names).toContain(\"name\");\n expect(names).toContain(\"title\");\n });\n\n it(\"getType should return the field type\", () => {\n const form = createCmsForm();\n const types: Record<string, string> = {};\n form.traverse(builder => {\n types[builder.getName()] = builder.getType();\n });\n expect(types[\"textSingle\"]).toBe(\"text\");\n expect(types[\"objectMultiple\"]).toBe(\"object\");\n expect(types[\"uuid\"]).toBe(\"text\");\n });\n\n it(\"should find builders by name using traverse\", () => {\n const form = createCmsForm();\n const matched: string[] = [];\n form.traverse(builder => {\n if (builder.getName() === \"uuid\") {\n matched.push(builder.getName());\n }\n });\n expect(matched.length).toBe(2);\n });\n\n it(\"should find builders by type using traverse\", () => {\n const form = createCmsForm();\n const textBuilders: string[] = [];\n form.traverse(builder => {\n if (builder.getType() === \"text\") {\n textBuilders.push(builder.getName());\n }\n });\n // textSingle + objectMultiple._id + objectMultiple.uuid + objectMultiple.name + dz.textBlock._id + dz.textBlock.uuid + dz.textBlock.title = 7\n expect(textBuilders.length).toBe(7);\n });\n\n it(\"should combine getName, getType, and getTags for precise filtering\", () => {\n const form = createCmsForm();\n const matched: string[] = [];\n form.traverse(builder => {\n if (\n builder.getType() === \"text\" &&\n builder.getName() === \"uuid\" &&\n builder.getTags().includes(\"uuid\")\n ) {\n matched.push(builder.getName());\n }\n });\n expect(matched.length).toBe(2);\n });\n});\n"],"names":["model","createCmsForm","container","Container","IdentityContextFeature","FormModelFeature","CmsFormModelFeature","builder","CmsFormModelBuilder","config","factory","FormModelFactory","describe","it","form","visited","expect","uuidBuilders","count","String","Date","names","types","matched","textBuilders"],"mappings":";;;;;;;AAQA,MAAMA,QAAQ;IACV,SAAS;IACT,QAAQ;QACJ;YACI,IAAI;YACJ,SAAS;YACT,MAAM;YACN,OAAO;YACP,MAAM,EAAE;YACR,MAAM;YACN,UAAU;gBAAE,MAAM;gBAAc,UAAU,CAAC;YAAE;YAC7C,YAAY,EAAE;YACd,gBAAgB,EAAE;YAClB,UAAU,CAAC;YACX,kBAAkB;gBAAE,SAAS;gBA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9C,MAAMC,OAAOb;QACb,MAAMsB,UAAoB,EAAE;QAC5BT,KAAK,QAAQ,CAACP,CAAAA;YACV,IAAIA,AAAsB,WAAtBA,QAAQ,OAAO,IACfgB,QAAQ,IAAI,CAAChB,QAAQ,OAAO;QAEpC;QACAS,OAAOO,QAAQ,MAAM,EAAE,IAAI,CAAC;IAChC;IAEAV,GAAG,+CAA+C;QAC9C,MAAMC,OAAOb;QACb,MAAMuB,eAAyB,EAAE;QACjCV,KAAK,QAAQ,CAACP,CAAAA;YACV,IAAIA,AAAsB,WAAtBA,QAAQ,OAAO,IACfiB,aAAa,IAAI,CAACjB,QAAQ,OAAO;QAEzC;QAEAS,OAAOQ,aAAa,MAAM,EAAE,IAAI,CAAC;IACrC;IAEAX,GAAG,sEAAsE;QACrE,MAAMC,OAAOb;QACb,MAAMsB,UAAoB,EAAE;QAC5BT,KAAK,QAAQ,CAACP,CAAAA;YACV,IACIA,AAAsB,WAAtBA,QAAQ,OAAO,MACfA,AAAsB,WAAtBA,QAAQ,OAAO,MACfA,QAAQ,OAAO,GAAG,QAAQ,CAAC,SAE3BgB,QAAQ,IAAI,CAAChB,QAAQ,OAAO;QAEpC;QACAS,OAAOO,QAAQ,MAAM,EAAE,IAAI,CAAC;IAChC;AACJ"}
@@ -0,0 +1,7 @@
1
+ import type { FormModel } from "@webiny/app-admin/features/formModel/abstractions.js";
2
+ import type { CmsModel } from "../../../types.js";
3
+ /**
4
+ * Converts a rejected save into form errors: per-field validation errors from the API are
5
+ * placed on their fields, anything else is shown as a form-level error.
6
+ */
7
+ export declare const toFormErrors: (error: unknown, model: CmsModel) => FormModel.FormError[];
@@ -0,0 +1,49 @@
1
+ import { CmsEntryError } from "../../../features/contentEntry/CmsEntryError.js";
2
+ const isApiFieldError = (value)=>{
3
+ const item = value;
4
+ return "string" == typeof item?.fieldId && "string" == typeof item.error;
5
+ };
6
+ const isIndex = (value)=>/^\d+$/.test(String(value));
7
+ const toFieldPath = (model, error)=>{
8
+ const parents = error.parents ?? [];
9
+ const path = [];
10
+ let fields = model.fields;
11
+ for(let i = 0; i < parents.length; i++){
12
+ const field = fields.find((f)=>f.fieldId === String(parents[i]));
13
+ if (!field) return [
14
+ ...parents,
15
+ error.fieldId
16
+ ].join(".");
17
+ path.push(field.fieldId);
18
+ if (field.list && isIndex(parents[i + 1])) path.push(String(parents[++i]));
19
+ if ("dynamicZone" === field.type) {
20
+ const templates = field.settings?.templates ?? [];
21
+ const template = templates.find((t)=>t.gqlTypeName === String(parents[i + 1]));
22
+ i++;
23
+ fields = template?.fields ?? [];
24
+ } else fields = field.settings?.fields ?? [];
25
+ }
26
+ return [
27
+ ...path,
28
+ error.fieldId
29
+ ].join(".");
30
+ };
31
+ const toFormErrors = (error, model)=>{
32
+ if (error instanceof CmsEntryError && Array.isArray(error.data)) {
33
+ const fieldErrors = error.data.filter(isApiFieldError);
34
+ if (fieldErrors.length > 0) return fieldErrors.map((item)=>({
35
+ path: toFieldPath(model, item),
36
+ message: item.error
37
+ }));
38
+ }
39
+ const message = error instanceof Error ? error.message : "Could not save the entry.";
40
+ return [
41
+ {
42
+ path: "",
43
+ message
44
+ }
45
+ ];
46
+ };
47
+ export { toFormErrors };
48
+
49
+ //# sourceMappingURL=toFormErrors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presentation/contentEntries/form/toFormErrors.js","sources":["../../../../src/presentation/contentEntries/form/toFormErrors.ts"],"sourcesContent":["import type { FormModel } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsDynamicZoneTemplate, CmsModel, CmsModelField } from \"~/types.js\";\nimport { CmsEntryError } from \"~/features/contentEntry/CmsEntryError.js\";\n\ninterface ApiFieldError {\n fieldId: string;\n error: string;\n parents?: (string | number)[];\n}\n\nconst isApiFieldError = (value: unknown): value is ApiFieldError => {\n const item = value as ApiFieldError;\n return typeof item?.fieldId === \"string\" && typeof item.error === \"string\";\n};\n\nconst isIndex = (value: unknown): boolean => /^\\d+$/.test(String(value));\n\n/**\n * The API lists the parents of a nested field as `fieldId`, then the item index for list\n * fields, then the template's `gqlTypeName` for dynamic zones. Form paths have no template\n * segment, so walk the model to drop it: `blocks.0.PageHero.title` → `blocks.0.title`.\n */\nconst toFieldPath = (model: CmsModel, error: ApiFieldError): string => {\n const parents = error.parents ?? [];\n const path: string[] = [];\n let fields: CmsModelField[] = model.fields;\n\n for (let i = 0; i < parents.length; i++) {\n const field = fields.find(f => f.fieldId === String(parents[i]));\n if (!field) {\n return [...parents, error.fieldId].join(\".\");\n }\n path.push(field.fieldId);\n\n if (field.list && isIndex(parents[i + 1])) {\n path.push(String(parents[++i]));\n }\n\n if (field.type === \"dynamicZone\") {\n const templates = (field.settings?.templates ?? []) as CmsDynamicZoneTemplate[];\n const template = templates.find(t => t.gqlTypeName === String(parents[i + 1]));\n i++;\n fields = template?.fields ?? [];\n } else {\n fields = (field.settings?.fields ?? []) as CmsModelField[];\n }\n }\n\n return [...path, error.fieldId].join(\".\");\n};\n\n/**\n * Converts a rejected save into form errors: per-field validation errors from the API are\n * placed on their fields, anything else is shown as a form-level error.\n */\nexport const toFormErrors = (error: unknown, model: CmsModel): FormModel.FormError[] => {\n if (error instanceof CmsEntryError && Array.isArray(error.data)) {\n const fieldErrors = error.data.filter(isApiFieldError);\n if (fieldErrors.length > 0) {\n return fieldErrors.map(item => ({\n path: toFieldPath(model, item),\n message: item.error\n }));\n }\n }\n\n const message = error instanceof Error ? error.message : \"Could not save the entry.\";\n return [{ path: \"\", message }];\n};\n"],"names":["isApiFieldError","value","item","isIndex","String","toFieldPath","model","error","parents","path","fields","i","field","f","templates","template","t","toFormErrors","CmsEntryError","Array","fieldErrors","message","Error"],"mappings":";AAUA,MAAMA,kBAAkB,CAACC;IACrB,MAAMC,OAAOD;IACb,OAAO,AAAyB,YAAzB,OAAOC,MAAM,WAAwB,AAAsB,YAAtB,OAAOA,KAAK,KAAK;AACjE;AAEA,MAAMC,UAAU,CAACF,QAA4B,QAAQ,IAAI,CAACG,OAAOH;A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