@webiny/api-headless-cms 6.4.5 → 6.6.0-alpha.0
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/HeadlessCmsContextualSchema.d.ts +16 -0
- package/HeadlessCmsContextualSchema.js +32 -0
- package/HeadlessCmsContextualSchema.js.map +1 -0
- package/HeadlessCmsEndpointConfig.d.ts +10 -0
- package/HeadlessCmsEndpointConfig.js +5 -0
- package/HeadlessCmsEndpointConfig.js.map +1 -0
- package/HeadlessCmsFeature.d.ts +10 -0
- package/HeadlessCmsFeature.js +192 -0
- package/HeadlessCmsFeature.js.map +1 -0
- package/createCmsRoute.d.ts +21 -0
- package/createCmsRoute.js +49 -0
- package/createCmsRoute.js.map +1 -0
- package/crud/contentEntry/entryDataValidation.d.ts +1 -1
- package/crud/contentEntry/entryDataValidation.js +2 -15
- package/crud/contentEntry/entryDataValidation.js.map +1 -1
- package/crud/contentEntry/references/validateEntries.d.ts +1 -1
- package/crud/contentEntry/references/validateEntries.js +17 -7
- package/crud/contentEntry/references/validateEntries.js.map +1 -1
- package/crud/contentEntry.crud.js +22 -20
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel.crud.js +8 -6
- package/crud/contentModel.crud.js.map +1 -1
- package/crud/contentModelGroup.crud.js +7 -5
- package/crud/contentModelGroup.crud.js.map +1 -1
- package/domain/contentModel/schemas.d.ts +6 -6
- package/domain/contentModel/schemas.js +1 -1
- package/domain/contentModel/schemas.js.map +1 -1
- package/domain/contentModel/validation/modelFields.js +21 -15
- package/domain/contentModel/validation/modelFields.js.map +1 -1
- package/export/abstractions.d.ts +9 -0
- package/export/abstractions.js +6 -0
- package/export/abstractions.js.map +1 -0
- package/export/crud/exporting.js +8 -2
- package/export/crud/exporting.js.map +1 -1
- package/export/crud/importing.js +13 -4
- package/export/crud/importing.js.map +1 -1
- package/export/crud/imports/importGroups.js +23 -23
- package/export/crud/imports/importGroups.js.map +1 -1
- package/export/crud/imports/importModels.js +25 -22
- package/export/crud/imports/importModels.js.map +1 -1
- package/export/graphql/index.d.ts +2 -3
- package/export/graphql/index.js +6 -10
- package/export/graphql/index.js.map +1 -1
- package/exports/api/cms/storage.d.ts +0 -1
- package/exports/api/cms/storage.js +0 -1
- package/features/contentEntry/CreateEntry/CreateEntryRepository.d.ts +6 -4
- package/features/contentEntry/CreateEntry/CreateEntryRepository.js +7 -8
- package/features/contentEntry/CreateEntry/CreateEntryRepository.js.map +1 -1
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.d.ts +3 -1
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js +2 -3
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.d.ts +6 -4
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js +7 -8
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.d.ts +3 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js +2 -3
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.d.ts +6 -4
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js +7 -8
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.d.ts +3 -1
- package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js +2 -3
- package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.d.ts +6 -4
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js +7 -8
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.d.ts +3 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js +2 -3
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.d.ts +3 -3
- package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js +5 -5
- package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js.map +1 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.d.ts +6 -4
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js +7 -8
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.d.ts +3 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js +2 -3
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js.map +1 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.d.ts +6 -4
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js +7 -8
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js.map +1 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js +2 -3
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js.map +1 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.d.ts +6 -4
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js +7 -8
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.d.ts +3 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js +2 -3
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetEntry/GetEntryUseCase.d.ts +3 -1
- package/features/contentEntry/GetEntry/GetEntryUseCase.js +2 -3
- package/features/contentEntry/GetEntry/GetEntryUseCase.js.map +1 -1
- package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.js +2 -3
- package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.d.ts +6 -4
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js +7 -8
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js +2 -3
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js +2 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.d.ts +6 -4
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js +7 -8
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.js +1 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.d.ts +3 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js +2 -3
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.d.ts +6 -4
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js +7 -8
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.d.ts +6 -4
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js +7 -8
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.d.ts +3 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js +2 -3
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.d.ts +6 -4
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js +7 -8
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.d.ts +6 -4
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js +7 -8
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js.map +1 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js +1 -3
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js.map +1 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.d.ts +6 -4
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js +7 -8
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetSingletonEntry/GetSingletonEntryUseCase.js +1 -3
- package/features/contentEntry/GetSingletonEntry/GetSingletonEntryUseCase.js.map +1 -1
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.d.ts +6 -4
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js +7 -8
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js.map +1 -1
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.d.ts +6 -2
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js +8 -6
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.js +1 -3
- package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListEntriesRepository.d.ts +6 -4
- package/features/contentEntry/ListEntries/ListEntriesRepository.js +7 -8
- package/features/contentEntry/ListEntries/ListEntriesRepository.js.map +1 -1
- package/features/contentEntry/ListEntries/ListEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/ListEntries/ListEntriesUseCase.js +2 -3
- package/features/contentEntry/ListEntries/ListEntriesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.js +1 -3
- package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.js +1 -3
- package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.js.map +1 -1
- package/features/contentEntry/MoveEntry/MoveEntryRepository.d.ts +6 -4
- package/features/contentEntry/MoveEntry/MoveEntryRepository.js +7 -8
- package/features/contentEntry/MoveEntry/MoveEntryRepository.js.map +1 -1
- package/features/contentEntry/MoveEntry/MoveEntryUseCase.d.ts +3 -1
- package/features/contentEntry/MoveEntry/MoveEntryUseCase.js +2 -3
- package/features/contentEntry/MoveEntry/MoveEntryUseCase.js.map +1 -1
- package/features/contentEntry/PublishEntry/PublishEntryRepository.d.ts +6 -4
- package/features/contentEntry/PublishEntry/PublishEntryRepository.js +7 -8
- package/features/contentEntry/PublishEntry/PublishEntryRepository.js.map +1 -1
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.d.ts +3 -1
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.js +2 -3
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.d.ts +8 -4
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js +11 -9
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js.map +1 -1
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.d.ts +3 -1
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js +2 -3
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.d.ts +6 -4
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js +7 -8
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js.map +1 -1
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.d.ts +3 -1
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js +2 -3
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js.map +1 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.d.ts +6 -4
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js +7 -8
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js.map +1 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.d.ts +3 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js +2 -3
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.d.ts +6 -4
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js +7 -8
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js.map +1 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.d.ts +3 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js +2 -3
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js.map +1 -1
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.d.ts +3 -1
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js +2 -3
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js.map +1 -1
- package/features/contentEntry/ValidateEntry/ValidateEntryUseCase.d.ts +3 -1
- package/features/contentEntry/ValidateEntry/ValidateEntryUseCase.js +2 -3
- package/features/contentEntry/ValidateEntry/ValidateEntryUseCase.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js +2 -4
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.d.ts +4 -4
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js +4 -8
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js +1 -3
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js +1 -3
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js +1 -3
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js +2 -4
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js.map +1 -1
- package/features/contentModel/ContentModelFeature.js +2 -0
- package/features/contentModel/ContentModelFeature.js.map +1 -1
- package/features/contentModel/CreateModel/CreateModelRepository.d.ts +4 -3
- package/features/contentModel/CreateModel/CreateModelRepository.js +6 -5
- package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.d.ts +4 -3
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +6 -5
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
- package/features/contentModel/DeleteModel/DeleteModelRepository.d.ts +3 -3
- package/features/contentModel/DeleteModel/DeleteModelRepository.js +5 -5
- package/features/contentModel/DeleteModel/DeleteModelRepository.js.map +1 -1
- package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.d.ts +1 -0
- package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js +11 -8
- package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js.map +1 -1
- package/features/contentModel/UpdateModel/UpdateModelRepository.d.ts +6 -3
- package/features/contentModel/UpdateModel/UpdateModelRepository.js +11 -7
- package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.d.ts +16 -0
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js +51 -0
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js.map +1 -0
- package/features/contentModel/ValuesSelectionGenerator/abstractions.d.ts +8 -0
- package/features/contentModel/ValuesSelectionGenerator/abstractions.js +5 -0
- package/features/contentModel/ValuesSelectionGenerator/abstractions.js.map +1 -0
- package/features/contentModel/ValuesSelectionGenerator/feature.d.ts +4 -0
- package/features/contentModel/ValuesSelectionGenerator/feature.js +11 -0
- package/features/contentModel/ValuesSelectionGenerator/feature.js.map +1 -0
- package/features/contentModel/ValuesSelectionGenerator/index.d.ts +1 -0
- package/features/contentModel/ValuesSelectionGenerator/index.js +1 -0
- package/features/contentModel/shared/ModelsFetcher.d.ts +3 -3
- package/features/contentModel/shared/ModelsFetcher.js +5 -5
- package/features/contentModel/shared/ModelsFetcher.js.map +1 -1
- package/features/contentModel/shared/PluginModelsProvider.d.ts +5 -4
- package/features/contentModel/shared/PluginModelsProvider.js +11 -8
- package/features/contentModel/shared/PluginModelsProvider.js.map +1 -1
- package/features/contentModel/shared/abstractions.d.ts +10 -0
- package/features/contentModel/shared/abstractions.js +2 -1
- package/features/contentModel/shared/abstractions.js.map +1 -1
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.d.ts +8 -4
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js +13 -11
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js.map +1 -1
- package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.d.ts +3 -1
- package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.js +2 -3
- package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.d.ts +8 -4
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js +11 -9
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js.map +1 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.d.ts +3 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js +2 -3
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/GetGroup/GetGroupRepository.d.ts +6 -4
- package/features/contentModelGroup/GetGroup/GetGroupRepository.js +9 -9
- package/features/contentModelGroup/GetGroup/GetGroupRepository.js.map +1 -1
- package/features/contentModelGroup/GetGroup/GetGroupUseCase.d.ts +3 -1
- package/features/contentModelGroup/GetGroup/GetGroupUseCase.js +2 -3
- package/features/contentModelGroup/GetGroup/GetGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/ListGroups/ListGroupsRepository.d.ts +6 -4
- package/features/contentModelGroup/ListGroups/ListGroupsRepository.js +9 -9
- package/features/contentModelGroup/ListGroups/ListGroupsRepository.js.map +1 -1
- package/features/contentModelGroup/ListGroups/ListGroupsUseCase.d.ts +3 -1
- package/features/contentModelGroup/ListGroups/ListGroupsUseCase.js +2 -3
- package/features/contentModelGroup/ListGroups/ListGroupsUseCase.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.d.ts +6 -4
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js +7 -8
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.d.ts +3 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js +2 -3
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/shared/PluginGroupsProvider.d.ts +6 -4
- package/features/contentModelGroup/shared/PluginGroupsProvider.js +13 -11
- package/features/contentModelGroup/shared/PluginGroupsProvider.js.map +1 -1
- package/features/contentModelGroup/shared/abstractions.d.ts +10 -0
- package/features/contentModelGroup/shared/abstractions.js +2 -1
- package/features/contentModelGroup/shared/abstractions.js.map +1 -1
- package/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.d.ts +2 -2
- package/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/DynamicZoneToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/RefToGraphQL.d.ts +1 -1
- package/features/graphql/fields/base/RefToGraphQL.js +3 -1
- package/features/graphql/fields/base/RefToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/richText/richTextResolver.d.ts +1 -1
- package/features/graphql/fields/base/richText/richTextResolver.js.map +1 -1
- package/features/modelBuilder/fields/BaseFieldBuilder.d.ts +1 -3
- package/features/modelBuilder/fields/BaseFieldBuilder.js +0 -4
- package/features/modelBuilder/fields/BaseFieldBuilder.js.map +1 -1
- package/features/modelBuilder/fields/DataFieldBuilder.d.ts +12 -18
- package/features/modelBuilder/fields/DataFieldBuilder.js +1 -2
- package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -1
- package/features/modelBuilder/fields/DynamicZoneFieldType.js +3 -8
- package/features/modelBuilder/fields/DynamicZoneFieldType.js.map +1 -1
- package/features/modelBuilder/fields/TextFieldType.d.ts +3 -1
- package/features/modelBuilder/fields/TextFieldType.js +1 -3
- package/features/modelBuilder/fields/TextFieldType.js.map +1 -1
- package/features/modelBuilder/fields/UiAlertFieldType.js +1 -2
- package/features/modelBuilder/fields/UiAlertFieldType.js.map +1 -1
- package/features/modelBuilder/fields/UiSeparatorFieldType.js +1 -2
- package/features/modelBuilder/fields/UiSeparatorFieldType.js.map +1 -1
- package/features/modelBuilder/fields/UiTabsFieldType.d.ts +1 -2
- package/features/modelBuilder/fields/UiTabsFieldType.js +3 -6
- package/features/modelBuilder/fields/UiTabsFieldType.js.map +1 -1
- package/features/shared/abstractions.d.ts +11 -15
- package/features/shared/abstractions.js +3 -3
- package/features/shared/abstractions.js.map +1 -1
- package/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/CreateEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/CreateEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/CreateEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/DeleteEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/DeleteEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/DeleteEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetRevisionsStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/ListEntriesStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/ListEntriesStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/ListEntriesStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/MoveEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/MoveEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/MoveEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/MoveToBinStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/MoveToBinStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/MoveToBinStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/PublishEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/PublishEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/PublishEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/UpdateEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/group/CreateGroupStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/group/CreateGroupStorageOperation.js +5 -0
- package/features/shared/storageOperations/group/CreateGroupStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/group/DeleteGroupStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/group/DeleteGroupStorageOperation.js +5 -0
- package/features/shared/storageOperations/group/DeleteGroupStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/group/GetGroupStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/group/GetGroupStorageOperation.js +5 -0
- package/features/shared/storageOperations/group/GetGroupStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/group/ListGroupsStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/group/ListGroupsStorageOperation.js +5 -0
- package/features/shared/storageOperations/group/ListGroupsStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/group/UpdateGroupStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/group/UpdateGroupStorageOperation.js +5 -0
- package/features/shared/storageOperations/group/UpdateGroupStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/index.d.ts +32 -0
- package/features/shared/storageOperations/index.js +32 -0
- package/features/shared/storageOperations/model/CreateModelStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/model/CreateModelStorageOperation.js +5 -0
- package/features/shared/storageOperations/model/CreateModelStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/model/DeleteModelStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/model/DeleteModelStorageOperation.js +5 -0
- package/features/shared/storageOperations/model/DeleteModelStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/model/GetModelStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/model/GetModelStorageOperation.js +5 -0
- package/features/shared/storageOperations/model/GetModelStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/model/ListModelsStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/model/ListModelsStorageOperation.js +5 -0
- package/features/shared/storageOperations/model/ListModelsStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/model/UpdateModelStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/model/UpdateModelStorageOperation.js +5 -0
- package/features/shared/storageOperations/model/UpdateModelStorageOperation.js.map +1 -0
- package/fieldConverters/abstractions.d.ts +14 -0
- package/fieldConverters/abstractions.js +13 -0
- package/fieldConverters/abstractions.js.map +1 -0
- package/fieldConverters/index.d.ts +1 -1
- package/graphql/CmsGraphQLSchemaFactory.d.ts +8 -0
- package/graphql/CmsGraphQLSchemaFactory.js +5 -0
- package/graphql/CmsGraphQLSchemaFactory.js.map +1 -0
- package/graphql/CmsSchemaExecutor.d.ts +10 -0
- package/graphql/CmsSchemaExecutor.js +5 -0
- package/graphql/CmsSchemaExecutor.js.map +1 -0
- package/graphql/buildSchemaPlugins.d.ts +2 -1
- package/graphql/buildSchemaPlugins.js +1 -3
- package/graphql/buildSchemaPlugins.js.map +1 -1
- package/graphql/checkEndpointAccess.js +5 -2
- package/graphql/checkEndpointAccess.js.map +1 -1
- package/graphql/createExecutableSchema.d.ts +1 -1
- package/graphql/createExecutableSchema.js +1 -1
- package/graphql/createExecutableSchema.js.map +1 -1
- package/graphql/generateSchema.d.ts +2 -1
- package/graphql/generateSchema.js +14 -5
- package/graphql/generateSchema.js.map +1 -1
- package/graphql/getSchema.js +7 -2
- package/graphql/getSchema.js.map +1 -1
- package/graphql/scalars/RevisionIdScalarPlugin.d.ts +1 -1
- package/graphql/scalars/RevisionIdScalarPlugin.js.map +1 -1
- package/graphql/schema/baseContentSchema.d.ts +1 -6
- package/graphql/schema/baseContentSchema.js +5 -8
- package/graphql/schema/baseContentSchema.js.map +1 -1
- package/graphql/schema/baseSchema.d.ts +2 -2
- package/graphql/schema/baseSchema.js +6 -41
- package/graphql/schema/baseSchema.js.map +1 -1
- package/graphql/schema/cms/CmsBaseErrorTypeFactory.d.ts +14 -0
- package/graphql/schema/cms/CmsBaseErrorTypeFactory.js +21 -0
- package/graphql/schema/cms/CmsBaseErrorTypeFactory.js.map +1 -0
- package/graphql/schema/cms/createEntryResolver.js +2 -2
- package/graphql/schema/cms/createEntryResolver.js.map +1 -1
- package/graphql/schema/cms/deleteEntryResolver.js +2 -2
- package/graphql/schema/cms/deleteEntryResolver.js.map +1 -1
- package/graphql/schema/cms/getEntryResolver.js +2 -2
- package/graphql/schema/cms/getEntryResolver.js.map +1 -1
- package/graphql/schema/cms/helpers/getModel.d.ts +0 -3
- package/graphql/schema/cms/helpers/getModel.js +5 -3
- package/graphql/schema/cms/helpers/getModel.js.map +1 -1
- package/graphql/schema/cms/helpers/transformWhereToNested.js +17 -39
- package/graphql/schema/cms/helpers/transformWhereToNested.js.map +1 -1
- package/graphql/schema/cms/listEntriesResolver.js +2 -2
- package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
- package/graphql/schema/cms/publishEntryResolver.js +2 -2
- package/graphql/schema/cms/publishEntryResolver.js.map +1 -1
- package/graphql/schema/cms/resolvers/createEntry.d.ts +2 -2
- package/graphql/schema/cms/resolvers/createEntry.js +1 -1
- package/graphql/schema/cms/resolvers/createEntry.js.map +1 -1
- package/graphql/schema/cms/resolvers/deleteEntryRevision.d.ts +2 -2
- package/graphql/schema/cms/resolvers/deleteEntryRevision.js +1 -1
- package/graphql/schema/cms/resolvers/deleteEntryRevision.js.map +1 -1
- package/graphql/schema/cms/resolvers/getEntry.d.ts +2 -2
- package/graphql/schema/cms/resolvers/getEntry.js +1 -1
- package/graphql/schema/cms/resolvers/getEntry.js.map +1 -1
- package/graphql/schema/cms/resolvers/listEntries.d.ts +2 -2
- package/graphql/schema/cms/resolvers/listEntries.js +1 -1
- package/graphql/schema/cms/resolvers/listEntries.js.map +1 -1
- package/graphql/schema/cms/resolvers/mutationCms.d.ts +2 -2
- package/graphql/schema/cms/resolvers/mutationCms.js +1 -1
- package/graphql/schema/cms/resolvers/mutationCms.js.map +1 -1
- package/graphql/schema/cms/resolvers/publishEntryRevision.d.ts +2 -2
- package/graphql/schema/cms/resolvers/publishEntryRevision.js +1 -1
- package/graphql/schema/cms/resolvers/publishEntryRevision.js.map +1 -1
- package/graphql/schema/cms/resolvers/queryCms.d.ts +2 -2
- package/graphql/schema/cms/resolvers/queryCms.js +1 -1
- package/graphql/schema/cms/resolvers/queryCms.js.map +1 -1
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.d.ts +2 -2
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.js +1 -1
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.js.map +1 -1
- package/graphql/schema/cms/resolvers/updateEntryRevision.d.ts +2 -2
- package/graphql/schema/cms/resolvers/updateEntryRevision.js +1 -1
- package/graphql/schema/cms/resolvers/updateEntryRevision.js.map +1 -1
- package/graphql/schema/cms/typeDefs/mutation.d.ts +2 -2
- package/graphql/schema/cms/typeDefs/mutation.js +1 -1
- package/graphql/schema/cms/typeDefs/mutation.js.map +1 -1
- package/graphql/schema/cms/typeDefs/query.d.ts +2 -2
- package/graphql/schema/cms/typeDefs/query.js +1 -1
- package/graphql/schema/cms/typeDefs/query.js.map +1 -1
- package/graphql/schema/cms/typeDefs/responses.d.ts +2 -2
- package/graphql/schema/cms/typeDefs/responses.js +1 -1
- package/graphql/schema/cms/typeDefs/responses.js.map +1 -1
- package/graphql/schema/cms/unpublishEntryResolver.js +2 -2
- package/graphql/schema/cms/unpublishEntryResolver.js.map +1 -1
- package/graphql/schema/cms/updateEntryResolver.js +2 -2
- package/graphql/schema/cms/updateEntryResolver.js.map +1 -1
- package/graphql/schema/contentEntries.js +43 -32
- package/graphql/schema/contentEntries.js.map +1 -1
- package/graphql/schema/contentModelGroups.js +39 -18
- package/graphql/schema/contentModelGroups.js.map +1 -1
- package/graphql/schema/contentModels.js +37 -16
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createFieldResolvers.d.ts +1 -1
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/graphql/schema/createManageResolvers.js +4 -2
- package/graphql/schema/createManageResolvers.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveCreate.js +5 -3
- package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js +5 -3
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveDelete.js +9 -4
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +5 -3
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGet.js +11 -6
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetByIds.js +5 -3
- package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js +5 -3
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +5 -3
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveList.js +5 -3
- package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveListDeleted.js +5 -3
- package/graphql/schema/resolvers/manage/resolveListDeleted.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveMove.js +4 -2
- package/graphql/schema/resolvers/manage/resolveMove.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolvePublish.js +5 -3
- package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveRepublish.js +5 -3
- package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveRestoreFromBin.js +5 -3
- package/graphql/schema/resolvers/manage/resolveRestoreFromBin.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveUnpublish.js +5 -3
- package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveUpdate.js +5 -3
- package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveUpdateRevisionDescription.js +5 -3
- package/graphql/schema/resolvers/manage/resolveUpdateRevisionDescription.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveValidate.js +5 -3
- package/graphql/schema/resolvers/manage/resolveValidate.js.map +1 -1
- package/graphql/schema/resolvers/preview/resolveGet.js +6 -3
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/preview/resolveList.js +5 -3
- package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
- package/graphql/schema/resolvers/read/resolveGet.js +5 -2
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/read/resolveList.js +5 -3
- package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
- package/graphql/schema/resolvers/singular/resolveGet.js +1 -1
- package/graphql/schema/resolvers/singular/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/singular/resolveUpdate.js +1 -1
- package/graphql/schema/resolvers/singular/resolveUpdate.js.map +1 -1
- package/graphql/schema/schemaPlugins.d.ts +2 -1
- package/graphql/schema/schemaPlugins.js +2 -4
- package/graphql/schema/schemaPlugins.js.map +1 -1
- package/index.d.ts +7 -6
- package/index.js +4 -22
- package/legacy/abstractions.js.map +1 -1
- package/package.json +22 -27
- package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.d.ts +2 -2
- package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js +1 -1
- package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js.map +1 -1
- package/plugins/index.d.ts +0 -1
- package/plugins/index.js +0 -1
- package/types/fields/dynamicZoneField.d.ts +2 -2
- package/types/modelField.d.ts +1 -1
- package/types/types.d.ts +10 -183
- package/types/types.js.map +1 -1
- package/utils/contentModelToJsonSchema/CmsModelToJsonSchemaConverter.d.ts +28 -0
- package/utils/contentModelToJsonSchema/CmsModelToJsonSchemaConverter.js +324 -0
- package/utils/contentModelToJsonSchema/CmsModelToJsonSchemaConverter.js.map +1 -0
- package/utils/contentModelToJsonSchema/index.d.ts +2 -0
- package/utils/contentModelToJsonSchema/index.js +1 -0
- package/utils/contentModelToJsonSchema/types.d.ts +24 -0
- package/utils/contentModelToJsonSchema/types.js +0 -0
- package/utils/converters/ConverterCollection.d.ts +2 -2
- package/utils/converters/ConverterCollection.js +1 -3
- package/utils/converters/ConverterCollection.js.map +1 -1
- package/utils/converters/valueKeyFromStorageConverter.d.ts +2 -2
- package/utils/converters/valueKeyFromStorageConverter.js +2 -2
- package/utils/converters/valueKeyFromStorageConverter.js.map +1 -1
- package/utils/converters/valueKeyStorageConverter.js +4 -2
- package/utils/converters/valueKeyStorageConverter.js.map +1 -1
- package/utils/converters/valueKeyToStorageConverter.d.ts +2 -2
- package/utils/converters/valueKeyToStorageConverter.js +2 -2
- package/utils/converters/valueKeyToStorageConverter.js.map +1 -1
- package/utils/getSchemaFromFieldPlugins.d.ts +2 -2
- package/utils/getSchemaFromFieldPlugins.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/isHeadlessCmsReady.d.ts +1 -1
- package/utils/isHeadlessCmsReady.js +3 -2
- package/utils/isHeadlessCmsReady.js.map +1 -1
- package/abstractions/entryHooks/OnEntryBeforeCreate.d.ts +0 -8
- package/abstractions/entryHooks/OnEntryBeforeCreate.js +0 -5
- package/abstractions/entryHooks/OnEntryBeforeCreate.js.map +0 -1
- package/abstractions/entryHooks/index.d.ts +0 -1
- package/abstractions/entryHooks/index.js +0 -1
- package/abstractions/index.d.ts +0 -1
- package/abstractions/index.js +0 -1
- package/context.d.ts +0 -3
- package/context.js +0 -131
- package/context.js.map +0 -1
- package/extensions/entryHooks/OnEntryBeforeCreate.d.ts +0 -4
- package/extensions/entryHooks/OnEntryBeforeCreate.js +0 -21
- package/extensions/entryHooks/OnEntryBeforeCreate.js.map +0 -1
- package/extensions/entryHooks/index.d.ts +0 -1
- package/extensions/entryHooks/index.js +0 -1
- package/extensions/index.d.ts +0 -5
- package/extensions/index.js +0 -7
- package/extensions/index.js.map +0 -1
- package/graphql/graphQLHandlerFactory.d.ts +0 -5
- package/graphql/graphQLHandlerFactory.js +0 -22
- package/graphql/graphQLHandlerFactory.js.map +0 -1
- package/graphql/handleRequest.d.ts +0 -11
- package/graphql/handleRequest.js +0 -62
- package/graphql/handleRequest.js.map +0 -1
- package/graphql/index.d.ts +0 -4
- package/graphql/index.js +0 -11
- package/graphql/index.js.map +0 -1
- package/graphql/schema/cms/index.d.ts +0 -2
- package/graphql/schema/cms/index.js +0 -24
- package/graphql/schema/cms/index.js.map +0 -1
- package/index.js.map +0 -1
- package/parameters/context.d.ts +0 -2
- package/parameters/context.js +0 -7
- package/parameters/context.js.map +0 -1
- package/parameters/header.d.ts +0 -2
- package/parameters/header.js +0 -13
- package/parameters/header.js.map +0 -1
- package/parameters/index.d.ts +0 -3
- package/parameters/index.js +0 -3
- package/parameters/path.d.ts +0 -2
- package/parameters/path.js +0 -12
- package/parameters/path.js.map +0 -1
- package/plugins/CmsParametersPlugin.d.ts +0 -18
- package/plugins/CmsParametersPlugin.js +0 -16
- package/plugins/CmsParametersPlugin.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js","sources":["../../../../src/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.ts"],"sourcesContent":["import { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { Result } from \"@webiny/feature/api\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js","sources":["../../../../src/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.ts"],"sourcesContent":["import { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { Result } from \"@webiny/feature/api\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { UnpublishEntryUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { UnpublishEntryRepository } from \"./abstractions.js\";\nimport { EntryBeforeUnpublishEvent } from \"./events.js\";\nimport { EntryAfterUnpublishEvent } from \"./events.js\";\nimport { EntryUnpublishErrorEvent } from \"./events.js\";\nimport { AccessControl } from \"~/features/shared/abstractions.js\";\nimport { GetPublishedRevisionByEntryIdUseCase } from \"~/features/contentEntry/GetPublishedRevisionByEntryId/index.js\";\nimport type { CmsEntry, CmsEntryValues } from \"~/types/index.js\";\nimport type { CmsModel } from \"~/types/index.js\";\nimport { EntryNotAuthorizedError } from \"~/domain/contentEntry/errors.js\";\nimport { EntryNotFoundError } from \"~/domain/contentEntry/errors.js\";\nimport { EntryValidationError } from \"~/domain/contentEntry/errors.js\";\nimport { CreateUnpublishEntryDataFactory } from \"~/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/index.js\";\n\nclass UnpublishEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private eventPublisher: EventPublisher.Interface,\n private repository: UnpublishEntryRepository.Interface,\n private accessControl: AccessControl.Interface,\n private getPublishedRevisionByEntryId: GetPublishedRevisionByEntryIdUseCase.Interface,\n private createUnpublishEntryDataFactory: CreateUnpublishEntryDataFactory.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n id: string\n ): Promise<Result<CmsEntry<T>, UseCaseAbstraction.Error>> {\n const canAccess = await this.accessControl.canAccessEntry({ model, pw: \"u\" });\n if (!canAccess) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n const { id: entryId } = parseIdentifier(id);\n\n const publishedResult = await this.getPublishedRevisionByEntryId.execute<T>(model, entryId);\n\n if (publishedResult.isFail()) {\n return Result.fail(publishedResult.error);\n }\n\n const originalEntry = publishedResult.value;\n\n if (!originalEntry) {\n return Result.fail(new EntryNotFoundError(id));\n }\n\n if (originalEntry.id !== id) {\n return Result.fail(new EntryValidationError(`Entry is not published!`));\n }\n\n const canAccessEntry = await this.accessControl.canAccessEntry({\n model,\n entry: originalEntry,\n pw: \"u\"\n });\n\n if (!canAccessEntry) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n const { entry } = await this.createUnpublishEntryDataFactory.create<T>(originalEntry);\n\n try {\n await this.eventPublisher.publish(new EntryBeforeUnpublishEvent({ entry, model }));\n\n const unpublishResult = await this.repository.execute<T>(model, entry);\n if (unpublishResult.isFail()) {\n await this.eventPublisher.publish(\n new EntryUnpublishErrorEvent({ entry, model, error: unpublishResult.error })\n );\n return Result.fail(unpublishResult.error);\n }\n\n const storageEntry = unpublishResult.value;\n\n await this.eventPublisher.publish(\n new EntryAfterUnpublishEvent({\n entry,\n storageEntry,\n model\n })\n );\n\n return Result.ok(entry);\n } catch (error) {\n await this.eventPublisher.publish(\n new EntryUnpublishErrorEvent({ entry, model, error: error as Error })\n );\n return Result.fail(error as UseCaseAbstraction.Error);\n }\n }\n}\n\nexport const UnpublishEntryUseCase = UseCaseAbstraction.createImplementation({\n implementation: UnpublishEntryUseCaseImpl,\n dependencies: [\n EventPublisher,\n UnpublishEntryRepository,\n AccessControl,\n GetPublishedRevisionByEntryIdUseCase,\n CreateUnpublishEntryDataFactory\n ]\n});\n"],"names":["UnpublishEntryUseCaseImpl","eventPublisher","repository","accessControl","getPublishedRevisionByEntryId","createUnpublishEntryDataFactory","model","id","canAccess","Result","EntryNotAuthorizedError","entryId","parseIdentifier","publishedResult","originalEntry","EntryNotFoundError","EntryValidationError","canAccessEntry","entry","EntryBeforeUnpublishEvent","unpublishResult","EntryUnpublishErrorEvent","storageEntry","EntryAfterUnpublishEvent","error","UnpublishEntryUseCase","UseCaseAbstraction","EventPublisher","UnpublishEntryRepository","AccessControl","GetPublishedRevisionByEntryIdUseCase","CreateUnpublishEntryDataFactory"],"mappings":";;;;;;;;;AAiBA,MAAMA;IACF,YACYC,cAAwC,EACxCC,UAA8C,EAC9CC,aAAsC,EACtCC,6BAA6E,EAC7EC,+BAA0E,CACpF;aALUJ,cAAc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AOZ;oBAAO,OAAOc,gBAAgB,KAAK;gBAAC;gBAE9E,OAAOX,OAAO,IAAI,CAACW,gBAAgB,KAAK;YAC5C;YAEA,MAAME,eAAeF,gBAAgB,KAAK;YAE1C,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIG,yBAAyB;gBACzBL;gBACAI;gBACAhB;YACJ;YAGJ,OAAOG,OAAO,EAAE,CAACS;QACrB,EAAE,OAAOM,OAAO;YACZ,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIH,yBAAyB;gBAAEH;gBAAOZ;gBAAO,OAAOkB;YAAe;YAEvE,OAAOf,OAAO,IAAI,CAACe;QACvB;IACJ;AACJ;AAEO,MAAMC,8CAAwBC,sBAAAA,oBAAuC,CAAC;IACzE,gBAAgB1B;IAChB,cAAc;QACV2B;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateEntryRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
3
3
|
import type { CmsEntry, CmsEntryValues, CmsModel } from "../../../types/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { UpdateEntryStorageOperation } from "../../../features/shared/storageOperations/entry/UpdateEntryStorageOperation.js";
|
|
5
5
|
import { EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
6
6
|
/**
|
|
7
7
|
* UpdateEntryRepository - Handles persistence of entry updates.
|
|
@@ -9,9 +9,11 @@ import { EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
|
9
9
|
*/
|
|
10
10
|
declare class UpdateEntryRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
11
11
|
private entryToStorageTransform;
|
|
12
|
-
private
|
|
13
|
-
constructor(entryToStorageTransform: EntryToStorageTransform.Interface,
|
|
12
|
+
private updateEntryStorage;
|
|
13
|
+
constructor(entryToStorageTransform: EntryToStorageTransform.Interface, updateEntryStorage: UpdateEntryStorageOperation.Interface);
|
|
14
14
|
execute<T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, entry: CmsEntry<T>): Promise<Result<void, RepositoryAbstraction.Error>>;
|
|
15
15
|
}
|
|
16
|
-
export declare const UpdateEntryRepository:
|
|
16
|
+
export declare const UpdateEntryRepository: typeof UpdateEntryRepositoryImpl & {
|
|
17
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateEntryRepository>;
|
|
18
|
+
};
|
|
17
19
|
export {};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Result
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateEntryRepository } from "./abstractions.js";
|
|
3
3
|
import { EntryPersistenceError } from "../../../domain/contentEntry/errors.js";
|
|
4
|
-
import {
|
|
4
|
+
import { UpdateEntryStorageOperation } from "../../shared/storageOperations/entry/UpdateEntryStorageOperation.js";
|
|
5
5
|
import { EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
6
6
|
class UpdateEntryRepositoryImpl {
|
|
7
|
-
constructor(entryToStorageTransform,
|
|
7
|
+
constructor(entryToStorageTransform, updateEntryStorage){
|
|
8
8
|
this.entryToStorageTransform = entryToStorageTransform;
|
|
9
|
-
this.
|
|
9
|
+
this.updateEntryStorage = updateEntryStorage;
|
|
10
10
|
}
|
|
11
11
|
async execute(model, entry) {
|
|
12
12
|
try {
|
|
13
13
|
const storageEntry = await this.entryToStorageTransform(model, entry);
|
|
14
|
-
await this.
|
|
14
|
+
await this.updateEntryStorage.execute(model, {
|
|
15
15
|
entry,
|
|
16
16
|
storageEntry
|
|
17
17
|
});
|
|
@@ -21,12 +21,11 @@ class UpdateEntryRepositoryImpl {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
const UpdateEntryRepository_UpdateEntryRepository = createImplementation({
|
|
25
|
-
abstraction: UpdateEntryRepository,
|
|
24
|
+
const UpdateEntryRepository_UpdateEntryRepository = UpdateEntryRepository.createImplementation({
|
|
26
25
|
implementation: UpdateEntryRepositoryImpl,
|
|
27
26
|
dependencies: [
|
|
28
27
|
EntryToStorageTransform,
|
|
29
|
-
|
|
28
|
+
UpdateEntryStorageOperation
|
|
30
29
|
]
|
|
31
30
|
});
|
|
32
31
|
export { UpdateEntryRepository_UpdateEntryRepository as UpdateEntryRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/UpdateEntry/UpdateEntryRepository.js","sources":["../../../../src/features/contentEntry/UpdateEntry/UpdateEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/contentEntry/UpdateEntry/UpdateEntryRepository.js","sources":["../../../../src/features/contentEntry/UpdateEntry/UpdateEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { UpdateEntryStorageOperation } from \"~/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js\";\nimport { EntryToStorageTransform } from \"~/legacy/abstractions.js\";\n\n/**\n * UpdateEntryRepository - Handles persistence of entry updates.\n * Transforms domain entry to storage format and persists changes.\n */\nclass UpdateEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private entryToStorageTransform: EntryToStorageTransform.Interface,\n private updateEntryStorage: UpdateEntryStorageOperation.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n entry: CmsEntry<T>\n ): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n // Transform domain entry to storage format\n const storageEntry = await this.entryToStorageTransform<T>(model, entry);\n\n // Persist to storage\n await this.updateEntryStorage.execute<T>(model, {\n entry,\n storageEntry\n });\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new EntryPersistenceError(error as Error));\n }\n }\n}\n\nexport const UpdateEntryRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateEntryRepositoryImpl,\n dependencies: [EntryToStorageTransform, UpdateEntryStorageOperation]\n});\n"],"names":["UpdateEntryRepositoryImpl","entryToStorageTransform","updateEntryStorage","model","entry","storageEntry","Result","error","EntryPersistenceError","UpdateEntryRepository","RepositoryAbstraction","EntryToStorageTransform","UpdateEntryStorageOperation"],"mappings":";;;;;AAWA,MAAMA;IACF,YACYC,uBAA0D,EAC1DC,kBAAyD,CACnE;aAFUD,uBAAuB,GAAvBA;aACAC,kBAAkB,GAAlBA;IACT;IAEH,MAAM,QACFC,KAAe,EACfC,KAAkB,EACgC;QAClD,IAAI;YAEA,MAAMC,eAAe,MAAM,IAAI,CAAC,uBAAuB,CAAIF,OAAOC;YAGlE,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAID,OAAO;gBAC5CC;gBACAC;YACJ;YAEA,OAAOC,OAAO,EAAE;QACpB,EAAE,OAAOC,OAAO;YACZ,OAAOD,OAAO,IAAI,CAAC,IAAIE,sBAAsBD;QACjD;IACJ;AACJ;AAEO,MAAME,8CAAwBC,sBAAAA,oBAA0C,CAAC;IAC5E,gBAAgBV;IAChB,cAAc;QAACW;QAAyBC;KAA4B;AACxE"}
|
|
@@ -14,5 +14,7 @@ declare class UpdateEntryUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
|
14
14
|
constructor(eventPublisher: EventPublisher.Interface, repository: UpdateEntryRepository.Interface, accessControl: AccessControl.Interface, getRevisionByIdUseCase: GetRevisionByIdUseCase.Interface, updateEntryDataFactory: UpdateEntryDataFactory.Interface);
|
|
15
15
|
execute<T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, id: string, rawInput: UpdateCmsEntryInput<T>, options?: UpdateCmsEntryOptionsInput): Promise<Result<CmsEntry<T>, UseCaseAbstraction.Error>>;
|
|
16
16
|
}
|
|
17
|
-
export declare const UpdateEntryUseCase:
|
|
17
|
+
export declare const UpdateEntryUseCase: typeof UpdateEntryUseCaseImpl & {
|
|
18
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateEntryUseCase>;
|
|
19
|
+
};
|
|
18
20
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Result
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateEntryRepository, UpdateEntryUseCase } from "./abstractions.js";
|
|
3
3
|
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
4
4
|
import { EntryAfterUpdateEvent, EntryBeforeUpdateEvent } from "./events.js";
|
|
@@ -52,8 +52,7 @@ class UpdateEntryUseCaseImpl {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
const UpdateEntryUseCase_UpdateEntryUseCase = createImplementation({
|
|
56
|
-
abstraction: UpdateEntryUseCase,
|
|
55
|
+
const UpdateEntryUseCase_UpdateEntryUseCase = UpdateEntryUseCase.createImplementation({
|
|
57
56
|
implementation: UpdateEntryUseCaseImpl,
|
|
58
57
|
dependencies: [
|
|
59
58
|
EventPublisher,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/UpdateEntry/UpdateEntryUseCase.js","sources":["../../../../src/features/contentEntry/UpdateEntry/UpdateEntryUseCase.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"features/contentEntry/UpdateEntry/UpdateEntryUseCase.js","sources":["../../../../src/features/contentEntry/UpdateEntry/UpdateEntryUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateEntryRepository, UpdateEntryUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { EntryAfterUpdateEvent, EntryBeforeUpdateEvent } from \"./events.js\";\nimport { AccessControl } from \"~/features/shared/abstractions.js\";\nimport { GetRevisionByIdUseCase } from \"~/features/contentEntry/GetRevisionById/abstractions.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { EntryLockedError, EntryNotAuthorizedError } from \"~/domain/contentEntry/errors.js\";\nimport { UpdateEntryDataFactory } from \"~/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/index.js\";\n\nclass UpdateEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private eventPublisher: EventPublisher.Interface,\n private repository: UpdateEntryRepository.Interface,\n private accessControl: AccessControl.Interface,\n private getRevisionByIdUseCase: GetRevisionByIdUseCase.Interface,\n private updateEntryDataFactory: UpdateEntryDataFactory.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n id: string,\n rawInput: UpdateCmsEntryInput<T>,\n options?: UpdateCmsEntryOptionsInput\n ): Promise<Result<CmsEntry<T>, UseCaseAbstraction.Error>> {\n const canAccess = await this.accessControl.canAccessEntry({ model, rwd: \"w\" });\n if (!canAccess) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n try {\n const result = await this.getRevisionByIdUseCase.execute<T>(model, id);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const originalEntry = result.value;\n\n if (originalEntry.locked) {\n return Result.fail(new EntryLockedError());\n }\n\n const { entry, input } = await this.updateEntryDataFactory.create<T>(\n model,\n rawInput,\n originalEntry,\n options\n );\n\n const canAccessEntry = await this.accessControl.canAccessEntry({\n model,\n entry,\n rwd: \"w\"\n });\n\n if (!canAccessEntry) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n await this.eventPublisher.publish(\n new EntryBeforeUpdateEvent({ entry, original: originalEntry, input, model })\n );\n\n const updateResult = await this.repository.execute(model, entry);\n if (updateResult.isFail()) {\n return Result.fail(updateResult.error);\n }\n\n await this.eventPublisher.publish(\n new EntryAfterUpdateEvent({\n entry,\n original: originalEntry,\n input,\n model\n })\n );\n\n return Result.ok(entry);\n } catch (error) {\n return Result.fail(error as UseCaseAbstraction.Error);\n }\n }\n}\n\nexport const UpdateEntryUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateEntryUseCaseImpl,\n dependencies: [\n EventPublisher,\n UpdateEntryRepository,\n AccessControl,\n GetRevisionByIdUseCase,\n UpdateEntryDataFactory\n ]\n});\n"],"names":["UpdateEntryUseCaseImpl","eventPublisher","repository","accessControl","getRevisionByIdUseCase","updateEntryDataFactory","model","id","rawInput","options","canAccess","Result","EntryNotAuthorizedError","result","originalEntry","EntryLockedError","entry","input","canAccessEntry","EntryBeforeUpdateEvent","updateResult","EntryAfterUpdateEvent","error","UpdateEntryUseCase","UseCaseAbstraction","EventPublisher","UpdateEntryRepository","AccessControl","GetRevisionByIdUseCase","UpdateEntryDataFactory"],"mappings":";;;;;;;;AAgBA,MAAMA;IACF,YACYC,cAAwC,EACxCC,UAA2C,EAC3CC,aAAsC,EACtCC,sBAAwD,EACxDC,sBAAwD,CAClE;aALUJ,cAAc,GAAdA;aACAC,UAAU,GAAVA;aACAC,aAAa,GAAbA;aACAC,sBAAsB,GAAtBA;aACAC,sBAAsB,GAAtBA;IACT;IAEH,MAAM,QACFC,KAAe,EACfC,EAAU,EACVC,QAAgC,EAChCC,OAAoC,EACkB;QACtD,MAAMC,YAAY,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAAEJ;YAAO,KAAK;QAAI;QAC5E,IAAI,CAACI,WACD,OAAOC,OAAO,IAAI,CAACC,wBAAwB,SAAS,CAACN;QAGzD,IAAI;YACA,MAAMO,SAAS,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAIP,OAAOC;YAEnE,IAAIM,OAAO,MAAM,IACb,OAAOF,OAAO,IAAI,CAACE,OAAO,KAAK;YAGnC,MAAMC,gBAAgBD,OAAO,KAAK;YAElC,IAAIC,cAAc,MAAM,EACpB,OAAOH,OAAO,IAAI,CAAC,IAAII;YAG3B,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAC7DX,OACAE,UACAM,eACAL;YAGJ,MAAMS,iBAAiB,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;gBAC3DZ;gBACAU;gBACA,KAAK;YACT;YAEA,IAAI,CAACE,gBACD,OAAOP,OAAO,IAAI,CAACC,wBAAwB,SAAS,CAACN;YAGzD,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIa,uBAAuB;gBAAEH;gBAAO,UAAUF;gBAAeG;gBAAOX;YAAM;YAG9E,MAAMc,eAAe,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACd,OAAOU;YAC1D,IAAII,aAAa,MAAM,IACnB,OAAOT,OAAO,IAAI,CAACS,aAAa,KAAK;YAGzC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,sBAAsB;gBACtBL;gBACA,UAAUF;gBACVG;gBACAX;YACJ;YAGJ,OAAOK,OAAO,EAAE,CAACK;QACrB,EAAE,OAAOM,OAAO;YACZ,OAAOX,OAAO,IAAI,CAACW;QACvB;IACJ;AACJ;AAEO,MAAMC,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBxB;IAChB,cAAc;QACVyB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.d.ts
CHANGED
|
@@ -13,5 +13,7 @@ declare class UpdateRevisionDescriptionUseCaseImpl implements UseCaseAbstraction
|
|
|
13
13
|
constructor(eventPublisher: EventPublisher.Interface, repository: UpdateEntryRepository.Interface, accessControl: AccessControl.Interface, getRevisionByIdUseCase: GetRevisionByIdUseCase.Interface);
|
|
14
14
|
execute<T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, id: string, revisionDescription: string | undefined): Promise<Result<CmsEntry<T>, UseCaseAbstraction.Error>>;
|
|
15
15
|
}
|
|
16
|
-
export declare const UpdateRevisionDescriptionUseCase:
|
|
16
|
+
export declare const UpdateRevisionDescriptionUseCase: typeof UpdateRevisionDescriptionUseCaseImpl & {
|
|
17
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateRevisionDescriptionUseCase>;
|
|
18
|
+
};
|
|
17
19
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Result
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateRevisionDescriptionUseCase } from "./abstractions.js";
|
|
3
3
|
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
4
4
|
import { EntryAfterUpdateRevisionDescriptionEvent, EntryBeforeUpdateRevisionDescriptionEvent } from "./events.js";
|
|
@@ -53,8 +53,7 @@ class UpdateRevisionDescriptionUseCaseImpl {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
const UpdateRevisionDescriptionUseCase_UpdateRevisionDescriptionUseCase = createImplementation({
|
|
57
|
-
abstraction: UpdateRevisionDescriptionUseCase,
|
|
56
|
+
const UpdateRevisionDescriptionUseCase_UpdateRevisionDescriptionUseCase = UpdateRevisionDescriptionUseCase.createImplementation({
|
|
58
57
|
implementation: UpdateRevisionDescriptionUseCaseImpl,
|
|
59
58
|
dependencies: [
|
|
60
59
|
EventPublisher,
|
package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js","sources":["../../../../src/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js","sources":["../../../../src/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateRevisionDescriptionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport {\n EntryAfterUpdateRevisionDescriptionEvent,\n EntryBeforeUpdateRevisionDescriptionEvent\n} from \"./events.js\";\nimport { AccessControl } from \"~/features/shared/abstractions.js\";\nimport { GetRevisionByIdUseCase } from \"~/features/contentEntry/GetRevisionById/abstractions.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { EntryNotAuthorizedError } from \"~/domain/contentEntry/errors.js\";\nimport { UpdateEntryRepository } from \"../UpdateEntry/index.js\";\n\nclass UpdateRevisionDescriptionUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private eventPublisher: EventPublisher.Interface,\n private repository: UpdateEntryRepository.Interface,\n private accessControl: AccessControl.Interface,\n private getRevisionByIdUseCase: GetRevisionByIdUseCase.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n id: string,\n revisionDescription: string | undefined\n ): Promise<Result<CmsEntry<T>, UseCaseAbstraction.Error>> {\n // Check initial access control\n const canAccess = await this.accessControl.canAccessEntry({ model, rwd: \"w\" });\n if (!canAccess) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n try {\n const result = await this.getRevisionByIdUseCase.execute<T>(model, id);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const originalEntry = result.value;\n\n const entry = {\n ...originalEntry,\n revisionDescription\n };\n\n // Apply access control on the updated entry\n const canAccessEntry = await this.accessControl.canAccessEntry({\n model,\n entry,\n rwd: \"w\"\n });\n\n if (!canAccessEntry) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeUpdateRevisionDescriptionEvent({\n entry,\n original: originalEntry,\n revisionDescription,\n model\n })\n );\n\n // Persist updated entry\n const updateResult = await this.repository.execute(model, entry);\n if (updateResult.isFail()) {\n return Result.fail(updateResult.error);\n }\n\n // Publish after event\n await this.eventPublisher.publish(\n new EntryAfterUpdateRevisionDescriptionEvent({\n entry,\n original: originalEntry,\n revisionDescription,\n model\n })\n );\n\n return Result.ok(entry);\n } catch (error) {\n // Handle errors from createUpdateEntryData or other operations\n return Result.fail(error as UseCaseAbstraction.Error);\n }\n }\n}\n\nexport const UpdateRevisionDescriptionUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateRevisionDescriptionUseCaseImpl,\n dependencies: [EventPublisher, UpdateEntryRepository, AccessControl, GetRevisionByIdUseCase]\n});\n"],"names":["UpdateRevisionDescriptionUseCaseImpl","eventPublisher","repository","accessControl","getRevisionByIdUseCase","model","id","revisionDescription","canAccess","Result","EntryNotAuthorizedError","result","originalEntry","entry","canAccessEntry","EntryBeforeUpdateRevisionDescriptionEvent","updateResult","EntryAfterUpdateRevisionDescriptionEvent","error","UpdateRevisionDescriptionUseCase","UseCaseAbstraction","EventPublisher","UpdateEntryRepository","AccessControl","GetRevisionByIdUseCase"],"mappings":";;;;;;;;AAaA,MAAMA;IACF,YACYC,cAAwC,EACxCC,UAA2C,EAC3CC,aAAsC,EACtCC,sBAAwD,CAClE;aAJUH,cAAc,GAAdA;aACAC,UAAU,GAAVA;aACAC,aAAa,GAAbA;aACAC,sBAAsB,GAAtBA;IACT;IAEH,MAAM,QACFC,KAAe,EACfC,EAAU,EACVC,mBAAuC,EACe;QAEtD,MAAMC,YAAY,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAAEH;YAAO,KAAK;QAAI;QAC5E,IAAI,CAACG,WACD,OAAOC,OAAO,IAAI,CAACC,wBAAwB,SAAS,CAACL;QAGzD,IAAI;YACA,MAAMM,SAAS,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAIN,OAAOC;YAEnE,IAAIK,OAAO,MAAM,IACb,OAAOF,OAAO,IAAI,CAACE,OAAO,KAAK;YAGnC,MAAMC,gBAAgBD,OAAO,KAAK;YAElC,MAAME,QAAQ;gBACV,GAAGD,aAAa;gBAChBL;YACJ;YAGA,MAAMO,iBAAiB,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;gBAC3DT;gBACAQ;gBACA,KAAK;YACT;YAEA,IAAI,CAACC,gBACD,OAAOL,OAAO,IAAI,CAACC,wBAAwB,SAAS,CAACL;YAIzD,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIU,0CAA0C;gBAC1CF;gBACA,UAAUD;gBACVL;gBACAF;YACJ;YAIJ,MAAMW,eAAe,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACX,OAAOQ;YAC1D,IAAIG,aAAa,MAAM,IACnB,OAAOP,OAAO,IAAI,CAACO,aAAa,KAAK;YAIzC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,yCAAyC;gBACzCJ;gBACA,UAAUD;gBACVL;gBACAF;YACJ;YAGJ,OAAOI,OAAO,EAAE,CAACI;QACrB,EAAE,OAAOK,OAAO;YAEZ,OAAOT,OAAO,IAAI,CAACS;QACvB;IACJ;AACJ;AAEO,MAAMC,oEAAmCC,iCAAAA,oBAAuC,CAAC;IACpF,gBAAgBpB;IAChB,cAAc;QAACqB;QAAgBC;QAAuBC;QAAeC;KAAuB;AAChG"}
|
|
@@ -20,5 +20,7 @@ declare class ValidateEntryUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
|
20
20
|
constructor(accessControl: AccessControl.Interface, getRevisionById: GetRevisionByIdUseCase.Interface, cmsContext: CmsContext.Interface);
|
|
21
21
|
execute<T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, id: string | null, inputData: UpdateCmsEntryInput<T>): Promise<Result<IValidateEntryUserCaseExecuteResult[], UseCaseAbstraction.Error>>;
|
|
22
22
|
}
|
|
23
|
-
export declare const ValidateEntryUseCase:
|
|
23
|
+
export declare const ValidateEntryUseCase: typeof ValidateEntryUseCaseImpl & {
|
|
24
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IValidateEntryUseCase>;
|
|
25
|
+
};
|
|
24
26
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Result
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ValidateEntryUseCase } from "./abstractions.js";
|
|
3
3
|
import { AccessControl, CmsContext } from "../../shared/abstractions.js";
|
|
4
4
|
import { GetRevisionByIdUseCase } from "../GetRevisionById/index.js";
|
|
@@ -39,8 +39,7 @@ class ValidateEntryUseCaseImpl {
|
|
|
39
39
|
return Result.ok(validationResult.length > 0 ? validationResult : []);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
const ValidateEntryUseCase_ValidateEntryUseCase = createImplementation({
|
|
43
|
-
abstraction: ValidateEntryUseCase,
|
|
42
|
+
const ValidateEntryUseCase_ValidateEntryUseCase = ValidateEntryUseCase.createImplementation({
|
|
44
43
|
implementation: ValidateEntryUseCaseImpl,
|
|
45
44
|
dependencies: [
|
|
46
45
|
AccessControl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/ValidateEntry/ValidateEntryUseCase.js","sources":["../../../../src/features/contentEntry/ValidateEntry/ValidateEntryUseCase.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"features/contentEntry/ValidateEntry/ValidateEntryUseCase.js","sources":["../../../../src/features/contentEntry/ValidateEntry/ValidateEntryUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n type IValidateEntryUserCaseExecuteResult,\n ValidateEntryUseCase as UseCaseAbstraction\n} from \"./abstractions.js\";\nimport { AccessControl, CmsContext } from \"~/features/shared/abstractions.js\";\nimport { GetRevisionByIdUseCase } from \"~/features/contentEntry/GetRevisionById/index.js\";\nimport type { CmsEntryValues, CmsModel, UpdateCmsEntryInput } from \"~/types/index.js\";\nimport { EntryNotAuthorizedError } from \"~/domain/contentEntry/errors.js\";\nimport { mapAndCleanUpdatedInputData } from \"~/features/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.js\";\nimport { validateModelEntryData } from \"~/crud/contentEntry/entryDataValidation.js\";\n\n/**\n * ValidateEntryUseCase - Orchestrates entry data validation.\n *\n * Responsibilities:\n * - Apply access control\n * - Optionally get the entry being validated (if id provided)\n * - Map and clean input data\n * - Validate data against model field validators\n * - Return validation results\n */\nclass ValidateEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private accessControl: AccessControl.Interface,\n private getRevisionById: GetRevisionByIdUseCase.Interface,\n private cmsContext: CmsContext.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n id: string | null,\n inputData: UpdateCmsEntryInput<T>\n ): Promise<Result<IValidateEntryUserCaseExecuteResult[], UseCaseAbstraction.Error>> {\n // Check access control\n const canAccess = await this.accessControl.canAccessEntry({ model, rwd: \"w\" });\n if (!canAccess) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n // Map and clean input data\n const input = mapAndCleanUpdatedInputData<T>(model, inputData.values || ({} as T));\n\n // Optionally get the entry being validated\n let originalEntry = undefined;\n if (id) {\n const entryResult = await this.getRevisionById.execute(model, id);\n\n if (entryResult.isFail()) {\n return Result.fail(entryResult.error);\n }\n\n originalEntry = entryResult.value;\n\n // Check access control on the specific entry\n const canAccessEntry = await this.accessControl.canAccessEntry({\n model,\n entry: originalEntry,\n rwd: \"w\"\n });\n\n if (!canAccessEntry) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n }\n\n // Validate the data\n const validationResult = await validateModelEntryData({\n context: this.cmsContext,\n model,\n values: input,\n entry: originalEntry\n });\n\n return Result.ok(validationResult.length > 0 ? validationResult : []);\n }\n}\n\nexport const ValidateEntryUseCase = UseCaseAbstraction.createImplementation({\n implementation: ValidateEntryUseCaseImpl,\n dependencies: [AccessControl, GetRevisionByIdUseCase, CmsContext]\n});\n"],"names":["ValidateEntryUseCaseImpl","accessControl","getRevisionById","cmsContext","model","id","inputData","canAccess","Result","EntryNotAuthorizedError","input","mapAndCleanUpdatedInputData","originalEntry","entryResult","canAccessEntry","validationResult","validateModelEntryData","ValidateEntryUseCase","UseCaseAbstraction","AccessControl","GetRevisionByIdUseCase","CmsContext"],"mappings":";;;;;;;AAsBA,MAAMA;IACF,YACYC,aAAsC,EACtCC,eAAiD,EACjDC,UAAgC,CAC1C;aAHUF,aAAa,GAAbA;aACAC,eAAe,GAAfA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAa,QACTC,KAAe,EACfC,EAAiB,EACjBC,SAAiC,EAC+C;QAEhF,MAAMC,YAAY,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAAEH;YAAO,KAAK;QAAI;QAC5E,IAAI,CAACG,WACD,OAAOC,OAAO,IAAI,CAACC,wBAAwB,SAAS,CAACL;QAIzD,MAAMM,QAAQC,4BAA+BP,OAAOE,UAAU,MAAM,IAAK,CAAC;QAG1E,IAAIM;QACJ,IAAIP,IAAI;YACJ,MAAMQ,cAAc,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAACT,OAAOC;YAE9D,IAAIQ,YAAY,MAAM,IAClB,OAAOL,OAAO,IAAI,CAACK,YAAY,KAAK;YAGxCD,gBAAgBC,YAAY,KAAK;YAGjC,MAAMC,iBAAiB,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;gBAC3DV;gBACA,OAAOQ;gBACP,KAAK;YACT;YAEA,IAAI,CAACE,gBACD,OAAON,OAAO,IAAI,CAACC,wBAAwB,SAAS,CAACL;QAE7D;QAGA,MAAMW,mBAAmB,MAAMC,uBAAuB;YAClD,SAAS,IAAI,CAAC,UAAU;YACxBZ;YACA,QAAQM;YACR,OAAOE;QACX;QAEA,OAAOJ,OAAO,EAAE,CAACO,iBAAiB,MAAM,GAAG,IAAIA,mBAAmB,EAAE;IACxE;AACJ;AAEO,MAAME,4CAAuBC,qBAAAA,oBAAuC,CAAC;IACxE,gBAAgBlB;IAChB,cAAc;QAACmB;QAAeC;QAAwBC;KAAW;AACrE"}
|
package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.d.ts
CHANGED
|
@@ -11,5 +11,7 @@ declare class CreateEntryDataFactoryImpl implements ICreateEntryDataFactory {
|
|
|
11
11
|
constructor(cmsContext: CmsContext.Interface, identityContext: IdentityContext.Interface, tenantContext: TenantContext.Interface, accessControl: AccessControl.Interface);
|
|
12
12
|
create<TValues extends CmsEntryValues = CmsEntryValues>(model: CmsModel, rawInput: CreateCmsEntryInput<TValues>, options?: CreateCmsEntryOptionsInput): Promise<ICreateEntryDataResponse<TValues>>;
|
|
13
13
|
}
|
|
14
|
-
export declare const CreateEntryDataFactory:
|
|
14
|
+
export declare const CreateEntryDataFactory: typeof CreateEntryDataFactoryImpl & {
|
|
15
|
+
__abstraction: import("@webiny/di").Abstraction<ICreateEntryDataFactory>;
|
|
16
|
+
};
|
|
15
17
|
export {};
|
package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createImplementation } from "@webiny/feature/api";
|
|
2
1
|
import { CreateEntryDataFactory } from "./abstractions.js";
|
|
3
2
|
import { AccessControl, CmsContext } from "../../../shared/abstractions.js";
|
|
4
3
|
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
@@ -76,7 +75,7 @@ class CreateEntryDataFactoryImpl {
|
|
|
76
75
|
context: this.cmsContext,
|
|
77
76
|
model,
|
|
78
77
|
values: initialValues,
|
|
79
|
-
|
|
78
|
+
skipValidation: options?.skipValidation
|
|
80
79
|
});
|
|
81
80
|
const values = await referenceFieldsMapping({
|
|
82
81
|
context: this.cmsContext,
|
|
@@ -201,8 +200,7 @@ class CreateEntryDataFactoryImpl {
|
|
|
201
200
|
};
|
|
202
201
|
}
|
|
203
202
|
}
|
|
204
|
-
const CreateEntryDataFactory_CreateEntryDataFactory = createImplementation({
|
|
205
|
-
abstraction: CreateEntryDataFactory,
|
|
203
|
+
const CreateEntryDataFactory_CreateEntryDataFactory = CreateEntryDataFactory.createImplementation({
|
|
206
204
|
implementation: CreateEntryDataFactoryImpl,
|
|
207
205
|
dependencies: [
|
|
208
206
|
CmsContext,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport {\n CreateEntryDataFactory as FactoryAbstraction,\n type ICreateEntryDataFactory,\n type ICreateEntryDataResponse\n} from \"./abstractions.js\";\nimport { AccessControl, CmsContext } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CmsModelField,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport WebinyError from \"@webiny/error\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { createIdentifier, mdbid } from \"@webiny/utils\";\nimport { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from \"../statuses.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { NotAuthorizedError } from \"~/utils/errors.js\";\nimport { getSystem } from \"../system.js\";\nimport { getExpiresAt } from \"../expiresAt.js\";\n\ntype DefaultValue = boolean | number | string | null;\n\nconst convertDefaultValue = (field: CmsModelField, value: DefaultValue): DefaultValue => {\n switch (field.type) {\n case \"boolean\":\n return Boolean(value);\n case \"number\":\n return Number(value);\n default:\n return value;\n }\n};\n\nconst getDefaultValue = (field: CmsModelField): (DefaultValue | DefaultValue[]) | undefined => {\n const { settings, list } = field;\n if (settings && settings.defaultValue !== undefined) {\n return convertDefaultValue(field, settings.defaultValue);\n }\n const { predefinedValues } = field;\n if (\n !predefinedValues ||\n !predefinedValues.enabled ||\n Array.isArray(predefinedValues.values) === false\n ) {\n return undefined;\n }\n if (!list) {\n const selectedValue = predefinedValues.values.find(value => {\n return !!value.selected;\n });\n if (selectedValue) {\n return convertDefaultValue(field, selectedValue.value);\n }\n return undefined;\n }\n return predefinedValues.values\n .filter(({ selected }) => !!selected)\n .map(({ value }) => {\n return convertDefaultValue(field, value);\n });\n};\n\nconst cleanInputValues = <TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n input: TValues\n) => {\n return model.fields.reduce<TValues>((acc, field) => {\n if (!field.fieldId) {\n throw new WebinyError(\"Field does not have an fieldId.\", \"MISSING_FIELD_ID\", {\n field\n });\n }\n const key = field.fieldId as keyof TValues;\n const value = input[key] as TValues[keyof TValues];\n acc[key] = value === undefined ? (getDefaultValue(field) as TValues[keyof TValues]) : value;\n return acc;\n }, {} as TValues);\n};\n\nconst createEntryId = (input: CreateCmsEntryInput) => {\n let entryId = mdbid();\n if (input.id) {\n if (input.id.match(/^([a-zA-Z0-9])([a-zA-Z0-9-]+)([a-zA-Z0-9])$/) === null) {\n throw new WebinyError(\n \"The provided ID is not valid. It must be a string which can be A-Z, a-z, 0-9, - and it cannot start or end with a -.\",\n \"INVALID_ID\",\n {\n id: input.id\n }\n );\n }\n entryId = input.id;\n }\n const version = 1;\n return {\n entryId,\n version,\n id: createIdentifier({\n id: entryId,\n version\n })\n };\n};\n\nclass CreateEntryDataFactoryImpl implements ICreateEntryDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly accessControl: AccessControl.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: CreateCmsEntryInput<TValues>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<ICreateEntryDataResponse<TValues>> {\n const initialValues = cleanInputValues<TValues>(model, rawInput.values || ({} as TValues));\n\n await validateModelEntryDataOrThrow({\n context: this.cmsContext,\n model,\n values: initialValues,\n skipValidators: options?.skipValidators\n });\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: initialValues,\n validateEntries: true\n });\n\n const { id, entryId, version } = createEntryId(rawInput);\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n const status = rawInput.status || STATUS_DRAFT;\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n const canPublish = await this.accessControl.canAccessEntry({ model, pw: \"p\" });\n if (!canPublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n } else if (status === STATUS_UNPUBLISHED) {\n const canUnpublish = await this.accessControl.canAccessEntry({ model, pw: \"u\" });\n if (!canUnpublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n }\n }\n\n const locked = status !== STATUS_DRAFT;\n\n let revisionLevelPublishingMetaFields: Pick<\n CmsEntry,\n | \"revisionFirstPublishedOn\"\n | \"revisionLastPublishedOn\"\n | \"revisionFirstPublishedBy\"\n | \"revisionLastPublishedBy\"\n > = {\n revisionFirstPublishedOn: null,\n revisionLastPublishedOn: null,\n revisionFirstPublishedBy: null,\n revisionLastPublishedBy: null\n };\n\n let entryLevelPublishingMetaFields: Pick<\n CmsEntry,\n \"firstPublishedOn\" | \"lastPublishedOn\" | \"firstPublishedBy\" | \"lastPublishedBy\"\n > = {\n firstPublishedOn: null,\n lastPublishedOn: null,\n firstPublishedBy: null,\n lastPublishedBy: null\n };\n\n if (status === STATUS_PUBLISHED) {\n revisionLevelPublishingMetaFields = {\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n currentDateTime\n ),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n currentIdentity\n )\n };\n\n entryLevelPublishingMetaFields = {\n firstPublishedOn: getDate(rawInput.firstPublishedOn, currentDateTime),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, currentDateTime),\n firstPublishedBy: getIdentity(rawInput.firstPublishedBy, currentIdentity),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, currentIdentity)\n };\n }\n\n const entry: CmsEntry<TValues> = {\n tenant: this.tenantContext.getTenant().id,\n entryId,\n id,\n modelId: model.modelId,\n createdOn: getDate(rawInput.createdOn, currentDateTime),\n modifiedOn: getDate(rawInput.modifiedOn, null),\n savedOn: getDate(rawInput.savedOn, currentDateTime),\n deletedOn: getDate(rawInput.deletedOn, null),\n restoredOn: getDate(rawInput.restoredOn, null),\n createdBy: getIdentity(rawInput.createdBy, currentIdentity)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, null),\n savedBy: getIdentity(rawInput.savedBy, currentIdentity)!,\n deletedBy: getIdentity(rawInput.deletedBy, null),\n restoredBy: getIdentity(rawInput.restoredBy, null),\n ...entryLevelPublishingMetaFields,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, currentDateTime),\n revisionModifiedOn: getDate(rawInput.revisionModifiedOn, null),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, currentDateTime),\n revisionDeletedOn: getDate(rawInput.revisionDeletedOn, null),\n revisionRestoredOn: getDate(rawInput.revisionRestoredOn, null),\n revisionCreatedBy: getIdentity(rawInput.revisionCreatedBy, currentIdentity)!,\n revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, null),\n revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity)!,\n revisionDeletedBy: getIdentity(rawInput.revisionDeletedBy, null),\n revisionRestoredBy: getIdentity(rawInput.revisionRestoredBy, null),\n ...revisionLevelPublishingMetaFields,\n version,\n status,\n locked,\n values,\n location: {\n folderId:\n rawInput.location?.folderId || rawInput.wbyAco_location?.folderId || ROOT_FOLDER\n },\n system: getSystem({\n input: rawInput\n }),\n live:\n status === STATUS_PUBLISHED\n ? {\n version\n }\n : null,\n revisionDescription: \"\",\n expiresAt: getExpiresAt({ expiresAt: rawInput.expiresAt })\n };\n\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n const canPublish = await this.accessControl.canAccessEntry({\n model,\n entry,\n pw: \"p\"\n });\n if (!canPublish) {\n throw new NotAuthorizedError(`Not allowed to access entry \"${entry.entryId}\".`);\n }\n } else if (status === STATUS_UNPUBLISHED) {\n const canUnpublish = await this.accessControl.canAccessEntry({\n model,\n entry,\n pw: \"u\"\n });\n if (!canUnpublish) {\n throw new NotAuthorizedError(`Not allowed to access entry \"${entry.entryId}\".`);\n }\n }\n }\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n }\n}\n\nexport const CreateEntryDataFactory = createImplementation({\n abstraction: FactoryAbstraction,\n implementation: CreateEntryDataFactoryImpl,\n dependencies: [CmsContext, IdentityContext, TenantContext, AccessControl]\n});\n"],"names":["convertDefaultValue","field","value","Boolean","Number","getDefaultValue","settings","list","undefined","predefinedValues","Array","selectedValue","selected","cleanInputValues","model","input","acc","WebinyError","key","createEntryId","entryId","mdbid","version","createIdentifier","CreateEntryDataFactoryImpl","cmsContext","identityContext","tenantContext","accessControl","rawInput","options","initialValues","validateModelEntryDataOrThrow","values","referenceFieldsMapping","id","currentIdentity","currentDateTime","Date","status","STATUS_DRAFT","STATUS_PUBLISHED","canPublish","NotAuthorizedError","STATUS_UNPUBLISHED","canUnpublish","locked","revisionLevelPublishingMetaFields","entryLevelPublishingMetaFields","getDate","getIdentity","entry","ROOT_FOLDER","getSystem","getExpiresAt","structuredClone","CreateEntryDataFactory","createImplementation","FactoryAbstraction","CmsContext","IdentityContext","TenantContext","AccessControl"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAMA,sBAAsB,CAACC,OAAsBC;IAC/C,OAAQD,MAAM,IAAI;QACd,KAAK;YACD,OAAOE,QAAQD;QACnB,KAAK;YACD,OAAOE,OAAOF;QAClB;YACI,OAAOA;IACf;AACJ;AAEA,MAAMG,kBAAkB,CAACJ;IACrB,MAAM,EAAEK,QAAQ,EAAEC,IAAI,EAAE,GAAGN;IAC3B,IAAIK,YAAYA,AAA0BE,WAA1BF,SAAS,YAAY,EACjC,OAAON,oBAAoBC,OAAOK,SAAS,YAAY;IAE3D,MAAM,EAAEG,gBAAgB,EAAE,GAAGR;IAC7B,IACI,CAACQ,oBACD,CAACA,iBAAiB,OAAO,IACzBC,AAA2C,UAA3CA,MAAM,OAAO,CAACD,iBAAiB,MAAM,GAErC;IAEJ,IAAI,CAACF,MAAM;QACP,MAAMI,gBAAgBF,iBAAiB,MAAM,CAAC,IAAI,CAACP,CAAAA,QACxC,CAAC,CAACA,MAAM,QAAQ;QAE3B,IAAIS,eACA,OAAOX,oBAAoBC,OAAOU,cAAc,KAAK;QAEzD;IACJ;IACA,OAAOF,iBAAiB,MAAM,CACzB,MAAM,CAAC,CAAC,EAAEG,QAAQ,EAAE,GAAK,CAAC,CAACA,UAC3B,GAAG,CAAC,CAAC,EAAEV,KAAK,EAAE,GACJF,oBAAoBC,OAAOC;AAE9C;AAEA,MAAMW,mBAAmB,CACrBC,OACAC,QAEOD,MAAM,MAAM,CAAC,MAAM,CAAU,CAACE,KAAKf;QACtC,IAAI,CAACA,MAAM,OAAO,EACd,MAAM,IAAIgB,MAAY,mCAAmC,oBAAoB;YACzEhB;QACJ;QAEJ,MAAMiB,MAAMjB,MAAM,OAAO;QACzB,MAAMC,QAAQa,KAAK,CAACG,IAAI;QAC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ACvD5B;oBACAqC;oBACA,IAAI;gBACR;gBACA,IAAI,CAACT,YACD,MAAM,IAAIC,mBAAmB,CAAC,6BAA6B,EAAEQ,MAAM,OAAO,CAAC,EAAE,CAAC;YAEtF,OAAO,IAAIZ,WAAWK,oBAAoB;gBACtC,MAAMC,eAAe,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;oBACzD/B;oBACAqC;oBACA,IAAI;gBACR;gBACA,IAAI,CAACN,cACD,MAAM,IAAIF,mBAAmB,CAAC,6BAA6B,EAAEQ,MAAM,OAAO,CAAC,EAAE,CAAC;YAEtF;QAAA;QAGJ,OAAO;YACHA;YACA,OAAO;gBACH,GAAGtB,QAAQ;gBACX,QAAQ0B,gBAAgBtB;YAC5B;QACJ;IACJ;AACJ;AAEO,MAAMuB,gDAAyBC,qBAAqB;IACvD,aAAaC;IACb,gBAAgBlC;IAChB,cAAc;QAACmC;QAAYC;QAAiBC;QAAeC;KAAc;AAC7E"}
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.ts"],"sourcesContent":["import {\n CreateEntryDataFactory as FactoryAbstraction,\n type ICreateEntryDataFactory,\n type ICreateEntryDataResponse\n} from \"./abstractions.js\";\nimport { AccessControl, CmsContext } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CmsModelField,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport WebinyError from \"@webiny/error\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { createIdentifier, mdbid } from \"@webiny/utils\";\nimport { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from \"../statuses.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { NotAuthorizedError } from \"~/utils/errors.js\";\nimport { getSystem } from \"../system.js\";\nimport { getExpiresAt } from \"../expiresAt.js\";\n\ntype DefaultValue = boolean | number | string | null;\n\nconst convertDefaultValue = (field: CmsModelField, value: DefaultValue): DefaultValue => {\n switch (field.type) {\n case \"boolean\":\n return Boolean(value);\n case \"number\":\n return Number(value);\n default:\n return value;\n }\n};\n\nconst getDefaultValue = (field: CmsModelField): (DefaultValue | DefaultValue[]) | undefined => {\n const { settings, list } = field;\n if (settings && settings.defaultValue !== undefined) {\n return convertDefaultValue(field, settings.defaultValue);\n }\n const { predefinedValues } = field;\n if (\n !predefinedValues ||\n !predefinedValues.enabled ||\n Array.isArray(predefinedValues.values) === false\n ) {\n return undefined;\n }\n if (!list) {\n const selectedValue = predefinedValues.values.find(value => {\n return !!value.selected;\n });\n if (selectedValue) {\n return convertDefaultValue(field, selectedValue.value);\n }\n return undefined;\n }\n return predefinedValues.values\n .filter(({ selected }) => !!selected)\n .map(({ value }) => {\n return convertDefaultValue(field, value);\n });\n};\n\nconst cleanInputValues = <TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n input: TValues\n) => {\n return model.fields.reduce<TValues>((acc, field) => {\n if (!field.fieldId) {\n throw new WebinyError(\"Field does not have an fieldId.\", \"MISSING_FIELD_ID\", {\n field\n });\n }\n const key = field.fieldId as keyof TValues;\n const value = input[key] as TValues[keyof TValues];\n acc[key] = value === undefined ? (getDefaultValue(field) as TValues[keyof TValues]) : value;\n return acc;\n }, {} as TValues);\n};\n\nconst createEntryId = (input: CreateCmsEntryInput) => {\n let entryId = mdbid();\n if (input.id) {\n if (input.id.match(/^([a-zA-Z0-9])([a-zA-Z0-9-]+)([a-zA-Z0-9])$/) === null) {\n throw new WebinyError(\n \"The provided ID is not valid. It must be a string which can be A-Z, a-z, 0-9, - and it cannot start or end with a -.\",\n \"INVALID_ID\",\n {\n id: input.id\n }\n );\n }\n entryId = input.id;\n }\n const version = 1;\n return {\n entryId,\n version,\n id: createIdentifier({\n id: entryId,\n version\n })\n };\n};\n\nclass CreateEntryDataFactoryImpl implements ICreateEntryDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly accessControl: AccessControl.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: CreateCmsEntryInput<TValues>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<ICreateEntryDataResponse<TValues>> {\n const initialValues = cleanInputValues<TValues>(model, rawInput.values || ({} as TValues));\n\n await validateModelEntryDataOrThrow({\n context: this.cmsContext,\n model,\n values: initialValues,\n skipValidation: options?.skipValidation\n });\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: initialValues,\n validateEntries: true\n });\n\n const { id, entryId, version } = createEntryId(rawInput);\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n const status = rawInput.status || STATUS_DRAFT;\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n const canPublish = await this.accessControl.canAccessEntry({ model, pw: \"p\" });\n if (!canPublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n } else if (status === STATUS_UNPUBLISHED) {\n const canUnpublish = await this.accessControl.canAccessEntry({ model, pw: \"u\" });\n if (!canUnpublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n }\n }\n\n const locked = status !== STATUS_DRAFT;\n\n let revisionLevelPublishingMetaFields: Pick<\n CmsEntry,\n | \"revisionFirstPublishedOn\"\n | \"revisionLastPublishedOn\"\n | \"revisionFirstPublishedBy\"\n | \"revisionLastPublishedBy\"\n > = {\n revisionFirstPublishedOn: null,\n revisionLastPublishedOn: null,\n revisionFirstPublishedBy: null,\n revisionLastPublishedBy: null\n };\n\n let entryLevelPublishingMetaFields: Pick<\n CmsEntry,\n \"firstPublishedOn\" | \"lastPublishedOn\" | \"firstPublishedBy\" | \"lastPublishedBy\"\n > = {\n firstPublishedOn: null,\n lastPublishedOn: null,\n firstPublishedBy: null,\n lastPublishedBy: null\n };\n\n if (status === STATUS_PUBLISHED) {\n revisionLevelPublishingMetaFields = {\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n currentDateTime\n ),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n currentIdentity\n )\n };\n\n entryLevelPublishingMetaFields = {\n firstPublishedOn: getDate(rawInput.firstPublishedOn, currentDateTime),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, currentDateTime),\n firstPublishedBy: getIdentity(rawInput.firstPublishedBy, currentIdentity),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, currentIdentity)\n };\n }\n\n const entry: CmsEntry<TValues> = {\n tenant: this.tenantContext.getTenant().id,\n entryId,\n id,\n modelId: model.modelId,\n createdOn: getDate(rawInput.createdOn, currentDateTime),\n modifiedOn: getDate(rawInput.modifiedOn, null),\n savedOn: getDate(rawInput.savedOn, currentDateTime),\n deletedOn: getDate(rawInput.deletedOn, null),\n restoredOn: getDate(rawInput.restoredOn, null),\n createdBy: getIdentity(rawInput.createdBy, currentIdentity)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, null),\n savedBy: getIdentity(rawInput.savedBy, currentIdentity)!,\n deletedBy: getIdentity(rawInput.deletedBy, null),\n restoredBy: getIdentity(rawInput.restoredBy, null),\n ...entryLevelPublishingMetaFields,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, currentDateTime),\n revisionModifiedOn: getDate(rawInput.revisionModifiedOn, null),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, currentDateTime),\n revisionDeletedOn: getDate(rawInput.revisionDeletedOn, null),\n revisionRestoredOn: getDate(rawInput.revisionRestoredOn, null),\n revisionCreatedBy: getIdentity(rawInput.revisionCreatedBy, currentIdentity)!,\n revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, null),\n revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity)!,\n revisionDeletedBy: getIdentity(rawInput.revisionDeletedBy, null),\n revisionRestoredBy: getIdentity(rawInput.revisionRestoredBy, null),\n ...revisionLevelPublishingMetaFields,\n version,\n status,\n locked,\n values,\n location: {\n folderId:\n rawInput.location?.folderId || rawInput.wbyAco_location?.folderId || ROOT_FOLDER\n },\n system: getSystem({\n input: rawInput\n }),\n live:\n status === STATUS_PUBLISHED\n ? {\n version\n }\n : null,\n revisionDescription: \"\",\n expiresAt: getExpiresAt({ expiresAt: rawInput.expiresAt })\n };\n\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n const canPublish = await this.accessControl.canAccessEntry({\n model,\n entry,\n pw: \"p\"\n });\n if (!canPublish) {\n throw new NotAuthorizedError(`Not allowed to access entry \"${entry.entryId}\".`);\n }\n } else if (status === STATUS_UNPUBLISHED) {\n const canUnpublish = await this.accessControl.canAccessEntry({\n model,\n entry,\n pw: \"u\"\n });\n if (!canUnpublish) {\n throw new NotAuthorizedError(`Not allowed to access entry \"${entry.entryId}\".`);\n }\n }\n }\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n }\n}\n\nexport const CreateEntryDataFactory = FactoryAbstraction.createImplementation({\n implementation: CreateEntryDataFactoryImpl,\n dependencies: [CmsContext, IdentityContext, TenantContext, AccessControl]\n});\n"],"names":["convertDefaultValue","field","value","Boolean","Number","getDefaultValue","settings","list","undefined","predefinedValues","Array","selectedValue","selected","cleanInputValues","model","input","acc","WebinyError","key","createEntryId","entryId","mdbid","version","createIdentifier","CreateEntryDataFactoryImpl","cmsContext","identityContext","tenantContext","accessControl","rawInput","options","initialValues","validateModelEntryDataOrThrow","values","referenceFieldsMapping","id","currentIdentity","currentDateTime","Date","status","STATUS_DRAFT","STATUS_PUBLISHED","canPublish","NotAuthorizedError","STATUS_UNPUBLISHED","canUnpublish","locked","revisionLevelPublishingMetaFields","entryLevelPublishingMetaFields","getDate","getIdentity","entry","ROOT_FOLDER","getSystem","getExpiresAt","structuredClone","CreateEntryDataFactory","FactoryAbstraction","CmsContext","IdentityContext","TenantContext","AccessControl"],"mappings":";;;;;;;;;;;;;;;AA8BA,MAAMA,sBAAsB,CAACC,OAAsBC;IAC/C,OAAQD,MAAM,IAAI;QACd,KAAK;YACD,OAAOE,QAAQD;QACnB,KAAK;YACD,OAAOE,OAAOF;QAClB;YACI,OAAOA;IACf;AACJ;AAEA,MAAMG,kBAAkB,CAACJ;IACrB,MAAM,EAAEK,QAAQ,EAAEC,IAAI,EAAE,GAAGN;IAC3B,IAAIK,YAAYA,AAA0BE,WAA1BF,SAAS,YAAY,EACjC,OAAON,oBAAoBC,OAAOK,SAAS,YAAY;IAE3D,MAAM,EAAEG,gBAAgB,EAAE,GAAGR;IAC7B,IACI,CAACQ,oBACD,CAACA,iBAAiB,OAAO,IACzBC,AAA2C,UAA3CA,MAAM,OAAO,CAACD,iBAAiB,MAAM,GAErC;IAEJ,IAAI,CAACF,MAAM;QACP,MAAMI,gBAAgBF,iBAAiB,MAAM,CAAC,IAAI,CAACP,CAAAA,QACxC,CAAC,CAACA,MAAM,QAAQ;QAE3B,IAAIS,eACA,OAAOX,oBAAoBC,OAAOU,cAAc,KAAK;QAEzD;IACJ;IACA,OAAOF,iBAAiB,MAAM,CACzB,MAAM,CAAC,CAAC,EAAEG,QAAQ,EAAE,GAAK,CAAC,CAACA,UAC3B,GAAG,CAA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SAAS,eAAe,EAAE,YAAYuB;YAC7E;YACA,QAAQC,UAAU;gBACd,OAAOxB;YACX;YACA,MACIU,WAAWE,mBACL;gBACInB;YACJ,IACA;YACV,qBAAqB;YACrB,WAAWgC,aAAa;gBAAE,WAAWzB,SAAS,SAAS;YAAC;QAC5D;QAEA,IAAIU,WAAWC,cACX;YAAA,IAAID,WAAWE,kBAAkB;gBAC7B,MAAMC,aAAa,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;oBACvD5B;oBACAqC;oBACA,IAAI;gBACR;gBACA,IAAI,CAACT,YACD,MAAM,IAAIC,mBAAmB,CAAC,6BAA6B,EAAEQ,MAAM,OAAO,CAAC,EAAE,CAAC;YAEtF,OAAO,IAAIZ,WAAWK,oBAAoB;gBACtC,MAAMC,eAAe,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;oBACzD/B;oBACAqC;oBACA,IAAI;gBACR;gBACA,IAAI,CAACN,cACD,MAAM,IAAIF,mBAAmB,CAAC,6BAA6B,EAAEQ,MAAM,OAAO,CAAC,EAAE,CAAC;YAEtF;QAAA;QAGJ,OAAO;YACHA;YACA,OAAO;gBACH,GAAGtB,QAAQ;gBACX,QAAQ0B,gBAAgBtB;YAC5B;QACJ;IACJ;AACJ;AAEO,MAAMuB,gDAAyBC,uBAAAA,oBAAuC,CAAC;IAC1E,gBAAgBjC;IAChB,cAAc;QAACkC;QAAYC;QAAiBC;QAAeC;KAAc;AAC7E"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { type ICreateEntryRevisionFromDataFactory, type ICreateEntryRevisionFromDataResponse } from "./abstractions.js";
|
|
2
2
|
import { AccessControl, CmsContext } from "../../../../features/shared/abstractions.js";
|
|
3
|
-
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
4
3
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
5
4
|
import type { CmsEntry, CmsEntryValues, CmsModel, CreateCmsEntryInput, CreateCmsEntryOptionsInput } from "../../../../types/index.js";
|
|
6
5
|
declare class CreateEntryRevisionFromDataFactoryImpl implements ICreateEntryRevisionFromDataFactory {
|
|
7
6
|
private readonly cmsContext;
|
|
8
7
|
private readonly identityContext;
|
|
9
|
-
private readonly tenantContext;
|
|
10
8
|
private readonly accessControl;
|
|
11
|
-
constructor(cmsContext: CmsContext.Interface, identityContext: IdentityContext.Interface,
|
|
9
|
+
constructor(cmsContext: CmsContext.Interface, identityContext: IdentityContext.Interface, accessControl: AccessControl.Interface);
|
|
12
10
|
create<TValues extends CmsEntryValues = CmsEntryValues>(sourceId: string, model: CmsModel, rawInput: CreateCmsEntryInput<TValues>, originalEntry: CmsEntry<TValues>, latestStorageEntry: CmsEntry<TValues>, options?: CreateCmsEntryOptionsInput): Promise<ICreateEntryRevisionFromDataResponse<TValues>>;
|
|
13
11
|
}
|
|
14
|
-
export declare const CreateEntryRevisionFromDataFactory:
|
|
12
|
+
export declare const CreateEntryRevisionFromDataFactory: typeof CreateEntryRevisionFromDataFactoryImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<ICreateEntryRevisionFromDataFactory>;
|
|
14
|
+
};
|
|
15
15
|
export {};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { createImplementation } from "@webiny/feature/api";
|
|
2
1
|
import { CreateEntryRevisionFromDataFactory } from "./abstractions.js";
|
|
3
2
|
import { AccessControl, CmsContext } from "../../../shared/abstractions.js";
|
|
4
|
-
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
5
3
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
6
4
|
import { getDate } from "../../../../utils/date.js";
|
|
7
5
|
import { getIdentity } from "../../../../utils/identity.js";
|
|
@@ -28,10 +26,9 @@ const increaseEntryIdVersion = (id)=>{
|
|
|
28
26
|
};
|
|
29
27
|
};
|
|
30
28
|
class CreateEntryRevisionFromDataFactoryImpl {
|
|
31
|
-
constructor(cmsContext, identityContext,
|
|
29
|
+
constructor(cmsContext, identityContext, accessControl){
|
|
32
30
|
this.cmsContext = cmsContext;
|
|
33
31
|
this.identityContext = identityContext;
|
|
34
|
-
this.tenantContext = tenantContext;
|
|
35
32
|
this.accessControl = accessControl;
|
|
36
33
|
}
|
|
37
34
|
async create(sourceId, model, rawInput, originalEntry, latestStorageEntry, options) {
|
|
@@ -44,7 +41,7 @@ class CreateEntryRevisionFromDataFactoryImpl {
|
|
|
44
41
|
model,
|
|
45
42
|
values: initialValues,
|
|
46
43
|
entry: originalEntry,
|
|
47
|
-
|
|
44
|
+
skipValidation: options?.skipValidation
|
|
48
45
|
});
|
|
49
46
|
const values = await referenceFieldsMapping({
|
|
50
47
|
context: this.cmsContext,
|
|
@@ -116,6 +113,7 @@ class CreateEntryRevisionFromDataFactoryImpl {
|
|
|
116
113
|
revisionCreatedBy: getIdentity(rawInput.revisionCreatedBy, currentIdentity),
|
|
117
114
|
revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity),
|
|
118
115
|
revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, null),
|
|
116
|
+
revisionDescription: void 0,
|
|
119
117
|
...revisionLevelPublishingMetaFields,
|
|
120
118
|
locked,
|
|
121
119
|
status,
|
|
@@ -136,13 +134,11 @@ class CreateEntryRevisionFromDataFactoryImpl {
|
|
|
136
134
|
};
|
|
137
135
|
}
|
|
138
136
|
}
|
|
139
|
-
const CreateEntryRevisionFromDataFactory_CreateEntryRevisionFromDataFactory = createImplementation({
|
|
140
|
-
abstraction: CreateEntryRevisionFromDataFactory,
|
|
137
|
+
const CreateEntryRevisionFromDataFactory_CreateEntryRevisionFromDataFactory = CreateEntryRevisionFromDataFactory.createImplementation({
|
|
141
138
|
implementation: CreateEntryRevisionFromDataFactoryImpl,
|
|
142
139
|
dependencies: [
|
|
143
140
|
CmsContext,
|
|
144
141
|
IdentityContext,
|
|
145
|
-
TenantContext,
|
|
146
142
|
AccessControl
|
|
147
143
|
]
|
|
148
144
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport {\n CreateEntryRevisionFromDataFactory as FactoryAbstraction,\n type ICreateEntryRevisionFromDataFactory,\n type ICreateEntryRevisionFromDataResponse\n} from \"./abstractions.js\";\nimport { AccessControl, CmsContext } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { mapAndCleanUpdatedInputData } from \"../mapAndCleanUpdatedInputData.js\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\nimport { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from \"../statuses.js\";\nimport { NotAuthorizedError } from \"~/utils/errors.js\";\nimport { getSystem } from \"../system.js\";\n\nconst increaseEntryIdVersion = (id: string) => {\n const { id: entryId, version } = parseIdentifier(id);\n if (!version) {\n throw new WebinyError(\n \"Cannot increase version on the ID without the version part.\",\n \"WRONG_ID\",\n {\n id\n }\n );\n }\n return {\n entryId,\n version: version + 1,\n id: createIdentifier({\n id: entryId,\n version: version + 1\n })\n };\n};\n\nclass CreateEntryRevisionFromDataFactoryImpl implements ICreateEntryRevisionFromDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly accessControl: AccessControl.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n sourceId: string,\n model: CmsModel,\n rawInput: CreateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n latestStorageEntry: CmsEntry<TValues>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<ICreateEntryRevisionFromDataResponse<TValues>> {\n const initialValues = {\n ...originalEntry.values,\n ...mapAndCleanUpdatedInputData<TValues>(model, rawInput.values)\n };\n\n await validateModelEntryDataOrThrow({\n context: this.cmsContext,\n model,\n values: initialValues,\n entry: originalEntry,\n skipValidators: options?.skipValidators\n });\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: initialValues,\n validateEntries: false\n });\n\n const latestId = latestStorageEntry ? latestStorageEntry.id : sourceId;\n const { id, version: nextVersion } = increaseEntryIdVersion(latestId);\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n const status = rawInput.status || STATUS_DRAFT;\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n const canPublish = await this.accessControl.canAccessEntry({ model, pw: \"p\" });\n if (!canPublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n } else if (status === STATUS_UNPUBLISHED) {\n const canUnpublish = await this.accessControl.canAccessEntry({ model, pw: \"u\" });\n if (!canUnpublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n }\n }\n\n const locked = status !== STATUS_DRAFT;\n\n let revisionLevelPublishingMetaFields: Pick<\n CmsEntry,\n | \"revisionFirstPublishedOn\"\n | \"revisionLastPublishedOn\"\n | \"revisionFirstPublishedBy\"\n | \"revisionLastPublishedBy\"\n > = {\n revisionFirstPublishedOn: getDate(rawInput.revisionFirstPublishedOn, null),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, null),\n revisionFirstPublishedBy: getIdentity(rawInput.revisionFirstPublishedBy, null),\n revisionLastPublishedBy: getIdentity(rawInput.revisionLastPublishedBy, null)\n };\n\n let entryLevelPublishingMetaFields: Pick<\n CmsEntry,\n \"firstPublishedOn\" | \"lastPublishedOn\" | \"firstPublishedBy\" | \"lastPublishedBy\"\n > = {\n firstPublishedOn: getDate(\n rawInput.firstPublishedOn,\n latestStorageEntry.firstPublishedOn\n ),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, latestStorageEntry.lastPublishedOn),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n latestStorageEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(\n rawInput.lastPublishedBy,\n latestStorageEntry.lastPublishedBy\n )\n };\n\n if (status === STATUS_PUBLISHED) {\n revisionLevelPublishingMetaFields = {\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n currentDateTime\n ),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n currentIdentity\n )\n };\n\n entryLevelPublishingMetaFields = {\n firstPublishedOn: getDate(\n rawInput.firstPublishedOn,\n latestStorageEntry.firstPublishedOn\n ),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, currentDateTime),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n latestStorageEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, currentIdentity)\n };\n }\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n id,\n version: nextVersion,\n createdOn: getDate(rawInput.createdOn, latestStorageEntry.createdOn),\n savedOn: getDate(rawInput.savedOn, currentDateTime),\n modifiedOn: getDate(rawInput.modifiedOn, currentDateTime),\n createdBy: getIdentity(rawInput.createdBy, latestStorageEntry.createdBy)!,\n savedBy: getIdentity(rawInput.savedBy, currentIdentity)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, currentIdentity),\n ...entryLevelPublishingMetaFields,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, currentDateTime),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, currentDateTime),\n revisionModifiedOn: getDate(rawInput.revisionModifiedOn, null),\n revisionCreatedBy: getIdentity(rawInput.revisionCreatedBy, currentIdentity)!,\n revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity)!,\n revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, null),\n ...revisionLevelPublishingMetaFields,\n locked,\n status,\n values,\n system: getSystem({\n input: rawInput,\n original: originalEntry\n }),\n live: originalEntry.live,\n expiresAt: null\n };\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n }\n}\n\nexport const CreateEntryRevisionFromDataFactory = createImplementation({\n abstraction: FactoryAbstraction,\n implementation: CreateEntryRevisionFromDataFactoryImpl,\n dependencies: [CmsContext, IdentityContext, TenantContext, AccessControl]\n});\n"],"names":["increaseEntryIdVersion","id","entryId","version","parseIdentifier","WebinyError","createIdentifier","CreateEntryRevisionFromDataFactoryImpl","cmsContext","identityContext","tenantContext","accessControl","sourceId","model","rawInput","originalEntry","latestStorageEntry","options","initialValues","mapAndCleanUpdatedInputData","validateModelEntryDataOrThrow","values","referenceFieldsMapping","latestId","nextVersion","currentIdentity","currentDateTime","Date","status","STATUS_DRAFT","STATUS_PUBLISHED","canPublish","NotAuthorizedError","STATUS_UNPUBLISHED","canUnpublish","locked","revisionLevelPublishingMetaFields","getDate","getIdentity","entryLevelPublishingMetaFields","entry","getSystem","structuredClone","CreateEntryRevisionFromDataFactory","createImplementation","FactoryAbstraction","CmsContext","IdentityContext","TenantContext","AccessControl"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAM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ACdxB,SAAS,gBAAgB,EACzBE,mBAAmB,gBAAgB;gBAEvC,iBAAiBsB,YAAYxB,SAAS,eAAe,EAAEW;YAC3D;QACJ;QAEA,MAAMe,QAA2B;YAC7B,GAAGzB,aAAa;YAChBd;YACA,SAASuB;YACT,WAAWa,QAAQvB,SAAS,SAAS,EAAEE,mBAAmB,SAAS;YACnE,SAASqB,QAAQvB,SAAS,OAAO,EAAEY;YACnC,YAAYW,QAAQvB,SAAS,UAAU,EAAEY;YACzC,WAAWY,YAAYxB,SAAS,SAAS,EAAEE,mBAAmB,SAAS;YACvE,SAASsB,YAAYxB,SAAS,OAAO,EAAEW;YACvC,YAAYa,YAAYxB,SAAS,UAAU,EAAEW;YAC7C,GAAGc,8BAA8B;YACjC,mBAAmBF,QAAQvB,SAAS,iBAAiB,EAAEY;YACvD,iBAAiBW,QAAQvB,SAAS,eAAe,EAAEY;YACnD,oBAAoBW,QAAQvB,SAAS,kBAAkB,EAAE;YACzD,mBAAmBwB,YAAYxB,SAAS,iBAAiB,EAAEW;YAC3D,iBAAiBa,YAAYxB,SAAS,eAAe,EAAEW;YACvD,oBAAoBa,YAAYxB,SAAS,kBAAkB,EAAE;YAC7D,GAAGsB,iCAAiC;YACpCD;YACAP;YACAP;YACA,QAAQoB,UAAU;gBACd,OAAO3B;gBACP,UAAUC;YACd;YACA,MAAMA,cAAc,IAAI;YACxB,WAAW;QACf;QAEA,OAAO;YACHyB;YACA,OAAO;gBACH,GAAG1B,QAAQ;gBACX,QAAQ4B,gBAAgBrB;YAC5B;QACJ;IACJ;AACJ;AAEO,MAAMsB,wEAAqCC,qBAAqB;IACnE,aAAaC;IACb,gBAAgBtC;IAChB,cAAc;QAACuC;QAAYC;QAAiBC;QAAeC;KAAc;AAC7E"}
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.ts"],"sourcesContent":["import {\n CreateEntryRevisionFromDataFactory as FactoryAbstraction,\n type ICreateEntryRevisionFromDataFactory,\n type ICreateEntryRevisionFromDataResponse\n} from \"./abstractions.js\";\nimport { AccessControl, CmsContext } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { mapAndCleanUpdatedInputData } from \"../mapAndCleanUpdatedInputData.js\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\nimport { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from \"../statuses.js\";\nimport { NotAuthorizedError } from \"~/utils/errors.js\";\nimport { getSystem } from \"../system.js\";\n\nconst increaseEntryIdVersion = (id: string) => {\n const { id: entryId, version } = parseIdentifier(id);\n if (!version) {\n throw new WebinyError(\n \"Cannot increase version on the ID without the version part.\",\n \"WRONG_ID\",\n {\n id\n }\n );\n }\n return {\n entryId,\n version: version + 1,\n id: createIdentifier({\n id: entryId,\n version: version + 1\n })\n };\n};\n\nclass CreateEntryRevisionFromDataFactoryImpl implements ICreateEntryRevisionFromDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly accessControl: AccessControl.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n sourceId: string,\n model: CmsModel,\n rawInput: CreateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n latestStorageEntry: CmsEntry<TValues>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<ICreateEntryRevisionFromDataResponse<TValues>> {\n const initialValues = {\n ...originalEntry.values,\n ...mapAndCleanUpdatedInputData<TValues>(model, rawInput.values)\n };\n\n await validateModelEntryDataOrThrow({\n context: this.cmsContext,\n model,\n values: initialValues,\n entry: originalEntry,\n skipValidation: options?.skipValidation\n });\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: initialValues,\n validateEntries: false\n });\n\n const latestId = latestStorageEntry ? latestStorageEntry.id : sourceId;\n const { id, version: nextVersion } = increaseEntryIdVersion(latestId);\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n const status = rawInput.status || STATUS_DRAFT;\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n const canPublish = await this.accessControl.canAccessEntry({ model, pw: \"p\" });\n if (!canPublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n } else if (status === STATUS_UNPUBLISHED) {\n const canUnpublish = await this.accessControl.canAccessEntry({ model, pw: \"u\" });\n if (!canUnpublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n }\n }\n\n const locked = status !== STATUS_DRAFT;\n\n let revisionLevelPublishingMetaFields: Pick<\n CmsEntry,\n | \"revisionFirstPublishedOn\"\n | \"revisionLastPublishedOn\"\n | \"revisionFirstPublishedBy\"\n | \"revisionLastPublishedBy\"\n > = {\n revisionFirstPublishedOn: getDate(rawInput.revisionFirstPublishedOn, null),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, null),\n revisionFirstPublishedBy: getIdentity(rawInput.revisionFirstPublishedBy, null),\n revisionLastPublishedBy: getIdentity(rawInput.revisionLastPublishedBy, null)\n };\n\n let entryLevelPublishingMetaFields: Pick<\n CmsEntry,\n \"firstPublishedOn\" | \"lastPublishedOn\" | \"firstPublishedBy\" | \"lastPublishedBy\"\n > = {\n firstPublishedOn: getDate(\n rawInput.firstPublishedOn,\n latestStorageEntry.firstPublishedOn\n ),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, latestStorageEntry.lastPublishedOn),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n latestStorageEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(\n rawInput.lastPublishedBy,\n latestStorageEntry.lastPublishedBy\n )\n };\n\n if (status === STATUS_PUBLISHED) {\n revisionLevelPublishingMetaFields = {\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n currentDateTime\n ),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n currentIdentity\n )\n };\n\n entryLevelPublishingMetaFields = {\n firstPublishedOn: getDate(\n rawInput.firstPublishedOn,\n latestStorageEntry.firstPublishedOn\n ),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, currentDateTime),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n latestStorageEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, currentIdentity)\n };\n }\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n id,\n version: nextVersion,\n createdOn: getDate(rawInput.createdOn, latestStorageEntry.createdOn),\n savedOn: getDate(rawInput.savedOn, currentDateTime),\n modifiedOn: getDate(rawInput.modifiedOn, currentDateTime),\n createdBy: getIdentity(rawInput.createdBy, latestStorageEntry.createdBy)!,\n savedBy: getIdentity(rawInput.savedBy, currentIdentity)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, currentIdentity),\n ...entryLevelPublishingMetaFields,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, currentDateTime),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, currentDateTime),\n revisionModifiedOn: getDate(rawInput.revisionModifiedOn, null),\n revisionCreatedBy: getIdentity(rawInput.revisionCreatedBy, currentIdentity)!,\n revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity)!,\n revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, null),\n revisionDescription: undefined,\n ...revisionLevelPublishingMetaFields,\n locked,\n status,\n values,\n system: getSystem({\n input: rawInput,\n original: originalEntry\n }),\n live: originalEntry.live,\n expiresAt: null\n };\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n }\n}\n\nexport const CreateEntryRevisionFromDataFactory = FactoryAbstraction.createImplementation({\n implementation: CreateEntryRevisionFromDataFactoryImpl,\n dependencies: [CmsContext, IdentityContext, AccessControl]\n});\n"],"names":["increaseEntryIdVersion","id","entryId","version","parseIdentifier","WebinyError","createIdentifier","CreateEntryRevisionFromDataFactoryImpl","cmsContext","identityContext","accessControl","sourceId","model","rawInput","originalEntry","latestStorageEntry","options","initialValues","mapAndCleanUpdatedInputData","validateModelEntryDataOrThrow","values","referenceFieldsMapping","latestId","nextVersion","currentIdentity","currentDateTime","Date","status","STATUS_DRAFT","STATUS_PUBLISHED","canPublish","NotAuthorizedError","STATUS_UNPUBLISHED","canUnpublish","locked","revisionLevelPublishingMetaFields","getDate","getIdentity","entryLevelPublishingMetaFields","entry","undefined","getSystem","structuredClone","CreateEntryRevisionFromDataFactory","FactoryAbstraction","CmsContext","IdentityContext","AccessControl"],"mappings":";;;;;;;;;;;;;AAyBA,MAAMA,yBAAyB,CAACC;IAC5B,MAAM,EAAE,IAAIC,OAAO,EAAEC,OAAO,EAAE,GAAGC,gBAAgBH;IACjD,IAAI,CAACE,SACD,MAAM,IAAIE,MACN,+DACA,YACA;QACIJ;IACJ;IAGR,OAAO;QACHC;QACA,SAASC,UAAU;QACnB,IAAIG,iBAAiB;YACjB,IAAIJ;YACJ,SAASC,UAAU;QACvB;IACJ;AACJ;AAEA,MAAMI;IACF,YACqBC,UAAgC,EAChCC,eAA0C,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AEE,mBAAmB,SAAS;YACvE,SAASsB,YAAYxB,SAAS,OAAO,EAAEW;YACvC,YAAYa,YAAYxB,SAAS,UAAU,EAAEW;YAC7C,GAAGc,8BAA8B;YACjC,mBAAmBF,QAAQvB,SAAS,iBAAiB,EAAEY;YACvD,iBAAiBW,QAAQvB,SAAS,eAAe,EAAEY;YACnD,oBAAoBW,QAAQvB,SAAS,kBAAkB,EAAE;YACzD,mBAAmBwB,YAAYxB,SAAS,iBAAiB,EAAEW;YAC3D,iBAAiBa,YAAYxB,SAAS,eAAe,EAAEW;YACvD,oBAAoBa,YAAYxB,SAAS,kBAAkB,EAAE;YAC7D,qBAAqB2B;YACrB,GAAGL,iCAAiC;YACpCD;YACAP;YACAP;YACA,QAAQqB,UAAU;gBACd,OAAO5B;gBACP,UAAUC;YACd;YACA,MAAMA,cAAc,IAAI;YACxB,WAAW;QACf;QAEA,OAAO;YACHyB;YACA,OAAO;gBACH,GAAG1B,QAAQ;gBACX,QAAQ6B,gBAAgBtB;YAC5B;QACJ;IACJ;AACJ;AAEO,MAAMuB,wEAAqCC,mCAAAA,oBAAuC,CAAC;IACtF,gBAAgBrC;IAChB,cAAc;QAACsC;QAAYC;QAAiBC;KAAc;AAC9D"}
|
|
@@ -8,5 +8,7 @@ declare class CreatePublishEntryDataFactoryImpl implements ICreatePublishEntryDa
|
|
|
8
8
|
constructor(cmsContext: CmsContext.Interface, identityContext: IdentityContext.Interface);
|
|
9
9
|
create<TValues extends CmsEntryValues = CmsEntryValues>(model: CmsModel, originalEntry: CmsEntry<TValues>, latestEntry: CmsEntry<TValues>): Promise<ICreatePublishEntryDataResponse<TValues>>;
|
|
10
10
|
}
|
|
11
|
-
export declare const CreatePublishEntryDataFactory:
|
|
11
|
+
export declare const CreatePublishEntryDataFactory: typeof CreatePublishEntryDataFactoryImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<ICreatePublishEntryDataFactory>;
|
|
13
|
+
};
|
|
12
14
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createImplementation } from "@webiny/feature/api";
|
|
2
1
|
import { CreatePublishEntryDataFactory } from "./abstractions.js";
|
|
3
2
|
import { CmsContext } from "../../../shared/abstractions.js";
|
|
4
3
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
@@ -53,8 +52,7 @@ class CreatePublishEntryDataFactoryImpl {
|
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
|
-
const CreatePublishEntryDataFactory_CreatePublishEntryDataFactory = createImplementation({
|
|
57
|
-
abstraction: CreatePublishEntryDataFactory,
|
|
55
|
+
const CreatePublishEntryDataFactory_CreatePublishEntryDataFactory = CreatePublishEntryDataFactory.createImplementation({
|
|
58
56
|
implementation: CreatePublishEntryDataFactoryImpl,
|
|
59
57
|
dependencies: [
|
|
60
58
|
CmsContext,
|