@webiny/app-headless-cms 6.5.0-beta.0 → 6.5.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/ContentEntriesModule.js +14 -2
  2. package/ContentEntriesModule.js.map +1 -1
  3. package/admin/components/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
  4. package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
  5. package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
  6. package/admin/components/ContentEntries/BulkActions/ActionMove.js.map +1 -1
  7. package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
  8. package/admin/components/ContentEntries/BulkActions/ActionPublish.js.map +1 -1
  9. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
  10. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.js.map +1 -1
  11. package/admin/components/ContentEntries/Filters/RefFieldRenderer.d.ts +2 -0
  12. package/admin/components/ContentEntries/Filters/RefFieldRenderer.js +84 -0
  13. package/admin/components/ContentEntries/Filters/RefFieldRenderer.js.map +1 -0
  14. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.d.ts +2 -0
  15. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js +34 -0
  16. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js.map +1 -0
  17. package/admin/components/ContentEntries/Table/Actions/index.d.ts +1 -0
  18. package/admin/components/ContentEntries/Table/Actions/index.js +1 -0
  19. package/admin/components/ContentModelEditor/ContentModelEditor.js +1 -1
  20. package/admin/components/ContentModelEditor/ContentModelEditor.js.map +1 -1
  21. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.d.ts +2 -0
  22. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js +22 -0
  23. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js.map +1 -0
  24. package/admin/components/FieldEditor/EditFieldDialog.d.ts +2 -2
  25. package/admin/components/FieldEditor/Field.js +4 -4
  26. package/admin/components/FieldEditor/Field.js.map +1 -1
  27. package/features/contentEntry/CmsEntryError.d.ts +10 -0
  28. package/features/contentEntry/CmsEntryError.js +11 -0
  29. package/features/contentEntry/CmsEntryError.js.map +1 -0
  30. package/features/contentEntry/createEntry/CreateEntryGateway.d.ts +0 -1
  31. package/features/contentEntry/createEntry/CreateEntryGateway.js +3 -10
  32. package/features/contentEntry/createEntry/CreateEntryGateway.js.map +1 -1
  33. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.d.ts +3 -1
  34. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js +8 -3
  35. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js.map +1 -1
  36. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.d.ts +14 -0
  37. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js +43 -0
  38. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js.map +1 -0
  39. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.d.ts +15 -0
  40. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js +34 -0
  41. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js.map +1 -0
  42. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.d.ts +11 -0
  43. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js +18 -0
  44. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js.map +1 -0
  45. package/features/contentEntry/duplicateEntry/abstractions.d.ts +26 -0
  46. package/features/contentEntry/duplicateEntry/abstractions.js +7 -0
  47. package/features/contentEntry/duplicateEntry/abstractions.js.map +1 -0
  48. package/features/contentEntry/duplicateEntry/feature.d.ts +3 -0
  49. package/features/contentEntry/duplicateEntry/feature.js +21 -0
  50. package/features/contentEntry/duplicateEntry/feature.js.map +1 -0
  51. package/features/contentEntry/entryValueGateways.test.d.ts +1 -0
  52. package/features/contentEntry/entryValueGateways.test.js +106 -0
  53. package/features/contentEntry/entryValueGateways.test.js.map +1 -0
  54. package/features/contentEntry/feature.js +2 -0
  55. package/features/contentEntry/feature.js.map +1 -1
  56. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.d.ts +0 -1
  57. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js +3 -10
  58. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js.map +1 -1
  59. package/features/contentEntry/updateEntry/UpdateEntryGateway.d.ts +0 -1
  60. package/features/contentEntry/updateEntry/UpdateEntryGateway.js +3 -10
  61. package/features/contentEntry/updateEntry/UpdateEntryGateway.js.map +1 -1
  62. package/features/contentEntry/valueTransformers/EntryDataPreparer.d.ts +9 -0
  63. package/features/contentEntry/valueTransformers/EntryDataPreparer.js +8 -0
  64. package/features/contentEntry/valueTransformers/EntryDataPreparer.js.map +1 -1
  65. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.d.ts +1 -0
  66. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js +113 -0
  67. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js.map +1 -0
  68. package/features/contentEntry/valueTransformers/entryValueFixtures.d.ts +146 -0
  69. package/features/contentEntry/valueTransformers/entryValueFixtures.js +171 -0
  70. package/features/contentEntry/valueTransformers/entryValueFixtures.js.map +1 -0
  71. package/features/formModel/CmsFormModelBuilder.d.ts +9 -1
  72. package/features/formModel/CmsFormModelBuilder.js +26 -15
  73. package/features/formModel/CmsFormModelBuilder.js.map +1 -1
  74. package/features/formModel/CmsFormModelBuilder.test.d.ts +1 -0
  75. package/features/formModel/CmsFormModelBuilder.test.js +252 -0
  76. package/features/formModel/CmsFormModelBuilder.test.js.map +1 -0
  77. package/features/formModel/CmsLayoutMapper.d.ts +8 -1
  78. package/features/formModel/CmsLayoutMapper.js +23 -1
  79. package/features/formModel/CmsLayoutMapper.js.map +1 -1
  80. package/features/formModel/mappers/DynamicZoneFieldMapper.js +4 -0
  81. package/features/formModel/mappers/DynamicZoneFieldMapper.js.map +1 -1
  82. package/features/formModel/mappers/ObjectFieldMapper.js +11 -6
  83. package/features/formModel/mappers/ObjectFieldMapper.js.map +1 -1
  84. package/features/model/exportModels/ExportModelsGateway.d.ts +1 -1
  85. package/features/model/exportModels/ExportModelsGateway.js.map +1 -1
  86. package/features/model/exportModels/ExportModelsUseCase.js +7 -1
  87. package/features/model/exportModels/ExportModelsUseCase.js.map +1 -1
  88. package/features/model/exportModels/abstractions.d.ts +8 -2
  89. package/features/model/exportModels/abstractions.js.map +1 -1
  90. package/package.json +26 -26
  91. package/presentation/cloneContentModel/CloneContentModelPresenter.d.ts +1 -0
  92. package/presentation/cloneContentModel/CloneContentModelPresenter.js +8 -6
  93. package/presentation/cloneContentModel/CloneContentModelPresenter.js.map +1 -1
  94. package/presentation/contentEntries/form/ContentEntryFormPresenter.js +34 -29
  95. package/presentation/contentEntries/form/ContentEntryFormPresenter.js.map +1 -1
  96. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.d.ts +1 -0
  97. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js +210 -0
  98. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js.map +1 -0
  99. package/presentation/contentEntries/form/toFormErrors.d.ts +7 -0
  100. package/presentation/contentEntries/form/toFormErrors.js +49 -0
  101. package/presentation/contentEntries/form/toFormErrors.js.map +1 -0
  102. package/presentation/contentEntries/form/toFormErrors.test.d.ts +1 -0
  103. package/presentation/contentEntries/form/toFormErrors.test.js +175 -0
  104. package/presentation/contentEntries/form/toFormErrors.test.js.map +1 -0
  105. package/presentation/contentEntries/list/ContentEntriesDataSource.d.ts +5 -0
  106. package/presentation/contentEntries/list/ContentEntriesDataSource.js +11 -2
  107. package/presentation/contentEntries/list/ContentEntriesDataSource.js.map +1 -1
  108. package/presentation/contentEntries/list/ContentEntriesPresenter.d.ts +6 -2
  109. package/presentation/contentEntries/list/ContentEntriesPresenter.js +27 -2
  110. package/presentation/contentEntries/list/ContentEntriesPresenter.js.map +1 -1
  111. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +130 -5
  112. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
  113. package/presentation/contentEntries/list/abstractions.d.ts +12 -0
  114. package/presentation/contentEntries/list/abstractions.js.map +1 -1
  115. package/presentation/contentEntries/preview/LivePreviewPresenter.d.ts +12 -1
  116. package/presentation/contentEntries/preview/LivePreviewPresenter.js +48 -5
  117. package/presentation/contentEntries/preview/LivePreviewPresenter.js.map +1 -1
  118. package/presentation/contentEntries/preview/LivePreviewPresenter.test.d.ts +1 -0
  119. package/presentation/contentEntries/preview/LivePreviewPresenter.test.js +81 -0
  120. package/presentation/contentEntries/preview/LivePreviewPresenter.test.js.map +1 -0
  121. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js +1 -1
  122. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js.map +1 -1
  123. package/presentation/contentEntries/preview/PreviewDecorator.js +25 -6
  124. package/presentation/contentEntries/preview/PreviewDecorator.js.map +1 -1
  125. package/presentation/contentEntries/preview/PreviewDomainStatus.d.ts +10 -0
  126. package/presentation/contentEntries/preview/PreviewDomainStatus.js +19 -0
  127. package/presentation/contentEntries/preview/PreviewDomainStatus.js.map +1 -0
  128. package/presentation/contentEntries/preview/PreviewPane.d.ts +10 -1
  129. package/presentation/contentEntries/preview/PreviewPane.js +81 -45
  130. package/presentation/contentEntries/preview/PreviewPane.js.map +1 -1
  131. package/presentation/contentEntries/preview/abstractions.d.ts +8 -0
  132. package/presentation/contentEntries/preview/abstractions.js.map +1 -1
  133. package/presentation/contentEntries/preview/resolvePreviewUrl.d.ts +21 -0
  134. package/presentation/contentEntries/preview/resolvePreviewUrl.js +50 -1
  135. package/presentation/contentEntries/preview/resolvePreviewUrl.js.map +1 -1
  136. package/presentation/contentEntries/preview/resolvePreviewUrl.test.d.ts +1 -0
  137. package/presentation/contentEntries/preview/resolvePreviewUrl.test.js +127 -0
  138. package/presentation/contentEntries/preview/resolvePreviewUrl.test.js.map +1 -0
  139. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js +9 -4
  140. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js.map +1 -1
  141. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.d.ts +1 -0
  142. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js +122 -0
  143. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js.map +1 -0
  144. package/presentation/contentEntries/trashBin/CmsTrashBin.d.ts +2 -2
  145. package/presentation/contentEntries/views/CmsAdvancedSearch.d.ts +2 -2
  146. package/presentation/contentEntries/views/ContentEntriesListLayout.d.ts +2 -2
  147. package/presentation/contentEntries/views/ContentEntryFormView.d.ts +2 -2
  148. package/presentation/contentEntries/views/OlderRevisionAlert.d.ts +2 -2
  149. package/presentation/contentEntries/views/RevisionDrawer.d.ts +2 -2
  150. package/presentation/contentEntries/views/RevisionsList.d.ts +2 -2
  151. package/presentation/contentEntries/views/SingleEntryLayout.d.ts +2 -2
  152. package/presentation/contentEntries/views/Table/Table.d.ts +2 -2
  153. package/presentation/contentEntries/views/actions/CreateNewRevisionButton.d.ts +2 -2
  154. package/presentation/contentEntries/views/actions/DeleteEntryMenuItem.d.ts +2 -2
  155. package/presentation/contentEntries/views/actions/PublishOnlyButton.d.ts +2 -2
  156. package/presentation/contentEntries/views/actions/RevisionSelector.d.ts +2 -2
  157. package/presentation/contentEntries/views/actions/SaveAndPublishButton.d.ts +2 -2
  158. package/presentation/contentEntries/views/actions/SaveContentButton.d.ts +2 -2
  159. package/presentation/contentEntries/views/actions/ShowRevisionListMenuItem.d.ts +2 -2
  160. package/presentation/contentEntries/views/layout/ContentEntryForm.d.ts +12 -12
  161. package/presentation/contentModels/ContentModelsPresenter.d.ts +5 -5
  162. package/presentation/contentModels/ContentModelsPresenter.js +1 -1
  163. package/presentation/contentModels/ContentModelsPresenter.js.map +1 -1
  164. package/presentation/contentModels/abstractions.d.ts +7 -2
  165. package/presentation/contentModels/abstractions.js.map +1 -1
  166. package/presentation/contentModels/components/CloneContentModelDialog.d.ts +2 -2
  167. package/presentation/contentModels/components/ContentModels.d.ts +2 -2
  168. package/presentation/contentModels/components/ContentModelsDataList.d.ts +2 -2
  169. package/presentation/contentModels/components/ContentModelsDataList.js +6 -5
  170. package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
  171. package/presentation/contentModels/components/NewContentModelDialog.d.ts +2 -2
  172. package/presentation/contentModels/components/fullDelete/dialog/Content.js +2 -2
  173. package/presentation/contentModels/components/fullDelete/dialog/Content.js.map +1 -1
  174. package/presentation/contentModels/components/fullDelete/types.js.map +1 -1
  175. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.d.ts +1 -0
  176. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js +133 -0
  177. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js.map +1 -0
  178. package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js +1 -1
  179. package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js.map +1 -1
  180. package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js +1 -1
  181. package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js.map +1 -1
  182. package/presentation/fieldRenderers/ref/components/RefFieldOptions.d.ts +2 -2
  183. package/presentation/fieldRenderers/ref/components/RefFieldOptions.js +3 -2
  184. package/presentation/fieldRenderers/ref/components/RefFieldOptions.js.map +1 -1
  185. package/presentation/importContentModels/ImportContentModelsDialog.d.ts +2 -2
  186. package/presentation/importContentModels/ImportContentModelsPresenter.js +1 -1
  187. package/presentation/importContentModels/ImportContentModelsPresenter.js.map +1 -1
  188. package/presentation/importContentModels/components/DataList.d.ts +2 -2
  189. package/presentation/importContentModels/components/FileUpload.d.ts +2 -2
  190. package/presentation/importContentModels/components/FileUpload.js +1 -1
  191. package/presentation/importContentModels/components/FileUpload.js.map +1 -1
  192. package/presentation/importContentModels/components/Model/DataListModelItem.js +3 -3
  193. package/presentation/importContentModels/components/Model/DataListModelItem.js.map +1 -1
  194. package/presentation/importContentModels/components/Model/DataListModelItemInfo.js +2 -2
  195. package/presentation/importContentModels/components/Model/DataListModelItemInfo.js.map +1 -1
  196. package/presentation/importContentModels/components/Model/DataListModels.d.ts +2 -2
  197. package/presentation/menus/ContentGroupsMenuItems.d.ts +2 -2
  198. package/presentation/modelGroup/ModelGroupPresenter.js +1 -2
  199. package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
  200. package/presentation/modelGroup/components/ContentModelGroups.d.ts +2 -2
  201. package/presentation/modelGroup/components/ContentModelGroupsDataList.d.ts +6 -2
  202. package/presentation/modelGroup/components/ContentModelGroupsForm.d.ts +8 -2
  203. package/presentation/newContentModel/NewContentModelPresenter.d.ts +1 -0
  204. package/presentation/newContentModel/NewContentModelPresenter.js +8 -6
  205. package/presentation/newContentModel/NewContentModelPresenter.js.map +1 -1
  206. package/utils/normalizeIcon.d.ts +4 -0
  207. package/utils/normalizeIcon.js +9 -6
  208. package/utils/normalizeIcon.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"admin/components/FieldEditor/Field.js","sources":["../../../../src/admin/components/FieldEditor/Field.tsx"],"sourcesContent":["import React, { Fragment, useCallback, useMemo } from \"react\";\nimport capitalize from \"lodash/capitalize.js\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { ReactComponent as TitleIcon } from \"@webiny/icons/title.svg\";\nimport { ReactComponent as MoreVerticalIcon } from \"@webiny/icons/more_vert.svg\";\nimport { plugins } from \"@webiny/plugins\";\nimport type { CmsModelField, CmsEditorFieldOptionPlugin, CmsModel } from \"~/types.js\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { useModelEditor } from \"~/admin/hooks/index.js\";\nimport { useModelFieldEditor } from \"~/admin/components/FieldEditor/useModelFieldEditor.js\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { Icon, IconButton, Text, DropdownMenu, Tag } from \"@webiny/admin-ui\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/components/editor/field\");\n\nconst allowedTitleFieldTypes: string[] = [\"text\", \"number\"];\n\nconst isFieldAllowedToBeTitle = (model: CmsModel, field: CmsModelField, parent?: CmsModelField) => {\n if (field.list || parent) {\n return false;\n } else if (allowedTitleFieldTypes.includes(field.type) === false) {\n return false;\n } else if (model.titleFieldId === field.fieldId) {\n return false;\n }\n return true;\n};\nconst isFieldAllowedToBeDescription = (\n model: CmsModel,\n field: CmsModelField,\n parent?: CmsModelField\n) => {\n if (field.list || parent) {\n return false;\n } else if (model.descriptionFieldId === field.fieldId) {\n return false;\n }\n return field.type === \"long-text\";\n};\n\nconst isFieldAllowedToBeImage = (model: CmsModel, field: CmsModelField, parent?: CmsModelField) => {\n if (field.list || parent) {\n return false;\n } else if (model.imageFieldId === field.fieldId) {\n return false;\n }\n return field.type === \"file\" && field.settings?.imagesOnly;\n};\n\nconst getFieldTypeName = (\n model: CmsModel,\n field: CmsModelField,\n parent?: CmsModelField\n): string | null => {\n if (parent) {\n return null;\n }\n const isTitleField = field.fieldId === model?.titleFieldId && !parent;\n const isDescriptionField = field.fieldId === model?.descriptionFieldId && !parent;\n const isImageField = field.fieldId === model?.imageFieldId && !parent;\n\n return (\n [\n isTitleField ? \"entry title\" : null,\n isDescriptionField ? \"entry description\" : null,\n isImageField ? \"entry image\" : null\n ]\n .filter(Boolean)\n .join(\"\") || null\n );\n};\n\nexport interface FieldProps {\n field: CmsModelField;\n onDelete: (field: CmsModelField) => void;\n onEdit: (field: CmsModelField) => void;\n parent?: CmsModelField;\n}\n\nconst Field = (props: FieldProps) => {\n const { field, onEdit, parent } = props;\n const { showSnackbar, showErrorSnackbar } = useSnackbar();\n const { setData: setModel, data: model } = useModelEditor();\n const { getFieldType, getFieldRenderer } = useModelFieldEditor();\n\n const removeFieldFromSelected = useCallback(async () => {\n if (model.titleFieldId === field.fieldId) {\n await setModel(data => {\n return {\n ...data,\n titleFieldId: null\n };\n });\n } else if (model.descriptionFieldId === field.fieldId) {\n await setModel(data => {\n return {\n ...data,\n descriptionFieldId: null\n };\n });\n } else if (model.imageFieldId === field.fieldId) {\n await setModel(data => {\n return {\n ...data,\n imageFieldId: null\n };\n });\n }\n }, [field.id, setModel, model]);\n\n const onDelete = useCallback(async () => {\n await removeFieldFromSelected();\n props.onDelete(field);\n return;\n }, [field.fieldId]);\n\n const setAsTitle = useCallback(async (): Promise<void> => {\n const response = await setModel(data => {\n return { ...data, titleFieldId: field.fieldId };\n });\n\n if (response && response.error) {\n return showErrorSnackbar(response.error.message);\n }\n\n showSnackbar(t`Title field set successfully.`);\n }, [field.fieldId, setModel]);\n\n const setAsDescription = useCallback(async (): Promise<void> => {\n const response = await setModel(data => {\n return { ...data, descriptionFieldId: field.fieldId };\n });\n\n if (response && response.error) {\n return showErrorSnackbar(response.error.message);\n }\n\n showSnackbar(t`Description field set successfully.`);\n }, [field.fieldId, setModel]);\n\n const setAsImage = useCallback(async (): Promise<void> => {\n const response = await setModel(data => {\n return { ...data, imageFieldId: field.fieldId };\n });\n\n if (response && response.error) {\n return showErrorSnackbar(response.error.message);\n }\n\n showSnackbar(t`Image field set successfully.`);\n }, [field.fieldId, setModel]);\n\n const fieldType = getFieldType(field);\n const editorFieldOptionPlugins =\n plugins.byType<CmsEditorFieldOptionPlugin>(\"cms-editor-field-option\");\n\n if (!fieldType) {\n return null;\n }\n\n const renderer = getFieldRenderer(field.renderer.name);\n const canEdit = fieldType.canEditSettings !== false;\n\n const defaultInformationRenderer = useMemo(() => {\n const fieldTypeName = getFieldTypeName(model, field, parent);\n const fn = () => {\n if (!fieldTypeName) {\n return null;\n }\n return <Tag content={capitalize(fieldTypeName)} variant={\"neutral-light\"} />;\n };\n\n fn.displayName = \"FieldTypeRenderer\";\n\n return fn;\n }, [field.id]);\n\n const fieldInformationRenderer = fieldType.renderInfo;\n\n const info = [renderer?.name, field.list ? \"multiple values\" : null].filter(Boolean).join(\", \");\n\n return (\n <Fragment>\n <div className={\"flex items-center justify-between gap-sm-extra\"}>\n <div className={\"flex items-center gap-sm-extra flex-1 min-w-0\"}>\n <Icon\n icon={fieldType.icon}\n label={fieldType.label}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n <div className={\"flex flex-col gap-xxs min-w-0\"}>\n <span\n className={\n \"text-md font-semibold text-neutral-primary truncate leading-5\"\n }\n >\n {field.label}\n </span>\n <Text size={\"sm\"} className={\"text-neutral-muted truncate\"}>\n {fieldType.label}\n {info && <span> / {info}</span>}\n </Text>\n </div>\n </div>\n <div className={\"flex items-center justify-end gap-xs shrink-0\"}>\n {fieldInformationRenderer\n ? fieldInformationRenderer({ model, field })\n : defaultInformationRenderer()}\n <DropdownMenu\n trigger={\n <IconButton icon={<MoreVerticalIcon />} variant={\"ghost\"} size={\"sm\"} />\n }\n >\n {canEdit && (\n <DropdownMenu.Item\n onClick={() => onEdit(field)}\n text={t`Edit`}\n icon={\n <DropdownMenu.Item.Icon\n element={<EditIcon />}\n label={t`Edit field`}\n />\n }\n />\n )}\n {editorFieldOptionPlugins.map(pl =>\n React.cloneElement(pl.render(), { key: pl.name })\n )}\n {/* We only allow this action for top-level fields. */}\n <DropdownMenu.Item\n disabled={!isFieldAllowedToBeTitle(model, field, parent)}\n onClick={setAsTitle}\n text={t`Use as title`}\n icon={\n <DropdownMenu.Item.Icon\n element={<TitleIcon />}\n label={t`Use as title`}\n />\n }\n />\n <DropdownMenu.Item\n disabled={!isFieldAllowedToBeDescription(model, field, parent)}\n onClick={setAsDescription}\n text={t`Use as description`}\n icon={\n <DropdownMenu.Item.Icon\n element={<TitleIcon />}\n label={t`Use as description`}\n />\n }\n />\n <DropdownMenu.Item\n disabled={!isFieldAllowedToBeImage(model, field, parent)}\n onClick={setAsImage}\n text={t`Use as image`}\n icon={\n <DropdownMenu.Item.Icon\n element={<TitleIcon />}\n label={t`Use as image`}\n />\n }\n />\n <DropdownMenu.Item\n onClick={onDelete}\n text={t`Delete`}\n icon={\n <DropdownMenu.Item.Icon\n element={<DeleteIcon />}\n label={t`Delete`}\n />\n }\n variant={\"destructive\"}\n />\n </DropdownMenu>\n </div>\n </div>\n {fieldType.renderEditor && (\n <div className={\"pt-md\"}>{fieldType.renderEditor({ field, model })}</div>\n )}\n </Fragment>\n );\n};\n\nexport default React.memo(Field);\n"],"names":["t","i18n","allowedTitleFieldTypes","isFieldAllowedToBeTitle","model","field","parent","isFieldAllowedToBeDescription","isFieldAllowedToBeImage","getFieldTypeName","isTitleField","isDescriptionField","isImageField","Boolean","Field","props","onEdit","showSnackbar","showErrorSnackbar","useSnackbar","setModel","useModelEditor","getFieldType","getFieldRenderer","useModelFieldEditor","removeFieldFromSelected","useCallback","data","onDelete","setAsTitle","response","setAsDescription","setAsImage","fieldType","editorFieldOptionPlugins","plugins","renderer","canEdit","defaultInformationRenderer","useMemo","fieldTypeName","fn","Tag","capitalize","fieldInformationRenderer","info","Fragment","Icon","Text","DropdownMenu","IconButton","MoreVerticalIcon","EditIcon","pl","React","TitleIcon","DeleteIcon"],"mappings":";;;;;;;;;;;;AAcA,MAAMA,IAAIC,KAAK,EAAE,CAAC;AAElB,MAAMC,yBAAmC;IAAC;IAAQ;CAAS;AAE3D,MAAMC,0BAA0B,CAACC,OAAiBC,OAAsBC;IACpE,IAAID,MAAM,IAAI,IAAIC,QACd,OAAO;IACJ,IAAIJ,AAAgD,UAAhDA,uBAAuB,QAAQ,CAACG,MAAM,IAAI,GACjD,OAAO;IACJ,IAAID,MAAM,YAAY,KAAKC,MAAM,OAAO,EAC3C,OAAO;IAEX,OAAO;AACX;AACA,MAAME,gCAAgC,CAClCH,OACAC,OACAC;IAEA,IAAID,MAAM,IAAI,IAAIC,QACd,OAAO;IACJ,IAAIF,MAAM,kBAAkB,KAAKC,MAAM,OAAO,EACjD,OAAO;IAEX,OAAOA,AAAe,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AAIhF;AAEA,wCAAekD,MAAAA,IAAU,CAACxC"}
