@webiny/app-headless-cms 6.6.0-alpha.1 → 6.6.0-alpha.11
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 +20 -3
- package/ContentEntriesModule.js.map +1 -1
- package/admin/RoutesConfig.js +5 -1
- package/admin/RoutesConfig.js.map +1 -1
- 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/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/evaluateExpression.d.ts +1 -1
- package/admin/components/ContentModelEditor/evaluateExpression.js +6 -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/FieldEditor/Field.js +4 -4
- package/admin/components/FieldEditor/Field.js.map +1 -1
- package/admin/components/ModelFieldProvider/ModelFieldContext.d.ts +1 -0
- package/admin/config/contentEntries/editor/ContentEntryEditorConfig.d.ts +1 -1
- package/admin/graphql/contentModels.d.ts +2 -2
- package/admin/graphql/contentModels.js +1 -0
- 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 +0 -16
- 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/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/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/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/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/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/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/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/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/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 +130 -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 +3 -2
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js +2 -2
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js.map +1 -1
- package/presentation/contentEntries/preview/LivePreviewPresenter.d.ts +12 -1
- package/presentation/contentEntries/preview/LivePreviewPresenter.js +48 -5
- package/presentation/contentEntries/preview/LivePreviewPresenter.js.map +1 -1
- 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.js +8 -5
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js.map +1 -1
- package/presentation/contentEntries/preview/PreviewDecorator.js +30 -10
- package/presentation/contentEntries/preview/PreviewDecorator.js.map +1 -1
- 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 +12 -3
- package/presentation/contentEntries/preview/PreviewPane.js +82 -46
- package/presentation/contentEntries/preview/PreviewPane.js.map +1 -1
- package/presentation/contentEntries/preview/abstractions.d.ts +8 -0
- package/presentation/contentEntries/preview/abstractions.js.map +1 -1
- package/presentation/contentEntries/preview/resolvePreviewUrl.d.ts +23 -2
- package/presentation/contentEntries/preview/resolvePreviewUrl.js +62 -10
- package/presentation/contentEntries/preview/resolvePreviewUrl.js.map +1 -1
- 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/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/views/ContentEntriesListLayout.js +1 -0
- 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.js +4 -1
- 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.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.js +3 -3
- package/presentation/contentEntries/views/RevisionsList.js.map +1 -1
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.js +11 -0
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.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/ContentModelsDataList.js +6 -5
- package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
- 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/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 +20 -6
- package/presentation/fieldEditor/groups/ValidationsGroup.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/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/RefFieldOptions.js +3 -2
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.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/index.d.ts +1 -0
- package/presentation/fieldTypes/renderers/index.js +1 -0
- 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/ImportContentModelsPresenter.js +1 -1
- package/presentation/importContentModels/ImportContentModelsPresenter.js.map +1 -1
- 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/modelGroup/ModelGroupPresenter.js +1 -2
- package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
- 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,29 @@
|
|
|
1
|
+
import { FieldValueFormatter } from "@webiny/app-admin/features/formModel/abstractions.js";
|
|
2
|
+
import { ReferenceTitles } from "../contentEntry/referenceTitles/abstractions.js";
|
|
3
|
+
function isReference(value) {
|
|
4
|
+
const ref = value;
|
|
5
|
+
return "string" == typeof ref?.id && "string" == typeof ref?.modelId;
|
|
6
|
+
}
|
|
7
|
+
class CmsRefFieldValueFormatterImpl {
|
|
8
|
+
constructor(titles){
|
|
9
|
+
this.titles = titles;
|
|
10
|
+
this.type = "ref";
|
|
11
|
+
}
|
|
12
|
+
format(field) {
|
|
13
|
+
const values = Array.isArray(field.value) ? field.value : [
|
|
14
|
+
field.value
|
|
15
|
+
];
|
|
16
|
+
const titles = values.filter(isReference).map((ref)=>this.titles.getTitle(ref));
|
|
17
|
+
if (titles.some((title)=>void 0 === title)) return;
|
|
18
|
+
return titles.filter(Boolean).join(", ");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const CmsRefFieldValueFormatter = FieldValueFormatter.createImplementation({
|
|
22
|
+
implementation: CmsRefFieldValueFormatterImpl,
|
|
23
|
+
dependencies: [
|
|
24
|
+
ReferenceTitles
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
export { CmsRefFieldValueFormatter };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=CmsRefFieldValueFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/formModel/CmsRefFieldValueFormatter.js","sources":["../../../src/features/formModel/CmsRefFieldValueFormatter.ts"],"sourcesContent":["import {\n FieldValueFormatter,\n type IFieldVM\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { ReferenceTitles } from \"~/features/contentEntry/referenceTitles/abstractions.js\";\nimport type { CmsReferenceValue } from \"~/features/contentEntry/refTypes.js\";\n\nfunction isReference(value: unknown): value is CmsReferenceValue {\n const ref = value as CmsReferenceValue | null;\n return typeof ref?.id === \"string\" && typeof ref?.modelId === \"string\";\n}\n\nclass CmsRefFieldValueFormatterImpl implements FieldValueFormatter.Interface {\n readonly type = \"ref\";\n\n constructor(private titles: ReferenceTitles.Interface) {}\n\n format(field: IFieldVM): string | undefined {\n const values = Array.isArray(field.value) ? field.value : [field.value];\n const titles = values.filter(isReference).map(ref => this.titles.getTitle(ref));\n // Show nothing until every title is in, rather than a list that fills in one at a time.\n if (titles.some(title => title === undefined)) {\n return undefined;\n }\n return titles.filter(Boolean).join(\", \");\n }\n}\n\nexport const CmsRefFieldValueFormatter = FieldValueFormatter.createImplementation({\n implementation: CmsRefFieldValueFormatterImpl,\n dependencies: [ReferenceTitles]\n});\n"],"names":["isReference","value","ref","CmsRefFieldValueFormatterImpl","titles","field","values","Array","title","undefined","Boolean","CmsRefFieldValueFormatter","FieldValueFormatter","ReferenceTitles"],"mappings":";;AAOA,SAASA,YAAYC,KAAc;IAC/B,MAAMC,MAAMD;IACZ,OAAO,AAAmB,YAAnB,OAAOC,KAAK,MAAmB,AAAwB,YAAxB,OAAOA,KAAK;AACtD;AAEA,MAAMC;IAGF,YAAoBC,MAAiC,CAAE;aAAnCA,MAAM,GAANA;aAFX,IAAI,GAAG;IAEwC;IAExD,OAAOC,KAAe,EAAsB;QACxC,MAAMC,SAASC,MAAM,OAAO,CAACF,MAAM,KAAK,IAAIA,MAAM,KAAK,GAAG;YAACA,MAAM,KAAK;SAAC;QACvE,MAAMD,SAASE,OAAO,MAAM,CAACN,aAAa,GAAG,CAACE,CAAAA,MAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAACA;QAE1E,IAAIE,OAAO,IAAI,CAACI,CAAAA,QAASA,AAAUC,WAAVD,QACrB;QAEJ,OAAOJ,OAAO,MAAM,CAACM,SAAS,IAAI,CAAC;IACvC;AACJ;AAEO,MAAMC,4BAA4BC,oBAAoB,oBAAoB,CAAC;IAC9E,gBAAgBT;IAChB,cAAc;QAACU;KAAgB;AACnC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { DateBound } from "@webiny/utils";
|
|
2
3
|
import type { CmsModelFieldValidator } from "../../types.js";
|
|
3
4
|
export declare function mapCmsValidators(validators: (CmsModelFieldValidator | {
|
|
4
5
|
name: string;
|
|
@@ -7,6 +8,14 @@ export declare function mapCmsValidators(validators: (CmsModelFieldValidator | {
|
|
|
7
8
|
requiredMessage?: string;
|
|
8
9
|
schema: z.ZodTypeAny | undefined;
|
|
9
10
|
};
|
|
11
|
+
/** The `dateGte`/`dateLte` validators, as limits for the `datetime()` builder. */
|
|
12
|
+
export declare function mapCmsDateLimits(validators: (CmsModelFieldValidator | {
|
|
13
|
+
name: string;
|
|
14
|
+
})[] | undefined): {
|
|
15
|
+
name: "dateGte" | "dateLte";
|
|
16
|
+
bound: DateBound;
|
|
17
|
+
message?: string;
|
|
18
|
+
}[];
|
|
10
19
|
export declare function mapCmsListValidators(validators: (CmsModelFieldValidator | {
|
|
11
20
|
name: string;
|
|
12
21
|
})[] | undefined): {
|
|
@@ -44,31 +44,37 @@ function mapCmsValidators(validators) {
|
|
|
44
44
|
case "in":
|
|
45
45
|
if (Array.isArray(settings.values) && settings.values.length > 0) schemas.push(z["enum"](settings.values));
|
|
46
46
|
break;
|
|
47
|
-
case "dateGte":
|
|
48
|
-
if (null != settings.value) {
|
|
49
|
-
const minDate = settings.value;
|
|
50
|
-
schemas.push(z.string().refine((val)=>val >= minDate, {
|
|
51
|
-
message: msg || `Must be on or after ${minDate}`
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
55
|
-
case "dateLte":
|
|
56
|
-
if (null != settings.value) {
|
|
57
|
-
const maxDate = settings.value;
|
|
58
|
-
schemas.push(z.string().refine((val)=>val <= maxDate, {
|
|
59
|
-
message: msg || `Must be on or before ${maxDate}`
|
|
60
|
-
}));
|
|
61
|
-
}
|
|
62
|
-
break;
|
|
63
47
|
}
|
|
64
48
|
}
|
|
65
|
-
const schema = 0 === schemas.length ? void 0 :
|
|
49
|
+
const schema = 0 === schemas.length ? void 0 : schemas.slice(1).reduce((acc, s)=>z.intersection(acc, s), schemas[0]);
|
|
66
50
|
return {
|
|
67
51
|
required,
|
|
68
52
|
requiredMessage,
|
|
69
|
-
schema
|
|
53
|
+
schema
|
|
70
54
|
};
|
|
71
55
|
}
|
|
56
|
+
function mapCmsDateLimits(validators) {
|
|
57
|
+
const limits = [];
|
|
58
|
+
for (const v of validators || []){
|
|
59
|
+
const validator = v;
|
|
60
|
+
if ("dateGte" !== validator.name && "dateLte" !== validator.name) continue;
|
|
61
|
+
const settings = validator.settings || {};
|
|
62
|
+
const message = interpolateMessage(validator.message, settings);
|
|
63
|
+
if ("string" == typeof settings.expression) limits.push({
|
|
64
|
+
name: validator.name,
|
|
65
|
+
bound: {
|
|
66
|
+
expression: settings.expression
|
|
67
|
+
},
|
|
68
|
+
message
|
|
69
|
+
});
|
|
70
|
+
else if (null != settings.value) limits.push({
|
|
71
|
+
name: validator.name,
|
|
72
|
+
bound: String(settings.value),
|
|
73
|
+
message
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return limits;
|
|
77
|
+
}
|
|
72
78
|
function mapCmsListValidators(validators) {
|
|
73
79
|
if (!validators || 0 === validators.length) return {
|
|
74
80
|
required: false,
|
|
@@ -101,6 +107,6 @@ function mapCmsListValidators(validators) {
|
|
|
101
107
|
schema: hasConstraints ? arraySchema : void 0
|
|
102
108
|
};
|
|
103
109
|
}
|
|
104
|
-
export { mapCmsListValidators, mapCmsValidators };
|
|
110
|
+
export { mapCmsDateLimits, mapCmsListValidators, mapCmsValidators };
|
|
105
111
|
|
|
106
112
|
//# sourceMappingURL=CmsValidationMapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/formModel/CmsValidationMapper.js","sources":["../../../src/features/formModel/CmsValidationMapper.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { CmsModelFieldValidator } from \"~/types.js\";\n\nfunction interpolateMessage(\n message: string | undefined,\n settings: Record<string, unknown>\n): string | undefined {\n if (!message) {\n return undefined;\n }\n return message.replace(/\\{(\\w+)}/g, (match, key) => {\n const val = settings[key];\n return val != null ? String(val) : match;\n });\n}\n\nexport function mapCmsValidators(\n validators: (CmsModelFieldValidator | { name: string })[] | undefined\n): { required: boolean; requiredMessage?: string; schema: z.ZodTypeAny | undefined } {\n if (!validators || validators.length === 0) {\n return { required: false, schema: undefined };\n }\n\n let required = false;\n let requiredMessage: string | undefined;\n const schemas: z.ZodTypeAny[] = [];\n\n for (const v of validators) {\n const validator = v as CmsModelFieldValidator;\n const settings = validator.settings || {};\n\n const msg = interpolateMessage(validator.message, settings);\n\n switch (validator.name) {\n case \"required\":\n required = true;\n requiredMessage = msg;\n break;\n\n case \"minLength\":\n if (settings.value != null) {\n schemas.push(z.string().min(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"maxLength\":\n if (settings.value != null) {\n schemas.push(z.string().max(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"pattern\":\n if (settings.regex) {\n const flags = settings.flags || \"\";\n schemas.push(\n z.string().regex(new RegExp(settings.regex, flags), msg || undefined)\n );\n }\n break;\n\n case \"gte\":\n if (settings.value != null) {\n schemas.push(z.number().gte(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"lte\":\n if (settings.value != null) {\n schemas.push(z.number().lte(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"in\":\n if (Array.isArray(settings.values) && settings.values.length > 0) {\n schemas.push(z.enum(settings.values as [string, ...string[]]));\n }\n break;\n\n
|
|
1
|
+
{"version":3,"file":"features/formModel/CmsValidationMapper.js","sources":["../../../src/features/formModel/CmsValidationMapper.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { DateBound } from \"@webiny/utils\";\nimport type { CmsModelFieldValidator } from \"~/types.js\";\n\nfunction interpolateMessage(\n message: string | undefined,\n settings: Record<string, unknown>\n): string | undefined {\n if (!message) {\n return undefined;\n }\n return message.replace(/\\{(\\w+)}/g, (match, key) => {\n const val = settings[key];\n return val != null ? String(val) : match;\n });\n}\n\nexport function mapCmsValidators(\n validators: (CmsModelFieldValidator | { name: string })[] | undefined\n): { required: boolean; requiredMessage?: string; schema: z.ZodTypeAny | undefined } {\n if (!validators || validators.length === 0) {\n return { required: false, schema: undefined };\n }\n\n let required = false;\n let requiredMessage: string | undefined;\n const schemas: z.ZodTypeAny[] = [];\n\n for (const v of validators) {\n const validator = v as CmsModelFieldValidator;\n const settings = validator.settings || {};\n\n const msg = interpolateMessage(validator.message, settings);\n\n switch (validator.name) {\n case \"required\":\n required = true;\n requiredMessage = msg;\n break;\n\n case \"minLength\":\n if (settings.value != null) {\n schemas.push(z.string().min(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"maxLength\":\n if (settings.value != null) {\n schemas.push(z.string().max(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"pattern\":\n if (settings.regex) {\n const flags = settings.flags || \"\";\n schemas.push(\n z.string().regex(new RegExp(settings.regex, flags), msg || undefined)\n );\n }\n break;\n\n case \"gte\":\n if (settings.value != null) {\n schemas.push(z.number().gte(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"lte\":\n if (settings.value != null) {\n schemas.push(z.number().lte(Number(settings.value), msg || undefined));\n }\n break;\n\n case \"in\":\n if (Array.isArray(settings.values) && settings.values.length > 0) {\n schemas.push(z.enum(settings.values as [string, ...string[]]));\n }\n break;\n\n // \"dateGte\" and \"dateLte\" are applied by `DateTimeFieldMapper`, through the\n // `datetime()` builder, which also hands the limits to the field's picker.\n }\n }\n\n const schema =\n schemas.length === 0\n ? undefined\n : schemas.slice(1).reduce<z.ZodTypeAny>((acc, s) => z.intersection(acc, s), schemas[0]);\n\n return { required, requiredMessage, schema };\n}\n\n/** The `dateGte`/`dateLte` validators, as limits for the `datetime()` builder. */\nexport function mapCmsDateLimits(\n validators: (CmsModelFieldValidator | { name: string })[] | undefined\n): { name: \"dateGte\" | \"dateLte\"; bound: DateBound; message?: string }[] {\n const limits: { name: \"dateGte\" | \"dateLte\"; bound: DateBound; message?: string }[] = [];\n for (const v of validators || []) {\n const validator = v as CmsModelFieldValidator;\n if (validator.name !== \"dateGte\" && validator.name !== \"dateLte\") {\n continue;\n }\n const settings = validator.settings || {};\n const message = interpolateMessage(validator.message, settings);\n if (typeof settings.expression === \"string\") {\n limits.push({\n name: validator.name,\n bound: { expression: settings.expression },\n message\n });\n } else if (settings.value != null) {\n limits.push({ name: validator.name, bound: String(settings.value), message });\n }\n }\n return limits;\n}\n\nexport function mapCmsListValidators(\n validators: (CmsModelFieldValidator | { name: string })[] | undefined\n): { required: boolean; requiredMessage?: string; schema: z.ZodTypeAny | undefined } {\n if (!validators || validators.length === 0) {\n return { required: false, schema: undefined };\n }\n\n let required = false;\n let requiredMessage: string | undefined;\n let arraySchema = z.array(z.unknown());\n\n for (const v of validators) {\n const validator = v as CmsModelFieldValidator;\n const settings = validator.settings || {};\n const msg = interpolateMessage(validator.message, settings);\n\n switch (validator.name) {\n case \"required\":\n required = true;\n requiredMessage = msg;\n break;\n\n case \"minLength\":\n if (settings.value != null) {\n arraySchema = arraySchema.min(\n Number(settings.value),\n msg || undefined\n ) as typeof arraySchema;\n }\n break;\n\n case \"maxLength\":\n if (settings.value != null) {\n arraySchema = arraySchema.max(\n Number(settings.value),\n msg || undefined\n ) as typeof arraySchema;\n }\n break;\n }\n }\n\n const hasConstraints = validators.some(\n v =>\n (v as CmsModelFieldValidator).name === \"minLength\" ||\n (v as CmsModelFieldValidator).name === \"maxLength\"\n );\n\n return {\n required,\n requiredMessage,\n schema: hasConstraints ? arraySchema : undefined\n };\n}\n"],"names":["interpolateMessage","message","settings","match","key","val","String","mapCmsValidators","validators","undefined","required","requiredMessage","schemas","v","validator","msg","z","Number","flags","RegExp","Array","schema","acc","s","mapCmsDateLimits","limits","mapCmsListValidators","arraySchema","hasConstraints"],"mappings":";AAIA,SAASA,mBACLC,OAA2B,EAC3BC,QAAiC;IAEjC,IAAI,CAACD,SACD;IAEJ,OAAOA,QAAQ,OAAO,CAAC,aAAa,CAACE,OAAOC;QACxC,MAAMC,MAAMH,QAAQ,CAACE,IAAI;QACzB,OAAOC,AAAO,QAAPA,MAAcC,OAAOD,OAAOF;IACvC;AACJ;AAEO,SAASI,iBACZC,UAAqE;IAErE,IAAI,CAACA,cAAcA,AAAsB,MAAtBA,WAAW,MAAM,EAChC,OAAO;QAAE,UAAU;QAAO,QAAQC;IAAU;IAGhD,IAAIC,WAAW;IACf,IAAIC;IACJ,MAAMC,UAA0B,EAAE;IAElC,KAAK,MAAMC,KAAKL,WAAY;QACxB,MAAMM,YAAYD;QAClB,MAAMX,WAAWY,UAAU,QAAQ,IAAI,CAAC;QAExC,MAAMC,MAAMf,mBAAmBc,UAAU,OAAO,EAAEZ;QAElD,OAAQY,UAAU,IAAI;YAClB,KAAK;gBACDJ,WAAW;gBACXC,kBAAkBI;gBAClB;YAEJ,KAAK;gBACD,IAAIb,AAAkB,QAAlBA,SAAS,KAAK,EACdU,QAAQ,IAAI,CAACI,EAAE,MAAM,GAAG,GAAG,CAACC,OAAOf,SAAS,KAAK,GAAGa,OAAON;gBAE/D;YAEJ,KAAK;gBACD,IAAIP,AAAkB,QAAlBA,SAAS,KAAK,EACdU,QAAQ,IAAI,CAACI,EAAE,MAAM,GAAG,GAAG,CAACC,OAAOf,SAAS,KAAK,GAAGa,OAAON;gBAE/D;YAEJ,KAAK;gBACD,IAAIP,SAAS,KAAK,EAAE;oBAChB,MAAMgB,QAAQhB,SAAS,KAAK,IAAI;oBAChCU,QAAQ,IAAI,CACRI,EAAE,MAAM,GAAG,KAAK,CAAC,IAAIG,OAAOjB,SAAS,KAAK,EAAEgB,QAAQH,OAAON;gBAEnE;gBACA;YAEJ,KAAK;gBACD,IAAIP,AAAkB,QAAlBA,SAAS,KAAK,EACdU,QAAQ,IAAI,CAACI,EAAE,MAAM,GAAG,GAAG,CAACC,OAAOf,SAAS,KAAK,GAAGa,OAAON;gBAE/D;YAEJ,KAAK;gBACD,IAAIP,AAAkB,QAAlBA,SAAS,KAAK,EACdU,QAAQ,IAAI,CAACI,EAAE,MAAM,GAAG,GAAG,CAACC,OAAOf,SAAS,KAAK,GAAGa,OAAON;gBAE/D;YAEJ,KAAK;gBACD,IAAIW,MAAM,OAAO,CAAClB,SAAS,MAAM,KAAKA,SAAS,MAAM,CAAC,MAAM,GAAG,GAC3DU,QAAQ,IAAI,CAACI,CAAC,CAADA,OAAM,CAACd,SAAS,MAAM;gBAEvC;QAIR;IACJ;IAEA,MAAMmB,SACFT,AAAmB,MAAnBA,QAAQ,MAAM,GACRH,SACAG,QAAQ,KAAK,CAAC,GAAG,MAAM,CAAe,CAACU,KAAKC,IAAMP,EAAE,YAAY,CAACM,KAAKC,IAAIX,OAAO,CAAC,EAAE;IAE9F,OAAO;QAAEF;QAAUC;QAAiBU;IAAO;AAC/C;AAGO,SAASG,iBACZhB,UAAqE;IAErE,MAAMiB,SAAgF,EAAE;IACxF,KAAK,MAAMZ,KAAKL,cAAc,EAAE,CAAE;QAC9B,MAAMM,YAAYD;QAClB,IAAIC,AAAmB,cAAnBA,UAAU,IAAI,IAAkBA,AAAmB,cAAnBA,UAAU,IAAI,EAC9C;QAEJ,MAAMZ,WAAWY,UAAU,QAAQ,IAAI,CAAC;QACxC,MAAMb,UAAUD,mBAAmBc,UAAU,OAAO,EAAEZ;QACtD,IAAI,AAA+B,YAA/B,OAAOA,SAAS,UAAU,EAC1BuB,OAAO,IAAI,CAAC;YACR,MAAMX,UAAU,IAAI;YACpB,OAAO;gBAAE,YAAYZ,SAAS,UAAU;YAAC;YACzCD;QACJ;aACG,IAAIC,AAAkB,QAAlBA,SAAS,KAAK,EACrBuB,OAAO,IAAI,CAAC;YAAE,MAAMX,UAAU,IAAI;YAAE,OAAOR,OAAOJ,SAAS,KAAK;YAAGD;QAAQ;IAEnF;IACA,OAAOwB;AACX;AAEO,SAASC,qBACZlB,UAAqE;IAErE,IAAI,CAACA,cAAcA,AAAsB,MAAtBA,WAAW,MAAM,EAChC,OAAO;QAAE,UAAU;QAAO,QAAQC;IAAU;IAGhD,IAAIC,WAAW;IACf,IAAIC;IACJ,IAAIgB,cAAcX,EAAE,KAAK,CAACA,EAAE,OAAO;IAEnC,KAAK,MAAMH,KAAKL,WAAY;QACxB,MAAMM,YAAYD;QAClB,MAAMX,WAAWY,UAAU,QAAQ,IAAI,CAAC;QACxC,MAAMC,MAAMf,mBAAmBc,UAAU,OAAO,EAAEZ;QAElD,OAAQY,UAAU,IAAI;YAClB,KAAK;gBACDJ,WAAW;gBACXC,kBAAkBI;gBAClB;YAEJ,KAAK;gBACD,IAAIb,AAAkB,QAAlBA,SAAS,KAAK,EACdyB,cAAcA,YAAY,GAAG,CACzBV,OAAOf,SAAS,KAAK,GACrBa,OAAON;gBAGf;YAEJ,KAAK;gBACD,IAAIP,AAAkB,QAAlBA,SAAS,KAAK,EACdyB,cAAcA,YAAY,GAAG,CACzBV,OAAOf,SAAS,KAAK,GACrBa,OAAON;gBAGf;QACR;IACJ;IAEA,MAAMmB,iBAAiBpB,WAAW,IAAI,CAClCK,CAAAA,IACKA,AAAsC,gBAAtCA,EAA6B,IAAI,IACjCA,AAAsC,gBAAtCA,EAA6B,IAAI;IAG1C,OAAO;QACHH;QACAC;QACA,QAAQiB,iBAAiBD,cAAclB;IAC3C;AACJ"}
|
|
@@ -2,13 +2,13 @@ import { createFeature } from "@webiny/feature/admin";
|
|
|
2
2
|
import { CmsFormModelBuilder } from "./abstractions.js";
|
|
3
3
|
import { CmsFormModelBuilder as external_CmsFormModelBuilder_js_CmsFormModelBuilder } from "./CmsFormModelBuilder.js";
|
|
4
4
|
import { CmsRefFieldType } from "./CmsRefFieldType.js";
|
|
5
|
-
import {
|
|
5
|
+
import { CmsRefFieldValueFormatter } from "./CmsRefFieldValueFormatter.js";
|
|
6
6
|
const CmsFormModelFeature = createFeature({
|
|
7
7
|
name: "CmsFormModel",
|
|
8
8
|
register (container) {
|
|
9
9
|
container.register(external_CmsFormModelBuilder_js_CmsFormModelBuilder).inSingletonScope();
|
|
10
10
|
container.register(CmsRefFieldType);
|
|
11
|
-
container.register(
|
|
11
|
+
container.register(CmsRefFieldValueFormatter);
|
|
12
12
|
},
|
|
13
13
|
resolve (container) {
|
|
14
14
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/formModel/feature.js","sources":["../../../src/features/formModel/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { CmsFormModelBuilder as CmsFormModelBuilderAbstraction } from \"./abstractions.js\";\nimport { CmsFormModelBuilder } from \"./CmsFormModelBuilder.js\";\nimport { CmsRefFieldType } from \"./CmsRefFieldType.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/formModel/feature.js","sources":["../../../src/features/formModel/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { CmsFormModelBuilder as CmsFormModelBuilderAbstraction } from \"./abstractions.js\";\nimport { CmsFormModelBuilder } from \"./CmsFormModelBuilder.js\";\nimport { CmsRefFieldType } from \"./CmsRefFieldType.js\";\nimport { CmsRefFieldValueFormatter } from \"./CmsRefFieldValueFormatter.js\";\n\nexport const CmsFormModelFeature = createFeature({\n name: \"CmsFormModel\",\n register(container) {\n container.register(CmsFormModelBuilder).inSingletonScope();\n container.register(CmsRefFieldType);\n container.register(CmsRefFieldValueFormatter);\n },\n resolve(container) {\n return {\n builder: container.resolve(CmsFormModelBuilderAbstraction)\n };\n }\n});\n"],"names":["CmsFormModelFeature","createFeature","container","CmsFormModelBuilder","CmsRefFieldType","CmsRefFieldValueFormatter","CmsFormModelBuilderAbstraction"],"mappings":";;;;;AAMO,MAAMA,sBAAsBC,cAAc;IAC7C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,qDAAqB,gBAAgB;QACxDD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;IACvB;IACA,SAAQH,SAAS;QACb,OAAO;YACH,SAASA,UAAU,OAAO,CAACI;QAC/B;IACJ;AACJ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { applyFieldProps } from "./applyFieldProps.js";
|
|
2
|
+
import { mapCmsDateLimits } from "../CmsValidationMapper.js";
|
|
2
3
|
class DateTimeFieldMapper {
|
|
3
4
|
map(field, registry, context) {
|
|
4
5
|
const builder = registry.datetime();
|
|
@@ -18,6 +19,8 @@ class DateTimeFieldMapper {
|
|
|
18
19
|
builder.withoutTimezone();
|
|
19
20
|
break;
|
|
20
21
|
}
|
|
22
|
+
for (const limit of mapCmsDateLimits(field.validation))if ("dateGte" === limit.name) builder.dateGte(limit.bound, limit.message);
|
|
23
|
+
else builder.dateLte(limit.bound, limit.message);
|
|
21
24
|
return builder;
|
|
22
25
|
}
|
|
23
26
|
constructor(){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/formModel/mappers/DateTimeFieldMapper.js","sources":["../../../../src/features/formModel/mappers/DateTimeFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type { IFieldBuilderRegistry } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\n\nexport class DateTimeFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"datetime\";\n\n map(field: CmsModelField, registry: IFieldBuilderRegistry, context: ICmsFieldMapperContext) {\n const builder = registry.datetime();\n applyFieldProps(builder, field, context.rendererMap);\n\n const subtype = field.settings?.type as string | undefined;\n switch (subtype) {\n case \"date\":\n builder.dateOnly();\n break;\n case \"time\":\n builder.timeOnly();\n break;\n case \"dateTimeWithTimezone\":\n builder.withTimezone();\n break;\n case \"dateTimeWithoutTimezone\":\n builder.withoutTimezone();\n break;\n }\n\n return builder;\n }\n}\n"],"names":["DateTimeFieldMapper","field","registry","context","builder","applyFieldProps","subtype"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/formModel/mappers/DateTimeFieldMapper.js","sources":["../../../../src/features/formModel/mappers/DateTimeFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type { IFieldBuilderRegistry } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport { mapCmsDateLimits } from \"../CmsValidationMapper.js\";\n\nexport class DateTimeFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"datetime\";\n\n map(field: CmsModelField, registry: IFieldBuilderRegistry, context: ICmsFieldMapperContext) {\n const builder = registry.datetime();\n applyFieldProps(builder, field, context.rendererMap);\n\n const subtype = field.settings?.type as string | undefined;\n switch (subtype) {\n case \"date\":\n builder.dateOnly();\n break;\n case \"time\":\n builder.timeOnly();\n break;\n case \"dateTimeWithTimezone\":\n builder.withTimezone();\n break;\n case \"dateTimeWithoutTimezone\":\n builder.withoutTimezone();\n break;\n }\n\n for (const limit of mapCmsDateLimits(field.validation)) {\n if (limit.name === \"dateGte\") {\n builder.dateGte(limit.bound, limit.message);\n } else {\n builder.dateLte(limit.bound, limit.message);\n }\n }\n\n return builder;\n }\n}\n"],"names":["DateTimeFieldMapper","field","registry","context","builder","applyFieldProps","subtype","limit","mapCmsDateLimits"],"mappings":";;AAMO,MAAMA;IAGT,IAAIC,KAAoB,EAAEC,QAA+B,EAAEC,OAA+B,EAAE;QACxF,MAAMC,UAAUF,SAAS,QAAQ;QACjCG,gBAAgBD,SAASH,OAAOE,QAAQ,WAAW;QAEnD,MAAMG,UAAUL,MAAM,QAAQ,EAAE;QAChC,OAAQK;YACJ,KAAK;gBACDF,QAAQ,QAAQ;gBAChB;YACJ,KAAK;gBACDA,QAAQ,QAAQ;gBAChB;YACJ,KAAK;gBACDA,QAAQ,YAAY;gBACpB;YACJ,KAAK;gBACDA,QAAQ,eAAe;gBACvB;QACR;QAEA,KAAK,MAAMG,SAASC,iBAAiBP,MAAM,UAAU,EACjD,IAAIM,AAAe,cAAfA,MAAM,IAAI,EACVH,QAAQ,OAAO,CAACG,MAAM,KAAK,EAAEA,MAAM,OAAO;aAE1CH,QAAQ,OAAO,CAACG,MAAM,KAAK,EAAEA,MAAM,OAAO;QAIlD,OAAOH;IACX;;aA/BS,IAAI,GAAG;;AAgCpB"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { applyFieldProps } from "./applyFieldProps.js";
|
|
2
|
+
import { mapCmsNestedLayout } from "../CmsLayoutMapper.js";
|
|
3
|
+
import { generateAlphaNumericLowerCaseId } from "@webiny/utils/generateId";
|
|
2
4
|
class DynamicZoneFieldMapper {
|
|
3
5
|
map(field, registry, context) {
|
|
4
6
|
const builder = registry.object();
|
|
5
7
|
const templates = field.settings?.templates;
|
|
6
8
|
if (templates) for (const template of templates)builder.template(template.id, (t)=>{
|
|
7
9
|
t.label(template.name);
|
|
10
|
+
if (template.description) t.description(template.description);
|
|
8
11
|
if (template.icon) {
|
|
9
12
|
const icon = template.icon;
|
|
10
13
|
if ("object" == typeof icon && "name" in icon) t.icon(icon);
|
|
@@ -13,11 +16,14 @@ class DynamicZoneFieldMapper {
|
|
|
13
16
|
name: icon
|
|
14
17
|
});
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
t.fields((childRegistry)=>{
|
|
17
20
|
const result = {};
|
|
18
|
-
|
|
21
|
+
result["_id"] = childRegistry.text().hidden().defaultValue(()=>generateAlphaNumericLowerCaseId(12)).cloneValue(()=>generateAlphaNumericLowerCaseId(12));
|
|
22
|
+
if (template.fields && template.fields.length > 0) for (const child of template.fields)result[child.fieldId] = context.mapField(child, childRegistry);
|
|
19
23
|
return result;
|
|
20
24
|
});
|
|
25
|
+
const layout = mapCmsNestedLayout(template.layout, template.fields ?? []);
|
|
26
|
+
if (layout) t.layout(layout);
|
|
21
27
|
});
|
|
22
28
|
return applyFieldProps(builder, field, context.rendererMap);
|
|
23
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/formModel/mappers/DynamicZoneFieldMapper.js","sources":["../../../../src/features/formModel/mappers/DynamicZoneFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type {\n IFieldBuilder,\n IFieldBuilderRegistry,\n IObjectFieldBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField, CmsDynamicZoneTemplate } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport type { ITemplateIcon } from \"@webiny/app-admin/features/formModel/index.js\";\n\nexport class DynamicZoneFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"dynamicZone\";\n\n map(\n field: CmsModelField,\n registry: IFieldBuilderRegistry,\n context: ICmsFieldMapperContext\n ): IFieldBuilder {\n const builder = registry.object() as IObjectFieldBuilder;\n\n const templates = field.settings?.templates as CmsDynamicZoneTemplate[] | undefined;\n if (templates) {\n for (const template of templates) {\n builder.template(template.id, t => {\n t.label(template.name);\n if (template.icon) {\n const icon = template.icon;\n if (typeof icon === \"object\" && \"name\" in icon) {\n t.icon(icon as ITemplateIcon);\n } else if (typeof icon === \"string\") {\n t.icon({ type: \"icon\", name: icon });\n }\n }\n
|
|
1
|
+
{"version":3,"file":"features/formModel/mappers/DynamicZoneFieldMapper.js","sources":["../../../../src/features/formModel/mappers/DynamicZoneFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type {\n IFieldBuilder,\n IFieldBuilderRegistry,\n IObjectFieldBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField, CmsDynamicZoneTemplate } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport { mapCmsNestedLayout } from \"../CmsLayoutMapper.js\";\nimport type { ITemplateIcon } from \"@webiny/app-admin/features/formModel/index.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils/generateId\";\n\nexport class DynamicZoneFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"dynamicZone\";\n\n map(\n field: CmsModelField,\n registry: IFieldBuilderRegistry,\n context: ICmsFieldMapperContext\n ): IFieldBuilder {\n const builder = registry.object() as IObjectFieldBuilder;\n\n const templates = field.settings?.templates as CmsDynamicZoneTemplate[] | undefined;\n if (templates) {\n for (const template of templates) {\n builder.template(template.id, t => {\n t.label(template.name);\n if (template.description) {\n t.description(template.description);\n }\n if (template.icon) {\n const icon = template.icon;\n if (typeof icon === \"object\" && \"name\" in icon) {\n t.icon(icon as ITemplateIcon);\n } else if (typeof icon === \"string\") {\n t.icon({ type: \"icon\", name: icon });\n }\n }\n t.fields(childRegistry => {\n const result: Record<string, IFieldBuilder> = {};\n result[\"_id\"] = childRegistry\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericLowerCaseId(12))\n .cloneValue(() => generateAlphaNumericLowerCaseId(12));\n if (template.fields && template.fields.length > 0) {\n for (const child of template.fields) {\n result[child.fieldId] = context.mapField(child, childRegistry);\n }\n }\n return result;\n });\n const layout = mapCmsNestedLayout(template.layout, template.fields ?? []);\n if (layout) {\n t.layout(layout);\n }\n });\n }\n }\n\n return applyFieldProps(builder, field, context.rendererMap);\n }\n}\n"],"names":["DynamicZoneFieldMapper","field","registry","context","builder","templates","template","t","icon","childRegistry","result","generateAlphaNumericLowerCaseId","child","layout","mapCmsNestedLayout","applyFieldProps"],"mappings":";;;AAYO,MAAMA;IAGT,IACIC,KAAoB,EACpBC,QAA+B,EAC/BC,OAA+B,EAClB;QACb,MAAMC,UAAUF,SAAS,MAAM;QAE/B,MAAMG,YAAYJ,MAAM,QAAQ,EAAE;QAClC,IAAII,WACA,KAAK,MAAMC,YAAYD,UACnBD,QAAQ,QAAQ,CAACE,SAAS,EAAE,EAAEC,CAAAA;YAC1BA,EAAE,KAAK,CAACD,SAAS,IAAI;YACrB,IAAIA,SAAS,WAAW,EACpBC,EAAE,WAAW,CAACD,SAAS,WAAW;YAEtC,IAAIA,SAAS,IAAI,EAAE;gBACf,MAAME,OAAOF,SAAS,IAAI;gBAC1B,IAAI,AAAgB,YAAhB,OAAOE,QAAqB,UAAUA,MACtCD,EAAE,IAAI,CAACC;qBACJ,IAAI,AAAgB,YAAhB,OAAOA,MACdD,EAAE,IAAI,CAAC;oBAAE,MAAM;oBAAQ,MAAMC;gBAAK;YAE1C;YACAD,EAAE,MAAM,CAACE,CAAAA;gBACL,MAAMC,SAAwC,CAAC;gBAC/CA,MAAM,CAAC,MAAM,GAAGD,cACX,IAAI,GACJ,MAAM,GACN,YAAY,CAAC,IAAME,gCAAgC,KACnD,UAAU,CAAC,IAAMA,gCAAgC;gBACtD,IAAIL,SAAS,MAAM,IAAIA,SAAS,MAAM,CAAC,MAAM,GAAG,GAC5C,KAAK,MAAMM,SAASN,SAAS,MAAM,CAC/BI,MAAM,CAACE,MAAM,OAAO,CAAC,GAAGT,QAAQ,QAAQ,CAACS,OAAOH;gBAGxD,OAAOC;YACX;YACA,MAAMG,SAASC,mBAAmBR,SAAS,MAAM,EAAEA,SAAS,MAAM,IAAI,EAAE;YACxE,IAAIO,QACAN,EAAE,MAAM,CAACM;QAEjB;QAIR,OAAOE,gBAAgBX,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aAhDS,IAAI,GAAG;;AAiDpB"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { applyFieldProps } from "./applyFieldProps.js";
|
|
2
|
+
import { mapCmsNestedLayout } from "../CmsLayoutMapper.js";
|
|
3
|
+
import { generateAlphaNumericLowerCaseId } from "@webiny/utils/generateId";
|
|
2
4
|
class ObjectFieldMapper {
|
|
3
5
|
map(field, registry, context) {
|
|
4
6
|
const builder = registry.object();
|
|
5
7
|
const childFields = field.settings?.fields;
|
|
6
|
-
if (childFields && childFields.length > 0)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
if (childFields && childFields.length > 0) {
|
|
9
|
+
builder.fields((childRegistry)=>{
|
|
10
|
+
const result = {};
|
|
11
|
+
result["_id"] = childRegistry.text().hidden().defaultValue(()=>generateAlphaNumericLowerCaseId(12)).cloneValue(()=>generateAlphaNumericLowerCaseId(12));
|
|
12
|
+
for (const child of childFields)result[child.fieldId] = context.mapField(child, childRegistry);
|
|
13
|
+
return result;
|
|
14
|
+
});
|
|
15
|
+
const layout = mapCmsNestedLayout(field.settings?.layout, childFields);
|
|
16
|
+
if (layout) builder.layout(layout);
|
|
17
|
+
}
|
|
11
18
|
return applyFieldProps(builder, field, context.rendererMap);
|
|
12
19
|
}
|
|
13
20
|
constructor(){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/formModel/mappers/ObjectFieldMapper.js","sources":["../../../../src/features/formModel/mappers/ObjectFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type {\n IFieldBuilder,\n IFieldBuilderRegistry,\n IObjectFieldBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\n\nexport class ObjectFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"object\";\n\n map(\n field: CmsModelField,\n registry: IFieldBuilderRegistry,\n context: ICmsFieldMapperContext\n ): IFieldBuilder {\n const builder = registry.object() as IObjectFieldBuilder;\n\n const childFields = field.settings?.fields;\n if (childFields && childFields.length > 0) {\n builder.fields(childRegistry => {\n const result: Record<string, IFieldBuilder> = {};\n for (const child of childFields) {\n result[child.fieldId] = context.mapField(child, childRegistry);\n }\n return result;\n });\n }\n\n return applyFieldProps(builder, field, context.rendererMap);\n }\n}\n"],"names":["ObjectFieldMapper","field","registry","context","builder","childFields","childRegistry","result","child","applyFieldProps"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/formModel/mappers/ObjectFieldMapper.js","sources":["../../../../src/features/formModel/mappers/ObjectFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type {\n IFieldBuilder,\n IFieldBuilderRegistry,\n IObjectFieldBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport { mapCmsNestedLayout } from \"../CmsLayoutMapper.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils/generateId\";\n\nexport class ObjectFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"object\";\n\n map(\n field: CmsModelField,\n registry: IFieldBuilderRegistry,\n context: ICmsFieldMapperContext\n ): IFieldBuilder {\n const builder = registry.object() as IObjectFieldBuilder;\n\n const childFields = field.settings?.fields;\n if (childFields && childFields.length > 0) {\n builder.fields(childRegistry => {\n const result: Record<string, IFieldBuilder> = {};\n result[\"_id\"] = childRegistry\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericLowerCaseId(12))\n .cloneValue(() => generateAlphaNumericLowerCaseId(12));\n for (const child of childFields) {\n result[child.fieldId] = context.mapField(child, childRegistry);\n }\n return result;\n });\n\n const layout = mapCmsNestedLayout(field.settings?.layout, childFields);\n if (layout) {\n builder.layout(layout);\n }\n }\n\n return applyFieldProps(builder, field, context.rendererMap);\n }\n}\n"],"names":["ObjectFieldMapper","field","registry","context","builder","childFields","childRegistry","result","generateAlphaNumericLowerCaseId","child","layout","mapCmsNestedLayout","applyFieldProps"],"mappings":";;;AAWO,MAAMA;IAGT,IACIC,KAAoB,EACpBC,QAA+B,EAC/BC,OAA+B,EAClB;QACb,MAAMC,UAAUF,SAAS,MAAM;QAE/B,MAAMG,cAAcJ,MAAM,QAAQ,EAAE;QACpC,IAAII,eAAeA,YAAY,MAAM,GAAG,GAAG;YACvCD,QAAQ,MAAM,CAACE,CAAAA;gBACX,MAAMC,SAAwC,CAAC;gBAC/CA,MAAM,CAAC,MAAM,GAAGD,cACX,IAAI,GACJ,MAAM,GACN,YAAY,CAAC,IAAME,gCAAgC,KACnD,UAAU,CAAC,IAAMA,gCAAgC;gBACtD,KAAK,MAAMC,SAASJ,YAChBE,MAAM,CAACE,MAAM,OAAO,CAAC,GAAGN,QAAQ,QAAQ,CAACM,OAAOH;gBAEpD,OAAOC;YACX;YAEA,MAAMG,SAASC,mBAAmBV,MAAM,QAAQ,EAAE,QAAQI;YAC1D,IAAIK,QACAN,QAAQ,MAAM,CAACM;QAEvB;QAEA,OAAOE,gBAAgBR,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aA/BS,IAAI,GAAG;;AAgCpB"}
|
|
@@ -9,6 +9,7 @@ function applyFieldProps(builder, field, rendererMap) {
|
|
|
9
9
|
if (Array.isArray(field.tags)) builder.tags(field.tags);
|
|
10
10
|
if (field.settings?.defaultValue != null) builder.defaultValue(field.settings.defaultValue);
|
|
11
11
|
if (field.list) builder.list();
|
|
12
|
+
if (field.disabled) builder.disabled(true);
|
|
12
13
|
if (field.predefinedValues?.enabled && field.predefinedValues.values) {
|
|
13
14
|
const optionsBuilder = builder;
|
|
14
15
|
if ("function" == typeof optionsBuilder.options) optionsBuilder.options(field.predefinedValues.values.map((v)=>({
|
|
@@ -38,7 +39,7 @@ function applyFieldProps(builder, field, rendererMap) {
|
|
|
38
39
|
type: r.type,
|
|
39
40
|
target: r.target,
|
|
40
41
|
operator: r.operator,
|
|
41
|
-
value:
|
|
42
|
+
value: r.value ?? null,
|
|
42
43
|
action: r.action
|
|
43
44
|
})));
|
|
44
45
|
if (field.tags && field.tags.length > 0) builder.tags(field.tags);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/formModel/mappers/applyFieldProps.js","sources":["../../../../src/features/formModel/mappers/applyFieldProps.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { IFieldBuilder } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { mapCmsValidators, mapCmsListValidators } from \"../CmsValidationMapper.js\";\n\nexport function applyFieldProps(\n builder: IFieldBuilder,\n field: CmsModelField,\n rendererMap: Map<string, string>\n): IFieldBuilder {\n if (field.label) {\n builder.label(field.label);\n }\n if (field.help) {\n builder.help(String(field.help));\n }\n if (field.description) {\n builder.description(String(field.description));\n }\n if (field.note) {\n builder.note(String(field.note));\n }\n if (field.placeholder) {\n builder.placeholder(field.placeholder);\n }\n\n if (Array.isArray(field.tags)) {\n builder.tags(field.tags);\n }\n\n if (field.settings?.defaultValue != null) {\n builder.defaultValue(field.settings.defaultValue);\n }\n\n if (field.list) {\n builder.list();\n }\n\n if (field.predefinedValues?.enabled && field.predefinedValues.values) {\n const optionsBuilder = builder as any;\n if (typeof optionsBuilder.options === \"function\") {\n optionsBuilder.options(\n field.predefinedValues.values.map(\n (v: { label: string; value: string; selected?: boolean }) => ({\n label: v.label,\n value: v.value\n })\n )\n );\n }\n }\n\n if (field.list) {\n const itemResult = mapCmsValidators(field.validation);\n const listResult = mapCmsListValidators(field.listValidation);\n\n if (itemResult.required || listResult.required) {\n builder.required(itemResult.requiredMessage || listResult.requiredMessage);\n }\n\n const itemSchema = itemResult.schema ? z.array(itemResult.schema) : null;\n const listSchema = listResult.schema;\n\n if (itemSchema && listSchema) {\n builder.schema(z.intersection(itemSchema, listSchema));\n } else if (itemSchema) {\n builder.schema(itemSchema);\n } else if (listSchema) {\n builder.schema(listSchema);\n }\n } else {\n const { required, requiredMessage, schema } = mapCmsValidators(field.validation);\n if (required) {\n builder.required(requiredMessage);\n }\n if (schema) {\n builder.schema(schema);\n }\n }\n\n if (field.renderer && typeof field.renderer === \"object\") {\n const mappedRenderer = rendererMap.get(field.renderer.name);\n if (mappedRenderer) {\n builder.renderer(mappedRenderer as any, field.renderer.settings);\n }\n }\n\n if (field.rules && field.rules.length > 0) {\n builder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value
|
|
1
|
+
{"version":3,"file":"features/formModel/mappers/applyFieldProps.js","sources":["../../../../src/features/formModel/mappers/applyFieldProps.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { IFieldBuilder } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { mapCmsValidators, mapCmsListValidators } from \"../CmsValidationMapper.js\";\n\nexport function applyFieldProps(\n builder: IFieldBuilder,\n field: CmsModelField,\n rendererMap: Map<string, string>\n): IFieldBuilder {\n if (field.label) {\n builder.label(field.label);\n }\n if (field.help) {\n builder.help(String(field.help));\n }\n if (field.description) {\n builder.description(String(field.description));\n }\n if (field.note) {\n builder.note(String(field.note));\n }\n if (field.placeholder) {\n builder.placeholder(field.placeholder);\n }\n\n if (Array.isArray(field.tags)) {\n builder.tags(field.tags);\n }\n\n if (field.settings?.defaultValue != null) {\n builder.defaultValue(field.settings.defaultValue);\n }\n\n if (field.list) {\n builder.list();\n }\n\n if (field.disabled) {\n builder.disabled(true);\n }\n\n if (field.predefinedValues?.enabled && field.predefinedValues.values) {\n const optionsBuilder = builder as any;\n if (typeof optionsBuilder.options === \"function\") {\n optionsBuilder.options(\n field.predefinedValues.values.map(\n (v: { label: string; value: string; selected?: boolean }) => ({\n label: v.label,\n value: v.value\n })\n )\n );\n }\n }\n\n if (field.list) {\n const itemResult = mapCmsValidators(field.validation);\n const listResult = mapCmsListValidators(field.listValidation);\n\n if (itemResult.required || listResult.required) {\n builder.required(itemResult.requiredMessage || listResult.requiredMessage);\n }\n\n const itemSchema = itemResult.schema ? z.array(itemResult.schema) : null;\n const listSchema = listResult.schema;\n\n if (itemSchema && listSchema) {\n builder.schema(z.intersection(itemSchema, listSchema));\n } else if (itemSchema) {\n builder.schema(itemSchema);\n } else if (listSchema) {\n builder.schema(listSchema);\n }\n } else {\n const { required, requiredMessage, schema } = mapCmsValidators(field.validation);\n if (required) {\n builder.required(requiredMessage);\n }\n if (schema) {\n builder.schema(schema);\n }\n }\n\n if (field.renderer && typeof field.renderer === \"object\") {\n const mappedRenderer = rendererMap.get(field.renderer.name);\n if (mappedRenderer) {\n builder.renderer(mappedRenderer as any, field.renderer.settings);\n }\n }\n\n if (field.rules && field.rules.length > 0) {\n builder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n\n if (field.tags && field.tags.length > 0) {\n builder.tags(field.tags);\n }\n\n return builder;\n}\n"],"names":["applyFieldProps","builder","field","rendererMap","String","Array","optionsBuilder","v","itemResult","mapCmsValidators","listResult","mapCmsListValidators","itemSchema","z","listSchema","required","requiredMessage","schema","mappedRenderer","r"],"mappings":";;AAKO,SAASA,gBACZC,OAAsB,EACtBC,KAAoB,EACpBC,WAAgC;IAEhC,IAAID,MAAM,KAAK,EACXD,QAAQ,KAAK,CAACC,MAAM,KAAK;IAE7B,IAAIA,MAAM,IAAI,EACVD,QAAQ,IAAI,CAACG,OAAOF,MAAM,IAAI;IAElC,IAAIA,MAAM,WAAW,EACjBD,QAAQ,WAAW,CAACG,OAAOF,MAAM,WAAW;IAEhD,IAAIA,MAAM,IAAI,EACVD,QAAQ,IAAI,CAACG,OAAOF,MAAM,IAAI;IAElC,IAAIA,MAAM,WAAW,EACjBD,QAAQ,WAAW,CAACC,MAAM,WAAW;IAGzC,IAAIG,MAAM,OAAO,CAACH,MAAM,IAAI,GACxBD,QAAQ,IAAI,CAACC,MAAM,IAAI;IAG3B,IAAIA,MAAM,QAAQ,EAAE,gBAAgB,MAChCD,QAAQ,YAAY,CAACC,MAAM,QAAQ,CAAC,YAAY;IAGpD,IAAIA,MAAM,IAAI,EACVD,QAAQ,IAAI;IAGhB,IAAIC,MAAM,QAAQ,EACdD,QAAQ,QAAQ,CAAC;IAGrB,IAAIC,MAAM,gBAAgB,EAAE,WAAWA,MAAM,gBAAgB,CAAC,MAAM,EAAE;QAClE,MAAMI,iBAAiBL;QACvB,IAAI,AAAkC,cAAlC,OAAOK,eAAe,OAAO,EAC7BA,eAAe,OAAO,CAClBJ,MAAM,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAC7B,CAACK,IAA6D;gBAC1D,OAAOA,EAAE,KAAK;gBACd,OAAOA,EAAE,KAAK;YAClB;IAIhB;IAEA,IAAIL,MAAM,IAAI,EAAE;QACZ,MAAMM,aAAaC,iBAAiBP,MAAM,UAAU;QACpD,MAAMQ,aAAaC,qBAAqBT,MAAM,cAAc;QAE5D,IAAIM,WAAW,QAAQ,IAAIE,WAAW,QAAQ,EAC1CT,QAAQ,QAAQ,CAACO,WAAW,eAAe,IAAIE,WAAW,eAAe;QAG7E,MAAME,aAAaJ,WAAW,MAAM,GAAGK,EAAE,KAAK,CAACL,WAAW,MAAM,IAAI;QACpE,MAAMM,aAAaJ,WAAW,MAAM;QAEpC,IAAIE,cAAcE,YACdb,QAAQ,MAAM,CAACY,EAAE,YAAY,CAACD,YAAYE;aACvC,IAAIF,YACPX,QAAQ,MAAM,CAACW;aACZ,IAAIE,YACPb,QAAQ,MAAM,CAACa;IAEvB,OAAO;QACH,MAAM,EAAEC,QAAQ,EAAEC,eAAe,EAAEC,MAAM,EAAE,GAAGR,iBAAiBP,MAAM,UAAU;QAC/E,IAAIa,UACAd,QAAQ,QAAQ,CAACe;QAErB,IAAIC,QACAhB,QAAQ,MAAM,CAACgB;IAEvB;IAEA,IAAIf,MAAM,QAAQ,IAAI,AAA0B,YAA1B,OAAOA,MAAM,QAAQ,EAAe;QACtD,MAAMgB,iBAAiBf,YAAY,GAAG,CAACD,MAAM,QAAQ,CAAC,IAAI;QAC1D,IAAIgB,gBACAjB,QAAQ,QAAQ,CAACiB,gBAAuBhB,MAAM,QAAQ,CAAC,QAAQ;IAEvE;IAEA,IAAIA,MAAM,KAAK,IAAIA,MAAM,KAAK,CAAC,MAAM,GAAG,GACpCD,QAAQ,KAAK,CACTC,MAAM,KAAK,CAAC,GAAG,CAACiB,CAAAA,IAAM;YAClB,MAAMA,EAAE,IAAI;YACZ,QAAQA,EAAE,MAAM;YAChB,UAAUA,EAAE,QAAQ;YACpB,OAAOA,EAAE,KAAK,IAAI;YAClB,QAAQA,EAAE,MAAM;QACpB;IAIR,IAAIjB,MAAM,IAAI,IAAIA,MAAM,IAAI,CAAC,MAAM,GAAG,GAClCD,QAAQ,IAAI,CAACC,MAAM,IAAI;IAG3B,OAAOD;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { Container } from "@webiny/di";
|
|
3
|
+
import { FormModelFeature } from "@webiny/app-admin/features/formModel/feature.js";
|
|
4
|
+
import { IdentityContextFeature } from "@webiny/app-admin/features/security/IdentityContext/feature.js";
|
|
5
|
+
import { FormModelFactory } from "@webiny/app-admin/features/formModel/abstractions.js";
|
|
6
|
+
import { applyFieldProps } from "./applyFieldProps.js";
|
|
7
|
+
const createField = (overrides)=>({
|
|
8
|
+
id: "externalId",
|
|
9
|
+
fieldId: "externalId",
|
|
10
|
+
storageId: "text@externalId",
|
|
11
|
+
type: "text",
|
|
12
|
+
label: "External ID",
|
|
13
|
+
renderer: {
|
|
14
|
+
name: "text-input"
|
|
15
|
+
},
|
|
16
|
+
validation: [],
|
|
17
|
+
listValidation: [],
|
|
18
|
+
...overrides
|
|
19
|
+
});
|
|
20
|
+
const buildForm = (field)=>{
|
|
21
|
+
const container = new Container();
|
|
22
|
+
IdentityContextFeature.register(container);
|
|
23
|
+
FormModelFeature.register(container);
|
|
24
|
+
return container.resolve(FormModelFactory).create({
|
|
25
|
+
fields: (registry)=>({
|
|
26
|
+
[field.fieldId]: applyFieldProps(registry.text(), field, new Map())
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
describe("applyFieldProps disabled", ()=>{
|
|
31
|
+
it("disables the form field when the model field is disabled", ()=>{
|
|
32
|
+
const form = buildForm(createField({
|
|
33
|
+
disabled: true
|
|
34
|
+
}));
|
|
35
|
+
expect(form.field("externalId").disabled).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
it("leaves the field editable when disabled is false or absent", ()=>{
|
|
38
|
+
expect(buildForm(createField({
|
|
39
|
+
disabled: false
|
|
40
|
+
})).field("externalId").disabled).toBe(false);
|
|
41
|
+
expect(buildForm(createField({})).field("externalId").disabled).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
it("keeps the field visible", ()=>{
|
|
44
|
+
const form = buildForm(createField({
|
|
45
|
+
disabled: true
|
|
46
|
+
}));
|
|
47
|
+
expect(form.field("externalId").visible).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
it("does not stop the field from holding a value", ()=>{
|
|
50
|
+
const form = buildForm(createField({
|
|
51
|
+
disabled: true
|
|
52
|
+
}));
|
|
53
|
+
form.field("externalId").setValue("abc-123");
|
|
54
|
+
expect(form.field("externalId").getValue()).toBe("abc-123");
|
|
55
|
+
expect(form.field("externalId").disabled).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=applyFieldProps.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/formModel/mappers/applyFieldProps.test.js","sources":["../../../../src/features/formModel/mappers/applyFieldProps.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { FormModelFeature } from \"@webiny/app-admin/features/formModel/feature.js\";\nimport { IdentityContextFeature } from \"@webiny/app-admin/features/security/IdentityContext/feature.js\";\nimport { FormModelFactory } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport type { CmsModelField } from \"~/types.js\";\n\nconst createField = (overrides: Partial<CmsModelField>): CmsModelField =>\n ({\n id: \"externalId\",\n fieldId: \"externalId\",\n storageId: \"text@externalId\",\n type: \"text\",\n label: \"External ID\",\n renderer: { name: \"text-input\" },\n validation: [],\n listValidation: [],\n ...overrides\n }) as CmsModelField;\n\n/**\n * Builds a one-field form the way CmsFormModelBuilder does, so we assert on the\n * field the entry form actually renders rather than on the builder in isolation.\n */\nconst buildForm = (field: CmsModelField) => {\n const container = new Container();\n IdentityContextFeature.register(container);\n FormModelFeature.register(container);\n\n return container.resolve(FormModelFactory).create({\n fields: registry => ({\n [field.fieldId]: applyFieldProps(registry.text(), field, new Map())\n })\n });\n};\n\ndescribe(\"applyFieldProps disabled\", () => {\n it(\"disables the form field when the model field is disabled\", () => {\n const form = buildForm(createField({ disabled: true }));\n\n expect(form.field(\"externalId\").disabled).toBe(true);\n });\n\n it(\"leaves the field editable when disabled is false or absent\", () => {\n expect(buildForm(createField({ disabled: false })).field(\"externalId\").disabled).toBe(\n false\n );\n expect(buildForm(createField({})).field(\"externalId\").disabled).toBe(false);\n });\n\n it(\"keeps the field visible\", () => {\n const form = buildForm(createField({ disabled: true }));\n\n expect(form.field(\"externalId\").visible).toBe(true);\n });\n\n it(\"does not stop the field from holding a value\", () => {\n const form = buildForm(createField({ disabled: true }));\n form.field(\"externalId\").setValue(\"abc-123\");\n\n expect(form.field(\"externalId\").getValue()).toBe(\"abc-123\");\n expect(form.field(\"externalId\").disabled).toBe(true);\n });\n});\n"],"names":["createField","overrides","buildForm","field","container","Container","IdentityContextFeature","FormModelFeature","FormModelFactory","registry","applyFieldProps","Map","describe","it","form","expect"],"mappings":";;;;;;AAQA,MAAMA,cAAc,CAACC,YAChB;QACG,IAAI;QACJ,SAAS;QACT,WAAW;QACX,MAAM;QACN,OAAO;QACP,UAAU;YAAE,MAAM;QAAa;QAC/B,YAAY,EAAE;QACd,gBAAgB,EAAE;QAClB,GAAGA,SAAS;IAChB;AAMJ,MAAMC,YAAY,CAACC;IACf,MAAMC,YAAY,IAAIC;IACtBC,uBAAuB,QAAQ,CAACF;IAChCG,iBAAiB,QAAQ,CAACH;IAE1B,OAAOA,UAAU,OAAO,CAACI,kBAAkB,MAAM,CAAC;QAC9C,QAAQC,CAAAA,WAAa;gBACjB,CAACN,MAAM,OAAO,CAAC,EAAEO,gBAAgBD,SAAS,IAAI,IAAIN,OAAO,IAAIQ;YACjE;IACJ;AACJ;AAEAC,SAAS,4BAA4B;IACjCC,GAAG,4DAA4D;QAC3D,MAAMC,OAAOZ,UAAUF,YAAY;YAAE,UAAU;QAAK;QAEpDe,OAAOD,KAAK,KAAK,CAAC,cAAc,QAAQ,EAAE,IAAI,CAAC;IACnD;IAEAD,GAAG,8DAA8D;QAC7DE,OAAOb,UAAUF,YAAY;YAAE,UAAU;QAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,EAAE,IAAI,CACjF;QAEJe,OAAOb,UAAUF,YAAY,CAAC,IAAI,KAAK,CAAC,cAAc,QAAQ,EAAE,IAAI,CAAC;IACzE;IAEAa,GAAG,2BAA2B;QAC1B,MAAMC,OAAOZ,UAAUF,YAAY;YAAE,UAAU;QAAK;QAEpDe,OAAOD,KAAK,KAAK,CAAC,cAAc,OAAO,EAAE,IAAI,CAAC;IAClD;IAEAD,GAAG,gDAAgD;QAC/C,MAAMC,OAAOZ,UAAUF,YAAY;YAAE,UAAU;QAAK;QACpDc,KAAK,KAAK,CAAC,cAAc,QAAQ,CAAC;QAElCC,OAAOD,KAAK,KAAK,CAAC,cAAc,QAAQ,IAAI,IAAI,CAAC;QACjDC,OAAOD,KAAK,KAAK,CAAC,cAAc,QAAQ,EAAE,IAAI,CAAC;IACnD;AACJ"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GraphQLOperationError } from "@webiny/app/errors/index.js";
|
|
1
2
|
import { CmsGraphQLClient } from "../../graphQLClient/abstractions.js";
|
|
2
3
|
import { DeleteModelGateway } from "./abstractions.js";
|
|
3
4
|
const FULLY_DELETE_CONTENT_MODEL = `
|
|
@@ -30,7 +31,11 @@ class DeleteModelGatewayImpl {
|
|
|
30
31
|
}
|
|
31
32
|
});
|
|
32
33
|
const { data: result, error } = response.fullyDeleteModel;
|
|
33
|
-
if (!result) throw new
|
|
34
|
+
if (!result) throw new GraphQLOperationError({
|
|
35
|
+
message: error?.message || "Could not delete content model",
|
|
36
|
+
code: error?.code,
|
|
37
|
+
data: error?.data
|
|
38
|
+
});
|
|
34
39
|
return result;
|
|
35
40
|
}
|
|
36
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/model/deleteModel/DeleteModelGateway.js","sources":["../../../../src/features/model/deleteModel/DeleteModelGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsErrorResponse } from \"~/types.js\";\nimport type { DeleteModelResult } from \"./abstractions.js\";\nimport { DeleteModelGateway as GatewayAbstraction } from \"./abstractions.js\";\n\ninterface DeleteModelResponse {\n fullyDeleteModel: {\n data: DeleteModelResult | null;\n error: CmsErrorResponse | null;\n };\n}\n\ninterface DeleteModelVariables {\n modelId: string;\n confirmation: string;\n}\n\nconst FULLY_DELETE_CONTENT_MODEL = /* GraphQL */ `\n mutation CmsFullyDeleteContentModel($modelId: ID!, $confirmation: String!) {\n fullyDeleteModel(modelId: $modelId, confirmation: $confirmation) {\n data {\n id\n status\n deleted\n total\n }\n error {\n message\n code\n data\n }\n }\n }\n`;\n\nclass DeleteModelGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: CmsGraphQLClient.Interface) {}\n\n async execute(modelId: string, confirmation: string) {\n const response = await this.client.execute<DeleteModelResponse, DeleteModelVariables>({\n query: FULLY_DELETE_CONTENT_MODEL,\n variables: { modelId, confirmation }\n });\n\n const { data: result, error } = response.fullyDeleteModel;\n\n if (!result) {\n throw new
|
|
1
|
+
{"version":3,"file":"features/model/deleteModel/DeleteModelGateway.js","sources":["../../../../src/features/model/deleteModel/DeleteModelGateway.ts"],"sourcesContent":["import { GraphQLOperationError } from \"@webiny/app/errors/index.js\";\nimport { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsErrorResponse } from \"~/types.js\";\nimport type { DeleteModelResult } from \"./abstractions.js\";\nimport { DeleteModelGateway as GatewayAbstraction } from \"./abstractions.js\";\n\ninterface DeleteModelResponse {\n fullyDeleteModel: {\n data: DeleteModelResult | null;\n error: CmsErrorResponse | null;\n };\n}\n\ninterface DeleteModelVariables {\n modelId: string;\n confirmation: string;\n}\n\nconst FULLY_DELETE_CONTENT_MODEL = /* GraphQL */ `\n mutation CmsFullyDeleteContentModel($modelId: ID!, $confirmation: String!) {\n fullyDeleteModel(modelId: $modelId, confirmation: $confirmation) {\n data {\n id\n status\n deleted\n total\n }\n error {\n message\n code\n data\n }\n }\n }\n`;\n\nclass DeleteModelGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: CmsGraphQLClient.Interface) {}\n\n async execute(modelId: string, confirmation: string) {\n const response = await this.client.execute<DeleteModelResponse, DeleteModelVariables>({\n query: FULLY_DELETE_CONTENT_MODEL,\n variables: { modelId, confirmation }\n });\n\n const { data: result, error } = response.fullyDeleteModel;\n\n if (!result) {\n // The typed error keeps the server's code and data, so a refusal can be shown as such.\n throw new GraphQLOperationError({\n message: error?.message || \"Could not delete content model\",\n code: error?.code,\n data: error?.data\n });\n }\n\n return result;\n }\n}\n\nexport const DeleteModelGateway = GatewayAbstraction.createImplementation({\n implementation: DeleteModelGatewayImpl,\n dependencies: [CmsGraphQLClient]\n});\n"],"names":["FULLY_DELETE_CONTENT_MODEL","DeleteModelGatewayImpl","client","modelId","confirmation","response","result","error","GraphQLOperationError","DeleteModelGateway","GatewayAbstraction","CmsGraphQLClient"],"mappings":";;;AAkBA,MAAMA,6BAA2C,CAAC;;;;;;;;;;;;;;;;AAgBlD,CAAC;AAED,MAAMC;IACF,YAAoBC,MAAkC,CAAE;aAApCA,MAAM,GAANA;IAAqC;IAEzD,MAAM,QAAQC,OAAe,EAAEC,YAAoB,EAAE;QACjD,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA4C;YAClF,OAAOL;YACP,WAAW;gBAAEG;gBAASC;YAAa;QACvC;QAEA,MAAM,EAAE,MAAME,MAAM,EAAEC,KAAK,EAAE,GAAGF,SAAS,gBAAgB;QAEzD,IAAI,CAACC,QAED,MAAM,IAAIE,sBAAsB;YAC5B,SAASD,OAAO,WAAW;YAC3B,MAAMA,OAAO;YACb,MAAMA,OAAO;QACjB;QAGJ,OAAOD;IACX;AACJ;AAEO,MAAMG,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBT;IAChB,cAAc;QAACU;KAAiB;AACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { Container } from "@webiny/di";
|
|
3
|
+
import { GraphQLOperationError } from "@webiny/app/errors/index.js";
|
|
4
|
+
import { CmsGraphQLClient } from "../../graphQLClient/abstractions.js";
|
|
5
|
+
import { DeleteModelGateway } from "./abstractions.js";
|
|
6
|
+
import { DeleteModelGateway as external_DeleteModelGateway_js_DeleteModelGateway } from "./DeleteModelGateway.js";
|
|
7
|
+
const blockedData = {
|
|
8
|
+
modelId: "article",
|
|
9
|
+
workflows: [
|
|
10
|
+
{
|
|
11
|
+
id: "wf1",
|
|
12
|
+
name: "Article review"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
};
|
|
16
|
+
function setup() {
|
|
17
|
+
const client = {
|
|
18
|
+
execute: vi.fn()
|
|
19
|
+
};
|
|
20
|
+
const container = new Container();
|
|
21
|
+
container.registerInstance(CmsGraphQLClient, client);
|
|
22
|
+
container.register(external_DeleteModelGateway_js_DeleteModelGateway).inSingletonScope();
|
|
23
|
+
const gateway = container.resolve(DeleteModelGateway);
|
|
24
|
+
return {
|
|
25
|
+
client,
|
|
26
|
+
gateway
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
describe("DeleteModelGateway", ()=>{
|
|
30
|
+
it("returns the result and sends the model id and the confirmation", async ()=>{
|
|
31
|
+
const { client, gateway } = setup();
|
|
32
|
+
const result = {
|
|
33
|
+
id: "task-1",
|
|
34
|
+
status: "pending",
|
|
35
|
+
deleted: 0,
|
|
36
|
+
total: 3
|
|
37
|
+
};
|
|
38
|
+
client.execute.mockResolvedValue({
|
|
39
|
+
fullyDeleteModel: {
|
|
40
|
+
data: result,
|
|
41
|
+
error: null
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
expect(await gateway.execute("article", "delete article")).toEqual(result);
|
|
45
|
+
const request = client.execute.mock.calls[0][0];
|
|
46
|
+
expect(request.variables).toEqual({
|
|
47
|
+
modelId: "article",
|
|
48
|
+
confirmation: "delete article"
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
it("throws a GraphQLOperationError carrying the code, data and message of the envelope error", async ()=>{
|
|
52
|
+
const { client, gateway } = setup();
|
|
53
|
+
client.execute.mockResolvedValue({
|
|
54
|
+
fullyDeleteModel: {
|
|
55
|
+
data: null,
|
|
56
|
+
error: {
|
|
57
|
+
message: "The model is used by a workflow.",
|
|
58
|
+
code: "Workflows/Model/BoundToWorkflow",
|
|
59
|
+
data: blockedData
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const error = await gateway.execute("article", "delete article").catch((ex)=>ex);
|
|
64
|
+
expect(error).toBeInstanceOf(GraphQLOperationError);
|
|
65
|
+
expect(error.message).toBe("The model is used by a workflow.");
|
|
66
|
+
expect(error.code).toBe("Workflows/Model/BoundToWorkflow");
|
|
67
|
+
expect(error.data).toEqual(blockedData);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=DeleteModelGateway.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/model/deleteModel/DeleteModelGateway.test.js","sources":["../../../../src/features/model/deleteModel/DeleteModelGateway.test.ts"],"sourcesContent":["import { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { GraphQLOperationError } from \"@webiny/app/errors/index.js\";\nimport { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport { DeleteModelGateway as GatewayAbstraction } from \"./abstractions.js\";\nimport { DeleteModelGateway } from \"./DeleteModelGateway.js\";\n\nconst blockedData = {\n modelId: \"article\",\n workflows: [{ id: \"wf1\", name: \"Article review\" }]\n};\n\nfunction setup() {\n const client = { execute: vi.fn() };\n const container = new Container();\n container.registerInstance(CmsGraphQLClient, client);\n container.register(DeleteModelGateway).inSingletonScope();\n const gateway = container.resolve(GatewayAbstraction);\n return { client, gateway };\n}\n\ndescribe(\"DeleteModelGateway\", () => {\n it(\"returns the result and sends the model id and the confirmation\", async () => {\n const { client, gateway } = setup();\n const result = { id: \"task-1\", status: \"pending\", deleted: 0, total: 3 };\n client.execute.mockResolvedValue({ fullyDeleteModel: { data: result, error: null } });\n\n expect(await gateway.execute(\"article\", \"delete article\")).toEqual(result);\n const request = client.execute.mock.calls[0][0];\n expect(request.variables).toEqual({ modelId: \"article\", confirmation: \"delete article\" });\n });\n\n it(\"throws a GraphQLOperationError carrying the code, data and message of the envelope error\", async () => {\n const { client, gateway } = setup();\n client.execute.mockResolvedValue({\n fullyDeleteModel: {\n data: null,\n error: {\n message: \"The model is used by a workflow.\",\n code: \"Workflows/Model/BoundToWorkflow\",\n data: blockedData\n }\n }\n });\n\n const error = await gateway.execute(\"article\", \"delete article\").catch(ex => ex);\n\n expect(error).toBeInstanceOf(GraphQLOperationError);\n expect(error.message).toBe(\"The model is used by a workflow.\");\n expect(error.code).toBe(\"Workflows/Model/BoundToWorkflow\");\n expect(error.data).toEqual(blockedData);\n });\n});\n"],"names":["blockedData","setup","client","vi","container","Container","CmsGraphQLClient","DeleteModelGateway","gateway","GatewayAbstraction","describe","it","result","expect","request","error","ex","GraphQLOperationError"],"mappings":";;;;;;AAUA,MAAMA,cAAc;IAChB,SAAS;IACT,WAAW;QAAC;YAAE,IAAI;YAAO,MAAM;QAAiB;KAAE;AACtD;AAEA,SAASC;IACL,MAAMC,SAAS;QAAE,SAASC,GAAG,EAAE;IAAG;IAClC,MAAMC,YAAY,IAAIC;IACtBD,UAAU,gBAAgB,CAACE,kBAAkBJ;IAC7CE,UAAU,QAAQ,CAACG,mDAAoB,gBAAgB;IACvD,MAAMC,UAAUJ,UAAU,OAAO,CAACK;IAClC,OAAO;QAAEP;QAAQM;IAAQ;AAC7B;AAEAE,SAAS,sBAAsB;IAC3BC,GAAG,kEAAkE;QACjE,MAAM,EAAET,MAAM,EAAEM,OAAO,EAAE,GAAGP;QAC5B,MAAMW,SAAS;YAAE,IAAI;YAAU,QAAQ;YAAW,SAAS;YAAG,OAAO;QAAE;QACvEV,OAAO,OAAO,CAAC,iBAAiB,CAAC;YAAE,kBAAkB;gBAAE,MAAMU;gBAAQ,OAAO;YAAK;QAAE;QAEnFC,OAAO,MAAML,QAAQ,OAAO,CAAC,WAAW,mBAAmB,OAAO,CAACI;QACnE,MAAME,UAAUZ,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;QAC/CW,OAAOC,QAAQ,SAAS,EAAE,OAAO,CAAC;YAAE,SAAS;YAAW,cAAc;QAAiB;IAC3F;IAEAH,GAAG,4FAA4F;QAC3F,MAAM,EAAET,MAAM,EAAEM,OAAO,EAAE,GAAGP;QAC5BC,OAAO,OAAO,CAAC,iBAAiB,CAAC;YAC7B,kBAAkB;gBACd,MAAM;gBACN,OAAO;oBACH,SAAS;oBACT,MAAM;oBACN,MAAMF;gBACV;YACJ;QACJ;QAEA,MAAMe,QAAQ,MAAMP,QAAQ,OAAO,CAAC,WAAW,kBAAkB,KAAK,CAACQ,CAAAA,KAAMA;QAE7EH,OAAOE,OAAO,cAAc,CAACE;QAC7BJ,OAAOE,MAAM,OAAO,EAAE,IAAI,CAAC;QAC3BF,OAAOE,MAAM,IAAI,EAAE,IAAI,CAAC;QACxBF,OAAOE,MAAM,IAAI,EAAE,OAAO,CAACf;IAC/B;AACJ"}
|
|
@@ -3,7 +3,7 @@ import { ExportModelsGateway as GatewayAbstraction } from "./abstractions.js";
|
|
|
3
3
|
declare class ExportModelsGatewayImpl implements GatewayAbstraction.Interface {
|
|
4
4
|
private client;
|
|
5
5
|
constructor(client: CmsGraphQLClient.Interface);
|
|
6
|
-
execute(models?: string[]): Promise<
|
|
6
|
+
execute(models?: string[]): Promise<string>;
|
|
7
7
|
}
|
|
8
8
|
export declare const ExportModelsGateway: typeof ExportModelsGatewayImpl & {
|
|
9
9
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IExportModelsGateway>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/model/exportModels/ExportModelsGateway.js","sources":["../../../../src/features/model/exportModels/ExportModelsGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsErrorResponse } from \"~/types.js\";\nimport { ExportModelsGateway as GatewayAbstraction } from \"./abstractions.js\";\n\ninterface ExportModelsResponse {\n exportStructure: {\n data:
|
|
1
|
+
{"version":3,"file":"features/model/exportModels/ExportModelsGateway.js","sources":["../../../../src/features/model/exportModels/ExportModelsGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsErrorResponse } from \"~/types.js\";\nimport { ExportModelsGateway as GatewayAbstraction } from \"./abstractions.js\";\n\ninterface ExportModelsResponse {\n exportStructure: {\n data: string;\n error: CmsErrorResponse | null;\n };\n}\n\ninterface ExportModelsVariables {\n models?: string[];\n}\n\nconst CMS_EXPORT_STRUCTURE_QUERY = /* GraphQL */ `\n query CmsExportStructure($models: [String!]) {\n exportStructure(models: $models) {\n data\n error {\n message\n code\n data\n }\n }\n }\n`;\n\nclass ExportModelsGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: CmsGraphQLClient.Interface) {}\n\n async execute(models?: string[]) {\n const response = await this.client.execute<ExportModelsResponse, ExportModelsVariables>({\n query: CMS_EXPORT_STRUCTURE_QUERY,\n variables: { models }\n });\n\n const { data, error } = response.exportStructure;\n\n if (error) {\n throw new Error(error.message);\n }\n\n return data;\n }\n}\n\nexport const ExportModelsGateway = GatewayAbstraction.createImplementation({\n implementation: ExportModelsGatewayImpl,\n dependencies: [CmsGraphQLClient]\n});\n"],"names":["CMS_EXPORT_STRUCTURE_QUERY","ExportModelsGatewayImpl","client","models","response","data","error","Error","ExportModelsGateway","GatewayAbstraction","CmsGraphQLClient"],"mappings":";;AAeA,MAAMA,6BAA2C,CAAC;;;;;;;;;;;AAWlD,CAAC;AAED,MAAMC;IACF,YAAoBC,MAAkC,CAAE;aAApCA,MAAM,GAANA;IAAqC;IAEzD,MAAM,QAAQC,MAAiB,EAAE;QAC7B,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA8C;YACpF,OAAOJ;YACP,WAAW;gBAAEG;YAAO;QACxB;QAEA,MAAM,EAAEE,IAAI,EAAEC,KAAK,EAAE,GAAGF,SAAS,eAAe;QAEhD,IAAIE,OACA,MAAM,IAAIC,MAAMD,MAAM,OAAO;QAGjC,OAAOD;IACX;AACJ;AAEO,MAAMG,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBR;IAChB,cAAc;QAACS;KAAiB;AACpC"}
|