@webiny/api-headless-cms 0.0.0-mt-2 → 0.0.0-unstable.1145e7667f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.d.ts +6 -0
- package/context.js +98 -0
- package/context.js.map +1 -0
- package/crud/contentEntry/afterDelete.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.js +2 -7
- package/crud/contentEntry/afterDelete.js.map +1 -0
- package/crud/contentEntry/beforeCreate.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeCreate.js +2 -5
- package/crud/contentEntry/beforeCreate.js.map +1 -0
- package/crud/contentEntry/beforeUpdate.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/beforeUpdate.js +2 -5
- package/crud/contentEntry/beforeUpdate.js.map +1 -0
- package/crud/contentEntry/entryDataValidation.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.js +22 -49
- package/crud/contentEntry/entryDataValidation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.d.ts +3 -2
- package/{content/plugins/crud → crud}/contentEntry/markLockedFields.js +29 -43
- package/crud/contentEntry/markLockedFields.js.map +1 -0
- package/crud/contentEntry/referenceFieldsMapping.d.ts +13 -0
- package/crud/contentEntry/referenceFieldsMapping.js +265 -0
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -0
- package/crud/contentEntry/searchableFields.d.ts +9 -0
- package/crud/contentEntry/searchableFields.js +72 -0
- package/crud/contentEntry/searchableFields.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry.crud.d.ts +7 -8
- package/crud/contentEntry.crud.js +1212 -0
- package/crud/contentEntry.crud.js.map +1 -0
- package/crud/contentModel/afterCreate.d.ts +8 -0
- package/crud/contentModel/afterCreate.js +16 -0
- package/crud/contentModel/afterCreate.js.map +1 -0
- package/crud/contentModel/afterCreateFrom.d.ts +8 -0
- package/crud/contentModel/afterCreateFrom.js +16 -0
- package/crud/contentModel/afterCreateFrom.js.map +1 -0
- package/crud/contentModel/afterDelete.d.ts +8 -0
- package/crud/contentModel/afterDelete.js +16 -0
- package/crud/contentModel/afterDelete.js.map +1 -0
- package/crud/contentModel/afterUpdate.d.ts +8 -0
- package/crud/contentModel/afterUpdate.js +16 -0
- package/crud/contentModel/afterUpdate.js.map +1 -0
- package/crud/contentModel/beforeCreate.d.ts +14 -0
- package/crud/contentModel/beforeCreate.js +128 -0
- package/crud/contentModel/beforeCreate.js.map +1 -0
- package/crud/contentModel/beforeDelete.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.js +8 -18
- package/crud/contentModel/beforeDelete.js.map +1 -0
- package/crud/contentModel/beforeUpdate.d.ts +8 -0
- package/crud/contentModel/beforeUpdate.js +60 -0
- package/crud/contentModel/beforeUpdate.js.map +1 -0
- package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
- package/crud/contentModel/compatibility/modelApiName.js +24 -0
- package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
- package/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js +0 -7
- package/crud/contentModel/contentModelManagerFactory.js.map +1 -0
- package/crud/contentModel/createFieldModels.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/createFieldModels.js +6 -2
- package/crud/contentModel/createFieldModels.js.map +1 -0
- package/crud/contentModel/createFieldStorageId.d.ts +2 -0
- package/crud/contentModel/createFieldStorageId.js +17 -0
- package/crud/contentModel/createFieldStorageId.js.map +1 -0
- package/crud/contentModel/defaultFields.d.ts +5 -0
- package/crud/contentModel/defaultFields.js +58 -0
- package/crud/contentModel/defaultFields.js.map +1 -0
- package/crud/contentModel/fieldIdValidation.d.ts +1 -0
- package/crud/contentModel/fieldIdValidation.js +25 -0
- package/crud/contentModel/fieldIdValidation.js.map +1 -0
- package/crud/contentModel/fields/descriptionField.d.ts +2 -0
- package/crud/contentModel/fields/descriptionField.js +42 -0
- package/crud/contentModel/fields/descriptionField.js.map +1 -0
- package/crud/contentModel/fields/imageField.d.ts +2 -0
- package/crud/contentModel/fields/imageField.js +46 -0
- package/crud/contentModel/fields/imageField.js.map +1 -0
- package/crud/contentModel/fields/titleField.d.ts +2 -0
- package/crud/contentModel/fields/titleField.js +58 -0
- package/crud/contentModel/fields/titleField.js.map +1 -0
- package/crud/contentModel/idValidation.d.ts +1 -0
- package/{content/plugins/crud → crud}/contentModel/idValidation.js +3 -3
- package/crud/contentModel/idValidation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/models.d.ts +2 -1
- package/{content/plugins/crud → crud}/contentModel/models.js +76 -25
- package/crud/contentModel/models.js.map +1 -0
- package/crud/contentModel/systemFields.d.ts +1 -0
- package/crud/contentModel/systemFields.js +8 -0
- package/crud/contentModel/systemFields.js.map +1 -0
- package/crud/contentModel/validate/endingAllowed.d.ts +6 -0
- package/crud/contentModel/validate/endingAllowed.js +26 -0
- package/crud/contentModel/validate/endingAllowed.js.map +1 -0
- package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
- package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
- package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
- package/crud/contentModel/validate/modelId.d.ts +11 -0
- package/crud/contentModel/validate/modelId.js +36 -0
- package/crud/contentModel/validate/modelId.js.map +1 -0
- package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
- package/crud/contentModel/validate/pluralApiName.js +24 -0
- package/crud/contentModel/validate/pluralApiName.js.map +1 -0
- package/crud/contentModel/validate/singularApiName.d.ts +7 -0
- package/crud/contentModel/validate/singularApiName.js +24 -0
- package/crud/contentModel/validate/singularApiName.js.map +1 -0
- package/crud/contentModel/validateLayout.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/validateLayout.js +1 -11
- package/crud/contentModel/validateLayout.js.map +1 -0
- package/crud/contentModel/validateModel.d.ts +9 -0
- package/crud/contentModel/validateModel.js +27 -0
- package/crud/contentModel/validateModel.js.map +1 -0
- package/crud/contentModel/validateModelFields.d.ts +9 -0
- package/crud/contentModel/validateModelFields.js +342 -0
- package/crud/contentModel/validateModelFields.js.map +1 -0
- package/crud/contentModel/validation.d.ts +551 -0
- package/crud/contentModel/validation.js +145 -0
- package/crud/contentModel/validation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel.crud.d.ts +3 -3
- package/crud/contentModel.crud.js +616 -0
- package/crud/contentModel.crud.js.map +1 -0
- package/crud/contentModelGroup/beforeCreate.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.js +8 -20
- package/crud/contentModelGroup/beforeCreate.js.map +1 -0
- package/crud/contentModelGroup/beforeDelete.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.js +4 -12
- package/crud/contentModelGroup/beforeDelete.js.map +1 -0
- package/crud/contentModelGroup/beforeUpdate.d.ts +9 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.js +3 -8
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
- package/crud/contentModelGroup/validation.d.ts +30 -0
- package/crud/contentModelGroup/validation.js +34 -0
- package/crud/contentModelGroup/validation.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup.crud.d.ts +3 -3
- package/crud/contentModelGroup.crud.js +352 -0
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/{plugins/crud → crud}/settings.crud.d.ts +3 -3
- package/crud/settings.crud.js +66 -0
- package/crud/settings.crud.js.map +1 -0
- package/{plugins/crud → crud}/system.crud.d.ts +6 -3
- package/crud/system.crud.js +126 -0
- package/crud/system.crud.js.map +1 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +7 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +53 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +203 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +251 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/index.d.ts +4 -0
- package/fieldConverters/index.js +13 -0
- package/fieldConverters/index.js.map +1 -0
- package/graphql/buildSchemaPlugins.d.ts +11 -0
- package/graphql/buildSchemaPlugins.js +19 -0
- package/graphql/buildSchemaPlugins.js.map +1 -0
- package/graphql/checkEndpointAccess.d.ts +2 -0
- package/graphql/checkEndpointAccess.js +18 -0
- package/graphql/checkEndpointAccess.js.map +1 -0
- package/graphql/createExecutableSchema.d.ts +6 -0
- package/graphql/createExecutableSchema.js +29 -0
- package/graphql/createExecutableSchema.js.map +1 -0
- package/graphql/createRequestBody.d.ts +2 -0
- package/graphql/createRequestBody.js +14 -0
- package/graphql/createRequestBody.js.map +1 -0
- package/graphql/formatErrorPayload.d.ts +1 -0
- package/graphql/formatErrorPayload.js +25 -0
- package/graphql/formatErrorPayload.js.map +1 -0
- package/graphql/generateSchema.d.ts +8 -0
- package/graphql/generateSchema.js +31 -0
- package/graphql/generateSchema.js.map +1 -0
- package/graphql/getSchema.d.ts +17 -0
- package/graphql/getSchema.js +102 -0
- package/graphql/getSchema.js.map +1 -0
- package/graphql/graphQLHandlerFactory.d.ts +5 -0
- package/graphql/graphQLHandlerFactory.js +35 -0
- package/graphql/graphQLHandlerFactory.js.map +1 -0
- package/graphql/handleRequest.d.ts +11 -0
- package/graphql/handleRequest.js +81 -0
- package/graphql/handleRequest.js.map +1 -0
- package/graphql/index.d.ts +3 -0
- package/graphql/index.js +13 -0
- package/graphql/index.js.map +1 -0
- package/graphql/schema/baseContentSchema.d.ts +7 -0
- package/graphql/schema/baseContentSchema.js +66 -0
- package/graphql/schema/baseContentSchema.js.map +1 -0
- package/graphql/schema/baseSchema.d.ts +3 -0
- package/graphql/schema/baseSchema.js +53 -0
- package/graphql/schema/baseSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +7 -0
- package/graphql/schema/contentEntries.js +362 -0
- package/graphql/schema/contentEntries.js.map +1 -0
- package/graphql/schema/contentModelGroups.d.ts +7 -0
- package/{content/plugins → graphql}/schema/contentModelGroups.js +39 -33
- package/graphql/schema/contentModelGroups.js.map +1 -0
- package/graphql/schema/contentModels.d.ts +7 -0
- package/{content/plugins → graphql}/schema/contentModels.js +121 -29
- package/graphql/schema/contentModels.js.map +1 -0
- package/graphql/schema/createFieldResolvers.d.ts +20 -0
- package/graphql/schema/createFieldResolvers.js +111 -0
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +12 -0
- package/graphql/schema/createManageResolvers.js +127 -0
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/graphql/schema/createManageSDL.d.ts +13 -0
- package/graphql/schema/createManageSDL.js +157 -0
- package/graphql/schema/createManageSDL.js.map +1 -0
- package/graphql/schema/createPreviewResolvers.d.ts +12 -0
- package/graphql/schema/createPreviewResolvers.js +44 -0
- package/graphql/schema/createPreviewResolvers.js.map +1 -0
- package/graphql/schema/createReadResolvers.d.ts +12 -0
- package/graphql/schema/createReadResolvers.js +49 -0
- package/graphql/schema/createReadResolvers.js.map +1 -0
- package/graphql/schema/createReadSDL.d.ts +13 -0
- package/graphql/schema/createReadSDL.js +100 -0
- package/graphql/schema/createReadSDL.js.map +1 -0
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js +2 -3
- package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveCreate.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreate.js +2 -7
- package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +8 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveCreateFrom.js +2 -7
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveDelete.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveDelete.js +8 -12
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGet.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveGet.js +63 -0
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js +2 -7
- package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetRevisions.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetRevisions.js +2 -7
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveList.d.ts +4 -0
- package/{content/plugins/schema/resolvers/preview → graphql/schema/resolvers/manage}/resolveList.js +2 -7
- package/graphql/schema/resolvers/manage/resolveList.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolvePublish.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolvePublish.js +0 -3
- package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveRepublish.d.ts +7 -0
- package/{content/plugins/schema/resolvers/manage/resolveGet.js → graphql/schema/resolvers/manage/resolveRepublish.js} +4 -7
- package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveUnpublish.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUnpublish.js +0 -3
- package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +8 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveUpdate.js +2 -7
- package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveGet.d.ts +4 -0
- package/graphql/schema/resolvers/preview/resolveGet.js +26 -0
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveList.d.ts +4 -0
- package/{content/plugins/schema/resolvers/manage → graphql/schema/resolvers/preview}/resolveList.js +2 -7
- package/graphql/schema/resolvers/preview/resolveList.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveGet.d.ts +4 -0
- package/graphql/schema/resolvers/read/resolveGet.js +26 -0
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveList.d.ts +4 -0
- package/{content/plugins → graphql}/schema/resolvers/read/resolveList.js +2 -7
- package/graphql/schema/resolvers/read/resolveList.js.map +1 -0
- package/graphql/schema/schemaPlugins.d.ts +8 -0
- package/graphql/schema/schemaPlugins.js +109 -0
- package/graphql/schema/schemaPlugins.js.map +1 -0
- package/graphql/system.d.ts +6 -0
- package/{plugins/graphql → graphql}/system.js +39 -24
- package/graphql/system.js.map +1 -0
- package/graphqlFields/boolean.d.ts +2 -0
- package/graphqlFields/boolean.js +57 -0
- package/graphqlFields/boolean.js.map +1 -0
- package/graphqlFields/datetime.d.ts +2 -0
- package/graphqlFields/datetime.js +78 -0
- package/graphqlFields/datetime.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js +243 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js +63 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
- package/graphqlFields/dynamicZone/index.d.ts +2 -0
- package/graphqlFields/dynamicZone/index.js +19 -0
- package/graphqlFields/dynamicZone/index.js.map +1 -0
- package/graphqlFields/file.d.ts +2 -0
- package/graphqlFields/file.js +42 -0
- package/graphqlFields/file.js.map +1 -0
- package/graphqlFields/helpers.d.ts +6 -0
- package/graphqlFields/helpers.js +39 -0
- package/graphqlFields/helpers.js.map +1 -0
- package/graphqlFields/index.d.ts +2 -0
- package/graphqlFields/index.js +18 -0
- package/graphqlFields/index.js.map +1 -0
- package/graphqlFields/longText.d.ts +2 -0
- package/graphqlFields/longText.js +53 -0
- package/graphqlFields/longText.js.map +1 -0
- package/graphqlFields/number.d.ts +2 -0
- package/graphqlFields/number.js +67 -0
- package/graphqlFields/number.js.map +1 -0
- package/graphqlFields/object.d.ts +2 -0
- package/graphqlFields/object.js +258 -0
- package/graphqlFields/object.js.map +1 -0
- package/graphqlFields/ref.d.ts +2 -0
- package/graphqlFields/ref.js +255 -0
- package/graphqlFields/ref.js.map +1 -0
- package/graphqlFields/richText.d.ts +2 -0
- package/graphqlFields/richText.js +47 -0
- package/graphqlFields/richText.js.map +1 -0
- package/graphqlFields/text.d.ts +2 -0
- package/graphqlFields/text.js +62 -0
- package/graphqlFields/text.js.map +1 -0
- package/index.d.ts +12 -12
- package/index.js +98 -55
- package/index.js.map +1 -0
- package/modelManager/DefaultCmsModelManager.d.ts +14 -0
- package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js +10 -24
- package/modelManager/DefaultCmsModelManager.js.map +1 -0
- package/modelManager/index.d.ts +2 -0
- package/{content/plugins/modelManager → modelManager}/index.js +3 -7
- package/modelManager/index.js.map +1 -0
- package/package.json +37 -38
- package/parameters/context.d.ts +2 -0
- package/parameters/context.js +18 -0
- package/parameters/context.js.map +1 -0
- package/parameters/header.d.ts +2 -0
- package/parameters/header.js +44 -0
- package/parameters/header.js.map +1 -0
- package/parameters/index.d.ts +4 -0
- package/parameters/index.js +49 -0
- package/parameters/index.js.map +1 -0
- package/parameters/manual.d.ts +6 -0
- package/parameters/manual.js +37 -0
- package/parameters/manual.js.map +1 -0
- package/parameters/path.d.ts +2 -0
- package/parameters/path.js +40 -0
- package/parameters/path.js.map +1 -0
- package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
- package/plugins/CmsGraphQLSchemaPlugin.js +12 -0
- package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js +28 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
- package/plugins/CmsGroupPlugin.d.ts +13 -0
- package/{content/plugins → plugins}/CmsGroupPlugin.js +7 -9
- package/plugins/CmsGroupPlugin.js.map +1 -0
- package/plugins/CmsModelFieldConverterPlugin.d.ts +14 -0
- package/plugins/CmsModelFieldConverterPlugin.js +12 -0
- package/plugins/CmsModelFieldConverterPlugin.js.map +1 -0
- package/plugins/CmsModelPlugin.d.ts +61 -0
- package/plugins/CmsModelPlugin.js +184 -0
- package/plugins/CmsModelPlugin.js.map +1 -0
- package/plugins/CmsParametersPlugin.d.ts +20 -0
- package/plugins/CmsParametersPlugin.js +21 -0
- package/plugins/CmsParametersPlugin.js.map +1 -0
- package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
- package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
- package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
- package/plugins/StorageTransformPlugin.d.ts +31 -0
- package/{content/plugins/storage → plugins}/StorageTransformPlugin.js +2 -10
- package/plugins/StorageTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +8 -0
- package/plugins/index.js +93 -0
- package/plugins/index.js.map +1 -0
- package/storage/default.d.ts +2 -0
- package/storage/default.js +24 -0
- package/storage/default.js.map +1 -0
- package/storage/object.d.ts +2 -0
- package/storage/object.js +108 -0
- package/storage/object.js.map +1 -0
- package/types.d.ts +920 -374
- package/types.js +105 -62
- package/types.js.map +1 -0
- package/upgrades/5.33.0/index.d.ts +3 -0
- package/upgrades/5.33.0/index.js +182 -0
- package/upgrades/5.33.0/index.js.map +1 -0
- package/upgrades/index.d.ts +1 -0
- package/upgrades/index.js +12 -0
- package/upgrades/index.js.map +1 -0
- package/utils/access.d.ts +8 -0
- package/utils/access.js +76 -0
- package/utils/access.js.map +1 -0
- package/utils/converters/Converter.d.ts +27 -0
- package/utils/converters/Converter.js +58 -0
- package/utils/converters/Converter.js.map +1 -0
- package/utils/converters/ConverterCollection.d.ts +31 -0
- package/utils/converters/ConverterCollection.js +119 -0
- package/utils/converters/ConverterCollection.js.map +1 -0
- package/utils/converters/valueKeyStorageConverter.d.ts +14 -0
- package/utils/converters/valueKeyStorageConverter.js +125 -0
- package/utils/converters/valueKeyStorageConverter.js.map +1 -0
- package/utils/createTypeFromFields.d.ts +16 -0
- package/utils/createTypeFromFields.js +66 -0
- package/utils/createTypeFromFields.js.map +1 -0
- package/utils/createTypeName.d.ts +1 -0
- package/utils/createTypeName.js +13 -0
- package/utils/createTypeName.js.map +1 -0
- package/{content/plugins/utils → utils}/entryStorage.d.ts +3 -3
- package/{content/plugins/utils → utils}/entryStorage.js +26 -47
- package/utils/entryStorage.js.map +1 -0
- package/utils/filterAsync.d.ts +1 -0
- package/utils/filterAsync.js +18 -0
- package/utils/filterAsync.js.map +1 -0
- package/utils/getBaseFieldType.d.ts +4 -0
- package/utils/getBaseFieldType.js +10 -0
- package/utils/getBaseFieldType.js.map +1 -0
- package/utils/getEntryDescription.d.ts +2 -0
- package/utils/getEntryDescription.js +17 -0
- package/utils/getEntryDescription.js.map +1 -0
- package/utils/getEntryImage.d.ts +2 -0
- package/utils/getEntryImage.js +17 -0
- package/utils/getEntryImage.js.map +1 -0
- package/utils/getEntryTitle.d.ts +2 -0
- package/{content/plugins/utils → utils}/getEntryTitle.js +7 -15
- package/utils/getEntryTitle.js.map +1 -0
- package/utils/getSchemaFromFieldPlugins.d.ts +9 -0
- package/utils/getSchemaFromFieldPlugins.js +39 -0
- package/utils/getSchemaFromFieldPlugins.js.map +1 -0
- package/utils/incrementEntryIdVersion.d.ts +5 -0
- package/utils/incrementEntryIdVersion.js +29 -0
- package/utils/incrementEntryIdVersion.js.map +1 -0
- package/utils/ownership.d.ts +8 -0
- package/utils/ownership.js +33 -0
- package/utils/ownership.js.map +1 -0
- package/utils/permissions.d.ts +7 -0
- package/utils/permissions.js +91 -0
- package/utils/permissions.js.map +1 -0
- package/utils/pluralizedTypeName.d.ts +1 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.js +1 -1
- package/utils/pluralizedTypeName.js.map +1 -0
- package/utils/renderFields.d.ts +16 -0
- package/{content/plugins/utils → utils}/renderFields.js +14 -12
- package/utils/renderFields.js.map +1 -0
- package/utils/renderGetFilterFields.d.ts +10 -0
- package/utils/renderGetFilterFields.js +48 -0
- package/utils/renderGetFilterFields.js.map +1 -0
- package/utils/renderInputFields.d.ts +15 -0
- package/{content/plugins/utils → utils}/renderInputFields.js +7 -10
- package/utils/renderInputFields.js.map +1 -0
- package/utils/renderListFilterFields.d.ts +11 -0
- package/{content/plugins/utils → utils}/renderListFilterFields.js +36 -22
- package/utils/renderListFilterFields.js.map +1 -0
- package/utils/renderSortEnum.d.ts +12 -0
- package/utils/renderSortEnum.js +42 -0
- package/utils/renderSortEnum.js.map +1 -0
- package/utils/toSlug.d.ts +1 -0
- package/utils/toSlug.js +16 -0
- package/utils/toSlug.js.map +1 -0
- package/validators/dateGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateGte.js +4 -11
- package/validators/dateGte.js.map +1 -0
- package/validators/dateLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateLte.js +4 -11
- package/validators/dateLte.js.map +1 -0
- package/validators/dynamicZone.d.ts +2 -0
- package/validators/dynamicZone.js +20 -0
- package/validators/dynamicZone.js.map +1 -0
- package/validators/gte.d.ts +2 -0
- package/validators/gte.js +28 -0
- package/validators/gte.js.map +1 -0
- package/validators/in.d.ts +2 -0
- package/validators/in.js +28 -0
- package/validators/in.js.map +1 -0
- package/validators/index.d.ts +1 -0
- package/validators/index.js +22 -0
- package/validators/index.js.map +1 -0
- package/validators/lte.d.ts +2 -0
- package/validators/lte.js +28 -0
- package/validators/lte.js.map +1 -0
- package/validators/maxLength.d.ts +2 -0
- package/validators/maxLength.js +28 -0
- package/validators/maxLength.js.map +1 -0
- package/validators/minLength.d.ts +2 -0
- package/validators/minLength.js +28 -0
- package/validators/minLength.js.map +1 -0
- package/validators/pattern.d.ts +2 -0
- package/validators/pattern.js +41 -0
- package/validators/pattern.js.map +1 -0
- package/validators/patternPlugins/email.d.ts +2 -0
- package/validators/patternPlugins/email.js +18 -0
- package/validators/patternPlugins/email.js.map +1 -0
- package/validators/patternPlugins/index.d.ts +2 -0
- package/validators/patternPlugins/index.js +16 -0
- package/validators/patternPlugins/index.js.map +1 -0
- package/validators/patternPlugins/lowerCase.d.ts +2 -0
- package/validators/patternPlugins/lowerCase.js +18 -0
- package/validators/patternPlugins/lowerCase.js.map +1 -0
- package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/lowerCaseSpace.js +18 -0
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
- package/validators/patternPlugins/upperCase.d.ts +2 -0
- package/validators/patternPlugins/upperCase.js +18 -0
- package/validators/patternPlugins/upperCase.js.map +1 -0
- package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/upperCaseSpace.js +18 -0
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
- package/validators/patternPlugins/url.d.ts +2 -0
- package/validators/patternPlugins/url.js +18 -0
- package/validators/patternPlugins/url.js.map +1 -0
- package/validators/required.d.ts +2 -0
- package/validators/required.js +22 -0
- package/validators/required.js.map +1 -0
- package/validators/timeGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeGte.js +5 -11
- package/validators/timeGte.js.map +1 -0
- package/validators/timeLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeLte.js +5 -11
- package/validators/timeLte.js.map +1 -0
- package/validators/unique.d.ts +6 -0
- package/validators/unique.js +56 -0
- package/validators/unique.js.map +1 -0
- package/content/contextSetup.d.ts +0 -4
- package/content/contextSetup.js +0 -65
- package/content/graphQLHandlerFactory.d.ts +0 -5
- package/content/graphQLHandlerFactory.js +0 -173
- package/content/plugins/CmsGroupPlugin.d.ts +0 -11
- package/content/plugins/CmsModelPlugin.d.ts +0 -11
- package/content/plugins/CmsModelPlugin.js +0 -24
- package/content/plugins/buildSchemaPlugins.d.ts +0 -7
- package/content/plugins/buildSchemaPlugins.js +0 -29
- package/content/plugins/crud/contentEntry/afterDelete.d.ts +0 -7
- package/content/plugins/crud/contentEntry/beforeCreate.d.ts +0 -7
- package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +0 -7
- package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +0 -4
- package/content/plugins/crud/contentEntry.crud.js +0 -931
- package/content/plugins/crud/contentModel/afterCreate.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterCreate.js +0 -18
- package/content/plugins/crud/contentModel/afterDelete.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterDelete.js +0 -18
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterUpdate.js +0 -18
- package/content/plugins/crud/contentModel/beforeCreate.d.ts +0 -9
- package/content/plugins/crud/contentModel/beforeCreate.js +0 -146
- package/content/plugins/crud/contentModel/beforeDelete.d.ts +0 -9
- package/content/plugins/crud/contentModel/beforeUpdate.d.ts +0 -9
- package/content/plugins/crud/contentModel/beforeUpdate.js +0 -128
- package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +0 -2
- package/content/plugins/crud/contentModel/createFieldModels.d.ts +0 -2
- package/content/plugins/crud/contentModel/idValidation.d.ts +0 -2
- package/content/plugins/crud/contentModel/validateLayout.d.ts +0 -2
- package/content/plugins/crud/contentModel.crud.js +0 -425
- package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +0 -9
- package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +0 -9
- package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +0 -8
- package/content/plugins/crud/contentModelGroup.crud.js +0 -351
- package/content/plugins/crud/index.d.ts +0 -6
- package/content/plugins/crud/index.js +0 -100
- package/content/plugins/graphqlFields/boolean.d.ts +0 -3
- package/content/plugins/graphqlFields/boolean.js +0 -69
- package/content/plugins/graphqlFields/datetime.d.ts +0 -3
- package/content/plugins/graphqlFields/datetime.js +0 -83
- package/content/plugins/graphqlFields/file.d.ts +0 -3
- package/content/plugins/graphqlFields/file.js +0 -49
- package/content/plugins/graphqlFields/index.d.ts +0 -2
- package/content/plugins/graphqlFields/index.js +0 -30
- package/content/plugins/graphqlFields/longText.d.ts +0 -3
- package/content/plugins/graphqlFields/longText.js +0 -62
- package/content/plugins/graphqlFields/number.d.ts +0 -3
- package/content/plugins/graphqlFields/number.js +0 -75
- package/content/plugins/graphqlFields/object.d.ts +0 -3
- package/content/plugins/graphqlFields/object.js +0 -180
- package/content/plugins/graphqlFields/ref.d.ts +0 -3
- package/content/plugins/graphqlFields/ref.js +0 -205
- package/content/plugins/graphqlFields/richText.d.ts +0 -3
- package/content/plugins/graphqlFields/richText.js +0 -55
- package/content/plugins/graphqlFields/text.d.ts +0 -3
- package/content/plugins/graphqlFields/text.js +0 -72
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +0 -8
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +0 -54
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +0 -7
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +0 -35
- package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +0 -15
- package/content/plugins/modelManager/index.d.ts +0 -3
- package/content/plugins/schema/baseSchema.d.ts +0 -4
- package/content/plugins/schema/baseSchema.js +0 -98
- package/content/plugins/schema/contentEntries.d.ts +0 -4
- package/content/plugins/schema/contentEntries.js +0 -166
- package/content/plugins/schema/contentModelGroups.d.ts +0 -4
- package/content/plugins/schema/contentModels.d.ts +0 -4
- package/content/plugins/schema/createFieldResolvers.d.ts +0 -19
- package/content/plugins/schema/createFieldResolvers.js +0 -92
- package/content/plugins/schema/createManageResolvers.d.ts +0 -11
- package/content/plugins/schema/createManageResolvers.js +0 -135
- package/content/plugins/schema/createManageSDL.d.ts +0 -9
- package/content/plugins/schema/createManageSDL.js +0 -153
- package/content/plugins/schema/createPreviewResolvers.d.ts +0 -10
- package/content/plugins/schema/createPreviewResolvers.js +0 -55
- package/content/plugins/schema/createReadResolvers.d.ts +0 -10
- package/content/plugins/schema/createReadResolvers.js +0 -55
- package/content/plugins/schema/createReadSDL.d.ts +0 -9
- package/content/plugins/schema/createReadSDL.js +0 -96
- package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +0 -7
- package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveList.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +0 -23
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +0 -6
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +0 -23
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +0 -2
- package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +0 -7
- package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/preview/resolveGet.js +0 -38
- package/content/plugins/schema/resolvers/preview/resolveList.d.ts +0 -2
- package/content/plugins/schema/resolvers/read/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/read/resolveGet.js +0 -38
- package/content/plugins/schema/resolvers/read/resolveList.d.ts +0 -2
- package/content/plugins/schema/schemaPlugins.d.ts +0 -3
- package/content/plugins/schema/schemaPlugins.js +0 -92
- package/content/plugins/storage/StorageTransformPlugin.d.ts +0 -30
- package/content/plugins/storage/default.d.ts +0 -3
- package/content/plugins/storage/default.js +0 -28
- package/content/plugins/storage/object.d.ts +0 -3
- package/content/plugins/storage/object.js +0 -119
- package/content/plugins/utils/createTypeName.d.ts +0 -3
- package/content/plugins/utils/createTypeName.js +0 -28
- package/content/plugins/utils/getEntryTitle.d.ts +0 -2
- package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +0 -11
- package/content/plugins/utils/getSchemaFromFieldPlugins.js +0 -30
- package/content/plugins/utils/pluralizedTypeName.d.ts +0 -1
- package/content/plugins/utils/renderFields.d.ts +0 -16
- package/content/plugins/utils/renderGetFilterFields.d.ts +0 -9
- package/content/plugins/utils/renderGetFilterFields.js +0 -41
- package/content/plugins/utils/renderInputFields.d.ts +0 -14
- package/content/plugins/utils/renderListFilterFields.d.ts +0 -10
- package/content/plugins/utils/renderSortEnum.d.ts +0 -9
- package/content/plugins/utils/renderSortEnum.js +0 -32
- package/content/plugins/validators/dateGte.d.ts +0 -3
- package/content/plugins/validators/dateLte.d.ts +0 -3
- package/content/plugins/validators/gte.d.ts +0 -3
- package/content/plugins/validators/gte.js +0 -32
- package/content/plugins/validators/in.d.ts +0 -3
- package/content/plugins/validators/in.js +0 -32
- package/content/plugins/validators/index.d.ts +0 -2
- package/content/plugins/validators/index.js +0 -36
- package/content/plugins/validators/lte.d.ts +0 -3
- package/content/plugins/validators/lte.js +0 -32
- package/content/plugins/validators/maxLength.d.ts +0 -3
- package/content/plugins/validators/maxLength.js +0 -32
- package/content/plugins/validators/minLength.d.ts +0 -3
- package/content/plugins/validators/minLength.js +0 -32
- package/content/plugins/validators/pattern.d.ts +0 -3
- package/content/plugins/validators/pattern.js +0 -47
- package/content/plugins/validators/patternPlugins/email.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/email.js +0 -17
- package/content/plugins/validators/patternPlugins/index.d.ts +0 -2
- package/content/plugins/validators/patternPlugins/index.js +0 -19
- package/content/plugins/validators/patternPlugins/lowerCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/lowerCase.js +0 -17
- package/content/plugins/validators/patternPlugins/upperCase.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/upperCase.js +0 -17
- package/content/plugins/validators/patternPlugins/url.d.ts +0 -3
- package/content/plugins/validators/patternPlugins/url.js +0 -17
- package/content/plugins/validators/required.d.ts +0 -3
- package/content/plugins/validators/required.js +0 -25
- package/content/plugins/validators/timeGte.d.ts +0 -3
- package/content/plugins/validators/timeLte.d.ts +0 -3
- package/migrateCMSPermissions.d.ts +0 -17
- package/migrateCMSPermissions.js +0 -193
- package/plugins/context.d.ts +0 -4
- package/plugins/context.js +0 -34
- package/plugins/crud/index.d.ts +0 -6
- package/plugins/crud/index.js +0 -100
- package/plugins/crud/settings.crud.js +0 -93
- package/plugins/crud/system.crud.js +0 -182
- package/plugins/graphql/system.d.ts +0 -17
- package/plugins/graphql.d.ts +0 -2
- package/plugins/graphql.js +0 -79
- package/plugins/upgrades/index.d.ts +0 -2
- package/plugins/upgrades/index.js +0 -14
- package/plugins/upgrades/v5.5.0/helpers.d.ts +0 -6
- package/plugins/upgrades/v5.5.0/helpers.js +0 -10
- package/plugins/upgrades/v5.5.0/index.d.ts +0 -4
- package/plugins/upgrades/v5.5.0/index.js +0 -129
- package/transformers.d.ts +0 -2
- package/transformers.js +0 -25
- package/utils.d.ts +0 -25
- package/utils.js +0 -251
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createValueKeyToStorageConverter = exports.createValueKeyFromStorageConverter = exports.createCmsModelFieldConvertersAttachFactory = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _ConverterCollection = require("./ConverterCollection");
|
|
10
|
+
var _semver = _interopRequireDefault(require("semver"));
|
|
11
|
+
const featureVersion = _semver.default.coerce("5.33.0");
|
|
12
|
+
const isBetaOrNext = model => {
|
|
13
|
+
if (!model.webinyVersion) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return model.webinyVersion.match(/next|beta/) !== null;
|
|
17
|
+
};
|
|
18
|
+
const isFeatureEnabled = model => {
|
|
19
|
+
/**
|
|
20
|
+
* In case of disabled webinyVersion value, we disable this feature.
|
|
21
|
+
* This is only for testing...
|
|
22
|
+
*/
|
|
23
|
+
if (model.webinyVersion === "disable") {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* If is a test environment, always have this turned on.
|
|
28
|
+
*/
|
|
29
|
+
const nodeEnv = process.env.NODE_ENV;
|
|
30
|
+
if (nodeEnv === "test" || nodeEnv === "disable" || isBetaOrNext(model)) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Possibility that the version is not defined, this means it is a quite old system where models did not change.
|
|
35
|
+
*/
|
|
36
|
+
if (!model.webinyVersion) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* In case feature version value is greater than the model version, feature is not enabled as it is an older model with no storageId.
|
|
41
|
+
*
|
|
42
|
+
* TODO change if necessary after the update to the system
|
|
43
|
+
*/
|
|
44
|
+
const modelVersion = _semver.default.coerce(model.webinyVersion);
|
|
45
|
+
if (!modelVersion) {
|
|
46
|
+
console.log(`Warning: Model "${model.modelId}" does not have valid Webiny version set.`);
|
|
47
|
+
return true;
|
|
48
|
+
} else if (_semver.default.compare(modelVersion, featureVersion) === -1) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
};
|
|
53
|
+
const createValueKeyToStorageConverter = params => {
|
|
54
|
+
const {
|
|
55
|
+
plugins,
|
|
56
|
+
model
|
|
57
|
+
} = params;
|
|
58
|
+
if (isFeatureEnabled(model) === false) {
|
|
59
|
+
return ({
|
|
60
|
+
values
|
|
61
|
+
}) => {
|
|
62
|
+
return values || {};
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const converters = new _ConverterCollection.ConverterCollection({
|
|
66
|
+
plugins
|
|
67
|
+
});
|
|
68
|
+
return ({
|
|
69
|
+
fields,
|
|
70
|
+
values
|
|
71
|
+
}) => {
|
|
72
|
+
const result = converters.convertToStorage({
|
|
73
|
+
fields: fields || model.fields,
|
|
74
|
+
values
|
|
75
|
+
});
|
|
76
|
+
return result || {};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
exports.createValueKeyToStorageConverter = createValueKeyToStorageConverter;
|
|
80
|
+
const createValueKeyFromStorageConverter = params => {
|
|
81
|
+
const {
|
|
82
|
+
plugins,
|
|
83
|
+
model
|
|
84
|
+
} = params;
|
|
85
|
+
if (isFeatureEnabled(model) === false) {
|
|
86
|
+
return ({
|
|
87
|
+
values
|
|
88
|
+
}) => {
|
|
89
|
+
return values || {};
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const converters = new _ConverterCollection.ConverterCollection({
|
|
93
|
+
plugins
|
|
94
|
+
});
|
|
95
|
+
return ({
|
|
96
|
+
fields,
|
|
97
|
+
values
|
|
98
|
+
}) => {
|
|
99
|
+
const result = converters.convertFromStorage({
|
|
100
|
+
fields: fields || model.fields,
|
|
101
|
+
values
|
|
102
|
+
});
|
|
103
|
+
return result || {};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
exports.createValueKeyFromStorageConverter = createValueKeyFromStorageConverter;
|
|
107
|
+
const createCmsModelFieldConvertersAttachFactory = plugins => {
|
|
108
|
+
return model => {
|
|
109
|
+
const storageModel = model;
|
|
110
|
+
if (!!storageModel.convertValueKeyToStorage && !!storageModel.convertValueKeyFromStorage) {
|
|
111
|
+
return storageModel;
|
|
112
|
+
}
|
|
113
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, model), {}, {
|
|
114
|
+
convertValueKeyToStorage: createValueKeyToStorageConverter({
|
|
115
|
+
model,
|
|
116
|
+
plugins
|
|
117
|
+
}),
|
|
118
|
+
convertValueKeyFromStorage: createValueKeyFromStorageConverter({
|
|
119
|
+
model,
|
|
120
|
+
plugins
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
exports.createCmsModelFieldConvertersAttachFactory = createCmsModelFieldConvertersAttachFactory;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["featureVersion","semver","coerce","isBetaOrNext","model","webinyVersion","match","isFeatureEnabled","nodeEnv","process","env","NODE_ENV","modelVersion","console","log","modelId","compare","createValueKeyToStorageConverter","params","plugins","values","converters","ConverterCollection","fields","result","convertToStorage","createValueKeyFromStorageConverter","convertFromStorage","createCmsModelFieldConvertersAttachFactory","storageModel","convertValueKeyToStorage","convertValueKeyFromStorage"],"sources":["valueKeyStorageConverter.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsModelConverterCallable,\n ConverterCollection,\n ConverterCollectionConvertParams as BaseConverterCollectionConvertParams\n} from \"~/utils/converters/ConverterCollection\";\nimport { CmsModel, StorageOperationsCmsModel } from \"~/types\";\nimport semver, { SemVer } from \"semver\";\n\nconst featureVersion = semver.coerce(\"5.33.0\") as SemVer;\n\nconst isBetaOrNext = (model: CmsModel): boolean => {\n if (!model.webinyVersion) {\n return false;\n }\n return model.webinyVersion.match(/next|beta/) !== null;\n};\n\nconst isFeatureEnabled = (model: CmsModel): boolean => {\n /**\n * In case of disabled webinyVersion value, we disable this feature.\n * This is only for testing...\n */\n if (model.webinyVersion === \"disable\") {\n return false;\n }\n /**\n * If is a test environment, always have this turned on.\n */\n const nodeEnv = process.env.NODE_ENV as string;\n if (nodeEnv === \"test\" || nodeEnv === \"disable\" || isBetaOrNext(model)) {\n return true;\n }\n /**\n * Possibility that the version is not defined, this means it is a quite old system where models did not change.\n */\n if (!model.webinyVersion) {\n return false;\n }\n /**\n * In case feature version value is greater than the model version, feature is not enabled as it is an older model with no storageId.\n *\n * TODO change if necessary after the update to the system\n */\n const modelVersion = semver.coerce(model.webinyVersion);\n if (!modelVersion) {\n console.log(`Warning: Model \"${model.modelId}\" does not have valid Webiny version set.`);\n return true;\n } else if (semver.compare(modelVersion, featureVersion) === -1) {\n return false;\n }\n return true;\n};\n\ninterface Params {\n /**\n * We need a model to determine if the conversion feature is enabled.\n */\n model: CmsModel;\n plugins: PluginsContainer;\n}\n\n/**\n * In the first call of the converter we do not need the fields property as it will be taken directly from the model.\n */\ninterface ConverterCollectionConvertParams\n extends Omit<BaseConverterCollectionConvertParams, \"fields\"> {\n fields?: BaseConverterCollectionConvertParams[\"fields\"];\n}\n\nexport const createValueKeyToStorageConverter = (params: Params): CmsModelConverterCallable => {\n const { plugins, model } = params;\n\n if (isFeatureEnabled(model) === false) {\n return ({ values }: ConverterCollectionConvertParams) => {\n return values || {};\n };\n }\n\n const converters = new ConverterCollection({\n plugins\n });\n\n return ({ fields, values }: ConverterCollectionConvertParams) => {\n const result = converters.convertToStorage({\n fields: fields || model.fields,\n values\n });\n return result || {};\n };\n};\n\nexport const createValueKeyFromStorageConverter = (params: Params): CmsModelConverterCallable => {\n const { plugins, model } = params;\n\n if (isFeatureEnabled(model) === false) {\n return ({ values }: ConverterCollectionConvertParams) => {\n return values || {};\n };\n }\n\n const converters = new ConverterCollection({\n plugins\n });\n\n return ({ fields, values }: ConverterCollectionConvertParams) => {\n const result = converters.convertFromStorage({\n fields: fields || model.fields,\n values\n });\n return result || {};\n };\n};\n\nexport const createCmsModelFieldConvertersAttachFactory = (plugins: PluginsContainer) => {\n return (model: StorageOperationsCmsModel | CmsModel): StorageOperationsCmsModel => {\n const storageModel = model as Partial<StorageOperationsCmsModel>;\n if (!!storageModel.convertValueKeyToStorage && !!storageModel.convertValueKeyFromStorage) {\n return storageModel as StorageOperationsCmsModel;\n }\n return {\n ...model,\n convertValueKeyToStorage: createValueKeyToStorageConverter({\n model,\n plugins\n }),\n convertValueKeyFromStorage: createValueKeyFromStorageConverter({\n model,\n plugins\n })\n };\n };\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from "../types";
|
|
2
|
+
interface TypeFromFieldParams {
|
|
3
|
+
typeOfType: "type" | "input";
|
|
4
|
+
models: CmsModel[];
|
|
5
|
+
model: CmsModel;
|
|
6
|
+
type: ApiEndpoint;
|
|
7
|
+
typeNamePrefix: string;
|
|
8
|
+
fields: CmsModelField[];
|
|
9
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
10
|
+
}
|
|
11
|
+
interface TypeFromFieldResponse {
|
|
12
|
+
fieldType: string;
|
|
13
|
+
typeDefs: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const createTypeFromFields: (params: TypeFromFieldParams) => TypeFromFieldResponse | null;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createTypeFromFields = void 0;
|
|
7
|
+
var _renderFields = require("./renderFields");
|
|
8
|
+
var _renderInputFields = require("./renderInputFields");
|
|
9
|
+
const createTypeFromFields = params => {
|
|
10
|
+
const {
|
|
11
|
+
typeOfType,
|
|
12
|
+
model,
|
|
13
|
+
models,
|
|
14
|
+
type,
|
|
15
|
+
typeNamePrefix,
|
|
16
|
+
fields,
|
|
17
|
+
fieldTypePlugins
|
|
18
|
+
} = params;
|
|
19
|
+
const typeSuffix = typeOfType === "input" ? "Input" : "";
|
|
20
|
+
const mTypeName = model.singularApiName;
|
|
21
|
+
const typeFields = [];
|
|
22
|
+
const nestedTypes = [];
|
|
23
|
+
|
|
24
|
+
// Once the loop below starts, we'll be executing a recursive "object" type generation.
|
|
25
|
+
// The main trick here is that nested objects don't know who the parent is, and will generate
|
|
26
|
+
// type names using the "model", as if they're at the top level:
|
|
27
|
+
// Every time the types are returned, we need to replace the model name in the generated type name
|
|
28
|
+
// with the actual prefix which includes parent field name type.
|
|
29
|
+
const replace = new RegExp(`${mTypeName}_`, "g");
|
|
30
|
+
for (const field of fields) {
|
|
31
|
+
const result = typeOfType === "type" ? (0, _renderFields.renderField)({
|
|
32
|
+
field,
|
|
33
|
+
type,
|
|
34
|
+
models,
|
|
35
|
+
model,
|
|
36
|
+
fieldTypePlugins
|
|
37
|
+
}) : (0, _renderInputFields.renderInputField)({
|
|
38
|
+
field,
|
|
39
|
+
models,
|
|
40
|
+
model,
|
|
41
|
+
fieldTypePlugins
|
|
42
|
+
});
|
|
43
|
+
if (!result) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const {
|
|
47
|
+
fields,
|
|
48
|
+
typeDefs
|
|
49
|
+
} = result;
|
|
50
|
+
typeFields.push(fields.replace(replace, `${typeNamePrefix}_`));
|
|
51
|
+
if (typeDefs) {
|
|
52
|
+
nestedTypes.push(typeDefs.replace(replace, `${typeNamePrefix}_`));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
fieldType: `${typeNamePrefix}${typeSuffix}`,
|
|
57
|
+
typeDefs: /* GraphQL */`
|
|
58
|
+
${nestedTypes.join("\n")}
|
|
59
|
+
|
|
60
|
+
${typeOfType} ${typeNamePrefix}${typeSuffix} {
|
|
61
|
+
${typeFields.join("\n")}
|
|
62
|
+
}
|
|
63
|
+
`
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
exports.createTypeFromFields = createTypeFromFields;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createTypeFromFields","params","typeOfType","model","models","type","typeNamePrefix","fields","fieldTypePlugins","typeSuffix","mTypeName","singularApiName","typeFields","nestedTypes","replace","RegExp","field","result","renderField","renderInputField","typeDefs","push","fieldType","join"],"sources":["createTypeFromFields.ts"],"sourcesContent":["import { renderField } from \"~/utils/renderFields\";\nimport { renderInputField } from \"~/utils/renderInputFields\";\nimport { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from \"~/types\";\n\ninterface TypeFromFieldParams {\n typeOfType: \"type\" | \"input\";\n models: CmsModel[];\n model: CmsModel;\n type: ApiEndpoint;\n typeNamePrefix: string;\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface TypeFromFieldResponse {\n fieldType: string;\n typeDefs: string;\n}\n\nexport const createTypeFromFields = (params: TypeFromFieldParams): TypeFromFieldResponse | null => {\n const { typeOfType, model, models, type, typeNamePrefix, fields, fieldTypePlugins } = params;\n const typeSuffix = typeOfType === \"input\" ? \"Input\" : \"\";\n const mTypeName = model.singularApiName;\n\n const typeFields: string[] = [];\n const nestedTypes: string[] = [];\n\n // Once the loop below starts, we'll be executing a recursive \"object\" type generation.\n // The main trick here is that nested objects don't know who the parent is, and will generate\n // type names using the \"model\", as if they're at the top level:\n // Every time the types are returned, we need to replace the model name in the generated type name\n // with the actual prefix which includes parent field name type.\n const replace = new RegExp(`${mTypeName}_`, \"g\");\n\n for (const field of fields) {\n const result =\n typeOfType === \"type\"\n ? renderField({ field, type, models, model, fieldTypePlugins })\n : renderInputField({ field, models, model, fieldTypePlugins });\n\n if (!result) {\n continue;\n }\n\n const { fields, typeDefs } = result;\n\n typeFields.push(fields.replace(replace, `${typeNamePrefix}_`));\n if (typeDefs) {\n nestedTypes.push(typeDefs.replace(replace, `${typeNamePrefix}_`));\n }\n }\n\n return {\n fieldType: `${typeNamePrefix}${typeSuffix}`,\n typeDefs: /* GraphQL */ `\n ${nestedTypes.join(\"\\n\")}\n\n ${typeOfType} ${typeNamePrefix}${typeSuffix} {\n ${typeFields.join(\"\\n\")}\n }\n `\n };\n};\n"],"mappings":";;;;;;AAAA;AACA;AAkBO,MAAMA,oBAAoB,GAAIC,MAA2B,IAAmC;EAC/F,MAAM;IAAEC,UAAU;IAAEC,KAAK;IAAEC,MAAM;IAAEC,IAAI;IAAEC,cAAc;IAAEC,MAAM;IAAEC;EAAiB,CAAC,GAAGP,MAAM;EAC5F,MAAMQ,UAAU,GAAGP,UAAU,KAAK,OAAO,GAAG,OAAO,GAAG,EAAE;EACxD,MAAMQ,SAAS,GAAGP,KAAK,CAACQ,eAAe;EAEvC,MAAMC,UAAoB,GAAG,EAAE;EAC/B,MAAMC,WAAqB,GAAG,EAAE;;EAEhC;EACA;EACA;EACA;EACA;EACA,MAAMC,OAAO,GAAG,IAAIC,MAAM,CAAE,GAAEL,SAAU,GAAE,EAAE,GAAG,CAAC;EAEhD,KAAK,MAAMM,KAAK,IAAIT,MAAM,EAAE;IACxB,MAAMU,MAAM,GACRf,UAAU,KAAK,MAAM,GACf,IAAAgB,yBAAW,EAAC;MAAEF,KAAK;MAAEX,IAAI;MAAED,MAAM;MAAED,KAAK;MAAEK;IAAiB,CAAC,CAAC,GAC7D,IAAAW,mCAAgB,EAAC;MAAEH,KAAK;MAAEZ,MAAM;MAAED,KAAK;MAAEK;IAAiB,CAAC,CAAC;IAEtE,IAAI,CAACS,MAAM,EAAE;MACT;IACJ;IAEA,MAAM;MAAEV,MAAM;MAAEa;IAAS,CAAC,GAAGH,MAAM;IAEnCL,UAAU,CAACS,IAAI,CAACd,MAAM,CAACO,OAAO,CAACA,OAAO,EAAG,GAAER,cAAe,GAAE,CAAC,CAAC;IAC9D,IAAIc,QAAQ,EAAE;MACVP,WAAW,CAACQ,IAAI,CAACD,QAAQ,CAACN,OAAO,CAACA,OAAO,EAAG,GAAER,cAAe,GAAE,CAAC,CAAC;IACrE;EACJ;EAEA,OAAO;IACHgB,SAAS,EAAG,GAAEhB,cAAe,GAAEG,UAAW,EAAC;IAC3CW,QAAQ,EAAE,aAAe;AACjC,cAAcP,WAAW,CAACU,IAAI,CAAC,IAAI,CAAE;AACrC;AACA,cAAcrB,UAAW,IAAGI,cAAe,GAAEG,UAAW;AACxD,kBAAkBG,UAAU,CAACW,IAAI,CAAC,IAAI,CAAE;AACxC;AACA;EACI,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createTypeName: (modelId: string) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createTypeName = void 0;
|
|
8
|
+
var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
|
|
9
|
+
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
10
|
+
const createTypeName = modelId => {
|
|
11
|
+
return (0, _upperFirst.default)((0, _camelCase.default)(modelId));
|
|
12
|
+
};
|
|
13
|
+
exports.createTypeName = createTypeName;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createTypeName","modelId","upperFirst","camelCase"],"sources":["createTypeName.ts"],"sourcesContent":["import upperFirst from \"lodash/upperFirst\";\nimport camelCase from \"lodash/camelCase\";\n\nexport const createTypeName = (modelId: string): string => {\n return upperFirst(camelCase(modelId));\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEO,MAAMA,cAAc,GAAIC,OAAe,IAAa;EACvD,OAAO,IAAAC,mBAAU,EAAC,IAAAC,kBAAS,EAACF,OAAO,CAAC,CAAC;AACzC,CAAC;AAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CmsEntry, CmsModel, CmsModelField, CmsContext } from "
|
|
1
|
+
import { CmsEntry, CmsModel, CmsModelField, CmsContext } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* A function that is used in crud to transform entry into the storage type.
|
|
4
4
|
*/
|
|
@@ -6,12 +6,12 @@ export declare const entryToStorageTransform: (context: CmsContext, model: CmsMo
|
|
|
6
6
|
/**
|
|
7
7
|
* A function that is used to transform the whole entry from storage into its native form.
|
|
8
8
|
*/
|
|
9
|
-
export declare const entryFromStorageTransform: (context: CmsContext, model: CmsModel, entry
|
|
9
|
+
export declare const entryFromStorageTransform: (context: CmsContext, model: CmsModel, entry: CmsEntry) => Promise<CmsEntry>;
|
|
10
10
|
interface EntryFieldFromStorageTransformParams {
|
|
11
11
|
context: CmsContext;
|
|
12
12
|
model: CmsModel;
|
|
13
13
|
field: CmsModelField;
|
|
14
14
|
value: any;
|
|
15
15
|
}
|
|
16
|
-
export declare const entryFieldFromStorageTransform: (params: EntryFieldFromStorageTransformParams) => Promise<
|
|
16
|
+
export declare const entryFieldFromStorageTransform: <T = any>(params: EntryFieldFromStorageTransformParams) => Promise<T>;
|
|
17
17
|
export {};
|
|
@@ -1,63 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.entryToStorageTransform = exports.entryFromStorageTransform = exports.entryFieldFromStorageTransform = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
12
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
-
|
|
10
|
+
var _StorageTransformPlugin = require("../plugins/StorageTransformPlugin");
|
|
11
|
+
var _getBaseFieldType = require("./getBaseFieldType");
|
|
20
12
|
const getStoragePluginFactory = context => {
|
|
21
13
|
let defaultStoragePlugin;
|
|
22
|
-
const plugins = context.plugins.byType(_StorageTransformPlugin.StorageTransformPlugin.type)
|
|
14
|
+
const plugins = context.plugins.byType(_StorageTransformPlugin.StorageTransformPlugin.type)
|
|
15
|
+
// we reverse plugins because we want to get latest added only
|
|
23
16
|
.reverse().reduce((collection, plugin) => {
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Check if it's a default plugin and set it - always override the previous one.
|
|
19
|
+
*/
|
|
20
|
+
if (plugin.fieldType === "*") {
|
|
26
21
|
defaultStoragePlugin = plugin;
|
|
27
22
|
return collection;
|
|
28
23
|
}
|
|
24
|
+
|
|
29
25
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
26
|
+
* We will just set the plugin for given type.
|
|
27
|
+
* The last one will override existing one - so users can override our default ones.
|
|
32
28
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!collection[plugin.fieldType]) {
|
|
36
|
-
collection[plugin.fieldType] = plugin;
|
|
37
|
-
}
|
|
38
|
-
|
|
29
|
+
collection[plugin.fieldType] = plugin;
|
|
39
30
|
return collection;
|
|
40
31
|
}, {});
|
|
41
32
|
return fieldType => {
|
|
42
33
|
return plugins[fieldType] || defaultStoragePlugin;
|
|
43
34
|
};
|
|
44
35
|
};
|
|
36
|
+
|
|
45
37
|
/**
|
|
46
38
|
* This should be used when transforming the whole entry.
|
|
47
39
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
40
|
const entryStorageTransform = async (context, model, operation, entry) => {
|
|
51
41
|
const getStoragePlugin = getStoragePluginFactory(context);
|
|
52
42
|
const transformedValues = {};
|
|
53
|
-
|
|
54
43
|
for (const field of model.fields) {
|
|
55
|
-
const
|
|
56
|
-
|
|
44
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
45
|
+
const plugin = getStoragePlugin(baseType);
|
|
46
|
+
// TODO: remove this once plugins are converted into classes
|
|
57
47
|
if (typeof plugin[operation] !== "function") {
|
|
58
|
-
throw new _error.default(`Missing "${operation}" function in storage plugin "${plugin.name}" for field type "${
|
|
48
|
+
throw new _error.default(`Missing "${operation}" function in storage plugin "${plugin.name}" for field type "${baseType}"`);
|
|
59
49
|
}
|
|
60
|
-
|
|
61
50
|
transformedValues[field.fieldId] = await plugin[operation]({
|
|
62
51
|
plugins: context.plugins,
|
|
63
52
|
model,
|
|
@@ -66,36 +55,26 @@ const entryStorageTransform = async (context, model, operation, entry) => {
|
|
|
66
55
|
getStoragePlugin
|
|
67
56
|
});
|
|
68
57
|
}
|
|
69
|
-
|
|
70
|
-
return _objectSpread(_objectSpread({}, entry), {}, {
|
|
58
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
71
59
|
values: transformedValues
|
|
72
60
|
});
|
|
73
61
|
};
|
|
62
|
+
|
|
74
63
|
/**
|
|
75
64
|
* A function that is used in crud to transform entry into the storage type.
|
|
76
65
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
66
|
const entryToStorageTransform = async (context, model, entry) => {
|
|
80
67
|
return entryStorageTransform(context, model, "toStorage", entry);
|
|
81
68
|
};
|
|
69
|
+
|
|
82
70
|
/**
|
|
83
71
|
* A function that is used to transform the whole entry from storage into its native form.
|
|
84
72
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
73
|
exports.entryToStorageTransform = entryToStorageTransform;
|
|
88
|
-
|
|
89
74
|
const entryFromStorageTransform = async (context, model, entry) => {
|
|
90
|
-
if (!entry) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
75
|
return entryStorageTransform(context, model, "fromStorage", entry);
|
|
95
76
|
};
|
|
96
|
-
|
|
97
77
|
exports.entryFromStorageTransform = entryFromStorageTransform;
|
|
98
|
-
|
|
99
78
|
/*
|
|
100
79
|
* A function that is used to transform a single field from storage
|
|
101
80
|
*/
|
|
@@ -107,12 +86,13 @@ const entryFieldFromStorageTransform = async params => {
|
|
|
107
86
|
value
|
|
108
87
|
} = params;
|
|
109
88
|
const getStoragePlugin = getStoragePluginFactory(context);
|
|
110
|
-
const
|
|
89
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
90
|
+
const plugin = getStoragePlugin(baseType);
|
|
111
91
|
|
|
92
|
+
// TODO: remove this once plugins are converted into classes
|
|
112
93
|
if (typeof plugin.fromStorage !== "function") {
|
|
113
|
-
throw new _error.default(`Missing "fromStorage" function in storage plugin "${plugin.name}" for field type "${
|
|
94
|
+
throw new _error.default(`Missing "fromStorage" function in storage plugin "${plugin.name}" for field type "${baseType}"`);
|
|
114
95
|
}
|
|
115
|
-
|
|
116
96
|
return plugin.fromStorage({
|
|
117
97
|
plugins: context.plugins,
|
|
118
98
|
model,
|
|
@@ -121,5 +101,4 @@ const entryFieldFromStorageTransform = async params => {
|
|
|
121
101
|
getStoragePlugin
|
|
122
102
|
});
|
|
123
103
|
};
|
|
124
|
-
|
|
125
104
|
exports.entryFieldFromStorageTransform = entryFieldFromStorageTransform;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getStoragePluginFactory","context","defaultStoragePlugin","plugins","byType","StorageTransformPlugin","type","reverse","reduce","collection","plugin","fieldType","entryStorageTransform","model","operation","entry","getStoragePlugin","transformedValues","field","fields","baseType","getBaseFieldType","WebinyError","name","fieldId","value","values","entryToStorageTransform","entryFromStorageTransform","entryFieldFromStorageTransform","params","fromStorage"],"sources":["entryStorage.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"~/plugins/StorageTransformPlugin\";\nimport { CmsEntry, CmsModel, CmsModelField, CmsContext } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface GetStoragePluginFactory {\n (context: CmsContext): (fieldType: string) => StorageTransformPlugin<any>;\n}\n\nconst getStoragePluginFactory: GetStoragePluginFactory = context => {\n let defaultStoragePlugin: StorageTransformPlugin;\n\n const plugins = context.plugins\n .byType<StorageTransformPlugin>(StorageTransformPlugin.type)\n // we reverse plugins because we want to get latest added only\n .reverse()\n .reduce((collection, plugin) => {\n /**\n * Check if it's a default plugin and set it - always override the previous one.\n */\n if (plugin.fieldType === \"*\") {\n defaultStoragePlugin = plugin;\n return collection;\n }\n\n /**\n * We will just set the plugin for given type.\n * The last one will override existing one - so users can override our default ones.\n */\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {} as Record<string, StorageTransformPlugin>);\n\n return (fieldType: string) => {\n return plugins[fieldType] || defaultStoragePlugin;\n };\n};\n\n/**\n * This should be used when transforming the whole entry.\n */\nconst entryStorageTransform = async (\n context: CmsContext,\n model: CmsModel,\n operation: \"toStorage\" | \"fromStorage\",\n entry: CmsEntry\n): Promise<CmsEntry> => {\n const getStoragePlugin = getStoragePluginFactory(context);\n\n const transformedValues: Record<string, any> = {};\n for (const field of model.fields) {\n const baseType = getBaseFieldType(field);\n const plugin = getStoragePlugin(baseType);\n // TODO: remove this once plugins are converted into classes\n if (typeof plugin[operation] !== \"function\") {\n throw new WebinyError(\n `Missing \"${operation}\" function in storage plugin \"${plugin.name}\" for field type \"${baseType}\"`\n );\n }\n\n transformedValues[field.fieldId] = await plugin[operation]({\n plugins: context.plugins,\n model,\n field,\n value: entry.values[field.fieldId],\n getStoragePlugin\n });\n }\n\n return { ...entry, values: transformedValues };\n};\n\n/**\n * A function that is used in crud to transform entry into the storage type.\n */\nexport const entryToStorageTransform = async (\n context: CmsContext,\n model: CmsModel,\n entry: CmsEntry\n): Promise<CmsEntry> => {\n return entryStorageTransform(context, model, \"toStorage\", entry);\n};\n\n/**\n * A function that is used to transform the whole entry from storage into its native form.\n */\nexport const entryFromStorageTransform = async (\n context: CmsContext,\n model: CmsModel,\n entry: CmsEntry\n): Promise<CmsEntry> => {\n return entryStorageTransform(context, model, \"fromStorage\", entry);\n};\n\ninterface EntryFieldFromStorageTransformParams {\n context: CmsContext;\n model: CmsModel;\n field: CmsModelField;\n value: any;\n}\n/*\n * A function that is used to transform a single field from storage\n */\nexport const entryFieldFromStorageTransform = async <T = any>(\n params: EntryFieldFromStorageTransformParams\n): Promise<T> => {\n const { context, model, field, value } = params;\n const getStoragePlugin = getStoragePluginFactory(context);\n\n const baseType = getBaseFieldType(field);\n const plugin = getStoragePlugin(baseType);\n\n // TODO: remove this once plugins are converted into classes\n if (typeof plugin.fromStorage !== \"function\") {\n throw new WebinyError(\n `Missing \"fromStorage\" function in storage plugin \"${plugin.name}\" for field type \"${baseType}\"`\n );\n }\n\n return plugin.fromStorage({\n plugins: context.plugins,\n model,\n field,\n value,\n getStoragePlugin\n });\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const filterAsync: <T = Record<string, any>>(items: T[], predicate: (param: T) => Promise<boolean>) => Promise<T[]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.filterAsync = void 0;
|
|
7
|
+
const filterAsync = async (items, predicate) => {
|
|
8
|
+
const filteredItems = [];
|
|
9
|
+
for (let i = 0; i < items.length; i++) {
|
|
10
|
+
const item = items[i];
|
|
11
|
+
const valid = await predicate(item);
|
|
12
|
+
if (valid) {
|
|
13
|
+
filteredItems.push(item);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return filteredItems;
|
|
17
|
+
};
|
|
18
|
+
exports.filterAsync = filterAsync;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["filterAsync","items","predicate","filteredItems","i","length","item","valid","push"],"sources":["filterAsync.ts"],"sourcesContent":["export const filterAsync = async <T = Record<string, any>>(\n items: T[],\n predicate: (param: T) => Promise<boolean>\n): Promise<T[]> => {\n const filteredItems = [];\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const valid = await predicate(item);\n if (valid) {\n filteredItems.push(item);\n }\n }\n\n return filteredItems;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,WAAW,GAAG,OACvBC,KAAU,EACVC,SAAyC,KAC1B;EACf,MAAMC,aAAa,GAAG,EAAE;EAExB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,KAAK,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;IACnC,MAAME,IAAI,GAAGL,KAAK,CAACG,CAAC,CAAC;IACrB,MAAMG,KAAK,GAAG,MAAML,SAAS,CAACI,IAAI,CAAC;IACnC,IAAIC,KAAK,EAAE;MACPJ,aAAa,CAACK,IAAI,CAACF,IAAI,CAAC;IAC5B;EACJ;EAEA,OAAOH,aAAa;AACxB,CAAC;AAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getBaseFieldType","field","type","split"],"sources":["getBaseFieldType.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\n\nexport const getBaseFieldType = (field: { type: CmsModelField[\"type\"] }) => {\n return field.type.split(\":\")[0];\n};\n"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAIC,KAAsC,IAAK;EACxE,OAAOA,KAAK,CAACC,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEntryDescription = getEntryDescription;
|
|
7
|
+
function getEntryDescription(model, entry) {
|
|
8
|
+
if (!model.descriptionFieldId) {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);
|
|
12
|
+
if (!field) {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
const descriptionFieldId = field.fieldId;
|
|
16
|
+
return entry.values[descriptionFieldId] || "";
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getEntryDescription","model","entry","descriptionFieldId","field","fields","find","f","fieldId","values"],"sources":["getEntryDescription.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryDescription(model: CmsModel, entry: CmsEntry): string {\n if (!model.descriptionFieldId) {\n return \"\";\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return \"\";\n }\n const descriptionFieldId = field.fieldId;\n return entry.values[descriptionFieldId] || \"\";\n}\n"],"mappings":";;;;;;AAEO,SAASA,mBAAmB,CAACC,KAAe,EAAEC,KAAe,EAAU;EAC1E,IAAI,CAACD,KAAK,CAACE,kBAAkB,EAAE;IAC3B,OAAO,EAAE;EACb;EACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKP,KAAK,CAACE,kBAAkB,CAAC;EAC5E,IAAI,CAACC,KAAK,EAAE;IACR,OAAO,EAAE;EACb;EACA,MAAMD,kBAAkB,GAAGC,KAAK,CAACI,OAAO;EACxC,OAAON,KAAK,CAACO,MAAM,CAACN,kBAAkB,CAAC,IAAI,EAAE;AACjD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEntryImage = getEntryImage;
|
|
7
|
+
function getEntryImage(model, entry) {
|
|
8
|
+
if (!model.imageFieldId) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const field = model.fields.find(f => f.fieldId === model.imageFieldId);
|
|
12
|
+
if (!field) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const imageFieldId = field.fieldId;
|
|
16
|
+
return entry.values[imageFieldId] || null;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getEntryImage","model","entry","imageFieldId","field","fields","find","f","fieldId","values"],"sources":["getEntryImage.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryImage(model: CmsModel, entry: CmsEntry): string | null {\n if (!model.imageFieldId) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.imageFieldId);\n if (!field) {\n return null;\n }\n const imageFieldId = field.fieldId;\n return entry.values[imageFieldId] || null;\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAa,CAACC,KAAe,EAAEC,KAAe,EAAiB;EAC3E,IAAI,CAACD,KAAK,CAACE,YAAY,EAAE;IACrB,OAAO,IAAI;EACf;EACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKP,KAAK,CAACE,YAAY,CAAC;EACtE,IAAI,CAACC,KAAK,EAAE;IACR,OAAO,IAAI;EACf;EACA,MAAMD,YAAY,GAAGC,KAAK,CAACI,OAAO;EAClC,OAAON,KAAK,CAACO,MAAM,CAACN,YAAY,CAAC,IAAI,IAAI;AAC7C"}
|
|
@@ -4,39 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getEntryTitle = getEntryTitle;
|
|
7
|
-
|
|
8
7
|
function getEntryTitle(model, entry) {
|
|
9
8
|
if (!model.titleFieldId) {
|
|
10
9
|
return entry.id;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
const titleValue = entry.values[model.titleFieldId];
|
|
14
|
-
|
|
15
|
-
if (!titleValue) {
|
|
16
|
-
return entry.id;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
11
|
const field = model.fields.find(f => f.fieldId === model.titleFieldId);
|
|
20
|
-
|
|
21
12
|
if (!field) {
|
|
22
|
-
return
|
|
13
|
+
return entry.id;
|
|
14
|
+
}
|
|
15
|
+
const titleFieldId = field.fieldId;
|
|
16
|
+
const titleValue = entry.values[titleFieldId];
|
|
17
|
+
if (!titleValue) {
|
|
18
|
+
return entry.id;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
const {
|
|
26
21
|
enabled = false,
|
|
27
22
|
values
|
|
28
23
|
} = field.predefinedValues || {};
|
|
29
|
-
|
|
30
|
-
if (!enabled || Array.isArray(values) === false) {
|
|
24
|
+
if (!enabled || !values || Array.isArray(values) === false) {
|
|
31
25
|
return titleValue;
|
|
32
26
|
}
|
|
33
|
-
|
|
34
27
|
for (const value of values) {
|
|
35
28
|
// needs to be loose because titleValue can be a number and value can be a string - but it must match
|
|
36
29
|
if (value.value == titleValue) {
|
|
37
30
|
return value.label;
|
|
38
31
|
}
|
|
39
32
|
}
|
|
40
|
-
|
|
41
33
|
return titleValue;
|
|
42
34
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getEntryTitle","model","entry","titleFieldId","id","field","fields","find","f","fieldId","titleValue","values","enabled","predefinedValues","Array","isArray","value","label"],"sources":["getEntryTitle.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryTitle(model: CmsModel, entry: CmsEntry): string {\n if (!model.titleFieldId) {\n return entry.id;\n }\n const field = model.fields.find(f => f.fieldId === model.titleFieldId);\n if (!field) {\n return entry.id;\n }\n const titleFieldId = field.fieldId;\n const titleValue = entry.values[titleFieldId];\n if (!titleValue) {\n return entry.id;\n }\n\n const { enabled = false, values } = field.predefinedValues || {};\n if (!enabled || !values || Array.isArray(values) === false) {\n return titleValue;\n }\n for (const value of values) {\n // needs to be loose because titleValue can be a number and value can be a string - but it must match\n if (value.value == titleValue) {\n return value.label;\n }\n }\n return titleValue;\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAa,CAACC,KAAe,EAAEC,KAAe,EAAU;EACpE,IAAI,CAACD,KAAK,CAACE,YAAY,EAAE;IACrB,OAAOD,KAAK,CAACE,EAAE;EACnB;EACA,MAAMC,KAAK,GAAGJ,KAAK,CAACK,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKR,KAAK,CAACE,YAAY,CAAC;EACtE,IAAI,CAACE,KAAK,EAAE;IACR,OAAOH,KAAK,CAACE,EAAE;EACnB;EACA,MAAMD,YAAY,GAAGE,KAAK,CAACI,OAAO;EAClC,MAAMC,UAAU,GAAGR,KAAK,CAACS,MAAM,CAACR,YAAY,CAAC;EAC7C,IAAI,CAACO,UAAU,EAAE;IACb,OAAOR,KAAK,CAACE,EAAE;EACnB;EAEA,MAAM;IAAEQ,OAAO,GAAG,KAAK;IAAED;EAAO,CAAC,GAAGN,KAAK,CAACQ,gBAAgB,IAAI,CAAC,CAAC;EAChE,IAAI,CAACD,OAAO,IAAI,CAACD,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,KAAK,KAAK,EAAE;IACxD,OAAOD,UAAU;EACrB;EACA,KAAK,MAAMM,KAAK,IAAIL,MAAM,EAAE;IACxB;IACA,IAAIK,KAAK,CAACA,KAAK,IAAIN,UAAU,EAAE;MAC3B,OAAOM,KAAK,CAACC,KAAK;IACtB;EACJ;EACA,OAAOP,UAAU;AACrB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CmsModel, CmsFieldTypePlugins, ApiEndpoint } from "../types";
|
|
2
|
+
import { CmsGraphQLSchemaPlugin } from "../plugins";
|
|
3
|
+
interface Params {
|
|
4
|
+
models: CmsModel[];
|
|
5
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
|
+
type: ApiEndpoint;
|
|
7
|
+
}
|
|
8
|
+
export declare const createGraphQLSchemaPluginFromFieldPlugins: (params: Params) => CmsGraphQLSchemaPlugin<import("../types").CmsContext>[];
|
|
9
|
+
export {};
|