@webiny/api-headless-cms 5.29.0 → 5.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.d.ts +3 -0
- package/{content/contextSetup.js → context.js} +13 -8
- package/context.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.js +0 -0
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.js.map +0 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.js +0 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.js.map +0 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.js +0 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.js.map +0 -0
- package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.js +7 -1
- package/crud/contentEntry/entryDataValidation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.js +1 -1
- package/crud/contentEntry/markLockedFields.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/referenceFieldsMapping.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/referenceFieldsMapping.js +0 -0
- package/{content/plugins/crud → crud}/contentEntry/referenceFieldsMapping.js.map +0 -0
- package/{content/plugins/crud → crud}/contentEntry.crud.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry.crud.js +68 -42
- package/crud/contentEntry.crud.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/afterCreate.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreate.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreateFrom.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/afterCreateFrom.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreateFrom.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterDelete.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/afterDelete.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterDelete.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterUpdate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/afterUpdate.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterUpdate.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/beforeCreate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/beforeCreate.js +1 -1
- package/crud/contentModel/beforeCreate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.js +1 -1
- package/crud/contentModel/beforeDelete.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/beforeUpdate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/beforeUpdate.js +0 -0
- package/crud/contentModel/beforeUpdate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js.map +0 -0
- package/crud/contentModel/createFieldModels.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/createFieldModels.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/createFieldModels.js.map +0 -0
- package/crud/contentModel/idValidation.d.ts +1 -0
- package/{content/plugins/crud → crud}/contentModel/idValidation.js +3 -3
- package/crud/contentModel/idValidation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/models.d.ts +0 -0
- package/{content/plugins/crud → crud}/contentModel/models.js +2 -2
- package/crud/contentModel/models.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/validateLayout.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/validateLayout.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/validateLayout.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/validateModelFields.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/validateModelFields.js +2 -2
- package/crud/contentModel/validateModelFields.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel.crud.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel.crud.js +14 -12
- package/crud/contentModel.crud.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.js +5 -5
- package/crud/contentModelGroup/beforeCreate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.js +1 -1
- package/crud/contentModelGroup/beforeDelete.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.js +1 -1
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup.crud.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModelGroup.crud.js +15 -13
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/crud/index.d.ts +6 -0
- package/{content/plugins/crud → crud}/index.js +5 -17
- package/crud/index.js.map +1 -0
- package/{plugins/crud → crud}/settings.crud.d.ts +1 -1
- package/{plugins/crud → crud}/settings.crud.js +3 -7
- package/crud/settings.crud.js.map +1 -0
- package/{plugins/crud → crud}/system.crud.d.ts +1 -1
- package/{plugins/crud → crud}/system.crud.js +0 -0
- package/{plugins/crud → crud}/system.crud.js.map +0 -0
- package/{content/plugins → graphql}/buildSchemaPlugins.d.ts +2 -3
- package/graphql/buildSchemaPlugins.js +27 -0
- package/graphql/buildSchemaPlugins.js.map +1 -0
- package/graphql/graphQLHandlerFactory.d.ts +5 -0
- package/{content → graphql}/graphQLHandlerFactory.js +26 -18
- package/graphql/graphQLHandlerFactory.js.map +1 -0
- package/graphql/index.d.ts +5 -0
- package/graphql/index.js +57 -0
- package/graphql/index.js.map +1 -0
- package/graphql/schema/baseContentSchema.d.ts +3 -0
- package/{content/plugins/schema/baseSchema.js → graphql/schema/baseContentSchema.js} +3 -27
- package/graphql/schema/baseContentSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +3 -0
- package/{content/plugins → graphql}/schema/contentEntries.js +5 -58
- package/graphql/schema/contentEntries.js.map +1 -0
- package/graphql/schema/contentModelGroups.d.ts +3 -0
- package/{content/plugins → graphql}/schema/contentModelGroups.js +27 -11
- package/graphql/schema/contentModelGroups.js.map +1 -0
- package/graphql/schema/contentModels.d.ts +3 -0
- package/{content/plugins → graphql}/schema/contentModels.js +13 -7
- package/graphql/schema/contentModels.js.map +1 -0
- package/{content/plugins → graphql}/schema/createFieldResolvers.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createFieldResolvers.js +1 -1
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/{content/plugins → graphql}/schema/createManageResolvers.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createManageResolvers.js +7 -3
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/{content/plugins → graphql}/schema/createManageSDL.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createManageSDL.js +11 -7
- package/graphql/schema/createManageSDL.js.map +1 -0
- package/{content/plugins → graphql}/schema/createPreviewResolvers.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createPreviewResolvers.js +2 -2
- package/graphql/schema/createPreviewResolvers.js.map +1 -0
- package/{content/plugins → graphql}/schema/createReadResolvers.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createReadResolvers.js +2 -2
- package/graphql/schema/createReadResolvers.js.map +1 -0
- package/{content/plugins → graphql}/schema/createReadSDL.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createReadSDL.js +6 -6
- package/graphql/schema/createReadSDL.js.map +1 -0
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +6 -0
- package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGet.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGet.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGet.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveList.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveList.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveList.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRepublish.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRepublish.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRepublish.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js.map +0 -0
- package/{content/plugins/schema/resolvers/read → graphql/schema/resolvers/preview}/resolveGet.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveGet.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveGet.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveList.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveList.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveList.js.map +0 -0
- package/{content/plugins/schema/resolvers/preview → graphql/schema/resolvers/read}/resolveGet.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/read/resolveGet.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveGet.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.js.map +0 -0
- package/{content/plugins → graphql}/schema/schemaPlugins.d.ts +1 -1
- package/{content/plugins → graphql}/schema/schemaPlugins.js +18 -5
- package/graphql/schema/schemaPlugins.js.map +1 -0
- package/graphql/system.d.ts +6 -0
- package/graphql/system.js +119 -0
- package/graphql/system.js.map +1 -0
- package/graphqlFields/boolean.d.ts +2 -0
- package/graphqlFields/boolean.js +69 -0
- package/graphqlFields/boolean.js.map +1 -0
- package/graphqlFields/datetime.d.ts +2 -0
- package/{content/plugins/graphqlFields → graphqlFields}/datetime.js +42 -40
- package/graphqlFields/datetime.js.map +1 -0
- package/graphqlFields/file.d.ts +2 -0
- package/graphqlFields/file.js +50 -0
- package/graphqlFields/file.js.map +1 -0
- package/{content/plugins/graphqlFields → graphqlFields}/helpers.d.ts +1 -1
- package/{content/plugins/graphqlFields → graphqlFields}/helpers.js +0 -0
- package/{content/plugins/graphqlFields → graphqlFields}/helpers.js.map +0 -0
- package/graphqlFields/index.d.ts +2 -0
- package/graphqlFields/index.js +28 -0
- package/graphqlFields/index.js.map +1 -0
- package/graphqlFields/longText.d.ts +2 -0
- package/graphqlFields/longText.js +63 -0
- package/graphqlFields/longText.js.map +1 -0
- package/graphqlFields/number.d.ts +2 -0
- package/graphqlFields/number.js +75 -0
- package/graphqlFields/number.js.map +1 -0
- package/graphqlFields/object.d.ts +2 -0
- package/graphqlFields/object.js +225 -0
- package/graphqlFields/object.js.map +1 -0
- package/graphqlFields/ref.d.ts +2 -0
- package/graphqlFields/ref.js +279 -0
- package/graphqlFields/ref.js.map +1 -0
- package/graphqlFields/richText.d.ts +2 -0
- package/graphqlFields/richText.js +56 -0
- package/graphqlFields/richText.js.map +1 -0
- package/graphqlFields/text.d.ts +2 -0
- package/graphqlFields/text.js +73 -0
- package/graphqlFields/text.js.map +1 -0
- package/index.d.ts +10 -17
- package/index.js +73 -56
- package/index.js.map +1 -1
- package/modelManager/DefaultCmsModelManager.d.ts +14 -0
- package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js +0 -0
- package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js.map +0 -0
- package/modelManager/index.d.ts +2 -0
- package/{content/plugins/modelManager → modelManager}/index.js +3 -3
- package/modelManager/index.js.map +1 -0
- package/package.json +26 -27
- package/parameters/context.d.ts +2 -0
- package/parameters/context.js +22 -0
- package/parameters/context.js.map +1 -0
- package/parameters/header.d.ts +2 -0
- package/parameters/header.js +55 -0
- package/parameters/header.js.map +1 -0
- package/parameters/index.d.ts +4 -0
- package/parameters/index.js +57 -0
- package/parameters/index.js.map +1 -0
- package/parameters/manual.d.ts +6 -0
- package/{plugins/context.js → parameters/manual.js} +27 -27
- package/parameters/manual.js.map +1 -0
- package/parameters/path.d.ts +2 -0
- package/parameters/path.js +54 -0
- package/parameters/path.js.map +1 -0
- package/{content/plugins → plugins}/CmsGroupPlugin.d.ts +1 -1
- package/{content/plugins → plugins}/CmsGroupPlugin.js +0 -0
- package/{content/plugins → plugins}/CmsGroupPlugin.js.map +0 -0
- package/{content/plugins → plugins}/CmsModelPlugin.d.ts +1 -1
- package/{content/plugins → plugins}/CmsModelPlugin.js +0 -0
- package/{content/plugins → plugins}/CmsModelPlugin.js.map +0 -0
- package/{content/plugins → plugins}/CmsParametersPlugin.d.ts +8 -3
- package/{content/plugins → plugins}/CmsParametersPlugin.js +0 -0
- package/plugins/CmsParametersPlugin.js.map +1 -0
- package/{content/plugins/storage → plugins}/StorageTransformPlugin.d.ts +2 -1
- package/{content/plugins/storage → plugins}/StorageTransformPlugin.js +1 -0
- package/plugins/StorageTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +4 -0
- package/plugins/index.js +57 -0
- package/plugins/index.js.map +1 -0
- package/storage/default.d.ts +2 -0
- package/storage/default.js +27 -0
- package/storage/default.js.map +1 -0
- package/storage/object.d.ts +2 -0
- package/{content/plugins/storage → storage}/object.js +63 -64
- package/storage/object.js.map +1 -0
- package/types.d.ts +28 -3
- package/types.js.map +1 -1
- package/upgrades/index.d.ts +1 -0
- package/upgrades/index.js +10 -0
- package/upgrades/index.js.map +1 -0
- package/utils/access.d.ts +8 -0
- package/utils/access.js +90 -0
- package/utils/access.js.map +1 -0
- package/{content/plugins/utils → utils}/createTypeName.d.ts +0 -0
- package/{content/plugins/utils → utils}/createTypeName.js +0 -0
- package/{content/plugins/utils → utils}/createTypeName.js.map +0 -0
- package/{content/plugins/utils → utils}/entryStorage.d.ts +1 -1
- package/{content/plugins/utils → utils}/entryStorage.js +1 -1
- package/utils/entryStorage.js.map +1 -0
- package/utils/filterAsync.d.ts +1 -0
- package/utils/filterAsync.js +23 -0
- package/utils/filterAsync.js.map +1 -0
- package/{content/plugins/utils → utils}/getEntryTitle.d.ts +1 -1
- package/{content/plugins/utils → utils}/getEntryTitle.js +0 -0
- package/{content/plugins/utils → utils}/getEntryTitle.js.map +0 -0
- package/{content/plugins/utils → utils}/getSchemaFromFieldPlugins.d.ts +1 -1
- package/{content/plugins/utils → utils}/getSchemaFromFieldPlugins.js +0 -0
- package/{content/plugins/utils → utils}/getSchemaFromFieldPlugins.js.map +0 -0
- package/utils/ownership.d.ts +8 -0
- package/utils/ownership.js +39 -0
- package/utils/ownership.js.map +1 -0
- package/utils/permissions.d.ts +7 -0
- package/utils/permissions.js +110 -0
- package/utils/permissions.js.map +1 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.d.ts +0 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.js +0 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.js.map +0 -0
- package/{content/plugins/utils → utils}/renderFields.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderFields.js +0 -0
- package/{content/plugins/utils → utils}/renderFields.js.map +0 -0
- package/{content/plugins/utils → utils}/renderGetFilterFields.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderGetFilterFields.js +0 -0
- package/{content/plugins/utils → utils}/renderGetFilterFields.js.map +0 -0
- package/{content/plugins/utils → utils}/renderInputFields.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderInputFields.js +0 -0
- package/{content/plugins/utils → utils}/renderInputFields.js.map +0 -0
- package/{content/plugins/utils → utils}/renderListFilterFields.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderListFilterFields.js +0 -0
- package/{content/plugins/utils → utils}/renderListFilterFields.js.map +0 -0
- package/{content/plugins/utils → utils}/renderSortEnum.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderSortEnum.js +0 -0
- package/{content/plugins/utils → utils}/renderSortEnum.js.map +0 -0
- package/utils/toSlug.d.ts +1 -0
- package/utils/toSlug.js +20 -0
- package/utils/toSlug.js.map +1 -0
- package/validators/dateGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateGte.js +3 -3
- package/validators/dateGte.js.map +1 -0
- package/validators/dateLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateLte.js +3 -3
- package/validators/dateLte.js.map +1 -0
- package/validators/gte.d.ts +2 -0
- package/validators/gte.js +36 -0
- package/validators/gte.js.map +1 -0
- package/validators/in.d.ts +2 -0
- package/validators/in.js +36 -0
- package/validators/in.js.map +1 -0
- package/validators/index.d.ts +1 -0
- package/validators/index.js +36 -0
- package/validators/index.js.map +1 -0
- package/validators/lte.d.ts +2 -0
- package/validators/lte.js +36 -0
- package/validators/lte.js.map +1 -0
- package/validators/maxLength.d.ts +2 -0
- package/validators/maxLength.js +36 -0
- package/validators/maxLength.js.map +1 -0
- package/validators/minLength.d.ts +2 -0
- package/validators/minLength.js +36 -0
- package/validators/minLength.js.map +1 -0
- package/validators/pattern.d.ts +2 -0
- package/validators/pattern.js +50 -0
- package/validators/pattern.js.map +1 -0
- package/validators/patternPlugins/email.d.ts +2 -0
- package/validators/patternPlugins/email.js +20 -0
- package/validators/patternPlugins/email.js.map +1 -0
- package/validators/patternPlugins/index.d.ts +2 -0
- package/validators/patternPlugins/index.js +24 -0
- package/validators/patternPlugins/index.js.map +1 -0
- package/validators/patternPlugins/lowerCase.d.ts +2 -0
- package/validators/patternPlugins/lowerCase.js +20 -0
- package/validators/patternPlugins/lowerCase.js.map +1 -0
- package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/lowerCaseSpace.js +20 -0
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
- package/validators/patternPlugins/upperCase.d.ts +2 -0
- package/validators/patternPlugins/upperCase.js +20 -0
- package/validators/patternPlugins/upperCase.js.map +1 -0
- package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/upperCaseSpace.js +20 -0
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
- package/validators/patternPlugins/url.d.ts +2 -0
- package/validators/patternPlugins/url.js +20 -0
- package/validators/patternPlugins/url.js.map +1 -0
- package/validators/required.d.ts +2 -0
- package/validators/required.js +27 -0
- package/validators/required.js.map +1 -0
- package/validators/timeGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeGte.js +3 -3
- package/validators/timeGte.js.map +1 -0
- package/validators/timeLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeLte.js +3 -3
- package/validators/timeLte.js.map +1 -0
- package/{content/plugins/validators → validators}/unique.d.ts +2 -3
- package/{content/plugins/validators → validators}/unique.js +3 -3
- package/validators/unique.js.map +1 -0
- package/content/contextSetup.d.ts +0 -4
- package/content/contextSetup.js.map +0 -1
- package/content/graphQLHandlerFactory.d.ts +0 -5
- package/content/graphQLHandlerFactory.js.map +0 -1
- package/content/parameterPlugins.d.ts +0 -6
- package/content/parameterPlugins.js +0 -78
- package/content/parameterPlugins.js.map +0 -1
- package/content/plugins/CmsParametersPlugin.js.map +0 -1
- package/content/plugins/buildSchemaPlugins.js +0 -29
- package/content/plugins/buildSchemaPlugins.js.map +0 -1
- package/content/plugins/crud/contentEntry/entryDataValidation.js.map +0 -1
- package/content/plugins/crud/contentEntry/markLockedFields.js.map +0 -1
- package/content/plugins/crud/contentEntry.crud.js.map +0 -1
- package/content/plugins/crud/contentModel/beforeCreate.js.map +0 -1
- package/content/plugins/crud/contentModel/beforeDelete.js.map +0 -1
- package/content/plugins/crud/contentModel/beforeUpdate.js.map +0 -1
- package/content/plugins/crud/contentModel/createFieldModels.d.ts +0 -2
- package/content/plugins/crud/contentModel/idValidation.d.ts +0 -2
- package/content/plugins/crud/contentModel/idValidation.js.map +0 -1
- package/content/plugins/crud/contentModel/models.js.map +0 -1
- package/content/plugins/crud/contentModel/validateModelFields.js.map +0 -1
- package/content/plugins/crud/contentModel.crud.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/beforeCreate.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/beforeDelete.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/beforeUpdate.js.map +0 -1
- package/content/plugins/crud/contentModelGroup.crud.js.map +0 -1
- package/content/plugins/crud/index.d.ts +0 -6
- package/content/plugins/crud/index.js.map +0 -1
- package/content/plugins/graphqlFields/boolean.d.ts +0 -3
- package/content/plugins/graphqlFields/boolean.js +0 -67
- package/content/plugins/graphqlFields/boolean.js.map +0 -1
- package/content/plugins/graphqlFields/datetime.d.ts +0 -3
- package/content/plugins/graphqlFields/datetime.js.map +0 -1
- package/content/plugins/graphqlFields/file.d.ts +0 -3
- package/content/plugins/graphqlFields/file.js +0 -48
- package/content/plugins/graphqlFields/file.js.map +0 -1
- package/content/plugins/graphqlFields/index.d.ts +0 -2
- package/content/plugins/graphqlFields/index.js +0 -30
- package/content/plugins/graphqlFields/index.js.map +0 -1
- package/content/plugins/graphqlFields/longText.d.ts +0 -3
- package/content/plugins/graphqlFields/longText.js +0 -61
- package/content/plugins/graphqlFields/longText.js.map +0 -1
- package/content/plugins/graphqlFields/number.d.ts +0 -3
- package/content/plugins/graphqlFields/number.js +0 -73
- package/content/plugins/graphqlFields/number.js.map +0 -1
- package/content/plugins/graphqlFields/object.d.ts +0 -3
- package/content/plugins/graphqlFields/object.js +0 -223
- package/content/plugins/graphqlFields/object.js.map +0 -1
- package/content/plugins/graphqlFields/ref.d.ts +0 -3
- package/content/plugins/graphqlFields/ref.js +0 -276
- package/content/plugins/graphqlFields/ref.js.map +0 -1
- package/content/plugins/graphqlFields/richText.d.ts +0 -3
- package/content/plugins/graphqlFields/richText.js +0 -54
- package/content/plugins/graphqlFields/richText.js.map +0 -1
- package/content/plugins/graphqlFields/text.d.ts +0 -3
- package/content/plugins/graphqlFields/text.js +0 -71
- package/content/plugins/graphqlFields/text.js.map +0 -1
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +0 -8
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +0 -55
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js.map +0 -1
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +0 -7
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +0 -36
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js.map +0 -1
- package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +0 -14
- package/content/plugins/modelManager/index.d.ts +0 -3
- package/content/plugins/modelManager/index.js.map +0 -1
- package/content/plugins/schema/baseSchema.d.ts +0 -4
- package/content/plugins/schema/baseSchema.js.map +0 -1
- package/content/plugins/schema/contentEntries.d.ts +0 -4
- package/content/plugins/schema/contentEntries.js.map +0 -1
- package/content/plugins/schema/contentModelGroups.d.ts +0 -4
- package/content/plugins/schema/contentModelGroups.js.map +0 -1
- package/content/plugins/schema/contentModels.d.ts +0 -4
- package/content/plugins/schema/contentModels.js.map +0 -1
- package/content/plugins/schema/createFieldResolvers.js.map +0 -1
- package/content/plugins/schema/createManageResolvers.js.map +0 -1
- package/content/plugins/schema/createManageSDL.js.map +0 -1
- package/content/plugins/schema/createPreviewResolvers.js.map +0 -1
- package/content/plugins/schema/createReadResolvers.js.map +0 -1
- package/content/plugins/schema/createReadSDL.js.map +0 -1
- package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +0 -6
- package/content/plugins/schema/schemaPlugins.js.map +0 -1
- package/content/plugins/storage/StorageTransformPlugin.js.map +0 -1
- package/content/plugins/storage/default.d.ts +0 -3
- package/content/plugins/storage/default.js +0 -28
- package/content/plugins/storage/default.js.map +0 -1
- package/content/plugins/storage/object.d.ts +0 -3
- package/content/plugins/storage/object.js.map +0 -1
- package/content/plugins/utils/entryStorage.js.map +0 -1
- package/content/plugins/validators/dateGte.d.ts +0 -3
- package/content/plugins/validators/dateGte.js.map +0 -1
- package/content/plugins/validators/dateLte.d.ts +0 -3
- package/content/plugins/validators/dateLte.js.map +0 -1
- package/content/plugins/validators/gte.d.ts +0 -3
- package/content/plugins/validators/gte.js +0 -34
- package/content/plugins/validators/gte.js.map +0 -1
- package/content/plugins/validators/in.d.ts +0 -3
- package/content/plugins/validators/in.js +0 -34
- package/content/plugins/validators/in.js.map +0 -1
- package/content/plugins/validators/index.d.ts +0 -2
- package/content/plugins/validators/index.js +0 -38
- package/content/plugins/validators/index.js.map +0 -1
- package/content/plugins/validators/lte.d.ts +0 -3
- package/content/plugins/validators/lte.js +0 -34
- package/content/plugins/validators/lte.js.map +0 -1
- package/content/plugins/validators/maxLength.d.ts +0 -3
- package/content/plugins/validators/maxLength.js +0 -34
- package/content/plugins/validators/maxLength.js.map +0 -1
- package/content/plugins/validators/minLength.d.ts +0 -3
- package/content/plugins/validators/minLength.js +0 -34
- package/content/plugins/validators/minLength.js.map +0 -1
- package/content/plugins/validators/pattern.d.ts +0 -3
- package/content/plugins/validators/pattern.js +0 -47
- package/content/plugins/validators/pattern.js.map +0 -1
- package/content/plugins/validators/patternPlugins/email.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/email.js +0 -17
- package/content/plugins/validators/patternPlugins/email.js.map +0 -1
- package/content/plugins/validators/patternPlugins/index.d.ts +0 -2
- package/content/plugins/validators/patternPlugins/index.js +0 -23
- package/content/plugins/validators/patternPlugins/index.js.map +0 -1
- package/content/plugins/validators/patternPlugins/lowerCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/lowerCase.js +0 -17
- package/content/plugins/validators/patternPlugins/lowerCase.js.map +0 -1
- package/content/plugins/validators/patternPlugins/lowerCaseSpace.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/lowerCaseSpace.js +0 -17
- package/content/plugins/validators/patternPlugins/lowerCaseSpace.js.map +0 -1
- package/content/plugins/validators/patternPlugins/upperCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/upperCase.js +0 -17
- package/content/plugins/validators/patternPlugins/upperCase.js.map +0 -1
- package/content/plugins/validators/patternPlugins/upperCaseSpace.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/upperCaseSpace.js +0 -17
- package/content/plugins/validators/patternPlugins/upperCaseSpace.js.map +0 -1
- package/content/plugins/validators/patternPlugins/url.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/url.js +0 -17
- package/content/plugins/validators/patternPlugins/url.js.map +0 -1
- package/content/plugins/validators/required.d.ts +0 -3
- package/content/plugins/validators/required.js +0 -25
- package/content/plugins/validators/required.js.map +0 -1
- package/content/plugins/validators/timeGte.d.ts +0 -3
- package/content/plugins/validators/timeGte.js.map +0 -1
- package/content/plugins/validators/timeLte.d.ts +0 -3
- package/content/plugins/validators/timeLte.js.map +0 -1
- package/content/plugins/validators/unique.js.map +0 -1
- package/migrateCMSPermissions.d.ts +0 -17
- package/migrateCMSPermissions.js +0 -199
- package/migrateCMSPermissions.js.map +0 -1
- package/plugins/context.d.ts +0 -4
- package/plugins/context.js.map +0 -1
- package/plugins/crud/index.d.ts +0 -6
- package/plugins/crud/index.js +0 -108
- package/plugins/crud/index.js.map +0 -1
- package/plugins/crud/settings.crud.js.map +0 -1
- package/plugins/graphql/system.d.ts +0 -18
- package/plugins/graphql/system.js +0 -74
- package/plugins/graphql/system.js.map +0 -1
- package/plugins/graphql.d.ts +0 -2
- package/plugins/graphql.js +0 -86
- package/plugins/graphql.js.map +0 -1
- package/plugins/upgrades/index.d.ts +0 -2
- package/plugins/upgrades/index.js +0 -14
- package/plugins/upgrades/index.js.map +0 -1
- package/plugins/upgrades/v5.5.0/helpers.d.ts +0 -6
- package/plugins/upgrades/v5.5.0/helpers.js +0 -10
- package/plugins/upgrades/v5.5.0/helpers.js.map +0 -1
- package/plugins/upgrades/v5.5.0/index.d.ts +0 -4
- package/plugins/upgrades/v5.5.0/index.js +0 -134
- package/plugins/upgrades/v5.5.0/index.js.map +0 -1
- package/transformers.d.ts +0 -2
- package/transformers.js +0 -25
- package/transformers.js.map +0 -1
- package/utils.d.ts +0 -23
- package/utils.js +0 -251
- package/utils.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["STATUS_DRAFT","STATUS_PUBLISHED","STATUS_UNPUBLISHED","STATUS_CHANGES_REQUESTED","STATUS_REVIEW_REQUESTED","convertDefaultValue","field","value","type","Boolean","Number","getDefaultValue","settings","multipleValues","defaultValue","undefined","predefinedValues","enabled","Array","isArray","values","selectedValue","find","selected","filter","map","cleanInputData","model","input","fields","reduce","acc","fieldId","cleanUpdatedInputData","createEntryMeta","original","meta","lodashMerge","key","createEntryId","version","entryId","mdbid","id","createIdentifier","increaseEntryIdVersion","parseIdentifier","WebinyError","getSearchableFields","params","plugins","fieldPluginMap","byType","collection","fieldType","plugin","fullTextSearch","length","includes","createContentEntryCrud","storageOperations","context","getIdentity","getTenant","onBeforeEntryCreate","createTopic","onAfterEntryCreate","onBeforeEntryCreateRevision","onAfterEntryCreateRevision","onBeforeEntryUpdate","onAfterEntryUpdate","onBeforeEntryPublish","onAfterEntryPublish","onBeforeEntryUnpublish","onAfterEntryUnpublish","onBeforeEntryRequestChanges","onAfterEntryRequestChanges","onBeforeEntryRequestReview","onAfterEntryRequestReview","onBeforeEntryDelete","onAfterEntryDelete","onBeforeEntryDeleteRevision","onAfterEntryDeleteRevision","onBeforeEntryGet","onBeforeEntryList","assignBeforeEntryCreate","assignBeforeEntryUpdate","assignAfterEntryDelete","checkEntryPermissions","check","checkPermissions","deleteEntry","entry","publish","entries","delete","ex","message","code","getEntriesByIds","ids","permission","rwd","checkModelAccess","getByIds","validateOwnership","getEntryById","where","NotFoundError","getPublishedEntriesByIds","getPublishedByIds","getLatestEntriesByIds","getLatestByIds","getEntryRevisions","getRevisions","getEntry","sort","items","cms","listEntries","limit","initialWhere","ownedBy","own","latest","published","hasMoreItems","totalCount","cursor","list","listLatestEntries","listPublishedEntries","createEntry","inputData","initialInput","validateModelEntryData","data","referenceFieldsMapping","validateEntries","identity","security","locale","getLocale","owner","displayName","webinyVersion","WEBINY_VERSION","tenant","modelId","createdOn","Date","toISOString","savedOn","createdBy","locked","status","storageEntry","entryToStorageTransform","result","create","error","createEntryRevisionFrom","sourceId","uniqueId","originalStorageEntry","getRevisionById","latestStorageEntry","getLatestRevisionByEntryId","originalEntry","entryFromStorageTransform","initialValues","checkOwnership","latestId","nextVersion","publishedOn","createRevisionFrom","updateEntry","metaInput","update","republishEntry","deleteEntryRevision","revisionId","storageEntryToDelete","previousStorageEntry","getPreviousRevision","latestEntryRevisionId","entryToDelete","entryToSetAsLatest","storageEntryToSetAsLatest","deleteRevision","latestEntry","publishEntry","pw","currentDate","requestEntryChanges","requestChanges","requestEntryReview","latestEntryRevision","allowedStatuses","requestReview","unpublishEntry","getPublishedRevisionByEntryId","unpublish"],"sources":["contentEntry.crud.ts"],"sourcesContent":["/**\n * Package mdbid does not have types.\n */\n// @ts-ignore\nimport mdbid from \"mdbid\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport {\n CmsEntryContext,\n CmsEntryPermission,\n CmsEntry,\n CmsModel,\n CmsContext,\n CmsStorageEntry,\n HeadlessCmsStorageOperations,\n BeforeEntryCreateTopicParams,\n AfterEntryCreateTopicParams,\n BeforeEntryUpdateTopicParams,\n AfterEntryUpdateTopicParams,\n AfterEntryDeleteTopicParams,\n BeforeEntryDeleteTopicParams,\n BeforeEntryCreateRevisionTopicParams,\n AfterEntryCreateRevisionTopicParams,\n BeforeEntryPublishTopicParams,\n AfterEntryPublishTopicParams,\n BeforeEntryUnpublishTopicParams,\n AfterEntryUnpublishTopicParams,\n BeforeEntryRequestChangesTopicParams,\n AfterEntryRequestChangesTopicParams,\n BeforeEntryRequestReviewTopicParams,\n AfterEntryRequestReviewTopicParams,\n BeforeEntryDeleteRevisionTopicParams,\n AfterEntryDeleteRevisionTopicParams,\n BeforeEntryGetTopicParams,\n BeforeEntryListTopicParams,\n CmsEntryListWhere,\n UpdateCmsEntryInput,\n CreateCmsEntryInput,\n CmsModelField,\n CreatedBy,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { validateModelEntryData } from \"./contentEntry/entryDataValidation\";\nimport WebinyError from \"@webiny/error\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport { assignBeforeEntryCreate } from \"./contentEntry/beforeCreate\";\nimport { assignBeforeEntryUpdate } from \"./contentEntry/beforeUpdate\";\nimport { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport { assignAfterEntryDelete } from \"./contentEntry/afterDelete\";\nimport { referenceFieldsMapping } from \"./contentEntry/referenceFieldsMapping\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport lodashMerge from \"lodash/merge\";\nimport { checkPermissions } from \"~/utils/permissions\";\nimport { checkModelAccess } from \"~/utils/access\";\nimport { checkOwnership, validateOwnership } from \"~/utils/ownership\";\nimport { entryFromStorageTransform, entryToStorageTransform } from \"~/utils/entryStorage\";\n\nexport const STATUS_DRAFT = \"draft\";\nexport const STATUS_PUBLISHED = \"published\";\nexport const STATUS_UNPUBLISHED = \"unpublished\";\nexport const STATUS_CHANGES_REQUESTED = \"changesRequested\";\nexport const STATUS_REVIEW_REQUESTED = \"reviewRequested\";\n\ntype DefaultValue = boolean | number | string | null;\n/**\n * Used for some fields to convert their values.\n */\nconst convertDefaultValue = (field: CmsModelField, value: DefaultValue): DefaultValue => {\n switch (field.type) {\n case \"boolean\":\n return Boolean(value);\n case \"number\":\n return Number(value);\n default:\n return value;\n }\n};\nconst getDefaultValue = (field: CmsModelField): (DefaultValue | DefaultValue[]) | undefined => {\n const { settings, multipleValues } = field;\n if (settings && settings.defaultValue !== undefined) {\n return convertDefaultValue(field, settings.defaultValue);\n }\n const { predefinedValues } = field;\n if (\n !predefinedValues ||\n !predefinedValues.enabled ||\n Array.isArray(predefinedValues.values) === false\n ) {\n return undefined;\n }\n if (!multipleValues) {\n const selectedValue = predefinedValues.values.find(value => {\n return !!value.selected;\n });\n if (selectedValue) {\n return convertDefaultValue(field, selectedValue.value);\n }\n return undefined;\n }\n return predefinedValues.values\n .filter(({ selected }) => !!selected)\n .map(({ value }) => {\n return convertDefaultValue(field, value);\n });\n};\n/**\n * Cleans and adds default values to create input data.\n */\nconst cleanInputData = (model: CmsModel, input: CreateCmsEntryInput): CreateCmsEntryInput => {\n return model.fields.reduce((acc, field) => {\n const value = input[field.fieldId];\n /**\n * We set the default value on create input if value is not defined.\n */\n acc[field.fieldId] = value === undefined ? getDefaultValue(field) : value;\n return acc;\n }, {} as CreateCmsEntryInput);\n};\n/**\n * Cleans the update input entry data.\n */\nconst cleanUpdatedInputData = (\n model: CmsModel,\n input: UpdateCmsEntryInput\n): UpdateCmsEntryInput => {\n return model.fields.reduce((acc, field) => {\n /**\n * We cannot set default value here because user might want to updated only certain field values.\n */\n if (input[field.fieldId] === undefined) {\n return acc;\n }\n acc[field.fieldId] = input[field.fieldId];\n return acc;\n }, {} as CreateCmsEntryInput);\n};\n/**\n * This method takes original entry meta and new input.\n * When new meta is merged onto the existing one, everything that has undefined or null value is removed.\n */\nconst createEntryMeta = (input?: Record<string, any>, original?: Record<string, any>) => {\n const meta = lodashMerge(original || {}, input || {});\n\n for (const key in meta) {\n if (meta[key] !== undefined || meta[key] !== null) {\n continue;\n }\n delete meta[key];\n }\n\n return meta;\n};\n\ninterface DeleteEntryParams {\n model: CmsModel;\n entry: CmsEntry;\n}\n\ninterface EntryIdResult {\n /**\n * A generated id that will connect all the entry records.\n */\n entryId: string;\n /**\n * Version of the entry.\n */\n version: number;\n /**\n * Combination of entryId and version.\n */\n id: string;\n}\n\nconst createEntryId = (version: number): EntryIdResult => {\n const entryId = mdbid();\n return {\n entryId,\n version,\n id: createIdentifier({\n id: entryId,\n version\n })\n };\n};\n\nconst increaseEntryIdVersion = (id: string): EntryIdResult => {\n const { id: entryId, version } = parseIdentifier(id);\n if (!version) {\n throw new WebinyError(\n \"Cannot increase version on the ID without the version part.\",\n \"WRONG_ID\",\n {\n id\n }\n );\n }\n return {\n entryId,\n version: version + 1,\n id: createIdentifier({\n id: entryId,\n version: version + 1\n })\n };\n};\n\ninterface GetSearchableFieldsParams {\n plugins: PluginsContainer;\n model: CmsModel;\n fields?: string[];\n}\nconst getSearchableFields = (params: GetSearchableFieldsParams): string[] => {\n const { plugins, model, fields } = params;\n\n const fieldPluginMap = plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((collection, field) => {\n collection[field.fieldType] = field;\n return collection;\n }, {} as Record<string, CmsModelFieldToGraphQLPlugin>);\n\n return model.fields\n .filter(field => {\n const plugin = fieldPluginMap[field.type];\n if (!plugin) {\n return false;\n } else if (!plugin.fullTextSearch) {\n return false;\n } else if (!fields || fields.length === 0) {\n return true;\n }\n return fields.includes(field.fieldId);\n })\n .map(field => field.fieldId);\n};\n\nexport interface CreateContentEntryCrudParams {\n storageOperations: HeadlessCmsStorageOperations;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n getTenant: () => Tenant;\n}\n\nexport const createContentEntryCrud = (params: CreateContentEntryCrudParams): CmsEntryContext => {\n const { storageOperations, context, getIdentity, getTenant } = params;\n\n const onBeforeEntryCreate = createTopic<BeforeEntryCreateTopicParams>();\n const onAfterEntryCreate = createTopic<AfterEntryCreateTopicParams>();\n const onBeforeEntryCreateRevision = createTopic<BeforeEntryCreateRevisionTopicParams>();\n const onAfterEntryCreateRevision = createTopic<AfterEntryCreateRevisionTopicParams>();\n const onBeforeEntryUpdate = createTopic<BeforeEntryUpdateTopicParams>();\n const onAfterEntryUpdate = createTopic<AfterEntryUpdateTopicParams>();\n const onBeforeEntryPublish = createTopic<BeforeEntryPublishTopicParams>();\n const onAfterEntryPublish = createTopic<AfterEntryPublishTopicParams>();\n const onBeforeEntryUnpublish = createTopic<BeforeEntryUnpublishTopicParams>();\n const onAfterEntryUnpublish = createTopic<AfterEntryUnpublishTopicParams>();\n const onBeforeEntryRequestChanges = createTopic<BeforeEntryRequestChangesTopicParams>();\n const onAfterEntryRequestChanges = createTopic<AfterEntryRequestChangesTopicParams>();\n const onBeforeEntryRequestReview = createTopic<BeforeEntryRequestReviewTopicParams>();\n const onAfterEntryRequestReview = createTopic<AfterEntryRequestReviewTopicParams>();\n const onBeforeEntryDelete = createTopic<BeforeEntryDeleteTopicParams>();\n const onAfterEntryDelete = createTopic<AfterEntryDeleteTopicParams>();\n const onBeforeEntryDeleteRevision = createTopic<BeforeEntryDeleteRevisionTopicParams>();\n const onAfterEntryDeleteRevision = createTopic<AfterEntryDeleteRevisionTopicParams>();\n const onBeforeEntryGet = createTopic<BeforeEntryGetTopicParams>();\n const onBeforeEntryList = createTopic<BeforeEntryListTopicParams>();\n\n /**\n * We need to assign some default behaviors.\n */\n assignBeforeEntryCreate({\n context,\n onBeforeEntryCreate\n });\n assignBeforeEntryUpdate({\n context,\n onBeforeEntryUpdate\n });\n assignAfterEntryDelete({\n context,\n onAfterEntryDelete\n });\n\n const checkEntryPermissions = (check: {\n rwd?: string;\n pw?: string;\n }): Promise<CmsEntryPermission> => {\n return checkPermissions(context, \"cms.contentEntry\", check);\n };\n\n /**\n * A helper to delete the entire entry.\n */\n const deleteEntry = async (params: DeleteEntryParams): Promise<void> => {\n const { model, entry } = params;\n try {\n await onBeforeEntryDelete.publish({\n entry,\n model\n });\n\n await storageOperations.entries.delete(model, {\n entry\n });\n\n await onAfterEntryDelete.publish({\n entry,\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete entry.\",\n ex.code || \"DELETE_ERROR\",\n {\n entry\n }\n );\n }\n };\n /**\n * A helper to get entries by revision IDs\n */\n const getEntriesByIds = async (model: CmsModel, ids: string[]) => {\n const permission = await checkEntryPermissions({ rwd: \"r\" });\n await checkModelAccess(context, model);\n\n const entries = await storageOperations.entries.getByIds(model, {\n ids\n });\n\n return entries.filter(entry => validateOwnership(context, permission, entry));\n };\n\n return {\n onBeforeEntryCreate,\n onAfterEntryCreate,\n onBeforeEntryCreateRevision,\n onAfterEntryCreateRevision,\n onBeforeEntryUpdate,\n onAfterEntryUpdate,\n onBeforeEntryDelete,\n onAfterEntryDelete,\n onBeforeEntryDeleteRevision,\n onAfterEntryDeleteRevision,\n onBeforeEntryPublish,\n onAfterEntryPublish,\n onBeforeEntryUnpublish,\n onAfterEntryUnpublish,\n onBeforeEntryRequestChanges,\n onAfterEntryRequestChanges,\n onBeforeEntryRequestReview,\n onAfterEntryRequestReview,\n onBeforeEntryGet,\n onBeforeEntryList,\n /**\n * Get entries by exact revision IDs from the database.\n */\n getEntriesByIds: getEntriesByIds,\n /**\n * Get a single entry by revision ID from the database.\n */\n getEntryById: async (model, id) => {\n const where: CmsEntryListWhere = {\n id\n };\n await onBeforeEntryGet.publish({\n where,\n model\n });\n const [entry] = await getEntriesByIds(model, [id]);\n if (!entry) {\n throw new NotFoundError(`Entry by ID \"${id}\" not found.`);\n }\n return entry;\n },\n /**\n * Get published revisions by entry IDs.\n */\n getPublishedEntriesByIds: async (model: CmsModel, ids: string[]) => {\n const permission = await checkEntryPermissions({ rwd: \"r\" });\n await checkModelAccess(context, model);\n\n const entries = await storageOperations.entries.getPublishedByIds(model, {\n ids\n });\n\n return entries.filter(entry => validateOwnership(context, permission, entry));\n },\n /**\n * Get latest revisions by entry IDs.\n */\n getLatestEntriesByIds: async (model: CmsModel, ids: string[]) => {\n const permission = await checkEntryPermissions({ rwd: \"r\" });\n await checkModelAccess(context, model);\n\n const entries = await storageOperations.entries.getLatestByIds(model, {\n ids\n });\n\n return entries.filter(entry => validateOwnership(context, permission, entry));\n },\n\n getEntryRevisions: async (model, entryId) => {\n return storageOperations.entries.getRevisions(model, {\n id: entryId\n });\n },\n /**\n * TODO determine if this method is required at all.\n *\n * @internal\n */\n getEntry: async (model, params) => {\n await checkEntryPermissions({ rwd: \"r\" });\n\n const { where, sort } = params;\n\n await onBeforeEntryGet.publish({\n where,\n model\n });\n\n const [items] = await context.cms.listEntries(model, {\n where,\n sort,\n limit: 1\n });\n\n if (items.length === 0) {\n throw new NotFoundError(`Entry not found!`);\n }\n return items[0];\n },\n /**\n * @description Should not be used directly. Internal use only!\n *\n * @internal\n */\n listEntries: async (model: CmsModel, params) => {\n const permission = await checkEntryPermissions({ rwd: \"r\" });\n await checkModelAccess(context, model);\n\n const { where: initialWhere } = params;\n /**\n * We always assign tenant and locale because we do not allow one model to have content through multiple tenants.\n */\n const where: CmsEntryListWhere = {\n ...initialWhere\n };\n /**\n * Possibly only get records which are owned by current user.\n * Or if searching for the owner set that value - in the case that user can see other entries than their own.\n */\n const ownedBy = permission.own ? getIdentity().id : where.ownedBy;\n if (ownedBy !== undefined) {\n where.ownedBy = ownedBy;\n }\n /**\n * Where must contain either latest or published keys.\n * We cannot list entries without one of those\n */\n if (where.latest && where.published) {\n throw new WebinyError(\n \"Cannot list entries that are both published and latest.\",\n \"LIST_ENTRIES_ERROR\",\n {\n where\n }\n );\n } else if (!where.latest && !where.published) {\n throw new WebinyError(\n \"Cannot list entries if we do not have latest or published defined.\",\n \"LIST_ENTRIES_ERROR\",\n {\n where\n }\n );\n }\n\n await onBeforeEntryList.publish({\n where,\n model\n });\n\n const fields = getSearchableFields({\n model,\n plugins: context.plugins,\n fields: params.fields || []\n });\n\n const { hasMoreItems, totalCount, cursor, items } =\n await storageOperations.entries.list(model, {\n ...params,\n where,\n fields\n });\n\n const meta = {\n hasMoreItems,\n totalCount,\n /**\n * Cursor should be null if there are no more items to load.\n * Just make sure of that, disregarding what is returned from the storageOperations.entries.list method.\n */\n cursor: hasMoreItems ? cursor : null\n };\n\n return [items, meta];\n },\n listLatestEntries: async function (model, params) {\n const where = params?.where || ({} as CmsEntryListWhere);\n\n return context.cms.listEntries(model, {\n sort: [\"createdOn_DESC\"],\n ...(params || {}),\n where: {\n ...where,\n latest: true\n }\n });\n },\n listPublishedEntries: async function (model, params) {\n const where = params?.where || ({} as CmsEntryListWhere);\n\n return context.cms.listEntries(model, {\n sort: [\"createdOn_DESC\"],\n ...(params || {}),\n where: {\n ...where,\n published: true\n }\n });\n },\n createEntry: async (model, inputData) => {\n await checkEntryPermissions({ rwd: \"w\" });\n await checkModelAccess(context, model);\n\n /**\n * Make sure we only work with fields that are defined in the model.\n */\n const initialInput = cleanInputData(model, inputData);\n\n await validateModelEntryData({\n context,\n model,\n data: initialInput\n });\n\n const input = await referenceFieldsMapping({\n context,\n model,\n input: initialInput,\n validateEntries: true\n });\n\n const identity = context.security.getIdentity();\n const locale = context.cms.getLocale();\n\n const owner: CreatedBy = {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n };\n\n const { id, entryId, version } = createEntryId(1);\n\n const entry: CmsEntry = {\n webinyVersion: context.WEBINY_VERSION,\n tenant: getTenant().id,\n entryId,\n id,\n modelId: model.modelId,\n locale: locale.code,\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n createdBy: owner,\n ownedBy: owner,\n version,\n locked: false,\n status: STATUS_DRAFT,\n values: input\n };\n\n let storageEntry: CmsStorageEntry | null = null;\n try {\n await onBeforeEntryCreate.publish({\n entry,\n input,\n model\n });\n\n storageEntry = await entryToStorageTransform(context, model, entry);\n const result = await storageOperations.entries.create(model, {\n entry,\n storageEntry\n });\n\n await onAfterEntryCreate.publish({\n entry,\n storageEntry: result,\n model,\n input\n });\n\n return result;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create content entry.\",\n ex.code || \"CREATE_ENTRY_ERROR\",\n ex.data || {\n error: ex,\n input,\n entry,\n storageEntry\n }\n );\n }\n },\n createEntryRevisionFrom: async (model, sourceId, inputData) => {\n const permission = await checkEntryPermissions({ rwd: \"w\" });\n await checkModelAccess(context, model);\n\n /**\n * Make sure we only work with fields that are defined in the model.\n */\n const input = cleanUpdatedInputData(model, inputData);\n\n /**\n * Entries are identified by a common parent ID + Revision number.\n */\n const { id: uniqueId } = parseIdentifier(sourceId);\n\n const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {\n id: sourceId\n });\n const latestStorageEntry = await storageOperations.entries.getLatestRevisionByEntryId(\n model,\n {\n id: uniqueId\n }\n );\n\n if (!originalStorageEntry) {\n throw new NotFoundError(\n `Entry \"${sourceId}\" of model \"${model.modelId}\" was not found.`\n );\n }\n\n /**\n * We need to convert data from DB to its original form before using it further.\n */\n const originalEntry = await entryFromStorageTransform(\n context,\n model,\n originalStorageEntry\n );\n\n const initialValues = {\n ...originalEntry.values,\n ...input\n };\n\n await validateModelEntryData({\n context,\n model,\n data: initialValues,\n entry: originalEntry\n });\n\n const values = await referenceFieldsMapping({\n context,\n model,\n input: initialValues,\n validateEntries: false\n });\n\n checkOwnership(context, permission, originalEntry);\n\n const identity = context.security.getIdentity();\n\n const latestId = latestStorageEntry ? latestStorageEntry.id : sourceId;\n const { id, version: nextVersion } = increaseEntryIdVersion(latestId);\n\n const entry: CmsEntry = {\n ...originalEntry,\n id,\n version: nextVersion,\n savedOn: new Date().toISOString(),\n createdOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n locked: false,\n publishedOn: undefined,\n status: STATUS_DRAFT,\n values\n };\n\n let storageEntry: CmsStorageEntry | null = null;\n\n try {\n await onBeforeEntryCreateRevision.publish({\n input,\n entry,\n original: originalEntry,\n model\n });\n\n storageEntry = await entryToStorageTransform(context, model, entry);\n\n const result = await storageOperations.entries.createRevisionFrom(model, {\n entry,\n storageEntry\n });\n\n await onAfterEntryCreateRevision.publish({\n input,\n entry,\n model,\n original: originalEntry,\n storageEntry: result\n });\n return result;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create entry from existing one.\",\n ex.code || \"CREATE_FROM_REVISION_ERROR\",\n {\n error: ex,\n entry,\n storageEntry,\n originalEntry,\n originalStorageEntry\n }\n );\n }\n },\n updateEntry: async (model, id, inputData, metaInput) => {\n const permission = await checkEntryPermissions({ rwd: \"w\" });\n await checkModelAccess(context, model);\n\n /**\n * Make sure we only work with fields that are defined in the model.\n */\n const input = cleanUpdatedInputData(model, inputData);\n\n /**\n * The entry we are going to update.\n */\n const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {\n id\n });\n\n if (!originalStorageEntry) {\n throw new NotFoundError(`Entry \"${id}\" of model \"${model.modelId}\" was not found.`);\n }\n\n if (originalStorageEntry.locked) {\n throw new WebinyError(\n `Cannot update entry because it's locked.`,\n \"CONTENT_ENTRY_UPDATE_ERROR\"\n );\n }\n\n const originalEntry = await entryFromStorageTransform(\n context,\n model,\n originalStorageEntry\n );\n\n await validateModelEntryData({\n context,\n model,\n data: input,\n entry: originalEntry\n });\n\n checkOwnership(context, permission, originalEntry);\n\n const initialValues = {\n /**\n * Existing values from the database, transformed back to original, of course.\n */\n ...originalEntry.values,\n /**\n * Add new values.\n */\n ...input\n };\n\n const values = await referenceFieldsMapping({\n context,\n model,\n input: initialValues,\n validateEntries: false\n });\n /**\n * If users wants to remove a key from meta values, they need to send meta key with the null value.\n */\n const meta = createEntryMeta(metaInput, originalEntry.meta);\n /**\n * We always send the full entry to the hooks and storage operations update.\n */\n const entry: CmsEntry = {\n ...originalEntry,\n savedOn: new Date().toISOString(),\n values,\n meta\n };\n\n let storageEntry: CmsStorageEntry | null = null;\n\n try {\n await onBeforeEntryUpdate.publish({\n entry,\n model,\n input,\n original: originalEntry\n });\n\n storageEntry = await entryToStorageTransform(context, model, entry);\n\n const result = await storageOperations.entries.update(model, {\n entry,\n storageEntry\n });\n\n await onAfterEntryUpdate.publish({\n entry,\n storageEntry: result,\n model,\n input,\n original: originalEntry\n });\n return result;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update existing entry.\",\n ex.code || \"UPDATE_ERROR\",\n {\n error: ex,\n entry,\n storageEntry,\n originalEntry,\n input\n }\n );\n }\n },\n republishEntry: async (model, id) => {\n await checkEntryPermissions({ rwd: \"w\" });\n await checkModelAccess(context, model);\n /**\n * Fetch the entry from the storage.\n */\n const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {\n id\n });\n if (!originalStorageEntry) {\n throw new NotFoundError(`Entry \"${id}\" was not found!`);\n }\n\n const originalEntry = await entryFromStorageTransform(\n context,\n model,\n originalStorageEntry\n );\n /**\n * We can only process published entries.\n */\n if (originalEntry.status !== \"published\") {\n throw new WebinyError(\n \"Entry with given ID is not published!\",\n \"NOT_PUBLISHED_ERROR\",\n {\n id,\n original: originalEntry\n }\n );\n }\n\n const values = await referenceFieldsMapping({\n context,\n model,\n input: originalEntry.values,\n validateEntries: false\n });\n\n const entry: CmsEntry = {\n ...originalEntry,\n savedOn: new Date().toISOString(),\n webinyVersion: context.WEBINY_VERSION,\n values\n };\n\n const storageEntry = await entryToStorageTransform(context, model, entry);\n /**\n * First we need to update existing entry.\n */\n try {\n await storageOperations.entries.update(model, {\n entry,\n storageEntry\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not update existing entry with new data while re-publishing.\",\n \"REPUBLISH_UPDATE_ERROR\",\n {\n entry\n }\n );\n }\n /**\n * Then we move onto publishing it again.\n */\n try {\n return await storageOperations.entries.publish(model, {\n entry,\n storageEntry\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not publish existing entry while re-publishing.\",\n \"REPUBLISH_PUBLISH_ERROR\",\n {\n entry\n }\n );\n }\n },\n deleteEntryRevision: async (model, revisionId) => {\n const permission = await checkEntryPermissions({ rwd: \"d\" });\n await checkModelAccess(context, model);\n\n const { id: entryId, version } = parseIdentifier(revisionId);\n\n const storageEntryToDelete = await storageOperations.entries.getRevisionById(model, {\n id: revisionId\n });\n const latestStorageEntry = await storageOperations.entries.getLatestRevisionByEntryId(\n model,\n {\n id: entryId\n }\n );\n const previousStorageEntry = await storageOperations.entries.getPreviousRevision(\n model,\n {\n entryId,\n version: version as number\n }\n );\n\n if (!storageEntryToDelete) {\n throw new NotFoundError(`Entry \"${revisionId}\" was not found!`);\n }\n\n checkOwnership(context, permission, storageEntryToDelete);\n\n const latestEntryRevisionId = latestStorageEntry ? latestStorageEntry.id : null;\n\n const entryToDelete = await entryFromStorageTransform(\n context,\n model,\n storageEntryToDelete\n );\n /**\n * If targeted record is the latest entry record and there is no previous one, we need to run full delete with hooks.\n * At this point deleteRevision hooks are not fired.\n */\n if (entryToDelete.id === latestEntryRevisionId && !previousStorageEntry) {\n return await deleteEntry({\n model,\n entry: entryToDelete\n });\n }\n /**\n * If targeted record is latest entry revision, set the previous one as the new latest\n */\n let entryToSetAsLatest: CmsEntry | null = null;\n let storageEntryToSetAsLatest: CmsStorageEntry | null = null;\n if (entryToDelete.id === latestEntryRevisionId && previousStorageEntry) {\n entryToSetAsLatest = await entryFromStorageTransform(\n context,\n model,\n previousStorageEntry\n );\n storageEntryToSetAsLatest = previousStorageEntry;\n }\n\n try {\n await onBeforeEntryDeleteRevision.publish({\n entry: entryToDelete,\n model\n });\n\n await storageOperations.entries.deleteRevision(model, {\n entry: entryToDelete,\n storageEntry: storageEntryToDelete,\n latestEntry: entryToSetAsLatest,\n latestStorageEntry: storageEntryToSetAsLatest\n });\n\n await onAfterEntryDeleteRevision.publish({\n entry: entryToDelete,\n model\n });\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code || \"DELETE_REVISION_ERROR\", {\n error: ex,\n entry: entryToDelete,\n storageEntry: storageEntryToDelete,\n latestEntry: entryToSetAsLatest,\n latestStorageEntry: storageEntryToSetAsLatest\n });\n }\n },\n deleteEntry: async (model, entryId) => {\n const permission = await checkEntryPermissions({ rwd: \"d\" });\n await checkModelAccess(context, model);\n\n const storageEntry = await storageOperations.entries.getLatestRevisionByEntryId(model, {\n id: entryId\n });\n\n if (!storageEntry) {\n throw new NotFoundError(`Entry \"${entryId}\" was not found!`);\n }\n\n checkOwnership(context, permission, storageEntry);\n\n const entry = await entryFromStorageTransform(context, model, storageEntry);\n\n return await deleteEntry({\n model,\n entry\n });\n },\n publishEntry: async (model, id) => {\n const permission = await checkEntryPermissions({ pw: \"p\" });\n await checkModelAccess(context, model);\n\n const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {\n id\n });\n\n if (!originalStorageEntry) {\n throw new NotFoundError(\n `Entry \"${id}\" in the model \"${model.modelId}\" was not found.`\n );\n }\n\n checkOwnership(context, permission, originalStorageEntry);\n\n const originalEntry = await entryFromStorageTransform(\n context,\n model,\n originalStorageEntry\n );\n\n const currentDate = new Date().toISOString();\n const entry: CmsEntry = {\n ...originalEntry,\n status: STATUS_PUBLISHED,\n locked: true,\n savedOn: currentDate,\n publishedOn: currentDate\n };\n\n let storageEntry: CmsStorageEntry | null = null;\n\n try {\n await onBeforeEntryPublish.publish({\n entry,\n model\n });\n\n storageEntry = await entryToStorageTransform(context, model, entry);\n const result = await storageOperations.entries.publish(model, {\n entry,\n storageEntry\n });\n\n await onAfterEntryPublish.publish({\n entry,\n storageEntry: result,\n model\n });\n return result;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not publish entry.\",\n ex.code || \"PUBLISH_ERROR\",\n {\n error: ex,\n entry,\n storageEntry,\n originalEntry,\n originalStorageEntry\n }\n );\n }\n },\n requestEntryChanges: async (model, id) => {\n const permission = await checkEntryPermissions({ pw: \"c\" });\n\n const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {\n id\n });\n\n if (!originalStorageEntry) {\n throw new NotFoundError(`Entry \"${id}\" of model \"${model.modelId}\" was not found.`);\n }\n\n const originalEntry = await entryFromStorageTransform(\n context,\n model,\n originalStorageEntry\n );\n\n if (originalEntry.status !== STATUS_REVIEW_REQUESTED) {\n throw new WebinyError(\n \"Cannot request changes on an entry that's not under review.\",\n \"ENTRY_NOT_UNDER_REVIEW\"\n );\n }\n\n const identity = context.security.getIdentity();\n if (originalEntry.ownedBy.id === identity.id) {\n throw new WebinyError(\n \"You cannot request changes on your own entry.\",\n \"CANNOT_REQUEST_CHANGES_ON_OWN_ENTRY\"\n );\n }\n\n checkOwnership(context, permission, originalEntry);\n\n const entry: CmsEntry = {\n ...originalEntry,\n status: STATUS_CHANGES_REQUESTED\n };\n\n let storageEntry: CmsStorageEntry | null = null;\n\n try {\n await onBeforeEntryRequestChanges.publish({\n entry,\n model\n });\n\n storageEntry = await entryToStorageTransform(context, model, entry);\n\n const result = await storageOperations.entries.requestChanges(model, {\n entry,\n storageEntry\n });\n\n await onAfterEntryRequestChanges.publish({\n entry,\n storageEntry: result,\n model\n });\n\n return result;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not request changes for the entry.\",\n ex.code || \"REQUEST_CHANGES_ERROR\",\n {\n entry,\n originalEntry\n }\n );\n }\n },\n requestEntryReview: async (model, id) => {\n const permission = await checkEntryPermissions({ pw: \"r\" });\n const { id: entryId } = parseIdentifier(id);\n\n const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {\n id\n });\n const latestEntryRevision = await storageOperations.entries.getLatestRevisionByEntryId(\n model,\n {\n id: entryId\n }\n );\n\n if (!originalStorageEntry) {\n throw new NotFoundError(`Entry \"${id}\" of model \"${model.modelId}\" was not found.`);\n } else if (!latestEntryRevision) {\n throw new NotFoundError(`Entry \"${id}\" does not have latest record`);\n }\n\n const originalEntry = await entryFromStorageTransform(\n context,\n model,\n originalStorageEntry\n );\n\n const allowedStatuses = [STATUS_DRAFT, STATUS_CHANGES_REQUESTED];\n if (!allowedStatuses.includes(originalEntry.status)) {\n throw new WebinyError(\n \"Cannot request review - entry is not a draft nor was a change request issued.\",\n \"REQUEST_REVIEW_ERROR\",\n {\n entry: originalEntry\n }\n );\n }\n\n checkOwnership(context, permission, originalEntry);\n\n const entry: CmsEntry = {\n ...originalEntry,\n status: STATUS_REVIEW_REQUESTED\n };\n\n let storageEntry: CmsStorageEntry | null = null;\n\n try {\n await onBeforeEntryRequestReview.publish({\n entry,\n model\n });\n\n storageEntry = await entryToStorageTransform(context, model, entry);\n\n const result = await storageOperations.entries.requestReview(model, {\n entry,\n storageEntry\n });\n\n await onAfterEntryRequestReview.publish({\n entry,\n storageEntry: result,\n model\n });\n\n return result;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not request review on the entry.\",\n ex.code || \"REQUEST_REVIEW_ERROR\",\n {\n originalEntry,\n entry\n }\n );\n }\n },\n unpublishEntry: async (model, id) => {\n const permission = await checkEntryPermissions({ pw: \"u\" });\n\n const { id: entryId } = parseIdentifier(id);\n\n const originalStorageEntry =\n await storageOperations.entries.getPublishedRevisionByEntryId(model, {\n id: entryId\n });\n\n if (!originalStorageEntry) {\n throw new NotFoundError(`Entry \"${id}\" of model \"${model.modelId}\" was not found.`);\n }\n\n if (originalStorageEntry.id !== id) {\n throw new WebinyError(`Entry is not published.`, \"UNPUBLISH_ERROR\", {\n entry: originalStorageEntry\n });\n }\n\n checkOwnership(context, permission, originalStorageEntry);\n\n const originalEntry = await entryFromStorageTransform(\n context,\n model,\n originalStorageEntry\n );\n\n const entry: CmsEntry = {\n ...originalEntry,\n status: STATUS_UNPUBLISHED\n };\n\n let storageEntry: CmsStorageEntry | null = null;\n\n try {\n await onBeforeEntryUnpublish.publish({\n entry,\n model\n });\n\n storageEntry = await entryToStorageTransform(context, model, entry);\n\n const result = await storageOperations.entries.unpublish(model, {\n entry,\n storageEntry\n });\n\n await onAfterEntryUnpublish.publish({\n entry,\n storageEntry: result,\n model\n });\n\n return result;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not unpublish entry.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n originalEntry,\n originalStorageEntry,\n entry,\n storageEntry\n }\n );\n }\n }\n };\n};\n"],"mappings":";;;;;;;;;;;AAIA;;AACA;;AAoCA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEO,MAAMA,YAAY,GAAG,OAArB;;AACA,MAAMC,gBAAgB,GAAG,WAAzB;;AACA,MAAMC,kBAAkB,GAAG,aAA3B;;AACA,MAAMC,wBAAwB,GAAG,kBAAjC;;AACA,MAAMC,uBAAuB,GAAG,iBAAhC;;;AAGP;AACA;AACA;AACA,MAAMC,mBAAmB,GAAG,CAACC,KAAD,EAAuBC,KAAvB,KAA6D;EACrF,QAAQD,KAAK,CAACE,IAAd;IACI,KAAK,SAAL;MACI,OAAOC,OAAO,CAACF,KAAD,CAAd;;IACJ,KAAK,QAAL;MACI,OAAOG,MAAM,CAACH,KAAD,CAAb;;IACJ;MACI,OAAOA,KAAP;EANR;AAQH,CATD;;AAUA,MAAMI,eAAe,GAAIL,KAAD,IAAuE;EAC3F,MAAM;IAAEM,QAAF;IAAYC;EAAZ,IAA+BP,KAArC;;EACA,IAAIM,QAAQ,IAAIA,QAAQ,CAACE,YAAT,KAA0BC,SAA1C,EAAqD;IACjD,OAAOV,mBAAmB,CAACC,KAAD,EAAQM,QAAQ,CAACE,YAAjB,CAA1B;EACH;;EACD,MAAM;IAAEE;EAAF,IAAuBV,KAA7B;;EACA,IACI,CAACU,gBAAD,IACA,CAACA,gBAAgB,CAACC,OADlB,IAEAC,KAAK,CAACC,OAAN,CAAcH,gBAAgB,CAACI,MAA/B,MAA2C,KAH/C,EAIE;IACE,OAAOL,SAAP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,IAA3C;;MAEA,IAAI;QACA,MAAMnF,sBAAsB,CAACoB,OAAvB,CAA+B;UACjCD,KADiC;UAEjCjE;QAFiC,CAA/B,CAAN;QAKAiI,YAAY,GAAG,MAAM,IAAAC,qCAAA,EAAwBhG,OAAxB,EAAiClC,KAAjC,EAAwCiE,KAAxC,CAArB;QAEA,MAAMkE,MAAM,GAAG,MAAMlG,iBAAiB,CAACkC,OAAlB,CAA0B4G,SAA1B,CAAoC/K,KAApC,EAA2C;UAC5DiE,KAD4D;UAE5DgE;QAF4D,CAA3C,CAArB;QAKA,MAAMlF,qBAAqB,CAACmB,OAAtB,CAA8B;UAChCD,KADgC;UAEhCgE,YAAY,EAAEE,MAFkB;UAGhCnI;QAHgC,CAA9B,CAAN;QAMA,OAAOmI,MAAP;MACH,CApBD,CAoBE,OAAO9D,EAAP,EAAW;QACT,MAAM,IAAIjD,cAAJ,CACFiD,EAAE,CAACC,OAAH,IAAc,4BADZ,EAEFD,EAAE,CAACE,IAAH,IAAW,iBAFT,EAGF;UACIsE,aADJ;UAEIJ,oBAFJ;UAGIxE,KAHJ;UAIIgE;QAJJ,CAHE,CAAN;MAUH;IACJ;EA79BE,CAAP;AA+9BH,CAzjCM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AfterModelCreateTopicParams, CmsContext } from "
|
|
1
|
+
import { AfterModelCreateTopicParams, CmsContext } from "../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
interface AssignAfterModelCreateParams {
|
|
4
4
|
onAfterModelCreate: Topic<AfterModelCreateTopicParams>;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AfterModelCreateFromTopicParams, CmsContext } from "
|
|
1
|
+
import { AfterModelCreateFromTopicParams, CmsContext } from "../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
interface AssignAfterModelCreateFromParams {
|
|
4
4
|
onAfterModelCreateFrom: Topic<AfterModelCreateFromTopicParams>;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AfterModelDeleteTopicParams, CmsContext } from "
|
|
1
|
+
import { AfterModelDeleteTopicParams, CmsContext } from "../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
interface AssignAfterModelDeleteParams {
|
|
4
4
|
onAfterModelDelete: Topic<AfterModelDeleteTopicParams>;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AfterModelUpdateTopicParams, CmsContext } from "
|
|
1
|
+
import { AfterModelUpdateTopicParams, CmsContext } from "../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
interface AssignAfterModelUpdateParams {
|
|
4
4
|
onAfterModelUpdate: Topic<AfterModelUpdateTopicParams>;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BeforeModelCreateFromTopicParams, BeforeModelCreateTopicParams, HeadlessCmsStorageOperations } from "
|
|
1
|
+
import { BeforeModelCreateFromTopicParams, BeforeModelCreateTopicParams, HeadlessCmsStorageOperations } from "../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
4
|
interface AssignBeforeModelCreateParams {
|
|
@@ -13,7 +13,7 @@ var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
|
13
13
|
|
|
14
14
|
var _pluralize = _interopRequireDefault(require("pluralize"));
|
|
15
15
|
|
|
16
|
-
var _CmsModelPlugin = require("../../CmsModelPlugin");
|
|
16
|
+
var _CmsModelPlugin = require("../../plugins/CmsModelPlugin");
|
|
17
17
|
|
|
18
18
|
var _validateModelFields = require("./validateModelFields");
|
|
19
19
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["disallowedModelIdList","disallowedModelIdEndingList","checkModelIdUniqueness","modelIdList","modelId","includes","WebinyError","pluralizedModelIdCamelCase","pluralize","plural","singularizedModelIdCamelCase","singular","checkModelIdAllowed","checkModelIdEndingAllowed","ending","re","RegExp","matched","match","getModelId","model","name","camelCase","trim","createOnBeforeCb","plugins","storageOperations","params","modelPlugin","byType","CmsModelPlugin","type","find","item","contentModel","models","list","where","tenant","locale","map","m","assignBeforeModelCreate","onBeforeModelCreate","onBeforeModelCreateFrom","subscribe","input","cb","validateModelFields"],"sources":["beforeCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport camelCase from \"lodash/camelCase\";\nimport pluralize from \"pluralize\";\nimport {\n BeforeModelCreateFromTopicParams,\n BeforeModelCreateTopicParams,\n CmsModel,\n HeadlessCmsStorageOperations\n} from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { validateModelFields } from \"./validateModelFields\";\n\nconst disallowedModelIdList: string[] = [\n \"contentModel\",\n \"contentModels\",\n \"contentModelGroup\",\n \"contentModelGroups\"\n];\n/**\n * This list is to disallow creating models that might interfere with GraphQL schema creation.\n * Add more if required.\n */\nconst disallowedModelIdEndingList: string[] = [\n \"Response\",\n \"List\",\n \"Meta\",\n \"Input\",\n \"Sorter\",\n \"RefType\"\n];\n\n/**\n * Checks for the uniqueness of provided modelId, against the provided list of models.\n * It also takes plural / singular forms of the provided modelId into account.\n */\nconst checkModelIdUniqueness = (modelIdList: string[], modelId: string) => {\n if (modelIdList.includes(modelId) === true) {\n throw new WebinyError(\n `Content model with modelId \"${modelId}\" already exists.`,\n \"MODEL_ID_EXISTS\",\n {\n modelId\n }\n );\n }\n /**\n * Additionally, check if the plural form of the received modelId exists too. This prevents users\n * from creating, for example, \"event\" and \"events\" models, which would break the GraphQL schema.\n * 1. First check if user wants to create the \"event\" model, but the \"events\" model already exists.\n */\n const pluralizedModelIdCamelCase = pluralize(modelId);\n if (modelIdList.includes(pluralizedModelIdCamelCase) === true) {\n throw new WebinyError(\n `Content model with modelId \"${modelId}\" does not exist, but a model with modelId \"${pluralizedModelIdCamelCase}\" does.`,\n \"MODEL_ID_PLURAL_ERROR\",\n {\n modelId,\n plural: pluralizedModelIdCamelCase\n }\n );\n }\n\n /**\n * 2. Then check if user wants to create the \"events\" model, but the \"event\" model already exists.\n */\n const singularizedModelIdCamelCase = pluralize.singular(modelId);\n if (modelIdList.includes(singularizedModelIdCamelCase) === true) {\n throw new WebinyError(\n `Content model with modelId \"${modelId}\" does not exist, but a model with modelId \"${singularizedModelIdCamelCase}\" does.`,\n \"MODEL_ID_SINGULAR_ERROR\",\n {\n modelId,\n singular: singularizedModelIdCamelCase\n }\n );\n }\n};\n\nconst checkModelIdAllowed = (modelId: string): void => {\n if (disallowedModelIdList.includes(modelId) === false) {\n return;\n }\n throw new WebinyError(`Provided model ID \"${modelId}\" is not allowed.`);\n};\n\nconst checkModelIdEndingAllowed = (modelId: string): void => {\n for (const ending of disallowedModelIdEndingList) {\n const re = new RegExp(`${ending}$`, \"i\");\n const matched = modelId.match(re);\n if (matched === null) {\n continue;\n }\n throw new WebinyError(\n `ModelId that ends with \"${ending}\" is not allowed.`,\n \"MODEL_ID_NOT_ALLOWED\",\n {\n modelId\n }\n );\n }\n};\n\nconst getModelId = (model: CmsModel): string => {\n const { modelId, name } = model;\n if (!!modelId) {\n return camelCase(modelId.trim());\n } else if (name) {\n return camelCase(name.trim());\n }\n throw new WebinyError(\n `There is no \"modelId\" or \"name\" passed into the create model method.`,\n \"MISSING_MODEL_DATA\",\n {\n model\n }\n );\n};\n\ninterface CreateOnBeforeCreateCbParams {\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\nconst createOnBeforeCb = ({ plugins, storageOperations }: CreateOnBeforeCreateCbParams) => {\n return async (params: BeforeModelCreateTopicParams | BeforeModelCreateFromTopicParams) => {\n const { model } = params;\n\n const modelId = getModelId(model);\n\n const modelPlugin = plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n .find((item: CmsModelPlugin) => item.contentModel.modelId === modelId);\n\n if (modelPlugin) {\n throw new WebinyError(\n `Cannot create \"${model.modelId}\" content model because one is already registered via a plugin.`,\n \"CONTENT_MODEL_CREATE_ERROR\",\n {\n modelId: model.modelId\n }\n );\n }\n\n const models = await storageOperations.models.list({\n where: {\n tenant: model.tenant,\n locale: model.locale\n }\n });\n const modelIdList = models.map(m => m.modelId);\n\n /**\n * We need to check for:\n * - is that exact modelId allowed\n * - is modelId unique\n * - is model ending allowed\n */\n checkModelIdAllowed(modelId);\n checkModelIdEndingAllowed(modelId);\n checkModelIdUniqueness(modelIdList, modelId);\n model.modelId = modelId;\n };\n};\n\ninterface AssignBeforeModelCreateParams {\n onBeforeModelCreate: Topic<BeforeModelCreateTopicParams>;\n onBeforeModelCreateFrom: Topic<BeforeModelCreateFromTopicParams>;\n storageOperations: HeadlessCmsStorageOperations;\n plugins: PluginsContainer;\n}\n\n/**\n * We attach both on before create and createFrom events here.\n * Callables are identical.\n */\nexport const assignBeforeModelCreate = (params: AssignBeforeModelCreateParams) => {\n const { onBeforeModelCreate, onBeforeModelCreateFrom, storageOperations, plugins } = params;\n\n onBeforeModelCreate.subscribe(async ({ model, input }) => {\n /**\n * First we need to validate base data of the model.\n */\n const cb = createOnBeforeCb({\n storageOperations,\n plugins\n });\n await cb({\n model,\n input\n });\n /**\n * Then we move onto fields...\n */\n await validateModelFields({\n model,\n plugins\n });\n });\n\n onBeforeModelCreateFrom.subscribe(\n createOnBeforeCb({\n storageOperations,\n plugins\n })\n );\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AASA;;AACA;;AAEA,MAAMA,qBAA+B,GAAG,CACpC,cADoC,EAEpC,eAFoC,EAGpC,mBAHoC,EAIpC,oBAJoC,CAAxC;AAMA;AACA;AACA;AACA;;AACA,MAAMC,2BAAqC,GAAG,CAC1C,UAD0C,EAE1C,MAF0C,EAG1C,MAH0C,EA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teTopicParams, HeadlessCmsStorageOperations } from "
|
|
2
|
+
import { BeforeModelDeleteTopicParams, HeadlessCmsStorageOperations } from "../../types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
4
|
interface AssignBeforeModelDeleteParams {
|
|
5
5
|
onBeforeModelDelete: Topic<BeforeModelDeleteTopicParams>;
|
|
@@ -9,7 +9,7 @@ exports.assignBeforeModelDelete = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
11
|
|
|
12
|
-
var _CmsModelPlugin = require("../../CmsModelPlugin");
|
|
12
|
+
var _CmsModelPlugin = require("../../plugins/CmsModelPlugin");
|
|
13
13
|
|
|
14
14
|
const assignBeforeModelDelete = params => {
|
|
15
15
|
const {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["assignBeforeModelDelete","params","onBeforeModelDelete","storageOperations","plugins","subscribe","model","modelPlugin","byType","CmsModelPlugin","type","find","item","contentModel","modelId","WebinyError","entries","result","list","where","latest","limit","items","ex","error","length"],"sources":["beforeDelete.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { BeforeModelDeleteTopicParams, HeadlessCmsStorageOperations } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\n\ninterface AssignBeforeModelDeleteParams {\n onBeforeModelDelete: Topic<BeforeModelDeleteTopicParams>;\n storageOperations: HeadlessCmsStorageOperations;\n plugins: PluginsContainer;\n}\nexport const assignBeforeModelDelete = (params: AssignBeforeModelDeleteParams) => {\n const { onBeforeModelDelete, storageOperations, plugins } = params;\n\n onBeforeModelDelete.subscribe(async params => {\n const { model } = params;\n\n const modelPlugin = plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n .find(item => item.contentModel.modelId === model.modelId);\n\n if (modelPlugin) {\n throw new WebinyError(\n \"Content models defined via plugins cannot be deleted.\",\n \"CONTENT_MODEL_DELETE_ERROR\",\n {\n modelId: model.modelId\n }\n );\n }\n\n let entries = [];\n try {\n const result = await storageOperations.entries.list(model, {\n where: {\n latest: true\n },\n limit: 1\n });\n entries = result.items;\n } catch (ex) {\n throw new WebinyError(\n \"Could not retrieve a list of content entries from the model.\",\n \"ENTRIES_ERROR\",\n {\n error: ex,\n model\n }\n );\n }\n if (entries.length > 0) {\n throw new WebinyError(\n `Cannot delete content model \"${model.modelId}\" because there are existing entries.`,\n \"CONTENT_MODEL_BEFORE_DELETE_HOOK_FAILED\"\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAGA;;AACA;;AAOO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,mBAAF;IAAuBC,iBAAvB;IAA0CC;EAA1C,IAAsDH,MAA5D;EAEAC,mBAAmB,CAACG,SAApB,CAA8B,MAAMJ,MAAN,IAAgB;IAC1C,MAAM;MAAEK;IAAF,IAAYL,MAAlB;IAEA,MAAMM,WAAW,GAAGH,OAAO,CACtBI,MADe,CACQC,8BAAA,CAAeC,IADvB,EAEfC,IAFe,CAEVC,IAAI,IAAIA,IAAI,CAACC,YAAL,CAAkBC,OAAlB,KAA8BR,KAAK,CAACQ,OAFlC,CAApB;;IAIA,IAAIP,WAAJ,EAAiB;MACb,MAAM,IAAIQ,cAAJ,CACF,uDADE,EAEF,4BAFE,EAGF;QACID,OAAO,EAAER,KAAK,CAACQ;MADnB,CAHE,CAAN;IAOH;;IAED,IAAIE,OAAO,GAAG,EAAd;;IACA,IAAI;MACA,MAAMC,MAAM,GAAG,MAAMd,iBAAiB,CAACa,OAAlB,CAA0BE,IAA1B,CAA+BZ,KAA/B,EAAsC;QACvDa,KAAK,EAAE;UACHC,MAAM,EAAE;QADL,CADgD;QAIvDC,KAAK,EAAE;MAJgD,CAAtC,CAArB;MAMAL,OAAO,GAAGC,MAAM,CAACK,KAAjB;IACH,CARD,CAQE,OAAOC,EAAP,EAAW;MACT,MAAM,IAAIR,cAAJ,CACF,8DADE,EAEF,eAFE,EAGF;QACIS,KAAK,EAAED,EADX;QAEIjB;MAFJ,CAHE,CAAN;IAQH;;IACD,IAAIU,OAAO,CAACS,MAAR,GAAiB,CAArB,EAAwB;MACpB,MAAM,IAAIV,cAAJ,CACD,gCAA+BT,KAAK,CAACQ,OAAQ,uCAD5C,EAEF,yCAFE,CAAN;IAIH;EACJ,CA1CD;AA2CH,CA9CM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Topic } from "@webiny/pubsub/types";
|
|
2
|
-
import { BeforeModelUpdateTopicParams, HeadlessCmsStorageOperations } from "
|
|
2
|
+
import { BeforeModelUpdateTopicParams, HeadlessCmsStorageOperations } from "../../types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
4
|
interface AssignBeforeModelUpdateParams {
|
|
5
5
|
onBeforeModelUpdate: Topic<BeforeModelUpdateTopicParams>;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["assignBeforeModelUpdate","params","onBeforeModelUpdate","plugins","subscribe","validateModelFields","model"],"sources":["beforeUpdate.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { BeforeModelUpdateTopicParams, HeadlessCmsStorageOperations } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { validateModelFields } from \"./validateModelFields\";\n\ninterface AssignBeforeModelUpdateParams {\n onBeforeModelUpdate: Topic<BeforeModelUpdateTopicParams>;\n storageOperations: HeadlessCmsStorageOperations;\n plugins: PluginsContainer;\n}\n\nexport const assignBeforeModelUpdate = (params: AssignBeforeModelUpdateParams) => {\n const { onBeforeModelUpdate, plugins } = params;\n\n onBeforeModelUpdate.subscribe(async params => {\n await validateModelFields({\n model: params.model,\n plugins\n });\n });\n};\n"],"mappings":";;;;;;;AAGA;;AAQO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,mBAAF;IAAuBC;EAAvB,IAAmCF,MAAzC;EAEAC,mBAAmB,CAACE,SAApB,CAA8B,MAAMH,MAAN,IAAgB;IAC1C,MAAM,IAAAI,wCAAA,EAAoB;MACtBC,KAAK,EAAEL,MAAM,CAACK,KADQ;MAEtBH;IAFsB,CAApB,CAAN;EAIH,CALD;AAMH,CATM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CmsModel, CmsContext, CmsModelManager } from "
|
|
1
|
+
import { CmsModel, CmsContext, CmsModelManager } from "../../types";
|
|
2
2
|
export declare const contentModelManagerFactory: (context: CmsContext, model: CmsModel) => Promise<CmsModelManager>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const validateId: (value: string) => Promise<void>;
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.validateId = void 0;
|
|
7
7
|
|
|
8
8
|
var _validation = require("@webiny/validation");
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const validateId = async value => {
|
|
11
11
|
await _validation.validation.validate(value, "required,maxLength:100");
|
|
12
12
|
|
|
13
13
|
if (!value.charAt(0).match(/[a-zA-Z]/)) {
|
|
@@ -19,4 +19,4 @@ var _default = async value => {
|
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
exports.
|
|
22
|
+
exports.validateId = validateId;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["validateId","value","validation","validate","charAt","match","Error","trim","toLowerCase"],"sources":["idValidation.ts"],"sourcesContent":["import { validation } from \"@webiny/validation\";\n\nexport const validateId = async (value: string): Promise<void> => {\n await validation.validate(value, \"required,maxLength:100\");\n if (!value.charAt(0).match(/[a-zA-Z]/)) {\n throw new Error(`Provided ID ${value} is not valid - must not start with a number.`);\n }\n if (value.trim().toLowerCase() === \"id\") {\n throw new Error(`Provided ID ${value} is not valid - \"id\" is an auto-generated field.`);\n }\n};\n"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,UAAU,GAAG,MAAOC,KAAP,IAAwC;EAC9D,MAAMC,sBAAA,CAAWC,QAAX,CAAoBF,KAApB,EAA2B,wBAA3B,CAAN;;EACA,IAAI,CAACA,KAAK,CAACG,MAAN,CAAa,CAAb,EAAgBC,KAAhB,CAAsB,UAAtB,CAAL,EAAwC;IACpC,MAAM,IAAIC,KAAJ,CAAW,eAAcL,KAAM,+CAA/B,CAAN;EACH;;EACD,IAAIA,KAAK,CAACM,IAAN,GAAaC,WAAb,OAA+B,IAAnC,EAAyC;IACrC,MAAM,IAAIF,KAAJ,CAAW,eAAcL,KAAM,kDAA/B,CAAN;EACH;AACJ,CARM"}
|
|
File without changes
|
|
@@ -15,7 +15,7 @@ var _commodoFieldsObject = require("commodo-fields-object");
|
|
|
15
15
|
|
|
16
16
|
var _fields = require("@commodo/fields");
|
|
17
17
|
|
|
18
|
-
var _idValidation =
|
|
18
|
+
var _idValidation = require("./idValidation");
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Package commodo-fields-object does not have types
|
|
@@ -40,7 +40,7 @@ const ContentModelFieldModel = (0, _fields.withFields)({
|
|
|
40
40
|
validation: requiredShortString
|
|
41
41
|
}),
|
|
42
42
|
fieldId: (0, _flow.default)((0, _fields.onSet)(value => value && value.trim()), (0, _fields.setOnce)())((0, _fields.string)({
|
|
43
|
-
validation: _idValidation.
|
|
43
|
+
validation: _idValidation.validateId
|
|
44
44
|
})),
|
|
45
45
|
label: (0, _fields.string)({
|
|
46
46
|
validation: requiredShortString
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["requiredShortString","validation","create","shortString","RendererModel","withFields","name","string","ContentModelFieldModel","id","fieldId","flow","onSet","value","trim","setOnce","validateId","label","helpText","placeholderText","type","multipleValues","boolean","predefinedValues","fields","instanceOf","enabled","values","list","selected","renderer","message","settings","object","listValidation","CreateContentModelModel","modelId","description","group","required","layout","CreateContentModelModelFrom","locale","UpdateContentModelModel","titleFieldId"],"sources":["models.ts"],"sourcesContent":["import { validation } from \"@webiny/validation\";\nimport flow from \"lodash/flow\";\n/**\n * Package commodo-fields-object does not have types\n */\n// @ts-ignore\nimport { object } from \"commodo-fields-object\";\n/**\n * Package commodo-fields does not have object.\n */\n// @ts-ignore\nimport { withFields, string, setOnce, onSet, boolean, fields } from \"@commodo/fields\";\nimport { validateId } from \"./idValidation\";\n\nconst requiredShortString = validation.create(\"required,maxLength:255\");\nconst shortString = validation.create(\"maxLength:255\");\n\nconst RendererModel = withFields({\n name: string({ validation: requiredShortString })\n})();\n\nexport const ContentModelFieldModel = withFields({\n id: string({ validation: requiredShortString }),\n fieldId: flow(\n onSet((value?: string) => value && value.trim()),\n setOnce()\n )(string({ validation: validateId })),\n label: string({ validation: requiredShortString }),\n helpText: string({ validation: shortString }),\n placeholderText: string({ validation: shortString }),\n type: setOnce()(string({ validation: requiredShortString })),\n multipleValues: boolean({ value: false }),\n predefinedValues: fields({\n value: {},\n instanceOf: withFields({\n enabled: boolean(),\n values: fields({\n value: [],\n list: true,\n instanceOf: withFields({\n label: string(),\n value: string(),\n selected: boolean()\n })()\n })\n })()\n }),\n renderer: fields({ instanceOf: RendererModel, validation: shortString }),\n validation: fields({\n list: true,\n value: [],\n instanceOf: withFields({\n name: string({ validation: requiredShortString }),\n message: string({ validation: shortString }),\n settings: object({ value: {} })\n })()\n }),\n listValidation: fields({\n list: true,\n value: [],\n instanceOf: withFields({\n name: string({ validation: requiredShortString }),\n message: string({ validation: shortString }),\n settings: object({ value: {} })\n })()\n }),\n settings: object({ value: {} })\n})();\n\nexport const CreateContentModelModel = withFields({\n name: string({ validation: requiredShortString }),\n modelId: string({ validation: shortString }),\n description: string({ validation: shortString }),\n group: string({ validation: requiredShortString }),\n fields: fields({ instanceOf: ContentModelFieldModel, value: [], list: true, required: true }),\n layout: object({ value: [], required: true })\n})();\n\nexport const CreateContentModelModelFrom = withFields({\n name: string({ validation: requiredShortString }),\n modelId: string({ validation: shortString }),\n description: string({ validation: shortString }),\n group: string({ validation: requiredShortString }),\n locale: string({ validation: shortString })\n})();\n\nexport const UpdateContentModelModel = withFields({\n name: string({ validation: shortString }),\n description: string({ validation: shortString }),\n group: string({ validation: shortString }),\n titleFieldId: string(),\n fields: fields({ instanceOf: ContentModelFieldModel, value: [], list: true, required: true }),\n layout: object({ value: [], required: true })\n})();\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAKA;;AAKA;;AACA;;AAVA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AAIA,MAAMA,mBAAmB,GAAGC,sBAAA,CAAWC,MAAX,CAAkB,wBAAlB,CAA5B;;AACA,MAAMC,WAAW,GAAGF,sBAAA,CAAWC,MAAX,CAAkB,eAAlB,CAApB;;AAEA,MAAME,aAAa,GAAG,IAAAC,kBAAA,EAAW;EAC7BC,IAAI,EAAE,IAAAC,cAAA,EAAO;IAAEN,UAAU,EAAED;EAAd,CAAP;AADuB,CAAX,GAAtB;AAIO,MAAMQ,sBAAsB,GAAG,IAAAH,kBAAA,EAAW;EAC7CI,EAAE,EAAE,IAAAF,cAAA,EAAO;IAAEN,UAAU,EAAED;EAAd,CAAP,CADyC;EAE7CU,OAAO,EAAE,IAAAC,aAAA,EACL,IAAAC,aAAA,EAAOC,KAAD,IAAoBA,KAAK,IAAIA,KAAK,CAACC,IAAN,EAAnC,CADK,EAEL,IAAAC,eAAA,GAFK,EAGP,IAAAR,cAAA,EAAO;IAAEN,UAAU,EAAEe;EAAd,CAAP,CAHO,CAFoC;EAM7CC,KAAK,EAAE,IAAAV,cAAA,EAAO;IAAEN,UAAU,EAAED;EAAd,CAAP,CANsC;EAO7CkB,QAAQ,EAAE,IAAAX,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP,CAPmC;EAQ7CgB,eAAe,EAAE,IAAAZ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EAElDoC,OAAO,EAAE,IAAA7B,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP,CAFyC;EAGlDkC,WAAW,EAAE,IAAA9B,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP,CAHqC;EAIlDmC,KAAK,EAAE,IAAA/B,cAAA,EAAO;IAAEN,UAAU,EAAED;EAAd,CAAP,CAJ2C;EAKlD0C,MAAM,EAAE,IAAAnC,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP;AAL0C,CAAX,GAApC;;AAQA,MAAMwC,uBAAuB,GAAG,IAAAtC,kBAAA,EAAW;EAC9CC,IAAI,EAAE,IAAAC,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP,CADwC;EAE9CkC,WAAW,EAAE,IAAA9B,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP,CAFiC;EAG9CmC,KAAK,EAAE,IAAA/B,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP,CAHuC;EAI9CyC,YAAY,EAAE,IAAArC,cAAA,GAJgC;EAK9CiB,MAAM,EAAE,IAAAA,cAAA,EAAO;IAAEC,UAAU,EAAEjB,sBAAd;IAAsCK,KAAK,EAAE,EAA7C;IAAiDe,IAAI,EAAE,IAAvD;IAA6DW,QAAQ,EAAE;EAAvE,CAAP,CALsC;EAM9CC,MAAM,EAAE,IAAAP,2BAAA,EAAO;IAAEpB,KAAK,EAAE,EAAT;IAAa0B,QAAQ,EAAE;EAAvB,CAAP;AANsC,CAAX,GAAhC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CmsModelField, CmsModel } from "
|
|
1
|
+
import { CmsModelField, CmsModel } from "../../types";
|
|
2
2
|
export declare const validateLayout: (model: CmsModel, fields?: CmsModelField[]) => void;
|
|
File without changes
|
|
File without changes
|
|
@@ -13,9 +13,9 @@ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
|
13
13
|
|
|
14
14
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
15
|
|
|
16
|
-
var _CmsModelPlugin = require("../../CmsModelPlugin");
|
|
16
|
+
var _CmsModelPlugin = require("../../plugins/CmsModelPlugin");
|
|
17
17
|
|
|
18
|
-
var _createManageSDL = require("../../schema/createManageSDL");
|
|
18
|
+
var _createManageSDL = require("../../graphql/schema/createManageSDL");
|
|
19
19
|
|
|
20
20
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
21
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultTitleFieldId","allowedTitleFieldTypes","getContentModelTitleFieldId","fields","titleFieldId","titleField","find","field","type","multipleValues","fieldId","target","f","WebinyError","includes","join","extractInvalidField","model","err","sdl","source","body","line","lineNumber","locations","sdlLines","split","sdlLine","gqlType","i","match","invalidField","undefined","Array","isArray","fieldRegex","RegExp","matched","message","data","modelId","code","validateModelFields","params","plugins","modelPlugin","byType","CmsModelPlugin","item","contentModel","lockedFields","fieldTypePlugins","length","fieldType","Error","schema","createManageSDL","reduce","acc","pl","gql","cmsLockedFieldPlugins","lockedField","existingField","lockedFieldsByType","filter","plugin","checkLockedField"],"sources":["validateModelFields.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport {\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin,\n CmsModelLockedFieldPlugin\n} from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { GraphQLError } from \"graphql\";\nimport { createManageSDL } from \"~/graphql/schema/createManageSDL\";\n\nconst defaultTitleFieldId = \"id\";\n\nconst allowedTitleFieldTypes = [\"text\", \"number\"];\n\nconst getContentModelTitleFieldId = (fields: CmsModelField[], titleFieldId?: string): string => {\n // if there is no title field defined either in input data or existing content model data\n // we will take first text field that has no multiple values enabled\n // or if initial titleFieldId is the default one also try to find first available text field\n if (!titleFieldId || titleFieldId === defaultTitleFieldId) {\n const titleField = fields.find(field => {\n return field.type === \"text\" && !field.multipleValues;\n });\n return titleField ? titleField.fieldId : defaultTitleFieldId;\n }\n // check existing titleFieldId for existence in the model\n // for correct type\n // and that it is not multiple values field\n const target = fields.find(f => f.fieldId === titleFieldId);\n if (!target) {\n throw new WebinyError(`Field does not exist in the model.`, \"VALIDATION_ERROR\", {\n fieldId: titleFieldId,\n fields\n });\n }\n\n if (allowedTitleFieldTypes.includes(target.type) === false) {\n throw new WebinyError(\n `Only ${allowedTitleFieldTypes.join(\n \", \"\n )} and id fields can be used as an entry title.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n if (target.multipleValues) {\n throw new WebinyError(\n `Fields that accept multiple values cannot be used as the entry title.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n return target.fieldId;\n};\n\nconst extractInvalidField = (model: CmsModel, err: GraphQLError) => {\n const sdl = err.source?.body || \"\";\n\n // Find the invalid type\n const { line: lineNumber } = err.locations\n ? err.locations[0]\n : {\n line: 0\n };\n const sdlLines = sdl.split(\"\\n\");\n let sdlLine;\n let gqlType;\n for (let i = lineNumber; i > 0; i--) {\n if (sdlLine && sdlLine.includes(\"type \")) {\n gqlType = sdlLine.match(/type\\s+(.*?)\\s+{/);\n break;\n }\n\n sdlLine = sdlLines[i];\n }\n\n let invalidField: string | undefined = undefined;\n if (Array.isArray(gqlType)) {\n const fieldRegex = new RegExp(`([^\\\\s+].*?):\\\\s+\\\\[?${gqlType[1]}!?\\\\]?`);\n\n const matched = sdl.match(fieldRegex);\n if (matched) {\n invalidField = matched[1];\n }\n }\n\n let message = `See more details in the browser console.`;\n if (invalidField) {\n message = `Please review the definition of \"${invalidField}\" field.`;\n }\n\n return {\n data: {\n modelId: model.modelId,\n sdl,\n invalidField\n },\n code: \"INVALID_MODEL_DEFINITION\",\n message: [`Model \"${model.modelId}\" was not saved!`, message].join(\"\\n\")\n };\n};\n\ninterface ValidateModelParams {\n model: CmsModel;\n plugins: PluginsContainer;\n}\n\nexport const validateModelFields = async (params: ValidateModelParams) => {\n const { model, plugins } = params;\n\n const modelPlugin = plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n .find(item => item.contentModel.modelId === model.modelId);\n\n if (modelPlugin) {\n throw new WebinyError(\n \"Content models defined via plugins cannot be updated.\",\n \"CONTENT_MODEL_UPDATE_ERROR\",\n {\n modelId: model.modelId\n }\n );\n }\n\n const { titleFieldId } = model;\n\n // There should be fields/locked fields in either model or data to be updated.\n const { fields = [], lockedFields = [] } = model;\n\n // Let's inspect the fields of the received content model. We prevent saving of a content model if it\n // contains a field for which a \"cms-model-field-to-graphql\" plugin does not exist on the backend.\n const fieldTypePlugins = plugins.byType<CmsModelFieldToGraphQLPlugin>(\n \"cms-model-field-to-graphql\"\n );\n\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i];\n if (!fieldTypePlugins.find(item => item.fieldType === field.type)) {\n throw new Error(\n `Cannot update content model because of the unknown \"${field.type}\" field.`\n );\n }\n }\n\n if (fields.length) {\n // Make sure that this model can be safely converted to a GraphQL SDL\n const schema = createManageSDL({\n model,\n fieldTypePlugins: fieldTypePlugins.reduce(\n (acc, pl) => ({ ...acc, [pl.fieldType]: pl }),\n {}\n )\n });\n\n try {\n gql(schema);\n } catch (err) {\n throw new WebinyError(extractInvalidField(model, err));\n }\n }\n\n model.titleFieldId = getContentModelTitleFieldId(fields, titleFieldId);\n\n const cmsLockedFieldPlugins =\n plugins.byType<CmsModelLockedFieldPlugin>(\"cms-model-locked-field\");\n\n // We must not allow removal or changes in fields that are already in use in content entries.\n for (const lockedField of lockedFields) {\n const existingField = fields.find(item => item.fieldId === lockedField.fieldId);\n if (!existingField) {\n throw new WebinyError(\n `Cannot remove the field \"${lockedField.fieldId}\" because it's already in use in created content.`,\n \"ENTRY_FIELD_USED\"\n );\n }\n\n if (lockedField.multipleValues !== existingField.multipleValues) {\n throw new WebinyError(\n `Cannot change \"multipleValues\" for the \"${lockedField.fieldId}\" field because it's already in use in created content.`,\n \"ENTRY_FIELD_USED\"\n );\n }\n\n if (lockedField.type !== existingField.type) {\n throw new WebinyError(\n `Cannot change field type for the \"${lockedField.fieldId}\" field because it's already in use in created content.`,\n \"ENTRY_FIELD_USED\"\n );\n }\n\n // Check `lockedField` invariant for specific field\n const lockedFieldsByType = cmsLockedFieldPlugins.filter(\n pl => pl.fieldType === lockedField.type\n );\n for (const plugin of lockedFieldsByType) {\n if (typeof plugin.checkLockedField !== \"function\") {\n continue;\n }\n plugin.checkLockedField({\n lockedField,\n field: existingField\n });\n }\n }\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AASA;;;;;;AAEA,MAAMA,mBAAmB,GAAG,IAA5B;AAEA,MAAMC,sBAAsB,GAAG,CAAC,MAAD,EAAS,QAAT,CAA/B;;AAEA,MAAMC,2BAA2B,GAAG,CAACC,MAAD,EAA0BC,YAA1B,KAA4D;EAC5F;EACA;EACA;EACA,IAAI,CAACA,YAAD,IAAiBA,YAAY,KAAKJ,mBAAtC,EAA2D;IACvD,MAAMK,UAAU,GAAGF,MAAM,CAACG,IAAP,CAAYC,KAAK,IAAI;MACpC,OAAOA,KAAK,CAACC,IAAN,KAAe,MAAf,IAAyB,CAACD,KAAK,CAACE,cAAvC;IACH,CAFkB,CAAnB;IAGA,OAAOJ,UAAU,GAAGA,UAAU,CAACK,OAAd,GAAwBV,mBAAzC;EACH,CAT2F,CAU5F;EACA;EACA;;;EACA,MAAMW,MAAM,GAAGR,MAAM,CAACG,IAAP,CAAYM,CAAC,IAAIA,CAAC,CAACF,OAAF,KAAcN,YAA/B,CAAf;;EACA,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AA0C,wBAA1C,CADJ,CAxDsE,CA2DtE;;EACA,KAAK,MAAMgB,WAAX,IAA0BZ,YAA1B,EAAwC;IACpC,MAAMa,aAAa,GAAG5D,MAAM,CAACG,IAAP,CAAY0C,IAAI,IAAIA,IAAI,CAACtC,OAAL,KAAiBoD,WAAW,CAACpD,OAAjD,CAAtB;;IACA,IAAI,CAACqD,aAAL,EAAoB;MAChB,MAAM,IAAIlD,cAAJ,CACD,4BAA2BiD,WAAW,CAACpD,OAAQ,mDAD9C,EAEF,kBAFE,CAAN;IAIH;;IAED,IAAIoD,WAAW,CAACrD,cAAZ,KAA+BsD,aAAa,CAACtD,cAAjD,EAAiE;MAC7D,MAAM,IAAII,cAAJ,CACD,2CAA0CiD,WAAW,CAACpD,OAAQ,yDAD7D,EAEF,kBAFE,CAAN;IAIH;;IAED,IAAIoD,WAAW,CAACtD,IAAZ,KAAqBuD,aAAa,CAACvD,IAAvC,EAA6C;MACzC,MAAM,IAAIK,cAAJ,CACD,qCAAoCiD,WAAW,CAACpD,OAAQ,yDADvD,EAEF,kBAFE,CAAN;IAIH,CArBmC,CAuBpC;;;IACA,MAAMsD,kBAAkB,GAAGH,qBAAqB,CAACI,MAAtB,CACvBN,EAAE,IAAIA,EAAE,CAACN,SAAH,KAAiBS,WAAW,CAACtD,IADZ,CAA3B;;IAGA,KAAK,MAAM0D,MAAX,IAAqBF,kBAArB,EAAyC;MACrC,IAAI,OAAOE,MAAM,CAACC,gBAAd,KAAmC,UAAvC,EAAmD;QAC/C;MACH;;MACDD,MAAM,CAACC,gBAAP,CAAwB;QACpBL,WADoB;QAEpBvD,KAAK,EAAEwD;MAFa,CAAxB;IAIH;EACJ;AACJ,CAjGM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CmsContext, CmsModelContext, HeadlessCmsStorageOperations } from "
|
|
1
|
+
import { CmsContext, CmsModelContext, HeadlessCmsStorageOperations } from "../types";
|
|
2
2
|
import { Tenant } from "@webiny/api-tenancy/types";
|
|
3
3
|
import { I18NLocale } from "@webiny/api-i18n/types";
|
|
4
4
|
import { SecurityIdentity } from "@webiny/api-security/types";
|
|
@@ -9,8 +9,6 @@ exports.createModelsCrud = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var utils = _interopRequireWildcard(require("../../../utils"));
|
|
13
|
-
|
|
14
12
|
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
15
13
|
|
|
16
14
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
@@ -25,8 +23,6 @@ var _validateLayout = require("./contentModel/validateLayout");
|
|
|
25
23
|
|
|
26
24
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
27
25
|
|
|
28
|
-
var _CmsModelPlugin = require("../CmsModelPlugin");
|
|
29
|
-
|
|
30
26
|
var _pubsub = require("@webiny/pubsub");
|
|
31
27
|
|
|
32
28
|
var _beforeCreate = require("./contentModel/beforeCreate");
|
|
@@ -43,9 +39,15 @@ var _afterDelete = require("./contentModel/afterDelete");
|
|
|
43
39
|
|
|
44
40
|
var _afterCreateFrom = require("./contentModel/afterCreateFrom");
|
|
45
41
|
|
|
46
|
-
|
|
42
|
+
var _CmsModelPlugin = require("../plugins/CmsModelPlugin");
|
|
43
|
+
|
|
44
|
+
var _permissions = require("../utils/permissions");
|
|
45
|
+
|
|
46
|
+
var _filterAsync = require("../utils/filterAsync");
|
|
47
|
+
|
|
48
|
+
var _ownership = require("../utils/ownership");
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
var _access = require("../utils/access");
|
|
49
51
|
|
|
50
52
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
51
53
|
|
|
@@ -91,7 +93,7 @@ const createModelsCrud = params => {
|
|
|
91
93
|
};
|
|
92
94
|
|
|
93
95
|
const checkModelPermissions = check => {
|
|
94
|
-
return
|
|
96
|
+
return (0, _permissions.checkPermissions)(context, "cms.contentModel", {
|
|
95
97
|
rwd: check
|
|
96
98
|
});
|
|
97
99
|
};
|
|
@@ -158,20 +160,20 @@ const createModelsCrud = params => {
|
|
|
158
160
|
const listModels = async () => {
|
|
159
161
|
const permission = await checkModelPermissions("r");
|
|
160
162
|
const models = await modelsList();
|
|
161
|
-
return
|
|
162
|
-
if (!
|
|
163
|
+
return (0, _filterAsync.filterAsync)(models, async model => {
|
|
164
|
+
if (!(0, _ownership.validateOwnership)(context, permission, model)) {
|
|
163
165
|
return false;
|
|
164
166
|
}
|
|
165
167
|
|
|
166
|
-
return
|
|
168
|
+
return (0, _access.validateModelAccess)(context, model);
|
|
167
169
|
});
|
|
168
170
|
};
|
|
169
171
|
|
|
170
172
|
const getModel = async modelId => {
|
|
171
173
|
const permission = await checkModelPermissions("r");
|
|
172
174
|
const model = await modelsGet(modelId);
|
|
173
|
-
|
|
174
|
-
await
|
|
175
|
+
(0, _ownership.checkOwnership)(context, permission, model);
|
|
176
|
+
await (0, _access.checkModelAccess)(context, model);
|
|
175
177
|
return model;
|
|
176
178
|
};
|
|
177
179
|
|