@webiny/api-headless-cms 5.29.0 → 5.30.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.d.ts +3 -0
- package/{content/contextSetup.js → context.js} +13 -8
- package/context.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.js +0 -0
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.js.map +0 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.js +0 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.js.map +0 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.js +0 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.js.map +0 -0
- package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.js +7 -1
- package/crud/contentEntry/entryDataValidation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.js +1 -1
- package/crud/contentEntry/markLockedFields.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/referenceFieldsMapping.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/referenceFieldsMapping.js +0 -0
- package/{content/plugins/crud → crud}/contentEntry/referenceFieldsMapping.js.map +0 -0
- package/{content/plugins/crud → crud}/contentEntry.crud.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry.crud.js +68 -42
- package/crud/contentEntry.crud.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/afterCreate.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreate.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreateFrom.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/afterCreateFrom.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreateFrom.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterDelete.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/afterDelete.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterDelete.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterUpdate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/afterUpdate.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterUpdate.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/beforeCreate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/beforeCreate.js +1 -1
- package/crud/contentModel/beforeCreate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.js +1 -1
- package/crud/contentModel/beforeDelete.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/beforeUpdate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/beforeUpdate.js +0 -0
- package/crud/contentModel/beforeUpdate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js.map +0 -0
- package/crud/contentModel/createFieldModels.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/createFieldModels.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/createFieldModels.js.map +0 -0
- package/crud/contentModel/idValidation.d.ts +1 -0
- package/{content/plugins/crud → crud}/contentModel/idValidation.js +3 -3
- package/crud/contentModel/idValidation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/models.d.ts +0 -0
- package/{content/plugins/crud → crud}/contentModel/models.js +2 -2
- package/crud/contentModel/models.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/validateLayout.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/validateLayout.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/validateLayout.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/validateModelFields.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/validateModelFields.js +2 -2
- package/crud/contentModel/validateModelFields.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel.crud.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel.crud.js +14 -12
- package/crud/contentModel.crud.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.js +5 -5
- package/crud/contentModelGroup/beforeCreate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.js +1 -1
- package/crud/contentModelGroup/beforeDelete.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.js +1 -1
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup.crud.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModelGroup.crud.js +15 -13
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/crud/index.d.ts +6 -0
- package/{content/plugins/crud → crud}/index.js +5 -17
- package/crud/index.js.map +1 -0
- package/{plugins/crud → crud}/settings.crud.d.ts +1 -1
- package/{plugins/crud → crud}/settings.crud.js +3 -7
- package/crud/settings.crud.js.map +1 -0
- package/{plugins/crud → crud}/system.crud.d.ts +1 -1
- package/{plugins/crud → crud}/system.crud.js +0 -0
- package/{plugins/crud → crud}/system.crud.js.map +0 -0
- package/{content/plugins → graphql}/buildSchemaPlugins.d.ts +2 -3
- package/graphql/buildSchemaPlugins.js +27 -0
- package/graphql/buildSchemaPlugins.js.map +1 -0
- package/graphql/graphQLHandlerFactory.d.ts +5 -0
- package/{content → graphql}/graphQLHandlerFactory.js +26 -18
- package/graphql/graphQLHandlerFactory.js.map +1 -0
- package/graphql/index.d.ts +5 -0
- package/graphql/index.js +57 -0
- package/graphql/index.js.map +1 -0
- package/graphql/schema/baseContentSchema.d.ts +3 -0
- package/{content/plugins/schema/baseSchema.js → graphql/schema/baseContentSchema.js} +3 -27
- package/graphql/schema/baseContentSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +3 -0
- package/{content/plugins → graphql}/schema/contentEntries.js +5 -58
- package/graphql/schema/contentEntries.js.map +1 -0
- package/graphql/schema/contentModelGroups.d.ts +3 -0
- package/{content/plugins → graphql}/schema/contentModelGroups.js +27 -11
- package/graphql/schema/contentModelGroups.js.map +1 -0
- package/graphql/schema/contentModels.d.ts +3 -0
- package/{content/plugins → graphql}/schema/contentModels.js +13 -7
- package/graphql/schema/contentModels.js.map +1 -0
- package/{content/plugins → graphql}/schema/createFieldResolvers.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createFieldResolvers.js +1 -1
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/{content/plugins → graphql}/schema/createManageResolvers.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createManageResolvers.js +7 -3
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/{content/plugins → graphql}/schema/createManageSDL.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createManageSDL.js +11 -7
- package/graphql/schema/createManageSDL.js.map +1 -0
- package/{content/plugins → graphql}/schema/createPreviewResolvers.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createPreviewResolvers.js +2 -2
- package/graphql/schema/createPreviewResolvers.js.map +1 -0
- package/{content/plugins → graphql}/schema/createReadResolvers.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createReadResolvers.js +2 -2
- package/graphql/schema/createReadResolvers.js.map +1 -0
- package/{content/plugins → graphql}/schema/createReadSDL.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createReadSDL.js +6 -6
- package/graphql/schema/createReadSDL.js.map +1 -0
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +6 -0
- package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGet.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGet.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGet.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveList.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveList.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveList.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRepublish.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRepublish.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRepublish.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js.map +0 -0
- package/{content/plugins/schema/resolvers/read → graphql/schema/resolvers/preview}/resolveGet.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveGet.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveGet.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveList.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveList.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveList.js.map +0 -0
- package/{content/plugins/schema/resolvers/preview → graphql/schema/resolvers/read}/resolveGet.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/read/resolveGet.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveGet.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.js.map +0 -0
- package/{content/plugins → graphql}/schema/schemaPlugins.d.ts +1 -1
- package/{content/plugins → graphql}/schema/schemaPlugins.js +18 -5
- package/graphql/schema/schemaPlugins.js.map +1 -0
- package/graphql/system.d.ts +6 -0
- package/graphql/system.js +119 -0
- package/graphql/system.js.map +1 -0
- package/graphqlFields/boolean.d.ts +2 -0
- package/graphqlFields/boolean.js +69 -0
- package/graphqlFields/boolean.js.map +1 -0
- package/graphqlFields/datetime.d.ts +2 -0
- package/{content/plugins/graphqlFields → graphqlFields}/datetime.js +42 -40
- package/graphqlFields/datetime.js.map +1 -0
- package/graphqlFields/file.d.ts +2 -0
- package/graphqlFields/file.js +50 -0
- package/graphqlFields/file.js.map +1 -0
- package/{content/plugins/graphqlFields → graphqlFields}/helpers.d.ts +1 -1
- package/{content/plugins/graphqlFields → graphqlFields}/helpers.js +0 -0
- package/{content/plugins/graphqlFields → graphqlFields}/helpers.js.map +0 -0
- package/graphqlFields/index.d.ts +2 -0
- package/graphqlFields/index.js +28 -0
- package/graphqlFields/index.js.map +1 -0
- package/graphqlFields/longText.d.ts +2 -0
- package/graphqlFields/longText.js +63 -0
- package/graphqlFields/longText.js.map +1 -0
- package/graphqlFields/number.d.ts +2 -0
- package/graphqlFields/number.js +75 -0
- package/graphqlFields/number.js.map +1 -0
- package/graphqlFields/object.d.ts +2 -0
- package/graphqlFields/object.js +225 -0
- package/graphqlFields/object.js.map +1 -0
- package/graphqlFields/ref.d.ts +2 -0
- package/graphqlFields/ref.js +279 -0
- package/graphqlFields/ref.js.map +1 -0
- package/graphqlFields/richText.d.ts +2 -0
- package/graphqlFields/richText.js +56 -0
- package/graphqlFields/richText.js.map +1 -0
- package/graphqlFields/text.d.ts +2 -0
- package/graphqlFields/text.js +73 -0
- package/graphqlFields/text.js.map +1 -0
- package/index.d.ts +10 -17
- package/index.js +73 -56
- package/index.js.map +1 -1
- package/modelManager/DefaultCmsModelManager.d.ts +14 -0
- package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js +0 -0
- package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js.map +0 -0
- package/modelManager/index.d.ts +2 -0
- package/{content/plugins/modelManager → modelManager}/index.js +3 -3
- package/modelManager/index.js.map +1 -0
- package/package.json +26 -27
- package/parameters/context.d.ts +2 -0
- package/parameters/context.js +22 -0
- package/parameters/context.js.map +1 -0
- package/parameters/header.d.ts +2 -0
- package/parameters/header.js +55 -0
- package/parameters/header.js.map +1 -0
- package/parameters/index.d.ts +4 -0
- package/parameters/index.js +57 -0
- package/parameters/index.js.map +1 -0
- package/parameters/manual.d.ts +6 -0
- package/{plugins/context.js → parameters/manual.js} +27 -27
- package/parameters/manual.js.map +1 -0
- package/parameters/path.d.ts +2 -0
- package/parameters/path.js +54 -0
- package/parameters/path.js.map +1 -0
- package/{content/plugins → plugins}/CmsGroupPlugin.d.ts +1 -1
- package/{content/plugins → plugins}/CmsGroupPlugin.js +0 -0
- package/{content/plugins → plugins}/CmsGroupPlugin.js.map +0 -0
- package/{content/plugins → plugins}/CmsModelPlugin.d.ts +1 -1
- package/{content/plugins → plugins}/CmsModelPlugin.js +0 -0
- package/{content/plugins → plugins}/CmsModelPlugin.js.map +0 -0
- package/{content/plugins → plugins}/CmsParametersPlugin.d.ts +8 -3
- package/{content/plugins → plugins}/CmsParametersPlugin.js +0 -0
- package/plugins/CmsParametersPlugin.js.map +1 -0
- package/{content/plugins/storage → plugins}/StorageTransformPlugin.d.ts +2 -1
- package/{content/plugins/storage → plugins}/StorageTransformPlugin.js +1 -0
- package/plugins/StorageTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +4 -0
- package/plugins/index.js +57 -0
- package/plugins/index.js.map +1 -0
- package/storage/default.d.ts +2 -0
- package/storage/default.js +27 -0
- package/storage/default.js.map +1 -0
- package/storage/object.d.ts +2 -0
- package/{content/plugins/storage → storage}/object.js +63 -64
- package/storage/object.js.map +1 -0
- package/types.d.ts +28 -3
- package/types.js.map +1 -1
- package/upgrades/index.d.ts +1 -0
- package/upgrades/index.js +10 -0
- package/upgrades/index.js.map +1 -0
- package/utils/access.d.ts +8 -0
- package/utils/access.js +90 -0
- package/utils/access.js.map +1 -0
- package/{content/plugins/utils → utils}/createTypeName.d.ts +0 -0
- package/{content/plugins/utils → utils}/createTypeName.js +0 -0
- package/{content/plugins/utils → utils}/createTypeName.js.map +0 -0
- package/{content/plugins/utils → utils}/entryStorage.d.ts +1 -1
- package/{content/plugins/utils → utils}/entryStorage.js +1 -1
- package/utils/entryStorage.js.map +1 -0
- package/utils/filterAsync.d.ts +1 -0
- package/utils/filterAsync.js +23 -0
- package/utils/filterAsync.js.map +1 -0
- package/{content/plugins/utils → utils}/getEntryTitle.d.ts +1 -1
- package/{content/plugins/utils → utils}/getEntryTitle.js +0 -0
- package/{content/plugins/utils → utils}/getEntryTitle.js.map +0 -0
- package/{content/plugins/utils → utils}/getSchemaFromFieldPlugins.d.ts +1 -1
- package/{content/plugins/utils → utils}/getSchemaFromFieldPlugins.js +0 -0
- package/{content/plugins/utils → utils}/getSchemaFromFieldPlugins.js.map +0 -0
- package/utils/ownership.d.ts +8 -0
- package/utils/ownership.js +39 -0
- package/utils/ownership.js.map +1 -0
- package/utils/permissions.d.ts +7 -0
- package/utils/permissions.js +110 -0
- package/utils/permissions.js.map +1 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.d.ts +0 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.js +0 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.js.map +0 -0
- package/{content/plugins/utils → utils}/renderFields.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderFields.js +0 -0
- package/{content/plugins/utils → utils}/renderFields.js.map +0 -0
- package/{content/plugins/utils → utils}/renderGetFilterFields.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderGetFilterFields.js +0 -0
- package/{content/plugins/utils → utils}/renderGetFilterFields.js.map +0 -0
- package/{content/plugins/utils → utils}/renderInputFields.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderInputFields.js +0 -0
- package/{content/plugins/utils → utils}/renderInputFields.js.map +0 -0
- package/{content/plugins/utils → utils}/renderListFilterFields.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderListFilterFields.js +0 -0
- package/{content/plugins/utils → utils}/renderListFilterFields.js.map +0 -0
- package/{content/plugins/utils → utils}/renderSortEnum.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderSortEnum.js +0 -0
- package/{content/plugins/utils → utils}/renderSortEnum.js.map +0 -0
- package/utils/toSlug.d.ts +1 -0
- package/utils/toSlug.js +20 -0
- package/utils/toSlug.js.map +1 -0
- package/validators/dateGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateGte.js +3 -3
- package/validators/dateGte.js.map +1 -0
- package/validators/dateLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateLte.js +3 -3
- package/validators/dateLte.js.map +1 -0
- package/validators/gte.d.ts +2 -0
- package/validators/gte.js +36 -0
- package/validators/gte.js.map +1 -0
- package/validators/in.d.ts +2 -0
- package/validators/in.js +36 -0
- package/validators/in.js.map +1 -0
- package/validators/index.d.ts +1 -0
- package/validators/index.js +36 -0
- package/validators/index.js.map +1 -0
- package/validators/lte.d.ts +2 -0
- package/validators/lte.js +36 -0
- package/validators/lte.js.map +1 -0
- package/validators/maxLength.d.ts +2 -0
- package/validators/maxLength.js +36 -0
- package/validators/maxLength.js.map +1 -0
- package/validators/minLength.d.ts +2 -0
- package/validators/minLength.js +36 -0
- package/validators/minLength.js.map +1 -0
- package/validators/pattern.d.ts +2 -0
- package/validators/pattern.js +50 -0
- package/validators/pattern.js.map +1 -0
- package/validators/patternPlugins/email.d.ts +2 -0
- package/validators/patternPlugins/email.js +20 -0
- package/validators/patternPlugins/email.js.map +1 -0
- package/validators/patternPlugins/index.d.ts +2 -0
- package/validators/patternPlugins/index.js +24 -0
- package/validators/patternPlugins/index.js.map +1 -0
- package/validators/patternPlugins/lowerCase.d.ts +2 -0
- package/validators/patternPlugins/lowerCase.js +20 -0
- package/validators/patternPlugins/lowerCase.js.map +1 -0
- package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/lowerCaseSpace.js +20 -0
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
- package/validators/patternPlugins/upperCase.d.ts +2 -0
- package/validators/patternPlugins/upperCase.js +20 -0
- package/validators/patternPlugins/upperCase.js.map +1 -0
- package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/upperCaseSpace.js +20 -0
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
- package/validators/patternPlugins/url.d.ts +2 -0
- package/validators/patternPlugins/url.js +20 -0
- package/validators/patternPlugins/url.js.map +1 -0
- package/validators/required.d.ts +2 -0
- package/validators/required.js +27 -0
- package/validators/required.js.map +1 -0
- package/validators/timeGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeGte.js +3 -3
- package/validators/timeGte.js.map +1 -0
- package/validators/timeLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeLte.js +3 -3
- package/validators/timeLte.js.map +1 -0
- package/{content/plugins/validators → validators}/unique.d.ts +2 -3
- package/{content/plugins/validators → validators}/unique.js +3 -3
- package/validators/unique.js.map +1 -0
- package/content/contextSetup.d.ts +0 -4
- package/content/contextSetup.js.map +0 -1
- package/content/graphQLHandlerFactory.d.ts +0 -5
- package/content/graphQLHandlerFactory.js.map +0 -1
- package/content/parameterPlugins.d.ts +0 -6
- package/content/parameterPlugins.js +0 -78
- package/content/parameterPlugins.js.map +0 -1
- package/content/plugins/CmsParametersPlugin.js.map +0 -1
- package/content/plugins/buildSchemaPlugins.js +0 -29
- package/content/plugins/buildSchemaPlugins.js.map +0 -1
- package/content/plugins/crud/contentEntry/entryDataValidation.js.map +0 -1
- package/content/plugins/crud/contentEntry/markLockedFields.js.map +0 -1
- package/content/plugins/crud/contentEntry.crud.js.map +0 -1
- package/content/plugins/crud/contentModel/beforeCreate.js.map +0 -1
- package/content/plugins/crud/contentModel/beforeDelete.js.map +0 -1
- package/content/plugins/crud/contentModel/beforeUpdate.js.map +0 -1
- package/content/plugins/crud/contentModel/createFieldModels.d.ts +0 -2
- package/content/plugins/crud/contentModel/idValidation.d.ts +0 -2
- package/content/plugins/crud/contentModel/idValidation.js.map +0 -1
- package/content/plugins/crud/contentModel/models.js.map +0 -1
- package/content/plugins/crud/contentModel/validateModelFields.js.map +0 -1
- package/content/plugins/crud/contentModel.crud.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/beforeCreate.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/beforeDelete.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/beforeUpdate.js.map +0 -1
- package/content/plugins/crud/contentModelGroup.crud.js.map +0 -1
- package/content/plugins/crud/index.d.ts +0 -6
- package/content/plugins/crud/index.js.map +0 -1
- package/content/plugins/graphqlFields/boolean.d.ts +0 -3
- package/content/plugins/graphqlFields/boolean.js +0 -67
- package/content/plugins/graphqlFields/boolean.js.map +0 -1
- package/content/plugins/graphqlFields/datetime.d.ts +0 -3
- package/content/plugins/graphqlFields/datetime.js.map +0 -1
- package/content/plugins/graphqlFields/file.d.ts +0 -3
- package/content/plugins/graphqlFields/file.js +0 -48
- package/content/plugins/graphqlFields/file.js.map +0 -1
- package/content/plugins/graphqlFields/index.d.ts +0 -2
- package/content/plugins/graphqlFields/index.js +0 -30
- package/content/plugins/graphqlFields/index.js.map +0 -1
- package/content/plugins/graphqlFields/longText.d.ts +0 -3
- package/content/plugins/graphqlFields/longText.js +0 -61
- package/content/plugins/graphqlFields/longText.js.map +0 -1
- package/content/plugins/graphqlFields/number.d.ts +0 -3
- package/content/plugins/graphqlFields/number.js +0 -73
- package/content/plugins/graphqlFields/number.js.map +0 -1
- package/content/plugins/graphqlFields/object.d.ts +0 -3
- package/content/plugins/graphqlFields/object.js +0 -223
- package/content/plugins/graphqlFields/object.js.map +0 -1
- package/content/plugins/graphqlFields/ref.d.ts +0 -3
- package/content/plugins/graphqlFields/ref.js +0 -276
- package/content/plugins/graphqlFields/ref.js.map +0 -1
- package/content/plugins/graphqlFields/richText.d.ts +0 -3
- package/content/plugins/graphqlFields/richText.js +0 -54
- package/content/plugins/graphqlFields/richText.js.map +0 -1
- package/content/plugins/graphqlFields/text.d.ts +0 -3
- package/content/plugins/graphqlFields/text.js +0 -71
- package/content/plugins/graphqlFields/text.js.map +0 -1
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +0 -8
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +0 -55
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js.map +0 -1
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +0 -7
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +0 -36
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js.map +0 -1
- package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +0 -14
- package/content/plugins/modelManager/index.d.ts +0 -3
- package/content/plugins/modelManager/index.js.map +0 -1
- package/content/plugins/schema/baseSchema.d.ts +0 -4
- package/content/plugins/schema/baseSchema.js.map +0 -1
- package/content/plugins/schema/contentEntries.d.ts +0 -4
- package/content/plugins/schema/contentEntries.js.map +0 -1
- package/content/plugins/schema/contentModelGroups.d.ts +0 -4
- package/content/plugins/schema/contentModelGroups.js.map +0 -1
- package/content/plugins/schema/contentModels.d.ts +0 -4
- package/content/plugins/schema/contentModels.js.map +0 -1
- package/content/plugins/schema/createFieldResolvers.js.map +0 -1
- package/content/plugins/schema/createManageResolvers.js.map +0 -1
- package/content/plugins/schema/createManageSDL.js.map +0 -1
- package/content/plugins/schema/createPreviewResolvers.js.map +0 -1
- package/content/plugins/schema/createReadResolvers.js.map +0 -1
- package/content/plugins/schema/createReadSDL.js.map +0 -1
- package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +0 -6
- package/content/plugins/schema/schemaPlugins.js.map +0 -1
- package/content/plugins/storage/StorageTransformPlugin.js.map +0 -1
- package/content/plugins/storage/default.d.ts +0 -3
- package/content/plugins/storage/default.js +0 -28
- package/content/plugins/storage/default.js.map +0 -1
- package/content/plugins/storage/object.d.ts +0 -3
- package/content/plugins/storage/object.js.map +0 -1
- package/content/plugins/utils/entryStorage.js.map +0 -1
- package/content/plugins/validators/dateGte.d.ts +0 -3
- package/content/plugins/validators/dateGte.js.map +0 -1
- package/content/plugins/validators/dateLte.d.ts +0 -3
- package/content/plugins/validators/dateLte.js.map +0 -1
- package/content/plugins/validators/gte.d.ts +0 -3
- package/content/plugins/validators/gte.js +0 -34
- package/content/plugins/validators/gte.js.map +0 -1
- package/content/plugins/validators/in.d.ts +0 -3
- package/content/plugins/validators/in.js +0 -34
- package/content/plugins/validators/in.js.map +0 -1
- package/content/plugins/validators/index.d.ts +0 -2
- package/content/plugins/validators/index.js +0 -38
- package/content/plugins/validators/index.js.map +0 -1
- package/content/plugins/validators/lte.d.ts +0 -3
- package/content/plugins/validators/lte.js +0 -34
- package/content/plugins/validators/lte.js.map +0 -1
- package/content/plugins/validators/maxLength.d.ts +0 -3
- package/content/plugins/validators/maxLength.js +0 -34
- package/content/plugins/validators/maxLength.js.map +0 -1
- package/content/plugins/validators/minLength.d.ts +0 -3
- package/content/plugins/validators/minLength.js +0 -34
- package/content/plugins/validators/minLength.js.map +0 -1
- package/content/plugins/validators/pattern.d.ts +0 -3
- package/content/plugins/validators/pattern.js +0 -47
- package/content/plugins/validators/pattern.js.map +0 -1
- package/content/plugins/validators/patternPlugins/email.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/email.js +0 -17
- package/content/plugins/validators/patternPlugins/email.js.map +0 -1
- package/content/plugins/validators/patternPlugins/index.d.ts +0 -2
- package/content/plugins/validators/patternPlugins/index.js +0 -23
- package/content/plugins/validators/patternPlugins/index.js.map +0 -1
- package/content/plugins/validators/patternPlugins/lowerCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/lowerCase.js +0 -17
- package/content/plugins/validators/patternPlugins/lowerCase.js.map +0 -1
- package/content/plugins/validators/patternPlugins/lowerCaseSpace.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/lowerCaseSpace.js +0 -17
- package/content/plugins/validators/patternPlugins/lowerCaseSpace.js.map +0 -1
- package/content/plugins/validators/patternPlugins/upperCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/upperCase.js +0 -17
- package/content/plugins/validators/patternPlugins/upperCase.js.map +0 -1
- package/content/plugins/validators/patternPlugins/upperCaseSpace.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/upperCaseSpace.js +0 -17
- package/content/plugins/validators/patternPlugins/upperCaseSpace.js.map +0 -1
- package/content/plugins/validators/patternPlugins/url.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/url.js +0 -17
- package/content/plugins/validators/patternPlugins/url.js.map +0 -1
- package/content/plugins/validators/required.d.ts +0 -3
- package/content/plugins/validators/required.js +0 -25
- package/content/plugins/validators/required.js.map +0 -1
- package/content/plugins/validators/timeGte.d.ts +0 -3
- package/content/plugins/validators/timeGte.js.map +0 -1
- package/content/plugins/validators/timeLte.d.ts +0 -3
- package/content/plugins/validators/timeLte.js.map +0 -1
- package/content/plugins/validators/unique.js.map +0 -1
- package/migrateCMSPermissions.d.ts +0 -17
- package/migrateCMSPermissions.js +0 -199
- package/migrateCMSPermissions.js.map +0 -1
- package/plugins/context.d.ts +0 -4
- package/plugins/context.js.map +0 -1
- package/plugins/crud/index.d.ts +0 -6
- package/plugins/crud/index.js +0 -108
- package/plugins/crud/index.js.map +0 -1
- package/plugins/crud/settings.crud.js.map +0 -1
- package/plugins/graphql/system.d.ts +0 -18
- package/plugins/graphql/system.js +0 -74
- package/plugins/graphql/system.js.map +0 -1
- package/plugins/graphql.d.ts +0 -2
- package/plugins/graphql.js +0 -86
- package/plugins/graphql.js.map +0 -1
- package/plugins/upgrades/index.d.ts +0 -2
- package/plugins/upgrades/index.js +0 -14
- package/plugins/upgrades/index.js.map +0 -1
- package/plugins/upgrades/v5.5.0/helpers.d.ts +0 -6
- package/plugins/upgrades/v5.5.0/helpers.js +0 -10
- package/plugins/upgrades/v5.5.0/helpers.js.map +0 -1
- package/plugins/upgrades/v5.5.0/index.d.ts +0 -4
- package/plugins/upgrades/v5.5.0/index.js +0 -134
- package/plugins/upgrades/v5.5.0/index.js.map +0 -1
- package/transformers.d.ts +0 -2
- package/transformers.js +0 -25
- package/transformers.js.map +0 -1
- package/utils.d.ts +0 -23
- package/utils.js +0 -251
- package/utils.js.map +0 -1
|
@@ -9,8 +9,6 @@ exports.graphQLHandlerFactory = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var _boolean = require("boolean");
|
|
13
|
-
|
|
14
12
|
var _schema = require("@graphql-tools/schema");
|
|
15
13
|
|
|
16
14
|
var _apiSecurity = require("@webiny/api-security");
|
|
@@ -19,7 +17,7 @@ var _debugPlugins = _interopRequireDefault(require("@webiny/handler-graphql/debu
|
|
|
19
17
|
|
|
20
18
|
var _processRequestBody = _interopRequireDefault(require("@webiny/handler-graphql/processRequestBody"));
|
|
21
19
|
|
|
22
|
-
var _buildSchemaPlugins =
|
|
20
|
+
var _buildSchemaPlugins = require("./buildSchemaPlugins");
|
|
23
21
|
|
|
24
22
|
var _plugins = require("@webiny/handler-graphql/plugins");
|
|
25
23
|
|
|
@@ -67,7 +65,7 @@ const generateSchema = async args => {
|
|
|
67
65
|
const {
|
|
68
66
|
context
|
|
69
67
|
} = args;
|
|
70
|
-
context.plugins.register(await (0, _buildSchemaPlugins.
|
|
68
|
+
context.plugins.register(await (0, _buildSchemaPlugins.buildSchemaPlugins)(context));
|
|
71
69
|
/**
|
|
72
70
|
* Really hard to type this to satisfy the makeExecutableSchema
|
|
73
71
|
*/
|
|
@@ -87,22 +85,25 @@ const generateSchema = async args => {
|
|
|
87
85
|
typeDefs,
|
|
88
86
|
resolvers
|
|
89
87
|
});
|
|
90
|
-
};
|
|
91
|
-
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Gets an existing schema or rewrites existing one or creates a completely new one
|
|
91
|
+
* depending on the schemaId created from type and locale parameters
|
|
92
|
+
*/
|
|
92
93
|
|
|
93
94
|
|
|
94
|
-
const getSchema = async
|
|
95
|
+
const getSchema = async params => {
|
|
95
96
|
const {
|
|
96
97
|
context,
|
|
97
98
|
type,
|
|
98
99
|
locale
|
|
99
|
-
} =
|
|
100
|
+
} = params;
|
|
100
101
|
const tenantId = context.tenancy.getCurrentTenant().id;
|
|
101
102
|
const id = `${tenantId}#${type}#${locale.code}`;
|
|
102
|
-
const cacheKey = await generateCacheKey(
|
|
103
|
+
const cacheKey = await generateCacheKey(params);
|
|
103
104
|
|
|
104
105
|
if (!schemaList.has(id)) {
|
|
105
|
-
const schema = await generateSchema(
|
|
106
|
+
const schema = await generateSchema(params);
|
|
106
107
|
schemaList.set(id, {
|
|
107
108
|
key: cacheKey,
|
|
108
109
|
schema
|
|
@@ -120,7 +121,7 @@ const getSchema = async args => {
|
|
|
120
121
|
return cache.schema;
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
const schema = await generateSchema(
|
|
124
|
+
const schema = await generateSchema(params);
|
|
124
125
|
schemaList.set(id, {
|
|
125
126
|
key: cacheKey,
|
|
126
127
|
schema
|
|
@@ -140,18 +141,25 @@ const checkEndpointAccess = async context => {
|
|
|
140
141
|
}
|
|
141
142
|
};
|
|
142
143
|
|
|
143
|
-
const graphQLHandlerFactory = (
|
|
144
|
-
|
|
144
|
+
const graphQLHandlerFactory = ({
|
|
145
|
+
debug
|
|
146
|
+
}) => {
|
|
145
147
|
const handler = {
|
|
146
148
|
type: "handler",
|
|
147
|
-
name: "handler
|
|
149
|
+
name: "handler.cms.graphql",
|
|
148
150
|
|
|
149
151
|
async handle(context, next) {
|
|
150
152
|
const {
|
|
151
|
-
http
|
|
153
|
+
http,
|
|
154
|
+
cms
|
|
152
155
|
} = context;
|
|
156
|
+
/**
|
|
157
|
+
* Possibly not a CMS request?
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
const type = cms === null || cms === void 0 ? void 0 : cms.type;
|
|
153
161
|
|
|
154
|
-
if (!
|
|
162
|
+
if (!type || !(http !== null && http !== void 0 && http.request)) {
|
|
155
163
|
return next();
|
|
156
164
|
}
|
|
157
165
|
|
|
@@ -183,8 +191,8 @@ const graphQLHandlerFactory = (options = {}) => {
|
|
|
183
191
|
|
|
184
192
|
const schema = await getSchema({
|
|
185
193
|
context,
|
|
186
|
-
locale:
|
|
187
|
-
type
|
|
194
|
+
locale: cms.getLocale(),
|
|
195
|
+
type
|
|
188
196
|
});
|
|
189
197
|
const body = JSON.parse(http.request.body);
|
|
190
198
|
const result = await (0, _processRequestBody.default)(body, schema, context);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DEFAULT_HEADERS","getWebinyVersionHeaders","DEFAULT_CACHE_MAX_AGE","OPTIONS_HEADERS","respond","http","result","response","body","JSON","stringify","statusCode","headers","schemaList","Map","generateCacheKey","args","context","locale","type","lastModelChange","cms","getModelLastChange","code","toISOString","join","generateSchema","plugins","register","buildSchemaPlugins","typeDefs","resolvers","schemaPlugins","byType","GraphQLSchemaPlugin","pl","push","schema","makeExecutableSchema","getSchema","params","tenantId","tenancy","getCurrentTenant","id","cacheKey","has","set","key","cache","get","checkEndpointAccess","permission","security","getPermission","NotAuthorizedError","data","reason","graphQLHandlerFactory","debug","handler","name","handle","next","request","method","toLowerCase","ex","NotAuthorizedResponse","getLocale","parse","processRequestBody","debugPlugins"],"sources":["graphQLHandlerFactory.ts"],"sourcesContent":["import { GraphQLSchema } from \"graphql\";\nimport { makeExecutableSchema } from \"@graphql-tools/schema\";\nimport { ApiEndpoint, CmsContext } from \"~/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { NotAuthorizedError, NotAuthorizedResponse } from \"@webiny/api-security\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport debugPlugins from \"@webiny/handler-graphql/debugPlugins\";\nimport processRequestBody from \"@webiny/handler-graphql/processRequestBody\";\nimport { buildSchemaPlugins } from \"./buildSchemaPlugins\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport { getWebinyVersionHeaders } from \"@webiny/utils\";\nimport { HttpObject } from \"@webiny/handler-http/types\";\nimport { HandlerPlugin } from \"@webiny/handler/types\";\nimport { GraphQLRequestBody } from \"@webiny/handler-graphql/types\";\n\ninterface SchemaCache {\n key: string;\n schema: GraphQLSchema;\n}\ninterface GetSchemaParams {\n context: CmsContext;\n type: ApiEndpoint;\n locale: I18NLocale;\n}\n\nconst DEFAULT_HEADERS: Record<string, string> = {\n \"Access-Control-Allow-Origin\": \"*\",\n \"Access-Control-Allow-Headers\": \"*\",\n \"Access-Control-Allow-Methods\": \"OPTIONS,POST\",\n \"Content-Type\": \"application/json\",\n ...getWebinyVersionHeaders()\n};\n\nconst DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year\n\nconst OPTIONS_HEADERS: Record<string, string> = {\n \"Access-Control-Max-Age\": `${DEFAULT_CACHE_MAX_AGE}`,\n \"Cache-Control\": `public, max-age=${DEFAULT_CACHE_MAX_AGE}`\n};\n\nconst respond = (http: HttpObject, result: unknown) => {\n return http.response({\n body: JSON.stringify(result),\n statusCode: 200,\n headers: DEFAULT_HEADERS\n });\n};\nconst schemaList = new Map<string, SchemaCache>();\n\nconst generateCacheKey = async (args: GetSchemaParams): Promise<string> => {\n const { context, locale, type } = args;\n const lastModelChange = await context.cms.getModelLastChange();\n return [locale.code, type, lastModelChange.toISOString()].join(\"#\");\n};\n\nconst generateSchema = async (args: GetSchemaParams): Promise<GraphQLSchema> => {\n const { context } = args;\n\n context.plugins.register(await buildSchemaPlugins(context));\n /**\n * Really hard to type this to satisfy the makeExecutableSchema\n */\n // TODO @ts-refactor\n const typeDefs: any = [];\n const resolvers: any = [];\n\n // Get schema definitions from plugins\n const schemaPlugins = context.plugins.byType<GraphQLSchemaPlugin>(GraphQLSchemaPlugin.type);\n for (const pl of schemaPlugins) {\n typeDefs.push(pl.schema.typeDefs);\n resolvers.push(pl.schema.resolvers);\n }\n\n return makeExecutableSchema({\n typeDefs,\n resolvers\n });\n};\n\n/**\n * Gets an existing schema or rewrites existing one or creates a completely new one\n * depending on the schemaId created from type and locale parameters\n */\nconst getSchema = async (params: GetSchemaParams): Promise<GraphQLSchema> => {\n const { context, type, locale } = params;\n const tenantId = context.tenancy.getCurrentTenant().id;\n const id = `${tenantId}#${type}#${locale.code}`;\n\n const cacheKey = await generateCacheKey(params);\n if (!schemaList.has(id)) {\n const schema = await generateSchema(params);\n\n schemaList.set(id, {\n key: cacheKey,\n schema\n });\n return schema;\n }\n /**\n * Safe to cast because check was done few lines up.\n */\n const cache = schemaList.get(id) as SchemaCache;\n if (cache.key === cacheKey) {\n return cache.schema;\n }\n const schema = await generateSchema(params);\n schemaList.set(id, {\n key: cacheKey,\n schema\n });\n return schema;\n};\n\nconst checkEndpointAccess = async (context: CmsContext): Promise<void> => {\n const permission = await context.security.getPermission(`cms.endpoint.${context.cms.type}`);\n if (!permission) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to access \"${context.cms.type}\" endpoint.`\n }\n });\n }\n};\n\nexport interface GraphQLHandlerFactoryParams {\n debug?: boolean;\n}\n\nexport const graphQLHandlerFactory = ({ debug }: GraphQLHandlerFactoryParams): PluginCollection => {\n const handler: HandlerPlugin = {\n type: \"handler\",\n name: \"handler.cms.graphql\",\n async handle(context: CmsContext, next) {\n const { http, cms } = context;\n /**\n * Possibly not a CMS request?\n */\n const type = cms?.type;\n if (!type || !http?.request) {\n return next();\n }\n\n const method = (http.request.method || \"\").toLowerCase();\n /**\n * In case of OPTIONS method we just return the headers since there is no need to go further.\n */\n if (method.toLowerCase() === \"options\") {\n return http.response({\n statusCode: 204,\n headers: {\n ...DEFAULT_HEADERS,\n ...OPTIONS_HEADERS\n }\n });\n }\n /**\n * We expect, and allow, only POST method to access our GraphQL\n */\n if (method !== \"post\") {\n return next();\n }\n\n try {\n await checkEndpointAccess(context);\n } catch (ex) {\n return respond(http, new NotAuthorizedResponse(ex));\n }\n\n const schema = await getSchema({\n context,\n locale: cms.getLocale(),\n type\n });\n\n const body: GraphQLRequestBody | GraphQLRequestBody[] = JSON.parse(http.request.body);\n\n const result = await processRequestBody(body, schema, context);\n return respond(http, result);\n }\n };\n\n return [\n ...(debug ? debugPlugins() : []),\n handler,\n {\n type: \"wcp-telemetry-tracker\"\n }\n ];\n};\n"],"mappings":";;;;;;;;;;;AACA;;AAGA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;AAeA,MAAMA,eAAuC;EACzC,+BAA+B,GADU;EAEzC,gCAAgC,GAFS;EAGzC,gCAAgC,cAHS;EAIzC,gBAAgB;AAJyB,GAKtC,IAAAC,8BAAA,GALsC,CAA7C;;AAQA,MAAMC,qBAAqB,GAAG,QAA9B,C,CAAwC;;AAExC,MAAMC,eAAuC,GAAG;EAC5C,0BAA2B,GAAED,qBAAsB,EADP;EAE5C,iBAAkB,mBAAkBA,qBAAsB;AAFd,CAAhD;;AAKA,MAAME,OAAO,GAAG,CAACC,IAAD,EAAmBC,MAAnB,KAAuC;EACnD,OAAOD,IAAI,CAACE,QAAL,CAAc;IACjBC,IAAI,EAAEC,IAAI,CAACC,SAAL,C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AAC2D,OAAL,CAAaxD,IAAxB,CAAxD;MAEA,MAAMF,MAAM,GAAG,MAAM,IAAAiE,2BAAA,EAAmB/D,IAAnB,EAAyB6B,MAAzB,EAAiCpB,OAAjC,CAArB;MACA,OAAOb,OAAO,CAACC,IAAD,EAAOC,MAAP,CAAd;IACH;;EAjD0B,CAA/B;EAoDA,OAAO,CACH,IAAIqD,KAAK,GAAG,IAAAa,qBAAA,GAAH,GAAoB,EAA7B,CADG,EAEHZ,OAFG,EAGH;IACIzC,IAAI,EAAE;EADV,CAHG,CAAP;AAOH,CA5DM"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/types";
|
|
2
|
+
import { GraphQLHandlerFactoryParams } from "./graphQLHandlerFactory";
|
|
3
|
+
import { CmsContext } from "../types";
|
|
4
|
+
export declare type CreateGraphQLParams = GraphQLHandlerFactoryParams;
|
|
5
|
+
export declare const createGraphQL: (params: CreateGraphQLParams) => (import("@webiny/handler").ContextPlugin<CmsContext> | GraphQLSchemaPlugin<CmsContext> | import("@webiny/plugins/types").PluginCollection)[];
|
package/graphql/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createGraphQL = void 0;
|
|
7
|
+
|
|
8
|
+
var _system = require("./system");
|
|
9
|
+
|
|
10
|
+
var _graphQLHandlerFactory = require("./graphQLHandlerFactory");
|
|
11
|
+
|
|
12
|
+
const createBaseSchema = () => {
|
|
13
|
+
return {
|
|
14
|
+
name: "cms.graphql.schema.base",
|
|
15
|
+
type: "graphql-schema",
|
|
16
|
+
schema: {
|
|
17
|
+
typeDefs:
|
|
18
|
+
/* GraphQL */
|
|
19
|
+
`
|
|
20
|
+
type CmsError {
|
|
21
|
+
code: String
|
|
22
|
+
message: String
|
|
23
|
+
data: JSON
|
|
24
|
+
stack: String
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type CmsCursors {
|
|
28
|
+
next: String
|
|
29
|
+
previous: String
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type CmsListMeta {
|
|
33
|
+
cursor: String
|
|
34
|
+
hasMoreItems: Boolean
|
|
35
|
+
totalCount: Int
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type CmsDeleteResponse {
|
|
39
|
+
data: Boolean
|
|
40
|
+
error: CmsError
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type CmsBooleanResponse {
|
|
44
|
+
data: Boolean
|
|
45
|
+
error: CmsError
|
|
46
|
+
}
|
|
47
|
+
`,
|
|
48
|
+
resolvers: {}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const createGraphQL = params => {
|
|
54
|
+
return [createBaseSchema(), (0, _system.createSystemSchemaPlugin)(), (0, _graphQLHandlerFactory.graphQLHandlerFactory)(params)];
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.createGraphQL = createGraphQL;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createBaseSchema","name","type","schema","typeDefs","resolvers","createGraphQL","params","createSystemSchemaPlugin","graphQLHandlerFactory"],"sources":["index.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { createSystemSchemaPlugin } from \"./system\";\nimport { graphQLHandlerFactory, GraphQLHandlerFactoryParams } from \"./graphQLHandlerFactory\";\nimport { CmsContext } from \"~/types\";\n\nconst createBaseSchema = (): GraphQLSchemaPlugin<CmsContext> => {\n return {\n name: \"cms.graphql.schema.base\",\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type CmsError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type CmsCursors {\n next: String\n previous: String\n }\n\n type CmsListMeta {\n cursor: String\n hasMoreItems: Boolean\n totalCount: Int\n }\n\n type CmsDeleteResponse {\n data: Boolean\n error: CmsError\n }\n\n type CmsBooleanResponse {\n data: Boolean\n error: CmsError\n }\n `,\n resolvers: {}\n }\n };\n};\n\nexport type CreateGraphQLParams = GraphQLHandlerFactoryParams;\nexport const createGraphQL = (params: CreateGraphQLParams) => {\n return [createBaseSchema(), createSystemSchemaPlugin(), graphQLHandlerFactory(params)];\n};\n"],"mappings":";;;;;;;AACA;;AACA;;AAGA,MAAMA,gBAAgB,GAAG,MAAuC;EAC5D,OAAO;IACHC,IAAI,EAAE,yBADH;IAEHC,IAAI,EAAE,gBAFH;IAGHC,MAAM,EAAE;MACJC,QAAQ;MAAE;MAAe;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aA7BgB;MA8BJC,SAAS,EAAE;IA9BP;EAHL,CAAP;AAoCH,CArCD;;AAwCO,MAAMC,aAAa,GAAIC,MAAD,IAAiC;EAC1D,OAAO,CAACP,gBAAgB,EAAjB,EAAqB,IAAAQ,gCAAA,GAArB,EAAiD,IAAAC,4CAAA,EAAsBF,MAAtB,CAAjD,CAAP;AACH,CAFM"}
|
|
@@ -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.createBaseContentSchema = void 0;
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
@@ -17,7 +17,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
17
17
|
|
|
18
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const createBaseContentSchema = context => {
|
|
21
21
|
const scalars = context.plugins.byType("graphql-scalar").map(item => item.scalar);
|
|
22
22
|
return new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
23
23
|
typeDefs:
|
|
@@ -40,29 +40,6 @@ const baseSchema = context => {
|
|
|
40
40
|
_empty: String
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
type CmsError {
|
|
44
|
-
code: String
|
|
45
|
-
message: String
|
|
46
|
-
data: JSON
|
|
47
|
-
stack: String
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
type CmsListMeta {
|
|
51
|
-
cursor: String
|
|
52
|
-
hasMoreItems: Boolean
|
|
53
|
-
totalCount: Int
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
type CmsDeleteResponse {
|
|
57
|
-
data: Boolean
|
|
58
|
-
error: CmsError
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
type CmsBooleanResponse {
|
|
62
|
-
data: Boolean
|
|
63
|
-
error: CmsError
|
|
64
|
-
}
|
|
65
|
-
|
|
66
43
|
type CmsCreatedBy {
|
|
67
44
|
id: String
|
|
68
45
|
displayName: String
|
|
@@ -100,5 +77,4 @@ const baseSchema = context => {
|
|
|
100
77
|
});
|
|
101
78
|
};
|
|
102
79
|
|
|
103
|
-
|
|
104
|
-
exports.default = _default;
|
|
80
|
+
exports.createBaseContentSchema = createBaseContentSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createBaseContentSchema","context","scalars","plugins","byType","map","item","scalar","GraphQLSchemaPlugin","typeDefs","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","Number","NumberScalar","Any","AnyScalar","DateTime","DateTimeScalar","DateTimeZ","DateTimeZScalar","Date","DateScalar","Time","TimeScalar","Mutation","_empty"],"sources":["baseContentSchema.ts"],"sourcesContent":["import { GraphQLScalarPlugin } from \"@webiny/handler-graphql/types\";\nimport { CmsContext } from \"~/types\";\nimport {\n RefInput,\n Number as NumberScalar,\n Any as AnyScalar,\n DateTimeScalar,\n DateScalar,\n TimeScalar,\n LongScalar,\n JsonScalar,\n DateTimeZScalar\n} from \"@webiny/handler-graphql/builtInTypes\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\nimport { GraphQLScalarType } from \"graphql\";\n\nexport const createBaseContentSchema = (context: CmsContext): GraphQLSchemaPlugin => {\n const scalars = context.plugins\n .byType<GraphQLScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n return new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n ${scalars.map(scalar => `scalar ${scalar.name}`).join(\" \")}\n scalar JSON\n scalar Long\n scalar RefInput\n scalar Number\n scalar Any\n scalar Date\n scalar DateTime\n scalar DateTimeZ\n scalar Time\n\n type Query\n\n type Mutation {\n _empty: String\n }\n\n type CmsCreatedBy {\n id: String\n displayName: String\n type: String\n }\n\n type CmsOwnedBy {\n id: String\n displayName: String\n type: String\n }\n\n enum CmsEntryStatusType {\n latest\n published\n }\n `,\n resolvers: {\n ...scalars.reduce((acc, s) => {\n acc[s.name] = s;\n return acc;\n }, {} as Record<string, GraphQLScalarType>),\n JSON: JsonScalar,\n Long: LongScalar,\n RefInput,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n DateTimeZ: DateTimeZScalar,\n Date: DateScalar,\n Time: TimeScalar,\n Mutation: {\n _empty: () => \"_empty\"\n }\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAEA;;AAWA;;;;;;AAGO,MAAMA,uBAAuB,GAAIC,OAAD,IAA8C;EACjF,MAAMC,OAAO,GAAGD,OAAO,CAACE,OAAR,CACXC,MADW,CACiB,gBADjB,EAEXC,GAFW,CAEPC,IAAI,IAAIA,IAAI,CAACC,MAFN,CAAhB;EAIA,OAAO,IAAIC,wCAAJ,CAAwB;IAC3BC,QAAQ;IAAE;IAAe;AACjC,cAAcP,OAAO,CAACG,GAAR,CAAYE,MAAM,IAAK,UAASA,MAAM,CAACG,IAAK,EAA5C,EAA+CC,IAA/C,CAAoD,GAApD,CAAyD;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAnCmC;IAoC3BC,SAAS,kCACFV,OAAO,CAACW,MAAR,CAAe,CAACC,GAAD,EAAMC,CAAN,KAAY;MAC1BD,GAAG,CAACC,CAAC,CAACL,IAAH,CAAH,GAAcK,CAAd;MACA,OAAOD,GAAP;IACH,CAHE,EAGA,EAHA,CADE;MAKLE,IAAI,EAAEC,wBALD;MAMLC,IAAI,EAAEC,wBAND;MAOLC,QAAQ,EAARA,sBAPK;MAQLC,MAAM,EAAEC,oBARH;MASLC,GAAG,EAAEC,iBATA;MAULC,QAAQ,EAAEC,4BAVL;MAWLC,SAAS,EAAEC,6BAXN;MAYLC,IAAI,EAAEC,wBAZD;MAaLC,IAAI,EAAEC,wBAbD;MAcLC,QAAQ,EAAE;QACNC,MAAM,EAAE,MAAM;MADR;IAdL;EApCkB,CAAxB,CAAP;AAuDH,CA5DM"}
|
|
@@ -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.createContentEntriesSchema = void 0;
|
|
9
9
|
|
|
10
10
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
11
11
|
|
|
@@ -13,7 +13,7 @@ var _apiSecurity = require("@webiny/api-security");
|
|
|
13
13
|
|
|
14
14
|
var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
|
|
15
15
|
|
|
16
|
-
var _getEntryTitle = require("
|
|
16
|
+
var _getEntryTitle = require("../../utils/getEntryTitle");
|
|
17
17
|
|
|
18
18
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
19
19
|
|
|
@@ -157,7 +157,7 @@ const getContentEntry = async params => {
|
|
|
157
157
|
});
|
|
158
158
|
};
|
|
159
159
|
|
|
160
|
-
const
|
|
160
|
+
const createContentEntriesSchema = context => {
|
|
161
161
|
if (!context.cms.MANAGE) {
|
|
162
162
|
return new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
163
163
|
typeDefs: "",
|
|
@@ -324,59 +324,7 @@ const plugin = context => {
|
|
|
324
324
|
args,
|
|
325
325
|
context,
|
|
326
326
|
type: "exact"
|
|
327
|
-
});
|
|
328
|
-
//
|
|
329
|
-
// const modelsMap = models.reduce((collection, model) => {
|
|
330
|
-
// collection[model.modelId] = model;
|
|
331
|
-
// return collection;
|
|
332
|
-
// }, {} as Record<string, CmsModel>);
|
|
333
|
-
//
|
|
334
|
-
// const argsEntries = args.entries as Pick<CmsEntry, "id" | "modelId">[];
|
|
335
|
-
//
|
|
336
|
-
// const entriesByModel = argsEntries.reduce((collection, ref) => {
|
|
337
|
-
// if (!collection[ref.modelId]) {
|
|
338
|
-
// collection[ref.modelId] = [];
|
|
339
|
-
// } else if (collection[ref.modelId].includes(ref.id)) {
|
|
340
|
-
// return collection;
|
|
341
|
-
// }
|
|
342
|
-
// collection[ref.modelId].push(ref.id);
|
|
343
|
-
// return collection;
|
|
344
|
-
// }, {} as EntriesByModel);
|
|
345
|
-
//
|
|
346
|
-
// const getters: Promise<CmsEntry[]>[] = Object.keys(entriesByModel).map(
|
|
347
|
-
// async modelId => {
|
|
348
|
-
// return context.cms.getEntriesByIds(
|
|
349
|
-
// modelsMap[modelId],
|
|
350
|
-
// entriesByModel[modelId]
|
|
351
|
-
// );
|
|
352
|
-
// }
|
|
353
|
-
// );
|
|
354
|
-
//
|
|
355
|
-
// if (getters.length === 0) {
|
|
356
|
-
// return new Response([]);
|
|
357
|
-
// }
|
|
358
|
-
//
|
|
359
|
-
// const results = await Promise.all(getters);
|
|
360
|
-
//
|
|
361
|
-
// const entries = results.reduce((collection, items) => {
|
|
362
|
-
// return collection.concat(
|
|
363
|
-
// items.map(item => {
|
|
364
|
-
// const model = modelsMap[item.modelId];
|
|
365
|
-
//
|
|
366
|
-
// return {
|
|
367
|
-
// id: item.id,
|
|
368
|
-
// model: {
|
|
369
|
-
// modelId: model.modelId,
|
|
370
|
-
// name: model.name
|
|
371
|
-
// },
|
|
372
|
-
// status: item.status,
|
|
373
|
-
// title: getEntryTitle(model, item)
|
|
374
|
-
// };
|
|
375
|
-
// })
|
|
376
|
-
// );
|
|
377
|
-
// }, [] as any[]);
|
|
378
|
-
//
|
|
379
|
-
// return new Response(entries);
|
|
327
|
+
});
|
|
380
328
|
},
|
|
381
329
|
|
|
382
330
|
async getLatestContentEntries(_, args, context) {
|
|
@@ -400,5 +348,4 @@ const plugin = context => {
|
|
|
400
348
|
});
|
|
401
349
|
};
|
|
402
350
|
|
|
403
|
-
|
|
404
|
-
exports.default = _default;
|
|
351
|
+
exports.createContentEntriesSchema = createContentEntriesSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getFetchMethod","type","context","getContentEntriesMethods","WebinyError","methodName","cms","GetContentEntryMethods","latest","published","exact","getContentEntries","params","args","method","models","listModels","modelsMap","reduce","collection","model","modelId","argsEntries","entries","entriesByModel","ref","includes","id","push","getters","Object","keys","map","length","Response","results","Promise","all","items","concat","item","entryId","name","status","title","getEntryTitle","filter","Boolean","getContentEntry","entry","find","m","NotAuthorizedResponse","data","result","shift","createContentEntriesSchema","MANAGE","GraphQLSchemaPlugin","typeDefs","resolvers","CmsContentEntry","parent","_","getPublishedEntriesByIds","ex","Query","searchContentEntries","modelIds","fields","query","limit","modelManager","getModelManager","where","listLatest","search","undefined","savedOn","then","sort","a","b","Date","parse","slice","getLatestContentEntry","getPublishedContentEntry","getLatestContentEntries","getPublishedContentEntries"],"sources":["contentEntries.ts"],"sourcesContent":["import { Response } from \"@webiny/handler-graphql\";\nimport { CmsEntry, CmsContext, CmsModel, CmsEntryListWhere } from \"~/types\";\nimport { NotAuthorizedResponse } from \"@webiny/api-security\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle\";\nimport WebinyError from \"@webiny/error\";\n\ninterface EntriesByModel {\n [key: string]: string[];\n}\n\ntype GetContentEntryType = \"latest\" | \"published\" | \"exact\";\n\ninterface CmsEntryRecord {\n id: string;\n entryId: string;\n model: {\n modelId: string;\n name: string;\n };\n status: string;\n title: string;\n}\n\ninterface FetchMethod {\n (model: CmsModel, ids: string[]): Promise<CmsEntry[]>;\n}\n\nconst getFetchMethod = (type: GetContentEntryType, context: CmsContext): FetchMethod => {\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntries method \"${type}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type\n }\n );\n }\n const methodName = getContentEntriesMethods[type] as GetContentEntryMethods;\n if (!context.cms[methodName]) {\n throw new WebinyError(\n `Unknown context.cms method \"${methodName}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type,\n methodName\n }\n );\n }\n\n return context.cms[methodName];\n};\n/**\n * Function to get the list of content entries depending on latest, published or exact GraphQL queries.\n */\ninterface GetContentEntriesParams {\n args: {\n entries: Pick<CmsEntry, \"id\" | \"modelId\">[];\n };\n context: CmsContext;\n type: GetContentEntryType;\n}\nenum GetContentEntryMethods {\n getLatestEntriesByIds = \"getLatestEntriesByIds\",\n getPublishedEntriesByIds = \"getPublishedEntriesByIds\",\n getEntriesByIds = \"getEntriesByIds\"\n}\nconst getContentEntriesMethods = {\n latest: \"getLatestEntriesByIds\",\n published: \"getPublishedEntriesByIds\",\n exact: \"getEntriesByIds\"\n};\nconst getContentEntries = async (params: GetContentEntriesParams): Promise<Response> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const models = await context.cms.listModels();\n\n const modelsMap = models.reduce((collection, model) => {\n collection[model.modelId] = model;\n return collection;\n }, {} as Record<string, CmsModel>);\n\n const argsEntries = args.entries as Pick<CmsEntry, \"id\" | \"modelId\">[];\n\n const entriesByModel = argsEntries.reduce((collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.id)) {\n return collection;\n }\n collection[ref.modelId].push(ref.id);\n return collection;\n }, {} as EntriesByModel);\n\n const getters: Promise<CmsEntry[]>[] = Object.keys(entriesByModel).map(async modelId => {\n return method(modelsMap[modelId], entriesByModel[modelId]);\n });\n\n if (getters.length === 0) {\n return new Response([]);\n }\n\n const results = await Promise.all(getters);\n\n const entries = results\n .reduce((collection, items) => {\n return collection.concat(\n items.map(item => {\n const model = modelsMap[item.modelId];\n\n return {\n id: item.id,\n entryId: item.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: item.status,\n title: getEntryTitle(model, item)\n };\n })\n );\n }, [] as CmsEntryRecord[])\n .filter(Boolean);\n\n return new Response(entries);\n};\n\n/**\n * Function to fetch a single content entry depending on latest, published or exact GraphQL query.\n */\ninterface GetContentEntryParams {\n args: {\n entry: Pick<CmsEntry, \"id\" | \"modelId\">;\n };\n context: CmsContext;\n type: \"latest\" | \"published\" | \"exact\";\n}\nconst getContentEntry = async (\n params: GetContentEntryParams\n): Promise<Response | NotAuthorizedResponse> => {\n const { args, context, type } = params;\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntry method \"${type}\". Could not fetch content entry.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n args,\n type\n }\n );\n }\n\n const method = getFetchMethod(type, context);\n\n const { modelId, id } = args.entry;\n const models = await context.cms.listModels();\n const model = models.find(m => m.modelId === modelId);\n\n if (!model) {\n return new NotAuthorizedResponse({\n data: {\n modelId\n }\n });\n }\n\n const result = await method(model, [id]);\n\n const entry = result.shift();\n if (!entry) {\n return new Response(null);\n }\n\n return new Response({\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry)\n });\n};\n\nexport const createContentEntriesSchema = (\n context: CmsContext\n): GraphQLSchemaPlugin<CmsContext> => {\n if (!context.cms.MANAGE) {\n return new GraphQLSchemaPlugin({\n typeDefs: \"\",\n resolvers: {}\n });\n }\n\n return new GraphQLSchemaPlugin<CmsContext>({\n typeDefs: /* GraphQL */ `\n type CmsModelMeta {\n modelId: String\n name: String\n }\n\n type CmsPublishedContentEntry {\n id: ID!\n entryId: String!\n title: String\n }\n\n type CmsContentEntry {\n id: ID!\n entryId: String!\n model: CmsModelMeta\n status: String\n title: String\n published: CmsPublishedContentEntry\n }\n\n type CmsContentEntriesResponse {\n data: [CmsContentEntry]\n error: CmsError\n }\n\n type CmsContentEntryResponse {\n data: CmsContentEntry\n error: CmsError\n }\n\n input CmsModelEntryInput {\n modelId: ID!\n id: ID!\n }\n\n extend type Query {\n # Search content entries for given content models using the query string.\n searchContentEntries(\n modelIds: [ID!]!\n query: String\n fields: [String!]\n limit: Int\n ): CmsContentEntriesResponse\n\n # Get content entry meta data\n getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse\n\n getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse\n getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse\n\n # Get content entries meta data\n getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse\n getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse\n getPublishedContentEntries(\n entries: [CmsModelEntryInput!]!\n ): CmsContentEntriesResponse\n }\n `,\n resolvers: {\n CmsContentEntry: {\n published: async (parent, _, context) => {\n try {\n const models = await context.cms.listModels();\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const [entry] = await context.cms.getPublishedEntriesByIds(model, [\n parent.id\n ]);\n if (!entry) {\n return null;\n }\n return {\n id: entry.id,\n entryId: entry.entryId,\n title: getEntryTitle(model, entry)\n };\n } catch (ex) {\n return null;\n }\n }\n },\n Query: {\n async searchContentEntries(_, args: any, context) {\n const { modelIds, fields, query, limit = 10 } = args;\n const models = await context.cms.listModels();\n\n const getters = models\n .filter(model => modelIds.includes(model.modelId))\n .map(async model => {\n const modelManager = await context.cms.getModelManager(model.modelId);\n const where: CmsEntryListWhere = {};\n\n const [items] = await modelManager.listLatest({\n limit,\n where,\n search: !!query ? query : undefined,\n fields: fields || []\n });\n\n return items.map((entry: CmsEntry) => {\n return {\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry),\n // We need `savedOn` to sort entries from latest to oldest\n savedOn: entry.savedOn\n };\n });\n });\n\n const entries = await Promise.all(getters).then(results =>\n results.reduce((result, item) => result.concat(item), [])\n );\n\n return new Response(\n entries\n .sort((a, b) => Date.parse(b.savedOn) - Date.parse(a.savedOn))\n .slice(0, limit)\n );\n },\n async getContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"published\"\n });\n },\n async getContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"published\"\n });\n }\n }\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AAuBA,MAAMA,cAAc,GAAG,CAACC,IAAD,EAA4BC,OAA5B,KAAiE;EACpF,IAAI,CAACC,wBAAwB,CAACF,IAAD,CAA7B,EAAqC;IACjC,MAAM,IAAIG,cAAJ,CACD,qCAAoCH,IAAK,qCADxC,EAEF,sBAFE,EAGF;MACIA;IADJ,CAHE,CAAN;EAOH;;EACD,MAAMI,UAAU,GAAGF,wBAAwB,CAACF,IAAD,CAA3C;;EACA,IAAI,CAACC,OAAO,CAACI,GAAR,CAAYD,UAAZ,CAAL,EAA8B;IAC1B,MAAM,IAAID,cAAJ,CACD,+BAA8BC,UAAW,qCADxC,EAEF,sBAFE,EAGF;MACIJ,IADJ;MAEII;IAFJ,CAHE,CAAN;EAQH;;EAED,OAAOH,OAAO,CAACI,GAAR,CAAYD,UAAZ,CAAP;AACH,CAvBD;AAwBA;AACA;AACA;;;IAQKE,sB;;WAAAA,sB;EAAAA,sB;EAAAA,sB;EAAAA,sB;GAAAA,sB,KAAAA,sB;;AAKL,MAAMJ,wBAAwB,GAAG;EAC7BK,MAAM,EAAE,uBADqB;EAE7BC,SAAS,EAAE,0BAFkB;EAG7BC,KAAK,EAAE;AAHsB,CAAjC;;AAKA,MAAMC,iBAAiB,GAAG,MAAOC,MAAP,IAA8D;EACpF,MAAM;IAAEC,IAAF;IAAQX,OAAR;IAAiBD;EAAjB,IAA0BW,MAAhC;EAEA,MAAME,MAAM,GAAGd,cAAc,CAACC,IAAD,EAAOC,OAAP,CAA7B;EAEA,MAAMa,MAAM,GAAG,MAAMb,OAAO,CAACI,GAAR,CAAYU,UAAZ,EAArB;EAEA,MAAMC,SAAS,GAAGF,MAAM,CAACG,MAAP,CAAc,CAACC,UAAD,EAAaC,KAAb,KAAuB;IACnDD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3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createGroupsSchema = void 0;
|
|
7
7
|
|
|
8
8
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
9
9
|
|
|
10
10
|
var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
|
|
11
11
|
|
|
12
|
-
var _CmsGroupPlugin = require("
|
|
12
|
+
var _CmsGroupPlugin = require("../../plugins/CmsGroupPlugin");
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const createGroupsSchema = context => {
|
|
15
15
|
let manageSchema = "";
|
|
16
16
|
|
|
17
17
|
if (context.cms.MANAGE) {
|
|
@@ -65,13 +65,25 @@ const plugin = context => {
|
|
|
65
65
|
context.security.disableAuthorization();
|
|
66
66
|
const models = await context.cms.listModels();
|
|
67
67
|
context.security.enableAuthorization();
|
|
68
|
-
return models.filter(
|
|
68
|
+
return models.filter(model => {
|
|
69
|
+
if (model.isPrivate === true) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return model.group.id === group.id;
|
|
74
|
+
});
|
|
69
75
|
},
|
|
70
76
|
totalContentModels: async (group, _, context) => {
|
|
71
77
|
context.security.disableAuthorization();
|
|
72
78
|
const models = await context.cms.listModels();
|
|
73
79
|
context.security.enableAuthorization();
|
|
74
|
-
return models.filter(
|
|
80
|
+
return models.filter(model => {
|
|
81
|
+
if (model.isPrivate === true) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return model.group === group.id;
|
|
86
|
+
}).length;
|
|
75
87
|
},
|
|
76
88
|
plugin: async (group, _, context) => {
|
|
77
89
|
return context.plugins.byType(_CmsGroupPlugin.CmsGroupPlugin.type).some(item => item.contentModelGroup.id === group.id);
|
|
@@ -83,16 +95,21 @@ const plugin = context => {
|
|
|
83
95
|
const {
|
|
84
96
|
id
|
|
85
97
|
} = args;
|
|
86
|
-
const
|
|
87
|
-
|
|
98
|
+
const group = await context.cms.getGroup(id);
|
|
99
|
+
|
|
100
|
+
if (group !== null && group !== void 0 && group.isPrivate) {
|
|
101
|
+
throw new _handlerGraphql.NotFoundError(`Cms Group "${id}" was not found!`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return new _handlerGraphql.Response(group);
|
|
88
105
|
} catch (e) {
|
|
89
106
|
return new _handlerGraphql.ErrorResponse(e);
|
|
90
107
|
}
|
|
91
108
|
},
|
|
92
109
|
listContentModelGroups: async (_, __, context) => {
|
|
93
110
|
try {
|
|
94
|
-
const
|
|
95
|
-
return new _handlerGraphql.Response(
|
|
111
|
+
const groups = await context.cms.listGroups();
|
|
112
|
+
return new _handlerGraphql.Response(groups.filter(group => group.isPrivate !== true));
|
|
96
113
|
} catch (e) {
|
|
97
114
|
return new _handlerGraphql.ErrorResponse(e);
|
|
98
115
|
}
|
|
@@ -152,5 +169,4 @@ const plugin = context => {
|
|
|
152
169
|
});
|
|
153
170
|
};
|
|
154
171
|
|
|
155
|
-
|
|
156
|
-
exports.default = _default;
|
|
172
|
+
exports.createGroupsSchema = createGroupsSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createGroupsSchema","context","manageSchema","cms","MANAGE","resolvers","CmsContentModelGroup","contentModels","group","_","security","disableAuthorization","models","listModels","enableAuthorization","filter","model","isPrivate","id","totalContentModels","length","plugin","plugins","byType","CmsGroupPlugin","type","some","item","contentModelGroup","Query","getContentModelGroup","args","getGroup","NotFoundError","Response","e","ErrorResponse","listContentModelGroups","__","groups","listGroups","Mutation","createContentModelGroup","createGroup","data","updateContentModelGroup","updateGroup","deleteContentModelGroup","deleteGroup","GraphQLSchemaPlugin","typeDefs"],"sources":["contentModelGroups.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/handler-graphql\";\n\nimport { CmsContext } from \"~/types\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\nimport { Resolvers } from \"@webiny/handler-graphql/types\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\n\nexport const createGroupsSchema = (context: CmsContext): GraphQLSchemaPlugin<CmsContext> => {\n let manageSchema = \"\";\n if (context.cms.MANAGE) {\n manageSchema = /* GraphQL */ `\n input CmsContentModelGroupInput {\n name: String!\n slug: String\n description: String\n icon: String!\n }\n\n type CmsContentModelGroupResponse {\n data: CmsContentModelGroup\n error: CmsError\n }\n\n type CmsContentModelGroupListResponse {\n data: [CmsContentModelGroup]\n meta: CmsListMeta\n error: CmsError\n }\n\n extend type Query {\n getContentModelGroup(id: ID): CmsContentModelGroupResponse\n listContentModelGroups: CmsContentModelGroupListResponse\n }\n\n extend type Mutation {\n createContentModelGroup(\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n updateContentModelGroup(\n id: ID!\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n deleteContentModelGroup(id: ID!): CmsDeleteResponse\n }\n `;\n }\n\n let resolvers: Resolvers<CmsContext> = {};\n\n if (context.cms.MANAGE) {\n resolvers = {\n CmsContentModelGroup: {\n contentModels: async (group, _, context) => {\n context.security.disableAuthorization();\n const models = await context.cms.listModels();\n context.security.enableAuthorization();\n return models.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group.id === group.id;\n });\n },\n totalContentModels: async (group, _, context) => {\n context.security.disableAuthorization();\n const models = await context.cms.listModels();\n context.security.enableAuthorization();\n return models.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.id;\n }).length;\n },\n plugin: async (group, _, context: CmsContext): Promise<boolean> => {\n return context.plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .some(item => item.contentModelGroup.id === group.id);\n }\n },\n Query: {\n getContentModelGroup: async (_, args: any, context) => {\n try {\n const { id } = args;\n const group = await context.cms.getGroup(id);\n if (group?.isPrivate) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listContentModelGroups: async (_, __, context) => {\n try {\n const groups = await context.cms.listGroups();\n return new Response(groups.filter(group => group.isPrivate !== true));\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n Mutation: {\n createContentModelGroup: async (_, args: any, context) => {\n try {\n const model = await context.cms.createGroup(args.data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n updateContentModelGroup: async (_, args: any, context) => {\n try {\n const group = await context.cms.updateGroup(args.id, args.data);\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n deleteContentModelGroup: async (_, args: any, context) => {\n try {\n await context.cms.deleteGroup(args.id);\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n }\n };\n }\n\n return new GraphQLSchemaPlugin<CmsContext>({\n typeDefs: /* GraphQL */ `\n type CmsContentModelGroup {\n id: ID!\n createdOn: DateTime\n savedOn: DateTime\n name: String!\n contentModels: [CmsContentModel!]\n totalContentModels: Int!\n slug: String!\n description: String\n icon: String\n createdBy: CmsCreatedBy\n\n # Returns true if the content model group is registered via a plugin.\n plugin: Boolean!\n }\n ${manageSchema}\n `,\n resolvers\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAGA;;AAEA;;AAEO,MAAMA,kBAAkB,GAAIC,OAAD,IAA0D;EACxF,IAAIC,YAAY,GAAG,EAAnB;;EACA,IAAID,OAAO,CAACE,GAAR,CAAYC,MAAhB,EAAwB;IACpBF,YAAY;IAAG;IAAe;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SApCQ;EAqCH;;EAED,IAAIG,SAAgC,GAAG,EAAvC;;EAEA,IA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AAJ,CAAkBD,CAAlB,CAAP;UACH;QACJ,CARK;QASNU,uBAAuB,EAAE,OAAOpC,CAAP,EAAUsB,IAAV,EAAqB9B,OAArB,KAAiC;UACtD,IAAI;YACA,MAAMO,KAAK,GAAG,MAAMP,OAAO,CAACE,GAAR,CAAY2C,WAAZ,CAAwBf,IAAI,CAACb,EAA7B,EAAiCa,IAAI,CAACa,IAAtC,CAApB;YACA,OAAO,IAAIV,wBAAJ,CAAa1B,KAAb,CAAP;UACH,CAHD,CAGE,OAAO2B,CAAP,EAAU;YACR,OAAO,IAAIC,6BAAJ,CAAkBD,CAAlB,CAAP;UACH;QACJ,CAhBK;QAiBNY,uBAAuB,EAAE,OAAOtC,CAAP,EAAUsB,IAAV,EAAqB9B,OAArB,KAAiC;UACtD,IAAI;YACA,MAAMA,OAAO,CAACE,GAAR,CAAY6C,WAAZ,CAAwBjB,IAAI,CAACb,EAA7B,CAAN;YACA,OAAO,IAAIgB,wBAAJ,CAAa,IAAb,CAAP;UACH,CAHD,CAGE,OAAOC,CAAP,EAAU;YACR,OAAO,IAAIC,6BAAJ,CAAkBD,CAAlB,CAAP;UACH;QACJ;MAxBK;IApDF,CAAZ;EA+EH;;EAED,OAAO,IAAIc,wCAAJ,CAAoC;IACvCC,QAAQ;IAAE;IAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAchD,YAAa;AAC3B,SAlB+C;IAmBvCG;EAnBuC,CAApC,CAAP;AAqBH,CAnJM"}
|
|
@@ -3,20 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createModelsSchema = void 0;
|
|
7
7
|
|
|
8
8
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
9
9
|
|
|
10
10
|
var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
|
|
11
11
|
|
|
12
|
-
var _CmsModelPlugin = require("
|
|
12
|
+
var _CmsModelPlugin = require("../../plugins/CmsModelPlugin");
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const createModelsSchema = context => {
|
|
15
15
|
const resolvers = {
|
|
16
16
|
Query: {
|
|
17
17
|
getContentModel: async (_, args, context) => {
|
|
18
18
|
try {
|
|
19
19
|
const model = await context.cms.getModel(args.modelId);
|
|
20
|
+
|
|
21
|
+
if ((model === null || model === void 0 ? void 0 : model.isPrivate) === true) {
|
|
22
|
+
if (!model) {
|
|
23
|
+
throw new _handlerGraphql.NotFoundError(`Content model "${args.modelId}" was not found!`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
return new _handlerGraphql.Response(model);
|
|
21
28
|
} catch (e) {
|
|
22
29
|
return new _handlerGraphql.ErrorResponse(e);
|
|
@@ -24,8 +31,8 @@ const plugin = context => {
|
|
|
24
31
|
},
|
|
25
32
|
listContentModels: async (_, __, context) => {
|
|
26
33
|
try {
|
|
27
|
-
const
|
|
28
|
-
return new _handlerGraphql.Response(model);
|
|
34
|
+
const models = await context.cms.listModels();
|
|
35
|
+
return new _handlerGraphql.Response(models.filter(model => model.isPrivate !== true));
|
|
29
36
|
} catch (e) {
|
|
30
37
|
return new _handlerGraphql.ErrorResponse(e);
|
|
31
38
|
}
|
|
@@ -246,5 +253,4 @@ const plugin = context => {
|
|
|
246
253
|
});
|
|
247
254
|
};
|
|
248
255
|
|
|
249
|
-
|
|
250
|
-
exports.default = _default;
|
|
256
|
+
exports.createModelsSchema = createModelsSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createModelsSchema","context","resolvers","Query","getContentModel","_","args","model","cms","getModel","modelId","isPrivate","NotFoundError","Response","e","ErrorResponse","listContentModels","__","models","listModels","filter","CmsContentModel","plugin","plugins","byType","CmsModelPlugin","type","some","item","contentModel","manageSchema","MANAGE","createContentModel","createModel","data","createContentModelFrom","createModelFrom","updateContentModel","updateModel","deleteContentModel","deleteModel","GraphQLSchemaPlugin","typeDefs"],"sources":["contentModels.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/handler-graphql\";\nimport { CmsContext } from \"~/types\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\nimport { Resolvers } from \"@webiny/handler-graphql/types\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\n\nexport const createModelsSchema = (context: CmsContext): GraphQLSchemaPlugin<CmsContext> => {\n const resolvers: Resolvers<CmsContext> = {\n Query: {\n getContentModel: async (_: unknown, args: any, context) => {\n try {\n const model = await context.cms.getModel(args.modelId);\n if (model?.isPrivate === true) {\n if (!model) {\n throw new NotFoundError(\n `Content model \"${args.modelId}\" was not found!`\n );\n }\n }\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listContentModels: async (_: unknown, __: unknown, context: CmsContext) => {\n try {\n const models = await context.cms.listModels();\n return new Response(models.filter(model => model.isPrivate !== true));\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n CmsContentModel: {\n plugin: async (model, _, context): Promise<boolean> => {\n return context.plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n .some(item => item.contentModel.modelId === model.modelId);\n }\n }\n };\n\n let manageSchema = \"\";\n if (context.cms.MANAGE) {\n resolvers[\"Mutation\"] = {\n createContentModel: async (_: unknown, args: any, context) => {\n try {\n const model = await context.cms.createModel(args.data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n createContentModelFrom: async (_: unknown, args: any, context) => {\n try {\n const model = await context.cms.createModelFrom(args.modelId, args.data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n updateContentModel: async (_: unknown, args: any, context) => {\n const { modelId, data } = args;\n try {\n const model = await context.cms.updateModel(modelId, data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n deleteContentModel: async (_: unknown, args: any, context) => {\n const { modelId } = args;\n try {\n await context.cms.deleteModel(modelId);\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n };\n\n manageSchema = /* GraphQL */ `\n input CmsPredefinedValueInput {\n label: String!\n value: String!\n selected: Boolean\n }\n\n input CmsPredefinedValuesInput {\n enabled: Boolean\n values: [CmsPredefinedValueInput]\n }\n input CmsFieldRendererInput {\n name: String\n }\n\n input CmsFieldValidationInput {\n name: String!\n message: String\n settings: JSON\n }\n\n input CmsContentModelFieldInput {\n id: ID!\n label: String!\n helpText: String\n placeholderText: String\n fieldId: String!\n type: String!\n multipleValues: Boolean\n predefinedValues: CmsPredefinedValuesInput\n renderer: CmsFieldRendererInput\n validation: [CmsFieldValidationInput]\n listValidation: [CmsFieldValidationInput]\n settings: JSON\n }\n\n input CmsContentModelCreateInput {\n name: String!\n modelId: String\n group: RefInput!\n description: String\n layout: [[ID!]!]\n fields: [CmsContentModelFieldInput!]\n titleFieldId: String\n }\n\n input CmsContentModelCreateFromInput {\n name: String!\n modelId: String\n group: RefInput!\n description: String\n locale: String\n }\n\n input CmsContentModelUpdateInput {\n name: String\n group: RefInput\n description: String\n layout: [[ID!]!]!\n fields: [CmsContentModelFieldInput!]!\n titleFieldId: String\n }\n\n extend type Mutation {\n createContentModel(data: CmsContentModelCreateInput!): CmsContentModelResponse\n\n createContentModelFrom(\n modelId: ID!\n data: CmsContentModelCreateFromInput!\n ): CmsContentModelResponse\n\n updateContentModel(\n modelId: ID!\n data: CmsContentModelUpdateInput!\n ): CmsContentModelResponse\n\n deleteContentModel(modelId: ID!): CmsDeleteResponse\n }\n `;\n }\n\n return new GraphQLSchemaPlugin<CmsContext>({\n typeDefs: /* GraphQL */ `\n type CmsFieldValidation {\n name: String!\n message: String\n settings: JSON\n }\n\n type CmsFieldRenderer {\n name: String\n }\n\n type CmsPredefinedValue {\n label: String\n value: String\n selected: Boolean\n }\n\n type CmsPredefinedValues {\n enabled: Boolean\n values: [CmsPredefinedValue]\n }\n\n type CmsContentModelField {\n id: ID!\n fieldId: String!\n label: String!\n helpText: String\n placeholderText: String\n type: String!\n multipleValues: Boolean\n predefinedValues: CmsPredefinedValues\n renderer: CmsFieldRenderer\n validation: [CmsFieldValidation!]\n listValidation: [CmsFieldValidation!]\n settings: JSON\n }\n\n type CmsContentModel {\n name: String!\n modelId: String!\n description: String\n group: CmsContentModelGroup!\n createdOn: DateTime\n savedOn: DateTime\n createdBy: CmsCreatedBy\n fields: [CmsContentModelField!]!\n lockedFields: [JSON]\n layout: [[String!]!]!\n titleFieldId: String\n\n # Returns true if the content model is registered via a plugin.\n plugin: Boolean!\n }\n\n type CmsContentModelResponse {\n data: CmsContentModel\n error: CmsError\n }\n\n type CmsContentModelListResponse {\n data: [CmsContentModel]\n meta: CmsListMeta\n error: CmsError\n }\n\n extend type Query {\n getContentModel(modelId: ID!, where: JSON, sort: String): CmsContentModelResponse\n\n listContentModels: CmsContentModelListResponse\n }\n\n ${manageSchema}\n `,\n resolvers\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AAEO,MAAMA,kBAAkB,GAAIC,OAAD,IAA0D;EACxF,MAAMC,SAAgC,GAAG;IACrCC,KAAK,EAAE;MACHC,eAAe,EAAE,OAAOC,CAAP,EAAmBC,IAAnB,EAA8BL,OAA9B,KAA0C;QACvD,IAAI;UACA,MAAMM,KAAK,GAAG,MAAMN,OAAO,CAACO,GAAR,CAAYC,QAAZ,CAAqBH,IAAI,CAACI,OAA1B,CAApB;;UACA,IAAI,CAAAH,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEI,SAAP,MAAqB,IAAzB,EAA+B;YAC3B,IAAI,CAACJ,KAAL,EAAY;cACR,MAAM,IAAIK,6BAAJ,CACD,kBAAiBN,IAAI,CAACI,OAAQ,kBAD7B,CAAN;YAGH;UACJ;;UACD,OAAO,IAAIG,wBAAJ,CAAaN,KAAb,CAAP;QACH,CAV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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SA9EQ;EA+EH;;EAED,OAAO,IAAIW,wCAAJ,CAAoC;IACvCC,QAAQ;IAAE;IAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcZ,YAAa;AAC3B,SAzE+C;IA0EvC5B;EA1EuC,CAApC,CAAP;AA4EH,CAxOM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CmsModelField, ApiEndpoint, CmsModel, CmsFieldTypePlugins } from "
|
|
1
|
+
import { CmsModelField, ApiEndpoint, CmsModel, CmsFieldTypePlugins } from "../../types";
|
|
2
2
|
import { Resolvers } from "@webiny/handler-graphql/types";
|
|
3
3
|
interface CreateFieldResolvers {
|
|
4
4
|
graphQLType: string;
|