@webiny/api-headless-cms 0.0.0-mt-3 → 0.0.0-unstable.1145e7667f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.d.ts +6 -0
- package/context.js +98 -0
- package/context.js.map +1 -0
- package/crud/contentEntry/afterDelete.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.js +2 -7
- package/crud/contentEntry/afterDelete.js.map +1 -0
- package/crud/contentEntry/beforeCreate.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.js +2 -5
- package/crud/contentEntry/beforeCreate.js.map +1 -0
- package/crud/contentEntry/beforeUpdate.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.js +2 -5
- package/crud/contentEntry/beforeUpdate.js.map +1 -0
- package/crud/contentEntry/entryDataValidation.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.js +22 -49
- package/crud/contentEntry/entryDataValidation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.d.ts +3 -2
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.js +29 -43
- package/crud/contentEntry/markLockedFields.js.map +1 -0
- package/crud/contentEntry/referenceFieldsMapping.d.ts +13 -0
- package/crud/contentEntry/referenceFieldsMapping.js +265 -0
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -0
- package/crud/contentEntry/searchableFields.d.ts +9 -0
- package/crud/contentEntry/searchableFields.js +72 -0
- package/crud/contentEntry/searchableFields.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry.crud.d.ts +7 -8
- package/crud/contentEntry.crud.js +1212 -0
- package/crud/contentEntry.crud.js.map +1 -0
- package/crud/contentModel/afterCreate.d.ts +8 -0
- package/crud/contentModel/afterCreate.js +16 -0
- package/crud/contentModel/afterCreate.js.map +1 -0
- package/crud/contentModel/afterCreateFrom.d.ts +8 -0
- package/crud/contentModel/afterCreateFrom.js +16 -0
- package/crud/contentModel/afterCreateFrom.js.map +1 -0
- package/crud/contentModel/afterDelete.d.ts +8 -0
- package/crud/contentModel/afterDelete.js +16 -0
- package/crud/contentModel/afterDelete.js.map +1 -0
- package/crud/contentModel/afterUpdate.d.ts +8 -0
- package/crud/contentModel/afterUpdate.js +16 -0
- package/crud/contentModel/afterUpdate.js.map +1 -0
- package/crud/contentModel/beforeCreate.d.ts +14 -0
- package/crud/contentModel/beforeCreate.js +128 -0
- package/crud/contentModel/beforeCreate.js.map +1 -0
- package/crud/contentModel/beforeDelete.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.js +8 -18
- package/crud/contentModel/beforeDelete.js.map +1 -0
- package/crud/contentModel/beforeUpdate.d.ts +8 -0
- package/crud/contentModel/beforeUpdate.js +60 -0
- package/crud/contentModel/beforeUpdate.js.map +1 -0
- package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
- package/crud/contentModel/compatibility/modelApiName.js +24 -0
- package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
- package/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js +0 -7
- package/crud/contentModel/contentModelManagerFactory.js.map +1 -0
- package/crud/contentModel/createFieldModels.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/createFieldModels.js +6 -2
- package/crud/contentModel/createFieldModels.js.map +1 -0
- package/crud/contentModel/createFieldStorageId.d.ts +2 -0
- package/crud/contentModel/createFieldStorageId.js +17 -0
- package/crud/contentModel/createFieldStorageId.js.map +1 -0
- package/crud/contentModel/defaultFields.d.ts +5 -0
- package/crud/contentModel/defaultFields.js +58 -0
- package/crud/contentModel/defaultFields.js.map +1 -0
- package/crud/contentModel/fieldIdValidation.d.ts +1 -0
- package/crud/contentModel/fieldIdValidation.js +25 -0
- package/crud/contentModel/fieldIdValidation.js.map +1 -0
- package/crud/contentModel/fields/descriptionField.d.ts +2 -0
- package/crud/contentModel/fields/descriptionField.js +42 -0
- package/crud/contentModel/fields/descriptionField.js.map +1 -0
- package/crud/contentModel/fields/imageField.d.ts +2 -0
- package/crud/contentModel/fields/imageField.js +46 -0
- package/crud/contentModel/fields/imageField.js.map +1 -0
- package/crud/contentModel/fields/titleField.d.ts +2 -0
- package/crud/contentModel/fields/titleField.js +58 -0
- package/crud/contentModel/fields/titleField.js.map +1 -0
- package/crud/contentModel/idValidation.d.ts +1 -0
- package/{content/plugins/crud → crud}/contentModel/idValidation.js +3 -3
- package/crud/contentModel/idValidation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/models.d.ts +2 -1
- package/{content/plugins/crud → crud}/contentModel/models.js +76 -25
- package/crud/contentModel/models.js.map +1 -0
- package/crud/contentModel/systemFields.d.ts +1 -0
- package/crud/contentModel/systemFields.js +8 -0
- package/crud/contentModel/systemFields.js.map +1 -0
- package/crud/contentModel/validate/endingAllowed.d.ts +6 -0
- package/crud/contentModel/validate/endingAllowed.js +26 -0
- package/crud/contentModel/validate/endingAllowed.js.map +1 -0
- package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
- package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
- package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
- package/crud/contentModel/validate/modelId.d.ts +11 -0
- package/crud/contentModel/validate/modelId.js +36 -0
- package/crud/contentModel/validate/modelId.js.map +1 -0
- package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
- package/crud/contentModel/validate/pluralApiName.js +24 -0
- package/crud/contentModel/validate/pluralApiName.js.map +1 -0
- package/crud/contentModel/validate/singularApiName.d.ts +7 -0
- package/crud/contentModel/validate/singularApiName.js +24 -0
- package/crud/contentModel/validate/singularApiName.js.map +1 -0
- package/crud/contentModel/validateLayout.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/validateLayout.js +1 -11
- package/crud/contentModel/validateLayout.js.map +1 -0
- package/crud/contentModel/validateModel.d.ts +9 -0
- package/crud/contentModel/validateModel.js +27 -0
- package/crud/contentModel/validateModel.js.map +1 -0
- package/crud/contentModel/validateModelFields.d.ts +9 -0
- package/crud/contentModel/validateModelFields.js +342 -0
- package/crud/contentModel/validateModelFields.js.map +1 -0
- package/crud/contentModel/validation.d.ts +551 -0
- package/crud/contentModel/validation.js +145 -0
- package/crud/contentModel/validation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel.crud.d.ts +3 -3
- package/crud/contentModel.crud.js +616 -0
- package/crud/contentModel.crud.js.map +1 -0
- package/crud/contentModelGroup/beforeCreate.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.js +8 -20
- package/crud/contentModelGroup/beforeCreate.js.map +1 -0
- package/crud/contentModelGroup/beforeDelete.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.js +4 -12
- package/crud/contentModelGroup/beforeDelete.js.map +1 -0
- package/crud/contentModelGroup/beforeUpdate.d.ts +9 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.js +3 -8
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
- package/crud/contentModelGroup/validation.d.ts +30 -0
- package/crud/contentModelGroup/validation.js +34 -0
- package/crud/contentModelGroup/validation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup.crud.d.ts +3 -3
- package/crud/contentModelGroup.crud.js +352 -0
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/{plugins/crud → crud}/settings.crud.d.ts +3 -3
- package/crud/settings.crud.js +66 -0
- package/crud/settings.crud.js.map +1 -0
- package/{plugins/crud → crud}/system.crud.d.ts +6 -3
- package/crud/system.crud.js +126 -0
- package/crud/system.crud.js.map +1 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +7 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +53 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +203 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +251 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/index.d.ts +4 -0
- package/fieldConverters/index.js +13 -0
- package/fieldConverters/index.js.map +1 -0
- package/graphql/buildSchemaPlugins.d.ts +11 -0
- package/graphql/buildSchemaPlugins.js +19 -0
- package/graphql/buildSchemaPlugins.js.map +1 -0
- package/graphql/checkEndpointAccess.d.ts +2 -0
- package/graphql/checkEndpointAccess.js +18 -0
- package/graphql/checkEndpointAccess.js.map +1 -0
- package/graphql/createExecutableSchema.d.ts +6 -0
- package/graphql/createExecutableSchema.js +29 -0
- package/graphql/createExecutableSchema.js.map +1 -0
- package/graphql/createRequestBody.d.ts +2 -0
- package/graphql/createRequestBody.js +14 -0
- package/graphql/createRequestBody.js.map +1 -0
- package/graphql/formatErrorPayload.d.ts +1 -0
- package/graphql/formatErrorPayload.js +25 -0
- package/graphql/formatErrorPayload.js.map +1 -0
- package/graphql/generateSchema.d.ts +8 -0
- package/graphql/generateSchema.js +31 -0
- package/graphql/generateSchema.js.map +1 -0
- package/graphql/getSchema.d.ts +17 -0
- package/graphql/getSchema.js +102 -0
- package/graphql/getSchema.js.map +1 -0
- package/graphql/graphQLHandlerFactory.d.ts +5 -0
- package/graphql/graphQLHandlerFactory.js +35 -0
- package/graphql/graphQLHandlerFactory.js.map +1 -0
- package/graphql/handleRequest.d.ts +11 -0
- package/graphql/handleRequest.js +81 -0
- package/graphql/handleRequest.js.map +1 -0
- package/graphql/index.d.ts +3 -0
- package/graphql/index.js +13 -0
- package/graphql/index.js.map +1 -0
- package/graphql/schema/baseContentSchema.d.ts +7 -0
- package/graphql/schema/baseContentSchema.js +66 -0
- package/graphql/schema/baseContentSchema.js.map +1 -0
- package/graphql/schema/baseSchema.d.ts +3 -0
- package/graphql/schema/baseSchema.js +53 -0
- package/graphql/schema/baseSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +7 -0
- package/graphql/schema/contentEntries.js +362 -0
- package/graphql/schema/contentEntries.js.map +1 -0
- package/graphql/schema/contentModelGroups.d.ts +7 -0
- package/{content/plugins → graphql}/schema/contentModelGroups.js +39 -33
- package/graphql/schema/contentModelGroups.js.map +1 -0
- package/graphql/schema/contentModels.d.ts +7 -0
- package/{content/plugins → graphql}/schema/contentModels.js +121 -29
- package/graphql/schema/contentModels.js.map +1 -0
- package/graphql/schema/createFieldResolvers.d.ts +20 -0
- package/graphql/schema/createFieldResolvers.js +111 -0
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +12 -0
- package/graphql/schema/createManageResolvers.js +127 -0
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/graphql/schema/createManageSDL.d.ts +13 -0
- package/graphql/schema/createManageSDL.js +157 -0
- package/graphql/schema/createManageSDL.js.map +1 -0
- package/graphql/schema/createPreviewResolvers.d.ts +12 -0
- package/graphql/schema/createPreviewResolvers.js +44 -0
- package/graphql/schema/createPreviewResolvers.js.map +1 -0
- package/graphql/schema/createReadResolvers.d.ts +12 -0
- package/graphql/schema/createReadResolvers.js +49 -0
- package/graphql/schema/createReadResolvers.js.map +1 -0
- package/graphql/schema/createReadSDL.d.ts +13 -0
- package/graphql/schema/createReadSDL.js +100 -0
- package/graphql/schema/createReadSDL.js.map +1 -0
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js +2 -3
- package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveCreate.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js +2 -7
- package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +8 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js +2 -7
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveDelete.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js +8 -12
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGet.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveGet.js +63 -0
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js +2 -7
- package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetRevisions.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js +2 -7
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveList.d.ts +4 -0
- package/{content/plugins/schema/resolvers/preview → graphql/schema/resolvers/manage}/resolveList.js +2 -7
- package/graphql/schema/resolvers/manage/resolveList.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolvePublish.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js +0 -3
- package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveRepublish.d.ts +7 -0
- package/{content/plugins/schema/resolvers/manage/resolveGet.js → graphql/schema/resolvers/manage/resolveRepublish.js} +4 -7
- package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveUnpublish.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js +0 -3
- package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +8 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js +2 -7
- package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveGet.d.ts +4 -0
- package/graphql/schema/resolvers/preview/resolveGet.js +26 -0
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveList.d.ts +4 -0
- package/{content/plugins/schema/resolvers/manage → graphql/schema/resolvers/preview}/resolveList.js +2 -7
- package/graphql/schema/resolvers/preview/resolveList.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveGet.d.ts +4 -0
- package/graphql/schema/resolvers/read/resolveGet.js +26 -0
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveList.d.ts +4 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.js +2 -7
- package/graphql/schema/resolvers/read/resolveList.js.map +1 -0
- package/graphql/schema/schemaPlugins.d.ts +8 -0
- package/graphql/schema/schemaPlugins.js +109 -0
- package/graphql/schema/schemaPlugins.js.map +1 -0
- package/graphql/system.d.ts +6 -0
- package/{plugins/graphql → graphql}/system.js +39 -24
- package/graphql/system.js.map +1 -0
- package/graphqlFields/boolean.d.ts +2 -0
- package/graphqlFields/boolean.js +57 -0
- package/graphqlFields/boolean.js.map +1 -0
- package/graphqlFields/datetime.d.ts +2 -0
- package/graphqlFields/datetime.js +78 -0
- package/graphqlFields/datetime.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js +243 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js +63 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
- package/graphqlFields/dynamicZone/index.d.ts +2 -0
- package/graphqlFields/dynamicZone/index.js +19 -0
- package/graphqlFields/dynamicZone/index.js.map +1 -0
- package/graphqlFields/file.d.ts +2 -0
- package/graphqlFields/file.js +42 -0
- package/graphqlFields/file.js.map +1 -0
- package/graphqlFields/helpers.d.ts +6 -0
- package/graphqlFields/helpers.js +39 -0
- package/graphqlFields/helpers.js.map +1 -0
- package/graphqlFields/index.d.ts +2 -0
- package/graphqlFields/index.js +18 -0
- package/graphqlFields/index.js.map +1 -0
- package/graphqlFields/longText.d.ts +2 -0
- package/graphqlFields/longText.js +53 -0
- package/graphqlFields/longText.js.map +1 -0
- package/graphqlFields/number.d.ts +2 -0
- package/graphqlFields/number.js +67 -0
- package/graphqlFields/number.js.map +1 -0
- package/graphqlFields/object.d.ts +2 -0
- package/graphqlFields/object.js +258 -0
- package/graphqlFields/object.js.map +1 -0
- package/graphqlFields/ref.d.ts +2 -0
- package/graphqlFields/ref.js +255 -0
- package/graphqlFields/ref.js.map +1 -0
- package/graphqlFields/richText.d.ts +2 -0
- package/graphqlFields/richText.js +47 -0
- package/graphqlFields/richText.js.map +1 -0
- package/graphqlFields/text.d.ts +2 -0
- package/graphqlFields/text.js +62 -0
- package/graphqlFields/text.js.map +1 -0
- package/index.d.ts +12 -12
- package/index.js +98 -55
- package/index.js.map +1 -0
- package/modelManager/DefaultCmsModelManager.d.ts +14 -0
- package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js +10 -24
- package/modelManager/DefaultCmsModelManager.js.map +1 -0
- package/modelManager/index.d.ts +2 -0
- package/{content/plugins/modelManager → modelManager}/index.js +3 -7
- package/modelManager/index.js.map +1 -0
- package/package.json +37 -38
- package/parameters/context.d.ts +2 -0
- package/parameters/context.js +18 -0
- package/parameters/context.js.map +1 -0
- package/parameters/header.d.ts +2 -0
- package/parameters/header.js +44 -0
- package/parameters/header.js.map +1 -0
- package/parameters/index.d.ts +4 -0
- package/parameters/index.js +49 -0
- package/parameters/index.js.map +1 -0
- package/parameters/manual.d.ts +6 -0
- package/parameters/manual.js +37 -0
- package/parameters/manual.js.map +1 -0
- package/parameters/path.d.ts +2 -0
- package/parameters/path.js +40 -0
- package/parameters/path.js.map +1 -0
- package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
- package/plugins/CmsGraphQLSchemaPlugin.js +12 -0
- package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js +28 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
- package/plugins/CmsGroupPlugin.d.ts +13 -0
- package/{content/plugins → plugins}/CmsGroupPlugin.js +7 -9
- package/plugins/CmsGroupPlugin.js.map +1 -0
- package/plugins/CmsModelFieldConverterPlugin.d.ts +14 -0
- package/plugins/CmsModelFieldConverterPlugin.js +12 -0
- package/plugins/CmsModelFieldConverterPlugin.js.map +1 -0
- package/plugins/CmsModelPlugin.d.ts +61 -0
- package/plugins/CmsModelPlugin.js +184 -0
- package/plugins/CmsModelPlugin.js.map +1 -0
- package/plugins/CmsParametersPlugin.d.ts +20 -0
- package/plugins/CmsParametersPlugin.js +21 -0
- package/plugins/CmsParametersPlugin.js.map +1 -0
- package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
- package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
- package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
- package/plugins/StorageTransformPlugin.d.ts +31 -0
- package/{content/plugins/storage → plugins}/StorageTransformPlugin.js +2 -10
- package/plugins/StorageTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +8 -0
- package/plugins/index.js +93 -0
- package/plugins/index.js.map +1 -0
- package/storage/default.d.ts +2 -0
- package/storage/default.js +24 -0
- package/storage/default.js.map +1 -0
- package/storage/object.d.ts +2 -0
- package/storage/object.js +108 -0
- package/storage/object.js.map +1 -0
- package/types.d.ts +920 -374
- package/types.js +105 -62
- package/types.js.map +1 -0
- package/upgrades/5.33.0/index.d.ts +3 -0
- package/upgrades/5.33.0/index.js +182 -0
- package/upgrades/5.33.0/index.js.map +1 -0
- package/upgrades/index.d.ts +1 -0
- package/upgrades/index.js +12 -0
- package/upgrades/index.js.map +1 -0
- package/utils/access.d.ts +8 -0
- package/utils/access.js +76 -0
- package/utils/access.js.map +1 -0
- package/utils/converters/Converter.d.ts +27 -0
- package/utils/converters/Converter.js +58 -0
- package/utils/converters/Converter.js.map +1 -0
- package/utils/converters/ConverterCollection.d.ts +31 -0
- package/utils/converters/ConverterCollection.js +119 -0
- package/utils/converters/ConverterCollection.js.map +1 -0
- package/utils/converters/valueKeyStorageConverter.d.ts +14 -0
- package/utils/converters/valueKeyStorageConverter.js +125 -0
- package/utils/converters/valueKeyStorageConverter.js.map +1 -0
- package/utils/createTypeFromFields.d.ts +16 -0
- package/utils/createTypeFromFields.js +66 -0
- package/utils/createTypeFromFields.js.map +1 -0
- package/utils/createTypeName.d.ts +1 -0
- package/utils/createTypeName.js +13 -0
- package/utils/createTypeName.js.map +1 -0
- package/{content/plugins/utils → utils}/entryStorage.d.ts +3 -3
- package/{content/plugins/utils → utils}/entryStorage.js +26 -47
- package/utils/entryStorage.js.map +1 -0
- package/utils/filterAsync.d.ts +1 -0
- package/utils/filterAsync.js +18 -0
- package/utils/filterAsync.js.map +1 -0
- package/utils/getBaseFieldType.d.ts +4 -0
- package/utils/getBaseFieldType.js +10 -0
- package/utils/getBaseFieldType.js.map +1 -0
- package/utils/getEntryDescription.d.ts +2 -0
- package/utils/getEntryDescription.js +17 -0
- package/utils/getEntryDescription.js.map +1 -0
- package/utils/getEntryImage.d.ts +2 -0
- package/utils/getEntryImage.js +17 -0
- package/utils/getEntryImage.js.map +1 -0
- package/utils/getEntryTitle.d.ts +2 -0
- package/{content/plugins/utils → utils}/getEntryTitle.js +7 -15
- package/utils/getEntryTitle.js.map +1 -0
- package/utils/getSchemaFromFieldPlugins.d.ts +9 -0
- package/utils/getSchemaFromFieldPlugins.js +39 -0
- package/utils/getSchemaFromFieldPlugins.js.map +1 -0
- package/utils/incrementEntryIdVersion.d.ts +5 -0
- package/utils/incrementEntryIdVersion.js +29 -0
- package/utils/incrementEntryIdVersion.js.map +1 -0
- package/utils/ownership.d.ts +8 -0
- package/utils/ownership.js +33 -0
- package/utils/ownership.js.map +1 -0
- package/utils/permissions.d.ts +7 -0
- package/utils/permissions.js +91 -0
- package/utils/permissions.js.map +1 -0
- package/utils/pluralizedTypeName.d.ts +1 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.js +1 -1
- package/utils/pluralizedTypeName.js.map +1 -0
- package/utils/renderFields.d.ts +16 -0
- package/{content/plugins/utils → utils}/renderFields.js +14 -12
- package/utils/renderFields.js.map +1 -0
- package/utils/renderGetFilterFields.d.ts +10 -0
- package/utils/renderGetFilterFields.js +48 -0
- package/utils/renderGetFilterFields.js.map +1 -0
- package/utils/renderInputFields.d.ts +15 -0
- package/{content/plugins/utils → utils}/renderInputFields.js +7 -10
- package/utils/renderInputFields.js.map +1 -0
- package/utils/renderListFilterFields.d.ts +11 -0
- package/{content/plugins/utils → utils}/renderListFilterFields.js +36 -22
- package/utils/renderListFilterFields.js.map +1 -0
- package/utils/renderSortEnum.d.ts +12 -0
- package/utils/renderSortEnum.js +42 -0
- package/utils/renderSortEnum.js.map +1 -0
- package/utils/toSlug.d.ts +1 -0
- package/utils/toSlug.js +16 -0
- package/utils/toSlug.js.map +1 -0
- package/validators/dateGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateGte.js +4 -11
- package/validators/dateGte.js.map +1 -0
- package/validators/dateLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateLte.js +4 -11
- package/validators/dateLte.js.map +1 -0
- package/validators/dynamicZone.d.ts +2 -0
- package/validators/dynamicZone.js +20 -0
- package/validators/dynamicZone.js.map +1 -0
- package/validators/gte.d.ts +2 -0
- package/validators/gte.js +28 -0
- package/validators/gte.js.map +1 -0
- package/validators/in.d.ts +2 -0
- package/validators/in.js +28 -0
- package/validators/in.js.map +1 -0
- package/validators/index.d.ts +1 -0
- package/validators/index.js +22 -0
- package/validators/index.js.map +1 -0
- package/validators/lte.d.ts +2 -0
- package/validators/lte.js +28 -0
- package/validators/lte.js.map +1 -0
- package/validators/maxLength.d.ts +2 -0
- package/validators/maxLength.js +28 -0
- package/validators/maxLength.js.map +1 -0
- package/validators/minLength.d.ts +2 -0
- package/validators/minLength.js +28 -0
- package/validators/minLength.js.map +1 -0
- package/validators/pattern.d.ts +2 -0
- package/validators/pattern.js +41 -0
- package/validators/pattern.js.map +1 -0
- package/validators/patternPlugins/email.d.ts +2 -0
- package/validators/patternPlugins/email.js +18 -0
- package/validators/patternPlugins/email.js.map +1 -0
- package/validators/patternPlugins/index.d.ts +2 -0
- package/validators/patternPlugins/index.js +16 -0
- package/validators/patternPlugins/index.js.map +1 -0
- package/validators/patternPlugins/lowerCase.d.ts +2 -0
- package/validators/patternPlugins/lowerCase.js +18 -0
- package/validators/patternPlugins/lowerCase.js.map +1 -0
- package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/lowerCaseSpace.js +18 -0
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
- package/validators/patternPlugins/upperCase.d.ts +2 -0
- package/validators/patternPlugins/upperCase.js +18 -0
- package/validators/patternPlugins/upperCase.js.map +1 -0
- package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/upperCaseSpace.js +18 -0
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
- package/validators/patternPlugins/url.d.ts +2 -0
- package/validators/patternPlugins/url.js +18 -0
- package/validators/patternPlugins/url.js.map +1 -0
- package/validators/required.d.ts +2 -0
- package/validators/required.js +22 -0
- package/validators/required.js.map +1 -0
- package/validators/timeGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeGte.js +5 -11
- package/validators/timeGte.js.map +1 -0
- package/validators/timeLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeLte.js +5 -11
- package/validators/timeLte.js.map +1 -0
- package/validators/unique.d.ts +6 -0
- package/validators/unique.js +56 -0
- package/validators/unique.js.map +1 -0
- package/content/contextSetup.d.ts +0 -4
- package/content/contextSetup.js +0 -65
- package/content/graphQLHandlerFactory.d.ts +0 -5
- package/content/graphQLHandlerFactory.js +0 -173
- package/content/plugins/CmsGroupPlugin.d.ts +0 -11
- package/content/plugins/CmsModelPlugin.d.ts +0 -11
- package/content/plugins/CmsModelPlugin.js +0 -24
- package/content/plugins/buildSchemaPlugins.d.ts +0 -7
- package/content/plugins/buildSchemaPlugins.js +0 -29
- package/content/plugins/crud/contentEntry/afterDelete.d.ts +0 -7
- package/content/plugins/crud/contentEntry/beforeCreate.d.ts +0 -7
- package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +0 -7
- package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +0 -4
- package/content/plugins/crud/contentEntry.crud.js +0 -931
- package/content/plugins/crud/contentModel/afterCreate.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterCreate.js +0 -18
- package/content/plugins/crud/contentModel/afterDelete.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterDelete.js +0 -18
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterUpdate.js +0 -18
- package/content/plugins/crud/contentModel/beforeCreate.d.ts +0 -9
- package/content/plugins/crud/contentModel/beforeCreate.js +0 -146
- package/content/plugins/crud/contentModel/beforeDelete.d.ts +0 -9
- package/content/plugins/crud/contentModel/beforeUpdate.d.ts +0 -9
- package/content/plugins/crud/contentModel/beforeUpdate.js +0 -128
- package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +0 -2
- package/content/plugins/crud/contentModel/createFieldModels.d.ts +0 -2
- package/content/plugins/crud/contentModel/idValidation.d.ts +0 -2
- package/content/plugins/crud/contentModel/validateLayout.d.ts +0 -2
- package/content/plugins/crud/contentModel.crud.js +0 -425
- package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +0 -9
- package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +0 -9
- package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +0 -8
- package/content/plugins/crud/contentModelGroup.crud.js +0 -351
- package/content/plugins/crud/index.d.ts +0 -6
- package/content/plugins/crud/index.js +0 -100
- package/content/plugins/graphqlFields/boolean.d.ts +0 -3
- package/content/plugins/graphqlFields/boolean.js +0 -69
- package/content/plugins/graphqlFields/datetime.d.ts +0 -3
- package/content/plugins/graphqlFields/datetime.js +0 -83
- package/content/plugins/graphqlFields/file.d.ts +0 -3
- package/content/plugins/graphqlFields/file.js +0 -49
- package/content/plugins/graphqlFields/index.d.ts +0 -2
- package/content/plugins/graphqlFields/index.js +0 -30
- package/content/plugins/graphqlFields/longText.d.ts +0 -3
- package/content/plugins/graphqlFields/longText.js +0 -62
- package/content/plugins/graphqlFields/number.d.ts +0 -3
- package/content/plugins/graphqlFields/number.js +0 -75
- package/content/plugins/graphqlFields/object.d.ts +0 -3
- package/content/plugins/graphqlFields/object.js +0 -180
- package/content/plugins/graphqlFields/ref.d.ts +0 -3
- package/content/plugins/graphqlFields/ref.js +0 -205
- package/content/plugins/graphqlFields/richText.d.ts +0 -3
- package/content/plugins/graphqlFields/richText.js +0 -55
- package/content/plugins/graphqlFields/text.d.ts +0 -3
- package/content/plugins/graphqlFields/text.js +0 -72
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +0 -8
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +0 -54
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +0 -7
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +0 -35
- package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +0 -15
- package/content/plugins/modelManager/index.d.ts +0 -3
- package/content/plugins/schema/baseSchema.d.ts +0 -4
- package/content/plugins/schema/baseSchema.js +0 -98
- package/content/plugins/schema/contentEntries.d.ts +0 -4
- package/content/plugins/schema/contentEntries.js +0 -166
- package/content/plugins/schema/contentModelGroups.d.ts +0 -4
- package/content/plugins/schema/contentModels.d.ts +0 -4
- package/content/plugins/schema/createFieldResolvers.d.ts +0 -19
- package/content/plugins/schema/createFieldResolvers.js +0 -92
- package/content/plugins/schema/createManageResolvers.d.ts +0 -11
- package/content/plugins/schema/createManageResolvers.js +0 -135
- package/content/plugins/schema/createManageSDL.d.ts +0 -9
- package/content/plugins/schema/createManageSDL.js +0 -153
- package/content/plugins/schema/createPreviewResolvers.d.ts +0 -10
- package/content/plugins/schema/createPreviewResolvers.js +0 -55
- package/content/plugins/schema/createReadResolvers.d.ts +0 -10
- package/content/plugins/schema/createReadResolvers.js +0 -55
- package/content/plugins/schema/createReadSDL.d.ts +0 -9
- package/content/plugins/schema/createReadSDL.js +0 -96
- package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +0 -7
- package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveList.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +0 -23
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +0 -23
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +0 -7
- package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/preview/resolveGet.js +0 -38
- package/content/plugins/schema/resolvers/preview/resolveList.d.ts +0 -2
- package/content/plugins/schema/resolvers/read/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/read/resolveGet.js +0 -38
- package/content/plugins/schema/resolvers/read/resolveList.d.ts +0 -2
- package/content/plugins/schema/schemaPlugins.d.ts +0 -3
- package/content/plugins/schema/schemaPlugins.js +0 -92
- package/content/plugins/storage/StorageTransformPlugin.d.ts +0 -30
- package/content/plugins/storage/default.d.ts +0 -3
- package/content/plugins/storage/default.js +0 -28
- package/content/plugins/storage/object.d.ts +0 -3
- package/content/plugins/storage/object.js +0 -119
- package/content/plugins/utils/createTypeName.d.ts +0 -3
- package/content/plugins/utils/createTypeName.js +0 -28
- package/content/plugins/utils/getEntryTitle.d.ts +0 -2
- package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +0 -11
- package/content/plugins/utils/getSchemaFromFieldPlugins.js +0 -30
- package/content/plugins/utils/pluralizedTypeName.d.ts +0 -1
- package/content/plugins/utils/renderFields.d.ts +0 -16
- package/content/plugins/utils/renderGetFilterFields.d.ts +0 -9
- package/content/plugins/utils/renderGetFilterFields.js +0 -41
- package/content/plugins/utils/renderInputFields.d.ts +0 -14
- package/content/plugins/utils/renderListFilterFields.d.ts +0 -10
- package/content/plugins/utils/renderSortEnum.d.ts +0 -9
- package/content/plugins/utils/renderSortEnum.js +0 -32
- package/content/plugins/validators/dateGte.d.ts +0 -3
- package/content/plugins/validators/dateLte.d.ts +0 -3
- package/content/plugins/validators/gte.d.ts +0 -3
- package/content/plugins/validators/gte.js +0 -32
- package/content/plugins/validators/in.d.ts +0 -3
- package/content/plugins/validators/in.js +0 -32
- package/content/plugins/validators/index.d.ts +0 -2
- package/content/plugins/validators/index.js +0 -36
- package/content/plugins/validators/lte.d.ts +0 -3
- package/content/plugins/validators/lte.js +0 -32
- package/content/plugins/validators/maxLength.d.ts +0 -3
- package/content/plugins/validators/maxLength.js +0 -32
- package/content/plugins/validators/minLength.d.ts +0 -3
- package/content/plugins/validators/minLength.js +0 -32
- package/content/plugins/validators/pattern.d.ts +0 -3
- package/content/plugins/validators/pattern.js +0 -47
- package/content/plugins/validators/patternPlugins/email.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/email.js +0 -17
- package/content/plugins/validators/patternPlugins/index.d.ts +0 -2
- package/content/plugins/validators/patternPlugins/index.js +0 -19
- package/content/plugins/validators/patternPlugins/lowerCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/lowerCase.js +0 -17
- package/content/plugins/validators/patternPlugins/upperCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/upperCase.js +0 -17
- package/content/plugins/validators/patternPlugins/url.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/url.js +0 -17
- package/content/plugins/validators/required.d.ts +0 -3
- package/content/plugins/validators/required.js +0 -25
- package/content/plugins/validators/timeGte.d.ts +0 -3
- package/content/plugins/validators/timeLte.d.ts +0 -3
- package/migrateCMSPermissions.d.ts +0 -17
- package/migrateCMSPermissions.js +0 -193
- package/plugins/context.d.ts +0 -4
- package/plugins/context.js +0 -34
- package/plugins/crud/index.d.ts +0 -6
- package/plugins/crud/index.js +0 -100
- package/plugins/crud/settings.crud.js +0 -93
- package/plugins/crud/system.crud.js +0 -182
- package/plugins/graphql/system.d.ts +0 -17
- package/plugins/graphql.d.ts +0 -2
- package/plugins/graphql.js +0 -79
- package/plugins/upgrades/index.d.ts +0 -2
- package/plugins/upgrades/index.js +0 -14
- package/plugins/upgrades/v5.5.0/helpers.d.ts +0 -6
- package/plugins/upgrades/v5.5.0/helpers.js +0 -10
- package/plugins/upgrades/v5.5.0/index.d.ts +0 -4
- package/plugins/upgrades/v5.5.0/index.js +0 -129
- package/transformers.d.ts +0 -2
- package/transformers.js +0 -25
- package/utils.d.ts +0 -25
- package/utils.js +0 -251
package/context.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CmsContext, HeadlessCmsStorageOperations } from "./types";
|
|
2
|
+
import { ContextPlugin } from "@webiny/api";
|
|
3
|
+
export interface CrudParams {
|
|
4
|
+
storageOperations: HeadlessCmsStorageOperations;
|
|
5
|
+
}
|
|
6
|
+
export declare const createContextPlugin: ({ storageOperations }: CrudParams) => ContextPlugin<CmsContext>;
|
package/context.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createContextPlugin = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
+
var _api = require("@webiny/api");
|
|
11
|
+
var _CmsParametersPlugin = require("./plugins/CmsParametersPlugin");
|
|
12
|
+
var _system = require("./crud/system.crud");
|
|
13
|
+
var _settings = require("./crud/settings.crud");
|
|
14
|
+
var _contentModelGroup = require("./crud/contentModelGroup.crud");
|
|
15
|
+
var _contentModel = require("./crud/contentModel.crud");
|
|
16
|
+
var _contentEntry = require("./crud/contentEntry.crud");
|
|
17
|
+
var _plugins = require("./plugins");
|
|
18
|
+
var _valueKeyStorageConverter = require("./utils/converters/valueKeyStorageConverter");
|
|
19
|
+
const getParameters = async context => {
|
|
20
|
+
const plugins = context.plugins.byType(_CmsParametersPlugin.CmsParametersPlugin.type);
|
|
21
|
+
for (const plugin of plugins) {
|
|
22
|
+
const result = await plugin.getParameters(context);
|
|
23
|
+
if (result !== null) {
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
throw new _error.default("Could not determine locale and/or type of the CMS.", "CMS_LOCALE_AND_TYPE_ERROR");
|
|
28
|
+
};
|
|
29
|
+
const createContextPlugin = ({
|
|
30
|
+
storageOperations
|
|
31
|
+
}) => {
|
|
32
|
+
return new _api.ContextPlugin(async context => {
|
|
33
|
+
const {
|
|
34
|
+
type,
|
|
35
|
+
locale
|
|
36
|
+
} = await getParameters(context);
|
|
37
|
+
const getLocale = () => {
|
|
38
|
+
const systemLocale = context.i18n.getLocale(locale);
|
|
39
|
+
if (!systemLocale) {
|
|
40
|
+
throw new _error.default(`There is no locale "${locale}" in the system.`);
|
|
41
|
+
}
|
|
42
|
+
return systemLocale;
|
|
43
|
+
};
|
|
44
|
+
const getIdentity = () => {
|
|
45
|
+
return context.security.getIdentity();
|
|
46
|
+
};
|
|
47
|
+
const getTenant = () => {
|
|
48
|
+
return context.tenancy.getCurrentTenant();
|
|
49
|
+
};
|
|
50
|
+
context.plugins.register(new _plugins.StorageOperationsCmsModelPlugin((0, _valueKeyStorageConverter.createCmsModelFieldConvertersAttachFactory)(context.plugins)));
|
|
51
|
+
await context.benchmark.measure("headlessCms.createContext", async () => {
|
|
52
|
+
await storageOperations.beforeInit(context);
|
|
53
|
+
context.cms = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
54
|
+
type,
|
|
55
|
+
locale,
|
|
56
|
+
getLocale,
|
|
57
|
+
READ: type === "read",
|
|
58
|
+
PREVIEW: type === "preview",
|
|
59
|
+
MANAGE: type === "manage",
|
|
60
|
+
storageOperations
|
|
61
|
+
}, (0, _system.createSystemCrud)({
|
|
62
|
+
context,
|
|
63
|
+
getTenant,
|
|
64
|
+
getLocale,
|
|
65
|
+
getIdentity,
|
|
66
|
+
storageOperations
|
|
67
|
+
})), (0, _settings.createSettingsCrud)({
|
|
68
|
+
context,
|
|
69
|
+
getTenant,
|
|
70
|
+
getLocale,
|
|
71
|
+
storageOperations
|
|
72
|
+
})), (0, _contentModelGroup.createModelGroupsCrud)({
|
|
73
|
+
context,
|
|
74
|
+
getTenant,
|
|
75
|
+
getLocale,
|
|
76
|
+
getIdentity,
|
|
77
|
+
storageOperations
|
|
78
|
+
})), (0, _contentModel.createModelsCrud)({
|
|
79
|
+
context,
|
|
80
|
+
getLocale,
|
|
81
|
+
getTenant,
|
|
82
|
+
getIdentity,
|
|
83
|
+
storageOperations
|
|
84
|
+
})), (0, _contentEntry.createContentEntryCrud)({
|
|
85
|
+
context,
|
|
86
|
+
getIdentity,
|
|
87
|
+
getTenant,
|
|
88
|
+
getLocale,
|
|
89
|
+
storageOperations
|
|
90
|
+
}));
|
|
91
|
+
if (!storageOperations.init) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
await storageOperations.init(context);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
exports.createContextPlugin = createContextPlugin;
|
package/context.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getParameters","context","plugins","byType","CmsParametersPlugin","type","plugin","result","WebinyError","createContextPlugin","storageOperations","ContextPlugin","locale","getLocale","systemLocale","i18n","getIdentity","security","getTenant","tenancy","getCurrentTenant","register","StorageOperationsCmsModelPlugin","createCmsModelFieldConvertersAttachFactory","benchmark","measure","beforeInit","cms","READ","PREVIEW","MANAGE","createSystemCrud","createSettingsCrud","createModelGroupsCrud","createModelsCrud","createContentEntryCrud","init"],"sources":["context.ts"],"sourcesContent":["import { CmsContext, HeadlessCmsStorageOperations } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { CmsParametersPlugin, CmsParametersPluginResponse } from \"~/plugins/CmsParametersPlugin\";\nimport { createSystemCrud } from \"~/crud/system.crud\";\nimport { createSettingsCrud } from \"~/crud/settings.crud\";\nimport { createModelGroupsCrud } from \"~/crud/contentModelGroup.crud\";\nimport { createModelsCrud } from \"~/crud/contentModel.crud\";\nimport { createContentEntryCrud } from \"~/crud/contentEntry.crud\";\nimport { StorageOperationsCmsModelPlugin } from \"~/plugins\";\nimport { createCmsModelFieldConvertersAttachFactory } from \"~/utils/converters/valueKeyStorageConverter\";\n\nconst getParameters = async (context: CmsContext): Promise<CmsParametersPluginResponse> => {\n const plugins = context.plugins.byType<CmsParametersPlugin>(CmsParametersPlugin.type);\n\n for (const plugin of plugins) {\n const result = await plugin.getParameters(context);\n if (result !== null) {\n return result;\n }\n }\n throw new WebinyError(\n \"Could not determine locale and/or type of the CMS.\",\n \"CMS_LOCALE_AND_TYPE_ERROR\"\n );\n};\n\nexport interface CrudParams {\n storageOperations: HeadlessCmsStorageOperations;\n}\n\nexport const createContextPlugin = ({ storageOperations }: CrudParams) => {\n return new ContextPlugin<CmsContext>(async context => {\n const { type, locale } = await getParameters(context);\n\n const getLocale = () => {\n const systemLocale = context.i18n.getLocale(locale);\n if (!systemLocale) {\n throw new WebinyError(`There is no locale \"${locale}\" in the system.`);\n }\n return systemLocale;\n };\n\n const getIdentity = () => {\n return context.security.getIdentity();\n };\n\n const getTenant = () => {\n return context.tenancy.getCurrentTenant();\n };\n\n context.plugins.register(\n new StorageOperationsCmsModelPlugin(\n createCmsModelFieldConvertersAttachFactory(context.plugins)\n )\n );\n\n await context.benchmark.measure(\"headlessCms.createContext\", async () => {\n await storageOperations.beforeInit(context);\n\n context.cms = {\n type,\n locale,\n getLocale,\n READ: type === \"read\",\n PREVIEW: type === \"preview\",\n MANAGE: type === \"manage\",\n storageOperations,\n ...createSystemCrud({\n context,\n getTenant,\n getLocale,\n getIdentity,\n storageOperations\n }),\n ...createSettingsCrud({\n context,\n getTenant,\n getLocale,\n storageOperations\n }),\n ...createModelGroupsCrud({\n context,\n getTenant,\n getLocale,\n getIdentity,\n storageOperations\n }),\n ...createModelsCrud({\n context,\n getLocale,\n getTenant,\n getIdentity,\n storageOperations\n }),\n ...createContentEntryCrud({\n context,\n getIdentity,\n getTenant,\n getLocale,\n storageOperations\n })\n };\n\n if (!storageOperations.init) {\n return;\n }\n await storageOperations.init(context);\n });\n });\n};\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAMA,aAAa,GAAG,MAAOC,OAAmB,IAA2C;EACvF,MAAMC,OAAO,GAAGD,OAAO,CAACC,OAAO,CAACC,MAAM,CAAsBC,wCAAmB,CAACC,IAAI,CAAC;EAErF,KAAK,MAAMC,MAAM,IAAIJ,OAAO,EAAE;IAC1B,MAAMK,MAAM,GAAG,MAAMD,MAAM,CAACN,aAAa,CAACC,OAAO,CAAC;IAClD,IAAIM,MAAM,KAAK,IAAI,EAAE;MACjB,OAAOA,MAAM;IACjB;EACJ;EACA,MAAM,IAAIC,cAAW,CACjB,oDAAoD,EACpD,2BAA2B,CAC9B;AACL,CAAC;AAMM,MAAMC,mBAAmB,GAAG,CAAC;EAAEC;AAA8B,CAAC,KAAK;EACtE,OAAO,IAAIC,kBAAa,CAAa,MAAMV,OAAO,IAAI;IAClD,MAAM;MAAEI,IAAI;MAAEO;IAAO,CAAC,GAAG,MAAMZ,aAAa,CAACC,OAAO,CAAC;IAErD,MAAMY,SAAS,GAAG,MAAM;MACpB,MAAMC,YAAY,GAAGb,OAAO,CAACc,IAAI,CAACF,SAAS,CAACD,MAAM,CAAC;MACnD,IAAI,CAACE,YAAY,EAAE;QACf,MAAM,IAAIN,cAAW,CAAE,uBAAsBI,MAAO,kBAAiB,CAAC;MAC1E;MACA,OAAOE,YAAY;IACvB,CAAC;IAED,MAAME,WAAW,GAAG,MAAM;MACtB,OAAOf,OAAO,CAACgB,QAAQ,CAACD,WAAW,EAAE;IACzC,CAAC;IAED,MAAME,SAAS,GAAG,MAAM;MACpB,OAAOjB,OAAO,CAACkB,OAAO,CAACC,gBAAgB,EAAE;IAC7C,CAAC;IAEDnB,OAAO,CAACC,OAAO,CAACmB,QAAQ,CACpB,IAAIC,wCAA+B,CAC/B,IAAAC,oEAA0C,EAACtB,OAAO,CAACC,OAAO,CAAC,CAC9D,CACJ;IAED,MAAMD,OAAO,CAACuB,SAAS,CAACC,OAAO,CAAC,2BAA2B,EAAE,YAAY;MACrE,MAAMf,iBAAiB,CAACgB,UAAU,CAACzB,OAAO,CAAC;MAE3CA,OAAO,CAAC0B,GAAG;QACPtB,IAAI;QACJO,MAAM;QACNC,SAAS;QACTe,IAAI,EAAEvB,IAAI,KAAK,MAAM;QACrBwB,OAAO,EAAExB,IAAI,KAAK,SAAS;QAC3ByB,MAAM,EAAEzB,IAAI,KAAK,QAAQ;QACzBK;MAAiB,GACd,IAAAqB,wBAAgB,EAAC;QAChB9B,OAAO;QACPiB,SAAS;QACTL,SAAS;QACTG,WAAW;QACXN;MACJ,CAAC,CAAC,GACC,IAAAsB,4BAAkB,EAAC;QAClB/B,OAAO;QACPiB,SAAS;QACTL,SAAS;QACTH;MACJ,CAAC,CAAC,GACC,IAAAuB,wCAAqB,EAAC;QACrBhC,OAAO;QACPiB,SAAS;QACTL,SAAS;QACTG,WAAW;QACXN;MACJ,CAAC,CAAC,GACC,IAAAwB,8BAAgB,EAAC;QAChBjC,OAAO;QACPY,SAAS;QACTK,SAAS;QACTF,WAAW;QACXN;MACJ,CAAC,CAAC,GACC,IAAAyB,oCAAsB,EAAC;QACtBlC,OAAO;QACPe,WAAW;QACXE,SAAS;QACTL,SAAS;QACTH;MACJ,CAAC,CAAC,CACL;MAED,IAAI,CAACA,iBAAiB,CAAC0B,IAAI,EAAE;QACzB;MACJ;MACA,MAAM1B,iBAAiB,CAAC0B,IAAI,CAACnC,OAAO,CAAC;IACzC,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Topic } from "@webiny/pubsub/types";
|
|
2
|
+
import { OnEntryAfterDeleteTopicParams, CmsContext } from "../../types";
|
|
3
|
+
interface AssignAfterEntryDeleteParams {
|
|
4
|
+
context: CmsContext;
|
|
5
|
+
onEntryAfterDelete: Topic<OnEntryAfterDeleteTopicParams>;
|
|
6
|
+
}
|
|
7
|
+
export declare const assignAfterEntryDelete: (params: AssignAfterEntryDeleteParams) => void;
|
|
8
|
+
export {};
|
|
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.assignAfterEntryDelete = void 0;
|
|
7
|
-
|
|
8
7
|
var _markLockedFields = require("./markLockedFields");
|
|
9
|
-
|
|
10
8
|
const assignAfterEntryDelete = params => {
|
|
11
9
|
const {
|
|
12
10
|
context,
|
|
13
|
-
|
|
11
|
+
onEntryAfterDelete
|
|
14
12
|
} = params;
|
|
15
|
-
|
|
13
|
+
onEntryAfterDelete.subscribe(async params => {
|
|
16
14
|
const {
|
|
17
15
|
entry,
|
|
18
16
|
model
|
|
@@ -26,16 +24,13 @@ const assignAfterEntryDelete = params => {
|
|
|
26
24
|
},
|
|
27
25
|
limit: 1
|
|
28
26
|
});
|
|
29
|
-
|
|
30
27
|
if (items.length > 0) {
|
|
31
28
|
return;
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
await (0, _markLockedFields.markUnlockedFields)({
|
|
35
31
|
context,
|
|
36
32
|
model
|
|
37
33
|
});
|
|
38
34
|
});
|
|
39
35
|
};
|
|
40
|
-
|
|
41
36
|
exports.assignAfterEntryDelete = assignAfterEntryDelete;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["assignAfterEntryDelete","params","context","onEntryAfterDelete","subscribe","entry","model","items","cms","storageOperations","entries","list","where","entryId_not","entryId","latest","limit","length","markUnlockedFields"],"sources":["afterDelete.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { OnEntryAfterDeleteTopicParams, CmsContext } from \"~/types\";\nimport { markUnlockedFields } from \"./markLockedFields\";\n\ninterface AssignAfterEntryDeleteParams {\n context: CmsContext;\n onEntryAfterDelete: Topic<OnEntryAfterDeleteTopicParams>;\n}\nexport const assignAfterEntryDelete = (params: AssignAfterEntryDeleteParams) => {\n const { context, onEntryAfterDelete } = params;\n\n onEntryAfterDelete.subscribe(async params => {\n const { entry, model } = params;\n\n const { items } = await context.cms.storageOperations.entries.list(model, {\n where: {\n entryId_not: entry.entryId,\n latest: true\n },\n limit: 1\n });\n if (items.length > 0) {\n return;\n }\n await markUnlockedFields({\n context,\n model\n });\n });\n};\n"],"mappings":";;;;;;AAEA;AAMO,MAAMA,sBAAsB,GAAIC,MAAoC,IAAK;EAC5E,MAAM;IAAEC,OAAO;IAAEC;EAAmB,CAAC,GAAGF,MAAM;EAE9CE,kBAAkB,CAACC,SAAS,CAAC,MAAMH,MAAM,IAAI;IACzC,MAAM;MAAEI,KAAK;MAAEC;IAAM,CAAC,GAAGL,MAAM;IAE/B,MAAM;MAAEM;IAAM,CAAC,GAAG,MAAML,OAAO,CAACM,GAAG,CAACC,iBAAiB,CAACC,OAAO,CAACC,IAAI,CAACL,KAAK,EAAE;MACtEM,KAAK,EAAE;QACHC,WAAW,EAAER,KAAK,CAACS,OAAO;QAC1BC,MAAM,EAAE;MACZ,CAAC;MACDC,KAAK,EAAE;IACX,CAAC,CAAC;IACF,IAAIT,KAAK,CAACU,MAAM,GAAG,CAAC,EAAE;MAClB;IACJ;IACA,MAAM,IAAAC,oCAAkB,EAAC;MACrBhB,OAAO;MACPI;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Topic } from "@webiny/pubsub/types";
|
|
2
|
+
import { OnEntryBeforeCreateTopicParams, CmsContext } from "../../types";
|
|
3
|
+
interface AssignBeforeEntryCreateParams {
|
|
4
|
+
context: CmsContext;
|
|
5
|
+
onEntryBeforeCreate: Topic<OnEntryBeforeCreateTopicParams>;
|
|
6
|
+
}
|
|
7
|
+
export declare const assignBeforeEntryCreate: (params: AssignBeforeEntryCreateParams) => void;
|
|
8
|
+
export {};
|
|
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.assignBeforeEntryCreate = void 0;
|
|
7
|
-
|
|
8
7
|
var _markLockedFields = require("./markLockedFields");
|
|
9
|
-
|
|
10
8
|
const assignBeforeEntryCreate = params => {
|
|
11
9
|
const {
|
|
12
10
|
context,
|
|
13
|
-
|
|
11
|
+
onEntryBeforeCreate
|
|
14
12
|
} = params;
|
|
15
|
-
|
|
13
|
+
onEntryBeforeCreate.subscribe(async params => {
|
|
16
14
|
const {
|
|
17
15
|
entry,
|
|
18
16
|
model
|
|
@@ -24,5 +22,4 @@ const assignBeforeEntryCreate = params => {
|
|
|
24
22
|
});
|
|
25
23
|
});
|
|
26
24
|
};
|
|
27
|
-
|
|
28
25
|
exports.assignBeforeEntryCreate = assignBeforeEntryCreate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["assignBeforeEntryCreate","params","context","onEntryBeforeCreate","subscribe","entry","model","markLockedFields"],"sources":["beforeCreate.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { OnEntryBeforeCreateTopicParams, CmsContext } from \"~/types\";\nimport { markLockedFields } from \"./markLockedFields\";\n\ninterface AssignBeforeEntryCreateParams {\n context: CmsContext;\n onEntryBeforeCreate: Topic<OnEntryBeforeCreateTopicParams>;\n}\nexport const assignBeforeEntryCreate = (params: AssignBeforeEntryCreateParams) => {\n const { context, onEntryBeforeCreate } = params;\n\n onEntryBeforeCreate.subscribe(async params => {\n const { entry, model } = params;\n\n await markLockedFields({\n model,\n entry,\n context\n });\n });\n};\n"],"mappings":";;;;;;AAEA;AAMO,MAAMA,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,OAAO;IAAEC;EAAoB,CAAC,GAAGF,MAAM;EAE/CE,mBAAmB,CAACC,SAAS,CAAC,MAAMH,MAAM,IAAI;IAC1C,MAAM;MAAEI,KAAK;MAAEC;IAAM,CAAC,GAAGL,MAAM;IAE/B,MAAM,IAAAM,kCAAgB,EAAC;MACnBD,KAAK;MACLD,KAAK;MACLH;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Topic } from "@webiny/pubsub/types";
|
|
2
|
+
import { OnEntryBeforeUpdateTopicParams, CmsContext } from "../../types";
|
|
3
|
+
interface AssignBeforeEntryUpdateParams {
|
|
4
|
+
context: CmsContext;
|
|
5
|
+
onEntryBeforeUpdate: Topic<OnEntryBeforeUpdateTopicParams>;
|
|
6
|
+
}
|
|
7
|
+
export declare const assignBeforeEntryUpdate: (params: AssignBeforeEntryUpdateParams) => void;
|
|
8
|
+
export {};
|
|
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.assignBeforeEntryUpdate = void 0;
|
|
7
|
-
|
|
8
7
|
var _markLockedFields = require("./markLockedFields");
|
|
9
|
-
|
|
10
8
|
const assignBeforeEntryUpdate = params => {
|
|
11
9
|
const {
|
|
12
10
|
context,
|
|
13
|
-
|
|
11
|
+
onEntryBeforeUpdate
|
|
14
12
|
} = params;
|
|
15
|
-
|
|
13
|
+
onEntryBeforeUpdate.subscribe(async params => {
|
|
16
14
|
const {
|
|
17
15
|
entry,
|
|
18
16
|
model
|
|
@@ -24,5 +22,4 @@ const assignBeforeEntryUpdate = params => {
|
|
|
24
22
|
});
|
|
25
23
|
});
|
|
26
24
|
};
|
|
27
|
-
|
|
28
25
|
exports.assignBeforeEntryUpdate = assignBeforeEntryUpdate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["assignBeforeEntryUpdate","params","context","onEntryBeforeUpdate","subscribe","entry","model","markLockedFields"],"sources":["beforeUpdate.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { OnEntryBeforeUpdateTopicParams, CmsContext } from \"~/types\";\nimport { markLockedFields } from \"./markLockedFields\";\n\ninterface AssignBeforeEntryUpdateParams {\n context: CmsContext;\n onEntryBeforeUpdate: Topic<OnEntryBeforeUpdateTopicParams>;\n}\nexport const assignBeforeEntryUpdate = (params: AssignBeforeEntryUpdateParams) => {\n const { context, onEntryBeforeUpdate } = params;\n\n onEntryBeforeUpdate.subscribe(async params => {\n const { entry, model } = params;\n\n await markLockedFields({\n model,\n entry,\n context\n });\n });\n};\n"],"mappings":";;;;;;AAEA;AAMO,MAAMA,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,OAAO;IAAEC;EAAoB,CAAC,GAAGF,MAAM;EAE/CE,mBAAmB,CAACC,SAAS,CAAC,MAAMH,MAAM,IAAI;IAC1C,MAAM;MAAEI,KAAK;MAAEC;IAAM,CAAC,GAAGL,MAAM;IAE/B,MAAM,IAAAM,kCAAgB,EAAC;MACnBD,KAAK;MACLD,KAAK;MACLH;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CmsModel, CmsContext, CmsEntry } from "../../types";
|
|
2
|
+
declare type InputData = Record<string, any>;
|
|
3
|
+
export interface ValidateModelEntryDataParams {
|
|
4
|
+
context: CmsContext;
|
|
5
|
+
model: CmsModel;
|
|
6
|
+
data: InputData;
|
|
7
|
+
entry?: CmsEntry;
|
|
8
|
+
}
|
|
9
|
+
export declare const validateModelEntryData: (params: ValidateModelEntryDataParams) => Promise<void>;
|
|
10
|
+
export {};
|
|
@@ -1,44 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.validateModelEntryData = void 0;
|
|
9
|
-
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
10
|
const validateValue = async (args, fieldValidators, value) => {
|
|
13
11
|
if (!fieldValidators) {
|
|
14
12
|
return null;
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
const {
|
|
18
15
|
validatorList,
|
|
19
16
|
context,
|
|
20
17
|
field,
|
|
21
|
-
|
|
18
|
+
model,
|
|
19
|
+
entry
|
|
22
20
|
} = args;
|
|
23
|
-
|
|
24
21
|
try {
|
|
25
22
|
for (const fieldValidator of fieldValidators) {
|
|
26
23
|
const name = fieldValidator.name;
|
|
27
24
|
const validations = validatorList[name];
|
|
28
|
-
|
|
29
25
|
if (!validations || validations.length === 0) {
|
|
30
26
|
return `There are no "${name}" validators defined.`;
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
for (const validate of validations) {
|
|
34
29
|
const result = await validate({
|
|
35
30
|
value,
|
|
36
31
|
context,
|
|
37
32
|
validator: fieldValidator,
|
|
38
33
|
field,
|
|
39
|
-
|
|
34
|
+
model,
|
|
35
|
+
entry
|
|
40
36
|
});
|
|
41
|
-
|
|
42
37
|
if (!result) {
|
|
43
38
|
return fieldValidator.message;
|
|
44
39
|
}
|
|
@@ -47,142 +42,120 @@ const validateValue = async (args, fieldValidators, value) => {
|
|
|
47
42
|
} catch (ex) {
|
|
48
43
|
return ex.message;
|
|
49
44
|
}
|
|
50
|
-
|
|
51
45
|
return null;
|
|
52
46
|
};
|
|
53
|
-
|
|
54
47
|
const validatePredefinedValue = (field, value) => {
|
|
55
48
|
const {
|
|
56
49
|
enabled = false,
|
|
57
50
|
values: predefinedValues = []
|
|
58
51
|
} = field.predefinedValues || {};
|
|
59
|
-
|
|
60
52
|
if (!enabled) {
|
|
61
53
|
return null;
|
|
62
54
|
} else if (Array.isArray(predefinedValues) === false || predefinedValues.length === 0) {
|
|
63
55
|
return "Missing predefined values to validate against.";
|
|
64
56
|
}
|
|
65
|
-
|
|
66
57
|
for (const predefinedValue of predefinedValues) {
|
|
67
|
-
// console.log(field.fieldId, predefinedValue.value, value, predefinedValue.value == value);
|
|
68
58
|
if (predefinedValue.value == value) {
|
|
69
59
|
return null;
|
|
70
60
|
}
|
|
71
61
|
}
|
|
72
|
-
|
|
73
62
|
return "Value sent does not match any of the available predefined values.";
|
|
74
63
|
};
|
|
75
64
|
/**
|
|
76
65
|
* When multiple values is selected we must run validations on the array containing the values
|
|
77
66
|
* And then on each value in the array
|
|
78
67
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
68
|
const runFieldMultipleValuesValidations = async args => {
|
|
82
69
|
const {
|
|
83
70
|
field,
|
|
84
71
|
data
|
|
85
72
|
} = args;
|
|
86
|
-
const values = data[field.fieldId];
|
|
87
|
-
|
|
73
|
+
const values = data[field.fieldId] || [];
|
|
88
74
|
if (Array.isArray(values) === false) {
|
|
89
75
|
return `Value of the field "${field.fieldId}" is not an array.`;
|
|
90
76
|
}
|
|
91
|
-
|
|
92
77
|
const valuesError = await validateValue(args, field.listValidation || [], values);
|
|
93
|
-
|
|
94
78
|
if (valuesError) {
|
|
95
79
|
return valuesError;
|
|
96
80
|
}
|
|
97
|
-
|
|
98
81
|
for (const value of values) {
|
|
99
82
|
const valueError = await validateValue(args, field.validation || [], value);
|
|
100
|
-
|
|
101
83
|
if (valueError) {
|
|
102
84
|
return valueError;
|
|
103
85
|
}
|
|
104
|
-
|
|
105
86
|
const predefinedValueError = validatePredefinedValue(field, value);
|
|
106
|
-
|
|
107
87
|
if (predefinedValueError) {
|
|
108
88
|
return predefinedValueError;
|
|
109
89
|
}
|
|
110
90
|
}
|
|
111
|
-
|
|
112
91
|
return null;
|
|
113
92
|
};
|
|
114
93
|
/**
|
|
115
94
|
* Runs validation on given value.
|
|
116
95
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
96
|
const runFieldValueValidations = async args => {
|
|
120
97
|
const {
|
|
121
98
|
data,
|
|
122
99
|
field
|
|
123
100
|
} = args;
|
|
124
101
|
const value = data[field.fieldId];
|
|
125
|
-
const error = await validateValue(args, field.validation, value);
|
|
126
|
-
|
|
102
|
+
const error = await validateValue(args, field.validation || [], value);
|
|
127
103
|
if (error) {
|
|
128
104
|
return error;
|
|
129
105
|
}
|
|
130
|
-
|
|
131
106
|
return validatePredefinedValue(field, value);
|
|
132
107
|
};
|
|
133
|
-
|
|
134
108
|
const execValidation = async args => {
|
|
135
109
|
if (args.field.multipleValues) {
|
|
136
110
|
return await runFieldMultipleValuesValidations(args);
|
|
137
111
|
}
|
|
138
|
-
|
|
139
112
|
return await runFieldValueValidations(args);
|
|
140
113
|
};
|
|
141
|
-
|
|
142
|
-
const
|
|
114
|
+
const validateModelEntryData = async params => {
|
|
115
|
+
const {
|
|
116
|
+
context,
|
|
117
|
+
model,
|
|
118
|
+
entry,
|
|
119
|
+
data
|
|
120
|
+
} = params;
|
|
143
121
|
/**
|
|
144
122
|
* To later simplify searching for the validations we map them to a name.
|
|
145
123
|
* @see CmsModelFieldValidatorPlugin.validator.validate
|
|
146
124
|
*/
|
|
147
125
|
const validatorList = context.plugins.byType("cms-model-field-validator").reduce((acc, plugin) => {
|
|
148
126
|
const name = plugin.validator.name;
|
|
149
|
-
|
|
150
127
|
if (!acc[name]) {
|
|
151
128
|
acc[name] = [];
|
|
152
129
|
}
|
|
153
|
-
|
|
154
130
|
acc[name].push(plugin.validator.validate);
|
|
155
131
|
return acc;
|
|
156
132
|
}, {});
|
|
133
|
+
|
|
157
134
|
/**
|
|
158
135
|
* Loop through model fields and validate the corresponding data.
|
|
159
136
|
* Run validation only if the field has validation configured.
|
|
160
137
|
*/
|
|
161
|
-
|
|
162
138
|
const invalidFields = [];
|
|
163
|
-
|
|
164
|
-
for (const field of contentModel.fields) {
|
|
139
|
+
for (const field of model.fields) {
|
|
165
140
|
const error = await execValidation({
|
|
166
|
-
|
|
141
|
+
model,
|
|
167
142
|
validatorList,
|
|
168
143
|
field,
|
|
169
|
-
data,
|
|
170
|
-
context
|
|
144
|
+
data: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (entry === null || entry === void 0 ? void 0 : entry.values) || {}), data),
|
|
145
|
+
context,
|
|
146
|
+
entry
|
|
171
147
|
});
|
|
172
|
-
|
|
173
148
|
if (!error) {
|
|
174
149
|
continue;
|
|
175
150
|
}
|
|
176
|
-
|
|
177
151
|
invalidFields.push({
|
|
178
152
|
fieldId: field.fieldId,
|
|
153
|
+
storageId: field.storageId,
|
|
179
154
|
error
|
|
180
155
|
});
|
|
181
156
|
}
|
|
182
|
-
|
|
183
157
|
if (invalidFields.length > 0) {
|
|
184
158
|
throw new _error.default("Validation failed.", "VALIDATION_FAILED", invalidFields);
|
|
185
159
|
}
|
|
186
160
|
};
|
|
187
|
-
|
|
188
161
|
exports.validateModelEntryData = validateModelEntryData;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["validateValue","args","fieldValidators","value","validatorList","context","field","model","entry","fieldValidator","name","validations","length","validate","result","validator","message","ex","validatePredefinedValue","enabled","values","predefinedValues","Array","isArray","predefinedValue","runFieldMultipleValuesValidations","data","fieldId","valuesError","listValidation","valueError","validation","predefinedValueError","runFieldValueValidations","error","execValidation","multipleValues","validateModelEntryData","params","plugins","byType","reduce","acc","plugin","push","invalidFields","fields","storageId","WebinyError"],"sources":["entryDataValidation.ts"],"sourcesContent":["import {\n CmsModel,\n CmsModelField,\n CmsModelFieldValidation,\n CmsContext,\n CmsModelFieldValidatorPlugin,\n CmsModelFieldValidatorValidateParams,\n CmsEntry\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\n\ntype PluginValidationCallable = (params: CmsModelFieldValidatorValidateParams) => Promise<boolean>;\ntype PluginValidationList = Record<string, PluginValidationCallable[]>;\ntype InputData = Record<string, any>;\n\ninterface ValidateArgs {\n validatorList: PluginValidationList;\n field: CmsModelField;\n model: CmsModel;\n data: InputData;\n context: CmsContext;\n entry?: CmsEntry;\n}\n\ntype PossibleValue = boolean | number | string | null | undefined;\n\nconst validateValue = async (\n args: ValidateArgs,\n fieldValidators: CmsModelFieldValidation[],\n value: PossibleValue | PossibleValue[]\n): Promise<string | null> => {\n if (!fieldValidators) {\n return null;\n }\n\n const { validatorList, context, field, model, entry } = args;\n try {\n for (const fieldValidator of fieldValidators) {\n const name = fieldValidator.name;\n const validations = validatorList[name];\n if (!validations || validations.length === 0) {\n return `There are no \"${name}\" validators defined.`;\n }\n for (const validate of validations) {\n const result = await validate({\n value,\n context,\n validator: fieldValidator,\n field,\n model,\n entry\n });\n if (!result) {\n return fieldValidator.message;\n }\n }\n }\n } catch (ex) {\n return ex.message;\n }\n\n return null;\n};\n\nconst validatePredefinedValue = (field: CmsModelField, value: any | any[]): string | null => {\n const { enabled = false, values: predefinedValues = [] } = field.predefinedValues || {};\n if (!enabled) {\n return null;\n } else if (Array.isArray(predefinedValues) === false || predefinedValues.length === 0) {\n return \"Missing predefined values to validate against.\";\n }\n for (const predefinedValue of predefinedValues) {\n if (predefinedValue.value == value) {\n return null;\n }\n }\n return \"Value sent does not match any of the available predefined values.\";\n};\n/**\n * When multiple values is selected we must run validations on the array containing the values\n * And then on each value in the array\n */\nconst runFieldMultipleValuesValidations = async (args: ValidateArgs): Promise<string | null> => {\n const { field, data } = args;\n const values = data[field.fieldId] || [];\n if (Array.isArray(values) === false) {\n return `Value of the field \"${field.fieldId}\" is not an array.`;\n }\n const valuesError = await validateValue(args, field.listValidation || [], values);\n if (valuesError) {\n return valuesError;\n }\n for (const value of values) {\n const valueError = await validateValue(args, field.validation || [], value);\n if (valueError) {\n return valueError;\n }\n const predefinedValueError = validatePredefinedValue(field, value);\n if (predefinedValueError) {\n return predefinedValueError;\n }\n }\n return null;\n};\n/**\n * Runs validation on given value.\n */\nconst runFieldValueValidations = async (args: ValidateArgs): Promise<string | null> => {\n const { data, field } = args;\n const value = data[field.fieldId];\n const error = await validateValue(args, field.validation || [], value);\n if (error) {\n return error;\n }\n return validatePredefinedValue(field, value);\n};\n\nconst execValidation = async (args: ValidateArgs): Promise<string | null> => {\n if (args.field.multipleValues) {\n return await runFieldMultipleValuesValidations(args);\n }\n return await runFieldValueValidations(args);\n};\n\nexport interface ValidateModelEntryDataParams {\n context: CmsContext;\n model: CmsModel;\n data: InputData;\n entry?: CmsEntry;\n}\nexport const validateModelEntryData = async (params: ValidateModelEntryDataParams) => {\n const { context, model, entry, data } = params;\n /**\n * To later simplify searching for the validations we map them to a name.\n * @see CmsModelFieldValidatorPlugin.validator.validate\n */\n const validatorList: PluginValidationList = context.plugins\n .byType<CmsModelFieldValidatorPlugin>(\"cms-model-field-validator\")\n .reduce((acc, plugin) => {\n const name = plugin.validator.name;\n if (!acc[name]) {\n acc[name] = [];\n }\n acc[name].push(plugin.validator.validate);\n\n return acc;\n }, {} as PluginValidationList);\n\n /**\n * Loop through model fields and validate the corresponding data.\n * Run validation only if the field has validation configured.\n */\n const invalidFields = [];\n for (const field of model.fields) {\n const error = await execValidation({\n model,\n validatorList,\n field,\n data: {\n ...(entry?.values || {}),\n ...data\n },\n context,\n entry\n });\n if (!error) {\n continue;\n }\n invalidFields.push({\n fieldId: field.fieldId,\n storageId: field.storageId,\n error\n });\n }\n\n if (invalidFields.length > 0) {\n throw new WebinyError(\"Validation failed.\", \"VALIDATION_FAILED\", invalidFields);\n }\n};\n"],"mappings":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CmsEntry,
|
|
2
|
-
|
|
1
|
+
import { CmsEntry, CmsContext, CmsModel } from "../../types";
|
|
2
|
+
interface MarkLockedFieldsParams {
|
|
3
3
|
model: CmsModel;
|
|
4
4
|
entry: CmsEntry;
|
|
5
5
|
context: CmsContext;
|
|
@@ -10,3 +10,4 @@ export interface MarkFieldsUnlockedParams {
|
|
|
10
10
|
model: CmsModel;
|
|
11
11
|
}
|
|
12
12
|
export declare const markUnlockedFields: (params: MarkFieldsUnlockedParams) => Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.markUnlockedFields = exports.markLockedFields = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
12
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
-
|
|
10
|
+
var _CmsModelPlugin = require("../../plugins/CmsModelPlugin");
|
|
11
|
+
var _getBaseFieldType = require("../../utils/getBaseFieldType");
|
|
20
12
|
const markLockedFields = async params => {
|
|
21
13
|
const {
|
|
22
14
|
model,
|
|
@@ -25,67 +17,61 @@ const markLockedFields = async params => {
|
|
|
25
17
|
/**
|
|
26
18
|
* If the model is registered via a plugin, we don't need do process anything.
|
|
27
19
|
*/
|
|
28
|
-
|
|
29
20
|
const plugins = context.plugins.byType(_CmsModelPlugin.CmsModelPlugin.type);
|
|
30
|
-
|
|
31
21
|
if (plugins.find(plugin => plugin.contentModel.modelId === model.modelId)) {
|
|
32
22
|
return;
|
|
33
23
|
}
|
|
34
|
-
|
|
35
24
|
const cmsLockedFieldPlugins = context.plugins.byType("cms-model-locked-field");
|
|
36
25
|
const existingLockedFields = model.lockedFields || [];
|
|
37
26
|
const lockedFields = [];
|
|
38
|
-
|
|
39
27
|
for (const field of model.fields) {
|
|
40
|
-
const
|
|
41
|
-
|
|
28
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
29
|
+
const alreadyLocked = existingLockedFields.some(lockedField => lockedField.fieldId === field.storageId);
|
|
42
30
|
if (alreadyLocked) {
|
|
43
31
|
continue;
|
|
44
32
|
}
|
|
45
|
-
|
|
46
33
|
let lockedFieldData = {};
|
|
47
|
-
const lockedFieldPlugins = cmsLockedFieldPlugins.filter(pl => pl.fieldType ===
|
|
48
|
-
|
|
34
|
+
const lockedFieldPlugins = cmsLockedFieldPlugins.filter(pl => pl.fieldType === baseType);
|
|
49
35
|
for (const plugin of lockedFieldPlugins) {
|
|
50
36
|
if (typeof plugin.getLockedFieldData !== "function") {
|
|
51
37
|
continue;
|
|
52
38
|
}
|
|
53
|
-
|
|
54
39
|
const data = plugin.getLockedFieldData({
|
|
55
40
|
field
|
|
56
41
|
});
|
|
57
|
-
lockedFieldData =
|
|
42
|
+
lockedFieldData = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, lockedFieldData), data);
|
|
58
43
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
type: field.type
|
|
44
|
+
lockedFields.push((0, _objectSpread2.default)({
|
|
45
|
+
fieldId: field.storageId,
|
|
46
|
+
multipleValues: !!field.multipleValues,
|
|
47
|
+
type: baseType
|
|
64
48
|
}, lockedFieldData));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
49
|
+
}
|
|
50
|
+
// no need to update anything if no locked fields were added
|
|
68
51
|
if (lockedFields.length === 0) {
|
|
69
52
|
return;
|
|
70
53
|
}
|
|
71
|
-
|
|
72
54
|
const newLockedFields = existingLockedFields.concat(lockedFields);
|
|
73
|
-
|
|
74
55
|
try {
|
|
75
56
|
await context.cms.updateModelDirect({
|
|
57
|
+
/**
|
|
58
|
+
* At this point we know this is a CmsModel, so it is safe to cast.
|
|
59
|
+
*/
|
|
76
60
|
original: model,
|
|
77
|
-
model:
|
|
61
|
+
model: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, model), {}, {
|
|
78
62
|
lockedFields: newLockedFields
|
|
79
63
|
})
|
|
80
64
|
});
|
|
81
65
|
model.lockedFields = newLockedFields;
|
|
82
66
|
} catch (ex) {
|
|
83
|
-
throw new _error.default(`Could not update model "${model.modelId}" with new locked fields.`, "MODEL_LOCKED_FIELDS_UPDATE_FAILED",
|
|
67
|
+
throw new _error.default(`Could not update model "${model.modelId}" with new locked fields.`, "MODEL_LOCKED_FIELDS_UPDATE_FAILED", {
|
|
68
|
+
message: ex.message,
|
|
69
|
+
code: ex.code,
|
|
70
|
+
data: ex.data
|
|
71
|
+
});
|
|
84
72
|
}
|
|
85
73
|
};
|
|
86
|
-
|
|
87
74
|
exports.markLockedFields = markLockedFields;
|
|
88
|
-
|
|
89
75
|
const markUnlockedFields = async params => {
|
|
90
76
|
const {
|
|
91
77
|
context,
|
|
@@ -94,24 +80,24 @@ const markUnlockedFields = async params => {
|
|
|
94
80
|
/**
|
|
95
81
|
* If the model is registered via a plugin, we don't need do process anything.
|
|
96
82
|
*/
|
|
97
|
-
|
|
98
83
|
const plugins = context.plugins.byType(_CmsModelPlugin.CmsModelPlugin.type);
|
|
99
|
-
|
|
100
84
|
if (plugins.find(plugin => plugin.contentModel.modelId === model.modelId)) {
|
|
101
85
|
return;
|
|
102
86
|
}
|
|
103
|
-
|
|
104
87
|
try {
|
|
105
88
|
await context.cms.updateModelDirect({
|
|
106
89
|
original: model,
|
|
107
|
-
model:
|
|
90
|
+
model: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, model), {}, {
|
|
108
91
|
lockedFields: []
|
|
109
92
|
})
|
|
110
93
|
});
|
|
111
94
|
model.lockedFields = [];
|
|
112
95
|
} catch (ex) {
|
|
113
|
-
throw new _error.default(`Could not update model "${model.modelId}" with unlocked fields.`, "MODEL_UNLOCKED_FIELDS_UPDATE_FAILED",
|
|
96
|
+
throw new _error.default(`Could not update model "${model.modelId}" with unlocked fields.`, "MODEL_UNLOCKED_FIELDS_UPDATE_FAILED", {
|
|
97
|
+
message: ex.message,
|
|
98
|
+
code: ex.code,
|
|
99
|
+
data: ex.data
|
|
100
|
+
});
|
|
114
101
|
}
|
|
115
102
|
};
|
|
116
|
-
|
|
117
103
|
exports.markUnlockedFields = markUnlockedFields;
|