@webiny/api-headless-cms 0.0.0-mt-3 → 0.0.0-unstable.1145e7667f
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 +98 -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 +29 -43
- package/crud/contentEntry/markLockedFields.js.map +1 -0
- package/crud/contentEntry/referenceFieldsMapping.d.ts +13 -0
- package/crud/contentEntry/referenceFieldsMapping.js +265 -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 +7 -8
- package/crud/contentEntry.crud.js +1212 -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/crud/contentModel/beforeCreate.js +128 -0
- package/crud/contentModel/beforeCreate.js.map +1 -0
- package/crud/contentModel/beforeDelete.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.js +8 -18
- package/crud/contentModel/beforeDelete.js.map +1 -0
- package/crud/contentModel/beforeUpdate.d.ts +8 -0
- package/crud/contentModel/beforeUpdate.js +60 -0
- package/crud/contentModel/beforeUpdate.js.map +1 -0
- package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
- package/crud/contentModel/compatibility/modelApiName.js +24 -0
- package/crud/contentModel/compatibility/modelApiName.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/createFieldModels.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/createFieldModels.js +6 -2
- package/crud/contentModel/createFieldModels.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/defaultFields.d.ts +5 -0
- package/crud/contentModel/defaultFields.js +58 -0
- package/crud/contentModel/defaultFields.js.map +1 -0
- package/crud/contentModel/fieldIdValidation.d.ts +1 -0
- package/crud/contentModel/fieldIdValidation.js +25 -0
- package/crud/contentModel/fieldIdValidation.js.map +1 -0
- package/crud/contentModel/fields/descriptionField.d.ts +2 -0
- package/crud/contentModel/fields/descriptionField.js +42 -0
- package/crud/contentModel/fields/descriptionField.js.map +1 -0
- package/crud/contentModel/fields/imageField.d.ts +2 -0
- package/crud/contentModel/fields/imageField.js +46 -0
- package/crud/contentModel/fields/imageField.js.map +1 -0
- package/crud/contentModel/fields/titleField.d.ts +2 -0
- package/crud/contentModel/fields/titleField.js +58 -0
- package/crud/contentModel/fields/titleField.js.map +1 -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 +2 -1
- package/{content/plugins/crud → crud}/contentModel/models.js +76 -25
- package/crud/contentModel/models.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/validate/endingAllowed.d.ts +6 -0
- package/crud/contentModel/validate/endingAllowed.js +26 -0
- package/crud/contentModel/validate/endingAllowed.js.map +1 -0
- package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
- package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
- package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
- package/crud/contentModel/validate/modelId.d.ts +11 -0
- package/crud/contentModel/validate/modelId.js +36 -0
- package/crud/contentModel/validate/modelId.js.map +1 -0
- package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
- package/crud/contentModel/validate/pluralApiName.js +24 -0
- package/crud/contentModel/validate/pluralApiName.js.map +1 -0
- package/crud/contentModel/validate/singularApiName.d.ts +7 -0
- package/crud/contentModel/validate/singularApiName.js +24 -0
- package/crud/contentModel/validate/singularApiName.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 +9 -0
- package/crud/contentModel/validateModel.js +27 -0
- package/crud/contentModel/validateModel.js.map +1 -0
- package/crud/contentModel/validateModelFields.d.ts +9 -0
- package/crud/contentModel/validateModelFields.js +342 -0
- package/crud/contentModel/validateModelFields.js.map +1 -0
- package/crud/contentModel/validation.d.ts +551 -0
- package/crud/contentModel/validation.js +145 -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 +616 -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 +352 -0
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/{plugins/crud → crud}/settings.crud.d.ts +3 -3
- package/crud/settings.crud.js +66 -0
- package/crud/settings.crud.js.map +1 -0
- package/{plugins/crud → crud}/system.crud.d.ts +6 -3
- package/crud/system.crud.js +126 -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/checkEndpointAccess.d.ts +2 -0
- package/graphql/checkEndpointAccess.js +18 -0
- package/graphql/checkEndpointAccess.js.map +1 -0
- package/graphql/createExecutableSchema.d.ts +6 -0
- package/graphql/createExecutableSchema.js +29 -0
- package/graphql/createExecutableSchema.js.map +1 -0
- package/graphql/createRequestBody.d.ts +2 -0
- package/graphql/createRequestBody.js +14 -0
- package/graphql/createRequestBody.js.map +1 -0
- package/graphql/formatErrorPayload.d.ts +1 -0
- package/graphql/formatErrorPayload.js +25 -0
- package/graphql/formatErrorPayload.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/getSchema.d.ts +17 -0
- package/graphql/getSchema.js +102 -0
- package/graphql/getSchema.js.map +1 -0
- package/graphql/graphQLHandlerFactory.d.ts +5 -0
- package/graphql/graphQLHandlerFactory.js +35 -0
- package/graphql/graphQLHandlerFactory.js.map +1 -0
- package/graphql/handleRequest.d.ts +11 -0
- package/graphql/handleRequest.js +81 -0
- package/graphql/handleRequest.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 +66 -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 +362 -0
- package/graphql/schema/contentEntries.js.map +1 -0
- package/graphql/schema/contentModelGroups.d.ts +7 -0
- package/{content/plugins → graphql}/schema/contentModelGroups.js +39 -33
- package/graphql/schema/contentModelGroups.js.map +1 -0
- package/graphql/schema/contentModels.d.ts +7 -0
- package/{content/plugins → graphql}/schema/contentModels.js +121 -29
- package/graphql/schema/contentModels.js.map +1 -0
- package/graphql/schema/createFieldResolvers.d.ts +20 -0
- package/graphql/schema/createFieldResolvers.js +111 -0
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +12 -0
- package/graphql/schema/createManageResolvers.js +127 -0
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/graphql/schema/createManageSDL.d.ts +13 -0
- package/graphql/schema/createManageSDL.js +157 -0
- package/graphql/schema/createManageSDL.js.map +1 -0
- package/graphql/schema/createPreviewResolvers.d.ts +12 -0
- package/graphql/schema/createPreviewResolvers.js +44 -0
- package/graphql/schema/createPreviewResolvers.js.map +1 -0
- package/graphql/schema/createReadResolvers.d.ts +12 -0
- package/graphql/schema/createReadResolvers.js +49 -0
- package/graphql/schema/createReadResolvers.js.map +1 -0
- package/graphql/schema/createReadSDL.d.ts +13 -0
- package/graphql/schema/createReadSDL.js +100 -0
- package/graphql/schema/createReadSDL.js.map +1 -0
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js +2 -3
- 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 +39 -24
- 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 +243 -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 +258 -0
- package/graphqlFields/object.js.map +1 -0
- package/graphqlFields/ref.d.ts +2 -0
- package/graphqlFields/ref.js +255 -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 +12 -12
- package/index.js +98 -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 +37 -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 +61 -0
- package/plugins/CmsModelPlugin.js +184 -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/StorageOperationsCmsModelPlugin.d.ts +23 -0
- package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
- package/plugins/StorageOperationsCmsModelPlugin.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 +8 -0
- package/plugins/index.js +93 -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 +920 -374
- package/types.js +105 -62
- package/types.js.map +1 -0
- package/upgrades/5.33.0/index.d.ts +3 -0
- package/upgrades/5.33.0/index.js +182 -0
- package/upgrades/5.33.0/index.js.map +1 -0
- package/upgrades/index.d.ts +1 -0
- package/upgrades/index.js +12 -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 +14 -0
- package/utils/converters/valueKeyStorageConverter.js +125 -0
- package/utils/converters/valueKeyStorageConverter.js.map +1 -0
- package/utils/createTypeFromFields.d.ts +16 -0
- package/utils/createTypeFromFields.js +66 -0
- package/utils/createTypeFromFields.js.map +1 -0
- package/utils/createTypeName.d.ts +1 -0
- package/utils/createTypeName.js +13 -0
- 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/getEntryDescription.d.ts +2 -0
- package/utils/getEntryDescription.js +17 -0
- package/utils/getEntryDescription.js.map +1 -0
- package/utils/getEntryImage.d.ts +2 -0
- package/utils/getEntryImage.js +17 -0
- package/utils/getEntryImage.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/incrementEntryIdVersion.d.ts +5 -0
- package/utils/incrementEntryIdVersion.js +29 -0
- package/utils/incrementEntryIdVersion.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 -1
- package/utils/pluralizedTypeName.js.map +1 -0
- package/utils/renderFields.d.ts +16 -0
- package/{content/plugins/utils → utils}/renderFields.js +14 -12
- 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 +15 -0
- package/{content/plugins/utils → utils}/renderInputFields.js +7 -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/beforeCreate.js +0 -146
- 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/idValidation.d.ts +0 -2
- 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/createManageResolvers.js +0 -135
- package/content/plugins/schema/createManageSDL.d.ts +0 -9
- package/content/plugins/schema/createManageSDL.js +0 -153
- 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/createReadSDL.js +0 -96
- 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/createTypeName.d.ts +0 -3
- package/content/plugins/utils/createTypeName.js +0 -28
- 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 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createContentEntriesSchema = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
10
|
+
var _apiSecurity = require("@webiny/api-security");
|
|
11
|
+
var _getEntryTitle = require("../../utils/getEntryTitle");
|
|
12
|
+
var _plugins = require("../../plugins");
|
|
13
|
+
var _getEntryDescription = require("../../utils/getEntryDescription");
|
|
14
|
+
var _getEntryImage = require("../../utils/getEntryImage");
|
|
15
|
+
var _entryStorage = require("../../utils/entryStorage");
|
|
16
|
+
const createDate = date => {
|
|
17
|
+
try {
|
|
18
|
+
return new Date(date);
|
|
19
|
+
} catch {}
|
|
20
|
+
return new Date();
|
|
21
|
+
};
|
|
22
|
+
const createCmsEntryRecord = (model, entry) => {
|
|
23
|
+
return {
|
|
24
|
+
id: entry.id,
|
|
25
|
+
entryId: entry.entryId,
|
|
26
|
+
model: {
|
|
27
|
+
modelId: model.modelId,
|
|
28
|
+
name: model.name
|
|
29
|
+
},
|
|
30
|
+
status: entry.status,
|
|
31
|
+
title: (0, _getEntryTitle.getEntryTitle)(model, entry),
|
|
32
|
+
description: (0, _getEntryDescription.getEntryDescription)(model, entry),
|
|
33
|
+
image: (0, _getEntryImage.getEntryImage)(model, entry),
|
|
34
|
+
createdBy: entry.createdBy,
|
|
35
|
+
modifiedBy: entry.modifiedBy,
|
|
36
|
+
createdOn: createDate(entry.createdOn),
|
|
37
|
+
savedOn: createDate(entry.savedOn)
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const getFetchMethod = (type, context) => {
|
|
41
|
+
if (!getContentEntriesMethods[type]) {
|
|
42
|
+
throw new _error.default(`Unknown getContentEntries method "${type}". Could not fetch content entries.`, "UNKNOWN_METHOD_ERROR", {
|
|
43
|
+
type
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const methodName = getContentEntriesMethods[type];
|
|
47
|
+
if (!context.cms[methodName]) {
|
|
48
|
+
throw new _error.default(`Unknown context.cms method "${methodName}". Could not fetch content entries.`, "UNKNOWN_METHOD_ERROR", {
|
|
49
|
+
type,
|
|
50
|
+
methodName
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return context.cms[methodName];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Function to get the list of content entries depending on latest, published or exact GraphQL queries.
|
|
57
|
+
*/
|
|
58
|
+
var GetContentEntryMethods;
|
|
59
|
+
(function (GetContentEntryMethods) {
|
|
60
|
+
GetContentEntryMethods["getLatestEntriesByIds"] = "getLatestEntriesByIds";
|
|
61
|
+
GetContentEntryMethods["getPublishedEntriesByIds"] = "getPublishedEntriesByIds";
|
|
62
|
+
GetContentEntryMethods["getEntriesByIds"] = "getEntriesByIds";
|
|
63
|
+
})(GetContentEntryMethods || (GetContentEntryMethods = {}));
|
|
64
|
+
const getContentEntriesMethods = {
|
|
65
|
+
latest: "getLatestEntriesByIds",
|
|
66
|
+
published: "getPublishedEntriesByIds",
|
|
67
|
+
exact: "getEntriesByIds"
|
|
68
|
+
};
|
|
69
|
+
const getContentEntries = async params => {
|
|
70
|
+
const {
|
|
71
|
+
args,
|
|
72
|
+
context,
|
|
73
|
+
type
|
|
74
|
+
} = params;
|
|
75
|
+
const method = getFetchMethod(type, context);
|
|
76
|
+
const models = await context.cms.listModels();
|
|
77
|
+
const modelsMap = models.reduce((collection, model) => {
|
|
78
|
+
collection[model.modelId] = model;
|
|
79
|
+
return collection;
|
|
80
|
+
}, {});
|
|
81
|
+
const argsEntries = args.entries;
|
|
82
|
+
const entriesByModel = argsEntries.reduce((collection, ref) => {
|
|
83
|
+
if (!collection[ref.modelId]) {
|
|
84
|
+
collection[ref.modelId] = [];
|
|
85
|
+
} else if (collection[ref.modelId].includes(ref.id)) {
|
|
86
|
+
return collection;
|
|
87
|
+
}
|
|
88
|
+
collection[ref.modelId].push(ref.id);
|
|
89
|
+
return collection;
|
|
90
|
+
}, {});
|
|
91
|
+
const getters = Object.keys(entriesByModel).map(async modelId => {
|
|
92
|
+
return method(modelsMap[modelId], entriesByModel[modelId]);
|
|
93
|
+
});
|
|
94
|
+
if (getters.length === 0) {
|
|
95
|
+
return new _handlerGraphql.Response([]);
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const results = await Promise.all(getters);
|
|
99
|
+
const entries = results.reduce((collection, items) => {
|
|
100
|
+
return collection.concat(items.map(item => {
|
|
101
|
+
const model = modelsMap[item.modelId];
|
|
102
|
+
return createCmsEntryRecord(model, item);
|
|
103
|
+
}));
|
|
104
|
+
}, []).filter(Boolean);
|
|
105
|
+
return new _handlerGraphql.Response(entries);
|
|
106
|
+
} catch (ex) {
|
|
107
|
+
return new _handlerGraphql.ErrorResponse(ex);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Function to fetch a single content entry depending on latest, published or exact GraphQL query.
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
const getContentEntry = async params => {
|
|
116
|
+
const {
|
|
117
|
+
args,
|
|
118
|
+
context,
|
|
119
|
+
type
|
|
120
|
+
} = params;
|
|
121
|
+
if (!getContentEntriesMethods[type]) {
|
|
122
|
+
throw new _error.default(`Unknown getContentEntry method "${type}". Could not fetch content entry.`, "UNKNOWN_METHOD_ERROR", {
|
|
123
|
+
args,
|
|
124
|
+
type
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const method = getFetchMethod(type, context);
|
|
128
|
+
const {
|
|
129
|
+
modelId,
|
|
130
|
+
id
|
|
131
|
+
} = args.entry;
|
|
132
|
+
const models = await context.cms.listModels();
|
|
133
|
+
const model = models.find(m => m.modelId === modelId);
|
|
134
|
+
if (!model) {
|
|
135
|
+
return new _apiSecurity.NotAuthorizedResponse({
|
|
136
|
+
data: {
|
|
137
|
+
modelId
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const result = await method(model, [id]);
|
|
142
|
+
const entry = result.shift();
|
|
143
|
+
if (!entry) {
|
|
144
|
+
return new _handlerGraphql.Response(null);
|
|
145
|
+
}
|
|
146
|
+
return new _handlerGraphql.Response(createCmsEntryRecord(model, entry));
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* As we support description field, we need to transform the value from storage.
|
|
150
|
+
*/
|
|
151
|
+
const createResolveDescription = () => {
|
|
152
|
+
return async (parent, _, context) => {
|
|
153
|
+
const models = await context.cms.listModels();
|
|
154
|
+
const model = models.find(({
|
|
155
|
+
modelId
|
|
156
|
+
}) => {
|
|
157
|
+
return parent.model.modelId === modelId;
|
|
158
|
+
});
|
|
159
|
+
if (!model) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);
|
|
163
|
+
if (!field) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const value = parent.description || parent[field.fieldId];
|
|
167
|
+
if (!value) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return (0, _entryStorage.entryFieldFromStorageTransform)({
|
|
171
|
+
context,
|
|
172
|
+
model,
|
|
173
|
+
field,
|
|
174
|
+
value
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
const createContentEntriesSchema = ({
|
|
179
|
+
context
|
|
180
|
+
}) => {
|
|
181
|
+
if (!context.cms.MANAGE) {
|
|
182
|
+
const plugin = new _plugins.CmsGraphQLSchemaPlugin({
|
|
183
|
+
typeDefs: "",
|
|
184
|
+
resolvers: {}
|
|
185
|
+
});
|
|
186
|
+
plugin.name = `headless-cms.graphql.schema.${context.cms.type}.empty`;
|
|
187
|
+
return plugin;
|
|
188
|
+
}
|
|
189
|
+
const plugin = new _plugins.CmsGraphQLSchemaPlugin({
|
|
190
|
+
typeDefs: /* GraphQL */`
|
|
191
|
+
type CmsModelMeta {
|
|
192
|
+
modelId: String!
|
|
193
|
+
name: String!
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
type CmsPublishedContentEntry {
|
|
197
|
+
id: ID!
|
|
198
|
+
entryId: String!
|
|
199
|
+
title: String
|
|
200
|
+
description: String
|
|
201
|
+
image: String
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
type CmsContentEntry {
|
|
205
|
+
id: ID!
|
|
206
|
+
entryId: String!
|
|
207
|
+
model: CmsModelMeta!
|
|
208
|
+
status: String!
|
|
209
|
+
title: String!
|
|
210
|
+
description: String
|
|
211
|
+
image: String
|
|
212
|
+
createdBy: CmsIdentity!
|
|
213
|
+
ownedBy: CmsIdentity!
|
|
214
|
+
modifiedBy: CmsIdentity
|
|
215
|
+
published: CmsPublishedContentEntry
|
|
216
|
+
createdOn: DateTime!
|
|
217
|
+
savedOn: DateTime!
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
type CmsContentEntriesResponse {
|
|
221
|
+
data: [CmsContentEntry!]
|
|
222
|
+
error: CmsError
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
type CmsContentEntryResponse {
|
|
226
|
+
data: CmsContentEntry
|
|
227
|
+
error: CmsError
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
input CmsModelEntryInput {
|
|
231
|
+
modelId: ID!
|
|
232
|
+
id: ID!
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
extend type Query {
|
|
236
|
+
# Search content entries for given content models using the query string.
|
|
237
|
+
searchContentEntries(
|
|
238
|
+
modelIds: [ID!]!
|
|
239
|
+
query: String
|
|
240
|
+
fields: [String!]
|
|
241
|
+
limit: Int
|
|
242
|
+
): CmsContentEntriesResponse!
|
|
243
|
+
|
|
244
|
+
# Get content entry meta data
|
|
245
|
+
getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!
|
|
246
|
+
|
|
247
|
+
getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!
|
|
248
|
+
getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!
|
|
249
|
+
|
|
250
|
+
# Get content entries meta data
|
|
251
|
+
getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!
|
|
252
|
+
getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!
|
|
253
|
+
getPublishedContentEntries(
|
|
254
|
+
entries: [CmsModelEntryInput!]!
|
|
255
|
+
): CmsContentEntriesResponse!
|
|
256
|
+
}
|
|
257
|
+
`,
|
|
258
|
+
resolvers: {
|
|
259
|
+
CmsContentEntry: {
|
|
260
|
+
published: async (parent, _, context) => {
|
|
261
|
+
try {
|
|
262
|
+
const models = await context.cms.listModels();
|
|
263
|
+
const model = models.find(({
|
|
264
|
+
modelId
|
|
265
|
+
}) => {
|
|
266
|
+
return parent.model.modelId === modelId;
|
|
267
|
+
});
|
|
268
|
+
if (!model) {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
const [entry] = await context.cms.getPublishedEntriesByIds(model, [parent.id]);
|
|
272
|
+
if (!entry) {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
return createCmsEntryRecord(model, entry);
|
|
276
|
+
} catch (ex) {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
description: createResolveDescription()
|
|
281
|
+
},
|
|
282
|
+
CmsPublishedContentEntry: {
|
|
283
|
+
description: createResolveDescription()
|
|
284
|
+
},
|
|
285
|
+
Query: {
|
|
286
|
+
async searchContentEntries(_, args, context) {
|
|
287
|
+
const {
|
|
288
|
+
modelIds,
|
|
289
|
+
fields,
|
|
290
|
+
query,
|
|
291
|
+
limit = 10
|
|
292
|
+
} = args;
|
|
293
|
+
const models = await context.cms.listModels();
|
|
294
|
+
const getters = models.filter(model => modelIds.includes(model.modelId)).map(async model => {
|
|
295
|
+
const modelManager = await context.cms.getModelManager(model.modelId);
|
|
296
|
+
const where = {};
|
|
297
|
+
const [items] = await modelManager.listLatest({
|
|
298
|
+
limit,
|
|
299
|
+
where,
|
|
300
|
+
search: !!query ? query : undefined,
|
|
301
|
+
fields: fields || []
|
|
302
|
+
});
|
|
303
|
+
return items.map(entry => {
|
|
304
|
+
return createCmsEntryRecord(model, entry);
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
try {
|
|
308
|
+
const entries = await Promise.all(getters).then(results => results.reduce((result, item) => result.concat(item), []));
|
|
309
|
+
return new _handlerGraphql.Response(entries.sort((a, b) => b.savedOn.getTime() - a.savedOn.getTime()).slice(0, limit));
|
|
310
|
+
} catch (ex) {
|
|
311
|
+
return new _handlerGraphql.ErrorResponse(ex);
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
async getContentEntry(_, args, context) {
|
|
315
|
+
return getContentEntry({
|
|
316
|
+
args,
|
|
317
|
+
context,
|
|
318
|
+
type: "exact"
|
|
319
|
+
});
|
|
320
|
+
},
|
|
321
|
+
async getLatestContentEntry(_, args, context) {
|
|
322
|
+
return getContentEntry({
|
|
323
|
+
args,
|
|
324
|
+
context,
|
|
325
|
+
type: "latest"
|
|
326
|
+
});
|
|
327
|
+
},
|
|
328
|
+
async getPublishedContentEntry(_, args, context) {
|
|
329
|
+
return getContentEntry({
|
|
330
|
+
args,
|
|
331
|
+
context,
|
|
332
|
+
type: "published"
|
|
333
|
+
});
|
|
334
|
+
},
|
|
335
|
+
async getContentEntries(_, args, context) {
|
|
336
|
+
return getContentEntries({
|
|
337
|
+
args,
|
|
338
|
+
context,
|
|
339
|
+
type: "exact"
|
|
340
|
+
});
|
|
341
|
+
},
|
|
342
|
+
async getLatestContentEntries(_, args, context) {
|
|
343
|
+
return getContentEntries({
|
|
344
|
+
args,
|
|
345
|
+
context,
|
|
346
|
+
type: "latest"
|
|
347
|
+
});
|
|
348
|
+
},
|
|
349
|
+
async getPublishedContentEntries(_, args, context) {
|
|
350
|
+
return getContentEntries({
|
|
351
|
+
args,
|
|
352
|
+
context,
|
|
353
|
+
type: "published"
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-entries`;
|
|
360
|
+
return plugin;
|
|
361
|
+
};
|
|
362
|
+
exports.createContentEntriesSchema = createContentEntriesSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createDate","date","Date","createCmsEntryRecord","model","entry","id","entryId","modelId","name","status","title","getEntryTitle","description","getEntryDescription","image","getEntryImage","createdBy","modifiedBy","createdOn","savedOn","getFetchMethod","type","context","getContentEntriesMethods","WebinyError","methodName","cms","GetContentEntryMethods","latest","published","exact","getContentEntries","params","args","method","models","listModels","modelsMap","reduce","collection","argsEntries","entries","entriesByModel","ref","includes","push","getters","Object","keys","map","length","Response","results","Promise","all","items","concat","item","filter","Boolean","ex","ErrorResponse","getContentEntry","find","m","NotAuthorizedResponse","data","result","shift","createResolveDescription","parent","_","field","fields","f","fieldId","descriptionFieldId","value","entryFieldFromStorageTransform","createContentEntriesSchema","MANAGE","plugin","CmsGraphQLSchemaPlugin","typeDefs","resolvers","CmsContentEntry","getPublishedEntriesByIds","CmsPublishedContentEntry","Query","searchContentEntries","modelIds","query","limit","modelManager","getModelManager","where","listLatest","search","undefined","then","sort","a","b","getTime","slice","getLatestContentEntry","getPublishedContentEntry","getLatestContentEntries","getPublishedContentEntries"],"sources":["contentEntries.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport { CmsEntry, CmsContext, CmsModel, CmsEntryListWhere, CmsIdentity } from \"~/types\";\nimport { NotAuthorizedResponse } from \"@webiny/api-security\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { getEntryDescription } from \"~/utils/getEntryDescription\";\nimport { getEntryImage } from \"~/utils/getEntryImage\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage\";\nimport { Resolvers } from \"@webiny/handler-graphql/types\";\n\ninterface EntriesByModel {\n [key: string]: string[];\n}\n\ntype GetContentEntryType = \"latest\" | \"published\" | \"exact\";\n\nconst createDate = (date: string): Date => {\n try {\n return new Date(date);\n } catch {}\n return new Date();\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 description?: string | null;\n image?: string | null;\n createdBy: CmsIdentity;\n modifiedBy?: CmsIdentity | null;\n /**\n * We can use the number since it is an internal field.\n * Created via Date.parse() method.\n */\n createdOn: Date;\n savedOn: Date;\n}\n\nconst createCmsEntryRecord = (model: CmsModel, entry: CmsEntry): CmsEntryRecord => {\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 description: getEntryDescription(model, entry),\n image: getEntryImage(model, entry),\n createdBy: entry.createdBy,\n modifiedBy: entry.modifiedBy,\n createdOn: createDate(entry.createdOn),\n savedOn: createDate(entry.savedOn)\n };\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 (\n params: GetContentEntriesParams\n): Promise<Response | ErrorResponse> => {\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 try {\n const results = await Promise.all(getters);\n\n const entries = results\n .reduce<CmsEntryRecord[]>((collection, items) => {\n return collection.concat(\n items.map(item => {\n const model = modelsMap[item.modelId];\n\n return createCmsEntryRecord(model, item);\n })\n );\n }, [])\n .filter(Boolean);\n\n return new Response(entries);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\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<CmsEntryRecord | null> | 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(createCmsEntryRecord(model, entry));\n};\n/**\n * As we support description field, we need to transform the value from storage.\n */\nconst createResolveDescription = (): Resolvers<CmsContext> => {\n return async (parent, _, context) => {\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 field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return null;\n }\n const value = parent.description || parent[field.fieldId];\n if (!value) {\n return null;\n }\n return entryFieldFromStorageTransform({\n context,\n model,\n field,\n value\n });\n };\n};\n\ninterface Params {\n context: CmsContext;\n}\nexport const createContentEntriesSchema = ({\n context\n}: Params): CmsGraphQLSchemaPlugin<CmsContext> => {\n if (!context.cms.MANAGE) {\n const plugin = new CmsGraphQLSchemaPlugin({\n typeDefs: \"\",\n resolvers: {}\n });\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.empty`;\n return plugin;\n }\n\n const plugin = new CmsGraphQLSchemaPlugin({\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 description: String\n image: String\n }\n\n type CmsContentEntry {\n id: ID!\n entryId: String!\n model: CmsModelMeta!\n status: String!\n title: String!\n description: String\n image: String\n createdBy: CmsIdentity!\n ownedBy: CmsIdentity!\n modifiedBy: CmsIdentity\n published: CmsPublishedContentEntry\n createdOn: DateTime!\n savedOn: DateTime!\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 createCmsEntryRecord(model, entry);\n } catch (ex) {\n return null;\n }\n },\n description: createResolveDescription()\n },\n CmsPublishedContentEntry: {\n description: createResolveDescription()\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 createCmsEntryRecord(model, entry);\n });\n });\n\n try {\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) => b.savedOn.getTime() - a.savedOn.getTime())\n .slice(0, limit)\n );\n } catch (ex) {\n return new ErrorResponse(ex);\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 plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-entries`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AASA,MAAMA,U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CAAC;IACF,IAAI,CAACJ,KAAK,EAAE;MACR,OAAO,IAAI;IACf;IACA,MAAMqE,KAAK,GAAGrE,KAAK,CAACsE,MAAM,CAACV,IAAI,CAACW,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKxE,KAAK,CAACyE,kBAAkB,CAAC;IAC5E,IAAI,CAACJ,KAAK,EAAE;MACR,OAAO,IAAI;IACf;IACA,MAAMK,KAAK,GAAGP,MAAM,CAAC1D,WAAW,IAAI0D,MAAM,CAACE,KAAK,CAACG,OAAO,CAAC;IACzD,IAAI,CAACE,KAAK,EAAE;MACR,OAAO,IAAI;IACf;IACA,OAAO,IAAAC,4CAA8B,EAAC;MAClCxD,OAAO;MACPnB,KAAK;MACLqE,KAAK;MACLK;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAKM,MAAME,0BAA0B,GAAG,CAAC;EACvCzD;AACI,CAAC,KAAyC;EAC9C,IAAI,CAACA,OAAO,CAACI,GAAG,CAACsD,MAAM,EAAE;IACrB,MAAMC,MAAM,GAAG,IAAIC,+BAAsB,CAAC;MACtCC,QAAQ,EAAE,EAAE;MACZC,SAAS,EAAE,CAAC;IAChB,CAAC,CAAC;IACFH,MAAM,CAACzE,IAAI,GAAI,+BAA8Bc,OAAO,CAACI,GAAG,CAACL,IAAK,QAAO;IACrE,OAAO4D,MAAM;EACjB;EAEA,MAAMA,MAAM,GAAG,IAAIC,+BAAsB,CAAC;IACtCC,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;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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AC,CAAC;QACN,CAAC;QACD,MAAMoF,qBAAqB,CAAClC,CAAC,EAAEtC,IAAS,EAAEX,OAAO,EAAE;UAC/C,OAAOwC,eAAe,CAAC;YACnB7B,IAAI;YACJX,OAAO;YACPD,IAAI,EAAE;UACV,CAAC,CAAC;QACN,CAAC;QACD,MAAMqF,wBAAwB,CAACnC,CAAC,EAAEtC,IAAS,EAAEX,OAAO,EAAE;UAClD,OAAOwC,eAAe,CAAC;YACnB7B,IAAI;YACJX,OAAO;YACPD,IAAI,EAAE;UACV,CAAC,CAAC;QACN,CAAC;QACD,MAAMU,iBAAiB,CAACwC,CAAC,EAAEtC,IAAS,EAAEX,OAAO,EAAE;UAC3C,OAAOS,iBAAiB,CAAC;YACrBE,IAAI;YACJX,OAAO;YACPD,IAAI,EAAE;UACV,CAAC,CAAC;QACN,CAAC;QACD,MAAMsF,uBAAuB,CAACpC,CAAC,EAAEtC,IAAS,EAAEX,OAAO,EAAE;UACjD,OAAOS,iBAAiB,CAAC;YACrBE,IAAI;YACJX,OAAO;YACPD,IAAI,EAAE;UACV,CAAC,CAAC;QACN,CAAC;QACD,MAAMuF,0BAA0B,CAACrC,CAAC,EAAEtC,IAAS,EAAEX,OAAO,EAAE;UACpD,OAAOS,iBAAiB,CAAC;YACrBE,IAAI;YACJX,OAAO;YACPD,IAAI,EAAE;UACV,CAAC,CAAC;QACN;MACJ;IACJ;EACJ,CAAC,CAAC;EAEF4D,MAAM,CAACzE,IAAI,GAAI,+BAA8Bc,OAAO,CAACI,GAAG,CAACL,IAAK,kBAAiB;EAE/E,OAAO4D,MAAM;AACjB,CAAC;AAAC"}
|
|
@@ -3,21 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.createGroupsSchema = void 0;
|
|
8
7
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const plugin = context => {
|
|
8
|
+
var _CmsGroupPlugin = require("../../plugins/CmsGroupPlugin");
|
|
9
|
+
var _plugins = require("../../plugins");
|
|
10
|
+
const createGroupsSchema = ({
|
|
11
|
+
context
|
|
12
|
+
}) => {
|
|
15
13
|
let manageSchema = "";
|
|
16
|
-
|
|
17
14
|
if (context.cms.MANAGE) {
|
|
18
|
-
manageSchema =
|
|
19
|
-
/* GraphQL */
|
|
20
|
-
`
|
|
15
|
+
manageSchema = /* GraphQL */`
|
|
21
16
|
input CmsContentModelGroupInput {
|
|
22
17
|
name: String!
|
|
23
18
|
slug: String
|
|
@@ -55,23 +50,34 @@ const plugin = context => {
|
|
|
55
50
|
}
|
|
56
51
|
`;
|
|
57
52
|
}
|
|
58
|
-
|
|
59
53
|
let resolvers = {};
|
|
60
|
-
|
|
61
54
|
if (context.cms.MANAGE) {
|
|
62
55
|
resolvers = {
|
|
63
56
|
CmsContentModelGroup: {
|
|
64
57
|
contentModels: async (group, _, context) => {
|
|
65
|
-
const models = await context.
|
|
66
|
-
|
|
58
|
+
const models = await context.security.withoutAuthorization(async () => {
|
|
59
|
+
return context.cms.listModels();
|
|
60
|
+
});
|
|
61
|
+
return models.filter(model => {
|
|
62
|
+
if (model.isPrivate === true) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return model.group.id === group.id;
|
|
66
|
+
});
|
|
67
67
|
},
|
|
68
68
|
totalContentModels: async (group, _, context) => {
|
|
69
|
-
const models = await context.
|
|
70
|
-
|
|
69
|
+
const models = await context.security.withoutAuthorization(async () => {
|
|
70
|
+
return context.cms.listModels();
|
|
71
|
+
});
|
|
72
|
+
return models.filter(model => {
|
|
73
|
+
if (model.isPrivate === true) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return model.group === group.id;
|
|
77
|
+
}).length;
|
|
71
78
|
},
|
|
72
79
|
plugin: async (group, _, context) => {
|
|
73
|
-
|
|
74
|
-
return Boolean(groupPlugin);
|
|
80
|
+
return context.plugins.byType(_CmsGroupPlugin.CmsGroupPlugin.type).some(item => item.contentModelGroup.id === group.id);
|
|
75
81
|
}
|
|
76
82
|
},
|
|
77
83
|
Query: {
|
|
@@ -80,16 +86,19 @@ const plugin = context => {
|
|
|
80
86
|
const {
|
|
81
87
|
id
|
|
82
88
|
} = args;
|
|
83
|
-
const
|
|
84
|
-
|
|
89
|
+
const group = await context.cms.getGroup(id);
|
|
90
|
+
if (group !== null && group !== void 0 && group.isPrivate) {
|
|
91
|
+
throw new _handlerGraphql.NotFoundError(`Cms Group "${id}" was not found!`);
|
|
92
|
+
}
|
|
93
|
+
return new _handlerGraphql.Response(group);
|
|
85
94
|
} catch (e) {
|
|
86
95
|
return new _handlerGraphql.ErrorResponse(e);
|
|
87
96
|
}
|
|
88
97
|
},
|
|
89
98
|
listContentModelGroups: async (_, __, context) => {
|
|
90
99
|
try {
|
|
91
|
-
const
|
|
92
|
-
return new _handlerGraphql.Response(
|
|
100
|
+
const groups = await context.cms.listGroups();
|
|
101
|
+
return new _handlerGraphql.Response(groups.filter(group => group.isPrivate !== true));
|
|
93
102
|
} catch (e) {
|
|
94
103
|
return new _handlerGraphql.ErrorResponse(e);
|
|
95
104
|
}
|
|
@@ -123,11 +132,8 @@ const plugin = context => {
|
|
|
123
132
|
}
|
|
124
133
|
};
|
|
125
134
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
typeDefs:
|
|
129
|
-
/* GraphQL */
|
|
130
|
-
`
|
|
135
|
+
const plugin = new _plugins.CmsGraphQLSchemaPlugin({
|
|
136
|
+
typeDefs: /* GraphQL */`
|
|
131
137
|
type CmsContentModelGroup {
|
|
132
138
|
id: ID!
|
|
133
139
|
createdOn: DateTime
|
|
@@ -138,7 +144,7 @@ const plugin = context => {
|
|
|
138
144
|
slug: String!
|
|
139
145
|
description: String
|
|
140
146
|
icon: String
|
|
141
|
-
createdBy:
|
|
147
|
+
createdBy: CmsIdentity
|
|
142
148
|
|
|
143
149
|
# Returns true if the content model group is registered via a plugin.
|
|
144
150
|
plugin: Boolean!
|
|
@@ -147,7 +153,7 @@ const plugin = context => {
|
|
|
147
153
|
`,
|
|
148
154
|
resolvers
|
|
149
155
|
});
|
|
156
|
+
plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-model-groups`;
|
|
157
|
+
return plugin;
|
|
150
158
|
};
|
|
151
|
-
|
|
152
|
-
var _default = plugin;
|
|
153
|
-
exports.default = _default;
|
|
159
|
+
exports.createGroupsSchema = createGroupsSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createGroupsSchema","context","manageSchema","cms","MANAGE","resolvers","CmsContentModelGroup","contentModels","group","_","models","security","withoutAuthorization","listModels","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","CmsGraphQLSchemaPlugin","typeDefs","name"],"sources":["contentModelGroups.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/handler-graphql\";\nimport { CmsContext } from \"~/types\";\nimport { Resolvers } from \"@webiny/handler-graphql/types\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\n\ninterface Params {\n context: CmsContext;\n}\nexport const createGroupsSchema = ({ context }: Params): CmsGraphQLSchemaPlugin => {\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 const models = await context.security.withoutAuthorization(async () => {\n return context.cms.listModels();\n });\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 const models = await context.security.withoutAuthorization(async () => {\n return context.cms.listModels();\n });\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 const plugin = new CmsGraphQLSchemaPlugin({\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: CmsIdentity\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 plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-model-groups`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA;AAGA;AACA;AAKO,MAAMA,kBAAkB,GAAG,CAAC;EAAEC;AAAgB,CAAC,KAA6B;EAC/E,IAAIC,YAAY,GAAG,EAAE;EACrB,IAAID,OAAO,CAACE,GAAG,CAACC,MAAM,EAAE;IACpBF,YAAY,GAAG,aAAe;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,SAAS;EACL;EAEA,IAAIG,SAAgC,GAAG,CAAC,CAAC;EAEzC,IAAIJ,OAAO,CAACE,GAAG,CAACC,MAAM,EAAE;IACpBC,SAAS,GAAG;MACRC,oBAAoB,EAAE;QAClBC,aAAa,EAAE,OAAOC,KAAK,EAAEC,CAAC,EAAER,OAAO,KAAK;UACxC,MAAMS,MAAM,GAAG,MAAMT,OAAO,CAACU,QAAQ,CAACC,oBAAoB,CAAC,YAAY;YACnE,OAAOX,OAAO,CAACE,GAAG,CAACU,UAAU,EAAE;UACnC,CAAC,CAAC;UACF,OAAOH,MAAM,CAACI,MAAM,CAACC,KAAK,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