@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/plugins/editor/defaultBar/Name/Name.js","sources":["../../../../../../src/admin/plugins/editor/defaultBar/Name/Name.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport { useHotkeys } from \"@webiny/app-admin\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { useModelEditor } from \"~/admin/hooks/index.js\";\nimport { EditableTitle } from \"@webiny/admin-ui\";\n\nconst t = i18n.namespace(\"ContentModelEditor.Name\");\n\
|
|
1
|
+
{"version":3,"file":"admin/plugins/editor/defaultBar/Name/Name.js","sources":["../../../../../../src/admin/plugins/editor/defaultBar/Name/Name.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport { useHotkeys } from \"@webiny/app-admin\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { useModelEditor } from \"~/admin/hooks/index.js\";\nimport { EditableTitle } from \"@webiny/admin-ui\";\n\nconst t = i18n.namespace(\"ContentModelEditor.Name\");\n\nexport const Name = () => {\n const { data, setData } = useModelEditor();\n const [editing, setEditing] = useState<boolean>(false);\n\n const saveName = useCallback(\n (name: string) => {\n setData(data => {\n data.name = name;\n return data;\n });\n },\n [setData]\n );\n\n useHotkeys({\n zIndex: 100,\n keys: {\n \"alt+cmd+enter\": () => setEditing(true)\n }\n });\n\n return (\n <EditableTitle\n value={data.name}\n onCommit={saveName}\n isEditing={editing}\n onEditingChange={setEditing}\n tooltip={<span>{t`Rename content model`}</span>}\n data-testid=\"cms-editor-model-title\"\n />\n );\n};\n"],"names":["t","i18n","Name","data","setData","useModelEditor","editing","setEditing","useState","saveName","useCallback","name","useHotkeys","EditableTitle"],"mappings":";;;;;AAMA,MAAMA,IAAIC,KAAK,SAAS,CAAC;AAElB,MAAMC,OAAO;IAChB,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAE,GAAGC;IAC1B,MAAM,CAACC,SAASC,WAAW,GAAGC,SAAkB;IAEhD,MAAMC,WAAWC,YACb,CAACC;QACGP,QAAQD,CAAAA;YACJA,KAAK,IAAI,GAAGQ;YACZ,OAAOR;QACX;IACJ,GACA;QAACC;KAAQ;IAGbQ,WAAW;QACP,QAAQ;QACR,MAAM;YACF,iBAAiB,IAAML,WAAW;QACtC;IACJ;IAEA,OAAO,WAAP,GACI,oBAACM,eAAaA;QACV,OAAOV,KAAK,IAAI;QAChB,UAAUM;QACV,WAAWH;QACX,iBAAiBC;QACjB,uBAAS,oBAAC,cAAMP,CAAC,CAAC,oBAAoB,CAAC;QACvC,eAAY;;AAGxB"}
|
|
@@ -65,22 +65,6 @@ const GeneralSettings = ({ Bind })=>/*#__PURE__*/ react.createElement(react.Frag
|
|
|
65
65
|
}, /*#__PURE__*/ react.createElement(Switch, {
|
|
66
66
|
label: "Generate with AI",
|
|
67
67
|
note: "Show an AI-powered wizard that generates content before opening the editor."
|
|
68
|
-
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
69
|
-
span: 6
|
|
70
|
-
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
71
|
-
name: "settings.previewPrefix"
|
|
72
|
-
}, /*#__PURE__*/ react.createElement(Input, {
|
|
73
|
-
label: "Preview URL Prefix",
|
|
74
|
-
placeholder: "http://localhost:3000/articles",
|
|
75
|
-
description: "Base URL for live preview."
|
|
76
|
-
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
77
|
-
span: 6
|
|
78
|
-
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
79
|
-
name: "settings.previewSlug"
|
|
80
|
-
}, /*#__PURE__*/ react.createElement(Input, {
|
|
81
|
-
label: "Preview Slug",
|
|
82
|
-
placeholder: "{values.slug}",
|
|
83
|
-
description: "Entry field pattern for the URL slug. Use {values.fieldId}."
|
|
84
68
|
})))));
|
|
85
69
|
const components_GeneralSettings = GeneralSettings;
|
|
86
70
|
export default components_GeneralSettings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/plugins/editor/formSettings/components/GeneralSettings.js","sources":["../../../../../../src/admin/plugins/editor/formSettings/components/GeneralSettings.tsx"],"sourcesContent":["import React from \"react\";\nimport { Grid, Input, Switch, Textarea, Tags } from \"@webiny/admin-ui\";\nimport { validation } from \"@webiny/validation\";\nimport type { BindComponent } from \"@webiny/form\";\nimport GroupSelect from \"./GroupSelect.js\";\nimport { IconPicker } from \"~/admin/components/IconPicker.js\";\n\ninterface GeneralSettingsProps {\n Bind: BindComponent;\n}\n\nconst GeneralSettings = ({ Bind }: GeneralSettingsProps) => {\n return (\n <React.Fragment>\n <Grid>\n <Grid.Column span={12}>\n <Bind name={\"name\"}>\n <Input label={\"Content model name\"} />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"modelId\"}>\n <Input disabled={true} label={\"Content model ID\"} />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"singularApiName\"}>\n <Input disabled={true} label={\"Singular API Name\"} />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"pluralApiName\"}>\n <Input disabled={true} label={\"Plural API Name\"} />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"description\"}>\n <Textarea rows={5} label={\"Content model description\"} />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"group\"} validators={validation.create(\"required\")}>\n <GroupSelect />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name=\"icon\">\n <IconPicker\n label={`Icon`}\n description={`Choose an icon to represent the model.`}\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"tags\"}>\n <Tags label={\"Tags\"} protectedValues={[\"type:model\"]} />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"settings.aiEntryWizard\"}>\n <Switch\n label={\"Generate with AI\"}\n note={\n \"Show an AI-powered wizard that generates content before opening the editor.\"\n }\n />\n </Bind>\n </Grid.Column>\n
|
|
1
|
+
{"version":3,"file":"admin/plugins/editor/formSettings/components/GeneralSettings.js","sources":["../../../../../../src/admin/plugins/editor/formSettings/components/GeneralSettings.tsx"],"sourcesContent":["import React from \"react\";\nimport { Grid, Input, Switch, Textarea, Tags } from \"@webiny/admin-ui\";\nimport { validation } from \"@webiny/validation\";\nimport type { BindComponent } from \"@webiny/form\";\nimport GroupSelect from \"./GroupSelect.js\";\nimport { IconPicker } from \"~/admin/components/IconPicker.js\";\n\ninterface GeneralSettingsProps {\n Bind: BindComponent;\n}\n\nconst GeneralSettings = ({ Bind }: GeneralSettingsProps) => {\n return (\n <React.Fragment>\n <Grid>\n <Grid.Column span={12}>\n <Bind name={\"name\"}>\n <Input label={\"Content model name\"} />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"modelId\"}>\n <Input disabled={true} label={\"Content model ID\"} />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"singularApiName\"}>\n <Input disabled={true} label={\"Singular API Name\"} />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"pluralApiName\"}>\n <Input disabled={true} label={\"Plural API Name\"} />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"description\"}>\n <Textarea rows={5} label={\"Content model description\"} />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"group\"} validators={validation.create(\"required\")}>\n <GroupSelect />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name=\"icon\">\n <IconPicker\n label={`Icon`}\n description={`Choose an icon to represent the model.`}\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"tags\"}>\n <Tags label={\"Tags\"} protectedValues={[\"type:model\"]} />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"settings.aiEntryWizard\"}>\n <Switch\n label={\"Generate with AI\"}\n note={\n \"Show an AI-powered wizard that generates content before opening the editor.\"\n }\n />\n </Bind>\n </Grid.Column>\n </Grid>\n </React.Fragment>\n );\n};\n\nexport default GeneralSettings;\n"],"names":["GeneralSettings","Bind","React","Grid","Input","Textarea","validation","GroupSelect","IconPicker","Tags","Switch"],"mappings":";;;;;AAWA,MAAMA,kBAAkB,CAAC,EAAEC,IAAI,EAAwB,GAC5C,WAAP,GACI,oBAACC,MAAAA,QAAc,sBACX,oBAACC,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACF,MAAAA;QAAK,MAAM;qBACR,oBAACG,OAAKA;QAAC,OAAO;wBAGtB,oBAACD,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACF,MAAAA;QAAK,MAAM;qBACR,oBAACG,OAAKA;QAAC,UAAU;QAAM,OAAO;wBAGtC,oBAACD,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACF,MAAAA;QAAK,MAAM;qBACR,oBAACG,OAAKA;QAAC,UAAU;QAAM,OAAO;wBAGtC,oBAACD,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACF,MAAAA;QAAK,MAAM;qBACR,oBAACG,OAAKA;QAAC,UAAU;QAAM,OAAO;wBAGtC,oBAACD,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACF,MAAAA;QAAK,MAAM;qBACR,oBAACI,UAAQA;QAAC,MAAM;QAAG,OAAO;wBAGlC,oBAACF,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACF,MAAAA;QAAK,MAAM;QAAS,YAAYK,WAAW,MAAM,CAAC;qBAC/C,oBAACC,aAAWA,SAAAA,WAAAA,GAGpB,oBAACJ,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACF,MAAAA;QAAK,MAAK;qBACP,oBAACO,YAAUA;QACP,OAAO;QACP,aAAa;wBAIzB,oBAACL,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACF,MAAAA;QAAK,MAAM;qBACR,oBAACQ,MAAIA;QAAC,OAAO;QAAQ,iBAAiB;YAAC;SAAa;wBAG5D,oBAACN,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACF,MAAAA;QAAK,MAAM;qBACR,oBAACS,QAAMA;QACH,OAAO;QACP,MACI;;AAUhC,mCAAeV"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Identity } from "@webiny/app-admin/domain/Identity.js";
|
|
2
|
+
import type { CmsSecurityPermission } from "../../types.js";
|
|
3
|
+
export interface CheckCmsPermissionParams {
|
|
4
|
+
identity: Identity;
|
|
5
|
+
/** The model the check is scoped to, through the `_src` groups; none checks without one. */
|
|
6
|
+
modelId: string | undefined;
|
|
7
|
+
permissionName: string;
|
|
8
|
+
check: (permission: CmsSecurityPermission) => boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The CMS permission check of `usePermission`, for code outside React (presenters): full access,
|
|
12
|
+
* else a permission named `permissionName` that passes `check`, scoped to the model when given.
|
|
13
|
+
*/
|
|
14
|
+
export declare const checkCmsPermission: (params: CheckCmsPermissionParams) => boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { hasAccessForModel } from "./hasAccessForModel.js";
|
|
2
|
+
const checkCmsPermission = (params)=>{
|
|
3
|
+
const { identity, modelId, permissionName, check } = params;
|
|
4
|
+
if (identity.getPermission("cms.*")) return true;
|
|
5
|
+
const permissions = identity.getPermissions(permissionName);
|
|
6
|
+
if (!permissions.length) return false;
|
|
7
|
+
if (modelId) {
|
|
8
|
+
const modelPermissions = identity.getPermissions("cms.contentModel") ?? [];
|
|
9
|
+
return hasAccessForModel({
|
|
10
|
+
permissions,
|
|
11
|
+
modelPermissions,
|
|
12
|
+
modelId,
|
|
13
|
+
check
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return permissions.some(check);
|
|
17
|
+
};
|
|
18
|
+
export { checkCmsPermission };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=checkCmsPermission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain/permissions/checkCmsPermission.js","sources":["../../../src/domain/permissions/checkCmsPermission.ts"],"sourcesContent":["import type { Identity } from \"@webiny/app-admin/domain/Identity.js\";\nimport type { CmsSecurityPermission } from \"~/types.js\";\nimport { hasAccessForModel } from \"./hasAccessForModel.js\";\n\nexport interface CheckCmsPermissionParams {\n identity: Identity;\n /** The model the check is scoped to, through the `_src` groups; none checks without one. */\n modelId: string | undefined;\n permissionName: string;\n check: (permission: CmsSecurityPermission) => boolean;\n}\n\n/**\n * The CMS permission check of `usePermission`, for code outside React (presenters): full access,\n * else a permission named `permissionName` that passes `check`, scoped to the model when given.\n */\nexport const checkCmsPermission = (params: CheckCmsPermissionParams): boolean => {\n const { identity, modelId, permissionName, check } = params;\n if (identity.getPermission(\"cms.*\")) {\n return true;\n }\n\n const permissions = identity.getPermissions<CmsSecurityPermission>(permissionName);\n if (!permissions.length) {\n return false;\n }\n\n if (modelId) {\n const modelPermissions =\n identity.getPermissions<CmsSecurityPermission>(\"cms.contentModel\") ?? [];\n return hasAccessForModel({ permissions, modelPermissions, modelId, check });\n }\n\n return permissions.some(check);\n};\n"],"names":["checkCmsPermission","params","identity","modelId","permissionName","check","permissions","modelPermissions","hasAccessForModel"],"mappings":";AAgBO,MAAMA,qBAAqB,CAACC;IAC/B,MAAM,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,cAAc,EAAEC,KAAK,EAAE,GAAGJ;IACrD,IAAIC,SAAS,aAAa,CAAC,UACvB,OAAO;IAGX,MAAMI,cAAcJ,SAAS,cAAc,CAAwBE;IACnE,IAAI,CAACE,YAAY,MAAM,EACnB,OAAO;IAGX,IAAIH,SAAS;QACT,MAAMI,mBACFL,SAAS,cAAc,CAAwB,uBAAuB,EAAE;QAC5E,OAAOM,kBAAkB;YAAEF;YAAaC;YAAkBJ;YAASE;QAAM;IAC7E;IAEA,OAAOC,YAAY,IAAI,CAACD;AAC5B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CmsSecurityPermission } from "../../types.js";
|
|
2
|
+
export interface HasAccessForModelParams {
|
|
3
|
+
permissions: CmsSecurityPermission[];
|
|
4
|
+
modelPermissions: CmsSecurityPermission[];
|
|
5
|
+
modelId: string;
|
|
6
|
+
check: (permission: CmsSecurityPermission) => boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Check if any _src group grants access for the given model.
|
|
10
|
+
*/
|
|
11
|
+
export declare function hasAccessForModel({ permissions, modelPermissions, modelId, check }: HasAccessForModelParams): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isModelAllowed } from "./isModelAllowed.js";
|
|
2
|
+
function hasAccessForModel({ permissions, modelPermissions, modelId, check }) {
|
|
3
|
+
const srcKeys = new Set();
|
|
4
|
+
for (const p of [
|
|
5
|
+
...permissions,
|
|
6
|
+
...modelPermissions
|
|
7
|
+
])srcKeys.add(p._src);
|
|
8
|
+
for (const src of srcKeys){
|
|
9
|
+
const srcPerms = permissions.filter((p)=>p._src === src);
|
|
10
|
+
const srcModelPerms = modelPermissions.filter((p)=>p._src === src);
|
|
11
|
+
if (!srcPerms.length) continue;
|
|
12
|
+
if (!srcPerms.some(check)) continue;
|
|
13
|
+
const modelAllowed = isModelAllowed(srcModelPerms, modelId);
|
|
14
|
+
if (modelAllowed) return true;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
export { hasAccessForModel };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=hasAccessForModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain/permissions/hasAccessForModel.js","sources":["../../../src/domain/permissions/hasAccessForModel.ts"],"sourcesContent":["import type { CmsSecurityPermission } from \"~/types.js\";\nimport { isModelAllowed } from \"./isModelAllowed.js\";\n\nexport interface HasAccessForModelParams {\n permissions: CmsSecurityPermission[];\n modelPermissions: CmsSecurityPermission[];\n modelId: string;\n check: (permission: CmsSecurityPermission) => boolean;\n}\n\n/**\n * Check if any _src group grants access for the given model.\n */\nexport function hasAccessForModel({\n permissions,\n modelPermissions,\n modelId,\n check\n}: HasAccessForModelParams): boolean {\n const srcKeys = new Set<string | undefined>();\n for (const p of [...permissions, ...modelPermissions]) {\n srcKeys.add(p._src);\n }\n\n for (const src of srcKeys) {\n const srcPerms = permissions.filter(p => p._src === src);\n const srcModelPerms = modelPermissions.filter(p => p._src === src);\n\n if (!srcPerms.length) {\n continue;\n }\n\n if (!srcPerms.some(check)) {\n continue;\n }\n\n const modelAllowed = isModelAllowed(srcModelPerms, modelId);\n if (!modelAllowed) {\n continue;\n }\n\n return true;\n }\n\n return false;\n}\n"],"names":["hasAccessForModel","permissions","modelPermissions","modelId","check","srcKeys","Set","p","src","srcPerms","srcModelPerms","modelAllowed","isModelAllowed"],"mappings":";AAaO,SAASA,kBAAkB,EAC9BC,WAAW,EACXC,gBAAgB,EAChBC,OAAO,EACPC,KAAK,EACiB;IACtB,MAAMC,UAAU,IAAIC;IACpB,KAAK,MAAMC,KAAK;WAAIN;WAAgBC;KAAiB,CACjDG,QAAQ,GAAG,CAACE,EAAE,IAAI;IAGtB,KAAK,MAAMC,OAAOH,QAAS;QACvB,MAAMI,WAAWR,YAAY,MAAM,CAACM,CAAAA,IAAKA,EAAE,IAAI,KAAKC;QACpD,MAAME,gBAAgBR,iBAAiB,MAAM,CAACK,CAAAA,IAAKA,EAAE,IAAI,KAAKC;QAE9D,IAAI,CAACC,SAAS,MAAM,EAChB;QAGJ,IAAI,CAACA,SAAS,IAAI,CAACL,QACf;QAGJ,MAAMO,eAAeC,eAAeF,eAAeP;QACnD,IAAKQ,cAIL,OAAO;IACX;IAEA,OAAO;AACX"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function isModelAllowed(modelPermissions, modelId) {
|
|
2
|
+
if (!modelPermissions.length) return true;
|
|
3
|
+
for (const permission of modelPermissions){
|
|
4
|
+
if (!Array.isArray(permission.models)) return true;
|
|
5
|
+
if (permission.models.includes(modelId)) return true;
|
|
6
|
+
}
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
export { isModelAllowed };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=isModelAllowed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain/permissions/isModelAllowed.js","sources":["../../../src/domain/permissions/isModelAllowed.ts"],"sourcesContent":["import type { CmsSecurityPermission } from \"~/types.js\";\n\nexport function isModelAllowed(\n modelPermissions: CmsSecurityPermission[],\n modelId: string\n): boolean {\n // No model permissions in this group means all models are allowed.\n if (!modelPermissions.length) {\n return true;\n }\n\n for (const permission of modelPermissions) {\n // If no models array, this permission grants access to all models.\n if (!Array.isArray(permission.models)) {\n return true;\n }\n\n if (permission.models.includes(modelId)) {\n return true;\n }\n }\n\n return false;\n}\n"],"names":["isModelAllowed","modelPermissions","modelId","permission","Array"],"mappings":"AAEO,SAASA,eACZC,gBAAyC,EACzCC,OAAe;IAGf,IAAI,CAACD,iBAAiB,MAAM,EACxB,OAAO;IAGX,KAAK,MAAME,cAAcF,iBAAkB;QAEvC,IAAI,CAACG,MAAM,OAAO,CAACD,WAAW,MAAM,GAChC,OAAO;QAGX,IAAIA,WAAW,MAAM,CAAC,QAAQ,CAACD,UAC3B,OAAO;IAEf;IAEA,OAAO;AACX"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CmsErrorResponse } from "../../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* An error returned by the CMS API. Keeps the error `code` and `data` (e.g. the per-field
|
|
4
|
+
* list of a `Cms/Entry/ValidationError`) so the form can show what was rejected.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CmsEntryError extends Error {
|
|
7
|
+
readonly code: string | undefined;
|
|
8
|
+
readonly data: CmsErrorResponse["data"];
|
|
9
|
+
constructor(error: CmsErrorResponse | null | undefined, fallbackMessage: string);
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class CmsEntryError extends Error {
|
|
2
|
+
constructor(error, fallbackMessage){
|
|
3
|
+
super(error?.message || fallbackMessage);
|
|
4
|
+
this.name = "CmsEntryError";
|
|
5
|
+
this.code = error?.code;
|
|
6
|
+
this.data = error?.data;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export { CmsEntryError };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=CmsEntryError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/contentEntry/CmsEntryError.js","sources":["../../../src/features/contentEntry/CmsEntryError.ts"],"sourcesContent":["import type { CmsErrorResponse } from \"~/types.js\";\n\n/**\n * An error returned by the CMS API. Keeps the error `code` and `data` (e.g. the per-field\n * list of a `Cms/Entry/ValidationError`) so the form can show what was rejected.\n */\nexport class CmsEntryError extends Error {\n public readonly code: string | undefined;\n public readonly data: CmsErrorResponse[\"data\"];\n\n public constructor(error: CmsErrorResponse | null | undefined, fallbackMessage: string) {\n super(error?.message || fallbackMessage);\n this.name = \"CmsEntryError\";\n this.code = error?.code;\n this.data = error?.data;\n }\n}\n"],"names":["CmsEntryError","Error","error","fallbackMessage"],"mappings":"AAMO,MAAMA,sBAAsBC;IAI/B,YAAmBC,KAA0C,EAAEC,eAAuB,CAAE;QACpF,KAAK,CAACD,OAAO,WAAWC;QACxB,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,IAAI,GAAGD,OAAO;QACnB,IAAI,CAAC,IAAI,GAAGA,OAAO;IACvB;AACJ"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GraphQLOperationError } from "@webiny/app/errors/index.js";
|
|
1
2
|
import { CmsGraphQLClient } from "../../graphQLClient/abstractions.js";
|
|
2
3
|
import { BulkActionGateway } from "./abstractions.js";
|
|
3
4
|
function createMutation(model) {
|
|
@@ -31,7 +32,11 @@ class BulkActionGatewayImpl {
|
|
|
31
32
|
}
|
|
32
33
|
});
|
|
33
34
|
const { data: result, error } = response.content;
|
|
34
|
-
if (!result) throw new
|
|
35
|
+
if (!result) throw new GraphQLOperationError({
|
|
36
|
+
message: error?.message || "Bulk action failed",
|
|
37
|
+
code: error?.code,
|
|
38
|
+
data: error?.data
|
|
39
|
+
});
|
|
35
40
|
return result;
|
|
36
41
|
}
|
|
37
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/bulkAction/BulkActionGateway.js","sources":["../../../../src/features/contentEntry/bulkAction/BulkActionGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport {\n BulkActionGateway as GatewayAbstraction,\n type IBulkActionParams,\n type IBulkActionResult\n} from \"./abstractions.js\";\n\ninterface BulkActionResponse {\n content: {\n data: IBulkActionResult | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel) {\n return /* GraphQL */ `\n mutation CmsBulkAction${model.singularApiName}($action: BulkAction${model.singularApiName}Name!, $where: ${model.singularApiName}ListWhereInput, $search: String, $data: JSON) {\n content: bulkAction${model.singularApiName}(action: $action, where: $where, search: $search, data: $data) {\n data {\n id\n }\n error {\n message\n code\n data\n }\n }\n }`;\n}\n\nclass BulkActionGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: CmsGraphQLClient.Interface) {}\n\n async execute({ model, action, where, search, data }: IBulkActionParams) {\n const mutation = createMutation(model);\n\n const response = await this.client.execute<BulkActionResponse>({\n query: mutation,\n variables: { action, where, search, data }\n });\n\n const { data: result, error } = response.content;\n\n if (!result) {\n throw new
|
|
1
|
+
{"version":3,"file":"features/contentEntry/bulkAction/BulkActionGateway.js","sources":["../../../../src/features/contentEntry/bulkAction/BulkActionGateway.ts"],"sourcesContent":["import { GraphQLOperationError } from \"@webiny/app/errors/index.js\";\nimport { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport {\n BulkActionGateway as GatewayAbstraction,\n type IBulkActionParams,\n type IBulkActionResult\n} from \"./abstractions.js\";\n\ninterface BulkActionResponse {\n content: {\n data: IBulkActionResult | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel) {\n return /* GraphQL */ `\n mutation CmsBulkAction${model.singularApiName}($action: BulkAction${model.singularApiName}Name!, $where: ${model.singularApiName}ListWhereInput, $search: String, $data: JSON) {\n content: bulkAction${model.singularApiName}(action: $action, where: $where, search: $search, data: $data) {\n data {\n id\n }\n error {\n message\n code\n data\n }\n }\n }`;\n}\n\nclass BulkActionGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: CmsGraphQLClient.Interface) {}\n\n async execute({ model, action, where, search, data }: IBulkActionParams) {\n const mutation = createMutation(model);\n\n const response = await this.client.execute<BulkActionResponse>({\n query: mutation,\n variables: { action, where, search, data }\n });\n\n const { data: result, error } = response.content;\n\n if (!result) {\n throw new GraphQLOperationError({\n message: error?.message || \"Bulk action failed\",\n code: error?.code,\n data: error?.data\n });\n }\n\n return result;\n }\n}\n\nexport const BulkActionGateway = GatewayAbstraction.createImplementation({\n implementation: BulkActionGatewayImpl,\n dependencies: [CmsGraphQLClient]\n});\n"],"names":["createMutation","model","BulkActionGatewayImpl","client","action","where","search","data","mutation","response","result","error","GraphQLOperationError","BulkActionGateway","GatewayAbstraction","CmsGraphQLClient"],"mappings":";;;AAgBA,SAASA,eAAeC,KAAe;IACnC,OAAqB,CAAC;8BACI,EAAEA,MAAM,eAAe,CAAC,oBAAoB,EAAEA,MAAM,eAAe,CAAC,eAAe,EAAEA,MAAM,eAAe,CAAC;+BAC1G,EAAEA,MAAM,eAAe,CAAC;;;;;;;;;;SAU9C,CAAC;AACV;AAEA,MAAMC;IACF,YAAoBC,MAAkC,CAAE;aAApCA,MAAM,GAANA;IAAqC;IAEzD,MAAM,QAAQ,EAAEF,KAAK,EAAEG,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAqB,EAAE;QACrE,MAAMC,WAAWR,eAAeC;QAEhC,MAAMQ,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAqB;YAC3D,OAAOD;YACP,WAAW;gBAAEJ;gBAAQC;gBAAOC;gBAAQC;YAAK;QAC7C;QAEA,MAAM,EAAE,MAAMG,MAAM,EAAEC,KAAK,EAAE,GAAGF,SAAS,OAAO;QAEhD,IAAI,CAACC,QACD,MAAM,IAAIE,sBAAsB;YAC5B,SAASD,OAAO,WAAW;YAC3B,MAAMA,OAAO;YACb,MAAMA,OAAO;QACjB;QAGJ,OAAOD;IACX;AACJ;AAEO,MAAMG,sCAAoBC,kBAAAA,oBAAuC,CAAC;IACrE,gBAAgBZ;IAChB,cAAc;QAACa;KAAiB;AACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
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 { BulkActionGateway } from "./abstractions.js";
|
|
6
|
+
import { BulkActionGateway as external_BulkActionGateway_js_BulkActionGateway } from "./BulkActionGateway.js";
|
|
7
|
+
const model = {
|
|
8
|
+
modelId: "article",
|
|
9
|
+
singularApiName: "Article"
|
|
10
|
+
};
|
|
11
|
+
function setup() {
|
|
12
|
+
const client = {
|
|
13
|
+
execute: vi.fn()
|
|
14
|
+
};
|
|
15
|
+
const container = new Container();
|
|
16
|
+
container.registerInstance(CmsGraphQLClient, client);
|
|
17
|
+
container.register(external_BulkActionGateway_js_BulkActionGateway).inSingletonScope();
|
|
18
|
+
const gateway = container.resolve(BulkActionGateway);
|
|
19
|
+
return {
|
|
20
|
+
client,
|
|
21
|
+
gateway
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
describe("BulkActionGateway", ()=>{
|
|
25
|
+
it("returns the background task id and sends the action arguments unchanged", async ()=>{
|
|
26
|
+
const { client, gateway } = setup();
|
|
27
|
+
client.execute.mockResolvedValue({
|
|
28
|
+
content: {
|
|
29
|
+
data: {
|
|
30
|
+
id: "task-1"
|
|
31
|
+
},
|
|
32
|
+
error: null
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const result = await gateway.execute({
|
|
36
|
+
model: model,
|
|
37
|
+
action: "MoveToTrash",
|
|
38
|
+
where: {
|
|
39
|
+
id_in: [
|
|
40
|
+
"entry-1#0001"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
expect(result).toEqual({
|
|
45
|
+
id: "task-1"
|
|
46
|
+
});
|
|
47
|
+
const request = client.execute.mock.calls[0][0];
|
|
48
|
+
expect(request.variables).toEqual({
|
|
49
|
+
action: "MoveToTrash",
|
|
50
|
+
where: {
|
|
51
|
+
id_in: [
|
|
52
|
+
"entry-1#0001"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
search: void 0,
|
|
56
|
+
data: void 0
|
|
57
|
+
});
|
|
58
|
+
expect(request.query).toMatch(/error\s*\{\s*message\s*code\s*data\s*\}/);
|
|
59
|
+
});
|
|
60
|
+
it("A72: the response carries only the task id, no per-entry failures", async ()=>{
|
|
61
|
+
const { client, gateway } = setup();
|
|
62
|
+
client.execute.mockResolvedValue({
|
|
63
|
+
content: {
|
|
64
|
+
data: {
|
|
65
|
+
id: "task-1"
|
|
66
|
+
},
|
|
67
|
+
error: null
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const result = await gateway.execute({
|
|
71
|
+
model: model,
|
|
72
|
+
action: "MoveToTrash"
|
|
73
|
+
});
|
|
74
|
+
expect(Object.keys(result)).toEqual([
|
|
75
|
+
"id"
|
|
76
|
+
]);
|
|
77
|
+
const request = client.execute.mock.calls[0][0];
|
|
78
|
+
expect(request.query).toMatch(/data\s*\{\s*id\s*\}/);
|
|
79
|
+
});
|
|
80
|
+
it("throws a GraphQLOperationError carrying the code, data and message when the mutation is refused", async ()=>{
|
|
81
|
+
const { client, gateway } = setup();
|
|
82
|
+
client.execute.mockResolvedValue({
|
|
83
|
+
content: {
|
|
84
|
+
data: null,
|
|
85
|
+
error: {
|
|
86
|
+
message: "Not authorized.",
|
|
87
|
+
code: "Workflows/NotAuthorized",
|
|
88
|
+
data: {
|
|
89
|
+
reason: "denied"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const error = await gateway.execute({
|
|
95
|
+
model: model,
|
|
96
|
+
action: "MoveToTrash"
|
|
97
|
+
}).catch((e)=>e);
|
|
98
|
+
expect(error).toBeInstanceOf(GraphQLOperationError);
|
|
99
|
+
expect(error.message).toBe("Not authorized.");
|
|
100
|
+
expect(error.code).toBe("Workflows/NotAuthorized");
|
|
101
|
+
expect(error.data).toEqual({
|
|
102
|
+
reason: "denied"
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
it("keeps its condition: no data and no error throws the fallback with a null code and data", async ()=>{
|
|
106
|
+
const { client, gateway } = setup();
|
|
107
|
+
client.execute.mockResolvedValue({
|
|
108
|
+
content: {
|
|
109
|
+
data: null,
|
|
110
|
+
error: null
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
const error = await gateway.execute({
|
|
114
|
+
model: model,
|
|
115
|
+
action: "MoveToTrash"
|
|
116
|
+
}).catch((e)=>e);
|
|
117
|
+
expect(error).toBeInstanceOf(GraphQLOperationError);
|
|
118
|
+
expect(error.message).toBe("Bulk action failed");
|
|
119
|
+
expect(error.code).toBeNull();
|
|
120
|
+
expect(error.data).toBeNull();
|
|
121
|
+
});
|
|
122
|
+
it("lets a transport failure pass through unchanged", async ()=>{
|
|
123
|
+
const { client, gateway } = setup();
|
|
124
|
+
client.execute.mockRejectedValue(new Error("Network down"));
|
|
125
|
+
const error = await gateway.execute({
|
|
126
|
+
model: model,
|
|
127
|
+
action: "MoveToTrash"
|
|
128
|
+
}).catch((e)=>e);
|
|
129
|
+
expect(error).not.toBeInstanceOf(GraphQLOperationError);
|
|
130
|
+
expect(error.message).toBe("Network down");
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
//# sourceMappingURL=BulkActionGateway.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/contentEntry/bulkAction/BulkActionGateway.test.js","sources":["../../../../src/features/contentEntry/bulkAction/BulkActionGateway.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 type { CmsModel } from \"~/types.js\";\nimport { BulkActionGateway as GatewayAbstraction } from \"./abstractions.js\";\nimport { BulkActionGateway } from \"./BulkActionGateway.js\";\n\nconst model = { modelId: \"article\", singularApiName: \"Article\" } as CmsModel;\n\nfunction setup() {\n const client = { execute: vi.fn() };\n const container = new Container();\n container.registerInstance(CmsGraphQLClient, client);\n container.register(BulkActionGateway).inSingletonScope();\n const gateway = container.resolve(GatewayAbstraction);\n return { client, gateway };\n}\n\ndescribe(\"BulkActionGateway\", () => {\n it(\"returns the background task id and sends the action arguments unchanged\", async () => {\n const { client, gateway } = setup();\n client.execute.mockResolvedValue({ content: { data: { id: \"task-1\" }, error: null } });\n\n const result = await gateway.execute({\n model,\n action: \"MoveToTrash\",\n where: { id_in: [\"entry-1#0001\"] }\n });\n\n expect(result).toEqual({ id: \"task-1\" });\n const request = client.execute.mock.calls[0][0];\n expect(request.variables).toEqual({\n action: \"MoveToTrash\",\n where: { id_in: [\"entry-1#0001\"] },\n search: undefined,\n data: undefined\n });\n expect(request.query).toMatch(/error\\s*\\{\\s*message\\s*code\\s*data\\s*\\}/);\n });\n\n it(\"A72: the response carries only the task id, no per-entry failures\", async () => {\n const { client, gateway } = setup();\n client.execute.mockResolvedValue({ content: { data: { id: \"task-1\" }, error: null } });\n\n const result = await gateway.execute({ model, action: \"MoveToTrash\" });\n\n expect(Object.keys(result)).toEqual([\"id\"]);\n const request = client.execute.mock.calls[0][0];\n expect(request.query).toMatch(/data\\s*\\{\\s*id\\s*\\}/);\n });\n\n it(\"throws a GraphQLOperationError carrying the code, data and message when the mutation is refused\", async () => {\n const { client, gateway } = setup();\n client.execute.mockResolvedValue({\n content: {\n data: null,\n error: {\n message: \"Not authorized.\",\n code: \"Workflows/NotAuthorized\",\n data: { reason: \"denied\" }\n }\n }\n });\n\n const error = await gateway.execute({ model, action: \"MoveToTrash\" }).catch(e => e);\n\n expect(error).toBeInstanceOf(GraphQLOperationError);\n expect(error.message).toBe(\"Not authorized.\");\n expect(error.code).toBe(\"Workflows/NotAuthorized\");\n expect(error.data).toEqual({ reason: \"denied\" });\n });\n\n it(\"keeps its condition: no data and no error throws the fallback with a null code and data\", async () => {\n const { client, gateway } = setup();\n client.execute.mockResolvedValue({ content: { data: null, error: null } });\n\n const error = await gateway.execute({ model, action: \"MoveToTrash\" }).catch(e => e);\n\n expect(error).toBeInstanceOf(GraphQLOperationError);\n expect(error.message).toBe(\"Bulk action failed\");\n expect(error.code).toBeNull();\n expect(error.data).toBeNull();\n });\n\n it(\"lets a transport failure pass through unchanged\", async () => {\n const { client, gateway } = setup();\n client.execute.mockRejectedValue(new Error(\"Network down\"));\n\n const error = await gateway.execute({ model, action: \"MoveToTrash\" }).catch(e => e);\n\n expect(error).not.toBeInstanceOf(GraphQLOperationError);\n expect(error.message).toBe(\"Network down\");\n });\n});\n"],"names":["model","setup","client","vi","container","Container","CmsGraphQLClient","BulkActionGateway","gateway","GatewayAbstraction","describe","it","result","expect","request","undefined","Object","error","e","GraphQLOperationError","Error"],"mappings":";;;;;;AAWA,MAAMA,QAAQ;IAAE,SAAS;IAAW,iBAAiB;AAAU;AAE/D,SAASC;IACL,MAAMC,SAAS;QAAE,SAASC,GAAG,EAAE;IAAG;IAClC,MAAMC,YAAY,IAAIC;IACtBD,UAAU,gBAAgB,CAACE,kBAAkBJ;IAC7CE,UAAU,QAAQ,CAACG,iDAAmB,gBAAgB;IACtD,MAAMC,UAAUJ,UAAU,OAAO,CAACK;IAClC,OAAO;QAAEP;QAAQM;IAAQ;AAC7B;AAEAE,SAAS,qBAAqB;IAC1BC,GAAG,2EAA2E;QAC1E,MAAM,EAAET,MAAM,EAAEM,OAAO,EAAE,GAAGP;QAC5BC,OAAO,OAAO,CAAC,iBAAiB,CAAC;YAAE,SAAS;gBAAE,MAAM;oBAAE,IAAI;gBAAS;gBAAG,OAAO;YAAK;QAAE;QAEpF,MAAMU,SAAS,MAAMJ,QAAQ,OAAO,CAAC;YACjCR,OAAAA;YACA,QAAQ;YACR,OAAO;gBAAE,OAAO;oBAAC;iBAAe;YAAC;QACrC;QAEAa,OAAOD,QAAQ,OAAO,CAAC;YAAE,IAAI;QAAS;QACtC,MAAME,UAAUZ,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;QAC/CW,OAAOC,QAAQ,SAAS,EAAE,OAAO,CAAC;YAC9B,QAAQ;YACR,OAAO;gBAAE,OAAO;oBAAC;iBAAe;YAAC;YACjC,QAAQC;YACR,MAAMA;QACV;QACAF,OAAOC,QAAQ,KAAK,EAAE,OAAO,CAAC;IAClC;IAEAH,GAAG,qEAAqE;QACpE,MAAM,EAAET,MAAM,EAAEM,OAAO,EAAE,GAAGP;QAC5BC,OAAO,OAAO,CAAC,iBAAiB,CAAC;YAAE,SAAS;gBAAE,MAAM;oBAAE,IAAI;gBAAS;gBAAG,OAAO;YAAK;QAAE;QAEpF,MAAMU,SAAS,MAAMJ,QAAQ,OAAO,CAAC;YAAER,OAAAA;YAAO,QAAQ;QAAc;QAEpEa,OAAOG,OAAO,IAAI,CAACJ,SAAS,OAAO,CAAC;YAAC;SAAK;QAC1C,MAAME,UAAUZ,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;QAC/CW,OAAOC,QAAQ,KAAK,EAAE,OAAO,CAAC;IAClC;IAEAH,GAAG,mGAAmG;QAClG,MAAM,EAAET,MAAM,EAAEM,OAAO,EAAE,GAAGP;QAC5BC,OAAO,OAAO,CAAC,iBAAiB,CAAC;YAC7B,SAAS;gBACL,MAAM;gBACN,OAAO;oBACH,SAAS;oBACT,MAAM;oBACN,MAAM;wBAAE,QAAQ;oBAAS;gBAC7B;YACJ;QACJ;QAEA,MAAMe,QAAQ,MAAMT,QAAQ,OAAO,CAAC;YAAER,OAAAA;YAAO,QAAQ;QAAc,GAAG,KAAK,CAACkB,CAAAA,IAAKA;QAEjFL,OAAOI,OAAO,cAAc,CAACE;QAC7BN,OAAOI,MAAM,OAAO,EAAE,IAAI,CAAC;QAC3BJ,OAAOI,MAAM,IAAI,EAAE,IAAI,CAAC;QACxBJ,OAAOI,MAAM,IAAI,EAAE,OAAO,CAAC;YAAE,QAAQ;QAAS;IAClD;IAEAN,GAAG,2FAA2F;QAC1F,MAAM,EAAET,MAAM,EAAEM,OAAO,EAAE,GAAGP;QAC5BC,OAAO,OAAO,CAAC,iBAAiB,CAAC;YAAE,SAAS;gBAAE,MAAM;gBAAM,OAAO;YAAK;QAAE;QAExE,MAAMe,QAAQ,MAAMT,QAAQ,OAAO,CAAC;YAAER,OAAAA;YAAO,QAAQ;QAAc,GAAG,KAAK,CAACkB,CAAAA,IAAKA;QAEjFL,OAAOI,OAAO,cAAc,CAACE;QAC7BN,OAAOI,MAAM,OAAO,EAAE,IAAI,CAAC;QAC3BJ,OAAOI,MAAM,IAAI,EAAE,QAAQ;QAC3BJ,OAAOI,MAAM,IAAI,EAAE,QAAQ;IAC/B;IAEAN,GAAG,mDAAmD;QAClD,MAAM,EAAET,MAAM,EAAEM,OAAO,EAAE,GAAGP;QAC5BC,OAAO,OAAO,CAAC,iBAAiB,CAAC,IAAIkB,MAAM;QAE3C,MAAMH,QAAQ,MAAMT,QAAQ,OAAO,CAAC;YAAER,OAAAA;YAAO,QAAQ;QAAc,GAAG,KAAK,CAACkB,CAAAA,IAAKA;QAEjFL,OAAOI,OAAO,GAAG,CAAC,cAAc,CAACE;QACjCN,OAAOI,MAAM,OAAO,EAAE,IAAI,CAAC;IAC/B;AACJ"}
|
|
@@ -9,7 +9,6 @@ declare class CreateEntryGatewayImpl implements GatewayAbstraction.Interface {
|
|
|
9
9
|
private fields;
|
|
10
10
|
constructor(client: CmsGraphQLClient.Interface, preparer: EntryDataPreparer.Interface, fields: EntryGraphQLFields.Interface);
|
|
11
11
|
execute({ model, data, options }: ICreateEntryGatewayParams): Promise<CmsContentEntry<import("@webiny/app/types.js").GenericRecord>>;
|
|
12
|
-
private prepareData;
|
|
13
12
|
}
|
|
14
13
|
export declare const CreateEntryGateway: typeof CreateEntryGatewayImpl & {
|
|
15
14
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ICreateEntryGateway>;
|
|
@@ -2,6 +2,7 @@ import { CmsGraphQLClient } from "../../graphQLClient/abstractions.js";
|
|
|
2
2
|
import { EntryGraphQLFields } from "../abstractions.js";
|
|
3
3
|
import { CreateEntryGateway } from "./abstractions.js";
|
|
4
4
|
import { EntryDataPreparer } from "../valueTransformers/EntryDataPreparer.js";
|
|
5
|
+
import { CmsEntryError } from "../CmsEntryError.js";
|
|
5
6
|
function createMutation(model, fields) {
|
|
6
7
|
return `
|
|
7
8
|
mutation CmsEntriesCreate${model.singularApiName}($data: ${model.singularApiName}Input!, $options: CreateCmsEntryOptionsInput) {
|
|
@@ -22,7 +23,7 @@ class CreateEntryGatewayImpl {
|
|
|
22
23
|
this.fields = fields;
|
|
23
24
|
}
|
|
24
25
|
async execute({ model, data, options }) {
|
|
25
|
-
const preparedData = this.
|
|
26
|
+
const preparedData = this.preparer.prepareEntryData(data, model.fields);
|
|
26
27
|
const response = await this.client.execute({
|
|
27
28
|
query: createMutation(model, this.fields),
|
|
28
29
|
variables: {
|
|
@@ -31,17 +32,9 @@ class CreateEntryGatewayImpl {
|
|
|
31
32
|
}
|
|
32
33
|
});
|
|
33
34
|
const { data: entry, error } = response.content;
|
|
34
|
-
if (!entry) throw new
|
|
35
|
+
if (!entry) throw new CmsEntryError(error, "Could not create entry");
|
|
35
36
|
return entry;
|
|
36
37
|
}
|
|
37
|
-
prepareData(data, fields) {
|
|
38
|
-
const values = data.values;
|
|
39
|
-
if (!values || "object" != typeof values) return data;
|
|
40
|
-
return {
|
|
41
|
-
...data,
|
|
42
|
-
values: this.preparer.prepare(values, fields)
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
38
|
}
|
|
46
39
|
const CreateEntryGateway_CreateEntryGateway = CreateEntryGateway.createImplementation({
|
|
47
40
|
implementation: CreateEntryGatewayImpl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/createEntry/CreateEntryGateway.js","sources":["../../../../src/features/contentEntry/createEntry/CreateEntryGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel
|
|
1
|
+
{"version":3,"file":"features/contentEntry/createEntry/CreateEntryGateway.js","sources":["../../../../src/features/contentEntry/createEntry/CreateEntryGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { EntryGraphQLFields } from \"../abstractions.js\";\nimport {\n CreateEntryGateway as GatewayAbstraction,\n type ICreateEntryGatewayParams\n} from \"./abstractions.js\";\nimport { EntryDataPreparer } from \"~/features/contentEntry/valueTransformers/EntryDataPreparer.js\";\nimport { CmsEntryError } from \"~/features/contentEntry/CmsEntryError.js\";\n\ninterface CreateEntryResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel, fields: EntryGraphQLFields.Interface) {\n return /* GraphQL */ `\n mutation CmsEntriesCreate${model.singularApiName}($data: ${model.singularApiName}Input!, $options: CreateCmsEntryOptionsInput) {\n content: create${model.singularApiName}(data: $data, options: $options) {\n data {\n ${fields.getSystemFields(model)}\n ${fields.getValuesBlock(model)}\n }\n error { message code data }\n }\n }\n `;\n}\n\nclass CreateEntryGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: CmsGraphQLClient.Interface,\n private preparer: EntryDataPreparer.Interface,\n private fields: EntryGraphQLFields.Interface\n ) {}\n\n async execute({ model, data, options }: ICreateEntryGatewayParams) {\n const preparedData = this.preparer.prepareEntryData(data, model.fields);\n\n const response = await this.client.execute<CreateEntryResponse>({\n query: createMutation(model, this.fields),\n variables: { data: preparedData, options }\n });\n\n const { data: entry, error } = response.content;\n\n if (!entry) {\n throw new CmsEntryError(error, \"Could not create entry\");\n }\n\n return entry;\n }\n}\n\nexport const CreateEntryGateway = GatewayAbstraction.createImplementation({\n implementation: CreateEntryGatewayImpl,\n dependencies: [CmsGraphQLClient, EntryDataPreparer, EntryGraphQLFields]\n});\n"],"names":["createMutation","model","fields","CreateEntryGatewayImpl","client","preparer","data","options","preparedData","response","entry","error","CmsEntryError","CreateEntryGateway","GatewayAbstraction","CmsGraphQLClient","EntryDataPreparer","EntryGraphQLFields"],"mappings":";;;;;AAiBA,SAASA,eAAeC,KAAe,EAAEC,MAAoC;IACzE,OAAqB,CAAC;iCACO,EAAED,MAAM,eAAe,CAAC,QAAQ,EAAEA,MAAM,eAAe,CAAC;2BAC9D,EAAEA,MAAM,eAAe,CAAC;;oBAE/B,EAAEC,OAAO,eAAe,CAACD,OAAO;oBAChC,EAAEC,OAAO,cAAc,CAACD,OAAO;;;;;IAK/C,CAAC;AACL;AAEA,MAAME;IACF,YACYC,MAAkC,EAClCC,QAAqC,EACrCH,MAAoC,CAC9C;aAHUE,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAH,MAAM,GAANA;IACT;IAEH,MAAM,QAAQ,EAAED,KAAK,EAAEK,IAAI,EAAEC,OAAO,EAA6B,EAAE;QAC/D,MAAMC,eAAe,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAACF,MAAML,MAAM,MAAM;QAEtE,MAAMQ,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAsB;YAC5D,OAAOT,eAAeC,OAAO,IAAI,CAAC,MAAM;YACxC,WAAW;gBAAE,MAAMO;gBAAcD;YAAQ;QAC7C;QAEA,MAAM,EAAE,MAAMG,KAAK,EAAEC,KAAK,EAAE,GAAGF,SAAS,OAAO;QAE/C,IAAI,CAACC,OACD,MAAM,IAAIE,cAAcD,OAAO;QAGnC,OAAOD;IACX;AACJ;AAEO,MAAMG,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBX;IAChB,cAAc;QAACY;QAAkBC;QAAmBC;KAAmB;AAC3E"}
|
|
@@ -2,10 +2,12 @@ import { CmsGraphQLClient } from "../../../features/graphQLClient/abstractions.j
|
|
|
2
2
|
import type { CmsContentEntry } from "../../../types.js";
|
|
3
3
|
import { EntryGraphQLFields } from "../abstractions.js";
|
|
4
4
|
import { CreateRevisionFromGateway as GatewayAbstraction, type ICreateRevisionFromParams } from "./abstractions.js";
|
|
5
|
+
import { EntryDataPreparer } from "../../../features/contentEntry/valueTransformers/EntryDataPreparer.js";
|
|
5
6
|
declare class CreateRevisionFromGatewayImpl implements GatewayAbstraction.Interface {
|
|
6
7
|
private client;
|
|
8
|
+
private preparer;
|
|
7
9
|
private fields;
|
|
8
|
-
constructor(client: CmsGraphQLClient.Interface, fields: EntryGraphQLFields.Interface);
|
|
10
|
+
constructor(client: CmsGraphQLClient.Interface, preparer: EntryDataPreparer.Interface, fields: EntryGraphQLFields.Interface);
|
|
9
11
|
execute({ model, revisionId, data, options }: ICreateRevisionFromParams): Promise<CmsContentEntry<import("@webiny/app/types.js").GenericRecord>>;
|
|
10
12
|
}
|
|
11
13
|
export declare const CreateRevisionFromGateway: typeof CreateRevisionFromGatewayImpl & {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CmsGraphQLClient } from "../../graphQLClient/abstractions.js";
|
|
2
2
|
import { EntryGraphQLFields } from "../abstractions.js";
|
|
3
3
|
import { CreateRevisionFromGateway } from "./abstractions.js";
|
|
4
|
+
import { EntryDataPreparer } from "../valueTransformers/EntryDataPreparer.js";
|
|
5
|
+
import { CmsEntryError } from "../CmsEntryError.js";
|
|
4
6
|
function createMutation(model, fields) {
|
|
5
7
|
return `
|
|
6
8
|
mutation CmsCreate${model.singularApiName}From($revision: ID!, $data: ${model.singularApiName}Input, $options: CreateRevisionCmsEntryOptionsInput) {
|
|
@@ -14,21 +16,23 @@ function createMutation(model, fields) {
|
|
|
14
16
|
}`;
|
|
15
17
|
}
|
|
16
18
|
class CreateRevisionFromGatewayImpl {
|
|
17
|
-
constructor(client, fields){
|
|
19
|
+
constructor(client, preparer, fields){
|
|
18
20
|
this.client = client;
|
|
21
|
+
this.preparer = preparer;
|
|
19
22
|
this.fields = fields;
|
|
20
23
|
}
|
|
21
24
|
async execute({ model, revisionId, data, options }) {
|
|
25
|
+
const preparedData = data ? this.preparer.prepareEntryData(data, model.fields) : data;
|
|
22
26
|
const response = await this.client.execute({
|
|
23
27
|
query: createMutation(model, this.fields),
|
|
24
28
|
variables: {
|
|
25
29
|
revision: revisionId,
|
|
26
|
-
data,
|
|
30
|
+
data: preparedData,
|
|
27
31
|
options
|
|
28
32
|
}
|
|
29
33
|
});
|
|
30
34
|
const { data: entry, error } = response.content;
|
|
31
|
-
if (!entry) throw new
|
|
35
|
+
if (!entry) throw new CmsEntryError(error, "Could not create revision");
|
|
32
36
|
return entry;
|
|
33
37
|
}
|
|
34
38
|
}
|
|
@@ -36,6 +40,7 @@ const CreateRevisionFromGateway_CreateRevisionFromGateway = CreateRevisionFromGa
|
|
|
36
40
|
implementation: CreateRevisionFromGatewayImpl,
|
|
37
41
|
dependencies: [
|
|
38
42
|
CmsGraphQLClient,
|
|
43
|
+
EntryDataPreparer,
|
|
39
44
|
EntryGraphQLFields
|
|
40
45
|
]
|
|
41
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js","sources":["../../../../src/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { EntryGraphQLFields } from \"../abstractions.js\";\nimport {\n CreateRevisionFromGateway as GatewayAbstraction,\n type ICreateRevisionFromParams\n} from \"./abstractions.js\";\n\ninterface CreateRevisionFromResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel, fields: EntryGraphQLFields.Interface) {\n return /* GraphQL */ `\n mutation CmsCreate${model.singularApiName}From($revision: ID!, $data: ${model.singularApiName}Input, $options: CreateRevisionCmsEntryOptionsInput) {\n content: create${model.singularApiName}From(revision: $revision, data: $data, options: $options) {\n data {\n ${fields.getSystemFields(model)}\n ${fields.getValuesBlock(model)}\n }\n error { message code data }\n }\n }`;\n}\n\nclass CreateRevisionFromGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: CmsGraphQLClient.Interface,\n private fields: EntryGraphQLFields.Interface\n ) {}\n\n async execute({ model, revisionId, data, options }: ICreateRevisionFromParams) {\n const response = await this.client.execute<CreateRevisionFromResponse>({\n query: createMutation(model, this.fields),\n variables: { revision: revisionId, data, options }\n });\n\n const { data: entry, error } = response.content;\n\n if (!entry) {\n throw new
|
|
1
|
+
{"version":3,"file":"features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js","sources":["../../../../src/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { EntryGraphQLFields } from \"../abstractions.js\";\nimport {\n CreateRevisionFromGateway as GatewayAbstraction,\n type ICreateRevisionFromParams\n} from \"./abstractions.js\";\nimport { EntryDataPreparer } from \"~/features/contentEntry/valueTransformers/EntryDataPreparer.js\";\nimport { CmsEntryError } from \"~/features/contentEntry/CmsEntryError.js\";\n\ninterface CreateRevisionFromResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel, fields: EntryGraphQLFields.Interface) {\n return /* GraphQL */ `\n mutation CmsCreate${model.singularApiName}From($revision: ID!, $data: ${model.singularApiName}Input, $options: CreateRevisionCmsEntryOptionsInput) {\n content: create${model.singularApiName}From(revision: $revision, data: $data, options: $options) {\n data {\n ${fields.getSystemFields(model)}\n ${fields.getValuesBlock(model)}\n }\n error { message code data }\n }\n }`;\n}\n\nclass CreateRevisionFromGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: CmsGraphQLClient.Interface,\n private preparer: EntryDataPreparer.Interface,\n private fields: EntryGraphQLFields.Interface\n ) {}\n\n async execute({ model, revisionId, data, options }: ICreateRevisionFromParams) {\n const preparedData = data ? this.preparer.prepareEntryData(data, model.fields) : data;\n\n const response = await this.client.execute<CreateRevisionFromResponse>({\n query: createMutation(model, this.fields),\n variables: { revision: revisionId, data: preparedData, options }\n });\n\n const { data: entry, error } = response.content;\n\n if (!entry) {\n throw new CmsEntryError(error, \"Could not create revision\");\n }\n\n return entry;\n }\n}\n\nexport const CreateRevisionFromGateway = GatewayAbstraction.createImplementation({\n implementation: CreateRevisionFromGatewayImpl,\n dependencies: [CmsGraphQLClient, EntryDataPreparer, EntryGraphQLFields]\n});\n"],"names":["createMutation","model","fields","CreateRevisionFromGatewayImpl","client","preparer","revisionId","data","options","preparedData","response","entry","error","CmsEntryError","CreateRevisionFromGateway","GatewayAbstraction","CmsGraphQLClient","EntryDataPreparer","EntryGraphQLFields"],"mappings":";;;;;AAiBA,SAASA,eAAeC,KAAe,EAAEC,MAAoC;IACzE,OAAqB,CAAC;0BACA,EAAED,MAAM,eAAe,CAAC,4BAA4B,EAAEA,MAAM,eAAe,CAAC;2BAC3E,EAAEA,MAAM,eAAe,CAAC;;oBAE/B,EAAEC,OAAO,eAAe,CAACD,OAAO;oBAChC,EAAEC,OAAO,cAAc,CAACD,OAAO;;;;SAI1C,CAAC;AACV;AAEA,MAAME;IACF,YACYC,MAAkC,EAClCC,QAAqC,EACrCH,MAAoC,CAC9C;aAHUE,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAH,MAAM,GAANA;IACT;IAEH,MAAM,QAAQ,EAAED,KAAK,EAAEK,UAAU,EAAEC,IAAI,EAAEC,OAAO,EAA6B,EAAE;QAC3E,MAAMC,eAAeF,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAACA,MAAMN,MAAM,MAAM,IAAIM;QAEjF,MAAMG,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA6B;YACnE,OAAOV,eAAeC,OAAO,IAAI,CAAC,MAAM;YACxC,WAAW;gBAAE,UAAUK;gBAAY,MAAMG;gBAAcD;YAAQ;QACnE;QAEA,MAAM,EAAE,MAAMG,KAAK,EAAEC,KAAK,EAAE,GAAGF,SAAS,OAAO;QAE/C,IAAI,CAACC,OACD,MAAM,IAAIE,cAAcD,OAAO;QAGnC,OAAOD;IACX;AACJ;AAEO,MAAMG,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBZ;IAChB,cAAc;QAACa;QAAkBC;QAAmBC;KAAmB;AAC3E"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GraphQLOperationError } from "@webiny/app/errors/index.js";
|
|
1
2
|
import { CmsGraphQLClient } from "../../graphQLClient/abstractions.js";
|
|
2
3
|
import { DeleteEntryGateway } from "./abstractions.js";
|
|
3
4
|
function createMutation(model) {
|
|
@@ -23,7 +24,11 @@ class DeleteEntryGatewayImpl {
|
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
26
|
const { error } = response.content;
|
|
26
|
-
if (error) throw new
|
|
27
|
+
if (error) throw new GraphQLOperationError({
|
|
28
|
+
message: error.message || "Could not delete entry",
|
|
29
|
+
code: error.code,
|
|
30
|
+
data: error.data
|
|
31
|
+
});
|
|
27
32
|
return true;
|
|
28
33
|
}
|
|
29
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/deleteEntry/DeleteEntryGateway.js","sources":["../../../../src/features/contentEntry/deleteEntry/DeleteEntryGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport {\n DeleteEntryGateway as GatewayAbstraction,\n type IDeleteEntryParams\n} from \"./abstractions.js\";\n\ninterface DeleteEntryResponse {\n content: {\n data: boolean | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel) {\n return /* GraphQL */ `\n mutation CmsEntriesDelete${model.singularApiName}($revision: ID!, $permanently: Boolean) {\n content: delete${model.singularApiName}(revision: $revision, options: {permanently: $permanently}) {\n data\n error { message code data }\n }\n }\n `;\n}\n\nclass DeleteEntryGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: CmsGraphQLClient.Interface) {}\n\n async execute({ model, id }: IDeleteEntryParams) {\n const response = await this.client.execute<DeleteEntryResponse>({\n query: createMutation(model),\n variables: { revision: id, permanently: false }\n });\n\n const { error } = response.content;\n\n if (error) {\n throw new
|
|
1
|
+
{"version":3,"file":"features/contentEntry/deleteEntry/DeleteEntryGateway.js","sources":["../../../../src/features/contentEntry/deleteEntry/DeleteEntryGateway.ts"],"sourcesContent":["import { GraphQLOperationError } from \"@webiny/app/errors/index.js\";\nimport { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport {\n DeleteEntryGateway as GatewayAbstraction,\n type IDeleteEntryParams\n} from \"./abstractions.js\";\n\ninterface DeleteEntryResponse {\n content: {\n data: boolean | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel) {\n return /* GraphQL */ `\n mutation CmsEntriesDelete${model.singularApiName}($revision: ID!, $permanently: Boolean) {\n content: delete${model.singularApiName}(revision: $revision, options: {permanently: $permanently}) {\n data\n error { message code data }\n }\n }\n `;\n}\n\nclass DeleteEntryGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: CmsGraphQLClient.Interface) {}\n\n async execute({ model, id }: IDeleteEntryParams) {\n const response = await this.client.execute<DeleteEntryResponse>({\n query: createMutation(model),\n variables: { revision: id, permanently: false }\n });\n\n const { error } = response.content;\n\n if (error) {\n throw new GraphQLOperationError({\n message: error.message || \"Could not delete entry\",\n code: error.code,\n data: error.data\n });\n }\n\n return true;\n }\n}\n\nexport const DeleteEntryGateway = GatewayAbstraction.createImplementation({\n implementation: DeleteEntryGatewayImpl,\n dependencies: [CmsGraphQLClient]\n});\n"],"names":["createMutation","model","DeleteEntryGatewayImpl","client","id","response","error","GraphQLOperationError","DeleteEntryGateway","GatewayAbstraction","CmsGraphQLClient"],"mappings":";;;AAeA,SAASA,eAAeC,KAAe;IACnC,OAAqB,CAAC;iCACO,EAAEA,MAAM,eAAe,CAAC;2BAC9B,EAAEA,MAAM,eAAe,CAAC;;;;;IAK/C,CAAC;AACL;AAEA,MAAMC;IACF,YAAoBC,MAAkC,CAAE;aAApCA,MAAM,GAANA;IAAqC;IAEzD,MAAM,QAAQ,EAAEF,KAAK,EAAEG,EAAE,EAAsB,EAAE;QAC7C,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAsB;YAC5D,OAAOL,eAAeC;YACtB,WAAW;gBAAE,UAAUG;gBAAI,aAAa;YAAM;QAClD;QAEA,MAAM,EAAEE,KAAK,EAAE,GAAGD,SAAS,OAAO;QAElC,IAAIC,OACA,MAAM,IAAIC,sBAAsB;YAC5B,SAASD,MAAM,OAAO,IAAI;YAC1B,MAAMA,MAAM,IAAI;YAChB,MAAMA,MAAM,IAAI;QACpB;QAGJ,OAAO;IACX;AACJ;AAEO,MAAME,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBP;IAChB,cAAc;QAACQ;KAAiB;AACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|