1
+ {"version":3,"file":"admin/components/FieldEditor/Field.js","sources":["../../../../src/admin/components/FieldEditor/Field.tsx"],"sourcesContent":["import React, { Fragment, useCallback, useMemo } from \"react\";\nimport capitalize from \"lodash/capitalize.js\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { ReactComponent as TitleIcon } from \"@webiny/icons/title.svg\";\nimport { ReactComponent as MoreVerticalIcon } from \"@webiny/icons/more_vert.svg\";\nimport { plugins } from \"@webiny/plugins\";\nimport type { CmsModelField, CmsEditorFieldOptionPlugin, CmsModel } from \"~/types.js\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { useModelEditor } from \"~/admin/hooks/index.js\";\nimport { useModelFieldEditor } from \"~/admin/components/FieldEditor/useModelFieldEditor.js\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { Icon, IconButton, Text, DropdownMenu, Tag } from \"@webiny/admin-ui\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/components/editor/field\");\n\nconst allowedTitleFieldTypes: string[] = [\"text\", \"number\"];\n\nconst isFieldAllowedToBeTitle = (model: CmsModel, field: CmsModelField, parent?: CmsModelField) => {\n if (field.list || parent) {\n return false;\n } else if (allowedTitleFieldTypes.includes(field.type) === false) {\n return false;\n } else if (model.titleFieldId === field.fieldId) {\n return false;\n }\n return true;\n};\nconst isFieldAllowedToBeDescription = (\n model: CmsModel,\n field: CmsModelField,\n parent?: CmsModelField\n) => {\n if (field.list || parent) {\n return false;\n } else if (model.descriptionFieldId === field.fieldId) {\n return false;\n }\n return field.type === \"long-text\";\n};\n\nconst isFieldAllowedToBeImage = (model: CmsModel, field: CmsModelField, parent?: CmsModelField) => {\n if (field.list || parent) {\n return false;\n } else if (model.imageFieldId === field.fieldId) {\n return false;\n }\n return field.type === \"file\" && field.settings?.imagesOnly;\n};\n\nconst getFieldTypeName = (\n model: CmsModel,\n field: CmsModelField,\n parent?: CmsModelField\n): string | null => {\n if (parent) {\n return null;\n }\n const isTitleField = field.fieldId === model?.titleFieldId && !parent;\n const isDescriptionField = field.fieldId === model?.descriptionFieldId && !parent;\n const isImageField = field.fieldId === model?.imageFieldId && !parent;\n\n return (\n [\n isTitleField ? \"entry title\" : null,\n isDescriptionField ? \"entry description\" : null,\n isImageField ? \"entry image\" : null\n ]\n .filter(Boolean)\n .join(\"\") || null\n );\n};\n\nexport interface FieldProps {\n field: CmsModelField;\n onDelete: (field: CmsModelField) => void;\n onEdit: (field: CmsModelField) => void;\n parent?: CmsModelField;\n}\n\nconst Field = (props: FieldProps) => {\n const { field, onEdit, parent } = props;\n const { showSnackbar, showErrorSnackbar } = useSnackbar();\n const { setData: setModel, data: model } = useModelEditor();\n const { getFieldType, getFieldRenderer } = useModelFieldEditor();\n\n const removeFieldFromSelected = useCallback(async () => {\n if (model.titleFieldId === field.fieldId) {\n await setModel(data => {\n return {\n ...data,\n titleFieldId: null\n };\n });\n } else if (model.descriptionFieldId === field.fieldId) {\n await setModel(data => {\n return {\n ...data,\n descriptionFieldId: null\n };\n });\n } else if (model.imageFieldId === field.fieldId) {\n await setModel(data => {\n return {\n ...data,\n imageFieldId: null\n };\n });\n }\n }, [field.id, setModel, model]);\n\n const onDelete = useCallback(async () => {\n await removeFieldFromSelected();\n props.onDelete(field);\n return;\n }, [field.fieldId]);\n\n const setAsTitle = useCallback(async (): Promise<void> => {\n const response = await setModel(data => {\n return { ...data, titleFieldId: field.fieldId };\n });\n\n if (response && response.error) {\n return showErrorSnackbar(response.error.message);\n }\n\n showSnackbar(t`Title field set successfully.`);\n }, [field.fieldId, setModel]);\n\n const setAsDescription = useCallback(async (): Promise<void> => {\n const response = await setModel(data => {\n return { ...data, descriptionFieldId: field.fieldId };\n });\n\n if (response && response.error) {\n return showErrorSnackbar(response.error.message);\n }\n\n showSnackbar(t`Description field set successfully.`);\n }, [field.fieldId, setModel]);\n\n const setAsImage = useCallback(async (): Promise<void> => {\n const response = await setModel(data => {\n return { ...data, imageFieldId: field.fieldId };\n });\n\n if (response && response.error) {\n return showErrorSnackbar(response.error.message);\n }\n\n showSnackbar(t`Image field set successfully.`);\n }, [field.fieldId, setModel]);\n\n const fieldType = getFieldType(field);\n const editorFieldOptionPlugins =\n plugins.byType<CmsEditorFieldOptionPlugin>(\"cms-editor-field-option\");\n\n if (!fieldType) {\n return null;\n }\n\n const renderer = getFieldRenderer(field.renderer.name);\n const canEdit = fieldType.canEditSettings !== false;\n\n const defaultInformationRenderer = useMemo(() => {\n const fieldTypeName = getFieldTypeName(model, field, parent);\n const fn = () => {\n if (!fieldTypeName) {\n return null;\n }\n return <Tag content={capitalize(fieldTypeName)} variant={\"neutral-light\"} />;\n };\n\n fn.displayName = \"FieldTypeRenderer\";\n\n return fn;\n }, [field.id]);\n\n const fieldInformationRenderer = fieldType.renderInfo;\n\n const info = [renderer?.name, field.list ? \"multiple values\" : null].filter(Boolean).join(\", \");\n\n return (\n <Fragment>\n <div className={\"flex items-center justify-between gap-sm-extra\"}>\n <div className={\"flex items-center gap-sm-extra flex-1 min-w-0\"}>\n <Icon\n icon={fieldType.icon}\n label={fieldType.label}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n <div className={\"flex flex-col gap-xxs min-w-0\"}>\n <span\n className={\n \"text-md font-semibold text-neutral-primary truncate leading-5\"\n }\n >\n {field.label}\n </span>\n <Text size={\"sm\"} className={\"text-neutral-muted truncate\"}>\n {fieldType.label}\n {info && <span> / {info}</span>}\n </Text>\n </div>\n </div>\n <div className={\"flex items-center justify-end gap-xs shrink-0\"}>\n {fieldInformationRenderer\n ? fieldInformationRenderer({ model, field })\n : defaultInformationRenderer()}\n <DropdownMenu\n trigger={\n <IconButton icon={<MoreVerticalIcon />} variant={\"ghost\"} size={\"sm\"} />\n }\n >\n {canEdit && (\n <DropdownMenu.Item\n onClick={() => onEdit(field)}\n text={t`Edit`}\n icon={\n <DropdownMenu.Item.Icon\n element={<EditIcon />}\n label={t`Edit field`}\n />\n }\n />\n )}\n {editorFieldOptionPlugins.map(pl =>\n React.cloneElement(pl.render(), { key: pl.name })\n )}\n {/* We only allow this action for top-level fields. */}\n <DropdownMenu.Item\n disabled={!isFieldAllowedToBeTitle(model, field, parent)}\n onClick={setAsTitle}\n text={t`Use as title`}\n icon={\n <DropdownMenu.Item.Icon\n element={<TitleIcon />}\n label={t`Use as title`}\n />\n }\n />\n <DropdownMenu.Item\n disabled={!isFieldAllowedToBeDescription(model, field, parent)}\n onClick={setAsDescription}\n text={t`Use as description`}\n icon={\n <DropdownMenu.Item.Icon\n element={<TitleIcon />}\n label={t`Use as description`}\n />\n }\n />\n <DropdownMenu.Item\n disabled={!isFieldAllowedToBeImage(model, field, parent)}\n onClick={setAsImage}\n text={t`Use as image`}\n icon={\n <DropdownMenu.Item.Icon\n element={<TitleIcon />}\n label={t`Use as image`}\n />\n }\n />\n <DropdownMenu.Item\n onClick={onDelete}\n text={t`Delete`}\n icon={\n <DropdownMenu.Item.Icon\n element={<DeleteIcon />}\n label={t`Delete`}\n />\n }\n variant={\"destructive\"}\n />\n </DropdownMenu>\n </div>\n </div>\n {fieldType.renderEditor && (\n <div className={\"pt-md\"}>{fieldType.renderEditor({ field, model })}</div>\n )}\n </Fragment>\n );\n};\n\nexport default React.memo(Field);\n"],"names":["t","i18n","allowedTitleFieldTypes","isFieldAllowedToBeTitle","model","field","parent","isFieldAllowedToBeDescription","isFieldAllowedToBeImage","getFieldTypeName","isTitleField","isDescriptionField","isImageField","Boolean","Field","props","onEdit","showSnackbar","showErrorSnackbar","useSnackbar","setModel","useModelEditor","getFieldType","getFieldRenderer","useModelFieldEditor","removeFieldFromSelected","useCallback","data","onDelete","setAsTitle","response","setAsDescription","setAsImage","fieldType","editorFieldOptionPlugins","plugins","renderer","canEdit","defaultInformationRenderer","useMemo","fieldTypeName","fn","Tag","capitalize","fieldInformationRenderer","info","Fragment","Icon","Text","DropdownMenu","IconButton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IxC,oBAACiD,aAAa,IAAI;QACd,UAAU,CAACzC,wBAAwBJ,OAAOC,OAAOC;QACjD,SAAS0B;QACT,MAAMhC,CAAC,CAAC,YAAY,CAAC;QACrB,oBACI,oBAACiD,aAAa,IAAI,CAAC,IAAI;YACnB,uBAAS,oBAACM,0BAASA;YACnB,OAAOvD,CAAC,CAAC,YAAY,CAAC;;sBAIlC,oBAACiD,aAAa,IAAI;QACd,SAASrB;QACT,MAAM5B,CAAC,CAAC,MAAM,CAAC;QACf,oBACI,oBAACiD,aAAa,IAAI,CAAC,IAAI;YACnB,uBAAS,oBAACO,2BAAUA;YACpB,OAAOxD,CAAC,CAAC,MAAM,CAAC;;QAGxB,SAAS;WAKxBiC,UAAU,YAAY,IAAI,WAAJ,GACnB,oBAAC;QAAI,WAAW;OAAUA,UAAU,YAAY,CAAC;QAAE5B;QAAOD;IAAM;AAIhF;AAEA,wCAAekD,MAAAA,IAAU,CAACxC"}
@@ -0,0 +1,10 @@
1
+ import type { CmsErrorResponse } from "../../types.js";
2
+ /**
3
+ * An error returned by the CMS API. Keeps the error `code` and `data` (e.g. the per-field
4
+ * list of a `Cms/Entry/ValidationError`) so the form can show what was rejected.
5
+ */
6
+ export declare class CmsEntryError extends Error {
7
+ readonly code: string | undefined;
8
+ readonly data: CmsErrorResponse["data"];
9
+ constructor(error: CmsErrorResponse | null | undefined, fallbackMessage: string);
10
+ }
@@ -0,0 +1,11 @@
1
+ class CmsEntryError extends Error {
2
+ constructor(error, fallbackMessage){
3
+ super(error?.message || fallbackMessage);
4
+ this.name = "CmsEntryError";
5
+ this.code = error?.code;
6
+ this.data = error?.data;
7
+ }
8
+ }
9
+ export { CmsEntryError };
10
+
11
+ //# sourceMappingURL=CmsEntryError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/contentEntry/CmsEntryError.js","sources":["../../../src/features/contentEntry/CmsEntryError.ts"],"sourcesContent":["import type { CmsErrorResponse } from \"~/types.js\";\n\n/**\n * An error returned by the CMS API. Keeps the error `code` and `data` (e.g. the per-field\n * list of a `Cms/Entry/ValidationError`) so the form can show what was rejected.\n */\nexport class CmsEntryError extends Error {\n public readonly code: string | undefined;\n public readonly data: CmsErrorResponse[\"data\"];\n\n public constructor(error: CmsErrorResponse | null | undefined, fallbackMessage: string) {\n super(error?.message || fallbackMessage);\n this.name = \"CmsEntryError\";\n this.code = error?.code;\n this.data = error?.data;\n }\n}\n"],"names":["CmsEntryError","Error","error","fallbackMessage"],"mappings":"AAMO,MAAMA,sBAAsBC;IAI/B,YAAmBC,KAA0C,EAAEC,eAAuB,CAAE;QACpF,KAAK,CAACD,OAAO,WAAWC;QACxB,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,IAAI,GAAGD,OAAO;QACnB,IAAI,CAAC,IAAI,GAAGA,OAAO;IACvB;AACJ"}
@@ -9,7 +9,6 @@ declare class CreateEntryGatewayImpl implements GatewayAbstraction.Interface {
9
9
  private fields;
10
10
  constructor(client: CmsGraphQLClient.Interface, preparer: EntryDataPreparer.Interface, fields: EntryGraphQLFields.Interface);
11
11
  execute({ model, data, options }: ICreateEntryGatewayParams): Promise<CmsContentEntry<import("@webiny/app/types.js").GenericRecord>>;
12
- private prepareData;
13
12
  }
14
13
  export declare const CreateEntryGateway: typeof CreateEntryGatewayImpl & {
15
14
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ICreateEntryGateway>;
@@ -2,6 +2,7 @@ import { CmsGraphQLClient } from "../../graphQLClient/abstractions.js";
2
2
  import { EntryGraphQLFields } from "../abstractions.js";
3
3
  import { CreateEntryGateway } from "./abstractions.js";
4
4
  import { EntryDataPreparer } from "../valueTransformers/EntryDataPreparer.js";
5
+ import { CmsEntryError } from "../CmsEntryError.js";
5
6
  function createMutation(model, fields) {
6
7
  return `
7
8
  mutation CmsEntriesCreate${model.singularApiName}($data: ${model.singularApiName}Input!, $options: CreateCmsEntryOptionsInput) {
@@ -22,7 +23,7 @@ class CreateEntryGatewayImpl {
22
23
  this.fields = fields;
23
24
  }
24
25
  async execute({ model, data, options }) {
25
- const preparedData = this.prepareData(data, model.fields);
26
+ const preparedData = this.preparer.prepareEntryData(data, model.fields);
26
27
  const response = await this.client.execute({
27
28
  query: createMutation(model, this.fields),
28
29
  variables: {
@@ -31,17 +32,9 @@ class CreateEntryGatewayImpl {
31
32
  }
32
33
  });
33
34
  const { data: entry, error } = response.content;
34
- if (!entry) throw new Error(error?.message || "Could not create entry");
35
+ if (!entry) throw new CmsEntryError(error, "Could not create entry");
35
36
  return entry;
36
37
  }
37
- prepareData(data, fields) {
38
- const values = data.values;
39
- if (!values || "object" != typeof values) return data;
40
- return {
41
- ...data,
42
- values: this.preparer.prepare(values, fields)
43
- };
44
- }
45
38
  }
46
39
  const CreateEntryGateway_CreateEntryGateway = CreateEntryGateway.createImplementation({
47
40
  implementation: CreateEntryGatewayImpl,
@@ -1 +1 @@
1
- {"version":3,"file":"features/contentEntry/createEntry/CreateEntryGateway.js","sources":["../../../../src/features/contentEntry/createEntry/CreateEntryGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel, CmsModelField } from \"~/types.js\";\nimport { EntryGraphQLFields } from \"../abstractions.js\";\nimport {\n CreateEntryGateway as GatewayAbstraction,\n type ICreateEntryGatewayParams\n} from \"./abstractions.js\";\nimport { EntryDataPreparer } from \"~/features/contentEntry/valueTransformers/EntryDataPreparer.js\";\n\ninterface CreateEntryResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel, fields: EntryGraphQLFields.Interface) {\n return /* GraphQL */ `\n mutation CmsEntriesCreate${model.singularApiName}($data: ${model.singularApiName}Input!, $options: CreateCmsEntryOptionsInput) {\n content: create${model.singularApiName}(data: $data, options: $options) {\n data {\n ${fields.getSystemFields(model)}\n ${fields.getValuesBlock(model)}\n }\n error { message code data }\n }\n }\n `;\n}\n\nclass CreateEntryGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: CmsGraphQLClient.Interface,\n private preparer: EntryDataPreparer.Interface,\n private fields: EntryGraphQLFields.Interface\n ) {}\n\n async execute({ model, data, options }: ICreateEntryGatewayParams) {\n const preparedData = this.prepareData(data, model.fields);\n\n const response = await this.client.execute<CreateEntryResponse>({\n query: createMutation(model, this.fields),\n variables: { data: preparedData, options }\n });\n\n const { data: entry, error } = response.content;\n\n if (!entry) {\n throw new Error(error?.message || \"Could not create entry\");\n }\n\n return entry;\n }\n\n private prepareData(\n data: Record<string, unknown>,\n fields: CmsModelField[]\n ): Record<string, unknown> {\n const values = data.values;\n if (!values || typeof values !== \"object\") {\n return data;\n }\n return {\n ...data,\n values: this.preparer.prepare(values as Record<string, unknown>, fields)\n };\n }\n}\n\nexport const CreateEntryGateway = GatewayAbstraction.createImplementation({\n implementation: CreateEntryGatewayImpl,\n dependencies: [CmsGraphQLClient, EntryDataPreparer, EntryGraphQLFields]\n});\n"],"names":["createMutation","model","fields","CreateEntryGatewayImpl","client","preparer","data","options","preparedData","response","entry","error","Error","values","CreateEntryGateway","GatewayAbstraction","CmsGraphQLClient","EntryDataPreparer","EntryGraphQLFields"],"mappings":";;;;AAgBA,SAASA,eAAeC,KAAe,EAAEC,MAAoC;IACzE,OAAqB,CAAC;iCACO,EAAED,MAAM,eAAe,CAAC,QAAQ,EAAEA,MAAM,eAAe,CAAC;2BAC9D,EAAEA,MAAM,eAAe,CAAC;;oBAE/B,EAAEC,OAAO,eAAe,CAACD,OAAO;oBAChC,EAAEC,OAAO,cAAc,CAACD,OAAO;;;;;IAK/C,CAAC;AACL;AAEA,MAAME;IACF,YACYC,MAAkC,EAClCC,QAAqC,EACrCH,MAAoC,CAC9C;aAHUE,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAH,MAAM,GAANA;IACT;IAEH,MAAM,QAAQ,EAAED,KAAK,EAAEK,IAAI,EAAEC,OAAO,EAA6B,EAAE;QAC/D,MAAMC,eAAe,IAAI,CAAC,WAAW,CAACF,MAAML,MAAM,MAAM;QAExD,MAAMQ,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAsB;YAC5D,OAAOT,eAAeC,OAAO,IAAI,CAAC,MAAM;YACxC,WAAW;gBAAE,MAAMO;gBAAcD;YAAQ;QAC7C;QAEA,MAAM,EAAE,MAAMG,KAAK,EAAEC,KAAK,EAAE,GAAGF,SAAS,OAAO;QAE/C,IAAI,CAACC,OACD,MAAM,IAAIE,MAAMD,OAAO,WAAW;QAGtC,OAAOD;IACX;IAEQ,YACJJ,IAA6B,EAC7BJ,MAAuB,EACA;QACvB,MAAMW,SAASP,KAAK,MAAM;QAC1B,IAAI,CAACO,UAAU,AAAkB,YAAlB,OAAOA,QAClB,OAAOP;QAEX,OAAO;YACH,GAAGA,IAAI;YACP,QAAQ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACO,QAAmCX;QACrE;IACJ;AACJ;AAEO,MAAMY,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBZ;IAChB,cAAc;QAACa;QAAkBC;QAAmBC;KAAmB;AAC3E"}
1
+ {"version":3,"file":"features/contentEntry/createEntry/CreateEntryGateway.js","sources":["../../../../src/features/contentEntry/createEntry/CreateEntryGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { EntryGraphQLFields } from \"../abstractions.js\";\nimport {\n CreateEntryGateway as GatewayAbstraction,\n type ICreateEntryGatewayParams\n} from \"./abstractions.js\";\nimport { EntryDataPreparer } from \"~/features/contentEntry/valueTransformers/EntryDataPreparer.js\";\nimport { CmsEntryError } from \"~/features/contentEntry/CmsEntryError.js\";\n\ninterface CreateEntryResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel, fields: EntryGraphQLFields.Interface) {\n return /* GraphQL */ `\n mutation CmsEntriesCreate${model.singularApiName}($data: ${model.singularApiName}Input!, $options: CreateCmsEntryOptionsInput) {\n content: create${model.singularApiName}(data: $data, options: $options) {\n data {\n ${fields.getSystemFields(model)}\n ${fields.getValuesBlock(model)}\n }\n error { message code data }\n }\n }\n `;\n}\n\nclass CreateEntryGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: CmsGraphQLClient.Interface,\n private preparer: EntryDataPreparer.Interface,\n private fields: EntryGraphQLFields.Interface\n ) {}\n\n async execute({ model, data, options }: ICreateEntryGatewayParams) {\n const preparedData = this.preparer.prepareEntryData(data, model.fields);\n\n const response = await this.client.execute<CreateEntryResponse>({\n query: createMutation(model, this.fields),\n variables: { data: preparedData, options }\n });\n\n const { data: entry, error } = response.content;\n\n if (!entry) {\n throw new CmsEntryError(error, \"Could not create entry\");\n }\n\n return entry;\n }\n}\n\nexport const CreateEntryGateway = GatewayAbstraction.createImplementation({\n implementation: CreateEntryGatewayImpl,\n dependencies: [CmsGraphQLClient, EntryDataPreparer, EntryGraphQLFields]\n});\n"],"names":["createMutation","model","fields","CreateEntryGatewayImpl","client","preparer","data","options","preparedData","response","entry","error","CmsEntryError","CreateEntryGateway","GatewayAbstraction","CmsGraphQLClient","EntryDataPreparer","EntryGraphQLFields"],"mappings":";;;;;AAiBA,SAASA,eAAeC,KAAe,EAAEC,MAAoC;IACzE,OAAqB,CAAC;iCACO,EAAED,MAAM,eAAe,CAAC,QAAQ,EAAEA,MAAM,eAAe,CAAC;2BAC9D,EAAEA,MAAM,eAAe,CAAC;;oBAE/B,EAAEC,OAAO,eAAe,CAACD,OAAO;oBAChC,EAAEC,OAAO,cAAc,CAACD,OAAO;;;;;IAK/C,CAAC;AACL;AAEA,MAAME;IACF,YACYC,MAAkC,EAClCC,QAAqC,EACrCH,MAAoC,CAC9C;aAHUE,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAH,MAAM,GAANA;IACT;IAEH,MAAM,QAAQ,EAAED,KAAK,EAAEK,IAAI,EAAEC,OAAO,EAA6B,EAAE;QAC/D,MAAMC,eAAe,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAACF,MAAML,MAAM,MAAM;QAEtE,MAAMQ,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAsB;YAC5D,OAAOT,eAAeC,OAAO,IAAI,CAAC,MAAM;YACxC,WAAW;gBAAE,MAAMO;gBAAcD;YAAQ;QAC7C;QAEA,MAAM,EAAE,MAAMG,KAAK,EAAEC,KAAK,EAAE,GAAGF,SAAS,OAAO;QAE/C,IAAI,CAACC,OACD,MAAM,IAAIE,cAAcD,OAAO;QAGnC,OAAOD;IACX;AACJ;AAEO,MAAMG,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBX;IAChB,cAAc;QAACY;QAAkBC;QAAmBC;KAAmB;AAC3E"}
@@ -2,10 +2,12 @@ import { CmsGraphQLClient } from "../../../features/graphQLClient/abstractions.j
2
2
  import type { CmsContentEntry } from "../../../types.js";
3
3
  import { EntryGraphQLFields } from "../abstractions.js";
4
4
  import { CreateRevisionFromGateway as GatewayAbstraction, type ICreateRevisionFromParams } from "./abstractions.js";
5
+ import { EntryDataPreparer } from "../../../features/contentEntry/valueTransformers/EntryDataPreparer.js";
5
6
  declare class CreateRevisionFromGatewayImpl implements GatewayAbstraction.Interface {
6
7
  private client;
8
+ private preparer;
7
9
  private fields;
8
- constructor(client: CmsGraphQLClient.Interface, fields: EntryGraphQLFields.Interface);
10
+ constructor(client: CmsGraphQLClient.Interface, preparer: EntryDataPreparer.Interface, fields: EntryGraphQLFields.Interface);
9
11
  execute({ model, revisionId, data, options }: ICreateRevisionFromParams): Promise<CmsContentEntry<import("@webiny/app/types.js").GenericRecord>>;
10
12
  }
11
13
  export declare const CreateRevisionFromGateway: typeof CreateRevisionFromGatewayImpl & {
@@ -1,6 +1,8 @@
1
1
  import { CmsGraphQLClient } from "../../graphQLClient/abstractions.js";
2
2
  import { EntryGraphQLFields } from "../abstractions.js";
3
3
  import { CreateRevisionFromGateway } from "./abstractions.js";
4
+ import { EntryDataPreparer } from "../valueTransformers/EntryDataPreparer.js";
5
+ import { CmsEntryError } from "../CmsEntryError.js";
4
6
  function createMutation(model, fields) {
5
7
  return `
6
8
  mutation CmsCreate${model.singularApiName}From($revision: ID!, $data: ${model.singularApiName}Input, $options: CreateRevisionCmsEntryOptionsInput) {
@@ -14,21 +16,23 @@ function createMutation(model, fields) {
14
16
  }`;
15
17
  }
16
18
  class CreateRevisionFromGatewayImpl {
17
- constructor(client, fields){
19
+ constructor(client, preparer, fields){
18
20
  this.client = client;
21
+ this.preparer = preparer;
19
22
  this.fields = fields;
20
23
  }
21
24
  async execute({ model, revisionId, data, options }) {
25
+ const preparedData = data ? this.preparer.prepareEntryData(data, model.fields) : data;
22
26
  const response = await this.client.execute({
23
27
  query: createMutation(model, this.fields),
24
28
  variables: {
25
29
  revision: revisionId,
26
- data,
30
+ data: preparedData,
27
31
  options
28
32
  }
29
33
  });
30
34
  const { data: entry, error } = response.content;
31
- if (!entry) throw new Error(error?.message || "Could not create revision");
35
+ if (!entry) throw new CmsEntryError(error, "Could not create revision");
32
36
  return entry;
33
37
  }
34
38
  }
@@ -36,6 +40,7 @@ const CreateRevisionFromGateway_CreateRevisionFromGateway = CreateRevisionFromGa
36
40
  implementation: CreateRevisionFromGatewayImpl,
37
41
  dependencies: [
38
42
  CmsGraphQLClient,
43
+ EntryDataPreparer,
39
44
  EntryGraphQLFields
40
45
  ]
41
46
  });
@@ -1 +1 @@
1
- {"version":3,"file":"features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js","sources":["../../../../src/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { EntryGraphQLFields } from \"../abstractions.js\";\nimport {\n CreateRevisionFromGateway as GatewayAbstraction,\n type ICreateRevisionFromParams\n} from \"./abstractions.js\";\n\ninterface CreateRevisionFromResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel, fields: EntryGraphQLFields.Interface) {\n return /* GraphQL */ `\n mutation CmsCreate${model.singularApiName}From($revision: ID!, $data: ${model.singularApiName}Input, $options: CreateRevisionCmsEntryOptionsInput) {\n content: create${model.singularApiName}From(revision: $revision, data: $data, options: $options) {\n data {\n ${fields.getSystemFields(model)}\n ${fields.getValuesBlock(model)}\n }\n error { message code data }\n }\n }`;\n}\n\nclass CreateRevisionFromGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: CmsGraphQLClient.Interface,\n private fields: EntryGraphQLFields.Interface\n ) {}\n\n async execute({ model, revisionId, data, options }: ICreateRevisionFromParams) {\n const response = await this.client.execute<CreateRevisionFromResponse>({\n query: createMutation(model, this.fields),\n variables: { revision: revisionId, data, options }\n });\n\n const { data: entry, error } = response.content;\n\n if (!entry) {\n throw new Error(error?.message || \"Could not create revision\");\n }\n\n return entry;\n }\n}\n\nexport const CreateRevisionFromGateway = GatewayAbstraction.createImplementation({\n implementation: CreateRevisionFromGatewayImpl,\n dependencies: [CmsGraphQLClient, EntryGraphQLFields]\n});\n"],"names":["createMutation","model","fields","CreateRevisionFromGatewayImpl","client","revisionId","data","options","response","entry","error","Error","CreateRevisionFromGateway","GatewayAbstraction","CmsGraphQLClient","EntryGraphQLFields"],"mappings":";;;AAeA,SAASA,eAAeC,KAAe,EAAEC,MAAoC;IACzE,OAAqB,CAAC;0BACA,EAAED,MAAM,eAAe,CAAC,4BAA4B,EAAEA,MAAM,eAAe,CAAC;2BAC3E,EAAEA,MAAM,eAAe,CAAC;;oBAE/B,EAAEC,OAAO,eAAe,CAACD,OAAO;oBAChC,EAAEC,OAAO,cAAc,CAACD,OAAO;;;;SAI1C,CAAC;AACV;AAEA,MAAME;IACF,YACYC,MAAkC,EAClCF,MAAoC,CAC9C;aAFUE,MAAM,GAANA;aACAF,MAAM,GAANA;IACT;IAEH,MAAM,QAAQ,EAAED,KAAK,EAAEI,UAAU,EAAEC,IAAI,EAAEC,OAAO,EAA6B,EAAE;QAC3E,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA6B;YACnE,OAAOR,eAAeC,OAAO,IAAI,CAAC,MAAM;YACxC,WAAW;gBAAE,UAAUI;gBAAYC;gBAAMC;YAAQ;QACrD;QAEA,MAAM,EAAE,MAAME,KAAK,EAAEC,KAAK,EAAE,GAAGF,SAAS,OAAO;QAE/C,IAAI,CAACC,OACD,MAAM,IAAIE,MAAMD,OAAO,WAAW;QAGtC,OAAOD;IACX;AACJ;AAEO,MAAMG,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBV;IAChB,cAAc;QAACW;QAAkBC;KAAmB;AACxD"}
1
+ {"version":3,"file":"features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js","sources":["../../../../src/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { EntryGraphQLFields } from \"../abstractions.js\";\nimport {\n CreateRevisionFromGateway as GatewayAbstraction,\n type ICreateRevisionFromParams\n} from \"./abstractions.js\";\nimport { EntryDataPreparer } from \"~/features/contentEntry/valueTransformers/EntryDataPreparer.js\";\nimport { CmsEntryError } from \"~/features/contentEntry/CmsEntryError.js\";\n\ninterface CreateRevisionFromResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel, fields: EntryGraphQLFields.Interface) {\n return /* GraphQL */ `\n mutation CmsCreate${model.singularApiName}From($revision: ID!, $data: ${model.singularApiName}Input, $options: CreateRevisionCmsEntryOptionsInput) {\n content: create${model.singularApiName}From(revision: $revision, data: $data, options: $options) {\n data {\n ${fields.getSystemFields(model)}\n ${fields.getValuesBlock(model)}\n }\n error { message code data }\n }\n }`;\n}\n\nclass CreateRevisionFromGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: CmsGraphQLClient.Interface,\n private preparer: EntryDataPreparer.Interface,\n private fields: EntryGraphQLFields.Interface\n ) {}\n\n async execute({ model, revisionId, data, options }: ICreateRevisionFromParams) {\n const preparedData = data ? this.preparer.prepareEntryData(data, model.fields) : data;\n\n const response = await this.client.execute<CreateRevisionFromResponse>({\n query: createMutation(model, this.fields),\n variables: { revision: revisionId, data: preparedData, options }\n });\n\n const { data: entry, error } = response.content;\n\n if (!entry) {\n throw new CmsEntryError(error, \"Could not create revision\");\n }\n\n return entry;\n }\n}\n\nexport const CreateRevisionFromGateway = GatewayAbstraction.createImplementation({\n implementation: CreateRevisionFromGatewayImpl,\n dependencies: [CmsGraphQLClient, EntryDataPreparer, EntryGraphQLFields]\n});\n"],"names":["createMutation","model","fields","CreateRevisionFromGatewayImpl","client","preparer","revisionId","data","options","preparedData","response","entry","error","CmsEntryError","CreateRevisionFromGateway","GatewayAbstraction","CmsGraphQLClient","EntryDataPreparer","EntryGraphQLFields"],"mappings":";;;;;AAiBA,SAASA,eAAeC,KAAe,EAAEC,MAAoC;IACzE,OAAqB,CAAC;0BACA,EAAED,MAAM,eAAe,CAAC,4BAA4B,EAAEA,MAAM,eAAe,CAAC;2BAC3E,EAAEA,MAAM,eAAe,CAAC;;oBAE/B,EAAEC,OAAO,eAAe,CAACD,OAAO;oBAChC,EAAEC,OAAO,cAAc,CAACD,OAAO;;;;SAI1C,CAAC;AACV;AAEA,MAAME;IACF,YACYC,MAAkC,EAClCC,QAAqC,EACrCH,MAAoC,CAC9C;aAHUE,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAH,MAAM,GAANA;IACT;IAEH,MAAM,QAAQ,EAAED,KAAK,EAAEK,UAAU,EAAEC,IAAI,EAAEC,OAAO,EAA6B,EAAE;QAC3E,MAAMC,eAAeF,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAACA,MAAMN,MAAM,MAAM,IAAIM;QAEjF,MAAMG,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA6B;YACnE,OAAOV,eAAeC,OAAO,IAAI,CAAC,MAAM;YACxC,WAAW;gBAAE,UAAUK;gBAAY,MAAMG;gBAAcD;YAAQ;QACnE;QAEA,MAAM,EAAE,MAAMG,KAAK,EAAEC,KAAK,EAAE,GAAGF,SAAS,OAAO;QAE/C,IAAI,CAACC,OACD,MAAM,IAAIE,cAAcD,OAAO;QAGnC,OAAOD;IACX;AACJ;AAEO,MAAMG,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBZ;IAChB,cAAc;QAACa;QAAkBC;QAAmBC;KAAmB;AAC3E"}
@@ -0,0 +1,14 @@
1
+ import { CmsGraphQLClient } from "../../../features/graphQLClient/abstractions.js";
2
+ import type { CmsContentEntry } from "../../../types.js";
3
+ import { EntryGraphQLFields } from "../abstractions.js";
4
+ import { DuplicateEntryGateway as GatewayAbstraction, type IDuplicateEntryParams } from "./abstractions.js";
5
+ declare class DuplicateEntryGatewayImpl implements GatewayAbstraction.Interface {
6
+ private client;
7
+ private fields;
8
+ constructor(client: CmsGraphQLClient.Interface, fields: EntryGraphQLFields.Interface);
9
+ execute({ model, revisionId }: IDuplicateEntryParams): Promise<CmsContentEntry<import("@webiny/app/types.js").GenericRecord>>;
10
+ }
11
+ export declare const DuplicateEntryGateway: typeof DuplicateEntryGatewayImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IDuplicateEntryGateway>;
13
+ };
14
+ export {};
@@ -0,0 +1,43 @@
1
+ import { CmsGraphQLClient } from "../../graphQLClient/abstractions.js";
2
+ import { EntryGraphQLFields } from "../abstractions.js";
3
+ import { DuplicateEntryGateway } from "./abstractions.js";
4
+ function createMutation(model, fields) {
5
+ return `
6
+ mutation CmsEntriesDuplicate${model.singularApiName}($revision: ID!) {
7
+ content: duplicate${model.singularApiName}(revision: $revision) {
8
+ data {
9
+ ${fields.getSystemFields(model)}
10
+ ${fields.getValuesBlock(model)}
11
+ }
12
+ error { message code data }
13
+ }
14
+ }
15
+ `;
16
+ }
17
+ class DuplicateEntryGatewayImpl {
18
+ constructor(client, fields){
19
+ this.client = client;
20
+ this.fields = fields;
21
+ }
22
+ async execute({ model, revisionId }) {
23
+ const response = await this.client.execute({
24
+ query: createMutation(model, this.fields),
25
+ variables: {
26
+ revision: revisionId
27
+ }
28
+ });
29
+ const { data: entry, error } = response.content;
30
+ if (!entry) throw new Error(error?.message || "Could not duplicate entry");
31
+ return entry;
32
+ }
33
+ }
34
+ const DuplicateEntryGateway_DuplicateEntryGateway = DuplicateEntryGateway.createImplementation({
35
+ implementation: DuplicateEntryGatewayImpl,
36
+ dependencies: [
37
+ CmsGraphQLClient,
38
+ EntryGraphQLFields
39
+ ]
40
+ });
41
+ export { DuplicateEntryGateway_DuplicateEntryGateway as DuplicateEntryGateway };
42
+
43
+ //# sourceMappingURL=DuplicateEntryGateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/contentEntry/duplicateEntry/DuplicateEntryGateway.js","sources":["../../../../src/features/contentEntry/duplicateEntry/DuplicateEntryGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { EntryGraphQLFields } from \"../abstractions.js\";\nimport {\n DuplicateEntryGateway as GatewayAbstraction,\n type IDuplicateEntryParams\n} from \"./abstractions.js\";\n\ninterface DuplicateEntryResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel, fields: EntryGraphQLFields.Interface) {\n return /* GraphQL */ `\n mutation CmsEntriesDuplicate${model.singularApiName}($revision: ID!) {\n content: duplicate${model.singularApiName}(revision: $revision) {\n data {\n ${fields.getSystemFields(model)}\n ${fields.getValuesBlock(model)}\n }\n error { message code data }\n }\n }\n `;\n}\n\nclass DuplicateEntryGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: CmsGraphQLClient.Interface,\n private fields: EntryGraphQLFields.Interface\n ) {}\n\n async execute({ model, revisionId }: IDuplicateEntryParams) {\n const response = await this.client.execute<DuplicateEntryResponse>({\n query: createMutation(model, this.fields),\n variables: { revision: revisionId }\n });\n\n const { data: entry, error } = response.content;\n\n if (!entry) {\n throw new Error(error?.message || \"Could not duplicate entry\");\n }\n\n return entry;\n }\n}\n\nexport const DuplicateEntryGateway = GatewayAbstraction.createImplementation({\n implementation: DuplicateEntryGatewayImpl,\n dependencies: [CmsGraphQLClient, EntryGraphQLFields]\n});\n"],"names":["createMutation","model","fields","DuplicateEntryGatewayImpl","client","revisionId","response","entry","error","Error","DuplicateEntryGateway","GatewayAbstraction","CmsGraphQLClient","EntryGraphQLFields"],"mappings":";;;AAeA,SAASA,eAAeC,KAAe,EAAEC,MAAoC;IACzE,OAAqB,CAAC;oCACU,EAAED,MAAM,eAAe,CAAC;8BAC9B,EAAEA,MAAM,eAAe,CAAC;;oBAElC,EAAEC,OAAO,eAAe,CAACD,OAAO;oBAChC,EAAEC,OAAO,cAAc,CAACD,OAAO;;;;;IAK/C,CAAC;AACL;AAEA,MAAME;IACF,YACYC,MAAkC,EAClCF,MAAoC,CAC9C;aAFUE,MAAM,GAANA;aACAF,MAAM,GAANA;IACT;IAEH,MAAM,QAAQ,EAAED,KAAK,EAAEI,UAAU,EAAyB,EAAE;QACxD,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAyB;YAC/D,OAAON,eAAeC,OAAO,IAAI,CAAC,MAAM;YACxC,WAAW;gBAAE,UAAUI;YAAW;QACtC;QAEA,MAAM,EAAE,MAAME,KAAK,EAAEC,KAAK,EAAE,GAAGF,SAAS,OAAO;QAE/C,IAAI,CAACC,OACD,MAAM,IAAIE,MAAMD,OAAO,WAAW;QAGtC,OAAOD;IACX;AACJ;AAEO,MAAMG,8CAAwBC,sBAAAA,oBAAuC,CAAC;IACzE,gBAAgBR;IAChB,cAAc;QAACS;QAAkBC;KAAmB;AACxD"}
@@ -0,0 +1,15 @@
1
+ import { DuplicateEntryRepository as RepositoryAbstraction, DuplicateEntryGateway } from "./abstractions.js";
2
+ import type { IDuplicateEntryParams } from "./abstractions.js";
3
+ import { ContentEntriesCacheProvider } from "../../../features/contentEntry/abstractions.js";
4
+ import { EventPublisher } from "@webiny/app/features/eventPublisher/index.js";
5
+ declare class DuplicateEntryRepositoryImpl implements RepositoryAbstraction.Interface {
6
+ private cacheProvider;
7
+ private gateway;
8
+ private eventPublisher;
9
+ constructor(cacheProvider: ContentEntriesCacheProvider.Interface, gateway: DuplicateEntryGateway.Interface, eventPublisher: EventPublisher.Interface);
10
+ execute(params: IDuplicateEntryParams): Promise<import("@webiny/app-headless-cms-common/types/index.js").CmsContentEntry<import("@webiny/app/types.js").GenericRecord>>;
11
+ }
12
+ export declare const DuplicateEntryRepository: typeof DuplicateEntryRepositoryImpl & {
13
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IDuplicateEntryRepository>;
14
+ };
15
+ export {};
@@ -0,0 +1,34 @@
1
+ import { DuplicateEntryGateway, DuplicateEntryRepository } from "./abstractions.js";
2
+ import { ContentEntriesCacheProvider } from "../abstractions.js";
3
+ import { EventPublisher } from "@webiny/app/features/eventPublisher/index.js";
4
+ import { EntryAfterCreateEvent } from "../events/EntryAfterCreateEvent.js";
5
+ class DuplicateEntryRepositoryImpl {
6
+ constructor(cacheProvider, gateway, eventPublisher){
7
+ this.cacheProvider = cacheProvider;
8
+ this.gateway = gateway;
9
+ this.eventPublisher = eventPublisher;
10
+ }
11
+ async execute(params) {
12
+ const entry = await this.gateway.execute(params);
13
+ const cache = this.cacheProvider.get(params.model.modelId);
14
+ cache.addItems([
15
+ entry
16
+ ]);
17
+ await this.eventPublisher.publish(new EntryAfterCreateEvent({
18
+ entry,
19
+ model: params.model
20
+ }));
21
+ return entry;
22
+ }
23
+ }
24
+ const DuplicateEntryRepository_DuplicateEntryRepository = DuplicateEntryRepository.createImplementation({
25
+ implementation: DuplicateEntryRepositoryImpl,
26
+ dependencies: [
27
+ ContentEntriesCacheProvider,
28
+ DuplicateEntryGateway,
29
+ EventPublisher
30
+ ]
31
+ });
32
+ export { DuplicateEntryRepository_DuplicateEntryRepository as DuplicateEntryRepository };
33
+
34
+ //# sourceMappingURL=DuplicateEntryRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/contentEntry/duplicateEntry/DuplicateEntryRepository.js","sources":["../../../../src/features/contentEntry/duplicateEntry/DuplicateEntryRepository.ts"],"sourcesContent":["import {\n DuplicateEntryRepository as RepositoryAbstraction,\n DuplicateEntryGateway\n} from \"./abstractions.js\";\nimport type { IDuplicateEntryParams } from \"./abstractions.js\";\nimport { ContentEntriesCacheProvider } from \"~/features/contentEntry/abstractions.js\";\nimport { EventPublisher } from \"@webiny/app/features/eventPublisher/index.js\";\nimport { EntryAfterCreateEvent } from \"~/features/contentEntry/events/EntryAfterCreateEvent.js\";\n\nclass DuplicateEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private cacheProvider: ContentEntriesCacheProvider.Interface,\n private gateway: DuplicateEntryGateway.Interface,\n private eventPublisher: EventPublisher.Interface\n ) {}\n\n async execute(params: IDuplicateEntryParams) {\n const entry = await this.gateway.execute(params);\n\n const cache = this.cacheProvider.get(params.model.modelId);\n cache.addItems([entry]);\n\n // Duplicating results in a brand-new entry, so we notify the same listeners as on create.\n await this.eventPublisher.publish(\n new EntryAfterCreateEvent({ entry, model: params.model })\n );\n\n return entry;\n }\n}\n\nexport const DuplicateEntryRepository = RepositoryAbstraction.createImplementation({\n implementation: DuplicateEntryRepositoryImpl,\n dependencies: [ContentEntriesCacheProvider, DuplicateEntryGateway, EventPublisher]\n});\n"],"names":["DuplicateEntryRepositoryImpl","cacheProvider","gateway","eventPublisher","params","entry","cache","EntryAfterCreateEvent","DuplicateEntryRepository","RepositoryAbstraction","ContentEntriesCacheProvider","DuplicateEntryGateway","EventPublisher"],"mappings":";;;;AASA,MAAMA;IACF,YACYC,aAAoD,EACpDC,OAAwC,EACxCC,cAAwC,CAClD;aAHUF,aAAa,GAAbA;aACAC,OAAO,GAAPA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQC,MAA6B,EAAE;QACzC,MAAMC,QAAQ,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAACD;QAEzC,MAAME,QAAQ,IAAI,CAAC,aAAa,CAAC,GAAG,CAACF,OAAO,KAAK,CAAC,OAAO;QACzDE,MAAM,QAAQ,CAAC;YAACD;SAAM;QAGtB,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIE,sBAAsB;YAAEF;YAAO,OAAOD,OAAO,KAAK;QAAC;QAG3D,OAAOC;IACX;AACJ;AAEO,MAAMG,oDAA2BC,yBAAAA,oBAA0C,CAAC;IAC/E,gBAAgBT;IAChB,cAAc;QAACU;QAA6BC;QAAuBC;KAAe;AACtF"}
@@ -0,0 +1,11 @@
1
+ import { DuplicateEntryUseCase as UseCaseAbstraction, DuplicateEntryRepository } from "./abstractions.js";
2
+ import type { IDuplicateEntryParams } from "./abstractions.js";
3
+ declare class DuplicateEntryUseCaseImpl implements UseCaseAbstraction.Interface {
4
+ private repository;
5
+ constructor(repository: DuplicateEntryRepository.Interface);
6
+ execute(params: IDuplicateEntryParams): Promise<import("@webiny/app-headless-cms-common/types/index.js").CmsContentEntry<import("@webiny/app/types.js").GenericRecord>>;
7
+ }
8
+ export declare const DuplicateEntryUseCase: typeof DuplicateEntryUseCaseImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IDuplicateEntryUseCase>;
10
+ };
11
+ export {};
@@ -0,0 +1,18 @@
1
+ import { DuplicateEntryRepository, DuplicateEntryUseCase } from "./abstractions.js";
2
+ class DuplicateEntryUseCaseImpl {
3
+ constructor(repository){
4
+ this.repository = repository;
5
+ }
6
+ async execute(params) {
7
+ return this.repository.execute(params);
8
+ }
9
+ }
10
+ const DuplicateEntryUseCase_DuplicateEntryUseCase = DuplicateEntryUseCase.createImplementation({
11
+ implementation: DuplicateEntryUseCaseImpl,
12
+ dependencies: [
13
+ DuplicateEntryRepository
14
+ ]
15
+ });
16
+ export { DuplicateEntryUseCase_DuplicateEntryUseCase as DuplicateEntryUseCase };
17
+
18
+ //# sourceMappingURL=DuplicateEntryUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js","sources":["../../../../src/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.ts"],"sourcesContent":["import {\n DuplicateEntryUseCase as UseCaseAbstraction,\n DuplicateEntryRepository\n} from \"./abstractions.js\";\nimport type { IDuplicateEntryParams } from \"./abstractions.js\";\n\nclass DuplicateEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(private repository: DuplicateEntryRepository.Interface) {}\n\n async execute(params: IDuplicateEntryParams) {\n return this.repository.execute(params);\n }\n}\n\nexport const DuplicateEntryUseCase = UseCaseAbstraction.createImplementation({\n implementation: DuplicateEntryUseCaseImpl,\n dependencies: [DuplicateEntryRepository]\n});\n"],"names":["DuplicateEntryUseCaseImpl","repository","params","DuplicateEntryUseCase","UseCaseAbstraction","DuplicateEntryRepository"],"mappings":";AAMA,MAAMA;IACF,YAAoBC,UAA8C,CAAE;aAAhDA,UAAU,GAAVA;IAAiD;IAErE,MAAM,QAAQC,MAA6B,EAAE;QACzC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAACA;IACnC;AACJ;AAEO,MAAMC,8CAAwBC,sBAAAA,oBAAuC,CAAC;IACzE,gBAAgBJ;IAChB,cAAc;QAACK;KAAyB;AAC5C"}
@@ -0,0 +1,26 @@
1
+ import type { CmsContentEntry, CmsModel } from "../../../types.js";
2
+ export interface IDuplicateEntryParams {
3
+ model: CmsModel;
4
+ revisionId: string;
5
+ }
6
+ export interface IDuplicateEntryGateway {
7
+ execute(params: IDuplicateEntryParams): Promise<CmsContentEntry>;
8
+ }
9
+ export declare const DuplicateEntryGateway: import("@webiny/di").Abstraction<IDuplicateEntryGateway>;
10
+ export declare namespace DuplicateEntryGateway {
11
+ type Interface = IDuplicateEntryGateway;
12
+ }
13
+ export interface IDuplicateEntryRepository {
14
+ execute(params: IDuplicateEntryParams): Promise<CmsContentEntry>;
15
+ }
16
+ export declare const DuplicateEntryRepository: import("@webiny/di").Abstraction<IDuplicateEntryRepository>;
17
+ export declare namespace DuplicateEntryRepository {
18
+ type Interface = IDuplicateEntryRepository;
19
+ }
20
+ export interface IDuplicateEntryUseCase {
21
+ execute(params: IDuplicateEntryParams): Promise<CmsContentEntry>;
22
+ }
23
+ export declare const DuplicateEntryUseCase: import("@webiny/di").Abstraction<IDuplicateEntryUseCase>;
24
+ export declare namespace DuplicateEntryUseCase {
25
+ type Interface = IDuplicateEntryUseCase;
26
+ }
@@ -0,0 +1,7 @@
1
+ import { createAbstraction } from "@webiny/feature/admin";
2
+ const DuplicateEntryGateway = createAbstraction("DuplicateEntryGateway");
3
+ const DuplicateEntryRepository = createAbstraction("DuplicateEntryRepository");
4
+ const DuplicateEntryUseCase = createAbstraction("DuplicateEntryUseCase");
5
+ export { DuplicateEntryGateway, DuplicateEntryRepository, DuplicateEntryUseCase };
6
+
7
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/contentEntry/duplicateEntry/abstractions.js","sources":["../../../../src/features/contentEntry/duplicateEntry/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { CmsContentEntry, CmsModel } from \"~/types.js\";\n\nexport interface IDuplicateEntryParams {\n model: CmsModel;\n revisionId: string;\n}\n\n// Gateway\n\nexport interface IDuplicateEntryGateway {\n execute(params: IDuplicateEntryParams): Promise<CmsContentEntry>;\n}\n\nexport const DuplicateEntryGateway =\n createAbstraction<IDuplicateEntryGateway>(\"DuplicateEntryGateway\");\n\nexport namespace DuplicateEntryGateway {\n export type Interface = IDuplicateEntryGateway;\n}\n\n// Repository\n\nexport interface IDuplicateEntryRepository {\n execute(params: IDuplicateEntryParams): Promise<CmsContentEntry>;\n}\n\nexport const DuplicateEntryRepository = createAbstraction<IDuplicateEntryRepository>(\n \"DuplicateEntryRepository\"\n);\n\nexport namespace DuplicateEntryRepository {\n export type Interface = IDuplicateEntryRepository;\n}\n\n// UseCase\n\nexport interface IDuplicateEntryUseCase {\n execute(params: IDuplicateEntryParams): Promise<CmsContentEntry>;\n}\n\nexport const DuplicateEntryUseCase =\n createAbstraction<IDuplicateEntryUseCase>(\"DuplicateEntryUseCase\");\n\nexport namespace DuplicateEntryUseCase {\n export type Interface = IDuplicateEntryUseCase;\n}\n"],"names":["DuplicateEntryGateway","createAbstraction","DuplicateEntryRepository","DuplicateEntryUseCase"],"mappings":";AAcO,MAAMA,wBACTC,kBAA0C;AAYvC,MAAMC,2BAA2BD,kBACpC;AAaG,MAAME,wBACTF,kBAA0C"}
@@ -0,0 +1,3 @@
1
+ export declare const DuplicateEntryFeature: import("@webiny/feature/admin").FeatureDefinition<{
2
+ useCase: import("./abstractions.js").IDuplicateEntryUseCase;
3
+ }, []>;
@@ -0,0 +1,21 @@
1
+ import { createFeature } from "@webiny/feature/admin";
2
+ import { DuplicateEntryUseCase } from "./abstractions.js";
3
+ import { DuplicateEntryUseCase as external_DuplicateEntryUseCase_js_DuplicateEntryUseCase } from "./DuplicateEntryUseCase.js";
4
+ import { DuplicateEntryRepository } from "./DuplicateEntryRepository.js";
5
+ import { DuplicateEntryGateway } from "./DuplicateEntryGateway.js";
6
+ const DuplicateEntryFeature = createFeature({
7
+ name: "CmsContentEntry/DuplicateEntry",
8
+ register (container) {
9
+ container.register(external_DuplicateEntryUseCase_js_DuplicateEntryUseCase);
10
+ container.register(DuplicateEntryRepository).inSingletonScope();
11
+ container.register(DuplicateEntryGateway).inSingletonScope();
12
+ },
13
+ resolve (container) {
14
+ return {
15
+ useCase: container.resolve(DuplicateEntryUseCase)
16
+ };
17
+ }
18
+ });
19
+ export { DuplicateEntryFeature };
20
+
21
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/contentEntry/duplicateEntry/feature.js","sources":["../../../../src/features/contentEntry/duplicateEntry/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { DuplicateEntryUseCase as UseCase } from \"./abstractions.js\";\nimport { DuplicateEntryUseCase } from \"./DuplicateEntryUseCase.js\";\nimport { DuplicateEntryRepository } from \"./DuplicateEntryRepository.js\";\nimport { DuplicateEntryGateway } from \"./DuplicateEntryGateway.js\";\n\nexport const DuplicateEntryFeature = createFeature({\n name: \"CmsContentEntry/DuplicateEntry\",\n register(container) {\n container.register(DuplicateEntryUseCase);\n container.register(DuplicateEntryRepository).inSingletonScope();\n container.register(DuplicateEntryGateway).inSingletonScope();\n },\n resolve(container) {\n return {\n useCase: container.resolve(UseCase)\n };\n }\n});\n"],"names":["DuplicateEntryFeature","createFeature","container","DuplicateEntryUseCase","DuplicateEntryRepository","DuplicateEntryGateway","UseCase"],"mappings":";;;;;AAMO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,0BAA0B,gBAAgB;QAC7DF,UAAU,QAAQ,CAACG,uBAAuB,gBAAgB;IAC9D;IACA,SAAQH,SAAS;QACb,OAAO;YACH,SAASA,UAAU,OAAO,CAACI;QAC/B;IACJ;AACJ"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,106 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { Container } from "@webiny/di";
3
+ import { CmsGraphQLClient } from "../graphQLClient/abstractions.js";
4
+ import { EntryGraphQLFields } from "./abstractions.js";
5
+ import { ValueTransformersFeature } from "./valueTransformers/feature.js";
6
+ import { formValues, graphQLInputValues, pageModel } from "./valueTransformers/entryValueFixtures.js";
7
+ import { CreateEntryGateway } from "./createEntry/abstractions.js";
8
+ import { CreateEntryGateway as CreateEntryGateway_js_CreateEntryGateway } from "./createEntry/CreateEntryGateway.js";
9
+ import { UpdateEntryGateway } from "./updateEntry/abstractions.js";
10
+ import { UpdateEntryGateway as UpdateEntryGateway_js_UpdateEntryGateway } from "./updateEntry/UpdateEntryGateway.js";
11
+ import { UpdateSingletonEntryGateway } from "./singletonEntry/abstractions.js";
12
+ import { UpdateSingletonEntryGateway as UpdateSingletonEntryGateway_js_UpdateSingletonEntryGateway } from "./singletonEntry/UpdateSingletonEntryGateway.js";
13
+ import { CreateRevisionFromGateway } from "./createRevisionFrom/abstractions.js";
14
+ import { CreateRevisionFromGateway as CreateRevisionFromGateway_js_CreateRevisionFromGateway } from "./createRevisionFrom/CreateRevisionFromGateway.js";
15
+ const ENTRY = {
16
+ id: "entry-1#0001",
17
+ entryId: "entry-1",
18
+ values: {}
19
+ };
20
+ const cases = [
21
+ {
22
+ name: "CreateEntryGateway",
23
+ register: (container)=>container.register(CreateEntryGateway_js_CreateEntryGateway),
24
+ execute: (container, data)=>container.resolve(CreateEntryGateway).execute({
25
+ model: pageModel,
26
+ data
27
+ })
28
+ },
29
+ {
30
+ name: "UpdateEntryGateway",
31
+ register: (container)=>container.register(UpdateEntryGateway_js_UpdateEntryGateway),
32
+ execute: (container, data)=>container.resolve(UpdateEntryGateway).execute({
33
+ model: pageModel,
34
+ revisionId: ENTRY.id,
35
+ data
36
+ })
37
+ },
38
+ {
39
+ name: "UpdateSingletonEntryGateway",
40
+ register: (container)=>container.register(UpdateSingletonEntryGateway_js_UpdateSingletonEntryGateway),
41
+ execute: (container, data)=>container.resolve(UpdateSingletonEntryGateway).execute({
42
+ model: pageModel,
43
+ data
44
+ })
45
+ },
46
+ {
47
+ name: "CreateRevisionFromGateway",
48
+ register: (container)=>container.register(CreateRevisionFromGateway_js_CreateRevisionFromGateway),
49
+ execute: (container, data)=>container.resolve(CreateRevisionFromGateway).execute({
50
+ model: pageModel,
51
+ revisionId: ENTRY.id,
52
+ data
53
+ })
54
+ }
55
+ ];
56
+ describe.each(cases)("$name", ({ register, execute })=>{
57
+ let container;
58
+ let client;
59
+ beforeEach(()=>{
60
+ container = new Container();
61
+ client = {
62
+ execute: vi.fn().mockResolvedValue({
63
+ content: {
64
+ data: ENTRY,
65
+ error: null
66
+ }
67
+ })
68
+ };
69
+ ValueTransformersFeature.register(container);
70
+ container.registerInstance(CmsGraphQLClient, client);
71
+ container.registerInstance(EntryGraphQLFields, {
72
+ getSystemFields: ()=>"id",
73
+ getValuesBlock: ()=>""
74
+ });
75
+ register(container);
76
+ });
77
+ it("should send dynamic zone values in the GraphQL input shape", async ()=>{
78
+ await execute(container, {
79
+ values: formValues
80
+ });
81
+ expect(client.execute).toHaveBeenCalledTimes(1);
82
+ const { variables } = client.execute.mock.calls[0][0];
83
+ expect(variables.data).toEqual({
84
+ values: graphQLInputValues
85
+ });
86
+ });
87
+ it("should keep keys other than values in the payload", async ()=>{
88
+ await execute(container, {
89
+ values: formValues,
90
+ wbyAco_location: {
91
+ folderId: "root"
92
+ }
93
+ });
94
+ const { variables } = client.execute.mock.calls[0][0];
95
+ expect(variables.data.wbyAco_location).toEqual({
96
+ folderId: "root"
97
+ });
98
+ });
99
+ it("should return the entry from the API response", async ()=>{
100
+ await expect(execute(container, {
101
+ values: formValues
102
+ })).resolves.toEqual(ENTRY);
103
+ });
104
+ });
105
+
106
+ //# sourceMappingURL=entryValueGateways.test.js.map