@webiny/api-headless-cms 6.4.11 → 6.6.0-alpha.1
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 +195 -0
- package/HeadlessCmsFeature.js.map +1 -0
- package/createCmsRoute.d.ts +26 -0
- package/createCmsRoute.js +59 -0
- package/createCmsRoute.js.map +1 -0
- package/crud/contentEntry/entryDataValidation.d.ts +1 -1
- package/crud/contentEntry/entryDataValidation.js +29 -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/defaultFields.js +3 -2
- package/crud/contentModel/defaultFields.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 +2 -0
- package/domain/contentModel/schemas.js +4 -2
- 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/model.d.ts +4 -1
- package/exports/api/cms/model.js +2 -0
- package/exports/api/cms/storage.d.ts +0 -1
- package/exports/api/cms/storage.js +0 -1
- package/features/ai/DescribeContentModelTool.d.ts +55 -0
- package/features/ai/DescribeContentModelTool.js +60 -0
- package/features/ai/DescribeContentModelTool.js.map +1 -0
- package/features/ai/ListContentModelsTool.d.ts +41 -0
- package/features/ai/ListContentModelsTool.js +44 -0
- package/features/ai/ListContentModelsTool.js.map +1 -0
- package/features/ai/QueryEntriesTool.d.ts +75 -0
- package/features/ai/QueryEntriesTool.js +90 -0
- package/features/ai/QueryEntriesTool.js.map +1 -0
- package/features/ai/feature.d.ts +8 -0
- package/features/ai/feature.js +15 -0
- package/features/ai/feature.js.map +1 -0
- package/features/ai/index.d.ts +4 -0
- package/features/ai/index.js +4 -0
- package/features/contentEntry/ContentEntriesFeature.js +0 -2
- package/features/contentEntry/ContentEntriesFeature.js.map +1 -1
- package/features/contentEntry/CreateEntry/CreateEntryRepository.d.ts +7 -7
- package/features/contentEntry/CreateEntry/CreateEntryRepository.js +8 -14
- 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 +7 -7
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js +8 -14
- 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 +7 -7
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js +8 -14
- 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 -6
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js +8 -14
- 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 -6
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js +8 -14
- 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 +7 -7
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js +8 -13
- 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 +9 -7
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js +15 -13
- 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 +7 -7
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js +8 -13
- 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 +7 -7
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js +8 -13
- 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 +7 -7
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js +8 -13
- 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 +7 -7
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js +8 -13
- 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 +7 -7
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js +8 -13
- 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 +7 -7
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js +8 -13
- 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 +7 -7
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js +8 -13
- 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 +7 -7
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js +8 -13
- 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 +7 -7
- package/features/contentEntry/ListEntries/ListEntriesRepository.js +8 -13
- 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 +7 -7
- package/features/contentEntry/MoveEntry/MoveEntryRepository.js +8 -13
- 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 +7 -7
- package/features/contentEntry/PublishEntry/PublishEntryRepository.js +8 -14
- 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 +9 -7
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js +12 -15
- 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 +7 -7
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js +8 -14
- 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 +7 -7
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js +8 -14
- 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 +7 -7
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js +8 -14
- 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/ComponentMapGenerator/ComponentMapGenerator.d.ts +14 -0
- package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.js +32 -0
- package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/abstractions.d.ts +8 -0
- package/features/contentModel/ComponentMapGenerator/abstractions.js +5 -0
- package/features/contentModel/ComponentMapGenerator/abstractions.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/feature.d.ts +4 -0
- package/features/contentModel/ComponentMapGenerator/feature.js +11 -0
- package/features/contentModel/ComponentMapGenerator/feature.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/index.d.ts +2 -0
- package/features/contentModel/ComponentMapGenerator/index.js +2 -0
- package/features/contentModel/ContentModelFeature.js +6 -0
- package/features/contentModel/ContentModelFeature.js.map +1 -1
- package/features/contentModel/CreateModel/CreateModelRepository.d.ts +5 -6
- package/features/contentModel/CreateModel/CreateModelRepository.js +9 -12
- package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
- package/features/contentModel/CreateModel/CreateModelUseCase.js +2 -2
- package/features/contentModel/CreateModel/CreateModelUseCase.js.map +1 -1
- package/features/contentModel/CreateModel/abstractions.d.ts +1 -1
- package/features/contentModel/CreateModel/abstractions.js.map +1 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.d.ts +5 -6
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +9 -12
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromUseCase.js +2 -2
- package/features/contentModel/CreateModelFrom/CreateModelFromUseCase.js.map +1 -1
- package/features/contentModel/CreateModelFrom/abstractions.d.ts +1 -1
- package/features/contentModel/CreateModelFrom/abstractions.js.map +1 -1
- package/features/contentModel/DeleteModel/DeleteModelRepository.d.ts +4 -6
- package/features/contentModel/DeleteModel/DeleteModelRepository.js +6 -10
- 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/RefModelsGenerator/RefModelsGenerator.d.ts +19 -0
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.js +56 -0
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.js.map +1 -0
- package/features/contentModel/RefModelsGenerator/abstractions.d.ts +11 -0
- package/features/contentModel/RefModelsGenerator/abstractions.js +5 -0
- package/features/contentModel/RefModelsGenerator/abstractions.js.map +1 -0
- package/features/contentModel/RefModelsGenerator/feature.d.ts +4 -0
- package/features/contentModel/RefModelsGenerator/feature.js +11 -0
- package/features/contentModel/RefModelsGenerator/feature.js.map +1 -0
- package/features/contentModel/RefModelsGenerator/index.d.ts +2 -0
- package/features/contentModel/RefModelsGenerator/index.js +2 -0
- package/features/contentModel/UpdateModel/UpdateModelRepository.d.ts +7 -6
- package/features/contentModel/UpdateModel/UpdateModelRepository.js +12 -12
- package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
- package/features/contentModel/UpdateModel/UpdateModelUseCase.js +2 -2
- package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
- package/features/contentModel/UpdateModel/abstractions.d.ts +1 -1
- package/features/contentModel/UpdateModel/abstractions.js.map +1 -1
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.d.ts +16 -0
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js +53 -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 +11 -7
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js +19 -19
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js.map +1 -1
- package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.d.ts +6 -2
- package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.js +9 -8
- package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/CreateGroup/abstractions.d.ts +1 -1
- package/features/contentModelGroup/CreateGroup/abstractions.js.map +1 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.d.ts +9 -7
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js +12 -14
- 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 +7 -7
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js +9 -14
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.d.ts +3 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js +4 -5
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/abstractions.d.ts +1 -1
- package/features/contentModelGroup/UpdateGroup/abstractions.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/feature.js +2 -0
- package/features/graphql/feature.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/AssetToGraphQL.d.ts +26 -0
- package/features/graphql/fields/base/AssetToGraphQL.js +148 -0
- package/features/graphql/fields/base/AssetToGraphQL.js.map +1 -0
- package/features/graphql/fields/base/DynamicZoneToGraphQL.js +5 -1
- package/features/graphql/fields/base/DynamicZoneToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/ObjectToGraphQL.js +2 -2
- package/features/graphql/fields/base/ObjectToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/RefToGraphQL.d.ts +1 -1
- package/features/graphql/fields/base/RefToGraphQL.js +10 -18
- 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/abstractions.d.ts +10 -0
- package/features/modelBuilder/abstractions.js.map +1 -1
- package/features/modelBuilder/feature.js +2 -0
- package/features/modelBuilder/feature.js.map +1 -1
- package/features/modelBuilder/fields/AssetFieldType.d.ts +20 -0
- package/features/modelBuilder/fields/AssetFieldType.js +46 -0
- package/features/modelBuilder/fields/AssetFieldType.js.map +1 -0
- package/features/modelBuilder/fields/DataFieldBuilder.d.ts +54 -18
- package/features/modelBuilder/fields/DataFieldBuilder.js +3 -0
- package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -1
- package/features/modelBuilder/fields/DynamicZoneFieldType.d.ts +1 -0
- package/features/modelBuilder/fields/DynamicZoneFieldType.js +2 -6
- 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/resolveAssetUrl.d.ts +35 -0
- package/features/modelBuilder/fields/resolveAssetUrl.js +26 -0
- package/features/modelBuilder/fields/resolveAssetUrl.js.map +1 -0
- package/features/modelBuilder/index.d.ts +1 -1
- package/features/modelBuilder/models/BaseModelBuilder.d.ts +3 -1
- package/features/modelBuilder/models/BaseModelBuilder.js +7 -0
- package/features/modelBuilder/models/BaseModelBuilder.js.map +1 -1
- package/features/modelBuilder/models/PrivateModelBuilder.js +2 -1
- package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
- package/features/modelBuilder/models/PublicModelBuilder.js +2 -1
- package/features/modelBuilder/models/PublicModelBuilder.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/features/sortMapper/SortMapper.js +2 -5
- package/features/sortMapper/SortMapper.js.map +1 -1
- package/features/whereMapper/WhereMapper.js +7 -5
- package/features/whereMapper/WhereMapper.js.map +1 -1
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +3 -7
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
- 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 +5 -4
- package/graphql/schema/cms/getEntryResolver.js.map +1 -1
- package/graphql/schema/cms/getModelResolver.d.ts +35 -0
- package/graphql/schema/cms/getModelResolver.js +49 -0
- package/graphql/schema/cms/getModelResolver.js.map +1 -0
- package/graphql/schema/cms/helpers/buildFieldsSelection.js +9 -2
- package/graphql/schema/cms/helpers/buildFieldsSelection.js.map +1 -1
- package/graphql/schema/cms/helpers/expandFieldWildcards.d.ts +2 -0
- package/graphql/schema/cms/helpers/expandFieldWildcards.js +13 -0
- package/graphql/schema/cms/helpers/expandFieldWildcards.js.map +1 -0
- 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/index.d.ts +1 -0
- package/graphql/schema/cms/helpers/index.js +1 -0
- package/graphql/schema/cms/helpers.d.ts +1 -0
- package/graphql/schema/cms/helpers.js +1 -0
- package/graphql/schema/cms/listEntriesResolver.js +5 -4
- 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/getModel.d.ts +8 -0
- package/graphql/schema/cms/resolvers/getModel.js +18 -0
- package/graphql/schema/cms/resolvers/getModel.js.map +1 -0
- package/graphql/schema/cms/resolvers/index.d.ts +1 -0
- package/graphql/schema/cms/resolvers/index.js +1 -0
- 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 +2 -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 +6 -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 +68 -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 +23 -29
- 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/CmsModelPlugin.js +2 -1
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/plugins/index.d.ts +0 -1
- package/plugins/index.js +0 -1
- package/types/fields/dynamicZoneField.d.ts +1 -0
- package/types/model.d.ts +6 -0
- package/types/modelField.d.ts +2 -0
- 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/features/runtimeTenant/RuntimeTenant.d.ts +0 -13
- package/features/runtimeTenant/RuntimeTenant.js +0 -22
- package/features/runtimeTenant/RuntimeTenant.js.map +0 -1
- package/features/runtimeTenant/abstractions.d.ts +0 -11
- package/features/runtimeTenant/abstractions.js +0 -5
- package/features/runtimeTenant/abstractions.js.map +0 -1
- package/features/runtimeTenant/index.d.ts +0 -2
- package/features/runtimeTenant/index.js +0 -2
- 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":"crud/contentModel.crud.js","sources":["../../src/crud/contentModel.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsContext, CmsModel, CmsModelContext, ICmsModelListParams } from \"~/types/index.js\";\nimport { CreateModelUseCase } from \"~/features/contentModel/CreateModel/index.js\";\nimport { CreateModelFromUseCase } from \"~/features/contentModel/CreateModelFrom/index.js\";\nimport { UpdateModelUseCase } from \"~/features/contentModel/UpdateModel/index.js\";\nimport { DeleteModelUseCase } from \"~/features/contentModel/DeleteModel/index.js\";\nimport { GetModelUseCase } from \"~/features/contentModel/GetModel/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\nimport { createMemoryCache } from \"~/utils/index.js\";\nimport {\n CmsModelFieldToAstConverterFromPlugins,\n CmsModelToAstConverter\n} from \"~/utils/contentModelAst/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"~/features/graphql/index.js\";\n\nexport interface CreateModelsCrudParams {\n context: CmsContext;\n}\n\nexport const createModelsCrud = (params: CreateModelsCrudParams): CmsModelContext => {\n const { context } = params;\n\n const listFilteredModelsCache = createMemoryCache<Promise<CmsModel[]>>();\n const listDatabaseModelsCache = createMemoryCache<Promise<CmsModel[]>>();\n const clearModelsCache = (): void => {\n listDatabaseModelsCache.clear();\n listFilteredModelsCache.clear();\n };\n\n const fieldTypePlugins = context.container.resolve(CmsModelFieldToGraphQLRegistry).getAll();\n\n const getModelToAstConverter = () => {\n return new CmsModelToAstConverter(\n new CmsModelFieldToAstConverterFromPlugins(fieldTypePlugins)\n );\n };\n\n /**\n * The list models cache is a key -> Promise pair so it the listModels() can be called multiple times but executed only once.\n *\n * We always fetch the plugins and database models separately.\n * Then we combine them and run access filtering on them\n */\n const listModels = async (input?: ICmsModelListParams) => {\n return
|
|
1
|
+
{"version":3,"file":"crud/contentModel.crud.js","sources":["../../src/crud/contentModel.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { BenchmarkAbstraction } from \"@webiny/api\";\nimport type { CmsContext, CmsModel, CmsModelContext, ICmsModelListParams } from \"~/types/index.js\";\nimport { CreateModelUseCase } from \"~/features/contentModel/CreateModel/index.js\";\nimport { CreateModelFromUseCase } from \"~/features/contentModel/CreateModelFrom/index.js\";\nimport { UpdateModelUseCase } from \"~/features/contentModel/UpdateModel/index.js\";\nimport { DeleteModelUseCase } from \"~/features/contentModel/DeleteModel/index.js\";\nimport { GetModelUseCase } from \"~/features/contentModel/GetModel/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\nimport { createMemoryCache } from \"~/utils/index.js\";\nimport {\n CmsModelFieldToAstConverterFromPlugins,\n CmsModelToAstConverter\n} from \"~/utils/contentModelAst/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"~/features/graphql/index.js\";\n\nexport interface CreateModelsCrudParams {\n context: CmsContext;\n}\n\nexport const createModelsCrud = (params: CreateModelsCrudParams): CmsModelContext => {\n const { context } = params;\n const benchmark = context.container.resolve(BenchmarkAbstraction);\n\n const listFilteredModelsCache = createMemoryCache<Promise<CmsModel[]>>();\n const listDatabaseModelsCache = createMemoryCache<Promise<CmsModel[]>>();\n const clearModelsCache = (): void => {\n listDatabaseModelsCache.clear();\n listFilteredModelsCache.clear();\n };\n\n const fieldTypePlugins = context.container.resolve(CmsModelFieldToGraphQLRegistry).getAll();\n\n const getModelToAstConverter = () => {\n return new CmsModelToAstConverter(\n new CmsModelFieldToAstConverterFromPlugins(fieldTypePlugins)\n );\n };\n\n /**\n * The list models cache is a key -> Promise pair so it the listModels() can be called multiple times but executed only once.\n *\n * We always fetch the plugins and database models separately.\n * Then we combine them and run access filtering on them\n */\n const listModels = async (input?: ICmsModelListParams) => {\n return benchmark.measure(\"headlessCms.crud.models.listModels\", async () => {\n // Delegate to new ListModels use case\n const useCase = context.container.resolve(ListModelsUseCase);\n const result = await useCase.execute(input);\n\n if (result.isFail()) {\n throw new WebinyError(result.error.message, result.error.code, result.error.data);\n }\n\n return result.value;\n });\n };\n\n const getModel = async (modelId: string): Promise<CmsModel> => {\n return benchmark.measure(\"headlessCms.crud.models.getModel\", async () => {\n // Delegate to new GetModel use case\n const useCase = context.container.resolve(GetModelUseCase);\n const result = await useCase.execute(modelId);\n\n if (result.isFail()) {\n throw new WebinyError(result.error.message, result.error.code, result.error.data);\n }\n\n return result.value;\n });\n };\n\n /**\n * CRUD methods\n */\n const createModel: CmsModelContext[\"createModel\"] = async input => {\n // Delegate to new CreateModel use case\n const useCase = context.container.resolve(CreateModelUseCase);\n const result = await useCase.execute(input);\n\n if (result.isFail()) {\n throw new WebinyError(result.error.message, result.error.code, result.error.data);\n }\n\n return result.value;\n };\n const updateModel: CmsModelContext[\"updateModel\"] = async (modelId, input) => {\n // Delegate to new UpdateModel use case\n const useCase = context.container.resolve(UpdateModelUseCase);\n const result = await useCase.execute(modelId, input);\n\n if (result.isFail()) {\n throw new WebinyError(result.error.message, result.error.code, result.error.data);\n }\n\n return result.value;\n };\n\n const createModelFrom: CmsModelContext[\"createModelFrom\"] = async (modelId, input) => {\n // Delegate to new CreateModelFrom use case\n const useCase = context.container.resolve(CreateModelFromUseCase);\n const result = await useCase.execute(modelId, input);\n\n if (result.isFail()) {\n throw new WebinyError(result.error.message, result.error.code, result.error.data);\n }\n\n return result.value;\n };\n const deleteModel: CmsModelContext[\"deleteModel\"] = async modelId => {\n // Delegate to new DeleteModel use case\n const useCase = context.container.resolve(DeleteModelUseCase);\n const result = await useCase.execute(modelId);\n\n if (result.isFail()) {\n throw new WebinyError(result.error.message, result.error.code, result.error.data);\n }\n };\n\n return {\n clearModelsCache,\n getModel,\n getModelToAstConverter,\n listModels,\n async createModel(input) {\n return benchmark.measure(\"headlessCms.crud.models.createModel\", async () => {\n return createModel(input);\n });\n },\n\n async createModelFrom(modelId, userInput) {\n return benchmark.measure(\"headlessCms.crud.models.createModelFrom\", async () => {\n return createModelFrom(modelId, userInput);\n });\n },\n async updateModel(modelId, input) {\n return benchmark.measure(\"headlessCms.crud.models.updateModel\", async () => {\n return updateModel(modelId, input);\n });\n },\n async deleteModel(modelId) {\n return benchmark.measure(\"headlessCms.crud.models.deleteModel\", async () => {\n return deleteModel(modelId);\n });\n }\n };\n};\n"],"names":["createModelsCrud","params","context","benchmark","BenchmarkAbstraction","listFilteredModelsCache","createMemoryCache","listDatabaseModelsCache","clearModelsCache","fieldTypePlugins","CmsModelFieldToGraphQLRegistry","getModelToAstConverter","CmsModelToAstConverter","CmsModelFieldToAstConverterFromPlugins","listModels","input","useCase","ListModelsUseCase","result","WebinyError","getModel","modelId","GetModelUseCase","createModel","CreateModelUseCase","updateModel","UpdateModelUseCase","createModelFrom","CreateModelFromUseCase","deleteModel","DeleteModelUseCase","userInput"],"mappings":";;;;;;;;;;;AAoBO,MAAMA,mBAAmB,CAACC;IAC7B,MAAM,EAAEC,OAAO,EAAE,GAAGD;IACpB,MAAME,YAAYD,QAAQ,SAAS,CAAC,OAAO,CAACE;IAE5C,MAAMC,0BAA0BC;IAChC,MAAMC,0BAA0BD;IAChC,MAAME,mBAAmB;QACrBD,wBAAwB,KAAK;QAC7BF,wBAAwB,KAAK;IACjC;IAEA,MAAMI,mBAAmBP,QAAQ,SAAS,CAAC,OAAO,CAACQ,gCAAgC,MAAM;IAEzF,MAAMC,yBAAyB,IACpB,IAAIC,uBACP,IAAIC,uCAAuCJ;IAUnD,MAAMK,aAAa,OAAOC,QACfZ,UAAU,OAAO,CAAC,sCAAsC;YAE3D,MAAMa,UAAUd,QAAQ,SAAS,CAAC,OAAO,CAACe;YAC1C,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACD;YAErC,IAAIG,OAAO,MAAM,IACb,MAAM,IAAIC,MAAYD,OAAO,KAAK,CAAC,OAAO,EAAEA,OAAO,KAAK,CAAC,IAAI,EAAEA,OAAO,KAAK,CAAC,IAAI;YAGpF,OAAOA,OAAO,KAAK;QACvB;IAGJ,MAAME,WAAW,OAAOC,UACblB,UAAU,OAAO,CAAC,oCAAoC;YAEzD,MAAMa,UAAUd,QAAQ,SAAS,CAAC,OAAO,CAACoB;YAC1C,MAAMJ,SAAS,MAAMF,QAAQ,OAAO,CAACK;YAErC,IAAIH,OAAO,MAAM,IACb,MAAM,IAAIC,MAAYD,OAAO,KAAK,CAAC,OAAO,EAAEA,OAAO,KAAK,CAAC,IAAI,EAAEA,OAAO,KAAK,CAAC,IAAI;YAGpF,OAAOA,OAAO,KAAK;QACvB;IAMJ,MAAMK,cAA8C,OAAMR;Q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AAOZ,UAAU,OAAO,CAAC,uCAAuC,UACrDoB,YAAYR;QAE3B;QAEA,MAAM,iBAAgBM,OAAO,EAAEU,SAAS;YACpC,OAAO5B,UAAU,OAAO,CAAC,2CAA2C,UACzDwB,gBAAgBN,SAASU;QAExC;QACA,MAAM,aAAYV,OAAO,EAAEN,KAAK;YAC5B,OAAOZ,UAAU,OAAO,CAAC,uCAAuC,UACrDsB,YAAYJ,SAASN;QAEpC;QACA,MAAM,aAAYM,OAAO;YACrB,OAAOlB,UAAU,OAAO,CAAC,uCAAuC,UACrD0B,YAAYR;QAE3B;IACJ;AACJ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _webiny_error from "@webiny/error";
|
|
2
|
+
import { BenchmarkAbstraction } from "@webiny/api";
|
|
2
3
|
import { createMemoryCache } from "../utils/index.js";
|
|
3
4
|
import { GetGroupUseCase } from "../features/contentModelGroup/GetGroup/index.js";
|
|
4
5
|
import { ListGroupsUseCase } from "../features/contentModelGroup/ListGroups/index.js";
|
|
@@ -7,6 +8,7 @@ import { UpdateGroupUseCase } from "../features/contentModelGroup/UpdateGroup/in
|
|
|
7
8
|
import { DeleteGroupUseCase } from "../features/contentModelGroup/DeleteGroup/index.js";
|
|
8
9
|
const createModelGroupsCrud = (params)=>{
|
|
9
10
|
const { context } = params;
|
|
11
|
+
const benchmark = context.container.resolve(BenchmarkAbstraction);
|
|
10
12
|
const listDatabaseGroupsCache = createMemoryCache();
|
|
11
13
|
const listFilteredDatabaseGroupsCache = createMemoryCache();
|
|
12
14
|
const listPluginGroupsCache = createMemoryCache();
|
|
@@ -62,11 +64,11 @@ const createModelGroupsCrud = (params)=>{
|
|
|
62
64
|
};
|
|
63
65
|
return {
|
|
64
66
|
clearGroupsCache,
|
|
65
|
-
getGroup: async (id)=>
|
|
66
|
-
listGroups: async (params)=>
|
|
67
|
-
createGroup: async (input)=>
|
|
68
|
-
updateGroup: async (id, input)=>
|
|
69
|
-
deleteGroup: async (id)=>
|
|
67
|
+
getGroup: async (id)=>benchmark.measure("headlessCms.crud.groups.getGroup", async ()=>getGroup(id)),
|
|
68
|
+
listGroups: async (params)=>benchmark.measure("headlessCms.crud.groups.listGroups", async ()=>listGroups()),
|
|
69
|
+
createGroup: async (input)=>benchmark.measure("headlessCms.crud.groups.createGroup", async ()=>createGroup(input)),
|
|
70
|
+
updateGroup: async (id, input)=>benchmark.measure("headlessCms.crud.groups.updateGroup", async ()=>updateGroup(id, input)),
|
|
71
|
+
deleteGroup: async (id)=>benchmark.measure("headlessCms.crud.groups.deleteGroup", async ()=>deleteGroup(id))
|
|
70
72
|
};
|
|
71
73
|
};
|
|
72
74
|
export { createModelGroupsCrud };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud/contentModelGroup.crud.js","sources":["../../src/crud/contentModelGroup.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsContext, CmsGroup, CmsGroupContext } from \"~/types/index.js\";\nimport { createMemoryCache } from \"~/utils/index.js\";\nimport { GetGroupUseCase } from \"~/features/contentModelGroup/GetGroup/index.js\";\nimport { ListGroupsUseCase } from \"~/features/contentModelGroup/ListGroups/index.js\";\nimport { CreateGroupUseCase } from \"~/features/contentModelGroup/CreateGroup/index.js\";\nimport { UpdateGroupUseCase } from \"~/features/contentModelGroup/UpdateGroup/index.js\";\nimport { DeleteGroupUseCase } from \"~/features/contentModelGroup/DeleteGroup/index.js\";\n\nexport interface CreateModelGroupsCrudParams {\n context: CmsContext;\n}\n\nexport const createModelGroupsCrud = (params: CreateModelGroupsCrudParams): CmsGroupContext => {\n const { context } = params;\n\n const listDatabaseGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const listFilteredDatabaseGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const listPluginGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const clearGroupsCache = (): void => {\n listPluginGroupsCache.clear();\n listDatabaseGroupsCache.clear();\n listFilteredDatabaseGroupsCache.clear();\n };\n\n /**\n * CRUD Methods\n */\n const getGroup: CmsGroupContext[\"getGroup\"] = async id => {\n const useCase = context.container.resolve(GetGroupUseCase);\n const result = await useCase.execute(id);\n\n if (result.isFail()) {\n const error = result.error;\n throw new WebinyError(error.message, error.code, error.data);\n }\n\n return result.value;\n };\n\n const listGroups: CmsGroupContext[\"listGroups\"] = async () => {\n const useCase = context.container.resolve(ListGroupsUseCase);\n const result = await useCase.execute();\n\n if (result.isFail()) {\n const error = result.error;\n\n throw new WebinyError(error.message, error.code, error.data);\n }\n\n return result.value;\n };\n\n const createGroup: CmsGroupContext[\"createGroup\"] = async input => {\n const useCase = context.container.resolve(CreateGroupUseCase);\n const result = await useCase.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n throw new WebinyError(error.message, error.code, error.data);\n }\n\n return result.value;\n };\n const updateGroup: CmsGroupContext[\"updateGroup\"] = async (id, input) => {\n const useCase = context.container.resolve(UpdateGroupUseCase);\n const result = await useCase.execute(id, input);\n\n if (result.isFail()) {\n const error = result.error;\n throw new WebinyError(error.message, error.code, error.data);\n }\n\n return result.value;\n };\n const deleteGroup: CmsGroupContext[\"deleteGroup\"] = async id => {\n const useCase = context.container.resolve(DeleteGroupUseCase);\n const result = await useCase.execute(id);\n\n if (result.isFail()) {\n const error = result.error;\n throw new WebinyError(error.message, error.code, error.data);\n }\n\n return true;\n };\n\n return {\n clearGroupsCache,\n getGroup: async id => {\n return
|
|
1
|
+
{"version":3,"file":"crud/contentModelGroup.crud.js","sources":["../../src/crud/contentModelGroup.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { BenchmarkAbstraction } from \"@webiny/api\";\nimport type { CmsContext, CmsGroup, CmsGroupContext } from \"~/types/index.js\";\nimport { createMemoryCache } from \"~/utils/index.js\";\nimport { GetGroupUseCase } from \"~/features/contentModelGroup/GetGroup/index.js\";\nimport { ListGroupsUseCase } from \"~/features/contentModelGroup/ListGroups/index.js\";\nimport { CreateGroupUseCase } from \"~/features/contentModelGroup/CreateGroup/index.js\";\nimport { UpdateGroupUseCase } from \"~/features/contentModelGroup/UpdateGroup/index.js\";\nimport { DeleteGroupUseCase } from \"~/features/contentModelGroup/DeleteGroup/index.js\";\n\nexport interface CreateModelGroupsCrudParams {\n context: CmsContext;\n}\n\nexport const createModelGroupsCrud = (params: CreateModelGroupsCrudParams): CmsGroupContext => {\n const { context } = params;\n const benchmark = context.container.resolve(BenchmarkAbstraction);\n\n const listDatabaseGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const listFilteredDatabaseGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const listPluginGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const clearGroupsCache = (): void => {\n listPluginGroupsCache.clear();\n listDatabaseGroupsCache.clear();\n listFilteredDatabaseGroupsCache.clear();\n };\n\n /**\n * CRUD Methods\n */\n const getGroup: CmsGroupContext[\"getGroup\"] = async id => {\n const useCase = context.container.resolve(GetGroupUseCase);\n const result = await useCase.execute(id);\n\n if (result.isFail()) {\n const error = result.error;\n throw new WebinyError(error.message, error.code, error.data);\n }\n\n return result.value;\n };\n\n const listGroups: CmsGroupContext[\"listGroups\"] = async () => {\n const useCase = context.container.resolve(ListGroupsUseCase);\n const result = await useCase.execute();\n\n if (result.isFail()) {\n const error = result.error;\n\n throw new WebinyError(error.message, error.code, error.data);\n }\n\n return result.value;\n };\n\n const createGroup: CmsGroupContext[\"createGroup\"] = async input => {\n const useCase = context.container.resolve(CreateGroupUseCase);\n const result = await useCase.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n throw new WebinyError(error.message, error.code, error.data);\n }\n\n return result.value;\n };\n const updateGroup: CmsGroupContext[\"updateGroup\"] = async (id, input) => {\n const useCase = context.container.resolve(UpdateGroupUseCase);\n const result = await useCase.execute(id, input);\n\n if (result.isFail()) {\n const error = result.error;\n throw new WebinyError(error.message, error.code, error.data);\n }\n\n return result.value;\n };\n const deleteGroup: CmsGroupContext[\"deleteGroup\"] = async id => {\n const useCase = context.container.resolve(DeleteGroupUseCase);\n const result = await useCase.execute(id);\n\n if (result.isFail()) {\n const error = result.error;\n throw new WebinyError(error.message, error.code, error.data);\n }\n\n return true;\n };\n\n return {\n clearGroupsCache,\n getGroup: async id => {\n return benchmark.measure(\"headlessCms.crud.groups.getGroup\", async () => {\n return getGroup(id);\n });\n },\n listGroups: async params => {\n return benchmark.measure(\"headlessCms.crud.groups.listGroups\", async () => {\n return listGroups(params);\n });\n },\n createGroup: async input => {\n return benchmark.measure(\"headlessCms.crud.groups.createGroup\", async () => {\n return createGroup(input);\n });\n },\n updateGroup: async (id, input) => {\n return benchmark.measure(\"headlessCms.crud.groups.updateGroup\", async () => {\n return updateGroup(id, input);\n });\n },\n deleteGroup: async id => {\n return benchmark.measure(\"headlessCms.crud.groups.deleteGroup\", async () => {\n return deleteGroup(id);\n });\n }\n };\n};\n"],"names":["createModelGroupsCrud","params","context","benchmark","BenchmarkAbstraction","listDatabaseGroupsCache","createMemoryCache","listFilteredDatabaseGroupsCache","listPluginGroupsCache","clearGroupsCache","getGroup","id","useCase","GetGroupUseCase","result","error","WebinyError","listGroups","ListGroupsUseCase","createGroup","input","CreateGroupUseCase","updateGroup","UpdateGroupUseCase","deleteGroup","DeleteGroupUseCase"],"mappings":";;;;;;;;AAcO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,OAAO,EAAE,GAAGD;IACpB,MAAME,YAAYD,QAAQ,SAAS,CAAC,OAAO,CAACE;IAE5C,MAAMC,0BAA0BC;IAChC,MAAMC,kCAAkCD;IACxC,MAAME,wBAAwBF;IAC9B,MAAMG,mBAAmB;QACrBD,sBAAsB,KAAK;QAC3BH,wBAAwB,KAAK;QAC7BE,gCAAgC,KAAK;IACzC;IAKA,MAAMG,WAAwC,OAAMC;QAChD,MAAMC,UAAUV,QAAQ,SAAS,CAAC,OAAO,CAACW;QAC1C,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACD;QAErC,IAAIG,OAAO,MAAM,IA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AM,IAAI;YACjB,MAAMC,QAAQD,OAAO,KAAK;YAC1B,MAAM,IAAIE,cAAYD,MAAM,OAAO,EAAEA,MAAM,IAAI,EAAEA,MAAM,IAAI;QAC/D;QAEA,OAAO;IACX;IAEA,OAAO;QACHN;QACA,UAAU,OAAME,KACLR,UAAU,OAAO,CAAC,oCAAoC,UAClDO,SAASC;QAGxB,YAAY,OAAMV,SACPE,UAAU,OAAO,CAAC,sCAAsC,UACpDc;QAGf,aAAa,OAAMG,QACRjB,UAAU,OAAO,CAAC,uCAAuC,UACrDgB,YAAYC;QAG3B,aAAa,OAAOT,IAAIS,QACbjB,UAAU,OAAO,CAAC,uCAAuC,UACrDmB,YAAYX,IAAIS;QAG/B,aAAa,OAAMT,KACRR,UAAU,OAAO,CAAC,uCAAuC,UACrDqB,YAAYb;IAG/B;AACJ"}
|
|
@@ -135,6 +135,7 @@ export declare const createModelCreateValidation: () => zod.ZodObject<{
|
|
|
135
135
|
descriptionFieldId: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>;
|
|
136
136
|
imageFieldId: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>;
|
|
137
137
|
defaultFields: zod.ZodOptional<zod.ZodNullable<zod.ZodBoolean>>;
|
|
138
|
+
settings: zod.ZodDefault<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodObject<{}, zod.core.$loose>>>>>;
|
|
138
139
|
}, zod.core.$strip>;
|
|
139
140
|
export declare const createModelUpdateValidation: () => zod.ZodObject<{
|
|
140
141
|
name: zod.ZodOptional<zod.ZodString>;
|
|
@@ -270,6 +271,7 @@ export declare const createModelUpdateValidation: () => zod.ZodObject<{
|
|
|
270
271
|
descriptionFieldId: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>;
|
|
271
272
|
imageFieldId: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>;
|
|
272
273
|
tags: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
|
|
274
|
+
settings: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodObject<{}, zod.core.$loose>>>>;
|
|
273
275
|
}, zod.core.$strip>;
|
|
274
276
|
export declare const createModelCreateFromValidation: () => zod.ZodObject<{
|
|
275
277
|
name: zod.ZodString;
|
|
@@ -119,7 +119,8 @@ const createModelCreateValidation = ()=>zod.object({
|
|
|
119
119
|
titleFieldId: optionalShortString.nullish(),
|
|
120
120
|
descriptionFieldId: optionalShortString.nullish(),
|
|
121
121
|
imageFieldId: optionalShortString.nullish(),
|
|
122
|
-
defaultFields: zod.boolean().nullish()
|
|
122
|
+
defaultFields: zod.boolean().nullish(),
|
|
123
|
+
settings: zod.looseObject({}).optional().nullish().default({})
|
|
123
124
|
});
|
|
124
125
|
const createModelUpdateValidation = ()=>zod.object({
|
|
125
126
|
name: optionalShortString,
|
|
@@ -137,7 +138,8 @@ const createModelUpdateValidation = ()=>zod.object({
|
|
|
137
138
|
titleFieldId: optionalShortString.nullish(),
|
|
138
139
|
descriptionFieldId: optionalShortString.nullish(),
|
|
139
140
|
imageFieldId: optionalShortString.nullish(),
|
|
140
|
-
tags: zod.array(shortString).optional()
|
|
141
|
+
tags: zod.array(shortString).optional(),
|
|
142
|
+
settings: zod.looseObject({}).optional().nullish()
|
|
141
143
|
});
|
|
142
144
|
const createModelCreateFromValidation = ()=>zod.object({
|
|
143
145
|
name: shortString,
|
|
@@ -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;IACh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AO;QACzC,eAAeH,IAAI,OAAO,GAAG,OAAO;IACxC;AAGG,MAAMsB,8BAA8B,IAChCtB,IAAI,MAAM,CAAC;QACd,MAAMG;QACN,iBAAiBA,oBAAoB,WAAW,CAAC,CAACK,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\", \"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 settings: zod.looseObject({}).optional().nullish().default({})\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 settings: zod.looseObject({}).optional().nullish()\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,G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,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC;IAChE;AAGG,MAAMsB,8BAA8B,IAChCtB,IAAI,MAAM,CAAC;QACd,MAAMG;QACN,iBAAiBA,oBAAoB,WAAW,CAAC,CAACK,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;QACrC,UAAUD,IAAI,WAAW,CAAC,CAAC,GAAG,QAAQ,GAAG,OAAO;IACpD;AAGG,MAAMuB,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,E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B,MAAM,EAAEnC,KAAK,EAAEoD,QAAQ,EAAElB,OAAO,EAAE,GAAGf;IAC7C,MAAM,EAAEkC,YAAY,EAAEC,kBAAkB,EAAEC,YAAY,EAAE,GAAGvD;IAK3D,MAAM,EAAEgB,SAAS,EAAE,EAAE,GAAGhB;IAMxB,MAAMwD,gBAAgBtB,QAAQ,SAAS,CAAC,OAAO,CAACuB;IAChD,MAAMC,UAAUxB,QAAQ,SAAS,CAAC,UAAU,CAACyB;IAE7CzC,eAAe;QACXF;QACA,gBAAgBoC,UAAU,UAAU,EAAE;QACtC,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,CA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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,OAAOkD,mBAAmBjD;gBAC9B;YACJ;QACJ;IACJ;IAEAD,MAAM,YAAY,GAAGkE,4BAA4BlD,QAAQwC;IACzDxD,MAAM,kBAAkB,GAAGmE,kCAAkCnD,QAAQyC;IACrEzD,MAAM,YAAY,GAAGoE,4BAA4BpD,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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