@webiny/api-headless-cms 0.0.0-mt-3 → 0.0.0-unstable.3386f66516
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 +119 -0
- package/context.js.map +1 -0
- package/crud/contentEntry/afterDelete.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentEntry/afterDelete.js +2 -2
- 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 -2
- 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 -2
- package/crud/contentEntry/beforeUpdate.js.map +1 -0
- package/crud/contentEntry/entryDataValidation.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentEntry/entryDataValidation.js +23 -11
- 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 +14 -15
- package/crud/contentEntry/markLockedFields.js.map +1 -0
- package/crud/contentEntry/referenceFieldsMapping.d.ts +13 -0
- package/crud/contentEntry/referenceFieldsMapping.js +292 -0
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -0
- package/crud/contentEntry/searchableFields.d.ts +9 -0
- package/crud/contentEntry/searchableFields.js +83 -0
- package/crud/contentEntry/searchableFields.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry.crud.d.ts +5 -9
- package/crud/contentEntry.crud.js +1309 -0
- package/crud/contentEntry.crud.js.map +1 -0
- package/crud/contentModel/afterCreate.d.ts +8 -0
- package/crud/contentModel/afterCreate.js +18 -0
- package/crud/contentModel/afterCreate.js.map +1 -0
- package/crud/contentModel/afterCreateFrom.d.ts +8 -0
- package/crud/contentModel/afterCreateFrom.js +18 -0
- package/crud/contentModel/afterCreateFrom.js.map +1 -0
- package/crud/contentModel/afterDelete.d.ts +8 -0
- package/crud/contentModel/afterDelete.js +18 -0
- package/crud/contentModel/afterDelete.js.map +1 -0
- package/crud/contentModel/afterUpdate.d.ts +8 -0
- package/crud/contentModel/afterUpdate.js +18 -0
- package/crud/contentModel/afterUpdate.js.map +1 -0
- package/crud/contentModel/beforeCreate.d.ts +14 -0
- package/{content/plugins/crud → crud}/contentModel/beforeCreate.js +61 -13
- package/crud/contentModel/beforeCreate.js.map +1 -0
- package/crud/contentModel/beforeDelete.d.ts +10 -0
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.js +14 -10
- package/crud/contentModel/beforeDelete.js.map +1 -0
- package/crud/contentModel/beforeUpdate.d.ts +8 -0
- package/crud/contentModel/beforeUpdate.js +37 -0
- package/crud/contentModel/beforeUpdate.js.map +1 -0
- package/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/contentModelManagerFactory.js +0 -0
- 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 +20 -0
- package/crud/contentModel/createFieldStorageId.js.map +1 -0
- package/crud/contentModel/fieldIdValidation.d.ts +1 -0
- package/crud/contentModel/fieldIdValidation.js +25 -0
- package/crud/contentModel/fieldIdValidation.js.map +1 -0
- package/crud/contentModel/idValidation.d.ts +1 -0
- package/{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/validateLayout.d.ts +2 -0
- package/{content/plugins/crud → crud}/contentModel/validateLayout.js +1 -3
- package/crud/contentModel/validateLayout.js.map +1 -0
- package/crud/contentModel/validateModel.d.ts +8 -0
- package/crud/contentModel/validateModel.js +35 -0
- package/crud/contentModel/validateModel.js.map +1 -0
- package/crud/contentModel/validateModelFields.d.ts +8 -0
- package/crud/contentModel/validateModelFields.js +436 -0
- package/crud/contentModel/validateModelFields.js.map +1 -0
- package/crud/contentModel/validation.d.ts +477 -0
- package/crud/contentModel/validation.js +109 -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 +642 -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 +9 -9
- 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 -4
- 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 -3
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
- package/crud/contentModelGroup/validation.d.ts +30 -0
- package/crud/contentModelGroup/validation.js +43 -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 +366 -0
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/{plugins/crud → crud}/settings.crud.d.ts +3 -3
- package/crud/settings.crud.js +83 -0
- package/crud/settings.crud.js.map +1 -0
- package/{plugins/crud → crud}/system.crud.d.ts +6 -3
- package/crud/system.crud.js +221 -0
- package/crud/system.crud.js.map +1 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +7 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +66 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +239 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +304 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/index.d.ts +4 -0
- package/fieldConverters/index.js +18 -0
- package/fieldConverters/index.js.map +1 -0
- package/graphql/buildSchemaPlugins.d.ts +11 -0
- package/graphql/buildSchemaPlugins.js +24 -0
- package/graphql/buildSchemaPlugins.js.map +1 -0
- package/graphql/createExecutableSchema.d.ts +7 -0
- package/graphql/createExecutableSchema.js +33 -0
- package/graphql/createExecutableSchema.js.map +1 -0
- package/graphql/generateSchema.d.ts +8 -0
- package/graphql/generateSchema.js +38 -0
- package/graphql/generateSchema.js.map +1 -0
- package/graphql/graphQLHandlerFactory.d.ts +5 -0
- package/graphql/graphQLHandlerFactory.js +202 -0
- package/graphql/graphQLHandlerFactory.js.map +1 -0
- package/graphql/index.d.ts +3 -0
- package/graphql/index.js +18 -0
- package/graphql/index.js.map +1 -0
- package/graphql/schema/baseContentSchema.d.ts +7 -0
- package/graphql/schema/baseContentSchema.js +78 -0
- package/graphql/schema/baseContentSchema.js.map +1 -0
- package/graphql/schema/baseSchema.d.ts +3 -0
- package/graphql/schema/baseSchema.js +60 -0
- package/graphql/schema/baseSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +7 -0
- package/graphql/schema/contentEntries.js +357 -0
- package/graphql/schema/contentEntries.js.map +1 -0
- package/graphql/schema/contentModelGroups.d.ts +7 -0
- package/{content/plugins → graphql}/schema/contentModelGroups.js +40 -17
- package/graphql/schema/contentModelGroups.js.map +1 -0
- package/graphql/schema/contentModels.d.ts +7 -0
- package/{content/plugins → graphql}/schema/contentModels.js +108 -13
- package/graphql/schema/contentModels.js.map +1 -0
- package/graphql/schema/createFieldResolvers.d.ts +20 -0
- package/graphql/schema/createFieldResolvers.js +133 -0
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +12 -0
- package/{content/plugins → graphql}/schema/createManageResolvers.js +36 -34
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/graphql/schema/createManageSDL.d.ts +12 -0
- package/{content/plugins → graphql}/schema/createManageSDL.js +31 -21
- package/graphql/schema/createManageSDL.js.map +1 -0
- package/graphql/schema/createPreviewResolvers.d.ts +12 -0
- package/graphql/schema/createPreviewResolvers.js +58 -0
- package/graphql/schema/createPreviewResolvers.js.map +1 -0
- package/graphql/schema/createReadResolvers.d.ts +12 -0
- package/graphql/schema/createReadResolvers.js +63 -0
- package/graphql/schema/createReadResolvers.js.map +1 -0
- package/graphql/schema/createReadSDL.d.ts +12 -0
- package/{content/plugins → graphql}/schema/createReadSDL.js +25 -13
- package/graphql/schema/createReadSDL.js.map +1 -0
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +6 -0
- package/{content/plugins → graphql}/schema/resolvers/commonFieldResolvers.js +0 -0
- 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 -4
- 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 -4
- 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 +10 -8
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGet.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveGet.js +79 -0
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +7 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveGetByIds.js +2 -4
- 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 -4
- 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/read → graphql/schema/resolvers/manage}/resolveList.js +2 -4
- 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 -0
- 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 -4
- 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 -0
- 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 -4
- package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveGet.d.ts +4 -0
- package/graphql/schema/resolvers/preview/resolveGet.js +34 -0
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveList.d.ts +4 -0
- package/{content/plugins → graphql}/schema/resolvers/preview/resolveList.js +2 -4
- package/graphql/schema/resolvers/preview/resolveList.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveGet.d.ts +4 -0
- package/graphql/schema/resolvers/read/resolveGet.js +34 -0
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveList.d.ts +4 -0
- package/{content/plugins/schema/resolvers/manage → graphql/schema/resolvers/read}/resolveList.js +2 -4
- package/graphql/schema/resolvers/read/resolveList.js.map +1 -0
- package/graphql/schema/schemaPlugins.d.ts +8 -0
- package/graphql/schema/schemaPlugins.js +119 -0
- package/graphql/schema/schemaPlugins.js.map +1 -0
- package/graphql/system.d.ts +6 -0
- package/{plugins/graphql → graphql}/system.js +50 -6
- package/graphql/system.js.map +1 -0
- package/graphqlFields/boolean.d.ts +2 -0
- package/graphqlFields/boolean.js +69 -0
- package/graphqlFields/boolean.js.map +1 -0
- package/graphqlFields/datetime.d.ts +2 -0
- package/graphqlFields/datetime.js +95 -0
- package/graphqlFields/datetime.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js +234 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js +79 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
- package/graphqlFields/dynamicZone/index.d.ts +2 -0
- package/graphqlFields/dynamicZone/index.js +21 -0
- package/graphqlFields/dynamicZone/index.js.map +1 -0
- package/graphqlFields/file.d.ts +2 -0
- package/graphqlFields/file.js +50 -0
- package/graphqlFields/file.js.map +1 -0
- package/graphqlFields/helpers.d.ts +6 -0
- package/graphqlFields/helpers.js +49 -0
- package/graphqlFields/helpers.js.map +1 -0
- package/graphqlFields/index.d.ts +2 -0
- package/graphqlFields/index.js +30 -0
- package/graphqlFields/index.js.map +1 -0
- package/graphqlFields/longText.d.ts +2 -0
- package/graphqlFields/longText.js +63 -0
- package/graphqlFields/longText.js.map +1 -0
- package/graphqlFields/number.d.ts +2 -0
- package/graphqlFields/number.js +79 -0
- package/graphqlFields/number.js.map +1 -0
- package/graphqlFields/object.d.ts +2 -0
- package/graphqlFields/object.js +275 -0
- package/graphqlFields/object.js.map +1 -0
- package/graphqlFields/ref.d.ts +2 -0
- package/graphqlFields/ref.js +261 -0
- package/graphqlFields/ref.js.map +1 -0
- package/graphqlFields/richText.d.ts +2 -0
- package/graphqlFields/richText.js +56 -0
- package/graphqlFields/richText.js.map +1 -0
- package/graphqlFields/text.d.ts +2 -0
- package/graphqlFields/text.js +73 -0
- package/graphqlFields/text.js.map +1 -0
- package/index.d.ts +10 -12
- package/index.js +75 -36
- package/index.js.map +1 -0
- package/modelManager/DefaultCmsModelManager.d.ts +14 -0
- package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js +12 -10
- package/modelManager/DefaultCmsModelManager.js.map +1 -0
- package/modelManager/index.d.ts +2 -0
- package/{content/plugins/modelManager → modelManager}/index.js +3 -3
- package/modelManager/index.js.map +1 -0
- package/package.json +38 -38
- package/parameters/context.d.ts +2 -0
- package/parameters/context.js +22 -0
- package/parameters/context.js.map +1 -0
- package/parameters/header.d.ts +2 -0
- package/parameters/header.js +55 -0
- package/parameters/header.js.map +1 -0
- package/parameters/index.d.ts +4 -0
- package/parameters/index.js +57 -0
- package/parameters/index.js.map +1 -0
- package/parameters/manual.d.ts +6 -0
- package/parameters/manual.js +44 -0
- package/parameters/manual.js.map +1 -0
- package/parameters/path.d.ts +2 -0
- package/parameters/path.js +51 -0
- package/parameters/path.js.map +1 -0
- package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
- package/plugins/CmsGraphQLSchemaPlugin.js +17 -0
- package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js +38 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
- package/plugins/CmsGroupPlugin.d.ts +13 -0
- package/{content/plugins → plugins}/CmsGroupPlugin.js +9 -3
- package/plugins/CmsGroupPlugin.js.map +1 -0
- package/plugins/CmsModelFieldConverterPlugin.d.ts +14 -0
- package/plugins/CmsModelFieldConverterPlugin.js +17 -0
- package/plugins/CmsModelFieldConverterPlugin.js.map +1 -0
- package/plugins/CmsModelPlugin.d.ts +45 -0
- package/plugins/CmsModelPlugin.js +194 -0
- package/plugins/CmsModelPlugin.js.map +1 -0
- package/plugins/CmsParametersPlugin.d.ts +20 -0
- package/plugins/CmsParametersPlugin.js +28 -0
- package/plugins/CmsParametersPlugin.js.map +1 -0
- package/plugins/StorageTransformPlugin.d.ts +31 -0
- package/{content/plugins/storage → plugins}/StorageTransformPlugin.js +2 -1
- package/plugins/StorageTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +7 -0
- package/plugins/index.js +96 -0
- package/plugins/index.js.map +1 -0
- package/storage/default.d.ts +2 -0
- package/storage/default.js +27 -0
- package/storage/default.js.map +1 -0
- package/storage/object.d.ts +2 -0
- package/storage/object.js +127 -0
- package/storage/object.js.map +1 -0
- package/types.d.ts +878 -387
- package/types.js +130 -8
- package/types.js.map +1 -0
- package/upgrades/5.33.0/index.d.ts +3 -0
- package/upgrades/5.33.0/index.js +182 -0
- package/upgrades/5.33.0/index.js.map +1 -0
- package/upgrades/index.d.ts +1 -0
- package/upgrades/index.js +12 -0
- package/upgrades/index.js.map +1 -0
- package/utils/access.d.ts +8 -0
- package/utils/access.js +90 -0
- package/utils/access.js.map +1 -0
- package/utils/converters/Converter.d.ts +27 -0
- package/utils/converters/Converter.js +71 -0
- package/utils/converters/Converter.js.map +1 -0
- package/utils/converters/ConverterCollection.d.ts +31 -0
- package/utils/converters/ConverterCollection.js +143 -0
- package/utils/converters/ConverterCollection.js.map +1 -0
- package/utils/converters/valueKeyStorageConverter.d.ts +18 -0
- package/utils/converters/valueKeyStorageConverter.js +148 -0
- package/utils/converters/valueKeyStorageConverter.js.map +1 -0
- package/utils/createTypeFromFields.d.ts +15 -0
- package/utils/createTypeFromFields.js +75 -0
- package/utils/createTypeFromFields.js.map +1 -0
- package/{content/plugins/utils → utils}/createTypeName.d.ts +3 -3
- package/{content/plugins/utils → utils}/createTypeName.js +4 -2
- package/utils/createTypeName.js.map +1 -0
- package/{content/plugins/utils → utils}/entryStorage.d.ts +3 -3
- package/{content/plugins/utils → utils}/entryStorage.js +18 -23
- package/utils/entryStorage.js.map +1 -0
- package/utils/filterAsync.d.ts +1 -0
- package/utils/filterAsync.js +23 -0
- package/utils/filterAsync.js.map +1 -0
- package/utils/getBaseFieldType.d.ts +4 -0
- package/utils/getBaseFieldType.js +12 -0
- package/utils/getBaseFieldType.js.map +1 -0
- package/utils/getEntryTitle.d.ts +2 -0
- package/{content/plugins/utils → utils}/getEntryTitle.js +7 -6
- package/utils/getEntryTitle.js.map +1 -0
- package/utils/getSchemaFromFieldPlugins.d.ts +9 -0
- package/utils/getSchemaFromFieldPlugins.js +48 -0
- package/utils/getSchemaFromFieldPlugins.js.map +1 -0
- package/utils/ownership.d.ts +8 -0
- package/utils/ownership.js +41 -0
- package/utils/ownership.js.map +1 -0
- package/utils/permissions.d.ts +7 -0
- package/utils/permissions.js +106 -0
- package/utils/permissions.js.map +1 -0
- package/utils/pluralizedTypeName.d.ts +1 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.js +1 -1
- package/utils/pluralizedTypeName.js.map +1 -0
- package/utils/renderFields.d.ts +15 -0
- package/{content/plugins/utils → utils}/renderFields.js +7 -3
- package/utils/renderFields.js.map +1 -0
- package/utils/renderGetFilterFields.d.ts +10 -0
- package/utils/renderGetFilterFields.js +61 -0
- package/utils/renderGetFilterFields.js.map +1 -0
- package/utils/renderInputFields.d.ts +14 -0
- package/{content/plugins/utils → utils}/renderInputFields.js +4 -2
- package/utils/renderInputFields.js.map +1 -0
- package/utils/renderListFilterFields.d.ts +11 -0
- package/{content/plugins/utils → utils}/renderListFilterFields.js +40 -17
- package/utils/renderListFilterFields.js.map +1 -0
- package/utils/renderSortEnum.d.ts +12 -0
- package/utils/renderSortEnum.js +51 -0
- package/utils/renderSortEnum.js.map +1 -0
- package/utils/toSlug.d.ts +1 -0
- package/utils/toSlug.js +20 -0
- package/utils/toSlug.js.map +1 -0
- package/validators/dateGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateGte.js +4 -4
- package/validators/dateGte.js.map +1 -0
- package/validators/dateLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/dateLte.js +4 -4
- package/validators/dateLte.js.map +1 -0
- package/validators/dynamicZone.d.ts +2 -0
- package/validators/dynamicZone.js +24 -0
- package/validators/dynamicZone.js.map +1 -0
- package/validators/gte.d.ts +2 -0
- package/validators/gte.js +36 -0
- package/validators/gte.js.map +1 -0
- package/validators/in.d.ts +2 -0
- package/validators/in.js +36 -0
- package/validators/in.js.map +1 -0
- package/validators/index.d.ts +1 -0
- package/validators/index.js +38 -0
- package/validators/index.js.map +1 -0
- package/validators/lte.d.ts +2 -0
- package/validators/lte.js +36 -0
- package/validators/lte.js.map +1 -0
- package/validators/maxLength.d.ts +2 -0
- package/validators/maxLength.js +36 -0
- package/validators/maxLength.js.map +1 -0
- package/validators/minLength.d.ts +2 -0
- package/validators/minLength.js +36 -0
- package/validators/minLength.js.map +1 -0
- package/validators/pattern.d.ts +2 -0
- package/validators/pattern.js +50 -0
- package/validators/pattern.js.map +1 -0
- package/validators/patternPlugins/email.d.ts +2 -0
- package/validators/patternPlugins/email.js +20 -0
- package/validators/patternPlugins/email.js.map +1 -0
- package/validators/patternPlugins/index.d.ts +2 -0
- package/validators/patternPlugins/index.js +24 -0
- package/validators/patternPlugins/index.js.map +1 -0
- package/validators/patternPlugins/lowerCase.d.ts +2 -0
- package/validators/patternPlugins/lowerCase.js +20 -0
- package/validators/patternPlugins/lowerCase.js.map +1 -0
- package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/lowerCaseSpace.js +20 -0
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
- package/validators/patternPlugins/upperCase.d.ts +2 -0
- package/validators/patternPlugins/upperCase.js +20 -0
- package/validators/patternPlugins/upperCase.js.map +1 -0
- package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/upperCaseSpace.js +20 -0
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
- package/validators/patternPlugins/url.d.ts +2 -0
- package/validators/patternPlugins/url.js +20 -0
- package/validators/patternPlugins/url.js.map +1 -0
- package/validators/required.d.ts +2 -0
- package/validators/required.js +27 -0
- package/validators/required.js.map +1 -0
- package/validators/timeGte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeGte.js +6 -4
- package/validators/timeGte.js.map +1 -0
- package/validators/timeLte.d.ts +2 -0
- package/{content/plugins/validators → validators}/timeLte.js +6 -4
- package/validators/timeLte.js.map +1 -0
- package/validators/unique.d.ts +6 -0
- package/validators/unique.js +63 -0
- package/validators/unique.js.map +1 -0
- 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/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/createManageSDL.d.ts +0 -9
- 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/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/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,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createTypeFromFields = void 0;
|
|
7
|
+
|
|
8
|
+
var _createTypeName = require("./createTypeName");
|
|
9
|
+
|
|
10
|
+
var _renderFields = require("./renderFields");
|
|
11
|
+
|
|
12
|
+
var _renderInputFields = require("./renderInputFields");
|
|
13
|
+
|
|
14
|
+
const createTypeFromFields = params => {
|
|
15
|
+
const {
|
|
16
|
+
typeOfType,
|
|
17
|
+
model,
|
|
18
|
+
type,
|
|
19
|
+
typeNamePrefix,
|
|
20
|
+
fields,
|
|
21
|
+
fieldTypePlugins
|
|
22
|
+
} = params;
|
|
23
|
+
const typeSuffix = typeOfType === "input" ? "Input" : "";
|
|
24
|
+
const mTypeName = (0, _createTypeName.createTypeName)(model.modelId);
|
|
25
|
+
const typeFields = [];
|
|
26
|
+
const nestedTypes = []; // Once the loop below starts, we'll be executing a recursive "object" type generation.
|
|
27
|
+
// The main trick here is that nested objects don't know who the parent is, and will generate
|
|
28
|
+
// type names using the "model", as if they're at the top level:
|
|
29
|
+
// Every time the types are returned, we need to replace the model name in the generated type name
|
|
30
|
+
// with the actual prefix which includes parent field name type.
|
|
31
|
+
|
|
32
|
+
const replace = new RegExp(`${mTypeName}_`, "g");
|
|
33
|
+
|
|
34
|
+
for (const f of fields) {
|
|
35
|
+
const result = typeOfType === "type" ? (0, _renderFields.renderField)({
|
|
36
|
+
field: f,
|
|
37
|
+
type,
|
|
38
|
+
model,
|
|
39
|
+
fieldTypePlugins
|
|
40
|
+
}) : (0, _renderInputFields.renderInputField)({
|
|
41
|
+
field: f,
|
|
42
|
+
model,
|
|
43
|
+
fieldTypePlugins
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
if (!result) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const {
|
|
51
|
+
fields,
|
|
52
|
+
typeDefs
|
|
53
|
+
} = result;
|
|
54
|
+
typeFields.push(fields.replace(replace, `${typeNamePrefix}_`));
|
|
55
|
+
|
|
56
|
+
if (typeDefs) {
|
|
57
|
+
nestedTypes.push(typeDefs.replace(replace, `${typeNamePrefix}_`));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
fieldType: `${typeNamePrefix}${typeSuffix}`,
|
|
63
|
+
typeDefs:
|
|
64
|
+
/* GraphQL */
|
|
65
|
+
`
|
|
66
|
+
${nestedTypes.join("\n")}
|
|
67
|
+
|
|
68
|
+
${typeOfType} ${typeNamePrefix}${typeSuffix} {
|
|
69
|
+
${typeFields.join("\n")}
|
|
70
|
+
}
|
|
71
|
+
`
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.createTypeFromFields = createTypeFromFields;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createTypeFromFields","params","typeOfType","model","type","typeNamePrefix","fields","fieldTypePlugins","typeSuffix","mTypeName","createTypeName","modelId","typeFields","nestedTypes","replace","RegExp","f","result","renderField","field","renderInputField","typeDefs","push","fieldType","join"],"sources":["createTypeFromFields.ts"],"sourcesContent":["import { createTypeName } from \"~/utils/createTypeName\";\nimport { renderField } from \"~/utils/renderFields\";\nimport { renderInputField } from \"~/utils/renderInputFields\";\nimport { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from \"~/types\";\n\ninterface TypeFromFieldParams {\n typeOfType: \"type\" | \"input\";\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, type, typeNamePrefix, fields, fieldTypePlugins } = params;\n const typeSuffix = typeOfType === \"input\" ? \"Input\" : \"\";\n const mTypeName = createTypeName(model.modelId);\n\n const typeFields = [];\n const nestedTypes = [];\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 f of fields) {\n const result =\n typeOfType === \"type\"\n ? renderField({ field: f, type, model, fieldTypePlugins })\n : renderInputField({ field: f, 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;;AACA;;AAiBO,MAAMA,oBAAoB,GAAIC,MAAD,IAA+D;EAC/F,MAAM;IAAEC,UAAF;IAAcC,KAAd;IAAqBC,IAArB;IAA2BC,cAA3B;IAA2CC,MAA3C;IAAmDC;EAAnD,IAAwEN,MAA9E;EACA,MAAMO,UAAU,GAAGN,UAAU,KAAK,OAAf,GAAyB,OAAzB,GAAmC,EAAtD;EACA,MAAMO,SAAS,GAAG,IAAAC,8BAAA,EAAeP,KAAK,CAACQ,OAArB,CAAlB;EAEA,MAAMC,UAAU,GAAG,EAAnB;EACA,MAAMC,WAAW,GAAG,EAApB,CAN+F,CAQ/F;EACA;EACA;EACA;EACA;;EACA,MAAMC,OAAO,GAAG,IAAIC,MAAJ,CAAY,GAAEN,SAAU,GAAxB,EAA4B,GAA5B,CAAhB;;EAEA,KAAK,MAAMO,CAAX,IAAgBV,MAAhB,EAAwB;IACpB,MAAMW,MAAM,GACRf,UAAU,KAAK,MAAf,GACM,IAAAgB,yBAAA,EAAY;MAAEC,KAAK,EAAEH,CAAT;MAAYZ,IAAZ;MAAkBD,KAAlB;MAAyBI;IAAzB,CAAZ,CADN,GAEM,IAAAa,mCAAA,EAAiB;MAAED,KAAK,EAAEH,CAAT;MAAYb,KAAZ;MAAmBI;IAAnB,CAAjB,CAHV;;IAKA,IAAI,CAACU,MAAL,EAAa;MACT;IACH;;IAED,MAAM;MAAEX,MAAF;MAAUe;IAAV,IAAuBJ,MAA7B;IAEAL,UAAU,CAACU,IAAX,CAAgBhB,MAAM,CAACQ,OAAP,CAAeA,OAAf,EAAyB,GAAET,cAAe,GAA1C,CAAhB;;IACA,IAAIgB,QAAJ,EAAc;MACVR,WAAW,CAACS,IAAZ,CAAiBD,QAAQ,CAACP,OAAT,CAAiBA,OAAjB,EAA2B,GAAET,cAAe,GAA5C,CAAjB;IACH;EACJ;;EAED,OAAO;IACHkB,SAAS,EAAG,GAAElB,cAAe,GAAEG,UAAW,EADvC;IAEHa,QAAQ;IAAE;IAAe;AACjC,cAAcR,WAAW,CAACW,IAAZ,CAAiB,IAAjB,CAAuB;AACrC;AACA,cAActB,UAAW,IAAGG,cAAe,GAAEG,UAAW;AACxD,kBAAkBI,UAAU,CAACY,IAAX,CAAgB,IAAhB,CAAsB;AACxC;AACA;EARW,CAAP;AAUH,CA3CM"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const createTypeName: (modelId: string) =>
|
|
2
|
-
export declare const createReadTypeName: (baseTypeName: string) =>
|
|
3
|
-
export declare const createManageTypeName: (baseTypeName: string) =>
|
|
1
|
+
export declare const createTypeName: (modelId: string) => string;
|
|
2
|
+
export declare const createReadTypeName: (baseTypeName: string) => string;
|
|
3
|
+
export declare const createManageTypeName: (baseTypeName: string) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -9,8 +9,10 @@ exports.createTypeName = exports.createReadTypeName = exports.createManageTypeNa
|
|
|
9
9
|
|
|
10
10
|
var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
|
|
11
11
|
|
|
12
|
+
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
13
|
+
|
|
12
14
|
const createTypeName = modelId => {
|
|
13
|
-
return (0, _upperFirst.default)(modelId);
|
|
15
|
+
return (0, _upperFirst.default)((0, _camelCase.default)(modelId));
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
exports.createTypeName = createTypeName;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createTypeName","modelId","upperFirst","camelCase","createReadTypeName","baseTypeName","createManageTypeName"],"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\nexport const createReadTypeName = (baseTypeName: string): string => {\n return createTypeName(baseTypeName);\n};\n\nexport const createManageTypeName = (baseTypeName: string): string => {\n return createTypeName(baseTypeName);\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEO,MAAMA,cAAc,GAAIC,OAAD,IAA6B;EACvD,OAAO,IAAAC,mBAAA,EAAW,IAAAC,kBAAA,EAAUF,OAAV,CAAX,CAAP;AACH,CAFM;;;;AAIA,MAAMG,kBAAkB,GAAIC,YAAD,IAAkC;EAChE,OAAOL,cAAc,CAACK,YAAD,CAArB;AACH,CAFM;;;;AAIA,MAAMC,oBAAoB,GAAID,YAAD,IAAkC;EAClE,OAAOL,cAAc,CAACK,YAAD,CAArB;AACH,CAFM"}
|
|
@@ -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,41 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.entryToStorageTransform = exports.entryFromStorageTransform = exports.entryFieldFromStorageTransform = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
13
|
|
|
14
|
-
var _StorageTransformPlugin = require("../
|
|
14
|
+
var _StorageTransformPlugin = require("../plugins/StorageTransformPlugin");
|
|
15
15
|
|
|
16
|
-
|
|
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; }
|
|
16
|
+
var _getBaseFieldType = require("./getBaseFieldType");
|
|
19
17
|
|
|
20
18
|
const getStoragePluginFactory = context => {
|
|
21
19
|
let defaultStoragePlugin;
|
|
22
20
|
const plugins = context.plugins.byType(_StorageTransformPlugin.StorageTransformPlugin.type) // we reverse plugins because we want to get latest added only
|
|
23
21
|
.reverse().reduce((collection, plugin) => {
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Check if it's a default plugin and set it - always override the previous one.
|
|
24
|
+
*/
|
|
25
|
+
if (plugin.fieldType === "*") {
|
|
26
26
|
defaultStoragePlugin = plugin;
|
|
27
27
|
return collection;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* We will just set the plugin for given type.
|
|
31
|
+
* The last one will override existing one - so users can override our default ones.
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
collection[plugin.fieldType] = plugin;
|
|
37
|
-
}
|
|
38
|
-
|
|
35
|
+
collection[plugin.fieldType] = plugin;
|
|
39
36
|
return collection;
|
|
40
37
|
}, {});
|
|
41
38
|
return fieldType => {
|
|
@@ -52,10 +49,11 @@ const entryStorageTransform = async (context, model, operation, entry) => {
|
|
|
52
49
|
const transformedValues = {};
|
|
53
50
|
|
|
54
51
|
for (const field of model.fields) {
|
|
55
|
-
const
|
|
52
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
53
|
+
const plugin = getStoragePlugin(baseType); // TODO: remove this once plugins are converted into classes
|
|
56
54
|
|
|
57
55
|
if (typeof plugin[operation] !== "function") {
|
|
58
|
-
throw new _error.default(`Missing "${operation}" function in storage plugin "${plugin.name}" for field type "${
|
|
56
|
+
throw new _error.default(`Missing "${operation}" function in storage plugin "${plugin.name}" for field type "${baseType}"`);
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
transformedValues[field.fieldId] = await plugin[operation]({
|
|
@@ -67,7 +65,7 @@ const entryStorageTransform = async (context, model, operation, entry) => {
|
|
|
67
65
|
});
|
|
68
66
|
}
|
|
69
67
|
|
|
70
|
-
return
|
|
68
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
71
69
|
values: transformedValues
|
|
72
70
|
});
|
|
73
71
|
};
|
|
@@ -87,10 +85,6 @@ const entryToStorageTransform = async (context, model, entry) => {
|
|
|
87
85
|
exports.entryToStorageTransform = entryToStorageTransform;
|
|
88
86
|
|
|
89
87
|
const entryFromStorageTransform = async (context, model, entry) => {
|
|
90
|
-
if (!entry) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
88
|
return entryStorageTransform(context, model, "fromStorage", entry);
|
|
95
89
|
};
|
|
96
90
|
|
|
@@ -107,10 +101,11 @@ const entryFieldFromStorageTransform = async params => {
|
|
|
107
101
|
value
|
|
108
102
|
} = params;
|
|
109
103
|
const getStoragePlugin = getStoragePluginFactory(context);
|
|
110
|
-
const
|
|
104
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
105
|
+
const plugin = getStoragePlugin(baseType); // TODO: remove this once plugins are converted into classes
|
|
111
106
|
|
|
112
107
|
if (typeof plugin.fromStorage !== "function") {
|
|
113
|
-
throw new _error.default(`Missing "fromStorage" function in storage plugin "${plugin.name}" for field type "${
|
|
108
|
+
throw new _error.default(`Missing "fromStorage" function in storage plugin "${plugin.name}" for field type "${baseType}"`);
|
|
114
109
|
}
|
|
115
110
|
|
|
116
111
|
return plugin.fromStorage({
|
|
@@ -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,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.filterAsync = void 0;
|
|
7
|
+
|
|
8
|
+
const filterAsync = async (items, predicate) => {
|
|
9
|
+
const filteredItems = [];
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < items.length; i++) {
|
|
12
|
+
const item = items[i];
|
|
13
|
+
const valid = await predicate(item);
|
|
14
|
+
|
|
15
|
+
if (valid) {
|
|
16
|
+
filteredItems.push(item);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return filteredItems;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
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,KADuB,EAEvBC,SAFuB,KAGR;EACf,MAAMC,aAAa,GAAG,EAAtB;;EAEA,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGH,KAAK,CAACI,MAA1B,EAAkCD,CAAC,EAAnC,EAAuC;IACnC,MAAME,IAAI,GAAGL,KAAK,CAACG,CAAD,CAAlB;IACA,MAAMG,KAAK,GAAG,MAAML,SAAS,CAACI,IAAD,CAA7B;;IACA,IAAIC,KAAJ,EAAW;MACPJ,aAAa,CAACK,IAAd,CAAmBF,IAAnB;IACH;EACJ;;EAED,OAAOH,aAAP;AACH,CAfM"}
|
|
@@ -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,KAAD,IAA4C;EACxE,OAAOA,KAAK,CAACC,IAAN,CAAWC,KAAX,CAAiB,GAAjB,EAAsB,CAAtB,CAAP;AACH,CAFM"}
|
|
@@ -10,16 +10,17 @@ function getEntryTitle(model, entry) {
|
|
|
10
10
|
return entry.id;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const field = model.fields.find(f => f.fieldId === model.titleFieldId);
|
|
14
14
|
|
|
15
|
-
if (!
|
|
15
|
+
if (!field) {
|
|
16
16
|
return entry.id;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const titleFieldId = field.fieldId;
|
|
20
|
+
const titleValue = entry.values[titleFieldId];
|
|
20
21
|
|
|
21
|
-
if (!
|
|
22
|
-
return
|
|
22
|
+
if (!titleValue) {
|
|
23
|
+
return entry.id;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
const {
|
|
@@ -27,7 +28,7 @@ function getEntryTitle(model, entry) {
|
|
|
27
28
|
values
|
|
28
29
|
} = field.predefinedValues || {};
|
|
29
30
|
|
|
30
|
-
if (!enabled || Array.isArray(values) === false) {
|
|
31
|
+
if (!enabled || !values || Array.isArray(values) === false) {
|
|
31
32
|
return titleValue;
|
|
32
33
|
}
|
|
33
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,aAAT,CAAuBC,KAAvB,EAAwCC,KAAxC,EAAiE;EACpE,IAAI,CAACD,KAAK,CAACE,YAAX,EAAyB;IACrB,OAAOD,KAAK,CAACE,EAAb;EACH;;EACD,MAAMC,KAAK,GAAGJ,KAAK,CAACK,MAAN,CAAaC,IAAb,CAAkBC,CAAC,IAAIA,CAAC,CAACC,OAAF,KAAcR,KAAK,CAACE,YAA3C,CAAd;;EACA,IAAI,CAACE,KAAL,EAAY;IACR,OAAOH,KAAK,CAACE,EAAb;EACH;;EACD,MAAMD,YAAY,GAAGE,KAAK,CAACI,OAA3B;EACA,MAAMC,UAAU,GAAGR,KAAK,CAACS,MAAN,CAAaR,YAAb,CAAnB;;EACA,IAAI,CAACO,UAAL,EAAiB;IACb,OAAOR,KAAK,CAACE,EAAb;EACH;;EAED,MAAM;IAAEQ,OAAO,GAAG,KAAZ;IAAmBD;EAAnB,IAA8BN,KAAK,CAACQ,gBAAN,IAA0B,EAA9D;;EACA,IAAI,CAACD,OAAD,IAAY,CAACD,MAAb,IAAuBG,KAAK,CAACC,OAAN,CAAcJ,MAAd,MAA0B,KAArD,EAA4D;IACxD,OAAOD,UAAP;EACH;;EACD,KAAK,MAAMM,KAAX,IAAoBL,MAApB,EAA4B;IACxB;IACA,IAAIK,KAAK,CAACA,KAAN,IAAeN,UAAnB,EAA+B;MAC3B,OAAOM,KAAK,CAACC,KAAb;IACH;EACJ;;EACD,OAAOP,UAAP;AACH"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CmsModel, CmsFieldTypePlugins, ApiEndpoint } from "../types";
|
|
2
|
+
import { CmsGraphQLSchemaPlugin } from "../plugins";
|
|
3
|
+
interface Params {
|
|
4
|
+
models: CmsModel[];
|
|
5
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
|
+
type: ApiEndpoint;
|
|
7
|
+
}
|
|
8
|
+
export declare const createGraphQLSchemaPluginFromFieldPlugins: (params: Params) => CmsGraphQLSchemaPlugin<import("../types").CmsContext>[];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createGraphQLSchemaPluginFromFieldPlugins = void 0;
|
|
7
|
+
|
|
8
|
+
var _plugins = require("../plugins");
|
|
9
|
+
|
|
10
|
+
const TYPE_MAP = {
|
|
11
|
+
preview: "read",
|
|
12
|
+
read: "read",
|
|
13
|
+
manage: "manage"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const createGraphQLSchemaPluginFromFieldPlugins = params => {
|
|
17
|
+
const {
|
|
18
|
+
models,
|
|
19
|
+
fieldTypePlugins,
|
|
20
|
+
type
|
|
21
|
+
} = params;
|
|
22
|
+
const plugins = [];
|
|
23
|
+
|
|
24
|
+
for (const key in fieldTypePlugins) {
|
|
25
|
+
const fieldTypePlugin = fieldTypePlugins[key];
|
|
26
|
+
|
|
27
|
+
if (!TYPE_MAP[type] || !fieldTypePlugin[TYPE_MAP[type]]) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const createSchema = fieldTypePlugin[TYPE_MAP[type]].createSchema; // Render gql types generated by field type plugins
|
|
32
|
+
|
|
33
|
+
if (!createSchema) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const schema = createSchema({
|
|
38
|
+
models
|
|
39
|
+
});
|
|
40
|
+
const plugin = new _plugins.CmsGraphQLSchemaPlugin(schema);
|
|
41
|
+
plugin.name = `headless-cms.graphql.schema.${type}.field.${fieldTypePlugin.fieldType}`;
|
|
42
|
+
plugins.push(plugin);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return plugins;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.createGraphQLSchemaPluginFromFieldPlugins = createGraphQLSchemaPluginFromFieldPlugins;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TYPE_MAP","preview","read","manage","createGraphQLSchemaPluginFromFieldPlugins","params","models","fieldTypePlugins","type","plugins","key","fieldTypePlugin","createSchema","schema","plugin","CmsGraphQLSchemaPlugin","name","fieldType","push"],"sources":["getSchemaFromFieldPlugins.ts"],"sourcesContent":["import { CmsModel, CmsFieldTypePlugins, ApiEndpoint } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\n\nconst TYPE_MAP: Record<string, \"manage\" | \"read\"> = {\n preview: \"read\",\n read: \"read\",\n manage: \"manage\"\n};\n\ninterface Params {\n models: CmsModel[];\n fieldTypePlugins: CmsFieldTypePlugins;\n type: ApiEndpoint;\n}\nexport const createGraphQLSchemaPluginFromFieldPlugins = (params: Params) => {\n const { models, fieldTypePlugins, type } = params;\n\n const plugins: CmsGraphQLSchemaPlugin[] = [];\n for (const key in fieldTypePlugins) {\n const fieldTypePlugin = fieldTypePlugins[key];\n if (!TYPE_MAP[type] || !fieldTypePlugin[TYPE_MAP[type]]) {\n continue;\n }\n const createSchema = fieldTypePlugin[TYPE_MAP[type]].createSchema;\n // Render gql types generated by field type plugins\n if (!createSchema) {\n continue;\n }\n const schema = createSchema({ models });\n\n const plugin = new CmsGraphQLSchemaPlugin(schema);\n plugin.name = `headless-cms.graphql.schema.${type}.field.${fieldTypePlugin.fieldType}`;\n plugins.push(plugin);\n }\n return plugins;\n};\n"],"mappings":";;;;;;;AACA;;AAEA,MAAMA,QAA2C,GAAG;EAChDC,OAAO,EAAE,MADuC;EAEhDC,IAAI,EAAE,MAF0C;EAGhDC,MAAM,EAAE;AAHwC,CAApD;;AAWO,MAAMC,yCAAyC,GAAIC,MAAD,IAAoB;EACzE,MAAM;IAAEC,MAAF;IAAUC,gBAAV;IAA4BC;EAA5B,IAAqCH,MAA3C;EAEA,MAAMI,OAAiC,GAAG,EAA1C;;EACA,KAAK,MAAMC,GAAX,IAAkBH,gBAAlB,EAAoC;IAChC,MAAMI,eAAe,GAAGJ,gBAAgB,CAACG,GAAD,CAAxC;;IACA,IAAI,CAACV,QAAQ,CAACQ,IAAD,CAAT,IAAmB,CAACG,eAAe,CAACX,QAAQ,CAACQ,IAAD,CAAT,CAAvC,EAAyD;MACrD;IACH;;IACD,MAAMI,YAAY,GAAGD,eAAe,CAACX,QAAQ,CAACQ,IAAD,CAAT,CAAf,CAAgCI,YAArD,CALgC,CAMhC;;IACA,IAAI,CAACA,YAAL,EAAmB;MACf;IACH;;IACD,MAAMC,MAAM,GAAGD,YAAY,CAAC;MAAEN;IAAF,CAAD,CAA3B;IAEA,MAAMQ,MAAM,GAAG,IAAIC,+BAAJ,CAA2BF,MAA3B,CAAf;IACAC,MAAM,CAACE,IAAP,GAAe,+BAA8BR,IAAK,UAASG,eAAe,CAACM,SAAU,EAArF;IACAR,OAAO,CAACS,IAAR,CAAaJ,MAAb;EACH;;EACD,OAAOL,OAAP;AACH,CArBM"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseCmsSecurityPermission, CmsContext, CreatedBy } from "../types";
|
|
2
|
+
interface OwnableRecord {
|
|
3
|
+
createdBy?: CreatedBy;
|
|
4
|
+
ownedBy?: CreatedBy;
|
|
5
|
+
}
|
|
6
|
+
export declare const checkOwnership: (context: CmsContext, permission: BaseCmsSecurityPermission, record: OwnableRecord) => void;
|
|
7
|
+
export declare const validateOwnership: (context: CmsContext, permission: BaseCmsSecurityPermission, record: OwnableRecord) => boolean;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.validateOwnership = exports.checkOwnership = void 0;
|
|
7
|
+
|
|
8
|
+
var _apiSecurity = require("@webiny/api-security");
|
|
9
|
+
|
|
10
|
+
const checkOwnership = (context, permission, record) => {
|
|
11
|
+
var _record$ownedBy, _record$createdBy;
|
|
12
|
+
|
|
13
|
+
if (!permission.own) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const identity = context.security.getIdentity();
|
|
18
|
+
const owner = identity && ((_record$ownedBy = record.ownedBy) === null || _record$ownedBy === void 0 ? void 0 : _record$ownedBy.id) === identity.id;
|
|
19
|
+
const creator = identity && ((_record$createdBy = record.createdBy) === null || _record$createdBy === void 0 ? void 0 : _record$createdBy.id) === identity.id;
|
|
20
|
+
|
|
21
|
+
if (!owner && !creator) {
|
|
22
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
23
|
+
data: {
|
|
24
|
+
reason: `You are not the owner of the record.`
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.checkOwnership = checkOwnership;
|
|
31
|
+
|
|
32
|
+
const validateOwnership = (context, permission, record) => {
|
|
33
|
+
try {
|
|
34
|
+
checkOwnership(context, permission, record);
|
|
35
|
+
return true;
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.validateOwnership = validateOwnership;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["checkOwnership","context","permission","record","own","identity","security","getIdentity","owner","ownedBy","id","creator","createdBy","NotAuthorizedError","data","reason","validateOwnership"],"sources":["ownership.ts"],"sourcesContent":["import { BaseCmsSecurityPermission, CmsContext, CreatedBy } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\ninterface OwnableRecord {\n createdBy?: CreatedBy;\n ownedBy?: CreatedBy;\n}\n\nexport const checkOwnership = (\n context: CmsContext,\n permission: BaseCmsSecurityPermission,\n record: OwnableRecord\n): void => {\n if (!permission.own) {\n return;\n }\n\n const identity = context.security.getIdentity();\n const owner = identity && record.ownedBy?.id === identity.id;\n const creator = identity && record.createdBy?.id === identity.id;\n\n if (!owner && !creator) {\n throw new NotAuthorizedError({\n data: {\n reason: `You are not the owner of the record.`\n }\n });\n }\n};\n\nexport const validateOwnership = (\n context: CmsContext,\n permission: BaseCmsSecurityPermission,\n record: OwnableRecord\n): boolean => {\n try {\n checkOwnership(context, permission, record);\n return true;\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;;AACA;;AAOO,MAAMA,cAAc,GAAG,CAC1BC,OAD0B,EAE1BC,UAF0B,EAG1BC,MAH0B,KAInB;EAAA;;EACP,IAAI,CAACD,UAAU,CAACE,GAAhB,EAAqB;IACjB;EACH;;EAED,MAAMC,QAAQ,GAAGJ,OAAO,CAACK,QAAR,CAAiBC,WAAjB,EAAjB;EACA,MAAMC,KAAK,GAAGH,QAAQ,IAAI,oBAAAF,MAAM,CAACM,OAAP,oEAAgBC,EAAhB,MAAuBL,QAAQ,CAACK,EAA1D;EACA,MAAMC,OAAO,GAAGN,QAAQ,IAAI,sBAAAF,MAAM,CAACS,SAAP,wEAAkBF,EAAlB,MAAyBL,QAAQ,CAACK,EAA9D;;EAEA,IAAI,CAACF,KAAD,IAAU,CAACG,OAAf,EAAwB;IACpB,MAAM,IAAIE,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG;MADP;IADmB,CAAvB,CAAN;EAKH;AACJ,CApBM;;;;AAsBA,MAAMC,iBAAiB,GAAG,CAC7Bf,OAD6B,EAE7BC,UAF6B,EAG7BC,MAH6B,KAInB;EACV,IAAI;IACAH,cAAc,CAACC,OAAD,EAAUC,UAAV,EAAsBC,MAAtB,CAAd;IACA,OAAO,IAAP;EACH,CAHD,CAGE,MAAM;IACJ,OAAO,KAAP;EACH;AACJ,CAXM"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseCmsSecurityPermission, CmsContext, CmsEntryPermission } from "../types";
|
|
2
|
+
export declare const hasRwd: (permission: BaseCmsSecurityPermission, rwd: string) => boolean;
|
|
3
|
+
export declare const hasPw: (permission: CmsEntryPermission, pw: string) => boolean;
|
|
4
|
+
export declare const checkPermissions: <TPermission extends BaseCmsSecurityPermission = BaseCmsSecurityPermission>(context: CmsContext, name: string, check?: {
|
|
5
|
+
rwd?: string;
|
|
6
|
+
pw?: string;
|
|
7
|
+
}) => Promise<TPermission>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hasRwd = exports.hasPw = exports.checkPermissions = void 0;
|
|
7
|
+
|
|
8
|
+
var _apiSecurity = require("@webiny/api-security");
|
|
9
|
+
|
|
10
|
+
const hasRwd = (permission, rwd) => {
|
|
11
|
+
if (typeof permission.rwd !== "string") {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return permission.rwd.includes(rwd);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.hasRwd = hasRwd;
|
|
19
|
+
|
|
20
|
+
const hasPw = (permission, pw) => {
|
|
21
|
+
const isCustom = Object.keys(permission).length > 1; // "name" key is always present
|
|
22
|
+
|
|
23
|
+
if (!isCustom) {
|
|
24
|
+
// Means it's a "full-access" permission.
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (typeof permission.pw !== "string") {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return permission.pw.includes(pw);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.hasPw = hasPw;
|
|
36
|
+
const PW = {
|
|
37
|
+
p: "publish",
|
|
38
|
+
u: "unpublish"
|
|
39
|
+
};
|
|
40
|
+
const RWD = {
|
|
41
|
+
r: "read",
|
|
42
|
+
w: "write",
|
|
43
|
+
d: "delete"
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const checkPermissions = async (context, name, check) => {
|
|
47
|
+
// Check if user is allowed to edit content in current language
|
|
48
|
+
const contentPermission = await context.security.getPermission("content.i18n");
|
|
49
|
+
|
|
50
|
+
if (!contentPermission) {
|
|
51
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
52
|
+
data: {
|
|
53
|
+
reason: "Missing access to content in any locale."
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
} // We need to check this manually as CMS locale comes from the URL and not the default i18n app.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
const code = context.cms.getLocale().code;
|
|
60
|
+
const locales = contentPermission.locales; // IMPORTANT: If we have a `contentPermission`, and `locales` key is NOT SET - it means the user has access to all locales.
|
|
61
|
+
// However, if the the `locales` IS SET - check that it contains the required locale.
|
|
62
|
+
|
|
63
|
+
if (Array.isArray(locales) && !locales.includes(code)) {
|
|
64
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
65
|
+
data: {
|
|
66
|
+
reason: `Not allowed to access content in "${code}."`
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const permission = await context.security.getPermission(name);
|
|
72
|
+
|
|
73
|
+
if (!permission) {
|
|
74
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
75
|
+
data: {
|
|
76
|
+
reason: `Missing permission "${name}".`
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!check) {
|
|
82
|
+
return permission;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (check.rwd && !hasRwd(permission, check.rwd)) {
|
|
86
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
87
|
+
data: {
|
|
88
|
+
reason: `Not allowed to perform "${RWD[check.rwd]}" on "${name}".`
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
} // p = publish
|
|
92
|
+
// u = unpublish
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
if (check.pw && !hasPw(permission, check.pw)) {
|
|
96
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
97
|
+
data: {
|
|
98
|
+
reason: `Not allowed to perform "${PW[check.pw]}" on "${name}".`
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return permission;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
exports.checkPermissions = checkPermissions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["hasRwd","permission","rwd","includes","hasPw","pw","isCustom","Object","keys","length","PW","p","u","RWD","r","w","d","checkPermissions","context","name","check","contentPermission","security","getPermission","NotAuthorizedError","data","reason","code","cms","getLocale","locales","Array","isArray"],"sources":["permissions.ts"],"sourcesContent":["import { BaseCmsSecurityPermission, CmsContext, CmsEntryPermission } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\nexport const hasRwd = (permission: BaseCmsSecurityPermission, rwd: string): boolean => {\n if (typeof permission.rwd !== \"string\") {\n return true;\n }\n\n return permission.rwd.includes(rwd);\n};\n\nexport const hasPw = (permission: CmsEntryPermission, pw: string): boolean => {\n const isCustom = Object.keys(permission).length > 1; // \"name\" key is always present\n\n if (!isCustom) {\n // Means it's a \"full-access\" permission.\n return true;\n }\n\n if (typeof permission.pw !== \"string\") {\n return false;\n }\n\n return permission.pw.includes(pw);\n};\n\nconst PW: Record<string, string> = {\n p: \"publish\",\n u: \"unpublish\"\n};\n\nconst RWD: Record<string, string> = {\n r: \"read\",\n w: \"write\",\n d: \"delete\"\n};\n\nexport const checkPermissions = async <\n TPermission extends BaseCmsSecurityPermission = BaseCmsSecurityPermission\n>(\n context: CmsContext,\n name: string,\n check?: { rwd?: string; pw?: string }\n): Promise<TPermission> => {\n // Check if user is allowed to edit content in current language\n const contentPermission = await context.security.getPermission(\"content.i18n\");\n\n if (!contentPermission) {\n throw new NotAuthorizedError({\n data: {\n reason: \"Missing access to content in any locale.\"\n }\n });\n }\n\n // We need to check this manually as CMS locale comes from the URL and not the default i18n app.\n const code = context.cms.getLocale().code;\n\n const locales: string[] = contentPermission.locales;\n\n // IMPORTANT: If we have a `contentPermission`, and `locales` key is NOT SET - it means the user has access to all locales.\n // However, if the the `locales` IS SET - check that it contains the required locale.\n if (Array.isArray(locales) && !locales.includes(code)) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to access content in \"${code}.\"`\n }\n });\n }\n\n const permission = await context.security.getPermission<TPermission>(name);\n\n if (!permission) {\n throw new NotAuthorizedError({\n data: {\n reason: `Missing permission \"${name}\".`\n }\n });\n }\n\n if (!check) {\n return permission;\n }\n\n if (check.rwd && !hasRwd(permission, check.rwd)) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to perform \"${RWD[check.rwd]}\" on \"${name}\".`\n }\n });\n }\n\n // p = publish\n // u = unpublish\n if (check.pw && !hasPw(permission, check.pw)) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to perform \"${PW[check.pw]}\" on \"${name}\".`\n }\n });\n }\n\n return permission;\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pluralizedTypeName: (typeName: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["pluralizedTypeName","typeName","length","pluralize"],"sources":["pluralizedTypeName.ts"],"sourcesContent":["import pluralize from \"pluralize\";\n\n// This will make it so if the content model name is a single capitalized letter\n// Ex. A, pluralizedTypeName will capitalize the name to As, instead of AS\nexport const pluralizedTypeName = (typeName: string): string => {\n let pluralizedTypeName;\n if (typeName.length === 1) {\n pluralizedTypeName = `${typeName}s`;\n } else {\n pluralizedTypeName = pluralize(typeName);\n }\n return pluralizedTypeName;\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;AACA;AACO,MAAMA,kBAAkB,GAAIC,QAAD,IAA8B;EAC5D,IAAID,kBAAJ;;EACA,IAAIC,QAAQ,CAACC,MAAT,KAAoB,CAAxB,EAA2B;IACvBF,kBAAkB,GAAI,GAAEC,QAAS,GAAjC;EACH,CAFD,MAEO;IACHD,kBAAkB,GAAG,IAAAG,kBAAA,EAAUF,QAAV,CAArB;EACH;;EACD,OAAOD,kBAAP;AACH,CARM"}
|