@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createApiName","name","upperFirst","camelCase","createPluralApiName","pluralize","CmsModelPlugin","Plugin","constructor","contentModel","options","buildModel","input","isPrivate","singularApiName","pluralApiName","noValidate","model","fields","buildFields","validateLayout","inputFields","length","WebinyError","modelId","storageIdList","fieldIdList","fieldId","trim","field","lodashCamelCase","match","includes","storageId","createFieldStorageId","settings","childFields","type","push","total","row","layout","count","filter","cell","id","createCmsModel"],"sources":["CmsModelPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport lodashCamelCase from \"lodash/camelCase\";\nimport camelCase from \"lodash/camelCase\";\nimport upperFirst from \"lodash/upperFirst\";\nimport pluralize from \"pluralize\";\nimport { Plugin } from \"@webiny/plugins\";\nimport {\n CmsModel as CmsModelBase,\n CmsModelField as CmsModelFieldBase,\n CmsModelFieldSettings as BaseCmsModelFieldSettings\n} from \"~/types\";\nimport { createFieldStorageId } from \"~/crud/contentModel/createFieldStorageId\";\n\nconst createApiName = (name: string) => {\n return upperFirst(camelCase(name));\n};\n\nconst createPluralApiName = (name: string) => {\n return pluralize(createApiName(name));\n};\n\ninterface CmsModelFieldSettings extends Omit<BaseCmsModelFieldSettings, \"fields\"> {\n /**\n * Object field has child fields.\n */\n fields?: CmsModelFieldInput[];\n}\n\ninterface CmsModelFieldInput extends Omit<CmsModelFieldBase, \"storageId\" | \"settings\"> {\n /**\n * If defined, it must be camelCased string.\n * This is for backwards compatibility - before fields had storageId.\n *\n * This should only be populated in old model fields.\n * News ones must have this empty.\n */\n storageId?: string;\n /**\n * We must have a possibility to have a nested field defined without the storageId.\n */\n settings?: CmsModelFieldSettings;\n}\n\nexport interface CmsApiModel\n extends Omit<CmsModel, \"isPrivate\" | \"fields\" | \"singularApiName\" | \"pluralApiName\"> {\n isPrivate?: never;\n noValidate?: never;\n singularApiName?: string;\n pluralApiName?: string;\n fields: CmsModelFieldInput[];\n}\n\nexport interface CmsApiModelFull extends Omit<CmsApiModel, \"fields\" | \"noValidate\"> {\n noValidate: true;\n fields: CmsModelFieldBase[];\n}\n\ninterface CmsPrivateModel\n extends Omit<CmsModel, \"isPrivate\" | \"singularApiName\" | \"pluralApiName\" | \"fields\"> {\n noValidate?: never;\n singularApiName?: never;\n pluralApiName?: never;\n isPrivate: true;\n fields: CmsModelFieldInput[];\n}\n\nexport interface CmsPrivateModelFull extends Omit<CmsPrivateModel, \"fields\" | \"noValidate\"> {\n fields: CmsModelFieldBase[];\n noValidate: true;\n}\n\nexport type CmsModelInput = CmsApiModel | CmsPrivateModel | CmsApiModelFull | CmsPrivateModelFull;\n\ninterface CmsModel extends Omit<CmsModelBase, \"locale\" | \"tenant\" | \"webinyVersion\"> {\n locale?: string;\n tenant?: string;\n}\n\ninterface CmsModelPluginOptions {\n validateLayout?: boolean;\n}\n\nexport class CmsModelPlugin extends Plugin {\n public static override readonly type: string = \"cms-content-model\";\n public readonly contentModel: CmsModel;\n\n private readonly options: CmsModelPluginOptions;\n\n constructor(contentModel: CmsModelInput, options?: CmsModelPluginOptions) {\n super();\n this.options = options || {};\n this.contentModel = this.buildModel(contentModel);\n }\n\n private buildModel(input: CmsModelInput): CmsModel {\n const isPrivate = input.isPrivate || false;\n const singularApiName = input.singularApiName\n ? createApiName(input.singularApiName)\n : createApiName(input.name);\n const pluralApiName = input.pluralApiName\n ? createApiName(input.pluralApiName)\n : createPluralApiName(input.name);\n\n if (input.noValidate) {\n /**\n * We can safely ignore this error, because we are sure noValidate is not a model field.\n */\n // @ts-ignore\n delete input[\"noValidate\"];\n return {\n ...input,\n isPrivate,\n singularApiName,\n pluralApiName\n };\n }\n\n const model: CmsModel = {\n ...input,\n isPrivate,\n singularApiName,\n pluralApiName,\n fields: this.buildFields(input, input.fields)\n };\n this.validateLayout(model);\n return model;\n }\n\n private buildFields(\n model: CmsModelInput,\n inputFields: CmsModelFieldInput[]\n ): CmsModelFieldBase[] {\n if (inputFields.length === 0) {\n throw new WebinyError(\n `Missing fields for the defined model \"${model.modelId}\".`,\n \"MISSING_FIELDS\",\n {\n model\n }\n );\n }\n const fields: CmsModelFieldBase[] = [];\n const storageIdList: string[] = [];\n const fieldIdList: string[] = [];\n for (const input of inputFields) {\n /**\n * Field must contain an fieldId. It is required in the graphql, but lets check it just in case\n */\n if (!(input.fieldId || \"\").trim()) {\n throw new WebinyError(\n `Field's \"storageId\" is not defined for the content model \"${model.modelId}\".`,\n \"FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n const fieldId = lodashCamelCase(input.fieldId);\n /**\n * FieldID must be in correct pattern.\n */\n if (fieldId.match(/^[0-9]/) !== null) {\n throw new WebinyError(\n `Field's \"fieldId\" does not match correct pattern in the content model \"${model.modelId}\" - cannot start with a number.`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * FieldID also must be camelCased.\n */\n if (fieldId !== input.fieldId) {\n throw new WebinyError(\n `Field's \"fieldId\" must be a camel cased string in the content model \"${model.modelId}\".`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * ... and fieldId must be unique.\n */\n if (fieldIdList.includes(fieldId) === true) {\n throw new WebinyError(\n `Field's \"fieldId\" is not unique in the content model \"${model.modelId}\".`,\n \"FIELD_ID_NOT_UNIQUE_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n let storageId = input.storageId ? lodashCamelCase(input.storageId) : null;\n /**\n * If defined, storageId MUST be camel cased string - for backward compatibility.\n */\n if (\n storageId &&\n (storageId.match(/^([a-zA-Z-0-9]+)$/) === null || storageId !== input.storageId)\n ) {\n throw new WebinyError(\n `Field's \"storageId\" of the field with \"fieldId\" ${input.fieldId} is not camel cased string in the content model \"${model.modelId}\".`,\n \"STORAGE_ID_NOT_CAMEL_CASED_ERROR\",\n {\n model,\n storageId,\n field: input\n }\n );\n } else if (!storageId) {\n storageId = createFieldStorageId(input);\n }\n\n /**\n * Fields storageId must be unique.\n */\n if (storageIdList.includes(storageId) === true) {\n throw new WebinyError(\n `Field's \"storageId\" is not unique in the content model \"${model.modelId}\".`,\n \"STORAGE_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n /**\n * We can safely ignore error because we are going through the fields and making sure each has storageId.\n */\n // @ts-ignore\n let settings: BaseCmsModelFieldSettings = input.settings;\n\n const childFields = settings?.fields || [];\n if (input.type === \"object\" && childFields.length > 0) {\n settings = {\n ...(settings || {}),\n fields: this.buildFields(model, childFields)\n };\n }\n\n const field: CmsModelFieldBase = {\n ...input,\n settings,\n storageId\n };\n /**\n * Add all relevant data to arrays.\n */\n fields.push(field);\n storageIdList.push(field.storageId);\n fieldIdList.push(field.fieldId);\n }\n return fields;\n }\n\n private validateLayout(model: CmsModel): void {\n /**\n * Only skip validation if option.validateLayout was set as false, explicitly.\n */\n if (this.options.validateLayout === false) {\n return;\n }\n for (const field of model.fields) {\n let total = 0;\n for (const row of model.layout) {\n const count = row.filter(cell => cell === field.id).length;\n total = total + count;\n }\n if (total === 1) {\n continue;\n } else if (total > 1) {\n throw new WebinyError(\n `Field \"${field.id}\" is in more than one layout cell.`,\n \"DUPLICATE_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n throw new WebinyError(\n `Missing field \"${field.id}\" in layout.`,\n \"MISSING_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n }\n}\n\nexport const createCmsModel = (\n model: CmsModelInput,\n options?: CmsModelPluginOptions\n): CmsModelPlugin => {\n return new CmsModelPlugin(model, options);\n};\n"],"mappings":";;;;;;;;;AAAA;AACA;AAEA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;AAC7C,CAAC;AAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { ApiEndpoint, CmsContext } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Type can be null because it might be that Headless CMS context is loaded on a different Lambda where there is no GraphQL Schema generated.
|
|
5
|
+
*/
|
|
6
|
+
export declare type CmsParametersPluginResponseType = ApiEndpoint | null;
|
|
7
|
+
export declare type CmsParametersPluginResponseLocale = string;
|
|
8
|
+
export interface CmsParametersPluginResponse {
|
|
9
|
+
type: CmsParametersPluginResponseType;
|
|
10
|
+
locale: CmsParametersPluginResponseLocale;
|
|
11
|
+
}
|
|
12
|
+
export interface CmsParametersPluginCallable {
|
|
13
|
+
(context: CmsContext): Promise<CmsParametersPluginResponse | null>;
|
|
14
|
+
}
|
|
15
|
+
export declare class CmsParametersPlugin extends Plugin {
|
|
16
|
+
static readonly type: string;
|
|
17
|
+
private readonly callable;
|
|
18
|
+
constructor(callable: CmsParametersPluginCallable);
|
|
19
|
+
getParameters(context: CmsContext): Promise<CmsParametersPluginResponse | null>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.CmsParametersPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _plugins = require("@webiny/plugins");
|
|
10
|
+
class CmsParametersPlugin extends _plugins.Plugin {
|
|
11
|
+
constructor(callable) {
|
|
12
|
+
super();
|
|
13
|
+
(0, _defineProperty2.default)(this, "callable", void 0);
|
|
14
|
+
this.callable = callable;
|
|
15
|
+
}
|
|
16
|
+
async getParameters(context) {
|
|
17
|
+
return this.callable(context);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.CmsParametersPlugin = CmsParametersPlugin;
|
|
21
|
+
(0, _defineProperty2.default)(CmsParametersPlugin, "type", "cms-parameters-plugin");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CmsParametersPlugin","Plugin","constructor","callable","getParameters","context"],"sources":["CmsParametersPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { ApiEndpoint, CmsContext } from \"~/types\";\n\n/**\n * Type can be null because it might be that Headless CMS context is loaded on a different Lambda where there is no GraphQL Schema generated.\n */\nexport type CmsParametersPluginResponseType = ApiEndpoint | null;\nexport type CmsParametersPluginResponseLocale = string;\n\nexport interface CmsParametersPluginResponse {\n type: CmsParametersPluginResponseType;\n locale: CmsParametersPluginResponseLocale;\n}\n\nexport interface CmsParametersPluginCallable {\n (context: CmsContext): Promise<CmsParametersPluginResponse | null>;\n}\n\nexport class CmsParametersPlugin extends Plugin {\n public static override readonly type: string = \"cms-parameters-plugin\";\n\n private readonly callable: CmsParametersPluginCallable;\n\n public constructor(callable: CmsParametersPluginCallable) {\n super();\n\n this.callable = callable;\n }\n\n public async getParameters(context: CmsContext): Promise<CmsParametersPluginResponse | null> {\n return this.callable(context);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAkBO,MAAMA,mBAAmB,SAASC,eAAM,CAAC;EAKrCC,WAAW,CAACC,QAAqC,EAAE;IACtD,KAAK,EAAE;IAAC;IAER,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEA,MAAaC,aAAa,CAACC,OAAmB,EAA+C;IACzF,OAAO,IAAI,CAACF,QAAQ,CAACE,OAAO,CAAC;EACjC;AACJ;AAAC;AAAA,8BAdYL,mBAAmB,UACmB,uBAAuB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { CmsModel, StorageOperationsCmsModel } from "../types";
|
|
3
|
+
export interface StorageOperationsCmsModelPluginCallable {
|
|
4
|
+
(model: CmsModel): StorageOperationsCmsModel;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* This plugin should be initialized only once and hence the name.
|
|
8
|
+
*/
|
|
9
|
+
export declare class StorageOperationsCmsModelPlugin extends Plugin {
|
|
10
|
+
static readonly type: string;
|
|
11
|
+
name: string;
|
|
12
|
+
private readonly models;
|
|
13
|
+
private readonly cb;
|
|
14
|
+
constructor(cb: StorageOperationsCmsModelPluginCallable);
|
|
15
|
+
getModel(input: CmsModel): StorageOperationsCmsModel;
|
|
16
|
+
/**
|
|
17
|
+
* We can cache the converters by having a cache key that is a combination of model ID and savedOn.
|
|
18
|
+
* The models created via the code will not have savedOn, so they will be unknown - and that is ok as they cannot change in the middle of the call.
|
|
19
|
+
*
|
|
20
|
+
* The models created via the CRUD operations might get changed in the middle of the call, so we need to re-create the SO model.
|
|
21
|
+
*/
|
|
22
|
+
private createCacheKey;
|
|
23
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.StorageOperationsCmsModelPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _plugins = require("@webiny/plugins");
|
|
10
|
+
/**
|
|
11
|
+
* This plugin should be initialized only once and hence the name.
|
|
12
|
+
*/
|
|
13
|
+
class StorageOperationsCmsModelPlugin extends _plugins.Plugin {
|
|
14
|
+
constructor(cb) {
|
|
15
|
+
super();
|
|
16
|
+
(0, _defineProperty2.default)(this, "name", "cms.storageOperations.model");
|
|
17
|
+
(0, _defineProperty2.default)(this, "models", {});
|
|
18
|
+
(0, _defineProperty2.default)(this, "cb", void 0);
|
|
19
|
+
this.cb = cb;
|
|
20
|
+
}
|
|
21
|
+
getModel(input) {
|
|
22
|
+
const cacheKey = this.createCacheKey(input);
|
|
23
|
+
if (this.models[cacheKey]) {
|
|
24
|
+
return this.models[cacheKey];
|
|
25
|
+
}
|
|
26
|
+
const model = this.cb(input);
|
|
27
|
+
this.models[cacheKey] = model;
|
|
28
|
+
return model;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* We can cache the converters by having a cache key that is a combination of model ID and savedOn.
|
|
33
|
+
* The models created via the code will not have savedOn, so they will be unknown - and that is ok as they cannot change in the middle of the call.
|
|
34
|
+
*
|
|
35
|
+
* The models created via the CRUD operations might get changed in the middle of the call, so we need to re-create the SO model.
|
|
36
|
+
*/
|
|
37
|
+
createCacheKey(model) {
|
|
38
|
+
return [model.tenant, model.locale, model.modelId, model.savedOn || "unknown"].join("#");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.StorageOperationsCmsModelPlugin = StorageOperationsCmsModelPlugin;
|
|
42
|
+
(0, _defineProperty2.default)(StorageOperationsCmsModelPlugin, "type", "cms.storageOperations.model");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["StorageOperationsCmsModelPlugin","Plugin","constructor","cb","getModel","input","cacheKey","createCacheKey","models","model","tenant","locale","modelId","savedOn","join"],"sources":["StorageOperationsCmsModelPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsModel, StorageOperationsCmsModel } from \"~/types\";\n\nexport interface StorageOperationsCmsModelPluginCallable {\n (model: CmsModel): StorageOperationsCmsModel;\n}\n\n/**\n * This plugin should be initialized only once and hence the name.\n */\nexport class StorageOperationsCmsModelPlugin extends Plugin {\n public static override readonly type: string = \"cms.storageOperations.model\";\n public override name = \"cms.storageOperations.model\";\n\n private readonly models: Record<string, StorageOperationsCmsModel> = {};\n private readonly cb: StorageOperationsCmsModelPluginCallable;\n\n public constructor(cb: StorageOperationsCmsModelPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public getModel(input: CmsModel) {\n const cacheKey = this.createCacheKey(input);\n if (this.models[cacheKey]) {\n return this.models[cacheKey];\n }\n const model = this.cb(input);\n\n this.models[cacheKey] = model;\n\n return model;\n }\n\n /**\n * We can cache the converters by having a cache key that is a combination of model ID and savedOn.\n * The models created via the code will not have savedOn, so they will be unknown - and that is ok as they cannot change in the middle of the call.\n *\n * The models created via the CRUD operations might get changed in the middle of the call, so we need to re-create the SO model.\n */\n private createCacheKey(model: CmsModel): string {\n return [model.tenant, model.locale, model.modelId, model.savedOn || \"unknown\"].join(\"#\");\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAOA;AACA;AACA;AACO,MAAMA,+BAA+B,SAASC,eAAM,CAAC;EAOjDC,WAAW,CAACC,EAA2C,EAAE;IAC5D,KAAK,EAAE;IAAC,4CANW,6BAA6B;IAAA,8CAEiB,CAAC,CAAC;IAAA;IAKnE,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEOC,QAAQ,CAACC,KAAe,EAAE;IAC7B,MAAMC,QAAQ,GAAG,IAAI,CAACC,cAAc,CAACF,KAAK,CAAC;IAC3C,IAAI,IAAI,CAACG,MAAM,CAACF,QAAQ,CAAC,EAAE;MACvB,OAAO,IAAI,CAACE,MAAM,CAACF,QAAQ,CAAC;IAChC;IACA,MAAMG,KAAK,GAAG,IAAI,CAACN,EAAE,CAACE,KAAK,CAAC;IAE5B,IAAI,CAACG,MAAM,CAACF,QAAQ,CAAC,GAAGG,KAAK;IAE7B,OAAOA,KAAK;EAChB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACYF,cAAc,CAACE,KAAe,EAAU;IAC5C,OAAO,CAACA,KAAK,CAACC,MAAM,EAAED,KAAK,CAACE,MAAM,EAAEF,KAAK,CAACG,OAAO,EAAEH,KAAK,CAACI,OAAO,IAAI,SAAS,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;EAC5F;AACJ;AAAC;AAAA,8BAjCYd,+BAA+B,UACO,6BAA6B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
+
import { CmsModel, CmsModelField } from "../types";
|
|
3
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
+
export interface ToStorageParams<T, F extends CmsModelField> {
|
|
5
|
+
model: CmsModel;
|
|
6
|
+
field: F;
|
|
7
|
+
value: T;
|
|
8
|
+
getStoragePlugin(fieldType: string): StorageTransformPlugin<T>;
|
|
9
|
+
plugins: PluginsContainer;
|
|
10
|
+
}
|
|
11
|
+
export interface FromStorageParams<T, F extends CmsModelField> {
|
|
12
|
+
model: CmsModel;
|
|
13
|
+
field: Partial<F> & Pick<F, "id" | "fieldId" | "storageId" | "type" | "settings">;
|
|
14
|
+
value: T;
|
|
15
|
+
getStoragePlugin(fieldType: string): StorageTransformPlugin<T>;
|
|
16
|
+
plugins: PluginsContainer;
|
|
17
|
+
}
|
|
18
|
+
export interface StorageTransformPluginParams<T, R, F extends CmsModelField> {
|
|
19
|
+
name?: string;
|
|
20
|
+
fieldType: string;
|
|
21
|
+
toStorage: (params: ToStorageParams<T, F>) => Promise<R>;
|
|
22
|
+
fromStorage: (params: FromStorageParams<R, F>) => Promise<T>;
|
|
23
|
+
}
|
|
24
|
+
export declare class StorageTransformPlugin<T = any, R = any, F extends CmsModelField = CmsModelField> extends Plugin {
|
|
25
|
+
static readonly type: string;
|
|
26
|
+
get fieldType(): string;
|
|
27
|
+
private readonly config;
|
|
28
|
+
constructor(config: StorageTransformPluginParams<T, R, F>);
|
|
29
|
+
toStorage(params: ToStorageParams<T, F>): Promise<R>;
|
|
30
|
+
fromStorage(params: FromStorageParams<R, F>): Promise<T>;
|
|
31
|
+
}
|
|
@@ -1,36 +1,28 @@
|
|
|
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.StorageTransformPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _Plugin = require("@webiny/plugins/Plugin");
|
|
13
|
-
|
|
14
10
|
class StorageTransformPlugin extends _Plugin.Plugin {
|
|
15
11
|
get fieldType() {
|
|
16
12
|
return this.config.fieldType;
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
constructor(config) {
|
|
20
15
|
super();
|
|
21
16
|
(0, _defineProperty2.default)(this, "config", void 0);
|
|
17
|
+
this.name = config.name;
|
|
22
18
|
this.config = config;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
toStorage(params) {
|
|
26
21
|
return this.config.toStorage(params);
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
fromStorage(params) {
|
|
30
24
|
return this.config.fromStorage(params);
|
|
31
25
|
}
|
|
32
|
-
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
exports.StorageTransformPlugin = StorageTransformPlugin;
|
|
36
28
|
(0, _defineProperty2.default)(StorageTransformPlugin, "type", "cms.storage.transform.plugin");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["StorageTransformPlugin","Plugin","fieldType","config","constructor","name","toStorage","params","fromStorage"],"sources":["StorageTransformPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { CmsModel, CmsModelField } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport interface ToStorageParams<T, F extends CmsModelField> {\n model: CmsModel;\n field: F;\n value: T;\n getStoragePlugin(fieldType: string): StorageTransformPlugin<T>;\n plugins: PluginsContainer;\n}\n\nexport interface FromStorageParams<T, F extends CmsModelField> {\n model: CmsModel;\n field: Partial<F> & Pick<F, \"id\" | \"fieldId\" | \"storageId\" | \"type\" | \"settings\">;\n value: T;\n getStoragePlugin(fieldType: string): StorageTransformPlugin<T>;\n plugins: PluginsContainer;\n}\n\nexport interface StorageTransformPluginParams<T, R, F extends CmsModelField> {\n name?: string;\n fieldType: string;\n toStorage: (params: ToStorageParams<T, F>) => Promise<R>;\n fromStorage: (params: FromStorageParams<R, F>) => Promise<T>;\n}\nexport class StorageTransformPlugin<\n T = any,\n R = any,\n F extends CmsModelField = CmsModelField\n> extends Plugin {\n public static override readonly type: string = \"cms.storage.transform.plugin\";\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n private readonly config: StorageTransformPluginParams<T, R, F>;\n\n public constructor(config: StorageTransformPluginParams<T, R, F>) {\n super();\n this.name = config.name;\n this.config = config;\n }\n\n public toStorage(params: ToStorageParams<T, F>): Promise<R> {\n return this.config.toStorage(params);\n }\n\n public fromStorage(params: FromStorageParams<R, F>): Promise<T> {\n return this.config.fromStorage(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AA0BO,MAAMA,sBAAsB,SAIzBC,cAAM,CAAC;EAEb,IAAWC,SAAS,GAAW;IAC3B,OAAO,IAAI,CAACC,MAAM,CAACD,SAAS;EAChC;EAIOE,WAAW,CAACD,MAA6C,EAAE;IAC9D,KAAK,EAAE;IAAC;IACR,IAAI,CAACE,IAAI,GAAGF,MAAM,CAACE,IAAI;IACvB,IAAI,CAACF,MAAM,GAAGA,MAAM;EACxB;EAEOG,SAAS,CAACC,MAA6B,EAAc;IACxD,OAAO,IAAI,CAACJ,MAAM,CAACG,SAAS,CAACC,MAAM,CAAC;EACxC;EAEOC,WAAW,CAACD,MAA+B,EAAc;IAC5D,OAAO,IAAI,CAACJ,MAAM,CAACK,WAAW,CAACD,MAAM,CAAC;EAC1C;AACJ;AAAC;AAAA,8BAzBYP,sBAAsB,UAKgB,8BAA8B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./CmsGroupPlugin";
|
|
2
|
+
export * from "./CmsModelPlugin";
|
|
3
|
+
export * from "./StorageTransformPlugin";
|
|
4
|
+
export * from "./CmsParametersPlugin";
|
|
5
|
+
export * from "./CmsModelFieldConverterPlugin";
|
|
6
|
+
export * from "./CmsGraphQLSchemaPlugin";
|
|
7
|
+
export * from "./CmsGraphQLSchemaSorterPlugin";
|
|
8
|
+
export * from "./StorageOperationsCmsModelPlugin";
|
package/plugins/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _CmsGroupPlugin = require("./CmsGroupPlugin");
|
|
7
|
+
Object.keys(_CmsGroupPlugin).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _CmsGroupPlugin[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _CmsGroupPlugin[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _CmsModelPlugin = require("./CmsModelPlugin");
|
|
18
|
+
Object.keys(_CmsModelPlugin).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _CmsModelPlugin[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _CmsModelPlugin[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _StorageTransformPlugin = require("./StorageTransformPlugin");
|
|
29
|
+
Object.keys(_StorageTransformPlugin).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _StorageTransformPlugin[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _StorageTransformPlugin[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _CmsParametersPlugin = require("./CmsParametersPlugin");
|
|
40
|
+
Object.keys(_CmsParametersPlugin).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _CmsParametersPlugin[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _CmsParametersPlugin[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _CmsModelFieldConverterPlugin = require("./CmsModelFieldConverterPlugin");
|
|
51
|
+
Object.keys(_CmsModelFieldConverterPlugin).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _CmsModelFieldConverterPlugin[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _CmsModelFieldConverterPlugin[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _CmsGraphQLSchemaPlugin = require("./CmsGraphQLSchemaPlugin");
|
|
62
|
+
Object.keys(_CmsGraphQLSchemaPlugin).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _CmsGraphQLSchemaPlugin[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _CmsGraphQLSchemaPlugin[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _CmsGraphQLSchemaSorterPlugin = require("./CmsGraphQLSchemaSorterPlugin");
|
|
73
|
+
Object.keys(_CmsGraphQLSchemaSorterPlugin).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _CmsGraphQLSchemaSorterPlugin[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _CmsGraphQLSchemaSorterPlugin[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _StorageOperationsCmsModelPlugin = require("./StorageOperationsCmsModelPlugin");
|
|
84
|
+
Object.keys(_StorageOperationsCmsModelPlugin).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _StorageOperationsCmsModelPlugin[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _StorageOperationsCmsModelPlugin[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./CmsGroupPlugin\";\nexport * from \"./CmsModelPlugin\";\nexport * from \"./StorageTransformPlugin\";\nexport * from \"./CmsParametersPlugin\";\nexport * from \"./CmsModelFieldConverterPlugin\";\nexport * from \"./CmsGraphQLSchemaPlugin\";\nexport * from \"./CmsGraphQLSchemaSorterPlugin\";\nexport * from \"./StorageOperationsCmsModelPlugin\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createDefaultStorageTransform = void 0;
|
|
7
|
+
var _StorageTransformPlugin = require("../plugins/StorageTransformPlugin");
|
|
8
|
+
const createDefaultStorageTransform = () => {
|
|
9
|
+
return new _StorageTransformPlugin.StorageTransformPlugin({
|
|
10
|
+
name: "headless-cms.storage-transform.all.default",
|
|
11
|
+
fieldType: "*",
|
|
12
|
+
fromStorage: async ({
|
|
13
|
+
value
|
|
14
|
+
}) => {
|
|
15
|
+
return value;
|
|
16
|
+
},
|
|
17
|
+
toStorage: async ({
|
|
18
|
+
value
|
|
19
|
+
}) => {
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
exports.createDefaultStorageTransform = createDefaultStorageTransform;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createDefaultStorageTransform","StorageTransformPlugin","name","fieldType","fromStorage","value","toStorage"],"sources":["default.ts"],"sourcesContent":["import { StorageTransformPlugin } from \"~/plugins/StorageTransformPlugin\";\n\nexport const createDefaultStorageTransform = (): StorageTransformPlugin => {\n return new StorageTransformPlugin({\n name: \"headless-cms.storage-transform.all.default\",\n fieldType: \"*\",\n fromStorage: async ({ value }) => {\n return value;\n },\n toStorage: async ({ value }) => {\n return value;\n }\n });\n};\n"],"mappings":";;;;;;AAAA;AAEO,MAAMA,6BAA6B,GAAG,MAA8B;EACvE,OAAO,IAAIC,8CAAsB,CAAC;IAC9BC,IAAI,EAAE,4CAA4C;IAClDC,SAAS,EAAE,GAAG;IACdC,WAAW,EAAE,OAAO;MAAEC;IAAM,CAAC,KAAK;MAC9B,OAAOA,KAAK;IAChB,CAAC;IACDC,SAAS,EAAE,OAAO;MAAED;IAAM,CAAC,KAAK;MAC5B,OAAOA,KAAK;IAChB;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createObjectStorageTransform = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _pReduce = _interopRequireDefault(require("p-reduce"));
|
|
10
|
+
var _pMap = _interopRequireDefault(require("p-map"));
|
|
11
|
+
var _StorageTransformPlugin = require("../plugins/StorageTransformPlugin");
|
|
12
|
+
var _getBaseFieldType = require("../utils/getBaseFieldType");
|
|
13
|
+
const processValue = async params => {
|
|
14
|
+
const {
|
|
15
|
+
fields,
|
|
16
|
+
sourceValue,
|
|
17
|
+
getStoragePlugin,
|
|
18
|
+
plugins,
|
|
19
|
+
model,
|
|
20
|
+
operation
|
|
21
|
+
} = params;
|
|
22
|
+
return await (0, _pReduce.default)(fields, async (values, field) => {
|
|
23
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
24
|
+
const plugin = getStoragePlugin(baseType);
|
|
25
|
+
if (!plugin) {
|
|
26
|
+
throw new Error(`Missing storage plugin for field type "${baseType}".`);
|
|
27
|
+
}
|
|
28
|
+
const value = await plugin[operation]({
|
|
29
|
+
plugins,
|
|
30
|
+
model,
|
|
31
|
+
field,
|
|
32
|
+
value: sourceValue[field.fieldId],
|
|
33
|
+
getStoragePlugin
|
|
34
|
+
});
|
|
35
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, values), {}, {
|
|
36
|
+
[field.fieldId]: value
|
|
37
|
+
});
|
|
38
|
+
}, {});
|
|
39
|
+
};
|
|
40
|
+
const createObjectStorageTransform = () => {
|
|
41
|
+
return new _StorageTransformPlugin.StorageTransformPlugin({
|
|
42
|
+
name: "headless-cms.storage-transform.object.default",
|
|
43
|
+
fieldType: "object",
|
|
44
|
+
toStorage: async ({
|
|
45
|
+
field,
|
|
46
|
+
value,
|
|
47
|
+
getStoragePlugin,
|
|
48
|
+
model,
|
|
49
|
+
plugins
|
|
50
|
+
}) => {
|
|
51
|
+
var _field$settings;
|
|
52
|
+
if (!value) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const fields = ((_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.fields) || [];
|
|
56
|
+
if (field.multipleValues) {
|
|
57
|
+
return await (0, _pMap.default)(value, value => processValue({
|
|
58
|
+
sourceValue: value,
|
|
59
|
+
getStoragePlugin,
|
|
60
|
+
model,
|
|
61
|
+
plugins,
|
|
62
|
+
operation: "toStorage",
|
|
63
|
+
fields
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
return await processValue({
|
|
67
|
+
sourceValue: value,
|
|
68
|
+
getStoragePlugin,
|
|
69
|
+
model,
|
|
70
|
+
plugins,
|
|
71
|
+
operation: "toStorage",
|
|
72
|
+
fields
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
fromStorage: async ({
|
|
76
|
+
field,
|
|
77
|
+
value,
|
|
78
|
+
getStoragePlugin,
|
|
79
|
+
plugins,
|
|
80
|
+
model
|
|
81
|
+
}) => {
|
|
82
|
+
var _field$settings2;
|
|
83
|
+
if (!value) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const fields = ((_field$settings2 = field.settings) === null || _field$settings2 === void 0 ? void 0 : _field$settings2.fields) || [];
|
|
87
|
+
if (field.multipleValues) {
|
|
88
|
+
return (0, _pMap.default)(value, value => processValue({
|
|
89
|
+
sourceValue: value,
|
|
90
|
+
getStoragePlugin,
|
|
91
|
+
model,
|
|
92
|
+
plugins,
|
|
93
|
+
operation: "fromStorage",
|
|
94
|
+
fields
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
return processValue({
|
|
98
|
+
sourceValue: value,
|
|
99
|
+
getStoragePlugin,
|
|
100
|
+
model,
|
|
101
|
+
plugins,
|
|
102
|
+
operation: "fromStorage",
|
|
103
|
+
fields
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
exports.createObjectStorageTransform = createObjectStorageTransform;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["processValue","params","fields","sourceValue","getStoragePlugin","plugins","model","operation","pReduce","values","field","baseType","getBaseFieldType","plugin","Error","value","fieldId","createObjectStorageTransform","StorageTransformPlugin","name","fieldType","toStorage","settings","multipleValues","pMap","fromStorage"],"sources":["object.ts"],"sourcesContent":["import pReduce from \"p-reduce\";\nimport pMap from \"p-map\";\nimport { CmsModel, CmsModelField } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { StorageTransformPlugin } from \"~/plugins/StorageTransformPlugin\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface ProcessValueParams {\n fields: CmsModelField[];\n sourceValue: Record<string, any>;\n getStoragePlugin: (fieldType: string) => StorageTransformPlugin;\n plugins: PluginsContainer;\n model: CmsModel;\n operation: \"toStorage\" | \"fromStorage\";\n}\ninterface ProcessValue {\n (params: ProcessValueParams): Promise<Record<string, any>>;\n}\n\nconst processValue: ProcessValue = async params => {\n const { fields, sourceValue, getStoragePlugin, plugins, model, operation } = params;\n return await pReduce(\n fields,\n async (values, field) => {\n const baseType = getBaseFieldType(field);\n const plugin = getStoragePlugin(baseType);\n if (!plugin) {\n throw new Error(`Missing storage plugin for field type \"${baseType}\".`);\n }\n const value = await plugin[operation]({\n plugins,\n model,\n field,\n value: sourceValue[field.fieldId],\n getStoragePlugin\n });\n return { ...values, [field.fieldId]: value };\n },\n {}\n );\n};\n\nexport const createObjectStorageTransform = (): StorageTransformPlugin => {\n return new StorageTransformPlugin({\n name: \"headless-cms.storage-transform.object.default\",\n fieldType: \"object\",\n toStorage: async ({ field, value, getStoragePlugin, model, plugins }) => {\n if (!value) {\n return null;\n }\n\n const fields = (field.settings?.fields || []) as CmsModelField[];\n\n if (field.multipleValues) {\n return await pMap(value as Record<string, any>[], value =>\n processValue({\n sourceValue: value,\n getStoragePlugin,\n model,\n plugins,\n operation: \"toStorage\",\n fields\n })\n );\n }\n\n return await processValue({\n sourceValue: value,\n getStoragePlugin,\n model,\n plugins,\n operation: \"toStorage\",\n fields\n });\n },\n fromStorage: async ({ field, value, getStoragePlugin, plugins, model }) => {\n if (!value) {\n return null;\n }\n\n const fields = (field.settings?.fields || []) as CmsModelField[];\n\n if (field.multipleValues) {\n return pMap(value as Record<string, any>[], value =>\n processValue({\n sourceValue: value,\n getStoragePlugin,\n model,\n plugins,\n operation: \"fromStorage\",\n fields\n })\n );\n }\n\n return processValue({\n sourceValue: value,\n getStoragePlugin,\n model,\n plugins,\n operation: \"fromStorage\",\n fields\n });\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AAGA;AACA;AAcA,MAAMA,YAA0B,GAAG,MAAMC,MAAM,IAAI;EAC/C,MAAM;IAAEC,MAAM;IAAEC,WAAW;IAAEC,gBAAgB;IAAEC,OAAO;IAAEC,KAAK;IAAEC;EAAU,CAAC,GAAGN,MAAM;EACnF,OAAO,MAAM,IAAAO,gBAAO,EAChBN,MAAM,EACN,OAAOO,MAAM,EAAEC,KAAK,KAAK;IACrB,MAAMC,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,MAAMG,MAAM,GAAGT,gBAAgB,CA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