@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,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ErrorResponse, Response } from "@webiny/handler-graphql";
|
|
1
|
+
import { ErrorResponse, Response } from "@webiny/api-graphql";
|
|
3
2
|
import { getEntryTitle } from "../../utils/getEntryTitle.js";
|
|
4
3
|
import { createCmsGraphQLSchemaPlugin } from "../../plugins/index.js";
|
|
5
4
|
import { getEntryDescription } from "../../utils/getEntryDescription.js";
|
|
@@ -8,6 +7,11 @@ import { entryFieldFromStorageTransform } from "../../utils/entryStorage.js";
|
|
|
8
7
|
import { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from "../../constants.js";
|
|
9
8
|
import NotAuthorizedResponse from "@webiny/api-core/graphql/security/NotAuthorizedResponse.js";
|
|
10
9
|
import { ListLatestEntriesUseCase } from "../../features/contentEntry/ListEntries/index.js";
|
|
10
|
+
import { ListModelsUseCase } from "../../features/contentModel/ListModels/index.js";
|
|
11
|
+
import { GetLatestEntriesByIdsUseCase } from "../../features/contentEntry/GetLatestEntriesByIds/index.js";
|
|
12
|
+
import { GetPublishedEntriesByIdsUseCase } from "../../features/contentEntry/GetPublishedEntriesByIds/index.js";
|
|
13
|
+
import { GetEntriesByIdsUseCase } from "../../features/contentEntry/GetEntriesByIds/index.js";
|
|
14
|
+
import { HeadlessCmsEndpointConfig } from "../../HeadlessCmsEndpointConfig.js";
|
|
11
15
|
const createDate = (date)=>{
|
|
12
16
|
if (!date) return null;
|
|
13
17
|
try {
|
|
@@ -52,25 +56,28 @@ const createCmsEntryRecord = (model, entry)=>({
|
|
|
52
56
|
}
|
|
53
57
|
});
|
|
54
58
|
const getFetchMethod = (type, context)=>{
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
if ("latest" === type) return async (model, ids)=>{
|
|
60
|
+
const result = await context.container.resolve(GetLatestEntriesByIdsUseCase).execute(model, ids);
|
|
61
|
+
if (result.isFail()) throw result.error;
|
|
62
|
+
return result.value;
|
|
63
|
+
};
|
|
64
|
+
if ("published" === type) return async (model, ids)=>{
|
|
65
|
+
const result = await context.container.resolve(GetPublishedEntriesByIdsUseCase).execute(model, ids);
|
|
66
|
+
if (result.isFail()) throw result.error;
|
|
67
|
+
return result.value;
|
|
68
|
+
};
|
|
69
|
+
return async (model, ids)=>{
|
|
70
|
+
const result = await context.container.resolve(GetEntriesByIdsUseCase).execute(model, ids);
|
|
71
|
+
if (result.isFail()) throw result.error;
|
|
72
|
+
return result.value;
|
|
73
|
+
};
|
|
69
74
|
};
|
|
70
75
|
const getContentEntries = async (params)=>{
|
|
71
76
|
const { args, context, type } = params;
|
|
72
77
|
const method = getFetchMethod(type, context);
|
|
73
|
-
const
|
|
78
|
+
const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
|
|
79
|
+
if (modelsResult.isFail()) throw modelsResult.error;
|
|
80
|
+
const models = modelsResult.value;
|
|
74
81
|
const modelsMap = models.reduce((collection, model)=>{
|
|
75
82
|
collection[model.modelId] = model;
|
|
76
83
|
return collection;
|
|
@@ -98,14 +105,11 @@ const getContentEntries = async (params)=>{
|
|
|
98
105
|
};
|
|
99
106
|
const getContentEntry = async (params)=>{
|
|
100
107
|
const { args, context, type } = params;
|
|
101
|
-
if (!getContentEntriesMethods[type]) throw new error(`Unknown getContentEntry method "${type}". Could not fetch content entry.`, "UNKNOWN_METHOD_ERROR", {
|
|
102
|
-
args,
|
|
103
|
-
type
|
|
104
|
-
});
|
|
105
108
|
const method = getFetchMethod(type, context);
|
|
106
109
|
const { modelId, id } = args.entry;
|
|
107
|
-
const
|
|
108
|
-
|
|
110
|
+
const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
|
|
111
|
+
if (modelsResult.isFail()) throw modelsResult.error;
|
|
112
|
+
const model = modelsResult.value.find((m)=>m.modelId === modelId);
|
|
109
113
|
if (!model) return new NotAuthorizedResponse({
|
|
110
114
|
data: {
|
|
111
115
|
modelId
|
|
@@ -119,8 +123,9 @@ const getContentEntry = async (params)=>{
|
|
|
119
123
|
return new Response(createCmsEntryRecord(model, entry));
|
|
120
124
|
};
|
|
121
125
|
const createResolveDescription = ()=>async (parent, _, context)=>{
|
|
122
|
-
const
|
|
123
|
-
|
|
126
|
+
const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
|
|
127
|
+
if (modelsResult.isFail()) return null;
|
|
128
|
+
const model = modelsResult.value.find(({ modelId })=>parent.model.modelId === modelId);
|
|
124
129
|
if (!model) return null;
|
|
125
130
|
const field = model.fields.find((f)=>f.fieldId === model.descriptionFieldId);
|
|
126
131
|
if (!field) return null;
|
|
@@ -134,12 +139,13 @@ const createResolveDescription = ()=>async (parent, _, context)=>{
|
|
|
134
139
|
});
|
|
135
140
|
};
|
|
136
141
|
const createContentEntriesSchema = ({ context })=>{
|
|
137
|
-
|
|
142
|
+
const enhancerConfig = context.container.resolve(HeadlessCmsEndpointConfig);
|
|
143
|
+
if ("manage" !== enhancerConfig.type) {
|
|
138
144
|
const plugin = createCmsGraphQLSchemaPlugin({
|
|
139
145
|
typeDefs: "",
|
|
140
146
|
resolvers: {}
|
|
141
147
|
});
|
|
142
|
-
plugin.name = `headless-cms.graphql.schema.${
|
|
148
|
+
plugin.name = `headless-cms.graphql.schema.${enhancerConfig.type}.empty`;
|
|
143
149
|
return plugin;
|
|
144
150
|
}
|
|
145
151
|
const onByMetaFields = ENTRY_META_FIELDS.map((field)=>{
|
|
@@ -218,12 +224,15 @@ const createContentEntriesSchema = ({ context })=>{
|
|
|
218
224
|
CmsContentEntry: {
|
|
219
225
|
published: async (parent, _, context)=>{
|
|
220
226
|
try {
|
|
221
|
-
const
|
|
222
|
-
|
|
227
|
+
const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
|
|
228
|
+
if (modelsResult.isFail()) return null;
|
|
229
|
+
const model = modelsResult.value.find(({ modelId })=>parent.model.modelId === modelId);
|
|
223
230
|
if (!model) return null;
|
|
224
|
-
const
|
|
231
|
+
const result = await context.container.resolve(GetPublishedEntriesByIdsUseCase).execute(model, [
|
|
225
232
|
parent.id
|
|
226
233
|
]);
|
|
234
|
+
if (result.isFail()) return null;
|
|
235
|
+
const entry = result.value[0];
|
|
227
236
|
if (!entry) return null;
|
|
228
237
|
return createCmsEntryRecord(model, entry);
|
|
229
238
|
} catch {
|
|
@@ -238,7 +247,9 @@ const createContentEntriesSchema = ({ context })=>{
|
|
|
238
247
|
Query: {
|
|
239
248
|
async searchContentEntries (_, args, context) {
|
|
240
249
|
const { modelIds, fields, query, limit = 10 } = args;
|
|
241
|
-
const
|
|
250
|
+
const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
|
|
251
|
+
if (modelsResult.isFail()) return new ErrorResponse(modelsResult.error);
|
|
252
|
+
const models = modelsResult.value;
|
|
242
253
|
const getters = models.filter((model)=>modelIds.includes(model.modelId)).map(async (model)=>{
|
|
243
254
|
const listLatest = await context.container.resolve(ListLatestEntriesUseCase);
|
|
244
255
|
const where = {};
|
|
@@ -304,7 +315,7 @@ const createContentEntriesSchema = ({ context })=>{
|
|
|
304
315
|
}
|
|
305
316
|
}
|
|
306
317
|
});
|
|
307
|
-
plugin.name = `headless-cms.graphql.schema.${context.
|
|
318
|
+
plugin.name = `headless-cms.graphql.schema.${context.container.resolve(HeadlessCmsEndpointConfig).type}.content-entries`;
|
|
308
319
|
return plugin;
|
|
309
320
|
};
|
|
310
321
|
export { createContentEntriesSchema };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/schema/contentEntries.js","sources":["../../../src/graphql/schema/contentEntries.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport type {\n CmsContext,\n CmsEntry,\n CmsEntryListWhere,\n CmsIdentity,\n CmsModel\n} from \"~/types/index.js\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { getEntryDescription } from \"~/utils/getEntryDescription.js\";\nimport { getEntryImage } from \"~/utils/getEntryImage.js\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage.js\";\nimport type { GraphQLFieldResolver } from \"@webiny/handler-graphql/types.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { ListLatestEntriesUseCase } from \"~/features/contentEntry/ListEntries/index.js\";\n\ninterface EntriesByModel {\n [key: string]: string[];\n}\n\ntype GetContentEntryType = \"latest\" | \"published\" | \"exact\";\n\nconst createDate = (date: string | null): Date | null => {\n if (!date) {\n return null;\n }\n\n try {\n return new Date(date);\n } catch {\n return new Date();\n }\n};\n\ninterface CmsEntryRecord {\n id: string;\n entryId: string;\n model: {\n modelId: string;\n name: string;\n };\n status: string;\n title: string;\n description?: string | null;\n image?: string | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: Date;\n modifiedOn: Date | null;\n savedOn: Date;\n createdBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n savedBy: CmsIdentity;\n firstPublishedOn: Date | null;\n lastPublishedOn: Date | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: Date;\n revisionModifiedOn: Date | null;\n revisionSavedOn: Date;\n revisionCreatedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionSavedBy: CmsIdentity;\n revisionFirstPublishedOn: Date | null;\n revisionLastPublishedOn: Date | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n wbyAco_location?: {\n folderId?: string | null;\n };\n}\n\nconst createCmsEntryRecord = (model: CmsModel, entry: CmsEntry): CmsEntryRecord => {\n return {\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry),\n description: getEntryDescription(model, entry),\n image: getEntryImage(model, entry),\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: createDate(entry.createdOn)!,\n modifiedOn: createDate(entry.modifiedOn),\n savedOn: createDate(entry.savedOn)!,\n createdBy: entry.createdBy,\n savedBy: entry.savedBy,\n modifiedBy: entry.modifiedBy,\n firstPublishedOn: createDate(entry.firstPublishedOn),\n lastPublishedOn: createDate(entry.lastPublishedOn),\n firstPublishedBy: entry.firstPublishedBy,\n lastPublishedBy: entry.lastPublishedBy,\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: createDate(entry.revisionCreatedOn)!,\n revisionSavedOn: createDate(entry.revisionSavedOn)!,\n revisionModifiedOn: createDate(entry.revisionModifiedOn),\n revisionCreatedBy: entry.revisionCreatedBy,\n revisionModifiedBy: entry.revisionModifiedBy,\n revisionSavedBy: entry.revisionSavedBy,\n revisionFirstPublishedOn: createDate(entry.revisionFirstPublishedOn),\n revisionLastPublishedOn: createDate(entry.revisionLastPublishedOn),\n revisionFirstPublishedBy: entry.revisionFirstPublishedBy,\n revisionLastPublishedBy: entry.revisionLastPublishedBy,\n\n wbyAco_location: {\n folderId: entry.location?.folderId || null\n }\n };\n};\n\ninterface FetchMethod {\n (model: CmsModel, ids: string[]): Promise<CmsEntry[]>;\n}\n\nconst getFetchMethod = (type: GetContentEntryType, context: CmsContext): FetchMethod => {\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntries method \"${type}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type\n }\n );\n }\n const methodName = getContentEntriesMethods[type] as GetContentEntryMethods;\n if (!context.cms[methodName]) {\n throw new WebinyError(\n `Unknown context.cms method \"${methodName}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type,\n methodName\n }\n );\n }\n\n return context.cms[methodName];\n};\n\n/**\n * Function to get the list of content entries depending on latest, published or exact GraphQL queries.\n */\ninterface GetContentEntriesParams {\n args: {\n entries: Pick<CmsEntry, \"id\" | \"modelId\">[];\n };\n context: CmsContext;\n type: GetContentEntryType;\n}\n\nenum GetContentEntryMethods {\n getLatestEntriesByIds = \"getLatestEntriesByIds\",\n getPublishedEntriesByIds = \"getPublishedEntriesByIds\",\n getEntriesByIds = \"getEntriesByIds\"\n}\n\nconst getContentEntriesMethods = {\n latest: \"getLatestEntriesByIds\",\n published: \"getPublishedEntriesByIds\",\n exact: \"getEntriesByIds\"\n};\nconst getContentEntries = async (\n params: GetContentEntriesParams\n): Promise<Response | ErrorResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const models = await context.cms.listModels();\n\n const modelsMap = models.reduce(\n (collection, model) => {\n collection[model.modelId] = model;\n return collection;\n },\n {} as Record<string, CmsModel>\n );\n\n const argsEntries = args.entries as Pick<CmsEntry, \"id\" | \"modelId\">[];\n\n const entriesByModel = argsEntries.reduce((collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.id)) {\n return collection;\n }\n collection[ref.modelId].push(ref.id);\n return collection;\n }, {} as EntriesByModel);\n\n const getters: Promise<CmsEntry[]>[] = Object.keys(entriesByModel).map(async modelId => {\n return method(modelsMap[modelId], entriesByModel[modelId]);\n });\n\n if (getters.length === 0) {\n return new Response([]);\n }\n\n try {\n const results = await Promise.all(getters);\n\n const entries = results\n .reduce<CmsEntryRecord[]>((collection, items) => {\n return collection.concat(\n items.map(item => {\n const model = modelsMap[item.modelId];\n\n return createCmsEntryRecord(model, item);\n })\n );\n }, [])\n .filter(Boolean);\n\n return new Response(entries);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\n/**\n * Function to fetch a single content entry depending on latest, published or exact GraphQL query.\n */\ninterface GetContentEntryParams {\n args: {\n entry: Pick<CmsEntry, \"id\" | \"modelId\">;\n };\n context: CmsContext;\n type: \"latest\" | \"published\" | \"exact\";\n}\n\nconst getContentEntry = async (\n params: GetContentEntryParams\n): Promise<Response<CmsEntryRecord | null> | NotAuthorizedResponse> => {\n const { args, context, type } = params;\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntry method \"${type}\". Could not fetch content entry.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n args,\n type\n }\n );\n }\n\n const method = getFetchMethod(type, context);\n\n const { modelId, id } = args.entry;\n const models = await context.cms.listModels();\n const model = models.find(m => m.modelId === modelId);\n\n if (!model) {\n return new NotAuthorizedResponse({\n data: {\n modelId\n }\n });\n }\n\n const result = await method(model, [id]);\n\n const entry = result.shift();\n if (!entry) {\n return new Response(null);\n }\n\n return new Response(createCmsEntryRecord(model, entry));\n};\n/**\n * As we support description field, we need to transform the value from storage.\n */\nconst createResolveDescription = (): GraphQLFieldResolver<any, any, CmsContext> => {\n return async (parent, _, context) => {\n const models = await context.cms.listModels();\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return null;\n }\n const value = parent.description || parent[field.fieldId];\n if (!value) {\n return null;\n }\n return entryFieldFromStorageTransform({\n context,\n model,\n field,\n value\n });\n };\n};\n\ninterface Params {\n context: CmsContext;\n}\n\nexport const createContentEntriesSchema = ({\n context\n}: Params): ICmsGraphQLSchemaPlugin<CmsContext> => {\n if (!context.cms.MANAGE) {\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: \"\",\n resolvers: {}\n });\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.empty`;\n return plugin;\n }\n\n const onByMetaFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentity\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n const plugin = createCmsGraphQLSchemaPlugin({\n // Had to remove /* GraphQL */ because it causes issues with oxfmt formatting.\n typeDefs: `\n type CmsModelMeta {\n modelId: String!\n name: String!\n }\n\n type CmsPublishedContentEntry {\n id: ID!\n entryId: String!\n title: String\n description: String\n image: String\n }\n\n type CmsContentEntry {\n id: ID!\n entryId: String!\n model: CmsModelMeta!\n status: String!\n published: CmsPublishedContentEntry\n title: String!\n description: String\n image: String\n \n ${onByMetaFields}\n \n wbyAco_location: WbyAcoLocation\n }\n\n type CmsContentEntriesResponse {\n data: [CmsContentEntry!]\n error: CmsError\n }\n\n type CmsContentEntryResponse {\n data: CmsContentEntry\n error: CmsError\n }\n\n input CmsModelEntryInput {\n modelId: ID!\n id: ID!\n }\n\n extend type Query {\n # Search content entries for given content models using the query string.\n searchContentEntries(\n modelIds: [ID!]!\n query: String\n fields: [String!]\n limit: Int\n ): CmsContentEntriesResponse!\n\n # Get content entry meta data\n getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n # Get content entries meta data\n getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getPublishedContentEntries(\n entries: [CmsModelEntryInput!]!\n ): CmsContentEntriesResponse!\n }\n `,\n resolvers: {\n CmsContentEntry: {\n published: async (parent, _, context) => {\n try {\n const models = await context.cms.listModels();\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const [entry] = await context.cms.getPublishedEntriesByIds(model, [\n parent.id\n ]);\n if (!entry) {\n return null;\n }\n return createCmsEntryRecord(model, entry);\n } catch {\n return null;\n }\n },\n description: createResolveDescription()\n },\n CmsPublishedContentEntry: {\n description: createResolveDescription()\n },\n Query: {\n async searchContentEntries(_, args: any, context) {\n const { modelIds, fields, query, limit = 10 } = args;\n const models = await context.cms.listModels();\n\n const getters = models\n .filter(model => modelIds.includes(model.modelId))\n .map(async model => {\n const listLatest =\n await context.container.resolve(ListLatestEntriesUseCase);\n const where: CmsEntryListWhere = {};\n\n const result = await listLatest.execute(model, {\n limit,\n where,\n search: !!query ? query : undefined,\n fields: fields || []\n });\n // TODO figure a better way to handle errors in parallel execution\n if (result.isFail()) {\n throw result.error;\n }\n const { entries } = result.value;\n return entries.map((entry: CmsEntry) => {\n return createCmsEntryRecord(model, entry);\n });\n });\n\n try {\n const entries = await Promise.all(getters).then(results =>\n results.reduce((result, item) => result.concat(item), [])\n );\n\n return new Response(\n entries\n .sort((a, b) => b.savedOn.getTime() - a.savedOn.getTime())\n .slice(0, limit)\n );\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n async getContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"published\"\n });\n },\n async getContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"published\"\n });\n }\n }\n }\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-entries`;\n\n return plugin;\n};\n"],"names":["createDate","date","Date","createCmsEntryRecord","model","entry","getEntryTitle","getEntryDescription","getEntryImage","getFetchMethod","type","context","getContentEntriesMethods","WebinyError","methodName","getContentEntries","params","args","method","models","modelsMap","collection","argsEntries","entriesByModel","ref","getters","Object","modelId","Response","results","Promise","entries","items","item","Boolean","ex","ErrorResponse","getContentEntry","id","m","NotAuthorizedResponse","result","createResolveDescription","parent","_","field","f","value","entryFieldFromStorageTransform","createContentEntriesSchema","plugin","createCmsGraphQLSchemaPlugin","onByMetaFields","ENTRY_META_FIELDS","fieldType","isDateTimeEntryMetaField","modelIds","fields","query","limit","listLatest","ListLatestEntriesUseCase","where","undefined","a","b"],"mappings":";;;;;;;;;;AA0BA,MAAMA,aAAa,CAACC;IAChB,IAAI,CAACA,MACD,OAAO;IAGX,IAAI;QACA,OAAO,IAAIC,KAAKD;IACpB,EAAE,OAAM;QACJ,OAAO,IAAIC;IACf;AACJ;AA+CA,MAAMC,uBAAuB,CAACC,OAAiBC,QACpC;QACH,IAAIA,MAAM,EAAE;QACZ,SAASA,MAAM,OAAO;QACtB,OAAO;YACH,SAASD,MAA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,gBAAgB;wBACnBpB;wBACAN;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,uBAAsBiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBAC7C,OAAO0B,gBAAgB;wBACnBpB;wBACAN;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,0BAAyBiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBAChD,OAAO0B,gBAAgB;wBACnBpB;wBACAN;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,mBAAkBiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBACzC,OAAOI,kBAAkB;wBACrBE;wBACAN;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,yBAAwBiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBAC/C,OAAOI,kBAAkB;wBACrBE;wBACAN;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,4BAA2BiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBAClD,OAAOI,kBAAkB;wBACrBE;wBACAN;wBACA,MAAM;oBACV;gBACJ;YACJ;QACJ;IACJ;IAEAuC,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAEvC,QAAQ,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC;IAE/E,OAAOuC;AACX"}
|
|
1
|
+
{"version":3,"file":"graphql/schema/contentEntries.js","sources":["../../../src/graphql/schema/contentEntries.ts"],"sourcesContent":["import { ErrorResponse, Response } from \"@webiny/api-graphql\";\nimport type {\n CmsContext,\n CmsEntry,\n CmsEntryListWhere,\n CmsIdentity,\n CmsModel\n} from \"~/types/index.js\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { getEntryDescription } from \"~/utils/getEntryDescription.js\";\nimport { getEntryImage } from \"~/utils/getEntryImage.js\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage.js\";\nimport type { GraphQLFieldResolver } from \"@webiny/api-graphql/types.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { ListLatestEntriesUseCase } from \"~/features/contentEntry/ListEntries/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\nimport { GetLatestEntriesByIdsUseCase } from \"~/features/contentEntry/GetLatestEntriesByIds/index.js\";\nimport { GetPublishedEntriesByIdsUseCase } from \"~/features/contentEntry/GetPublishedEntriesByIds/index.js\";\nimport { GetEntriesByIdsUseCase } from \"~/features/contentEntry/GetEntriesByIds/index.js\";\nimport { HeadlessCmsEndpointConfig } from \"~/HeadlessCmsEndpointConfig.js\";\n\ninterface EntriesByModel {\n [key: string]: string[];\n}\n\ntype GetContentEntryType = \"latest\" | \"published\" | \"exact\";\n\nconst createDate = (date: string | null): Date | null => {\n if (!date) {\n return null;\n }\n\n try {\n return new Date(date);\n } catch {\n return new Date();\n }\n};\n\ninterface CmsEntryRecord {\n id: string;\n entryId: string;\n model: {\n modelId: string;\n name: string;\n };\n status: string;\n title: string;\n description?: string | null;\n image?: string | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: Date;\n modifiedOn: Date | null;\n savedOn: Date;\n createdBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n savedBy: CmsIdentity;\n firstPublishedOn: Date | null;\n lastPublishedOn: Date | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: Date;\n revisionModifiedOn: Date | null;\n revisionSavedOn: Date;\n revisionCreatedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionSavedBy: CmsIdentity;\n revisionFirstPublishedOn: Date | null;\n revisionLastPublishedOn: Date | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n wbyAco_location?: {\n folderId?: string | null;\n };\n}\n\nconst createCmsEntryRecord = (model: CmsModel, entry: CmsEntry): CmsEntryRecord => {\n return {\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry),\n description: getEntryDescription(model, entry),\n image: getEntryImage(model, entry),\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: createDate(entry.createdOn)!,\n modifiedOn: createDate(entry.modifiedOn),\n savedOn: createDate(entry.savedOn)!,\n createdBy: entry.createdBy,\n savedBy: entry.savedBy,\n modifiedBy: entry.modifiedBy,\n firstPublishedOn: createDate(entry.firstPublishedOn),\n lastPublishedOn: createDate(entry.lastPublishedOn),\n firstPublishedBy: entry.firstPublishedBy,\n lastPublishedBy: entry.lastPublishedBy,\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: createDate(entry.revisionCreatedOn)!,\n revisionSavedOn: createDate(entry.revisionSavedOn)!,\n revisionModifiedOn: createDate(entry.revisionModifiedOn),\n revisionCreatedBy: entry.revisionCreatedBy,\n revisionModifiedBy: entry.revisionModifiedBy,\n revisionSavedBy: entry.revisionSavedBy,\n revisionFirstPublishedOn: createDate(entry.revisionFirstPublishedOn),\n revisionLastPublishedOn: createDate(entry.revisionLastPublishedOn),\n revisionFirstPublishedBy: entry.revisionFirstPublishedBy,\n revisionLastPublishedBy: entry.revisionLastPublishedBy,\n\n wbyAco_location: {\n folderId: entry.location?.folderId || null\n }\n };\n};\n\ninterface FetchMethod {\n (model: CmsModel, ids: string[]): Promise<CmsEntry[]>;\n}\n\nconst getFetchMethod = (type: GetContentEntryType, context: CmsContext): FetchMethod => {\n if (type === \"latest\") {\n return async (model, ids) => {\n const result = await context.container\n .resolve(GetLatestEntriesByIdsUseCase)\n .execute(model, ids);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n } else if (type === \"published\") {\n return async (model, ids) => {\n const result = await context.container\n .resolve(GetPublishedEntriesByIdsUseCase)\n .execute(model, ids);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n } else {\n return async (model, ids) => {\n const result = await context.container\n .resolve(GetEntriesByIdsUseCase)\n .execute(model, ids);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n }\n};\n\n/**\n * Function to get the list of content entries depending on latest, published or exact GraphQL queries.\n */\ninterface GetContentEntriesParams {\n args: {\n entries: Pick<CmsEntry, \"id\" | \"modelId\">[];\n };\n context: CmsContext;\n type: GetContentEntryType;\n}\n\nconst getContentEntries = async (\n params: GetContentEntriesParams\n): Promise<Response | ErrorResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const modelsResult = await context.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n throw modelsResult.error;\n }\n const models = modelsResult.value;\n\n const modelsMap = models.reduce(\n (collection, model) => {\n collection[model.modelId] = model;\n return collection;\n },\n {} as Record<string, CmsModel>\n );\n\n const argsEntries = args.entries as Pick<CmsEntry, \"id\" | \"modelId\">[];\n\n const entriesByModel = argsEntries.reduce((collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.id)) {\n return collection;\n }\n collection[ref.modelId].push(ref.id);\n return collection;\n }, {} as EntriesByModel);\n\n const getters: Promise<CmsEntry[]>[] = Object.keys(entriesByModel).map(async modelId => {\n return method(modelsMap[modelId], entriesByModel[modelId]);\n });\n\n if (getters.length === 0) {\n return new Response([]);\n }\n\n try {\n const results = await Promise.all(getters);\n\n const entries = results\n .reduce<CmsEntryRecord[]>((collection, items) => {\n return collection.concat(\n items.map(item => {\n const model = modelsMap[item.modelId];\n\n return createCmsEntryRecord(model, item);\n })\n );\n }, [])\n .filter(Boolean);\n\n return new Response(entries);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\n/**\n * Function to fetch a single content entry depending on latest, published or exact GraphQL query.\n */\ninterface GetContentEntryParams {\n args: {\n entry: Pick<CmsEntry, \"id\" | \"modelId\">;\n };\n context: CmsContext;\n type: \"latest\" | \"published\" | \"exact\";\n}\n\nconst getContentEntry = async (\n params: GetContentEntryParams\n): Promise<Response<CmsEntryRecord | null> | NotAuthorizedResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const { modelId, id } = args.entry;\n const modelsResult = await context.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n throw modelsResult.error;\n }\n const model = modelsResult.value.find(m => m.modelId === modelId);\n\n if (!model) {\n return new NotAuthorizedResponse({\n data: {\n modelId\n }\n });\n }\n\n const result = await method(model, [id]);\n\n const entry = result.shift();\n if (!entry) {\n return new Response(null);\n }\n\n return new Response(createCmsEntryRecord(model, entry));\n};\n/**\n * As we support description field, we need to transform the value from storage.\n */\nconst createResolveDescription = (): GraphQLFieldResolver<any, any, CmsContext> => {\n return async (parent, _, context) => {\n const modelsResult = await context.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n return null;\n }\n const model = modelsResult.value.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return null;\n }\n const value = parent.description || parent[field.fieldId];\n if (!value) {\n return null;\n }\n return entryFieldFromStorageTransform({\n context,\n model,\n field,\n value\n });\n };\n};\n\ninterface Params {\n context: CmsContext;\n}\n\nexport const createContentEntriesSchema = ({\n context\n}: Params): ICmsGraphQLSchemaPlugin<CmsContext> => {\n const enhancerConfig = context.container.resolve(HeadlessCmsEndpointConfig);\n if (enhancerConfig.type !== \"manage\") {\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: \"\",\n resolvers: {}\n });\n plugin.name = `headless-cms.graphql.schema.${enhancerConfig.type}.empty`;\n return plugin;\n }\n\n const onByMetaFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentity\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n const plugin = createCmsGraphQLSchemaPlugin({\n // Had to remove /* GraphQL */ because it causes issues with oxfmt formatting.\n typeDefs: `\n type CmsModelMeta {\n modelId: String!\n name: String!\n }\n\n type CmsPublishedContentEntry {\n id: ID!\n entryId: String!\n title: String\n description: String\n image: String\n }\n\n type CmsContentEntry {\n id: ID!\n entryId: String!\n model: CmsModelMeta!\n status: String!\n published: CmsPublishedContentEntry\n title: String!\n description: String\n image: String\n \n ${onByMetaFields}\n \n wbyAco_location: WbyAcoLocation\n }\n\n type CmsContentEntriesResponse {\n data: [CmsContentEntry!]\n error: CmsError\n }\n\n type CmsContentEntryResponse {\n data: CmsContentEntry\n error: CmsError\n }\n\n input CmsModelEntryInput {\n modelId: ID!\n id: ID!\n }\n\n extend type Query {\n # Search content entries for given content models using the query string.\n searchContentEntries(\n modelIds: [ID!]!\n query: String\n fields: [String!]\n limit: Int\n ): CmsContentEntriesResponse!\n\n # Get content entry meta data\n getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n # Get content entries meta data\n getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getPublishedContentEntries(\n entries: [CmsModelEntryInput!]!\n ): CmsContentEntriesResponse!\n }\n `,\n resolvers: {\n CmsContentEntry: {\n published: async (parent, _, context) => {\n try {\n const modelsResult = await context.container\n .resolve(ListModelsUseCase)\n .execute();\n if (modelsResult.isFail()) {\n return null;\n }\n const model = modelsResult.value.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const result = await context.container\n .resolve(GetPublishedEntriesByIdsUseCase)\n .execute(model, [parent.id]);\n if (result.isFail()) {\n return null;\n }\n const entry = result.value[0];\n if (!entry) {\n return null;\n }\n return createCmsEntryRecord(model, entry);\n } catch {\n return null;\n }\n },\n description: createResolveDescription()\n },\n CmsPublishedContentEntry: {\n description: createResolveDescription()\n },\n Query: {\n async searchContentEntries(_, args: any, context) {\n const { modelIds, fields, query, limit = 10 } = args;\n const modelsResult = await context.container\n .resolve(ListModelsUseCase)\n .execute();\n if (modelsResult.isFail()) {\n return new ErrorResponse(modelsResult.error);\n }\n const models = modelsResult.value;\n\n const getters = models\n .filter(model => modelIds.includes(model.modelId))\n .map(async model => {\n const listLatest =\n await context.container.resolve(ListLatestEntriesUseCase);\n const where: CmsEntryListWhere = {};\n\n const result = await listLatest.execute(model, {\n limit,\n where,\n search: !!query ? query : undefined,\n fields: fields || []\n });\n // TODO figure a better way to handle errors in parallel execution\n if (result.isFail()) {\n throw result.error;\n }\n const { entries } = result.value;\n return entries.map((entry: CmsEntry) => {\n return createCmsEntryRecord(model, entry);\n });\n });\n\n try {\n const entries = await Promise.all(getters).then(results =>\n results.reduce((result, item) => result.concat(item), [])\n );\n\n return new Response(\n entries\n .sort((a, b) => b.savedOn.getTime() - a.savedOn.getTime())\n .slice(0, limit)\n );\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n async getContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"published\"\n });\n },\n async getContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"published\"\n });\n }\n }\n }\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.container.resolve(HeadlessCmsEndpointConfig).type}.content-entries`;\n\n return plugin;\n};\n"],"names":["createDate","date","Date","createCmsEntryRecord","model","entry","getEntryTitle","getEntryDescription","getEntryImage","getFetchMethod","type","context","ids","result","GetLatestEntriesByIdsUseCase","GetPublishedEntriesByIdsUseCase","GetEntriesByIdsUseCase","getContentEntries","params","args","method","modelsResult","ListModelsUseCase","models","modelsMap","collection","argsEntries","entriesByModel","ref","getters","Object","modelId","Response","results","Promise","entries","items","item","Boolean","ex","ErrorResponse","getContentEntry","id","m","NotAuthorizedResponse","createResolveDescription","parent","_","field","f","value","entryFieldFromStorageTransform","createContentEntriesSchema","enhancerConfig","HeadlessCmsEndpointConfig","plugin","createCmsGraphQLSchemaPlugin","onByMetaFields","ENTRY_META_FIELDS","fieldType","isDateTimeEntryMetaField","modelIds","fields","query","limit","listLatest","ListLatestEntriesUseCase","where","undefined","a","b"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAMA,aAAa,CAACC;IAChB,IAAI,CAACA,MACD,OAAO;IAGX,IAAI;QACA,OAAO,IAAIC,KAAKD;IACpB,EAAE,OAAM;QACJ,OAAO,IAAIC;IACf;AACJ;AA+CA,MAAMC,uBAAuB,CAACC,OAAiBC,QACpC;QACH,IAAIA,MAAM,EAAE;QACZ,SAASA,MAAM,OAAO;QACtB,OAAO;YACH,SAASD,MAAM,OAAO;YACtB,MAAMA,MAAM,IAAI;QACpB;QACA,QAAQC,MAAM,MAAM;QACpB,OAAOC,cAAcF,OAAOC;QAC5B,aAAaE,oBAAoBH,OAAOC;QACxC,OAAOG,cAAcJ,OAAOC;QAK5B,WAAWL,WAAWK,MAAM,SAAS;QACrC,YAAYL,WAAWK,MAAM,UAAU;QACvC,SAASL,WAAWK,MAAM,OAAO;QACjC,WAAWA,MAAM,SAAS;QAC1B,SAASA,MAAM,OAAO;QACtB,YAAYA,MAAM,UAAU;QAC5B,kBAAkBL,WAAWK,MAAM,gBAAgB;QACnD,iBAAiBL,WAAWK,MAAM,eAAe;QACj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CAAC,CAACkC,GAAGC,IAAMA,EAAE,OAAO,CAAC,OAAO,KAAKD,EAAE,OAAO,CAAC,OAAO,IACtD,KAAK,CAAC,GAAGL;oBAEtB,EAAE,OAAOzB,IAAI;wBACT,OAAO,IAAIC,cAAcD;oBAC7B;gBACJ;gBACA,MAAM,iBAAgBQ,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBACvC,OAAO8B,gBAAgB;wBACnBtB;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,uBAAsBoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBAC7C,OAAO8B,gBAAgB;wBACnBtB;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,0BAAyBoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBAChD,OAAO8B,gBAAgB;wBACnBtB;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,mBAAkBoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBACzC,OAAOM,kBAAkB;wBACrBE;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,yBAAwBoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBAC/C,OAAOM,kBAAkB;wBACrBE;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,4BAA2BoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBAClD,OAAOM,kBAAkB;wBACrBE;wBACAR;wBACA,MAAM;oBACV;gBACJ;YACJ;QACJ;IACJ;IAEA4C,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAE5C,QAAQ,SAAS,CAAC,OAAO,CAAC2C,2BAA2B,IAAI,CAAC,gBAAgB,CAAC;IAExH,OAAOC;AACX"}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { ErrorResponse, NotFoundError, Response } from "@webiny/
|
|
2
|
-
import {
|
|
1
|
+
import { ErrorResponse, NotFoundError, Response } from "@webiny/api-graphql";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
3
3
|
import { createCmsGraphQLSchemaPlugin } from "../../plugins/index.js";
|
|
4
|
+
import { GetGroupUseCase } from "../../features/contentModelGroup/GetGroup/index.js";
|
|
5
|
+
import { ListGroupsUseCase } from "../../features/contentModelGroup/ListGroups/index.js";
|
|
6
|
+
import { CreateGroupUseCase } from "../../features/contentModelGroup/CreateGroup/index.js";
|
|
7
|
+
import { UpdateGroupUseCase } from "../../features/contentModelGroup/UpdateGroup/index.js";
|
|
8
|
+
import { DeleteGroupUseCase } from "../../features/contentModelGroup/DeleteGroup/index.js";
|
|
9
|
+
import { PluginGroupsProvider } from "../../features/contentModelGroup/shared/index.js";
|
|
10
|
+
import { ListModelsUseCase } from "../../features/contentModel/ListModels/index.js";
|
|
11
|
+
import { HeadlessCmsEndpointConfig } from "../../HeadlessCmsEndpointConfig.js";
|
|
4
12
|
const createGroupsSchema = ({ context })=>{
|
|
13
|
+
const isManage = "manage" === context.container.resolve(HeadlessCmsEndpointConfig).type;
|
|
5
14
|
let manageSchema = "";
|
|
6
|
-
if (
|
|
15
|
+
if (isManage) manageSchema = `
|
|
7
16
|
input CmsContentModelGroupInput {
|
|
8
17
|
id: ID
|
|
9
18
|
name: String!
|
|
@@ -42,29 +51,36 @@ const createGroupsSchema = ({ context })=>{
|
|
|
42
51
|
}
|
|
43
52
|
`;
|
|
44
53
|
let resolvers = {};
|
|
45
|
-
if (
|
|
54
|
+
if (isManage) resolvers = {
|
|
46
55
|
CmsContentModelGroup: {
|
|
47
56
|
contentModels: async (group, _, context)=>{
|
|
48
|
-
const
|
|
49
|
-
|
|
57
|
+
const result = await context.container.resolve(IdentityContext).withoutAuthorization(async ()=>context.container.resolve(ListModelsUseCase).execute());
|
|
58
|
+
if (result.isFail()) return [];
|
|
59
|
+
return result.value.filter((model)=>{
|
|
50
60
|
if (true === model.isPrivate) return false;
|
|
51
61
|
return model.group === group.slug;
|
|
52
62
|
});
|
|
53
63
|
},
|
|
54
64
|
totalContentModels: async (group, _, context)=>{
|
|
55
|
-
const
|
|
56
|
-
|
|
65
|
+
const result = await context.container.resolve(IdentityContext).withoutAuthorization(async ()=>context.container.resolve(ListModelsUseCase).execute());
|
|
66
|
+
if (result.isFail()) return 0;
|
|
67
|
+
return result.value.filter((model)=>{
|
|
57
68
|
if (true === model.isPrivate) return false;
|
|
58
69
|
return model.group === group.slug;
|
|
59
70
|
}).length;
|
|
60
71
|
},
|
|
61
|
-
plugin: async (group, _, context)=>
|
|
72
|
+
plugin: async (group, _, context)=>{
|
|
73
|
+
const pluginGroups = await context.container.resolve(PluginGroupsProvider).getGroups();
|
|
74
|
+
return pluginGroups.some((pg)=>pg.id === group.id);
|
|
75
|
+
}
|
|
62
76
|
},
|
|
63
77
|
Query: {
|
|
64
78
|
getContentModelGroup: async (_, args, context)=>{
|
|
65
79
|
try {
|
|
66
80
|
const { id } = args;
|
|
67
|
-
const
|
|
81
|
+
const result = await context.container.resolve(GetGroupUseCase).execute(id);
|
|
82
|
+
if (result.isFail()) throw result.error;
|
|
83
|
+
const group = result.value;
|
|
68
84
|
if (group?.isPrivate) throw new NotFoundError(`Cms Group "${id}" was not found!`);
|
|
69
85
|
return new Response(group);
|
|
70
86
|
} catch (e) {
|
|
@@ -73,8 +89,9 @@ const createGroupsSchema = ({ context })=>{
|
|
|
73
89
|
},
|
|
74
90
|
listContentModelGroups: async (_, __, context)=>{
|
|
75
91
|
try {
|
|
76
|
-
const
|
|
77
|
-
|
|
92
|
+
const result = await context.container.resolve(ListGroupsUseCase).execute();
|
|
93
|
+
if (result.isFail()) throw result.error;
|
|
94
|
+
return new Response(result.value.filter((group)=>true !== group.isPrivate));
|
|
78
95
|
} catch (e) {
|
|
79
96
|
return new ErrorResponse(e);
|
|
80
97
|
}
|
|
@@ -83,23 +100,26 @@ const createGroupsSchema = ({ context })=>{
|
|
|
83
100
|
Mutation: {
|
|
84
101
|
createContentModelGroup: async (_, args, context)=>{
|
|
85
102
|
try {
|
|
86
|
-
const
|
|
87
|
-
|
|
103
|
+
const result = await context.container.resolve(CreateGroupUseCase).execute(args.data);
|
|
104
|
+
if (result.isFail()) throw result.error;
|
|
105
|
+
return new Response(result.value);
|
|
88
106
|
} catch (e) {
|
|
89
107
|
return new ErrorResponse(e);
|
|
90
108
|
}
|
|
91
109
|
},
|
|
92
110
|
updateContentModelGroup: async (_, args, context)=>{
|
|
93
111
|
try {
|
|
94
|
-
const
|
|
95
|
-
|
|
112
|
+
const result = await context.container.resolve(UpdateGroupUseCase).execute(args.id, args.data);
|
|
113
|
+
if (result.isFail()) throw result.error;
|
|
114
|
+
return new Response(result.value);
|
|
96
115
|
} catch (e) {
|
|
97
116
|
return new ErrorResponse(e);
|
|
98
117
|
}
|
|
99
118
|
},
|
|
100
119
|
deleteContentModelGroup: async (_, args, context)=>{
|
|
101
120
|
try {
|
|
102
|
-
await context.
|
|
121
|
+
const result = await context.container.resolve(DeleteGroupUseCase).execute(args.id);
|
|
122
|
+
if (result.isFail()) throw result.error;
|
|
103
123
|
return new Response(true);
|
|
104
124
|
} catch (e) {
|
|
105
125
|
return new ErrorResponse(e);
|
|
@@ -128,7 +148,8 @@ const createGroupsSchema = ({ context })=>{
|
|
|
128
148
|
`,
|
|
129
149
|
resolvers
|
|
130
150
|
});
|
|
131
|
-
|
|
151
|
+
const endpointType = context.container.resolve(HeadlessCmsEndpointConfig).type;
|
|
152
|
+
plugin.name = `headless-cms.graphql.schema.${endpointType}.content-model-groups`;
|
|
132
153
|
return plugin;
|
|
133
154
|
};
|
|
134
155
|
export { createGroupsSchema };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/schema/contentModelGroups.js","sources":["../../../src/graphql/schema/contentModelGroups.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/handler-graphql\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport type { Resolvers } from \"@webiny/handler-graphql/types.js\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\n\ninterface Params {\n context: CmsContext;\n}\nexport const createGroupsSchema = ({ context }: Params): ICmsGraphQLSchemaPlugin => {\n let manageSchema = \"\";\n if (context.cms.MANAGE) {\n manageSchema = /* GraphQL */ `\n input CmsContentModelGroupInput {\n id: ID\n name: String!\n slug: String\n description: String\n icon: Icon!\n }\n\n type CmsContentModelGroupResponse {\n data: CmsContentModelGroup\n error: CmsError\n }\n\n type CmsContentModelGroupListResponse {\n data: [CmsContentModelGroup]\n meta: CmsListMeta\n error: CmsError\n }\n\n extend type Query {\n getContentModelGroup(id: ID): CmsContentModelGroupResponse\n listContentModelGroups: CmsContentModelGroupListResponse\n }\n\n extend type Mutation {\n createContentModelGroup(\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n updateContentModelGroup(\n id: ID!\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n deleteContentModelGroup(id: ID!): CmsDeleteResponse\n }\n `;\n }\n\n let resolvers: Resolvers<CmsContext> = {};\n\n if (context.cms.MANAGE) {\n resolvers = {\n CmsContentModelGroup: {\n contentModels: async (group, _, context) => {\n const models = await context.security.withoutAuthorization(async () => {\n return context.cms.listModels();\n });\n return models.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.slug;\n });\n },\n totalContentModels: async (group, _, context) => {\n const models = await context.security.withoutAuthorization(async () => {\n return context.cms.listModels();\n });\n return models.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.slug;\n }).length;\n },\n plugin: async (group, _, context: CmsContext): Promise<boolean> => {\n return context.plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .some(item => item.contentModelGroup.id === group.id);\n }\n },\n Query: {\n getContentModelGroup: async (_, args: any, context) => {\n try {\n const { id } = args;\n const group = await context.cms.getGroup(id);\n if (group?.isPrivate) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listContentModelGroups: async (_, __, context) => {\n try {\n const groups = await context.cms.listGroups();\n return new Response(groups.filter(group => group.isPrivate !== true));\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n Mutation: {\n createContentModelGroup: async (_, args: any, context) => {\n try {\n const model = await context.cms.createGroup(args.data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n updateContentModelGroup: async (_, args: any, context) => {\n try {\n const group = await context.cms.updateGroup(args.id, args.data);\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n deleteContentModelGroup: async (_, args: any, context) => {\n try {\n await context.cms.deleteGroup(args.id);\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n }\n };\n }\n\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsContentModelGroup {\n id: ID!\n createdOn: DateTime\n savedOn: DateTime\n name: String!\n contentModels: [CmsContentModel!]\n totalContentModels: Int!\n slug: String!\n description: String\n icon: Icon\n createdBy: CmsIdentity\n\n # Returns true if the content model group is registered via a plugin.\n plugin: Boolean!\n }\n ${manageSchema}\n `,\n resolvers\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-model-groups`;\n\n return plugin;\n};\n"],"names":["createGroupsSchema","context","manageSchema","resolvers","group","_","models","model","CmsGroupPlugin","item","args","id","NotFoundError","Response","e","ErrorResponse","__","groups","plugin","createCmsGraphQLSchemaPlugin"],"mappings":";;;AAUO,MAAMA,qBAAqB,CAAC,EAAEC,OAAO,EAAU;IAClD,IAAIC,eAAe;IACnB,IAAID,QAAQ,GAAG,CAAC,MAAM,EAClBC,eAA6B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAqC9B,CAAC;IAGL,IAAIC,YAAmC,CAAC;IAExC,IAAIF,QAAQ,GAAG,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,OAAO,IAAIY,SAASI,OAAO,MAAM,CAACb,CAAAA,QAASA,AAAoB,SAApBA,MAAM,SAAS;gBAC9D,EAAE,OAAOU,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;QACJ;QACA,UAAU;YACN,yBAAyB,OAAOT,GAAGK,MAAWT;gBAC1C,IAAI;oBACA,MAAMM,QAAQ,MAAMN,QAAQ,GAAG,CAAC,WAAW,CAACS,KAAK,IAAI;oBACrD,OAAO,IAAIG,SAASN;gBACxB,EAAE,OAAOO,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;YACA,yBAAyB,OAAOT,GAAGK,MAAWT;gBAC1C,IAAI;oBACA,MAAMG,QAAQ,MAAMH,QAAQ,GAAG,CAAC,WAAW,CAACS,KAAK,EAAE,EAAEA,KAAK,IAAI;oBAC9D,OAAO,IAAIG,SAAST;gBACxB,EAAE,OAAOU,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;YACA,yBAAyB,OAAOT,GAAGK,MAAWT;gBAC1C,IAAI;oBACA,MAAMA,QAAQ,GAAG,CAAC,WAAW,CAACS,KAAK,EAAE;oBACrC,OAAO,IAAIG,SAAS;gBACxB,EAAE,OAAOC,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;QACJ;IACJ;IAGJ,MAAMI,SAASC,6BAA6B;QACxC,UAAwB,CAAC;;;;;;;;;;;;;;;;YAgBrB,EAAEjB,aAAa;QACnB,CAAC;QACDC;IACJ;IAEAe,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAEjB,QAAQ,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC;IAEpF,OAAOiB;AACX"}
|
|
1
|
+
{"version":3,"file":"graphql/schema/contentModelGroups.js","sources":["../../../src/graphql/schema/contentModelGroups.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/api-graphql\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport type { Resolvers } from \"@webiny/api-graphql/types.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { GetGroupUseCase } from \"~/features/contentModelGroup/GetGroup/index.js\";\nimport { ListGroupsUseCase } from \"~/features/contentModelGroup/ListGroups/index.js\";\nimport { CreateGroupUseCase } from \"~/features/contentModelGroup/CreateGroup/index.js\";\nimport { UpdateGroupUseCase } from \"~/features/contentModelGroup/UpdateGroup/index.js\";\nimport { DeleteGroupUseCase } from \"~/features/contentModelGroup/DeleteGroup/index.js\";\nimport { PluginGroupsProvider } from \"~/features/contentModelGroup/shared/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\nimport { HeadlessCmsEndpointConfig } from \"~/HeadlessCmsEndpointConfig.js\";\n\ninterface Params {\n context: CmsContext;\n}\nexport const createGroupsSchema = ({ context }: Params): ICmsGraphQLSchemaPlugin => {\n const isManage = context.container.resolve(HeadlessCmsEndpointConfig).type === \"manage\";\n\n let manageSchema = \"\";\n if (isManage) {\n manageSchema = /* GraphQL */ `\n input CmsContentModelGroupInput {\n id: ID\n name: String!\n slug: String\n description: String\n icon: Icon!\n }\n\n type CmsContentModelGroupResponse {\n data: CmsContentModelGroup\n error: CmsError\n }\n\n type CmsContentModelGroupListResponse {\n data: [CmsContentModelGroup]\n meta: CmsListMeta\n error: CmsError\n }\n\n extend type Query {\n getContentModelGroup(id: ID): CmsContentModelGroupResponse\n listContentModelGroups: CmsContentModelGroupListResponse\n }\n\n extend type Mutation {\n createContentModelGroup(\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n updateContentModelGroup(\n id: ID!\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n deleteContentModelGroup(id: ID!): CmsDeleteResponse\n }\n `;\n }\n\n let resolvers: Resolvers<CmsContext> = {};\n\n if (isManage) {\n resolvers = {\n CmsContentModelGroup: {\n contentModels: async (group, _, context) => {\n const result = await context.container\n .resolve(IdentityContext)\n .withoutAuthorization(async () => {\n return context.container.resolve(ListModelsUseCase).execute();\n });\n if (result.isFail()) {\n return [];\n }\n return result.value.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.slug;\n });\n },\n totalContentModels: async (group, _, context) => {\n const result = await context.container\n .resolve(IdentityContext)\n .withoutAuthorization(async () => {\n return context.container.resolve(ListModelsUseCase).execute();\n });\n if (result.isFail()) {\n return 0;\n }\n return result.value.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.slug;\n }).length;\n },\n plugin: async (group, _, context) => {\n const pluginGroups = await context.container\n .resolve(PluginGroupsProvider)\n .getGroups();\n return pluginGroups.some(pg => pg.id === group.id);\n }\n },\n Query: {\n getContentModelGroup: async (_, args: any, context) => {\n try {\n const { id } = args;\n const result = await context.container.resolve(GetGroupUseCase).execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n const group = result.value;\n if (group?.isPrivate) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listContentModelGroups: async (_, __, context) => {\n try {\n const result = await context.container.resolve(ListGroupsUseCase).execute();\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(result.value.filter(group => group.isPrivate !== true));\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n Mutation: {\n createContentModelGroup: async (_, args: any, context) => {\n try {\n const result = await context.container\n .resolve(CreateGroupUseCase)\n .execute(args.data);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(result.value);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n updateContentModelGroup: async (_, args: any, context) => {\n try {\n const result = await context.container\n .resolve(UpdateGroupUseCase)\n .execute(args.id, args.data);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(result.value);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n deleteContentModelGroup: async (_, args: any, context) => {\n try {\n const result = await context.container\n .resolve(DeleteGroupUseCase)\n .execute(args.id);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n }\n };\n }\n\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsContentModelGroup {\n id: ID!\n createdOn: DateTime\n savedOn: DateTime\n name: String!\n contentModels: [CmsContentModel!]\n totalContentModels: Int!\n slug: String!\n description: String\n icon: Icon\n createdBy: CmsIdentity\n\n # Returns true if the content model group is registered via a plugin.\n plugin: Boolean!\n }\n ${manageSchema}\n `,\n resolvers\n });\n\n const endpointType = context.container.resolve(HeadlessCmsEndpointConfig).type;\n plugin.name = `headless-cms.graphql.schema.${endpointType}.content-model-groups`;\n\n return plugin;\n};\n"],"names":["createGroupsSchema","context","isManage","HeadlessCmsEndpointConfig","manageSchema","resolvers","group","_","result","IdentityContext","ListModelsUseCase","model","pluginGroups","PluginGroupsProvider","pg","args","id","GetGroupUseCase","NotFoundError","Response","e","ErrorResponse","__","ListGroupsUseCase","CreateGroupUseCase","UpdateGroupUseCase","DeleteGroupUseCase","plugin","createCmsGraphQLSchemaPlugin","endpointType"],"mappings":";;;;;;;;;;;AAkBO,MAAMA,qBAAqB,CAAC,EAAEC,OAAO,EAAU;IAClD,MAAMC,WAAWD,AAA8D,aAA9DA,QAAQ,SAAS,CAAC,OAAO,CAACE,2BAA2B,IAAI;IAE1E,IAAIC,eAAe;IACnB,IAAIF,UACAE,eAA6B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAqC9B,CAAC;IAGL,IAAIC,YAAmC,CAAC;IAExC,IAAIH,UACAG,YAAY;QACR,sBAAsB;YAClB,eAAe,OAAOC,OAAOC,GAAGN;gBAC5B,MAAMO,SAAS,MAAMP,QAAQ,SAAS,CACjC,OAAO,CAACQ,iBACR,oBAAoB,CAAC,UACXR,QAAQ,SAA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C,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;QACJ;IACJ;IAGJ,MAAMO,SAASC,6BAA6B;QACxC,UAAwB,CAAC;;;;;;;;;;;;;;;;YAgBrB,EAAExB,aAAa;QACnB,CAAC;QACDC;IACJ;IAEA,MAAMwB,eAAe5B,QAAQ,SAAS,CAAC,OAAO,CAACE,2BAA2B,IAAI;IAC9EwB,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAEE,aAAa,qBAAqB,CAAC;IAEhF,OAAOF;AACX"}
|
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import { ErrorResponse, NotFoundError, Response } from "@webiny/
|
|
1
|
+
import { ErrorResponse, NotFoundError, Response } from "@webiny/api-graphql";
|
|
2
2
|
import { createCmsGraphQLSchemaPlugin } from "../../plugins/index.js";
|
|
3
|
+
import { GetModelUseCase } from "../../features/contentModel/GetModel/index.js";
|
|
4
|
+
import { ListModelsUseCase } from "../../features/contentModel/ListModels/index.js";
|
|
5
|
+
import { CreateModelUseCase } from "../../features/contentModel/CreateModel/index.js";
|
|
6
|
+
import { CreateModelFromUseCase } from "../../features/contentModel/CreateModelFrom/index.js";
|
|
7
|
+
import { UpdateModelUseCase } from "../../features/contentModel/UpdateModel/index.js";
|
|
8
|
+
import { DeleteModelUseCase } from "../../features/contentModel/DeleteModel/index.js";
|
|
9
|
+
import { HeadlessCmsEndpointConfig } from "../../HeadlessCmsEndpointConfig.js";
|
|
10
|
+
import { ValuesSelectionGenerator } from "../../features/contentModel/ValuesSelectionGenerator/abstractions.js";
|
|
3
11
|
const createModelsSchema = ({ context })=>{
|
|
12
|
+
const isManage = "manage" === context.container.resolve(HeadlessCmsEndpointConfig).type;
|
|
4
13
|
const resolvers = {
|
|
5
14
|
Query: {
|
|
6
15
|
getContentModel: async (_, args, context)=>{
|
|
7
16
|
try {
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
|
|
17
|
+
const result = await context.container.resolve(GetModelUseCase).execute(args.modelId);
|
|
18
|
+
if (result.isFail()) throw result.error;
|
|
19
|
+
if (!result.value) throw new NotFoundError(`Content model "${args.modelId}" was not found!`);
|
|
20
|
+
return new Response(result.value);
|
|
11
21
|
} catch (e) {
|
|
12
22
|
return new ErrorResponse(e);
|
|
13
23
|
}
|
|
14
24
|
},
|
|
15
25
|
listContentModels: async (_, args, context)=>{
|
|
16
26
|
try {
|
|
17
|
-
const
|
|
27
|
+
const result = await context.container.resolve(ListModelsUseCase).execute({
|
|
18
28
|
includePrivate: false,
|
|
19
29
|
includePlugins: args?.includePlugins !== false
|
|
20
30
|
});
|
|
21
|
-
|
|
31
|
+
if (result.isFail()) throw result.error;
|
|
32
|
+
return new Response(result.value);
|
|
22
33
|
} catch (e) {
|
|
23
34
|
return new ErrorResponse(e);
|
|
24
35
|
}
|
|
@@ -44,24 +55,30 @@ const createModelsSchema = ({ context })=>{
|
|
|
44
55
|
...model.tags || []
|
|
45
56
|
];
|
|
46
57
|
},
|
|
47
|
-
plugin: (model)=>model.isPlugin ?? false
|
|
58
|
+
plugin: (model)=>model.isPlugin ?? false,
|
|
59
|
+
valuesSelection: (model, _, ctx)=>{
|
|
60
|
+
const generator = ctx.container.resolve(ValuesSelectionGenerator);
|
|
61
|
+
return generator.generate(model);
|
|
62
|
+
}
|
|
48
63
|
}
|
|
49
64
|
};
|
|
50
65
|
let manageSchema = "";
|
|
51
|
-
if (
|
|
66
|
+
if (isManage) {
|
|
52
67
|
resolvers["Mutation"] = {
|
|
53
68
|
createContentModel: async (_, args, context)=>{
|
|
54
69
|
try {
|
|
55
|
-
const
|
|
56
|
-
|
|
70
|
+
const result = await context.container.resolve(CreateModelUseCase).execute(args.data);
|
|
71
|
+
if (result.isFail()) throw result.error;
|
|
72
|
+
return new Response(result.value);
|
|
57
73
|
} catch (e) {
|
|
58
74
|
return new ErrorResponse(e);
|
|
59
75
|
}
|
|
60
76
|
},
|
|
61
77
|
createContentModelFrom: async (_, args, context)=>{
|
|
62
78
|
try {
|
|
63
|
-
const
|
|
64
|
-
|
|
79
|
+
const result = await context.container.resolve(CreateModelFromUseCase).execute(args.modelId, args.data);
|
|
80
|
+
if (result.isFail()) throw result.error;
|
|
81
|
+
return new Response(result.value);
|
|
65
82
|
} catch (e) {
|
|
66
83
|
return new ErrorResponse(e);
|
|
67
84
|
}
|
|
@@ -69,8 +86,9 @@ const createModelsSchema = ({ context })=>{
|
|
|
69
86
|
updateContentModel: async (_, args, context)=>{
|
|
70
87
|
const { modelId, data } = args;
|
|
71
88
|
try {
|
|
72
|
-
const
|
|
73
|
-
|
|
89
|
+
const result = await context.container.resolve(UpdateModelUseCase).execute(modelId, data);
|
|
90
|
+
if (result.isFail()) throw result.error;
|
|
91
|
+
return new Response(result.value);
|
|
74
92
|
} catch (e) {
|
|
75
93
|
return new ErrorResponse(e);
|
|
76
94
|
}
|
|
@@ -78,7 +96,8 @@ const createModelsSchema = ({ context })=>{
|
|
|
78
96
|
deleteContentModel: async (_, args, context)=>{
|
|
79
97
|
const { modelId } = args;
|
|
80
98
|
try {
|
|
81
|
-
await context.
|
|
99
|
+
const result = await context.container.resolve(DeleteModelUseCase).execute(modelId);
|
|
100
|
+
if (result.isFail()) throw result.error;
|
|
82
101
|
return new Response(true);
|
|
83
102
|
} catch (e) {
|
|
84
103
|
return new ErrorResponse(e);
|
|
@@ -271,6 +290,7 @@ const createModelsSchema = ({ context })=>{
|
|
|
271
290
|
tenant: String!
|
|
272
291
|
# Returns true if the content model is registered via a plugin.
|
|
273
292
|
plugin: Boolean!
|
|
293
|
+
valuesSelection: String
|
|
274
294
|
}
|
|
275
295
|
|
|
276
296
|
type CmsContentModelResponse {
|
|
@@ -294,7 +314,8 @@ const createModelsSchema = ({ context })=>{
|
|
|
294
314
|
`,
|
|
295
315
|
resolvers
|
|
296
316
|
});
|
|
297
|
-
|
|
317
|
+
const endpointType = context.container.resolve(HeadlessCmsEndpointConfig).type;
|
|
318
|
+
plugin.name = `headless-cms.graphql.schema.${endpointType}.content-models`;
|
|
298
319
|
return plugin;
|
|
299
320
|
};
|
|
300
321
|
export { createModelsSchema };
|