@webiny/api-headless-cms 0.0.0-mt-2 → 0.0.0-unstable.085ff6572f
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/constants.d.ts +1 -0
- package/constants.js +8 -0
- package/constants.js.map +1 -0
- package/context.d.ts +6 -0
- package/context.js +130 -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/crud/contentEntry.crud.d.ts +20 -0
- package/crud/contentEntry.crud.js +1477 -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/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/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/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/crud/contentModel.crud.d.ts +14 -0
- package/crud/contentModel.crud.js +626 -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 +5 -3
- package/crud/contentModelGroup.crud.js +367 -0
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/crud/settings.crud.d.ts +12 -0
- package/crud/settings.crud.js +62 -0
- package/crud/settings.crud.js.map +1 -0
- package/{content/plugins/crud/contentModel.crud.d.ts → crud/system.crud.d.ts} +5 -4
- 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 +84 -0
- package/graphql/schema/baseSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +7 -0
- package/graphql/schema/contentEntries.js +367 -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 +104 -0
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
- package/graphql/schema/createFieldTypePluginRecords.js +13 -0
- package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +12 -0
- package/graphql/schema/createManageResolvers.js +141 -0
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/graphql/schema/createManageSDL.d.ts +13 -0
- package/graphql/schema/createManageSDL.js +180 -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 +104 -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 +8 -0
- package/graphql/schema/resolvers/manage/resolveDelete.js +36 -0
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +20 -0
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.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/resolveGetUniqueFieldValues.d.ts +4 -0
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +18 -0
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.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/resolveMove.d.ts +8 -0
- package/graphql/schema/resolvers/manage/resolveMove.js +30 -0
- package/graphql/schema/resolvers/manage/resolveMove.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 +100 -0
- package/graphql/schema/schemaPlugins.js.map +1 -0
- package/graphql/system.d.ts +3 -0
- package/{plugins/graphql → graphql}/system.js +29 -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 +68 -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 +64 -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 +39 -44
- 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 +63 -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 +1010 -382
- package/types.js +116 -62
- package/types.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 +128 -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 +2 -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/permissions/EntriesPermissions.d.ts +4 -0
- package/utils/permissions/EntriesPermissions.js +9 -0
- package/utils/permissions/EntriesPermissions.js.map +1 -0
- package/utils/permissions/ModelGroupsPermissions.d.ts +11 -0
- package/utils/permissions/ModelGroupsPermissions.js +48 -0
- package/utils/permissions/ModelGroupsPermissions.js.map +1 -0
- package/utils/permissions/ModelsPermissions.d.ts +20 -0
- package/utils/permissions/ModelsPermissions.js +91 -0
- package/utils/permissions/ModelsPermissions.js.map +1 -0
- package/utils/permissions/SettingsPermissions.d.ts +4 -0
- package/utils/permissions/SettingsPermissions.js +9 -0
- package/utils/permissions/SettingsPermissions.js.map +1 -0
- package/utils/renderFields.d.ts +17 -0
- package/{content/plugins/utils → utils}/renderFields.js +16 -13
- package/utils/renderFields.js.map +1 -0
- package/utils/renderGetFilterFields.d.ts +10 -0
- package/{content/plugins/utils → utils}/renderGetFilterFields.js +16 -22
- package/utils/renderGetFilterFields.js.map +1 -0
- package/utils/renderInputFields.d.ts +16 -0
- package/{content/plugins/utils → utils}/renderInputFields.js +20 -15
- package/utils/renderInputFields.js.map +1 -0
- package/utils/renderListFilterFields.d.ts +13 -0
- package/utils/renderListFilterFields.js +48 -0
- package/utils/renderListFilterFields.js.map +1 -0
- package/utils/renderSortEnum.d.ts +13 -0
- package/utils/renderSortEnum.js +46 -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.d.ts +0 -17
- 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/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/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/resolveDelete.js +0 -30
- 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/pluralizedTypeName.js +0 -26
- package/content/plugins/utils/renderFields.d.ts +0 -16
- package/content/plugins/utils/renderGetFilterFields.d.ts +0 -9
- package/content/plugins/utils/renderInputFields.d.ts +0 -14
- package/content/plugins/utils/renderListFilterFields.d.ts +0 -10
- package/content/plugins/utils/renderListFilterFields.js +0 -39
- 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.d.ts +0 -10
- package/plugins/crud/settings.crud.js +0 -93
- package/plugins/crud/system.crud.d.ts +0 -10
- 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
|
@@ -1,63 +1,52 @@
|
|
|
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.entryToStorageTransform = exports.entryFromStorageTransform = exports.entryFieldFromStorageTransform = 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 _StorageTransformPlugin = require("../plugins/StorageTransformPlugin");
|
|
11
|
+
var _getBaseFieldType = require("./getBaseFieldType");
|
|
20
12
|
const getStoragePluginFactory = context => {
|
|
21
13
|
let defaultStoragePlugin;
|
|
22
|
-
const plugins = context.plugins.byType(_StorageTransformPlugin.StorageTransformPlugin.type)
|
|
14
|
+
const plugins = context.plugins.byType(_StorageTransformPlugin.StorageTransformPlugin.type)
|
|
15
|
+
// we reverse plugins because we want to get latest added only
|
|
23
16
|
.reverse().reduce((collection, plugin) => {
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Check if it's a default plugin and set it - always override the previous one.
|
|
19
|
+
*/
|
|
20
|
+
if (plugin.fieldType === "*") {
|
|
26
21
|
defaultStoragePlugin = plugin;
|
|
27
22
|
return collection;
|
|
28
23
|
}
|
|
24
|
+
|
|
29
25
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
26
|
+
* We will just set the plugin for given type.
|
|
27
|
+
* The last one will override existing one - so users can override our default ones.
|
|
32
28
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!collection[plugin.fieldType]) {
|
|
36
|
-
collection[plugin.fieldType] = plugin;
|
|
37
|
-
}
|
|
38
|
-
|
|
29
|
+
collection[plugin.fieldType] = plugin;
|
|
39
30
|
return collection;
|
|
40
31
|
}, {});
|
|
41
32
|
return fieldType => {
|
|
42
33
|
return plugins[fieldType] || defaultStoragePlugin;
|
|
43
34
|
};
|
|
44
35
|
};
|
|
36
|
+
|
|
45
37
|
/**
|
|
46
38
|
* This should be used when transforming the whole entry.
|
|
47
39
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
40
|
const entryStorageTransform = async (context, model, operation, entry) => {
|
|
51
41
|
const getStoragePlugin = getStoragePluginFactory(context);
|
|
52
42
|
const transformedValues = {};
|
|
53
|
-
|
|
54
43
|
for (const field of model.fields) {
|
|
55
|
-
const
|
|
56
|
-
|
|
44
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
45
|
+
const plugin = getStoragePlugin(baseType);
|
|
46
|
+
// TODO: remove this once plugins are converted into classes
|
|
57
47
|
if (typeof plugin[operation] !== "function") {
|
|
58
|
-
throw new _error.default(`Missing "${operation}" function in storage plugin "${plugin.name}" for field type "${
|
|
48
|
+
throw new _error.default(`Missing "${operation}" function in storage plugin "${plugin.name}" for field type "${baseType}"`);
|
|
59
49
|
}
|
|
60
|
-
|
|
61
50
|
transformedValues[field.fieldId] = await plugin[operation]({
|
|
62
51
|
plugins: context.plugins,
|
|
63
52
|
model,
|
|
@@ -66,36 +55,26 @@ const entryStorageTransform = async (context, model, operation, entry) => {
|
|
|
66
55
|
getStoragePlugin
|
|
67
56
|
});
|
|
68
57
|
}
|
|
69
|
-
|
|
70
|
-
return _objectSpread(_objectSpread({}, entry), {}, {
|
|
58
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
71
59
|
values: transformedValues
|
|
72
60
|
});
|
|
73
61
|
};
|
|
62
|
+
|
|
74
63
|
/**
|
|
75
64
|
* A function that is used in crud to transform entry into the storage type.
|
|
76
65
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
66
|
const entryToStorageTransform = async (context, model, entry) => {
|
|
80
67
|
return entryStorageTransform(context, model, "toStorage", entry);
|
|
81
68
|
};
|
|
69
|
+
|
|
82
70
|
/**
|
|
83
71
|
* A function that is used to transform the whole entry from storage into its native form.
|
|
84
72
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
73
|
exports.entryToStorageTransform = entryToStorageTransform;
|
|
88
|
-
|
|
89
74
|
const entryFromStorageTransform = async (context, model, entry) => {
|
|
90
|
-
if (!entry) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
75
|
return entryStorageTransform(context, model, "fromStorage", entry);
|
|
95
76
|
};
|
|
96
|
-
|
|
97
77
|
exports.entryFromStorageTransform = entryFromStorageTransform;
|
|
98
|
-
|
|
99
78
|
/*
|
|
100
79
|
* A function that is used to transform a single field from storage
|
|
101
80
|
*/
|
|
@@ -107,12 +86,13 @@ const entryFieldFromStorageTransform = async params => {
|
|
|
107
86
|
value
|
|
108
87
|
} = params;
|
|
109
88
|
const getStoragePlugin = getStoragePluginFactory(context);
|
|
110
|
-
const
|
|
89
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
90
|
+
const plugin = getStoragePlugin(baseType);
|
|
111
91
|
|
|
92
|
+
// TODO: remove this once plugins are converted into classes
|
|
112
93
|
if (typeof plugin.fromStorage !== "function") {
|
|
113
|
-
throw new _error.default(`Missing "fromStorage" function in storage plugin "${plugin.name}" for field type "${
|
|
94
|
+
throw new _error.default(`Missing "fromStorage" function in storage plugin "${plugin.name}" for field type "${baseType}"`);
|
|
114
95
|
}
|
|
115
|
-
|
|
116
96
|
return plugin.fromStorage({
|
|
117
97
|
plugins: context.plugins,
|
|
118
98
|
model,
|
|
@@ -121,5 +101,4 @@ const entryFieldFromStorageTransform = async params => {
|
|
|
121
101
|
getStoragePlugin
|
|
122
102
|
});
|
|
123
103
|
};
|
|
124
|
-
|
|
125
104
|
exports.entryFieldFromStorageTransform = entryFieldFromStorageTransform;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getStoragePluginFactory","context","defaultStoragePlugin","plugins","byType","StorageTransformPlugin","type","reverse","reduce","collection","plugin","fieldType","entryStorageTransform","model","operation","entry","getStoragePlugin","transformedValues","field","fields","baseType","getBaseFieldType","WebinyError","name","fieldId","value","values","entryToStorageTransform","entryFromStorageTransform","entryFieldFromStorageTransform","params","fromStorage"],"sources":["entryStorage.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"~/plugins/StorageTransformPlugin\";\nimport { CmsEntry, CmsModel, CmsModelField, CmsContext } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface GetStoragePluginFactory {\n (context: CmsContext): (fieldType: string) => StorageTransformPlugin<any>;\n}\n\nconst getStoragePluginFactory: GetStoragePluginFactory = context => {\n let defaultStoragePlugin: StorageTransformPlugin;\n\n const plugins = context.plugins\n .byType<StorageTransformPlugin>(StorageTransformPlugin.type)\n // we reverse plugins because we want to get latest added only\n .reverse()\n .reduce((collection, plugin) => {\n /**\n * Check if it's a default plugin and set it - always override the previous one.\n */\n if (plugin.fieldType === \"*\") {\n defaultStoragePlugin = plugin;\n return collection;\n }\n\n /**\n * We will just set the plugin for given type.\n * The last one will override existing one - so users can override our default ones.\n */\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {} as Record<string, StorageTransformPlugin>);\n\n return (fieldType: string) => {\n return plugins[fieldType] || defaultStoragePlugin;\n };\n};\n\n/**\n * This should be used when transforming the whole entry.\n */\nconst entryStorageTransform = async (\n context: CmsContext,\n model: CmsModel,\n operation: \"toStorage\" | \"fromStorage\",\n entry: CmsEntry\n): Promise<CmsEntry> => {\n const getStoragePlugin = getStoragePluginFactory(context);\n\n const transformedValues: Record<string, any> = {};\n for (const field of model.fields) {\n const baseType = getBaseFieldType(field);\n const plugin = getStoragePlugin(baseType);\n // TODO: remove this once plugins are converted into classes\n if (typeof plugin[operation] !== \"function\") {\n throw new WebinyError(\n `Missing \"${operation}\" function in storage plugin \"${plugin.name}\" for field type \"${baseType}\"`\n );\n }\n\n transformedValues[field.fieldId] = await plugin[operation]({\n plugins: context.plugins,\n model,\n field,\n value: entry.values[field.fieldId],\n getStoragePlugin\n });\n }\n\n return { ...entry, values: transformedValues };\n};\n\n/**\n * A function that is used in crud to transform entry into the storage type.\n */\nexport const entryToStorageTransform = async (\n context: CmsContext,\n model: CmsModel,\n entry: CmsEntry\n): Promise<CmsEntry> => {\n return entryStorageTransform(context, model, \"toStorage\", entry);\n};\n\n/**\n * A function that is used to transform the whole entry from storage into its native form.\n */\nexport const entryFromStorageTransform = async (\n context: CmsContext,\n model: CmsModel,\n entry: CmsEntry\n): Promise<CmsEntry> => {\n return entryStorageTransform(context, model, \"fromStorage\", entry);\n};\n\ninterface EntryFieldFromStorageTransformParams {\n context: CmsContext;\n model: CmsModel;\n field: CmsModelField;\n value: any;\n}\n/*\n * A function that is used to transform a single field from storage\n */\nexport const entryFieldFromStorageTransform = async <T = any>(\n params: EntryFieldFromStorageTransformParams\n): Promise<T> => {\n const { context, model, field, value } = params;\n const getStoragePlugin = getStoragePluginFactory(context);\n\n const baseType = getBaseFieldType(field);\n const plugin = getStoragePlugin(baseType);\n\n // TODO: remove this once plugins are converted into classes\n if (typeof plugin.fromStorage !== \"function\") {\n throw new WebinyError(\n `Missing \"fromStorage\" function in storage plugin \"${plugin.name}\" for field type \"${baseType}\"`\n );\n }\n\n return plugin.fromStorage({\n plugins: context.plugins,\n model,\n field,\n value,\n getStoragePlugin\n });\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AAEA;AAMA,MAAMA,uBAAgD,GAAGC,OAAO,IAAI;EAChE,IAAIC,oBAA4C;EAEhD,MAAMC,OAAO,GAAGF,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAAyBC,8CAAsB,CAACC,IAAI;EAC3D;EAAA,CACCC,OAAO,EAAE,CACTC,MAAM,CAAC,CAACC,UAAU,EAAEC,MAAM,KAAK;IAC5B;AACZ;AACA;IACY,IAAIA,MAAM,CAACC,SAAS,KAAK,GAAG,EAAE;MAC1BT,oBAAoB,GAAGQ,MAAM;MAC7B,OAAOD,UAAU;IACrB;;IAEA;AACZ;AACA;AACA;IACYA,UAAU,CAACC,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM;IAErC,OAAOD,UAAU;EACrB,CAAC,EAAE,CAAC,CAAC,CAA2C;EAEpD,OAAQE,SAAiB,IAAK;IAC1B,OAAOR,OAAO,CAACQ,SAAS,CAAC,IAAIT,oBAAoB;EACrD,CAAC;AACL,CAAC;;AAED;AACA;AACA;AACA,MAAMU,qBAAqB,GAAG,OAC1BX,OAAmB,EACnBY,KAAe,EACfC,SAAsC,EACtCC,KAAe,KACK;EACpB,MAAMC,gBAAgB,GAAGhB,uBAAuB,CAACC,OAAO,CAAC;EAEzD,MAAMgB,iBAAsC,GAAG,CAAC,CAAC;EACjD,KAAK,MAAMC,KAAK,IAAIL,KAAK,CAACM,MAAM,EAAE;IAC9B,MAAMC,QAAQ,GAAG,IAAAC,kCAAgB,EAACH,KAAK,CAAC;IACxC,MAAMR,MAAM,GAAGM,gBAAgB,CAACI,QAAQ,CAAC;IACzC;IACA,IAAI,OAAOV,MAAM,CAACI,SAAS,CAAC,KAAK,UAAU,EAAE;MACzC,MAAM,IAAIQ,cAAW,CAChB,YAAWR,SAAU,iCAAgCJ,MAAM,CAACa,IAAK,qBAAoBH,QAAS,GAAE,CACpG;IACL;IAEAH,iBAAiB,CAACC,KAAK,CAACM,OAAO,CAAC,GAAG,MAAMd,MAAM,CAACI,SAAS,CAAC,CAAC;MACvDX,OAAO,EAAEF,OAAO,CAACE,OAAO;MACxBU,KAAK;MACLK,KAAK;MACLO,KAAK,EAAEV,KAAK,CAACW,MAAM,CAACR,KAAK,CAACM,OAAO,CAAC;MAClCR;IACJ,CAAC,CAAC;EACN;EAEA,mEAAYD,KAAK;IAAEW,MAAM,EAAET;EAAiB;AAChD,CAAC;;AAED;AACA;AACA;AACO,MAAMU,uBAAuB,GAAG,OACnC1B,OAAmB,EACnBY,KAAe,EACfE,KAAe,KACK;EACpB,OAAOH,qBAAqB,CAACX,OAAO,EAAEY,KAAK,EAAE,WAAW,EAAEE,KAAK,CAAC;AACpE,CAAC;;AAED;AACA;AACA;AAFA;AAGO,MAAMa,yBAAyB,GAAG,OACrC3B,OAAmB,EACnBY,KAAe,EACfE,KAAe,KACK;EACpB,OAAOH,qBAAqB,CAACX,OAAO,EAAEY,KAAK,EAAE,aAAa,EAAEE,KAAK,CAAC;AACtE,CAAC;AAAC;AAQF;AACA;AACA;AACO,MAAMc,8BAA8B,GAAG,MAC1CC,MAA4C,IAC/B;EACb,MAAM;IAAE7B,OAAO;IAAEY,KAAK;IAAEK,KAAK;IAAEO;EAAM,CAAC,GAAGK,MAAM;EAC/C,MAAMd,gBAAgB,GAAGhB,uBAAuB,CAACC,OAAO,CAAC;EAEzD,MAAMmB,QAAQ,GAAG,IAAAC,kCAAgB,EAACH,KAAK,CAAC;EACxC,MAAMR,MAAM,GAAGM,gBAAgB,CAACI,QAAQ,CAAC;;EAEzC;EACA,IAAI,OAAOV,MAAM,CAACqB,WAAW,KAAK,UAAU,EAAE;IAC1C,MAAM,IAAIT,cAAW,CAChB,qDAAoDZ,MAAM,CAACa,IAAK,qBAAoBH,QAAS,GAAE,CACnG;EACL;EAEA,OAAOV,MAAM,CAACqB,WAAW,CAAC;IACtB5B,OAAO,EAAEF,OAAO,CAACE,OAAO;IACxBU,KAAK;IACLK,KAAK;IACLO,KAAK;IACLT;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const filterAsync: <T = Record<string, any>>(items: T[], predicate: (param: T) => Promise<boolean>) => Promise<T[]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.filterAsync = void 0;
|
|
7
|
+
const filterAsync = async (items, predicate) => {
|
|
8
|
+
const filteredItems = [];
|
|
9
|
+
for (let i = 0; i < items.length; i++) {
|
|
10
|
+
const item = items[i];
|
|
11
|
+
const valid = await predicate(item);
|
|
12
|
+
if (valid) {
|
|
13
|
+
filteredItems.push(item);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return filteredItems;
|
|
17
|
+
};
|
|
18
|
+
exports.filterAsync = filterAsync;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["filterAsync","items","predicate","filteredItems","i","length","item","valid","push"],"sources":["filterAsync.ts"],"sourcesContent":["export const filterAsync = async <T = Record<string, any>>(\n items: T[],\n predicate: (param: T) => Promise<boolean>\n): Promise<T[]> => {\n const filteredItems = [];\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const valid = await predicate(item);\n if (valid) {\n filteredItems.push(item);\n }\n }\n\n return filteredItems;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,WAAW,GAAG,OACvBC,KAAU,EACVC,SAAyC,KAC1B;EACf,MAAMC,aAAa,GAAG,EAAE;EAExB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,KAAK,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;IACnC,MAAME,IAAI,GAAGL,KAAK,CAACG,CAAC,CAAC;IACrB,MAAMG,KAAK,GAAG,MAAML,SAAS,CAACI,IAAI,CAAC;IACnC,IAAIC,KAAK,EAAE;MACPJ,aAAa,CAACK,IAAI,CAACF,IAAI,CAAC;IAC5B;EACJ;EAEA,OAAOH,aAAa;AACxB,CAAC;AAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getBaseFieldType","field","type","split"],"sources":["getBaseFieldType.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\n\nexport const getBaseFieldType = (field: Pick<CmsModelField, \"type\">) => {\n return field.type.split(\":\")[0];\n};\n"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAIC,KAAkC,IAAK;EACpE,OAAOA,KAAK,CAACC,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEntryDescription = getEntryDescription;
|
|
7
|
+
function getEntryDescription(model, entry) {
|
|
8
|
+
if (!model.descriptionFieldId) {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);
|
|
12
|
+
if (!field) {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
const descriptionFieldId = field.fieldId;
|
|
16
|
+
return entry.values[descriptionFieldId] || "";
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getEntryDescription","model","entry","descriptionFieldId","field","fields","find","f","fieldId","values"],"sources":["getEntryDescription.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryDescription(\n model: Pick<CmsModel, \"descriptionFieldId\" | \"fields\">,\n entry: CmsEntry\n): string {\n if (!model.descriptionFieldId) {\n return \"\";\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return \"\";\n }\n const descriptionFieldId = field.fieldId;\n return entry.values[descriptionFieldId] || \"\";\n}\n"],"mappings":";;;;;;AAEO,SAASA,mBAAmB,CAC/BC,KAAsD,EACtDC,KAAe,EACT;EACN,IAAI,CAACD,KAAK,CAACE,kBAAkB,EAAE;IAC3B,OAAO,EAAE;EACb;EACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKP,KAAK,CAACE,kBAAkB,CAAC;EAC5E,IAAI,CAACC,KAAK,EAAE;IACR,OAAO,EAAE;EACb;EACA,MAAMD,kBAAkB,GAAGC,KAAK,CAACI,OAAO;EACxC,OAAON,KAAK,CAACO,MAAM,CAACN,kBAAkB,CAAC,IAAI,EAAE;AACjD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEntryImage = getEntryImage;
|
|
7
|
+
function getEntryImage(model, entry) {
|
|
8
|
+
if (!model.imageFieldId) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const field = model.fields.find(f => f.fieldId === model.imageFieldId);
|
|
12
|
+
if (!field) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const imageFieldId = field.fieldId;
|
|
16
|
+
return entry.values[imageFieldId] || null;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getEntryImage","model","entry","imageFieldId","field","fields","find","f","fieldId","values"],"sources":["getEntryImage.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryImage(\n model: Pick<CmsModel, \"imageFieldId\" | \"fields\">,\n entry: CmsEntry\n): string | null {\n if (!model.imageFieldId) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.imageFieldId);\n if (!field) {\n return null;\n }\n const imageFieldId = field.fieldId;\n return entry.values[imageFieldId] || null;\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAa,CACzBC,KAAgD,EAChDC,KAAe,EACF;EACb,IAAI,CAACD,KAAK,CAACE,YAAY,EAAE;IACrB,OAAO,IAAI;EACf;EACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKP,KAAK,CAACE,YAAY,CAAC;EACtE,IAAI,CAACC,KAAK,EAAE;IACR,OAAO,IAAI;EACf;EACA,MAAMD,YAAY,GAAGC,KAAK,CAACI,OAAO;EAClC,OAAON,KAAK,CAACO,MAAM,CAACN,YAAY,CAAC,IAAI,IAAI;AAC7C"}
|
|
@@ -4,39 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getEntryTitle = getEntryTitle;
|
|
7
|
-
|
|
8
7
|
function getEntryTitle(model, entry) {
|
|
9
8
|
if (!model.titleFieldId) {
|
|
10
9
|
return entry.id;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
const titleValue = entry.values[model.titleFieldId];
|
|
14
|
-
|
|
15
|
-
if (!titleValue) {
|
|
16
|
-
return entry.id;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
11
|
const field = model.fields.find(f => f.fieldId === model.titleFieldId);
|
|
20
|
-
|
|
21
12
|
if (!field) {
|
|
22
|
-
return
|
|
13
|
+
return entry.id;
|
|
14
|
+
}
|
|
15
|
+
const titleFieldId = field.fieldId;
|
|
16
|
+
const titleValue = entry.values[titleFieldId];
|
|
17
|
+
if (!titleValue) {
|
|
18
|
+
return entry.id;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
const {
|
|
26
21
|
enabled = false,
|
|
27
22
|
values
|
|
28
23
|
} = field.predefinedValues || {};
|
|
29
|
-
|
|
30
|
-
if (!enabled || Array.isArray(values) === false) {
|
|
24
|
+
if (!enabled || !values || Array.isArray(values) === false) {
|
|
31
25
|
return titleValue;
|
|
32
26
|
}
|
|
33
|
-
|
|
34
27
|
for (const value of values) {
|
|
35
28
|
// needs to be loose because titleValue can be a number and value can be a string - but it must match
|
|
36
29
|
if (value.value == titleValue) {
|
|
37
30
|
return value.label;
|
|
38
31
|
}
|
|
39
32
|
}
|
|
40
|
-
|
|
41
33
|
return titleValue;
|
|
42
34
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getEntryTitle","model","entry","titleFieldId","id","field","fields","find","f","fieldId","titleValue","values","enabled","predefinedValues","Array","isArray","value","label"],"sources":["getEntryTitle.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryTitle(\n model: Pick<CmsModel, \"titleFieldId\" | \"fields\">,\n entry: CmsEntry\n): string {\n if (!model.titleFieldId) {\n return entry.id;\n }\n const field = model.fields.find(f => f.fieldId === model.titleFieldId);\n if (!field) {\n return entry.id;\n }\n const titleFieldId = field.fieldId;\n const titleValue = entry.values[titleFieldId];\n if (!titleValue) {\n return entry.id;\n }\n\n const { enabled = false, values } = field.predefinedValues || {};\n if (!enabled || !values || Array.isArray(values) === false) {\n return titleValue;\n }\n for (const value of values) {\n // needs to be loose because titleValue can be a number and value can be a string - but it must match\n if (value.value == titleValue) {\n return value.label;\n }\n }\n return titleValue;\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAa,CACzBC,KAAgD,EAChDC,KAAe,EACT;EACN,IAAI,CAACD,KAAK,CAACE,YAAY,EAAE;IACrB,OAAOD,KAAK,CAACE,EAAE;EACnB;EACA,MAAMC,KAAK,GAAGJ,KAAK,CAACK,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKR,KAAK,CAACE,YAAY,CAAC;EACtE,IAAI,CAACE,KAAK,EAAE;IACR,OAAOH,KAAK,CAACE,EAAE;EACnB;EACA,MAAMD,YAAY,GAAGE,KAAK,CAACI,OAAO;EAClC,MAAMC,UAAU,GAAGR,KAAK,CAACS,MAAM,CAACR,YAAY,CAAC;EAC7C,IAAI,CAACO,UAAU,EAAE;IACb,OAAOR,KAAK,CAACE,EAAE;EACnB;EAEA,MAAM;IAAEQ,OAAO,GAAG,KAAK;IAAED;EAAO,CAAC,GAAGN,KAAK,CAACQ,gBAAgB,IAAI,CAAC,CAAC;EAChE,IAAI,CAACD,OAAO,IAAI,CAACD,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,KAAK,KAAK,EAAE;IACxD,OAAOD,UAAU;EACrB;EACA,KAAK,MAAMM,KAAK,IAAIL,MAAM,EAAE;IACxB;IACA,IAAIK,KAAK,CAACA,KAAK,IAAIN,UAAU,EAAE;MAC3B,OAAOM,KAAK,CAACC,KAAK;IACtB;EACJ;EACA,OAAOP,UAAU;AACrB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CmsModel, CmsFieldTypePlugins, ApiEndpoint } from "../types";
|
|
2
|
+
import { CmsGraphQLSchemaPlugin } from "../plugins";
|
|
3
|
+
interface Params {
|
|
4
|
+
models: CmsModel[];
|
|
5
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
|
+
type: ApiEndpoint;
|
|
7
|
+
}
|
|
8
|
+
export declare const createGraphQLSchemaPluginFromFieldPlugins: (params: Params) => CmsGraphQLSchemaPlugin<import("../types").CmsContext>[];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createGraphQLSchemaPluginFromFieldPlugins = void 0;
|
|
7
|
+
var _plugins = require("../plugins");
|
|
8
|
+
const TYPE_MAP = {
|
|
9
|
+
preview: "read",
|
|
10
|
+
read: "read",
|
|
11
|
+
manage: "manage"
|
|
12
|
+
};
|
|
13
|
+
const createGraphQLSchemaPluginFromFieldPlugins = params => {
|
|
14
|
+
const {
|
|
15
|
+
models,
|
|
16
|
+
fieldTypePlugins,
|
|
17
|
+
type
|
|
18
|
+
} = params;
|
|
19
|
+
const plugins = [];
|
|
20
|
+
for (const key in fieldTypePlugins) {
|
|
21
|
+
const fieldTypePlugin = fieldTypePlugins[key];
|
|
22
|
+
if (!TYPE_MAP[type] || !fieldTypePlugin[TYPE_MAP[type]]) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const createSchema = fieldTypePlugin[TYPE_MAP[type]].createSchema;
|
|
26
|
+
// Render gql types generated by field type plugins
|
|
27
|
+
if (!createSchema) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const schema = createSchema({
|
|
31
|
+
models
|
|
32
|
+
});
|
|
33
|
+
const plugin = new _plugins.CmsGraphQLSchemaPlugin(schema);
|
|
34
|
+
plugin.name = `headless-cms.graphql.schema.${type}.field.${fieldTypePlugin.fieldType}`;
|
|
35
|
+
plugins.push(plugin);
|
|
36
|
+
}
|
|
37
|
+
return plugins;
|
|
38
|
+
};
|
|
39
|
+
exports.createGraphQLSchemaPluginFromFieldPlugins = createGraphQLSchemaPluginFromFieldPlugins;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TYPE_MAP","preview","read","manage","createGraphQLSchemaPluginFromFieldPlugins","params","models","fieldTypePlugins","type","plugins","key","fieldTypePlugin","createSchema","schema","plugin","CmsGraphQLSchemaPlugin","name","fieldType","push"],"sources":["getSchemaFromFieldPlugins.ts"],"sourcesContent":["import { CmsModel, CmsFieldTypePlugins, ApiEndpoint } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\n\nconst TYPE_MAP: Record<string, \"manage\" | \"read\"> = {\n preview: \"read\",\n read: \"read\",\n manage: \"manage\"\n};\n\ninterface Params {\n models: CmsModel[];\n fieldTypePlugins: CmsFieldTypePlugins;\n type: ApiEndpoint;\n}\nexport const createGraphQLSchemaPluginFromFieldPlugins = (params: Params) => {\n const { models, fieldTypePlugins, type } = params;\n\n const plugins: CmsGraphQLSchemaPlugin[] = [];\n for (const key in fieldTypePlugins) {\n const fieldTypePlugin = fieldTypePlugins[key];\n if (!TYPE_MAP[type] || !fieldTypePlugin[TYPE_MAP[type]]) {\n continue;\n }\n const createSchema = fieldTypePlugin[TYPE_MAP[type]].createSchema;\n // Render gql types generated by field type plugins\n if (!createSchema) {\n continue;\n }\n const schema = createSchema({ models });\n\n const plugin = new CmsGraphQLSchemaPlugin(schema);\n plugin.name = `headless-cms.graphql.schema.${type}.field.${fieldTypePlugin.fieldType}`;\n plugins.push(plugin);\n }\n return plugins;\n};\n"],"mappings":";;;;;;AACA;AAEA,MAAMA,QAA2C,GAAG;EAChDC,OAAO,EAAE,MAAM;EACfC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC;AAOM,MAAMC,yCAAyC,GAAIC,MAAc,IAAK;EACzE,MAAM;IAAEC,MAAM;IAAEC,gBAAgB;IAAEC;EAAK,CAAC,GAAGH,MAAM;EAEjD,MAAMI,OAAiC,GAAG,EAAE;EAC5C,KAAK,MAAMC,GAAG,IAAIH,gBAAgB,EAAE;IAChC,MAAMI,eAAe,GAAGJ,gBAAgB,CAACG,GAAG,CAAC;IAC7C,IAAI,CAACV,QAAQ,CAACQ,IAAI,CAAC,IAAI,CAACG,eAAe,CAACX,QAAQ,CAACQ,IAAI,CAAC,CAAC,EAAE;MACrD;IACJ;IACA,MAAMI,YAAY,GAAGD,eAAe,CAACX,QAAQ,CAACQ,IAAI,CAAC,CAAC,CAACI,YAAY;IACjE;IACA,IAAI,CAACA,YAAY,EAAE;MACf;IACJ;IACA,MAAMC,MAAM,GAAGD,YAAY,CAAC;MAAEN;IAAO,CAAC,CAAC;IAEvC,MAAMQ,MAAM,GAAG,IAAIC,+BAAsB,CAACF,MAAM,CAAC;IACjDC,MAAM,CAACE,IAAI,GAAI,+BAA8BR,IAAK,UAASG,eAAe,CAACM,SAAU,EAAC;IACtFR,OAAO,CAACS,IAAI,CAACJ,MAAM,CAAC;EACxB;EACA,OAAOL,OAAO;AAClB,CAAC;AAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.incrementEntryIdVersion = void 0;
|
|
8
|
+
var _utils = require("@webiny/utils");
|
|
9
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
+
const incrementEntryIdVersion = id => {
|
|
11
|
+
const {
|
|
12
|
+
id: entryId,
|
|
13
|
+
version
|
|
14
|
+
} = (0, _utils.parseIdentifier)(id);
|
|
15
|
+
if (!version) {
|
|
16
|
+
throw new _error.default("Cannot increase version on the ID without the version part.", "WRONG_ID", {
|
|
17
|
+
id
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
entryId,
|
|
22
|
+
version: version + 1,
|
|
23
|
+
id: (0, _utils.createIdentifier)({
|
|
24
|
+
id: entryId,
|
|
25
|
+
version: version + 1
|
|
26
|
+
})
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
exports.incrementEntryIdVersion = incrementEntryIdVersion;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["incrementEntryIdVersion","id","entryId","version","parseIdentifier","WebinyError","createIdentifier"],"sources":["incrementEntryIdVersion.ts"],"sourcesContent":["import { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\n\nexport const incrementEntryIdVersion = (id: string) => {\n const { id: entryId, version } = parseIdentifier(id);\n if (!version) {\n throw new WebinyError(\n \"Cannot increase version on the ID without the version part.\",\n \"WRONG_ID\",\n {\n id\n }\n );\n }\n return {\n entryId,\n version: version + 1,\n id: createIdentifier({\n id: entryId,\n version: version + 1\n })\n };\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEO,MAAMA,uBAAuB,GAAIC,EAAU,IAAK;EACnD,MAAM;IAAEA,EAAE,EAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACH,EAAE,CAAC;EACpD,IAAI,CAACE,OAAO,EAAE;IACV,MAAM,IAAIE,cAAW,CACjB,6DAA6D,EAC7D,UAAU,EACV;MACIJ;IACJ,CAAC,CACJ;EACL;EACA,OAAO;IACHC,OAAO;IACPC,OAAO,EAAEA,OAAO,GAAG,CAAC;IACpBF,EAAE,EAAE,IAAAK,uBAAgB,EAAC;MACjBL,EAAE,EAAEC,OAAO;MACXC,OAAO,EAAEA,OAAO,GAAG;IACvB,CAAC;EACL,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EntriesPermissions = void 0;
|
|
7
|
+
var _apiSecurity = require("@webiny/api-security");
|
|
8
|
+
class EntriesPermissions extends _apiSecurity.AppPermissions {}
|
|
9
|
+
exports.EntriesPermissions = EntriesPermissions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EntriesPermissions","AppPermissions"],"sources":["EntriesPermissions.ts"],"sourcesContent":["import { CmsEntryPermission } from \"~/types\";\nimport { AppPermissions } from \"@webiny/api-security\";\n\nexport class EntriesPermissions extends AppPermissions<CmsEntryPermission> {}\n"],"mappings":";;;;;;AACA;AAEO,MAAMA,kBAAkB,SAASC,2BAAc,CAAqB;AAAE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AppPermissions } from "@webiny/api-security";
|
|
2
|
+
import { CmsGroup, CmsGroupPermission } from "../../types";
|
|
3
|
+
interface CanAccessGroupParams {
|
|
4
|
+
group: CmsGroup;
|
|
5
|
+
locale: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class ModelGroupsPermissions extends AppPermissions<CmsGroupPermission> {
|
|
8
|
+
canAccessGroup({ group, locale }: CanAccessGroupParams): Promise<boolean>;
|
|
9
|
+
ensureCanAccessGroup(params: CanAccessGroupParams): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ModelGroupsPermissions = void 0;
|
|
7
|
+
var _apiSecurity = require("@webiny/api-security");
|
|
8
|
+
class ModelGroupsPermissions extends _apiSecurity.AppPermissions {
|
|
9
|
+
async canAccessGroup({
|
|
10
|
+
group,
|
|
11
|
+
locale
|
|
12
|
+
}) {
|
|
13
|
+
if (await this.hasFullAccess()) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
const permissions = await this.getPermissions();
|
|
17
|
+
for (let i = 0; i < permissions.length; i++) {
|
|
18
|
+
const permission = permissions[i];
|
|
19
|
+
const {
|
|
20
|
+
groups
|
|
21
|
+
} = permission;
|
|
22
|
+
// When no groups defined on permission it means user has access to everything.
|
|
23
|
+
if (!groups) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// when there is no locale in groups, it means that no access was given
|
|
28
|
+
// this happens when access control was set but no models or groups were added
|
|
29
|
+
if (Array.isArray(groups[locale]) === false || groups[locale].includes(group.id) === false) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
async ensureCanAccessGroup(params) {
|
|
37
|
+
const canAccessModel = await this.canAccessGroup(params);
|
|
38
|
+
if (canAccessModel) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
42
|
+
data: {
|
|
43
|
+
reason: `Not allowed to access group "${params.group.id}".`
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.ModelGroupsPermissions = ModelGroupsPermissions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ModelGroupsPermissions","AppPermissions","canAccessGroup","group","locale","hasFullAccess","permissions","getPermissions","i","length","permission","groups","Array","isArray","includes","id","ensureCanAccessGroup","params","canAccessModel","NotAuthorizedError","data","reason"],"sources":["ModelGroupsPermissions.ts"],"sourcesContent":["import { AppPermissions, NotAuthorizedError } from \"@webiny/api-security\";\nimport { CmsGroup, CmsGroupPermission } from \"~/types\";\n\ninterface CanAccessGroupParams {\n group: CmsGroup;\n locale: string;\n}\n\nexport class ModelGroupsPermissions extends AppPermissions<CmsGroupPermission> {\n async canAccessGroup({ group, locale }: CanAccessGroupParams) {\n if (await this.hasFullAccess()) {\n return true;\n }\n\n const permissions = await this.getPermissions();\n\n for (let i = 0; i < permissions.length; i++) {\n const permission = permissions[i];\n const { groups } = permission;\n // When no groups defined on permission it means user has access to everything.\n if (!groups) {\n return true;\n }\n\n // when there is no locale in groups, it means that no access was given\n // this happens when access control was set but no models or groups were added\n if (\n Array.isArray(groups[locale]) === false ||\n groups[locale].includes(group.id) === false\n ) {\n return false;\n }\n return true;\n }\n\n return false;\n }\n\n async ensureCanAccessGroup(params: CanAccessGroupParams) {\n const canAccessModel = await this.canAccessGroup(params);\n if (canAccessModel) {\n return;\n }\n\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to access group \"${params.group.id}\".`\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA;AAQO,MAAMA,sBAAsB,SAASC,2BAAc,CAAqB;EAC3E,MAAMC,cAAc,CAAC;IAAEC,KAAK;IAAEC;EAA6B,CAAC,EAAE;IAC1D,IAAI,MAAM,IAAI,CAACC,aAAa,EAAE,EAAE;MAC5B,OAAO,IAAI;IACf;IAEA,MAAMC,WAAW,GAAG,MAAM,IAAI,CAACC,cAAc,EAAE;IAE/C,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,WAAW,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;MACzC,MAAME,UAAU,GAAGJ,WAAW,CAACE,CAAC,CAAC;MACjC,MAAM;QAAEG;MAAO,CAAC,GAAGD,UAAU;MAC7B;MACA,IAAI,CAACC,MAAM,EAAE;QACT,OAAO,IAAI;MACf;;MAEA;MACA;MACA,IACIC,KAAK,CAACC,OAAO,CAACF,MAAM,CAACP,MAAM,CAAC,CAAC,KAAK,KAAK,IACvCO,MAAM,CAACP,MAAM,CAAC,CAACU,QAAQ,CAACX,KAAK,CAACY,EAAE,CAAC,KAAK,KAAK,EAC7C;QACE,OAAO,KAAK;MAChB;MACA,OAAO,IAAI;IACf;IAEA,OAAO,KAAK;EAChB;EAEA,MAAMC,oBAAoB,CAACC,MAA4B,EAAE;IACrD,MAAMC,cAAc,GAAG,MAAM,IAAI,CAAChB,cAAc,CAACe,MAAM,CAAC;IACxD,IAAIC,cAAc,EAAE;MAChB;IACJ;IAEA,MAAM,IAAIC,+BAAkB,CAAC;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,gCAA+BJ,MAAM,CAACd,KAAK,CAACY,EAAG;MAC5D;IACJ,CAAC,CAAC;EACN;AACJ;AAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AppPermissions, AppPermissionsParams } from "@webiny/api-security";
|
|
2
|
+
import { CmsGroupPermission, CmsModel, CmsModelPermission } from "../../types";
|
|
3
|
+
import { ModelGroupsPermissions } from "./ModelGroupsPermissions";
|
|
4
|
+
export interface ModelsPermissionsParams extends AppPermissionsParams<CmsGroupPermission> {
|
|
5
|
+
modelGroupsPermissions: ModelGroupsPermissions;
|
|
6
|
+
}
|
|
7
|
+
export interface CanAccessModelParams {
|
|
8
|
+
model: CmsModel;
|
|
9
|
+
locale: string;
|
|
10
|
+
}
|
|
11
|
+
export interface EnsureModelAccessParams {
|
|
12
|
+
model: CmsModel;
|
|
13
|
+
locale: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class ModelsPermissions extends AppPermissions<CmsModelPermission> {
|
|
16
|
+
private modelGroupsPermissions;
|
|
17
|
+
constructor(params: ModelsPermissionsParams);
|
|
18
|
+
canAccessModel({ model, locale }: CanAccessModelParams): Promise<boolean>;
|
|
19
|
+
ensureCanAccessModel(params: EnsureModelAccessParams): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ModelsPermissions = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _apiSecurity = require("@webiny/api-security");
|
|
10
|
+
class ModelsPermissions extends _apiSecurity.AppPermissions {
|
|
11
|
+
constructor(params) {
|
|
12
|
+
super(params);
|
|
13
|
+
(0, _defineProperty2.default)(this, "modelGroupsPermissions", void 0);
|
|
14
|
+
this.modelGroupsPermissions = params.modelGroupsPermissions;
|
|
15
|
+
}
|
|
16
|
+
async canAccessModel({
|
|
17
|
+
model,
|
|
18
|
+
locale
|
|
19
|
+
}) {
|
|
20
|
+
if (await this.hasFullAccess()) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
const modelGroupsPermissions = this.modelGroupsPermissions;
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line
|
|
26
|
+
const modelsPermissions = this;
|
|
27
|
+
const canReadGroups = await modelGroupsPermissions.ensure({
|
|
28
|
+
rwd: "r"
|
|
29
|
+
}, {
|
|
30
|
+
throw: false
|
|
31
|
+
});
|
|
32
|
+
if (!canReadGroups) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const canReadModels = await modelsPermissions.ensure({
|
|
36
|
+
rwd: "r"
|
|
37
|
+
}, {
|
|
38
|
+
throw: false
|
|
39
|
+
});
|
|
40
|
+
if (!canReadModels) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const modelGroupsPermissionsList = await modelGroupsPermissions.getPermissions();
|
|
44
|
+
const modelsPermissionsList = await this.getPermissions();
|
|
45
|
+
for (let i = 0; i < modelGroupsPermissionsList.length; i++) {
|
|
46
|
+
const modelGroupPermission = modelGroupsPermissionsList[i];
|
|
47
|
+
const {
|
|
48
|
+
groups
|
|
49
|
+
} = modelGroupPermission;
|
|
50
|
+
for (let j = 0; j < modelsPermissionsList.length; j++) {
|
|
51
|
+
const modelPermission = modelsPermissionsList[j];
|
|
52
|
+
const {
|
|
53
|
+
models
|
|
54
|
+
} = modelPermission;
|
|
55
|
+
// when no models or groups defined on permission
|
|
56
|
+
// it means user has access to everything
|
|
57
|
+
if (!models && !groups) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Does the model belong to a group for which user has permission?
|
|
62
|
+
if (groups) {
|
|
63
|
+
if (Array.isArray(groups[locale]) === false || groups[locale].includes(model.group.id) === false) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Does the user have access to the specific model?
|
|
69
|
+
if (models) {
|
|
70
|
+
if (Array.isArray(models[locale]) === false || models[locale].includes(model.modelId) === false) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
async ensureCanAccessModel(params) {
|
|
80
|
+
const canAccessModel = await this.canAccessModel(params);
|
|
81
|
+
if (canAccessModel) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
85
|
+
data: {
|
|
86
|
+
reason: `Not allowed to access model "${params.model.modelId}".`
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.ModelsPermissions = ModelsPermissions;
|