@webiny/api-headless-cms 0.0.0-mt-3 → 0.0.0-unstable.2af142b57e
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 +6 -0
- package/context.js +94 -0
- package/context.js.map +1 -0
- package/crud/contentEntry/afterDelete.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.js +2 -7
- package/crud/contentEntry/afterDelete.js.map +1 -0
- package/crud/contentEntry/beforeCreate.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.js +2 -5
- package/crud/contentEntry/beforeCreate.js.map +1 -0
- package/crud/contentEntry/beforeUpdate.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.js +2 -5
- package/crud/contentEntry/beforeUpdate.js.map +1 -0
- package/crud/contentEntry/entryDataValidation.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.js +22 -49
- package/crud/contentEntry/entryDataValidation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.d.ts +3 -2
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.js +26 -43
- package/crud/contentEntry/markLockedFields.js.map +1 -0
- package/crud/contentEntry/referenceFieldsMapping.d.ts +13 -0
- package/crud/contentEntry/referenceFieldsMapping.js +236 -0
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -0
- package/crud/contentEntry/searchableFields.d.ts +9 -0
- package/crud/contentEntry/searchableFields.js +72 -0
- package/crud/contentEntry/searchableFields.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry.crud.d.ts +5 -9
- package/crud/contentEntry.crud.js +1194 -0
- package/crud/contentEntry.crud.js.map +1 -0
- package/crud/contentModel/afterCreate.d.ts +8 -0
- package/crud/contentModel/afterCreate.js +16 -0
- package/crud/contentModel/afterCreate.js.map +1 -0
- package/crud/contentModel/afterCreateFrom.d.ts +8 -0
- package/crud/contentModel/afterCreateFrom.js +16 -0
- package/crud/contentModel/afterCreateFrom.js.map +1 -0
- package/crud/contentModel/afterDelete.d.ts +8 -0
- package/crud/contentModel/afterDelete.js +16 -0
- package/crud/contentModel/afterDelete.js.map +1 -0
- package/crud/contentModel/afterUpdate.d.ts +8 -0
- package/crud/contentModel/afterUpdate.js +16 -0
- package/crud/contentModel/afterUpdate.js.map +1 -0
- package/crud/contentModel/beforeCreate.d.ts +14 -0
- package/{content/plugins/crud → crud}/contentModel/beforeCreate.js +58 -39
- package/crud/contentModel/beforeCreate.js.map +1 -0
- package/crud/contentModel/beforeDelete.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.js +13 -19
- package/crud/contentModel/beforeDelete.js.map +1 -0
- package/crud/contentModel/beforeUpdate.d.ts +8 -0
- package/crud/contentModel/beforeUpdate.js +32 -0
- package/crud/contentModel/beforeUpdate.js.map +1 -0
- package/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js +0 -7
- package/crud/contentModel/contentModelManagerFactory.js.map +1 -0
- package/crud/contentModel/createFieldStorageId.d.ts +2 -0
- package/crud/contentModel/createFieldStorageId.js +17 -0
- package/crud/contentModel/createFieldStorageId.js.map +1 -0
- package/crud/contentModel/systemFields.d.ts +1 -0
- package/crud/contentModel/systemFields.js +8 -0
- package/crud/contentModel/systemFields.js.map +1 -0
- package/crud/contentModel/validateLayout.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/validateLayout.js +1 -11
- package/crud/contentModel/validateLayout.js.map +1 -0
- package/crud/contentModel/validateModel.d.ts +8 -0
- package/crud/contentModel/validateModel.js +27 -0
- package/crud/contentModel/validateModel.js.map +1 -0
- package/crud/contentModel/validateModelFields.d.ts +8 -0
- package/crud/contentModel/validateModelFields.js +380 -0
- package/crud/contentModel/validateModelFields.js.map +1 -0
- package/crud/contentModel/validation.d.ts +477 -0
- package/crud/contentModel/validation.js +97 -0
- package/crud/contentModel/validation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel.crud.d.ts +3 -3
- package/crud/contentModel.crud.js +555 -0
- package/crud/contentModel.crud.js.map +1 -0
- package/crud/contentModelGroup/beforeCreate.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.js +8 -20
- package/crud/contentModelGroup/beforeCreate.js.map +1 -0
- package/crud/contentModelGroup/beforeDelete.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.js +4 -12
- package/crud/contentModelGroup/beforeDelete.js.map +1 -0
- package/crud/contentModelGroup/beforeUpdate.d.ts +9 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.js +3 -8
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
- package/crud/contentModelGroup/validation.d.ts +30 -0
- package/crud/contentModelGroup/validation.js +34 -0
- package/crud/contentModelGroup/validation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup.crud.d.ts +3 -3
- package/crud/contentModelGroup.crud.js +324 -0
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/{plugins/crud → crud}/settings.crud.d.ts +3 -3
- package/crud/settings.crud.js +71 -0
- package/crud/settings.crud.js.map +1 -0
- package/{plugins/crud → crud}/system.crud.d.ts +6 -3
- package/crud/system.crud.js +186 -0
- package/crud/system.crud.js.map +1 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +7 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +53 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +203 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +251 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/index.d.ts +4 -0
- package/fieldConverters/index.js +13 -0
- package/fieldConverters/index.js.map +1 -0
- package/graphql/buildSchemaPlugins.d.ts +11 -0
- package/graphql/buildSchemaPlugins.js +19 -0
- package/graphql/buildSchemaPlugins.js.map +1 -0
- package/graphql/createExecutableSchema.d.ts +7 -0
- package/graphql/createExecutableSchema.js +29 -0
- package/graphql/createExecutableSchema.js.map +1 -0
- package/graphql/generateSchema.d.ts +8 -0
- package/graphql/generateSchema.js +31 -0
- package/graphql/generateSchema.js.map +1 -0
- package/graphql/graphQLHandlerFactory.d.ts +5 -0
- package/graphql/graphQLHandlerFactory.js +174 -0
- package/graphql/graphQLHandlerFactory.js.map +1 -0
- package/graphql/index.d.ts +3 -0
- package/graphql/index.js +13 -0
- package/graphql/index.js.map +1 -0
- package/graphql/schema/baseContentSchema.d.ts +7 -0
- package/graphql/schema/baseContentSchema.js +72 -0
- package/graphql/schema/baseContentSchema.js.map +1 -0
- package/graphql/schema/baseSchema.d.ts +3 -0
- package/graphql/schema/baseSchema.js +53 -0
- package/graphql/schema/baseSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +7 -0
- package/graphql/schema/contentEntries.js +325 -0
- package/graphql/schema/contentEntries.js.map +1 -0
- package/graphql/schema/contentModelGroups.d.ts +7 -0
- package/{content/plugins → graphql}/schema/contentModelGroups.js +38 -32
- package/graphql/schema/contentModelGroups.js.map +1 -0
- package/graphql/schema/contentModels.d.ts +7 -0
- package/{content/plugins → graphql}/schema/contentModels.js +101 -28
- package/graphql/schema/contentModels.js.map +1 -0
- package/graphql/schema/createFieldResolvers.d.ts +20 -0
- package/graphql/schema/createFieldResolvers.js +110 -0
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +12 -0
- package/{content/plugins → graphql}/schema/createManageResolvers.js +32 -56
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/graphql/schema/createManageSDL.d.ts +12 -0
- package/{content/plugins → graphql}/schema/createManageSDL.js +31 -33
- package/graphql/schema/createManageSDL.js.map +1 -0
- package/graphql/schema/createPreviewResolvers.d.ts +12 -0
- package/graphql/schema/createPreviewResolvers.js +48 -0
- package/graphql/schema/createPreviewResolvers.js.map +1 -0
- package/graphql/schema/createReadResolvers.d.ts +12 -0
- package/graphql/schema/createReadResolvers.js +53 -0
- package/graphql/schema/createReadResolvers.js.map +1 -0
- package/graphql/schema/createReadSDL.d.ts +12 -0
- package/{content/plugins → graphql}/schema/createReadSDL.js +23 -21
- 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 -2
- package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveCreate.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js +2 -7
- package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +8 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js +2 -7
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveDelete.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js +8 -12
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGet.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveGet.js +63 -0
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js +2 -7
- package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetRevisions.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js +2 -7
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveList.d.ts +4 -0
- package/{content/plugins/schema/resolvers/preview → graphql/schema/resolvers/manage}/resolveList.js +2 -7
- package/graphql/schema/resolvers/manage/resolveList.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolvePublish.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js +0 -3
- package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveRepublish.d.ts +7 -0
- package/{content/plugins/schema/resolvers/manage/resolveGet.js → graphql/schema/resolvers/manage/resolveRepublish.js} +4 -7
- package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveUnpublish.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js +0 -3
- package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +8 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js +2 -7
- package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveGet.d.ts +4 -0
- package/graphql/schema/resolvers/preview/resolveGet.js +26 -0
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveList.d.ts +4 -0
- package/{content/plugins/schema/resolvers/manage → graphql/schema/resolvers/preview}/resolveList.js +2 -7
- package/graphql/schema/resolvers/preview/resolveList.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveGet.d.ts +4 -0
- package/graphql/schema/resolvers/read/resolveGet.js +26 -0
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveList.d.ts +4 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.js +2 -7
- package/graphql/schema/resolvers/read/resolveList.js.map +1 -0
- package/graphql/schema/schemaPlugins.d.ts +8 -0
- package/graphql/schema/schemaPlugins.js +109 -0
- package/graphql/schema/schemaPlugins.js.map +1 -0
- package/graphql/system.d.ts +6 -0
- package/{plugins/graphql → graphql}/system.js +43 -12
- package/graphql/system.js.map +1 -0
- package/graphqlFields/boolean.d.ts +2 -0
- package/graphqlFields/boolean.js +57 -0
- package/graphqlFields/boolean.js.map +1 -0
- package/graphqlFields/datetime.d.ts +2 -0
- package/graphqlFields/datetime.js +78 -0
- package/graphqlFields/datetime.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js +208 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js +63 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
- package/graphqlFields/dynamicZone/index.d.ts +2 -0
- package/graphqlFields/dynamicZone/index.js +19 -0
- package/graphqlFields/dynamicZone/index.js.map +1 -0
- package/graphqlFields/file.d.ts +2 -0
- package/graphqlFields/file.js +42 -0
- package/graphqlFields/file.js.map +1 -0
- package/graphqlFields/helpers.d.ts +6 -0
- package/graphqlFields/helpers.js +39 -0
- package/graphqlFields/helpers.js.map +1 -0
- package/graphqlFields/index.d.ts +2 -0
- package/graphqlFields/index.js +18 -0
- package/graphqlFields/index.js.map +1 -0
- package/graphqlFields/longText.d.ts +2 -0
- package/graphqlFields/longText.js +53 -0
- package/graphqlFields/longText.js.map +1 -0
- package/graphqlFields/number.d.ts +2 -0
- package/graphqlFields/number.js +67 -0
- package/graphqlFields/number.js.map +1 -0
- package/graphqlFields/object.d.ts +2 -0
- package/graphqlFields/object.js +239 -0
- package/graphqlFields/object.js.map +1 -0
- package/graphqlFields/ref.d.ts +2 -0
- package/graphqlFields/ref.js +227 -0
- package/graphqlFields/ref.js.map +1 -0
- package/graphqlFields/richText.d.ts +2 -0
- package/graphqlFields/richText.js +47 -0
- package/graphqlFields/richText.js.map +1 -0
- package/graphqlFields/text.d.ts +2 -0
- package/graphqlFields/text.js +62 -0
- package/graphqlFields/text.js.map +1 -0
- package/index.d.ts +10 -12
- package/index.js +75 -55
- package/index.js.map +1 -0
- package/modelManager/DefaultCmsModelManager.d.ts +14 -0
- package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js +10 -24
- package/modelManager/DefaultCmsModelManager.js.map +1 -0
- package/modelManager/index.d.ts +2 -0
- package/{content/plugins/modelManager → modelManager}/index.js +3 -7
- package/modelManager/index.js.map +1 -0
- package/package.json +38 -38
- package/parameters/context.d.ts +2 -0
- package/parameters/context.js +18 -0
- package/parameters/context.js.map +1 -0
- package/parameters/header.d.ts +2 -0
- package/parameters/header.js +44 -0
- package/parameters/header.js.map +1 -0
- package/parameters/index.d.ts +4 -0
- package/parameters/index.js +49 -0
- package/parameters/index.js.map +1 -0
- package/parameters/manual.d.ts +6 -0
- package/parameters/manual.js +37 -0
- package/parameters/manual.js.map +1 -0
- package/parameters/path.d.ts +2 -0
- package/parameters/path.js +40 -0
- package/parameters/path.js.map +1 -0
- package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
- package/plugins/CmsGraphQLSchemaPlugin.js +12 -0
- package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js +28 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
- package/plugins/CmsGroupPlugin.d.ts +13 -0
- package/{content/plugins → plugins}/CmsGroupPlugin.js +7 -9
- package/plugins/CmsGroupPlugin.js.map +1 -0
- package/plugins/CmsModelFieldConverterPlugin.d.ts +14 -0
- package/plugins/CmsModelFieldConverterPlugin.js +12 -0
- package/plugins/CmsModelFieldConverterPlugin.js.map +1 -0
- package/plugins/CmsModelPlugin.d.ts +45 -0
- package/plugins/CmsModelPlugin.js +158 -0
- package/plugins/CmsModelPlugin.js.map +1 -0
- package/plugins/CmsParametersPlugin.d.ts +20 -0
- package/plugins/CmsParametersPlugin.js +21 -0
- package/plugins/CmsParametersPlugin.js.map +1 -0
- package/plugins/StorageTransformPlugin.d.ts +31 -0
- package/{content/plugins/storage → plugins}/StorageTransformPlugin.js +2 -10
- package/plugins/StorageTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +7 -0
- package/plugins/index.js +82 -0
- package/plugins/index.js.map +1 -0
- package/storage/default.d.ts +2 -0
- package/storage/default.js +24 -0
- package/storage/default.js.map +1 -0
- package/storage/object.d.ts +2 -0
- package/storage/object.js +108 -0
- package/storage/object.js.map +1 -0
- package/types.d.ts +881 -389
- package/types.js +104 -61
- package/types.js.map +1 -0
- package/upgrades/5.33.0/index.d.ts +3 -0
- package/upgrades/5.33.0/index.js +159 -0
- package/upgrades/5.33.0/index.js.map +1 -0
- package/upgrades/index.d.ts +1 -0
- package/upgrades/index.js +9 -0
- package/upgrades/index.js.map +1 -0
- package/utils/access.d.ts +8 -0
- package/utils/access.js +76 -0
- package/utils/access.js.map +1 -0
- package/utils/converters/Converter.d.ts +27 -0
- package/utils/converters/Converter.js +58 -0
- package/utils/converters/Converter.js.map +1 -0
- package/utils/converters/ConverterCollection.d.ts +31 -0
- package/utils/converters/ConverterCollection.js +119 -0
- package/utils/converters/ConverterCollection.js.map +1 -0
- package/utils/converters/valueKeyStorageConverter.d.ts +18 -0
- package/utils/converters/valueKeyStorageConverter.js +122 -0
- package/utils/converters/valueKeyStorageConverter.js.map +1 -0
- package/utils/createTypeFromFields.d.ts +15 -0
- package/utils/createTypeFromFields.js +64 -0
- package/utils/createTypeFromFields.js.map +1 -0
- package/{content/plugins/utils → utils}/createTypeName.d.ts +3 -3
- package/{content/plugins/utils → utils}/createTypeName.js +3 -10
- package/utils/createTypeName.js.map +1 -0
- package/{content/plugins/utils → utils}/entryStorage.d.ts +3 -3
- package/{content/plugins/utils → utils}/entryStorage.js +26 -47
- package/utils/entryStorage.js.map +1 -0
- package/utils/filterAsync.d.ts +1 -0
- package/utils/filterAsync.js +18 -0
- package/utils/filterAsync.js.map +1 -0
- package/utils/getBaseFieldType.d.ts +4 -0
- package/utils/getBaseFieldType.js +10 -0
- package/utils/getBaseFieldType.js.map +1 -0
- package/utils/getEntryTitle.d.ts +2 -0
- package/{content/plugins/utils → utils}/getEntryTitle.js +7 -15
- package/utils/getEntryTitle.js.map +1 -0
- package/utils/getSchemaFromFieldPlugins.d.ts +9 -0
- package/utils/getSchemaFromFieldPlugins.js +39 -0
- package/utils/getSchemaFromFieldPlugins.js.map +1 -0
- package/utils/ownership.d.ts +8 -0
- package/utils/ownership.js +33 -0
- package/utils/ownership.js.map +1 -0
- package/utils/permissions.d.ts +7 -0
- package/utils/permissions.js +91 -0
- package/utils/permissions.js.map +1 -0
- package/utils/pluralizedTypeName.d.ts +1 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.js +1 -7
- package/utils/pluralizedTypeName.js.map +1 -0
- package/utils/renderFields.d.ts +15 -0
- package/{content/plugins/utils → utils}/renderFields.js +6 -11
- package/utils/renderFields.js.map +1 -0
- package/utils/renderGetFilterFields.d.ts +10 -0
- package/utils/renderGetFilterFields.js +48 -0
- package/utils/renderGetFilterFields.js.map +1 -0
- package/utils/renderInputFields.d.ts +14 -0
- package/{content/plugins/utils → utils}/renderInputFields.js +3 -10
- package/utils/renderInputFields.js.map +1 -0
- package/utils/renderListFilterFields.d.ts +11 -0
- package/{content/plugins/utils → utils}/renderListFilterFields.js +36 -22
- package/utils/renderListFilterFields.js.map +1 -0
- package/utils/renderSortEnum.d.ts +12 -0
- package/utils/renderSortEnum.js +42 -0
- package/utils/renderSortEnum.js.map +1 -0
- package/utils/toSlug.d.ts +1 -0
- package/utils/toSlug.js +16 -0
- package/utils/toSlug.js.map +1 -0
- package/validators/dateGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateGte.js +4 -11
- package/validators/dateGte.js.map +1 -0
- package/validators/dateLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateLte.js +4 -11
- package/validators/dateLte.js.map +1 -0
- package/validators/dynamicZone.d.ts +2 -0
- package/validators/dynamicZone.js +20 -0
- package/validators/dynamicZone.js.map +1 -0
- package/validators/gte.d.ts +2 -0
- package/validators/gte.js +28 -0
- package/validators/gte.js.map +1 -0
- package/validators/in.d.ts +2 -0
- package/validators/in.js +28 -0
- package/validators/in.js.map +1 -0
- package/validators/index.d.ts +1 -0
- package/validators/index.js +22 -0
- package/validators/index.js.map +1 -0
- package/validators/lte.d.ts +2 -0
- package/validators/lte.js +28 -0
- package/validators/lte.js.map +1 -0
- package/validators/maxLength.d.ts +2 -0
- package/validators/maxLength.js +28 -0
- package/validators/maxLength.js.map +1 -0
- package/validators/minLength.d.ts +2 -0
- package/validators/minLength.js +28 -0
- package/validators/minLength.js.map +1 -0
- package/validators/pattern.d.ts +2 -0
- package/validators/pattern.js +41 -0
- package/validators/pattern.js.map +1 -0
- package/validators/patternPlugins/email.d.ts +2 -0
- package/validators/patternPlugins/email.js +18 -0
- package/validators/patternPlugins/email.js.map +1 -0
- package/validators/patternPlugins/index.d.ts +2 -0
- package/validators/patternPlugins/index.js +16 -0
- package/validators/patternPlugins/index.js.map +1 -0
- package/validators/patternPlugins/lowerCase.d.ts +2 -0
- package/validators/patternPlugins/lowerCase.js +18 -0
- package/validators/patternPlugins/lowerCase.js.map +1 -0
- package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/lowerCaseSpace.js +18 -0
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
- package/validators/patternPlugins/upperCase.d.ts +2 -0
- package/validators/patternPlugins/upperCase.js +18 -0
- package/validators/patternPlugins/upperCase.js.map +1 -0
- package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/upperCaseSpace.js +18 -0
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
- package/validators/patternPlugins/url.d.ts +2 -0
- package/validators/patternPlugins/url.js +18 -0
- package/validators/patternPlugins/url.js.map +1 -0
- package/validators/required.d.ts +2 -0
- package/validators/required.js +22 -0
- package/validators/required.js.map +1 -0
- package/validators/timeGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeGte.js +5 -11
- package/validators/timeGte.js.map +1 -0
- package/validators/timeLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeLte.js +5 -11
- package/validators/timeLte.js.map +1 -0
- package/validators/unique.d.ts +6 -0
- package/validators/unique.js +56 -0
- package/validators/unique.js.map +1 -0
- package/content/contextSetup.d.ts +0 -4
- package/content/contextSetup.js +0 -65
- package/content/graphQLHandlerFactory.d.ts +0 -5
- package/content/graphQLHandlerFactory.js +0 -173
- package/content/plugins/CmsGroupPlugin.d.ts +0 -11
- package/content/plugins/CmsModelPlugin.d.ts +0 -11
- package/content/plugins/CmsModelPlugin.js +0 -24
- package/content/plugins/buildSchemaPlugins.d.ts +0 -7
- package/content/plugins/buildSchemaPlugins.js +0 -29
- package/content/plugins/crud/contentEntry/afterDelete.d.ts +0 -7
- package/content/plugins/crud/contentEntry/beforeCreate.d.ts +0 -7
- package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +0 -7
- package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +0 -4
- package/content/plugins/crud/contentEntry.crud.js +0 -931
- package/content/plugins/crud/contentModel/afterCreate.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterCreate.js +0 -18
- package/content/plugins/crud/contentModel/afterDelete.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterDelete.js +0 -18
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterUpdate.js +0 -18
- package/content/plugins/crud/contentModel/beforeCreate.d.ts +0 -9
- package/content/plugins/crud/contentModel/beforeDelete.d.ts +0 -9
- package/content/plugins/crud/contentModel/beforeUpdate.d.ts +0 -9
- package/content/plugins/crud/contentModel/beforeUpdate.js +0 -128
- package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +0 -2
- package/content/plugins/crud/contentModel/createFieldModels.d.ts +0 -2
- package/content/plugins/crud/contentModel/createFieldModels.js +0 -22
- package/content/plugins/crud/contentModel/idValidation.d.ts +0 -2
- package/content/plugins/crud/contentModel/idValidation.js +0 -22
- package/content/plugins/crud/contentModel/models.d.ts +0 -3
- package/content/plugins/crud/contentModel/models.js +0 -141
- package/content/plugins/crud/contentModel/validateLayout.d.ts +0 -2
- package/content/plugins/crud/contentModel.crud.js +0 -425
- package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +0 -9
- package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +0 -9
- package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +0 -8
- package/content/plugins/crud/contentModelGroup.crud.js +0 -351
- package/content/plugins/crud/index.d.ts +0 -6
- package/content/plugins/crud/index.js +0 -100
- package/content/plugins/graphqlFields/boolean.d.ts +0 -3
- package/content/plugins/graphqlFields/boolean.js +0 -69
- package/content/plugins/graphqlFields/datetime.d.ts +0 -3
- package/content/plugins/graphqlFields/datetime.js +0 -83
- package/content/plugins/graphqlFields/file.d.ts +0 -3
- package/content/plugins/graphqlFields/file.js +0 -49
- package/content/plugins/graphqlFields/index.d.ts +0 -2
- package/content/plugins/graphqlFields/index.js +0 -30
- package/content/plugins/graphqlFields/longText.d.ts +0 -3
- package/content/plugins/graphqlFields/longText.js +0 -62
- package/content/plugins/graphqlFields/number.d.ts +0 -3
- package/content/plugins/graphqlFields/number.js +0 -75
- package/content/plugins/graphqlFields/object.d.ts +0 -3
- package/content/plugins/graphqlFields/object.js +0 -180
- package/content/plugins/graphqlFields/ref.d.ts +0 -3
- package/content/plugins/graphqlFields/ref.js +0 -205
- package/content/plugins/graphqlFields/richText.d.ts +0 -3
- package/content/plugins/graphqlFields/richText.js +0 -55
- package/content/plugins/graphqlFields/text.d.ts +0 -3
- package/content/plugins/graphqlFields/text.js +0 -72
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +0 -8
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +0 -54
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +0 -7
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +0 -35
- package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +0 -15
- package/content/plugins/modelManager/index.d.ts +0 -3
- package/content/plugins/schema/baseSchema.d.ts +0 -4
- package/content/plugins/schema/baseSchema.js +0 -98
- package/content/plugins/schema/contentEntries.d.ts +0 -4
- package/content/plugins/schema/contentEntries.js +0 -166
- package/content/plugins/schema/contentModelGroups.d.ts +0 -4
- package/content/plugins/schema/contentModels.d.ts +0 -4
- package/content/plugins/schema/createFieldResolvers.d.ts +0 -19
- package/content/plugins/schema/createFieldResolvers.js +0 -92
- package/content/plugins/schema/createManageResolvers.d.ts +0 -11
- package/content/plugins/schema/createManageSDL.d.ts +0 -9
- package/content/plugins/schema/createPreviewResolvers.d.ts +0 -10
- package/content/plugins/schema/createPreviewResolvers.js +0 -55
- package/content/plugins/schema/createReadResolvers.d.ts +0 -10
- package/content/plugins/schema/createReadResolvers.js +0 -55
- package/content/plugins/schema/createReadSDL.d.ts +0 -9
- package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +0 -7
- package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveList.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +0 -23
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +0 -23
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +0 -7
- package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/preview/resolveGet.js +0 -38
- package/content/plugins/schema/resolvers/preview/resolveList.d.ts +0 -2
- package/content/plugins/schema/resolvers/read/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/read/resolveGet.js +0 -38
- package/content/plugins/schema/resolvers/read/resolveList.d.ts +0 -2
- package/content/plugins/schema/schemaPlugins.d.ts +0 -3
- package/content/plugins/schema/schemaPlugins.js +0 -92
- package/content/plugins/storage/StorageTransformPlugin.d.ts +0 -30
- package/content/plugins/storage/default.d.ts +0 -3
- package/content/plugins/storage/default.js +0 -28
- package/content/plugins/storage/object.d.ts +0 -3
- package/content/plugins/storage/object.js +0 -119
- package/content/plugins/utils/getEntryTitle.d.ts +0 -2
- package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +0 -11
- package/content/plugins/utils/getSchemaFromFieldPlugins.js +0 -30
- package/content/plugins/utils/pluralizedTypeName.d.ts +0 -1
- package/content/plugins/utils/renderFields.d.ts +0 -16
- package/content/plugins/utils/renderGetFilterFields.d.ts +0 -9
- package/content/plugins/utils/renderGetFilterFields.js +0 -41
- package/content/plugins/utils/renderInputFields.d.ts +0 -14
- package/content/plugins/utils/renderListFilterFields.d.ts +0 -10
- package/content/plugins/utils/renderSortEnum.d.ts +0 -9
- package/content/plugins/utils/renderSortEnum.js +0 -32
- package/content/plugins/validators/dateGte.d.ts +0 -3
- package/content/plugins/validators/dateLte.d.ts +0 -3
- package/content/plugins/validators/gte.d.ts +0 -3
- package/content/plugins/validators/gte.js +0 -32
- package/content/plugins/validators/in.d.ts +0 -3
- package/content/plugins/validators/in.js +0 -32
- package/content/plugins/validators/index.d.ts +0 -2
- package/content/plugins/validators/index.js +0 -36
- package/content/plugins/validators/lte.d.ts +0 -3
- package/content/plugins/validators/lte.js +0 -32
- package/content/plugins/validators/maxLength.d.ts +0 -3
- package/content/plugins/validators/maxLength.js +0 -32
- package/content/plugins/validators/minLength.d.ts +0 -3
- package/content/plugins/validators/minLength.js +0 -32
- package/content/plugins/validators/pattern.d.ts +0 -3
- package/content/plugins/validators/pattern.js +0 -47
- package/content/plugins/validators/patternPlugins/email.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/email.js +0 -17
- package/content/plugins/validators/patternPlugins/index.d.ts +0 -2
- package/content/plugins/validators/patternPlugins/index.js +0 -19
- package/content/plugins/validators/patternPlugins/lowerCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/lowerCase.js +0 -17
- package/content/plugins/validators/patternPlugins/upperCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/upperCase.js +0 -17
- package/content/plugins/validators/patternPlugins/url.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/url.js +0 -17
- package/content/plugins/validators/required.d.ts +0 -3
- package/content/plugins/validators/required.js +0 -25
- package/content/plugins/validators/timeGte.d.ts +0 -3
- package/content/plugins/validators/timeLte.d.ts +0 -3
- package/migrateCMSPermissions.d.ts +0 -17
- package/migrateCMSPermissions.js +0 -193
- package/plugins/context.d.ts +0 -4
- package/plugins/context.js +0 -34
- package/plugins/crud/index.d.ts +0 -6
- package/plugins/crud/index.js +0 -100
- package/plugins/crud/settings.crud.js +0 -93
- package/plugins/crud/system.crud.js +0 -182
- package/plugins/graphql/system.d.ts +0 -17
- package/plugins/graphql.d.ts +0 -2
- package/plugins/graphql.js +0 -79
- package/plugins/upgrades/index.d.ts +0 -2
- package/plugins/upgrades/index.js +0 -14
- 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/index.d.ts +0 -4
- package/plugins/upgrades/v5.5.0/index.js +0 -129
- package/transformers.d.ts +0 -2
- package/transformers.js +0 -25
- package/utils.d.ts +0 -25
- package/utils.js +0 -251
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.generateSchema = void 0;
|
|
7
|
+
var _buildSchemaPlugins = require("./buildSchemaPlugins");
|
|
8
|
+
var _createExecutableSchema = require("./createExecutableSchema");
|
|
9
|
+
var _plugins = require("../plugins");
|
|
10
|
+
const generateSchema = async params => {
|
|
11
|
+
const {
|
|
12
|
+
context,
|
|
13
|
+
models
|
|
14
|
+
} = params;
|
|
15
|
+
let generatedSchemaPlugins = [];
|
|
16
|
+
try {
|
|
17
|
+
generatedSchemaPlugins = await (0, _buildSchemaPlugins.buildSchemaPlugins)({
|
|
18
|
+
context,
|
|
19
|
+
models
|
|
20
|
+
});
|
|
21
|
+
} catch (ex) {
|
|
22
|
+
console.log(`Error while building schema plugins.`);
|
|
23
|
+
throw ex;
|
|
24
|
+
}
|
|
25
|
+
context.plugins.register(generatedSchemaPlugins);
|
|
26
|
+
const schemaPlugins = context.plugins.byType(_plugins.CmsGraphQLSchemaPlugin.type);
|
|
27
|
+
return (0, _createExecutableSchema.createExecutableSchema)({
|
|
28
|
+
plugins: schemaPlugins
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
exports.generateSchema = generateSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["generateSchema","params","context","models","generatedSchemaPlugins","buildSchemaPlugins","ex","console","log","plugins","register","schemaPlugins","byType","CmsGraphQLSchemaPlugin","type","createExecutableSchema"],"sources":["generateSchema.ts"],"sourcesContent":["import { CmsContext, CmsModel } from \"~/types\";\nimport { buildSchemaPlugins } from \"~/graphql/buildSchemaPlugins\";\nimport { createExecutableSchema } from \"~/graphql/createExecutableSchema\";\nimport { GraphQLSchema } from \"graphql/type\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\n\ninterface GenerateSchemaParams {\n context: CmsContext;\n models: CmsModel[];\n}\nexport const generateSchema = async (params: GenerateSchemaParams): Promise<GraphQLSchema> => {\n const { context, models } = params;\n\n let generatedSchemaPlugins: CmsGraphQLSchemaPlugin[] = [];\n try {\n generatedSchemaPlugins = await buildSchemaPlugins({ context, models });\n } catch (ex) {\n console.log(`Error while building schema plugins.`);\n throw ex;\n }\n\n context.plugins.register(generatedSchemaPlugins);\n\n const schemaPlugins = context.plugins.byType<CmsGraphQLSchemaPlugin>(\n CmsGraphQLSchemaPlugin.type\n );\n return createExecutableSchema({\n plugins: schemaPlugins\n });\n};\n"],"mappings":";;;;;;AACA;AACA;AAEA;AAMO,MAAMA,cAAc,GAAG,MAAOC,MAA4B,IAA6B;EAC1F,MAAM;IAAEC,OAAO;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAElC,IAAIG,sBAAgD,GAAG,EAAE;EACzD,IAAI;IACAA,sBAAsB,GAAG,MAAM,IAAAC,sCAAkB,EAAC;MAAEH,OAAO;MAAEC;IAAO,CAAC,CAAC;EAC1E,CAAC,CAAC,OAAOG,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAE,sCAAqC,CAAC;IACnD,MAAMF,EAAE;EACZ;EAEAJ,OAAO,CAACO,OAAO,CAACC,QAAQ,CAACN,sBAAsB,CAAC;EAEhD,MAAMO,aAAa,GAAGT,OAAO,CAACO,OAAO,CAACG,MAAM,CACxCC,+BAAsB,CAACC,IAAI,CAC9B;EACD,OAAO,IAAAC,8CAAsB,EAAC;IAC1BN,OAAO,EAAEE;EACb,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.graphQLHandlerFactory = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _apiSecurity = require("@webiny/api-security");
|
|
10
|
+
var _debugPlugins = _interopRequireDefault(require("@webiny/handler-graphql/debugPlugins"));
|
|
11
|
+
var _processRequestBody = _interopRequireDefault(require("@webiny/handler-graphql/processRequestBody"));
|
|
12
|
+
var _handler = require("@webiny/handler");
|
|
13
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
14
|
+
var _codeFrame = _interopRequireDefault(require("code-frame"));
|
|
15
|
+
var _generateSchema = require("./generateSchema");
|
|
16
|
+
// @ts-ignore `code-frame` has no types
|
|
17
|
+
|
|
18
|
+
const createRequestBody = body => {
|
|
19
|
+
/**
|
|
20
|
+
* We are trusting that the body payload is correct.
|
|
21
|
+
* The `processRequestBody` will fail if it is not.
|
|
22
|
+
*/
|
|
23
|
+
return typeof body === "string" ? JSON.parse(body) : body;
|
|
24
|
+
};
|
|
25
|
+
const schemaList = new Map();
|
|
26
|
+
const generateCacheKey = async args => {
|
|
27
|
+
const {
|
|
28
|
+
context,
|
|
29
|
+
locale,
|
|
30
|
+
type
|
|
31
|
+
} = args;
|
|
32
|
+
const lastModelChange = await context.cms.getModelLastChange();
|
|
33
|
+
return [locale.code, type, lastModelChange.toISOString()].join("#");
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Gets an existing schema or rewrites existing one or creates a completely new one
|
|
38
|
+
* depending on the schemaId created from type and locale parameters
|
|
39
|
+
*/
|
|
40
|
+
const getSchema = async params => {
|
|
41
|
+
const {
|
|
42
|
+
context,
|
|
43
|
+
type,
|
|
44
|
+
locale
|
|
45
|
+
} = params;
|
|
46
|
+
const tenantId = context.tenancy.getCurrentTenant().id;
|
|
47
|
+
const id = `${tenantId}#${type}#${locale.code}`;
|
|
48
|
+
const cacheKey = await generateCacheKey(params);
|
|
49
|
+
const cachedSchema = schemaList.get(id);
|
|
50
|
+
if ((cachedSchema === null || cachedSchema === void 0 ? void 0 : cachedSchema.key) === cacheKey) {
|
|
51
|
+
return cachedSchema.schema;
|
|
52
|
+
}
|
|
53
|
+
// Load model data
|
|
54
|
+
context.security.disableAuthorization();
|
|
55
|
+
const models = (await context.cms.listModels()).filter(model => model.isPrivate !== true);
|
|
56
|
+
context.security.enableAuthorization();
|
|
57
|
+
try {
|
|
58
|
+
const schema = await (0, _generateSchema.generateSchema)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
59
|
+
models
|
|
60
|
+
}));
|
|
61
|
+
schemaList.set(id, {
|
|
62
|
+
key: cacheKey,
|
|
63
|
+
schema
|
|
64
|
+
});
|
|
65
|
+
return schema;
|
|
66
|
+
} catch (err) {
|
|
67
|
+
if (!Array.isArray(err.locations)) {
|
|
68
|
+
throw new _error.default({
|
|
69
|
+
message: err.message,
|
|
70
|
+
code: err.code || "INVALID_GRAPHQL_SCHEMA_LOCATIONS",
|
|
71
|
+
data: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, err.data || {}), {}, {
|
|
72
|
+
locations: err.locations
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const [location] = err.locations;
|
|
77
|
+
throw new _error.default({
|
|
78
|
+
code: "INVALID_GRAPHQL_SCHEMA",
|
|
79
|
+
message: err.message,
|
|
80
|
+
data: {
|
|
81
|
+
invalidSegment: (0, _codeFrame.default)(err.source.body, location.line, location.column, {
|
|
82
|
+
frameSize: 15
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const checkEndpointAccess = async context => {
|
|
89
|
+
const permission = await context.security.getPermission(`cms.endpoint.${context.cms.type}`);
|
|
90
|
+
if (!permission) {
|
|
91
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
92
|
+
data: {
|
|
93
|
+
reason: `Not allowed to access "${context.cms.type}" endpoint.`
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const formatErrorPayload = error => {
|
|
99
|
+
if (error instanceof _error.default) {
|
|
100
|
+
return JSON.stringify({
|
|
101
|
+
type: "CmsGraphQLWebinyError",
|
|
102
|
+
message: error.message,
|
|
103
|
+
code: error.code,
|
|
104
|
+
data: error.data
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return JSON.stringify({
|
|
108
|
+
type: "Error",
|
|
109
|
+
name: error.name,
|
|
110
|
+
message: error.message,
|
|
111
|
+
stack: error.stack
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
const cmsRoutes = new _handler.RoutePlugin(({
|
|
115
|
+
onPost,
|
|
116
|
+
onOptions,
|
|
117
|
+
context
|
|
118
|
+
}) => {
|
|
119
|
+
onPost("/cms/:type(^manage|preview|read$)/:locale", async (request, reply) => {
|
|
120
|
+
try {
|
|
121
|
+
await checkEndpointAccess(context);
|
|
122
|
+
} catch (ex) {
|
|
123
|
+
return reply.code(401).send({
|
|
124
|
+
data: null,
|
|
125
|
+
error: {
|
|
126
|
+
message: ex.message || "Not authorized!",
|
|
127
|
+
code: ex.code || "SECURITY_NOT_AUTHORIZED",
|
|
128
|
+
data: ex.data || null,
|
|
129
|
+
stack: null
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
let schema;
|
|
134
|
+
try {
|
|
135
|
+
schema = await getSchema({
|
|
136
|
+
context,
|
|
137
|
+
locale: context.cms.getLocale(),
|
|
138
|
+
type: context.cms.type
|
|
139
|
+
});
|
|
140
|
+
} catch (ex) {
|
|
141
|
+
console.log(`Error while generating the schema.`);
|
|
142
|
+
console.log(formatErrorPayload(ex));
|
|
143
|
+
throw ex;
|
|
144
|
+
}
|
|
145
|
+
let body = [];
|
|
146
|
+
try {
|
|
147
|
+
body = createRequestBody(request.body);
|
|
148
|
+
} catch (ex) {
|
|
149
|
+
console.log(`Error while creating the body request.`);
|
|
150
|
+
console.log(formatErrorPayload(ex));
|
|
151
|
+
throw ex;
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
const result = await (0, _processRequestBody.default)(body, schema, context);
|
|
155
|
+
return reply.code(200).send(result);
|
|
156
|
+
} catch (ex) {
|
|
157
|
+
console.log(`Error while processing the body request.`);
|
|
158
|
+
console.log(formatErrorPayload(ex));
|
|
159
|
+
throw ex;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
onOptions("/cms/:type(^manage|preview|read$)/:locale", async (_, reply) => {
|
|
163
|
+
return reply.status(204).send({}).hijack();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
cmsRoutes.name = "headless-cms.graphql.route.default";
|
|
167
|
+
const graphQLHandlerFactory = ({
|
|
168
|
+
debug
|
|
169
|
+
}) => {
|
|
170
|
+
return [...(debug ? (0, _debugPlugins.default)() : []), cmsRoutes, {
|
|
171
|
+
type: "wcp-telemetry-tracker"
|
|
172
|
+
}];
|
|
173
|
+
};
|
|
174
|
+
exports.graphQLHandlerFactory = graphQLHandlerFactory;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createRequestBody","body","JSON","parse","schemaList","Map","generateCacheKey","args","context","locale","type","lastModelChange","cms","getModelLastChange","code","toISOString","join","getSchema","params","tenantId","tenancy","getCurrentTenant","id","cacheKey","cachedSchema","get","key","schema","security","disableAuthorization","models","listModels","filter","model","isPrivate","enableAuthorization","generateSchema","set","err","Array","isArray","locations","WebinyError","message","data","location","invalidSegment","codeFrame","source","line","column","frameSize","checkEndpointAccess","permission","getPermission","NotAuthorizedError","reason","formatErrorPayload","error","stringify","name","stack","cmsRoutes","RoutePlugin","onPost","onOptions","request","reply","ex","send","getLocale","console","log","result","processRequestBody","_","status","hijack","graphQLHandlerFactory","debug","debugPlugins"],"sources":["graphQLHandlerFactory.ts"],"sourcesContent":["import { GraphQLSchema } from \"graphql\";\nimport { ApiEndpoint, CmsContext } from \"~/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { NotAuthorizedError } 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 { GraphQLRequestBody } from \"@webiny/handler-graphql/types\";\nimport { RoutePlugin } from \"@webiny/handler\";\nimport WebinyError from \"@webiny/error\";\n// @ts-ignore `code-frame` has no types\nimport codeFrame from \"code-frame\";\nimport { generateSchema } from \"~/graphql/generateSchema\";\n\ninterface SchemaCache {\n key: string;\n schema: GraphQLSchema;\n}\ninterface GetSchemaParams {\n context: CmsContext;\n type: ApiEndpoint;\n locale: I18NLocale;\n}\n\nconst createRequestBody = (body: unknown): GraphQLRequestBody | GraphQLRequestBody[] => {\n /**\n * We are trusting that the body payload is correct.\n * The `processRequestBody` will fail if it is not.\n */\n return typeof body === \"string\" ? JSON.parse(body) : body;\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\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 const cachedSchema = schemaList.get(id);\n if (cachedSchema?.key === cacheKey) {\n return cachedSchema.schema;\n }\n // Load model data\n context.security.disableAuthorization();\n const models = (await context.cms.listModels()).filter(model => model.isPrivate !== true);\n context.security.enableAuthorization();\n try {\n const schema = await generateSchema({\n ...params,\n models\n });\n schemaList.set(id, {\n key: cacheKey,\n schema\n });\n return schema;\n } catch (err) {\n if (!Array.isArray(err.locations)) {\n throw new WebinyError({\n message: err.message,\n code: err.code || \"INVALID_GRAPHQL_SCHEMA_LOCATIONS\",\n data: {\n ...(err.data || {}),\n locations: err.locations\n }\n });\n }\n const [location] = err.locations;\n\n throw new WebinyError({\n code: \"INVALID_GRAPHQL_SCHEMA\",\n message: err.message,\n data: {\n invalidSegment: codeFrame(err.source.body, location.line, location.column, {\n frameSize: 15\n })\n }\n });\n }\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\nconst formatErrorPayload = (error: Error): string => {\n if (error instanceof WebinyError) {\n return JSON.stringify({\n type: \"CmsGraphQLWebinyError\",\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return JSON.stringify({\n type: \"Error\",\n name: error.name,\n message: error.message,\n stack: error.stack\n });\n};\n\nexport interface GraphQLHandlerFactoryParams {\n debug?: boolean;\n}\n\nconst cmsRoutes = new RoutePlugin<CmsContext>(({ onPost, onOptions, context }) => {\n onPost(\"/cms/:type(^manage|preview|read$)/:locale\", async (request, reply) => {\n try {\n await checkEndpointAccess(context);\n } catch (ex) {\n return reply.code(401).send({\n data: null,\n error: {\n message: ex.message || \"Not authorized!\",\n code: ex.code || \"SECURITY_NOT_AUTHORIZED\",\n data: ex.data || null,\n stack: null\n }\n });\n }\n\n let schema: GraphQLSchema;\n try {\n schema = await getSchema({\n context,\n locale: context.cms.getLocale(),\n type: context.cms.type as ApiEndpoint\n });\n } catch (ex) {\n console.log(`Error while generating the schema.`);\n console.log(formatErrorPayload(ex));\n throw ex;\n }\n\n let body: GraphQLRequestBody | GraphQLRequestBody[] = [];\n try {\n body = createRequestBody(request.body);\n } catch (ex) {\n console.log(`Error while creating the body request.`);\n console.log(formatErrorPayload(ex));\n throw ex;\n }\n\n try {\n const result = await processRequestBody(body, schema, context);\n return reply.code(200).send(result);\n } catch (ex) {\n console.log(`Error while processing the body request.`);\n console.log(formatErrorPayload(ex));\n throw ex;\n }\n });\n\n onOptions(\"/cms/:type(^manage|preview|read$)/:locale\", async (_, reply) => {\n return reply.status(204).send({}).hijack();\n });\n});\n\ncmsRoutes.name = \"headless-cms.graphql.route.default\";\n\nexport const graphQLHandlerFactory = ({ debug }: GraphQLHandlerFactoryParams): PluginCollection => {\n return [\n ...(debug ? debugPlugins() : []),\n cmsRoutes,\n {\n type: \"wcp-telemetry-tracker\"\n }\n ];\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GraphQLHandlerFactoryParams } from "./graphQLHandlerFactory";
|
|
2
|
+
export declare type CreateGraphQLParams = GraphQLHandlerFactoryParams;
|
|
3
|
+
export declare const createGraphQL: (params: CreateGraphQLParams) => (import("@webiny/plugins/types").PluginCollection | import("@webiny/handler-graphql").GraphQLSchemaPlugin<import("../types").CmsContext> | import("@webiny/api").ContextPlugin<import("../types").CmsContext>)[];
|
package/graphql/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createGraphQL = void 0;
|
|
7
|
+
var _system = require("./system");
|
|
8
|
+
var _graphQLHandlerFactory = require("./graphQLHandlerFactory");
|
|
9
|
+
var _baseSchema = require("./schema/baseSchema");
|
|
10
|
+
const createGraphQL = params => {
|
|
11
|
+
return [...(0, _baseSchema.createBaseSchema)(), (0, _system.createSystemSchemaPlugin)(), (0, _graphQLHandlerFactory.graphQLHandlerFactory)(params)];
|
|
12
|
+
};
|
|
13
|
+
exports.createGraphQL = createGraphQL;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createGraphQL","params","createBaseSchema","createSystemSchemaPlugin","graphQLHandlerFactory"],"sources":["index.ts"],"sourcesContent":["import { createSystemSchemaPlugin } from \"./system\";\nimport { graphQLHandlerFactory, GraphQLHandlerFactoryParams } from \"./graphQLHandlerFactory\";\nimport { createBaseSchema } from \"~/graphql/schema/baseSchema\";\n\nexport type CreateGraphQLParams = GraphQLHandlerFactoryParams;\nexport const createGraphQL = (params: CreateGraphQLParams) => {\n return [...createBaseSchema(), createSystemSchemaPlugin(), graphQLHandlerFactory(params)];\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAGO,MAAMA,aAAa,GAAIC,MAA2B,IAAK;EAC1D,OAAO,CAAC,GAAG,IAAAC,4BAAgB,GAAE,EAAE,IAAAC,gCAAwB,GAAE,EAAE,IAAAC,4CAAqB,EAACH,MAAM,CAAC,CAAC;AAC7F,CAAC;AAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createBaseContentSchema = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _builtInTypes = require("@webiny/handler-graphql/builtInTypes");
|
|
10
|
+
var _plugins = require("../../plugins");
|
|
11
|
+
const createBaseContentSchema = ({
|
|
12
|
+
context
|
|
13
|
+
}) => {
|
|
14
|
+
const scalars = context.plugins.byType("graphql-scalar").map(item => item.scalar);
|
|
15
|
+
const plugin = new _plugins.CmsGraphQLSchemaPlugin({
|
|
16
|
+
typeDefs: /* GraphQL */`
|
|
17
|
+
${scalars.map(scalar => `scalar ${scalar.name}`).join(" ")}
|
|
18
|
+
scalar JSON
|
|
19
|
+
scalar Long
|
|
20
|
+
scalar RefInput
|
|
21
|
+
scalar Number
|
|
22
|
+
scalar Any
|
|
23
|
+
scalar Date
|
|
24
|
+
scalar DateTime
|
|
25
|
+
scalar DateTimeZ
|
|
26
|
+
scalar Time
|
|
27
|
+
|
|
28
|
+
type Query
|
|
29
|
+
|
|
30
|
+
type Mutation {
|
|
31
|
+
_empty: String
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type CmsCreatedBy {
|
|
35
|
+
id: String
|
|
36
|
+
displayName: String
|
|
37
|
+
type: String
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type CmsOwnedBy {
|
|
41
|
+
id: String
|
|
42
|
+
displayName: String
|
|
43
|
+
type: String
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
enum CmsEntryStatusType {
|
|
47
|
+
latest
|
|
48
|
+
published
|
|
49
|
+
}
|
|
50
|
+
`,
|
|
51
|
+
resolvers: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, scalars.reduce((acc, s) => {
|
|
52
|
+
acc[s.name] = s;
|
|
53
|
+
return acc;
|
|
54
|
+
}, {})), {}, {
|
|
55
|
+
JSON: _builtInTypes.JsonScalar,
|
|
56
|
+
Long: _builtInTypes.LongScalar,
|
|
57
|
+
RefInput: _builtInTypes.RefInputScalar,
|
|
58
|
+
Number: _builtInTypes.NumberScalar,
|
|
59
|
+
Any: _builtInTypes.AnyScalar,
|
|
60
|
+
DateTime: _builtInTypes.DateTimeScalar,
|
|
61
|
+
DateTimeZ: _builtInTypes.DateTimeZScalar,
|
|
62
|
+
Date: _builtInTypes.DateScalar,
|
|
63
|
+
Time: _builtInTypes.TimeScalar,
|
|
64
|
+
Mutation: {
|
|
65
|
+
_empty: () => "_empty"
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
plugin.name = `headless-cms.graphql.schema.baseContentSchema`;
|
|
70
|
+
return plugin;
|
|
71
|
+
};
|
|
72
|
+
exports.createBaseContentSchema = createBaseContentSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createBaseContentSchema","context","scalars","plugins","byType","map","item","scalar","plugin","CmsGraphQLSchemaPlugin","typeDefs","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","RefInputScalar","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 RefInputScalar,\n NumberScalar,\n AnyScalar,\n DateTimeScalar,\n DateScalar,\n TimeScalar,\n LongScalar,\n JsonScalar,\n DateTimeZScalar\n} from \"@webiny/handler-graphql/builtInTypes\";\nimport { GraphQLScalarType } from \"graphql\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\n\ninterface Params {\n context: CmsContext;\n}\nexport const createBaseContentSchema = ({ context }: Params): CmsGraphQLSchemaPlugin => {\n const scalars = context.plugins\n .byType<GraphQLScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n const plugin = new CmsGraphQLSchemaPlugin({\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<Record<string, GraphQLScalarType>>((acc, s) => {\n acc[s.name] = s;\n return acc;\n }, {}),\n JSON: JsonScalar,\n Long: LongScalar,\n RefInput: RefInputScalar,\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 plugin.name = `headless-cms.graphql.schema.baseContentSchema`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;;AAEA;AAYA;AAKO,MAAMA,uBAAuB,GAAG,CAAC;EAAEC;AAAgB,CAAC,KAA6B;EACpF,MAAMC,OAAO,GAAGD,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAAsB,gBAAgB,CAAC,CAC7CC,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,MAAM,CAAC;EAE7B,MAAMC,MAAM,GAAG,IAAIC,+BAAsB,CAAC;IACtCC,QAAQ,EAAE,aAAe;AACjC,cAAcR,OAAO,CAACG,GAAG,CAACE,MAAM,IAAK,UAASA,MAAM,CAACI,IAAK,EAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;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,SAAS;IACDC,SAAS,8DACFX,OAAO,CAACY,MAAM,CAAoC,CAACC,GAAG,EAAEC,CAAC,KAAK;MAC7DD,GAAG,CAACC,CAAC,CAACL,IAAI,CAAC,GAAGK,CAAC;MACf,OAAOD,GAAG;IACd,CAAC,EAAE,CAAC,CAAC,CAAC;MACNE,IAAI,EAAEC,wBAAU;MAChBC,IAAI,EAAEC,wBAAU;MAChBC,QAAQ,EAAEC,4BAAc;MACxBC,MAAM,EAAEC,0BAAY;MACpBC,GAAG,EAAEC,uBAAS;MACdC,QAAQ,EAAEC,4BAAc;MACxBC,SAAS,EAAEC,6BAAe;MAC1BC,IAAI,EAAEC,wBAAU;MAChBC,IAAI,EAAEC,wBAAU;MAChBC,QAAQ,EAAE;QACNC,MAAM,EAAE,MAAM;MAClB;IAAC;EAET,CAAC,CAAC;EACF5B,MAAM,CAACG,IAAI,GAAI,+CAA8C;EAE7D,OAAOH,MAAM;AACjB,CAAC;AAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createBaseSchema = void 0;
|
|
7
|
+
var _plugins = require("../../plugins");
|
|
8
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
9
|
+
const createBaseSchema = () => {
|
|
10
|
+
const cmsPlugin = new _plugins.CmsGraphQLSchemaPlugin({
|
|
11
|
+
typeDefs: /* GraphQL */`
|
|
12
|
+
type CmsError {
|
|
13
|
+
code: String
|
|
14
|
+
message: String
|
|
15
|
+
data: JSON
|
|
16
|
+
stack: String
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type CmsCursors {
|
|
20
|
+
next: String
|
|
21
|
+
previous: String
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type CmsListMeta {
|
|
25
|
+
cursor: String
|
|
26
|
+
hasMoreItems: Boolean
|
|
27
|
+
totalCount: Int
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type CmsDeleteResponse {
|
|
31
|
+
data: Boolean
|
|
32
|
+
error: CmsError
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type CmsBooleanResponse {
|
|
36
|
+
data: Boolean
|
|
37
|
+
error: CmsError
|
|
38
|
+
}
|
|
39
|
+
`,
|
|
40
|
+
resolvers: {}
|
|
41
|
+
});
|
|
42
|
+
cmsPlugin.name = "headless-cms.graphql.schema.base";
|
|
43
|
+
const corePlugin = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
44
|
+
typeDefs: cmsPlugin.schema.typeDefs,
|
|
45
|
+
resolvers: cmsPlugin.schema.resolvers
|
|
46
|
+
});
|
|
47
|
+
corePlugin.name = "headless-cms.graphql.core.schema.base";
|
|
48
|
+
/**
|
|
49
|
+
* Due to splitting of CMS and Core schema plugins, we must have both defined for CMS to work.
|
|
50
|
+
*/
|
|
51
|
+
return [cmsPlugin, corePlugin];
|
|
52
|
+
};
|
|
53
|
+
exports.createBaseSchema = createBaseSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createBaseSchema","cmsPlugin","CmsGraphQLSchemaPlugin","typeDefs","resolvers","name","corePlugin","GraphQLSchemaPlugin","schema"],"sources":["baseSchema.ts"],"sourcesContent":["import { CmsContext } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\n\nexport const createBaseSchema = (): GraphQLSchemaPlugin<CmsContext>[] => {\n const cmsPlugin = new CmsGraphQLSchemaPlugin({\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 cmsPlugin.name = \"headless-cms.graphql.schema.base\";\n const corePlugin = new GraphQLSchemaPlugin<CmsContext>({\n typeDefs: cmsPlugin.schema.typeDefs,\n resolvers: cmsPlugin.schema.resolvers\n });\n corePlugin.name = \"headless-cms.graphql.core.schema.base\";\n /**\n * Due to splitting of CMS and Core schema plugins, we must have both defined for CMS to work.\n */\n return [cmsPlugin, corePlugin];\n};\n"],"mappings":";;;;;;AACA;AACA;AAEO,MAAMA,gBAAgB,GAAG,MAAyC;EACrE,MAAMC,SAAS,GAAG,IAAIC,+BAAsB,CAAC;IACzCC,QAAQ,EAAE,aAAe;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,SAAS;IACDC,SAAS,EAAE,CAAC;EAChB,CAAC,CAAC;EACFH,SAAS,CAACI,IAAI,GAAG,kCAAkC;EACnD,MAAMC,UAAU,GAAG,IAAIC,mCAAmB,CAAa;IACnDJ,QAAQ,EAAEF,SAAS,CAACO,MAAM,CAACL,QAAQ;IACnCC,SAAS,EAAEH,SAAS,CAACO,MAAM,CAACJ;EAChC,CAAC,CAAC;EACFE,UAAU,CAACD,IAAI,GAAG,uCAAuC;EACzD;AACJ;AACA;EACI,OAAO,CAACJ,SAAS,EAAEK,UAAU,CAAC;AAClC,CAAC;AAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CmsContext } from "../../types";
|
|
2
|
+
import { CmsGraphQLSchemaPlugin } from "../../plugins";
|
|
3
|
+
interface Params {
|
|
4
|
+
context: CmsContext;
|
|
5
|
+
}
|
|
6
|
+
export declare const createContentEntriesSchema: ({ context }: Params) => CmsGraphQLSchemaPlugin<CmsContext>;
|
|
7
|
+
export {};
|