@webiny/api-headless-cms 5.17.4 → 5.18.0-beta.3
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/content/contextSetup.js +1 -2
- package/content/graphQLHandlerFactory.d.ts +1 -2
- package/content/graphQLHandlerFactory.js +12 -4
- package/content/plugins/CmsGroupPlugin.d.ts +11 -0
- package/content/plugins/{ContentModelGroupPlugin.js → CmsGroupPlugin.js} +4 -5
- package/content/plugins/CmsModelPlugin.d.ts +11 -0
- package/content/plugins/{ContentModelPlugin.js → CmsModelPlugin.js} +4 -5
- package/content/plugins/buildSchemaPlugins.js +1 -2
- package/content/plugins/crud/contentEntry/beforeCreate.d.ts +7 -0
- package/content/plugins/crud/contentEntry/beforeCreate.js +28 -0
- package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +7 -0
- package/content/plugins/crud/contentEntry/beforeUpdate.js +28 -0
- package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +2 -2
- package/content/plugins/crud/contentEntry/entryDataValidation.js +1 -2
- package/content/plugins/crud/contentEntry/markLockedFields.d.ts +3 -3
- package/content/plugins/crud/contentEntry/markLockedFields.js +10 -7
- package/content/plugins/crud/contentEntry.crud.d.ts +12 -4
- package/content/plugins/crud/contentEntry.crud.js +807 -757
- package/content/plugins/crud/contentModel/afterCreate.d.ts +7 -0
- package/content/plugins/crud/contentModel/afterCreate.js +18 -0
- package/content/plugins/crud/contentModel/afterDelete.d.ts +7 -0
- package/content/plugins/crud/contentModel/afterDelete.js +18 -0
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +7 -0
- package/content/plugins/crud/contentModel/afterUpdate.js +18 -0
- package/content/plugins/crud/contentModel/beforeCreate.d.ts +9 -0
- package/content/plugins/crud/contentModel/beforeCreate.js +146 -0
- package/content/plugins/crud/contentModel/beforeDelete.d.ts +9 -0
- package/content/plugins/crud/contentModel/beforeDelete.js +56 -0
- package/content/plugins/crud/contentModel/beforeUpdate.d.ts +9 -0
- package/content/plugins/crud/contentModel/beforeUpdate.js +128 -0
- package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +2 -2
- package/content/plugins/crud/contentModel/contentModelManagerFactory.js +2 -3
- package/content/plugins/crud/contentModel/createFieldModels.d.ts +2 -2
- package/content/plugins/crud/contentModel/createFieldModels.js +2 -3
- package/content/plugins/crud/contentModel/idValidation.js +1 -2
- package/content/plugins/crud/contentModel/models.js +1 -2
- package/content/plugins/crud/contentModel/validateLayout.d.ts +2 -2
- package/content/plugins/crud/contentModel/validateLayout.js +1 -2
- package/content/plugins/crud/contentModel.crud.d.ts +12 -4
- package/content/plugins/crud/contentModel.crud.js +351 -279
- package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +9 -0
- package/content/plugins/crud/contentModelGroup/beforeCreate.js +66 -0
- package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +9 -0
- package/content/plugins/crud/contentModelGroup/beforeDelete.js +48 -0
- package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +8 -0
- package/content/plugins/crud/contentModelGroup/beforeUpdate.js +28 -0
- package/content/plugins/crud/contentModelGroup.crud.d.ts +12 -4
- package/content/plugins/crud/contentModelGroup.crud.js +259 -219
- package/content/plugins/crud/index.d.ts +6 -0
- package/content/plugins/crud/index.js +96 -0
- package/content/plugins/graphqlFields/boolean.js +1 -2
- package/content/plugins/graphqlFields/datetime.js +1 -2
- package/content/plugins/graphqlFields/file.js +1 -2
- package/content/plugins/graphqlFields/index.js +1 -2
- package/content/plugins/graphqlFields/longText.js +1 -2
- package/content/plugins/graphqlFields/number.js +1 -2
- package/content/plugins/graphqlFields/object.js +1 -2
- package/content/plugins/graphqlFields/ref.js +22 -11
- package/content/plugins/graphqlFields/richText.js +1 -2
- package/content/plugins/graphqlFields/text.js +1 -2
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +2 -3
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +1 -2
- package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +15 -0
- package/content/plugins/modelManager/DefaultCmsModelManager.js +62 -0
- package/content/plugins/modelManager/index.d.ts +2 -2
- package/content/plugins/modelManager/index.js +3 -4
- package/content/plugins/schema/baseSchema.js +1 -2
- package/content/plugins/schema/contentEntries.js +9 -10
- package/content/plugins/schema/contentModelGroups.js +13 -14
- package/content/plugins/schema/contentModels.js +9 -10
- package/content/plugins/schema/createFieldResolvers.d.ts +2 -2
- package/content/plugins/schema/createFieldResolvers.js +14 -20
- package/content/plugins/schema/createManageResolvers.d.ts +3 -3
- package/content/plugins/schema/createManageResolvers.js +6 -10
- package/content/plugins/schema/createManageSDL.d.ts +2 -2
- package/content/plugins/schema/createManageSDL.js +5 -6
- package/content/plugins/schema/createPreviewResolvers.d.ts +3 -3
- package/content/plugins/schema/createPreviewResolvers.js +5 -6
- package/content/plugins/schema/createReadResolvers.d.ts +3 -3
- package/content/plugins/schema/createReadResolvers.js +5 -6
- package/content/plugins/schema/createReadSDL.d.ts +2 -2
- package/content/plugins/schema/createReadSDL.js +3 -4
- package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +4 -4
- package/content/plugins/schema/resolvers/commonFieldResolvers.js +1 -2
- package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +1 -1
- package/content/plugins/schema/resolvers/manage/resolveCreate.js +3 -4
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +1 -1
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.js +3 -4
- package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +1 -1
- package/content/plugins/schema/resolvers/manage/resolveDelete.js +4 -5
- package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +1 -1
- package/content/plugins/schema/resolvers/manage/resolveGet.js +3 -4
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +1 -1
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.js +3 -4
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +1 -1
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.js +3 -4
- package/content/plugins/schema/resolvers/manage/resolveList.d.ts +1 -1
- package/content/plugins/schema/resolvers/manage/resolveList.js +3 -4
- package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +1 -1
- package/content/plugins/schema/resolvers/manage/resolvePublish.js +3 -4
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +1 -1
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +3 -4
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +1 -1
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +3 -4
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +1 -1
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.js +3 -4
- package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +1 -1
- package/content/plugins/schema/resolvers/manage/resolveUpdate.js +3 -4
- package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +1 -1
- package/content/plugins/schema/resolvers/preview/resolveGet.js +3 -4
- package/content/plugins/schema/resolvers/preview/resolveList.d.ts +1 -1
- package/content/plugins/schema/resolvers/preview/resolveList.js +3 -4
- package/content/plugins/schema/resolvers/read/resolveGet.d.ts +1 -1
- package/content/plugins/schema/resolvers/read/resolveGet.js +3 -4
- package/content/plugins/schema/resolvers/read/resolveList.d.ts +1 -1
- package/content/plugins/schema/resolvers/read/resolveList.js +3 -4
- package/content/plugins/schema/schemaPlugins.js +4 -3
- package/content/plugins/storage/StorageTransformPlugin.d.ts +30 -0
- package/content/plugins/storage/StorageTransformPlugin.js +36 -0
- package/content/plugins/storage/default.d.ts +2 -2
- package/content/plugins/storage/default.js +12 -12
- package/content/plugins/storage/object.d.ts +2 -2
- package/content/plugins/storage/object.js +28 -29
- package/content/plugins/utils/createTypeName.js +1 -2
- package/content/plugins/utils/entryStorage.d.ts +5 -5
- package/content/plugins/utils/entryStorage.js +21 -14
- package/content/plugins/utils/getEntryTitle.d.ts +2 -2
- package/content/plugins/utils/getEntryTitle.js +1 -2
- package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +2 -2
- package/content/plugins/utils/getSchemaFromFieldPlugins.js +1 -2
- package/content/plugins/utils/pluralizedTypeName.js +1 -2
- package/content/plugins/utils/renderFields.d.ts +2 -2
- package/content/plugins/utils/renderFields.js +1 -2
- package/content/plugins/utils/renderGetFilterFields.d.ts +2 -2
- package/content/plugins/utils/renderGetFilterFields.js +1 -2
- package/content/plugins/utils/renderInputFields.d.ts +2 -2
- package/content/plugins/utils/renderInputFields.js +1 -2
- package/content/plugins/utils/renderListFilterFields.d.ts +2 -2
- package/content/plugins/utils/renderListFilterFields.js +1 -2
- package/content/plugins/utils/renderSortEnum.d.ts +2 -2
- package/content/plugins/utils/renderSortEnum.js +1 -2
- package/content/plugins/validators/dateGte.js +1 -2
- package/content/plugins/validators/dateLte.js +1 -2
- package/content/plugins/validators/gte.js +1 -2
- package/content/plugins/validators/in.js +1 -2
- package/content/plugins/validators/index.js +1 -2
- package/content/plugins/validators/lte.js +1 -2
- package/content/plugins/validators/maxLength.js +1 -2
- package/content/plugins/validators/minLength.js +1 -2
- package/content/plugins/validators/pattern.js +1 -2
- package/content/plugins/validators/patternPlugins/email.js +1 -2
- package/content/plugins/validators/patternPlugins/index.js +1 -2
- package/content/plugins/validators/patternPlugins/lowerCase.js +1 -2
- package/content/plugins/validators/patternPlugins/upperCase.js +1 -2
- package/content/plugins/validators/patternPlugins/url.js +1 -2
- package/content/plugins/validators/required.js +1 -2
- package/content/plugins/validators/timeGte.js +1 -2
- package/content/plugins/validators/timeLte.js +1 -2
- package/index.d.ts +12 -0
- package/index.js +66 -0
- package/migrateCMSPermissions.d.ts +2 -2
- package/migrateCMSPermissions.js +1 -2
- package/package.json +23 -21
- package/plugins/context.js +1 -2
- package/plugins/crud/index.d.ts +6 -2
- package/plugins/crud/index.js +69 -6
- package/plugins/crud/settings.crud.d.ts +10 -4
- package/plugins/crud/settings.crud.js +64 -77
- package/plugins/crud/system.crud.d.ts +10 -4
- package/plugins/crud/system.crud.js +139 -126
- package/plugins/graphql/system.js +5 -6
- package/plugins/graphql.d.ts +1 -2
- package/plugins/graphql.js +49 -50
- package/plugins/upgrades/index.js +1 -2
- package/plugins/upgrades/v5.5.0/helpers.js +1 -2
- package/plugins/upgrades/v5.5.0/index.js +3 -4
- package/transformers.js +1 -2
- package/types.d.ts +742 -1232
- package/types.js +104 -254
- package/utils.d.ts +4 -11
- package/utils.js +2 -49
- package/content/contextSetup.js.map +0 -1
- package/content/graphQLHandlerFactory.js.map +0 -1
- package/content/index.d.ts +0 -5
- package/content/index.js +0 -37
- package/content/index.js.map +0 -1
- package/content/plugins/ContentModelGroupPlugin.d.ts +0 -7
- package/content/plugins/ContentModelGroupPlugin.js.map +0 -1
- package/content/plugins/ContentModelPlugin.d.ts +0 -7
- package/content/plugins/ContentModelPlugin.js.map +0 -1
- package/content/plugins/buildSchemaPlugins.js.map +0 -1
- package/content/plugins/crud/contentEntry/afterCreate.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/afterCreate.hook.js +0 -15
- package/content/plugins/crud/contentEntry/afterCreate.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/afterCreateRevisionFrom.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/afterCreateRevisionFrom.hook.js +0 -15
- package/content/plugins/crud/contentEntry/afterCreateRevisionFrom.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/afterDelete.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/afterDelete.hook.js +0 -15
- package/content/plugins/crud/contentEntry/afterDelete.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/afterDeleteRevision.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/afterDeleteRevision.hook.js +0 -15
- package/content/plugins/crud/contentEntry/afterDeleteRevision.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/afterPublish.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/afterPublish.hook.js +0 -15
- package/content/plugins/crud/contentEntry/afterPublish.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/afterRequestChanges.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/afterRequestChanges.hook.js +0 -15
- package/content/plugins/crud/contentEntry/afterRequestChanges.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/afterRequestReview.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/afterRequestReview.hook.js +0 -15
- package/content/plugins/crud/contentEntry/afterRequestReview.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/afterUnpublish.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/afterUnpublish.hook.js +0 -15
- package/content/plugins/crud/contentEntry/afterUnpublish.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/afterUpdate.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/afterUpdate.hook.js +0 -15
- package/content/plugins/crud/contentEntry/afterUpdate.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/beforeCreate.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/beforeCreate.hook.js +0 -18
- package/content/plugins/crud/contentEntry/beforeCreate.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/beforeCreateRevisionFrom.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/beforeCreateRevisionFrom.hook.js +0 -15
- package/content/plugins/crud/contentEntry/beforeCreateRevisionFrom.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/beforeDelete.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/beforeDelete.hook.js +0 -15
- package/content/plugins/crud/contentEntry/beforeDelete.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/beforeDeleteRevision.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/beforeDeleteRevision.hook.js +0 -15
- package/content/plugins/crud/contentEntry/beforeDeleteRevision.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/beforePublish.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/beforePublish.hook.js +0 -15
- package/content/plugins/crud/contentEntry/beforePublish.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/beforeRequestChanges.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/beforeRequestChanges.hook.js +0 -15
- package/content/plugins/crud/contentEntry/beforeRequestChanges.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/beforeRequestReview.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/beforeRequestReview.hook.js +0 -15
- package/content/plugins/crud/contentEntry/beforeRequestReview.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/beforeUnpublish.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/beforeUnpublish.hook.js +0 -15
- package/content/plugins/crud/contentEntry/beforeUnpublish.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/beforeUpdate.hook.d.ts +0 -2
- package/content/plugins/crud/contentEntry/beforeUpdate.hook.js +0 -18
- package/content/plugins/crud/contentEntry/beforeUpdate.hook.js.map +0 -1
- package/content/plugins/crud/contentEntry/entryDataValidation.js.map +0 -1
- package/content/plugins/crud/contentEntry/hooks.d.ts +0 -18
- package/content/plugins/crud/contentEntry/hooks.js +0 -240
- package/content/plugins/crud/contentEntry/hooks.js.map +0 -1
- package/content/plugins/crud/contentEntry/markLockedFields.js.map +0 -1
- package/content/plugins/crud/contentEntry/runContentEntryLifecycleHooks.d.ts +0 -4
- package/content/plugins/crud/contentEntry/runContentEntryLifecycleHooks.js +0 -24
- package/content/plugins/crud/contentEntry/runContentEntryLifecycleHooks.js.map +0 -1
- package/content/plugins/crud/contentEntry.crud.js.map +0 -1
- package/content/plugins/crud/contentModel/afterCreate.hook.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterCreate.hook.js +0 -24
- package/content/plugins/crud/contentModel/afterCreate.hook.js.map +0 -1
- package/content/plugins/crud/contentModel/afterDelete.hook.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterDelete.hook.js +0 -24
- package/content/plugins/crud/contentModel/afterDelete.hook.js.map +0 -1
- package/content/plugins/crud/contentModel/afterUpdate.hook.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterUpdate.hook.js +0 -24
- package/content/plugins/crud/contentModel/afterUpdate.hook.js.map +0 -1
- package/content/plugins/crud/contentModel/beforeCreate.hook.d.ts +0 -7
- package/content/plugins/crud/contentModel/beforeCreate.hook.js +0 -137
- package/content/plugins/crud/contentModel/beforeCreate.hook.js.map +0 -1
- package/content/plugins/crud/contentModel/beforeDelete.hook.d.ts +0 -7
- package/content/plugins/crud/contentModel/beforeDelete.hook.js +0 -58
- package/content/plugins/crud/contentModel/beforeDelete.hook.js.map +0 -1
- package/content/plugins/crud/contentModel/beforeUpdate.hook.d.ts +0 -7
- package/content/plugins/crud/contentModel/beforeUpdate.hook.js +0 -141
- package/content/plugins/crud/contentModel/beforeUpdate.hook.js.map +0 -1
- package/content/plugins/crud/contentModel/contentModelManagerFactory.js.map +0 -1
- package/content/plugins/crud/contentModel/createFieldModels.js.map +0 -1
- package/content/plugins/crud/contentModel/hooks.d.ts +0 -6
- package/content/plugins/crud/contentModel/hooks.js +0 -84
- package/content/plugins/crud/contentModel/hooks.js.map +0 -1
- 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/runContentModelLifecycleHooks.d.ts +0 -2
- package/content/plugins/crud/contentModel/runContentModelLifecycleHooks.js +0 -24
- package/content/plugins/crud/contentModel/runContentModelLifecycleHooks.js.map +0 -1
- package/content/plugins/crud/contentModel/validateLayout.js.map +0 -1
- package/content/plugins/crud/contentModel.crud.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/afterCreate.hook.d.ts +0 -7
- package/content/plugins/crud/contentModelGroup/afterCreate.hook.js +0 -24
- package/content/plugins/crud/contentModelGroup/afterCreate.hook.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/afterDelete.hook.d.ts +0 -8
- package/content/plugins/crud/contentModelGroup/afterDelete.hook.js +0 -22
- package/content/plugins/crud/contentModelGroup/afterDelete.hook.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/afterUpdate.hook.d.ts +0 -7
- package/content/plugins/crud/contentModelGroup/afterUpdate.hook.js +0 -26
- package/content/plugins/crud/contentModelGroup/afterUpdate.hook.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/beforeCreate.hook.d.ts +0 -7
- package/content/plugins/crud/contentModelGroup/beforeCreate.hook.js +0 -87
- package/content/plugins/crud/contentModelGroup/beforeCreate.hook.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/beforeDelete.hook.d.ts +0 -7
- package/content/plugins/crud/contentModelGroup/beforeDelete.hook.js +0 -46
- package/content/plugins/crud/contentModelGroup/beforeDelete.hook.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/beforeUpdate.hook.d.ts +0 -7
- package/content/plugins/crud/contentModelGroup/beforeUpdate.hook.js +0 -35
- package/content/plugins/crud/contentModelGroup/beforeUpdate.hook.js.map +0 -1
- package/content/plugins/crud/contentModelGroup.crud.js.map +0 -1
- package/content/plugins/graphqlFields/boolean.js.map +0 -1
- package/content/plugins/graphqlFields/datetime.js.map +0 -1
- package/content/plugins/graphqlFields/file.js.map +0 -1
- package/content/plugins/graphqlFields/index.js.map +0 -1
- package/content/plugins/graphqlFields/longText.js.map +0 -1
- package/content/plugins/graphqlFields/number.js.map +0 -1
- package/content/plugins/graphqlFields/object.js.map +0 -1
- package/content/plugins/graphqlFields/ref.js.map +0 -1
- package/content/plugins/graphqlFields/richText.js.map +0 -1
- package/content/plugins/graphqlFields/text.js.map +0 -1
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js.map +0 -1
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js.map +0 -1
- package/content/plugins/modelManager/DefaultContentModelManager.d.ts +0 -15
- package/content/plugins/modelManager/DefaultContentModelManager.js +0 -63
- package/content/plugins/modelManager/DefaultContentModelManager.js.map +0 -1
- package/content/plugins/modelManager/index.js.map +0 -1
- package/content/plugins/schema/baseSchema.js.map +0 -1
- package/content/plugins/schema/contentEntries.js.map +0 -1
- package/content/plugins/schema/contentModelGroups.js.map +0 -1
- 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.js.map +0 -1
- package/content/plugins/schema/resolvers/manage/resolveCreate.js.map +0 -1
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.js.map +0 -1
- package/content/plugins/schema/resolvers/manage/resolveDelete.js.map +0 -1
- package/content/plugins/schema/resolvers/manage/resolveGet.js.map +0 -1
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.js.map +0 -1
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.js.map +0 -1
- package/content/plugins/schema/resolvers/manage/resolveList.js.map +0 -1
- package/content/plugins/schema/resolvers/manage/resolvePublish.js.map +0 -1
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js.map +0 -1
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.js.map +0 -1
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.js.map +0 -1
- package/content/plugins/schema/resolvers/manage/resolveUpdate.js.map +0 -1
- package/content/plugins/schema/resolvers/preview/resolveGet.js.map +0 -1
- package/content/plugins/schema/resolvers/preview/resolveList.js.map +0 -1
- package/content/plugins/schema/resolvers/read/resolveGet.js.map +0 -1
- package/content/plugins/schema/resolvers/read/resolveList.js.map +0 -1
- package/content/plugins/schema/schemaPlugins.js.map +0 -1
- package/content/plugins/storage/default.js.map +0 -1
- package/content/plugins/storage/object.js.map +0 -1
- package/content/plugins/utils/createTypeName.js.map +0 -1
- package/content/plugins/utils/entryStorage.js.map +0 -1
- package/content/plugins/utils/getEntryTitle.js.map +0 -1
- package/content/plugins/utils/getSchemaFromFieldPlugins.js.map +0 -1
- package/content/plugins/utils/pluralizedTypeName.js.map +0 -1
- package/content/plugins/utils/renderFields.js.map +0 -1
- package/content/plugins/utils/renderGetFilterFields.js.map +0 -1
- package/content/plugins/utils/renderInputFields.js.map +0 -1
- package/content/plugins/utils/renderListFilterFields.js.map +0 -1
- package/content/plugins/utils/renderSortEnum.js.map +0 -1
- package/content/plugins/validators/dateGte.js.map +0 -1
- package/content/plugins/validators/dateLte.js.map +0 -1
- package/content/plugins/validators/gte.js.map +0 -1
- package/content/plugins/validators/in.js.map +0 -1
- package/content/plugins/validators/index.js.map +0 -1
- package/content/plugins/validators/lte.js.map +0 -1
- package/content/plugins/validators/maxLength.js.map +0 -1
- package/content/plugins/validators/minLength.js.map +0 -1
- package/content/plugins/validators/pattern.js.map +0 -1
- package/content/plugins/validators/patternPlugins/email.js.map +0 -1
- package/content/plugins/validators/patternPlugins/index.js.map +0 -1
- package/content/plugins/validators/patternPlugins/lowerCase.js.map +0 -1
- package/content/plugins/validators/patternPlugins/upperCase.js.map +0 -1
- package/content/plugins/validators/patternPlugins/url.js.map +0 -1
- package/content/plugins/validators/required.js.map +0 -1
- package/content/plugins/validators/timeGte.js.map +0 -1
- package/content/plugins/validators/timeLte.js.map +0 -1
- package/migrateCMSPermissions.js.map +0 -1
- package/plugins/InstallationPlugin.d.ts +0 -19
- package/plugins/InstallationPlugin.js +0 -39
- package/plugins/InstallationPlugin.js.map +0 -1
- package/plugins/context.js.map +0 -1
- package/plugins/crud/index.js.map +0 -1
- package/plugins/crud/settings.crud.js.map +0 -1
- package/plugins/crud/system.crud.js.map +0 -1
- package/plugins/graphql/system.js.map +0 -1
- package/plugins/graphql.js.map +0 -1
- package/plugins/index.d.ts +0 -2
- package/plugins/index.js +0 -25
- package/plugins/index.js.map +0 -1
- package/plugins/upgrades/index.js.map +0 -1
- package/plugins/upgrades/v5.5.0/helpers.js.map +0 -1
- package/plugins/upgrades/v5.5.0/index.js.map +0 -1
- package/transformers.js.map +0 -1
- package/types.js.map +0 -1
- package/utils.js.map +0 -1
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.createModelsCrud = void 0;
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
@@ -23,13 +23,25 @@ var _createFieldModels = require("./contentModel/createFieldModels");
|
|
|
23
23
|
|
|
24
24
|
var _validateLayout = require("./contentModel/validateLayout");
|
|
25
25
|
|
|
26
|
-
var _hooks = require("./contentModel/hooks");
|
|
27
|
-
|
|
28
26
|
var _apiSecurity = require("@webiny/api-security");
|
|
29
27
|
|
|
30
28
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
31
29
|
|
|
32
|
-
var
|
|
30
|
+
var _CmsModelPlugin = require("../CmsModelPlugin");
|
|
31
|
+
|
|
32
|
+
var _pubsub = require("@webiny/pubsub");
|
|
33
|
+
|
|
34
|
+
var _beforeCreate = require("./contentModel/beforeCreate");
|
|
35
|
+
|
|
36
|
+
var _beforeUpdate = require("./contentModel/beforeUpdate");
|
|
37
|
+
|
|
38
|
+
var _beforeDelete = require("./contentModel/beforeDelete");
|
|
39
|
+
|
|
40
|
+
var _afterCreate = require("./contentModel/afterCreate");
|
|
41
|
+
|
|
42
|
+
var _afterUpdate = require("./contentModel/afterUpdate");
|
|
43
|
+
|
|
44
|
+
var _afterDelete = require("./contentModel/afterDelete");
|
|
33
45
|
|
|
34
46
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
47
|
|
|
@@ -39,315 +51,375 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
39
51
|
|
|
40
52
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
41
53
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
const createModelsCrud = params => {
|
|
55
|
+
const {
|
|
56
|
+
getTenant,
|
|
57
|
+
getIdentity,
|
|
58
|
+
getLocale,
|
|
59
|
+
storageOperations,
|
|
60
|
+
context
|
|
61
|
+
} = params;
|
|
62
|
+
const loaders = {
|
|
63
|
+
listModels: new _dataloader.default(async () => {
|
|
64
|
+
const models = await storageOperations.models.list({
|
|
65
|
+
where: {
|
|
66
|
+
tenant: getTenant().id,
|
|
67
|
+
locale: getLocale().code
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return [models.map(model => {
|
|
71
|
+
return _objectSpread(_objectSpread({}, model), {}, {
|
|
72
|
+
tenant: model.tenant || getTenant().id,
|
|
73
|
+
locale: model.locale || getLocale().code
|
|
74
|
+
});
|
|
75
|
+
})];
|
|
76
|
+
})
|
|
77
|
+
};
|
|
78
|
+
const managers = new Map();
|
|
79
|
+
|
|
80
|
+
const updateManager = async (context, model) => {
|
|
81
|
+
const manager = await (0, _contentModelManagerFactory.contentModelManagerFactory)(context, model);
|
|
82
|
+
managers.set(model.modelId, manager);
|
|
83
|
+
return manager;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const checkModelPermissions = check => {
|
|
87
|
+
return utils.checkPermissions(context, "cms.contentModel", {
|
|
88
|
+
rwd: check
|
|
89
|
+
});
|
|
90
|
+
};
|
|
45
91
|
|
|
46
|
-
|
|
92
|
+
const getModelsAsPlugins = () => {
|
|
93
|
+
const tenant = getTenant().id;
|
|
94
|
+
const locale = getLocale().code;
|
|
95
|
+
return context.plugins.byType(_CmsModelPlugin.CmsModelPlugin.type)
|
|
47
96
|
/**
|
|
48
|
-
*
|
|
97
|
+
* We need to filter out models that are not for this tenant or locale.
|
|
98
|
+
* If it does not have tenant or locale define, it is for every locale and tenant
|
|
49
99
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
100
|
+
.filter(plugin => {
|
|
101
|
+
const {
|
|
102
|
+
tenant: t,
|
|
103
|
+
locale: l
|
|
104
|
+
} = plugin.contentModel;
|
|
105
|
+
|
|
106
|
+
if (t && t !== tenant) {
|
|
107
|
+
return false;
|
|
108
|
+
} else if (l && l !== locale) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
53
111
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
112
|
+
return true;
|
|
113
|
+
}).map(plugin => {
|
|
114
|
+
return _objectSpread(_objectSpread({}, plugin.contentModel), {}, {
|
|
115
|
+
tenant,
|
|
116
|
+
locale,
|
|
117
|
+
webinyVersion: context.WEBINY_VERSION
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|
|
60
121
|
|
|
61
|
-
|
|
122
|
+
const modelsGet = async modelId => {
|
|
123
|
+
const pluginModel = getModelsAsPlugins().find(model => model.modelId === modelId);
|
|
62
124
|
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
type: pluginType
|
|
66
|
-
});
|
|
125
|
+
if (pluginModel) {
|
|
126
|
+
return pluginModel;
|
|
67
127
|
}
|
|
68
128
|
|
|
69
|
-
const
|
|
70
|
-
|
|
129
|
+
const model = await storageOperations.models.get({
|
|
130
|
+
tenant: getTenant().id,
|
|
131
|
+
locale: getLocale().code,
|
|
132
|
+
modelId
|
|
71
133
|
});
|
|
72
|
-
const loaders = {
|
|
73
|
-
listModels: new _dataloader.default(async () => {
|
|
74
|
-
const models = await storageOperations.list();
|
|
75
|
-
return [models];
|
|
76
|
-
})
|
|
77
|
-
};
|
|
78
|
-
const managers = new Map();
|
|
79
|
-
|
|
80
|
-
const updateManager = async (context, model) => {
|
|
81
|
-
const manager = await (0, _contentModelManagerFactory.contentModelManagerFactory)(context, model);
|
|
82
|
-
managers.set(model.modelId, manager);
|
|
83
|
-
return manager;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const checkModelPermissions = check => {
|
|
87
|
-
return utils.checkPermissions(context, "cms.contentModel", {
|
|
88
|
-
rwd: check
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
134
|
|
|
92
|
-
|
|
93
|
-
|
|
135
|
+
if (!model) {
|
|
136
|
+
throw new _handlerGraphql.NotFoundError(`Content model "${modelId}" was not found!`);
|
|
137
|
+
}
|
|
94
138
|
|
|
95
|
-
|
|
96
|
-
|
|
139
|
+
return _objectSpread(_objectSpread({}, model), {}, {
|
|
140
|
+
tenant: model.tenant || getTenant().id,
|
|
141
|
+
locale: model.locale || getLocale().code
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const modelsList = async () => {
|
|
146
|
+
const databaseModels = await loaders.listModels.load("listModels");
|
|
147
|
+
const pluginsModels = getModelsAsPlugins();
|
|
148
|
+
return databaseModels.concat(pluginsModels);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const listOperations = async () => {
|
|
152
|
+
const permission = await checkModelPermissions("r");
|
|
153
|
+
const models = await modelsList();
|
|
154
|
+
return utils.filterAsync(models, async model => {
|
|
155
|
+
if (!utils.validateOwnership(context, permission, model)) {
|
|
156
|
+
return false;
|
|
97
157
|
}
|
|
98
158
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
159
|
+
return utils.validateModelAccess(context, model);
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const get = async modelId => {
|
|
164
|
+
const permission = await checkModelPermissions("r");
|
|
165
|
+
const model = await modelsGet(modelId);
|
|
166
|
+
utils.checkOwnership(context, permission, model);
|
|
167
|
+
await utils.checkModelAccess(context, model);
|
|
168
|
+
return model;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const getManager = async modelId => {
|
|
172
|
+
if (managers.has(modelId)) {
|
|
173
|
+
return managers.get(modelId);
|
|
174
|
+
}
|
|
106
175
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const modelsList = async () => {
|
|
111
|
-
const databaseModels = await loaders.listModels.load("listModels");
|
|
112
|
-
const pluginsModels = context.plugins.byType(_ContentModelPlugin.ContentModelPlugin.type).map(plugin => plugin.contentModel);
|
|
113
|
-
return [...databaseModels, ...pluginsModels];
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const models = {
|
|
117
|
-
operations: storageOperations,
|
|
118
|
-
noAuth: () => {
|
|
119
|
-
return {
|
|
120
|
-
get: modelsGet,
|
|
121
|
-
list: modelsList
|
|
122
|
-
};
|
|
123
|
-
},
|
|
124
|
-
silentAuth: () => {
|
|
125
|
-
return {
|
|
126
|
-
list: async () => {
|
|
127
|
-
try {
|
|
128
|
-
return await models.list();
|
|
129
|
-
} catch (ex) {
|
|
130
|
-
if (ex instanceof _apiSecurity.NotAuthorizedError) {
|
|
131
|
-
return [];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
throw ex;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
async get(modelId) {
|
|
141
|
-
const permission = await checkModelPermissions("r");
|
|
142
|
-
const model = await modelsGet(modelId);
|
|
143
|
-
utils.checkOwnership(context, permission, model);
|
|
144
|
-
await utils.checkModelAccess(context, model);
|
|
145
|
-
return model;
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
async list() {
|
|
149
|
-
const permission = await checkModelPermissions("r");
|
|
150
|
-
const models = await modelsList();
|
|
151
|
-
return utils.filterAsync(models, async model => {
|
|
152
|
-
if (!utils.validateOwnership(context, permission, model)) {
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
176
|
+
const models = await modelsList();
|
|
177
|
+
const model = models.find(m => m.modelId === modelId);
|
|
155
178
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
179
|
+
if (!model) {
|
|
180
|
+
throw new _handlerGraphql.NotFoundError(`There is no content model "${modelId}".`);
|
|
181
|
+
}
|
|
159
182
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
183
|
+
return await updateManager(context, model);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const onBeforeCreate = (0, _pubsub.createTopic)();
|
|
187
|
+
const onAfterCreate = (0, _pubsub.createTopic)();
|
|
188
|
+
const onBeforeUpdate = (0, _pubsub.createTopic)();
|
|
189
|
+
const onAfterUpdate = (0, _pubsub.createTopic)();
|
|
190
|
+
const onBeforeDelete = (0, _pubsub.createTopic)();
|
|
191
|
+
const onAfterDelete = (0, _pubsub.createTopic)();
|
|
192
|
+
/**
|
|
193
|
+
* We need to assign some default behaviors.
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
(0, _beforeCreate.assignBeforeModelCreate)({
|
|
197
|
+
onBeforeCreate,
|
|
198
|
+
plugins: context.plugins,
|
|
199
|
+
storageOperations
|
|
200
|
+
});
|
|
201
|
+
(0, _afterCreate.assignAfterModelCreate)({
|
|
202
|
+
context,
|
|
203
|
+
onAfterCreate
|
|
204
|
+
});
|
|
205
|
+
(0, _beforeUpdate.assignBeforeModelUpdate)({
|
|
206
|
+
onBeforeUpdate,
|
|
207
|
+
plugins: context.plugins,
|
|
208
|
+
storageOperations
|
|
209
|
+
});
|
|
210
|
+
(0, _afterUpdate.assignAfterModelUpdate)({
|
|
211
|
+
context,
|
|
212
|
+
onAfterUpdate
|
|
213
|
+
});
|
|
214
|
+
(0, _beforeDelete.assignBeforeModelDelete)({
|
|
215
|
+
onBeforeDelete,
|
|
216
|
+
plugins: context.plugins,
|
|
217
|
+
storageOperations
|
|
218
|
+
});
|
|
219
|
+
(0, _afterDelete.assignAfterModelDelete)({
|
|
220
|
+
context,
|
|
221
|
+
onAfterDelete
|
|
222
|
+
});
|
|
223
|
+
return {
|
|
224
|
+
onBeforeModelCreate: onBeforeCreate,
|
|
225
|
+
onAfterModelCreate: onAfterCreate,
|
|
226
|
+
onBeforeModelUpdate: onBeforeUpdate,
|
|
227
|
+
onAfterModelUpdate: onAfterUpdate,
|
|
228
|
+
onBeforeModelDelete: onBeforeDelete,
|
|
229
|
+
onAfterModelDelete: onAfterDelete,
|
|
230
|
+
silentAuthModel: () => {
|
|
231
|
+
return {
|
|
232
|
+
list: async () => {
|
|
233
|
+
try {
|
|
234
|
+
return await listOperations();
|
|
235
|
+
} catch (ex) {
|
|
236
|
+
if (ex instanceof _apiSecurity.NotAuthorizedError) {
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
166
239
|
|
|
167
|
-
|
|
168
|
-
|
|
240
|
+
throw ex;
|
|
241
|
+
}
|
|
169
242
|
}
|
|
243
|
+
};
|
|
244
|
+
},
|
|
245
|
+
getModel: get,
|
|
246
|
+
listModels: listOperations,
|
|
247
|
+
|
|
248
|
+
async createModel(inputData) {
|
|
249
|
+
await checkModelPermissions("w");
|
|
250
|
+
const createdData = new _models.CreateContentModelModel().populate(inputData);
|
|
251
|
+
await createdData.validate();
|
|
252
|
+
const input = await createdData.toJSON();
|
|
253
|
+
context.security.disableAuthorization();
|
|
254
|
+
const group = await context.cms.getGroup(input.group);
|
|
255
|
+
context.security.enableAuthorization();
|
|
256
|
+
|
|
257
|
+
if (!group) {
|
|
258
|
+
throw new _handlerGraphql.NotFoundError(`There is no group "${input.group}".`);
|
|
259
|
+
}
|
|
170
260
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
261
|
+
const identity = getIdentity();
|
|
262
|
+
|
|
263
|
+
const model = _objectSpread(_objectSpread({}, input), {}, {
|
|
264
|
+
titleFieldId: "id",
|
|
265
|
+
locale: getLocale().code,
|
|
266
|
+
tenant: getTenant().id,
|
|
267
|
+
group: {
|
|
268
|
+
id: group.id,
|
|
269
|
+
name: group.name
|
|
270
|
+
},
|
|
271
|
+
createdBy: {
|
|
272
|
+
id: identity.id,
|
|
273
|
+
displayName: identity.displayName,
|
|
274
|
+
type: identity.type
|
|
275
|
+
},
|
|
276
|
+
createdOn: new Date().toISOString(),
|
|
277
|
+
savedOn: new Date().toISOString(),
|
|
278
|
+
fields: [],
|
|
279
|
+
lockedFields: [],
|
|
280
|
+
layout: [],
|
|
281
|
+
webinyVersion: context.WEBINY_VERSION
|
|
282
|
+
});
|
|
191
283
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
});
|
|
209
|
-
return model;
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Method does not check for permissions or ownership.
|
|
214
|
-
* @internal
|
|
215
|
-
*/
|
|
216
|
-
async updateModel(model, data) {
|
|
217
|
-
const input = data;
|
|
218
|
-
await (0, _hooks.beforeUpdateHook)({
|
|
219
|
-
context,
|
|
220
|
-
storageOperations,
|
|
221
|
-
model,
|
|
222
|
-
data,
|
|
223
|
-
input
|
|
224
|
-
});
|
|
225
|
-
const resultModel = await storageOperations.update({
|
|
226
|
-
data,
|
|
227
|
-
model,
|
|
228
|
-
input
|
|
229
|
-
});
|
|
230
|
-
await updateManager(context, resultModel);
|
|
231
|
-
await (0, _hooks.afterUpdateHook)({
|
|
232
|
-
context,
|
|
233
|
-
storageOperations,
|
|
234
|
-
model: resultModel,
|
|
235
|
-
data,
|
|
236
|
-
input
|
|
237
|
-
});
|
|
238
|
-
return resultModel;
|
|
239
|
-
},
|
|
284
|
+
await onBeforeCreate.publish({
|
|
285
|
+
model,
|
|
286
|
+
input
|
|
287
|
+
});
|
|
288
|
+
const createdModel = await storageOperations.models.create({
|
|
289
|
+
input,
|
|
290
|
+
model
|
|
291
|
+
});
|
|
292
|
+
loaders.listModels.clearAll();
|
|
293
|
+
await updateManager(context, model);
|
|
294
|
+
await onAfterCreate.publish({
|
|
295
|
+
input,
|
|
296
|
+
model: createdModel
|
|
297
|
+
});
|
|
298
|
+
return createdModel;
|
|
299
|
+
},
|
|
240
300
|
|
|
241
|
-
|
|
242
|
-
|
|
301
|
+
/**
|
|
302
|
+
* Method does not check for permissions or ownership.
|
|
303
|
+
* @internal
|
|
304
|
+
*/
|
|
305
|
+
async updateModelDirect(params) {
|
|
306
|
+
const {
|
|
307
|
+
model: initialModel,
|
|
308
|
+
original
|
|
309
|
+
} = params;
|
|
310
|
+
|
|
311
|
+
const model = _objectSpread(_objectSpread({}, initialModel), {}, {
|
|
312
|
+
tenant: initialModel.tenant || getTenant().id,
|
|
313
|
+
locale: initialModel.locale || getLocale().code,
|
|
314
|
+
webinyVersion: context.WEBINY_VERSION
|
|
315
|
+
});
|
|
243
316
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
317
|
+
await onBeforeUpdate.publish({
|
|
318
|
+
input: {},
|
|
319
|
+
original,
|
|
320
|
+
model
|
|
321
|
+
});
|
|
322
|
+
const resultModel = await storageOperations.models.update({
|
|
323
|
+
original,
|
|
324
|
+
model,
|
|
325
|
+
input: {}
|
|
326
|
+
});
|
|
327
|
+
await updateManager(context, resultModel);
|
|
328
|
+
loaders.listModels.clearAll();
|
|
329
|
+
await onAfterUpdate.publish({
|
|
330
|
+
input: {},
|
|
331
|
+
original,
|
|
332
|
+
model: resultModel
|
|
333
|
+
});
|
|
334
|
+
return resultModel;
|
|
335
|
+
},
|
|
250
336
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
337
|
+
async updateModel(modelId, inputData) {
|
|
338
|
+
await checkModelPermissions("w"); // Get a model record; this will also perform ownership validation.
|
|
254
339
|
|
|
255
|
-
|
|
256
|
-
|
|
340
|
+
const original = await get(modelId);
|
|
341
|
+
const updatedData = new _models.UpdateContentModelModel().populate(inputData);
|
|
342
|
+
await updatedData.validate();
|
|
343
|
+
const input = await updatedData.toJSON({
|
|
344
|
+
onlyDirty: true
|
|
345
|
+
});
|
|
257
346
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
347
|
+
if (Object.keys(input).length === 0) {
|
|
348
|
+
return {};
|
|
349
|
+
}
|
|
261
350
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
351
|
+
if (input.group) {
|
|
352
|
+
context.security.disableAuthorization();
|
|
353
|
+
const group = await context.cms.getGroup(input.group);
|
|
354
|
+
context.security.enableAuthorization();
|
|
355
|
+
|
|
356
|
+
if (!group) {
|
|
357
|
+
throw new _handlerGraphql.NotFoundError(`There is no group "${input.group}".`);
|
|
266
358
|
}
|
|
267
359
|
|
|
268
|
-
|
|
269
|
-
|
|
360
|
+
input.group = {
|
|
361
|
+
id: group.id,
|
|
362
|
+
name: group.name
|
|
363
|
+
};
|
|
364
|
+
}
|
|
270
365
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
savedOn: new Date().toISOString()
|
|
274
|
-
});
|
|
366
|
+
const modelFields = await (0, _createFieldModels.createFieldModels)(original, inputData);
|
|
367
|
+
(0, _validateLayout.validateLayout)(input, modelFields);
|
|
275
368
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const resultModel = await storageOperations.update({
|
|
284
|
-
data,
|
|
285
|
-
model,
|
|
286
|
-
input
|
|
287
|
-
});
|
|
288
|
-
await updateManager(context, resultModel);
|
|
289
|
-
await (0, _hooks.afterUpdateHook)({
|
|
290
|
-
context,
|
|
291
|
-
storageOperations,
|
|
292
|
-
model: resultModel,
|
|
293
|
-
data,
|
|
294
|
-
input
|
|
295
|
-
});
|
|
296
|
-
return resultModel;
|
|
297
|
-
},
|
|
298
|
-
|
|
299
|
-
async delete(modelId) {
|
|
300
|
-
await checkModelPermissions("d");
|
|
301
|
-
const model = await context.cms.models.get(modelId);
|
|
302
|
-
await (0, _hooks.beforeDeleteHook)({
|
|
303
|
-
context,
|
|
304
|
-
storageOperations,
|
|
305
|
-
model
|
|
306
|
-
});
|
|
307
|
-
const result = await storageOperations.delete({
|
|
308
|
-
model
|
|
309
|
-
});
|
|
369
|
+
const model = _objectSpread(_objectSpread(_objectSpread({}, original), input), {}, {
|
|
370
|
+
tenant: original.tenant || getTenant().id,
|
|
371
|
+
locale: original.locale || getLocale().code,
|
|
372
|
+
webinyVersion: context.WEBINY_VERSION,
|
|
373
|
+
fields: modelFields,
|
|
374
|
+
savedOn: new Date().toISOString()
|
|
375
|
+
});
|
|
310
376
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
377
|
+
await onBeforeUpdate.publish({
|
|
378
|
+
input,
|
|
379
|
+
original,
|
|
380
|
+
model
|
|
381
|
+
});
|
|
382
|
+
const resultModel = await storageOperations.models.update({
|
|
383
|
+
original,
|
|
384
|
+
model,
|
|
385
|
+
input
|
|
386
|
+
});
|
|
387
|
+
await updateManager(context, resultModel);
|
|
388
|
+
await onAfterUpdate.publish({
|
|
389
|
+
original,
|
|
390
|
+
model: resultModel,
|
|
391
|
+
input
|
|
392
|
+
});
|
|
393
|
+
return resultModel;
|
|
394
|
+
},
|
|
395
|
+
|
|
396
|
+
async deleteModel(modelId) {
|
|
397
|
+
await checkModelPermissions("d");
|
|
398
|
+
const model = await get(modelId);
|
|
399
|
+
await onBeforeDelete.publish({
|
|
400
|
+
model
|
|
401
|
+
});
|
|
316
402
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
storageOperations,
|
|
403
|
+
try {
|
|
404
|
+
await storageOperations.models.delete({
|
|
320
405
|
model
|
|
321
406
|
});
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
return managers.get(modelId);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
const models = await modelsList();
|
|
331
|
-
const model = models.find(m => m.modelId === modelId);
|
|
332
|
-
|
|
333
|
-
if (!model) {
|
|
334
|
-
throw new _handlerGraphql.NotFoundError(`There is no content model "${modelId}".`);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
return await updateManager(context, model);
|
|
338
|
-
},
|
|
339
|
-
|
|
340
|
-
getManagers: () => managers
|
|
341
|
-
};
|
|
342
|
-
context.cms = _objectSpread(_objectSpread({}, context.cms || {}), {}, {
|
|
343
|
-
models,
|
|
344
|
-
getModel: modelId => {
|
|
345
|
-
return models.getManager(modelId);
|
|
407
|
+
} catch (ex) {
|
|
408
|
+
throw new _error.default(ex.message || "Could not delete the content model", ex.code || "CONTENT_MODEL_DELETE_ERROR", {
|
|
409
|
+
error: ex,
|
|
410
|
+
modelId: model.modelId
|
|
411
|
+
});
|
|
346
412
|
}
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
413
|
|
|
350
|
-
|
|
414
|
+
await onAfterDelete.publish({
|
|
415
|
+
model
|
|
416
|
+
});
|
|
417
|
+
managers.delete(model.modelId);
|
|
418
|
+
},
|
|
419
|
+
|
|
420
|
+
getModelManager: getManager,
|
|
421
|
+
getManagers: () => managers
|
|
422
|
+
};
|
|
423
|
+
};
|
|
351
424
|
|
|
352
|
-
exports.
|
|
353
|
-
//# sourceMappingURL=contentModel.crud.js.map
|
|
425
|
+
exports.createModelsCrud = createModelsCrud;
|