@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
|
@@ -3,14 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.createSystemSchemaPlugin = void 0;
|
|
8
7
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
8
|
+
var _api = require("@webiny/api");
|
|
9
|
+
const emptyResolver = () => ({});
|
|
10
|
+
const plugin = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
11
|
+
typeDefs: /* GraphQL */`
|
|
12
|
+
extend type Query {
|
|
13
|
+
cms: CmsQuery
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
extend type Mutation {
|
|
17
|
+
cms: CmsMutation
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type CmsQuery {
|
|
21
|
+
_empty: String
|
|
22
|
+
}
|
|
9
23
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
`
|
|
24
|
+
type CmsMutation {
|
|
25
|
+
_empty: String
|
|
26
|
+
}
|
|
14
27
|
extend type CmsQuery {
|
|
15
28
|
# Get installed version
|
|
16
29
|
version: String
|
|
@@ -19,12 +32,15 @@ var _default = {
|
|
|
19
32
|
extend type CmsMutation {
|
|
20
33
|
# Install CMS
|
|
21
34
|
install: CmsBooleanResponse
|
|
22
|
-
|
|
23
|
-
# Upgrade CMS
|
|
24
|
-
upgrade(version: String!): CmsBooleanResponse
|
|
25
35
|
}
|
|
26
36
|
`,
|
|
27
37
|
resolvers: {
|
|
38
|
+
Query: {
|
|
39
|
+
cms: emptyResolver
|
|
40
|
+
},
|
|
41
|
+
Mutation: {
|
|
42
|
+
cms: emptyResolver
|
|
43
|
+
},
|
|
28
44
|
CmsQuery: {
|
|
29
45
|
version: async (_, __, context) => {
|
|
30
46
|
try {
|
|
@@ -40,33 +56,32 @@ var _default = {
|
|
|
40
56
|
}) => {
|
|
41
57
|
try {
|
|
42
58
|
const version = await cms.getSystemVersion();
|
|
43
|
-
|
|
44
59
|
if (version) {
|
|
45
60
|
return new _handlerGraphql.ErrorResponse({
|
|
46
61
|
code: "CMS_INSTALLATION_ERROR",
|
|
47
62
|
message: "CMS is already installed."
|
|
48
63
|
});
|
|
49
64
|
}
|
|
50
|
-
|
|
51
65
|
await cms.installSystem();
|
|
52
66
|
return new _handlerGraphql.Response(true);
|
|
53
67
|
} catch (e) {
|
|
54
68
|
return new _handlerGraphql.ErrorResponse(e);
|
|
55
69
|
}
|
|
56
|
-
},
|
|
57
|
-
upgrade: async (_, {
|
|
58
|
-
version
|
|
59
|
-
}, {
|
|
60
|
-
cms
|
|
61
|
-
}) => {
|
|
62
|
-
try {
|
|
63
|
-
await cms.upgradeSystem(version);
|
|
64
|
-
return new _handlerGraphql.Response(true);
|
|
65
|
-
} catch (e) {
|
|
66
|
-
return new _handlerGraphql.ErrorResponse(e);
|
|
67
|
-
}
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
}
|
|
73
|
+
});
|
|
74
|
+
plugin.name = "cms.graphql.schema.system";
|
|
75
|
+
/**
|
|
76
|
+
* We only register system schema plugin if the endpoint is not manage/preview/read.
|
|
77
|
+
*/
|
|
78
|
+
const createSystemSchemaPlugin = () => {
|
|
79
|
+
return new _api.ContextPlugin(async context => {
|
|
80
|
+
var _context$cms;
|
|
81
|
+
if ((_context$cms = context.cms) !== null && _context$cms !== void 0 && _context$cms.type) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
context.plugins.register(plugin);
|
|
85
|
+
});
|
|
71
86
|
};
|
|
72
|
-
exports.
|
|
87
|
+
exports.createSystemSchemaPlugin = createSystemSchemaPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["emptyResolver","plugin","GraphQLSchemaPlugin","typeDefs","resolvers","Query","cms","Mutation","CmsQuery","version","_","__","context","getSystemVersion","e","ErrorResponse","CmsMutation","install","code","message","installSystem","Response","name","createSystemSchemaPlugin","ContextPlugin","type","plugins","register"],"sources":["system.ts"],"sourcesContent":["import { ErrorResponse, GraphQLSchemaPlugin, Response } from \"@webiny/handler-graphql\";\nimport { CmsContext } from \"~/types\";\nimport { ContextPlugin } from \"@webiny/api\";\n\nconst emptyResolver = () => ({});\n\nconst plugin = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n extend type Query {\n cms: CmsQuery\n }\n\n extend type Mutation {\n cms: CmsMutation\n }\n\n type CmsQuery {\n _empty: String\n }\n\n type CmsMutation {\n _empty: String\n }\n extend type CmsQuery {\n # Get installed version\n version: String\n }\n\n extend type CmsMutation {\n # Install CMS\n install: CmsBooleanResponse\n }\n `,\n resolvers: {\n Query: {\n cms: emptyResolver\n },\n Mutation: {\n cms: emptyResolver\n },\n CmsQuery: {\n version: async (_: any, __: any, context: CmsContext) => {\n try {\n return context.cms.getSystemVersion();\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n CmsMutation: {\n install: async (_: any, __: any, { cms }: CmsContext) => {\n try {\n const version = await cms.getSystemVersion();\n if (version) {\n return new ErrorResponse({\n code: \"CMS_INSTALLATION_ERROR\",\n message: \"CMS is already installed.\"\n });\n }\n\n await cms.installSystem();\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n }\n }\n});\nplugin.name = \"cms.graphql.schema.system\";\n/**\n * We only register system schema plugin if the endpoint is not manage/preview/read.\n */\nexport const createSystemSchemaPlugin = (): ContextPlugin<CmsContext> => {\n return new ContextPlugin<CmsContext>(async context => {\n if (context.cms?.type) {\n return;\n }\n context.plugins.register(plugin);\n });\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAEA,MAAMA,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC;AAEhC,MAAMC,MAAM,GAAG,IAAIC,mCAAmB,CAAC;EACnCC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,KAA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Property(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createBooleanField = void 0;
|
|
7
|
+
var _helpers = require("./helpers");
|
|
8
|
+
const createListFilters = ({
|
|
9
|
+
field
|
|
10
|
+
}) => {
|
|
11
|
+
return `
|
|
12
|
+
${field.fieldId}: Boolean
|
|
13
|
+
${field.fieldId}_not: Boolean
|
|
14
|
+
`;
|
|
15
|
+
};
|
|
16
|
+
const createBooleanField = () => {
|
|
17
|
+
return {
|
|
18
|
+
name: "cms-model-field-to-graphql-boolean",
|
|
19
|
+
type: "cms-model-field-to-graphql",
|
|
20
|
+
fieldType: "boolean",
|
|
21
|
+
isSortable: true,
|
|
22
|
+
isSearchable: true,
|
|
23
|
+
read: {
|
|
24
|
+
createListFilters,
|
|
25
|
+
createGetFilters({
|
|
26
|
+
field
|
|
27
|
+
}) {
|
|
28
|
+
return `${field.fieldId}: Boolean`;
|
|
29
|
+
},
|
|
30
|
+
createTypeField({
|
|
31
|
+
field
|
|
32
|
+
}) {
|
|
33
|
+
if (field.multipleValues) {
|
|
34
|
+
return `${field.fieldId}: [Boolean]`;
|
|
35
|
+
}
|
|
36
|
+
return `${field.fieldId}: Boolean`;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
manage: {
|
|
40
|
+
createListFilters,
|
|
41
|
+
createTypeField({
|
|
42
|
+
field
|
|
43
|
+
}) {
|
|
44
|
+
if (field.multipleValues) {
|
|
45
|
+
return field.fieldId + ": [Boolean]";
|
|
46
|
+
}
|
|
47
|
+
return field.fieldId + ": Boolean";
|
|
48
|
+
},
|
|
49
|
+
createInputField({
|
|
50
|
+
field
|
|
51
|
+
}) {
|
|
52
|
+
return (0, _helpers.createGraphQLInputField)(field, "Boolean");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
exports.createBooleanField = createBooleanField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createListFilters","field","fieldId","createBooleanField","name","type","fieldType","isSortable","isSearchable","read","createGetFilters","createTypeField","multipleValues","manage","createInputField","createGraphQLInputField"],"sources":["boolean.ts"],"sourcesContent":["import { CmsModelField, CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { createGraphQLInputField } from \"./helpers\";\n\ninterface CreateListFiltersParams {\n field: CmsModelField;\n}\nconst createListFilters = ({ field }: CreateListFiltersParams) => {\n return `\n ${field.fieldId}: Boolean\n ${field.fieldId}_not: Boolean\n `;\n};\n\nexport const createBooleanField = (): CmsModelFieldToGraphQLPlugin => {\n return {\n name: \"cms-model-field-to-graphql-boolean\",\n type: \"cms-model-field-to-graphql\",\n fieldType: \"boolean\",\n isSortable: true,\n isSearchable: true,\n read: {\n createListFilters,\n createGetFilters({ field }) {\n return `${field.fieldId}: Boolean`;\n },\n createTypeField({ field }) {\n if (field.multipleValues) {\n return `${field.fieldId}: [Boolean]`;\n }\n\n return `${field.fieldId}: Boolean`;\n }\n },\n manage: {\n createListFilters,\n createTypeField({ field }) {\n if (field.multipleValues) {\n return field.fieldId + \": [Boolean]\";\n }\n\n return field.fieldId + \": Boolean\";\n },\n createInputField({ field }) {\n return createGraphQLInputField(field, \"Boolean\");\n }\n }\n };\n};\n"],"mappings":";;;;;;AACA;AAKA,MAAMA,iBAAiB,GAAG,CAAC;EAAEC;AAA+B,CAAC,KAAK;EAC9D,OAAQ;AACZ,UAAUA,KAAK,CAACC,OAAQ;AACxB,UAAUD,KAAK,CAACC,OAAQ;AACxB,KAAK;AACL,CAAC;AAEM,MAAMC,kBAAkB,GAAG,MAAoC;EAClE,OAAO;IACHC,IAAI,EAAE,oCAAoC;IAC1CC,IAAI,EAAE,4BAA4B;IAClCC,SAAS,EAAE,SAAS;IACpBC,UAAU,EAAE,IAAI;IAChBC,YAAY,EAAE,IAAI;IAClBC,IAAI,EAAE;MACFT,iBAAiB;MACjBU,gBAAgB,CAAC;QAAET;MAAM,CAAC,EAAE;QACxB,OAAQ,GAAEA,KAAK,CAACC,OAAQ,WAAU;MACtC,CAAC;MACDS,eAAe,CAAC;QAAEV;MAAM,CAAC,EAAE;QACvB,IAAIA,KAAK,CAACW,cAAc,EAAE;UACtB,OAAQ,GAAEX,KAAK,CAACC,OAAQ,aAAY;QACxC;QAEA,OAAQ,GAAED,KAAK,CAACC,OAAQ,WAAU;MACtC;IACJ,CAAC;IACDW,MAAM,EAAE;MACJb,iBAAiB;MACjBW,eAAe,CAAC;QAAEV;MAAM,CAAC,EAAE;QACvB,IAAIA,KAAK,CAACW,cAAc,EAAE;UACtB,OAAOX,KAAK,CAACC,OAAO,GAAG,aAAa;QACxC;QAEA,OAAOD,KAAK,CAACC,OAAO,GAAG,WAAW;MACtC,CAAC;MACDY,gBAAgB,CAAC;QAAEb;MAAM,CAAC,EAAE;QACxB,OAAO,IAAAc,gCAAuB,EAACd,KAAK,EAAE,SAAS,CAAC;MACpD;IACJ;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createDateTimeField = void 0;
|
|
7
|
+
var _helpers = require("./helpers");
|
|
8
|
+
const fieldGraphQLTypes = {
|
|
9
|
+
time: "Time",
|
|
10
|
+
dateTimeWithoutTimezone: "DateTime",
|
|
11
|
+
dateTimeWithTimezone: "DateTimeZ",
|
|
12
|
+
date: "Date"
|
|
13
|
+
};
|
|
14
|
+
const getFieldGraphQLType = field => {
|
|
15
|
+
var _field$settings;
|
|
16
|
+
const type = (_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.type;
|
|
17
|
+
if (!type || !fieldGraphQLTypes[type]) {
|
|
18
|
+
return fieldGraphQLTypes.dateTimeWithoutTimezone;
|
|
19
|
+
}
|
|
20
|
+
return fieldGraphQLTypes[type];
|
|
21
|
+
};
|
|
22
|
+
const createListFilters = ({
|
|
23
|
+
field
|
|
24
|
+
}) => {
|
|
25
|
+
return `
|
|
26
|
+
${field.fieldId}: ${getFieldGraphQLType(field)}
|
|
27
|
+
${field.fieldId}_not: ${getFieldGraphQLType(field)}
|
|
28
|
+
${field.fieldId}_in: [${getFieldGraphQLType(field)}]
|
|
29
|
+
${field.fieldId}_not_in: [${getFieldGraphQLType(field)}]
|
|
30
|
+
${field.fieldId}_lt: ${getFieldGraphQLType(field)}
|
|
31
|
+
${field.fieldId}_lte: ${getFieldGraphQLType(field)}
|
|
32
|
+
${field.fieldId}_gt: ${getFieldGraphQLType(field)}
|
|
33
|
+
${field.fieldId}_gte: ${getFieldGraphQLType(field)}
|
|
34
|
+
`;
|
|
35
|
+
};
|
|
36
|
+
const createDateTimeField = () => {
|
|
37
|
+
return {
|
|
38
|
+
name: "cms-model-field-to-graphql-datetime",
|
|
39
|
+
type: "cms-model-field-to-graphql",
|
|
40
|
+
fieldType: "datetime",
|
|
41
|
+
isSortable: true,
|
|
42
|
+
isSearchable: true,
|
|
43
|
+
read: {
|
|
44
|
+
createListFilters,
|
|
45
|
+
createGetFilters({
|
|
46
|
+
field
|
|
47
|
+
}) {
|
|
48
|
+
return `${field.fieldId}: ${getFieldGraphQLType(field)}`;
|
|
49
|
+
},
|
|
50
|
+
createTypeField({
|
|
51
|
+
field
|
|
52
|
+
}) {
|
|
53
|
+
if (field.multipleValues) {
|
|
54
|
+
return `${field.fieldId}: [${getFieldGraphQLType(field)}]`;
|
|
55
|
+
}
|
|
56
|
+
return `${field.fieldId}: ${getFieldGraphQLType(field)}`;
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
manage: {
|
|
60
|
+
createListFilters,
|
|
61
|
+
createTypeField({
|
|
62
|
+
field
|
|
63
|
+
}) {
|
|
64
|
+
if (field.multipleValues) {
|
|
65
|
+
const def = (0, _helpers.attachRequiredFieldValue)(getFieldGraphQLType(field), field);
|
|
66
|
+
return `${field.fieldId}: [${def}]`;
|
|
67
|
+
}
|
|
68
|
+
return `${field.fieldId}: ${getFieldGraphQLType(field)}`;
|
|
69
|
+
},
|
|
70
|
+
createInputField({
|
|
71
|
+
field
|
|
72
|
+
}) {
|
|
73
|
+
return (0, _helpers.createGraphQLInputField)(field, getFieldGraphQLType(field));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
exports.createDateTimeField = createDateTimeField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fieldGraphQLTypes","time","dateTimeWithoutTimezone","dateTimeWithTimezone","date","getFieldGraphQLType","field","type","settings","createListFilters","fieldId","createDateTimeField","name","fieldType","isSortable","isSearchable","read","createGetFilters","createTypeField","multipleValues","manage","def","attachRequiredFieldValue","createInputField","createGraphQLInputField"],"sources":["datetime.ts"],"sourcesContent":["import { CmsModelField, CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { attachRequiredFieldValue, createGraphQLInputField } from \"./helpers\";\n\nconst fieldGraphQLTypes = {\n time: \"Time\",\n dateTimeWithoutTimezone: \"DateTime\",\n dateTimeWithTimezone: \"DateTimeZ\",\n date: \"Date\"\n};\n\ntype FieldGraphQLKeys = keyof typeof fieldGraphQLTypes;\n\nconst getFieldGraphQLType = (field: CmsModelField): string => {\n const type = field.settings?.type as FieldGraphQLKeys | undefined;\n if (!type || !fieldGraphQLTypes[type]) {\n return fieldGraphQLTypes.dateTimeWithoutTimezone;\n }\n return fieldGraphQLTypes[type];\n};\n\ninterface CreateListFiltersParams {\n field: CmsModelField;\n}\nconst createListFilters = ({ field }: CreateListFiltersParams) => {\n return `\n ${field.fieldId}: ${getFieldGraphQLType(field)}\n ${field.fieldId}_not: ${getFieldGraphQLType(field)}\n ${field.fieldId}_in: [${getFieldGraphQLType(field)}]\n ${field.fieldId}_not_in: [${getFieldGraphQLType(field)}]\n ${field.fieldId}_lt: ${getFieldGraphQLType(field)}\n ${field.fieldId}_lte: ${getFieldGraphQLType(field)}\n ${field.fieldId}_gt: ${getFieldGraphQLType(field)}\n ${field.fieldId}_gte: ${getFieldGraphQLType(field)}\n `;\n};\n\nexport const createDateTimeField = (): CmsModelFieldToGraphQLPlugin => {\n return {\n name: \"cms-model-field-to-graphql-datetime\",\n type: \"cms-model-field-to-graphql\",\n fieldType: \"datetime\",\n isSortable: true,\n isSearchable: true,\n read: {\n createListFilters,\n createGetFilters({ field }) {\n return `${field.fieldId}: ${getFieldGraphQLType(field)}`;\n },\n createTypeField({ field }) {\n if (field.multipleValues) {\n return `${field.fieldId}: [${getFieldGraphQLType(field)}]`;\n }\n\n return `${field.fieldId}: ${getFieldGraphQLType(field)}`;\n }\n },\n manage: {\n createListFilters,\n createTypeField({ field }) {\n if (field.multipleValues) {\n const def = attachRequiredFieldValue(getFieldGraphQLType(field), field);\n return `${field.fieldId}: [${def}]`;\n }\n return `${field.fieldId}: ${getFieldGraphQLType(field)}`;\n },\n createInputField({ field }) {\n return createGraphQLInputField(field, getFieldGraphQLType(field));\n }\n }\n };\n};\n"],"mappings":";;;;;;AACA;AAEA,MAAMA,iBAAiB,GAAG;EACtBC,IAAI,EAAE,MAAM;EACZC,uBAAuB,EAAE,UAAU;EACnCC,oBAAoB,EAAE,WAAW;EACjCC,IAAI,EAAE;AACV,CAAC;AAID,MAAMC,mBAAmB,GAAIC,KAAoB,IAAa;EAAA;EAC1D,MAAMC,IAAI,sBAAGD,KAAK,CAACE,QAAQ,oDAAd,gBAAgBD,IAAoC;EACjE,IAAI,CAACA,IAAI,IAAI,CAACP,iBAAiB,CAACO,IAAI,CAAC,EAAE;IACnC,OAAOP,iBAAiB,CAACE,uBAAuB;EACpD;EACA,OAAOF,iBAAiB,CAACO,IAAI,CAAC;AAClC,CAAC;AAKD,MAAME,iBAAiB,GAAG,CAAC;EAAEH;AAA+B,CAAC,KAAK;EAC9D,OAAQ;AACZ,UAAUA,KAAK,CAACI,OAAQ,KAAIL,mBAAmB,CAACC,KAAK,CAAE;AACvD,UAAUA,KAAK,CAACI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AAC,iCAAwB,EAACjB,mBAAmB,CAACC,KAAK,CAAC,EAAEA,KAAK,CAAC;UACvE,OAAQ,GAAEA,KAAK,CAACI,OAAQ,MAAKW,GAAI,GAAE;QACvC;QACA,OAAQ,GAAEf,KAAK,CAACI,OAAQ,KAAIL,mBAAmB,CAACC,KAAK,CAAE,EAAC;MAC5D,CAAC;MACDiB,gBAAgB,CAAC;QAAEjB;MAAM,CAAC,EAAE;QACxB,OAAO,IAAAkB,gCAAuB,EAAClB,KAAK,EAAED,mBAAmB,CAACC,KAAK,CAAC,CAAC;MACrE;IACJ;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createDynamicZoneField = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _createTypeName = require("../../utils/createTypeName");
|
|
10
|
+
var _createTypeFromFields = require("../../utils/createTypeFromFields");
|
|
11
|
+
var _helpers = require("../helpers");
|
|
12
|
+
const createUnionTypeName = (model, field) => {
|
|
13
|
+
return `${model.singularApiName}_${(0, _createTypeName.createTypeName)(field.fieldId)}`;
|
|
14
|
+
};
|
|
15
|
+
const getFieldTemplates = field => {
|
|
16
|
+
var _field$settings;
|
|
17
|
+
if (!Array.isArray((_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.templates)) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
return field.settings.templates;
|
|
21
|
+
};
|
|
22
|
+
const createTypeDefsForTemplates = ({
|
|
23
|
+
models,
|
|
24
|
+
model,
|
|
25
|
+
field,
|
|
26
|
+
type,
|
|
27
|
+
templates,
|
|
28
|
+
typeOfType,
|
|
29
|
+
fieldTypePlugins
|
|
30
|
+
}) => {
|
|
31
|
+
const typeDefs = [];
|
|
32
|
+
const templateTypes = [];
|
|
33
|
+
templates.forEach(template => {
|
|
34
|
+
const typeName = [model.singularApiName, (0, _createTypeName.createTypeName)(field.fieldId), template.gqlTypeName].join("_");
|
|
35
|
+
const result = (0, _createTypeFromFields.createTypeFromFields)({
|
|
36
|
+
models,
|
|
37
|
+
typeOfType,
|
|
38
|
+
model,
|
|
39
|
+
type,
|
|
40
|
+
typeNamePrefix: typeName,
|
|
41
|
+
fields: template.fields,
|
|
42
|
+
fieldTypePlugins
|
|
43
|
+
});
|
|
44
|
+
if (!result) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
typeDefs.push(result.typeDefs);
|
|
48
|
+
templateTypes.push(result.fieldType);
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
typeDefs,
|
|
52
|
+
templateTypes
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const remapTemplateValue = (value, typeName) => {
|
|
56
|
+
const templateType = Object.keys(value)[0];
|
|
57
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, value[templateType]), {}, {
|
|
58
|
+
__typename: `${typeName}_${templateType}`
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const createResolver = endpointType => {
|
|
62
|
+
return ({
|
|
63
|
+
model,
|
|
64
|
+
models,
|
|
65
|
+
field,
|
|
66
|
+
fieldTypePlugins,
|
|
67
|
+
createFieldResolvers
|
|
68
|
+
}) => {
|
|
69
|
+
const resolver = parent => {
|
|
70
|
+
const value = parent[field.fieldId];
|
|
71
|
+
if (!value) {
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
const typeName = `${model.singularApiName}_${(0, _createTypeName.createTypeName)(field.fieldId)}`;
|
|
75
|
+
if (field.multipleValues && Array.isArray(value)) {
|
|
76
|
+
return value.map(v => remapTemplateValue(v, typeName));
|
|
77
|
+
}
|
|
78
|
+
return remapTemplateValue(value, typeName);
|
|
79
|
+
};
|
|
80
|
+
const templates = getFieldTemplates(field);
|
|
81
|
+
const {
|
|
82
|
+
templateTypes
|
|
83
|
+
} = createTypeDefsForTemplates({
|
|
84
|
+
models,
|
|
85
|
+
field,
|
|
86
|
+
type: endpointType,
|
|
87
|
+
typeOfType: "type",
|
|
88
|
+
model,
|
|
89
|
+
fieldTypePlugins,
|
|
90
|
+
templates
|
|
91
|
+
});
|
|
92
|
+
const typeResolvers = templateTypes.reduce((typeResolvers, templateType, index) => {
|
|
93
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, typeResolvers), createFieldResolvers({
|
|
94
|
+
graphQLType: templateType,
|
|
95
|
+
fields: field.settings.templates[index].fields
|
|
96
|
+
}));
|
|
97
|
+
}, {});
|
|
98
|
+
return {
|
|
99
|
+
resolver,
|
|
100
|
+
typeResolvers
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
const createDynamicZoneField = () => {
|
|
105
|
+
return {
|
|
106
|
+
name: "cms-model-field-to-graphql-dynamic-zone",
|
|
107
|
+
type: "cms-model-field-to-graphql",
|
|
108
|
+
fieldType: "dynamicZone",
|
|
109
|
+
isSortable: false,
|
|
110
|
+
isSearchable: false,
|
|
111
|
+
validateChildFields: params => {
|
|
112
|
+
const {
|
|
113
|
+
validate,
|
|
114
|
+
originalField,
|
|
115
|
+
field
|
|
116
|
+
} = params;
|
|
117
|
+
const getOriginalTemplateFields = templateId => {
|
|
118
|
+
var _originalField$settin;
|
|
119
|
+
if (!(originalField !== null && originalField !== void 0 && (_originalField$settin = originalField.settings) !== null && _originalField$settin !== void 0 && _originalField$settin.templates)) {
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
122
|
+
const template = originalField.settings.templates.find(t => t.id === templateId);
|
|
123
|
+
return (template === null || template === void 0 ? void 0 : template.fields) || [];
|
|
124
|
+
};
|
|
125
|
+
for (const template of field.settings.templates) {
|
|
126
|
+
validate({
|
|
127
|
+
fields: template.fields,
|
|
128
|
+
originalFields: getOriginalTemplateFields(template.id)
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
read: {
|
|
133
|
+
createTypeField({
|
|
134
|
+
models,
|
|
135
|
+
model,
|
|
136
|
+
field,
|
|
137
|
+
fieldTypePlugins
|
|
138
|
+
}) {
|
|
139
|
+
const templates = getFieldTemplates(field);
|
|
140
|
+
const unionTypeName = createUnionTypeName(model, field);
|
|
141
|
+
const {
|
|
142
|
+
typeDefs,
|
|
143
|
+
templateTypes
|
|
144
|
+
} = createTypeDefsForTemplates({
|
|
145
|
+
models,
|
|
146
|
+
field,
|
|
147
|
+
type: "read",
|
|
148
|
+
typeOfType: "type",
|
|
149
|
+
model,
|
|
150
|
+
fieldTypePlugins,
|
|
151
|
+
templates
|
|
152
|
+
});
|
|
153
|
+
typeDefs.unshift(`union ${unionTypeName} = ${templateTypes.join(" | ")}`);
|
|
154
|
+
return {
|
|
155
|
+
fields: `${field.fieldId}: ${field.multipleValues ? `[${unionTypeName}!]` : unionTypeName}`,
|
|
156
|
+
typeDefs: typeDefs.join("\n")
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
createResolver: createResolver("read")
|
|
160
|
+
},
|
|
161
|
+
manage: {
|
|
162
|
+
createTypeField({
|
|
163
|
+
models,
|
|
164
|
+
model,
|
|
165
|
+
field,
|
|
166
|
+
fieldTypePlugins
|
|
167
|
+
}) {
|
|
168
|
+
const templates = getFieldTemplates(field);
|
|
169
|
+
const unionTypeName = createUnionTypeName(model, field);
|
|
170
|
+
const {
|
|
171
|
+
typeDefs,
|
|
172
|
+
templateTypes
|
|
173
|
+
} = createTypeDefsForTemplates({
|
|
174
|
+
models,
|
|
175
|
+
field,
|
|
176
|
+
type: "manage",
|
|
177
|
+
typeOfType: "type",
|
|
178
|
+
model,
|
|
179
|
+
fieldTypePlugins,
|
|
180
|
+
templates
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Add _templateId
|
|
184
|
+
const templateIds = templateTypes.map(type => {
|
|
185
|
+
return `extend type ${type} {
|
|
186
|
+
_templateId: ID!
|
|
187
|
+
}
|
|
188
|
+
`;
|
|
189
|
+
});
|
|
190
|
+
typeDefs.unshift(`union ${unionTypeName} = ${templateTypes.join(" | ")}`);
|
|
191
|
+
return {
|
|
192
|
+
fields: `${field.fieldId}: ${field.multipleValues ? `[${unionTypeName}!]` : unionTypeName}`,
|
|
193
|
+
typeDefs: typeDefs.concat(templateIds).join("\n")
|
|
194
|
+
};
|
|
195
|
+
},
|
|
196
|
+
createInputField({
|
|
197
|
+
models,
|
|
198
|
+
model,
|
|
199
|
+
field,
|
|
200
|
+
fieldTypePlugins
|
|
201
|
+
}) {
|
|
202
|
+
const templates = getFieldTemplates(field);
|
|
203
|
+
const {
|
|
204
|
+
typeDefs,
|
|
205
|
+
templateTypes
|
|
206
|
+
} = createTypeDefsForTemplates({
|
|
207
|
+
models,
|
|
208
|
+
field,
|
|
209
|
+
type: "manage",
|
|
210
|
+
typeOfType: "input",
|
|
211
|
+
model,
|
|
212
|
+
fieldTypePlugins,
|
|
213
|
+
templates
|
|
214
|
+
});
|
|
215
|
+
const typeName = `${model.singularApiName}_${(0, _createTypeName.createTypeName)(field.fieldId)}`;
|
|
216
|
+
const inputProperties = templateTypes.map(inputTypeName => {
|
|
217
|
+
const key = inputTypeName.replace(`${typeName}_`, "").replace("Input", "");
|
|
218
|
+
return [key, inputTypeName];
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Generate a field input type, similar to this example:
|
|
223
|
+
*
|
|
224
|
+
* input Article_ContentInput {
|
|
225
|
+
* Hero: Article_Content_HeroInput
|
|
226
|
+
* SimpleText: Article_Content_SimpleTextInput
|
|
227
|
+
* }
|
|
228
|
+
*/
|
|
229
|
+
typeDefs.push(`input ${typeName}Input {
|
|
230
|
+
${inputProperties.map(([key, value]) => `
|
|
231
|
+
${key}: ${value}
|
|
232
|
+
`)}
|
|
233
|
+
}`);
|
|
234
|
+
return {
|
|
235
|
+
fields: (0, _helpers.createGraphQLInputField)(field, `${typeName}Input`),
|
|
236
|
+
typeDefs: typeDefs.join("\n")
|
|
237
|
+
};
|
|
238
|
+
},
|
|
239
|
+
createResolver: createResolver("manage")
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
exports.createDynamicZoneField = createDynamicZoneField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createUnionTypeName","model","field","singularApiName","createTypeName","fieldId","getFieldTemplates","Array","isArray","settings","templates","createTypeDefsForTemplates","models","type","typeOfType","fieldTypePlugins","typeDefs","templateTypes","forEach","template","typeName","gqlTypeName","join","result","createTypeFromFields","typeNamePrefix","fields","push","fieldType","remapTemplateValue","value","templateType","Object","keys","__typename","createResolver","endpointType","createFieldResolvers","resolver","parent","multipleValues","map","v","typeResolvers","reduce","index","graphQLType","createDynamicZoneField","name","isSortable","isSearchable","validateChildFields","params","validate","originalField","getOriginalTemplateFields","templateId","find","t","id","originalFields","read","createTypeField","unionTypeName","unshift","manage","templateIds","concat","createInputField","inputProperties","inputTypeName","key","replace","createGraphQLInputField"],"sources":["dynamicZoneField.ts"],"sourcesContent":["import {\n ApiEndpoint,\n CmsDynamicZoneTemplate,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelDynamicZoneField,\n CmsModelField,\n CmsModelFieldToGraphQLCreateResolver,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { createTypeName } from \"~/utils/createTypeName\";\nimport { createTypeFromFields } from \"~/utils/createTypeFromFields\";\nimport { createGraphQLInputField } from \"../helpers\";\nimport { GraphQLFieldResolver } from \"@webiny/handler-graphql/types\";\n\nconst createUnionTypeName = (model: CmsModel, field: CmsModelField) => {\n return `${model.singularApiName}_${createTypeName(field.fieldId)}`;\n};\n\nconst getFieldTemplates = (field: CmsModelDynamicZoneField): CmsDynamicZoneTemplate[] => {\n if (!Array.isArray(field.settings?.templates)) {\n return [];\n }\n return field.settings.templates;\n};\n\ninterface CreateTypeDefsForTemplatesParams {\n models: CmsModel[];\n model: CmsModel;\n field: CmsModelField;\n type: ApiEndpoint;\n typeOfType: \"type\" | \"input\";\n templates: CmsDynamicZoneTemplate[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\nconst createTypeDefsForTemplates = ({\n models,\n model,\n field,\n type,\n templates,\n typeOfType,\n fieldTypePlugins\n}: CreateTypeDefsForTemplatesParams) => {\n const typeDefs: string[] = [];\n const templateTypes: string[] = [];\n\n templates.forEach(template => {\n const typeName = [\n model.singularApiName,\n createTypeName(field.fieldId),\n template.gqlTypeName\n ].join(\"_\");\n\n const result = createTypeFromFields({\n models,\n typeOfType,\n model,\n type,\n typeNamePrefix: typeName,\n fields: template.fields,\n fieldTypePlugins\n });\n\n if (!result) {\n return;\n }\n\n typeDefs.push(result.typeDefs);\n templateTypes.push(result.fieldType);\n });\n\n return { typeDefs, templateTypes };\n};\n\nconst remapTemplateValue = (value: any, typeName: string) => {\n const templateType = Object.keys(value)[0];\n\n return { ...value[templateType], __typename: `${typeName}_${templateType}` };\n};\n\nconst createResolver = (\n endpointType: ApiEndpoint\n): CmsModelFieldToGraphQLCreateResolver<CmsModelDynamicZoneField> => {\n return ({ model, models, field, fieldTypePlugins, createFieldResolvers }) => {\n const resolver = (parent: any) => {\n const value = parent[field.fieldId];\n if (!value) {\n return value;\n }\n\n const typeName = `${model.singularApiName}_${createTypeName(field.fieldId)}`;\n\n if (field.multipleValues && Array.isArray(value)) {\n return value.map(v => remapTemplateValue(v, typeName));\n }\n\n return remapTemplateValue(value, typeName);\n };\n\n const templates = getFieldTemplates(field);\n\n const { templateTypes } = createTypeDefsForTemplates({\n models,\n field,\n type: endpointType,\n typeOfType: \"type\",\n model,\n fieldTypePlugins,\n templates\n });\n\n const typeResolvers = templateTypes.reduce<\n Record<string, Record<string, GraphQLFieldResolver>>\n >((typeResolvers, templateType, index) => {\n return {\n ...typeResolvers,\n ...createFieldResolvers({\n graphQLType: templateType,\n fields: field.settings.templates[index].fields\n })\n };\n }, {});\n\n return {\n resolver,\n typeResolvers\n };\n };\n};\n\nexport const createDynamicZoneField =\n (): CmsModelFieldToGraphQLPlugin<CmsModelDynamicZoneField> => {\n return {\n name: \"cms-model-field-to-graphql-dynamic-zone\",\n type: \"cms-model-field-to-graphql\",\n fieldType: \"dynamicZone\",\n isSortable: false,\n isSearchable: false,\n validateChildFields: params => {\n const { validate, originalField, field } = params;\n\n const getOriginalTemplateFields = (templateId: string) => {\n if (!originalField?.settings?.templates) {\n return [];\n }\n const template = originalField.settings.templates.find(\n t => t.id === templateId\n );\n return template?.fields || [];\n };\n\n for (const template of field.settings.templates) {\n validate({\n fields: template.fields,\n originalFields: getOriginalTemplateFields(template.id)\n });\n }\n },\n read: {\n createTypeField({ models, model, field, fieldTypePlugins }) {\n const templates = getFieldTemplates(field);\n const unionTypeName = createUnionTypeName(model, field);\n\n const { typeDefs, templateTypes } = createTypeDefsForTemplates({\n models,\n field,\n type: \"read\",\n typeOfType: \"type\",\n model,\n fieldTypePlugins,\n templates\n });\n\n typeDefs.unshift(`union ${unionTypeName} = ${templateTypes.join(\" | \")}`);\n\n return {\n fields: `${field.fieldId}: ${\n field.multipleValues ? `[${unionTypeName}!]` : unionTypeName\n }`,\n typeDefs: typeDefs.join(\"\\n\")\n };\n },\n createResolver: createResolver(\"read\")\n },\n manage: {\n createTypeField({ models, model, field, fieldTypePlugins }) {\n const templates = getFieldTemplates(field);\n const unionTypeName = createUnionTypeName(model, field);\n\n const { typeDefs, templateTypes } = createTypeDefsForTemplates({\n models,\n field,\n type: \"manage\",\n typeOfType: \"type\",\n model,\n fieldTypePlugins,\n templates\n });\n\n // Add _templateId\n const templateIds = templateTypes.map(type => {\n return `extend type ${type} {\n _templateId: ID!\n }\n `;\n });\n\n typeDefs.unshift(`union ${unionTypeName} = ${templateTypes.join(\" | \")}`);\n\n return {\n fields: `${field.fieldId}: ${\n field.multipleValues ? `[${unionTypeName}!]` : unionTypeName\n }`,\n typeDefs: typeDefs.concat(templateIds).join(\"\\n\")\n };\n },\n createInputField({ models, model, field, fieldTypePlugins }) {\n const templates = getFieldTemplates(field);\n\n const { typeDefs, templateTypes } = createTypeDefsForTemplates({\n models,\n field,\n type: \"manage\",\n typeOfType: \"input\",\n model,\n fieldTypePlugins,\n templates\n });\n\n const typeName = `${model.singularApiName}_${createTypeName(field.fieldId)}`;\n\n const inputProperties = templateTypes.map(inputTypeName => {\n const key = inputTypeName.replace(`${typeName}_`, \"\").replace(\"Input\", \"\");\n return [key, inputTypeName];\n });\n\n /**\n * Generate a field input type, similar to this example:\n *\n * input Article_ContentInput {\n * Hero: Article_Content_HeroInput\n * SimpleText: Article_Content_SimpleTextInput\n * }\n */\n typeDefs.push(`input ${typeName}Input {\n ${inputProperties.map(\n ([key, value]) => `\n ${key}: ${value}\n `\n )}\n }`);\n\n return {\n fields: createGraphQLInputField(field, `${typeName}Input`),\n typeDefs: typeDefs.join(\"\\n\")\n };\n },\n createResolver: createResolver(\"manage\")\n }\n };\n };\n"],"mappings":";;;;;;;;AAUA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,CAACC,KAAe,EAAEC,KAAoB,KAAK;EACnE,OAAQ,GAAED,KAAK,CAACE,eAAgB,IAAG,IAAAC,8BAAc,EAACF,KAAK,CAACG,OAAO,CAAE,EAAC;AACtE,CAAC;AAED,MAAMC,iBAAiB,GAAIJ,KAA+B,IAA+B;EAAA;EACrF,IAAI,CAACK,KAAK,CAACC,OAAO,oBAACN,KAAK,CAACO,QAAQ,oDAAd,gBAAgBC,SAAS,CAAC,EAAE;IAC3C,OAAO,EAAE;EACb;EACA,OAAOR,KAAK,CAACO,QAAQ,CAACC,SAAS;AACnC,CAAC;AAYD,MAAMC,0BAA0B,GAAG,CAAC;EAChCC,MAAM;EACNX,KAAK;EACLC,KAAK;EACLW,IAAI;EACJH,SAAS;EACTI,UAAU;EACVC;AAC8B,CAAC,KAAK;EAC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efault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createDynamicZoneStorageTransform = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _plugins = require("../../plugins");
|
|
10
|
+
const convertToStorage = (value, templates) => {
|
|
11
|
+
// Only one key is allowed in the input object.
|
|
12
|
+
const inputType = Object.keys(value)[0];
|
|
13
|
+
const template = templates.find(tpl => tpl.gqlTypeName === inputType);
|
|
14
|
+
if (!template) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, value[inputType]), {}, {
|
|
18
|
+
_templateId: template.id
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const convertFromStorage = (value, templates) => {
|
|
22
|
+
const template = templates.find(tpl => value._templateId === tpl.id);
|
|
23
|
+
if (!template) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// We keep the `_templateId` property, to simplify further processing.
|
|
28
|
+
return {
|
|
29
|
+
[template.gqlTypeName]: value
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const createDynamicZoneStorageTransform = () => {
|
|
33
|
+
return new _plugins.StorageTransformPlugin({
|
|
34
|
+
fieldType: "dynamicZone",
|
|
35
|
+
fromStorage: async ({
|
|
36
|
+
value,
|
|
37
|
+
field
|
|
38
|
+
}) => {
|
|
39
|
+
if (!value) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const templates = field.settings.templates;
|
|
43
|
+
if (Array.isArray(value) && field.multipleValues) {
|
|
44
|
+
return value.map(value => convertFromStorage(value, templates)).filter(Boolean);
|
|
45
|
+
}
|
|
46
|
+
return convertFromStorage(value, templates);
|
|
47
|
+
},
|
|
48
|
+
toStorage: async ({
|
|
49
|
+
value,
|
|
50
|
+
field
|
|
51
|
+
}) => {
|
|
52
|
+
if (!value) {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
const templates = field.settings.templates;
|
|
56
|
+
if (Array.isArray(value) && field.multipleValues) {
|
|
57
|
+
return value.map(value => convertToStorage(value, templates)).filter(Boolean);
|
|
58
|
+
}
|
|
59
|
+
return convertToStorage(value, templates);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
exports.createDynamicZoneStorageTransform = createDynamicZoneStorageTransform;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["convertToStorage","value","templates","inputType","Object","keys","template","find","tpl","gqlTypeName","undefined","_templateId","id","convertFromStorage","createDynamicZoneStorageTransform","StorageTransformPlugin","fieldType","fromStorage","field","settings","Array","isArray","multipleValues","map","filter","Boolean","toStorage"],"sources":["dynamicZoneStorage.ts"],"sourcesContent":["import { CmsDynamicZoneTemplate, CmsModelDynamicZoneField } from \"~/types\";\nimport { StorageTransformPlugin } from \"~/plugins\";\n\nconst convertToStorage = (value: any, templates: CmsDynamicZoneTemplate[]) => {\n // Only one key is allowed in the input object.\n const inputType = Object.keys(value)[0];\n const template = templates.find(tpl => tpl.gqlTypeName === inputType);\n if (!template) {\n return undefined;\n }\n\n return { ...value[inputType], _templateId: template.id };\n};\n\ninterface TemplateValueFromStorage {\n _templateId: string;\n [key: string]: any;\n}\n\nconst convertFromStorage = (\n value: TemplateValueFromStorage,\n templates: CmsDynamicZoneTemplate[]\n) => {\n const template = templates.find(tpl => value._templateId === tpl.id);\n if (!template) {\n return undefined;\n }\n\n // We keep the `_templateId` property, to simplify further processing.\n return { [template.gqlTypeName]: value };\n};\n\nexport const createDynamicZoneStorageTransform = () => {\n return new StorageTransformPlugin<any, any, CmsModelDynamicZoneField>({\n fieldType: \"dynamicZone\",\n fromStorage: async ({ value, field }) => {\n if (!value) {\n return null;\n }\n\n const templates = field.settings.templates;\n\n if (Array.isArray(value) && field.multipleValues) {\n return value.map(value => convertFromStorage(value, templates)).filter(Boolean);\n }\n\n return convertFromStorage(value, templates);\n },\n toStorage: async ({ value, field }) => {\n if (!value) {\n return value;\n }\n\n const templates = field.settings.templates;\n\n if (Array.isArray(value) && field.multipleValues) {\n return value.map(value => convertToStorage(value, templates)).filter(Boolean);\n }\n\n return convertToStorage(value, templates);\n }\n });\n};\n"],"mappings":";;;;;;;;AACA;AAEA,MAAMA,gBAAgB,GAAG,CAACC,KAAU,EAAEC,SAAmC,KAAK;EAC1E;EACA,MAAMC,SAAS,GAAGC,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC,CAAC,CAAC,CAAC;EACvC,MAAMK,QAAQ,GAAGJ,SAAS,CAACK,IAAI,CAACC,GAAG,IAAIA,GAAG,CAACC,WAAW,KAAKN,SAAS,CAAC;EACrE,IAAI,CAACG,QAAQ,EAAE;IACX,OAAOI,SAAS;EACpB;EAEA,mEAAYT,KAAK,CAACE,SAAS,CAAC;IAAEQ,WAAW,EAAEL,QAAQ,CAACM;EAAE;AAC1D,CAAC;AAOD,MAAMC,kBAAkB,GAAG,CACvBZ,KAA+B,EAC/BC,SAAmC,KAClC;EACD,MAAMI,QAAQ,GAAGJ,SAAS,CAACK,IAAI,CAACC,GAAG,IAAIP,KAAK,CAACU,WAAW,KAAKH,GAAG,CAACI,EAAE,CAAC;EACpE,IAAI,CAACN,QAAQ,EAAE;IACX,OAAOI,SAAS;EACpB;;EAEA;EACA,OAAO;IAAE,CAACJ,QAAQ,CAACG,WAAW,GAAGR;EAAM,CAAC;AAC5C,CAAC;AAEM,MAAMa,iCAAiC,GAAG,MAAM;EACnD,OAAO,IAAIC,+BAAsB,CAAqC;IAClEC,SAAS,EAAE,aAAa;IACxBC,WAAW,EAAE,OAAO;MAAEhB,KAAK;MAAEiB;IAAM,CAAC,KAAK;MACrC,IAAI,CAACjB,KAAK,EAAE;QACR,OAAO,IAAI;MACf;MAEA,MAAMC,SAAS,GAAGgB,KAAK,CAACC,QAAQ,CAACjB,SAAS;MAE1C,IAAIkB,KAAK,CAACC,OAAO,CAACpB,KAAK,CAAC,IAAIiB,KAAK,CAACI,cAAc,EAAE;QAC9C,OAAOrB,KAAK,CAACsB,GAAG,CAACtB,KAAK,IAAIY,kBAAkB,CAACZ,KAAK,EAAEC,SAAS,CAAC,CAAC,CAACsB,MAAM,CAACC,OAAO,CAAC;MACnF;MAEA,OAAOZ,kBAAkB,CAACZ,KAAK,EAAEC,SAAS,CAAC;IAC/C,CAAC;IACDwB,SAAS,EAAE,OAAO;MAAEzB,KAAK;MAAEiB;IAAM,CAAC,KAAK;MACnC,IAAI,CAACjB,KAAK,EAAE;QACR,OAAOA,KAAK;MAChB;MAEA,MAAMC,SAAS,GAAGgB,KAAK,CAACC,QAAQ,CAACjB,SAAS;MAE1C,IAAIkB,KAAK,CAACC,OAAO,CAACpB,KAAK,CAAC,IAAIiB,KAAK,CAACI,cAAc,EAAE;QAC9C,OAAOrB,KAAK,CAACsB,GAAG,CAACtB,KAAK,IAAID,gBAAgB,CAACC,KAAK,EAAEC,SAAS,CAAC,CAAC,CAACsB,MAAM,CAACC,OAAO,CAAC;MACjF;MAEA,OAAOzB,gBAAgB,CAACC,KAAK,EAAEC,SAAS,CAAC;IAC7C;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "createDynamicZoneField", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _dynamicZoneField.createDynamicZoneField;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "createDynamicZoneStorageTransform", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _dynamicZoneStorage.createDynamicZoneStorageTransform;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _dynamicZoneField = require("./dynamicZoneField");
|
|
19
|
+
var _dynamicZoneStorage = require("./dynamicZoneStorage");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { createDynamicZoneField } from \"./dynamicZoneField\";\nexport { createDynamicZoneStorageTransform } from \"./dynamicZoneStorage\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA"}
|