@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.
- package/ContentEntriesModule.js +23 -6
- package/ContentEntriesModule.js.map +1 -1
- package/HeadlessCMS.js +7 -2
- package/HeadlessCMS.js.map +1 -1
- package/admin/RoutesConfig.js +19 -2
- package/admin/RoutesConfig.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionDelete.js +2 -1
- package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionDelete.test.d.ts +1 -0
- package/admin/components/ContentEntries/BulkActions/ActionDelete.test.js +125 -0
- package/admin/components/ContentEntries/BulkActions/ActionDelete.test.js.map +1 -0
- package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionMove.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionPublish.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionUnpublish.js.map +1 -1
- package/admin/components/ContentEntries/Filters/RefFieldRenderer.d.ts +2 -0
- package/admin/components/ContentEntries/Filters/RefFieldRenderer.js +85 -0
- package/admin/components/ContentEntries/Filters/RefFieldRenderer.js.map +1 -0
- package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.d.ts +2 -0
- package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js +34 -0
- package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js.map +1 -0
- package/admin/components/ContentEntries/Table/Actions/index.d.ts +1 -0
- package/admin/components/ContentEntries/Table/Actions/index.js +1 -0
- package/admin/components/ContentEntries/Table/Cells/CellLive.js +9 -2
- package/admin/components/ContentEntries/Table/Cells/CellLive.js.map +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditor.js +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditor.js.map +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditorProvider.js +1 -0
- package/admin/components/ContentModelEditor/ContentModelEditorProvider.js.map +1 -1
- package/admin/components/ContentModelEditor/FieldsSidebar.js +12 -2
- package/admin/components/ContentModelEditor/FieldsSidebar.js.map +1 -1
- package/admin/components/ContentModelEditor/evaluateExpression.d.ts +1 -1
- package/admin/components/ContentModelEditor/evaluateExpression.js +10 -0
- package/admin/components/ContentModelEditor/evaluateExpression.js.map +1 -1
- package/admin/components/ContentModelEditor/operatorOptions.js +12 -0
- package/admin/components/ContentModelEditor/operatorOptions.js.map +1 -1
- package/admin/components/Dialogs/DuplicateEntryConfirmDialog.d.ts +2 -0
- package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js +22 -0
- package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js.map +1 -0
- package/admin/components/Dialogs/EditRevisionNoteDialog.d.ts +2 -0
- package/admin/components/Dialogs/EditRevisionNoteDialog.js +33 -0
- package/admin/components/Dialogs/EditRevisionNoteDialog.js.map +1 -0
- package/admin/components/Dialogs/PublishEntryConfirmDialog.d.ts +26 -1
- package/admin/components/Dialogs/PublishEntryConfirmDialog.js +4 -3
- package/admin/components/Dialogs/PublishEntryConfirmDialog.js.map +1 -1
- package/admin/components/Dialogs/UnpublishEntryConfirmDialog.d.ts +26 -1
- package/admin/components/Dialogs/UnpublishEntryConfirmDialog.js +4 -3
- package/admin/components/Dialogs/UnpublishEntryConfirmDialog.js.map +1 -1
- package/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/PermissionsEditor.js +3 -3
- package/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/PermissionsEditor.js.map +1 -1
- package/admin/components/FieldEditor/EditFieldDialog.d.ts +2 -2
- package/admin/components/FieldEditor/EditFieldDialog.js +5 -2
- package/admin/components/FieldEditor/EditFieldDialog.js.map +1 -1
- package/admin/components/FieldEditor/Field.js +5 -5
- package/admin/components/FieldEditor/Field.js.map +1 -1
- package/admin/components/FieldEditor/FieldEditor.js +2 -2
- package/admin/components/FieldEditor/FieldEditor.js.map +1 -1
- package/admin/components/FieldEditor/FieldEditorContext.d.ts +1 -1
- package/admin/components/FieldEditor/FieldEditorContext.js +6 -1
- package/admin/components/FieldEditor/FieldEditorContext.js.map +1 -1
- package/admin/components/LexicalCmsEditor/LexicalEditor.js +10 -6
- package/admin/components/LexicalCmsEditor/LexicalEditor.js.map +1 -1
- package/admin/components/LexicalCmsEditor/TypographyDropDown.js +3 -2
- package/admin/components/LexicalCmsEditor/TypographyDropDown.js.map +1 -1
- package/admin/components/ModelFieldProvider/ModelFieldContext.d.ts +1 -0
- package/admin/config/contentEntries/editor/ContentEntryEditorConfig.d.ts +60 -2
- package/admin/config/contentEntries/editor/ContentEntryEditorConfig.js +18 -5
- package/admin/config/contentEntries/editor/ContentEntryEditorConfig.js.map +1 -1
- package/admin/config/contentEntries/editor/NewEntryWizard.d.ts +8 -1
- package/admin/config/contentEntries/editor/NewEntryWizard.js +20 -5
- package/admin/config/contentEntries/editor/NewEntryWizard.js.map +1 -1
- package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.d.ts +38 -0
- package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.js +23 -0
- package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.js.map +1 -0
- package/admin/config/contentEntries/list/Browser/index.d.ts +21 -0
- package/admin/config/contentEntries/list/Browser/index.js +2 -0
- package/admin/config/contentEntries/list/Browser/index.js.map +1 -1
- package/admin/config/contentEntries/list/ContentEntryListConfig.d.ts +39 -0
- package/admin/config/contentEntries/list/ContentEntryListConfig.js +2 -1
- package/admin/config/contentEntries/list/ContentEntryListConfig.js.map +1 -1
- package/admin/graphql/contentModels.d.ts +2 -2
- package/admin/graphql/contentModels.js +3 -1
- package/admin/graphql/contentModels.js.map +1 -1
- package/admin/hooks/usePermission.js +6 -34
- package/admin/hooks/usePermission.js.map +1 -1
- package/admin/plugins/editor/defaultBar/Name/Name.d.ts +0 -5
- package/admin/plugins/editor/defaultBar/Name/Name.js +0 -2
- package/admin/plugins/editor/defaultBar/Name/Name.js.map +1 -1
- package/admin/plugins/editor/formSettings/components/GeneralSettings.js +8 -1
- package/admin/plugins/editor/formSettings/components/GeneralSettings.js.map +1 -1
- package/domain/permissions/checkCmsPermission.d.ts +14 -0
- package/domain/permissions/checkCmsPermission.js +20 -0
- package/domain/permissions/checkCmsPermission.js.map +1 -0
- package/domain/permissions/hasAccessForModel.d.ts +11 -0
- package/domain/permissions/hasAccessForModel.js +20 -0
- package/domain/permissions/hasAccessForModel.js.map +1 -0
- package/domain/permissions/isModelAllowed.d.ts +2 -0
- package/domain/permissions/isModelAllowed.js +11 -0
- package/domain/permissions/isModelAllowed.js.map +1 -0
- package/exports/admin/cms/entry/editor.d.ts +1 -0
- package/exports/admin/cms/entry/editor.js +1 -0
- package/exports/admin/cms/entry/list.d.ts +2 -0
- package/exports/admin/cms/entry/list.js +2 -0
- package/exports/admin/cms.d.ts +2 -0
- package/exports/admin/cms.js +2 -0
- package/features/contentEntry/CmsEntryError.d.ts +10 -0
- package/features/contentEntry/CmsEntryError.js +11 -0
- package/features/contentEntry/CmsEntryError.js.map +1 -0
- package/features/contentEntry/EntryGraphQLFields.js +1 -1
- package/features/contentEntry/EntryGraphQLFields.js.map +1 -1
- package/features/contentEntry/bulkAction/BulkActionGateway.js +6 -1
- package/features/contentEntry/bulkAction/BulkActionGateway.js.map +1 -1
- package/features/contentEntry/bulkAction/BulkActionGateway.test.d.ts +1 -0
- package/features/contentEntry/bulkAction/BulkActionGateway.test.js +134 -0
- package/features/contentEntry/bulkAction/BulkActionGateway.test.js.map +1 -0
- package/features/contentEntry/createEntry/CreateEntryGateway.d.ts +0 -1
- package/features/contentEntry/createEntry/CreateEntryGateway.js +3 -10
- package/features/contentEntry/createEntry/CreateEntryGateway.js.map +1 -1
- package/features/contentEntry/createEntry/CreateEntryRepository.d.ts +3 -1
- package/features/contentEntry/createEntry/CreateEntryRepository.js +10 -2
- package/features/contentEntry/createEntry/CreateEntryRepository.js.map +1 -1
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.d.ts +3 -1
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js +8 -3
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js.map +1 -1
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.js +6 -1
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.js.map +1 -1
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.d.ts +1 -0
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.js +116 -0
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.js.map +1 -0
- package/features/contentEntry/deleteEntry/DeleteEntryRepository.d.ts +3 -1
- package/features/contentEntry/deleteEntry/DeleteEntryRepository.js +12 -2
- package/features/contentEntry/deleteEntry/DeleteEntryRepository.js.map +1 -1
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.js +6 -1
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.js.map +1 -1
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.d.ts +1 -0
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.js +112 -0
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.js.map +1 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.d.ts +14 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js +43 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js.map +1 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.d.ts +15 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js +34 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js.map +1 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.d.ts +11 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js +18 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js.map +1 -0
- package/features/contentEntry/duplicateEntry/abstractions.d.ts +26 -0
- package/features/contentEntry/duplicateEntry/abstractions.js +7 -0
- package/features/contentEntry/duplicateEntry/abstractions.js.map +1 -0
- package/features/contentEntry/duplicateEntry/feature.d.ts +3 -0
- package/features/contentEntry/duplicateEntry/feature.js +21 -0
- package/features/contentEntry/duplicateEntry/feature.js.map +1 -0
- package/features/contentEntry/entryValueGateways.test.d.ts +1 -0
- package/features/contentEntry/entryValueGateways.test.js +106 -0
- package/features/contentEntry/entryValueGateways.test.js.map +1 -0
- package/features/contentEntry/feature.js +4 -2
- package/features/contentEntry/feature.js.map +1 -1
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.js +6 -1
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.js.map +1 -1
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.d.ts +1 -0
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.js +130 -0
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.js.map +1 -0
- package/features/contentEntry/refTypes.d.ts +7 -0
- package/features/contentEntry/refTypes.js.map +1 -1
- package/features/contentEntry/referenceTitles/ReferenceTitles.d.ts +18 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.js +58 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.js.map +1 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.test.d.ts +1 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.test.js +173 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.test.js.map +1 -0
- package/features/contentEntry/referenceTitles/RememberTitlesDecorators.d.ts +22 -0
- package/features/contentEntry/referenceTitles/RememberTitlesDecorators.js +40 -0
- package/features/contentEntry/referenceTitles/RememberTitlesDecorators.js.map +1 -0
- package/features/contentEntry/referenceTitles/abstractions.d.ts +16 -0
- package/features/contentEntry/referenceTitles/abstractions.js +5 -0
- package/features/contentEntry/referenceTitles/abstractions.js.map +1 -0
- package/features/contentEntry/referenceTitles/feature.d.ts +3 -0
- package/features/contentEntry/referenceTitles/feature.js +20 -0
- package/features/contentEntry/referenceTitles/feature.js.map +1 -0
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.d.ts +0 -1
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js +3 -10
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js.map +1 -1
- package/features/contentEntry/updateEntry/UpdateEntryGateway.d.ts +0 -1
- package/features/contentEntry/updateEntry/UpdateEntryGateway.js +3 -10
- package/features/contentEntry/updateEntry/UpdateEntryGateway.js.map +1 -1
- package/features/contentEntry/updateEntry/UpdateEntryRepository.d.ts +3 -1
- package/features/contentEntry/updateEntry/UpdateEntryRepository.js +10 -2
- package/features/contentEntry/updateEntry/UpdateEntryRepository.js.map +1 -1
- package/features/contentEntry/valueTransformers/DynamicZoneValueTransformer.js +7 -2
- package/features/contentEntry/valueTransformers/DynamicZoneValueTransformer.js.map +1 -1
- package/features/contentEntry/valueTransformers/EntryDataPreparer.d.ts +9 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.js +8 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.js.map +1 -1
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.d.ts +1 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js +113 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js.map +1 -0
- package/features/contentEntry/valueTransformers/ObjectValueTransformer.js +16 -2
- package/features/contentEntry/valueTransformers/ObjectValueTransformer.js.map +1 -1
- package/features/contentEntry/valueTransformers/entryValueFixtures.d.ts +146 -0
- package/features/contentEntry/valueTransformers/entryValueFixtures.js +171 -0
- package/features/contentEntry/valueTransformers/entryValueFixtures.js.map +1 -0
- package/features/formModel/CmsFormModelBuilder.d.ts +9 -1
- package/features/formModel/CmsFormModelBuilder.js +26 -15
- package/features/formModel/CmsFormModelBuilder.js.map +1 -1
- package/features/formModel/CmsFormModelBuilder.test.d.ts +1 -0
- package/features/formModel/CmsFormModelBuilder.test.js +465 -0
- package/features/formModel/CmsFormModelBuilder.test.js.map +1 -0
- package/features/formModel/CmsLayoutMapper.d.ts +8 -1
- package/features/formModel/CmsLayoutMapper.js +27 -5
- package/features/formModel/CmsLayoutMapper.js.map +1 -1
- package/features/formModel/CmsRefFieldValueFormatter.d.ts +12 -0
- package/features/formModel/CmsRefFieldValueFormatter.js +29 -0
- package/features/formModel/CmsRefFieldValueFormatter.js.map +1 -0
- package/features/formModel/CmsValidationMapper.d.ts +9 -0
- package/features/formModel/CmsValidationMapper.js +25 -19
- package/features/formModel/CmsValidationMapper.js.map +1 -1
- package/features/formModel/feature.js +2 -2
- package/features/formModel/feature.js.map +1 -1
- package/features/formModel/mappers/AssetFieldMapper.d.ts +12 -0
- package/features/formModel/mappers/AssetFieldMapper.js +13 -0
- package/features/formModel/mappers/AssetFieldMapper.js.map +1 -0
- package/features/formModel/mappers/DateTimeFieldMapper.js +3 -0
- package/features/formModel/mappers/DateTimeFieldMapper.js.map +1 -1
- package/features/formModel/mappers/DynamicZoneFieldMapper.js +8 -2
- package/features/formModel/mappers/DynamicZoneFieldMapper.js.map +1 -1
- package/features/formModel/mappers/ObjectFieldMapper.js +12 -5
- package/features/formModel/mappers/ObjectFieldMapper.js.map +1 -1
- package/features/formModel/mappers/applyFieldProps.js +2 -1
- package/features/formModel/mappers/applyFieldProps.js.map +1 -1
- package/features/formModel/mappers/applyFieldProps.test.d.ts +1 -0
- package/features/formModel/mappers/applyFieldProps.test.js +59 -0
- package/features/formModel/mappers/applyFieldProps.test.js.map +1 -0
- package/features/formModel/mappers/index.js +2 -0
- package/features/formModel/mappers/index.js.map +1 -1
- package/features/model/deleteModel/DeleteModelGateway.js +6 -1
- package/features/model/deleteModel/DeleteModelGateway.js.map +1 -1
- package/features/model/deleteModel/DeleteModelGateway.test.d.ts +1 -0
- package/features/model/deleteModel/DeleteModelGateway.test.js +71 -0
- package/features/model/deleteModel/DeleteModelGateway.test.js.map +1 -0
- package/features/model/exportModels/ExportModelsGateway.d.ts +1 -1
- package/features/model/exportModels/ExportModelsGateway.js.map +1 -1
- package/features/model/exportModels/ExportModelsUseCase.js +7 -1
- package/features/model/exportModels/ExportModelsUseCase.js.map +1 -1
- package/features/model/exportModels/abstractions.d.ts +8 -2
- package/features/model/exportModels/abstractions.js.map +1 -1
- package/features/model/updateModel/UpdateModelGateway.js +1 -0
- package/features/model/updateModel/UpdateModelGateway.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +30 -28
- package/presentation/cloneContentModel/CloneContentModelPresenter.d.ts +1 -0
- package/presentation/cloneContentModel/CloneContentModelPresenter.js +8 -6
- package/presentation/cloneContentModel/CloneContentModelPresenter.js.map +1 -1
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.d.ts +1 -1
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.js +6 -1
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.js.map +1 -1
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.d.ts +1 -0
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.js +124 -0
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.js.map +1 -0
- package/presentation/contentEntries/bulkActions/abstractions.d.ts +1 -1
- package/presentation/contentEntries/bulkActions/abstractions.js.map +1 -1
- package/presentation/contentEntries/form/ContentEntryFormPresenter.d.ts +2 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.d.ts +1 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.js +107 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.js.map +1 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.js +47 -30
- package/presentation/contentEntries/form/ContentEntryFormPresenter.js.map +1 -1
- package/presentation/contentEntries/form/ContentEntryFormPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js +244 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js.map +1 -0
- package/presentation/contentEntries/form/abstractions.d.ts +1 -0
- package/presentation/contentEntries/form/abstractions.js.map +1 -1
- package/presentation/contentEntries/form/getFieldBuilders.test.js +4 -2
- package/presentation/contentEntries/form/getFieldBuilders.test.js.map +1 -1
- package/presentation/contentEntries/form/toFormErrors.d.ts +7 -0
- package/presentation/contentEntries/form/toFormErrors.js +49 -0
- package/presentation/contentEntries/form/toFormErrors.js.map +1 -0
- package/presentation/contentEntries/form/toFormErrors.test.d.ts +1 -0
- package/presentation/contentEntries/form/toFormErrors.test.js +175 -0
- package/presentation/contentEntries/form/toFormErrors.test.js.map +1 -0
- package/presentation/contentEntries/list/ContentEntriesDataSource.d.ts +5 -0
- package/presentation/contentEntries/list/ContentEntriesDataSource.js +16 -4
- package/presentation/contentEntries/list/ContentEntriesDataSource.js.map +1 -1
- package/presentation/contentEntries/list/ContentEntriesPresenter.d.ts +6 -2
- package/presentation/contentEntries/list/ContentEntriesPresenter.js +27 -2
- package/presentation/contentEntries/list/ContentEntriesPresenter.js.map +1 -1
- package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +134 -5
- package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
- package/presentation/contentEntries/list/abstractions.d.ts +12 -0
- package/presentation/contentEntries/list/abstractions.js.map +1 -1
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.d.ts +7 -0
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js +47 -0
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js.map +1 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.d.ts +25 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.js +76 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.js.map +1 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.test.js +81 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.test.js.map +1 -0
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.d.ts +2 -0
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js +30 -0
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewComponentsContext.d.ts +15 -0
- package/presentation/contentEntries/preview/PreviewComponentsContext.js +43 -0
- package/presentation/contentEntries/preview/PreviewComponentsContext.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewDecorator.d.ts +2 -0
- package/presentation/contentEntries/preview/PreviewDecorator.js +68 -0
- package/presentation/contentEntries/preview/PreviewDecorator.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewDomainStatus.d.ts +10 -0
- package/presentation/contentEntries/preview/PreviewDomainStatus.js +19 -0
- package/presentation/contentEntries/preview/PreviewDomainStatus.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewPane.d.ts +18 -0
- package/presentation/contentEntries/preview/PreviewPane.js +217 -0
- package/presentation/contentEntries/preview/PreviewPane.js.map +1 -0
- package/presentation/contentEntries/preview/abstractions.d.ts +24 -0
- package/presentation/contentEntries/preview/abstractions.js +5 -0
- package/presentation/contentEntries/preview/abstractions.js.map +1 -0
- package/presentation/contentEntries/preview/feature.d.ts +3 -0
- package/presentation/contentEntries/preview/feature.js +17 -0
- package/presentation/contentEntries/preview/feature.js.map +1 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.d.ts +26 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.js +81 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.js.map +1 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.test.d.ts +1 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.test.js +127 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.test.js.map +1 -0
- package/presentation/contentEntries/preview/useLivePreviewPresenter.d.ts +1 -0
- package/presentation/contentEntries/preview/useLivePreviewPresenter.js +8 -0
- package/presentation/contentEntries/preview/useLivePreviewPresenter.js.map +1 -0
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.d.ts +21 -2
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.js +143 -6
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.js.map +1 -1
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.js +384 -0
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.js.map +1 -0
- package/presentation/contentEntries/revisionsList/abstractions.d.ts +16 -0
- package/presentation/contentEntries/revisionsList/abstractions.js.map +1 -1
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js +9 -4
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js.map +1 -1
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js +122 -0
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js.map +1 -0
- package/presentation/contentEntries/trashBin/CmsTrashBin.d.ts +2 -2
- package/presentation/contentEntries/views/CmsAdvancedSearch.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.d.ts +13 -0
- package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.js +54 -0
- package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.js.map +1 -0
- package/presentation/contentEntries/views/ContentEntriesListLayout.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntriesListLayout.js +4 -2
- package/presentation/contentEntries/views/ContentEntriesListLayout.js.map +1 -1
- package/presentation/contentEntries/views/ContentEntriesView.js +2 -0
- package/presentation/contentEntries/views/ContentEntriesView.js.map +1 -1
- package/presentation/contentEntries/views/ContentEntryFormView.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntryFormView.js +8 -6
- package/presentation/contentEntries/views/ContentEntryFormView.js.map +1 -1
- package/presentation/contentEntries/views/OlderRevisionAlert.d.ts +4 -0
- package/presentation/contentEntries/views/OlderRevisionAlert.js +43 -0
- package/presentation/contentEntries/views/OlderRevisionAlert.js.map +1 -0
- package/presentation/contentEntries/views/RevisionDrawer.d.ts +2 -2
- package/presentation/contentEntries/views/RevisionDrawer.js +4 -0
- package/presentation/contentEntries/views/RevisionDrawer.js.map +1 -1
- package/presentation/contentEntries/views/RevisionListItem.d.ts +3 -3
- package/presentation/contentEntries/views/RevisionListItem.js +82 -14
- package/presentation/contentEntries/views/RevisionListItem.js.map +1 -1
- package/presentation/contentEntries/views/RevisionsList.d.ts +2 -2
- package/presentation/contentEntries/views/RevisionsList.js +3 -3
- package/presentation/contentEntries/views/RevisionsList.js.map +1 -1
- package/presentation/contentEntries/views/SingleEntryLayout.d.ts +2 -2
- package/presentation/contentEntries/views/Table/Table.d.ts +2 -2
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.js +11 -0
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.js.map +1 -1
- package/presentation/contentEntries/views/actions/DeleteEntryMenuItem.d.ts +2 -2
- package/presentation/contentEntries/views/actions/PublishOnlyButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/RevisionSelector.d.ts +2 -2
- package/presentation/contentEntries/views/actions/SaveAndPublishButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/SaveContentButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/ShowRevisionListMenuItem.d.ts +2 -2
- package/presentation/contentEntries/views/layout/ContentEntryForm.d.ts +12 -12
- package/presentation/contentEntries/views/layout/ContentEntryFormContent.d.ts +10 -6
- package/presentation/contentEntries/views/layout/ContentEntryFormContent.js +7 -2
- package/presentation/contentEntries/views/layout/ContentEntryFormContent.js.map +1 -1
- package/presentation/contentModels/ContentModelsPresenter.d.ts +5 -5
- package/presentation/contentModels/ContentModelsPresenter.js +1 -1
- package/presentation/contentModels/ContentModelsPresenter.js.map +1 -1
- package/presentation/contentModels/abstractions.d.ts +7 -2
- package/presentation/contentModels/abstractions.js.map +1 -1
- package/presentation/contentModels/components/CloneContentModelDialog.d.ts +2 -2
- package/presentation/contentModels/components/ContentModels.d.ts +2 -2
- package/presentation/contentModels/components/ContentModelsDataList.d.ts +2 -2
- package/presentation/contentModels/components/ContentModelsDataList.js +6 -5
- package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
- package/presentation/contentModels/components/NewContentModelDialog.d.ts +2 -2
- package/presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.js +8 -3
- package/presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.js.map +1 -1
- package/presentation/contentModels/components/fullDelete/dialog/Content.js +7 -2
- package/presentation/contentModels/components/fullDelete/dialog/Content.js.map +1 -1
- package/presentation/contentModels/components/fullDelete/dialog/Content.test.d.ts +1 -0
- package/presentation/contentModels/components/fullDelete/dialog/Content.test.js +54 -0
- package/presentation/contentModels/components/fullDelete/dialog/Content.test.js.map +1 -0
- package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.d.ts +25 -0
- package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.js +9 -0
- package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.js.map +1 -0
- package/presentation/contentModels/components/fullDelete/types.js.map +1 -1
- package/presentation/fieldEditor/FieldEditorPresenter.js +1 -1
- package/presentation/fieldEditor/FieldEditorPresenter.js.map +1 -1
- package/presentation/fieldEditor/groups/AppearanceGroup.js +12 -0
- package/presentation/fieldEditor/groups/AppearanceGroup.js.map +1 -1
- package/presentation/fieldEditor/groups/GeneralGroup.d.ts +5 -5
- package/presentation/fieldEditor/groups/GeneralGroup.js +5 -1
- package/presentation/fieldEditor/groups/GeneralGroup.js.map +1 -1
- package/presentation/fieldEditor/groups/GeneralGroup.test.d.ts +1 -0
- package/presentation/fieldEditor/groups/GeneralGroup.test.js +68 -0
- package/presentation/fieldEditor/groups/GeneralGroup.test.js.map +1 -0
- package/presentation/fieldEditor/groups/ValidationsGroup.d.ts +2 -0
- package/presentation/fieldEditor/groups/ValidationsGroup.js +21 -7
- package/presentation/fieldEditor/groups/ValidationsGroup.js.map +1 -1
- package/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js +3 -3
- package/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js.map +1 -1
- package/presentation/fieldEditor/renderers/CmsValidatorsRenderer.js +2 -2
- package/presentation/fieldEditor/renderers/CmsValidatorsRenderer.js.map +1 -1
- package/presentation/fieldRenderers/feature.js +2 -1
- package/presentation/fieldRenderers/feature.js.map +1 -1
- package/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js +8 -0
- package/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/CmsRefDetailedSingleRenderer.js +8 -0
- package/presentation/fieldRenderers/ref/CmsRefDetailedSingleRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/CmsRefInputRenderer.js +1 -0
- package/presentation/fieldRenderers/ref/CmsRefInputRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/CmsRefInputsRenderer.js +1 -0
- package/presentation/fieldRenderers/ref/CmsRefInputsRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.d.ts +1 -0
- package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.js +8 -2
- package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.d.ts +1 -0
- package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js +185 -0
- package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js.map +1 -0
- package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/components/EditEntryDrawer.d.ts +10 -0
- package/presentation/fieldRenderers/ref/components/EditEntryDrawer.js +94 -0
- package/presentation/fieldRenderers/ref/components/EditEntryDrawer.js.map +1 -0
- package/presentation/fieldRenderers/ref/components/EntryCard.d.ts +2 -0
- package/presentation/fieldRenderers/ref/components/EntryCard.js +13 -3
- package/presentation/fieldRenderers/ref/components/EntryCard.js.map +1 -1
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.d.ts +2 -2
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.js +3 -2
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.js.map +1 -1
- package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.d.ts +2 -1
- package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.js +6 -0
- package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/detailed/abstractions.d.ts +2 -1
- package/presentation/fieldRenderers/ref/detailed/abstractions.js.map +1 -1
- package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.d.ts +13 -0
- package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.js +25 -0
- package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.js.map +1 -0
- package/presentation/fieldRenderers/ref/editEntry/abstractions.d.ts +10 -0
- package/presentation/fieldRenderers/ref/editEntry/abstractions.js +5 -0
- package/presentation/fieldRenderers/ref/editEntry/abstractions.js.map +1 -0
- package/presentation/fieldRenderers/ref/editEntry/feature.d.ts +3 -0
- package/presentation/fieldRenderers/ref/editEntry/feature.js +17 -0
- package/presentation/fieldRenderers/ref/editEntry/feature.js.map +1 -0
- package/presentation/fieldTypes/abstractions.d.ts +12 -0
- package/presentation/fieldTypes/abstractions.js.map +1 -1
- package/presentation/fieldTypes/renderers/common/SelectBoxRenderer.js +1 -1
- package/presentation/fieldTypes/renderers/common/SelectBoxRenderer.js.map +1 -1
- package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.d.ts +15 -0
- package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.js +19 -0
- package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.js.map +1 -0
- package/presentation/fieldTypes/renderers/dynamicZone/DynamicZoneRenderer.js +6 -2
- package/presentation/fieldTypes/renderers/dynamicZone/DynamicZoneRenderer.js.map +1 -1
- package/presentation/fieldTypes/renderers/index.d.ts +1 -0
- package/presentation/fieldTypes/renderers/index.js +1 -0
- package/presentation/fieldTypes/renderers/object/ObjectAccordionRenderer.js +2 -0
- package/presentation/fieldTypes/renderers/object/ObjectAccordionRenderer.js.map +1 -1
- package/presentation/fieldTypes/renderers/object/ObjectsAccordionRenderer.js +6 -0
- package/presentation/fieldTypes/renderers/object/ObjectsAccordionRenderer.js.map +1 -1
- package/presentation/fieldTypes/types/DynamicZoneFieldType.d.ts +3 -6
- package/presentation/fieldTypes/types/DynamicZoneFieldType.js +2 -12
- package/presentation/fieldTypes/types/DynamicZoneFieldType.js.map +1 -1
- package/presentation/fieldTypes/types/dynamicZone/TemplateDialog.js +25 -3
- package/presentation/fieldTypes/types/dynamicZone/TemplateDialog.js.map +1 -1
- package/presentation/fieldValidators/abstractions.d.ts +7 -0
- package/presentation/fieldValidators/abstractions.js.map +1 -1
- package/presentation/fieldValidators/validators/DateGteValidator.d.ts +6 -0
- package/presentation/fieldValidators/validators/DateGteValidator.js +17 -25
- package/presentation/fieldValidators/validators/DateGteValidator.js.map +1 -1
- package/presentation/fieldValidators/validators/DateLteValidator.d.ts +6 -0
- package/presentation/fieldValidators/validators/DateLteValidator.js +17 -25
- package/presentation/fieldValidators/validators/DateLteValidator.js.map +1 -1
- package/presentation/fieldValidators/validators/dateLimitSettings.d.ts +20 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.js +124 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.js.map +1 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.test.d.ts +1 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.test.js +111 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.test.js.map +1 -0
- package/presentation/importContentModels/ImportContentModelsDialog.d.ts +2 -2
- package/presentation/importContentModels/ImportContentModelsPresenter.js +1 -1
- package/presentation/importContentModels/ImportContentModelsPresenter.js.map +1 -1
- package/presentation/importContentModels/components/DataList.d.ts +2 -2
- package/presentation/importContentModels/components/FileUpload.d.ts +2 -2
- package/presentation/importContentModels/components/Model/DataListModelItem.js +3 -3
- package/presentation/importContentModels/components/Model/DataListModelItem.js.map +1 -1
- package/presentation/importContentModels/components/Model/DataListModelItemInfo.js +2 -2
- package/presentation/importContentModels/components/Model/DataListModelItemInfo.js.map +1 -1
- package/presentation/importContentModels/components/Model/DataListModels.d.ts +2 -2
- package/presentation/menus/ContentGroupsMenuItems.d.ts +2 -2
- package/presentation/modelGroup/ModelGroupPresenter.d.ts +3 -1
- package/presentation/modelGroup/ModelGroupPresenter.js +8 -11
- package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
- package/presentation/modelGroup/components/ContentModelGroups.d.ts +2 -2
- package/presentation/modelGroup/components/ContentModelGroupsDataList.d.ts +6 -2
- package/presentation/modelGroup/components/ContentModelGroupsForm.d.ts +8 -2
- package/presentation/newContentModel/NewContentModelPresenter.d.ts +1 -0
- package/presentation/newContentModel/NewContentModelPresenter.js +8 -6
- package/presentation/newContentModel/NewContentModelPresenter.js.map +1 -1
- package/utils/normalizeIcon.d.ts +4 -0
- package/utils/normalizeIcon.js +9 -6
- package/utils/normalizeIcon.js.map +1 -1
- package/features/formModel/CmsAccessControlRuleEvaluator.d.ts +0 -9
- package/features/formModel/CmsAccessControlRuleEvaluator.js +0 -16
- 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":";;;;;;;;;;;;;;;;AAkBA,MAAMA,iBAAiB,CAACC,aAAmC;QACvD,IAAI,CAAC;QACL,SAAS;QACT,QAAQC,GAAG,EAAE,CAAC,UAAaD,aAAaA,aAAa;gBAAE,OAAO;YAAQ;QACtE,SAASC,GAAG,EAAE;QACd,OAAOA,GAAG,EAAE;QACZ,WAAWA,GAAG,EAAE;IACpB;AAGA,MAAMC,WAAW;IACb,IAAIC;IACJ,IAAIC;IACJ,MAAMC,UAAU,IAAIC,QAAW,CAACC,KAAKC;QACjCL,UAAUI;QACVH,SAASI;IACb;IACA,OAAO;QAAEH;QAASF;QAASC;IAAO;AACtC;AAEA,MAAMK,cAAc,CAACC,UAAqB;QACtC,IAAI,GAAGA,QAAQ,KAAK,CAAC;QACrBA;QACA,MAAM;YAAE,QAAQ;YAAO,QAAQ;YAAS,OAAOA;QAAQ;QACvD,QAAQ;YAAE,OAAOA;QAAQ;IAC7B;AAEA,MAAMC,QAAQ;IACV,MAAMC,QAA6C,EAAE;IACrD,MAAMC,SAASX;IACf,MAAMY,SAASZ;IAEf,IAAIa;IAEJ,MAAMC,eAAe,IAAIC;IAEzB,MAAMC,gBAAgBjB,GAAG,EAAE,CAAC,IAAMY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AAM4C,OAAO1B,eAAe,gBAAgB;QAE7D,MAAM4B,QAAQ7C;QACdc,aAAa,GAAG,CAAC,KAAK+B,MAAM,OAAO;QACnC,MAAMC,UAAUN,UAAU,YAAY,CAAC;QACvC5B,OAAO,OAAO,CAACL,YAAY;QAG3B,MAAMoC,OAAOF,QAAQ,QAAQ,CAAC,IAAI,CAAC;QACnCE,OAAOH,UAAU,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC;QAElCK,MAAM,OAAO,CAACtC,YAAY;QAC1B,MAAMuC;QACNH,OAAOH,UAAU,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC;IACtC;AACJ"}
|
|
@@ -27,6 +27,7 @@ export interface IContentEntryFormPresenter {
|
|
|
27
27
|
deleteEntry(): Promise<boolean>;
|
|
28
28
|
setFolderId(folderId: string | null): void;
|
|
29
29
|
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":";
|
|
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(
|
|
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(
|
|
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,CAAC;YAAE;YAC7C,YAAY,EAAE;YACd,gBAAgB,EAAE;YAClB,UAAU,CAAC;YACX,kBAAkB;gBAAE,SAAS;gBAAO,QAAQ,EAAE;YAAC;QACnD;QACA;YACI,IAAI;YACJ,SAAS;YACT,MAAM;YACN,OAAO;YACP,MAAM,EAAE;YACR,MAAM;YACN,UAAU;gBAAE,MAAM;gBAAqB,UAAU,CAAC;YAAE;YACpD,YAAY,EAAE;YACd,gBAAgB,EAAE;YAClB,kBAAkB;gBAAE,SAAS;gBAAO,QAAQ,EAAE;YAAC;YAC/C,UAAU;gBACN,QAAQ;oBACJ;wBACI,IAAI;wBACJ,SAAS;wBACT,MAAM;wBACN,OAAO;wBACP,MAAM;4BAAC;yBAAO;wBACd,MAAM;wBACN,UAAU;4BAAE,MAAM;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S,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;gBAAO,QAAQ,EAAE;YAAC;QACnD;QACA;YACI,IAAI;YACJ,SAAS;YACT,MAAM;YACN,OAAO;YACP,MAAM,EAAE;YACR,MAAM;YACN,UAAU;gBAAE,MAAM;gBAAqB,UAAU,CAAC;YAAE;YACpD,YAAY,EAAE;YACd,gBAAgB,EAAE;YAClB,kBAAkB;gBAAE,SAAS;gBAAO,QAAQ,EAAE;YAAC;YAC/C,UAAU;gBACN,QAAQ;oBACJ;wBACI,IAAI;wBACJ,SAAS;wBACT,MAAM;wBACN,OAAO;wBACP,MAAM;4BAAC;yBAAO;wBACd,MAAM;wBACN,UAAU;4BAAE,MAAM;4BAAc,UAAU;wBAAK;wBAC/C,YAAY,EAAE;wBACd,gBAAgB,EAAE;wBAClB,UAAU,CAAC;wBACX,kBAA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rE,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;AAOjE,MAAMI,cAAc,CAACC,OAAiBC;IAClC,MAAMC,UAAUD,MAA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