@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
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.beforeCreateHook = void 0;
|
|
9
|
-
|
|
10
|
-
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
11
|
-
|
|
12
|
-
var _runContentModelLifecycleHooks = require("./runContentModelLifecycleHooks");
|
|
13
|
-
|
|
14
|
-
var _pluralize = _interopRequireDefault(require("pluralize"));
|
|
15
|
-
|
|
16
|
-
var _ContentModelPlugin = require("../../ContentModelPlugin");
|
|
17
|
-
|
|
18
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
19
|
-
|
|
20
|
-
const MAX_MODEL_ID_SEARCH_AMOUNT = 50;
|
|
21
|
-
/**
|
|
22
|
-
* Checks for the uniqueness of provided modelId, against the provided list of models.
|
|
23
|
-
* It also takes plural / singular forms of the provided modelId into account.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const checkModelIdUniqueness = (models, modelId) => {
|
|
27
|
-
if (models.includes(modelId) === true) {
|
|
28
|
-
throw Error(`Content model with modelId "${modelId}" already exists.`);
|
|
29
|
-
} // Additionally, check if the plural form of the received modelId exists too. This prevents users
|
|
30
|
-
// from creating, for example, "event" and "events" models, which would break the GraphQL schema.
|
|
31
|
-
// 1. First check if user wants to create the "event" model, but the "events" model already exists.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const pluralizedModelIdCamelCase = (0, _pluralize.default)(modelId);
|
|
35
|
-
|
|
36
|
-
if (models.includes(pluralizedModelIdCamelCase) === true) {
|
|
37
|
-
throw Error(`Content model with modelId "${modelId}" does not exist, but a model with modelId "${pluralizedModelIdCamelCase}" does.`);
|
|
38
|
-
} // 2. Then check if user wants to create the "events" model, but the "event" model already exists.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const singularizedModelIdCamelCase = _pluralize.default.singular(modelId);
|
|
42
|
-
|
|
43
|
-
if (models.includes(singularizedModelIdCamelCase) === true) {
|
|
44
|
-
throw Error(`Content model with modelId "${modelId}" does not exist, but a model with modelId "${singularizedModelIdCamelCase}" does.`);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Also used to check uniqueness of the provided modelId, although this one just returns a simple boolean value.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const isUniqueModelId = (models, modelId) => {
|
|
53
|
-
try {
|
|
54
|
-
checkModelIdUniqueness(models, modelId);
|
|
55
|
-
return true;
|
|
56
|
-
} catch {
|
|
57
|
-
// If an error has been thrown - we return false.
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const DISALLOWED_MODEL_IDS = ["contentModel", "contentModels", "contentModelGroup", "contentModelGroups"];
|
|
63
|
-
|
|
64
|
-
const checkModelIdAllowed = modelId => {
|
|
65
|
-
if (DISALLOWED_MODEL_IDS.includes(modelId)) {
|
|
66
|
-
throw new Error(`Provided model ID "${modelId}" is not allowed.`);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const isAllowedModelId = modelId => {
|
|
71
|
-
return !DISALLOWED_MODEL_IDS.includes(modelId);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const createNewModelId = (existingModels, model) => {
|
|
75
|
-
const modelIdCamelCase = (0, _camelCase.default)(model.name);
|
|
76
|
-
let counter = 0;
|
|
77
|
-
|
|
78
|
-
while (true) {
|
|
79
|
-
if (counter > MAX_MODEL_ID_SEARCH_AMOUNT) {
|
|
80
|
-
throw new Error(`While loop reached #${MAX_MODEL_ID_SEARCH_AMOUNT} when checking for unique "modelId".`);
|
|
81
|
-
} // Let's try generating a new modelId and immediately check for its uniqueness.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const generatedModelId = `${modelIdCamelCase}${counter || ""}`;
|
|
85
|
-
|
|
86
|
-
if (isAllowedModelId(generatedModelId) && isUniqueModelId(existingModels, generatedModelId)) {
|
|
87
|
-
return generatedModelId;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
counter++;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const beforeCreateHook = async args => {
|
|
95
|
-
const {
|
|
96
|
-
context,
|
|
97
|
-
data,
|
|
98
|
-
storageOperations,
|
|
99
|
-
input
|
|
100
|
-
} = args;
|
|
101
|
-
const {
|
|
102
|
-
modelId
|
|
103
|
-
} = data;
|
|
104
|
-
const modelPlugin = context.plugins.byType(_ContentModelPlugin.ContentModelPlugin.type).find(item => item.contentModel.modelId === modelId);
|
|
105
|
-
|
|
106
|
-
if (modelPlugin) {
|
|
107
|
-
throw new _error.default(`Cannot create "${modelId}" content model because one is already registered via a plugin.`, "CONTENT_MODEL_CREATE_ERROR", {
|
|
108
|
-
modelId
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const models = (await storageOperations.list()).map(m => m.modelId); // If there is a modelId assigned, check if it's unique ...
|
|
113
|
-
|
|
114
|
-
if (!!(modelId || "").trim()) {
|
|
115
|
-
const modelIdCamelCase = (0, _camelCase.default)(data.name);
|
|
116
|
-
checkModelIdAllowed(modelIdCamelCase);
|
|
117
|
-
checkModelIdUniqueness(models, modelIdCamelCase);
|
|
118
|
-
data.modelId = modelIdCamelCase;
|
|
119
|
-
} else {
|
|
120
|
-
// ... otherwise, assign a unique modelId automatically.
|
|
121
|
-
data.modelId = createNewModelId(models, data);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (storageOperations.beforeCreate) {
|
|
125
|
-
await storageOperations.beforeCreate(args);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
await (0, _runContentModelLifecycleHooks.runContentModelLifecycleHooks)("beforeCreate", {
|
|
129
|
-
context,
|
|
130
|
-
storageOperations,
|
|
131
|
-
input,
|
|
132
|
-
model: data
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
exports.beforeCreateHook = beforeCreateHook;
|
|
137
|
-
//# sourceMappingURL=beforeCreate.hook.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/content/plugins/crud/contentModel/beforeCreate.hook.ts"],"names":["MAX_MODEL_ID_SEARCH_AMOUNT","checkModelIdUniqueness","models","modelId","includes","Error","pluralizedModelIdCamelCase","singularizedModelIdCamelCase","pluralize","singular","isUniqueModelId","DISALLOWED_MODEL_IDS","checkModelIdAllowed","isAllowedModelId","createNewModelId","existingModels","model","modelIdCamelCase","name","counter","generatedModelId","beforeCreateHook","args","context","data","storageOperations","input","modelPlugin","plugins","byType","ContentModelPlugin","type","find","item","contentModel","WebinyError","list","map","m","trim","beforeCreate"],"mappings":";;;;;;;;;AAOA;;AACA;;AACA;;AACA;;AACA;;AAEA,MAAMA,0BAA0B,GAAG,EAAnC;AAEA;AACA;AACA;AACA;;AACA,MAAMC,sBAAsB,GAAG,CAACC,MAAD,EAAmBC,OAAnB,KAAuC;AAClE,MAAID,MAAM,CAACE,QAAP,CAAgBD,OAAhB,MAA6B,IAAjC,EAAuC;AACnC,UAAME,KAAK,CAAE,+BAA8BF,OAAQ,mBAAxC,CAAX;AACH,GAHiE,CAKlE;AACA;AAEA;;;AACA,QAAMG,0BAA0B,GAAG,wBAAUH,OAAV,CAAnC;;AACA,MAAID,MAAM,CAACE,QAAP,CAAgBE,0BAAhB,MAAgD,IAApD,EAA0D;AACtD,UAAMD,KAAK,CACN,+BAA8BF,OAAQ,+CAA8CG,0BAA2B,SADzG,CAAX;AAGH,GAdiE,CAgBlE;;;AACA,QAAMC,4BAA4B,GAAGC,mBAAUC,QAAV,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AAMf,iBAAiB,CAACe,YAAlB,CAA+BlB,IAA/B,CAAN;AACH;;AACD,QAAM,kEAAmE,cAAnE,EAAmF;AACrFC,IAAAA,OADqF;AAErFE,IAAAA,iBAFqF;AAGrFC,IAAAA,KAHqF;AAIrFV,IAAAA,KAAK,EAAEQ;AAJ8E,GAAnF,CAAN;AAMH,CAvCM","sourcesContent":["import {\n CmsContentModel,\n CmsContentModelCreateHookPluginArgs,\n CmsContentModelStorageOperations,\n CmsContentModelStorageOperationsBeforeCreateArgs,\n CmsContext\n} from \"../../../../types\";\nimport camelCase from \"lodash/camelCase\";\nimport { runContentModelLifecycleHooks } from \"./runContentModelLifecycleHooks\";\nimport pluralize from \"pluralize\";\nimport { ContentModelPlugin } from \"~/content/plugins/ContentModelPlugin\";\nimport WebinyError from \"@webiny/error\";\n\nconst MAX_MODEL_ID_SEARCH_AMOUNT = 50;\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 = (models: string[], modelId: string) => {\n if (models.includes(modelId) === true) {\n throw Error(`Content model with modelId \"${modelId}\" already exists.`);\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\n // 1. First check if user wants to create the \"event\" model, but the \"events\" model already exists.\n const pluralizedModelIdCamelCase = pluralize(modelId);\n if (models.includes(pluralizedModelIdCamelCase) === true) {\n throw Error(\n `Content model with modelId \"${modelId}\" does not exist, but a model with modelId \"${pluralizedModelIdCamelCase}\" does.`\n );\n }\n\n // 2. Then check if user wants to create the \"events\" model, but the \"event\" model already exists.\n const singularizedModelIdCamelCase = pluralize.singular(modelId);\n if (models.includes(singularizedModelIdCamelCase) === true) {\n throw Error(\n `Content model with modelId \"${modelId}\" does not exist, but a model with modelId \"${singularizedModelIdCamelCase}\" does.`\n );\n }\n};\n\n/**\n * Also used to check uniqueness of the provided modelId, although this one just returns a simple boolean value.\n */\nconst isUniqueModelId = (models: string[], modelId: string) => {\n try {\n checkModelIdUniqueness(models, modelId);\n return true;\n } catch {\n // If an error has been thrown - we return false.\n return false;\n }\n};\n\nconst DISALLOWED_MODEL_IDS = [\n \"contentModel\",\n \"contentModels\",\n \"contentModelGroup\",\n \"contentModelGroups\"\n];\n\nconst checkModelIdAllowed = (modelId: string) => {\n if (DISALLOWED_MODEL_IDS.includes(modelId)) {\n throw new Error(`Provided model ID \"${modelId}\" is not allowed.`);\n }\n};\n\nconst isAllowedModelId = (modelId: string) => {\n return !DISALLOWED_MODEL_IDS.includes(modelId);\n};\n\nconst createNewModelId = (existingModels: string[], model: CmsContentModel): string => {\n const modelIdCamelCase = camelCase(model.name);\n let counter = 0;\n while (true) {\n if (counter > MAX_MODEL_ID_SEARCH_AMOUNT) {\n throw new Error(\n `While loop reached #${MAX_MODEL_ID_SEARCH_AMOUNT} when checking for unique \"modelId\".`\n );\n }\n\n // Let's try generating a new modelId and immediately check for its uniqueness.\n const generatedModelId = `${modelIdCamelCase}${counter || \"\"}`;\n if (\n isAllowedModelId(generatedModelId) &&\n isUniqueModelId(existingModels, generatedModelId)\n ) {\n return generatedModelId;\n }\n counter++;\n }\n};\n\ninterface Args extends CmsContentModelStorageOperationsBeforeCreateArgs {\n context: CmsContext;\n storageOperations: CmsContentModelStorageOperations;\n}\n\nexport const beforeCreateHook = async (args: Args): Promise<void> => {\n const { context, data, storageOperations, input } = args;\n const { modelId } = data;\n\n const modelPlugin: ContentModelPlugin = context.plugins\n .byType<ContentModelPlugin>(ContentModelPlugin.type)\n .find((item: ContentModelPlugin) => item.contentModel.modelId === modelId);\n\n if (modelPlugin) {\n throw new WebinyError(\n `Cannot create \"${modelId}\" content model because one is already registered via a plugin.`,\n \"CONTENT_MODEL_CREATE_ERROR\",\n {\n modelId\n }\n );\n }\n\n const models = (await storageOperations.list()).map(m => m.modelId);\n // If there is a modelId assigned, check if it's unique ...\n if (!!(modelId || \"\").trim()) {\n const modelIdCamelCase = camelCase(data.name);\n checkModelIdAllowed(modelIdCamelCase);\n checkModelIdUniqueness(models, modelIdCamelCase);\n data.modelId = modelIdCamelCase;\n } else {\n // ... otherwise, assign a unique modelId automatically.\n data.modelId = createNewModelId(models, data);\n }\n\n if (storageOperations.beforeCreate) {\n await storageOperations.beforeCreate(args);\n }\n await runContentModelLifecycleHooks<CmsContentModelCreateHookPluginArgs>(\"beforeCreate\", {\n context,\n storageOperations,\n input,\n model: data\n });\n};\n"],"file":"beforeCreate.hook.js"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CmsContentModelStorageOperations, CmsContentModelStorageOperationsBeforeDeleteArgs, CmsContext } from "../../../../types";
|
|
2
|
-
interface Args extends CmsContentModelStorageOperationsBeforeDeleteArgs {
|
|
3
|
-
context: CmsContext;
|
|
4
|
-
storageOperations: CmsContentModelStorageOperations;
|
|
5
|
-
}
|
|
6
|
-
export declare const beforeDeleteHook: (args: Args) => Promise<void>;
|
|
7
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.beforeDeleteHook = void 0;
|
|
9
|
-
|
|
10
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
|
-
var _runContentModelLifecycleHooks = require("./runContentModelLifecycleHooks");
|
|
13
|
-
|
|
14
|
-
var _ContentModelPlugin = require("@webiny/api-headless-cms/content/plugins/ContentModelPlugin");
|
|
15
|
-
|
|
16
|
-
const beforeDeleteHook = async args => {
|
|
17
|
-
const {
|
|
18
|
-
context,
|
|
19
|
-
model
|
|
20
|
-
} = args;
|
|
21
|
-
const {
|
|
22
|
-
modelId
|
|
23
|
-
} = model;
|
|
24
|
-
const modelPlugin = context.plugins.byType(_ContentModelPlugin.ContentModelPlugin.type).find(item => item.contentModel.modelId === modelId);
|
|
25
|
-
|
|
26
|
-
if (modelPlugin) {
|
|
27
|
-
throw new _error.default("Content models defined via plugins cannot be deleted.", "CONTENT_MODEL_DELETE_ERROR", {
|
|
28
|
-
modelId
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const manager = await context.cms.getModel(modelId);
|
|
33
|
-
let entries = [];
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
[entries] = await manager.list({
|
|
37
|
-
limit: 1
|
|
38
|
-
});
|
|
39
|
-
} catch (ex) {
|
|
40
|
-
throw new _error.default("Could not retrieve a list of content entries from the model.", "ENTRIES_ERROR", {
|
|
41
|
-
modelId,
|
|
42
|
-
error: ex
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (entries.length > 0) {
|
|
47
|
-
throw new _error.default(`Cannot delete content model "${modelId}" because there are existing entries.`, "CONTENT_MODEL_BEFORE_DELETE_HOOK_FAILED");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (args.storageOperations.beforeDelete) {
|
|
51
|
-
await args.storageOperations.beforeDelete(args);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
await (0, _runContentModelLifecycleHooks.runContentModelLifecycleHooks)("beforeDelete", args);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
exports.beforeDeleteHook = beforeDeleteHook;
|
|
58
|
-
//# sourceMappingURL=beforeDelete.hook.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/content/plugins/crud/contentModel/beforeDelete.hook.ts"],"names":["beforeDeleteHook","args","context","model","modelId","modelPlugin","plugins","byType","ContentModelPlugin","type","find","item","contentModel","WebinyError","manager","cms","getModel","entries","list","limit","ex","error","length","storageOperations","beforeDelete"],"mappings":";;;;;;;;;AAMA;;AACA;;AACA;;AAOO,MAAMA,gBAAgB,GAAG,MAAOC,IAAP,IAAsB;AAClD,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,MAAqBF,IAA3B;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAcD,KAApB;AAEA,QAAME,WAA+B,GAAGH,OAAO,CAACI,OAAR,CACnCC,MADmC,CACRC,uCAAmBC,IADX,EAEnCC,IAFmC,CAE7BC,IAAD,IAA8BA,IAAI,CAACC,YAAL,CAAkBR,OAAlB,KAA8BA,OAF9B,CAAxC;;AAIA,MAAIC,WAAJ,EAAiB;AACb,UAAM,IAAIQ,cAAJ,CACF,uDADE,EAEF,4BAFE,EAGF;AACIT,MAAAA;AADJ,KAHE,CAAN;AAOH;;AAED,QAAMU,OAAO,GAAG,MAAMZ,OAAO,CAACa,GAAR,CAAYC,QAAZ,CAAqBZ,OAArB,CAAtB;AAEA,MAAIa,OAAO,GAAG,EAAd;;AACA,MAAI;AACA,KAACA,OAAD,IAAY,MAAMH,OAAO,CAACI,IAAR,CAAa;AAC3BC,MAAAA,KAAK,EAAE;AADoB,KAAb,CAAlB;AAGH,GAJD,CAIE,OAAOC,EAAP,EAAW;AACT,UAAM,IAAIP,cAAJ,CACF,8DADE,EAEF,eAFE,EAGF;AACIT,MAAAA,OADJ;AAEIiB,MAAAA,KAAK,EAAED;AAFX,KAHE,CAAN;AAQH;;AACD,MAAIH,OAAO,CAACK,MAAR,GAAiB,CAArB,EAAwB;AACpB,UAAM,IAAIT,cAAJ,CACD,gCAA+BT,OAAQ,uCADtC,EAEF,yCAFE,CAAN;AAIH;;AACD,MAAIH,IAAI,CAACsB,iBAAL,CAAuBC,YAA3B,EAAyC;AACrC,UAAMvB,IAAI,CAACsB,iBAAL,CAAuBC,YAAvB,CAAoCvB,IAApC,CAAN;AACH;;AACD,QAAM,kEAA6D,cAA7D,EAA6EA,IAA7E,CAAN;AACH,CA7CM","sourcesContent":["import {\n CmsContentModelHookPluginArgs,\n CmsContentModelStorageOperations,\n CmsContentModelStorageOperationsBeforeDeleteArgs,\n CmsContext\n} from \"../../../../types\";\nimport WebinyError from \"@webiny/error\";\nimport { runContentModelLifecycleHooks } from \"./runContentModelLifecycleHooks\";\nimport { ContentModelPlugin } from \"@webiny/api-headless-cms/content/plugins/ContentModelPlugin\";\n\ninterface Args extends CmsContentModelStorageOperationsBeforeDeleteArgs {\n context: CmsContext;\n storageOperations: CmsContentModelStorageOperations;\n}\n\nexport const beforeDeleteHook = async (args: Args) => {\n const { context, model } = args;\n const { modelId } = model;\n\n const modelPlugin: ContentModelPlugin = context.plugins\n .byType<ContentModelPlugin>(ContentModelPlugin.type)\n .find((item: ContentModelPlugin) => item.contentModel.modelId === 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\n }\n );\n }\n\n const manager = await context.cms.getModel(modelId);\n\n let entries = [];\n try {\n [entries] = await manager.list({\n limit: 1\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not retrieve a list of content entries from the model.\",\n \"ENTRIES_ERROR\",\n {\n modelId,\n error: ex\n }\n );\n }\n if (entries.length > 0) {\n throw new WebinyError(\n `Cannot delete content model \"${modelId}\" because there are existing entries.`,\n \"CONTENT_MODEL_BEFORE_DELETE_HOOK_FAILED\"\n );\n }\n if (args.storageOperations.beforeDelete) {\n await args.storageOperations.beforeDelete(args);\n }\n await runContentModelLifecycleHooks<CmsContentModelHookPluginArgs>(\"beforeDelete\", args);\n};\n"],"file":"beforeDelete.hook.js"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CmsContentModelStorageOperations, CmsContentModelStorageOperationsBeforeUpdateArgs, CmsContext } from "../../../../types";
|
|
2
|
-
interface Args extends CmsContentModelStorageOperationsBeforeUpdateArgs {
|
|
3
|
-
context: CmsContext;
|
|
4
|
-
storageOperations: CmsContentModelStorageOperations;
|
|
5
|
-
}
|
|
6
|
-
export declare const beforeUpdateHook: (args: Args) => Promise<void>;
|
|
7
|
-
export {};
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.beforeUpdateHook = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
|
-
var _runContentModelLifecycleHooks = require("./runContentModelLifecycleHooks");
|
|
15
|
-
|
|
16
|
-
var _ContentModelPlugin = require("../../ContentModelPlugin");
|
|
17
|
-
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
|
|
22
|
-
const defaultTitleFieldId = "id";
|
|
23
|
-
const allowedTitleFieldTypes = ["text", "number"];
|
|
24
|
-
|
|
25
|
-
const getContentModelTitleFieldId = (fields, titleFieldId) => {
|
|
26
|
-
// if there is no title field defined either in input data or existing content model data
|
|
27
|
-
// we will take first text field that has no multiple values enabled
|
|
28
|
-
// or if initial titleFieldId is the default one also try to find first available text field
|
|
29
|
-
if (!titleFieldId || titleFieldId === defaultTitleFieldId) {
|
|
30
|
-
const titleField = fields.find(field => {
|
|
31
|
-
return field.type === "text" && !field.multipleValues;
|
|
32
|
-
});
|
|
33
|
-
return titleField ? titleField.fieldId : defaultTitleFieldId;
|
|
34
|
-
} // check existing titleFieldId for existence in the model
|
|
35
|
-
// for correct type
|
|
36
|
-
// and that it is not multiple values field
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const target = fields.find(f => f.fieldId === titleFieldId);
|
|
40
|
-
|
|
41
|
-
if (!target) {
|
|
42
|
-
throw new _error.default(`Field does not exist in the model.`, "VALIDATION_ERROR", {
|
|
43
|
-
fieldId: titleFieldId
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (allowedTitleFieldTypes.includes(target.type) === false) {
|
|
48
|
-
throw new _error.default(`Only ${allowedTitleFieldTypes.join(", ")} and id fields can be used as an entry title.`, "ENTRY_TITLE_FIELD_TYPE", {
|
|
49
|
-
fieldId: target.fieldId,
|
|
50
|
-
type: target.type
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (target.multipleValues) {
|
|
55
|
-
throw new _error.default(`Fields that accept multiple values cannot be used as the entry title.`, "ENTRY_TITLE_FIELD_TYPE", {
|
|
56
|
-
fieldId: target.fieldId,
|
|
57
|
-
type: target.type
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return target.fieldId;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const beforeUpdateHook = async args => {
|
|
65
|
-
const {
|
|
66
|
-
context,
|
|
67
|
-
model,
|
|
68
|
-
data
|
|
69
|
-
} = args;
|
|
70
|
-
const modelPlugin = context.plugins.byType(_ContentModelPlugin.ContentModelPlugin.type).find(item => item.contentModel.modelId === model.modelId);
|
|
71
|
-
|
|
72
|
-
if (modelPlugin) {
|
|
73
|
-
throw new _error.default("Content models defined via plugins cannot be updated.", "CONTENT_MODEL_UPDATE_ERROR", {
|
|
74
|
-
modelId: model.modelId
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const combinedModel = _objectSpread(_objectSpread({}, model), data);
|
|
79
|
-
|
|
80
|
-
const {
|
|
81
|
-
titleFieldId
|
|
82
|
-
} = combinedModel; // There should be fields/locked fields in either model or data to be updated.
|
|
83
|
-
|
|
84
|
-
const {
|
|
85
|
-
fields = [],
|
|
86
|
-
lockedFields = []
|
|
87
|
-
} = combinedModel; // Let's inspect the fields of the received content model. We prevent saving of a content model if it
|
|
88
|
-
// contains a field for which a "cms-model-field-to-graphql" plugin does not exist on the backend.
|
|
89
|
-
|
|
90
|
-
const fieldTypePlugins = context.plugins.byType("cms-model-field-to-graphql");
|
|
91
|
-
|
|
92
|
-
for (let i = 0; i < fields.length; i++) {
|
|
93
|
-
const field = fields[i];
|
|
94
|
-
|
|
95
|
-
if (!fieldTypePlugins.find(item => item.fieldType === field.type)) {
|
|
96
|
-
throw new Error(`Cannot update content model because of the unknown "${field.type}" field.`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
data.titleFieldId = getContentModelTitleFieldId(fields, titleFieldId);
|
|
101
|
-
const cmsLockedFieldPlugins = context.plugins.byType("cms-model-locked-field"); // We must not allow removal or changes in fields that are already in use in content entries.
|
|
102
|
-
|
|
103
|
-
for (const lockedField of lockedFields) {
|
|
104
|
-
const existingField = fields.find(item => item.fieldId === lockedField.fieldId);
|
|
105
|
-
|
|
106
|
-
if (!existingField) {
|
|
107
|
-
throw new _error.default(`Cannot remove the field "${lockedField.fieldId}" because it's already in use in created content.`, "ENTRY_FIELD_USED");
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (lockedField.multipleValues !== existingField.multipleValues) {
|
|
111
|
-
throw new _error.default(`Cannot change "multipleValues" for the "${lockedField.fieldId}" field because it's already in use in created content.`, "ENTRY_FIELD_USED");
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (lockedField.type !== existingField.type) {
|
|
115
|
-
throw new _error.default(`Cannot change field type for the "${lockedField.fieldId}" field because it's already in use in created content.`, "ENTRY_FIELD_USED");
|
|
116
|
-
} // Check `lockedField` invariant for specific field
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const lockedFieldsByType = cmsLockedFieldPlugins.filter(pl => pl.fieldType === lockedField.type);
|
|
120
|
-
|
|
121
|
-
for (const plugin of lockedFieldsByType) {
|
|
122
|
-
if (typeof plugin.checkLockedField !== "function") {
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
plugin.checkLockedField({
|
|
127
|
-
lockedField,
|
|
128
|
-
field: existingField
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (args.storageOperations.beforeUpdate) {
|
|
134
|
-
await args.storageOperations.beforeUpdate(args);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
await (0, _runContentModelLifecycleHooks.runContentModelLifecycleHooks)("beforeUpdate", args);
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
exports.beforeUpdateHook = beforeUpdateHook;
|
|
141
|
-
//# sourceMappingURL=beforeUpdate.hook.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/content/plugins/crud/contentModel/beforeUpdate.hook.ts"],"names":["defaultTitleFieldId","allowedTitleFieldTypes","getContentModelTitleFieldId","fields","titleFieldId","titleField","find","field","type","multipleValues","fieldId","target","f","WebinyError","includes","join","beforeUpdateHook","args","context","model","data","modelPlugin","plugins","byType","ContentModelPlugin","item","contentModel","modelId","combinedModel","lockedFields","fieldTypePlugins","i","length","fieldType","Error","cmsLockedFieldPlugins","lockedField","existingField","lockedFieldsByType","filter","pl","plugin","checkLockedField","storageOperations","beforeUpdate"],"mappings":";;;;;;;;;;;AASA;;AACA;;AACA;;;;;;AAOA,MAAMA,mBAAmB,GAAG,IAA5B;AAEA,MAAMC,sB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B,IAAI,CAAC0B,iBAAL,CAAuBC,YAAvB,CAAoC3B,IAApC,CAAN;AACH;;AACD,QAAM,kEAAmE,cAAnE,EAAmFA,IAAnF,CAAN;AACH,CAzFM","sourcesContent":["import {\n CmsContentModelStorageOperations,\n CmsContentModelStorageOperationsBeforeUpdateArgs,\n CmsContentModelField,\n CmsContentModelUpdateHookPluginArgs,\n CmsContext,\n CmsModelFieldToGraphQLPlugin,\n CmsModelLockedFieldPlugin\n} from \"../../../../types\";\nimport WebinyError from \"@webiny/error\";\nimport { runContentModelLifecycleHooks } from \"./runContentModelLifecycleHooks\";\nimport { ContentModelPlugin } from \"~/content/plugins/ContentModelPlugin\";\n\ninterface Args extends CmsContentModelStorageOperationsBeforeUpdateArgs {\n context: CmsContext;\n storageOperations: CmsContentModelStorageOperations;\n}\n\nconst defaultTitleFieldId = \"id\";\n\nconst allowedTitleFieldTypes = [\"text\", \"number\"];\n\nconst getContentModelTitleFieldId = (\n fields: CmsContentModelField[],\n titleFieldId?: string\n): 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 });\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\nexport const beforeUpdateHook = async (args: Args) => {\n const { context, model, data } = args;\n\n const modelPlugin: ContentModelPlugin = context.plugins\n .byType<ContentModelPlugin>(ContentModelPlugin.type)\n .find((item: ContentModelPlugin) => 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 combinedModel = {\n ...model,\n ...data\n };\n\n const { titleFieldId } = combinedModel;\n\n // There should be fields/locked fields in either model or data to be updated.\n const { fields = [], lockedFields = [] } = combinedModel;\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 = context.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 data.titleFieldId = getContentModelTitleFieldId(fields, titleFieldId);\n\n const cmsLockedFieldPlugins =\n context.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 if (args.storageOperations.beforeUpdate) {\n await args.storageOperations.beforeUpdate(args);\n }\n await runContentModelLifecycleHooks<CmsContentModelUpdateHookPluginArgs>(\"beforeUpdate\", args);\n};\n"],"file":"beforeUpdate.hook.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/content/plugins/crud/contentModel/contentModelManagerFactory.ts"],"names":["defaultName","contentModelManagerFactory","context","model","pluginsByType","plugins","byType","reverse","plugin","target","Array","isArray","modelId","includes","name","create","find","Error"],"mappings":";;;;;;AAEA,MAAMA,WAAW,GAAG,+BAApB;;AAEO,MAAMC,0BAA0B,GAAG,OAAOC,OAAP,EAA4BC,KAA5B,KAAuD;AAC7F,QAAMC,aAAa,GAAGF,OAAO,CAACG,OAAR,CACjBC,MADiB,CACiB,2BADjB,EAEjBC,OAFiB,EAAtB;;AAGA,OAAK,MAAMC,MAAX,IAAqBJ,aAArB,EAAoC;AAChC,UAAMK,MAAM,GAAGC,KAAK,CAACC,OAAN,CAAcH,MAAM,CAACI,OAArB,IAAgCJ,MAAM,CAACI,OAAvC,GAAiD,CAACJ,MAAM,CAACI,OAAR,CAAhE;;AACA,QAAIH,MAAM,CAACI,QAAP,CAAgBV,KAAK,CAACS,OAAtB,MAAmC,IAAnC,IAA2CJ,MAAM,CAACM,IAAP,KAAgBd,WAA/D,EAA4E;AACxE,aAAO,MAAMQ,MAAM,CAACO,MAAP,CAAcb,OAAd,EAAuBC,KAAvB,CAAb;AACH;AACJ;;AACD,QAAMK,MAAM,GAAGJ,aAAa,CAACY,IAAd,CAAmBR,MAAM,IAAIA,MAAM,CAACM,IAAP,KAAgBd,WAA7C,CAAf;;AACA,MAAI,CAACQ,MAAL,EAAa;AACT,UAAM,IAAIS,KAAJ,CAAU,0DAAV,CAAN;AACH;;AACD,SAAO,MAAMT,MAAM,CAACO,MAAP,CAAcb,OAAd,EAAuBC,KAAvB,CAAb;AACH,CAfM","sourcesContent":["import { CmsContentModel, CmsContext, ContentModelManagerPlugin } from \"../../../../types\";\n\nconst defaultName = \"content-model-manager-default\";\n\nexport const contentModelManagerFactory = async (context: CmsContext, model: CmsContentModel) => {\n const pluginsByType = context.plugins\n .byType<ContentModelManagerPlugin>(\"cms-content-model-manager\")\n .reverse();\n for (const plugin of pluginsByType) {\n const target = Array.isArray(plugin.modelId) ? plugin.modelId : [plugin.modelId];\n if (target.includes(model.modelId) === true && plugin.name !== defaultName) {\n return await plugin.create(context, model);\n }\n }\n const plugin = pluginsByType.find(plugin => plugin.name === defaultName);\n if (!plugin) {\n throw new Error(\"There is no default plugin to create ContentModelManager\");\n }\n return await plugin.create(context, model);\n};\n"],"file":"contentModelManagerFactory.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/content/plugins/crud/contentModel/createFieldModels.ts"],"names":["createFieldModels","model","data","fields","field","fieldData","ContentModelFieldModel","populate","validate","push","toJSON"],"mappings":";;;;;;;AAKA;;AAEO,MAAMA,iBAAiB,GAAG,OAC7BC,KAD6B,EAE7BC,IAF6B,KAGK;AAClC,QAAMC,MAA8B,GAAG,EAAvC;;AACA,OAAK,MAAMC,KAAX,IAAoBF,IAAI,CAACC,MAAzB,EAAiC;AAC7B,UAAME,SAAS,GAAG,IAAIC,8BAAJ,GAA6BC,QAA7B,CAAsCH,KAAtC,CAAlB;AACA,UAAMC,SAAS,CAACG,QAAV,EAAN;AACAL,IAAAA,MAAM,CAACM,IAAP,CAAY,MAAMJ,SAAS,CAACK,MAAV,EAAlB;AACH;;AACD,SAAOP,MAAP;AACH,CAXM","sourcesContent":["import {\n CmsContentModelField,\n CmsContentModel,\n CmsContentModelUpdateInput\n} from \"../../../../types\";\nimport { ContentModelFieldModel } from \"./models\";\n\nexport const createFieldModels = async (\n model: CmsContentModel,\n data: CmsContentModelUpdateInput\n): Promise<CmsContentModelField[]> => {\n const fields: CmsContentModelField[] = [];\n for (const field of data.fields) {\n const fieldData = new ContentModelFieldModel().populate(field);\n await fieldData.validate();\n fields.push(await fieldData.toJSON());\n }\n return fields;\n};\n"],"file":"createFieldModels.js"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _beforeCreate = require("./beforeCreate.hook");
|
|
8
|
-
|
|
9
|
-
Object.keys(_beforeCreate).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _beforeCreate[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _beforeCreate[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
var _afterCreate = require("./afterCreate.hook");
|
|
21
|
-
|
|
22
|
-
Object.keys(_afterCreate).forEach(function (key) {
|
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (key in exports && exports[key] === _afterCreate[key]) return;
|
|
25
|
-
Object.defineProperty(exports, key, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _afterCreate[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
var _beforeUpdate = require("./beforeUpdate.hook");
|
|
34
|
-
|
|
35
|
-
Object.keys(_beforeUpdate).forEach(function (key) {
|
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (key in exports && exports[key] === _beforeUpdate[key]) return;
|
|
38
|
-
Object.defineProperty(exports, key, {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () {
|
|
41
|
-
return _beforeUpdate[key];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
var _afterUpdate = require("./afterUpdate.hook");
|
|
47
|
-
|
|
48
|
-
Object.keys(_afterUpdate).forEach(function (key) {
|
|
49
|
-
if (key === "default" || key === "__esModule") return;
|
|
50
|
-
if (key in exports && exports[key] === _afterUpdate[key]) return;
|
|
51
|
-
Object.defineProperty(exports, key, {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function () {
|
|
54
|
-
return _afterUpdate[key];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
var _beforeDelete = require("./beforeDelete.hook");
|
|
60
|
-
|
|
61
|
-
Object.keys(_beforeDelete).forEach(function (key) {
|
|
62
|
-
if (key === "default" || key === "__esModule") return;
|
|
63
|
-
if (key in exports && exports[key] === _beforeDelete[key]) return;
|
|
64
|
-
Object.defineProperty(exports, key, {
|
|
65
|
-
enumerable: true,
|
|
66
|
-
get: function () {
|
|
67
|
-
return _beforeDelete[key];
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
var _afterDelete = require("./afterDelete.hook");
|
|
73
|
-
|
|
74
|
-
Object.keys(_afterDelete).forEach(function (key) {
|
|
75
|
-
if (key === "default" || key === "__esModule") return;
|
|
76
|
-
if (key in exports && exports[key] === _afterDelete[key]) return;
|
|
77
|
-
Object.defineProperty(exports, key, {
|
|
78
|
-
enumerable: true,
|
|
79
|
-
get: function () {
|
|
80
|
-
return _afterDelete[key];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/content/plugins/crud/contentModel/hooks.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from \"./beforeCreate.hook\";\nexport * from \"./afterCreate.hook\";\nexport * from \"./beforeUpdate.hook\";\nexport * from \"./afterUpdate.hook\";\nexport * from \"./beforeDelete.hook\";\nexport * from \"./afterDelete.hook\";\n"],"file":"hooks.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/content/plugins/crud/contentModel/idValidation.ts"],"names":["value","validation","validate","charAt","match","Error","trim","toLowerCase"],"mappings":";;;;;;;AAAA;;eAEe,MAAOA,KAAP,IAAyB;AACpC,QAAMC,uBAAWC,QAAX,CAAoBF,KAApB,EAA2B,wBAA3B,CAAN;;AACA,MAAI,CAACA,KAAK,CAACG,MAAN,CAAa,CAAb,EAAgBC,KAAhB,CAAsB,UAAtB,CAAL,EAAwC;AACpC,UAAM,IAAIC,KAAJ,CAAW,eAAcL,KAAM,+CAA/B,CAAN;AACH;;AACD,MAAIA,KAAK,CAACM,IAAN,GAAaC,WAAb,OAA+B,IAAnC,EAAyC;AACrC,UAAM,IAAIF,KAAJ,CAAW,eAAcL,KAAM,kDAA/B,CAAN;AACH;AACJ,C","sourcesContent":["import { validation } from \"@webiny/validation\";\n\nexport default async (value: string) => {\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"],"file":"idValidation.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/content/plugins/crud/contentModel/models.ts"],"names":["requiredShortString","validation","create","shortString","CreateContentModelModel","name","modelId","description","group","RendererModel","ContentModelFieldModel","id","fieldId","value","trim","idValidation","label","helpText","placeholderText","type","multipleValues","predefinedValues","instanceOf","enabled","values","list","renderer","message","settings","listValidation","UpdateContentModelModel","titleFieldId","fields","required","layout"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA,MAAMA,mBAAmB,GAAGC,uBAAWC,MAAX,CAAkB,wBAAlB,CAA5B;;AACA,MAAMC,WAAW,GAAGF,uBAAWC,MAAX,CAAkB,eAAlB,CAApB;;AAEO,MAAME,uBAAuB,GAAG,wBAAW;AAC9CC,EAAAA,IAAI,EAAE,oBAAO;AAAEJ,IAAAA,UAAU,EAAED;AAAd,GAAP,CADwC;AAE9CM,EAAAA,OAAO,EAAE,oBAAO;AAAEL,IAAAA,UAAU,EAAEE;AAAd,GAAP,CAFqC;AAG9CI,EAAAA,WAAW,EAAE,oBAAO;AAAEN,IAAAA,UAAU,EAAEE;AAAd,GAAP,CAHiC;AAI9CK,EAAAA,KAAK,EAAE,oBAAO;AAAEP,IAAAA,UAAU,EAAED;AAAd,GAAP;AAJuC,CAAX,GAAhC;;AAOP,MAAMS,aAAa,GAAG,wBAAW;AAC7BJ,EAAAA,IAAI,EAAE,oBAAO;AAAEJ,IAAAA,UAAU,EAAED;AAAd,GAAP;AADuB,CAAX,GAAtB;AAIO,MAAMU,sBAAsB,GAAG,wBAAW;AAC7CC,EAAAA,EAAE,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EZ,sBAAd;AAAsCG,IAAAA,KAAK,EAAE,EAA7C;AAAiDY,IAAAA,IAAI,EAAE,IAAvD;AAA6DQ,IAAAA,QAAQ,EAAE;AAAvE,GAAP,CALsC;AAM9CC,EAAAA,MAAM,EAAE,iCAAO;AAAErB,IAAAA,KAAK,EAAE,EAAT;AAAaoB,IAAAA,QAAQ,EAAE;AAAvB,GAAP;AANsC,CAAX,GAAhC","sourcesContent":["import { validation } from \"@webiny/validation\";\nimport flow from \"lodash/flow\";\nimport { object } from \"commodo-fields-object\";\nimport { withFields, string, setOnce, onSet, boolean, fields } from \"@commodo/fields\";\nimport idValidation from \"./idValidation\";\n\nconst requiredShortString = validation.create(\"required,maxLength:255\");\nconst shortString = validation.create(\"maxLength:255\");\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})();\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 => value && value.trim()),\n setOnce()\n )(string({ validation: idValidation })),\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 })()\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 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"],"file":"models.js"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { CmsContentModelCreateHookPluginArgs, CmsContentModelHookPluginArgs, CmsContentModelUpdateHookPluginArgs } from "../../../../types";
|
|
2
|
-
export declare const runContentModelLifecycleHooks: <T extends CmsContentModelHookPluginArgs | CmsContentModelCreateHookPluginArgs | CmsContentModelUpdateHookPluginArgs>(hookName: string, args: T) => Promise<void>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.runContentModelLifecycleHooks = void 0;
|
|
7
|
-
|
|
8
|
-
const runContentModelLifecycleHooks = async (hookName, args) => {
|
|
9
|
-
const {
|
|
10
|
-
context
|
|
11
|
-
} = args;
|
|
12
|
-
const hookPlugins = context.plugins.byType("cms-content-model-hook");
|
|
13
|
-
|
|
14
|
-
for (const hookPlugin of hookPlugins) {
|
|
15
|
-
if (typeof hookPlugin[hookName] !== "function") {
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
await hookPlugin[hookName](args);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
exports.runContentModelLifecycleHooks = runContentModelLifecycleHooks;
|
|
24
|
-
//# sourceMappingURL=runContentModelLifecycleHooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/content/plugins/crud/contentModel/runContentModelLifecycleHooks.ts"],"names":["runContentModelLifecycleHooks","hookName","args","context","hookPlugins","plugins","byType","hookPlugin"],"mappings":";;;;;;;AAOO,MAAMA,6BAA6B,GAAG,OAMzCC,QANyC,EAOzCC,IAPyC,KAQzB;AAChB,QAAM;AAAEC,IAAAA;AAAF,MAAcD,IAApB;AACA,QAAME,WAAW,GAAGD,OAAO,CAACE,OAAR,CAAgBC,MAAhB,CAAkD,wBAAlD,CAApB;;AACA,OAAK,MAAMC,UAAX,IAAyBH,WAAzB,EAAsC;AAClC,QAAI,OAAOG,UAAU,CAACN,QAAD,CAAjB,KAAgC,UAApC,EAAgD;AAC5C;AACH;;AACD,UAAMM,UAAU,CAACN,QAAD,CAAV,CAAqBC,IAArB,CAAN;AACH;AACJ,CAjBM","sourcesContent":["import {\n CmsContentModelCreateHookPluginArgs,\n CmsContentModelHookPlugin,\n CmsContentModelHookPluginArgs,\n CmsContentModelUpdateHookPluginArgs\n} from \"../../../../types\";\n\nexport const runContentModelLifecycleHooks = async <\n T extends\n | CmsContentModelHookPluginArgs\n | CmsContentModelCreateHookPluginArgs\n | CmsContentModelUpdateHookPluginArgs\n>(\n hookName: string,\n args: T\n): Promise<void> => {\n const { context } = args;\n const hookPlugins = context.plugins.byType<CmsContentModelHookPlugin>(\"cms-content-model-hook\");\n for (const hookPlugin of hookPlugins) {\n if (typeof hookPlugin[hookName] !== \"function\") {\n continue;\n }\n await hookPlugin[hookName](args);\n }\n};\n"],"file":"runContentModelLifecycleHooks.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/content/plugins/crud/contentModel/validateLayout.ts"],"names":["validateLayout","layout","fields","flatLayoutIdList","reduce","acc","id","concat","Array","isArray","length","Error","field","includes","fieldFound","some","f"],"mappings":";;;;;;;AAEO,MAAMA,cAAc,GAAG,CAC1B;AAAEC,EAAAA;AAAF,CAD0B,EAE1BC,MAF0B,KAGnB;AACP,QAAMC,gBAAgB,GAAGF,MAAM,CAACG,MAAP,CAAc,CAACC,GAAD,EAAMC,EAAN,KAAa;AAChD,WAAOD,GAAG,CAACE,MAAJ,CAAWC,KAAK,CAACC,OAAN,CAAcH,EAAd,IAAoBA,EAApB,GAAyB,CAACA,EAAD,CAApC,CAAP;AACH,GAFwB,EAEtB,EAFsB,CAAzB;;AAGA,MAAIH,gBAAgB,CAACO,MAAjB,KAA4BR,MAAM,CAACQ,MAAvC,EAA+C;AAC3C,UAAM,IAAIC,KAAJ,CACD,aAAYR,gBAAgB,CAACO,MAAO,0BAAyBR,MAAM,CAACQ,MAAO,yDAD1E,CAAN;AAGH;;AACD,OAAK,MAAME,KAAX,IAAoBV,MAApB,EAA4B;AACxB,QAAIC,gBAAgB,CAACU,QAAjB,CAA0BD,KAAK,CAACN,EAAhC,CAAJ,EAAyC;AACrC;AACH;;AACD,UAAM,IAAIK,KAAJ,CAAW,UAASC,KAAK,CAACN,EAAG,6BAA7B,CAAN;AACH;;AACD,OAAK,MAAMA,EAAX,IAAiBH,gBAAjB,EAAmC;AAC/B,UAAMW,UAAU,GAAGZ,MAAM,CAACa,IAAP,CAAYC,CAAC,IAAIA,CAAC,CAACV,EAAF,KAASA,EAA1B,CAAnB;;AACA,QAAIQ,UAAJ,EAAgB;AACZ;AACH;;AACD,UAAM,IAAIH,KAAJ,CAAW,aAAYL,EAAG,mCAA1B,CAAN;AACH;AACJ,CAzBM","sourcesContent":["import { CmsContentModelField, CmsContentModel } from \"../../../../types\";\n\nexport const validateLayout = (\n { layout }: CmsContentModel,\n fields: CmsContentModelField[]\n): void => {\n const flatLayoutIdList = layout.reduce((acc, id) => {\n return acc.concat(Array.isArray(id) ? id : [id]);\n }, []);\n if (flatLayoutIdList.length !== fields.length) {\n throw new Error(\n `There are ${flatLayoutIdList.length} IDs in the layout and ${fields.length} in fields, which cannot be - numbers must be the same.`\n );\n }\n for (const field of fields) {\n if (flatLayoutIdList.includes(field.id)) {\n continue;\n }\n throw new Error(`Field \"${field.id}\" is not defined in layout.`);\n }\n for (const id of flatLayoutIdList) {\n const fieldFound = fields.some(f => f.id === id);\n if (fieldFound) {\n continue;\n }\n throw new Error(`Field id \"${id}\" is in layout but not in fields.`);\n }\n};\n"],"file":"validateLayout.js"}
|