@webiny/api-headless-cms 0.0.0-ee-vpcs.549378cf03
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/LICENSE +21 -0
- package/README.md +73 -0
- package/context.d.ts +3 -0
- package/context.js +60 -0
- package/context.js.map +1 -0
- package/crud/contentEntry/afterDelete.d.ts +8 -0
- package/crud/contentEntry/afterDelete.js +41 -0
- package/crud/contentEntry/afterDelete.js.map +1 -0
- package/crud/contentEntry/beforeCreate.d.ts +8 -0
- package/crud/contentEntry/beforeCreate.js +28 -0
- package/crud/contentEntry/beforeCreate.js.map +1 -0
- package/crud/contentEntry/beforeUpdate.d.ts +8 -0
- package/crud/contentEntry/beforeUpdate.js +28 -0
- package/crud/contentEntry/beforeUpdate.js.map +1 -0
- package/crud/contentEntry/entryDataValidation.d.ts +10 -0
- package/crud/contentEntry/entryDataValidation.js +200 -0
- package/crud/contentEntry/entryDataValidation.js.map +1 -0
- package/crud/contentEntry/markLockedFields.d.ts +13 -0
- package/crud/contentEntry/markLockedFields.js +116 -0
- package/crud/contentEntry/markLockedFields.js.map +1 -0
- package/crud/contentEntry/referenceFieldsMapping.d.ts +13 -0
- package/crud/contentEntry/referenceFieldsMapping.js +292 -0
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -0
- package/crud/contentEntry/searchableFields.d.ts +9 -0
- package/crud/contentEntry/searchableFields.js +83 -0
- package/crud/contentEntry/searchableFields.js.map +1 -0
- package/crud/contentEntry.crud.d.ts +13 -0
- package/crud/contentEntry.crud.js +1277 -0
- package/crud/contentEntry.crud.js.map +1 -0
- package/crud/contentModel/afterCreate.d.ts +8 -0
- package/crud/contentModel/afterCreate.js +18 -0
- package/crud/contentModel/afterCreate.js.map +1 -0
- package/crud/contentModel/afterCreateFrom.d.ts +8 -0
- package/crud/contentModel/afterCreateFrom.js +18 -0
- package/crud/contentModel/afterCreateFrom.js.map +1 -0
- package/crud/contentModel/afterDelete.d.ts +8 -0
- package/crud/contentModel/afterDelete.js +18 -0
- package/crud/contentModel/afterDelete.js.map +1 -0
- package/crud/contentModel/afterUpdate.d.ts +8 -0
- package/crud/contentModel/afterUpdate.js +18 -0
- package/crud/contentModel/afterUpdate.js.map +1 -0
- package/crud/contentModel/beforeCreate.d.ts +15 -0
- package/crud/contentModel/beforeCreate.js +194 -0
- package/crud/contentModel/beforeCreate.js.map +1 -0
- package/crud/contentModel/beforeDelete.d.ts +10 -0
- package/crud/contentModel/beforeDelete.js +60 -0
- package/crud/contentModel/beforeDelete.js.map +1 -0
- package/crud/contentModel/beforeUpdate.d.ts +10 -0
- package/crud/contentModel/beforeUpdate.js +37 -0
- package/crud/contentModel/beforeUpdate.js.map +1 -0
- package/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
- package/crud/contentModel/contentModelManagerFactory.js +29 -0
- package/crud/contentModel/contentModelManagerFactory.js.map +1 -0
- package/crud/contentModel/createFieldModels.d.ts +2 -0
- package/crud/contentModel/createFieldModels.js +26 -0
- package/crud/contentModel/createFieldModels.js.map +1 -0
- package/crud/contentModel/createFieldStorageId.d.ts +2 -0
- package/crud/contentModel/createFieldStorageId.js +20 -0
- package/crud/contentModel/createFieldStorageId.js.map +1 -0
- package/crud/contentModel/fieldIdValidation.d.ts +1 -0
- package/crud/contentModel/fieldIdValidation.js +25 -0
- package/crud/contentModel/fieldIdValidation.js.map +1 -0
- package/crud/contentModel/idValidation.d.ts +1 -0
- package/crud/contentModel/idValidation.js +22 -0
- package/crud/contentModel/idValidation.js.map +1 -0
- package/crud/contentModel/models.d.ts +4 -0
- package/crud/contentModel/models.js +192 -0
- package/crud/contentModel/models.js.map +1 -0
- package/crud/contentModel/systemFields.d.ts +1 -0
- package/crud/contentModel/systemFields.js +8 -0
- package/crud/contentModel/systemFields.js.map +1 -0
- package/crud/contentModel/validateLayout.d.ts +2 -0
- package/crud/contentModel/validateLayout.js +36 -0
- package/crud/contentModel/validateLayout.js.map +1 -0
- package/crud/contentModel/validateModel.d.ts +9 -0
- package/crud/contentModel/validateModel.js +32 -0
- package/crud/contentModel/validateModel.js.map +1 -0
- package/crud/contentModel/validateModelFields.d.ts +9 -0
- package/crud/contentModel/validateModelFields.js +371 -0
- package/crud/contentModel/validateModelFields.js.map +1 -0
- package/crud/contentModel.crud.d.ts +12 -0
- package/crud/contentModel.crud.js +650 -0
- package/crud/contentModel.crud.js.map +1 -0
- package/crud/contentModelGroup/beforeCreate.d.ts +10 -0
- package/crud/contentModelGroup/beforeCreate.js +66 -0
- package/crud/contentModelGroup/beforeCreate.js.map +1 -0
- package/crud/contentModelGroup/beforeDelete.d.ts +10 -0
- package/crud/contentModelGroup/beforeDelete.js +48 -0
- package/crud/contentModelGroup/beforeDelete.js.map +1 -0
- package/crud/contentModelGroup/beforeUpdate.d.ts +9 -0
- package/crud/contentModelGroup/beforeUpdate.js +28 -0
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
- package/crud/contentModelGroup.crud.d.ts +12 -0
- package/crud/contentModelGroup.crud.js +396 -0
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/crud/index.d.ts +6 -0
- package/crud/index.js +85 -0
- package/crud/index.js.map +1 -0
- package/crud/settings.crud.d.ts +10 -0
- package/crud/settings.crud.js +83 -0
- package/crud/settings.crud.js.map +1 -0
- package/crud/system.crud.d.ts +13 -0
- package/crud/system.crud.js +221 -0
- package/crud/system.crud.js.map +1 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +7 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +66 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +239 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +304 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/index.d.ts +4 -0
- package/fieldConverters/index.js +18 -0
- package/fieldConverters/index.js.map +1 -0
- package/graphql/buildSchemaPlugins.d.ts +6 -0
- package/graphql/buildSchemaPlugins.js +27 -0
- package/graphql/buildSchemaPlugins.js.map +1 -0
- package/graphql/graphQLHandlerFactory.d.ts +5 -0
- package/graphql/graphQLHandlerFactory.js +202 -0
- package/graphql/graphQLHandlerFactory.js.map +1 -0
- package/graphql/index.d.ts +5 -0
- package/graphql/index.js +57 -0
- package/graphql/index.js.map +1 -0
- package/graphql/schema/baseContentSchema.d.ts +3 -0
- package/graphql/schema/baseContentSchema.js +76 -0
- package/graphql/schema/baseContentSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +3 -0
- package/graphql/schema/contentEntries.js +351 -0
- package/graphql/schema/contentEntries.js.map +1 -0
- package/graphql/schema/contentModelGroups.d.ts +3 -0
- package/graphql/schema/contentModelGroups.js +172 -0
- package/graphql/schema/contentModelGroups.js.map +1 -0
- package/graphql/schema/contentModels.d.ts +3 -0
- package/graphql/schema/contentModels.js +300 -0
- package/graphql/schema/contentModels.js.map +1 -0
- package/graphql/schema/createFieldResolvers.d.ts +20 -0
- package/graphql/schema/createFieldResolvers.js +121 -0
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +12 -0
- package/graphql/schema/createManageResolvers.js +137 -0
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/graphql/schema/createManageSDL.d.ts +10 -0
- package/graphql/schema/createManageSDL.js +161 -0
- package/graphql/schema/createManageSDL.js.map +1 -0
- package/graphql/schema/createPreviewResolvers.d.ts +12 -0
- package/graphql/schema/createPreviewResolvers.js +58 -0
- package/graphql/schema/createPreviewResolvers.js.map +1 -0
- package/graphql/schema/createReadResolvers.d.ts +12 -0
- package/graphql/schema/createReadResolvers.js +58 -0
- package/graphql/schema/createReadResolvers.js.map +1 -0
- package/graphql/schema/createReadSDL.d.ts +10 -0
- package/graphql/schema/createReadSDL.js +104 -0
- package/graphql/schema/createReadSDL.js.map +1 -0
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +6 -0
- package/graphql/schema/resolvers/commonFieldResolvers.js +14 -0
- package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveCreate.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveCreate.js +21 -0
- package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +8 -0
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js +21 -0
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveDelete.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveDelete.js +32 -0
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGet.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveGet.js +79 -0
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveGetByIds.js +21 -0
- package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetRevisions.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js +21 -0
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveList.d.ts +4 -0
- package/graphql/schema/resolvers/manage/resolveList.js +21 -0
- package/graphql/schema/resolvers/manage/resolveList.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolvePublish.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolvePublish.js +21 -0
- package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveRepublish.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveRepublish.js +21 -0
- package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveUnpublish.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveUnpublish.js +21 -0
- package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +8 -0
- package/graphql/schema/resolvers/manage/resolveUpdate.js +21 -0
- 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 +34 -0
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveList.d.ts +4 -0
- package/graphql/schema/resolvers/preview/resolveList.js +21 -0
- 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 +34 -0
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveList.d.ts +4 -0
- package/graphql/schema/resolvers/read/resolveList.js +21 -0
- package/graphql/schema/resolvers/read/resolveList.js.map +1 -0
- package/graphql/schema/schemaPlugins.d.ts +3 -0
- package/graphql/schema/schemaPlugins.js +111 -0
- package/graphql/schema/schemaPlugins.js.map +1 -0
- package/graphql/system.d.ts +6 -0
- package/graphql/system.js +119 -0
- package/graphql/system.js.map +1 -0
- package/graphqlFields/boolean.d.ts +2 -0
- package/graphqlFields/boolean.js +69 -0
- package/graphqlFields/boolean.js.map +1 -0
- package/graphqlFields/datetime.d.ts +2 -0
- package/graphqlFields/datetime.js +95 -0
- package/graphqlFields/datetime.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js +234 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js +79 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
- package/graphqlFields/dynamicZone/index.d.ts +2 -0
- package/graphqlFields/dynamicZone/index.js +21 -0
- package/graphqlFields/dynamicZone/index.js.map +1 -0
- package/graphqlFields/file.d.ts +2 -0
- package/graphqlFields/file.js +50 -0
- package/graphqlFields/file.js.map +1 -0
- package/graphqlFields/helpers.d.ts +6 -0
- package/graphqlFields/helpers.js +49 -0
- package/graphqlFields/helpers.js.map +1 -0
- package/graphqlFields/index.d.ts +2 -0
- package/graphqlFields/index.js +30 -0
- package/graphqlFields/index.js.map +1 -0
- package/graphqlFields/longText.d.ts +2 -0
- package/graphqlFields/longText.js +63 -0
- package/graphqlFields/longText.js.map +1 -0
- package/graphqlFields/number.d.ts +2 -0
- package/graphqlFields/number.js +79 -0
- package/graphqlFields/number.js.map +1 -0
- package/graphqlFields/object.d.ts +2 -0
- package/graphqlFields/object.js +275 -0
- package/graphqlFields/object.js.map +1 -0
- package/graphqlFields/ref.d.ts +2 -0
- package/graphqlFields/ref.js +257 -0
- package/graphqlFields/ref.js.map +1 -0
- package/graphqlFields/richText.d.ts +2 -0
- package/graphqlFields/richText.js +56 -0
- package/graphqlFields/richText.js.map +1 -0
- package/graphqlFields/text.d.ts +2 -0
- package/graphqlFields/text.js +73 -0
- package/graphqlFields/text.js.map +1 -0
- package/index.d.ts +10 -0
- package/index.js +111 -0
- package/index.js.map +1 -0
- package/modelManager/DefaultCmsModelManager.d.ts +14 -0
- package/modelManager/DefaultCmsModelManager.js +64 -0
- package/modelManager/DefaultCmsModelManager.js.map +1 -0
- package/modelManager/index.d.ts +2 -0
- package/modelManager/index.js +20 -0
- package/modelManager/index.js.map +1 -0
- package/package.json +81 -0
- package/parameters/context.d.ts +2 -0
- package/parameters/context.js +22 -0
- package/parameters/context.js.map +1 -0
- package/parameters/header.d.ts +2 -0
- package/parameters/header.js +55 -0
- package/parameters/header.js.map +1 -0
- package/parameters/index.d.ts +4 -0
- package/parameters/index.js +57 -0
- package/parameters/index.js.map +1 -0
- package/parameters/manual.d.ts +6 -0
- package/parameters/manual.js +44 -0
- package/parameters/manual.js.map +1 -0
- package/parameters/path.d.ts +2 -0
- package/parameters/path.js +51 -0
- package/parameters/path.js.map +1 -0
- package/plugins/CmsGroupPlugin.d.ts +13 -0
- package/plugins/CmsGroupPlugin.js +30 -0
- package/plugins/CmsGroupPlugin.js.map +1 -0
- package/plugins/CmsModelFieldConverterPlugin.d.ts +14 -0
- package/plugins/CmsModelFieldConverterPlugin.js +17 -0
- package/plugins/CmsModelFieldConverterPlugin.js.map +1 -0
- package/plugins/CmsModelPlugin.d.ts +45 -0
- package/plugins/CmsModelPlugin.js +194 -0
- package/plugins/CmsModelPlugin.js.map +1 -0
- package/plugins/CmsParametersPlugin.d.ts +20 -0
- package/plugins/CmsParametersPlugin.js +28 -0
- package/plugins/CmsParametersPlugin.js.map +1 -0
- package/plugins/StorageTransformPlugin.d.ts +31 -0
- package/plugins/StorageTransformPlugin.js +37 -0
- package/plugins/StorageTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +5 -0
- package/plugins/index.js +70 -0
- package/plugins/index.js.map +1 -0
- package/storage/default.d.ts +2 -0
- package/storage/default.js +27 -0
- package/storage/default.js.map +1 -0
- package/storage/object.d.ts +2 -0
- package/storage/object.js +127 -0
- package/storage/object.js.map +1 -0
- package/types.d.ts +2600 -0
- package/types.js +459 -0
- package/types.js.map +1 -0
- package/upgrades/5.33.0/index.d.ts +3 -0
- package/upgrades/5.33.0/index.js +182 -0
- package/upgrades/5.33.0/index.js.map +1 -0
- package/upgrades/index.d.ts +1 -0
- package/upgrades/index.js +12 -0
- package/upgrades/index.js.map +1 -0
- package/utils/access.d.ts +8 -0
- package/utils/access.js +90 -0
- package/utils/access.js.map +1 -0
- package/utils/converters/Converter.d.ts +27 -0
- package/utils/converters/Converter.js +71 -0
- package/utils/converters/Converter.js.map +1 -0
- package/utils/converters/ConverterCollection.d.ts +31 -0
- package/utils/converters/ConverterCollection.js +143 -0
- package/utils/converters/ConverterCollection.js.map +1 -0
- package/utils/converters/valueKeyStorageConverter.d.ts +18 -0
- package/utils/converters/valueKeyStorageConverter.js +148 -0
- package/utils/converters/valueKeyStorageConverter.js.map +1 -0
- package/utils/createTypeFromFields.d.ts +15 -0
- package/utils/createTypeFromFields.js +75 -0
- package/utils/createTypeFromFields.js.map +1 -0
- package/utils/createTypeName.d.ts +3 -0
- package/utils/createTypeName.js +30 -0
- package/utils/createTypeName.js.map +1 -0
- package/utils/entryStorage.d.ts +17 -0
- package/utils/entryStorage.js +120 -0
- package/utils/entryStorage.js.map +1 -0
- package/utils/filterAsync.d.ts +1 -0
- package/utils/filterAsync.js +23 -0
- package/utils/filterAsync.js.map +1 -0
- package/utils/filterModelFields.d.ts +16 -0
- package/utils/filterModelFields.js +77 -0
- package/utils/filterModelFields.js.map +1 -0
- package/utils/getBaseFieldType.d.ts +4 -0
- package/utils/getBaseFieldType.js +12 -0
- package/utils/getBaseFieldType.js.map +1 -0
- package/utils/getEntryTitle.d.ts +2 -0
- package/utils/getEntryTitle.js +43 -0
- package/utils/getEntryTitle.js.map +1 -0
- package/utils/getSchemaFromFieldPlugins.d.ts +12 -0
- package/utils/getSchemaFromFieldPlugins.js +35 -0
- package/utils/getSchemaFromFieldPlugins.js.map +1 -0
- package/utils/ownership.d.ts +8 -0
- package/utils/ownership.js +41 -0
- package/utils/ownership.js.map +1 -0
- package/utils/permissions.d.ts +7 -0
- package/utils/permissions.js +106 -0
- package/utils/permissions.js.map +1 -0
- package/utils/pluralizedTypeName.d.ts +1 -0
- package/utils/pluralizedTypeName.js +26 -0
- package/utils/pluralizedTypeName.js.map +1 -0
- package/utils/renderFields.d.ts +15 -0
- package/utils/renderFields.js +55 -0
- package/utils/renderFields.js.map +1 -0
- package/utils/renderGetFilterFields.d.ts +10 -0
- package/utils/renderGetFilterFields.js +61 -0
- package/utils/renderGetFilterFields.js.map +1 -0
- package/utils/renderInputFields.d.ts +14 -0
- package/utils/renderInputFields.js +55 -0
- package/utils/renderInputFields.js.map +1 -0
- package/utils/renderListFilterFields.d.ts +11 -0
- package/utils/renderListFilterFields.js +62 -0
- package/utils/renderListFilterFields.js.map +1 -0
- package/utils/renderSortEnum.d.ts +9 -0
- package/utils/renderSortEnum.js +34 -0
- package/utils/renderSortEnum.js.map +1 -0
- package/utils/toSlug.d.ts +1 -0
- package/utils/toSlug.js +20 -0
- package/utils/toSlug.js.map +1 -0
- package/validators/dateGte.d.ts +2 -0
- package/validators/dateGte.js +37 -0
- package/validators/dateGte.js.map +1 -0
- package/validators/dateLte.d.ts +2 -0
- package/validators/dateLte.js +37 -0
- package/validators/dateLte.js.map +1 -0
- package/validators/dynamicZone.d.ts +2 -0
- package/validators/dynamicZone.js +24 -0
- package/validators/dynamicZone.js.map +1 -0
- package/validators/gte.d.ts +2 -0
- package/validators/gte.js +36 -0
- package/validators/gte.js.map +1 -0
- package/validators/in.d.ts +2 -0
- package/validators/in.js +36 -0
- package/validators/in.js.map +1 -0
- package/validators/index.d.ts +1 -0
- package/validators/index.js +38 -0
- package/validators/index.js.map +1 -0
- package/validators/lte.d.ts +2 -0
- package/validators/lte.js +36 -0
- package/validators/lte.js.map +1 -0
- package/validators/maxLength.d.ts +2 -0
- package/validators/maxLength.js +36 -0
- package/validators/maxLength.js.map +1 -0
- package/validators/minLength.d.ts +2 -0
- package/validators/minLength.js +36 -0
- package/validators/minLength.js.map +1 -0
- package/validators/pattern.d.ts +2 -0
- package/validators/pattern.js +50 -0
- package/validators/pattern.js.map +1 -0
- package/validators/patternPlugins/email.d.ts +2 -0
- package/validators/patternPlugins/email.js +20 -0
- package/validators/patternPlugins/email.js.map +1 -0
- package/validators/patternPlugins/index.d.ts +2 -0
- package/validators/patternPlugins/index.js +24 -0
- package/validators/patternPlugins/index.js.map +1 -0
- package/validators/patternPlugins/lowerCase.d.ts +2 -0
- package/validators/patternPlugins/lowerCase.js +20 -0
- package/validators/patternPlugins/lowerCase.js.map +1 -0
- package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/lowerCaseSpace.js +20 -0
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
- package/validators/patternPlugins/upperCase.d.ts +2 -0
- package/validators/patternPlugins/upperCase.js +20 -0
- package/validators/patternPlugins/upperCase.js.map +1 -0
- package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/upperCaseSpace.js +20 -0
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
- package/validators/patternPlugins/url.d.ts +2 -0
- package/validators/patternPlugins/url.js +20 -0
- package/validators/patternPlugins/url.js.map +1 -0
- package/validators/required.d.ts +2 -0
- package/validators/required.js +27 -0
- package/validators/required.js.map +1 -0
- package/validators/timeGte.d.ts +2 -0
- package/validators/timeGte.js +34 -0
- package/validators/timeGte.js.map +1 -0
- package/validators/timeLte.d.ts +2 -0
- package/validators/timeLte.js +34 -0
- package/validators/timeLte.js.map +1 -0
- package/validators/unique.d.ts +6 -0
- package/validators/unique.js +63 -0
- package/validators/unique.js.map +1 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _manual = require("./manual");
|
|
8
|
+
|
|
9
|
+
Object.keys(_manual).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _manual[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _manual[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var _path = require("./path");
|
|
21
|
+
|
|
22
|
+
Object.keys(_path).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _path[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _path[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _context = require("./context");
|
|
34
|
+
|
|
35
|
+
Object.keys(_context).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _context[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _context[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var _header = require("./header");
|
|
47
|
+
|
|
48
|
+
Object.keys(_header).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (key in exports && exports[key] === _header[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _header[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./manual\";\nexport * from \"./path\";\nexport * from \"./context\";\nexport * from \"./header\";\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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CmsParametersPlugin, CmsParametersPluginResponseLocale, CmsParametersPluginResponseType } from "../plugins/CmsParametersPlugin";
|
|
2
|
+
export interface ManualPluginParams {
|
|
3
|
+
endpointType?: CmsParametersPluginResponseType;
|
|
4
|
+
locale?: CmsParametersPluginResponseLocale;
|
|
5
|
+
}
|
|
6
|
+
export declare const createManualPlugin: (params: ManualPluginParams) => CmsParametersPlugin;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createManualPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
12
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
+
|
|
14
|
+
var _CmsParametersPlugin = require("../plugins/CmsParametersPlugin");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This would be used for custom Lambdas when there is no path or header information about the endpoint type and locale.
|
|
18
|
+
*/
|
|
19
|
+
const createManualPlugin = params => {
|
|
20
|
+
return new _CmsParametersPlugin.CmsParametersPlugin(async () => {
|
|
21
|
+
const {
|
|
22
|
+
endpointType: type,
|
|
23
|
+
locale
|
|
24
|
+
} = params;
|
|
25
|
+
/**
|
|
26
|
+
* if both of parameters are not existing, just skip this plugin.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
if (!type && !locale) {
|
|
30
|
+
return null;
|
|
31
|
+
} else if (!type) {
|
|
32
|
+
throw new _error.default(`There is defined "locale" CMS parameter but no "endpointType".`, "MALFORMED_ENDPOINT_TYPE", (0, _objectSpread2.default)({}, params));
|
|
33
|
+
} else if (!locale) {
|
|
34
|
+
throw new _error.default(`There is defined "endpointType" CMS parameter but no "locale".`, "MALFORMED_LOCALE_TYPE", (0, _objectSpread2.default)({}, params));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
type,
|
|
39
|
+
locale
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.createManualPlugin = createManualPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createManualPlugin","params","CmsParametersPlugin","endpointType","type","locale","WebinyError"],"sources":["manual.ts"],"sourcesContent":["/**\n * This would be used for custom Lambdas when there is no path or header information about the endpoint type and locale.\n */\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsParametersPlugin,\n CmsParametersPluginResponseLocale,\n CmsParametersPluginResponseType\n} from \"~/plugins/CmsParametersPlugin\";\n\nexport interface ManualPluginParams {\n endpointType?: CmsParametersPluginResponseType;\n locale?: CmsParametersPluginResponseLocale;\n}\n\nexport const createManualPlugin = (params: ManualPluginParams): CmsParametersPlugin => {\n return new CmsParametersPlugin(async () => {\n const { endpointType: type, locale } = params;\n /**\n * if both of parameters are not existing, just skip this plugin.\n */\n if (!type && !locale) {\n return null;\n } else if (!type) {\n throw new WebinyError(\n `There is defined \"locale\" CMS parameter but no \"endpointType\".`,\n \"MALFORMED_ENDPOINT_TYPE\",\n {\n ...params\n }\n );\n } else if (!locale) {\n throw new WebinyError(\n `There is defined \"endpointType\" CMS parameter but no \"locale\".`,\n \"MALFORMED_LOCALE_TYPE\",\n {\n ...params\n }\n );\n }\n\n return {\n type,\n locale\n };\n });\n};\n"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAaO,MAAMA,kBAAkB,GAAIC,MAAD,IAAqD;EACnF,OAAO,IAAIC,wCAAJ,CAAwB,YAAY;IACvC,MAAM;MAAEC,YAAY,EAAEC,IAAhB;MAAsBC;IAAtB,IAAiCJ,MAAvC;IACA;AACR;AACA;;IACQ,IAAI,CAACG,IAAD,IAAS,CAACC,MAAd,EAAsB;MAClB,OAAO,IAAP;IACH,CAFD,MAEO,IAAI,CAACD,IAAL,EAAW;MACd,MAAM,IAAIE,cAAJ,CACD,gEADC,EAEF,yBAFE,kCAIKL,MAJL,EAAN;IAOH,CARM,MAQA,IAAI,CAACI,MAAL,EAAa;MAChB,MAAM,IAAIC,cAAJ,CACD,gEADC,EAEF,uBAFE,kCAIKL,MAJL,EAAN;IAOH;;IAED,OAAO;MACHG,IADG;MAEHC;IAFG,CAAP;EAIH,CA7BM,CAAP;AA8BH,CA/BM"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createPathParameterPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
|
|
12
|
+
var _CmsParametersPlugin = require("../plugins/CmsParametersPlugin");
|
|
13
|
+
|
|
14
|
+
const allowedEndpoints = ["manage", "read", "preview"];
|
|
15
|
+
|
|
16
|
+
const createPathParameterPlugin = () => {
|
|
17
|
+
return new _CmsParametersPlugin.CmsParametersPlugin(async context => {
|
|
18
|
+
var _context$request;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* If any of the properties is not defined, just ignore this plugin
|
|
22
|
+
*/
|
|
23
|
+
if (!((_context$request = context.request) !== null && _context$request !== void 0 && _context$request.params)) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
type,
|
|
29
|
+
locale
|
|
30
|
+
} = context.request.params;
|
|
31
|
+
|
|
32
|
+
if (!type && !locale) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!type) {
|
|
37
|
+
throw new _error.default(`Missing request parameter "type".`);
|
|
38
|
+
} else if (!locale) {
|
|
39
|
+
throw new _error.default(`Missing request parameter "locale".`);
|
|
40
|
+
} else if (allowedEndpoints.includes(type) === false) {
|
|
41
|
+
throw new _error.default(`Endpoint "${type}" not allowed!`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
type: type,
|
|
46
|
+
locale
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports.createPathParameterPlugin = createPathParameterPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["allowedEndpoints","createPathParameterPlugin","CmsParametersPlugin","context","request","params","type","locale","WebinyError","includes"],"sources":["path.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsParametersPlugin } from \"~/plugins/CmsParametersPlugin\";\nimport { ApiEndpoint } from \"~/types\";\n\nconst allowedEndpoints: ApiEndpoint[] = [\"manage\", \"read\", \"preview\"];\n\nexport const createPathParameterPlugin = () => {\n return new CmsParametersPlugin(async context => {\n /**\n * If any of the properties is not defined, just ignore this plugin\n */\n if (!context.request?.params) {\n return null;\n }\n\n const { type, locale } = context.request.params as Record<string, string | null>;\n if (!type && !locale) {\n return null;\n }\n\n if (!type) {\n throw new WebinyError(`Missing request parameter \"type\".`);\n } else if (!locale) {\n throw new WebinyError(`Missing request parameter \"locale\".`);\n } else if (allowedEndpoints.includes(type as ApiEndpoint) === false) {\n throw new WebinyError(`Endpoint \"${type}\" not allowed!`);\n }\n\n return {\n type: type as ApiEndpoint,\n locale\n };\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAGA,MAAMA,gBAA+B,GAAG,CAAC,QAAD,EAAW,MAAX,EAAmB,SAAnB,CAAxC;;AAEO,MAAMC,yBAAyB,GAAG,MAAM;EAC3C,OAAO,IAAIC,wCAAJ,CAAwB,MAAMC,OAAN,IAAiB;IAAA;;IAC5C;AACR;AACA;IACQ,IAAI,sBAACA,OAAO,CAACC,OAAT,6CAAC,iBAAiBC,MAAlB,CAAJ,EAA8B;MAC1B,OAAO,IAAP;IACH;;IAED,MAAM;MAAEC,IAAF;MAAQC;IAAR,IAAmBJ,OAAO,CAACC,OAAR,CAAgBC,MAAzC;;IACA,IAAI,CAACC,IAAD,IAAS,CAACC,MAAd,EAAsB;MAClB,OAAO,IAAP;IACH;;IAED,IAAI,CAACD,IAAL,EAAW;MACP,MAAM,IAAIE,cAAJ,CAAiB,mCAAjB,CAAN;IACH,CAFD,MAEO,IAAI,CAACD,MAAL,EAAa;MAChB,MAAM,IAAIC,cAAJ,CAAiB,qCAAjB,CAAN;IACH,CAFM,MAEA,IAAIR,gBAAgB,CAACS,QAAjB,CAA0BH,IAA1B,MAAmD,KAAvD,EAA8D;MACjE,MAAM,IAAIE,cAAJ,CAAiB,aAAYF,IAAK,gBAAlC,CAAN;IACH;;IAED,OAAO;MACHA,IAAI,EAAEA,IADH;MAEHC;IAFG,CAAP;EAIH,CAzBM,CAAP;AA0BH,CA3BM"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { CmsGroup as BaseCmsGroup } from "../types";
|
|
3
|
+
interface CmsGroup extends Omit<BaseCmsGroup, "locale" | "tenant" | "webinyVersion"> {
|
|
4
|
+
tenant?: string;
|
|
5
|
+
locale?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class CmsGroupPlugin extends Plugin {
|
|
8
|
+
static readonly type: string;
|
|
9
|
+
readonly contentModelGroup: CmsGroup;
|
|
10
|
+
constructor(contentModelGroup: CmsGroup);
|
|
11
|
+
}
|
|
12
|
+
export declare const createCmsGroup: (group: CmsGroup) => CmsGroupPlugin;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createCmsGroup = exports.CmsGroupPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _plugins = require("@webiny/plugins");
|
|
13
|
+
|
|
14
|
+
class CmsGroupPlugin extends _plugins.Plugin {
|
|
15
|
+
constructor(contentModelGroup) {
|
|
16
|
+
super();
|
|
17
|
+
(0, _defineProperty2.default)(this, "contentModelGroup", void 0);
|
|
18
|
+
this.contentModelGroup = contentModelGroup;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.CmsGroupPlugin = CmsGroupPlugin;
|
|
24
|
+
(0, _defineProperty2.default)(CmsGroupPlugin, "type", "cms-content-model-group");
|
|
25
|
+
|
|
26
|
+
const createCmsGroup = group => {
|
|
27
|
+
return new CmsGroupPlugin(group);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.createCmsGroup = createCmsGroup;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CmsGroupPlugin","Plugin","constructor","contentModelGroup","createCmsGroup","group"],"sources":["CmsGroupPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsGroup as BaseCmsGroup } from \"~/types\";\n\ninterface CmsGroup extends Omit<BaseCmsGroup, \"locale\" | \"tenant\" | \"webinyVersion\"> {\n tenant?: string;\n locale?: string;\n}\nexport class CmsGroupPlugin extends Plugin {\n public static override readonly type: string = \"cms-content-model-group\";\n public readonly contentModelGroup: CmsGroup;\n\n constructor(contentModelGroup: CmsGroup) {\n super();\n this.contentModelGroup = contentModelGroup;\n }\n}\n\nexport const createCmsGroup = (group: CmsGroup): CmsGroupPlugin => {\n return new CmsGroupPlugin(group);\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAOO,MAAMA,cAAN,SAA6BC,eAA7B,CAAoC;EAIvCC,WAAW,CAACC,iBAAD,EAA8B;IACrC;IADqC;IAErC,KAAKA,iBAAL,GAAyBA,iBAAzB;EACH;;AAPsC;;;8BAA9BH,c,UACsC,yB;;AAS5C,MAAMI,cAAc,GAAIC,KAAD,IAAqC;EAC/D,OAAO,IAAIL,cAAJ,CAAmBK,KAAnB,CAAP;AACH,CAFM"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { CmsEntryValues, CmsModelFieldWithParent } from "../types";
|
|
3
|
+
import { ConverterCollection } from "../utils/converters/ConverterCollection";
|
|
4
|
+
export interface ConvertParams<F = CmsModelFieldWithParent> {
|
|
5
|
+
field: F;
|
|
6
|
+
value: any;
|
|
7
|
+
converterCollection: ConverterCollection;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class CmsModelFieldConverterPlugin extends Plugin {
|
|
10
|
+
static type: string;
|
|
11
|
+
abstract getFieldType(): string;
|
|
12
|
+
abstract convertToStorage(params: ConvertParams): CmsEntryValues;
|
|
13
|
+
abstract convertFromStorage(params: ConvertParams): CmsEntryValues;
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.CmsModelFieldConverterPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _plugins = require("@webiny/plugins");
|
|
13
|
+
|
|
14
|
+
class CmsModelFieldConverterPlugin extends _plugins.Plugin {}
|
|
15
|
+
|
|
16
|
+
exports.CmsModelFieldConverterPlugin = CmsModelFieldConverterPlugin;
|
|
17
|
+
(0, _defineProperty2.default)(CmsModelFieldConverterPlugin, "type", "cms.field.converter");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CmsModelFieldConverterPlugin","Plugin"],"sources":["CmsModelFieldConverterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsEntryValues, CmsModelFieldWithParent } from \"~/types\";\nimport { ConverterCollection } from \"~/utils/converters/ConverterCollection\";\n\nexport interface ConvertParams<F = CmsModelFieldWithParent> {\n field: F;\n value: any;\n converterCollection: ConverterCollection;\n}\n\nexport abstract class CmsModelFieldConverterPlugin extends Plugin {\n public static override type = \"cms.field.converter\";\n\n public abstract getFieldType(): string;\n\n public abstract convertToStorage(params: ConvertParams): CmsEntryValues;\n public abstract convertFromStorage(params: ConvertParams): CmsEntryValues;\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAUO,MAAeA,4BAAf,SAAoDC,eAApD,CAA2D;;;8BAA5CD,4B,UACY,qB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { CmsModel as CmsModelBase, CmsModelField as CmsModelFieldBase, CmsModelFieldSettings as BaseCmsModelFieldSettings } from "../types";
|
|
3
|
+
interface CmsModelFieldSettings extends Omit<BaseCmsModelFieldSettings, "fields"> {
|
|
4
|
+
/**
|
|
5
|
+
* Object field has child fields.
|
|
6
|
+
*/
|
|
7
|
+
fields?: CmsModelFieldInput[];
|
|
8
|
+
}
|
|
9
|
+
interface CmsModelFieldInput extends Omit<CmsModelFieldBase, "storageId" | "settings"> {
|
|
10
|
+
/**
|
|
11
|
+
* If defined, it must be camelCased string.
|
|
12
|
+
* This is for backwards compatibility - before fields had storageId.
|
|
13
|
+
*
|
|
14
|
+
* This should only be populated in old model fields.
|
|
15
|
+
* News ones must have this empty.
|
|
16
|
+
*/
|
|
17
|
+
storageId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* We must have a possibility to have a nested field defined without the storageId.
|
|
20
|
+
*/
|
|
21
|
+
settings?: CmsModelFieldSettings;
|
|
22
|
+
}
|
|
23
|
+
interface CmsModelInput extends Omit<CmsModelBase, "locale" | "tenant" | "webinyVersion" | "fields"> {
|
|
24
|
+
fields: CmsModelFieldInput[];
|
|
25
|
+
locale?: string;
|
|
26
|
+
tenant?: string;
|
|
27
|
+
}
|
|
28
|
+
interface CmsModel extends Omit<CmsModelBase, "locale" | "tenant" | "webinyVersion"> {
|
|
29
|
+
locale?: string;
|
|
30
|
+
tenant?: string;
|
|
31
|
+
}
|
|
32
|
+
interface CmsModelPluginOptions {
|
|
33
|
+
validateLayout?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare class CmsModelPlugin extends Plugin {
|
|
36
|
+
static readonly type: string;
|
|
37
|
+
readonly contentModel: CmsModel;
|
|
38
|
+
private readonly options;
|
|
39
|
+
constructor(contentModel: CmsModelInput, options?: CmsModelPluginOptions);
|
|
40
|
+
private buildModel;
|
|
41
|
+
private buildFields;
|
|
42
|
+
private validateLayout;
|
|
43
|
+
}
|
|
44
|
+
export declare const createCmsModel: (model: CmsModelInput, options?: CmsModelPluginOptions) => CmsModelPlugin;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createCmsModel = exports.CmsModelPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _plugins = require("@webiny/plugins");
|
|
15
|
+
|
|
16
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
17
|
+
|
|
18
|
+
var _createFieldStorageId = require("../crud/contentModel/createFieldStorageId");
|
|
19
|
+
|
|
20
|
+
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
21
|
+
|
|
22
|
+
class CmsModelPlugin extends _plugins.Plugin {
|
|
23
|
+
constructor(contentModel, options) {
|
|
24
|
+
super();
|
|
25
|
+
(0, _defineProperty2.default)(this, "contentModel", void 0);
|
|
26
|
+
(0, _defineProperty2.default)(this, "options", void 0);
|
|
27
|
+
this.options = options || {};
|
|
28
|
+
this.contentModel = this.buildModel(contentModel);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
buildModel(input) {
|
|
32
|
+
const model = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
|
|
33
|
+
fields: this.buildFields(input, input.fields)
|
|
34
|
+
});
|
|
35
|
+
this.validateLayout(model);
|
|
36
|
+
return model;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
buildFields(model, inputFields) {
|
|
40
|
+
if (inputFields.length === 0) {
|
|
41
|
+
throw new _error.default(`Missing fields for the defined model "${model.modelId}".`, "MISSING_FIELDS", {
|
|
42
|
+
model
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const fields = [];
|
|
47
|
+
const storageIdList = [];
|
|
48
|
+
const fieldIdList = [];
|
|
49
|
+
|
|
50
|
+
for (const input of inputFields) {
|
|
51
|
+
var _settings;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Field must contain an fieldId. It is required in the graphql, but lets check it just in case
|
|
55
|
+
*/
|
|
56
|
+
if (!(input.fieldId || "").trim()) {
|
|
57
|
+
throw new _error.default(`Field's "storageId" is not defined for the content model "${model.modelId}".`, "FIELD_ID_ERROR", {
|
|
58
|
+
model,
|
|
59
|
+
field: input
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const fieldId = (0, _camelCase.default)(input.fieldId);
|
|
64
|
+
/**
|
|
65
|
+
* FieldID must be in correct pattern.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
if (fieldId.match(/^[0-9]/) !== null) {
|
|
69
|
+
throw new _error.default(`Field's "fieldId" does not match correct pattern in the content model "${model.modelId}" - cannot start with a number.`, "FIELD_FIELD_ID_ERROR", {
|
|
70
|
+
model,
|
|
71
|
+
field: input
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* FieldID also must be camelCased.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if (fieldId !== input.fieldId) {
|
|
80
|
+
throw new _error.default(`Field's "fieldId" must be a camel cased string in the content model "${model.modelId}".`, "FIELD_FIELD_ID_ERROR", {
|
|
81
|
+
model,
|
|
82
|
+
field: input
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* ... and fieldId must be unique.
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
if (fieldIdList.includes(fieldId) === true) {
|
|
91
|
+
throw new _error.default(`Field's "fieldId" is not unique in the content model "${model.modelId}".`, "FIELD_ID_NOT_UNIQUE_ERROR", {
|
|
92
|
+
model,
|
|
93
|
+
field: input
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let storageId = input.storageId ? (0, _camelCase.default)(input.storageId) : null;
|
|
98
|
+
/**
|
|
99
|
+
* If defined, storageId MUST be camel cased string - for backward compatibility.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
if (storageId && (storageId.match(/^([a-zA-Z-0-9]+)$/) === null || storageId !== input.storageId)) {
|
|
103
|
+
throw new _error.default(`Field's "storageId" of the field with "fieldId" ${input.fieldId} is not camel cased string in the content model "${model.modelId}".`, "STORAGE_ID_NOT_CAMEL_CASED_ERROR", {
|
|
104
|
+
model,
|
|
105
|
+
storageId,
|
|
106
|
+
field: input
|
|
107
|
+
});
|
|
108
|
+
} else if (!storageId) {
|
|
109
|
+
storageId = (0, _createFieldStorageId.createFieldStorageId)(input);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Fields storageId must be unique.
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
if (storageIdList.includes(storageId) === true) {
|
|
117
|
+
throw new _error.default(`Field's "storageId" is not unique in the content model "${model.modelId}".`, "STORAGE_ID_ERROR", {
|
|
118
|
+
model,
|
|
119
|
+
field: input
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* We can safely ignore error because we are going through the fields and making sure each has storageId.
|
|
124
|
+
*/
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
let settings = input.settings;
|
|
129
|
+
const childFields = ((_settings = settings) === null || _settings === void 0 ? void 0 : _settings.fields) || [];
|
|
130
|
+
|
|
131
|
+
if (input.type === "object" && childFields.length > 0) {
|
|
132
|
+
settings = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings || {}), {}, {
|
|
133
|
+
fields: this.buildFields(model, childFields)
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const field = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
|
|
138
|
+
settings,
|
|
139
|
+
storageId
|
|
140
|
+
});
|
|
141
|
+
/**
|
|
142
|
+
* Add all relevant data to arrays.
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
fields.push(field);
|
|
146
|
+
storageIdList.push(field.storageId);
|
|
147
|
+
fieldIdList.push(field.fieldId);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return fields;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
validateLayout(model) {
|
|
154
|
+
/**
|
|
155
|
+
* Only skip validation if option.validateLayout was set as false, explicitly.
|
|
156
|
+
*/
|
|
157
|
+
if (this.options.validateLayout === false) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
for (const field of model.fields) {
|
|
162
|
+
let total = 0;
|
|
163
|
+
|
|
164
|
+
for (const row of model.layout) {
|
|
165
|
+
const count = row.filter(cell => cell === field.id).length;
|
|
166
|
+
total = total + count;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (total === 1) {
|
|
170
|
+
continue;
|
|
171
|
+
} else if (total > 1) {
|
|
172
|
+
throw new _error.default(`Field "${field.id}" is in more than one layout cell.`, "DUPLICATE_FIELD_IN_LAYOUT", {
|
|
173
|
+
model,
|
|
174
|
+
field
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
throw new _error.default(`Missing field "${field.id}" in layout.`, "MISSING_FIELD_IN_LAYOUT", {
|
|
179
|
+
model,
|
|
180
|
+
field
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
exports.CmsModelPlugin = CmsModelPlugin;
|
|
188
|
+
(0, _defineProperty2.default)(CmsModelPlugin, "type", "cms-content-model");
|
|
189
|
+
|
|
190
|
+
const createCmsModel = (model, options) => {
|
|
191
|
+
return new CmsModelPlugin(model, options);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
exports.createCmsModel = createCmsModel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CmsModelPlugin","Plugin","constructor","contentModel","options","buildModel","input","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 { Plugin } from \"@webiny/plugins\";\nimport {\n CmsModel as CmsModelBase,\n CmsModelField as CmsModelFieldBase,\n CmsModelFieldSettings as BaseCmsModelFieldSettings\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { createFieldStorageId } from \"~/crud/contentModel/createFieldStorageId\";\nimport lodashCamelCase from \"lodash/camelCase\";\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\ninterface CmsModelInput\n extends Omit<CmsModelBase, \"locale\" | \"tenant\" | \"webinyVersion\" | \"fields\"> {\n fields: CmsModelFieldInput[];\n locale?: string;\n tenant?: string;\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 model: CmsModel = {\n ...input,\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":"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"}
|
|
@@ -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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.CmsParametersPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _plugins = require("@webiny/plugins");
|
|
13
|
+
|
|
14
|
+
class CmsParametersPlugin extends _plugins.Plugin {
|
|
15
|
+
constructor(callable) {
|
|
16
|
+
super();
|
|
17
|
+
(0, _defineProperty2.default)(this, "callable", void 0);
|
|
18
|
+
this.callable = callable;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async getParameters(context) {
|
|
22
|
+
return this.callable(context);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.CmsParametersPlugin = CmsParametersPlugin;
|
|
28
|
+
(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,mBAAN,SAAkCC,eAAlC,CAAyC;EAKrCC,WAAW,CAACC,QAAD,EAAwC;IACtD;IADsD;IAGtD,KAAKA,QAAL,GAAgBA,QAAhB;EACH;;EAEyB,MAAbC,aAAa,CAACC,OAAD,EAAmE;IACzF,OAAO,KAAKF,QAAL,CAAcE,OAAd,CAAP;EACH;;AAb2C;;;8BAAnCL,mB,UACsC,uB"}
|
|
@@ -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
|
+
}
|