@webiny/api-headless-cms 6.6.0-alpha.0 → 6.6.0-alpha.10
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/HeadlessCmsFeature.js +17 -38
- package/HeadlessCmsFeature.js.map +1 -1
- package/createCmsRoute.d.ts +13 -10
- package/createCmsRoute.js +40 -18
- package/createCmsRoute.js.map +1 -1
- package/crud/contentEntry/entryDataValidation.js +44 -11
- package/crud/contentEntry/entryDataValidation.js.map +1 -1
- package/crud/contentModel/defaultFields.js +3 -2
- package/crud/contentModel/defaultFields.js.map +1 -1
- package/crud/contentModel/validate/endingAllowed.js +1 -1
- package/crud/contentModel/validate/endingAllowed.js.map +1 -1
- package/crud/contentModel/validate/pluralApiName.js +1 -1
- package/crud/contentModel/validate/pluralApiName.js.map +1 -1
- package/crud/contentModel/validate/singularApiName.js +1 -1
- package/crud/contentModel/validate/singularApiName.js.map +1 -1
- package/crud/contentModel/validation.js +2 -2
- package/crud/contentModel/validation.js.map +1 -1
- package/domain/contentModel/schemas.d.ts +10 -6
- package/domain/contentModel/schemas.js +6 -3
- 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/endingAllowed.js +1 -1
- package/domain/contentModel/validation/endingAllowed.js.map +1 -1
- package/domain/contentModel/validation/modelFields.js +4 -2
- package/domain/contentModel/validation/modelFields.js.map +1 -1
- package/domain/contentModel/validation/pluralApiName.js +1 -1
- package/domain/contentModel/validation/pluralApiName.js.map +1 -1
- package/domain/contentModel/validation/singularApiName.js +1 -1
- package/domain/contentModel/validation/singularApiName.js.map +1 -1
- package/export/crud/exporting.js +2 -2
- package/export/crud/exporting.js.map +1 -1
- package/export/crud/imports/importGroups.js +1 -2
- package/export/crud/imports/importGroups.js.map +1 -1
- package/export/crud/imports/validateModels.js +1 -1
- package/export/crud/imports/validateModels.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/model.d.ts +4 -1
- package/exports/api/cms/model.js +2 -0
- 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 -0
- package/features/contentEntry/ContentEntriesFeature.js.map +1 -1
- package/features/contentEntry/CreateEntry/CreateEntryRepository.d.ts +4 -2
- package/features/contentEntry/CreateEntry/CreateEntryRepository.js +8 -3
- package/features/contentEntry/CreateEntry/CreateEntryRepository.js.map +1 -1
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.d.ts +2 -2
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js +3 -4
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.d.ts +4 -2
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js +8 -3
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.d.ts +2 -4
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js +6 -14
- 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 +4 -2
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js +8 -3
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.d.ts +2 -2
- package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js +2 -2
- package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.d.ts +3 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js +7 -3
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.d.ts +2 -2
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js +2 -2
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.d.ts +3 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js +9 -3
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.d.ts +2 -2
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js +2 -2
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js.map +1 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.d.ts +4 -2
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js +7 -3
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js.map +1 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.d.ts +2 -2
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js +11 -10
- 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/DuplicateEntry/feature.d.ts +4 -0
- 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 +4 -4
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js +8 -11
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.d.ts +4 -2
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js +7 -3
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.d.ts +4 -2
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js +7 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.d.ts +4 -2
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js +7 -3
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.d.ts +4 -2
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js +7 -3
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.d.ts +4 -2
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js +7 -3
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.d.ts +4 -2
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js +7 -3
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js.map +1 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.d.ts +4 -2
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js +7 -3
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.d.ts +4 -2
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js +7 -3
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js.map +1 -1
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js +3 -0
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js.map +1 -1
- package/features/contentEntry/ListEntries/ListEntriesRepository.d.ts +4 -2
- package/features/contentEntry/ListEntries/ListEntriesRepository.js +7 -3
- package/features/contentEntry/ListEntries/ListEntriesRepository.js.map +1 -1
- package/features/contentEntry/MoveEntry/MoveEntryRepository.d.ts +4 -2
- package/features/contentEntry/MoveEntry/MoveEntryRepository.js +7 -3
- package/features/contentEntry/MoveEntry/MoveEntryRepository.js.map +1 -1
- package/features/contentEntry/MoveEntry/MoveEntryUseCase.d.ts +2 -2
- package/features/contentEntry/MoveEntry/MoveEntryUseCase.js +11 -4
- package/features/contentEntry/MoveEntry/MoveEntryUseCase.js.map +1 -1
- package/features/contentEntry/PublishEntry/PublishEntryRepository.d.ts +4 -2
- package/features/contentEntry/PublishEntry/PublishEntryRepository.js +8 -3
- package/features/contentEntry/PublishEntry/PublishEntryRepository.js.map +1 -1
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.d.ts +4 -6
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.js +11 -13
- 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 +4 -2
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js +8 -3
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js.map +1 -1
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.d.ts +2 -2
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js +5 -3
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.d.ts +4 -2
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js +8 -3
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js.map +1 -1
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.d.ts +2 -2
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js +2 -2
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js.map +1 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.d.ts +4 -2
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js +8 -3
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js.map +1 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.d.ts +2 -2
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js +5 -3
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.d.ts +4 -2
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js +8 -3
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js.map +1 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.d.ts +2 -2
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js +5 -3
- 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 +2 -2
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js +2 -2
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js.map +1 -1
- package/features/contentEntry/ensureItemIds.d.ts +13 -0
- package/features/contentEntry/ensureItemIds.js +22 -0
- package/features/contentEntry/ensureItemIds.js.map +1 -0
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js +8 -2
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.d.ts +7 -3
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js +46 -13
- 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 +5 -3
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js +22 -15
- 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 +5 -3
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js +17 -12
- 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 +6 -6
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js +17 -17
- 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 +7 -3
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js +72 -28
- 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/expiresAt.js +2 -2
- package/features/contentEntry/entryDataFactories/expiresAt.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/ComponentMapGenerator/ComponentMapGenerator.d.ts +14 -0
- package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.js +32 -0
- package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/abstractions.d.ts +8 -0
- package/features/contentModel/ComponentMapGenerator/abstractions.js +5 -0
- package/features/contentModel/ComponentMapGenerator/abstractions.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/feature.d.ts +4 -0
- package/features/contentModel/ComponentMapGenerator/feature.js +11 -0
- package/features/contentModel/ComponentMapGenerator/feature.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/index.d.ts +2 -0
- package/features/contentModel/ComponentMapGenerator/index.js +2 -0
- package/features/contentModel/ContentModelFeature.js +4 -0
- package/features/contentModel/ContentModelFeature.js.map +1 -1
- package/features/contentModel/CreateModel/CreateModelRepository.js +1 -2
- package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +1 -2
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
- package/features/contentModel/DeleteModel/DeleteModelRepository.d.ts +4 -2
- package/features/contentModel/DeleteModel/DeleteModelRepository.js +7 -3
- package/features/contentModel/DeleteModel/DeleteModelRepository.js.map +1 -1
- package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.d.ts +9 -4
- package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js +36 -21
- 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/RefModelsGenerator/RefModelsGenerator.d.ts +19 -0
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.js +56 -0
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.js.map +1 -0
- package/features/contentModel/RefModelsGenerator/abstractions.d.ts +11 -0
- package/features/contentModel/RefModelsGenerator/abstractions.js +5 -0
- package/features/contentModel/RefModelsGenerator/abstractions.js.map +1 -0
- package/features/contentModel/RefModelsGenerator/feature.d.ts +4 -0
- package/features/contentModel/RefModelsGenerator/feature.js +11 -0
- package/features/contentModel/RefModelsGenerator/feature.js.map +1 -0
- package/features/contentModel/RefModelsGenerator/index.d.ts +2 -0
- package/features/contentModel/RefModelsGenerator/index.js +2 -0
- package/features/contentModel/UpdateModel/UpdateModelRepository.d.ts +4 -2
- package/features/contentModel/UpdateModel/UpdateModelRepository.js +8 -4
- package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
- package/features/contentModel/UpdateModel/UpdateModelUseCase.js +2 -2
- package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
- package/features/contentModel/UpdateModel/abstractions.d.ts +1 -1
- package/features/contentModel/UpdateModel/abstractions.js.map +1 -1
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js +5 -2
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js.map +1 -1
- package/features/contentModel/shared/ModelsFetcher.d.ts +6 -5
- package/features/contentModel/shared/ModelsFetcher.js.map +1 -1
- package/features/contentModel/shared/PluginModelsProvider.d.ts +6 -3
- package/features/contentModel/shared/PluginModelsProvider.js +2 -9
- package/features/contentModel/shared/PluginModelsProvider.js.map +1 -1
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.d.ts +3 -1
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js +6 -4
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js.map +1 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.d.ts +4 -2
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js +7 -3
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.d.ts +4 -2
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js +8 -4
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js +2 -2
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/abstractions.d.ts +1 -1
- package/features/contentModelGroup/UpdateGroup/abstractions.js.map +1 -1
- package/features/graphql/feature.js +2 -0
- package/features/graphql/feature.js.map +1 -1
- package/features/graphql/fields/base/AssetToGraphQL.d.ts +26 -0
- package/features/graphql/fields/base/AssetToGraphQL.js +153 -0
- package/features/graphql/fields/base/AssetToGraphQL.js.map +1 -0
- package/features/graphql/fields/base/DynamicZoneToGraphQL.js +12 -2
- package/features/graphql/fields/base/DynamicZoneToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/ObjectToGraphQL.js +8 -5
- package/features/graphql/fields/base/ObjectToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/RefToGraphQL.js +24 -10
- package/features/graphql/fields/base/RefToGraphQL.js.map +1 -1
- package/features/modelBuilder/abstractions.d.ts +13 -0
- package/features/modelBuilder/abstractions.js.map +1 -1
- package/features/modelBuilder/feature.js +3 -8
- package/features/modelBuilder/feature.js.map +1 -1
- package/features/modelBuilder/fields/AssetFieldType.d.ts +20 -0
- package/features/modelBuilder/fields/AssetFieldType.js +46 -0
- package/features/modelBuilder/fields/AssetFieldType.js.map +1 -0
- package/features/modelBuilder/fields/BaseFieldBuilder.d.ts +3 -1
- package/features/modelBuilder/fields/BaseFieldBuilder.js +4 -0
- package/features/modelBuilder/fields/BaseFieldBuilder.js.map +1 -1
- package/features/modelBuilder/fields/DataFieldBuilder.d.ts +59 -0
- package/features/modelBuilder/fields/DataFieldBuilder.js +11 -1
- 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/DynamicZoneFieldType.d.ts +1 -0
- package/features/modelBuilder/fields/DynamicZoneFieldType.js +10 -9
- package/features/modelBuilder/fields/DynamicZoneFieldType.js.map +1 -1
- package/features/modelBuilder/fields/UiAlertFieldType.js +2 -1
- package/features/modelBuilder/fields/UiAlertFieldType.js.map +1 -1
- package/features/modelBuilder/fields/UiSeparatorFieldType.js +2 -1
- package/features/modelBuilder/fields/UiSeparatorFieldType.js.map +1 -1
- package/features/modelBuilder/fields/UiTabsFieldType.d.ts +2 -1
- package/features/modelBuilder/fields/UiTabsFieldType.js +6 -3
- package/features/modelBuilder/fields/UiTabsFieldType.js.map +1 -1
- package/features/modelBuilder/fields/fieldTypeValidator.d.ts +5 -3
- package/features/modelBuilder/fields/resolveAssetUrl.d.ts +35 -0
- package/features/modelBuilder/fields/resolveAssetUrl.js +26 -0
- package/features/modelBuilder/fields/resolveAssetUrl.js.map +1 -0
- package/features/modelBuilder/index.d.ts +1 -1
- package/features/modelBuilder/models/BaseModelBuilder.d.ts +3 -1
- package/features/modelBuilder/models/BaseModelBuilder.js +7 -0
- package/features/modelBuilder/models/BaseModelBuilder.js.map +1 -1
- package/features/modelBuilder/models/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 +13 -1
- package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
- package/features/modelBuilder/models/PublicModelBuilder.js +2 -1
- package/features/modelBuilder/models/PublicModelBuilder.js.map +1 -1
- package/features/modelStorageSync/ModelStorageSyncTask.d.ts +31 -0
- package/features/modelStorageSync/ModelStorageSyncTask.js +66 -0
- package/features/modelStorageSync/ModelStorageSyncTask.js.map +1 -0
- package/features/modelStorageSync/SyncStorageOnModelUpdate.d.ts +23 -0
- package/features/modelStorageSync/SyncStorageOnModelUpdate.js +51 -0
- package/features/modelStorageSync/SyncStorageOnModelUpdate.js.map +1 -0
- package/features/modelStorageSync/abstractions.d.ts +34 -0
- package/features/modelStorageSync/abstractions.js +6 -0
- package/features/modelStorageSync/abstractions.js.map +1 -0
- package/features/modelStorageSync/feature.d.ts +8 -0
- package/features/modelStorageSync/feature.js +13 -0
- package/features/modelStorageSync/feature.js.map +1 -0
- package/features/modelStorageSync/index.d.ts +2 -0
- package/features/modelStorageSync/index.js +2 -0
- package/features/runtimeTenant/RuntimeTenant.d.ts +13 -0
- package/features/runtimeTenant/RuntimeTenant.js +22 -0
- package/features/runtimeTenant/RuntimeTenant.js.map +1 -0
- package/features/runtimeTenant/abstractions.d.ts +11 -0
- package/features/runtimeTenant/abstractions.js +5 -0
- package/features/runtimeTenant/abstractions.js.map +1 -0
- package/features/runtimeTenant/index.d.ts +2 -0
- package/features/runtimeTenant/index.js +2 -0
- package/features/shared/abstractions.d.ts +1 -5
- package/features/shared/abstractions.js +1 -2
- package/features/shared/abstractions.js.map +1 -1
- package/features/sortMapper/SortMapper.js +2 -5
- package/features/sortMapper/SortMapper.js.map +1 -1
- package/features/storage/fields/CompressedTextStorageTransform.js +1 -1
- package/features/storage/fields/CompressedTextStorageTransform.js.map +1 -1
- package/features/storage/fields/DateStorageTransform.js +3 -4
- package/features/storage/fields/DateStorageTransform.js.map +1 -1
- package/features/storage/fields/DynamicZoneStorageTransform.js +2 -2
- package/features/storage/fields/DynamicZoneStorageTransform.js.map +1 -1
- package/features/storage/fields/JsonStorageTransform.js +1 -1
- package/features/storage/fields/JsonStorageTransform.js.map +1 -1
- package/features/storage/fields/LongTextStorageTransform.js +1 -1
- package/features/storage/fields/LongTextStorageTransform.js.map +1 -1
- package/features/storage/fields/ObjectStorageTransform.js +27 -7
- package/features/storage/fields/ObjectStorageTransform.js.map +1 -1
- package/features/storage/fields/RichTextStorageTransform.js +1 -1
- package/features/storage/fields/RichTextStorageTransform.js.map +1 -1
- 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/PatternValidator.js +1 -1
- package/features/validation/validators/PatternValidator.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/features/whereMapper/WhereMapper.js +8 -8
- package/features/whereMapper/WhereMapper.js.map +1 -1
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +15 -5
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +8 -2
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
- package/graphql/checkEndpointAccess.d.ts +7 -2
- package/graphql/checkEndpointAccess.js +2 -4
- package/graphql/checkEndpointAccess.js.map +1 -1
- package/graphql/getSchema/generateCacheKey.js +1 -1
- package/graphql/getSchema/generateCacheKey.js.map +1 -1
- package/graphql/scalars/RevisionId.js +1 -1
- package/graphql/scalars/RevisionId.js.map +1 -1
- package/graphql/schema/cms/CmsBaseErrorTypeFactory.d.ts +1 -0
- package/graphql/schema/cms/CmsBaseErrorTypeFactory.js +4 -0
- package/graphql/schema/cms/CmsBaseErrorTypeFactory.js.map +1 -1
- package/graphql/schema/cms/getEntryResolver.js +3 -2
- package/graphql/schema/cms/getEntryResolver.js.map +1 -1
- package/graphql/schema/cms/getModelResolver.d.ts +35 -0
- package/graphql/schema/cms/getModelResolver.js +49 -0
- package/graphql/schema/cms/getModelResolver.js.map +1 -0
- package/graphql/schema/cms/helpers/buildFieldsSelection.js +9 -2
- package/graphql/schema/cms/helpers/buildFieldsSelection.js.map +1 -1
- package/graphql/schema/cms/helpers/expandFieldWildcards.d.ts +2 -0
- package/graphql/schema/cms/helpers/expandFieldWildcards.js +13 -0
- package/graphql/schema/cms/helpers/expandFieldWildcards.js.map +1 -0
- package/graphql/schema/cms/helpers/index.d.ts +1 -0
- package/graphql/schema/cms/helpers/index.js +1 -0
- package/graphql/schema/cms/helpers/transformWhereToNested.js +39 -17
- package/graphql/schema/cms/helpers/transformWhereToNested.js.map +1 -1
- package/graphql/schema/cms/helpers.d.ts +1 -0
- package/graphql/schema/cms/helpers.js +1 -0
- package/graphql/schema/cms/listEntriesResolver.js +3 -2
- package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
- package/graphql/schema/cms/resolvers/createEntry.d.ts +1 -0
- package/graphql/schema/cms/resolvers/createEntry.js +4 -0
- package/graphql/schema/cms/resolvers/createEntry.js.map +1 -1
- package/graphql/schema/cms/resolvers/deleteEntryRevision.d.ts +1 -0
- package/graphql/schema/cms/resolvers/deleteEntryRevision.js +4 -0
- package/graphql/schema/cms/resolvers/deleteEntryRevision.js.map +1 -1
- package/graphql/schema/cms/resolvers/getEntry.d.ts +1 -0
- package/graphql/schema/cms/resolvers/getEntry.js +4 -0
- package/graphql/schema/cms/resolvers/getEntry.js.map +1 -1
- package/graphql/schema/cms/resolvers/getModel.d.ts +9 -0
- package/graphql/schema/cms/resolvers/getModel.js +22 -0
- package/graphql/schema/cms/resolvers/getModel.js.map +1 -0
- package/graphql/schema/cms/resolvers/index.d.ts +1 -0
- package/graphql/schema/cms/resolvers/index.js +1 -0
- package/graphql/schema/cms/resolvers/listEntries.d.ts +1 -0
- package/graphql/schema/cms/resolvers/listEntries.js +4 -0
- package/graphql/schema/cms/resolvers/listEntries.js.map +1 -1
- package/graphql/schema/cms/resolvers/mutationCms.d.ts +1 -0
- package/graphql/schema/cms/resolvers/mutationCms.js +4 -0
- package/graphql/schema/cms/resolvers/mutationCms.js.map +1 -1
- package/graphql/schema/cms/resolvers/publishEntryRevision.d.ts +1 -0
- package/graphql/schema/cms/resolvers/publishEntryRevision.js +4 -0
- package/graphql/schema/cms/resolvers/publishEntryRevision.js.map +1 -1
- package/graphql/schema/cms/resolvers/queryCms.d.ts +1 -0
- package/graphql/schema/cms/resolvers/queryCms.js +4 -0
- package/graphql/schema/cms/resolvers/queryCms.js.map +1 -1
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.d.ts +1 -0
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.js +4 -0
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.js.map +1 -1
- package/graphql/schema/cms/resolvers/updateEntryRevision.d.ts +1 -0
- package/graphql/schema/cms/resolvers/updateEntryRevision.js +4 -0
- package/graphql/schema/cms/resolvers/updateEntryRevision.js.map +1 -1
- package/graphql/schema/cms/typeDefs/mutation.d.ts +1 -0
- package/graphql/schema/cms/typeDefs/mutation.js +4 -0
- package/graphql/schema/cms/typeDefs/mutation.js.map +1 -1
- package/graphql/schema/cms/typeDefs/query.d.ts +1 -0
- package/graphql/schema/cms/typeDefs/query.js +5 -0
- package/graphql/schema/cms/typeDefs/query.js.map +1 -1
- package/graphql/schema/cms/typeDefs/responses.d.ts +1 -0
- package/graphql/schema/cms/typeDefs/responses.js +9 -0
- package/graphql/schema/cms/typeDefs/responses.js.map +1 -1
- package/graphql/schema/contentEntries.js +19 -4
- package/graphql/schema/contentEntries.js.map +1 -1
- package/graphql/schema/contentModels.js +33 -0
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createFieldResolvers.js +1 -1
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/graphql/schema/createManageResolvers.js +3 -1
- 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/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/package.json +24 -25
- package/plugins/CmsModelPlugin.js +11 -11
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/types/fields/dynamicZoneField.d.ts +3 -2
- package/types/index.d.ts +0 -1
- package/types/model.d.ts +6 -0
- package/types/modelField.d.ts +14 -1
- package/types/types.d.ts +14 -109
- package/types/types.js.map +1 -1
- package/utils/caching/Cache.js +1 -1
- package/utils/caching/Cache.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/date.js +1 -1
- package/utils/date.js.map +1 -1
- package/utils/entryStorage.js +1 -1
- package/utils/entryStorage.js.map +1 -1
- package/utils/renderFields.js +1 -1
- package/utils/renderFields.js.map +1 -1
- package/HeadlessCmsContextualSchema.d.ts +0 -16
- package/HeadlessCmsContextualSchema.js +0 -32
- package/HeadlessCmsContextualSchema.js.map +0 -1
- package/crud/contentEntry.crud.d.ts +0 -6
- package/crud/contentEntry.crud.js +0 -336
- package/crud/contentEntry.crud.js.map +0 -1
- package/crud/contentModel.crud.d.ts +0 -5
- package/crud/contentModel.crud.js +0 -79
- package/crud/contentModel.crud.js.map +0 -1
- package/crud/contentModelGroup.crud.d.ts +0 -5
- package/crud/contentModelGroup.crud.js +0 -76
- package/crud/contentModelGroup.crud.js.map +0 -1
- package/types/context.d.ts +0 -110
- package/types/context.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { CreateUnpublishEntryDataFactory as FactoryAbstraction, type ICreateUnpublishEntryDataFactory } from "./abstractions.js";
|
|
2
|
+
import type { CmsEntry, CmsEntryValues, CmsModel } from "../../../../types/index.js";
|
|
3
|
+
import { GetLatestRevisionByEntryIdUseCase } from "../../../../features/contentEntry/GetLatestRevisionByEntryId/index.js";
|
|
4
4
|
declare class CreateUnpublishEntryDataFactoryImpl implements ICreateUnpublishEntryDataFactory {
|
|
5
|
-
private readonly
|
|
6
|
-
constructor(
|
|
7
|
-
create<TValues extends CmsEntryValues = CmsEntryValues>(originalEntry: CmsEntry<TValues>): Promise<
|
|
5
|
+
private readonly getLatestRevision;
|
|
6
|
+
constructor(getLatestRevision: GetLatestRevisionByEntryIdUseCase.Interface);
|
|
7
|
+
create<TValues extends CmsEntryValues = CmsEntryValues>(model: CmsModel, originalEntry: CmsEntry<TValues>): Promise<FactoryAbstraction.Return<TValues>>;
|
|
8
8
|
}
|
|
9
9
|
export declare const CreateUnpublishEntryDataFactory: typeof CreateUnpublishEntryDataFactoryImpl & {
|
|
10
10
|
__abstraction: import("@webiny/di").Abstraction<ICreateUnpublishEntryDataFactory>;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
1
2
|
import { CreateUnpublishEntryDataFactory } from "./abstractions.js";
|
|
2
|
-
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
3
|
import { STATUS_UNPUBLISHED } from "../statuses.js";
|
|
4
4
|
import { getIdentity } from "../../../../utils/identity.js";
|
|
5
5
|
import { getDate } from "../../../../utils/date.js";
|
|
6
|
+
import { GetLatestRevisionByEntryIdUseCase } from "../../GetLatestRevisionByEntryId/index.js";
|
|
6
7
|
class CreateUnpublishEntryDataFactoryImpl {
|
|
7
|
-
constructor(
|
|
8
|
-
this.
|
|
8
|
+
constructor(getLatestRevision){
|
|
9
|
+
this.getLatestRevision = getLatestRevision;
|
|
9
10
|
}
|
|
10
|
-
async create(originalEntry) {
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
async create(model, originalEntry) {
|
|
12
|
+
const latestResult = await this.getLatestRevision.execute(model, {
|
|
13
|
+
id: originalEntry.entryId
|
|
14
|
+
});
|
|
15
|
+
if (latestResult.isFail()) return Result.fail(latestResult.error);
|
|
16
|
+
const latestEntry = latestResult.value;
|
|
13
17
|
const entry = {
|
|
14
18
|
...originalEntry,
|
|
15
19
|
status: STATUS_UNPUBLISHED,
|
|
16
|
-
savedOn: getDate(
|
|
17
|
-
modifiedOn: getDate(
|
|
18
|
-
savedBy: getIdentity(
|
|
19
|
-
modifiedBy: getIdentity(
|
|
20
|
-
revisionSavedOn: getDate(currentDateTime),
|
|
21
|
-
revisionModifiedOn: getDate(currentDateTime),
|
|
22
|
-
revisionSavedBy: getIdentity(currentIdentity),
|
|
23
|
-
revisionModifiedBy: getIdentity(currentIdentity),
|
|
20
|
+
savedOn: getDate(latestEntry.savedOn, originalEntry.savedOn),
|
|
21
|
+
modifiedOn: getDate(latestEntry.modifiedOn),
|
|
22
|
+
savedBy: getIdentity(latestEntry.savedBy, originalEntry.savedBy),
|
|
23
|
+
modifiedBy: getIdentity(latestEntry.modifiedBy),
|
|
24
24
|
live: null
|
|
25
25
|
};
|
|
26
|
-
return {
|
|
26
|
+
return Result.ok({
|
|
27
27
|
entry
|
|
28
|
-
};
|
|
28
|
+
});
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
const CreateUnpublishEntryDataFactory_CreateUnpublishEntryDataFactory = CreateUnpublishEntryDataFactory.createImplementation({
|
|
32
32
|
implementation: CreateUnpublishEntryDataFactoryImpl,
|
|
33
33
|
dependencies: [
|
|
34
|
-
|
|
34
|
+
GetLatestRevisionByEntryIdUseCase
|
|
35
35
|
]
|
|
36
36
|
});
|
|
37
37
|
export { CreateUnpublishEntryDataFactory_CreateUnpublishEntryDataFactory as CreateUnpublishEntryDataFactory };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.ts"],"sourcesContent":["import {\n CreateUnpublishEntryDataFactory as FactoryAbstraction,\n type ICreateUnpublishEntryDataFactory
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n CreateUnpublishEntryDataFactory as FactoryAbstraction,\n type ICreateUnpublishEntryDataFactory\n} from \"./abstractions.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { STATUS_UNPUBLISHED } from \"../statuses.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { GetLatestRevisionByEntryIdUseCase } from \"~/features/contentEntry/GetLatestRevisionByEntryId/index.js\";\n\nclass CreateUnpublishEntryDataFactoryImpl implements ICreateUnpublishEntryDataFactory {\n public constructor(\n private readonly getLatestRevision: GetLatestRevisionByEntryIdUseCase.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n originalEntry: CmsEntry<TValues>\n ): Promise<FactoryAbstraction.Return<TValues>> {\n const latestResult = await this.getLatestRevision.execute<TValues>(model, {\n id: originalEntry.entryId\n });\n if (latestResult.isFail()) {\n return Result.fail(latestResult.error);\n }\n const latestEntry = latestResult.value;\n\n /**\n * Unpublishing is not a content modification, so saved/modified meta fields are kept.\n * Entry-level values are taken from the latest revision, because storage copies them\n * onto the latest revision when a non-latest revision is unpublished. Revision-level\n * values are the unpublished revision's own, and come from `originalEntry`.\n */\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n status: STATUS_UNPUBLISHED,\n savedOn: getDate(latestEntry.savedOn, originalEntry.savedOn),\n modifiedOn: getDate(latestEntry.modifiedOn),\n savedBy: getIdentity(latestEntry.savedBy, originalEntry.savedBy),\n modifiedBy: getIdentity(latestEntry.modifiedBy),\n live: null\n };\n\n return Result.ok({ entry });\n }\n}\n\nexport const CreateUnpublishEntryDataFactory = FactoryAbstraction.createImplementation({\n implementation: CreateUnpublishEntryDataFactoryImpl,\n dependencies: [GetLatestRevisionByEntryIdUseCase]\n});\n"],"names":["CreateUnpublishEntryDataFactoryImpl","getLatestRevision","model","originalEntry","latestResult","Result","latestEntry","entry","STATUS_UNPUBLISHED","getDate","getIdentity","CreateUnpublishEntryDataFactory","FactoryAbstraction","GetLatestRevisionByEntryIdUseCase"],"mappings":";;;;;;AAWA,MAAMA;IACF,YACqBC,iBAA8D,CACjF;aADmBA,iBAAiB,GAAjBA;IAClB;IAEH,MAAa,OACTC,KAAe,EACfC,aAAgC,EACW;QAC3C,MAAMC,eAAe,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAUF,OAAO;YACtE,IAAIC,cAAc,OAAO;QAC7B;QACA,IAAIC,aAAa,MAAM,IACnB,OAAOC,OAAO,IAAI,CAACD,aAAa,KAAK;QAEzC,MAAME,cAAcF,aAAa,KAAK;QAQtC,MAAMG,QAA2B;YAC7B,GAAGJ,aAAa;YAChB,QAAQK;YACR,SAASC,QAAQH,YAAY,OAAO,EAAEH,cAAc,OAAO;YAC3D,YAAYM,QAAQH,YAAY,UAAU;YAC1C,SAASI,YAAYJ,YAAY,OAAO,EAAEH,cAAc,OAAO;YAC/D,YAAYO,YAAYJ,YAAY,UAAU;YAC9C,MAAM;QACV;QAEA,OAAOD,OAAO,EAAE,CAAC;YAAEE;QAAM;IAC7B;AACJ;AAEO,MAAMI,kEAAkCC,gCAAAA,oBAAuC,CAAC;IACnF,gBAAgBZ;IAChB,cAAc;QAACa;KAAkC;AACrD"}
|
package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.d.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Result } from "@webiny/feature/api";
|
|
2
|
+
import type { GetLatestRevisionByEntryIdUseCase } from "../../../../features/contentEntry/GetLatestRevisionByEntryId/index.js";
|
|
3
|
+
import type { CmsEntry, CmsEntryValues, CmsModel } from "../../../../types/index.js";
|
|
2
4
|
export interface ICreateUnpublishEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {
|
|
3
5
|
entry: CmsEntry<TValues>;
|
|
4
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Expected failures of building the data of an entry being unpublished.
|
|
9
|
+
*/
|
|
10
|
+
export interface ICreateUnpublishEntryDataFactoryErrors {
|
|
11
|
+
latest: GetLatestRevisionByEntryIdUseCase.Error;
|
|
12
|
+
}
|
|
13
|
+
type FactoryError = ICreateUnpublishEntryDataFactoryErrors[keyof ICreateUnpublishEntryDataFactoryErrors];
|
|
5
14
|
export interface ICreateUnpublishEntryDataFactory {
|
|
6
|
-
create<TValues extends CmsEntryValues = CmsEntryValues>(originalEntry: CmsEntry<TValues>): Promise<ICreateUnpublishEntryDataResponse<TValues>>;
|
|
15
|
+
create<TValues extends CmsEntryValues = CmsEntryValues>(model: CmsModel, originalEntry: CmsEntry<TValues>): Promise<Result<ICreateUnpublishEntryDataResponse<TValues>, FactoryError>>;
|
|
7
16
|
}
|
|
8
17
|
export declare const CreateUnpublishEntryDataFactory: import("@webiny/di").Abstraction<ICreateUnpublishEntryDataFactory>;
|
|
9
18
|
export declare namespace CreateUnpublishEntryDataFactory {
|
|
10
19
|
type Interface = ICreateUnpublishEntryDataFactory;
|
|
20
|
+
type Error = FactoryError;
|
|
21
|
+
type Return<TValues extends CmsEntryValues = CmsEntryValues> = Result<ICreateUnpublishEntryDataResponse<TValues>, FactoryError>;
|
|
11
22
|
type Response<TValues extends CmsEntryValues = CmsEntryValues> = ICreateUnpublishEntryDataResponse<TValues>;
|
|
12
23
|
}
|
|
24
|
+
export {};
|
package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsEntry, CmsEntryValues } from \"~/types/index.js\";\n\nexport interface ICreateUnpublishEntryDataResponse<\n TValues extends CmsEntryValues = CmsEntryValues\n> {\n entry: CmsEntry<TValues>;\n}\n\nexport interface ICreateUnpublishEntryDataFactory {\n create<TValues extends CmsEntryValues = CmsEntryValues>(\n originalEntry: CmsEntry<TValues>\n ): Promise<ICreateUnpublishEntryDataResponse<TValues>>;\n}\n\nexport const CreateUnpublishEntryDataFactory = createAbstraction<ICreateUnpublishEntryDataFactory>(\n \"Cms/Entry/CreateUnpublishEntryDataFactory\"\n);\n\nexport namespace CreateUnpublishEntryDataFactory {\n export type Interface = ICreateUnpublishEntryDataFactory;\n export type Response<TValues extends CmsEntryValues = CmsEntryValues> =\n ICreateUnpublishEntryDataResponse<TValues>;\n}\n"],"names":["CreateUnpublishEntryDataFactory","createAbstraction"],"mappings":";
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { GetLatestRevisionByEntryIdUseCase } from \"~/features/contentEntry/GetLatestRevisionByEntryId/index.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\n\nexport interface ICreateUnpublishEntryDataResponse<\n TValues extends CmsEntryValues = CmsEntryValues\n> {\n entry: CmsEntry<TValues>;\n}\n\n/**\n * Expected failures of building the data of an entry being unpublished.\n */\nexport interface ICreateUnpublishEntryDataFactoryErrors {\n latest: GetLatestRevisionByEntryIdUseCase.Error;\n}\n\ntype FactoryError =\n ICreateUnpublishEntryDataFactoryErrors[keyof ICreateUnpublishEntryDataFactoryErrors];\n\nexport interface ICreateUnpublishEntryDataFactory {\n create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n originalEntry: CmsEntry<TValues>\n ): Promise<Result<ICreateUnpublishEntryDataResponse<TValues>, FactoryError>>;\n}\n\nexport const CreateUnpublishEntryDataFactory = createAbstraction<ICreateUnpublishEntryDataFactory>(\n \"Cms/Entry/CreateUnpublishEntryDataFactory\"\n);\n\nexport namespace CreateUnpublishEntryDataFactory {\n export type Interface = ICreateUnpublishEntryDataFactory;\n export type Error = FactoryError;\n export type Return<TValues extends CmsEntryValues = CmsEntryValues> = Result<\n ICreateUnpublishEntryDataResponse<TValues>,\n FactoryError\n >;\n export type Response<TValues extends CmsEntryValues = CmsEntryValues> =\n ICreateUnpublishEntryDataResponse<TValues>;\n}\n"],"names":["CreateUnpublishEntryDataFactory","createAbstraction"],"mappings":";AA2BO,MAAMA,kCAAkCC,kBAC3C"}
|
package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { type IUpdateEntryDataFactory,
|
|
1
|
+
import { type IUpdateEntryDataFactory, UpdateEntryDataFactory as FactoryAbstraction } from "./abstractions.js";
|
|
2
2
|
import { CmsContext } from "../../../../features/shared/abstractions.js";
|
|
3
3
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
4
4
|
import type { CmsEntry, CmsEntryValues, CmsModel, UpdateCmsEntryInput, UpdateCmsEntryOptionsInput } from "../../../../types/index.js";
|
|
5
|
+
import { ModelToAstConverter } from "../../../../features/contentModel/ModelToAstConverter/abstractions.js";
|
|
6
|
+
import { GetLatestRevisionByEntryIdUseCase } from "../../../../features/contentEntry/GetLatestRevisionByEntryId/index.js";
|
|
5
7
|
declare class UpdateEntryDataFactoryImpl implements IUpdateEntryDataFactory {
|
|
6
8
|
private readonly cmsContext;
|
|
7
9
|
private readonly identityContext;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
private readonly modelToAstConverter;
|
|
11
|
+
private readonly getLatestRevision;
|
|
12
|
+
constructor(cmsContext: CmsContext.Interface, identityContext: IdentityContext.Interface, modelToAstConverter: ModelToAstConverter.Interface, getLatestRevision: GetLatestRevisionByEntryIdUseCase.Interface);
|
|
13
|
+
create<TValues extends CmsEntryValues = CmsEntryValues>(model: CmsModel, rawInput: UpdateCmsEntryInput<TValues>, originalEntry: CmsEntry<TValues>, options?: UpdateCmsEntryOptionsInput): Promise<FactoryAbstraction.Return<TValues>>;
|
|
10
14
|
}
|
|
11
15
|
export declare const UpdateEntryDataFactory: typeof UpdateEntryDataFactoryImpl & {
|
|
12
16
|
__abstraction: import("@webiny/di").Abstraction<IUpdateEntryDataFactory>;
|
package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
1
2
|
import { UpdateEntryDataFactory } from "./abstractions.js";
|
|
2
3
|
import { CmsContext } from "../../../shared/abstractions.js";
|
|
3
4
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
4
5
|
import { getDate } from "../../../../utils/date.js";
|
|
5
6
|
import { getIdentity } from "../../../../utils/identity.js";
|
|
6
|
-
import {
|
|
7
|
+
import { validateModelEntryData } from "../../../../crud/contentEntry/entryDataValidation.js";
|
|
8
|
+
import { EntryValidationError } from "../../../../domain/contentEntry/errors.js";
|
|
7
9
|
import { referenceFieldsMapping } from "../../../../crud/contentEntry/referenceFieldsMapping.js";
|
|
8
10
|
import { mapAndCleanUpdatedInputData } from "../mapAndCleanUpdatedInputData.js";
|
|
9
11
|
import { getSystem } from "../system.js";
|
|
10
12
|
import { getExpiresAt } from "../expiresAt.js";
|
|
13
|
+
import { ModelToAstConverter } from "../../../contentModel/ModelToAstConverter/abstractions.js";
|
|
14
|
+
import { ensureItemIds } from "../../ensureItemIds.js";
|
|
15
|
+
import { hasEntryContentChanged } from "../hasEntryContentChanged.js";
|
|
16
|
+
import { GetLatestRevisionByEntryIdUseCase } from "../../GetLatestRevisionByEntryId/index.js";
|
|
11
17
|
const allowedEntryStatus = [
|
|
12
18
|
"draft",
|
|
13
19
|
"published",
|
|
@@ -15,23 +21,33 @@ const allowedEntryStatus = [
|
|
|
15
21
|
];
|
|
16
22
|
const transformEntryStatus = (status)=>allowedEntryStatus.includes(status) ? status : "draft";
|
|
17
23
|
class UpdateEntryDataFactoryImpl {
|
|
18
|
-
constructor(cmsContext, identityContext){
|
|
24
|
+
constructor(cmsContext, identityContext, modelToAstConverter, getLatestRevision){
|
|
19
25
|
this.cmsContext = cmsContext;
|
|
20
26
|
this.identityContext = identityContext;
|
|
27
|
+
this.modelToAstConverter = modelToAstConverter;
|
|
28
|
+
this.getLatestRevision = getLatestRevision;
|
|
21
29
|
}
|
|
22
30
|
async create(model, rawInput, originalEntry, options) {
|
|
31
|
+
const latestResult = await this.getLatestRevision.execute(model, {
|
|
32
|
+
id: originalEntry.entryId
|
|
33
|
+
});
|
|
34
|
+
if (latestResult.isFail()) return Result.fail(latestResult.error);
|
|
35
|
+
const latestEntry = latestResult.value;
|
|
23
36
|
const cleanedValues = mapAndCleanUpdatedInputData(model, rawInput?.values || {});
|
|
24
|
-
await
|
|
37
|
+
const invalidFields = await validateModelEntryData({
|
|
25
38
|
context: this.cmsContext,
|
|
26
39
|
model,
|
|
27
40
|
values: cleanedValues,
|
|
28
41
|
entry: originalEntry,
|
|
29
42
|
skipValidation: options?.skipValidation
|
|
30
43
|
});
|
|
44
|
+
if (invalidFields.length > 0) return Result.fail(new EntryValidationError("Validation failed.", invalidFields));
|
|
31
45
|
const mergedValues = {
|
|
32
46
|
...originalEntry.values,
|
|
33
47
|
...cleanedValues
|
|
34
48
|
};
|
|
49
|
+
const modelAst = this.modelToAstConverter.toAst(model);
|
|
50
|
+
await ensureItemIds(modelAst, mergedValues);
|
|
35
51
|
const values = await referenceFieldsMapping({
|
|
36
52
|
context: this.cmsContext,
|
|
37
53
|
model,
|
|
@@ -40,36 +56,62 @@ class UpdateEntryDataFactoryImpl {
|
|
|
40
56
|
});
|
|
41
57
|
const currentIdentity = this.identityContext.getIdentity();
|
|
42
58
|
const currentDateTime = new Date();
|
|
59
|
+
const contentChanged = hasEntryContentChanged({
|
|
60
|
+
values,
|
|
61
|
+
baselineValues: originalEntry.values
|
|
62
|
+
});
|
|
63
|
+
const entryLevelSaved = contentChanged ? {
|
|
64
|
+
savedOn: currentDateTime,
|
|
65
|
+
modifiedOn: currentDateTime,
|
|
66
|
+
savedBy: currentIdentity,
|
|
67
|
+
modifiedBy: currentIdentity
|
|
68
|
+
} : {
|
|
69
|
+
savedOn: latestEntry.savedOn,
|
|
70
|
+
modifiedOn: latestEntry.modifiedOn,
|
|
71
|
+
savedBy: latestEntry.savedBy,
|
|
72
|
+
modifiedBy: latestEntry.modifiedBy
|
|
73
|
+
};
|
|
74
|
+
const revisionLevelSaved = contentChanged ? {
|
|
75
|
+
revisionSavedOn: currentDateTime,
|
|
76
|
+
revisionModifiedOn: currentDateTime,
|
|
77
|
+
revisionSavedBy: currentIdentity,
|
|
78
|
+
revisionModifiedBy: currentIdentity
|
|
79
|
+
} : {
|
|
80
|
+
revisionSavedOn: originalEntry.revisionSavedOn,
|
|
81
|
+
revisionModifiedOn: originalEntry.revisionModifiedOn,
|
|
82
|
+
revisionSavedBy: originalEntry.revisionSavedBy,
|
|
83
|
+
revisionModifiedBy: originalEntry.revisionModifiedBy
|
|
84
|
+
};
|
|
43
85
|
const entry = {
|
|
44
86
|
...originalEntry,
|
|
45
87
|
revisionCreatedOn: getDate(rawInput.revisionCreatedOn, originalEntry.revisionCreatedOn),
|
|
46
|
-
revisionModifiedOn: getDate(rawInput.revisionModifiedOn,
|
|
47
|
-
revisionSavedOn: getDate(rawInput.revisionSavedOn,
|
|
48
|
-
revisionDeletedOn: getDate(rawInput.revisionDeletedOn,
|
|
49
|
-
revisionRestoredOn: getDate(rawInput.revisionRestoredOn,
|
|
88
|
+
revisionModifiedOn: getDate(rawInput.revisionModifiedOn, revisionLevelSaved.revisionModifiedOn),
|
|
89
|
+
revisionSavedOn: getDate(rawInput.revisionSavedOn, revisionLevelSaved.revisionSavedOn),
|
|
90
|
+
revisionDeletedOn: getDate(rawInput.revisionDeletedOn, originalEntry.revisionDeletedOn),
|
|
91
|
+
revisionRestoredOn: getDate(rawInput.revisionRestoredOn, originalEntry.revisionRestoredOn),
|
|
50
92
|
revisionFirstPublishedOn: getDate(rawInput.revisionFirstPublishedOn, originalEntry.revisionFirstPublishedOn),
|
|
51
93
|
revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, originalEntry.revisionLastPublishedOn),
|
|
52
94
|
revisionCreatedBy: getIdentity(rawInput.revisionCreatedBy, originalEntry.revisionCreatedBy),
|
|
53
|
-
revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy,
|
|
54
|
-
revisionSavedBy: getIdentity(rawInput.revisionSavedBy,
|
|
55
|
-
revisionDeletedBy: getIdentity(rawInput.
|
|
56
|
-
revisionRestoredBy: getIdentity(rawInput.revisionRestoredBy,
|
|
95
|
+
revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, revisionLevelSaved.revisionModifiedBy),
|
|
96
|
+
revisionSavedBy: getIdentity(rawInput.revisionSavedBy, revisionLevelSaved.revisionSavedBy),
|
|
97
|
+
revisionDeletedBy: getIdentity(rawInput.revisionDeletedBy, originalEntry.revisionDeletedBy),
|
|
98
|
+
revisionRestoredBy: getIdentity(rawInput.revisionRestoredBy, originalEntry.revisionRestoredBy),
|
|
57
99
|
revisionFirstPublishedBy: getIdentity(rawInput.revisionFirstPublishedBy, originalEntry.revisionFirstPublishedBy),
|
|
58
100
|
revisionLastPublishedBy: getIdentity(rawInput.revisionLastPublishedBy, originalEntry.revisionLastPublishedBy),
|
|
59
|
-
createdOn: getDate(rawInput.createdOn,
|
|
60
|
-
savedOn: getDate(rawInput.savedOn,
|
|
61
|
-
modifiedOn: getDate(rawInput.modifiedOn,
|
|
62
|
-
deletedOn: getDate(rawInput.deletedOn,
|
|
63
|
-
restoredOn: getDate(rawInput.restoredOn,
|
|
64
|
-
firstPublishedOn: getDate(rawInput.firstPublishedOn,
|
|
65
|
-
lastPublishedOn: getDate(rawInput.lastPublishedOn,
|
|
66
|
-
createdBy: getIdentity(rawInput.createdBy,
|
|
67
|
-
savedBy: getIdentity(rawInput.savedBy,
|
|
68
|
-
modifiedBy: getIdentity(rawInput.modifiedBy,
|
|
69
|
-
deletedBy: getIdentity(rawInput.deletedBy,
|
|
70
|
-
restoredBy: getIdentity(rawInput.restoredBy,
|
|
71
|
-
firstPublishedBy: getIdentity(rawInput.firstPublishedBy,
|
|
72
|
-
lastPublishedBy: getIdentity(rawInput.lastPublishedBy,
|
|
101
|
+
createdOn: getDate(rawInput.createdOn, latestEntry.createdOn),
|
|
102
|
+
savedOn: getDate(rawInput.savedOn, entryLevelSaved.savedOn),
|
|
103
|
+
modifiedOn: getDate(rawInput.modifiedOn, entryLevelSaved.modifiedOn),
|
|
104
|
+
deletedOn: getDate(rawInput.deletedOn, latestEntry.deletedOn),
|
|
105
|
+
restoredOn: getDate(rawInput.restoredOn, latestEntry.restoredOn),
|
|
106
|
+
firstPublishedOn: getDate(rawInput.firstPublishedOn, latestEntry.firstPublishedOn),
|
|
107
|
+
lastPublishedOn: getDate(rawInput.lastPublishedOn, latestEntry.lastPublishedOn),
|
|
108
|
+
createdBy: getIdentity(rawInput.createdBy, latestEntry.createdBy),
|
|
109
|
+
savedBy: getIdentity(rawInput.savedBy, entryLevelSaved.savedBy),
|
|
110
|
+
modifiedBy: getIdentity(rawInput.modifiedBy, entryLevelSaved.modifiedBy),
|
|
111
|
+
deletedBy: getIdentity(rawInput.deletedBy, latestEntry.deletedBy),
|
|
112
|
+
restoredBy: getIdentity(rawInput.restoredBy, latestEntry.restoredBy),
|
|
113
|
+
firstPublishedBy: getIdentity(rawInput.firstPublishedBy, latestEntry.firstPublishedBy),
|
|
114
|
+
lastPublishedBy: getIdentity(rawInput.lastPublishedBy, latestEntry.lastPublishedBy),
|
|
73
115
|
values,
|
|
74
116
|
status: transformEntryStatus(originalEntry.status),
|
|
75
117
|
system: getSystem({
|
|
@@ -85,20 +127,22 @@ class UpdateEntryDataFactoryImpl {
|
|
|
85
127
|
if (folderId) entry.location = {
|
|
86
128
|
folderId
|
|
87
129
|
};
|
|
88
|
-
return {
|
|
130
|
+
return Result.ok({
|
|
89
131
|
entry,
|
|
90
132
|
input: {
|
|
91
133
|
...rawInput,
|
|
92
134
|
values: structuredClone(values)
|
|
93
135
|
}
|
|
94
|
-
};
|
|
136
|
+
});
|
|
95
137
|
}
|
|
96
138
|
}
|
|
97
139
|
const UpdateEntryDataFactory_UpdateEntryDataFactory = UpdateEntryDataFactory.createImplementation({
|
|
98
140
|
implementation: UpdateEntryDataFactoryImpl,
|
|
99
141
|
dependencies: [
|
|
100
142
|
CmsContext,
|
|
101
|
-
IdentityContext
|
|
143
|
+
IdentityContext,
|
|
144
|
+
ModelToAstConverter,
|
|
145
|
+
GetLatestRevisionByEntryIdUseCase
|
|
102
146
|
]
|
|
103
147
|
});
|
|
104
148
|
export { UpdateEntryDataFactory_UpdateEntryDataFactory as UpdateEntryDataFactory };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.ts"],"sourcesContent":["import {\n type IUpdateEntryDataFactory,\n type IUpdateEntryDataResponse,\n UpdateEntryDataFactory as FactoryAbstraction\n} from \"./abstractions.js\";\nimport { CmsContext } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryStatus,\n CmsEntryValues,\n CmsModel,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { mapAndCleanUpdatedInputData } from \"../mapAndCleanUpdatedInputData.js\";\nimport { getSystem } from \"../system.js\";\nimport { getExpiresAt } from \"../expiresAt.js\";\n\nconst allowedEntryStatus: string[] = [\"draft\", \"published\", \"unpublished\"];\n\nconst transformEntryStatus = (status: CmsEntryStatus | string): CmsEntryStatus => {\n return allowedEntryStatus.includes(status) ? (status as CmsEntryStatus) : \"draft\";\n};\n\nclass UpdateEntryDataFactoryImpl implements IUpdateEntryDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: UpdateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n options?: UpdateCmsEntryOptionsInput\n ): Promise<IUpdateEntryDataResponse<TValues>> {\n const cleanedValues = mapAndCleanUpdatedInputData<TValues>(\n model,\n rawInput?.values || ({} as TValues)\n );\n\n await validateModelEntryDataOrThrow({\n context: this.cmsContext,\n model,\n values: cleanedValues,\n entry: originalEntry,\n skipValidation: options?.skipValidation\n });\n\n const mergedValues: TValues = {\n ...originalEntry.values,\n ...cleanedValues\n };\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: mergedValues,\n validateEntries: false\n });\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, originalEntry.revisionCreatedOn),\n revisionModifiedOn: getDate(rawInput.revisionModifiedOn, currentDateTime),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, currentDateTime),\n revisionDeletedOn: getDate(rawInput.revisionDeletedOn, null),\n revisionRestoredOn: getDate(rawInput.revisionRestoredOn, null),\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n originalEntry.revisionFirstPublishedOn\n ),\n revisionLastPublishedOn: getDate(\n rawInput.revisionLastPublishedOn,\n originalEntry.revisionLastPublishedOn\n ),\n revisionCreatedBy: getIdentity(\n rawInput.revisionCreatedBy,\n originalEntry.revisionCreatedBy\n )!,\n revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, currentIdentity),\n revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity)!,\n revisionDeletedBy: getIdentity(rawInput.revisionSavedBy, null),\n revisionRestoredBy: getIdentity(rawInput.revisionRestoredBy, null),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n originalEntry.revisionFirstPublishedBy\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n originalEntry.revisionLastPublishedBy\n ),\n createdOn: getDate(rawInput.createdOn, originalEntry.createdOn),\n savedOn: getDate(rawInput.savedOn, currentDateTime),\n modifiedOn: getDate(rawInput.modifiedOn, currentDateTime),\n deletedOn: getDate(rawInput.deletedOn, null),\n restoredOn: getDate(rawInput.restoredOn, null),\n firstPublishedOn: getDate(rawInput.firstPublishedOn, originalEntry.firstPublishedOn),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, originalEntry.lastPublishedOn),\n createdBy: getIdentity(rawInput.createdBy, originalEntry.createdBy)!,\n savedBy: getIdentity(rawInput.savedBy, currentIdentity)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, currentIdentity),\n deletedBy: getIdentity(rawInput.deletedBy, null),\n restoredBy: getIdentity(rawInput.restoredBy, null),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n originalEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, originalEntry.lastPublishedBy),\n values,\n status: transformEntryStatus(originalEntry.status),\n system: getSystem({\n input: rawInput,\n original: originalEntry\n }),\n live: originalEntry.live,\n expiresAt: getExpiresAt({ expiresAt: rawInput.expiresAt }, originalEntry)\n };\n\n const folderId = rawInput.wbyAco_location?.folderId;\n if (folderId) {\n entry.location = {\n folderId\n };\n }\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n }\n}\n\nexport const UpdateEntryDataFactory = FactoryAbstraction.createImplementation({\n implementation: UpdateEntryDataFactoryImpl,\n dependencies: [CmsContext, IdentityContext]\n});\n"],"names":["allowedEntryStatus","transformEntryStatus","status","UpdateEntryDataFactoryImpl","cmsContext","identityContext","model","rawInput","originalEntry","options","cleanedValues","mapAndCleanUpdatedInputData","validateModelEntryDataOrThrow","mergedValues","values","referenceFieldsMapping","currentIdentity","currentDateTime","Date","entry","getDate","getIdentity","getSystem","getExpiresAt","folderId","structuredClone","UpdateEntryDataFactory","FactoryAbstraction","CmsContext","IdentityContext"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n type IUpdateEntryDataFactory,\n UpdateEntryDataFactory as FactoryAbstraction\n} from \"./abstractions.js\";\nimport { CmsContext } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryStatus,\n CmsEntryValues,\n CmsModel,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { validateModelEntryData } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { EntryValidationError } from \"~/domain/contentEntry/errors.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { mapAndCleanUpdatedInputData } from \"../mapAndCleanUpdatedInputData.js\";\nimport { getSystem } from \"../system.js\";\nimport { getExpiresAt } from \"../expiresAt.js\";\nimport { ModelToAstConverter } from \"~/features/contentModel/ModelToAstConverter/abstractions.js\";\nimport { ensureItemIds } from \"../../ensureItemIds.js\";\nimport { hasEntryContentChanged } from \"../hasEntryContentChanged.js\";\nimport { GetLatestRevisionByEntryIdUseCase } from \"~/features/contentEntry/GetLatestRevisionByEntryId/index.js\";\n\nconst allowedEntryStatus: string[] = [\"draft\", \"published\", \"unpublished\"];\n\nconst transformEntryStatus = (status: CmsEntryStatus | string): CmsEntryStatus => {\n return allowedEntryStatus.includes(status) ? (status as CmsEntryStatus) : \"draft\";\n};\n\nclass UpdateEntryDataFactoryImpl implements IUpdateEntryDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly modelToAstConverter: ModelToAstConverter.Interface,\n private readonly getLatestRevision: GetLatestRevisionByEntryIdUseCase.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: UpdateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n options?: UpdateCmsEntryOptionsInput\n ): Promise<FactoryAbstraction.Return<TValues>> {\n const latestResult = await this.getLatestRevision.execute<TValues>(model, {\n id: originalEntry.entryId\n });\n if (latestResult.isFail()) {\n return Result.fail(latestResult.error);\n }\n const latestEntry = latestResult.value;\n\n const cleanedValues = mapAndCleanUpdatedInputData<TValues>(\n model,\n rawInput?.values || ({} as TValues)\n );\n\n const invalidFields = await validateModelEntryData({\n context: this.cmsContext,\n model,\n values: cleanedValues,\n entry: originalEntry,\n skipValidation: options?.skipValidation\n });\n if (invalidFields.length > 0) {\n return Result.fail(new EntryValidationError(\"Validation failed.\", invalidFields));\n }\n\n const mergedValues: TValues = {\n ...originalEntry.values,\n ...cleanedValues\n };\n\n const modelAst = this.modelToAstConverter.toAst(model);\n await ensureItemIds(modelAst, mergedValues);\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: mergedValues,\n validateEntries: false\n });\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n /**\n * Saving without changing the content (e.g. clicking \"Save\" without editing anything) is\n * not a modification, so the saved/modified meta fields are kept. Entry-level values are\n * then taken from the latest revision, because storage copies them onto the latest\n * revision when a non-latest revision is updated. Revision-level values are this\n * revision's own. Explicitly provided meta field values always take precedence.\n */\n const contentChanged = hasEntryContentChanged({\n values,\n baselineValues: originalEntry.values\n });\n\n const entryLevelSaved = contentChanged\n ? {\n savedOn: currentDateTime,\n modifiedOn: currentDateTime,\n savedBy: currentIdentity,\n modifiedBy: currentIdentity\n }\n : {\n savedOn: latestEntry.savedOn,\n modifiedOn: latestEntry.modifiedOn,\n savedBy: latestEntry.savedBy,\n modifiedBy: latestEntry.modifiedBy\n };\n\n const revisionLevelSaved = contentChanged\n ? {\n revisionSavedOn: currentDateTime,\n revisionModifiedOn: currentDateTime,\n revisionSavedBy: currentIdentity,\n revisionModifiedBy: currentIdentity\n }\n : {\n revisionSavedOn: originalEntry.revisionSavedOn,\n revisionModifiedOn: originalEntry.revisionModifiedOn,\n revisionSavedBy: originalEntry.revisionSavedBy,\n revisionModifiedBy: originalEntry.revisionModifiedBy\n };\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, originalEntry.revisionCreatedOn),\n revisionModifiedOn: getDate(\n rawInput.revisionModifiedOn,\n revisionLevelSaved.revisionModifiedOn\n ),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, revisionLevelSaved.revisionSavedOn),\n revisionDeletedOn: getDate(rawInput.revisionDeletedOn, originalEntry.revisionDeletedOn),\n revisionRestoredOn: getDate(\n rawInput.revisionRestoredOn,\n originalEntry.revisionRestoredOn\n ),\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n originalEntry.revisionFirstPublishedOn\n ),\n revisionLastPublishedOn: getDate(\n rawInput.revisionLastPublishedOn,\n originalEntry.revisionLastPublishedOn\n ),\n revisionCreatedBy: getIdentity(\n rawInput.revisionCreatedBy,\n originalEntry.revisionCreatedBy\n )!,\n revisionModifiedBy: getIdentity(\n rawInput.revisionModifiedBy,\n revisionLevelSaved.revisionModifiedBy\n ),\n revisionSavedBy: getIdentity(\n rawInput.revisionSavedBy,\n revisionLevelSaved.revisionSavedBy\n )!,\n revisionDeletedBy: getIdentity(\n rawInput.revisionDeletedBy,\n originalEntry.revisionDeletedBy\n ),\n revisionRestoredBy: getIdentity(\n rawInput.revisionRestoredBy,\n originalEntry.revisionRestoredBy\n ),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n originalEntry.revisionFirstPublishedBy\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n originalEntry.revisionLastPublishedBy\n ),\n createdOn: getDate(rawInput.createdOn, latestEntry.createdOn),\n savedOn: getDate(rawInput.savedOn, entryLevelSaved.savedOn),\n modifiedOn: getDate(rawInput.modifiedOn, entryLevelSaved.modifiedOn),\n deletedOn: getDate(rawInput.deletedOn, latestEntry.deletedOn),\n restoredOn: getDate(rawInput.restoredOn, latestEntry.restoredOn),\n firstPublishedOn: getDate(rawInput.firstPublishedOn, latestEntry.firstPublishedOn),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, latestEntry.lastPublishedOn),\n createdBy: getIdentity(rawInput.createdBy, latestEntry.createdBy)!,\n savedBy: getIdentity(rawInput.savedBy, entryLevelSaved.savedBy)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, entryLevelSaved.modifiedBy),\n deletedBy: getIdentity(rawInput.deletedBy, latestEntry.deletedBy),\n restoredBy: getIdentity(rawInput.restoredBy, latestEntry.restoredBy),\n firstPublishedBy: getIdentity(rawInput.firstPublishedBy, latestEntry.firstPublishedBy),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, latestEntry.lastPublishedBy),\n values,\n status: transformEntryStatus(originalEntry.status),\n system: getSystem({\n input: rawInput,\n original: originalEntry\n }),\n live: originalEntry.live,\n expiresAt: getExpiresAt({ expiresAt: rawInput.expiresAt }, originalEntry)\n };\n\n const folderId = rawInput.wbyAco_location?.folderId;\n if (folderId) {\n entry.location = {\n folderId\n };\n }\n\n return Result.ok({\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n });\n }\n}\n\nexport const UpdateEntryDataFactory = FactoryAbstraction.createImplementation({\n implementation: UpdateEntryDataFactoryImpl,\n dependencies: [\n CmsContext,\n IdentityContext,\n ModelToAstConverter,\n GetLatestRevisionByEntryIdUseCase\n ]\n});\n"],"names":["allowedEntryStatus","transformEntryStatus","status","UpdateEntryDataFactoryImpl","cmsContext","identityContext","modelToAstConverter","getLatestRevision","model","rawInput","originalEntry","options","latestResult","Result","latestEntry","cleanedValues","mapAndCleanUpdatedInputData","invalidFields","validateModelEntryData","EntryValidationError","mergedValues","modelAst","ensureItemIds","values","referenceFieldsMapping","currentIdentity","currentDateTime","Date","contentChanged","hasEntryContentChanged","entryLevelSaved","revisionLevelSaved","entry","getDate","getIdentity","getSystem","getExpiresAt","folderId","structuredClone","UpdateEntryDataFactory","FactoryAbstraction","CmsContext","IdentityContext","ModelToAstConverter","GetLatestRevisionByEntryIdUseCase"],"mappings":"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"}
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
+
import { type Result } from "@webiny/feature/api";
|
|
2
|
+
import type { GetLatestRevisionByEntryIdUseCase } from "../../../../features/contentEntry/GetLatestRevisionByEntryId/index.js";
|
|
3
|
+
import type { EntryValidationError } from "../../../../domain/contentEntry/errors.js";
|
|
1
4
|
import type { CmsEntry, CmsEntryValues, CmsModel, UpdateCmsEntryInput, UpdateCmsEntryOptionsInput } from "../../../../types/index.js";
|
|
2
5
|
export interface IUpdateEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {
|
|
3
6
|
entry: CmsEntry<TValues>;
|
|
4
7
|
input: UpdateCmsEntryInput<TValues>;
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Expected failures of building the data of an entry being updated.
|
|
11
|
+
*/
|
|
12
|
+
export interface IUpdateEntryDataFactoryErrors {
|
|
13
|
+
latest: GetLatestRevisionByEntryIdUseCase.Error;
|
|
14
|
+
validation: EntryValidationError;
|
|
15
|
+
}
|
|
16
|
+
type FactoryError = IUpdateEntryDataFactoryErrors[keyof IUpdateEntryDataFactoryErrors];
|
|
6
17
|
export interface IUpdateEntryDataFactory {
|
|
7
|
-
create<TValues extends CmsEntryValues = CmsEntryValues>(model: CmsModel, rawInput: UpdateCmsEntryInput<TValues>, originalEntry: CmsEntry<TValues>, options?: UpdateCmsEntryOptionsInput): Promise<IUpdateEntryDataResponse<TValues>>;
|
|
18
|
+
create<TValues extends CmsEntryValues = CmsEntryValues>(model: CmsModel, rawInput: UpdateCmsEntryInput<TValues>, originalEntry: CmsEntry<TValues>, options?: UpdateCmsEntryOptionsInput): Promise<Result<IUpdateEntryDataResponse<TValues>, FactoryError>>;
|
|
8
19
|
}
|
|
9
20
|
export declare const UpdateEntryDataFactory: import("@webiny/di").Abstraction<IUpdateEntryDataFactory>;
|
|
10
21
|
export declare namespace UpdateEntryDataFactory {
|
|
11
22
|
type Interface = IUpdateEntryDataFactory;
|
|
23
|
+
type Error = FactoryError;
|
|
24
|
+
type Return<TValues extends CmsEntryValues = CmsEntryValues> = Result<IUpdateEntryDataResponse<TValues>, FactoryError>;
|
|
12
25
|
type Response<TValues extends CmsEntryValues = CmsEntryValues> = IUpdateEntryDataResponse<TValues>;
|
|
13
26
|
}
|
|
27
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"~/types/index.js\";\n\nexport interface IUpdateEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n input: UpdateCmsEntryInput<TValues>;\n}\n\nexport interface IUpdateEntryDataFactory {\n create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: UpdateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n options?: UpdateCmsEntryOptionsInput\n ): Promise<IUpdateEntryDataResponse<TValues>>;\n}\n\nexport const UpdateEntryDataFactory = createAbstraction<IUpdateEntryDataFactory>(\n \"Cms/Entry/UpdateEntryDataFactory\"\n);\n\nexport namespace UpdateEntryDataFactory {\n export type Interface = IUpdateEntryDataFactory;\n export type Response<TValues extends CmsEntryValues = CmsEntryValues> =\n IUpdateEntryDataResponse<TValues>;\n}\n"],"names":["UpdateEntryDataFactory","createAbstraction"],"mappings":";
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { GetLatestRevisionByEntryIdUseCase } from \"~/features/contentEntry/GetLatestRevisionByEntryId/index.js\";\nimport type { EntryValidationError } from \"~/domain/contentEntry/errors.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"~/types/index.js\";\n\nexport interface IUpdateEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n input: UpdateCmsEntryInput<TValues>;\n}\n\n/**\n * Expected failures of building the data of an entry being updated.\n */\nexport interface IUpdateEntryDataFactoryErrors {\n latest: GetLatestRevisionByEntryIdUseCase.Error;\n validation: EntryValidationError;\n}\n\ntype FactoryError = IUpdateEntryDataFactoryErrors[keyof IUpdateEntryDataFactoryErrors];\n\nexport interface IUpdateEntryDataFactory {\n create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: UpdateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n options?: UpdateCmsEntryOptionsInput\n ): Promise<Result<IUpdateEntryDataResponse<TValues>, FactoryError>>;\n}\n\nexport const UpdateEntryDataFactory = createAbstraction<IUpdateEntryDataFactory>(\n \"Cms/Entry/UpdateEntryDataFactory\"\n);\n\nexport namespace UpdateEntryDataFactory {\n export type Interface = IUpdateEntryDataFactory;\n export type Error = FactoryError;\n export type Return<TValues extends CmsEntryValues = CmsEntryValues> = Result<\n IUpdateEntryDataResponse<TValues>,\n FactoryError\n >;\n export type Response<TValues extends CmsEntryValues = CmsEntryValues> =\n IUpdateEntryDataResponse<TValues>;\n}\n"],"names":["UpdateEntryDataFactory","createAbstraction"],"mappings":";AAmCO,MAAMA,yBAAyBC,kBAClC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const getExpiresAt = (input, original)=>{
|
|
2
2
|
if (void 0 === input.expiresAt) return original?.expiresAt ?? null;
|
|
3
|
-
if (input.expiresAt instanceof Date) return input.expiresAt.getTime() / 1000;
|
|
4
|
-
if ("number" == typeof input.expiresAt && !isNaN(input.expiresAt) && input.expiresAt > 0) return input.expiresAt;
|
|
3
|
+
else if (input.expiresAt instanceof Date) return input.expiresAt.getTime() / 1000;
|
|
4
|
+
else if ("number" == typeof input.expiresAt && !isNaN(input.expiresAt) && input.expiresAt > 0) return input.expiresAt;
|
|
5
5
|
return null;
|
|
6
6
|
};
|
|
7
7
|
export { getExpiresAt };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/expiresAt.js","sources":["../../../../src/features/contentEntry/entryDataFactories/expiresAt.ts"],"sourcesContent":["import type { CmsEntry } from \"~/types/index.js\";\n\nexport interface IRawInput {\n expiresAt: Date | number | null | undefined;\n}\n\nexport const getExpiresAt = (input: IRawInput, original?: CmsEntry): number | null => {\n if (input.expiresAt === undefined) {\n return original?.expiresAt ?? null;\n } else if (input.expiresAt instanceof Date) {\n return input.expiresAt.getTime() / 1000;\n } else if (\n typeof input.expiresAt === \"number\" &&\n !isNaN(input.expiresAt) &&\n input.expiresAt > 0\n ) {\n return input.expiresAt;\n }\n return null;\n};\n"],"names":["getExpiresAt","input","original","undefined","Date","isNaN"],"mappings":"AAMO,MAAMA,eAAe,CAACC,OAAkBC;IAC3C,IAAID,AAAoBE,WAApBF,MAAM,SAAS,EACf,OAAOC,UAAU,aAAa;
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/expiresAt.js","sources":["../../../../src/features/contentEntry/entryDataFactories/expiresAt.ts"],"sourcesContent":["import type { CmsEntry } from \"~/types/index.js\";\n\nexport interface IRawInput {\n expiresAt: Date | number | null | undefined;\n}\n\nexport const getExpiresAt = (input: IRawInput, original?: CmsEntry): number | null => {\n if (input.expiresAt === undefined) {\n return original?.expiresAt ?? null;\n } else if (input.expiresAt instanceof Date) {\n return input.expiresAt.getTime() / 1000;\n } else if (\n typeof input.expiresAt === \"number\" &&\n !isNaN(input.expiresAt) &&\n input.expiresAt > 0\n ) {\n return input.expiresAt;\n }\n return null;\n};\n"],"names":["getExpiresAt","input","original","undefined","Date","isNaN"],"mappings":"AAMO,MAAMA,eAAe,CAACC,OAAkBC;IAC3C,IAAID,AAAoBE,WAApBF,MAAM,SAAS,EACf,OAAOC,UAAU,aAAa;SAC3B,IAAID,MAAM,SAAS,YAAYG,MAClC,OAAOH,MAAM,SAAS,CAAC,OAAO,KAAK;SAChC,IACH,AAA2B,YAA3B,OAAOA,MAAM,SAAS,IACtB,CAACI,MAAMJ,MAAM,SAAS,KACtBA,MAAM,SAAS,GAAG,GAElB,OAAOA,MAAM,SAAS;IAE1B,OAAO;AACX"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CmsEntryValues } from "../../../types/index.js";
|
|
2
|
+
export interface IHasEntryContentChangedParams<TValues extends CmsEntryValues = CmsEntryValues> {
|
|
3
|
+
/**
|
|
4
|
+
* The values as they will be stored (normalized).
|
|
5
|
+
*/
|
|
6
|
+
values: TValues;
|
|
7
|
+
/**
|
|
8
|
+
* The values to compare against, as currently stored.
|
|
9
|
+
*/
|
|
10
|
+
baselineValues: TValues;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Decides whether saving `values` changes the content of an entry. Used to keep the
|
|
14
|
+
* saved/modified meta fields untouched when an entry is saved without actual changes, e.g. when
|
|
15
|
+
* the "Save" button is clicked without editing anything.
|
|
16
|
+
*
|
|
17
|
+
* Only the content counts: moving an entry to another folder is not a content change, the same
|
|
18
|
+
* as with the dedicated move operation.
|
|
19
|
+
*
|
|
20
|
+
* Values must already be normalized the same way as the stored ones (item IDs assigned, reference
|
|
21
|
+
* fields mapped). A value that does not normalize identically is treated as a change, which only
|
|
22
|
+
* means the meta fields get updated, exactly as they did before this check existed.
|
|
23
|
+
*/
|
|
24
|
+
export declare const hasEntryContentChanged: <TValues extends CmsEntryValues = CmsEntryValues>(params: IHasEntryContentChangedParams<TValues>) => boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import isEqual from "lodash/isEqual.js";
|
|
2
|
+
const withoutEmptyKeys = (value)=>{
|
|
3
|
+
if (Array.isArray(value)) return value.map(withoutEmptyKeys);
|
|
4
|
+
if (null === value || "object" != typeof value || value instanceof Date) return value;
|
|
5
|
+
return Object.entries(value).reduce((result, [key, item])=>{
|
|
6
|
+
if (null != item) result[key] = withoutEmptyKeys(item);
|
|
7
|
+
return result;
|
|
8
|
+
}, {});
|
|
9
|
+
};
|
|
10
|
+
const hasEntryContentChanged = (params)=>!isEqual(withoutEmptyKeys(params.values), withoutEmptyKeys(params.baselineValues));
|
|
11
|
+
export { hasEntryContentChanged };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=hasEntryContentChanged.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/hasEntryContentChanged.js","sources":["../../../../src/features/contentEntry/entryDataFactories/hasEntryContentChanged.ts"],"sourcesContent":["import lodashIsEqual from \"lodash/isEqual.js\";\nimport type { CmsEntryValues } from \"~/types/index.js\";\n\n/**\n * Removes object keys with `null` or `undefined` values, recursively, so that a field that was\n * never set and a field that is explicitly empty compare as equal.\n */\nconst withoutEmptyKeys = (value: unknown): unknown => {\n if (Array.isArray(value)) {\n return value.map(withoutEmptyKeys);\n }\n if (value === null || typeof value !== \"object\" || value instanceof Date) {\n return value;\n }\n return Object.entries(value).reduce<Record<string, unknown>>((result, [key, item]) => {\n if (item !== null && item !== undefined) {\n result[key] = withoutEmptyKeys(item);\n }\n return result;\n }, {});\n};\n\nexport interface IHasEntryContentChangedParams<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * The values as they will be stored (normalized).\n */\n values: TValues;\n /**\n * The values to compare against, as currently stored.\n */\n baselineValues: TValues;\n}\n\n/**\n * Decides whether saving `values` changes the content of an entry. Used to keep the\n * saved/modified meta fields untouched when an entry is saved without actual changes, e.g. when\n * the \"Save\" button is clicked without editing anything.\n *\n * Only the content counts: moving an entry to another folder is not a content change, the same\n * as with the dedicated move operation.\n *\n * Values must already be normalized the same way as the stored ones (item IDs assigned, reference\n * fields mapped). A value that does not normalize identically is treated as a change, which only\n * means the meta fields get updated, exactly as they did before this check existed.\n */\nexport const hasEntryContentChanged = <TValues extends CmsEntryValues = CmsEntryValues>(\n params: IHasEntryContentChangedParams<TValues>\n): boolean => {\n return !lodashIsEqual(withoutEmptyKeys(params.values), withoutEmptyKeys(params.baselineValues));\n};\n"],"names":["withoutEmptyKeys","value","Array","Date","Object","result","key","item","hasEntryContentChanged","params","lodashIsEqual"],"mappings":";AAOA,MAAMA,mBAAmB,CAACC;IACtB,IAAIC,MAAM,OAAO,CAACD,QACd,OAAOA,MAAM,GAAG,CAACD;IAErB,IAAIC,AAAU,SAAVA,SAAkB,AAAiB,YAAjB,OAAOA,SAAsBA,iBAAiBE,MAChE,OAAOF;IAEX,OAAOG,OAAO,OAAO,CAACH,OAAO,MAAM,CAA0B,CAACI,QAAQ,CAACC,KAAKC,KAAK;QAC7E,IAAIA,QAAAA,MACAF,MAAM,CAACC,IAAI,GAAGN,iBAAiBO;QAEnC,OAAOF;IACX,GAAG,CAAC;AACR;AAyBO,MAAMG,yBAAyB,CAClCC,SAEO,CAACC,QAAcV,iBAAiBS,OAAO,MAAM,GAAGT,iBAAiBS,OAAO,cAAc"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type IComponentMapGenerator } from "./abstractions.js";
|
|
2
|
+
import { ModelToAstConverter } from "../ModelToAstConverter/abstractions.js";
|
|
3
|
+
import type { CmsModel } from "../../../types/index.js";
|
|
4
|
+
declare class ComponentMapGeneratorImpl implements IComponentMapGenerator {
|
|
5
|
+
private readonly modelToAst;
|
|
6
|
+
constructor(modelToAst: ModelToAstConverter.Interface);
|
|
7
|
+
generate(model: CmsModel): Record<string, string>;
|
|
8
|
+
private walkNode;
|
|
9
|
+
private walkCollection;
|
|
10
|
+
}
|
|
11
|
+
export declare const ComponentMapGenerator: typeof ComponentMapGeneratorImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<IComponentMapGenerator>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentMapGenerator } from "./abstractions.js";
|
|
2
|
+
import { ModelToAstConverter } from "../ModelToAstConverter/abstractions.js";
|
|
3
|
+
class ComponentMapGeneratorImpl {
|
|
4
|
+
constructor(modelToAst){
|
|
5
|
+
this.modelToAst = modelToAst;
|
|
6
|
+
}
|
|
7
|
+
generate(model) {
|
|
8
|
+
const ast = this.modelToAst.toAst(model);
|
|
9
|
+
const map = {};
|
|
10
|
+
this.walkNode(ast, map);
|
|
11
|
+
return map;
|
|
12
|
+
}
|
|
13
|
+
walkNode(node, map) {
|
|
14
|
+
for (const child of node.children)if ("collection" === child.type) this.walkCollection(child, map);
|
|
15
|
+
else this.walkNode(child, map);
|
|
16
|
+
}
|
|
17
|
+
walkCollection(node, map) {
|
|
18
|
+
const { collection } = node;
|
|
19
|
+
if (collection.componentName && collection.id) map[collection.id] = collection.componentName;
|
|
20
|
+
for (const child of node.children)if ("collection" === child.type) this.walkCollection(child, map);
|
|
21
|
+
else this.walkNode(child, map);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const ComponentMapGenerator_ComponentMapGenerator = ComponentMapGenerator.createImplementation({
|
|
25
|
+
implementation: ComponentMapGeneratorImpl,
|
|
26
|
+
dependencies: [
|
|
27
|
+
ModelToAstConverter
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
export { ComponentMapGenerator_ComponentMapGenerator as ComponentMapGenerator };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=ComponentMapGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/contentModel/ComponentMapGenerator/ComponentMapGenerator.js","sources":["../../../../src/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.ts"],"sourcesContent":["import {\n ComponentMapGenerator as Abstraction,\n type IComponentMapGenerator\n} from \"./abstractions.js\";\nimport { ModelToAstConverter } from \"../ModelToAstConverter/abstractions.js\";\nimport type {\n CmsModel,\n CmsModelAst,\n CmsModelFieldAstNode,\n CmsModelFieldAstNodeCollection\n} from \"~/types/index.js\";\n\nclass ComponentMapGeneratorImpl implements IComponentMapGenerator {\n constructor(private readonly modelToAst: ModelToAstConverter.Interface) {}\n\n generate(model: CmsModel): Record<string, string> {\n const ast = this.modelToAst.toAst(model);\n const map: Record<string, string> = {};\n this.walkNode(ast, map);\n return map;\n }\n\n private walkNode(node: CmsModelAst | CmsModelFieldAstNode, map: Record<string, string>) {\n for (const child of node.children) {\n if (child.type === \"collection\") {\n this.walkCollection(child, map);\n } else {\n this.walkNode(child, map);\n }\n }\n }\n\n private walkCollection(node: CmsModelFieldAstNodeCollection, map: Record<string, string>) {\n const { collection } = node;\n if (collection.componentName && collection.id) {\n map[collection.id] = collection.componentName;\n }\n\n for (const child of node.children) {\n if (child.type === \"collection\") {\n this.walkCollection(child, map);\n } else {\n this.walkNode(child, map);\n }\n }\n }\n}\n\nexport const ComponentMapGenerator = Abstraction.createImplementation({\n implementation: ComponentMapGeneratorImpl,\n dependencies: [ModelToAstConverter]\n});\n"],"names":["ComponentMapGeneratorImpl","modelToAst","model","ast","map","node","child","collection","ComponentMapGenerator","Abstraction","ModelToAstConverter"],"mappings":";;AAYA,MAAMA;IACF,YAA6BC,UAAyC,CAAE;aAA3CA,UAAU,GAAVA;IAA4C;IAEzE,SAASC,KAAe,EAA0B;QAC9C,MAAMC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAACD;QAClC,MAAME,MAA8B,CAAC;QACrC,IAAI,CAAC,QAAQ,CAACD,KAAKC;QACnB,OAAOA;IACX;IAEQ,SAASC,IAAwC,EAAED,GAA2B,EAAE;QACpF,KAAK,MAAME,SAASD,KAAK,QAAQ,CAC7B,IAAIC,AAAe,iBAAfA,MAAM,IAAI,EACV,IAAI,CAAC,cAAc,CAACA,OAAOF;aAE3B,IAAI,CAAC,QAAQ,CAACE,OAAOF;IAGjC;IAEQ,eAAeC,IAAoC,EAAED,GAA2B,EAAE;QACtF,MAAM,EAAEG,UAAU,EAAE,GAAGF;QACvB,IAAIE,WAAW,aAAa,IAAIA,WAAW,EAAE,EACzCH,GAAG,CAACG,WAAW,EAAE,CAAC,GAAGA,WAAW,aAAa;QAGjD,KAAK,MAAMD,SAASD,KAAK,QAAQ,CAC7B,IAAIC,AAAe,iBAAfA,MAAM,IAAI,EACV,IAAI,CAAC,cAAc,CAACA,OAAOF;aAE3B,IAAI,CAAC,QAAQ,CAACE,OAAOF;IAGjC;AACJ;AAEO,MAAMI,8CAAwBC,sBAAAA,oBAAgC,CAAC;IAClE,gBAAgBT;IAChB,cAAc;QAACU;KAAoB;AACvC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CmsModel } from "../../../types/index.js";
|
|
2
|
+
export interface IComponentMapGenerator {
|
|
3
|
+
generate(model: CmsModel): Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
export declare const ComponentMapGenerator: import("@webiny/di").Abstraction<IComponentMapGenerator>;
|
|
6
|
+
export declare namespace ComponentMapGenerator {
|
|
7
|
+
type Interface = IComponentMapGenerator;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/contentModel/ComponentMapGenerator/abstractions.js","sources":["../../../../src/features/contentModel/ComponentMapGenerator/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"~/types/index.js\";\n\nexport interface IComponentMapGenerator {\n generate(model: CmsModel): Record<string, string>;\n}\n\nexport const ComponentMapGenerator =\n createAbstraction<IComponentMapGenerator>(\"ComponentMapGenerator\");\n\nexport namespace ComponentMapGenerator {\n export type Interface = IComponentMapGenerator;\n}\n"],"names":["ComponentMapGenerator","createAbstraction"],"mappings":";AAOO,MAAMA,wBACTC,kBAA0C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ComponentMapGenerator } from "./ComponentMapGenerator.js";
|
|
3
|
+
const ComponentMapGeneratorFeature = createFeature({
|
|
4
|
+
name: "CmsContentModel/ComponentMapGenerator",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(ComponentMapGenerator);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { ComponentMapGeneratorFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/contentModel/ComponentMapGenerator/feature.js","sources":["../../../../src/features/contentModel/ComponentMapGenerator/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ComponentMapGenerator } from \"./ComponentMapGenerator.js\";\n\nexport const ComponentMapGeneratorFeature = createFeature({\n name: \"CmsContentModel/ComponentMapGenerator\",\n register(container) {\n container.register(ComponentMapGenerator);\n }\n});\n"],"names":["ComponentMapGeneratorFeature","createFeature","container","ComponentMapGenerator"],"mappings":";;AAGO,MAAMA,+BAA+BC,cAAc;IACtD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|