@webiny/api-headless-cms 6.4.5 → 6.6.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HeadlessCmsContextualSchema.d.ts +16 -0
- package/HeadlessCmsContextualSchema.js +32 -0
- package/HeadlessCmsContextualSchema.js.map +1 -0
- package/HeadlessCmsEndpointConfig.d.ts +10 -0
- package/HeadlessCmsEndpointConfig.js +5 -0
- package/HeadlessCmsEndpointConfig.js.map +1 -0
- package/HeadlessCmsFeature.d.ts +10 -0
- package/HeadlessCmsFeature.js +192 -0
- package/HeadlessCmsFeature.js.map +1 -0
- package/createCmsRoute.d.ts +21 -0
- package/createCmsRoute.js +49 -0
- package/createCmsRoute.js.map +1 -0
- package/crud/contentEntry/entryDataValidation.d.ts +1 -1
- package/crud/contentEntry/entryDataValidation.js +2 -15
- package/crud/contentEntry/entryDataValidation.js.map +1 -1
- package/crud/contentEntry/references/validateEntries.d.ts +1 -1
- package/crud/contentEntry/references/validateEntries.js +17 -7
- package/crud/contentEntry/references/validateEntries.js.map +1 -1
- package/crud/contentEntry.crud.js +22 -20
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel.crud.js +8 -6
- package/crud/contentModel.crud.js.map +1 -1
- package/crud/contentModelGroup.crud.js +7 -5
- package/crud/contentModelGroup.crud.js.map +1 -1
- package/domain/contentModel/schemas.d.ts +6 -6
- package/domain/contentModel/schemas.js +1 -1
- package/domain/contentModel/schemas.js.map +1 -1
- package/domain/contentModel/validation/modelFields.js +21 -15
- package/domain/contentModel/validation/modelFields.js.map +1 -1
- package/export/abstractions.d.ts +9 -0
- package/export/abstractions.js +6 -0
- package/export/abstractions.js.map +1 -0
- package/export/crud/exporting.js +8 -2
- package/export/crud/exporting.js.map +1 -1
- package/export/crud/importing.js +13 -4
- package/export/crud/importing.js.map +1 -1
- package/export/crud/imports/importGroups.js +23 -23
- package/export/crud/imports/importGroups.js.map +1 -1
- package/export/crud/imports/importModels.js +25 -22
- package/export/crud/imports/importModels.js.map +1 -1
- package/export/graphql/index.d.ts +2 -3
- package/export/graphql/index.js +6 -10
- package/export/graphql/index.js.map +1 -1
- package/exports/api/cms/storage.d.ts +0 -1
- package/exports/api/cms/storage.js +0 -1
- package/features/contentEntry/CreateEntry/CreateEntryRepository.d.ts +6 -4
- package/features/contentEntry/CreateEntry/CreateEntryRepository.js +7 -8
- package/features/contentEntry/CreateEntry/CreateEntryRepository.js.map +1 -1
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.d.ts +3 -1
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js +2 -3
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.d.ts +6 -4
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js +7 -8
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.d.ts +3 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js +2 -3
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.d.ts +6 -4
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js +7 -8
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.d.ts +3 -1
- package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js +2 -3
- package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.d.ts +6 -4
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js +7 -8
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.d.ts +3 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js +2 -3
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.d.ts +3 -3
- package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js +5 -5
- package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js.map +1 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.d.ts +6 -4
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js +7 -8
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.d.ts +3 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js +2 -3
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js.map +1 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.d.ts +6 -4
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js +7 -8
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js.map +1 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js +2 -3
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js.map +1 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.d.ts +6 -4
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js +7 -8
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.d.ts +3 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js +2 -3
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetEntry/GetEntryUseCase.d.ts +3 -1
- package/features/contentEntry/GetEntry/GetEntryUseCase.js +2 -3
- package/features/contentEntry/GetEntry/GetEntryUseCase.js.map +1 -1
- package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.js +2 -3
- package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.d.ts +6 -4
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js +7 -8
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js +2 -3
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js +2 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.d.ts +6 -4
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js +7 -8
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.js +1 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.d.ts +3 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js +2 -3
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.d.ts +6 -4
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js +7 -8
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.d.ts +6 -4
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js +7 -8
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.d.ts +3 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js +2 -3
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.d.ts +6 -4
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js +7 -8
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.d.ts +6 -4
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js +7 -8
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js.map +1 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js +1 -3
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js.map +1 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.d.ts +6 -4
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js +7 -8
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetSingletonEntry/GetSingletonEntryUseCase.js +1 -3
- package/features/contentEntry/GetSingletonEntry/GetSingletonEntryUseCase.js.map +1 -1
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.d.ts +6 -4
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js +7 -8
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js.map +1 -1
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.d.ts +6 -2
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js +8 -6
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.js +1 -3
- package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListEntriesRepository.d.ts +6 -4
- package/features/contentEntry/ListEntries/ListEntriesRepository.js +7 -8
- package/features/contentEntry/ListEntries/ListEntriesRepository.js.map +1 -1
- package/features/contentEntry/ListEntries/ListEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/ListEntries/ListEntriesUseCase.js +2 -3
- package/features/contentEntry/ListEntries/ListEntriesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.js +1 -3
- package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.js +1 -3
- package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.js.map +1 -1
- package/features/contentEntry/MoveEntry/MoveEntryRepository.d.ts +6 -4
- package/features/contentEntry/MoveEntry/MoveEntryRepository.js +7 -8
- package/features/contentEntry/MoveEntry/MoveEntryRepository.js.map +1 -1
- package/features/contentEntry/MoveEntry/MoveEntryUseCase.d.ts +3 -1
- package/features/contentEntry/MoveEntry/MoveEntryUseCase.js +2 -3
- package/features/contentEntry/MoveEntry/MoveEntryUseCase.js.map +1 -1
- package/features/contentEntry/PublishEntry/PublishEntryRepository.d.ts +6 -4
- package/features/contentEntry/PublishEntry/PublishEntryRepository.js +7 -8
- package/features/contentEntry/PublishEntry/PublishEntryRepository.js.map +1 -1
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.d.ts +3 -1
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.js +2 -3
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.d.ts +8 -4
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js +11 -9
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js.map +1 -1
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.d.ts +3 -1
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js +2 -3
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.d.ts +6 -4
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js +7 -8
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js.map +1 -1
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.d.ts +3 -1
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js +2 -3
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js.map +1 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.d.ts +6 -4
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js +7 -8
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js.map +1 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.d.ts +3 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js +2 -3
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.d.ts +6 -4
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js +7 -8
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js.map +1 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.d.ts +3 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js +2 -3
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js.map +1 -1
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.d.ts +3 -1
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js +2 -3
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js.map +1 -1
- package/features/contentEntry/ValidateEntry/ValidateEntryUseCase.d.ts +3 -1
- package/features/contentEntry/ValidateEntry/ValidateEntryUseCase.js +2 -3
- package/features/contentEntry/ValidateEntry/ValidateEntryUseCase.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js +2 -4
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.d.ts +4 -4
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js +4 -8
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js +1 -3
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js +1 -3
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js +1 -3
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js +2 -4
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js.map +1 -1
- package/features/contentModel/ContentModelFeature.js +2 -0
- package/features/contentModel/ContentModelFeature.js.map +1 -1
- package/features/contentModel/CreateModel/CreateModelRepository.d.ts +4 -3
- package/features/contentModel/CreateModel/CreateModelRepository.js +6 -5
- package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.d.ts +4 -3
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +6 -5
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
- package/features/contentModel/DeleteModel/DeleteModelRepository.d.ts +3 -3
- package/features/contentModel/DeleteModel/DeleteModelRepository.js +5 -5
- package/features/contentModel/DeleteModel/DeleteModelRepository.js.map +1 -1
- package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.d.ts +1 -0
- package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js +11 -8
- package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js.map +1 -1
- package/features/contentModel/UpdateModel/UpdateModelRepository.d.ts +6 -3
- package/features/contentModel/UpdateModel/UpdateModelRepository.js +11 -7
- package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.d.ts +16 -0
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js +51 -0
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js.map +1 -0
- package/features/contentModel/ValuesSelectionGenerator/abstractions.d.ts +8 -0
- package/features/contentModel/ValuesSelectionGenerator/abstractions.js +5 -0
- package/features/contentModel/ValuesSelectionGenerator/abstractions.js.map +1 -0
- package/features/contentModel/ValuesSelectionGenerator/feature.d.ts +4 -0
- package/features/contentModel/ValuesSelectionGenerator/feature.js +11 -0
- package/features/contentModel/ValuesSelectionGenerator/feature.js.map +1 -0
- package/features/contentModel/ValuesSelectionGenerator/index.d.ts +1 -0
- package/features/contentModel/ValuesSelectionGenerator/index.js +1 -0
- package/features/contentModel/shared/ModelsFetcher.d.ts +3 -3
- package/features/contentModel/shared/ModelsFetcher.js +5 -5
- package/features/contentModel/shared/ModelsFetcher.js.map +1 -1
- package/features/contentModel/shared/PluginModelsProvider.d.ts +5 -4
- package/features/contentModel/shared/PluginModelsProvider.js +11 -8
- package/features/contentModel/shared/PluginModelsProvider.js.map +1 -1
- package/features/contentModel/shared/abstractions.d.ts +10 -0
- package/features/contentModel/shared/abstractions.js +2 -1
- package/features/contentModel/shared/abstractions.js.map +1 -1
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.d.ts +8 -4
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js +13 -11
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js.map +1 -1
- package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.d.ts +3 -1
- package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.js +2 -3
- package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.d.ts +8 -4
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js +11 -9
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js.map +1 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.d.ts +3 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js +2 -3
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/GetGroup/GetGroupRepository.d.ts +6 -4
- package/features/contentModelGroup/GetGroup/GetGroupRepository.js +9 -9
- package/features/contentModelGroup/GetGroup/GetGroupRepository.js.map +1 -1
- package/features/contentModelGroup/GetGroup/GetGroupUseCase.d.ts +3 -1
- package/features/contentModelGroup/GetGroup/GetGroupUseCase.js +2 -3
- package/features/contentModelGroup/GetGroup/GetGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/ListGroups/ListGroupsRepository.d.ts +6 -4
- package/features/contentModelGroup/ListGroups/ListGroupsRepository.js +9 -9
- package/features/contentModelGroup/ListGroups/ListGroupsRepository.js.map +1 -1
- package/features/contentModelGroup/ListGroups/ListGroupsUseCase.d.ts +3 -1
- package/features/contentModelGroup/ListGroups/ListGroupsUseCase.js +2 -3
- package/features/contentModelGroup/ListGroups/ListGroupsUseCase.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.d.ts +6 -4
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js +7 -8
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.d.ts +3 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js +2 -3
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/shared/PluginGroupsProvider.d.ts +6 -4
- package/features/contentModelGroup/shared/PluginGroupsProvider.js +13 -11
- package/features/contentModelGroup/shared/PluginGroupsProvider.js.map +1 -1
- package/features/contentModelGroup/shared/abstractions.d.ts +10 -0
- package/features/contentModelGroup/shared/abstractions.js +2 -1
- package/features/contentModelGroup/shared/abstractions.js.map +1 -1
- package/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.d.ts +2 -2
- package/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/DynamicZoneToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/RefToGraphQL.d.ts +1 -1
- package/features/graphql/fields/base/RefToGraphQL.js +3 -1
- package/features/graphql/fields/base/RefToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/richText/richTextResolver.d.ts +1 -1
- package/features/graphql/fields/base/richText/richTextResolver.js.map +1 -1
- package/features/modelBuilder/fields/BaseFieldBuilder.d.ts +1 -3
- package/features/modelBuilder/fields/BaseFieldBuilder.js +0 -4
- package/features/modelBuilder/fields/BaseFieldBuilder.js.map +1 -1
- package/features/modelBuilder/fields/DataFieldBuilder.d.ts +12 -18
- package/features/modelBuilder/fields/DataFieldBuilder.js +1 -2
- package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -1
- package/features/modelBuilder/fields/DynamicZoneFieldType.js +3 -8
- package/features/modelBuilder/fields/DynamicZoneFieldType.js.map +1 -1
- package/features/modelBuilder/fields/TextFieldType.d.ts +3 -1
- package/features/modelBuilder/fields/TextFieldType.js +1 -3
- package/features/modelBuilder/fields/TextFieldType.js.map +1 -1
- package/features/modelBuilder/fields/UiAlertFieldType.js +1 -2
- package/features/modelBuilder/fields/UiAlertFieldType.js.map +1 -1
- package/features/modelBuilder/fields/UiSeparatorFieldType.js +1 -2
- package/features/modelBuilder/fields/UiSeparatorFieldType.js.map +1 -1
- package/features/modelBuilder/fields/UiTabsFieldType.d.ts +1 -2
- package/features/modelBuilder/fields/UiTabsFieldType.js +3 -6
- package/features/modelBuilder/fields/UiTabsFieldType.js.map +1 -1
- package/features/shared/abstractions.d.ts +11 -15
- package/features/shared/abstractions.js +3 -3
- package/features/shared/abstractions.js.map +1 -1
- package/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/CreateEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/CreateEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/CreateEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/DeleteEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/DeleteEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/DeleteEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetRevisionsStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/ListEntriesStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/ListEntriesStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/ListEntriesStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/MoveEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/MoveEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/MoveEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/MoveToBinStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/MoveToBinStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/MoveToBinStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/PublishEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/PublishEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/PublishEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/entry/UpdateEntryStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js +5 -0
- package/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/group/CreateGroupStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/group/CreateGroupStorageOperation.js +5 -0
- package/features/shared/storageOperations/group/CreateGroupStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/group/DeleteGroupStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/group/DeleteGroupStorageOperation.js +5 -0
- package/features/shared/storageOperations/group/DeleteGroupStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/group/GetGroupStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/group/GetGroupStorageOperation.js +5 -0
- package/features/shared/storageOperations/group/GetGroupStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/group/ListGroupsStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/group/ListGroupsStorageOperation.js +5 -0
- package/features/shared/storageOperations/group/ListGroupsStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/group/UpdateGroupStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/group/UpdateGroupStorageOperation.js +5 -0
- package/features/shared/storageOperations/group/UpdateGroupStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/index.d.ts +32 -0
- package/features/shared/storageOperations/index.js +32 -0
- package/features/shared/storageOperations/model/CreateModelStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/model/CreateModelStorageOperation.js +5 -0
- package/features/shared/storageOperations/model/CreateModelStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/model/DeleteModelStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/model/DeleteModelStorageOperation.js +5 -0
- package/features/shared/storageOperations/model/DeleteModelStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/model/GetModelStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/model/GetModelStorageOperation.js +5 -0
- package/features/shared/storageOperations/model/GetModelStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/model/ListModelsStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/model/ListModelsStorageOperation.js +5 -0
- package/features/shared/storageOperations/model/ListModelsStorageOperation.js.map +1 -0
- package/features/shared/storageOperations/model/UpdateModelStorageOperation.d.ts +8 -0
- package/features/shared/storageOperations/model/UpdateModelStorageOperation.js +5 -0
- package/features/shared/storageOperations/model/UpdateModelStorageOperation.js.map +1 -0
- package/fieldConverters/abstractions.d.ts +14 -0
- package/fieldConverters/abstractions.js +13 -0
- package/fieldConverters/abstractions.js.map +1 -0
- package/fieldConverters/index.d.ts +1 -1
- package/graphql/CmsGraphQLSchemaFactory.d.ts +8 -0
- package/graphql/CmsGraphQLSchemaFactory.js +5 -0
- package/graphql/CmsGraphQLSchemaFactory.js.map +1 -0
- package/graphql/CmsSchemaExecutor.d.ts +10 -0
- package/graphql/CmsSchemaExecutor.js +5 -0
- package/graphql/CmsSchemaExecutor.js.map +1 -0
- package/graphql/buildSchemaPlugins.d.ts +2 -1
- package/graphql/buildSchemaPlugins.js +1 -3
- package/graphql/buildSchemaPlugins.js.map +1 -1
- package/graphql/checkEndpointAccess.js +5 -2
- package/graphql/checkEndpointAccess.js.map +1 -1
- package/graphql/createExecutableSchema.d.ts +1 -1
- package/graphql/createExecutableSchema.js +1 -1
- package/graphql/createExecutableSchema.js.map +1 -1
- package/graphql/generateSchema.d.ts +2 -1
- package/graphql/generateSchema.js +14 -5
- package/graphql/generateSchema.js.map +1 -1
- package/graphql/getSchema.js +7 -2
- package/graphql/getSchema.js.map +1 -1
- package/graphql/scalars/RevisionIdScalarPlugin.d.ts +1 -1
- package/graphql/scalars/RevisionIdScalarPlugin.js.map +1 -1
- package/graphql/schema/baseContentSchema.d.ts +1 -6
- package/graphql/schema/baseContentSchema.js +5 -8
- package/graphql/schema/baseContentSchema.js.map +1 -1
- package/graphql/schema/baseSchema.d.ts +2 -2
- package/graphql/schema/baseSchema.js +6 -41
- package/graphql/schema/baseSchema.js.map +1 -1
- package/graphql/schema/cms/CmsBaseErrorTypeFactory.d.ts +14 -0
- package/graphql/schema/cms/CmsBaseErrorTypeFactory.js +21 -0
- package/graphql/schema/cms/CmsBaseErrorTypeFactory.js.map +1 -0
- package/graphql/schema/cms/createEntryResolver.js +2 -2
- package/graphql/schema/cms/createEntryResolver.js.map +1 -1
- package/graphql/schema/cms/deleteEntryResolver.js +2 -2
- package/graphql/schema/cms/deleteEntryResolver.js.map +1 -1
- package/graphql/schema/cms/getEntryResolver.js +2 -2
- package/graphql/schema/cms/getEntryResolver.js.map +1 -1
- package/graphql/schema/cms/helpers/getModel.d.ts +0 -3
- package/graphql/schema/cms/helpers/getModel.js +5 -3
- package/graphql/schema/cms/helpers/getModel.js.map +1 -1
- package/graphql/schema/cms/helpers/transformWhereToNested.js +17 -39
- package/graphql/schema/cms/helpers/transformWhereToNested.js.map +1 -1
- package/graphql/schema/cms/listEntriesResolver.js +2 -2
- package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
- package/graphql/schema/cms/publishEntryResolver.js +2 -2
- package/graphql/schema/cms/publishEntryResolver.js.map +1 -1
- package/graphql/schema/cms/resolvers/createEntry.d.ts +2 -2
- package/graphql/schema/cms/resolvers/createEntry.js +1 -1
- package/graphql/schema/cms/resolvers/createEntry.js.map +1 -1
- package/graphql/schema/cms/resolvers/deleteEntryRevision.d.ts +2 -2
- package/graphql/schema/cms/resolvers/deleteEntryRevision.js +1 -1
- package/graphql/schema/cms/resolvers/deleteEntryRevision.js.map +1 -1
- package/graphql/schema/cms/resolvers/getEntry.d.ts +2 -2
- package/graphql/schema/cms/resolvers/getEntry.js +1 -1
- package/graphql/schema/cms/resolvers/getEntry.js.map +1 -1
- package/graphql/schema/cms/resolvers/listEntries.d.ts +2 -2
- package/graphql/schema/cms/resolvers/listEntries.js +1 -1
- package/graphql/schema/cms/resolvers/listEntries.js.map +1 -1
- package/graphql/schema/cms/resolvers/mutationCms.d.ts +2 -2
- package/graphql/schema/cms/resolvers/mutationCms.js +1 -1
- package/graphql/schema/cms/resolvers/mutationCms.js.map +1 -1
- package/graphql/schema/cms/resolvers/publishEntryRevision.d.ts +2 -2
- package/graphql/schema/cms/resolvers/publishEntryRevision.js +1 -1
- package/graphql/schema/cms/resolvers/publishEntryRevision.js.map +1 -1
- package/graphql/schema/cms/resolvers/queryCms.d.ts +2 -2
- package/graphql/schema/cms/resolvers/queryCms.js +1 -1
- package/graphql/schema/cms/resolvers/queryCms.js.map +1 -1
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.d.ts +2 -2
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.js +1 -1
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.js.map +1 -1
- package/graphql/schema/cms/resolvers/updateEntryRevision.d.ts +2 -2
- package/graphql/schema/cms/resolvers/updateEntryRevision.js +1 -1
- package/graphql/schema/cms/resolvers/updateEntryRevision.js.map +1 -1
- package/graphql/schema/cms/typeDefs/mutation.d.ts +2 -2
- package/graphql/schema/cms/typeDefs/mutation.js +1 -1
- package/graphql/schema/cms/typeDefs/mutation.js.map +1 -1
- package/graphql/schema/cms/typeDefs/query.d.ts +2 -2
- package/graphql/schema/cms/typeDefs/query.js +1 -1
- package/graphql/schema/cms/typeDefs/query.js.map +1 -1
- package/graphql/schema/cms/typeDefs/responses.d.ts +2 -2
- package/graphql/schema/cms/typeDefs/responses.js +1 -1
- package/graphql/schema/cms/typeDefs/responses.js.map +1 -1
- package/graphql/schema/cms/unpublishEntryResolver.js +2 -2
- package/graphql/schema/cms/unpublishEntryResolver.js.map +1 -1
- package/graphql/schema/cms/updateEntryResolver.js +2 -2
- package/graphql/schema/cms/updateEntryResolver.js.map +1 -1
- package/graphql/schema/contentEntries.js +43 -32
- package/graphql/schema/contentEntries.js.map +1 -1
- package/graphql/schema/contentModelGroups.js +39 -18
- package/graphql/schema/contentModelGroups.js.map +1 -1
- package/graphql/schema/contentModels.js +37 -16
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createFieldResolvers.d.ts +1 -1
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/graphql/schema/createManageResolvers.js +4 -2
- package/graphql/schema/createManageResolvers.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveCreate.js +5 -3
- package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js +5 -3
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveDelete.js +9 -4
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +5 -3
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGet.js +11 -6
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetByIds.js +5 -3
- package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js +5 -3
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +5 -3
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveList.js +5 -3
- package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveListDeleted.js +5 -3
- package/graphql/schema/resolvers/manage/resolveListDeleted.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveMove.js +4 -2
- package/graphql/schema/resolvers/manage/resolveMove.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolvePublish.js +5 -3
- package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveRepublish.js +5 -3
- package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveRestoreFromBin.js +5 -3
- package/graphql/schema/resolvers/manage/resolveRestoreFromBin.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveUnpublish.js +5 -3
- package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveUpdate.js +5 -3
- package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveUpdateRevisionDescription.js +5 -3
- package/graphql/schema/resolvers/manage/resolveUpdateRevisionDescription.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveValidate.js +5 -3
- package/graphql/schema/resolvers/manage/resolveValidate.js.map +1 -1
- package/graphql/schema/resolvers/preview/resolveGet.js +6 -3
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/preview/resolveList.js +5 -3
- package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
- package/graphql/schema/resolvers/read/resolveGet.js +5 -2
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/read/resolveList.js +5 -3
- package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
- package/graphql/schema/resolvers/singular/resolveGet.js +1 -1
- package/graphql/schema/resolvers/singular/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/singular/resolveUpdate.js +1 -1
- package/graphql/schema/resolvers/singular/resolveUpdate.js.map +1 -1
- package/graphql/schema/schemaPlugins.d.ts +2 -1
- package/graphql/schema/schemaPlugins.js +2 -4
- package/graphql/schema/schemaPlugins.js.map +1 -1
- package/index.d.ts +7 -6
- package/index.js +4 -22
- package/legacy/abstractions.js.map +1 -1
- package/package.json +22 -27
- package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.d.ts +2 -2
- package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js +1 -1
- package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js.map +1 -1
- package/plugins/index.d.ts +0 -1
- package/plugins/index.js +0 -1
- package/types/fields/dynamicZoneField.d.ts +2 -2
- package/types/modelField.d.ts +1 -1
- package/types/types.d.ts +10 -183
- package/types/types.js.map +1 -1
- package/utils/contentModelToJsonSchema/CmsModelToJsonSchemaConverter.d.ts +28 -0
- package/utils/contentModelToJsonSchema/CmsModelToJsonSchemaConverter.js +324 -0
- package/utils/contentModelToJsonSchema/CmsModelToJsonSchemaConverter.js.map +1 -0
- package/utils/contentModelToJsonSchema/index.d.ts +2 -0
- package/utils/contentModelToJsonSchema/index.js +1 -0
- package/utils/contentModelToJsonSchema/types.d.ts +24 -0
- package/utils/contentModelToJsonSchema/types.js +0 -0
- package/utils/converters/ConverterCollection.d.ts +2 -2
- package/utils/converters/ConverterCollection.js +1 -3
- package/utils/converters/ConverterCollection.js.map +1 -1
- package/utils/converters/valueKeyFromStorageConverter.d.ts +2 -2
- package/utils/converters/valueKeyFromStorageConverter.js +2 -2
- package/utils/converters/valueKeyFromStorageConverter.js.map +1 -1
- package/utils/converters/valueKeyStorageConverter.js +4 -2
- package/utils/converters/valueKeyStorageConverter.js.map +1 -1
- package/utils/converters/valueKeyToStorageConverter.d.ts +2 -2
- package/utils/converters/valueKeyToStorageConverter.js +2 -2
- package/utils/converters/valueKeyToStorageConverter.js.map +1 -1
- package/utils/getSchemaFromFieldPlugins.d.ts +2 -2
- package/utils/getSchemaFromFieldPlugins.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/isHeadlessCmsReady.d.ts +1 -1
- package/utils/isHeadlessCmsReady.js +3 -2
- package/utils/isHeadlessCmsReady.js.map +1 -1
- package/abstractions/entryHooks/OnEntryBeforeCreate.d.ts +0 -8
- package/abstractions/entryHooks/OnEntryBeforeCreate.js +0 -5
- package/abstractions/entryHooks/OnEntryBeforeCreate.js.map +0 -1
- package/abstractions/entryHooks/index.d.ts +0 -1
- package/abstractions/entryHooks/index.js +0 -1
- package/abstractions/index.d.ts +0 -1
- package/abstractions/index.js +0 -1
- package/context.d.ts +0 -3
- package/context.js +0 -131
- package/context.js.map +0 -1
- package/extensions/entryHooks/OnEntryBeforeCreate.d.ts +0 -4
- package/extensions/entryHooks/OnEntryBeforeCreate.js +0 -21
- package/extensions/entryHooks/OnEntryBeforeCreate.js.map +0 -1
- package/extensions/entryHooks/index.d.ts +0 -1
- package/extensions/entryHooks/index.js +0 -1
- package/extensions/index.d.ts +0 -5
- package/extensions/index.js +0 -7
- package/extensions/index.js.map +0 -1
- package/graphql/graphQLHandlerFactory.d.ts +0 -5
- package/graphql/graphQLHandlerFactory.js +0 -22
- package/graphql/graphQLHandlerFactory.js.map +0 -1
- package/graphql/handleRequest.d.ts +0 -11
- package/graphql/handleRequest.js +0 -62
- package/graphql/handleRequest.js.map +0 -1
- package/graphql/index.d.ts +0 -4
- package/graphql/index.js +0 -11
- package/graphql/index.js.map +0 -1
- package/graphql/schema/cms/index.d.ts +0 -2
- package/graphql/schema/cms/index.js +0 -24
- package/graphql/schema/cms/index.js.map +0 -1
- package/index.js.map +0 -1
- package/parameters/context.d.ts +0 -2
- package/parameters/context.js +0 -7
- package/parameters/context.js.map +0 -1
- package/parameters/header.d.ts +0 -2
- package/parameters/header.js +0 -13
- package/parameters/header.js.map +0 -1
- package/parameters/index.d.ts +0 -3
- package/parameters/index.js +0 -3
- package/parameters/path.d.ts +0 -2
- package/parameters/path.js +0 -12
- package/parameters/path.js.map +0 -1
- package/plugins/CmsParametersPlugin.d.ts +0 -18
- package/plugins/CmsParametersPlugin.js +0 -16
- package/plugins/CmsParametersPlugin.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain/contentModel/schemas.js","sources":["../../../src/domain/contentModel/schemas.ts"],"sourcesContent":["import zod from \"zod\";\nimport upperFirst from \"lodash/upperFirst.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst str = zod.string().trim();\nconst shortString = str.max(255);\nconst longString = str;\nconst optionalShortString = shortString.optional();\nconst optionalLongString = longString.optional();\nconst optionalNullishShortString = optionalShortString.nullish().default(null);\nconst optionalNullishLongString = optionalLongString.nullish().default(null);\n\nconst icon = zod\n .looseObject({\n type: zod.string(),\n name: zod.string(),\n value: zod.string().optional()\n })\n .optional()\n .nullish()\n .default(null)\n .transform(value => {\n if (typeof value === \"string\") {\n return {\n type: \"icon\",\n name: value\n };\n }\n return value;\n });\n\nconst fieldSchema = zod.object({\n id: shortString,\n storageId: zod\n .string()\n .optional()\n .transform(() => {\n return \"\";\n }),\n fieldId: shortString\n .max(100)\n .regex(/^!?[a-zA-Z]/, {\n message: `Must not start with a number.`\n })\n .regex(/^(^[a-zA-Z0-9]+)$/, {\n message: `Must be alphanumeric string.`\n }),\n label: shortString,\n help: optionalNullishLongString,\n description: optionalNullishShortString,\n note: optionalNullishShortString,\n placeholder: optionalNullishShortString,\n type: shortString,\n tags: zod.array(shortString).optional().default([]),\n list: zod\n .boolean()\n .optional()\n .nullish()\n .transform(value => {\n return !!value;\n })\n .default(false),\n predefinedValues: zod\n .object({\n enabled: zod.boolean(),\n values: zod\n .array(\n zod.object({\n value: shortString,\n label: shortString,\n selected: zod.boolean().optional().default(false)\n })\n )\n .default([])\n })\n .default({\n enabled: false,\n values: []\n })\n .nullish()\n .optional()\n .transform(value => {\n return value || undefined;\n }),\n renderer: zod\n .object({\n name: shortString,\n settings: zod.looseObject({}).nullish().optional()\n })\n .optional()\n .nullable()\n .default(null),\n validation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n listValidation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({}),\n rules: zod\n .array(\n zod.object({\n type: zod.enum([\"accessControl\", \"condition\"]),\n target: shortString,\n operator: shortString,\n value: zod.union([zod.string(), zod.number(), zod.boolean(), zod.null()]),\n action: shortString\n })\n )\n .optional()\n .nullish()\n .default([])\n .transform(value => value || [])\n});\n\nconst apiNameRefinementValidation = (value: string): boolean => {\n if (value.match(/^[A-Z]/) === null) {\n return false;\n }\n return value === upperFirst(camelCase(value));\n};\nconst refinementSingularValidationMessage = (value?: string) => {\n return {\n message: `The Singular API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategory\" or \"CarMake\".`\n };\n};\nconst refinementPluralValidationMessage = (value?: string) => {\n return {\n message: `The Plural API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategories\" or \"CarMakes\".`\n };\n};\n\nconst refineSingularApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementSingularValidationMessage(value)\n });\n }\n};\n\nconst refinePluralApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementPluralValidationMessage(value)\n });\n }\n};\n\nconst modelIdTransformation = (value?: string) => {\n if (!value) {\n return value;\n }\n const camelCasedValue = camelCase(value);\n if (camelCasedValue.toLowerCase() === value.toLowerCase()) {\n return value;\n }\n return camelCasedValue;\n};\n\nexport const createModelCreateValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.min(1).superRefine(refineSingularApiName),\n pluralApiName: shortString.min(1).superRefine(refinePluralApiName),\n description: optionalNullishShortString.transform(value => {\n return value || \"\";\n }),\n group: shortString,\n icon,\n fields: zod.array(fieldSchema).default([]),\n layout: zod.array(zod.array(zod.any())).default([]),\n tags: zod.array(shortString).optional(),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n defaultFields: zod.boolean().nullish()\n });\n};\n\nexport const createModelUpdateValidation = () => {\n return zod.object({\n name: optionalShortString,\n singularApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refineSingularApiName(value, ctx);\n }\n }),\n pluralApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refinePluralApiName(value, ctx);\n }\n }),\n description: optionalNullishShortString,\n group: optionalShortString,\n icon,\n fields: zod.array(fieldSchema),\n layout: zod.array(zod.array(zod.any())),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n tags: zod.array(shortString).optional()\n });\n};\n\nexport const createModelCreateFromValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.superRefine(refineSingularApiName),\n pluralApiName: shortString.superRefine(refinePluralApiName),\n description: optionalNullishShortString,\n group: shortString,\n icon\n });\n};\n"],"names":["str","zod","shortString","longString","optionalShortString","optionalLongString","optionalNullishShortString","optionalNullishLongString","icon","value","fieldSchema","undefined","apiNameRefinementValidation","upperFirst","camelCase","refinementSingularValidationMessage","refinementPluralValidationMessage","refineSingularApiName","ctx","refinePluralApiName","modelIdTransformation","camelCasedValue","createModelCreateValidation","createModelUpdateValidation","createModelCreateFromValidation"],"mappings":";;;AAIA,MAAMA,MAAMC,IAAI,MAAM,GAAG,IAAI;AAC7B,MAAMC,cAAcF,IAAI,GAAG,CAAC;AAC5B,MAAMG,aAAaH;AACnB,MAAMI,sBAAsBF,YAAY,QAAQ;AAChD,MAAMG,qBAAqBF,WAAW,QAAQ;AAC9C,MAAMG,6BAA6BF,oBAAoB,OAAO,GAAG,OAAO,CAAC;AACzE,MAAMG,4BAA4BF,mBAAmB,OAAO,GAAG,OAAO,CAAC;AAEvE,MAAMG,OAAOP,IAAAA,WACG,CAAC;IACT,MAAMA,IAAI,MAAM;IAChB,MAAMA,IAAI,MAAM;IAChB,OAAOA,IAAI,MAAM,GAAG,QAAQ;AAChC,GACC,QAAQ,GACR,OAAO,GACP,OAAO,CAAC,MACR,SAAS,CAACQ,CAAAA;IACP,IAAI,AAAiB,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OAAOS;YACrD,IAAIT,OACAQ,sBAAsBR,OAAOS;QAErC;QACA,eAAed,oBAAoB,WAAW,CAAC,CAACK,OAAOS;YACnD,IAAIT,OACAU,oBAAoBV,OAAOS;QAEnC;QACA,aAAaZ;QACb,OAAOF;QACPI,MAAAA;QACA,QAAQP,IAAI,KAAK,CAACS;QAClB,QAAQT,IAAI,KAAK,CAACA,IAAI,KAAK,CAACA,IAAI,GAAG;QACnC,cAAcG,oBAAoB,OAAO;QACzC,oBAAoBA,oBAAoB,OAAO;QAC/C,cAAcA,oBAAoB,OAAO;QACzC,MAAMH,IAAI,KAAK,CAACC,aAAa,QAAQ;IACzC;AAGG,MAAMsB,kCAAkC,IACpCvB,IAAI,MAAM,CAAC;QACd,MAAMC;QACN,SAASE,oBAAoB,SAAS,CAACgB;QACvC,iBAAiBlB,YAAY,WAAW,CAACe;QACzC,eAAef,YAAY,WAAW,CAACiB;QACvC,aAAab;QACb,OAAOJ;QACPM,MAAAA;IACJ"}
|
|
1
|
+
{"version":3,"file":"domain/contentModel/schemas.js","sources":["../../../src/domain/contentModel/schemas.ts"],"sourcesContent":["import zod from \"zod\";\nimport upperFirst from \"lodash/upperFirst.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst str = zod.string().trim();\nconst shortString = str.max(255);\nconst longString = str;\nconst optionalShortString = shortString.optional();\nconst optionalLongString = longString.optional();\nconst optionalNullishShortString = optionalShortString.nullish().default(null);\nconst optionalNullishLongString = optionalLongString.nullish().default(null);\n\nconst icon = zod\n .looseObject({\n type: zod.string(),\n name: zod.string(),\n value: zod.string().optional()\n })\n .optional()\n .nullish()\n .default(null)\n .transform(value => {\n if (typeof value === \"string\") {\n return {\n type: \"icon\",\n name: value\n };\n }\n return value;\n });\n\nconst fieldSchema = zod.object({\n id: shortString,\n storageId: zod\n .string()\n .optional()\n .transform(() => {\n return \"\";\n }),\n fieldId: shortString\n .max(100)\n .regex(/^!?[a-zA-Z]/, {\n message: `Must not start with a number.`\n })\n .regex(/^(^[a-zA-Z0-9]+)$/, {\n message: `Must be alphanumeric string.`\n }),\n label: shortString,\n help: optionalNullishLongString,\n description: optionalNullishShortString,\n note: optionalNullishShortString,\n placeholder: optionalNullishShortString,\n type: shortString,\n tags: zod.array(shortString).optional().default([]),\n list: zod\n .boolean()\n .optional()\n .nullish()\n .transform(value => {\n return !!value;\n })\n .default(false),\n predefinedValues: zod\n .object({\n enabled: zod.boolean(),\n values: zod\n .array(\n zod.object({\n value: shortString,\n label: shortString,\n selected: zod.boolean().optional().default(false)\n })\n )\n .default([])\n })\n .default({\n enabled: false,\n values: []\n })\n .nullish()\n .optional()\n .transform(value => {\n return value || undefined;\n }),\n renderer: zod\n .object({\n name: shortString,\n settings: zod.looseObject({}).nullish().optional()\n })\n .optional()\n .nullable()\n .default(null),\n validation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n listValidation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({}),\n rules: zod\n .array(\n zod.object({\n type: zod.enum([\"accessControl\", \"entryValue\"]),\n target: shortString,\n operator: shortString,\n value: zod.union([zod.string(), zod.number(), zod.boolean(), zod.null()]),\n action: shortString\n })\n )\n .optional()\n .nullish()\n .default([])\n .transform(value => value || [])\n});\n\nconst apiNameRefinementValidation = (value: string): boolean => {\n if (value.match(/^[A-Z]/) === null) {\n return false;\n }\n return value === upperFirst(camelCase(value));\n};\nconst refinementSingularValidationMessage = (value?: string) => {\n return {\n message: `The Singular API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategory\" or \"CarMake\".`\n };\n};\nconst refinementPluralValidationMessage = (value?: string) => {\n return {\n message: `The Plural API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategories\" or \"CarMakes\".`\n };\n};\n\nconst refineSingularApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementSingularValidationMessage(value)\n });\n }\n};\n\nconst refinePluralApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementPluralValidationMessage(value)\n });\n }\n};\n\nconst modelIdTransformation = (value?: string) => {\n if (!value) {\n return value;\n }\n const camelCasedValue = camelCase(value);\n if (camelCasedValue.toLowerCase() === value.toLowerCase()) {\n return value;\n }\n return camelCasedValue;\n};\n\nexport const createModelCreateValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.min(1).superRefine(refineSingularApiName),\n pluralApiName: shortString.min(1).superRefine(refinePluralApiName),\n description: optionalNullishShortString.transform(value => {\n return value || \"\";\n }),\n group: shortString,\n icon,\n fields: zod.array(fieldSchema).default([]),\n layout: zod.array(zod.array(zod.any())).default([]),\n tags: zod.array(shortString).optional(),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n defaultFields: zod.boolean().nullish()\n });\n};\n\nexport const createModelUpdateValidation = () => {\n return zod.object({\n name: optionalShortString,\n singularApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refineSingularApiName(value, ctx);\n }\n }),\n pluralApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refinePluralApiName(value, ctx);\n }\n }),\n description: optionalNullishShortString,\n group: optionalShortString,\n icon,\n fields: zod.array(fieldSchema),\n layout: zod.array(zod.array(zod.any())),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n tags: zod.array(shortString).optional()\n });\n};\n\nexport const createModelCreateFromValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.superRefine(refineSingularApiName),\n pluralApiName: shortString.superRefine(refinePluralApiName),\n description: optionalNullishShortString,\n group: shortString,\n icon\n });\n};\n"],"names":["str","zod","shortString","longString","optionalShortString","optionalLongString","optionalNullishShortString","optionalNullishLongString","icon","value","fieldSchema","undefined","apiNameRefinementValidation","upperFirst","camelCase","refinementSingularValidationMessage","refinementPluralValidationMessage","refineSingularApiName","ctx","refinePluralApiName","modelIdTransformation","camelCasedValue","createModelCreateValidation","createModelUpdateValidation","createModelCreateFromValidation"],"mappings":";;;AAIA,MAAMA,MAAMC,IAAI,MAAM,GAAG,IAAI;AAC7B,MAAMC,cAAcF,IAAI,GAAG,CAAC;AAC5B,MAAMG,aAAaH;AACnB,MAAMI,sBAAsBF,YAAY,QAAQ;AAChD,MAAMG,qBAAqBF,WAAW,QAAQ;AAC9C,MAAMG,6BAA6BF,oBAAoB,OAAO,GAAG,OAAO,CAAC;AACzE,MAAMG,4BAA4BF,mBAAmB,OAAO,GAAG,OAAO,CAAC;AAEvE,MAAMG,OAAOP,IAAAA,WACG,CAAC;IACT,MAAMA,IAAI,MAAM;IAChB,MAAMA,IAAI,MAAM;IAChB,OAAOA,IAAI,MAAM,GAAG,QAAQ;AAChC,GACC,QAAQ,GACR,OAAO,GACP,OAAO,CAAC,MACR,SAAS,CAACQ,CAAAA;IACP,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAO;QACH,MAAM;QACN,MAAMA;IACV;IAEJ,OAAOA;AACX;AAEJ,MAAMC,cAAcT,IAAI,MAAM,CAAC;IAC3B,IAAIC;IACJ,WAAWD,IAAAA,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aZ;QACb,OAAOF;QACPI,MAAAA;QACA,QAAQP,IAAI,KAAK,CAACS;QAClB,QAAQT,IAAI,KAAK,CAACA,IAAI,KAAK,CAACA,IAAI,GAAG;QACnC,cAAcG,oBAAoB,OAAO;QACzC,oBAAoBA,oBAAoB,OAAO;QAC/C,cAAcA,oBAAoB,OAAO;QACzC,MAAMH,IAAI,KAAK,CAACC,aAAa,QAAQ;IACzC;AAGG,MAAMsB,kCAAkC,IACpCvB,IAAI,MAAM,CAAC;QACd,MAAMC;QACN,SAASE,oBAAoB,SAAS,CAACgB;QACvC,iBAAiBlB,YAAY,WAAW,CAACe;QACzC,eAAef,YAAY,WAAW,CAACiB;QACvC,aAAab;QACb,OAAOJ;QACPM,MAAAA;IACJ"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import graphql_tag from "graphql-tag";
|
|
2
|
-
import { generateAlphaNumericId } from "@webiny/utils";
|
|
3
2
|
import _webiny_error from "@webiny/error";
|
|
3
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
4
|
+
import { ListModelsUseCase } from "../../../features/contentModel/ListModels/index.js";
|
|
4
5
|
import { createManageSDL } from "../../../graphql/schema/createManageSDL.js";
|
|
5
6
|
import { createFieldStorageId } from "../createFieldStorageId.js";
|
|
6
7
|
import { getBaseFieldType } from "../../../utils/getBaseFieldType.js";
|
|
7
8
|
import { getContentModelTitleFieldId } from "./fields/titleField.js";
|
|
8
9
|
import { getContentModelDescriptionFieldId } from "./fields/descriptionField.js";
|
|
9
10
|
import { getContentModelImageFieldId } from "./fields/imageField.js";
|
|
10
|
-
import { CmsGraphQLSchemaPlugin } from "../../../plugins/index.js";
|
|
11
11
|
import { buildSchemaPlugins } from "../../../graphql/buildSchemaPlugins.js";
|
|
12
|
+
import { HeadlessCms } from "../../../features/shared/abstractions.js";
|
|
13
|
+
import { CmsGraphQLSchemaFactory } from "../../../graphql/CmsGraphQLSchemaFactory.js";
|
|
12
14
|
import { createExecutableSchema } from "../../../graphql/createExecutableSchema.js";
|
|
13
15
|
import { CmsGraphQLSchemaSorter, CmsModelFieldToGraphQLRegistry } from "../../../features/graphql/index.js";
|
|
14
16
|
const extractInvalidField = (model, err)=>{
|
|
@@ -87,24 +89,28 @@ const validateFields = (params)=>{
|
|
|
87
89
|
};
|
|
88
90
|
const createGraphQLSchema = async (params)=>{
|
|
89
91
|
const { context, model } = params;
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
+
const modelsResult = await context.container.resolve(IdentityContext).withoutAuthorization(async ()=>context.container.resolve(ListModelsUseCase).execute());
|
|
93
|
+
if (modelsResult.isFail()) throw modelsResult.error;
|
|
94
|
+
const models = modelsResult.value.filter((model)=>true !== model.isPrivate);
|
|
95
|
+
const generatedSchemaPlugins = await buildSchemaPlugins({
|
|
92
96
|
context,
|
|
93
97
|
models: models.filter((m)=>m.modelId !== model.modelId).concat([
|
|
94
98
|
model
|
|
95
|
-
])
|
|
99
|
+
]),
|
|
100
|
+
type: context.container.resolve(HeadlessCms).type
|
|
101
|
+
});
|
|
102
|
+
const staticFactories = context.container.resolveAll(CmsGraphQLSchemaFactory);
|
|
103
|
+
const staticPlugins = [];
|
|
104
|
+
for (const factory of staticFactories)staticPlugins.push(...await factory.execute());
|
|
105
|
+
const schemaPlugins = [
|
|
106
|
+
...staticPlugins,
|
|
107
|
+
...generatedSchemaPlugins
|
|
108
|
+
].filter((pl)=>{
|
|
109
|
+
if ("function" == typeof pl.isApplicable) return pl.isApplicable(context);
|
|
110
|
+
return true;
|
|
96
111
|
});
|
|
97
|
-
const plugins = context.plugins.byType(CmsGraphQLSchemaPlugin.type).filter((plugin)=>plugin.isApplicable(context)).reduce((collection, plugin)=>{
|
|
98
|
-
const name = plugin.name || `${CmsGraphQLSchemaPlugin.type}-${generateAlphaNumericId(16)}`;
|
|
99
|
-
collection[name] = plugin;
|
|
100
|
-
return collection;
|
|
101
|
-
}, {});
|
|
102
|
-
for (const plugin of modelPlugins){
|
|
103
|
-
const name = plugin.name || `${plugin.type}-${generateAlphaNumericId(16)}`;
|
|
104
|
-
plugins[name] = plugin;
|
|
105
|
-
}
|
|
106
112
|
return createExecutableSchema({
|
|
107
|
-
plugins:
|
|
113
|
+
plugins: schemaPlugins
|
|
108
114
|
});
|
|
109
115
|
};
|
|
110
116
|
const extractErrorObject = (error)=>[
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain/contentModel/validation/modelFields.js","sources":["../../../../src/domain/contentModel/validation/modelFields.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport { generateAlphaNumericId } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\nimport type { CmsContext, CmsModel, CmsModelField } from \"~/types/index.js\";\nimport type { ValidateChildFieldsValidate } from \"~/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.js\";\nimport { createManageSDL } from \"~/graphql/schema/createManageSDL.js\";\nimport { createFieldStorageId } from \"../createFieldStorageId.js\";\nimport type { GraphQLError } from \"graphql\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType.js\";\nimport { getContentModelTitleFieldId } from \"./fields/titleField.js\";\nimport { getContentModelDescriptionFieldId } from \"./fields/descriptionField.js\";\nimport { getContentModelImageFieldId } from \"./fields/imageField.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { buildSchemaPlugins } from \"~/graphql/buildSchemaPlugins.js\";\nimport { createExecutableSchema } from \"~/graphql/createExecutableSchema.js\";\nimport {\n CmsGraphQLSchemaSorter,\n CmsModelFieldToGraphQLRegistry\n} from \"~/features/graphql/index.js\";\n\nconst extractInvalidField = (model: CmsModel, err: GraphQLError) => {\n const sdl = err.source?.body || \"\";\n\n /**\n * Find the invalid type\n */\n const { line: lineNumber } = err.locations\n ? err.locations[0]\n : {\n line: 0\n };\n const sdlLines = sdl.split(\"\\n\");\n let sdlLine;\n let gqlType;\n for (let i = lineNumber; i > 0; i--) {\n if (sdlLine && sdlLine.includes(\"type \")) {\n gqlType = sdlLine.match(/type\\s+(.*?)\\s+{/);\n break;\n }\n\n sdlLine = sdlLines[i];\n }\n\n let invalidField: string | undefined = undefined;\n if (Array.isArray(gqlType)) {\n const fieldRegex = new RegExp(`([^\\\\s+].*?):\\\\s+\\\\[?${gqlType[1]}!?\\\\]?`);\n\n const matched = sdl.match(fieldRegex);\n if (matched) {\n invalidField = matched[1];\n }\n }\n\n let message = `See more details in the browser console.`;\n if (invalidField) {\n message = `Please review the definition of \"${invalidField}\" field.`;\n }\n\n return {\n data: {\n modelId: model.modelId,\n sdl,\n invalidField\n },\n code: \"INVALID_MODEL_DEFINITION\",\n message: [`Model \"${model.modelId}\" was not saved!`, message].join(\"\\n\")\n };\n};\n\nconst createValidateChildFields = (\n registry: CmsModelFieldToGraphQLRegistry.Interface\n): ValidateChildFieldsValidate => {\n return ({ fields, originalFields }) => {\n if (fields.length === 0 && originalFields.length === 0) {\n return;\n }\n validateFields({\n fields,\n originalFields,\n registry\n });\n };\n};\n\ninterface ValidateFieldsParams {\n registry: CmsModelFieldToGraphQLRegistry.Interface;\n fields: CmsModelField[];\n originalFields: CmsModelField[];\n}\n\nconst validateFields = (params: ValidateFieldsParams) => {\n const { registry, fields, originalFields } = params;\n\n const idList: string[] = [];\n const fieldIdList: string[] = [];\n const storageIdList: string[] = [];\n\n for (const field of fields) {\n const baseType = getBaseFieldType(field);\n const fieldImpl = registry.get(baseType);\n\n if (!fieldImpl) {\n throw new Error(\n `Cannot update content model because of the unknown \"${baseType}\" field.`\n );\n }\n /**\n * Check the field's id against existing ones.\n * There cannot be two fields with the same id.\n */\n if (idList.includes(field.id)) {\n throw new WebinyError(\n `Cannot update content model because field \"${\n field.storageId || field.fieldId\n }\" has id \"${field.id}\", which is already used.`\n );\n }\n idList.push(field.id);\n\n const originalField = originalFields.find(f => f.id === field.id);\n /**\n * Field MUST have an fieldId defined.\n */\n if (!field.fieldId) {\n throw new WebinyError(`Field does not have an \"fieldId\" defined.`, \"MISSING_FIELD_ID\", {\n field\n });\n }\n /**\n * If storageId does not match a certain pattern, add that pattern, but only if field is not locked (used) already.\n * This is to avoid errors in the already installed systems.\n *\n * Why are we using the @?\n *\n * It is not part of special characters for the query syntax in the Lucene.\n *\n * Relevant links:\n * https://lucene.apache.org/core/3_4_0/queryparsersyntax.html\n * https://discuss.elastic.co/t/special-characters-in-field-names/10658/3\n * https://discuss.elastic.co/t/illegal-characters-in-elasticsearch-field-names/17196/2\n */\n if (!field.storageId) {\n /**\n * When having an original field, set the storageId to value from the originalField\n */\n if (originalField) {\n field.storageId = originalField.storageId;\n } else {\n field.storageId = createFieldStorageId(field);\n }\n }\n /**\n * Check the field's fieldId against existing ones.\n * There cannot be two fields with the same fieldId - outside world identifier.\n */\n if (fieldIdList.includes(field.fieldId)) {\n throw new WebinyError(\n `Cannot update content model because field \"${field.storageId}\" has fieldId \"${field.fieldId}\", which is already used.`\n );\n }\n fieldIdList.push(field.fieldId);\n /**\n * Check the field's storageId against the existing ones.\n * There cannot be two fields with the same storageId.\n */\n if (storageIdList.includes(field.storageId)) {\n throw new WebinyError(\n `Cannot update content model because field \"${field.label}\" has storageId \"${field.storageId}\", which is already used.`\n );\n }\n storageIdList.push(field.storageId);\n /**\n * There might be some plugins which allow child fields.\n * We use this method to validate them as well.\n */\n if (!fieldImpl.validateChildFields) {\n continue;\n }\n const validateChildFields = createValidateChildFields(registry);\n fieldImpl.validateChildFields({\n field,\n originalField,\n validate: validateChildFields\n });\n }\n};\n\ninterface CreateGraphQLSchemaParams {\n context: CmsContext;\n model: CmsModel;\n}\n\nconst createGraphQLSchema = async (params: CreateGraphQLSchemaParams): Promise<any> => {\n const { context, model } = params;\n\n const models = await context.security.withoutAuthorization(async () => {\n return (await context.cms.listModels()).filter((model): model is CmsModel => {\n return model.isPrivate !== true;\n });\n });\n\n const modelPlugins = await buildSchemaPlugins({\n context,\n /**\n * Must remove the current model from the list, as we are possibly updating it - there would be two if we didn't.\n */\n models: models.filter(m => m.modelId !== model.modelId).concat([model])\n });\n\n const plugins = context.plugins\n .byType<ICmsGraphQLSchemaPlugin>(CmsGraphQLSchemaPlugin.type)\n .filter(plugin => plugin.isApplicable(context))\n .reduce<Record<string, ICmsGraphQLSchemaPlugin>>((collection, plugin) => {\n const name =\n plugin.name || `${CmsGraphQLSchemaPlugin.type}-${generateAlphaNumericId(16)}`;\n collection[name] = plugin;\n return collection;\n }, {});\n for (const plugin of modelPlugins) {\n const name = plugin.name || `${plugin.type}-${generateAlphaNumericId(16)}`;\n plugins[name] = plugin;\n }\n\n return createExecutableSchema({\n plugins: Object.values(plugins)\n });\n};\n\nconst extractErrorObject = (error: any) => {\n return [\"message\", \"code\", \"data\", \"stack\"].reduce<Record<string, any>>((output, key) => {\n if (!error[key]) {\n return output;\n }\n output[key] = error[key];\n return output;\n }, {});\n};\n\ninterface ValidateModelFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n original?: CmsModel;\n context: CmsContext;\n}\n\nexport const validateModelFields = async (params: ValidateModelFieldsParams): Promise<void> => {\n const { models, model, original, context } = params;\n const { titleFieldId, descriptionFieldId, imageFieldId } = model;\n\n /**\n * There should be fields/locked fields in either model or data to be updated.\n */\n const { fields = [] } = model;\n\n /**\n * Let's inspect the fields of the received content model. We prevent saving of a content model if it\n * contains a field for which a \"cms-model-field-to-graphql\" plugin does not exist on the backend.\n */\n const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);\n const sorters = context.container.resolveAll(CmsGraphQLSchemaSorter);\n\n validateFields({\n fields,\n originalFields: original?.fields || [],\n registry: fieldRegistry\n });\n\n if (fields.length) {\n /**\n * Make sure that this model can be safely converted to a GraphQL SDL\n */\n const schema = createManageSDL({\n models,\n model,\n fieldRegistry,\n sorters\n });\n\n try {\n gql(schema);\n } catch (err) {\n throw new WebinyError(extractInvalidField(model, err));\n }\n /**\n *\n */\n try {\n await createGraphQLSchema({\n context,\n model\n });\n } catch (err) {\n throw new WebinyError({\n message:\n \"Cannot generate GraphQL schema when testing with the given model. Please check the response for more details.\",\n code: \"GRAPHQL_SCHEMA_ERROR\",\n data: {\n modelId: model.modelId,\n error: extractErrorObject(err)\n }\n });\n }\n }\n\n model.titleFieldId = getContentModelTitleFieldId(fields, titleFieldId);\n model.descriptionFieldId = getContentModelDescriptionFieldId(fields, descriptionFieldId);\n model.imageFieldId = getContentModelImageFieldId(fields, imageFieldId);\n};\n"],"names":["extractInvalidField","model","err","sdl","lineNumber","sdlLines","sdlLine","gqlType","i","invalidField","Array","fieldRegex","RegExp","matched","message","createValidateChildFields","registry","fields","originalFields","validateFields","params","idList","fieldIdList","storageIdList","field","baseType","getBaseFieldType","fieldImpl","Error","WebinyError","originalField","f","createFieldStorageId","validateChildFields","createGraphQLSchema","context","models","modelPlugins","buildSchemaPlugins","m","plugins","CmsGraphQLSchemaPlugin","plugin","collection","name","generateAlphaNumericId","createExecutableSchema","Object","extractErrorObject","error","output","key","validateModelFields","original","titleFieldId","descriptionFieldId","imageFieldId","fieldRegistry","CmsModelFieldToGraphQLRegistry","sorters","CmsGraphQLSchemaSorter","schema","createManageSDL","gql","getContentModelTitleFieldId","getContentModelDescriptionFieldId","getContentModelImageFieldId"],"mappings":";;;;;;;;;;;;;AAqBA,MAAMA,sBAAsB,CAACC,OAAiBC;IAC1C,MAAMC,MAAMD,IAAI,MAAM,EAAE,QAAQ;IAKhC,MAAM,EAAE,MAAME,UAAU,EAAE,GAAGF,IAAI,SAAS,GACpCA,IAAI,SAAS,CAAC,EAAE,GAChB;QACI,MAAM;IACV;IACN,MAAMG,WAAWF,IAAI,KAAK,CAAC;IAC3B,IAAIG;IACJ,IAAIC;IACJ,IAAK,IAAIC,IAAIJ,YAAYI,IAAI,GAAGA,IAAK;QACjC,IAAIF,WAAWA,QAAQ,QAAQ,CAAC,UAAU;YACtCC,UAAUD,QAAQ,KAAK,CAAC;YACxB;QACJ;QAEAA,UAAUD,QAAQ,CAACG,EAAE;IACzB;IAEA,IA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tC,UAAUI;IACd;IAEA,IAAIxC,OAAO,MAAM,EAAE;QAIf,MAAM4C,SAASC,gBAAgB;YAC3B1B;YACAnC;YACAwD;YACAE;QACJ;QAEA,IAAI;YACAI,YAAIF;QACR,EAAE,OAAO3D,KAAK;YACV,MAAM,IAAI2B,cAAY7B,oBAAoBC,OAAOC;QACrD;QAIA,IAAI;YACA,MAAMgC,oBAAoB;gBACtBC;gBACAlC;YACJ;QACJ,EAAE,OAAOC,KAAK;YACV,MAAM,IAAI2B,cAAY;gBAClB,SACI;gBACJ,MAAM;gBACN,MAAM;oBACF,SAAS5B,MAAM,OAAO;oBACtB,OAAO+C,mBAAmB9C;gBAC9B;YACJ;QACJ;IACJ;IAEAD,MAAM,YAAY,GAAG+D,4BAA4B/C,QAAQqC;IACzDrD,MAAM,kBAAkB,GAAGgE,kCAAkChD,QAAQsC;IACrEtD,MAAM,YAAY,GAAGiE,4BAA4BjD,QAAQuC;AAC7D"}
|
|
1
|
+
{"version":3,"file":"domain/contentModel/validation/modelFields.js","sources":["../../../../src/domain/contentModel/validation/modelFields.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport WebinyError from \"@webiny/error\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\nimport type { CmsContext, CmsModel, CmsModelField } from \"~/types/index.js\";\nimport type { ValidateChildFieldsValidate } from \"~/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.js\";\nimport { createManageSDL } from \"~/graphql/schema/createManageSDL.js\";\nimport { createFieldStorageId } from \"../createFieldStorageId.js\";\nimport type { GraphQLError } from \"graphql\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType.js\";\nimport { getContentModelTitleFieldId } from \"./fields/titleField.js\";\nimport { getContentModelDescriptionFieldId } from \"./fields/descriptionField.js\";\nimport { getContentModelImageFieldId } from \"./fields/imageField.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { buildSchemaPlugins } from \"~/graphql/buildSchemaPlugins.js\";\nimport { HeadlessCms } from \"~/features/shared/abstractions.js\";\nimport { CmsGraphQLSchemaFactory } from \"~/graphql/CmsGraphQLSchemaFactory.js\";\nimport { createExecutableSchema } from \"~/graphql/createExecutableSchema.js\";\nimport {\n CmsGraphQLSchemaSorter,\n CmsModelFieldToGraphQLRegistry\n} from \"~/features/graphql/index.js\";\n\nconst extractInvalidField = (model: CmsModel, err: GraphQLError) => {\n const sdl = err.source?.body || \"\";\n\n /**\n * Find the invalid type\n */\n const { line: lineNumber } = err.locations\n ? err.locations[0]\n : {\n line: 0\n };\n const sdlLines = sdl.split(\"\\n\");\n let sdlLine;\n let gqlType;\n for (let i = lineNumber; i > 0; i--) {\n if (sdlLine && sdlLine.includes(\"type \")) {\n gqlType = sdlLine.match(/type\\s+(.*?)\\s+{/);\n break;\n }\n\n sdlLine = sdlLines[i];\n }\n\n let invalidField: string | undefined = undefined;\n if (Array.isArray(gqlType)) {\n const fieldRegex = new RegExp(`([^\\\\s+].*?):\\\\s+\\\\[?${gqlType[1]}!?\\\\]?`);\n\n const matched = sdl.match(fieldRegex);\n if (matched) {\n invalidField = matched[1];\n }\n }\n\n let message = `See more details in the browser console.`;\n if (invalidField) {\n message = `Please review the definition of \"${invalidField}\" field.`;\n }\n\n return {\n data: {\n modelId: model.modelId,\n sdl,\n invalidField\n },\n code: \"INVALID_MODEL_DEFINITION\",\n message: [`Model \"${model.modelId}\" was not saved!`, message].join(\"\\n\")\n };\n};\n\nconst createValidateChildFields = (\n registry: CmsModelFieldToGraphQLRegistry.Interface\n): ValidateChildFieldsValidate => {\n return ({ fields, originalFields }) => {\n if (fields.length === 0 && originalFields.length === 0) {\n return;\n }\n validateFields({\n fields,\n originalFields,\n registry\n });\n };\n};\n\ninterface ValidateFieldsParams {\n registry: CmsModelFieldToGraphQLRegistry.Interface;\n fields: CmsModelField[];\n originalFields: CmsModelField[];\n}\n\nconst validateFields = (params: ValidateFieldsParams) => {\n const { registry, fields, originalFields } = params;\n\n const idList: string[] = [];\n const fieldIdList: string[] = [];\n const storageIdList: string[] = [];\n\n for (const field of fields) {\n const baseType = getBaseFieldType(field);\n const fieldImpl = registry.get(baseType);\n\n if (!fieldImpl) {\n throw new Error(\n `Cannot update content model because of the unknown \"${baseType}\" field.`\n );\n }\n /**\n * Check the field's id against existing ones.\n * There cannot be two fields with the same id.\n */\n if (idList.includes(field.id)) {\n throw new WebinyError(\n `Cannot update content model because field \"${\n field.storageId || field.fieldId\n }\" has id \"${field.id}\", which is already used.`\n );\n }\n idList.push(field.id);\n\n const originalField = originalFields.find(f => f.id === field.id);\n /**\n * Field MUST have an fieldId defined.\n */\n if (!field.fieldId) {\n throw new WebinyError(`Field does not have an \"fieldId\" defined.`, \"MISSING_FIELD_ID\", {\n field\n });\n }\n /**\n * If storageId does not match a certain pattern, add that pattern, but only if field is not locked (used) already.\n * This is to avoid errors in the already installed systems.\n *\n * Why are we using the @?\n *\n * It is not part of special characters for the query syntax in the Lucene.\n *\n * Relevant links:\n * https://lucene.apache.org/core/3_4_0/queryparsersyntax.html\n * https://discuss.elastic.co/t/special-characters-in-field-names/10658/3\n * https://discuss.elastic.co/t/illegal-characters-in-elasticsearch-field-names/17196/2\n */\n if (!field.storageId) {\n /**\n * When having an original field, set the storageId to value from the originalField\n */\n if (originalField) {\n field.storageId = originalField.storageId;\n } else {\n field.storageId = createFieldStorageId(field);\n }\n }\n /**\n * Check the field's fieldId against existing ones.\n * There cannot be two fields with the same fieldId - outside world identifier.\n */\n if (fieldIdList.includes(field.fieldId)) {\n throw new WebinyError(\n `Cannot update content model because field \"${field.storageId}\" has fieldId \"${field.fieldId}\", which is already used.`\n );\n }\n fieldIdList.push(field.fieldId);\n /**\n * Check the field's storageId against the existing ones.\n * There cannot be two fields with the same storageId.\n */\n if (storageIdList.includes(field.storageId)) {\n throw new WebinyError(\n `Cannot update content model because field \"${field.label}\" has storageId \"${field.storageId}\", which is already used.`\n );\n }\n storageIdList.push(field.storageId);\n /**\n * There might be some plugins which allow child fields.\n * We use this method to validate them as well.\n */\n if (!fieldImpl.validateChildFields) {\n continue;\n }\n const validateChildFields = createValidateChildFields(registry);\n fieldImpl.validateChildFields({\n field,\n originalField,\n validate: validateChildFields\n });\n }\n};\n\ninterface CreateGraphQLSchemaParams {\n context: CmsContext;\n model: CmsModel;\n}\n\nconst createGraphQLSchema = async (params: CreateGraphQLSchemaParams): Promise<any> => {\n const { context, model } = params;\n\n const modelsResult = await context.container\n .resolve(IdentityContext)\n .withoutAuthorization(async () => {\n return context.container.resolve(ListModelsUseCase).execute();\n });\n if (modelsResult.isFail()) {\n throw modelsResult.error;\n }\n const models = modelsResult.value.filter(\n (model): model is CmsModel => model.isPrivate !== true\n );\n\n const generatedSchemaPlugins = await buildSchemaPlugins({\n context,\n /**\n * Must remove the current model from the list, as we are possibly updating it - there would be two if we didn't.\n */\n models: models.filter(m => m.modelId !== model.modelId).concat([model]),\n type: context.container.resolve(HeadlessCms).type\n });\n\n /**\n * The base CMS GraphQL types (CmsError, CmsIdentity, entry options, etc.) are provided\n * by the CmsGraphQLSchemaFactory implementations registered in the DI container — mirror\n * generateSchema() so model validation builds against the same complete type set.\n */\n const staticFactories = context.container.resolveAll(CmsGraphQLSchemaFactory);\n const staticPlugins: ICmsGraphQLSchemaPlugin[] = [];\n for (const factory of staticFactories) {\n staticPlugins.push(...(await factory.execute()));\n }\n\n const schemaPlugins = [...staticPlugins, ...generatedSchemaPlugins].filter(pl => {\n if (typeof pl.isApplicable === \"function\") {\n return pl.isApplicable(context);\n }\n return true;\n });\n\n return createExecutableSchema({ plugins: schemaPlugins });\n};\n\nconst extractErrorObject = (error: any) => {\n return [\"message\", \"code\", \"data\", \"stack\"].reduce<Record<string, any>>((output, key) => {\n if (!error[key]) {\n return output;\n }\n output[key] = error[key];\n return output;\n }, {});\n};\n\ninterface ValidateModelFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n original?: CmsModel;\n context: CmsContext;\n}\n\nexport const validateModelFields = async (params: ValidateModelFieldsParams): Promise<void> => {\n const { models, model, original, context } = params;\n const { titleFieldId, descriptionFieldId, imageFieldId } = model;\n\n /**\n * There should be fields/locked fields in either model or data to be updated.\n */\n const { fields = [] } = model;\n\n /**\n * Let's inspect the fields of the received content model. We prevent saving of a content model if it\n * contains a field for which a \"cms-model-field-to-graphql\" plugin does not exist on the backend.\n */\n const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);\n const sorters = context.container.resolveAll(CmsGraphQLSchemaSorter);\n\n validateFields({\n fields,\n originalFields: original?.fields || [],\n registry: fieldRegistry\n });\n\n if (fields.length) {\n /**\n * Make sure that this model can be safely converted to a GraphQL SDL\n */\n const schema = createManageSDL({\n models,\n model,\n fieldRegistry,\n sorters\n });\n\n try {\n gql(schema);\n } catch (err) {\n throw new WebinyError(extractInvalidField(model, err));\n }\n /**\n *\n */\n try {\n await createGraphQLSchema({\n context,\n model\n });\n } catch (err) {\n throw new WebinyError({\n message:\n \"Cannot generate GraphQL schema when testing with the given model. Please check the response for more details.\",\n code: \"GRAPHQL_SCHEMA_ERROR\",\n data: {\n modelId: model.modelId,\n error: extractErrorObject(err)\n }\n });\n }\n }\n\n model.titleFieldId = getContentModelTitleFieldId(fields, titleFieldId);\n model.descriptionFieldId = getContentModelDescriptionFieldId(fields, descriptionFieldId);\n model.imageFieldId = getContentModelImageFieldId(fields, imageFieldId);\n};\n"],"names":["extractInvalidField","model","err","sdl","lineNumber","sdlLines","sdlLine","gqlType","i","invalidField","Array","fieldRegex","RegExp","matched","message","createValidateChildFields","registry","fields","originalFields","validateFields","params","idList","fieldIdList","storageIdList","field","baseType","getBaseFieldType","fieldImpl","Error","WebinyError","originalField","f","createFieldStorageId","validateChildFields","createGraphQLSchema","context","modelsResult","IdentityContext","ListModelsUseCase","models","generatedSchemaPlugins","buildSchemaPlugins","m","HeadlessCms","staticFactories","CmsGraphQLSchemaFactory","staticPlugins","factory","schemaPlugins","pl","createExecutableSchema","extractErrorObject","error","output","key","validateModelFields","original","titleFieldId","descriptionFieldId","imageFieldId","fieldRegistry","CmsModelFieldToGraphQLRegistry","sorters","CmsGraphQLSchemaSorter","schema","createManageSDL","gql","getContentModelTitleFieldId","getContentModelDescriptionFieldId","getContentModelImageFieldId"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAMA,sBAAsB,CAACC,OAAiBC;IAC1C,MAAMC,MAAMD,IAAI,MAAM,EAAE,QAAQ;IAKhC,MAAM,EAAE,MAAME,UAAU,EAAE,GAAGF,IAAI,SAAS,GACpCA,IAAI,SAAS,CAAC,EAAE,GAChB;QACI,MAAM;IACV;IACN,MAAMG,WAAWF,IAAI,KAAK,CAAC;IAC3B,IAAIG;IACJ,IAAIC;IACJ,IAAK,IAAIC,IAAIJ,YAAYI,IAAI,GAAGA,IAAK;QACjC,IAAIF,WAAWA,QAAQ,QAAQ,CAAC,UAAU;YACtCC,UAAUD,QAAQ,KAAK,CAAC;YACxB;QACJ;QAEAA,UAAUD,QAAQ,CAACG,EAAE;IACzB;IAEA,IAAIC;IACJ,IAAIC,MAAM,OAAO,CAACH,UAAU;QACxB,MAAMI,aAAa,IAAIC,OAAO,CAAC,qBAAqB,EAAEL,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC;QAExE,MAAMM,UAAUV,IAAI,KAAK,CAACQ;QAC1B,IAAIE,SACAJ,eAAeI,OAAO,CAAC,EAAE;IAEjC;IAEA,IAAIC,UAAU;IACd,IAAIL,cACAK,UAAU,CAAC,iCAAiC,EAAEL,aAAa,QAAQ,CAAC;IAGxE,OAAO;QACH,MAAM;YACF,SAASR,MAAM,OAAO;YACtBE;YACAM;QACJ;QACA,MAAM;QACN,SAAS;YAAC,CAAC,OAAO,EAAER,MAAM,OAAO,CAAC,gBAAgB,CAAC;YAAEa;SAAQ,CAAC,IAAI,CAAC;IACvE;AACJ;AAEA,MAAMC,4BAA4B,CAC9BC,WAEO,CAAC,EAAEC,MAAM,EAAEC,cA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4BpD,QAAQ0C;AAC7D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HeadlessCmsExport, HeadlessCmsImport } from "./types.js";
|
|
2
|
+
export declare const CmsExport: import("@webiny/di").Abstraction<HeadlessCmsExport>;
|
|
3
|
+
export declare namespace CmsExport {
|
|
4
|
+
type Interface = HeadlessCmsExport;
|
|
5
|
+
}
|
|
6
|
+
export declare const CmsImport: import("@webiny/di").Abstraction<HeadlessCmsImport>;
|
|
7
|
+
export declare namespace CmsImport {
|
|
8
|
+
type Interface = HeadlessCmsImport;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export/abstractions.js","sources":["../../src/export/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { HeadlessCmsExport, HeadlessCmsImport } from \"./types.js\";\n\nexport const CmsExport = createAbstraction<HeadlessCmsExport>(\"CmsExport\");\n\nexport namespace CmsExport {\n export type Interface = HeadlessCmsExport;\n}\n\nexport const CmsImport = createAbstraction<HeadlessCmsImport>(\"CmsImport\");\n\nexport namespace CmsImport {\n export type Interface = HeadlessCmsImport;\n}\n"],"names":["CmsExport","createAbstraction","CmsImport"],"mappings":";AAGO,MAAMA,YAAYC,kBAAqC;AAMvD,MAAMC,YAAYD,kBAAqC"}
|
package/export/crud/exporting.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { sanitizeGroup, sanitizeModel } from "./sanitize.js";
|
|
2
|
+
import { ListGroupsUseCase } from "../../features/contentModelGroup/ListGroups/index.js";
|
|
3
|
+
import { ListModelsUseCase } from "../../features/contentModel/ListModels/index.js";
|
|
2
4
|
const createExportStructureContext = (context)=>async (params)=>{
|
|
3
5
|
const { models: modelIdList } = params;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
+
const groupsResult = await context.container.resolve(ListGroupsUseCase).execute();
|
|
7
|
+
if (groupsResult.isFail()) throw groupsResult.error;
|
|
8
|
+
const groups = groupsResult.value.map(sanitizeGroup);
|
|
9
|
+
const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
|
|
10
|
+
if (modelsResult.isFail()) throw modelsResult.error;
|
|
11
|
+
const models = modelsResult.value.filter((model)=>{
|
|
6
12
|
if (model.isPrivate) return false;
|
|
7
13
|
if (!model.fields?.length) return false;
|
|
8
14
|
if (!modelIdList?.length) return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export/crud/exporting.js","sources":["../../../src/export/crud/exporting.ts"],"sourcesContent":["import type { HeadlessCmsExportStructure, SanitizedCmsModel } from \"~/export/types.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport { sanitizeGroup, sanitizeModel } from \"./sanitize.js\";\n\nexport const createExportStructureContext = (context: CmsContext): HeadlessCmsExportStructure => {\n return async params => {\n const { models: modelIdList } = params;\n const
|
|
1
|
+
{"version":3,"file":"export/crud/exporting.js","sources":["../../../src/export/crud/exporting.ts"],"sourcesContent":["import type { HeadlessCmsExportStructure, SanitizedCmsModel } from \"~/export/types.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport { sanitizeGroup, sanitizeModel } from \"./sanitize.js\";\nimport { ListGroupsUseCase } from \"~/features/contentModelGroup/ListGroups/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\n\nexport const createExportStructureContext = (context: CmsContext): HeadlessCmsExportStructure => {\n return async params => {\n const { models: modelIdList } = params;\n\n const groupsResult = await context.container.resolve(ListGroupsUseCase).execute();\n if (groupsResult.isFail()) {\n throw groupsResult.error;\n }\n const groups = groupsResult.value.map(sanitizeGroup);\n\n /**\n * We need all the models which:\n * * are accessible by current user\n * * are not private\n * * are included (if targets are provided)\n * * are part of one of the groups we already fetched\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 .filter(model => {\n if (model.isPrivate) {\n return false;\n } else if (!model.fields?.length) {\n return false;\n } else if (!modelIdList?.length) {\n return true;\n }\n return modelIdList.includes(model.modelId);\n })\n .map(model => {\n const group = groups.find(group => group.slug === model.group);\n if (!group) {\n return null;\n }\n return sanitizeModel(group, model);\n })\n .filter((model): model is SanitizedCmsModel => {\n return !!model;\n });\n\n return {\n groups: groups.filter(group => {\n return models.some(model => model.group === group.slug);\n }),\n models\n };\n };\n};\n"],"names":["createExportStructureContext","context","params","modelIdList","groupsResult","ListGroupsUseCase","groups","sanitizeGroup","modelsResult","ListModelsUseCase","models","model","group","sanitizeModel"],"mappings":";;;AAMO,MAAMA,+BAA+B,CAACC,UAClC,OAAMC;QACT,MAAM,EAAE,QAAQC,WAAW,EAAE,GAAGD;QAEhC,MAAME,eAAe,MAAMH,QAAQ,SAAS,CAAC,OAAO,CAACI,mBAAmB,OAAO;QAC/E,IAAID,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;QAE5B,MAAME,SAASF,aAAa,KAAK,CAAC,GAAG,CAACG;QAStC,MAAMC,eAAe,MAAMP,QAAQ,SAAS,CAAC,OAAO,CAACQ,mBAAmB,OAAO;QAC/E,IAAID,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;QAE5B,MAAME,SAASF,aAAa,KAAK,CAC5B,MAAM,CAACG,CAAAA;YACJ,IAAIA,MAAM,SAAS,EACf,OAAO;YACJ,IAAI,CAACA,MAAM,MAAM,EAAE,QACtB,OAAO;YACJ,IAAI,CAACR,aAAa,QACrB,OAAO;YAEX,OAAOA,YAAY,QAAQ,CAACQ,MAAM,OAAO;QAC7C,GACC,GAAG,CAACA,CAAAA;YACD,MAAMC,QAAQN,OAAO,IAAI,CAACM,CAAAA,QAASA,MAAM,IAAI,KAAKD,MAAM,KAAK;YAC7D,IAAI,CAACC,OACD,OAAO;YAEX,OAAOC,cAAcD,OAAOD;QAChC,GACC,MAAM,CAAC,CAACA,QACE,CAAC,CAACA;QAGjB,OAAO;YACH,QAAQL,OAAO,MAAM,CAACM,CAAAA,QACXF,OAAO,IAAI,CAACC,CAAAA,QAASA,MAAM,KAAK,KAAKC,MAAM,IAAI;YAE1DF;QACJ;IACJ"}
|
package/export/crud/importing.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import _webiny_error from "@webiny/error";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
2
3
|
import { importData } from "./imports/importData.js";
|
|
3
4
|
import { validateInput } from "./imports/validateInput.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { ListGroupsUseCase } from "../../features/contentModelGroup/ListGroups/index.js";
|
|
6
|
+
import { ListModelsUseCase } from "../../features/contentModel/ListModels/index.js";
|
|
7
|
+
const fetchGroupsAndModels = async (context)=>await context.container.resolve(IdentityContext).withoutAuthorization(async ()=>{
|
|
8
|
+
const groupsResult = await context.container.resolve(ListGroupsUseCase).execute();
|
|
9
|
+
if (groupsResult.isFail()) throw groupsResult.error;
|
|
10
|
+
const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
|
|
11
|
+
if (modelsResult.isFail()) throw modelsResult.error;
|
|
12
|
+
return {
|
|
13
|
+
groups: groupsResult.value,
|
|
14
|
+
models: modelsResult.value
|
|
15
|
+
};
|
|
16
|
+
});
|
|
8
17
|
const createImportCrud = (context)=>({
|
|
9
18
|
validate: async (params)=>{
|
|
10
19
|
const { data } = params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export/crud/importing.js","sources":["../../../src/export/crud/importing.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n HeadlessCmsImport,\n ValidCmsGroupResult,\n ValidCmsModelResult\n} from \"~/export/types.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport { importData } from \"./imports/importData.js\";\nimport { validateInput } from \"./imports/validateInput.js\";\n\nconst fetchGroupsAndModels = async (context: CmsContext) => {\n return await context.
|
|
1
|
+
{"version":3,"file":"export/crud/importing.js","sources":["../../../src/export/crud/importing.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport type {\n HeadlessCmsImport,\n ValidCmsGroupResult,\n ValidCmsModelResult\n} from \"~/export/types.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport { importData } from \"./imports/importData.js\";\nimport { validateInput } from \"./imports/validateInput.js\";\nimport { ListGroupsUseCase } from \"~/features/contentModelGroup/ListGroups/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\n\nconst fetchGroupsAndModels = async (context: CmsContext) => {\n return await context.container.resolve(IdentityContext).withoutAuthorization(async () => {\n const groupsResult = await context.container.resolve(ListGroupsUseCase).execute();\n if (groupsResult.isFail()) {\n throw groupsResult.error;\n }\n const modelsResult = await context.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n throw modelsResult.error;\n }\n return {\n groups: groupsResult.value,\n models: modelsResult.value\n };\n });\n};\n\nexport const createImportCrud = (context: CmsContext): HeadlessCmsImport => {\n return {\n validate: async params => {\n const { data } = params;\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n return {\n groups: validated.groups,\n models: validated.models,\n message: validated.error\n };\n }\n\n return {\n groups: validated.groups,\n models: validated.models,\n message: \"Validation done.\"\n };\n },\n structure: async params => {\n const { data } = params;\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n throw new WebinyError(validated.error, \"VALIDATION_ERROR\");\n }\n\n const imported = await importData({\n context,\n groups: validated.groups as ValidCmsGroupResult[],\n models: validated.models as ValidCmsModelResult[]\n });\n\n const modelError = imported.models.find(model => !!model.error);\n const error = imported.error || modelError;\n\n return {\n ...imported,\n message: error ? null : \"Import done.\"\n };\n }\n };\n};\n"],"names":["fetchGroupsAndModels","context","IdentityContext","groupsResult","ListGroupsUseCase","modelsResult","ListModelsUseCase","createImportCrud","params","data","groups","models","validated","validateInput","WebinyError","imported","importData","modelError","model","error"],"mappings":";;;;;;AAaA,MAAMA,uBAAuB,OAAOC,UACzB,MAAMA,QAAQ,SAAS,CAAC,OAAO,CAACC,iBAAiB,oBAAoB,CAAC;QACzE,MAAMC,eAAe,MAAMF,QAAQ,SAAS,CAAC,OAAO,CAACG,mBAAmB,OAAO;QAC/E,IAAID,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;QAE5B,MAAME,eAAe,MAAMJ,QAAQ,SAAS,CAAC,OAAO,CAACK,mBAAmB,OAAO;QAC/E,IAAID,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;QAE5B,OAAO;YACH,QAAQF,aAAa,KAAK;YAC1B,QAAQE,aAAa,KAAK;QAC9B;IACJ;AAGG,MAAME,mBAAmB,CAACN,UACtB;QACH,UAAU,OAAMO;YACZ,MAAM,EAAEC,IAAI,EAAE,GAAGD;YAEjB,MAAM,EAAEE,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMX,qBAAqBC;YAEtD,MAAMW,YAAY,MAAMC,cAAc;gBAClCH;gBACAC;gBACAF;YACJ;YACA,IAAIG,UAAU,KAAK,EACf,OAAO;gBACH,QAAQA,UAAU,MAAM;gBACxB,QAAQA,UAAU,MAAM;gBACxB,SAASA,UAAU,KAAK;YAC5B;YAGJ,OAAO;gBACH,QAAQA,UAAU,MAAM;gBACxB,QAAQA,UAAU,MAAM;gBACxB,SAAS;YACb;QACJ;QACA,WAAW,OAAMJ;YACb,MAAM,EAAEC,IAAI,EAAE,GAAGD;YAEjB,MAAM,EAAEE,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMX,qBAAqBC;YAEtD,MAAMW,YAAY,MAAMC,cAAc;gBAClCH;gBACAC;gBACAF;YACJ;YACA,IAAIG,UAAU,KAAK,EACf,MAAM,IAAIE,cAAYF,UAAU,KAAK,EAAE;YAG3C,MAAMG,WAAW,MAAMC,WAAW;gBAC9Bf;gBACA,QAAQW,UAAU,MAAM;gBACxB,QAAQA,UAAU,MAAM;YAC5B;YAEA,MAAMK,aAAaF,SAAS,MAAM,CAAC,IAAI,CAACG,CAAAA,QAAS,CAAC,CAACA,MAAM,KAAK;YAC9D,MAAMC,QAAQJ,SAAS,KAAK,IAAIE;YAEhC,OAAO;gBACH,GAAGF,QAAQ;gBACX,SAASI,QAAQ,OAAO;YAC5B;QACJ;IACJ"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { CmsImportAction } from "../../types.js";
|
|
2
|
+
import { CreateGroupUseCase } from "../../../features/contentModelGroup/CreateGroup/index.js";
|
|
3
|
+
import { UpdateGroupUseCase } from "../../../features/contentModelGroup/UpdateGroup/index.js";
|
|
2
4
|
const importGroups = async (params)=>{
|
|
3
5
|
const { context, groups } = params;
|
|
4
6
|
const results = [];
|
|
@@ -21,20 +23,13 @@ const importGroups = async (params)=>{
|
|
|
21
23
|
continue;
|
|
22
24
|
}
|
|
23
25
|
if (group.action === CmsImportAction.UPDATE) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
action: group.action,
|
|
32
|
-
group: {
|
|
33
|
-
...result
|
|
34
|
-
},
|
|
35
|
-
imported: true
|
|
36
|
-
});
|
|
37
|
-
} catch (ex) {
|
|
26
|
+
const updateResult = await context.container.resolve(UpdateGroupUseCase).execute(group.group.id, {
|
|
27
|
+
...group.group,
|
|
28
|
+
icon: group.group.icon ?? void 0,
|
|
29
|
+
description: group.group.description || void 0
|
|
30
|
+
});
|
|
31
|
+
if (updateResult.isFail()) {
|
|
32
|
+
const ex = updateResult.error;
|
|
38
33
|
results.push({
|
|
39
34
|
action: group.action,
|
|
40
35
|
group: group.group,
|
|
@@ -48,19 +43,18 @@ const importGroups = async (params)=>{
|
|
|
48
43
|
}
|
|
49
44
|
}
|
|
50
45
|
});
|
|
51
|
-
}
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
const result = await context.cms.createGroup(group.group);
|
|
56
|
-
results.push({
|
|
46
|
+
} else results.push({
|
|
57
47
|
action: group.action,
|
|
58
48
|
group: {
|
|
59
|
-
...
|
|
49
|
+
...updateResult.value
|
|
60
50
|
},
|
|
61
51
|
imported: true
|
|
62
52
|
});
|
|
63
|
-
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const createResult = await context.container.resolve(CreateGroupUseCase).execute(group.group);
|
|
56
|
+
if (createResult.isFail()) {
|
|
57
|
+
const ex = createResult.error;
|
|
64
58
|
results.push({
|
|
65
59
|
action: group.action,
|
|
66
60
|
group: group.group,
|
|
@@ -74,7 +68,13 @@ const importGroups = async (params)=>{
|
|
|
74
68
|
}
|
|
75
69
|
}
|
|
76
70
|
});
|
|
77
|
-
}
|
|
71
|
+
} else results.push({
|
|
72
|
+
action: group.action,
|
|
73
|
+
group: {
|
|
74
|
+
...createResult.value
|
|
75
|
+
},
|
|
76
|
+
imported: true
|
|
77
|
+
});
|
|
78
78
|
}
|
|
79
79
|
return results;
|
|
80
80
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export/crud/imports/importGroups.js","sources":["../../../../src/export/crud/imports/importGroups.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { CmsGroupImportResult, ValidCmsGroupResult } from \"~/export/types.js\";\nimport { CmsImportAction } from \"~/export/types.js\";\n\ninterface Params {\n context: CmsContext;\n groups: ValidCmsGroupResult[];\n}\n\nexport const importGroups = async (params: Params) => {\n const { context, groups } = params;\n\n const results: CmsGroupImportResult[] = [];\n for (const group of groups) {\n if (group.action === CmsImportAction.NONE || group.error) {\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: group.error || {\n message: \"No action to be ran on the group.\",\n code: \"NO_ACTION\"\n }\n });\n }\n /**\n * Cannot update if the group is created via plugin.\n */\n if (group.action === CmsImportAction.CODE) {\n results.push({\n action: group.action,\n group: group.group,\n imported: true\n });\n continue;\n }\n /**\n * Update the group.\n */\n //\n else if (group.action === CmsImportAction.UPDATE) {\n
|
|
1
|
+
{"version":3,"file":"export/crud/imports/importGroups.js","sources":["../../../../src/export/crud/imports/importGroups.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { CmsGroupImportResult, ValidCmsGroupResult } from \"~/export/types.js\";\nimport { CmsImportAction } from \"~/export/types.js\";\nimport { CreateGroupUseCase } from \"~/features/contentModelGroup/CreateGroup/index.js\";\nimport { UpdateGroupUseCase } from \"~/features/contentModelGroup/UpdateGroup/index.js\";\n\ninterface Params {\n context: CmsContext;\n groups: ValidCmsGroupResult[];\n}\n\nexport const importGroups = async (params: Params) => {\n const { context, groups } = params;\n\n const results: CmsGroupImportResult[] = [];\n for (const group of groups) {\n if (group.action === CmsImportAction.NONE || group.error) {\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: group.error || {\n message: \"No action to be ran on the group.\",\n code: \"NO_ACTION\"\n }\n });\n }\n /**\n * Cannot update if the group is created via plugin.\n */\n if (group.action === CmsImportAction.CODE) {\n results.push({\n action: group.action,\n group: group.group,\n imported: true\n });\n continue;\n }\n /**\n * Update the group.\n */\n //\n else if (group.action === CmsImportAction.UPDATE) {\n const updateResult = await context.container\n .resolve(UpdateGroupUseCase)\n .execute(group.group.id, {\n ...group.group,\n icon: group.group.icon ?? undefined,\n description: group.group.description || undefined\n });\n if (updateResult.isFail()) {\n const ex = updateResult.error;\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: {\n message: ex.message,\n code: (ex as any).code || \"UPDATE_GROUP_ERROR\",\n data: { ...(ex as any).data, group }\n }\n });\n } else {\n results.push({\n action: group.action,\n group: { ...updateResult.value },\n imported: true\n });\n }\n continue;\n }\n /**\n * Create the group\n */\n const createResult = await context.container\n .resolve(CreateGroupUseCase)\n .execute(group.group);\n if (createResult.isFail()) {\n const ex = createResult.error;\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: {\n message: ex.message,\n code: (ex as any).code || \"CREATE_GROUP_ERROR\",\n data: { ...(ex as any).data, group }\n }\n });\n } else {\n results.push({\n action: group.action,\n group: { ...createResult.value },\n imported: true\n });\n }\n }\n\n return results;\n};\n"],"names":["importGroups","params","context","groups","results","group","CmsImportAction","updateResult","UpdateGroupUseCase","undefined","ex","createResult","CreateGroupUseCase"],"mappings":";;;AAWO,MAAMA,eAAe,OAAOC;IAC/B,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGF;IAE5B,MAAMG,UAAkC,EAAE;IAC1C,KAAK,MAAMC,SAASF,OAAQ;QACxB,IAAIE,MAAM,MAAM,KAAKC,gBAAgB,IAAI,IAAID,MAAM,KAAK,EACpDD,QAAQ,IAAI,CAAC;YACT,QAAQC,MAAM,MAAM;YACpB,OAAOA,MAAM,KAAK;YAClB,UAAU;YACV,OAAOA,MAAM,KAAK,IAAI;gBAClB,SAAS;gBACT,MAAM;YACV;QACJ;QAKJ,IAAIA,MAAM,MAAM,KAAKC,gBAAgB,IAAI,EAAE;YACvCF,QAAQ,IAAI,CAAC;gBACT,QAAQC,MAAM,MAAM;gBACpB,OAAOA,MAAM,KAAK;gBAClB,UAAU;YACd;YACA;QACJ;QAKK,IAAIA,MAAM,MAAM,KAAKC,gBAAgB,MAAM,EAAE;YAC9C,MAAMC,eAAe,MAAML,QAAQ,SAAS,CACvC,OAAO,CAACM,oBACR,OAAO,CAACH,MAAM,KAAK,CAAC,EAAE,EAAE;gBACrB,GAAGA,MAAM,KAAK;gBACd,MAAMA,MAAM,KAAK,CAAC,IAAI,IAAII;gBAC1B,aAAaJ,MAAM,KAAK,CAAC,WAAW,IAAII;YAC5C;YACJ,IAAIF,aAAa,MAAM,IAAI;gBACvB,MAAMG,KAAKH,aAAa,KAAK;gBAC7BH,QAAQ,IAAI,CAAC;oBACT,QAAQC,MAAM,MAAM;oBACpB,OAAOA,MAAM,KAAK;oBAClB,UAAU;oBACV,OAAO;wBACH,SAASK,GAAG,OAAO;wBACnB,MAAOA,GAAW,IAAI,IAAI;wBAC1B,MAAM;4BAAE,GAAIA,GAAW,IAAI;4BAAEL;wBAAM;oBACvC;gBACJ;YACJ,OACID,QAAQ,IAAI,CAAC;gBACT,QAAQC,MAAM,MAAM;gBACpB,OAAO;oBAAE,GAAGE,aAAa,KAAK;gBAAC;gBAC/B,UAAU;YACd;YAEJ;QACJ;QAIA,MAAMI,eAAe,MAAMT,QAAQ,SAAS,CACvC,OAAO,CAACU,oBACR,OAAO,CAACP,MAAM,KAAK;QACxB,IAAIM,aAAa,MAAM,IAAI;YACvB,MAAMD,KAAKC,aAAa,KAAK;YAC7BP,QAAQ,IAAI,CAAC;gBACT,QAAQC,MAAM,MAAM;gBACpB,OAAOA,MAAM,KAAK;gBAClB,UAAU;gBACV,OAAO;oBACH,SAASK,GAAG,OAAO;oBACnB,MAAOA,GAAW,IAAI,IAAI;oBAC1B,MAAM;wBAAE,GAAIA,GAAW,IAAI;wBAAEL;oBAAM;gBACvC;YACJ;QACJ,OACID,QAAQ,IAAI,CAAC;YACT,QAAQC,MAAM,MAAM;YACpB,OAAO;gBAAE,GAAGM,aAAa,KAAK;YAAC;YAC/B,UAAU;QACd;IAER;IAEA,OAAOP;AACX"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { CmsImportAction } from "../../types.js";
|
|
2
|
+
import { ListGroupsUseCase } from "../../../features/contentModelGroup/ListGroups/index.js";
|
|
3
|
+
import { UpdateModelUseCase } from "../../../features/contentModel/UpdateModel/index.js";
|
|
4
|
+
import { CreateModelUseCase } from "../../../features/contentModel/CreateModel/index.js";
|
|
2
5
|
const importModels = async (params)=>{
|
|
3
6
|
const { context, models } = params;
|
|
4
|
-
const
|
|
7
|
+
const groupsResult = await context.container.resolve(ListGroupsUseCase).execute();
|
|
8
|
+
if (groupsResult.isFail()) throw groupsResult.error;
|
|
9
|
+
const groups = groupsResult.value;
|
|
5
10
|
const results = [];
|
|
6
11
|
for (const model of models){
|
|
7
12
|
const group = groups.find((group)=>group.slug === model.model.group);
|
|
@@ -44,18 +49,9 @@ const importModels = async (params)=>{
|
|
|
44
49
|
continue;
|
|
45
50
|
}
|
|
46
51
|
if (model.action === CmsImportAction.UPDATE) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
action: model.action,
|
|
51
|
-
model: {
|
|
52
|
-
...result,
|
|
53
|
-
group: group.slug
|
|
54
|
-
},
|
|
55
|
-
related: model.related,
|
|
56
|
-
imported: true
|
|
57
|
-
});
|
|
58
|
-
} catch (ex) {
|
|
52
|
+
const updateResult = await context.container.resolve(UpdateModelUseCase).execute(model.model.modelId, model.model);
|
|
53
|
+
if (updateResult.isFail()) {
|
|
54
|
+
const ex = updateResult.error;
|
|
59
55
|
results.push({
|
|
60
56
|
action: model.action,
|
|
61
57
|
model: model.model,
|
|
@@ -70,21 +66,20 @@ const importModels = async (params)=>{
|
|
|
70
66
|
}
|
|
71
67
|
}
|
|
72
68
|
});
|
|
73
|
-
}
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
const result = await context.cms.createModel(model.model);
|
|
78
|
-
results.push({
|
|
69
|
+
} else results.push({
|
|
79
70
|
action: model.action,
|
|
80
71
|
model: {
|
|
81
|
-
...
|
|
72
|
+
...updateResult.value,
|
|
82
73
|
group: group.slug
|
|
83
74
|
},
|
|
84
75
|
related: model.related,
|
|
85
76
|
imported: true
|
|
86
77
|
});
|
|
87
|
-
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const createResult = await context.container.resolve(CreateModelUseCase).execute(model.model);
|
|
81
|
+
if (createResult.isFail()) {
|
|
82
|
+
const ex = createResult.error;
|
|
88
83
|
results.push({
|
|
89
84
|
action: model.action,
|
|
90
85
|
model: model.model,
|
|
@@ -99,7 +94,15 @@ const importModels = async (params)=>{
|
|
|
99
94
|
}
|
|
100
95
|
}
|
|
101
96
|
});
|
|
102
|
-
}
|
|
97
|
+
} else results.push({
|
|
98
|
+
action: model.action,
|
|
99
|
+
model: {
|
|
100
|
+
...createResult.value,
|
|
101
|
+
group: group.slug
|
|
102
|
+
},
|
|
103
|
+
related: model.related,
|
|
104
|
+
imported: true
|
|
105
|
+
});
|
|
103
106
|
}
|
|
104
107
|
return results;
|
|
105
108
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export/crud/imports/importModels.js","sources":["../../../../src/export/crud/imports/importModels.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { CmsModelImportResult, ValidCmsModelResult } from \"~/export/types.js\";\nimport { CmsImportAction } from \"~/export/types.js\";\n\ninterface Params {\n context: CmsContext;\n models: ValidCmsModelResult[];\n}\n\nexport const importModels = async (params: Params) => {\n const { context, models } = params;\n\n const
|
|
1
|
+
{"version":3,"file":"export/crud/imports/importModels.js","sources":["../../../../src/export/crud/imports/importModels.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { CmsModelImportResult, ValidCmsModelResult } from \"~/export/types.js\";\nimport { CmsImportAction } from \"~/export/types.js\";\nimport { ListGroupsUseCase } from \"~/features/contentModelGroup/ListGroups/index.js\";\nimport { UpdateModelUseCase } from \"~/features/contentModel/UpdateModel/index.js\";\nimport { CreateModelUseCase } from \"~/features/contentModel/CreateModel/index.js\";\n\ninterface Params {\n context: CmsContext;\n models: ValidCmsModelResult[];\n}\n\nexport const importModels = async (params: Params) => {\n const { context, models } = params;\n\n const groupsResult = await context.container.resolve(ListGroupsUseCase).execute();\n if (groupsResult.isFail()) {\n throw groupsResult.error;\n }\n const groups = groupsResult.value;\n\n const results: CmsModelImportResult[] = [];\n\n for (const model of models) {\n /**\n * There is a possibility that group does not exist.\n */\n const group = groups.find(group => {\n return group.slug === model.model.group;\n });\n if (!group) {\n results.push({\n action: model.action,\n model: model.model,\n related: model.related,\n imported: false,\n error: {\n message: `Group \"${model.model.group}\" does not exist.`,\n code: \"GROUP_NOT_FOUND\",\n data: {\n model\n }\n }\n });\n continue;\n }\n /**\n * No update action or there is a validation error.\n */\n if (model.action === CmsImportAction.NONE || model.error) {\n results.push({\n action: model.action,\n model: model.model,\n related: model.related,\n imported: false,\n error: model.error || {\n message: \"No action to be ran on the model.\",\n code: \"NO_ACTION\"\n }\n });\n continue;\n }\n /**\n * Cannot update a model if it is created via plugin.\n */\n if (model.action === CmsImportAction.CODE) {\n results.push({\n action: model.action,\n model: model.model,\n related: model.related,\n imported: true\n });\n continue;\n }\n\n /**\n * Update the model\n */\n //\n if (model.action === CmsImportAction.UPDATE) {\n const updateResult = await context.container\n .resolve(UpdateModelUseCase)\n .execute(model.model.modelId, model.model);\n if (updateResult.isFail()) {\n const ex = updateResult.error;\n results.push({\n action: model.action,\n model: model.model,\n imported: false,\n related: model.related,\n error: {\n message: ex.message,\n code: (ex as any).code || \"UPDATE_MODEL_ERROR\",\n data: { model: model.model, ...(ex as any).data }\n }\n });\n } else {\n results.push({\n action: model.action,\n model: { ...updateResult.value, group: group.slug },\n related: model.related,\n imported: true\n });\n }\n continue;\n }\n /**\n * Create a new model.\n */\n const createResult = await context.container\n .resolve(CreateModelUseCase)\n .execute(model.model);\n if (createResult.isFail()) {\n const ex = createResult.error;\n results.push({\n action: model.action,\n model: model.model,\n imported: false,\n related: model.related,\n error: {\n message: ex.message,\n code: (ex as any).code || \"CREATE_MODEL_ERROR\",\n data: { model: model.model, ...(ex as any).data }\n }\n });\n } else {\n results.push({\n action: model.action,\n model: { ...createResult.value, group: group.slug },\n related: model.related,\n imported: true\n });\n }\n }\n\n return results;\n};\n"],"names":["importModels","params","context","models","groupsResult","ListGroupsUseCase","groups","results","model","group","CmsImportAction","updateResult","UpdateModelUseCase","ex","createResult","CreateModelUseCase"],"mappings":";;;;AAYO,MAAMA,eAAe,OAAOC;IAC/B,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGF;IAE5B,MAAMG,eAAe,MAAMF,QAAQ,SAAS,CAAC,OA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KF,aAAa,KAAK;gBAC7BJ,QAAQ,IAAI,CAAC;oBACT,QAAQC,MAAM,MAAM;oBACpB,OAAOA,MAAM,KAAK;oBAClB,UAAU;oBACV,SAASA,MAAM,OAAO;oBACtB,OAAO;wBACH,SAASK,GAAG,OAAO;wBACnB,MAAOA,GAAW,IAAI,IAAI;wBAC1B,MAAM;4BAAE,OAAOL,MAAM,KAAK;4BAAE,GAAIK,GAAW,IAAI;wBAAC;oBACpD;gBACJ;YACJ,OACIN,QAAQ,IAAI,CAAC;gBACT,QAAQC,MAAM,MAAM;gBACpB,OAAO;oBAAE,GAAGG,aAAa,KAAK;oBAAE,OAAOF,MAAM,IAAI;gBAAC;gBAClD,SAASD,MAAM,OAAO;gBACtB,UAAU;YACd;YAEJ;QACJ;QAIA,MAAMM,eAAe,MAAMZ,QAAQ,SAAS,CACvC,OAAO,CAACa,oBACR,OAAO,CAACP,MAAM,KAAK;QACxB,IAAIM,aAAa,MAAM,IAAI;YACvB,MAAMD,KAAKC,aAAa,KAAK;YAC7BP,QAAQ,IAAI,CAAC;gBACT,QAAQC,MAAM,MAAM;gBACpB,OAAOA,MAAM,KAAK;gBAClB,UAAU;gBACV,SAASA,MAAM,OAAO;gBACtB,OAAO;oBACH,SAASK,GAAG,OAAO;oBACnB,MAAOA,GAAW,IAAI,IAAI;oBAC1B,MAAM;wBAAE,OAAOL,MAAM,KAAK;wBAAE,GAAIK,GAAW,IAAI;oBAAC;gBACpD;YACJ;QACJ,OACIN,QAAQ,IAAI,CAAC;YACT,QAAQC,MAAM,MAAM;YACpB,OAAO;gBAAE,GAAGM,aAAa,KAAK;gBAAE,OAAOL,MAAM,IAAI;YAAC;YAClD,SAASD,MAAM,OAAO;YACtB,UAAU;QACd;IAER;IAEA,OAAOD;AACX"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const createExportGraphQL: () => ContextPlugin<CmsContext>;
|
|
1
|
+
declare const plugin: import("~/plugins/index.js").ICmsGraphQLSchemaPlugin<import("@webiny/api/types").Context>;
|
|
2
|
+
export { plugin as exportPlugin };
|
package/export/graphql/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createCmsGraphQLSchemaPlugin } from "../../plugins/index.js";
|
|
2
|
-
import { ErrorResponse, Response } from "@webiny/
|
|
3
|
-
import {
|
|
2
|
+
import { ErrorResponse, Response } from "@webiny/api-graphql";
|
|
3
|
+
import { CmsExport, CmsImport } from "../abstractions.js";
|
|
4
4
|
const graphql_plugin = createCmsGraphQLSchemaPlugin({
|
|
5
5
|
typeDefs: `
|
|
6
6
|
type CmsExportStructureResponse {
|
|
@@ -136,7 +136,7 @@ const graphql_plugin = createCmsGraphQLSchemaPlugin({
|
|
|
136
136
|
Query: {
|
|
137
137
|
exportStructure: async (_, args, context)=>{
|
|
138
138
|
try {
|
|
139
|
-
const result = await context.
|
|
139
|
+
const result = await context.container.resolve(CmsExport).structure({
|
|
140
140
|
models: args.models
|
|
141
141
|
});
|
|
142
142
|
return new Response(JSON.stringify(result));
|
|
@@ -148,7 +148,7 @@ const graphql_plugin = createCmsGraphQLSchemaPlugin({
|
|
|
148
148
|
Mutation: {
|
|
149
149
|
validateImportStructure: async (_, args, context)=>{
|
|
150
150
|
try {
|
|
151
|
-
const result = await context.
|
|
151
|
+
const result = await context.container.resolve(CmsImport).validate({
|
|
152
152
|
data: args.data
|
|
153
153
|
});
|
|
154
154
|
return new Response(result);
|
|
@@ -158,7 +158,7 @@ const graphql_plugin = createCmsGraphQLSchemaPlugin({
|
|
|
158
158
|
},
|
|
159
159
|
importStructure: async (_, args, context)=>{
|
|
160
160
|
try {
|
|
161
|
-
const result = await context.
|
|
161
|
+
const result = await context.container.resolve(CmsImport).structure({
|
|
162
162
|
data: args.data
|
|
163
163
|
});
|
|
164
164
|
return new Response(result);
|
|
@@ -170,10 +170,6 @@ const graphql_plugin = createCmsGraphQLSchemaPlugin({
|
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
172
|
graphql_plugin.name = "headless-cms.graphql.export";
|
|
173
|
-
|
|
174
|
-
if (!context.cms.MANAGE) return;
|
|
175
|
-
context.plugins.register(graphql_plugin);
|
|
176
|
-
});
|
|
177
|
-
export { createExportGraphQL };
|
|
173
|
+
export { graphql_plugin as exportPlugin };
|
|
178
174
|
|
|
179
175
|
//# sourceMappingURL=index.js.map
|