@webiny/api-headless-cms 0.0.0-unstable.a4f3e4ea8b → 0.0.0-unstable.a85ef555b2
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/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 +168 -0
- package/HeadlessCmsFeature.js.map +1 -0
- package/createCmsRoute.d.ts +24 -0
- package/createCmsRoute.js +47 -0
- package/createCmsRoute.js.map +1 -0
- package/crud/contentEntry/entryDataValidation.js +14 -7
- 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/domain/contentModel/schemas.d.ts +2 -0
- package/domain/contentModel/schemas.js +1 -0
- package/domain/contentModel/schemas.js.map +1 -1
- package/domain/contentModel/validation/dateExpressions.d.ts +6 -0
- package/domain/contentModel/validation/dateExpressions.js +27 -0
- package/domain/contentModel/validation/dateExpressions.js.map +1 -0
- package/domain/contentModel/validation/modelFields.js +23 -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/entry.d.ts +5 -0
- package/exports/api/cms/entry.js +5 -0
- package/exports/api/cms/storage.d.ts +0 -1
- package/exports/api/cms/storage.js +0 -1
- package/features/ai/DescribeContentModelTool.d.ts +60 -0
- package/features/ai/DescribeContentModelTool.js +69 -0
- package/features/ai/DescribeContentModelTool.js.map +1 -0
- package/features/ai/ListContentModelsTool.d.ts +46 -0
- package/features/ai/ListContentModelsTool.js +53 -0
- package/features/ai/ListContentModelsTool.js.map +1 -0
- package/features/ai/QueryEntriesTool.d.ts +80 -0
- package/features/ai/QueryEntriesTool.js +99 -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 +8 -4
- package/features/contentEntry/ContentEntriesFeature.js.map +1 -1
- package/features/contentEntry/CreateEntry/CreateEntryRepository.d.ts +6 -4
- package/features/contentEntry/CreateEntry/CreateEntryRepository.js +7 -8
- package/features/contentEntry/CreateEntry/CreateEntryRepository.js.map +1 -1
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.d.ts +5 -3
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js +4 -5
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.d.ts +6 -4
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js +7 -8
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.d.ts +5 -5
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js +8 -17
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/abstractions.d.ts +2 -0
- package/features/contentEntry/CreateEntryRevisionFrom/abstractions.js.map +1 -1
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.d.ts +6 -4
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js +7 -8
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.d.ts +5 -3
- package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js +4 -5
- package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.d.ts +6 -4
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js +9 -11
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.d.ts +5 -3
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js +4 -5
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.d.ts +3 -3
- package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js +5 -5
- package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js.map +1 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.d.ts +6 -4
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js +7 -8
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.d.ts +5 -3
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js +4 -5
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js.map +1 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.d.ts +6 -4
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js +8 -9
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js.map +1 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.d.ts +5 -3
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js +13 -13
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js.map +1 -1
- package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.d.ts +17 -0
- package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.js +83 -0
- package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.js.map +1 -0
- package/features/contentEntry/DuplicateEntry/abstractions.d.ts +47 -0
- package/features/contentEntry/DuplicateEntry/abstractions.js +5 -0
- package/features/contentEntry/DuplicateEntry/abstractions.js.map +1 -0
- package/features/contentEntry/DuplicateEntry/events.d.ts +41 -0
- package/features/contentEntry/DuplicateEntry/events.js +32 -0
- package/features/contentEntry/DuplicateEntry/events.js.map +1 -0
- package/features/contentEntry/{UpdateRevision → DuplicateEntry}/feature.d.ts +1 -1
- package/features/contentEntry/DuplicateEntry/feature.js +11 -0
- package/features/contentEntry/DuplicateEntry/feature.js.map +1 -0
- package/features/contentEntry/DuplicateEntry/index.d.ts +2 -0
- package/features/contentEntry/DuplicateEntry/index.js +2 -0
- package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.d.ts +7 -0
- package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.js +12 -0
- package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.js.map +1 -0
- package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.d.ts +10 -0
- package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.js +25 -0
- package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.js.map +1 -0
- package/features/contentEntry/EntryEventPublisher/abstractions.d.ts +16 -0
- package/features/contentEntry/EntryEventPublisher/abstractions.js +5 -0
- package/features/contentEntry/EntryEventPublisher/abstractions.js.map +1 -0
- package/features/contentEntry/EntryEventPublisher/feature.d.ts +4 -0
- package/features/contentEntry/EntryEventPublisher/feature.js +11 -0
- package/features/contentEntry/EntryEventPublisher/feature.js.map +1 -0
- package/features/contentEntry/EntryEventPublisher/index.d.ts +2 -0
- package/features/contentEntry/EntryEventPublisher/index.js +2 -0
- package/features/contentEntry/EntrySystemField/abstractions.d.ts +14 -0
- package/features/contentEntry/EntrySystemField/abstractions.js +5 -0
- package/features/contentEntry/EntrySystemField/abstractions.js.map +1 -0
- package/features/contentEntry/EntrySystemField/index.d.ts +1 -0
- package/features/contentEntry/EntrySystemField/index.js +1 -0
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.d.ts +6 -4
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js +7 -8
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.d.ts +3 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js +2 -3
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetEntry/GetEntryUseCase.d.ts +3 -1
- package/features/contentEntry/GetEntry/GetEntryUseCase.js +2 -3
- package/features/contentEntry/GetEntry/GetEntryUseCase.js.map +1 -1
- package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.js +2 -3
- package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.d.ts +6 -4
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js +8 -9
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js +2 -3
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js +2 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.d.ts +6 -4
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js +8 -9
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.js +1 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.d.ts +3 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js +2 -3
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.d.ts +6 -4
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js +7 -8
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.d.ts +6 -4
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js +8 -9
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.d.ts +3 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js +2 -3
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.d.ts +6 -4
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js +8 -9
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js +2 -3
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.d.ts +6 -4
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js +7 -8
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js.map +1 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.d.ts +3 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js +1 -3
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js.map +1 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.d.ts +6 -4
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js +8 -9
- 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/GetUniqueFieldValues/GetUniqueFieldValuesRepository.d.ts +6 -4
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js +7 -8
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js.map +1 -1
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.d.ts +6 -2
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js +8 -6
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.js +1 -3
- package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListEntriesRepository.d.ts +6 -4
- package/features/contentEntry/ListEntries/ListEntriesRepository.js +8 -9
- package/features/contentEntry/ListEntries/ListEntriesRepository.js.map +1 -1
- package/features/contentEntry/ListEntries/ListEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/ListEntries/ListEntriesUseCase.js +2 -3
- package/features/contentEntry/ListEntries/ListEntriesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.js +1 -3
- package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.d.ts +3 -1
- package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.js +1 -3
- package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.js.map +1 -1
- package/features/contentEntry/MoveEntry/MoveEntryRepository.d.ts +6 -4
- package/features/contentEntry/MoveEntry/MoveEntryRepository.js +7 -8
- package/features/contentEntry/MoveEntry/MoveEntryRepository.js.map +1 -1
- package/features/contentEntry/MoveEntry/MoveEntryUseCase.d.ts +5 -3
- package/features/contentEntry/MoveEntry/MoveEntryUseCase.js +13 -7
- package/features/contentEntry/MoveEntry/MoveEntryUseCase.js.map +1 -1
- package/features/contentEntry/PublishEntry/PublishEntryRepository.d.ts +7 -5
- package/features/contentEntry/PublishEntry/PublishEntryRepository.js +8 -9
- package/features/contentEntry/PublishEntry/PublishEntryRepository.js.map +1 -1
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.d.ts +7 -7
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.js +13 -16
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/PublishEntry/abstractions.d.ts +8 -1
- package/features/contentEntry/PublishEntry/abstractions.js.map +1 -1
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.d.ts +8 -4
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js +11 -9
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js.map +1 -1
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.d.ts +5 -3
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js +7 -6
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.d.ts +6 -4
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js +7 -8
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js.map +1 -1
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.d.ts +5 -3
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js +4 -5
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js.map +1 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.d.ts +6 -4
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js +7 -8
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js.map +1 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.d.ts +5 -3
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js +7 -6
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.d.ts +7 -5
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js +7 -8
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js.map +1 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.d.ts +5 -3
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js +7 -6
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js.map +1 -1
- package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.d.ts +19 -0
- package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.js +70 -0
- package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.js.map +1 -0
- package/features/contentEntry/UpdateEntrySystem/abstractions.d.ts +24 -0
- package/features/contentEntry/UpdateEntrySystem/abstractions.js +5 -0
- package/features/contentEntry/UpdateEntrySystem/abstractions.js.map +1 -0
- package/features/contentEntry/UpdateEntrySystem/events.d.ts +29 -0
- package/features/contentEntry/UpdateEntrySystem/events.js +23 -0
- package/features/contentEntry/UpdateEntrySystem/events.js.map +1 -0
- package/features/contentEntry/UpdateEntrySystem/feature.d.ts +4 -0
- package/features/contentEntry/UpdateEntrySystem/feature.js +11 -0
- package/features/contentEntry/UpdateEntrySystem/feature.js.map +1 -0
- package/features/contentEntry/UpdateEntrySystem/index.d.ts +2 -0
- package/features/contentEntry/UpdateEntrySystem/index.js +2 -0
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.d.ts +6 -4
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js +6 -7
- 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 +1 -3
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.d.ts +8 -4
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js +41 -16
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/abstractions.d.ts +17 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/abstractions.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.d.ts +8 -4
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js +23 -18
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/abstractions.d.ts +15 -1
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/abstractions.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.d.ts +8 -4
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js +18 -15
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/abstractions.d.ts +13 -1
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/abstractions.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.d.ts +9 -7
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js +18 -20
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.d.ts +14 -2
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.js.map +1 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.d.ts +8 -4
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js +67 -31
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.d.ts +15 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.js.map +1 -1
- package/features/contentEntry/entryDataFactories/hasEntryContentChanged.d.ts +24 -0
- package/features/contentEntry/entryDataFactories/hasEntryContentChanged.js +13 -0
- package/features/contentEntry/entryDataFactories/hasEntryContentChanged.js.map +1 -0
- 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 +3 -3
- package/features/contentModel/DeleteModel/DeleteModelRepository.js +5 -5
- package/features/contentModel/DeleteModel/DeleteModelRepository.js.map +1 -1
- package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.d.ts +9 -3
- package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js +36 -18
- package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js.map +1 -1
- package/features/contentModel/ModelToAstConverter/ModelToAstConverter.d.ts +1 -1
- package/features/contentModel/ModelToAstConverter/ModelToAstConverter.js.map +1 -1
- package/features/contentModel/ModelToAstConverter/abstractions.d.ts +1 -1
- package/features/contentModel/ModelToAstConverter/abstractions.js.map +1 -1
- package/features/contentModel/UpdateModel/UpdateModelRepository.d.ts +7 -4
- package/features/contentModel/UpdateModel/UpdateModelRepository.js +10 -6
- package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
- package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js +1 -1
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js.map +1 -1
- package/features/contentModel/shared/ModelsFetcher.d.ts +9 -8
- package/features/contentModel/shared/ModelsFetcher.js +5 -5
- package/features/contentModel/shared/ModelsFetcher.js.map +1 -1
- package/features/contentModel/shared/PluginModelsProvider.d.ts +9 -5
- package/features/contentModel/shared/PluginModelsProvider.js +11 -15
- 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 +8 -4
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js +11 -9
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js.map +1 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.d.ts +3 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js +2 -3
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/GetGroup/GetGroupRepository.d.ts +6 -4
- package/features/contentModelGroup/GetGroup/GetGroupRepository.js +9 -9
- package/features/contentModelGroup/GetGroup/GetGroupRepository.js.map +1 -1
- package/features/contentModelGroup/GetGroup/GetGroupUseCase.d.ts +3 -1
- package/features/contentModelGroup/GetGroup/GetGroupUseCase.js +2 -3
- package/features/contentModelGroup/GetGroup/GetGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/ListGroups/ListGroupsRepository.d.ts +6 -4
- package/features/contentModelGroup/ListGroups/ListGroupsRepository.js +9 -9
- package/features/contentModelGroup/ListGroups/ListGroupsRepository.js.map +1 -1
- package/features/contentModelGroup/ListGroups/ListGroupsUseCase.d.ts +3 -1
- package/features/contentModelGroup/ListGroups/ListGroupsUseCase.js +2 -3
- package/features/contentModelGroup/ListGroups/ListGroupsUseCase.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.d.ts +6 -4
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js +7 -8
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.d.ts +3 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js +2 -3
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/shared/PluginGroupsProvider.d.ts +6 -4
- package/features/contentModelGroup/shared/PluginGroupsProvider.js +13 -11
- package/features/contentModelGroup/shared/PluginGroupsProvider.js.map +1 -1
- package/features/contentModelGroup/shared/abstractions.d.ts +10 -0
- package/features/contentModelGroup/shared/abstractions.js +2 -1
- package/features/contentModelGroup/shared/abstractions.js.map +1 -1
- package/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.d.ts +2 -2
- package/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/AssetToGraphQL.d.ts +1 -1
- package/features/graphql/fields/base/AssetToGraphQL.js +7 -2
- package/features/graphql/fields/base/AssetToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/DynamicZoneToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/RefToGraphQL.d.ts +1 -1
- package/features/graphql/fields/base/RefToGraphQL.js +14 -8
- 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 +4 -0
- package/features/modelBuilder/abstractions.js.map +1 -1
- package/features/modelBuilder/feature.js +1 -8
- package/features/modelBuilder/feature.js.map +1 -1
- package/features/modelBuilder/fields/DataFieldBuilder.d.ts +17 -0
- package/features/modelBuilder/fields/DataFieldBuilder.js +6 -0
- package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -1
- package/features/modelBuilder/fields/DateTimeFieldType.js +27 -12
- package/features/modelBuilder/fields/DateTimeFieldType.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/fieldTypeValidator.d.ts +5 -3
- package/features/modelBuilder/models/ModelBuilder.d.ts +8 -0
- package/features/modelBuilder/models/ModelBuilder.js +1 -0
- package/features/modelBuilder/models/ModelBuilder.js.map +1 -1
- package/features/modelBuilder/models/ModelsProvider.d.ts +1 -3
- package/features/modelBuilder/models/ModelsProvider.js +2 -7
- package/features/modelBuilder/models/ModelsProvider.js.map +1 -1
- package/features/modelBuilder/models/PrivateModelBuilder.d.ts +5 -0
- package/features/modelBuilder/models/PrivateModelBuilder.js +12 -1
- package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
- package/features/shared/abstractions.d.ts +8 -16
- package/features/shared/abstractions.js +2 -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/validation/abstractions/CmsModelFieldValidator.d.ts +5 -0
- package/features/validation/abstractions/CmsModelFieldValidator.js.map +1 -1
- package/features/validation/validators/DateGteValidator.d.ts +2 -0
- package/features/validation/validators/DateGteValidator.js +12 -2
- package/features/validation/validators/DateGteValidator.js.map +1 -1
- package/features/validation/validators/DateLteValidator.d.ts +2 -0
- package/features/validation/validators/DateLteValidator.js +12 -2
- package/features/validation/validators/DateLteValidator.js.map +1 -1
- package/features/validation/validators/dateLimit.d.ts +9 -0
- package/features/validation/validators/dateLimit.js +18 -0
- package/features/validation/validators/dateLimit.js.map +1 -0
- 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/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 +3 -18
- package/graphql/schema/baseSchema.js.map +1 -1
- package/graphql/schema/cms/CmsBaseErrorTypeFactory.d.ts +15 -0
- package/graphql/schema/cms/CmsBaseErrorTypeFactory.js +25 -0
- package/graphql/schema/cms/CmsBaseErrorTypeFactory.js.map +1 -0
- package/graphql/schema/cms/createEntryResolver.js +2 -2
- package/graphql/schema/cms/createEntryResolver.js.map +1 -1
- package/graphql/schema/cms/deleteEntryResolver.js +2 -2
- package/graphql/schema/cms/deleteEntryResolver.js.map +1 -1
- package/graphql/schema/cms/getEntryResolver.js +2 -2
- package/graphql/schema/cms/getEntryResolver.js.map +1 -1
- package/graphql/schema/cms/helpers/getModel.d.ts +0 -3
- package/graphql/schema/cms/helpers/getModel.js +5 -3
- package/graphql/schema/cms/helpers/getModel.js.map +1 -1
- package/graphql/schema/cms/listEntriesResolver.js +2 -2
- package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
- package/graphql/schema/cms/publishEntryResolver.js +2 -2
- package/graphql/schema/cms/publishEntryResolver.js.map +1 -1
- package/graphql/schema/cms/resolvers/createEntry.d.ts +3 -2
- package/graphql/schema/cms/resolvers/createEntry.js +5 -1
- package/graphql/schema/cms/resolvers/createEntry.js.map +1 -1
- package/graphql/schema/cms/resolvers/deleteEntryRevision.d.ts +3 -2
- package/graphql/schema/cms/resolvers/deleteEntryRevision.js +5 -1
- package/graphql/schema/cms/resolvers/deleteEntryRevision.js.map +1 -1
- package/graphql/schema/cms/resolvers/getEntry.d.ts +3 -2
- package/graphql/schema/cms/resolvers/getEntry.js +5 -1
- package/graphql/schema/cms/resolvers/getEntry.js.map +1 -1
- package/graphql/schema/cms/resolvers/getModel.d.ts +3 -2
- package/graphql/schema/cms/resolvers/getModel.js +5 -1
- package/graphql/schema/cms/resolvers/getModel.js.map +1 -1
- package/graphql/schema/cms/resolvers/listEntries.d.ts +3 -2
- package/graphql/schema/cms/resolvers/listEntries.js +5 -1
- package/graphql/schema/cms/resolvers/listEntries.js.map +1 -1
- package/graphql/schema/cms/resolvers/mutationCms.d.ts +3 -2
- package/graphql/schema/cms/resolvers/mutationCms.js +5 -1
- package/graphql/schema/cms/resolvers/mutationCms.js.map +1 -1
- package/graphql/schema/cms/resolvers/publishEntryRevision.d.ts +3 -2
- package/graphql/schema/cms/resolvers/publishEntryRevision.js +5 -1
- package/graphql/schema/cms/resolvers/publishEntryRevision.js.map +1 -1
- package/graphql/schema/cms/resolvers/queryCms.d.ts +3 -2
- package/graphql/schema/cms/resolvers/queryCms.js +5 -1
- package/graphql/schema/cms/resolvers/queryCms.js.map +1 -1
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.d.ts +3 -2
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.js +5 -1
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.js.map +1 -1
- package/graphql/schema/cms/resolvers/updateEntryRevision.d.ts +3 -2
- package/graphql/schema/cms/resolvers/updateEntryRevision.js +5 -1
- package/graphql/schema/cms/resolvers/updateEntryRevision.js.map +1 -1
- package/graphql/schema/cms/typeDefs/mutation.d.ts +3 -2
- package/graphql/schema/cms/typeDefs/mutation.js +5 -1
- package/graphql/schema/cms/typeDefs/mutation.js.map +1 -1
- package/graphql/schema/cms/typeDefs/query.d.ts +3 -2
- package/graphql/schema/cms/typeDefs/query.js +5 -1
- package/graphql/schema/cms/typeDefs/query.js.map +1 -1
- package/graphql/schema/cms/typeDefs/responses.d.ts +3 -2
- package/graphql/schema/cms/typeDefs/responses.js +5 -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 +60 -34
- 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 +32 -15
- 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 +7 -3
- package/graphql/schema/createManageResolvers.js.map +1 -1
- package/graphql/schema/createManageSDL.js +2 -0
- package/graphql/schema/createManageSDL.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/resolveDuplicate.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveDuplicate.js +11 -0
- package/graphql/schema/resolvers/manage/resolveDuplicate.js.map +1 -0
- 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 -3
- package/index.js +4 -2
- package/legacy/abstractions.js.map +1 -1
- package/package.json +21 -24
- package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.d.ts +2 -2
- package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js +1 -1
- package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js.map +1 -1
- package/plugins/index.d.ts +0 -1
- package/plugins/index.js +0 -1
- package/types/index.d.ts +0 -1
- package/types/modelField.d.ts +11 -0
- package/types/types.d.ts +19 -291
- package/types/types.js.map +1 -1
- 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/createModelField.js +2 -1
- package/utils/createModelField.js.map +1 -1
- package/utils/createModelSchemaKey.d.ts +8 -0
- package/utils/createModelSchemaKey.js +18 -0
- package/utils/createModelSchemaKey.js.map +1 -0
- package/utils/getSchemaFromFieldPlugins.d.ts +2 -2
- package/utils/getSchemaFromFieldPlugins.js.map +1 -1
- 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/crud/contentEntry.crud.d.ts +0 -6
- package/crud/contentEntry.crud.js +0 -307
- package/crud/contentEntry.crud.js.map +0 -1
- package/crud/contentModel.crud.d.ts +0 -5
- package/crud/contentModel.crud.js +0 -77
- package/crud/contentModel.crud.js.map +0 -1
- package/crud/contentModelGroup.crud.d.ts +0 -5
- package/crud/contentModelGroup.crud.js +0 -74
- package/crud/contentModelGroup.crud.js.map +0 -1
- package/extension.d.ts +0 -3
- package/extension.js +0 -19
- package/extension.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/contentEntry/UpdateRevision/UpdateRevisionRepository.d.ts +0 -14
- package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.js +0 -34
- package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.js.map +0 -1
- package/features/contentEntry/UpdateRevision/abstractions.d.ts +0 -10
- package/features/contentEntry/UpdateRevision/abstractions.js +0 -5
- package/features/contentEntry/UpdateRevision/abstractions.js.map +0 -1
- package/features/contentEntry/UpdateRevision/feature.js +0 -11
- package/features/contentEntry/UpdateRevision/feature.js.map +0 -1
- package/features/contentEntry/UpdateRevision/index.d.ts +0 -1
- package/features/contentEntry/UpdateRevision/index.js +0 -1
- package/graphql/graphQLHandlerFactory.d.ts +0 -5
- package/graphql/graphQLHandlerFactory.js +0 -22
- package/graphql/graphQLHandlerFactory.js.map +0 -1
- package/graphql/handleRequest.d.ts +0 -11
- package/graphql/handleRequest.js +0 -62
- package/graphql/handleRequest.js.map +0 -1
- package/graphql/index.d.ts +0 -4
- package/graphql/index.js +0 -11
- package/graphql/index.js.map +0 -1
- package/graphql/schema/cms/index.d.ts +0 -2
- package/graphql/schema/cms/index.js +0 -25
- package/graphql/schema/cms/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
- package/types/context.d.ts +0 -110
- package/types/context.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { buildFieldsSelection, getErrorMessage, getModel } from "./helpers.js";
|
|
2
|
+
import { CmsSchemaExecutor } from "../../CmsSchemaExecutor.js";
|
|
2
3
|
const createUnpublishEntryRevisionResolver = ()=>async ({ args, context })=>{
|
|
3
4
|
const { modelId, revisionId, fields } = args;
|
|
4
5
|
try {
|
|
5
6
|
const model = await getModel(context, modelId);
|
|
6
7
|
const apiType = "manage";
|
|
7
|
-
const executeSchema = await context.cms.getExecutableSchema(apiType);
|
|
8
8
|
const fieldsSelection = buildFieldsSelection(fields);
|
|
9
9
|
const query = `
|
|
10
10
|
mutation Unpublish${model.singularApiName}($revisionId: ID!) {
|
|
@@ -20,7 +20,7 @@ const createUnpublishEntryRevisionResolver = ()=>async ({ args, context })=>{
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
`;
|
|
23
|
-
const result = await
|
|
23
|
+
const result = await context.container.resolve(CmsSchemaExecutor).execute(apiType, {
|
|
24
24
|
query,
|
|
25
25
|
variables: {
|
|
26
26
|
revisionId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/schema/cms/unpublishEntryResolver.js","sources":["../../../../src/graphql/schema/cms/unpublishEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"graphql/schema/cms/unpublishEntryResolver.js","sources":["../../../../src/graphql/schema/cms/unpublishEntryResolver.ts"],"sourcesContent":["import type { CmsContext, ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\nimport { CmsSchemaExecutor } from \"~/graphql/CmsSchemaExecutor.js\";\n\nexport interface UnpublishEntryRevisionArgs {\n modelId: string;\n revisionId: string;\n fields: string[];\n}\n\nexport const createUnpublishEntryRevisionResolver = () => {\n return async ({ args, context }: { args: UnpublishEntryRevisionArgs; context: CmsContext }) => {\n const { modelId, revisionId, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for unpublishing entries.\n const apiType: ApiEndpoint = \"manage\";\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Unpublish${model.singularApiName}($revisionId: ID!) {\n unpublish${model.singularApiName}(revision: $revisionId) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await context.container\n .resolve(CmsSchemaExecutor)\n .execute(apiType, { query, variables: { revisionId } })) as ExecutionResult;\n\n if (result.errors && result.errors.length > 0) {\n return {\n data: null,\n error: {\n message: result.errors.map(e => e.message).join(\"; \"),\n code: \"UNPUBLISH_ENTRY_ERROR\"\n }\n };\n }\n\n const operationName = `unpublish${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to unpublish entry\"),\n code: \"UNPUBLISH_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"names":["createUnpublishEntryRevisionResolver","args","context","modelId","revisionId","fields","model","getModel","apiType","fieldsSelection","buildFieldsSelection","query","result","CmsSchemaExecutor","e","operationName","error","getErrorMessage"],"mappings":";;AAWO,MAAMA,uCAAuC,IACzC,OAAO,EAAEC,IAAI,EAAEC,OAAO,EAA6D;QACtF,MAAM,EAAEC,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAE,GAAGJ;QAExC,IAAI;YACA,MAAMK,QAAQ,MAAMC,SAASL,SAASC;YAGtC,MAAMK,UAAuB;YAE7B,MAAMC,kBAAkBC,qBAAqBL;YAE7C,MAAMM,QAAsB,CAAC;kCACP,EAAEL,MAAM,eAAe,CAAC;6BAC7B,EAAEA,MAAM,eAAe,CAAC;;4BAEzB,EAAEG,gBAAgB;;;;;;;;;YASlC,CAAC;YAED,MAAMG,SAAU,MAAMV,QAAQ,SAAS,CAClC,OAAO,CAACW,mBACR,OAAO,CAACL,SAAS;gBAAEG;gBAAO,WAAW;oBAAEP;gBAAW;YAAE;YAEzD,IAAIQ,OAAO,MAAM,IAAIA,OAAO,MAAM,CAAC,MAAM,GAAG,GACxC,OAAO;gBACH,MAAM;gBACN,OAAO;oBACH,SAASA,OAAO,MAAM,CAAC,GAAG,CAACE,CAAAA,IAAKA,EAAE,OAAO,EAAE,IAAI,CAAC;oBAChD,MAAM;gBACV;YACJ;YAGJ,MAAMC,gBAAgB,CAAC,SAAS,EAAET,MAAM,eAAe,EAAE;YACzD,OAAOM,OAAO,IAAI,EAAE,CAACG,cAAc,IAAI;gBAAE,MAAM;gBAAM,OAAO;YAAK;QACrE,EAAE,OAAOC,OAAO;YACZ,OAAO;gBACH,MAAM;gBACN,OAAO;oBACH,SAASC,gBAAgBD,OAAO;oBAChC,MAAM;gBACV;YACJ;QACJ;IACJ"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { buildFieldsSelection, getErrorMessage, getModel } from "./helpers.js";
|
|
2
|
+
import { CmsSchemaExecutor } from "../../CmsSchemaExecutor.js";
|
|
2
3
|
const createUpdateEntryRevisionResolver = ()=>async ({ args, context })=>{
|
|
3
4
|
const { modelId, revisionId, data, fields } = args;
|
|
4
5
|
try {
|
|
5
6
|
const model = await getModel(context, modelId);
|
|
6
7
|
const apiType = "manage";
|
|
7
|
-
const executeSchema = await context.cms.getExecutableSchema(apiType);
|
|
8
8
|
const fieldsSelection = buildFieldsSelection(fields);
|
|
9
9
|
const query = `
|
|
10
10
|
mutation Update${model.singularApiName}($revisionId: ID!, $data: ${model.singularApiName}Input!) {
|
|
@@ -20,7 +20,7 @@ const createUpdateEntryRevisionResolver = ()=>async ({ args, context })=>{
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
`;
|
|
23
|
-
const result = await
|
|
23
|
+
const result = await context.container.resolve(CmsSchemaExecutor).execute(apiType, {
|
|
24
24
|
query,
|
|
25
25
|
variables: {
|
|
26
26
|
revisionId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/schema/cms/updateEntryResolver.js","sources":["../../../../src/graphql/schema/cms/updateEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"graphql/schema/cms/updateEntryResolver.js","sources":["../../../../src/graphql/schema/cms/updateEntryResolver.ts"],"sourcesContent":["import type { CmsContext, ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\nimport { CmsSchemaExecutor } from \"~/graphql/CmsSchemaExecutor.js\";\n\nexport interface UpdateEntryRevisionArgs {\n modelId: string;\n revisionId: string;\n data: Record<string, unknown>;\n fields: string[];\n}\n\nexport const createUpdateEntryRevisionResolver = () => {\n return async ({ args, context }: { args: UpdateEntryRevisionArgs; context: CmsContext }) => {\n const { modelId, revisionId, data, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for updating entries.\n const apiType: ApiEndpoint = \"manage\";\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Update${model.singularApiName}($revisionId: ID!, $data: ${model.singularApiName}Input!) {\n update${model.singularApiName}(revision: $revisionId, data: $data) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await context.container\n .resolve(CmsSchemaExecutor)\n .execute(apiType, { query, variables: { revisionId, data } })) as ExecutionResult;\n\n if (result.errors && result.errors.length > 0) {\n return {\n data: null,\n error: {\n message: result.errors.map(e => e.message).join(\"; \"),\n code: \"UPDATE_ENTRY_ERROR\"\n }\n };\n }\n\n const operationName = `update${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to update entry\"),\n code: \"UPDATE_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"names":["createUpdateEntryRevisionResolver","args","context","modelId","revisionId","data","fields","model","getModel","apiType","fieldsSelection","buildFieldsSelection","query","result","CmsSchemaExecutor","e","operationName","error","getErrorMessage"],"mappings":";;AAYO,MAAMA,oCAAoC,IACtC,OAAO,EAAEC,IAAI,EAAEC,OAAO,EAA0D;QACnF,MAAM,EAAEC,OAAO,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGL;QAE9C,IAAI;YACA,MAAMM,QAAQ,MAAMC,SAASN,SAASC;YAGtC,MAAMM,UAAuB;YAE7B,MAAMC,kBAAkBC,qBAAqBL;YAE7C,MAAMM,QAAsB,CAAC;+BACV,EAAEL,MAAM,eAAe,CAAC,0BAA0B,EAAEA,MAAM,eAAe,CAAC;0BAC/E,EAAEA,MAAM,eAAe,CAAC;;4BAEtB,EAAEG,gBAAgB;;;;;;;;;YASlC,CAAC;YAED,MAAMG,SAAU,MAAMX,QAAQ,SAAS,CAClC,OAAO,CAACY,mBACR,OAAO,CAACL,SAAS;gBAAEG;gBAAO,WAAW;oBAAER;oBAAYC;gBAAK;YAAE;YAE/D,IAAIQ,OAAO,MAAM,IAAIA,OAAO,MAAM,CAAC,MAAM,GAAG,GACxC,OAAO;gBACH,MAAM;gBACN,OAAO;oBACH,SAASA,OAAO,MAAM,CAAC,GAAG,CAACE,CAAAA,IAAKA,EAAE,OAAO,EAAE,IAAI,CAAC;oBAChD,MAAM;gBACV;YACJ;YAGJ,MAAMC,gBAAgB,CAAC,MAAM,EAAET,MAAM,eAAe,EAAE;YACtD,OAAOM,OAAO,IAAI,EAAE,CAACG,cAAc,IAAI;gBAAE,MAAM;gBAAM,OAAO;YAAK;QACrE,EAAE,OAAOC,OAAO;YACZ,OAAO;gBACH,MAAM;gBACN,OAAO;oBACH,SAASC,gBAAgBD,OAAO;oBAChC,MAAM;gBACV;YACJ;QACJ;IACJ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ErrorResponse, Response } from "@webiny/handler-graphql";
|
|
1
|
+
import { ErrorResponse, Response } from "@webiny/api-graphql";
|
|
3
2
|
import { getEntryTitle } from "../../utils/getEntryTitle.js";
|
|
4
3
|
import { createCmsGraphQLSchemaPlugin } from "../../plugins/index.js";
|
|
5
4
|
import { getEntryDescription } from "../../utils/getEntryDescription.js";
|
|
@@ -8,6 +7,11 @@ import { entryFieldFromStorageTransform } from "../../utils/entryStorage.js";
|
|
|
8
7
|
import { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from "../../constants.js";
|
|
9
8
|
import NotAuthorizedResponse from "@webiny/api-core/graphql/security/NotAuthorizedResponse.js";
|
|
10
9
|
import { ListLatestEntriesUseCase } from "../../features/contentEntry/ListEntries/index.js";
|
|
10
|
+
import { ListModelsUseCase } from "../../features/contentModel/ListModels/index.js";
|
|
11
|
+
import { GetLatestEntriesByIdsUseCase } from "../../features/contentEntry/GetLatestEntriesByIds/index.js";
|
|
12
|
+
import { GetPublishedEntriesByIdsUseCase } from "../../features/contentEntry/GetPublishedEntriesByIds/index.js";
|
|
13
|
+
import { GetEntriesByIdsUseCase } from "../../features/contentEntry/GetEntriesByIds/index.js";
|
|
14
|
+
import { HeadlessCmsEndpointConfig } from "../../HeadlessCmsEndpointConfig.js";
|
|
11
15
|
const createDate = (date)=>{
|
|
12
16
|
if (!date) return null;
|
|
13
17
|
try {
|
|
@@ -16,6 +20,16 @@ const createDate = (date)=>{
|
|
|
16
20
|
return new Date();
|
|
17
21
|
}
|
|
18
22
|
};
|
|
23
|
+
const SEARCH_CANDIDATES_LIMIT = 100;
|
|
24
|
+
const getSearchRank = (title, query)=>{
|
|
25
|
+
const normalizedQuery = query?.trim().toLowerCase();
|
|
26
|
+
if (!normalizedQuery) return 0;
|
|
27
|
+
const normalizedTitle = (title || "").trim().toLowerCase();
|
|
28
|
+
if (normalizedTitle === normalizedQuery) return 0;
|
|
29
|
+
if (normalizedTitle.startsWith(normalizedQuery)) return 1;
|
|
30
|
+
if (normalizedTitle.includes(normalizedQuery)) return 2;
|
|
31
|
+
return 3;
|
|
32
|
+
};
|
|
19
33
|
const createCmsEntryRecord = (model, entry)=>({
|
|
20
34
|
id: entry.id,
|
|
21
35
|
entryId: entry.entryId,
|
|
@@ -52,25 +66,28 @@ const createCmsEntryRecord = (model, entry)=>({
|
|
|
52
66
|
}
|
|
53
67
|
});
|
|
54
68
|
const getFetchMethod = (type, context)=>{
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
if ("latest" === type) return async (model, ids)=>{
|
|
70
|
+
const result = await context.container.resolve(GetLatestEntriesByIdsUseCase).execute(model, ids);
|
|
71
|
+
if (result.isFail()) throw result.error;
|
|
72
|
+
return result.value;
|
|
73
|
+
};
|
|
74
|
+
if ("published" === type) return async (model, ids)=>{
|
|
75
|
+
const result = await context.container.resolve(GetPublishedEntriesByIdsUseCase).execute(model, ids);
|
|
76
|
+
if (result.isFail()) throw result.error;
|
|
77
|
+
return result.value;
|
|
78
|
+
};
|
|
79
|
+
return async (model, ids)=>{
|
|
80
|
+
const result = await context.container.resolve(GetEntriesByIdsUseCase).execute(model, ids);
|
|
81
|
+
if (result.isFail()) throw result.error;
|
|
82
|
+
return result.value;
|
|
83
|
+
};
|
|
69
84
|
};
|
|
70
85
|
const getContentEntries = async (params)=>{
|
|
71
86
|
const { args, context, type } = params;
|
|
72
87
|
const method = getFetchMethod(type, context);
|
|
73
|
-
const
|
|
88
|
+
const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
|
|
89
|
+
if (modelsResult.isFail()) throw modelsResult.error;
|
|
90
|
+
const models = modelsResult.value;
|
|
74
91
|
const modelsMap = models.reduce((collection, model)=>{
|
|
75
92
|
collection[model.modelId] = model;
|
|
76
93
|
return collection;
|
|
@@ -98,14 +115,11 @@ const getContentEntries = async (params)=>{
|
|
|
98
115
|
};
|
|
99
116
|
const getContentEntry = async (params)=>{
|
|
100
117
|
const { args, context, type } = params;
|
|
101
|
-
if (!getContentEntriesMethods[type]) throw new error(`Unknown getContentEntry method "${type}". Could not fetch content entry.`, "UNKNOWN_METHOD_ERROR", {
|
|
102
|
-
args,
|
|
103
|
-
type
|
|
104
|
-
});
|
|
105
118
|
const method = getFetchMethod(type, context);
|
|
106
119
|
const { modelId, id } = args.entry;
|
|
107
|
-
const
|
|
108
|
-
|
|
120
|
+
const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
|
|
121
|
+
if (modelsResult.isFail()) throw modelsResult.error;
|
|
122
|
+
const model = modelsResult.value.find((m)=>m.modelId === modelId);
|
|
109
123
|
if (!model) return new NotAuthorizedResponse({
|
|
110
124
|
data: {
|
|
111
125
|
modelId
|
|
@@ -119,8 +133,9 @@ const getContentEntry = async (params)=>{
|
|
|
119
133
|
return new Response(createCmsEntryRecord(model, entry));
|
|
120
134
|
};
|
|
121
135
|
const createResolveDescription = ()=>async (parent, _, context)=>{
|
|
122
|
-
const
|
|
123
|
-
|
|
136
|
+
const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
|
|
137
|
+
if (modelsResult.isFail()) return null;
|
|
138
|
+
const model = modelsResult.value.find(({ modelId })=>parent.model.modelId === modelId);
|
|
124
139
|
if (!model) return null;
|
|
125
140
|
const field = model.fields.find((f)=>f.fieldId === model.descriptionFieldId);
|
|
126
141
|
if (!field) return null;
|
|
@@ -134,12 +149,13 @@ const createResolveDescription = ()=>async (parent, _, context)=>{
|
|
|
134
149
|
});
|
|
135
150
|
};
|
|
136
151
|
const createContentEntriesSchema = ({ context })=>{
|
|
137
|
-
|
|
152
|
+
const enhancerConfig = context.container.resolve(HeadlessCmsEndpointConfig);
|
|
153
|
+
if ("manage" !== enhancerConfig.type) {
|
|
138
154
|
const plugin = createCmsGraphQLSchemaPlugin({
|
|
139
155
|
typeDefs: "",
|
|
140
156
|
resolvers: {}
|
|
141
157
|
});
|
|
142
|
-
plugin.name = `headless-cms.graphql.schema.${
|
|
158
|
+
plugin.name = `headless-cms.graphql.schema.${enhancerConfig.type}.empty`;
|
|
143
159
|
return plugin;
|
|
144
160
|
}
|
|
145
161
|
const onByMetaFields = ENTRY_META_FIELDS.map((field)=>{
|
|
@@ -218,12 +234,15 @@ const createContentEntriesSchema = ({ context })=>{
|
|
|
218
234
|
CmsContentEntry: {
|
|
219
235
|
published: async (parent, _, context)=>{
|
|
220
236
|
try {
|
|
221
|
-
const
|
|
222
|
-
|
|
237
|
+
const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
|
|
238
|
+
if (modelsResult.isFail()) return null;
|
|
239
|
+
const model = modelsResult.value.find(({ modelId })=>parent.model.modelId === modelId);
|
|
223
240
|
if (!model) return null;
|
|
224
|
-
const
|
|
241
|
+
const result = await context.container.resolve(GetPublishedEntriesByIdsUseCase).execute(model, [
|
|
225
242
|
parent.id
|
|
226
243
|
]);
|
|
244
|
+
if (result.isFail()) return null;
|
|
245
|
+
const entry = result.value[0];
|
|
227
246
|
if (!entry) return null;
|
|
228
247
|
return createCmsEntryRecord(model, entry);
|
|
229
248
|
} catch {
|
|
@@ -238,12 +257,15 @@ const createContentEntriesSchema = ({ context })=>{
|
|
|
238
257
|
Query: {
|
|
239
258
|
async searchContentEntries (_, args, context) {
|
|
240
259
|
const { modelIds, fields, query, limit = 10 } = args;
|
|
241
|
-
const
|
|
260
|
+
const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
|
|
261
|
+
if (modelsResult.isFail()) return new ErrorResponse(modelsResult.error);
|
|
262
|
+
const models = modelsResult.value;
|
|
263
|
+
const storageLimit = query ? Math.max(limit, SEARCH_CANDIDATES_LIMIT) : limit;
|
|
242
264
|
const getters = models.filter((model)=>modelIds.includes(model.modelId)).map(async (model)=>{
|
|
243
265
|
const listLatest = await context.container.resolve(ListLatestEntriesUseCase);
|
|
244
266
|
const where = {};
|
|
245
267
|
const result = await listLatest.execute(model, {
|
|
246
|
-
limit,
|
|
268
|
+
limit: storageLimit,
|
|
247
269
|
where,
|
|
248
270
|
search: query ? query : void 0,
|
|
249
271
|
fields: fields || []
|
|
@@ -254,7 +276,11 @@ const createContentEntriesSchema = ({ context })=>{
|
|
|
254
276
|
});
|
|
255
277
|
try {
|
|
256
278
|
const entries = await Promise.all(getters).then((results)=>results.reduce((result, item)=>result.concat(item), []));
|
|
257
|
-
return new Response(entries.sort((a, b)=>
|
|
279
|
+
return new Response(entries.sort((a, b)=>{
|
|
280
|
+
const rank = getSearchRank(a.title, query) - getSearchRank(b.title, query);
|
|
281
|
+
if (0 !== rank) return rank;
|
|
282
|
+
return b.savedOn.getTime() - a.savedOn.getTime();
|
|
283
|
+
}).slice(0, limit));
|
|
258
284
|
} catch (ex) {
|
|
259
285
|
return new ErrorResponse(ex);
|
|
260
286
|
}
|
|
@@ -304,7 +330,7 @@ const createContentEntriesSchema = ({ context })=>{
|
|
|
304
330
|
}
|
|
305
331
|
}
|
|
306
332
|
});
|
|
307
|
-
plugin.name = `headless-cms.graphql.schema.${context.
|
|
333
|
+
plugin.name = `headless-cms.graphql.schema.${context.container.resolve(HeadlessCmsEndpointConfig).type}.content-entries`;
|
|
308
334
|
return plugin;
|
|
309
335
|
};
|
|
310
336
|
export { createContentEntriesSchema };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/schema/contentEntries.js","sources":["../../../src/graphql/schema/contentEntries.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport type {\n CmsContext,\n CmsEntry,\n CmsEntryListWhere,\n CmsIdentity,\n CmsModel\n} from \"~/types/index.js\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { getEntryDescription } from \"~/utils/getEntryDescription.js\";\nimport { getEntryImage } from \"~/utils/getEntryImage.js\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage.js\";\nimport type { GraphQLFieldResolver } from \"@webiny/handler-graphql/types.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { ListLatestEntriesUseCase } from \"~/features/contentEntry/ListEntries/index.js\";\n\ninterface EntriesByModel {\n [key: string]: string[];\n}\n\ntype GetContentEntryType = \"latest\" | \"published\" | \"exact\";\n\nconst createDate = (date: string | null): Date | null => {\n if (!date) {\n return null;\n }\n\n try {\n return new Date(date);\n } catch {\n return new Date();\n }\n};\n\ninterface CmsEntryRecord {\n id: string;\n entryId: string;\n model: {\n modelId: string;\n name: string;\n };\n status: string;\n title: string;\n description?: string | null;\n image?: string | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: Date;\n modifiedOn: Date | null;\n savedOn: Date;\n createdBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n savedBy: CmsIdentity;\n firstPublishedOn: Date | null;\n lastPublishedOn: Date | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: Date;\n revisionModifiedOn: Date | null;\n revisionSavedOn: Date;\n revisionCreatedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionSavedBy: CmsIdentity;\n revisionFirstPublishedOn: Date | null;\n revisionLastPublishedOn: Date | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n wbyAco_location?: {\n folderId?: string | null;\n };\n}\n\nconst createCmsEntryRecord = (model: CmsModel, entry: CmsEntry): CmsEntryRecord => {\n return {\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry),\n description: getEntryDescription(model, entry),\n image: getEntryImage(model, entry),\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: createDate(entry.createdOn)!,\n modifiedOn: createDate(entry.modifiedOn),\n savedOn: createDate(entry.savedOn)!,\n createdBy: entry.createdBy,\n savedBy: entry.savedBy,\n modifiedBy: entry.modifiedBy,\n firstPublishedOn: createDate(entry.firstPublishedOn),\n lastPublishedOn: createDate(entry.lastPublishedOn),\n firstPublishedBy: entry.firstPublishedBy,\n lastPublishedBy: entry.lastPublishedBy,\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: createDate(entry.revisionCreatedOn)!,\n revisionSavedOn: createDate(entry.revisionSavedOn)!,\n revisionModifiedOn: createDate(entry.revisionModifiedOn),\n revisionCreatedBy: entry.revisionCreatedBy,\n revisionModifiedBy: entry.revisionModifiedBy,\n revisionSavedBy: entry.revisionSavedBy,\n revisionFirstPublishedOn: createDate(entry.revisionFirstPublishedOn),\n revisionLastPublishedOn: createDate(entry.revisionLastPublishedOn),\n revisionFirstPublishedBy: entry.revisionFirstPublishedBy,\n revisionLastPublishedBy: entry.revisionLastPublishedBy,\n\n wbyAco_location: {\n folderId: entry.location?.folderId || null\n }\n };\n};\n\ninterface FetchMethod {\n (model: CmsModel, ids: string[]): Promise<CmsEntry[]>;\n}\n\nconst getFetchMethod = (type: GetContentEntryType, context: CmsContext): FetchMethod => {\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntries method \"${type}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type\n }\n );\n }\n const methodName = getContentEntriesMethods[type] as GetContentEntryMethods;\n if (!context.cms[methodName]) {\n throw new WebinyError(\n `Unknown context.cms method \"${methodName}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type,\n methodName\n }\n );\n }\n\n return context.cms[methodName];\n};\n\n/**\n * Function to get the list of content entries depending on latest, published or exact GraphQL queries.\n */\ninterface GetContentEntriesParams {\n args: {\n entries: Pick<CmsEntry, \"id\" | \"modelId\">[];\n };\n context: CmsContext;\n type: GetContentEntryType;\n}\n\nenum GetContentEntryMethods {\n getLatestEntriesByIds = \"getLatestEntriesByIds\",\n getPublishedEntriesByIds = \"getPublishedEntriesByIds\",\n getEntriesByIds = \"getEntriesByIds\"\n}\n\nconst getContentEntriesMethods = {\n latest: \"getLatestEntriesByIds\",\n published: \"getPublishedEntriesByIds\",\n exact: \"getEntriesByIds\"\n};\nconst getContentEntries = async (\n params: GetContentEntriesParams\n): Promise<Response | ErrorResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const models = await context.cms.listModels();\n\n const modelsMap = models.reduce(\n (collection, model) => {\n collection[model.modelId] = model;\n return collection;\n },\n {} as Record<string, CmsModel>\n );\n\n const argsEntries = args.entries as Pick<CmsEntry, \"id\" | \"modelId\">[];\n\n const entriesByModel = argsEntries.reduce((collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.id)) {\n return collection;\n }\n collection[ref.modelId].push(ref.id);\n return collection;\n }, {} as EntriesByModel);\n\n const getters: Promise<CmsEntry[]>[] = Object.keys(entriesByModel).map(async modelId => {\n return method(modelsMap[modelId], entriesByModel[modelId]);\n });\n\n if (getters.length === 0) {\n return new Response([]);\n }\n\n try {\n const results = await Promise.all(getters);\n\n const entries = results\n .reduce<CmsEntryRecord[]>((collection, items) => {\n return collection.concat(\n items.map(item => {\n const model = modelsMap[item.modelId];\n\n return createCmsEntryRecord(model, item);\n })\n );\n }, [])\n .filter(Boolean);\n\n return new Response(entries);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\n/**\n * Function to fetch a single content entry depending on latest, published or exact GraphQL query.\n */\ninterface GetContentEntryParams {\n args: {\n entry: Pick<CmsEntry, \"id\" | \"modelId\">;\n };\n context: CmsContext;\n type: \"latest\" | \"published\" | \"exact\";\n}\n\nconst getContentEntry = async (\n params: GetContentEntryParams\n): Promise<Response<CmsEntryRecord | null> | NotAuthorizedResponse> => {\n const { args, context, type } = params;\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntry method \"${type}\". Could not fetch content entry.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n args,\n type\n }\n );\n }\n\n const method = getFetchMethod(type, context);\n\n const { modelId, id } = args.entry;\n const models = await context.cms.listModels();\n const model = models.find(m => m.modelId === modelId);\n\n if (!model) {\n return new NotAuthorizedResponse({\n data: {\n modelId\n }\n });\n }\n\n const result = await method(model, [id]);\n\n const entry = result.shift();\n if (!entry) {\n return new Response(null);\n }\n\n return new Response(createCmsEntryRecord(model, entry));\n};\n/**\n * As we support description field, we need to transform the value from storage.\n */\nconst createResolveDescription = (): GraphQLFieldResolver<any, any, CmsContext> => {\n return async (parent, _, context) => {\n const models = await context.cms.listModels();\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return null;\n }\n const value = parent.description || parent[field.fieldId];\n if (!value) {\n return null;\n }\n return entryFieldFromStorageTransform({\n context,\n model,\n field,\n value\n });\n };\n};\n\ninterface Params {\n context: CmsContext;\n}\n\nexport const createContentEntriesSchema = ({\n context\n}: Params): ICmsGraphQLSchemaPlugin<CmsContext> => {\n if (!context.cms.MANAGE) {\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: \"\",\n resolvers: {}\n });\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.empty`;\n return plugin;\n }\n\n const onByMetaFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentity\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n const plugin = createCmsGraphQLSchemaPlugin({\n // Had to remove /* GraphQL */ because it causes issues with oxfmt formatting.\n typeDefs: `\n type CmsModelMeta {\n modelId: String!\n name: String!\n }\n\n type CmsPublishedContentEntry {\n id: ID!\n entryId: String!\n title: String\n description: String\n image: String\n }\n\n type CmsContentEntry {\n id: ID!\n entryId: String!\n model: CmsModelMeta!\n status: String!\n published: CmsPublishedContentEntry\n title: String!\n description: String\n image: String\n \n ${onByMetaFields}\n \n wbyAco_location: WbyAcoLocation\n }\n\n type CmsContentEntriesResponse {\n data: [CmsContentEntry!]\n error: CmsError\n }\n\n type CmsContentEntryResponse {\n data: CmsContentEntry\n error: CmsError\n }\n\n input CmsModelEntryInput {\n modelId: ID!\n id: ID!\n }\n\n extend type Query {\n # Search content entries for given content models using the query string.\n searchContentEntries(\n modelIds: [ID!]!\n query: String\n fields: [String!]\n limit: Int\n ): CmsContentEntriesResponse!\n\n # Get content entry meta data\n getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n # Get content entries meta data\n getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getPublishedContentEntries(\n entries: [CmsModelEntryInput!]!\n ): CmsContentEntriesResponse!\n }\n `,\n resolvers: {\n CmsContentEntry: {\n published: async (parent, _, context) => {\n try {\n const models = await context.cms.listModels();\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const [entry] = await context.cms.getPublishedEntriesByIds(model, [\n parent.id\n ]);\n if (!entry) {\n return null;\n }\n return createCmsEntryRecord(model, entry);\n } catch {\n return null;\n }\n },\n description: createResolveDescription()\n },\n CmsPublishedContentEntry: {\n description: createResolveDescription()\n },\n Query: {\n async searchContentEntries(_, args: any, context) {\n const { modelIds, fields, query, limit = 10 } = args;\n const models = await context.cms.listModels();\n\n const getters = models\n .filter(model => modelIds.includes(model.modelId))\n .map(async model => {\n const listLatest =\n await context.container.resolve(ListLatestEntriesUseCase);\n const where: CmsEntryListWhere = {};\n\n const result = await listLatest.execute(model, {\n limit,\n where,\n search: !!query ? query : undefined,\n fields: fields || []\n });\n // TODO figure a better way to handle errors in parallel execution\n if (result.isFail()) {\n throw result.error;\n }\n const { entries } = result.value;\n return entries.map((entry: CmsEntry) => {\n return createCmsEntryRecord(model, entry);\n });\n });\n\n try {\n const entries = await Promise.all(getters).then(results =>\n results.reduce((result, item) => result.concat(item), [])\n );\n\n return new Response(\n entries\n .sort((a, b) => b.savedOn.getTime() - a.savedOn.getTime())\n .slice(0, limit)\n );\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n async getContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"published\"\n });\n },\n async getContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"published\"\n });\n }\n }\n }\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-entries`;\n\n return plugin;\n};\n"],"names":["createDate","date","Date","createCmsEntryRecord","model","entry","getEntryTitle","getEntryDescription","getEntryImage","getFetchMethod","type","context","getContentEntriesMethods","WebinyError","methodName","getContentEntries","params","args","method","models","modelsMap","collection","argsEntries","entriesByModel","ref","getters","Object","modelId","Response","results","Promise","entries","items","item","Boolean","ex","ErrorResponse","getContentEntry","id","m","NotAuthorizedResponse","result","createResolveDescription","parent","_","field","f","value","entryFieldFromStorageTransform","createContentEntriesSchema","plugin","createCmsGraphQLSchemaPlugin","onByMetaFields","ENTRY_META_FIELDS","fieldType","isDateTimeEntryMetaField","modelIds","fields","query","limit","listLatest","ListLatestEntriesUseCase","where","undefined","a","b"],"mappings":";;;;;;;;;;AA0BA,MAAMA,aAAa,CAACC;IAChB,IAAI,CAACA,MACD,OAAO;IAGX,IAAI;QACA,OAAO,IAAIC,KAAKD;IACpB,EAAE,OAAM;QACJ,OAAO,IAAIC;IACf;AACJ;AA+CA,MAAMC,uBAAuB,CAACC,OAAiBC,QACpC;QACH,IAAIA,MAAM,EAAE;QACZ,SAASA,MAAM,OAAO;QACtB,OAAO;YACH,SAASD,MAAM,OAAO;YACtB,MAAMA,MAAM,IAAI;QACpB;QACA,QAAQC,MAAM,MAAM;QACpB,OAAOC,cAAcF,OAAOC;QAC5B,aAAaE,oBAAoBH,OAAOC;QACxC,OAAOG,cAAcJ,OAAOC;QAK5B,WAAWL,WAAWK,MAAM,SAAS;QACrC,YAAYL,WAAWK,MAAM,UAAU;QACvC,SAASL,WAAWK,MAAM,OAAO;QACjC,WAAWA,MAAM,SAAS;QAC1B,SAASA,MAAM,OAAO;QACtB,YAAYA,MAAM,UAAU;QAC5B,kBAAkBL,WAAWK,MAAM,gBAAgB;QACnD,iBAAiBL,WAAWK,MAAM,eAAe;QACjD,kBAAkBA,MA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;gBACA,MAAM,yBAAwBiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBAC/C,OAAOI,kBAAkB;wBACrBE;wBACAN;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,4BAA2BiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBAClD,OAAOI,kBAAkB;wBACrBE;wBACAN;wBACA,MAAM;oBACV;gBACJ;YACJ;QACJ;IACJ;IAEAuC,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAEvC,QAAQ,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC;IAE/E,OAAOuC;AACX"}
|
|
1
|
+
{"version":3,"file":"graphql/schema/contentEntries.js","sources":["../../../src/graphql/schema/contentEntries.ts"],"sourcesContent":["import { ErrorResponse, Response } from \"@webiny/api-graphql\";\nimport type {\n CmsContext,\n CmsEntry,\n CmsEntryListWhere,\n CmsIdentity,\n CmsModel\n} from \"~/types/index.js\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { getEntryDescription } from \"~/utils/getEntryDescription.js\";\nimport { getEntryImage } from \"~/utils/getEntryImage.js\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage.js\";\nimport type { GraphQLFieldResolver } from \"@webiny/api-graphql/types.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { ListLatestEntriesUseCase } from \"~/features/contentEntry/ListEntries/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\nimport { GetLatestEntriesByIdsUseCase } from \"~/features/contentEntry/GetLatestEntriesByIds/index.js\";\nimport { GetPublishedEntriesByIdsUseCase } from \"~/features/contentEntry/GetPublishedEntriesByIds/index.js\";\nimport { GetEntriesByIdsUseCase } from \"~/features/contentEntry/GetEntriesByIds/index.js\";\nimport { HeadlessCmsEndpointConfig } from \"~/HeadlessCmsEndpointConfig.js\";\n\ninterface EntriesByModel {\n [key: string]: string[];\n}\n\ntype GetContentEntryType = \"latest\" | \"published\" | \"exact\";\n\nconst createDate = (date: string | null): Date | null => {\n if (!date) {\n return null;\n }\n\n try {\n return new Date(date);\n } catch {\n return new Date();\n }\n};\n\n/**\n * How many matches per model `searchContentEntries` reads before ranking them by title.\n */\nconst SEARCH_CANDIDATES_LIMIT = 100;\n\n/**\n * Lower rank comes first: an exact title match, then a title starting with the query,\n * then a title containing it, then entries that matched on some other field.\n */\nconst getSearchRank = (title: string, query?: string): number => {\n const normalizedQuery = query?.trim().toLowerCase();\n if (!normalizedQuery) {\n return 0;\n }\n const normalizedTitle = (title || \"\").trim().toLowerCase();\n if (normalizedTitle === normalizedQuery) {\n return 0;\n } else if (normalizedTitle.startsWith(normalizedQuery)) {\n return 1;\n } else if (normalizedTitle.includes(normalizedQuery)) {\n return 2;\n }\n return 3;\n};\n\ninterface CmsEntryRecord {\n id: string;\n entryId: string;\n model: {\n modelId: string;\n name: string;\n };\n status: string;\n title: string;\n description?: string | null;\n image?: string | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: Date;\n modifiedOn: Date | null;\n savedOn: Date;\n createdBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n savedBy: CmsIdentity;\n firstPublishedOn: Date | null;\n lastPublishedOn: Date | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: Date;\n revisionModifiedOn: Date | null;\n revisionSavedOn: Date;\n revisionCreatedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionSavedBy: CmsIdentity;\n revisionFirstPublishedOn: Date | null;\n revisionLastPublishedOn: Date | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n wbyAco_location?: {\n folderId?: string | null;\n };\n}\n\nconst createCmsEntryRecord = (model: CmsModel, entry: CmsEntry): CmsEntryRecord => {\n return {\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry),\n description: getEntryDescription(model, entry),\n image: getEntryImage(model, entry),\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: createDate(entry.createdOn)!,\n modifiedOn: createDate(entry.modifiedOn),\n savedOn: createDate(entry.savedOn)!,\n createdBy: entry.createdBy,\n savedBy: entry.savedBy,\n modifiedBy: entry.modifiedBy,\n firstPublishedOn: createDate(entry.firstPublishedOn),\n lastPublishedOn: createDate(entry.lastPublishedOn),\n firstPublishedBy: entry.firstPublishedBy,\n lastPublishedBy: entry.lastPublishedBy,\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: createDate(entry.revisionCreatedOn)!,\n revisionSavedOn: createDate(entry.revisionSavedOn)!,\n revisionModifiedOn: createDate(entry.revisionModifiedOn),\n revisionCreatedBy: entry.revisionCreatedBy,\n revisionModifiedBy: entry.revisionModifiedBy,\n revisionSavedBy: entry.revisionSavedBy,\n revisionFirstPublishedOn: createDate(entry.revisionFirstPublishedOn),\n revisionLastPublishedOn: createDate(entry.revisionLastPublishedOn),\n revisionFirstPublishedBy: entry.revisionFirstPublishedBy,\n revisionLastPublishedBy: entry.revisionLastPublishedBy,\n\n wbyAco_location: {\n folderId: entry.location?.folderId || null\n }\n };\n};\n\ninterface FetchMethod {\n (model: CmsModel, ids: string[]): Promise<CmsEntry[]>;\n}\n\nconst getFetchMethod = (type: GetContentEntryType, context: CmsContext): FetchMethod => {\n if (type === \"latest\") {\n return async (model, ids) => {\n const result = await context.container\n .resolve(GetLatestEntriesByIdsUseCase)\n .execute(model, ids);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n } else if (type === \"published\") {\n return async (model, ids) => {\n const result = await context.container\n .resolve(GetPublishedEntriesByIdsUseCase)\n .execute(model, ids);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n } else {\n return async (model, ids) => {\n const result = await context.container\n .resolve(GetEntriesByIdsUseCase)\n .execute(model, ids);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n }\n};\n\n/**\n * Function to get the list of content entries depending on latest, published or exact GraphQL queries.\n */\ninterface GetContentEntriesParams {\n args: {\n entries: Pick<CmsEntry, \"id\" | \"modelId\">[];\n };\n context: CmsContext;\n type: GetContentEntryType;\n}\n\nconst getContentEntries = async (\n params: GetContentEntriesParams\n): Promise<Response | ErrorResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const modelsResult = await context.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n throw modelsResult.error;\n }\n const models = modelsResult.value;\n\n const modelsMap = models.reduce(\n (collection, model) => {\n collection[model.modelId] = model;\n return collection;\n },\n {} as Record<string, CmsModel>\n );\n\n const argsEntries = args.entries as Pick<CmsEntry, \"id\" | \"modelId\">[];\n\n const entriesByModel = argsEntries.reduce((collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.id)) {\n return collection;\n }\n collection[ref.modelId].push(ref.id);\n return collection;\n }, {} as EntriesByModel);\n\n const getters: Promise<CmsEntry[]>[] = Object.keys(entriesByModel).map(async modelId => {\n return method(modelsMap[modelId], entriesByModel[modelId]);\n });\n\n if (getters.length === 0) {\n return new Response([]);\n }\n\n try {\n const results = await Promise.all(getters);\n\n const entries = results\n .reduce<CmsEntryRecord[]>((collection, items) => {\n return collection.concat(\n items.map(item => {\n const model = modelsMap[item.modelId];\n\n return createCmsEntryRecord(model, item);\n })\n );\n }, [])\n .filter(Boolean);\n\n return new Response(entries);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\n/**\n * Function to fetch a single content entry depending on latest, published or exact GraphQL query.\n */\ninterface GetContentEntryParams {\n args: {\n entry: Pick<CmsEntry, \"id\" | \"modelId\">;\n };\n context: CmsContext;\n type: \"latest\" | \"published\" | \"exact\";\n}\n\nconst getContentEntry = async (\n params: GetContentEntryParams\n): Promise<Response<CmsEntryRecord | null> | NotAuthorizedResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const { modelId, id } = args.entry;\n const modelsResult = await context.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n throw modelsResult.error;\n }\n const model = modelsResult.value.find(m => m.modelId === modelId);\n\n if (!model) {\n return new NotAuthorizedResponse({\n data: {\n modelId\n }\n });\n }\n\n const result = await method(model, [id]);\n\n const entry = result.shift();\n if (!entry) {\n return new Response(null);\n }\n\n return new Response(createCmsEntryRecord(model, entry));\n};\n/**\n * As we support description field, we need to transform the value from storage.\n */\nconst createResolveDescription = (): GraphQLFieldResolver<any, any, CmsContext> => {\n return async (parent, _, context) => {\n const modelsResult = await context.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n return null;\n }\n const model = modelsResult.value.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return null;\n }\n const value = parent.description || parent[field.fieldId];\n if (!value) {\n return null;\n }\n return entryFieldFromStorageTransform({\n context,\n model,\n field,\n value\n });\n };\n};\n\ninterface Params {\n context: CmsContext;\n}\n\nexport const createContentEntriesSchema = ({\n context\n}: Params): ICmsGraphQLSchemaPlugin<CmsContext> => {\n const enhancerConfig = context.container.resolve(HeadlessCmsEndpointConfig);\n if (enhancerConfig.type !== \"manage\") {\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: \"\",\n resolvers: {}\n });\n plugin.name = `headless-cms.graphql.schema.${enhancerConfig.type}.empty`;\n return plugin;\n }\n\n const onByMetaFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentity\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n const plugin = createCmsGraphQLSchemaPlugin({\n // Had to remove /* GraphQL */ because it causes issues with oxfmt formatting.\n typeDefs: `\n type CmsModelMeta {\n modelId: String!\n name: String!\n }\n\n type CmsPublishedContentEntry {\n id: ID!\n entryId: String!\n title: String\n description: String\n image: String\n }\n\n type CmsContentEntry {\n id: ID!\n entryId: String!\n model: CmsModelMeta!\n status: String!\n published: CmsPublishedContentEntry\n title: String!\n description: String\n image: String\n \n ${onByMetaFields}\n \n wbyAco_location: WbyAcoLocation\n }\n\n type CmsContentEntriesResponse {\n data: [CmsContentEntry!]\n error: CmsError\n }\n\n type CmsContentEntryResponse {\n data: CmsContentEntry\n error: CmsError\n }\n\n input CmsModelEntryInput {\n modelId: ID!\n id: ID!\n }\n\n extend type Query {\n # Search content entries for given content models using the query string.\n searchContentEntries(\n modelIds: [ID!]!\n query: String\n fields: [String!]\n limit: Int\n ): CmsContentEntriesResponse!\n\n # Get content entry meta data\n getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n # Get content entries meta data\n getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getPublishedContentEntries(\n entries: [CmsModelEntryInput!]!\n ): CmsContentEntriesResponse!\n }\n `,\n resolvers: {\n CmsContentEntry: {\n published: async (parent, _, context) => {\n try {\n const modelsResult = await context.container\n .resolve(ListModelsUseCase)\n .execute();\n if (modelsResult.isFail()) {\n return null;\n }\n const model = modelsResult.value.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const result = await context.container\n .resolve(GetPublishedEntriesByIdsUseCase)\n .execute(model, [parent.id]);\n if (result.isFail()) {\n return null;\n }\n const entry = result.value[0];\n if (!entry) {\n return null;\n }\n return createCmsEntryRecord(model, entry);\n } catch {\n return null;\n }\n },\n description: createResolveDescription()\n },\n CmsPublishedContentEntry: {\n description: createResolveDescription()\n },\n Query: {\n async searchContentEntries(_, args: any, context) {\n const { modelIds, fields, query, limit = 10 } = args;\n const modelsResult = await context.container\n .resolve(ListModelsUseCase)\n .execute();\n if (modelsResult.isFail()) {\n return new ErrorResponse(modelsResult.error);\n }\n const models = modelsResult.value;\n\n /**\n * Full-text search matches the query against every searchable field, and the storage\n * returns the newest-created matches first. When many entries mention the query somewhere\n * in their content, an older entry whose title is the query falls outside the first `limit`.\n * So when searching, read more candidates than requested, rank them by title, then cut.\n */\n const storageLimit = query ? Math.max(limit, SEARCH_CANDIDATES_LIMIT) : limit;\n\n const getters = models\n .filter(model => modelIds.includes(model.modelId))\n .map(async model => {\n const listLatest =\n await context.container.resolve(ListLatestEntriesUseCase);\n const where: CmsEntryListWhere = {};\n\n const result = await listLatest.execute(model, {\n limit: storageLimit,\n where,\n search: !!query ? query : undefined,\n fields: fields || []\n });\n // TODO figure a better way to handle errors in parallel execution\n if (result.isFail()) {\n throw result.error;\n }\n const { entries } = result.value;\n return entries.map((entry: CmsEntry) => {\n return createCmsEntryRecord(model, entry);\n });\n });\n\n try {\n const entries = await Promise.all(getters).then(results =>\n results.reduce((result, item) => result.concat(item), [])\n );\n\n return new Response(\n entries\n .sort((a, b) => {\n const rank =\n getSearchRank(a.title, query) -\n getSearchRank(b.title, query);\n if (rank !== 0) {\n return rank;\n }\n return b.savedOn.getTime() - a.savedOn.getTime();\n })\n .slice(0, limit)\n );\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n async getContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"published\"\n });\n },\n async getContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"published\"\n });\n }\n }\n }\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.container.resolve(HeadlessCmsEndpointConfig).type}.content-entries`;\n\n return plugin;\n};\n"],"names":["createDate","date","Date","SEARCH_CANDIDATES_LIMIT","getSearchRank","title","query","normalizedQuery","normalizedTitle","createCmsEntryRecord","model","entry","getEntryTitle","getEntryDescription","getEntryImage","getFetchMethod","type","context","ids","result","GetLatestEntriesByIdsUseCase","GetPublishedEntriesByIdsUseCase","GetEntriesByIdsUseCase","getContentEntries","params","args","method","modelsResult","ListModelsUseCase","models","modelsMap","collection","argsEntries","entriesByModel","ref","getters","Object","modelId","Response","results","Promise","entries","items","item","Boolean","ex","ErrorResponse","getContentEntry","id","m","NotAuthorizedResponse","createResolveDescription","parent","_","field","f","value","entryFieldFromStorageTransform","createContentEntriesSchema","enhancerConfig","HeadlessCmsEndpointConfig","plugin","createCmsGraphQLSchemaPlugin","onByMetaFields","ENTRY_META_FIELDS","fieldType","isDateTimeEntryMetaField","modelIds","fields","limit","storageLimit","Math","listLatest","ListLatestEntriesUseCase","where","undefined","a","b","rank"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAMA,aAAa,CAACC;IAChB,IAAI,CAACA,MACD,OAAO;IAGX,IAAI;QACA,OAAO,IAAIC,KAAKD;IACpB,EAAE,OAAM;QACJ,OAAO,IAAIC;IACf;AACJ;AAKA,MAAMC,0BAA0B;AAMhC,MAAMC,gBAAgB,CAACC,OAAeC;IAClC,MAAMC,kBAAkBD,OAAO,OAAO;IACtC,IAAI,CAACC,iBACD,OAAO;IAEX,MAAMC,kBAAmBH,AAAAA,CAAAA,SAAS,EAAC,EAAG,IAAI,GAAG,WAAW;IACx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AAO;oBAC7C,OAAO8B,gBAAgB;wBACnBtB;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,0BAAyBoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBAChD,OAAO8B,gBAAgB;wBACnBtB;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,mBAAkBoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBACzC,OAAOM,kBAAkB;wBACrBE;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,yBAAwBoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBAC/C,OAAOM,kBAAkB;wBACrBE;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,4BAA2BoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBAClD,OAAOM,kBAAkB;wBACrBE;wBACAR;wBACA,MAAM;oBACV;gBACJ;YACJ;QACJ;IACJ;IAEA4C,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAE5C,QAAQ,SAAS,CAAC,OAAO,CAAC2C,2BAA2B,IAAI,CAAC,gBAAgB,CAAC;IAExH,OAAOC;AACX"}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { ErrorResponse, NotFoundError, Response } from "@webiny/
|
|
2
|
-
import {
|
|
1
|
+
import { ErrorResponse, NotFoundError, Response } from "@webiny/api-graphql";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
3
3
|
import { createCmsGraphQLSchemaPlugin } from "../../plugins/index.js";
|
|
4
|
+
import { GetGroupUseCase } from "../../features/contentModelGroup/GetGroup/index.js";
|
|
5
|
+
import { ListGroupsUseCase } from "../../features/contentModelGroup/ListGroups/index.js";
|
|
6
|
+
import { CreateGroupUseCase } from "../../features/contentModelGroup/CreateGroup/index.js";
|
|
7
|
+
import { UpdateGroupUseCase } from "../../features/contentModelGroup/UpdateGroup/index.js";
|
|
8
|
+
import { DeleteGroupUseCase } from "../../features/contentModelGroup/DeleteGroup/index.js";
|
|
9
|
+
import { PluginGroupsProvider } from "../../features/contentModelGroup/shared/index.js";
|
|
10
|
+
import { ListModelsUseCase } from "../../features/contentModel/ListModels/index.js";
|
|
11
|
+
import { HeadlessCmsEndpointConfig } from "../../HeadlessCmsEndpointConfig.js";
|
|
4
12
|
const createGroupsSchema = ({ context })=>{
|
|
13
|
+
const isManage = "manage" === context.container.resolve(HeadlessCmsEndpointConfig).type;
|
|
5
14
|
let manageSchema = "";
|
|
6
|
-
if (
|
|
15
|
+
if (isManage) manageSchema = `
|
|
7
16
|
input CmsContentModelGroupInput {
|
|
8
17
|
id: ID
|
|
9
18
|
name: String!
|
|
@@ -42,29 +51,36 @@ const createGroupsSchema = ({ context })=>{
|
|
|
42
51
|
}
|
|
43
52
|
`;
|
|
44
53
|
let resolvers = {};
|
|
45
|
-
if (
|
|
54
|
+
if (isManage) resolvers = {
|
|
46
55
|
CmsContentModelGroup: {
|
|
47
56
|
contentModels: async (group, _, context)=>{
|
|
48
|
-
const
|
|
49
|
-
|
|
57
|
+
const result = await context.container.resolve(IdentityContext).withoutAuthorization(async ()=>context.container.resolve(ListModelsUseCase).execute());
|
|
58
|
+
if (result.isFail()) return [];
|
|
59
|
+
return result.value.filter((model)=>{
|
|
50
60
|
if (true === model.isPrivate) return false;
|
|
51
61
|
return model.group === group.slug;
|
|
52
62
|
});
|
|
53
63
|
},
|
|
54
64
|
totalContentModels: async (group, _, context)=>{
|
|
55
|
-
const
|
|
56
|
-
|
|
65
|
+
const result = await context.container.resolve(IdentityContext).withoutAuthorization(async ()=>context.container.resolve(ListModelsUseCase).execute());
|
|
66
|
+
if (result.isFail()) return 0;
|
|
67
|
+
return result.value.filter((model)=>{
|
|
57
68
|
if (true === model.isPrivate) return false;
|
|
58
69
|
return model.group === group.slug;
|
|
59
70
|
}).length;
|
|
60
71
|
},
|
|
61
|
-
plugin: async (group, _, context)=>
|
|
72
|
+
plugin: async (group, _, context)=>{
|
|
73
|
+
const pluginGroups = await context.container.resolve(PluginGroupsProvider).getGroups();
|
|
74
|
+
return pluginGroups.some((pg)=>pg.id === group.id);
|
|
75
|
+
}
|
|
62
76
|
},
|
|
63
77
|
Query: {
|
|
64
78
|
getContentModelGroup: async (_, args, context)=>{
|
|
65
79
|
try {
|
|
66
80
|
const { id } = args;
|
|
67
|
-
const
|
|
81
|
+
const result = await context.container.resolve(GetGroupUseCase).execute(id);
|
|
82
|
+
if (result.isFail()) throw result.error;
|
|
83
|
+
const group = result.value;
|
|
68
84
|
if (group?.isPrivate) throw new NotFoundError(`Cms Group "${id}" was not found!`);
|
|
69
85
|
return new Response(group);
|
|
70
86
|
} catch (e) {
|
|
@@ -73,8 +89,9 @@ const createGroupsSchema = ({ context })=>{
|
|
|
73
89
|
},
|
|
74
90
|
listContentModelGroups: async (_, __, context)=>{
|
|
75
91
|
try {
|
|
76
|
-
const
|
|
77
|
-
|
|
92
|
+
const result = await context.container.resolve(ListGroupsUseCase).execute();
|
|
93
|
+
if (result.isFail()) throw result.error;
|
|
94
|
+
return new Response(result.value.filter((group)=>true !== group.isPrivate));
|
|
78
95
|
} catch (e) {
|
|
79
96
|
return new ErrorResponse(e);
|
|
80
97
|
}
|
|
@@ -83,23 +100,26 @@ const createGroupsSchema = ({ context })=>{
|
|
|
83
100
|
Mutation: {
|
|
84
101
|
createContentModelGroup: async (_, args, context)=>{
|
|
85
102
|
try {
|
|
86
|
-
const
|
|
87
|
-
|
|
103
|
+
const result = await context.container.resolve(CreateGroupUseCase).execute(args.data);
|
|
104
|
+
if (result.isFail()) throw result.error;
|
|
105
|
+
return new Response(result.value);
|
|
88
106
|
} catch (e) {
|
|
89
107
|
return new ErrorResponse(e);
|
|
90
108
|
}
|
|
91
109
|
},
|
|
92
110
|
updateContentModelGroup: async (_, args, context)=>{
|
|
93
111
|
try {
|
|
94
|
-
const
|
|
95
|
-
|
|
112
|
+
const result = await context.container.resolve(UpdateGroupUseCase).execute(args.id, args.data);
|
|
113
|
+
if (result.isFail()) throw result.error;
|
|
114
|
+
return new Response(result.value);
|
|
96
115
|
} catch (e) {
|
|
97
116
|
return new ErrorResponse(e);
|
|
98
117
|
}
|
|
99
118
|
},
|
|
100
119
|
deleteContentModelGroup: async (_, args, context)=>{
|
|
101
120
|
try {
|
|
102
|
-
await context.
|
|
121
|
+
const result = await context.container.resolve(DeleteGroupUseCase).execute(args.id);
|
|
122
|
+
if (result.isFail()) throw result.error;
|
|
103
123
|
return new Response(true);
|
|
104
124
|
} catch (e) {
|
|
105
125
|
return new ErrorResponse(e);
|
|
@@ -128,7 +148,8 @@ const createGroupsSchema = ({ context })=>{
|
|
|
128
148
|
`,
|
|
129
149
|
resolvers
|
|
130
150
|
});
|
|
131
|
-
|
|
151
|
+
const endpointType = context.container.resolve(HeadlessCmsEndpointConfig).type;
|
|
152
|
+
plugin.name = `headless-cms.graphql.schema.${endpointType}.content-model-groups`;
|
|
132
153
|
return plugin;
|
|
133
154
|
};
|
|
134
155
|
export { createGroupsSchema };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/schema/contentModelGroups.js","sources":["../../../src/graphql/schema/contentModelGroups.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/handler-graphql\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport type { Resolvers } from \"@webiny/handler-graphql/types.js\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\n\ninterface Params {\n context: CmsContext;\n}\nexport const createGroupsSchema = ({ context }: Params): ICmsGraphQLSchemaPlugin => {\n let manageSchema = \"\";\n if (context.cms.MANAGE) {\n manageSchema = /* GraphQL */ `\n input CmsContentModelGroupInput {\n id: ID\n name: String!\n slug: String\n description: String\n icon: Icon!\n }\n\n type CmsContentModelGroupResponse {\n data: CmsContentModelGroup\n error: CmsError\n }\n\n type CmsContentModelGroupListResponse {\n data: [CmsContentModelGroup]\n meta: CmsListMeta\n error: CmsError\n }\n\n extend type Query {\n getContentModelGroup(id: ID): CmsContentModelGroupResponse\n listContentModelGroups: CmsContentModelGroupListResponse\n }\n\n extend type Mutation {\n createContentModelGroup(\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n updateContentModelGroup(\n id: ID!\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n deleteContentModelGroup(id: ID!): CmsDeleteResponse\n }\n `;\n }\n\n let resolvers: Resolvers<CmsContext> = {};\n\n if (context.cms.MANAGE) {\n resolvers = {\n CmsContentModelGroup: {\n contentModels: async (group, _, context) => {\n const models = await context.security.withoutAuthorization(async () => {\n return context.cms.listModels();\n });\n return models.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.slug;\n });\n },\n totalContentModels: async (group, _, context) => {\n const models = await context.security.withoutAuthorization(async () => {\n return context.cms.listModels();\n });\n return models.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.slug;\n }).length;\n },\n plugin: async (group, _, context: CmsContext): Promise<boolean> => {\n return context.plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .some(item => item.contentModelGroup.id === group.id);\n }\n },\n Query: {\n getContentModelGroup: async (_, args: any, context) => {\n try {\n const { id } = args;\n const group = await context.cms.getGroup(id);\n if (group?.isPrivate) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listContentModelGroups: async (_, __, context) => {\n try {\n const groups = await context.cms.listGroups();\n return new Response(groups.filter(group => group.isPrivate !== true));\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n Mutation: {\n createContentModelGroup: async (_, args: any, context) => {\n try {\n const model = await context.cms.createGroup(args.data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n updateContentModelGroup: async (_, args: any, context) => {\n try {\n const group = await context.cms.updateGroup(args.id, args.data);\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n deleteContentModelGroup: async (_, args: any, context) => {\n try {\n await context.cms.deleteGroup(args.id);\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n }\n };\n }\n\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsContentModelGroup {\n id: ID!\n createdOn: DateTime\n savedOn: DateTime\n name: String!\n contentModels: [CmsContentModel!]\n totalContentModels: Int!\n slug: String!\n description: String\n icon: Icon\n createdBy: CmsIdentity\n\n # Returns true if the content model group is registered via a plugin.\n plugin: Boolean!\n }\n ${manageSchema}\n `,\n resolvers\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-model-groups`;\n\n return plugin;\n};\n"],"names":["createGroupsSchema","context","manageSchema","resolvers","group","_","models","model","CmsGroupPlugin","item","args","id","NotFoundError","Response","e","ErrorResponse","__","groups","plugin","createCmsGraphQLSchemaPlugin"],"mappings":";;;AAUO,MAAMA,qBAAqB,CAAC,EAAEC,OAAO,EAAU;IAClD,IAAIC,eAAe;IACnB,IAAID,QAAQ,GAAG,CAAC,MAAM,EAClBC,eAA6B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAqC9B,CAAC;IAGL,IAAIC,YAAmC,CAAC;IAExC,IAAIF,QAAQ,GAAG,CAAC,MAAM,EAClBE,YAAY;QACR,sBAAsB;YAClB,eAAe,OAAOC,OAAOC,GAAGJ;gBAC5B,MAAMK,SAAS,MAAML,QAAQ,QAAQ,CAAC,oBAAoB,CAAC,UAChDA,QAAQ,GAAG,CAAC,UAAU;gBAEjC,OAAOK,OAAO,MAAM,CAACC,CAAAA;oBACjB,IAAIA,AAAoB,SAApBA,MAAM,SAAS,EACf,OAAO;oBAEX,OAAOA,MAAM,KAAK,KAAKH,MAAM,IAAI;gBACrC;YACJ;YACA,oBAAoB,OAAOA,OAAOC,GAA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AIC,cAAcD;gBAC7B;YACJ;YACA,yBAAyB,OAAOT,GAAGK,MAAWT;gBAC1C,IAAI;oBACA,MAAMG,QAAQ,MAAMH,QAAQ,GAAG,CAAC,WAAW,CAACS,KAAK,EAAE,EAAEA,KAAK,IAAI;oBAC9D,OAAO,IAAIG,SAAST;gBACxB,EAAE,OAAOU,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;YACA,yBAAyB,OAAOT,GAAGK,MAAWT;gBAC1C,IAAI;oBACA,MAAMA,QAAQ,GAAG,CAAC,WAAW,CAACS,KAAK,EAAE;oBACrC,OAAO,IAAIG,SAAS;gBACxB,EAAE,OAAOC,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;QACJ;IACJ;IAGJ,MAAMI,SAASC,6BAA6B;QACxC,UAAwB,CAAC;;;;;;;;;;;;;;;;YAgBrB,EAAEjB,aAAa;QACnB,CAAC;QACDC;IACJ;IAEAe,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAEjB,QAAQ,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC;IAEpF,OAAOiB;AACX"}
|
|
1
|
+
{"version":3,"file":"graphql/schema/contentModelGroups.js","sources":["../../../src/graphql/schema/contentModelGroups.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/api-graphql\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport type { Resolvers } from \"@webiny/api-graphql/types.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { GetGroupUseCase } from \"~/features/contentModelGroup/GetGroup/index.js\";\nimport { ListGroupsUseCase } from \"~/features/contentModelGroup/ListGroups/index.js\";\nimport { CreateGroupUseCase } from \"~/features/contentModelGroup/CreateGroup/index.js\";\nimport { UpdateGroupUseCase } from \"~/features/contentModelGroup/UpdateGroup/index.js\";\nimport { DeleteGroupUseCase } from \"~/features/contentModelGroup/DeleteGroup/index.js\";\nimport { PluginGroupsProvider } from \"~/features/contentModelGroup/shared/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\nimport { HeadlessCmsEndpointConfig } from \"~/HeadlessCmsEndpointConfig.js\";\n\ninterface Params {\n context: CmsContext;\n}\nexport const createGroupsSchema = ({ context }: Params): ICmsGraphQLSchemaPlugin => {\n const isManage = context.container.resolve(HeadlessCmsEndpointConfig).type === \"manage\";\n\n let manageSchema = \"\";\n if (isManage) {\n manageSchema = /* GraphQL */ `\n input CmsContentModelGroupInput {\n id: ID\n name: String!\n slug: String\n description: String\n icon: Icon!\n }\n\n type CmsContentModelGroupResponse {\n data: CmsContentModelGroup\n error: CmsError\n }\n\n type CmsContentModelGroupListResponse {\n data: [CmsContentModelGroup]\n meta: CmsListMeta\n error: CmsError\n }\n\n extend type Query {\n getContentModelGroup(id: ID): CmsContentModelGroupResponse\n listContentModelGroups: CmsContentModelGroupListResponse\n }\n\n extend type Mutation {\n createContentModelGroup(\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n updateContentModelGroup(\n id: ID!\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n deleteContentModelGroup(id: ID!): CmsDeleteResponse\n }\n `;\n }\n\n let resolvers: Resolvers<CmsContext> = {};\n\n if (isManage) {\n resolvers = {\n CmsContentModelGroup: {\n contentModels: async (group, _, context) => {\n const result = await context.container\n .resolve(IdentityContext)\n .withoutAuthorization(async () => {\n return context.container.resolve(ListModelsUseCase).execute();\n });\n if (result.isFail()) {\n return [];\n }\n return result.value.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.slug;\n });\n },\n totalContentModels: async (group, _, context) => {\n const result = await context.container\n .resolve(IdentityContext)\n .withoutAuthorization(async () => {\n return context.container.resolve(ListModelsUseCase).execute();\n });\n if (result.isFail()) {\n return 0;\n }\n return result.value.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.slug;\n }).length;\n },\n plugin: async (group, _, context) => {\n const pluginGroups = await context.container\n .resolve(PluginGroupsProvider)\n .getGroups();\n return pluginGroups.some(pg => pg.id === group.id);\n }\n },\n Query: {\n getContentModelGroup: async (_, args: any, context) => {\n try {\n const { id } = args;\n const result = await context.container.resolve(GetGroupUseCase).execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n const group = result.value;\n if (group?.isPrivate) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listContentModelGroups: async (_, __, context) => {\n try {\n const result = await context.container.resolve(ListGroupsUseCase).execute();\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(result.value.filter(group => group.isPrivate !== true));\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n Mutation: {\n createContentModelGroup: async (_, args: any, context) => {\n try {\n const result = await context.container\n .resolve(CreateGroupUseCase)\n .execute(args.data);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(result.value);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n updateContentModelGroup: async (_, args: any, context) => {\n try {\n const result = await context.container\n .resolve(UpdateGroupUseCase)\n .execute(args.id, args.data);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(result.value);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n deleteContentModelGroup: async (_, args: any, context) => {\n try {\n const result = await context.container\n .resolve(DeleteGroupUseCase)\n .execute(args.id);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n }\n };\n }\n\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsContentModelGroup {\n id: ID!\n createdOn: DateTime\n savedOn: DateTime\n name: String!\n contentModels: [CmsContentModel!]\n totalContentModels: Int!\n slug: String!\n description: String\n icon: Icon\n createdBy: CmsIdentity\n\n # Returns true if the content model group is registered via a plugin.\n plugin: Boolean!\n }\n ${manageSchema}\n `,\n resolvers\n });\n\n const endpointType = context.container.resolve(HeadlessCmsEndpointConfig).type;\n plugin.name = `headless-cms.graphql.schema.${endpointType}.content-model-groups`;\n\n return plugin;\n};\n"],"names":["createGroupsSchema","context","isManage","HeadlessCmsEndpointConfig","manageSchema","resolvers","group","_","result","IdentityContext","ListModelsUseCase","model","pluginGroups","PluginGroupsProvider","pg","args","id","GetGroupUseCase","NotFoundError","Response","e","ErrorResponse","__","ListGroupsUseCase","CreateGroupUseCase","UpdateGroupUseCase","DeleteGroupUseCase","plugin","createCmsGraphQLSchemaPlugin","endpointType"],"mappings":";;;;;;;;;;;AAkBO,MAAMA,qBAAqB,CAAC,EAAEC,OAAO,EAAU;IAClD,MAAMC,WAAWD,AAA8D,aAA9DA,QAAQ,SAAS,CAAC,OAAO,CAACE,2BAA2B,IAAI;IAE1E,IAAIC,eAAe;IACnB,IAAIF,UACAE,eAA6B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAqC9B,CAAC;IAGL,IAAIC,YAAmC,CAAC;IAExC,IAAIH,UACAG,YAAY;QACR,sBAAsB;YAClB,eAAe,OAAOC,OAAOC,GAAGN;gBAC5B,MAAMO,SAAS,MAAMP,QAAQ,SAAS,CACjC,OAAO,CAACQ,iBACR,oBAAoB,CAAC,UACXR,QAAQ,SAAS,CAAC,OAAO,CAACS,mBAAmB,OAAO;gBAEnE,IAAIF,OAAO,MAAM,IACb,OAAO,EAAE;gBAEb,OAAOA,OAAO,KAAK,CAAC,MAAM,CAACG,CAAAA;oBACvB,IAAIA,AAAoB,SAApBA,MAAM,SAAS,EACf,OAAO;oBAEX,OAAOA,MAAM,KAAK,KAAKL,MAAM,IAAI;gBACrC;YACJ;YACA,oBAAoB,OAAOA,OAAOC,GAAGN;gBACjC,MAAMO,SAAS,MAAMP,QAAQ,SAAS,CACjC,OAAO,CAACQ,iBACR,oBAAoB,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