@webiny/api-headless-cms 5.29.0 → 5.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.d.ts +3 -0
- package/{content/contextSetup.js → context.js} +13 -8
- package/context.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.js +0 -0
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.js.map +0 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.js +0 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.js.map +0 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.js +0 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.js.map +0 -0
- package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.js +7 -1
- package/crud/contentEntry/entryDataValidation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.js +1 -1
- package/crud/contentEntry/markLockedFields.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/referenceFieldsMapping.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry/referenceFieldsMapping.js +0 -0
- package/{content/plugins/crud → crud}/contentEntry/referenceFieldsMapping.js.map +0 -0
- package/{content/plugins/crud → crud}/contentEntry.crud.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentEntry.crud.js +68 -42
- package/crud/contentEntry.crud.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/afterCreate.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreate.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreateFrom.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/afterCreateFrom.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreateFrom.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterDelete.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/afterDelete.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterDelete.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterUpdate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/afterUpdate.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/afterUpdate.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/beforeCreate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/beforeCreate.js +1 -1
- package/crud/contentModel/beforeCreate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.js +1 -1
- package/crud/contentModel/beforeDelete.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/beforeUpdate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/beforeUpdate.js +0 -0
- package/crud/contentModel/beforeUpdate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js.map +0 -0
- package/crud/contentModel/createFieldModels.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/createFieldModels.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/createFieldModels.js.map +0 -0
- package/crud/contentModel/idValidation.d.ts +1 -0
- package/{content/plugins/crud → crud}/contentModel/idValidation.js +3 -3
- package/crud/contentModel/idValidation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/models.d.ts +0 -0
- package/{content/plugins/crud → crud}/contentModel/models.js +2 -2
- package/crud/contentModel/models.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/validateLayout.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/validateLayout.js +0 -0
- package/{content/plugins/crud → crud}/contentModel/validateLayout.js.map +0 -0
- package/{content/plugins/crud → crud}/contentModel/validateModelFields.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel/validateModelFields.js +2 -2
- package/crud/contentModel/validateModelFields.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel.crud.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModel.crud.js +14 -12
- package/crud/contentModel.crud.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.js +5 -5
- package/crud/contentModelGroup/beforeCreate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.js +1 -1
- package/crud/contentModelGroup/beforeDelete.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.js +1 -1
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup.crud.d.ts +1 -1
- package/{content/plugins/crud → crud}/contentModelGroup.crud.js +15 -13
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/crud/index.d.ts +6 -0
- package/{content/plugins/crud → crud}/index.js +5 -17
- package/crud/index.js.map +1 -0
- package/{plugins/crud → crud}/settings.crud.d.ts +1 -1
- package/{plugins/crud → crud}/settings.crud.js +3 -7
- package/crud/settings.crud.js.map +1 -0
- package/{plugins/crud → crud}/system.crud.d.ts +1 -1
- package/{plugins/crud → crud}/system.crud.js +0 -0
- package/{plugins/crud → crud}/system.crud.js.map +0 -0
- package/{content/plugins → graphql}/buildSchemaPlugins.d.ts +2 -3
- package/graphql/buildSchemaPlugins.js +27 -0
- package/graphql/buildSchemaPlugins.js.map +1 -0
- package/graphql/graphQLHandlerFactory.d.ts +5 -0
- package/{content → graphql}/graphQLHandlerFactory.js +26 -18
- package/graphql/graphQLHandlerFactory.js.map +1 -0
- package/graphql/index.d.ts +5 -0
- package/graphql/index.js +57 -0
- package/graphql/index.js.map +1 -0
- package/graphql/schema/baseContentSchema.d.ts +3 -0
- package/{content/plugins/schema/baseSchema.js → graphql/schema/baseContentSchema.js} +3 -27
- package/graphql/schema/baseContentSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +3 -0
- package/{content/plugins → graphql}/schema/contentEntries.js +5 -58
- package/graphql/schema/contentEntries.js.map +1 -0
- package/graphql/schema/contentModelGroups.d.ts +3 -0
- package/{content/plugins → graphql}/schema/contentModelGroups.js +27 -11
- package/graphql/schema/contentModelGroups.js.map +1 -0
- package/graphql/schema/contentModels.d.ts +3 -0
- package/{content/plugins → graphql}/schema/contentModels.js +13 -7
- package/graphql/schema/contentModels.js.map +1 -0
- package/{content/plugins → graphql}/schema/createFieldResolvers.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createFieldResolvers.js +1 -1
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/{content/plugins → graphql}/schema/createManageResolvers.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createManageResolvers.js +7 -3
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/{content/plugins → graphql}/schema/createManageSDL.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createManageSDL.js +11 -7
- package/graphql/schema/createManageSDL.js.map +1 -0
- package/{content/plugins → graphql}/schema/createPreviewResolvers.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createPreviewResolvers.js +2 -2
- package/graphql/schema/createPreviewResolvers.js.map +1 -0
- package/{content/plugins → graphql}/schema/createReadResolvers.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createReadResolvers.js +2 -2
- package/graphql/schema/createReadResolvers.js.map +1 -0
- package/{content/plugins → graphql}/schema/createReadSDL.d.ts +1 -1
- package/{content/plugins → graphql}/schema/createReadSDL.js +6 -6
- package/graphql/schema/createReadSDL.js.map +1 -0
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +6 -0
- package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGet.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGet.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGet.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveList.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveList.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveList.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRepublish.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRepublish.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRepublish.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js.map +0 -0
- package/{content/plugins/schema/resolvers/read → graphql/schema/resolvers/preview}/resolveGet.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveGet.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveGet.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveList.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveList.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveList.js.map +0 -0
- package/{content/plugins/schema/resolvers/preview → graphql/schema/resolvers/read}/resolveGet.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/read/resolveGet.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveGet.js.map +0 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.d.ts +1 -1
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.js +0 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.js.map +0 -0
- package/{content/plugins → graphql}/schema/schemaPlugins.d.ts +1 -1
- package/{content/plugins → graphql}/schema/schemaPlugins.js +18 -5
- package/graphql/schema/schemaPlugins.js.map +1 -0
- package/graphql/system.d.ts +6 -0
- package/graphql/system.js +119 -0
- package/graphql/system.js.map +1 -0
- package/graphqlFields/boolean.d.ts +2 -0
- package/graphqlFields/boolean.js +69 -0
- package/graphqlFields/boolean.js.map +1 -0
- package/graphqlFields/datetime.d.ts +2 -0
- package/{content/plugins/graphqlFields → graphqlFields}/datetime.js +42 -40
- package/graphqlFields/datetime.js.map +1 -0
- package/graphqlFields/file.d.ts +2 -0
- package/graphqlFields/file.js +50 -0
- package/graphqlFields/file.js.map +1 -0
- package/{content/plugins/graphqlFields → graphqlFields}/helpers.d.ts +1 -1
- package/{content/plugins/graphqlFields → graphqlFields}/helpers.js +0 -0
- package/{content/plugins/graphqlFields → graphqlFields}/helpers.js.map +0 -0
- package/graphqlFields/index.d.ts +2 -0
- package/graphqlFields/index.js +28 -0
- package/graphqlFields/index.js.map +1 -0
- package/graphqlFields/longText.d.ts +2 -0
- package/graphqlFields/longText.js +63 -0
- package/graphqlFields/longText.js.map +1 -0
- package/graphqlFields/number.d.ts +2 -0
- package/graphqlFields/number.js +75 -0
- package/graphqlFields/number.js.map +1 -0
- package/graphqlFields/object.d.ts +2 -0
- package/graphqlFields/object.js +225 -0
- package/graphqlFields/object.js.map +1 -0
- package/graphqlFields/ref.d.ts +2 -0
- package/graphqlFields/ref.js +279 -0
- package/graphqlFields/ref.js.map +1 -0
- package/graphqlFields/richText.d.ts +2 -0
- package/graphqlFields/richText.js +56 -0
- package/graphqlFields/richText.js.map +1 -0
- package/graphqlFields/text.d.ts +2 -0
- package/graphqlFields/text.js +73 -0
- package/graphqlFields/text.js.map +1 -0
- package/index.d.ts +10 -17
- package/index.js +73 -56
- package/index.js.map +1 -1
- package/modelManager/DefaultCmsModelManager.d.ts +14 -0
- package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js +0 -0
- package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js.map +0 -0
- package/modelManager/index.d.ts +2 -0
- package/{content/plugins/modelManager → modelManager}/index.js +3 -3
- package/modelManager/index.js.map +1 -0
- package/package.json +26 -27
- package/parameters/context.d.ts +2 -0
- package/parameters/context.js +22 -0
- package/parameters/context.js.map +1 -0
- package/parameters/header.d.ts +2 -0
- package/parameters/header.js +55 -0
- package/parameters/header.js.map +1 -0
- package/parameters/index.d.ts +4 -0
- package/parameters/index.js +57 -0
- package/parameters/index.js.map +1 -0
- package/parameters/manual.d.ts +6 -0
- package/{plugins/context.js → parameters/manual.js} +27 -27
- package/parameters/manual.js.map +1 -0
- package/parameters/path.d.ts +2 -0
- package/parameters/path.js +54 -0
- package/parameters/path.js.map +1 -0
- package/{content/plugins → plugins}/CmsGroupPlugin.d.ts +1 -1
- package/{content/plugins → plugins}/CmsGroupPlugin.js +0 -0
- package/{content/plugins → plugins}/CmsGroupPlugin.js.map +0 -0
- package/{content/plugins → plugins}/CmsModelPlugin.d.ts +1 -1
- package/{content/plugins → plugins}/CmsModelPlugin.js +0 -0
- package/{content/plugins → plugins}/CmsModelPlugin.js.map +0 -0
- package/{content/plugins → plugins}/CmsParametersPlugin.d.ts +8 -3
- package/{content/plugins → plugins}/CmsParametersPlugin.js +0 -0
- package/plugins/CmsParametersPlugin.js.map +1 -0
- package/{content/plugins/storage → plugins}/StorageTransformPlugin.d.ts +2 -1
- package/{content/plugins/storage → plugins}/StorageTransformPlugin.js +1 -0
- package/plugins/StorageTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +4 -0
- package/plugins/index.js +57 -0
- package/plugins/index.js.map +1 -0
- package/storage/default.d.ts +2 -0
- package/storage/default.js +27 -0
- package/storage/default.js.map +1 -0
- package/storage/object.d.ts +2 -0
- package/{content/plugins/storage → storage}/object.js +63 -64
- package/storage/object.js.map +1 -0
- package/types.d.ts +28 -3
- package/types.js.map +1 -1
- package/upgrades/index.d.ts +1 -0
- package/upgrades/index.js +10 -0
- package/upgrades/index.js.map +1 -0
- package/utils/access.d.ts +8 -0
- package/utils/access.js +90 -0
- package/utils/access.js.map +1 -0
- package/{content/plugins/utils → utils}/createTypeName.d.ts +0 -0
- package/{content/plugins/utils → utils}/createTypeName.js +0 -0
- package/{content/plugins/utils → utils}/createTypeName.js.map +0 -0
- package/{content/plugins/utils → utils}/entryStorage.d.ts +1 -1
- package/{content/plugins/utils → utils}/entryStorage.js +1 -1
- package/utils/entryStorage.js.map +1 -0
- package/utils/filterAsync.d.ts +1 -0
- package/utils/filterAsync.js +23 -0
- package/utils/filterAsync.js.map +1 -0
- package/{content/plugins/utils → utils}/getEntryTitle.d.ts +1 -1
- package/{content/plugins/utils → utils}/getEntryTitle.js +0 -0
- package/{content/plugins/utils → utils}/getEntryTitle.js.map +0 -0
- package/{content/plugins/utils → utils}/getSchemaFromFieldPlugins.d.ts +1 -1
- package/{content/plugins/utils → utils}/getSchemaFromFieldPlugins.js +0 -0
- package/{content/plugins/utils → utils}/getSchemaFromFieldPlugins.js.map +0 -0
- package/utils/ownership.d.ts +8 -0
- package/utils/ownership.js +39 -0
- package/utils/ownership.js.map +1 -0
- package/utils/permissions.d.ts +7 -0
- package/utils/permissions.js +110 -0
- package/utils/permissions.js.map +1 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.d.ts +0 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.js +0 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.js.map +0 -0
- package/{content/plugins/utils → utils}/renderFields.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderFields.js +0 -0
- package/{content/plugins/utils → utils}/renderFields.js.map +0 -0
- package/{content/plugins/utils → utils}/renderGetFilterFields.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderGetFilterFields.js +0 -0
- package/{content/plugins/utils → utils}/renderGetFilterFields.js.map +0 -0
- package/{content/plugins/utils → utils}/renderInputFields.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderInputFields.js +0 -0
- package/{content/plugins/utils → utils}/renderInputFields.js.map +0 -0
- package/{content/plugins/utils → utils}/renderListFilterFields.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderListFilterFields.js +0 -0
- package/{content/plugins/utils → utils}/renderListFilterFields.js.map +0 -0
- package/{content/plugins/utils → utils}/renderSortEnum.d.ts +1 -1
- package/{content/plugins/utils → utils}/renderSortEnum.js +0 -0
- package/{content/plugins/utils → utils}/renderSortEnum.js.map +0 -0
- package/utils/toSlug.d.ts +1 -0
- package/utils/toSlug.js +20 -0
- package/utils/toSlug.js.map +1 -0
- package/validators/dateGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateGte.js +3 -3
- package/validators/dateGte.js.map +1 -0
- package/validators/dateLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateLte.js +3 -3
- package/validators/dateLte.js.map +1 -0
- package/validators/gte.d.ts +2 -0
- package/validators/gte.js +36 -0
- package/validators/gte.js.map +1 -0
- package/validators/in.d.ts +2 -0
- package/validators/in.js +36 -0
- package/validators/in.js.map +1 -0
- package/validators/index.d.ts +1 -0
- package/validators/index.js +36 -0
- package/validators/index.js.map +1 -0
- package/validators/lte.d.ts +2 -0
- package/validators/lte.js +36 -0
- package/validators/lte.js.map +1 -0
- package/validators/maxLength.d.ts +2 -0
- package/validators/maxLength.js +36 -0
- package/validators/maxLength.js.map +1 -0
- package/validators/minLength.d.ts +2 -0
- package/validators/minLength.js +36 -0
- package/validators/minLength.js.map +1 -0
- package/validators/pattern.d.ts +2 -0
- package/validators/pattern.js +50 -0
- package/validators/pattern.js.map +1 -0
- package/validators/patternPlugins/email.d.ts +2 -0
- package/validators/patternPlugins/email.js +20 -0
- package/validators/patternPlugins/email.js.map +1 -0
- package/validators/patternPlugins/index.d.ts +2 -0
- package/validators/patternPlugins/index.js +24 -0
- package/validators/patternPlugins/index.js.map +1 -0
- package/validators/patternPlugins/lowerCase.d.ts +2 -0
- package/validators/patternPlugins/lowerCase.js +20 -0
- package/validators/patternPlugins/lowerCase.js.map +1 -0
- package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/lowerCaseSpace.js +20 -0
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
- package/validators/patternPlugins/upperCase.d.ts +2 -0
- package/validators/patternPlugins/upperCase.js +20 -0
- package/validators/patternPlugins/upperCase.js.map +1 -0
- package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/upperCaseSpace.js +20 -0
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
- package/validators/patternPlugins/url.d.ts +2 -0
- package/validators/patternPlugins/url.js +20 -0
- package/validators/patternPlugins/url.js.map +1 -0
- package/validators/required.d.ts +2 -0
- package/validators/required.js +27 -0
- package/validators/required.js.map +1 -0
- package/validators/timeGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeGte.js +3 -3
- package/validators/timeGte.js.map +1 -0
- package/validators/timeLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeLte.js +3 -3
- package/validators/timeLte.js.map +1 -0
- package/{content/plugins/validators → validators}/unique.d.ts +2 -3
- package/{content/plugins/validators → validators}/unique.js +3 -3
- package/validators/unique.js.map +1 -0
- package/content/contextSetup.d.ts +0 -4
- package/content/contextSetup.js.map +0 -1
- package/content/graphQLHandlerFactory.d.ts +0 -5
- package/content/graphQLHandlerFactory.js.map +0 -1
- package/content/parameterPlugins.d.ts +0 -6
- package/content/parameterPlugins.js +0 -78
- package/content/parameterPlugins.js.map +0 -1
- package/content/plugins/CmsParametersPlugin.js.map +0 -1
- package/content/plugins/buildSchemaPlugins.js +0 -29
- package/content/plugins/buildSchemaPlugins.js.map +0 -1
- package/content/plugins/crud/contentEntry/entryDataValidation.js.map +0 -1
- package/content/plugins/crud/contentEntry/markLockedFields.js.map +0 -1
- package/content/plugins/crud/contentEntry.crud.js.map +0 -1
- package/content/plugins/crud/contentModel/beforeCreate.js.map +0 -1
- package/content/plugins/crud/contentModel/beforeDelete.js.map +0 -1
- package/content/plugins/crud/contentModel/beforeUpdate.js.map +0 -1
- package/content/plugins/crud/contentModel/createFieldModels.d.ts +0 -2
- package/content/plugins/crud/contentModel/idValidation.d.ts +0 -2
- package/content/plugins/crud/contentModel/idValidation.js.map +0 -1
- package/content/plugins/crud/contentModel/models.js.map +0 -1
- package/content/plugins/crud/contentModel/validateModelFields.js.map +0 -1
- package/content/plugins/crud/contentModel.crud.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/beforeCreate.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/beforeDelete.js.map +0 -1
- package/content/plugins/crud/contentModelGroup/beforeUpdate.js.map +0 -1
- package/content/plugins/crud/contentModelGroup.crud.js.map +0 -1
- package/content/plugins/crud/index.d.ts +0 -6
- package/content/plugins/crud/index.js.map +0 -1
- package/content/plugins/graphqlFields/boolean.d.ts +0 -3
- package/content/plugins/graphqlFields/boolean.js +0 -67
- package/content/plugins/graphqlFields/boolean.js.map +0 -1
- package/content/plugins/graphqlFields/datetime.d.ts +0 -3
- package/content/plugins/graphqlFields/datetime.js.map +0 -1
- package/content/plugins/graphqlFields/file.d.ts +0 -3
- package/content/plugins/graphqlFields/file.js +0 -48
- package/content/plugins/graphqlFields/file.js.map +0 -1
- package/content/plugins/graphqlFields/index.d.ts +0 -2
- package/content/plugins/graphqlFields/index.js +0 -30
- package/content/plugins/graphqlFields/index.js.map +0 -1
- package/content/plugins/graphqlFields/longText.d.ts +0 -3
- package/content/plugins/graphqlFields/longText.js +0 -61
- package/content/plugins/graphqlFields/longText.js.map +0 -1
- package/content/plugins/graphqlFields/number.d.ts +0 -3
- package/content/plugins/graphqlFields/number.js +0 -73
- package/content/plugins/graphqlFields/number.js.map +0 -1
- package/content/plugins/graphqlFields/object.d.ts +0 -3
- package/content/plugins/graphqlFields/object.js +0 -223
- package/content/plugins/graphqlFields/object.js.map +0 -1
- package/content/plugins/graphqlFields/ref.d.ts +0 -3
- package/content/plugins/graphqlFields/ref.js +0 -276
- package/content/plugins/graphqlFields/ref.js.map +0 -1
- package/content/plugins/graphqlFields/richText.d.ts +0 -3
- package/content/plugins/graphqlFields/richText.js +0 -54
- package/content/plugins/graphqlFields/richText.js.map +0 -1
- package/content/plugins/graphqlFields/text.d.ts +0 -3
- package/content/plugins/graphqlFields/text.js +0 -71
- package/content/plugins/graphqlFields/text.js.map +0 -1
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +0 -8
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +0 -55
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js.map +0 -1
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +0 -7
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +0 -36
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js.map +0 -1
- package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +0 -14
- package/content/plugins/modelManager/index.d.ts +0 -3
- package/content/plugins/modelManager/index.js.map +0 -1
- package/content/plugins/schema/baseSchema.d.ts +0 -4
- package/content/plugins/schema/baseSchema.js.map +0 -1
- package/content/plugins/schema/contentEntries.d.ts +0 -4
- package/content/plugins/schema/contentEntries.js.map +0 -1
- package/content/plugins/schema/contentModelGroups.d.ts +0 -4
- package/content/plugins/schema/contentModelGroups.js.map +0 -1
- package/content/plugins/schema/contentModels.d.ts +0 -4
- package/content/plugins/schema/contentModels.js.map +0 -1
- package/content/plugins/schema/createFieldResolvers.js.map +0 -1
- package/content/plugins/schema/createManageResolvers.js.map +0 -1
- package/content/plugins/schema/createManageSDL.js.map +0 -1
- package/content/plugins/schema/createPreviewResolvers.js.map +0 -1
- package/content/plugins/schema/createReadResolvers.js.map +0 -1
- package/content/plugins/schema/createReadSDL.js.map +0 -1
- package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +0 -6
- package/content/plugins/schema/schemaPlugins.js.map +0 -1
- package/content/plugins/storage/StorageTransformPlugin.js.map +0 -1
- package/content/plugins/storage/default.d.ts +0 -3
- package/content/plugins/storage/default.js +0 -28
- package/content/plugins/storage/default.js.map +0 -1
- package/content/plugins/storage/object.d.ts +0 -3
- package/content/plugins/storage/object.js.map +0 -1
- package/content/plugins/utils/entryStorage.js.map +0 -1
- package/content/plugins/validators/dateGte.d.ts +0 -3
- package/content/plugins/validators/dateGte.js.map +0 -1
- package/content/plugins/validators/dateLte.d.ts +0 -3
- package/content/plugins/validators/dateLte.js.map +0 -1
- package/content/plugins/validators/gte.d.ts +0 -3
- package/content/plugins/validators/gte.js +0 -34
- package/content/plugins/validators/gte.js.map +0 -1
- package/content/plugins/validators/in.d.ts +0 -3
- package/content/plugins/validators/in.js +0 -34
- package/content/plugins/validators/in.js.map +0 -1
- package/content/plugins/validators/index.d.ts +0 -2
- package/content/plugins/validators/index.js +0 -38
- package/content/plugins/validators/index.js.map +0 -1
- package/content/plugins/validators/lte.d.ts +0 -3
- package/content/plugins/validators/lte.js +0 -34
- package/content/plugins/validators/lte.js.map +0 -1
- package/content/plugins/validators/maxLength.d.ts +0 -3
- package/content/plugins/validators/maxLength.js +0 -34
- package/content/plugins/validators/maxLength.js.map +0 -1
- package/content/plugins/validators/minLength.d.ts +0 -3
- package/content/plugins/validators/minLength.js +0 -34
- package/content/plugins/validators/minLength.js.map +0 -1
- package/content/plugins/validators/pattern.d.ts +0 -3
- package/content/plugins/validators/pattern.js +0 -47
- package/content/plugins/validators/pattern.js.map +0 -1
- package/content/plugins/validators/patternPlugins/email.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/email.js +0 -17
- package/content/plugins/validators/patternPlugins/email.js.map +0 -1
- package/content/plugins/validators/patternPlugins/index.d.ts +0 -2
- package/content/plugins/validators/patternPlugins/index.js +0 -23
- package/content/plugins/validators/patternPlugins/index.js.map +0 -1
- package/content/plugins/validators/patternPlugins/lowerCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/lowerCase.js +0 -17
- package/content/plugins/validators/patternPlugins/lowerCase.js.map +0 -1
- package/content/plugins/validators/patternPlugins/lowerCaseSpace.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/lowerCaseSpace.js +0 -17
- package/content/plugins/validators/patternPlugins/lowerCaseSpace.js.map +0 -1
- package/content/plugins/validators/patternPlugins/upperCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/upperCase.js +0 -17
- package/content/plugins/validators/patternPlugins/upperCase.js.map +0 -1
- package/content/plugins/validators/patternPlugins/upperCaseSpace.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/upperCaseSpace.js +0 -17
- package/content/plugins/validators/patternPlugins/upperCaseSpace.js.map +0 -1
- package/content/plugins/validators/patternPlugins/url.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/url.js +0 -17
- package/content/plugins/validators/patternPlugins/url.js.map +0 -1
- package/content/plugins/validators/required.d.ts +0 -3
- package/content/plugins/validators/required.js +0 -25
- package/content/plugins/validators/required.js.map +0 -1
- package/content/plugins/validators/timeGte.d.ts +0 -3
- package/content/plugins/validators/timeGte.js.map +0 -1
- package/content/plugins/validators/timeLte.d.ts +0 -3
- package/content/plugins/validators/timeLte.js.map +0 -1
- package/content/plugins/validators/unique.js.map +0 -1
- package/migrateCMSPermissions.d.ts +0 -17
- package/migrateCMSPermissions.js +0 -199
- package/migrateCMSPermissions.js.map +0 -1
- package/plugins/context.d.ts +0 -4
- package/plugins/context.js.map +0 -1
- package/plugins/crud/index.d.ts +0 -6
- package/plugins/crud/index.js +0 -108
- package/plugins/crud/index.js.map +0 -1
- package/plugins/crud/settings.crud.js.map +0 -1
- package/plugins/graphql/system.d.ts +0 -18
- package/plugins/graphql/system.js +0 -74
- package/plugins/graphql/system.js.map +0 -1
- package/plugins/graphql.d.ts +0 -2
- package/plugins/graphql.js +0 -86
- package/plugins/graphql.js.map +0 -1
- package/plugins/upgrades/index.d.ts +0 -2
- package/plugins/upgrades/index.js +0 -14
- package/plugins/upgrades/index.js.map +0 -1
- package/plugins/upgrades/v5.5.0/helpers.d.ts +0 -6
- package/plugins/upgrades/v5.5.0/helpers.js +0 -10
- package/plugins/upgrades/v5.5.0/helpers.js.map +0 -1
- package/plugins/upgrades/v5.5.0/index.d.ts +0 -4
- package/plugins/upgrades/v5.5.0/index.js +0 -134
- package/plugins/upgrades/v5.5.0/index.js.map +0 -1
- package/transformers.d.ts +0 -2
- package/transformers.js +0 -25
- package/transformers.js.map +0 -1
- package/utils.d.ts +0 -23
- package/utils.js +0 -251
- package/utils.js.map +0 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createObjectField = void 0;
|
|
9
|
+
|
|
10
|
+
var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
|
|
11
|
+
|
|
12
|
+
var _renderFields = require("../utils/renderFields");
|
|
13
|
+
|
|
14
|
+
var _renderInputFields = require("../utils/renderInputFields");
|
|
15
|
+
|
|
16
|
+
var _createTypeName = require("../utils/createTypeName");
|
|
17
|
+
|
|
18
|
+
var _helpers = require("./helpers");
|
|
19
|
+
|
|
20
|
+
const typeFromField = params => {
|
|
21
|
+
var _field$settings;
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
typeOfType,
|
|
25
|
+
model,
|
|
26
|
+
type,
|
|
27
|
+
field,
|
|
28
|
+
fieldTypePlugins
|
|
29
|
+
} = params;
|
|
30
|
+
const typeSuffix = typeOfType === "input" ? "Input" : "";
|
|
31
|
+
const typeName = (0, _createTypeName.createTypeName)(model.modelId);
|
|
32
|
+
const mTypeName = (0, _createTypeName.createManageTypeName)(typeName); // `field` is an "object" field
|
|
33
|
+
|
|
34
|
+
const fields = ((_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.fields) || [];
|
|
35
|
+
const fieldTypeName = `${mTypeName}_${(0, _upperFirst.default)(field.fieldId)}`;
|
|
36
|
+
const typeFields = [];
|
|
37
|
+
const nestedTypes = []; // Once the loop below starts, we'll be executing a recursive "object" type generation.
|
|
38
|
+
// The main trick here is that nested objects don't know who the parent is, and will generate
|
|
39
|
+
// type names using the "model", as if they're at the top level:
|
|
40
|
+
// Every time the types are returned, we need to replace the model name in the generated type name
|
|
41
|
+
// with the actual prefix which includes parent field name type.
|
|
42
|
+
|
|
43
|
+
const replace = new RegExp(`${mTypeName}_`, "g");
|
|
44
|
+
|
|
45
|
+
for (const f of fields) {
|
|
46
|
+
const result = typeOfType === "type" ? (0, _renderFields.renderField)({
|
|
47
|
+
field: f,
|
|
48
|
+
type,
|
|
49
|
+
model,
|
|
50
|
+
fieldTypePlugins
|
|
51
|
+
}) : (0, _renderInputFields.renderInputField)({
|
|
52
|
+
field: f,
|
|
53
|
+
model,
|
|
54
|
+
fieldTypePlugins
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (!result) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const {
|
|
62
|
+
fields,
|
|
63
|
+
typeDefs
|
|
64
|
+
} = result;
|
|
65
|
+
typeFields.push(fields.replace(replace, `${fieldTypeName}_`));
|
|
66
|
+
|
|
67
|
+
if (typeDefs) {
|
|
68
|
+
nestedTypes.push(typeDefs.replace(replace, `${fieldTypeName}_`));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
fieldType: `${fieldTypeName}${typeSuffix}`,
|
|
74
|
+
typeDefs:
|
|
75
|
+
/* GraphQL */
|
|
76
|
+
`
|
|
77
|
+
${nestedTypes.join("\n")}
|
|
78
|
+
|
|
79
|
+
${typeOfType} ${fieldTypeName}${typeSuffix} {
|
|
80
|
+
${typeFields.join("\n")}
|
|
81
|
+
}
|
|
82
|
+
`
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const createObjectField = () => {
|
|
87
|
+
return {
|
|
88
|
+
name: "cms-model-field-to-graphql-object",
|
|
89
|
+
type: "cms-model-field-to-graphql",
|
|
90
|
+
fieldType: "object",
|
|
91
|
+
isSortable: false,
|
|
92
|
+
isSearchable: false,
|
|
93
|
+
read: {
|
|
94
|
+
createTypeField({
|
|
95
|
+
field,
|
|
96
|
+
model,
|
|
97
|
+
fieldTypePlugins
|
|
98
|
+
}) {
|
|
99
|
+
const result = typeFromField({
|
|
100
|
+
typeOfType: "type",
|
|
101
|
+
model,
|
|
102
|
+
type: "read",
|
|
103
|
+
field,
|
|
104
|
+
fieldTypePlugins
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
if (!result) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const {
|
|
112
|
+
fieldType,
|
|
113
|
+
typeDefs
|
|
114
|
+
} = result;
|
|
115
|
+
return {
|
|
116
|
+
fields: `${field.fieldId}: ${field.multipleValues ? `[${fieldType}!]` : fieldType}`,
|
|
117
|
+
typeDefs
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
createResolver({
|
|
122
|
+
field,
|
|
123
|
+
createFieldResolvers,
|
|
124
|
+
graphQLType
|
|
125
|
+
}) {
|
|
126
|
+
var _field$settings2;
|
|
127
|
+
|
|
128
|
+
if (!((_field$settings2 = field.settings) !== null && _field$settings2 !== void 0 && _field$settings2.fields) || field.settings.fields.length === 0) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const fieldType = `${graphQLType}_${(0, _upperFirst.default)(field.fieldId)}`;
|
|
133
|
+
const typeResolvers = createFieldResolvers({
|
|
134
|
+
graphQLType: fieldType,
|
|
135
|
+
fields: field.settings.fields
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
resolver: null,
|
|
139
|
+
typeResolvers: typeResolvers || {}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
},
|
|
144
|
+
manage: {
|
|
145
|
+
createTypeField({
|
|
146
|
+
model,
|
|
147
|
+
field,
|
|
148
|
+
fieldTypePlugins
|
|
149
|
+
}) {
|
|
150
|
+
const result = typeFromField({
|
|
151
|
+
typeOfType: "type",
|
|
152
|
+
model,
|
|
153
|
+
type: "manage",
|
|
154
|
+
field,
|
|
155
|
+
fieldTypePlugins
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
if (!result) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const {
|
|
163
|
+
fieldType,
|
|
164
|
+
typeDefs
|
|
165
|
+
} = result;
|
|
166
|
+
return {
|
|
167
|
+
fields: `${field.fieldId}: ${field.multipleValues ? `[${fieldType}!]` : fieldType}`,
|
|
168
|
+
typeDefs
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
createInputField({
|
|
173
|
+
model,
|
|
174
|
+
field,
|
|
175
|
+
fieldTypePlugins
|
|
176
|
+
}) {
|
|
177
|
+
const result = typeFromField({
|
|
178
|
+
typeOfType: "input",
|
|
179
|
+
model,
|
|
180
|
+
type: "manage",
|
|
181
|
+
field,
|
|
182
|
+
fieldTypePlugins
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
if (!result) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const {
|
|
190
|
+
fieldType,
|
|
191
|
+
typeDefs
|
|
192
|
+
} = result;
|
|
193
|
+
return {
|
|
194
|
+
fields: (0, _helpers.attachRequiredFieldValue)(`${field.fieldId}: ${field.multipleValues ? `[${fieldType}!]` : fieldType}`, field),
|
|
195
|
+
typeDefs
|
|
196
|
+
};
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
createResolver({
|
|
200
|
+
graphQLType,
|
|
201
|
+
field,
|
|
202
|
+
createFieldResolvers
|
|
203
|
+
}) {
|
|
204
|
+
var _field$settings3;
|
|
205
|
+
|
|
206
|
+
if (!((_field$settings3 = field.settings) !== null && _field$settings3 !== void 0 && _field$settings3.fields) || field.settings.fields.length === 0) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const fieldType = `${graphQLType}_${(0, _upperFirst.default)(field.fieldId)}`;
|
|
211
|
+
const typeResolvers = createFieldResolvers({
|
|
212
|
+
graphQLType: fieldType,
|
|
213
|
+
fields: field.settings.fields
|
|
214
|
+
});
|
|
215
|
+
return {
|
|
216
|
+
resolver: null,
|
|
217
|
+
typeResolvers: typeResolvers || {}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
exports.createObjectField = createObjectField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["typeFromField","params","typeOfType","model","type","field","fieldTypePlugins","typeSuffix","typeName","createTypeName","modelId","mTypeName","createManageTypeName","fields","settings","fieldTypeName","upperFirst","fieldId","typeFields","nestedTypes","replace","RegExp","f","result","renderField","renderInputField","typeDefs","push","fieldType","join","createObjectField","name","isSortable","isSearchable","read","createTypeField","multipleValues","createResolver","createFieldResolvers","graphQLType","length","typeResolvers","resolver","manage","createInputField","attachRequiredFieldValue"],"sources":["object.ts"],"sourcesContent":["import upperFirst from \"lodash/upperFirst\";\nimport {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { renderField } from \"~/utils/renderFields\";\nimport { renderInputField } from \"~/utils/renderInputFields\";\nimport { createManageTypeName, createTypeName } from \"~/utils/createTypeName\";\nimport { attachRequiredFieldValue } from \"./helpers\";\n\ninterface TypeFromFieldParams {\n typeOfType: string;\n model: CmsModel;\n type: ApiEndpoint;\n field: CmsModelField;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface TypeFromFieldResponse {\n fieldType: string;\n typeDefs: string;\n}\nconst typeFromField = (params: TypeFromFieldParams): TypeFromFieldResponse | null => {\n const { typeOfType, model, type, field, fieldTypePlugins } = params;\n const typeSuffix = typeOfType === \"input\" ? \"Input\" : \"\";\n const typeName = createTypeName(model.modelId);\n const mTypeName = createManageTypeName(typeName);\n\n // `field` is an \"object\" field\n const fields: CmsModelField[] = field.settings?.fields || [];\n\n const fieldTypeName = `${mTypeName}_${upperFirst(field.fieldId)}`;\n\n const typeFields = [];\n const nestedTypes = [];\n\n // Once the loop below starts, we'll be executing a recursive \"object\" type generation.\n // The main trick here is that nested objects don't know who the parent is, and will generate\n // type names using the \"model\", as if they're at the top level:\n // Every time the types are returned, we need to replace the model name in the generated type name\n // with the actual prefix which includes parent field name type.\n const replace = new RegExp(`${mTypeName}_`, \"g\");\n\n for (const f of fields) {\n const result =\n typeOfType === \"type\"\n ? renderField({ field: f, type, model, fieldTypePlugins })\n : renderInputField({ field: f, model, fieldTypePlugins });\n\n if (!result) {\n continue;\n }\n\n const { fields, typeDefs } = result;\n\n typeFields.push(fields.replace(replace, `${fieldTypeName}_`));\n if (typeDefs) {\n nestedTypes.push(typeDefs.replace(replace, `${fieldTypeName}_`));\n }\n }\n\n return {\n fieldType: `${fieldTypeName}${typeSuffix}`,\n typeDefs: /* GraphQL */ `\n ${nestedTypes.join(\"\\n\")}\n \n ${typeOfType} ${fieldTypeName}${typeSuffix} {\n ${typeFields.join(\"\\n\")}\n }\n `\n };\n};\n\nexport const createObjectField = (): CmsModelFieldToGraphQLPlugin => {\n return {\n name: \"cms-model-field-to-graphql-object\",\n type: \"cms-model-field-to-graphql\",\n fieldType: \"object\",\n isSortable: false,\n isSearchable: false,\n read: {\n createTypeField({ field, model, fieldTypePlugins }) {\n const result = typeFromField({\n typeOfType: \"type\",\n model,\n type: \"read\",\n field,\n fieldTypePlugins\n });\n\n if (!result) {\n return null;\n }\n const { fieldType, typeDefs } = result;\n\n return {\n fields: `${field.fieldId}: ${\n field.multipleValues ? `[${fieldType}!]` : fieldType\n }`,\n typeDefs\n };\n },\n createResolver({ field, createFieldResolvers, graphQLType }) {\n if (!field.settings?.fields || field.settings.fields.length === 0) {\n return false;\n }\n\n const fieldType = `${graphQLType}_${upperFirst(field.fieldId)}`;\n\n const typeResolvers = createFieldResolvers({\n graphQLType: fieldType,\n fields: field.settings.fields\n });\n return {\n resolver: null,\n typeResolvers: typeResolvers || {}\n };\n }\n },\n manage: {\n createTypeField({ model, field, fieldTypePlugins }) {\n const result = typeFromField({\n typeOfType: \"type\",\n model,\n type: \"manage\",\n field,\n fieldTypePlugins\n });\n\n if (!result) {\n return null;\n }\n const { fieldType, typeDefs } = result;\n\n return {\n fields: `${field.fieldId}: ${\n field.multipleValues ? `[${fieldType}!]` : fieldType\n }`,\n typeDefs\n };\n },\n createInputField({ model, field, fieldTypePlugins }) {\n const result = typeFromField({\n typeOfType: \"input\",\n model,\n type: \"manage\",\n field,\n fieldTypePlugins\n });\n if (!result) {\n return null;\n }\n const { fieldType, typeDefs } = result;\n\n return {\n fields: attachRequiredFieldValue(\n `${field.fieldId}: ${field.multipleValues ? `[${fieldType}!]` : fieldType}`,\n field\n ),\n typeDefs\n };\n },\n createResolver({ graphQLType, field, createFieldResolvers }) {\n if (!field.settings?.fields || field.settings.fields.length === 0) {\n return false;\n }\n const fieldType = `${graphQLType}_${upperFirst(field.fieldId)}`;\n const typeResolvers = createFieldResolvers({\n graphQLType: fieldType,\n fields: field.settings.fields\n });\n return {\n resolver: null,\n typeResolvers: typeResolvers || {}\n };\n }\n }\n };\n};\n"],"mappings":";;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AACA;;AAaA,MAAMA,aAAa,GAAIC,MAAD,IAA+D;EAAA;;EACjF,MAAM;IAAEC,UAAF;IAAcC,KAAd;IAAqBC,IAArB;IAA2BC,KAA3B;IAAkCC;EAAlC,IAAuDL,MAA7D;EACA,MAAMM,UAAU,GAAGL,UAAU,KAAK,OAAf,GAAyB,OAAzB,GAAmC,EAAtD;EACA,MAAMM,QAAQ,GAAG,IAAAC,8BAAA,EAAeN,KAAK,CAACO,OAArB,CAAjB;EACA,MAAMC,SAAS,GAAG,IAAAC,oCAAA,EAAqBJ,QAArB,CAAlB,CAJiF,CAMjF;;EACA,MAAMK,MAAuB,GAAG,oBAAAR,KAAK,CAACS,QAAN,oEAAgBD,MAAhB,KAA0B,EAA1D;EAEA,MAAME,aAAa,GAAI,GAAEJ,SAAU,IAAG,IAAAK,mBAAA,EAAWX,KAAK,CAACY,OAAjB,CAA0B,EAAhE;EAEA,MAAMC,UAAU,GAAG,EAAnB;EACA,MAAMC,WAAW,GAAG,EAApB,CAZiF,CAcjF;EACA;EACA;EACA;EACA;;EACA,MAAMC,OAAO,GAAG,IAAIC,MAAJ,CAAY,GAAEV,SAAU,GAAxB,EAA4B,GAA5B,CAAhB;;EAEA,KAAK,MAAMW,CAAX,IAAgBT,MAAhB,EAAwB;IACpB,MAAMU,MAAM,GACRrB,UAAU,KAAK,MAAf,GACM,IAAAsB,yBAAA,EAAY;MAAEnB,KAAK,EAAEiB,CAAT;MAAYlB,IAAZ;MAAkBD,KAAlB;MAAyBG;IAAzB,CAAZ,CADN,GAEM,IAAAmB,mCAAA,EAAiB;MAAEpB,KAAK,EAAEiB,CAAT;MAAYnB,KAAZ;MAAmBG;IAAnB,CAAjB,CAHV;;IAKA,IAAI,CAACiB,MAAL,EAAa;MACT;IAC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QACjD,MAAMiB,MAAM,GAAGvB,aAAa,CAAC;UACzBE,UAAU,EAAE,OADa;UAEzBC,KAFyB;UAGzBC,IAAI,EAAE,QAHmB;UAIzBC,KAJyB;UAKzBC;QALyB,CAAD,CAA5B;;QAOA,IAAI,CAACiB,MAAL,EAAa;UACT,OAAO,IAAP;QACH;;QACD,MAAM;UAAEK,SAAF;UAAaF;QAAb,IAA0BH,MAAhC;QAEA,OAAO;UACHV,MAAM,EAAE,IAAAgC,iCAAA,EACH,GAAExC,KAAK,CAACY,OAAQ,KAAIZ,KAAK,CAAC+B,cAAN,GAAwB,IAAGR,SAAU,IAArC,GAA2CA,SAAU,EADtE,EAEJvB,KAFI,CADL;UAKHqB;QALG,CAAP;MAOH,CA1CG;;MA2CJW,cAAc,CAAC;QAAEE,WAAF;QAAelC,KAAf;QAAsBiC;MAAtB,CAAD,EAA+C;QAAA;;QACzD,IAAI,sBAACjC,KAAK,CAACS,QAAP,6CAAC,iBAAgBD,MAAjB,KAA2BR,KAAK,CAACS,QAAN,CAAeD,MAAf,CAAsB2B,MAAtB,KAAiC,CAAhE,EAAmE;UAC/D,OAAO,KAAP;QACH;;QACD,MAAMZ,SAAS,GAAI,GAAEW,WAAY,IAAG,IAAAvB,mBAAA,EAAWX,KAAK,CAACY,OAAjB,CAA0B,EAA9D;QACA,MAAMwB,aAAa,GAAGH,oBAAoB,CAAC;UACvCC,WAAW,EAAEX,SAD0B;UAEvCf,MAAM,EAAER,KAAK,CAACS,QAAN,CAAeD;QAFgB,CAAD,CAA1C;QAIA,OAAO;UACH6B,QAAQ,EAAE,IADP;UAEHD,aAAa,EAAEA,aAAa,IAAI;QAF7B,CAAP;MAIH;;IAxDG;EA7CL,CAAP;AAwGH,CAzGM"}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createRefField = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _createTypeName = require("../utils/createTypeName");
|
|
13
|
+
|
|
14
|
+
var _utils = require("@webiny/utils");
|
|
15
|
+
|
|
16
|
+
var _helpers = require("./helpers");
|
|
17
|
+
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
+
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
+
|
|
22
|
+
const createUnionTypeName = (model, field) => {
|
|
23
|
+
return `${(0, _createTypeName.createReadTypeName)(model.modelId)}${(0, _createTypeName.createReadTypeName)(field.fieldId)}`;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const createListFilters = ({
|
|
27
|
+
field
|
|
28
|
+
}) => {
|
|
29
|
+
return `
|
|
30
|
+
${field.fieldId}: RefFieldWhereInput
|
|
31
|
+
`;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const createFilteringTypeDef = () => {
|
|
35
|
+
return `
|
|
36
|
+
input RefFieldWhereInput {
|
|
37
|
+
id: String
|
|
38
|
+
id_not: String
|
|
39
|
+
id_in: [String!]
|
|
40
|
+
id_not_in: [String]
|
|
41
|
+
entryId: String
|
|
42
|
+
entryId_not: String
|
|
43
|
+
entryId_in: [String!]
|
|
44
|
+
entryId_not_in: [String!]
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const appendTypename = (entries, typename) => {
|
|
50
|
+
return entries.map(item => {
|
|
51
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
52
|
+
__typename: typename
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* We cast settings.models as object to have modelId because internally we know that it is so.
|
|
58
|
+
* Internal stuff so we are sure that settings.models contains what we require.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const getFieldModels = field => {
|
|
63
|
+
if (!field.settings || Array.isArray(field.settings.models) === false) {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return field.settings.models;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const modelIdToTypeName = new Map();
|
|
71
|
+
|
|
72
|
+
const createRefField = () => {
|
|
73
|
+
return {
|
|
74
|
+
name: "cms-model-field-to-graphql-ref",
|
|
75
|
+
type: "cms-model-field-to-graphql",
|
|
76
|
+
fieldType: "ref",
|
|
77
|
+
isSortable: false,
|
|
78
|
+
isSearchable: true,
|
|
79
|
+
read: {
|
|
80
|
+
createTypeField({
|
|
81
|
+
model,
|
|
82
|
+
field
|
|
83
|
+
}) {
|
|
84
|
+
var _field$settings;
|
|
85
|
+
|
|
86
|
+
const models = ((_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.models) || [];
|
|
87
|
+
const gqlType = models.length > 1 ? createUnionTypeName(model, field) : (0, _createTypeName.createReadTypeName)(models[0].modelId);
|
|
88
|
+
return field.fieldId + `: ${field.multipleValues ? `[${gqlType}]` : gqlType}`;
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* TS is complaining about mixed types for createResolver.
|
|
93
|
+
* TODO @ts-refactor @pavel Maybe we should have a single createResolver method?
|
|
94
|
+
*/
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
createResolver(params) {
|
|
97
|
+
var _field$settings2;
|
|
98
|
+
|
|
99
|
+
const {
|
|
100
|
+
field
|
|
101
|
+
} = params; // Create a map of model types and corresponding modelIds so resolvers don't need to perform the lookup.
|
|
102
|
+
|
|
103
|
+
const models = ((_field$settings2 = field.settings) === null || _field$settings2 === void 0 ? void 0 : _field$settings2.models) || [];
|
|
104
|
+
|
|
105
|
+
for (const item of models) {
|
|
106
|
+
modelIdToTypeName.set(item.modelId, (0, _createTypeName.createReadTypeName)(item.modelId));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return async (parent, _, context) => {
|
|
110
|
+
const {
|
|
111
|
+
cms
|
|
112
|
+
} = context; // Get field value for this entry
|
|
113
|
+
|
|
114
|
+
const initialValue = parent[field.fieldId];
|
|
115
|
+
|
|
116
|
+
if (!initialValue) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (field.multipleValues) {
|
|
121
|
+
/**
|
|
122
|
+
* We cast because value really can be array and single value.
|
|
123
|
+
* At this point, we are 99% sure that it is an array (+ we check for it)
|
|
124
|
+
*/
|
|
125
|
+
const value = initialValue;
|
|
126
|
+
|
|
127
|
+
if (Array.isArray(value) === false || value.length === 0) {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const entriesByModel = value.reduce((collection, ref) => {
|
|
132
|
+
if (!collection[ref.modelId]) {
|
|
133
|
+
collection[ref.modelId] = [];
|
|
134
|
+
} else if (collection[ref.modelId].includes(ref.entryId) === true) {
|
|
135
|
+
return collection;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
collection[ref.modelId].push(ref.entryId);
|
|
139
|
+
return collection;
|
|
140
|
+
}, {});
|
|
141
|
+
const getters = Object.keys(entriesByModel).map(async modelId => {
|
|
142
|
+
const idList = entriesByModel[modelId]; // Get model manager, to get access to CRUD methods
|
|
143
|
+
|
|
144
|
+
const model = await cms.getModelManager(modelId);
|
|
145
|
+
let entries; // `read` API works with `published` data
|
|
146
|
+
|
|
147
|
+
if (cms.READ) {
|
|
148
|
+
entries = await model.getPublishedByIds(idList);
|
|
149
|
+
} // `preview` and `manage` with `latest` data
|
|
150
|
+
else {
|
|
151
|
+
entries = await model.getLatestByIds(idList);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return appendTypename(entries, modelIdToTypeName.get(modelId));
|
|
155
|
+
});
|
|
156
|
+
return await Promise.all(getters).then(results => results.reduce((result, item) => result.concat(item), []));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const value = initialValue; // Get model manager, to get access to CRUD methods
|
|
160
|
+
|
|
161
|
+
const model = await cms.getModelManager(value.modelId);
|
|
162
|
+
let revisions; // `read` API works with `published` data
|
|
163
|
+
|
|
164
|
+
if (cms.READ) {
|
|
165
|
+
revisions = await model.getPublishedByIds([value.entryId]);
|
|
166
|
+
} // `preview` API works with `latest` data
|
|
167
|
+
else {
|
|
168
|
+
revisions = await model.getLatestByIds([value.entryId]);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* If there are no revisions we must return null.
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
if (!revisions || revisions.length === 0) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return _objectSpread(_objectSpread({}, revisions[0]), {}, {
|
|
180
|
+
__typename: modelIdToTypeName.get(value.modelId)
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
createSchema({
|
|
186
|
+
models
|
|
187
|
+
}) {
|
|
188
|
+
const unionFields = [];
|
|
189
|
+
|
|
190
|
+
for (const model of models) {
|
|
191
|
+
// Generate a dedicated union type for every `ref` field which has more than 1 content model assigned.
|
|
192
|
+
model.fields.filter(field => {
|
|
193
|
+
var _field$settings3;
|
|
194
|
+
|
|
195
|
+
return field.type === "ref" && (((_field$settings3 = field.settings) === null || _field$settings3 === void 0 ? void 0 : _field$settings3.models) || []).length > 1;
|
|
196
|
+
}).forEach(field => unionFields.push({
|
|
197
|
+
model,
|
|
198
|
+
field,
|
|
199
|
+
typeName: createUnionTypeName(model, field)
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const unionFieldsTypeDef = unionFields.map(({
|
|
204
|
+
field,
|
|
205
|
+
typeName
|
|
206
|
+
}) => `union ${typeName} = ${getFieldModels(field).map(({
|
|
207
|
+
modelId
|
|
208
|
+
}) => (0, _createTypeName.createReadTypeName)(modelId)).join(" | ")}`).join("\n");
|
|
209
|
+
const filteringTypeDef = `
|
|
210
|
+
${createFilteringTypeDef()}
|
|
211
|
+
|
|
212
|
+
${unionFieldsTypeDef}
|
|
213
|
+
`;
|
|
214
|
+
return {
|
|
215
|
+
typeDefs: filteringTypeDef,
|
|
216
|
+
resolvers: {}
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
createListFilters
|
|
221
|
+
},
|
|
222
|
+
manage: {
|
|
223
|
+
createSchema() {
|
|
224
|
+
/**
|
|
225
|
+
* entryId in RefFieldInput is deprecated but cannot mark it as GraphQL does not allow marking input fields as deprecated
|
|
226
|
+
*/
|
|
227
|
+
return {
|
|
228
|
+
typeDefs: `
|
|
229
|
+
type RefField {
|
|
230
|
+
modelId: String!
|
|
231
|
+
entryId: ID!
|
|
232
|
+
id: ID!
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
input RefFieldInput {
|
|
236
|
+
modelId: String!
|
|
237
|
+
id: ID!
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
${createFilteringTypeDef()}
|
|
241
|
+
`,
|
|
242
|
+
resolvers: {
|
|
243
|
+
RefField: {
|
|
244
|
+
entryId: parent => {
|
|
245
|
+
const {
|
|
246
|
+
id
|
|
247
|
+
} = (0, _utils.parseIdentifier)(parent.entryId || parent.id);
|
|
248
|
+
return id;
|
|
249
|
+
},
|
|
250
|
+
id: parent => {
|
|
251
|
+
return parent.id || parent.entryId;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
},
|
|
257
|
+
|
|
258
|
+
createTypeField({
|
|
259
|
+
field
|
|
260
|
+
}) {
|
|
261
|
+
if (field.multipleValues) {
|
|
262
|
+
return `${field.fieldId}: [RefField!]`;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return `${field.fieldId}: RefField`;
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
createInputField({
|
|
269
|
+
field
|
|
270
|
+
}) {
|
|
271
|
+
return (0, _helpers.createGraphQLInputField)(field, "RefFieldInput");
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
createListFilters
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
exports.createRefField = createRefField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createUnionTypeName","model","field","createReadTypeName","modelId","fieldId","createListFilters","createFilteringTypeDef","appendTypename","entries","typename","map","item","__typename","getFieldModels","settings","Array","isArray","models","modelIdToTypeName","Map","createRefField","name","type","fieldType","isSortable","isSearchable","read","createTypeField","gqlType","length","multipleValues","createResolver","params","set","parent","_","context","cms","initialValue","value","entriesByModel","reduce","collection","ref","includes","entryId","push","getters","Object","keys","idList","getModelManager","READ","getPublishedByIds","getLatestByIds","get","Promise","all","then","results","result","concat","revisions","createSchema","unionFields","fields","filter","forEach","typeName","unionFieldsTypeDef","join","filteringTypeDef","typeDefs","resolvers","manage","RefField","id","parseIdentifier","createInputField","createGraphQLInputField"],"sources":["ref.ts"],"sourcesContent":["import {\n CmsEntry,\n CmsContext,\n CmsModelFieldToGraphQLPlugin,\n CmsModel,\n CmsModelField\n} from \"~/types\";\nimport { createReadTypeName } from \"~/utils/createTypeName\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createGraphQLInputField } from \"./helpers\";\n\ninterface RefFieldValue {\n id?: string;\n entryId: string;\n modelId: string;\n}\n\ninterface UnionField {\n model: CmsModel;\n field: CmsModelField;\n typeName: string;\n}\n\nconst createUnionTypeName = (model: CmsModel, field: CmsModelField) => {\n return `${createReadTypeName(model.modelId)}${createReadTypeName(field.fieldId)}`;\n};\n\ninterface CreateListFilterParams {\n field: CmsModelField;\n}\nconst createListFilters = ({ field }: CreateListFilterParams) => {\n return `\n ${field.fieldId}: RefFieldWhereInput\n `;\n};\n\nconst createFilteringTypeDef = () => {\n return `\n input RefFieldWhereInput {\n id: String\n id_not: String\n id_in: [String!]\n id_not_in: [String]\n entryId: String\n entryId_not: String\n entryId_in: [String!]\n entryId_not_in: [String!]\n }\n `;\n};\n\nconst appendTypename = (entries: CmsEntry[], typename: string): CmsEntry[] => {\n return entries.map(item => {\n return {\n ...item,\n __typename: typename\n };\n });\n};\n/**\n * We cast settings.models as object to have modelId because internally we know that it is so.\n * Internal stuff so we are sure that settings.models contains what we require.\n */\nconst getFieldModels = (field: CmsModelField): Pick<CmsModel, \"modelId\">[] => {\n if (!field.settings || Array.isArray(field.settings.models) === false) {\n return [];\n }\n return field.settings.models as Pick<CmsModel, \"modelId\">[];\n};\n\nconst modelIdToTypeName = new Map();\n\nexport const createRefField = (): CmsModelFieldToGraphQLPlugin => {\n return {\n name: \"cms-model-field-to-graphql-ref\",\n type: \"cms-model-field-to-graphql\",\n fieldType: \"ref\",\n isSortable: false,\n isSearchable: true,\n read: {\n createTypeField({ model, field }) {\n const models = field.settings?.models || [];\n const gqlType =\n models.length > 1\n ? createUnionTypeName(model, field)\n : createReadTypeName(models[0].modelId);\n\n return field.fieldId + `: ${field.multipleValues ? `[${gqlType}]` : gqlType}`;\n },\n /**\n * TS is complaining about mixed types for createResolver.\n * TODO @ts-refactor @pavel Maybe we should have a single createResolver method?\n */\n // @ts-ignore\n createResolver(params) {\n const { field } = params;\n // Create a map of model types and corresponding modelIds so resolvers don't need to perform the lookup.\n const models = field.settings?.models || [];\n for (const item of models) {\n modelIdToTypeName.set(item.modelId, createReadTypeName(item.modelId));\n }\n\n return async (parent, _, context: CmsContext) => {\n const { cms } = context;\n\n // Get field value for this entry\n const initialValue = parent[field.fieldId] as RefFieldValue | RefFieldValue[];\n\n if (!initialValue) {\n return null;\n }\n\n if (field.multipleValues) {\n /**\n * We cast because value really can be array and single value.\n * At this point, we are 99% sure that it is an array (+ we check for it)\n */\n const value = initialValue as RefFieldValue[];\n if (Array.isArray(value) === false || value.length === 0) {\n return [];\n }\n\n const entriesByModel = value.reduce((collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.entryId) === true) {\n return collection;\n }\n\n collection[ref.modelId].push(ref.entryId);\n\n return collection;\n }, {} as Record<string, string[]>);\n\n const getters = Object.keys(entriesByModel).map(async modelId => {\n const idList = entriesByModel[modelId];\n // Get model manager, to get access to CRUD methods\n const model = await cms.getModelManager(modelId);\n\n let entries: CmsEntry[];\n // `read` API works with `published` data\n if (cms.READ) {\n entries = await model.getPublishedByIds(idList);\n }\n // `preview` and `manage` with `latest` data\n else {\n entries = await model.getLatestByIds(idList);\n }\n\n return appendTypename(entries, modelIdToTypeName.get(modelId));\n });\n\n return await Promise.all(getters).then((results: any[]) =>\n results.reduce((result, item) => result.concat(item), [])\n );\n }\n\n const value = initialValue as RefFieldValue;\n\n // Get model manager, to get access to CRUD methods\n const model = await cms.getModelManager(value.modelId);\n\n let revisions: CmsEntry[];\n // `read` API works with `published` data\n if (cms.READ) {\n revisions = await model.getPublishedByIds([value.entryId]);\n }\n // `preview` API works with `latest` data\n else {\n revisions = await model.getLatestByIds([value.entryId]);\n }\n\n /**\n * If there are no revisions we must return null.\n */\n if (!revisions || revisions.length === 0) {\n return null;\n }\n return {\n ...revisions[0],\n __typename: modelIdToTypeName.get(value.modelId)\n };\n };\n },\n createSchema({ models }) {\n const unionFields: UnionField[] = [];\n for (const model of models) {\n // Generate a dedicated union type for every `ref` field which has more than 1 content model assigned.\n model.fields\n .filter(\n field =>\n field.type === \"ref\" && (field.settings?.models || []).length > 1\n )\n .forEach(field =>\n unionFields.push({\n model,\n field,\n typeName: createUnionTypeName(model, field)\n })\n );\n }\n const unionFieldsTypeDef = unionFields\n .map(\n ({ field, typeName }) =>\n `union ${typeName} = ${getFieldModels(field)\n .map(({ modelId }) => createReadTypeName(modelId))\n .join(\" | \")}`\n )\n .join(\"\\n\");\n\n const filteringTypeDef = `\n ${createFilteringTypeDef()}\n \n ${unionFieldsTypeDef}\n `;\n\n return {\n typeDefs: filteringTypeDef,\n resolvers: {}\n };\n },\n createListFilters\n },\n manage: {\n createSchema() {\n /**\n * entryId in RefFieldInput is deprecated but cannot mark it as GraphQL does not allow marking input fields as deprecated\n */\n return {\n typeDefs: `\n type RefField {\n modelId: String!\n entryId: ID!\n id: ID!\n }\n \n input RefFieldInput {\n modelId: String!\n id: ID!\n }\n \n ${createFilteringTypeDef()}\n `,\n resolvers: {\n RefField: {\n entryId: (parent: RefFieldValue) => {\n const { id } = parseIdentifier(parent.entryId || parent.id);\n return id;\n },\n id: (parent: RefFieldValue) => {\n return parent.id || parent.entryId;\n }\n }\n }\n };\n },\n createTypeField({ field }) {\n if (field.multipleValues) {\n return `${field.fieldId}: [RefField!]`;\n }\n return `${field.fieldId}: RefField`;\n },\n createInputField({ field }) {\n return createGraphQLInputField(field, \"RefFieldInput\");\n },\n createListFilters\n }\n };\n};\n"],"mappings":";;;;;;;;;;;AAOA;;AACA;;AACA;;;;;;AAcA,MAAMA,mBAAmB,GAAG,CAACC,KAAD,EAAkBC,KAAlB,KAA2C;EACnE,OAAQ,GAAE,IAAAC,kCAAA,EAAmBF,KAAK,CAACG,OAAzB,CAAkC,GAAE,IAAAD,kCAAA,EAAmBD,KAAK,CAACG,OAAzB,CAAkC,EAAhF;AACH,CAFD;;AAOA,MAAMC,iBA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ACH,CAzCG;;MA0CJI;IA1CI;EAtJL,CAAP;AAmMH,CApMM"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createRichTextField = void 0;
|
|
7
|
+
|
|
8
|
+
var _helpers = require("./helpers");
|
|
9
|
+
|
|
10
|
+
const createRichTextField = () => {
|
|
11
|
+
return {
|
|
12
|
+
name: "cms-model-field-to-graphql-rich-text",
|
|
13
|
+
type: "cms-model-field-to-graphql",
|
|
14
|
+
fieldType: "rich-text",
|
|
15
|
+
isSortable: false,
|
|
16
|
+
isSearchable: false,
|
|
17
|
+
read: {
|
|
18
|
+
createTypeField({
|
|
19
|
+
field
|
|
20
|
+
}) {
|
|
21
|
+
if (field.multipleValues) {
|
|
22
|
+
return `${field.fieldId}: [JSON]`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return `${field.fieldId}: JSON`;
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
createGetFilters({
|
|
29
|
+
field
|
|
30
|
+
}) {
|
|
31
|
+
return `${field.fieldId}: JSON`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
},
|
|
35
|
+
manage: {
|
|
36
|
+
createTypeField({
|
|
37
|
+
field
|
|
38
|
+
}) {
|
|
39
|
+
if (field.multipleValues) {
|
|
40
|
+
return `${field.fieldId}: [JSON]`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return `${field.fieldId}: JSON`;
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
createInputField({
|
|
47
|
+
field
|
|
48
|
+
}) {
|
|
49
|
+
return (0, _helpers.createGraphQLInputField)(field, "JSON");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.createRichTextField = createRichTextField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createRichTextField","name","type","fieldType","isSortable","isSearchable","read","createTypeField","field","multipleValues","fieldId","createGetFilters","manage","createInputField","createGraphQLInputField"],"sources":["richText.ts"],"sourcesContent":["import { CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { createGraphQLInputField } from \"./helpers\";\n\nexport const createRichTextField = (): CmsModelFieldToGraphQLPlugin => {\n return {\n name: \"cms-model-field-to-graphql-rich-text\",\n type: \"cms-model-field-to-graphql\",\n fieldType: \"rich-text\",\n isSortable: false,\n isSearchable: false,\n read: {\n createTypeField({ field }) {\n if (field.multipleValues) {\n return `${field.fieldId}: [JSON]`;\n }\n\n return `${field.fieldId}: JSON`;\n },\n createGetFilters({ field }) {\n return `${field.fieldId}: JSON`;\n }\n },\n manage: {\n createTypeField({ field }) {\n if (field.multipleValues) {\n return `${field.fieldId}: [JSON]`;\n }\n return `${field.fieldId}: JSON`;\n },\n createInputField({ field }) {\n return createGraphQLInputField(field, \"JSON\");\n }\n }\n };\n};\n"],"mappings":";;;;;;;AACA;;AAEO,MAAMA,mBAAmB,GAAG,MAAoC;EACnE,OAAO;IACHC,IAAI,EAAE,sCADH;IAEHC,IAAI,EAAE,4BAFH;IAGHC,SAAS,EAAE,WAHR;IAIHC,UAAU,EAAE,KAJT;IAKHC,YAAY,EAAE,KALX;IAMHC,IAAI,EAAE;MACFC,eAAe,CAAC;QAAEC;MAAF,CAAD,EAAY;QACvB,IAAIA,KAAK,CAACC,cAAV,EAA0B;UACtB,OAAQ,GAAED,KAAK,CAACE,OAAQ,UAAxB;QACH;;QAED,OAAQ,GAAEF,KAAK,CAACE,OAAQ,QAAxB;MACH,CAPC;;MAQFC,gBAAgB,CAAC;QAAEH;MAAF,CAAD,EAAY;QACxB,OAAQ,GAAEA,KAAK,CAACE,OAAQ,QAAxB;MACH;;IAVC,CANH;IAkBHE,MAAM,EAAE;MACJL,eAAe,CAAC;QAAEC;MAAF,CAAD,EAAY;QACvB,IAAIA,KAAK,CAACC,cAAV,EAA0B;UACtB,OAAQ,GAAED,KAAK,CAACE,OAAQ,UAAxB;QACH;;QACD,OAAQ,GAAEF,KAAK,CAACE,OAAQ,QAAxB;MACH,CANG;;MAOJG,gBAAgB,CAAC;QAAEL;MAAF,CAAD,EAAY;QACxB,OAAO,IAAAM,gCAAA,EAAwBN,KAAxB,EAA+B,MAA/B,CAAP;MACH;;IATG;EAlBL,CAAP;AA8BH,CA/BM"}
|