@webiny/api-headless-cms 0.0.0-mt-3 → 0.0.0-unstable.2af142b57e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.d.ts +6 -0
- package/context.js +94 -0
- package/context.js.map +1 -0
- package/crud/contentEntry/afterDelete.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.js +2 -7
- package/crud/contentEntry/afterDelete.js.map +1 -0
- package/crud/contentEntry/beforeCreate.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.js +2 -5
- package/crud/contentEntry/beforeCreate.js.map +1 -0
- package/crud/contentEntry/beforeUpdate.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.js +2 -5
- package/crud/contentEntry/beforeUpdate.js.map +1 -0
- package/crud/contentEntry/entryDataValidation.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.js +22 -49
- package/crud/contentEntry/entryDataValidation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.d.ts +3 -2
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.js +26 -43
- package/crud/contentEntry/markLockedFields.js.map +1 -0
- package/crud/contentEntry/referenceFieldsMapping.d.ts +13 -0
- package/crud/contentEntry/referenceFieldsMapping.js +236 -0
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -0
- package/crud/contentEntry/searchableFields.d.ts +9 -0
- package/crud/contentEntry/searchableFields.js +72 -0
- package/crud/contentEntry/searchableFields.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry.crud.d.ts +5 -9
- package/crud/contentEntry.crud.js +1194 -0
- package/crud/contentEntry.crud.js.map +1 -0
- package/crud/contentModel/afterCreate.d.ts +8 -0
- package/crud/contentModel/afterCreate.js +16 -0
- package/crud/contentModel/afterCreate.js.map +1 -0
- package/crud/contentModel/afterCreateFrom.d.ts +8 -0
- package/crud/contentModel/afterCreateFrom.js +16 -0
- package/crud/contentModel/afterCreateFrom.js.map +1 -0
- package/crud/contentModel/afterDelete.d.ts +8 -0
- package/crud/contentModel/afterDelete.js +16 -0
- package/crud/contentModel/afterDelete.js.map +1 -0
- package/crud/contentModel/afterUpdate.d.ts +8 -0
- package/crud/contentModel/afterUpdate.js +16 -0
- package/crud/contentModel/afterUpdate.js.map +1 -0
- package/crud/contentModel/beforeCreate.d.ts +14 -0
- package/{content/plugins/crud → crud}/contentModel/beforeCreate.js +58 -39
- package/crud/contentModel/beforeCreate.js.map +1 -0
- package/crud/contentModel/beforeDelete.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.js +13 -19
- package/crud/contentModel/beforeDelete.js.map +1 -0
- package/crud/contentModel/beforeUpdate.d.ts +8 -0
- package/crud/contentModel/beforeUpdate.js +32 -0
- package/crud/contentModel/beforeUpdate.js.map +1 -0
- package/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js +0 -7
- package/crud/contentModel/contentModelManagerFactory.js.map +1 -0
- package/crud/contentModel/createFieldStorageId.d.ts +2 -0
- package/crud/contentModel/createFieldStorageId.js +17 -0
- package/crud/contentModel/createFieldStorageId.js.map +1 -0
- package/crud/contentModel/systemFields.d.ts +1 -0
- package/crud/contentModel/systemFields.js +8 -0
- package/crud/contentModel/systemFields.js.map +1 -0
- package/crud/contentModel/validateLayout.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/validateLayout.js +1 -11
- package/crud/contentModel/validateLayout.js.map +1 -0
- package/crud/contentModel/validateModel.d.ts +8 -0
- package/crud/contentModel/validateModel.js +27 -0
- package/crud/contentModel/validateModel.js.map +1 -0
- package/crud/contentModel/validateModelFields.d.ts +8 -0
- package/crud/contentModel/validateModelFields.js +380 -0
- package/crud/contentModel/validateModelFields.js.map +1 -0
- package/crud/contentModel/validation.d.ts +477 -0
- package/crud/contentModel/validation.js +97 -0
- package/crud/contentModel/validation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel.crud.d.ts +3 -3
- package/crud/contentModel.crud.js +555 -0
- package/crud/contentModel.crud.js.map +1 -0
- package/crud/contentModelGroup/beforeCreate.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.js +8 -20
- package/crud/contentModelGroup/beforeCreate.js.map +1 -0
- package/crud/contentModelGroup/beforeDelete.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.js +4 -12
- package/crud/contentModelGroup/beforeDelete.js.map +1 -0
- package/crud/contentModelGroup/beforeUpdate.d.ts +9 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.js +3 -8
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
- package/crud/contentModelGroup/validation.d.ts +30 -0
- package/crud/contentModelGroup/validation.js +34 -0
- package/crud/contentModelGroup/validation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup.crud.d.ts +3 -3
- package/crud/contentModelGroup.crud.js +324 -0
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/{plugins/crud → crud}/settings.crud.d.ts +3 -3
- package/crud/settings.crud.js +71 -0
- package/crud/settings.crud.js.map +1 -0
- package/{plugins/crud → crud}/system.crud.d.ts +6 -3
- package/crud/system.crud.js +186 -0
- package/crud/system.crud.js.map +1 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +7 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +53 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +203 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +251 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/index.d.ts +4 -0
- package/fieldConverters/index.js +13 -0
- package/fieldConverters/index.js.map +1 -0
- package/graphql/buildSchemaPlugins.d.ts +11 -0
- package/graphql/buildSchemaPlugins.js +19 -0
- package/graphql/buildSchemaPlugins.js.map +1 -0
- package/graphql/createExecutableSchema.d.ts +7 -0
- package/graphql/createExecutableSchema.js +29 -0
- package/graphql/createExecutableSchema.js.map +1 -0
- package/graphql/generateSchema.d.ts +8 -0
- package/graphql/generateSchema.js +31 -0
- package/graphql/generateSchema.js.map +1 -0
- package/graphql/graphQLHandlerFactory.d.ts +5 -0
- package/graphql/graphQLHandlerFactory.js +174 -0
- package/graphql/graphQLHandlerFactory.js.map +1 -0
- package/graphql/index.d.ts +3 -0
- package/graphql/index.js +13 -0
- package/graphql/index.js.map +1 -0
- package/graphql/schema/baseContentSchema.d.ts +7 -0
- package/graphql/schema/baseContentSchema.js +72 -0
- package/graphql/schema/baseContentSchema.js.map +1 -0
- package/graphql/schema/baseSchema.d.ts +3 -0
- package/graphql/schema/baseSchema.js +53 -0
- package/graphql/schema/baseSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +7 -0
- package/graphql/schema/contentEntries.js +325 -0
- package/graphql/schema/contentEntries.js.map +1 -0
- package/graphql/schema/contentModelGroups.d.ts +7 -0
- package/{content/plugins → graphql}/schema/contentModelGroups.js +38 -32
- package/graphql/schema/contentModelGroups.js.map +1 -0
- package/graphql/schema/contentModels.d.ts +7 -0
- package/{content/plugins → graphql}/schema/contentModels.js +101 -28
- package/graphql/schema/contentModels.js.map +1 -0
- package/graphql/schema/createFieldResolvers.d.ts +20 -0
- package/graphql/schema/createFieldResolvers.js +110 -0
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +12 -0
- package/{content/plugins → graphql}/schema/createManageResolvers.js +32 -56
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/graphql/schema/createManageSDL.d.ts +12 -0
- package/{content/plugins → graphql}/schema/createManageSDL.js +31 -33
- package/graphql/schema/createManageSDL.js.map +1 -0
- package/graphql/schema/createPreviewResolvers.d.ts +12 -0
- package/graphql/schema/createPreviewResolvers.js +48 -0
- package/graphql/schema/createPreviewResolvers.js.map +1 -0
- package/graphql/schema/createReadResolvers.d.ts +12 -0
- package/graphql/schema/createReadResolvers.js +53 -0
- package/graphql/schema/createReadResolvers.js.map +1 -0
- package/graphql/schema/createReadSDL.d.ts +12 -0
- package/{content/plugins → graphql}/schema/createReadSDL.js +23 -21
- package/graphql/schema/createReadSDL.js.map +1 -0
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +6 -0
- package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js +0 -2
- package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveCreate.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js +2 -7
- package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +8 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js +2 -7
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveDelete.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js +8 -12
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGet.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveGet.js +63 -0
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js +2 -7
- package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetRevisions.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js +2 -7
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveList.d.ts +4 -0
- package/{content/plugins/schema/resolvers/preview → graphql/schema/resolvers/manage}/resolveList.js +2 -7
- package/graphql/schema/resolvers/manage/resolveList.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolvePublish.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js +0 -3
- package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveRepublish.d.ts +7 -0
- package/{content/plugins/schema/resolvers/manage/resolveGet.js → graphql/schema/resolvers/manage/resolveRepublish.js} +4 -7
- package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveUnpublish.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js +0 -3
- package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +8 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js +2 -7
- package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveGet.d.ts +4 -0
- package/graphql/schema/resolvers/preview/resolveGet.js +26 -0
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveList.d.ts +4 -0
- package/{content/plugins/schema/resolvers/manage → graphql/schema/resolvers/preview}/resolveList.js +2 -7
- package/graphql/schema/resolvers/preview/resolveList.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveGet.d.ts +4 -0
- package/graphql/schema/resolvers/read/resolveGet.js +26 -0
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveList.d.ts +4 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.js +2 -7
- package/graphql/schema/resolvers/read/resolveList.js.map +1 -0
- package/graphql/schema/schemaPlugins.d.ts +8 -0
- package/graphql/schema/schemaPlugins.js +109 -0
- package/graphql/schema/schemaPlugins.js.map +1 -0
- package/graphql/system.d.ts +6 -0
- package/{plugins/graphql → graphql}/system.js +43 -12
- package/graphql/system.js.map +1 -0
- package/graphqlFields/boolean.d.ts +2 -0
- package/graphqlFields/boolean.js +57 -0
- package/graphqlFields/boolean.js.map +1 -0
- package/graphqlFields/datetime.d.ts +2 -0
- package/graphqlFields/datetime.js +78 -0
- package/graphqlFields/datetime.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js +208 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js +63 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
- package/graphqlFields/dynamicZone/index.d.ts +2 -0
- package/graphqlFields/dynamicZone/index.js +19 -0
- package/graphqlFields/dynamicZone/index.js.map +1 -0
- package/graphqlFields/file.d.ts +2 -0
- package/graphqlFields/file.js +42 -0
- package/graphqlFields/file.js.map +1 -0
- package/graphqlFields/helpers.d.ts +6 -0
- package/graphqlFields/helpers.js +39 -0
- package/graphqlFields/helpers.js.map +1 -0
- package/graphqlFields/index.d.ts +2 -0
- package/graphqlFields/index.js +18 -0
- package/graphqlFields/index.js.map +1 -0
- package/graphqlFields/longText.d.ts +2 -0
- package/graphqlFields/longText.js +53 -0
- package/graphqlFields/longText.js.map +1 -0
- package/graphqlFields/number.d.ts +2 -0
- package/graphqlFields/number.js +67 -0
- package/graphqlFields/number.js.map +1 -0
- package/graphqlFields/object.d.ts +2 -0
- package/graphqlFields/object.js +239 -0
- package/graphqlFields/object.js.map +1 -0
- package/graphqlFields/ref.d.ts +2 -0
- package/graphqlFields/ref.js +227 -0
- package/graphqlFields/ref.js.map +1 -0
- package/graphqlFields/richText.d.ts +2 -0
- package/graphqlFields/richText.js +47 -0
- package/graphqlFields/richText.js.map +1 -0
- package/graphqlFields/text.d.ts +2 -0
- package/graphqlFields/text.js +62 -0
- package/graphqlFields/text.js.map +1 -0
- package/index.d.ts +10 -12
- package/index.js +75 -55
- package/index.js.map +1 -0
- package/modelManager/DefaultCmsModelManager.d.ts +14 -0
- package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js +10 -24
- package/modelManager/DefaultCmsModelManager.js.map +1 -0
- package/modelManager/index.d.ts +2 -0
- package/{content/plugins/modelManager → modelManager}/index.js +3 -7
- package/modelManager/index.js.map +1 -0
- package/package.json +38 -38
- package/parameters/context.d.ts +2 -0
- package/parameters/context.js +18 -0
- package/parameters/context.js.map +1 -0
- package/parameters/header.d.ts +2 -0
- package/parameters/header.js +44 -0
- package/parameters/header.js.map +1 -0
- package/parameters/index.d.ts +4 -0
- package/parameters/index.js +49 -0
- package/parameters/index.js.map +1 -0
- package/parameters/manual.d.ts +6 -0
- package/parameters/manual.js +37 -0
- package/parameters/manual.js.map +1 -0
- package/parameters/path.d.ts +2 -0
- package/parameters/path.js +40 -0
- package/parameters/path.js.map +1 -0
- package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
- package/plugins/CmsGraphQLSchemaPlugin.js +12 -0
- package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js +28 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
- package/plugins/CmsGroupPlugin.d.ts +13 -0
- package/{content/plugins → plugins}/CmsGroupPlugin.js +7 -9
- package/plugins/CmsGroupPlugin.js.map +1 -0
- package/plugins/CmsModelFieldConverterPlugin.d.ts +14 -0
- package/plugins/CmsModelFieldConverterPlugin.js +12 -0
- package/plugins/CmsModelFieldConverterPlugin.js.map +1 -0
- package/plugins/CmsModelPlugin.d.ts +45 -0
- package/plugins/CmsModelPlugin.js +158 -0
- package/plugins/CmsModelPlugin.js.map +1 -0
- package/plugins/CmsParametersPlugin.d.ts +20 -0
- package/plugins/CmsParametersPlugin.js +21 -0
- package/plugins/CmsParametersPlugin.js.map +1 -0
- package/plugins/StorageTransformPlugin.d.ts +31 -0
- package/{content/plugins/storage → plugins}/StorageTransformPlugin.js +2 -10
- package/plugins/StorageTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +7 -0
- package/plugins/index.js +82 -0
- package/plugins/index.js.map +1 -0
- package/storage/default.d.ts +2 -0
- package/storage/default.js +24 -0
- package/storage/default.js.map +1 -0
- package/storage/object.d.ts +2 -0
- package/storage/object.js +108 -0
- package/storage/object.js.map +1 -0
- package/types.d.ts +881 -389
- package/types.js +104 -61
- package/types.js.map +1 -0
- package/upgrades/5.33.0/index.d.ts +3 -0
- package/upgrades/5.33.0/index.js +159 -0
- package/upgrades/5.33.0/index.js.map +1 -0
- package/upgrades/index.d.ts +1 -0
- package/upgrades/index.js +9 -0
- package/upgrades/index.js.map +1 -0
- package/utils/access.d.ts +8 -0
- package/utils/access.js +76 -0
- package/utils/access.js.map +1 -0
- package/utils/converters/Converter.d.ts +27 -0
- package/utils/converters/Converter.js +58 -0
- package/utils/converters/Converter.js.map +1 -0
- package/utils/converters/ConverterCollection.d.ts +31 -0
- package/utils/converters/ConverterCollection.js +119 -0
- package/utils/converters/ConverterCollection.js.map +1 -0
- package/utils/converters/valueKeyStorageConverter.d.ts +18 -0
- package/utils/converters/valueKeyStorageConverter.js +122 -0
- package/utils/converters/valueKeyStorageConverter.js.map +1 -0
- package/utils/createTypeFromFields.d.ts +15 -0
- package/utils/createTypeFromFields.js +64 -0
- package/utils/createTypeFromFields.js.map +1 -0
- package/{content/plugins/utils → utils}/createTypeName.d.ts +3 -3
- package/{content/plugins/utils → utils}/createTypeName.js +3 -10
- package/utils/createTypeName.js.map +1 -0
- package/{content/plugins/utils → utils}/entryStorage.d.ts +3 -3
- package/{content/plugins/utils → utils}/entryStorage.js +26 -47
- package/utils/entryStorage.js.map +1 -0
- package/utils/filterAsync.d.ts +1 -0
- package/utils/filterAsync.js +18 -0
- package/utils/filterAsync.js.map +1 -0
- package/utils/getBaseFieldType.d.ts +4 -0
- package/utils/getBaseFieldType.js +10 -0
- package/utils/getBaseFieldType.js.map +1 -0
- package/utils/getEntryTitle.d.ts +2 -0
- package/{content/plugins/utils → utils}/getEntryTitle.js +7 -15
- package/utils/getEntryTitle.js.map +1 -0
- package/utils/getSchemaFromFieldPlugins.d.ts +9 -0
- package/utils/getSchemaFromFieldPlugins.js +39 -0
- package/utils/getSchemaFromFieldPlugins.js.map +1 -0
- package/utils/ownership.d.ts +8 -0
- package/utils/ownership.js +33 -0
- package/utils/ownership.js.map +1 -0
- package/utils/permissions.d.ts +7 -0
- package/utils/permissions.js +91 -0
- package/utils/permissions.js.map +1 -0
- package/utils/pluralizedTypeName.d.ts +1 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.js +1 -7
- package/utils/pluralizedTypeName.js.map +1 -0
- package/utils/renderFields.d.ts +15 -0
- package/{content/plugins/utils → utils}/renderFields.js +6 -11
- package/utils/renderFields.js.map +1 -0
- package/utils/renderGetFilterFields.d.ts +10 -0
- package/utils/renderGetFilterFields.js +48 -0
- package/utils/renderGetFilterFields.js.map +1 -0
- package/utils/renderInputFields.d.ts +14 -0
- package/{content/plugins/utils → utils}/renderInputFields.js +3 -10
- package/utils/renderInputFields.js.map +1 -0
- package/utils/renderListFilterFields.d.ts +11 -0
- package/{content/plugins/utils → utils}/renderListFilterFields.js +36 -22
- package/utils/renderListFilterFields.js.map +1 -0
- package/utils/renderSortEnum.d.ts +12 -0
- package/utils/renderSortEnum.js +42 -0
- package/utils/renderSortEnum.js.map +1 -0
- package/utils/toSlug.d.ts +1 -0
- package/utils/toSlug.js +16 -0
- package/utils/toSlug.js.map +1 -0
- package/validators/dateGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateGte.js +4 -11
- package/validators/dateGte.js.map +1 -0
- package/validators/dateLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateLte.js +4 -11
- package/validators/dateLte.js.map +1 -0
- package/validators/dynamicZone.d.ts +2 -0
- package/validators/dynamicZone.js +20 -0
- package/validators/dynamicZone.js.map +1 -0
- package/validators/gte.d.ts +2 -0
- package/validators/gte.js +28 -0
- package/validators/gte.js.map +1 -0
- package/validators/in.d.ts +2 -0
- package/validators/in.js +28 -0
- package/validators/in.js.map +1 -0
- package/validators/index.d.ts +1 -0
- package/validators/index.js +22 -0
- package/validators/index.js.map +1 -0
- package/validators/lte.d.ts +2 -0
- package/validators/lte.js +28 -0
- package/validators/lte.js.map +1 -0
- package/validators/maxLength.d.ts +2 -0
- package/validators/maxLength.js +28 -0
- package/validators/maxLength.js.map +1 -0
- package/validators/minLength.d.ts +2 -0
- package/validators/minLength.js +28 -0
- package/validators/minLength.js.map +1 -0
- package/validators/pattern.d.ts +2 -0
- package/validators/pattern.js +41 -0
- package/validators/pattern.js.map +1 -0
- package/validators/patternPlugins/email.d.ts +2 -0
- package/validators/patternPlugins/email.js +18 -0
- package/validators/patternPlugins/email.js.map +1 -0
- package/validators/patternPlugins/index.d.ts +2 -0
- package/validators/patternPlugins/index.js +16 -0
- package/validators/patternPlugins/index.js.map +1 -0
- package/validators/patternPlugins/lowerCase.d.ts +2 -0
- package/validators/patternPlugins/lowerCase.js +18 -0
- package/validators/patternPlugins/lowerCase.js.map +1 -0
- package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/lowerCaseSpace.js +18 -0
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
- package/validators/patternPlugins/upperCase.d.ts +2 -0
- package/validators/patternPlugins/upperCase.js +18 -0
- package/validators/patternPlugins/upperCase.js.map +1 -0
- package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/upperCaseSpace.js +18 -0
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
- package/validators/patternPlugins/url.d.ts +2 -0
- package/validators/patternPlugins/url.js +18 -0
- package/validators/patternPlugins/url.js.map +1 -0
- package/validators/required.d.ts +2 -0
- package/validators/required.js +22 -0
- package/validators/required.js.map +1 -0
- package/validators/timeGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeGte.js +5 -11
- package/validators/timeGte.js.map +1 -0
- package/validators/timeLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeLte.js +5 -11
- package/validators/timeLte.js.map +1 -0
- package/validators/unique.d.ts +6 -0
- package/validators/unique.js +56 -0
- package/validators/unique.js.map +1 -0
- package/content/contextSetup.d.ts +0 -4
- package/content/contextSetup.js +0 -65
- package/content/graphQLHandlerFactory.d.ts +0 -5
- package/content/graphQLHandlerFactory.js +0 -173
- package/content/plugins/CmsGroupPlugin.d.ts +0 -11
- package/content/plugins/CmsModelPlugin.d.ts +0 -11
- package/content/plugins/CmsModelPlugin.js +0 -24
- package/content/plugins/buildSchemaPlugins.d.ts +0 -7
- package/content/plugins/buildSchemaPlugins.js +0 -29
- package/content/plugins/crud/contentEntry/afterDelete.d.ts +0 -7
- package/content/plugins/crud/contentEntry/beforeCreate.d.ts +0 -7
- package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +0 -7
- package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +0 -4
- package/content/plugins/crud/contentEntry.crud.js +0 -931
- package/content/plugins/crud/contentModel/afterCreate.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterCreate.js +0 -18
- package/content/plugins/crud/contentModel/afterDelete.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterDelete.js +0 -18
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterUpdate.js +0 -18
- package/content/plugins/crud/contentModel/beforeCreate.d.ts +0 -9
- package/content/plugins/crud/contentModel/beforeDelete.d.ts +0 -9
- package/content/plugins/crud/contentModel/beforeUpdate.d.ts +0 -9
- package/content/plugins/crud/contentModel/beforeUpdate.js +0 -128
- package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +0 -2
- package/content/plugins/crud/contentModel/createFieldModels.d.ts +0 -2
- package/content/plugins/crud/contentModel/createFieldModels.js +0 -22
- package/content/plugins/crud/contentModel/idValidation.d.ts +0 -2
- package/content/plugins/crud/contentModel/idValidation.js +0 -22
- package/content/plugins/crud/contentModel/models.d.ts +0 -3
- package/content/plugins/crud/contentModel/models.js +0 -141
- package/content/plugins/crud/contentModel/validateLayout.d.ts +0 -2
- package/content/plugins/crud/contentModel.crud.js +0 -425
- package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +0 -9
- package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +0 -9
- package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +0 -8
- package/content/plugins/crud/contentModelGroup.crud.js +0 -351
- package/content/plugins/crud/index.d.ts +0 -6
- package/content/plugins/crud/index.js +0 -100
- package/content/plugins/graphqlFields/boolean.d.ts +0 -3
- package/content/plugins/graphqlFields/boolean.js +0 -69
- package/content/plugins/graphqlFields/datetime.d.ts +0 -3
- package/content/plugins/graphqlFields/datetime.js +0 -83
- package/content/plugins/graphqlFields/file.d.ts +0 -3
- package/content/plugins/graphqlFields/file.js +0 -49
- package/content/plugins/graphqlFields/index.d.ts +0 -2
- package/content/plugins/graphqlFields/index.js +0 -30
- package/content/plugins/graphqlFields/longText.d.ts +0 -3
- package/content/plugins/graphqlFields/longText.js +0 -62
- package/content/plugins/graphqlFields/number.d.ts +0 -3
- package/content/plugins/graphqlFields/number.js +0 -75
- package/content/plugins/graphqlFields/object.d.ts +0 -3
- package/content/plugins/graphqlFields/object.js +0 -180
- package/content/plugins/graphqlFields/ref.d.ts +0 -3
- package/content/plugins/graphqlFields/ref.js +0 -205
- package/content/plugins/graphqlFields/richText.d.ts +0 -3
- package/content/plugins/graphqlFields/richText.js +0 -55
- package/content/plugins/graphqlFields/text.d.ts +0 -3
- package/content/plugins/graphqlFields/text.js +0 -72
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +0 -8
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +0 -54
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +0 -7
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +0 -35
- package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +0 -15
- package/content/plugins/modelManager/index.d.ts +0 -3
- package/content/plugins/schema/baseSchema.d.ts +0 -4
- package/content/plugins/schema/baseSchema.js +0 -98
- package/content/plugins/schema/contentEntries.d.ts +0 -4
- package/content/plugins/schema/contentEntries.js +0 -166
- package/content/plugins/schema/contentModelGroups.d.ts +0 -4
- package/content/plugins/schema/contentModels.d.ts +0 -4
- package/content/plugins/schema/createFieldResolvers.d.ts +0 -19
- package/content/plugins/schema/createFieldResolvers.js +0 -92
- package/content/plugins/schema/createManageResolvers.d.ts +0 -11
- package/content/plugins/schema/createManageSDL.d.ts +0 -9
- package/content/plugins/schema/createPreviewResolvers.d.ts +0 -10
- package/content/plugins/schema/createPreviewResolvers.js +0 -55
- package/content/plugins/schema/createReadResolvers.d.ts +0 -10
- package/content/plugins/schema/createReadResolvers.js +0 -55
- package/content/plugins/schema/createReadSDL.d.ts +0 -9
- package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +0 -7
- package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveList.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +0 -23
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +0 -23
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +0 -7
- package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/preview/resolveGet.js +0 -38
- package/content/plugins/schema/resolvers/preview/resolveList.d.ts +0 -2
- package/content/plugins/schema/resolvers/read/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/read/resolveGet.js +0 -38
- package/content/plugins/schema/resolvers/read/resolveList.d.ts +0 -2
- package/content/plugins/schema/schemaPlugins.d.ts +0 -3
- package/content/plugins/schema/schemaPlugins.js +0 -92
- package/content/plugins/storage/StorageTransformPlugin.d.ts +0 -30
- package/content/plugins/storage/default.d.ts +0 -3
- package/content/plugins/storage/default.js +0 -28
- package/content/plugins/storage/object.d.ts +0 -3
- package/content/plugins/storage/object.js +0 -119
- package/content/plugins/utils/getEntryTitle.d.ts +0 -2
- package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +0 -11
- package/content/plugins/utils/getSchemaFromFieldPlugins.js +0 -30
- package/content/plugins/utils/pluralizedTypeName.d.ts +0 -1
- package/content/plugins/utils/renderFields.d.ts +0 -16
- package/content/plugins/utils/renderGetFilterFields.d.ts +0 -9
- package/content/plugins/utils/renderGetFilterFields.js +0 -41
- package/content/plugins/utils/renderInputFields.d.ts +0 -14
- package/content/plugins/utils/renderListFilterFields.d.ts +0 -10
- package/content/plugins/utils/renderSortEnum.d.ts +0 -9
- package/content/plugins/utils/renderSortEnum.js +0 -32
- package/content/plugins/validators/dateGte.d.ts +0 -3
- package/content/plugins/validators/dateLte.d.ts +0 -3
- package/content/plugins/validators/gte.d.ts +0 -3
- package/content/plugins/validators/gte.js +0 -32
- package/content/plugins/validators/in.d.ts +0 -3
- package/content/plugins/validators/in.js +0 -32
- package/content/plugins/validators/index.d.ts +0 -2
- package/content/plugins/validators/index.js +0 -36
- package/content/plugins/validators/lte.d.ts +0 -3
- package/content/plugins/validators/lte.js +0 -32
- package/content/plugins/validators/maxLength.d.ts +0 -3
- package/content/plugins/validators/maxLength.js +0 -32
- package/content/plugins/validators/minLength.d.ts +0 -3
- package/content/plugins/validators/minLength.js +0 -32
- package/content/plugins/validators/pattern.d.ts +0 -3
- package/content/plugins/validators/pattern.js +0 -47
- package/content/plugins/validators/patternPlugins/email.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/email.js +0 -17
- package/content/plugins/validators/patternPlugins/index.d.ts +0 -2
- package/content/plugins/validators/patternPlugins/index.js +0 -19
- package/content/plugins/validators/patternPlugins/lowerCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/lowerCase.js +0 -17
- package/content/plugins/validators/patternPlugins/upperCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/upperCase.js +0 -17
- package/content/plugins/validators/patternPlugins/url.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/url.js +0 -17
- package/content/plugins/validators/required.d.ts +0 -3
- package/content/plugins/validators/required.js +0 -25
- package/content/plugins/validators/timeGte.d.ts +0 -3
- package/content/plugins/validators/timeLte.d.ts +0 -3
- package/migrateCMSPermissions.d.ts +0 -17
- package/migrateCMSPermissions.js +0 -193
- package/plugins/context.d.ts +0 -4
- package/plugins/context.js +0 -34
- package/plugins/crud/index.d.ts +0 -6
- package/plugins/crud/index.js +0 -100
- package/plugins/crud/settings.crud.js +0 -93
- package/plugins/crud/system.crud.js +0 -182
- package/plugins/graphql/system.d.ts +0 -17
- package/plugins/graphql.d.ts +0 -2
- package/plugins/graphql.js +0 -79
- package/plugins/upgrades/index.d.ts +0 -2
- package/plugins/upgrades/index.js +0 -14
- package/plugins/upgrades/v5.5.0/helpers.d.ts +0 -6
- package/plugins/upgrades/v5.5.0/helpers.js +0 -10
- package/plugins/upgrades/v5.5.0/index.d.ts +0 -4
- package/plugins/upgrades/v5.5.0/index.js +0 -129
- package/transformers.d.ts +0 -2
- package/transformers.js +0 -25
- package/utils.d.ts +0 -25
- package/utils.js +0 -251
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.validateModelFields = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
+
var _createManageSDL = require("../../graphql/schema/createManageSDL");
|
|
11
|
+
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
12
|
+
var _createFieldStorageId = require("./createFieldStorageId");
|
|
13
|
+
var _getBaseFieldType = require("../../utils/getBaseFieldType");
|
|
14
|
+
var _plugins = require("../../plugins");
|
|
15
|
+
var _buildSchemaPlugins = require("../../graphql/buildSchemaPlugins");
|
|
16
|
+
var _createExecutableSchema = require("../../graphql/createExecutableSchema");
|
|
17
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
18
|
+
var _utils = require("@webiny/utils");
|
|
19
|
+
const defaultTitleFieldId = "id";
|
|
20
|
+
const allowedTitleFieldTypes = ["text", "number"];
|
|
21
|
+
const getContentModelTitleFieldId = (fields, titleFieldId) => {
|
|
22
|
+
/**
|
|
23
|
+
* If there are no fields defined, we will return the default field
|
|
24
|
+
*/
|
|
25
|
+
if (fields.length === 0) {
|
|
26
|
+
return defaultTitleFieldId;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* if there is no title field defined either in input data or existing content model data
|
|
30
|
+
* we will take first text field that has no multiple values enabled
|
|
31
|
+
* or if initial titleFieldId is the default one also try to find first available text field
|
|
32
|
+
*/
|
|
33
|
+
if (!titleFieldId || titleFieldId === defaultTitleFieldId) {
|
|
34
|
+
const titleField = fields.find(field => {
|
|
35
|
+
return (0, _getBaseFieldType.getBaseFieldType)(field) === "text" && !field.multipleValues;
|
|
36
|
+
});
|
|
37
|
+
return (titleField === null || titleField === void 0 ? void 0 : titleField.fieldId) || defaultTitleFieldId;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* check existing titleFieldId for existence in the model
|
|
41
|
+
* for correct type
|
|
42
|
+
* and that it is not multiple values field
|
|
43
|
+
*/
|
|
44
|
+
const target = fields.find(f => f.fieldId === titleFieldId);
|
|
45
|
+
if (!target) {
|
|
46
|
+
throw new _error.default(`Field selected for the title field does not exist in the model.`, "VALIDATION_ERROR", {
|
|
47
|
+
fieldId: titleFieldId,
|
|
48
|
+
fields
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (allowedTitleFieldTypes.includes(target.type) === false) {
|
|
52
|
+
throw new _error.default(`Only ${allowedTitleFieldTypes.join(", ")} and id fields can be used as an entry title.`, "ENTRY_TITLE_FIELD_TYPE", {
|
|
53
|
+
storageId: target.storageId,
|
|
54
|
+
fieldId: target.fieldId,
|
|
55
|
+
type: target.type
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (target.multipleValues) {
|
|
59
|
+
throw new _error.default(`Fields that accept multiple values cannot be used as the entry title.`, "ENTRY_TITLE_FIELD_TYPE", {
|
|
60
|
+
storageId: target.storageId,
|
|
61
|
+
fieldId: target.fieldId,
|
|
62
|
+
type: target.type
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return target.fieldId;
|
|
66
|
+
};
|
|
67
|
+
const extractInvalidField = (model, err) => {
|
|
68
|
+
var _err$source;
|
|
69
|
+
const sdl = ((_err$source = err.source) === null || _err$source === void 0 ? void 0 : _err$source.body) || "";
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Find the invalid type
|
|
73
|
+
*/
|
|
74
|
+
const {
|
|
75
|
+
line: lineNumber
|
|
76
|
+
} = err.locations ? err.locations[0] : {
|
|
77
|
+
line: 0
|
|
78
|
+
};
|
|
79
|
+
const sdlLines = sdl.split("\n");
|
|
80
|
+
let sdlLine;
|
|
81
|
+
let gqlType;
|
|
82
|
+
for (let i = lineNumber; i > 0; i--) {
|
|
83
|
+
if (sdlLine && sdlLine.includes("type ")) {
|
|
84
|
+
gqlType = sdlLine.match(/type\s+(.*?)\s+{/);
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
sdlLine = sdlLines[i];
|
|
88
|
+
}
|
|
89
|
+
let invalidField = undefined;
|
|
90
|
+
if (Array.isArray(gqlType)) {
|
|
91
|
+
const fieldRegex = new RegExp(`([^\\s+].*?):\\s+\\[?${gqlType[1]}!?\\]?`);
|
|
92
|
+
const matched = sdl.match(fieldRegex);
|
|
93
|
+
if (matched) {
|
|
94
|
+
invalidField = matched[1];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
let message = `See more details in the browser console.`;
|
|
98
|
+
if (invalidField) {
|
|
99
|
+
message = `Please review the definition of "${invalidField}" field.`;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
data: {
|
|
103
|
+
modelId: model.modelId,
|
|
104
|
+
sdl,
|
|
105
|
+
invalidField
|
|
106
|
+
},
|
|
107
|
+
code: "INVALID_MODEL_DEFINITION",
|
|
108
|
+
message: [`Model "${model.modelId}" was not saved!`, message].join("\n")
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
const createValidateChildFields = plugins => {
|
|
112
|
+
return ({
|
|
113
|
+
fields,
|
|
114
|
+
originalFields
|
|
115
|
+
}) => {
|
|
116
|
+
if (fields.length === 0 && originalFields.length === 0) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
validateFields({
|
|
120
|
+
fields,
|
|
121
|
+
originalFields,
|
|
122
|
+
plugins,
|
|
123
|
+
lockedFields: []
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
const validateFields = params => {
|
|
128
|
+
const {
|
|
129
|
+
plugins,
|
|
130
|
+
fields,
|
|
131
|
+
originalFields,
|
|
132
|
+
lockedFields
|
|
133
|
+
} = params;
|
|
134
|
+
const idList = [];
|
|
135
|
+
const fieldIdList = [];
|
|
136
|
+
const storageIdList = [];
|
|
137
|
+
for (const field of fields) {
|
|
138
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
139
|
+
const plugin = plugins.find(plugin => plugin.fieldType === baseType);
|
|
140
|
+
if (!plugin) {
|
|
141
|
+
throw new Error(`Cannot update content model because of the unknown "${baseType}" field.`);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Check the field's id against existing ones.
|
|
145
|
+
* There cannot be two fields with the same id.
|
|
146
|
+
*/
|
|
147
|
+
if (idList.includes(field.id)) {
|
|
148
|
+
throw new _error.default(`Cannot update content model because field "${field.storageId || field.fieldId}" has id "${field.id}", which is already used.`);
|
|
149
|
+
}
|
|
150
|
+
idList.push(field.id);
|
|
151
|
+
const originalField = originalFields.find(f => f.id === field.id);
|
|
152
|
+
/**
|
|
153
|
+
* Field MUST have an fieldId defined.
|
|
154
|
+
*/
|
|
155
|
+
if (!field.fieldId) {
|
|
156
|
+
throw new _error.default(`Field does not have an "fieldId" defined.`, "MISSING_FIELD_ID", {
|
|
157
|
+
field
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* If storageId does not match a certain pattern, add that pattern, but only if field is not locked (used) already.
|
|
162
|
+
* This is to avoid errors in the already installed systems.
|
|
163
|
+
*
|
|
164
|
+
* Why are we using the @?
|
|
165
|
+
*
|
|
166
|
+
* It is not part of special characters for the query syntax in the Lucene.
|
|
167
|
+
*
|
|
168
|
+
* Relevant links:
|
|
169
|
+
* https://lucene.apache.org/core/3_4_0/queryparsersyntax.html
|
|
170
|
+
* https://discuss.elastic.co/t/special-characters-in-field-names/10658/3
|
|
171
|
+
* https://discuss.elastic.co/t/illegal-characters-in-elasticsearch-field-names/17196/2
|
|
172
|
+
*/
|
|
173
|
+
const isLocked = lockedFields.some(lockedField => {
|
|
174
|
+
return lockedField.fieldId === field.storageId || lockedField.fieldId === field.fieldId;
|
|
175
|
+
});
|
|
176
|
+
if (!field.storageId) {
|
|
177
|
+
/**
|
|
178
|
+
* In case field is locked, we must set the storageId to the fieldId value.
|
|
179
|
+
* This should not happen, because we upgrade all the fields in 5.33.0, but let's have a check just in case of some upgrade miss.
|
|
180
|
+
*/
|
|
181
|
+
//
|
|
182
|
+
if (isLocked) {
|
|
183
|
+
field.storageId = field.fieldId;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* When having original field, just set the storageId to value from the originalField
|
|
187
|
+
*/
|
|
188
|
+
//
|
|
189
|
+
else if (originalField) {
|
|
190
|
+
field.storageId = originalField.storageId;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* The last case is when no original field and not locked - so this is a completely new field.
|
|
194
|
+
*/
|
|
195
|
+
//
|
|
196
|
+
else {
|
|
197
|
+
field.storageId = (0, _createFieldStorageId.createFieldStorageId)(field);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Check the field's fieldId against existing ones.
|
|
202
|
+
* There cannot be two fields with the same fieldId - outside world identifier.
|
|
203
|
+
*/
|
|
204
|
+
if (fieldIdList.includes(field.fieldId)) {
|
|
205
|
+
throw new _error.default(`Cannot update content model because field "${field.storageId}" has fieldId "${field.fieldId}", which is already used.`);
|
|
206
|
+
}
|
|
207
|
+
fieldIdList.push(field.fieldId);
|
|
208
|
+
/**
|
|
209
|
+
* Check the field's storageId against the existing ones.
|
|
210
|
+
* There cannot be two fields with the same storageId.
|
|
211
|
+
*/
|
|
212
|
+
if (storageIdList.includes(field.storageId)) {
|
|
213
|
+
throw new _error.default(`Cannot update content model because field "${field.label}" has storageId "${field.storageId}", which is already used.`);
|
|
214
|
+
}
|
|
215
|
+
storageIdList.push(field.storageId);
|
|
216
|
+
/**
|
|
217
|
+
* There might be some plugins which allow child fields.
|
|
218
|
+
* We use this method to validate them as well.
|
|
219
|
+
*/
|
|
220
|
+
if (!plugin.validateChildFields) {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
const validateChildFields = createValidateChildFields(plugins);
|
|
224
|
+
plugin.validateChildFields({
|
|
225
|
+
field,
|
|
226
|
+
originalField,
|
|
227
|
+
validate: validateChildFields
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
const createGraphQLSchema = async params => {
|
|
232
|
+
const {
|
|
233
|
+
context,
|
|
234
|
+
model
|
|
235
|
+
} = params;
|
|
236
|
+
context.security.disableAuthorization();
|
|
237
|
+
const models = await context.cms.listModels();
|
|
238
|
+
context.security.enableAuthorization();
|
|
239
|
+
const modelPlugins = await (0, _buildSchemaPlugins.buildSchemaPlugins)({
|
|
240
|
+
context,
|
|
241
|
+
models: models.concat([model])
|
|
242
|
+
});
|
|
243
|
+
const plugins = context.plugins.byType(_handlerGraphql.GraphQLSchemaPlugin.type).reduce((collection, plugin) => {
|
|
244
|
+
const name = plugin.name || `${plugin.type}-${(0, _utils.generateAlphaNumericId)(16)}`;
|
|
245
|
+
collection[name] = plugin;
|
|
246
|
+
return collection;
|
|
247
|
+
}, {});
|
|
248
|
+
for (const plugin of modelPlugins) {
|
|
249
|
+
const name = plugin.name || `${plugin.type}-${(0, _utils.generateAlphaNumericId)(16)}`;
|
|
250
|
+
plugins[name] = plugin;
|
|
251
|
+
}
|
|
252
|
+
return (0, _createExecutableSchema.createExecutableSchema)({
|
|
253
|
+
plugins: Object.values(plugins)
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
const extractErrorObject = error => {
|
|
257
|
+
return ["message", "code", "data", "stack"].reduce((output, key) => {
|
|
258
|
+
if (!error[key]) {
|
|
259
|
+
return output;
|
|
260
|
+
}
|
|
261
|
+
output[key] = error[key];
|
|
262
|
+
return output;
|
|
263
|
+
}, {});
|
|
264
|
+
};
|
|
265
|
+
const validateModelFields = async params => {
|
|
266
|
+
const {
|
|
267
|
+
model,
|
|
268
|
+
original,
|
|
269
|
+
context
|
|
270
|
+
} = params;
|
|
271
|
+
const {
|
|
272
|
+
titleFieldId
|
|
273
|
+
} = model;
|
|
274
|
+
const {
|
|
275
|
+
plugins
|
|
276
|
+
} = context;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* There should be fields/locked fields in either model or data to be updated.
|
|
280
|
+
*/
|
|
281
|
+
const {
|
|
282
|
+
fields = [],
|
|
283
|
+
lockedFields = []
|
|
284
|
+
} = model;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Let's inspect the fields of the received content model. We prevent saving of a content model if it
|
|
288
|
+
* contains a field for which a "cms-model-field-to-graphql" plugin does not exist on the backend.
|
|
289
|
+
*/
|
|
290
|
+
const fieldTypePlugins = plugins.byType("cms-model-field-to-graphql");
|
|
291
|
+
validateFields({
|
|
292
|
+
fields,
|
|
293
|
+
originalFields: (original === null || original === void 0 ? void 0 : original.fields) || [],
|
|
294
|
+
lockedFields,
|
|
295
|
+
plugins: fieldTypePlugins
|
|
296
|
+
});
|
|
297
|
+
if (fields.length) {
|
|
298
|
+
const sorterPlugins = plugins.byType(_plugins.CmsGraphQLSchemaSorterPlugin.type);
|
|
299
|
+
/**
|
|
300
|
+
* Make sure that this model can be safely converted to a GraphQL SDL
|
|
301
|
+
*/
|
|
302
|
+
const schema = (0, _createManageSDL.createManageSDL)({
|
|
303
|
+
model,
|
|
304
|
+
fieldTypePlugins: fieldTypePlugins.reduce((acc, pl) => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, acc), {}, {
|
|
305
|
+
[pl.fieldType]: pl
|
|
306
|
+
}), {}),
|
|
307
|
+
sorterPlugins
|
|
308
|
+
});
|
|
309
|
+
try {
|
|
310
|
+
(0, _graphqlTag.default)(schema);
|
|
311
|
+
} catch (err) {
|
|
312
|
+
throw new _error.default(extractInvalidField(model, err));
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
*
|
|
316
|
+
*/
|
|
317
|
+
try {
|
|
318
|
+
await createGraphQLSchema({
|
|
319
|
+
context,
|
|
320
|
+
model
|
|
321
|
+
});
|
|
322
|
+
} catch (err) {
|
|
323
|
+
throw new _error.default({
|
|
324
|
+
message: "Cannot generate GraphQL schema when testing with the given model. Please check the response for more details.",
|
|
325
|
+
code: "GRAPHQL_SCHEMA_ERROR",
|
|
326
|
+
data: {
|
|
327
|
+
modelId: model.modelId,
|
|
328
|
+
error: extractErrorObject(err)
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
model.titleFieldId = getContentModelTitleFieldId(fields, titleFieldId);
|
|
334
|
+
const cmsLockedFieldPlugins = plugins.byType("cms-model-locked-field");
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* We must not allow removal or changes in fields that are already in use in content entries.
|
|
338
|
+
* Locked fields still have fieldId (should be storageId) because of the old existing locked fields in the models.
|
|
339
|
+
*/
|
|
340
|
+
for (const lockedField of lockedFields) {
|
|
341
|
+
const existingField = fields.find(item => item.storageId === lockedField.fieldId);
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Starting with 5.33.0 fields can be deleted.
|
|
345
|
+
* Our UI gives a warning upon locked field deletion, but if user is managing fields through API directly - we cannot do anything.
|
|
346
|
+
*/
|
|
347
|
+
if (!existingField) {
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if (lockedField.multipleValues !== existingField.multipleValues) {
|
|
351
|
+
throw new _error.default(`Cannot change "multipleValues" for the "${lockedField.fieldId}" field because it's already in use in created content.`, "ENTRY_FIELD_USED", {
|
|
352
|
+
reason: `"multipleValues" changed`,
|
|
353
|
+
field: existingField
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
const fieldType = (0, _getBaseFieldType.getBaseFieldType)(existingField);
|
|
357
|
+
if (lockedField.type !== fieldType) {
|
|
358
|
+
throw new _error.default(`Cannot change field type for the "${lockedField.fieldId}" field because it's already in use in created content.`, "ENTRY_FIELD_USED", {
|
|
359
|
+
reason: `"type" changed`,
|
|
360
|
+
lockedFieldType: lockedField.type,
|
|
361
|
+
existingFieldType: fieldType
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Check `lockedField` invariant for specific field
|
|
367
|
+
*/
|
|
368
|
+
const lockedFieldsByType = cmsLockedFieldPlugins.filter(pl => pl.fieldType === (0, _getBaseFieldType.getBaseFieldType)(lockedField));
|
|
369
|
+
for (const plugin of lockedFieldsByType) {
|
|
370
|
+
if (typeof plugin.checkLockedField !== "function") {
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
plugin.checkLockedField({
|
|
374
|
+
lockedField,
|
|
375
|
+
field: existingField
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
exports.validateModelFields = validateModelFields;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultTitleFieldId","allowedTitleFieldTypes","getContentModelTitleFieldId","fields","titleFieldId","length","titleField","find","field","getBaseFieldType","multipleValues","fieldId","target","f","WebinyError","includes","type","join","storageId","extractInvalidField","model","err","sdl","source","body","line","lineNumber","locations","sdlLines","split","sdlLine","gqlType","i","match","invalidField","undefined","Array","isArray","fieldRegex","RegExp","matched","message","data","modelId","code","createValidateChildFields","plugins","originalFields","validateFields","lockedFields","params","idList","fieldIdList","storageIdList","baseType","plugin","fieldType","Error","id","push","originalField","isLocked","some","lockedField","createFieldStorageId","label","validateChildFields","validate","createGraphQLSchema","context","security","disableAuthorization","models","cms","listModels","enableAuthorization","modelPlugins","buildSchemaPlugins","concat","byType","GraphQLSchemaPlugin","reduce","collection","name","generateAlphaNumericId","createExecutableSchema","Object","values","extractErrorObject","error","output","key","validateModelFields","original","fieldTypePlugins","sorterPlugins","CmsGraphQLSchemaSorterPlugin","schema","createManageSDL","acc","pl","gql","cmsLockedFieldPlugins","existingField","item","reason","lockedFieldType","existingFieldType","lockedFieldsByType","filter","checkLockedField"],"sources":["validateModelFields.ts"],"sourcesContent":["import {\n CmsContext,\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin,\n CmsModelFieldToGraphQLPluginValidateChildFieldsValidate,\n CmsModelLockedFieldPlugin,\n LockedField\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { createManageSDL } from \"~/graphql/schema/createManageSDL\";\nimport gql from \"graphql-tag\";\nimport { createFieldStorageId } from \"./createFieldStorageId\";\nimport { GraphQLError } from \"graphql\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport { CmsGraphQLSchemaSorterPlugin } from \"~/plugins\";\nimport { buildSchemaPlugins } from \"~/graphql/buildSchemaPlugins\";\nimport { createExecutableSchema } from \"~/graphql/createExecutableSchema\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { generateAlphaNumericId } from \"@webiny/utils\";\n\nconst defaultTitleFieldId = \"id\";\n\nconst allowedTitleFieldTypes = [\"text\", \"number\"];\n\nconst getContentModelTitleFieldId = (fields: CmsModelField[], titleFieldId?: string): string => {\n /**\n * If there are no fields defined, we will return the default field\n */\n if (fields.length === 0) {\n return defaultTitleFieldId;\n }\n /**\n * if there is no title field defined either in input data or existing content model data\n * we will take first text field that has no multiple values enabled\n * or if initial titleFieldId is the default one also try to find first available text field\n */\n if (!titleFieldId || titleFieldId === defaultTitleFieldId) {\n const titleField = fields.find(field => {\n return getBaseFieldType(field) === \"text\" && !field.multipleValues;\n });\n return titleField?.fieldId || defaultTitleFieldId;\n }\n /**\n * check existing titleFieldId for existence in the model\n * for correct type\n * and that it is not multiple values field\n */\n const target = fields.find(f => f.fieldId === titleFieldId);\n if (!target) {\n throw new WebinyError(\n `Field selected for the title field does not exist in the model.`,\n \"VALIDATION_ERROR\",\n {\n fieldId: titleFieldId,\n fields\n }\n );\n }\n\n if (allowedTitleFieldTypes.includes(target.type) === false) {\n throw new WebinyError(\n `Only ${allowedTitleFieldTypes.join(\n \", \"\n )} and id fields can be used as an entry title.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n if (target.multipleValues) {\n throw new WebinyError(\n `Fields that accept multiple values cannot be used as the entry title.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n return target.fieldId;\n};\n\nconst extractInvalidField = (model: CmsModel, err: GraphQLError) => {\n const sdl = err.source?.body || \"\";\n\n /**\n * Find the invalid type\n */\n const { line: lineNumber } = err.locations\n ? err.locations[0]\n : {\n line: 0\n };\n const sdlLines = sdl.split(\"\\n\");\n let sdlLine;\n let gqlType;\n for (let i = lineNumber; i > 0; i--) {\n if (sdlLine && sdlLine.includes(\"type \")) {\n gqlType = sdlLine.match(/type\\s+(.*?)\\s+{/);\n break;\n }\n\n sdlLine = sdlLines[i];\n }\n\n let invalidField: string | undefined = undefined;\n if (Array.isArray(gqlType)) {\n const fieldRegex = new RegExp(`([^\\\\s+].*?):\\\\s+\\\\[?${gqlType[1]}!?\\\\]?`);\n\n const matched = sdl.match(fieldRegex);\n if (matched) {\n invalidField = matched[1];\n }\n }\n\n let message = `See more details in the browser console.`;\n if (invalidField) {\n message = `Please review the definition of \"${invalidField}\" field.`;\n }\n\n return {\n data: {\n modelId: model.modelId,\n sdl,\n invalidField\n },\n code: \"INVALID_MODEL_DEFINITION\",\n message: [`Model \"${model.modelId}\" was not saved!`, message].join(\"\\n\")\n };\n};\n\nconst createValidateChildFields = (\n plugins: CmsModelFieldToGraphQLPlugin[]\n): CmsModelFieldToGraphQLPluginValidateChildFieldsValidate => {\n return ({ fields, originalFields }) => {\n if (fields.length === 0 && originalFields.length === 0) {\n return;\n }\n validateFields({\n fields,\n originalFields,\n plugins,\n lockedFields: []\n });\n };\n};\n\ninterface ValidateFieldsParams {\n plugins: CmsModelFieldToGraphQLPlugin[];\n fields: CmsModelField[];\n originalFields: CmsModelField[];\n lockedFields: LockedField[];\n}\nconst validateFields = (params: ValidateFieldsParams) => {\n const { plugins, fields, originalFields, lockedFields } = params;\n\n const idList: string[] = [];\n const fieldIdList: string[] = [];\n const storageIdList: string[] = [];\n\n for (const field of fields) {\n const baseType = getBaseFieldType(field);\n const plugin = plugins.find(plugin => plugin.fieldType === baseType);\n\n if (!plugin) {\n throw new Error(\n `Cannot update content model because of the unknown \"${baseType}\" field.`\n );\n }\n /**\n * Check the field's id against existing ones.\n * There cannot be two fields with the same id.\n */\n if (idList.includes(field.id)) {\n throw new WebinyError(\n `Cannot update content model because field \"${\n field.storageId || field.fieldId\n }\" has id \"${field.id}\", which is already used.`\n );\n }\n idList.push(field.id);\n\n const originalField = originalFields.find(f => f.id === field.id);\n /**\n * Field MUST have an fieldId defined.\n */\n if (!field.fieldId) {\n throw new WebinyError(`Field does not have an \"fieldId\" defined.`, \"MISSING_FIELD_ID\", {\n field\n });\n }\n /**\n * If storageId does not match a certain pattern, add that pattern, but only if field is not locked (used) already.\n * This is to avoid errors in the already installed systems.\n *\n * Why are we using the @?\n *\n * It is not part of special characters for the query syntax in the Lucene.\n *\n * Relevant links:\n * https://lucene.apache.org/core/3_4_0/queryparsersyntax.html\n * https://discuss.elastic.co/t/special-characters-in-field-names/10658/3\n * https://discuss.elastic.co/t/illegal-characters-in-elasticsearch-field-names/17196/2\n */\n const isLocked = lockedFields.some(lockedField => {\n return lockedField.fieldId === field.storageId || lockedField.fieldId === field.fieldId;\n });\n if (!field.storageId) {\n /**\n * In case field is locked, we must set the storageId to the fieldId value.\n * This should not happen, because we upgrade all the fields in 5.33.0, but let's have a check just in case of some upgrade miss.\n */\n //\n if (isLocked) {\n field.storageId = field.fieldId;\n }\n /**\n * When having original field, just set the storageId to value from the originalField\n */\n //\n else if (originalField) {\n field.storageId = originalField.storageId;\n }\n /**\n * The last case is when no original field and not locked - so this is a completely new field.\n */\n //\n else {\n field.storageId = createFieldStorageId(field);\n }\n }\n /**\n * Check the field's fieldId against existing ones.\n * There cannot be two fields with the same fieldId - outside world identifier.\n */\n if (fieldIdList.includes(field.fieldId)) {\n throw new WebinyError(\n `Cannot update content model because field \"${field.storageId}\" has fieldId \"${field.fieldId}\", which is already used.`\n );\n }\n fieldIdList.push(field.fieldId);\n /**\n * Check the field's storageId against the existing ones.\n * There cannot be two fields with the same storageId.\n */\n if (storageIdList.includes(field.storageId)) {\n throw new WebinyError(\n `Cannot update content model because field \"${field.label}\" has storageId \"${field.storageId}\", which is already used.`\n );\n }\n storageIdList.push(field.storageId);\n /**\n * There might be some plugins which allow child fields.\n * We use this method to validate them as well.\n */\n if (!plugin.validateChildFields) {\n continue;\n }\n const validateChildFields = createValidateChildFields(plugins);\n plugin.validateChildFields({\n field,\n originalField,\n validate: validateChildFields\n });\n }\n};\ninterface CreateGraphQLSchemaParams {\n context: CmsContext;\n model: CmsModel;\n}\nconst createGraphQLSchema = async (params: CreateGraphQLSchemaParams): Promise<any> => {\n const { context, model } = params;\n\n context.security.disableAuthorization();\n const models = await context.cms.listModels();\n context.security.enableAuthorization();\n\n const modelPlugins = await buildSchemaPlugins({\n context,\n models: models.concat([model])\n });\n\n const plugins = context.plugins\n .byType<GraphQLSchemaPlugin<CmsContext>>(GraphQLSchemaPlugin.type)\n .reduce<Record<string, GraphQLSchemaPlugin<CmsContext>>>((collection, plugin) => {\n const name = plugin.name || `${plugin.type}-${generateAlphaNumericId(16)}`;\n collection[name] = plugin;\n return collection;\n }, {});\n for (const plugin of modelPlugins) {\n const name = plugin.name || `${plugin.type}-${generateAlphaNumericId(16)}`;\n plugins[name] = plugin;\n }\n\n return createExecutableSchema({\n plugins: Object.values(plugins)\n });\n};\n\nconst extractErrorObject = (error: any) => {\n return [\"message\", \"code\", \"data\", \"stack\"].reduce<Record<string, any>>((output, key) => {\n if (!error[key]) {\n return output;\n }\n output[key] = error[key];\n return output;\n }, {});\n};\n\ninterface ValidateModelFieldsParams {\n model: CmsModel;\n original?: CmsModel;\n context: CmsContext;\n}\nexport const validateModelFields = async (params: ValidateModelFieldsParams): Promise<void> => {\n const { model, original, context } = params;\n const { titleFieldId } = model;\n const { plugins } = context;\n\n /**\n * There should be fields/locked fields in either model or data to be updated.\n */\n const { fields = [], lockedFields = [] } = model;\n\n /**\n * Let's inspect the fields of the received content model. We prevent saving of a content model if it\n * contains a field for which a \"cms-model-field-to-graphql\" plugin does not exist on the backend.\n */\n const fieldTypePlugins = plugins.byType<CmsModelFieldToGraphQLPlugin>(\n \"cms-model-field-to-graphql\"\n );\n\n validateFields({\n fields,\n originalFields: original?.fields || [],\n lockedFields,\n plugins: fieldTypePlugins\n });\n\n if (fields.length) {\n const sorterPlugins = plugins.byType<CmsGraphQLSchemaSorterPlugin>(\n CmsGraphQLSchemaSorterPlugin.type\n );\n /**\n * Make sure that this model can be safely converted to a GraphQL SDL\n */\n const schema = createManageSDL({\n model,\n fieldTypePlugins: fieldTypePlugins.reduce(\n (acc, pl) => ({ ...acc, [pl.fieldType]: pl }),\n {}\n ),\n sorterPlugins\n });\n\n try {\n gql(schema);\n } catch (err) {\n throw new WebinyError(extractInvalidField(model, err));\n }\n /**\n *\n */\n try {\n await createGraphQLSchema({\n context,\n model\n });\n } catch (err) {\n throw new WebinyError({\n message:\n \"Cannot generate GraphQL schema when testing with the given model. Please check the response for more details.\",\n code: \"GRAPHQL_SCHEMA_ERROR\",\n data: {\n modelId: model.modelId,\n error: extractErrorObject(err)\n }\n });\n }\n }\n\n model.titleFieldId = getContentModelTitleFieldId(fields, titleFieldId);\n\n const cmsLockedFieldPlugins =\n plugins.byType<CmsModelLockedFieldPlugin>(\"cms-model-locked-field\");\n\n /**\n * We must not allow removal or changes in fields that are already in use in content entries.\n * Locked fields still have fieldId (should be storageId) because of the old existing locked fields in the models.\n */\n for (const lockedField of lockedFields) {\n const existingField = fields.find(item => item.storageId === lockedField.fieldId);\n\n /**\n * Starting with 5.33.0 fields can be deleted.\n * Our UI gives a warning upon locked field deletion, but if user is managing fields through API directly - we cannot do anything.\n */\n if (!existingField) {\n continue;\n }\n\n if (lockedField.multipleValues !== existingField.multipleValues) {\n throw new WebinyError(\n `Cannot change \"multipleValues\" for the \"${lockedField.fieldId}\" field because it's already in use in created content.`,\n \"ENTRY_FIELD_USED\",\n {\n reason: `\"multipleValues\" changed`,\n field: existingField\n }\n );\n }\n\n const fieldType = getBaseFieldType(existingField);\n if (lockedField.type !== fieldType) {\n throw new WebinyError(\n `Cannot change field type for the \"${lockedField.fieldId}\" field because it's already in use in created content.`,\n \"ENTRY_FIELD_USED\",\n {\n reason: `\"type\" changed`,\n lockedFieldType: lockedField.type,\n existingFieldType: fieldType\n }\n );\n }\n\n /**\n * Check `lockedField` invariant for specific field\n */\n const lockedFieldsByType = cmsLockedFieldPlugins.filter(\n pl => pl.fieldType === getBaseFieldType(lockedField)\n );\n for (const plugin of lockedFieldsByType) {\n if (typeof plugin.checkLockedField !== \"function\") {\n continue;\n }\n plugin.checkLockedField({\n lockedField,\n field: existingField\n });\n }\n }\n};\n"],"mappings":";;;;;;;;AASA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAMA,mBAAmB,GAAG,IAAI;AAEhC,MAAMC,sBAAsB,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;AAEjD,MAAMC,2BAA2B,GAAG,CAACC,MAAuB,EAAEC,YAAqB,KAAa;EAC5F;AACJ;AACA;EACI,IAAID,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE;IACrB,OAAOL,mBAAmB;EAC9B;EACA;AACJ;AACA;AACA;AACA;EACI,IAAI,CAACI,YAAY,IAAIA,YAAY,KAAKJ,mBAAmB,EAAE;IACvD,MAAMM,UAAU,GAAGH,MAAM,CAACI,IAAI,CAACC,KAAK,IAAI;MACpC,OA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