@webiny/api-headless-cms 0.0.0-mt-2 → 0.0.0-unstable.5e7233243f
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 +3 -0
- package/context.js +64 -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 +26 -10
- 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 +6 -6
- package/crud/contentEntry/markLockedFields.js.map +1 -0
- package/crud/contentEntry/referenceFieldsMapping.d.ts +13 -0
- package/crud/contentEntry/referenceFieldsMapping.js +294 -0
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -0
- package/{content/plugins/crud → crud}/contentEntry.crud.d.ts +5 -7
- package/{content/plugins/crud → crud}/contentEntry.crud.js +585 -219
- package/crud/contentEntry.crud.js.map +1 -0
- package/crud/contentModel/afterCreate.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentModel/afterCreate.js +2 -2
- 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/{content/plugins/crud → crud}/contentModel/afterDelete.js +2 -2
- package/crud/contentModel/afterDelete.js.map +1 -0
- package/crud/contentModel/afterUpdate.d.ts +8 -0
- package/{content/plugins/crud → crud}/contentModel/afterUpdate.js +2 -2
- package/crud/contentModel/afterUpdate.js.map +1 -0
- package/crud/contentModel/beforeCreate.d.ts +15 -0
- package/{content/plugins/crud → crud}/contentModel/beforeCreate.js +58 -10
- package/crud/contentModel/beforeCreate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.d.ts +5 -4
- package/{content/plugins/crud → crud}/contentModel/beforeDelete.js +10 -6
- package/crud/contentModel/beforeDelete.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel/beforeUpdate.d.ts +5 -4
- 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 +16 -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 +64 -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 +9 -0
- package/crud/contentModel/validateModel.js +32 -0
- package/crud/contentModel/validateModel.js.map +1 -0
- package/crud/contentModel/validateModelFields.d.ts +9 -0
- package/crud/contentModel/validateModelFields.js +363 -0
- package/crud/contentModel/validateModelFields.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModel.crud.d.ts +3 -3
- package/{content/plugins/crud → crud}/contentModel.crud.js +251 -95
- package/crud/contentModel.crud.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.d.ts +4 -3
- package/{content/plugins/crud → crud}/contentModelGroup/beforeCreate.js +6 -6
- package/crud/contentModelGroup/beforeCreate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.d.ts +4 -3
- package/{content/plugins/crud → crud}/contentModelGroup/beforeDelete.js +1 -1
- package/crud/contentModelGroup/beforeDelete.js.map +1 -0
- package/crud/contentModelGroup/beforeUpdate.d.ts +9 -0
- package/{content/plugins/crud → crud}/contentModelGroup/beforeUpdate.js +1 -1
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
- package/{content/plugins/crud → crud}/contentModelGroup.crud.d.ts +3 -3
- package/{content/plugins/crud → crud}/contentModelGroup.crud.js +54 -59
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/crud/index.d.ts +6 -0
- package/{content/plugins/crud → crud}/index.js +15 -26
- package/crud/index.js.map +1 -0
- package/{plugins/crud → crud}/settings.crud.d.ts +3 -3
- package/crud/settings.crud.js +88 -0
- package/crud/settings.crud.js.map +1 -0
- package/{plugins/crud → crud}/system.crud.d.ts +6 -3
- package/{plugins/crud → crud}/system.crud.js +43 -16
- 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/CmsModelObjectFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +306 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/index.d.ts +3 -0
- package/fieldConverters/index.js +16 -0
- package/fieldConverters/index.js.map +1 -0
- package/{content/plugins → graphql}/buildSchemaPlugins.d.ts +2 -3
- package/graphql/buildSchemaPlugins.js +27 -0
- package/graphql/buildSchemaPlugins.js.map +1 -0
- package/graphql/graphQLHandlerFactory.d.ts +5 -0
- package/graphql/graphQLHandlerFactory.js +158 -0
- package/graphql/graphQLHandlerFactory.js.map +1 -0
- package/graphql/index.d.ts +5 -0
- package/graphql/index.js +57 -0
- package/graphql/index.js.map +1 -0
- package/graphql/schema/baseContentSchema.d.ts +3 -0
- package/{content/plugins/schema/baseSchema.js → graphql/schema/baseContentSchema.js} +10 -28
- package/graphql/schema/baseContentSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +3 -0
- package/graphql/schema/contentEntries.js +351 -0
- package/graphql/schema/contentEntries.js.map +1 -0
- package/graphql/schema/contentModelGroups.d.ts +3 -0
- package/{content/plugins → graphql}/schema/contentModelGroups.js +34 -15
- package/graphql/schema/contentModelGroups.js.map +1 -0
- package/graphql/schema/contentModels.d.ts +3 -0
- package/{content/plugins → graphql}/schema/contentModels.js +47 -10
- package/graphql/schema/contentModels.js.map +1 -0
- package/graphql/schema/createFieldResolvers.d.ts +20 -0
- package/{content/plugins → graphql}/schema/createFieldResolvers.js +48 -17
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +12 -0
- package/{content/plugins → graphql}/schema/createManageResolvers.js +35 -19
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/graphql/schema/createManageSDL.d.ts +10 -0
- package/{content/plugins → graphql}/schema/createManageSDL.js +20 -9
- package/graphql/schema/createManageSDL.js.map +1 -0
- package/graphql/schema/createPreviewResolvers.d.ts +12 -0
- package/{content/plugins → graphql}/schema/createPreviewResolvers.js +16 -9
- package/graphql/schema/createPreviewResolvers.js.map +1 -0
- package/graphql/schema/createReadResolvers.d.ts +12 -0
- package/{content/plugins → graphql}/schema/createReadResolvers.js +16 -9
- package/graphql/schema/createReadResolvers.js.map +1 -0
- package/graphql/schema/createReadSDL.d.ts +10 -0
- package/{content/plugins → graphql}/schema/createReadSDL.js +14 -8
- 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 +83 -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/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.d.ts +4 -3
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestChanges.js +2 -4
- package/graphql/schema/resolvers/manage/resolveRequestChanges.js.map +1 -0
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.d.ts +4 -3
- package/{content/plugins → graphql}/schema/resolvers/manage/resolveRequestReview.js +2 -4
- package/graphql/schema/resolvers/manage/resolveRequestReview.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/{content/plugins → graphql}/schema/resolvers/preview/resolveGet.js +2 -2
- 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/{content/plugins → graphql}/schema/resolvers/read/resolveGet.js +2 -2
- 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/{content/plugins → graphql}/schema/schemaPlugins.d.ts +1 -1
- package/{content/plugins → graphql}/schema/schemaPlugins.js +25 -6
- package/graphql/schema/schemaPlugins.js.map +1 -0
- package/graphql/system.d.ts +6 -0
- package/graphql/system.js +119 -0
- package/graphql/system.js.map +1 -0
- package/graphqlFields/boolean.d.ts +2 -0
- package/graphqlFields/boolean.js +69 -0
- package/graphqlFields/boolean.js.map +1 -0
- package/graphqlFields/datetime.d.ts +2 -0
- package/graphqlFields/datetime.js +95 -0
- package/graphqlFields/datetime.js.map +1 -0
- package/graphqlFields/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 +28 -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 +75 -0
- package/graphqlFields/number.js.map +1 -0
- package/graphqlFields/object.d.ts +2 -0
- package/graphqlFields/object.js +225 -0
- package/graphqlFields/object.js.map +1 -0
- package/graphqlFields/ref.d.ts +2 -0
- package/graphqlFields/ref.js +279 -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 +80 -37
- package/index.js.map +1 -0
- package/modelManager/DefaultCmsModelManager.d.ts +14 -0
- package/{content/plugins/modelManager → modelManager}/DefaultCmsModelManager.js +11 -9
- 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 +37 -36
- 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 +45 -0
- package/parameters/manual.js.map +1 -0
- package/parameters/path.d.ts +2 -0
- package/parameters/path.js +51 -0
- package/parameters/path.js.map +1 -0
- package/plugins/CmsGroupPlugin.d.ts +13 -0
- package/{content/plugins → plugins}/CmsGroupPlugin.js +8 -2
- 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 +41 -0
- package/plugins/CmsModelPlugin.js +189 -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/{content/plugins/storage → plugins}/StorageTransformPlugin.d.ts +4 -3
- package/{content/plugins/storage → plugins}/StorageTransformPlugin.js +1 -0
- package/plugins/StorageTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +5 -0
- package/plugins/index.js +70 -0
- package/plugins/index.js.map +1 -0
- package/storage/default.d.ts +2 -0
- package/storage/default.js +27 -0
- package/storage/default.js.map +1 -0
- package/storage/object.d.ts +2 -0
- package/storage/object.js +128 -0
- package/storage/object.js.map +1 -0
- package/types.d.ts +413 -246
- package/types.js +52 -0
- package/types.js.map +1 -0
- package/upgrades/5.33.0/index.d.ts +3 -0
- package/upgrades/5.33.0/index.js +186 -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 +24 -0
- package/utils/converters/ConverterCollection.js +115 -0
- package/utils/converters/ConverterCollection.js.map +1 -0
- package/utils/converters/valueKeyStorageConverter.d.ts +18 -0
- package/utils/converters/valueKeyStorageConverter.js +152 -0
- package/utils/converters/valueKeyStorageConverter.js.map +1 -0
- package/{content/plugins/utils → utils}/createTypeName.d.ts +3 -3
- package/{content/plugins/utils → utils}/createTypeName.js +0 -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 +3 -7
- package/utils/entryStorage.js.map +1 -0
- package/utils/filterAsync.d.ts +1 -0
- package/utils/filterAsync.js +23 -0
- package/utils/filterAsync.js.map +1 -0
- package/utils/filterModelFields.d.ts +16 -0
- package/utils/filterModelFields.js +81 -0
- package/utils/filterModelFields.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 +12 -0
- package/utils/getSchemaFromFieldPlugins.js +35 -0
- package/utils/getSchemaFromFieldPlugins.js.map +1 -0
- package/utils/ownership.d.ts +8 -0
- package/utils/ownership.js +41 -0
- package/utils/ownership.js.map +1 -0
- package/utils/permissions.d.ts +7 -0
- package/utils/permissions.js +110 -0
- package/utils/permissions.js.map +1 -0
- package/utils/pluralizedTypeName.d.ts +1 -0
- package/{content/plugins/utils → utils}/pluralizedTypeName.js +0 -0
- package/utils/pluralizedTypeName.js.map +1 -0
- package/utils/renderFields.d.ts +15 -0
- package/{content/plugins/utils → utils}/renderFields.js +4 -2
- package/utils/renderFields.js.map +1 -0
- package/utils/renderGetFilterFields.d.ts +10 -0
- package/{content/plugins/utils → utils}/renderGetFilterFields.js +28 -13
- package/utils/renderGetFilterFields.js.map +1 -0
- package/utils/renderInputFields.d.ts +14 -0
- package/{content/plugins/utils → utils}/renderInputFields.js +1 -1
- package/utils/renderInputFields.js.map +1 -0
- package/utils/renderListFilterFields.d.ts +11 -0
- package/{content/plugins/utils → utils}/renderListFilterFields.js +30 -17
- package/utils/renderListFilterFields.js.map +1 -0
- package/{content/plugins/utils → utils}/renderSortEnum.d.ts +1 -1
- package/utils/renderSortEnum.js +32 -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/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 +36 -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.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/contentModel/afterCreate.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterDelete.d.ts +0 -7
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +0 -7
- package/content/plugins/crud/contentModel/beforeCreate.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/contentModelGroup/beforeUpdate.d.ts +0 -8
- package/content/plugins/crud/index.d.ts +0 -6
- 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/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/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/createReadResolvers.d.ts +0 -10
- 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/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/resolveList.d.ts +0 -2
- package/content/plugins/schema/resolvers/read/resolveGet.d.ts +0 -2
- package/content/plugins/schema/resolvers/read/resolveList.d.ts +0 -2
- 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/renderInputFields.d.ts +0 -14
- package/content/plugins/utils/renderListFilterFields.d.ts +0 -10
- 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/graphql/system.d.ts +0 -17
- package/plugins/graphql/system.js +0 -72
- 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
|
@@ -7,13 +7,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.assignBeforeGroupCreate = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _toSlug = require("../../utils/toSlug");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _CmsGroupPlugin = require("../../plugins/CmsGroupPlugin");
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _utils = require("@webiny/utils");
|
|
17
17
|
|
|
18
18
|
const assignBeforeGroupCreate = params => {
|
|
19
19
|
const {
|
|
@@ -39,7 +39,7 @@ const assignBeforeGroupCreate = params => {
|
|
|
39
39
|
throw new _error.default(`Cms Group with the slug "${group.slug}" already exists.`, "SLUG_ALREADY_EXISTS");
|
|
40
40
|
}
|
|
41
41
|
} else {
|
|
42
|
-
const slug = (0,
|
|
42
|
+
const slug = (0, _toSlug.toSlug)(group.name);
|
|
43
43
|
const groups = await storageOperations.groups.list({
|
|
44
44
|
where: {
|
|
45
45
|
tenant: group.tenant,
|
|
@@ -51,7 +51,7 @@ const assignBeforeGroupCreate = params => {
|
|
|
51
51
|
if (groups.length === 0) {
|
|
52
52
|
group.slug = slug;
|
|
53
53
|
} else {
|
|
54
|
-
group.slug = `${slug}-${
|
|
54
|
+
group.slug = `${slug}-${(0, _utils.generateAlphaNumericId)(8)}`;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["assignBeforeGroupCreate","params","onBeforeCreate","plugins","storageOperations","subscribe","group","slug","trim","groups","list","where","tenant","locale","length","WebinyError","toSlug","name","generateAlphaNumericId","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","Error"],"sources":["beforeCreate.ts"],"sourcesContent":["import { BeforeGroupCreateTopicParams, HeadlessCmsStorageOperations } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { toSlug } from \"~/utils/toSlug\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { generateAlphaNumericId } from \"@webiny/utils\";\n\ninterface AssignBeforeGroupCreateParams {\n onBeforeCreate: Topic<BeforeGroupCreateTopicParams>;\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\nexport const assignBeforeGroupCreate = (params: AssignBeforeGroupCreateParams) => {\n const { onBeforeCreate, plugins, storageOperations } = params;\n\n onBeforeCreate.subscribe(async params => {\n const { group } = params;\n\n if (group.slug && group.slug.trim()) {\n const groups = await storageOperations.groups.list({\n where: {\n tenant: group.tenant,\n locale: group.locale,\n slug: group.slug\n }\n });\n if (groups.length > 0) {\n throw new WebinyError(\n `Cms Group with the slug \"${group.slug}\" already exists.`,\n \"SLUG_ALREADY_EXISTS\"\n );\n }\n } else {\n const slug = toSlug(group.name);\n const groups = await storageOperations.groups.list({\n where: {\n tenant: group.tenant,\n locale: group.locale,\n slug\n }\n });\n\n if (groups.length === 0) {\n group.slug = slug;\n } else {\n group.slug = `${slug}-${generateAlphaNumericId(8)}`;\n }\n }\n\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n\n if (groupPlugin) {\n throw new Error(\n `Cannot create \"${group.slug}\" content model group because one is already registered via a plugin.`\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAOO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,cAAF;IAAkBC,OAAlB;IAA2BC;EAA3B,IAAiDH,MAAvD;EAEAC,cAAc,CAACG,SAAf,CAAyB,MAAMJ,MAAN,IAAgB;IACrC,MAAM;MAAEK;IAAF,IAAYL,MAAlB;;IAEA,IAAIK,KAAK,CAACC,IAAN,IAAcD,KAAK,CAACC,IAAN,CAAWC,IAAX,EAAlB,EAAqC;MACjC,MAAMC,MAAM,GAAG,MAAML,iBAAiB,CAACK,MAAlB,CAAyBC,IAAzB,CAA8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from "
|
|
2
|
+
import { BeforeGroupDeleteTopicParams, HeadlessCmsStorageOperations } from "../../types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
|
|
4
|
+
interface AssignBeforeGroupDeleteParams {
|
|
5
5
|
onBeforeDelete: Topic<BeforeGroupDeleteTopicParams>;
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
storageOperations: HeadlessCmsStorageOperations;
|
|
8
8
|
}
|
|
9
|
-
export declare const assignBeforeGroupDelete: (params:
|
|
9
|
+
export declare const assignBeforeGroupDelete: (params: AssignBeforeGroupDeleteParams) => void;
|
|
10
|
+
export {};
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.assignBeforeGroupDelete = void 0;
|
|
9
9
|
|
|
10
|
-
var _CmsGroupPlugin = require("../../CmsGroupPlugin");
|
|
10
|
+
var _CmsGroupPlugin = require("../../plugins/CmsGroupPlugin");
|
|
11
11
|
|
|
12
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
13
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["assignBeforeGroupDelete","params","onBeforeDelete","plugins","storageOperations","subscribe","group","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","slug","Error","models","list","where","tenant","locale","items","filter","model","id","length","WebinyError"],"sources":["beforeDelete.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { BeforeGroupDeleteTopicParams, HeadlessCmsStorageOperations } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport WebinyError from \"@webiny/error\";\n\ninterface AssignBeforeGroupDeleteParams {\n onBeforeDelete: Topic<BeforeGroupDeleteTopicParams>;\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\nexport const assignBeforeGroupDelete = (params: AssignBeforeGroupDeleteParams) => {\n const { onBeforeDelete, plugins, storageOperations } = params;\n\n onBeforeDelete.subscribe(async params => {\n const { group } = params;\n\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n\n if (groupPlugin) {\n throw new Error(`Cms Groups defined via plugins cannot be deleted.`);\n }\n\n const models = await storageOperations.models.list({\n where: {\n tenant: group.tenant,\n locale: group.locale\n }\n });\n const items = models.filter(model => {\n return model.group.id === group.id;\n });\n if (items.length > 0) {\n throw new WebinyError(\n \"Cannot delete this group because there are models that belong to it.\",\n \"BEFORE_DELETE_ERROR\",\n {\n group\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAGA;;AACA;;AAOO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,cAAF;IAAkBC,OAAlB;IAA2BC;EAA3B,IAAiDH,MAAvD;EAEAC,cAAc,CAACG,SAAf,CAAyB,MAAMJ,MAAN,IAAgB;IACrC,MAAM;MAAEK;IAAF,IAAYL,MAAlB;IAEA,MAAMM,WAAW,GAAGJ,OAAO,CACtBK,MADe,CACQC,8BAAA,CAAeC,IADvB,EAEfC,IAFe,CAEVC,IAAI,IAAIA,IAAI,CAACC,iBAAL,CAAuBC,IAAvB,KAAgCR,KAAK,CAACQ,IAFpC,CAApB;;IAIA,IAAIP,WAAJ,EAAiB;MACb,MAAM,IAAIQ,KAAJ,CAAW,mDAAX,CAAN;IACH;;IAED,MAAMC,MAAM,GAAG,MAAMZ,iBAAiB,CAACY,MAAlB,CAAyBC,IAAzB,CAA8B;MAC/CC,KAAK,EAAE;QACHC,MAAM,EAAEb,KAAK,CAACa,MADX;QAEHC,MAAM,EAAEd,KAAK,CAACc;MAFX;IADwC,CAA9B,CAArB;IAMA,MAAMC,KAAK,GAAGL,MAAM,CAACM,MAAP,CAAcC,KAAK,IAAI;MACjC,OAAOA,KAAK,CAACjB,KAAN,CAAYkB,EAAZ,KAAmBlB,KAAK,CAACkB,EAAhC;IACH,CAFa,CAAd;;IAGA,IAAIH,KAAK,CAACI,MAAN,GAAe,CAAnB,EAAsB;MAClB,MAAM,IAAIC,cAAJ,CACF,sEADE,EAEF,qBAFE,EAGF;QACIpB;MADJ,CAHE,CAAN;IAOH;EACJ,CA7BD;AA8BH,CAjCM"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Topic } from "@webiny/pubsub/types";
|
|
2
|
+
import { BeforeGroupUpdateTopicParams } from "../../types";
|
|
3
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
+
interface AssignBeforeGroupUpdateParams {
|
|
5
|
+
onBeforeUpdate: Topic<BeforeGroupUpdateTopicParams>;
|
|
6
|
+
plugins: PluginsContainer;
|
|
7
|
+
}
|
|
8
|
+
export declare const assignBeforeGroupUpdate: (params: AssignBeforeGroupUpdateParams) => void;
|
|
9
|
+
export {};
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.assignBeforeGroupUpdate = void 0;
|
|
7
7
|
|
|
8
|
-
var _CmsGroupPlugin = require("../../CmsGroupPlugin");
|
|
8
|
+
var _CmsGroupPlugin = require("../../plugins/CmsGroupPlugin");
|
|
9
9
|
|
|
10
10
|
const assignBeforeGroupUpdate = params => {
|
|
11
11
|
const {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["assignBeforeGroupUpdate","params","onBeforeUpdate","plugins","subscribe","group","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","slug","Error"],"sources":["beforeUpdate.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { BeforeGroupUpdateTopicParams } from \"~/types\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface AssignBeforeGroupUpdateParams {\n onBeforeUpdate: Topic<BeforeGroupUpdateTopicParams>;\n plugins: PluginsContainer;\n}\nexport const assignBeforeGroupUpdate = (params: AssignBeforeGroupUpdateParams) => {\n const { onBeforeUpdate, plugins } = params;\n\n onBeforeUpdate.subscribe(({ group }) => {\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n if (!groupPlugin) {\n return;\n }\n throw new Error(`Cms Groups defined via plugins cannot be updated.`);\n });\n};\n"],"mappings":";;;;;;;AAEA;;AAOO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,cAAF;IAAkBC;EAAlB,IAA8BF,MAApC;EAEAC,cAAc,CAACE,SAAf,CAAyB,CAAC;IAAEC;EAAF,CAAD,KAAe;IACpC,MAAMC,WAAW,GAAGH,OAAO,CACtBI,MADe,CACQC,8BAAA,CAAeC,IADvB,EAEfC,IAFe,CAEVC,IAAI,IAAIA,IAAI,CAACC,iBAAL,CAAuBC,IAAvB,KAAgCR,KAAK,CAACQ,IAFpC,CAApB;;IAGA,IAAI,CAACP,WAAL,EAAkB;MACd;IACH;;IACD,MAAM,IAAIQ,KAAJ,CAAW,mDAAX,CAAN;EACH,CARD;AASH,CAZM"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { CmsGroupContext, CmsContext, HeadlessCmsStorageOperations } from "
|
|
1
|
+
import { CmsGroupContext, CmsContext, HeadlessCmsStorageOperations } from "../types";
|
|
2
2
|
import { Tenant } from "@webiny/api-tenancy/types";
|
|
3
3
|
import { I18NLocale } from "@webiny/api-i18n/types";
|
|
4
4
|
import { SecurityIdentity } from "@webiny/api-security/types";
|
|
5
|
-
export interface
|
|
5
|
+
export interface CreateModelGroupsCrudParams {
|
|
6
6
|
getTenant: () => Tenant;
|
|
7
7
|
getLocale: () => I18NLocale;
|
|
8
8
|
storageOperations: HeadlessCmsStorageOperations;
|
|
9
9
|
context: CmsContext;
|
|
10
10
|
getIdentity: () => SecurityIdentity;
|
|
11
11
|
}
|
|
12
|
-
export declare const createModelGroupsCrud: (params:
|
|
12
|
+
export declare const createModelGroupsCrud: (params: CreateModelGroupsCrudParams) => CmsGroupContext;
|
|
@@ -15,13 +15,11 @@ var _validation = require("@webiny/validation");
|
|
|
15
15
|
|
|
16
16
|
var _mdbid = _interopRequireDefault(require("mdbid"));
|
|
17
17
|
|
|
18
|
-
var utils = _interopRequireWildcard(require("../../../utils"));
|
|
19
|
-
|
|
20
18
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
21
19
|
|
|
22
20
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
23
21
|
|
|
24
|
-
var _CmsGroupPlugin = require("../CmsGroupPlugin");
|
|
22
|
+
var _CmsGroupPlugin = require("../plugins/CmsGroupPlugin");
|
|
25
23
|
|
|
26
24
|
var _pubsub = require("@webiny/pubsub");
|
|
27
25
|
|
|
@@ -31,13 +29,19 @@ var _beforeCreate = require("./contentModelGroup/beforeCreate");
|
|
|
31
29
|
|
|
32
30
|
var _beforeDelete = require("./contentModelGroup/beforeDelete");
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
33
|
+
|
|
34
|
+
var _permissions = require("../utils/permissions");
|
|
35
|
+
|
|
36
|
+
var _ownership = require("../utils/ownership");
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
var _access = require("../utils/access");
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
var _toSlug = require("../utils/toSlug");
|
|
39
41
|
|
|
40
|
-
function
|
|
42
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
43
|
+
|
|
44
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
41
45
|
|
|
42
46
|
const CreateContentModelGroupModel = (0, _fields.withFields)({
|
|
43
47
|
name: (0, _fields.string)({
|
|
@@ -73,6 +77,31 @@ const createModelGroupsCrud = params => {
|
|
|
73
77
|
storageOperations,
|
|
74
78
|
context
|
|
75
79
|
} = params;
|
|
80
|
+
const dataLoaders = {
|
|
81
|
+
listGroups: new _dataloader.default(async () => {
|
|
82
|
+
const tenant = getTenant().id;
|
|
83
|
+
const locale = getLocale().code;
|
|
84
|
+
const pluginsGroups = getGroupsAsPlugins().map(group => {
|
|
85
|
+
return _objectSpread(_objectSpread({}, group), {}, {
|
|
86
|
+
tenant: group.tenant || tenant,
|
|
87
|
+
locale: group.locale || locale
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
const groups = await storageOperations.groups.list({
|
|
91
|
+
where: {
|
|
92
|
+
tenant: getTenant().id,
|
|
93
|
+
locale: getLocale().code
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return [groups.concat(pluginsGroups)];
|
|
97
|
+
})
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const clearGroupsCache = () => {
|
|
101
|
+
for (const loader of Object.values(dataLoaders)) {
|
|
102
|
+
loader.clearAll();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
76
105
|
|
|
77
106
|
const getGroupsAsPlugins = () => {
|
|
78
107
|
const tenant = getTenant().id;
|
|
@@ -105,65 +134,29 @@ const createModelGroupsCrud = params => {
|
|
|
105
134
|
};
|
|
106
135
|
|
|
107
136
|
const checkPermissions = check => {
|
|
108
|
-
return
|
|
137
|
+
return (0, _permissions.checkPermissions)(context, "cms.contentModelGroup", {
|
|
109
138
|
rwd: check
|
|
110
139
|
});
|
|
111
140
|
};
|
|
112
141
|
|
|
113
142
|
const groupsGet = async id => {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
if (groupPlugin) {
|
|
117
|
-
return groupPlugin;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const tenant = getTenant().id;
|
|
121
|
-
const locale = getLocale().code;
|
|
122
|
-
let group = null;
|
|
123
|
-
|
|
124
|
-
try {
|
|
125
|
-
group = await storageOperations.groups.get({
|
|
126
|
-
tenant,
|
|
127
|
-
locale,
|
|
128
|
-
id
|
|
129
|
-
});
|
|
130
|
-
} catch (ex) {
|
|
131
|
-
throw new _error.default(ex.message, ex.code || "GET_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
|
|
132
|
-
id
|
|
133
|
-
}));
|
|
134
|
-
}
|
|
143
|
+
const groups = await dataLoaders.listGroups.load("listGroups");
|
|
144
|
+
const group = groups.find(g => g.id === id);
|
|
135
145
|
|
|
136
146
|
if (!group) {
|
|
137
147
|
throw new _handlerGraphql.NotFoundError(`Cms Group "${id}" was not found!`);
|
|
138
148
|
}
|
|
139
149
|
|
|
140
|
-
return
|
|
141
|
-
tenant: group.tenant || tenant,
|
|
142
|
-
locale: group.locale || locale
|
|
143
|
-
});
|
|
150
|
+
return group;
|
|
144
151
|
};
|
|
145
152
|
|
|
146
153
|
const groupsList = async params => {
|
|
147
154
|
const {
|
|
148
155
|
where
|
|
149
156
|
} = params || {};
|
|
150
|
-
const tenant = getTenant().id;
|
|
151
|
-
const locale = getLocale().code;
|
|
152
157
|
|
|
153
158
|
try {
|
|
154
|
-
|
|
155
|
-
const databaseGroups = await storageOperations.groups.list({
|
|
156
|
-
where: _objectSpread(_objectSpread({}, where || {}), {}, {
|
|
157
|
-
tenant: where ? where.tenant : tenant,
|
|
158
|
-
locale: where ? where.locale : locale
|
|
159
|
-
})
|
|
160
|
-
});
|
|
161
|
-
return pluginsGroups.concat(databaseGroups.map(group => {
|
|
162
|
-
return _objectSpread(_objectSpread({}, group), {}, {
|
|
163
|
-
tenant: group.tenant || tenant,
|
|
164
|
-
locale: group.locale || locale
|
|
165
|
-
});
|
|
166
|
-
}));
|
|
159
|
+
return await dataLoaders.listGroups.load("listGroups");
|
|
167
160
|
} catch (ex) {
|
|
168
161
|
throw new _error.default(ex.message, ex.code || "LIST_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
|
|
169
162
|
where
|
|
@@ -202,11 +195,12 @@ const createModelGroupsCrud = params => {
|
|
|
202
195
|
onAfterGroupUpdate: onAfterUpdate,
|
|
203
196
|
onBeforeGroupDelete: onBeforeDelete,
|
|
204
197
|
onAfterGroupDelete: onAfterDelete,
|
|
198
|
+
clearGroupsCache,
|
|
205
199
|
getGroup: async id => {
|
|
206
200
|
const permission = await checkPermissions("r");
|
|
207
201
|
const group = await groupsGet(id);
|
|
208
|
-
|
|
209
|
-
|
|
202
|
+
(0, _ownership.checkOwnership)(context, permission, group);
|
|
203
|
+
(0, _access.validateGroupAccess)(context, permission, group);
|
|
210
204
|
return group;
|
|
211
205
|
},
|
|
212
206
|
listGroups: async params => {
|
|
@@ -225,17 +219,18 @@ const createModelGroupsCrud = params => {
|
|
|
225
219
|
})
|
|
226
220
|
}));
|
|
227
221
|
return response.filter(group => {
|
|
228
|
-
if (!
|
|
222
|
+
if (!(0, _ownership.validateOwnership)(context, permission, group)) {
|
|
229
223
|
return false;
|
|
230
224
|
}
|
|
231
225
|
|
|
232
|
-
return
|
|
226
|
+
return (0, _access.validateGroupAccess)(context, permission, group);
|
|
233
227
|
});
|
|
234
228
|
},
|
|
235
229
|
createGroup: async inputData => {
|
|
236
230
|
await checkPermissions("w");
|
|
237
231
|
const createdData = new CreateContentModelGroupModel().populate(_objectSpread(_objectSpread({}, inputData), {}, {
|
|
238
|
-
slug: inputData.slug ?
|
|
232
|
+
slug: inputData.slug ? (0, _toSlug.toSlug)(inputData.slug) : "",
|
|
233
|
+
description: inputData.description || ""
|
|
239
234
|
}));
|
|
240
235
|
await createdData.validate();
|
|
241
236
|
const input = await createdData.toJSON();
|
|
@@ -261,9 +256,9 @@ const createModelGroupsCrud = params => {
|
|
|
261
256
|
group
|
|
262
257
|
});
|
|
263
258
|
const result = await storageOperations.groups.create({
|
|
264
|
-
input,
|
|
265
259
|
group
|
|
266
260
|
});
|
|
261
|
+
clearGroupsCache();
|
|
267
262
|
await onAfterCreate.publish({
|
|
268
263
|
group: result
|
|
269
264
|
});
|
|
@@ -278,7 +273,7 @@ const createModelGroupsCrud = params => {
|
|
|
278
273
|
updateGroup: async (id, inputData) => {
|
|
279
274
|
const permission = await checkPermissions("w");
|
|
280
275
|
const original = await groupsGet(id);
|
|
281
|
-
|
|
276
|
+
(0, _ownership.checkOwnership)(context, permission, original);
|
|
282
277
|
const input = new UpdateContentModelGroupModel().populate(inputData);
|
|
283
278
|
await input.validate();
|
|
284
279
|
const updatedDataJson = await input.toJSON({
|
|
@@ -304,10 +299,9 @@ const createModelGroupsCrud = params => {
|
|
|
304
299
|
group
|
|
305
300
|
});
|
|
306
301
|
const updatedGroup = await storageOperations.groups.update({
|
|
307
|
-
|
|
308
|
-
group,
|
|
309
|
-
input
|
|
302
|
+
group
|
|
310
303
|
});
|
|
304
|
+
clearGroupsCache();
|
|
311
305
|
await onAfterUpdate.publish({
|
|
312
306
|
original,
|
|
313
307
|
group: updatedGroup
|
|
@@ -325,7 +319,7 @@ const createModelGroupsCrud = params => {
|
|
|
325
319
|
deleteGroup: async id => {
|
|
326
320
|
const permission = await checkPermissions("d");
|
|
327
321
|
const group = await groupsGet(id);
|
|
328
|
-
|
|
322
|
+
(0, _ownership.checkOwnership)(context, permission, group);
|
|
329
323
|
|
|
330
324
|
try {
|
|
331
325
|
await onBeforeDelete.publish({
|
|
@@ -334,6 +328,7 @@ const createModelGroupsCrud = params => {
|
|
|
334
328
|
await storageOperations.groups.delete({
|
|
335
329
|
group
|
|
336
330
|
});
|
|
331
|
+
clearGroupsCache();
|
|
337
332
|
await onAfterDelete.publish({
|
|
338
333
|
group
|
|
339
334
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CreateContentModelGroupModel","withFields","name","string","validation","create","slug","description","icon","UpdateContentModelGroupModel","createModelGroupsCrud","params","getTenant","getIdentity","getLocale","storageOperations","context","dataLoaders","listGroups","DataLoader","tenant","id","locale","code","pluginsGroups","getGroupsAsPlugins","map","group","groups","list","where","concat","clearGroupsCache","loader","Object","values","clearAll","plugins","byType","CmsGroupPlugin","type","filter","plugin","t","l","contentModelGroup","webinyVersion","WEBINY_VERSION","checkPermissions","check","baseCheckPermissions","rwd","groupsGet","load","find","g","NotFoundError","groupsList","ex","WebinyError","message","data","onBeforeCreate","createTopic","onAfterCreate","onBeforeUpdate","onAfterUpdate","onBeforeDelete","onAfterDelete","assignBeforeGroupCreate","assignBeforeGroupUpdate","assignBeforeGroupDelete","onBeforeGroupCreate","onAfterGroupCreate","onBeforeGroupUpdate","onAfterGroupUpdate","onBeforeGroupDelete","onAfterGroupDelete","getGroup","permission","checkOwnership","validateGroupAccess","response","validateOwnership","createGroup","inputData","createdData","populate","toSlug","validate","input","toJSON","identity","mdbid","createdOn","Date","toISOString","savedOn","createdBy","displayName","publish","result","updateGroup","original","updatedDataJson","onlyDirty","keys","length","updatedGroup","update","error","deleteGroup","delete"],"sources":["contentModelGroup.crud.ts"],"sourcesContent":["/**\n * Package @commodo/fields does not have types.\n */\n// @ts-ignore\nimport { withFields, string } from \"@commodo/fields\";\nimport { validation } from \"@webiny/validation\";\n/**\n * Package mdbid does not have types.\n */\n// @ts-ignore\nimport mdbid from \"mdbid\";\nimport {\n CmsGroupContext,\n CmsGroupListParams,\n CmsGroupPermission,\n CmsGroup,\n CmsContext,\n HeadlessCmsStorageOperations,\n CmsGroupCreateInput,\n BeforeGroupCreateTopicParams,\n AfterGroupCreateTopicParams,\n BeforeGroupUpdateTopicParams,\n AfterGroupUpdateTopicParams,\n BeforeGroupDeleteTopicParams,\n AfterGroupDeleteTopicParams\n} from \"~/types\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport { assignBeforeGroupUpdate } from \"./contentModelGroup/beforeUpdate\";\nimport { assignBeforeGroupCreate } from \"./contentModelGroup/beforeCreate\";\nimport { assignBeforeGroupDelete } from \"./contentModelGroup/beforeDelete\";\nimport DataLoader from \"dataloader\";\nimport { checkPermissions as baseCheckPermissions } from \"~/utils/permissions\";\nimport { checkOwnership, validateOwnership } from \"~/utils/ownership\";\nimport { validateGroupAccess } from \"~/utils/access\";\nimport { toSlug } from \"~/utils/toSlug\";\n\nconst CreateContentModelGroupModel = withFields({\n name: string({ validation: validation.create(\"required,maxLength:100\") }),\n slug: string({ validation: validation.create(\"maxLength:100\") }),\n description: string({ validation: validation.create(\"maxLength:255\") }),\n icon: string({ validation: validation.create(\"required,maxLength:255\") })\n})();\n\nconst UpdateContentModelGroupModel = withFields({\n name: string({ validation: validation.create(\"maxLength:100\") }),\n description: string({ validation: validation.create(\"maxLength:255\") }),\n icon: string({ validation: validation.create(\"maxLength:255\") })\n})();\n\nexport interface CreateModelGroupsCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\nexport const createModelGroupsCrud = (params: CreateModelGroupsCrudParams): CmsGroupContext => {\n const { getTenant, getIdentity, getLocale, storageOperations, context } = params;\n\n const dataLoaders = {\n listGroups: new DataLoader(async () => {\n const tenant = getTenant().id;\n const locale = getLocale().code;\n\n const pluginsGroups = getGroupsAsPlugins().map(group => {\n return {\n ...group,\n tenant: group.tenant || tenant,\n locale: group.locale || locale\n };\n });\n\n const groups = await storageOperations.groups.list({\n where: {\n tenant: getTenant().id,\n locale: getLocale().code\n }\n });\n\n return [groups.concat(pluginsGroups)];\n })\n };\n\n const clearGroupsCache = (): void => {\n for (const loader of Object.values(dataLoaders)) {\n loader.clearAll();\n }\n };\n\n const getGroupsAsPlugins = (): CmsGroup[] => {\n const tenant = getTenant().id;\n const locale = getLocale().code;\n\n return (\n context.plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n /**\n * We need to filter out groups that are not for this tenant or locale.\n * If it does not have tenant or locale define, it is for every locale and tenant\n */\n .filter(plugin => {\n const { tenant: t, locale: l } = plugin.contentModelGroup;\n if (t && t !== tenant) {\n return false;\n } else if (l && l !== locale) {\n return false;\n }\n return true;\n })\n .map(plugin => {\n return {\n ...plugin.contentModelGroup,\n tenant,\n locale,\n webinyVersion: context.WEBINY_VERSION\n };\n })\n );\n };\n\n const checkPermissions = (check: string): Promise<CmsGroupPermission> => {\n return baseCheckPermissions(context, \"cms.contentModelGroup\", { rwd: check });\n };\n\n const groupsGet = async (id: string) => {\n const groups = await dataLoaders.listGroups.load(\"listGroups\");\n\n const group = groups.find(g => g.id === id);\n\n if (!group) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n return group;\n };\n\n const groupsList = async (params: CmsGroupListParams) => {\n const { where } = params || {};\n\n try {\n return await dataLoaders.listGroups.load(\"listGroups\");\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code || \"LIST_ERROR\", {\n ...(ex.data || {}),\n where\n });\n }\n };\n\n const onBeforeCreate = createTopic<BeforeGroupCreateTopicParams>();\n const onAfterCreate = createTopic<AfterGroupCreateTopicParams>();\n const onBeforeUpdate = createTopic<BeforeGroupUpdateTopicParams>();\n const onAfterUpdate = createTopic<AfterGroupUpdateTopicParams>();\n const onBeforeDelete = createTopic<BeforeGroupDeleteTopicParams>();\n const onAfterDelete = createTopic<AfterGroupDeleteTopicParams>();\n\n /**\n * We need to assign some default behaviors.\n */\n assignBeforeGroupCreate({\n onBeforeCreate,\n plugins: context.plugins,\n storageOperations\n });\n assignBeforeGroupUpdate({\n onBeforeUpdate,\n plugins: context.plugins\n });\n assignBeforeGroupDelete({\n onBeforeDelete,\n plugins: context.plugins,\n storageOperations\n });\n\n return {\n onBeforeGroupCreate: onBeforeCreate,\n onAfterGroupCreate: onAfterCreate,\n onBeforeGroupUpdate: onBeforeUpdate,\n onAfterGroupUpdate: onAfterUpdate,\n onBeforeGroupDelete: onBeforeDelete,\n onAfterGroupDelete: onAfterDelete,\n clearGroupsCache,\n getGroup: async id => {\n const permission = await checkPermissions(\"r\");\n\n const group = await groupsGet(id);\n checkOwnership(context, permission, group);\n validateGroupAccess(context, permission, group);\n\n return group;\n },\n listGroups: async params => {\n const { where } = params || {};\n\n const { tenant, locale } = where || {};\n const permission = await checkPermissions(\"r\");\n\n const response = await groupsList({\n ...(params || {}),\n where: {\n ...(where || {}),\n tenant: tenant || getTenant().id,\n locale: locale || getLocale().code\n }\n });\n\n return response.filter(group => {\n if (!validateOwnership(context, permission, group)) {\n return false;\n }\n return validateGroupAccess(context, permission, group);\n });\n },\n createGroup: async inputData => {\n await checkPermissions(\"w\");\n\n const createdData = new CreateContentModelGroupModel().populate({\n ...inputData,\n slug: inputData.slug ? toSlug(inputData.slug) : \"\",\n description: inputData.description || \"\"\n });\n await createdData.validate();\n const input: CmsGroupCreateInput & { slug: string; description: string } =\n await createdData.toJSON();\n\n const identity = getIdentity();\n\n const id = mdbid();\n const group: CmsGroup = {\n ...input,\n id,\n tenant: getTenant().id,\n locale: getLocale().code,\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n webinyVersion: context.WEBINY_VERSION\n };\n try {\n await onBeforeCreate.publish({\n group\n });\n\n const result = await storageOperations.groups.create({\n group\n });\n\n clearGroupsCache();\n\n await onAfterCreate.publish({\n group: result\n });\n\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not save data model group.\",\n ex.code || \"ERROR_ON_CREATE\",\n {\n ...(ex.data || {}),\n group,\n input\n }\n );\n }\n },\n updateGroup: async (id, inputData) => {\n const permission = await checkPermissions(\"w\");\n\n const original = await groupsGet(id);\n\n checkOwnership(context, permission, original);\n\n const input = new UpdateContentModelGroupModel().populate(inputData);\n await input.validate();\n\n const updatedDataJson: Partial<CmsGroup> = await input.toJSON({\n onlyDirty: true\n });\n\n /**\n * No need to continue if no values were changed\n */\n if (Object.keys(updatedDataJson).length === 0) {\n return original;\n }\n\n const group: CmsGroup = {\n ...original,\n ...updatedDataJson,\n locale: getLocale().code,\n tenant: getTenant().id,\n savedOn: new Date().toISOString()\n };\n\n try {\n await onBeforeUpdate.publish({\n original,\n group\n });\n\n const updatedGroup = await storageOperations.groups.update({\n group\n });\n clearGroupsCache();\n\n await onAfterUpdate.publish({\n original,\n group: updatedGroup\n });\n\n return updatedGroup;\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code || \"UPDATE_ERROR\", {\n error: ex,\n original,\n group,\n input\n });\n }\n },\n deleteGroup: async id => {\n const permission = await checkPermissions(\"d\");\n\n const group = await groupsGet(id);\n\n checkOwnership(context, permission, group);\n\n try {\n await onBeforeDelete.publish({\n group\n });\n\n await storageOperations.groups.delete({ group });\n clearGroupsCache();\n\n await onAfterDelete.publish({\n group\n });\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code || \"DELETE_ERROR\", {\n ...(ex.data || {}),\n id\n });\n }\n\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;;;;AAIA;;AACA;;AAKA;;AAgBA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,MAAMA,4BAA4B,GAAG,IAAAC,kBAAA,EAAW;EAC5CC,IAAI,EAAE,IAAAC,cAAA,EAAO;IAAEC,UAAU,EAAEA,sBAAA,CAAWC,MAAX,CAAkB,wBAAlB;EAAd,CAAP,CADsC;EAE5CC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O+B,EAAP,EAAW;QACT,MAAM,IAAIC,cAAJ,CAAgBD,EAAE,CAACE,OAAnB,EAA4BF,EAAE,CAACnC,IAAH,IAAW,cAAvC,kCACEmC,EAAE,CAACG,IAAH,IAAW,EADb;UAEFxC;QAFE,GAAN;MAIH;;MAED,OAAO,IAAP;IACH;EAjLE,CAAP;AAmLH,CAxSM"}
|
package/crud/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContextPlugin } from "@webiny/api";
|
|
2
|
+
import { CmsContext, HeadlessCmsStorageOperations } from "../types";
|
|
3
|
+
export interface CrudParams {
|
|
4
|
+
storageOperations: HeadlessCmsStorageOperations;
|
|
5
|
+
}
|
|
6
|
+
export declare const createCrud: (params: CrudParams) => ContextPlugin<CmsContext>;
|
|
@@ -5,11 +5,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.createCrud = void 0;
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _api = require("@webiny/api");
|
|
13
13
|
|
|
14
14
|
var _contentModelGroup = require("./contentModelGroup.crud");
|
|
15
15
|
|
|
@@ -17,32 +17,21 @@ var _contentModel = require("./contentModel.crud");
|
|
|
17
17
|
|
|
18
18
|
var _contentEntry = require("./contentEntry.crud");
|
|
19
19
|
|
|
20
|
-
var _system = require("
|
|
20
|
+
var _system = require("./system.crud");
|
|
21
21
|
|
|
22
|
-
var _settings = require("
|
|
22
|
+
var _settings = require("./settings.crud");
|
|
23
23
|
|
|
24
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
25
|
|
|
26
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
27
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
const createContentCruds = params => {
|
|
28
|
+
const createCrud = params => {
|
|
31
29
|
const {
|
|
32
30
|
storageOperations
|
|
33
31
|
} = params;
|
|
34
|
-
return new
|
|
35
|
-
/**
|
|
36
|
-
* This should never happen in the actual project.
|
|
37
|
-
* It is to make sure that we load setup context before the CRUD init in our internal code.
|
|
38
|
-
*/
|
|
39
|
-
if (!context.cms) {
|
|
40
|
-
debug && console.log(`Missing initial "cms" on the context. Make sure that you set it up before creating Content CRUDs.`);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
32
|
+
return new _api.ContextPlugin(async context => {
|
|
44
33
|
const getLocale = () => {
|
|
45
|
-
return context.
|
|
34
|
+
return context.cms.getLocale();
|
|
46
35
|
};
|
|
47
36
|
|
|
48
37
|
const getIdentity = () => {
|
|
@@ -53,8 +42,8 @@ const createContentCruds = params => {
|
|
|
53
42
|
return context.tenancy.getCurrentTenant();
|
|
54
43
|
};
|
|
55
44
|
|
|
56
|
-
if (storageOperations.
|
|
57
|
-
|
|
45
|
+
if (storageOperations.beforeInit) {
|
|
46
|
+
await storageOperations.beforeInit(context);
|
|
58
47
|
}
|
|
59
48
|
|
|
60
49
|
context.cms = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, context.cms), {}, {
|
|
@@ -62,6 +51,7 @@ const createContentCruds = params => {
|
|
|
62
51
|
}, (0, _system.createSystemCrud)({
|
|
63
52
|
context,
|
|
64
53
|
getTenant,
|
|
54
|
+
getLocale,
|
|
65
55
|
getIdentity,
|
|
66
56
|
storageOperations
|
|
67
57
|
})), (0, _settings.createSettingsCrud)({
|
|
@@ -83,9 +73,8 @@ const createContentCruds = params => {
|
|
|
83
73
|
storageOperations
|
|
84
74
|
})), (0, _contentEntry.createContentEntryCrud)({
|
|
85
75
|
context,
|
|
86
|
-
getLocale,
|
|
87
|
-
getTenant,
|
|
88
76
|
getIdentity,
|
|
77
|
+
getTenant,
|
|
89
78
|
storageOperations
|
|
90
79
|
}));
|
|
91
80
|
|
|
@@ -93,8 +82,8 @@ const createContentCruds = params => {
|
|
|
93
82
|
return;
|
|
94
83
|
}
|
|
95
84
|
|
|
96
|
-
await storageOperations.init(context
|
|
85
|
+
await storageOperations.init(context);
|
|
97
86
|
});
|
|
98
87
|
};
|
|
99
88
|
|
|
100
|
-
exports.
|
|
89
|
+
exports.createCrud = createCrud;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createCrud","params","storageOperations","ContextPlugin","context","getLocale","cms","getIdentity","security","getTenant","tenancy","getCurrentTenant","beforeInit","createSystemCrud","createSettingsCrud","createModelGroupsCrud","createModelsCrud","createContentEntryCrud","init"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { CmsContext, HeadlessCmsStorageOperations } from \"~/types\";\nimport { createModelGroupsCrud } from \"./contentModelGroup.crud\";\nimport { createModelsCrud } from \"./contentModel.crud\";\nimport { createContentEntryCrud } from \"./contentEntry.crud\";\nimport { createSystemCrud } from \"./system.crud\";\nimport { createSettingsCrud } from \"./settings.crud\";\n\nexport interface CrudParams {\n storageOperations: HeadlessCmsStorageOperations;\n}\n\nexport const createCrud = (params: CrudParams) => {\n const { storageOperations } = params;\n return new ContextPlugin<CmsContext>(async context => {\n const getLocale = () => {\n return context.cms.getLocale();\n };\n\n const getIdentity = () => {\n return context.security.getIdentity();\n };\n\n const getTenant = () => {\n return context.tenancy.getCurrentTenant();\n };\n\n if (storageOperations.beforeInit) {\n await storageOperations.beforeInit(context);\n }\n\n context.cms = {\n ...context.cms,\n storageOperations,\n ...createSystemCrud({\n context,\n getTenant,\n getLocale,\n getIdentity,\n storageOperations\n }),\n ...createSettingsCrud({\n context,\n getTenant,\n getLocale,\n storageOperations\n }),\n ...createModelGroupsCrud({\n context,\n getTenant,\n getLocale,\n getIdentity,\n storageOperations\n }),\n ...createModelsCrud({\n context,\n getLocale,\n getTenant,\n getIdentity,\n storageOperations\n }),\n ...createContentEntryCrud({\n context,\n getIdentity,\n getTenant,\n storageOperations\n })\n };\n\n if (!storageOperations.init) {\n return;\n }\n await storageOperations.init(context);\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;AAMO,MAAMA,UAAU,GAAIC,MAAD,IAAwB;EAC9C,MAAM;IAAEC;EAAF,IAAwBD,MAA9B;EACA,OAAO,IAAIE,kBAAJ,CAA8B,MAAMC,OAAN,IAAiB;IAClD,MAAMC,SAAS,GAAG,MAAM;MACpB,OAAOD,OAAO,CAACE,GAAR,CAAYD,SAAZ,EAAP;IACH,CAFD;;IAIA,MAAME,WAAW,GAAG,MAAM;MACtB,OAAOH,OAAO,CAACI,QAAR,CAAiBD,WAAjB,EAAP;IACH,CAFD;;IAIA,MAAME,SAAS,GAAG,MAAM;MACpB,OAAOL,OAAO,CAACM,OAAR,CAAgBC,gBAAhB,EAAP;IACH,CAFD;;IAIA,IAAIT,iBAAiB,CAACU,UAAtB,EAAkC;MAC9B,MAAMV,iBAAiB,CAACU,UAAlB,CAA6BR,OAA7B,CAAN;IACH;;IAEDA,OAAO,CAACE,GAAR,2FACOF,OAAO,CAACE,GADf;MAEIJ;IAFJ,GAGO,IAAAW,wBAAA,EAAiB;MAChBT,OADgB;MAEhBK,SAFgB;MAGhBJ,SAHgB;MAIhBE,WAJgB;MAKhBL;IALgB,CAAjB,CAHP,GAUO,IAAAY,4BAAA,EAAmB;MAClBV,OADkB;MAElBK,SAFkB;MAGlBJ,SAHkB;MAIlBH;IAJkB,CAAnB,CAVP,GAgBO,IAAAa,wCAAA,EAAsB;MACrBX,OADqB;MAErBK,SAFqB;MAGrBJ,SAHqB;MAIrBE,WAJqB;MAKrBL;IALqB,CAAtB,CAhBP,GAuBO,IAAAc,8BAAA,EAAiB;MAChBZ,OADgB;MAEhBC,SAFgB;MAGhBI,SAHgB;MAIhBF,WAJgB;MAKhBL;IALgB,CAAjB,CAvBP,GA8BO,IAAAe,oCAAA,EAAuB;MACtBb,OADsB;MAEtBG,WAFsB;MAGtBE,SAHsB;MAItBP;IAJsB,CAAvB,CA9BP;;IAsCA,IAAI,CAACA,iBAAiB,CAACgB,IAAvB,EAA6B;MACzB;IACH;;IACD,MAAMhB,iBAAiB,CAACgB,IAAlB,CAAuBd,OAAvB,CAAN;EACH,CA3DM,CAAP;AA4DH,CA9DM"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CmsContext, HeadlessCmsStorageOperations, CmsSettingsContext } from "
|
|
1
|
+
import { CmsContext, HeadlessCmsStorageOperations, CmsSettingsContext } from "../types";
|
|
2
2
|
import { Tenant } from "@webiny/api-tenancy/types";
|
|
3
3
|
import { I18NLocale } from "@webiny/api-i18n/types";
|
|
4
|
-
export interface
|
|
4
|
+
export interface CreateSettingsCrudParams {
|
|
5
5
|
getTenant: () => Tenant;
|
|
6
6
|
getLocale: () => I18NLocale;
|
|
7
7
|
storageOperations: HeadlessCmsStorageOperations;
|
|
8
8
|
context: CmsContext;
|
|
9
9
|
}
|
|
10
|
-
export declare const createSettingsCrud: (params:
|
|
10
|
+
export declare const createSettingsCrud: (params: CreateSettingsCrudParams) => CmsSettingsContext;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createSettingsCrud = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _permissions = require("../utils/permissions");
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
|
|
18
|
+
const createSettingsCrud = params => {
|
|
19
|
+
const {
|
|
20
|
+
storageOperations,
|
|
21
|
+
context,
|
|
22
|
+
getTenant,
|
|
23
|
+
getLocale
|
|
24
|
+
} = params;
|
|
25
|
+
|
|
26
|
+
const checkPermissions = () => {
|
|
27
|
+
return (0, _permissions.checkPermissions)(context, "cms.settings");
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
getSettings: async () => {
|
|
32
|
+
await checkPermissions();
|
|
33
|
+
return await storageOperations.settings.get({
|
|
34
|
+
tenant: getTenant().id,
|
|
35
|
+
locale: getLocale().code
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
updateModelLastChange: async () => {
|
|
39
|
+
const original = await storageOperations.settings.get({
|
|
40
|
+
tenant: getTenant().id,
|
|
41
|
+
locale: getLocale().code
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const settings = _objectSpread(_objectSpread({}, original || {}), {}, {
|
|
45
|
+
contentModelLastChange: new Date(),
|
|
46
|
+
tenant: getTenant().id,
|
|
47
|
+
locale: getLocale().code
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (!original) {
|
|
51
|
+
await storageOperations.settings.create({
|
|
52
|
+
settings
|
|
53
|
+
});
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
await storageOperations.settings.update({
|
|
58
|
+
settings
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
getModelLastChange: async () => {
|
|
62
|
+
try {
|
|
63
|
+
const settings = await storageOperations.settings.get({
|
|
64
|
+
tenant: getTenant().id,
|
|
65
|
+
locale: getLocale().code
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (!(settings !== null && settings !== void 0 && settings.contentModelLastChange)) {
|
|
69
|
+
return new Date();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return settings.contentModelLastChange;
|
|
73
|
+
} catch (ex) {
|
|
74
|
+
console.log({
|
|
75
|
+
error: {
|
|
76
|
+
message: ex.message,
|
|
77
|
+
code: ex.code || "COULD_NOT_FETCH_CONTENT_MODEL_LAST_CHANGE",
|
|
78
|
+
data: ex
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return new Date();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
exports.createSettingsCrud = createSettingsCrud;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createSettingsCrud","params","storageOperations","context","getTenant","getLocale","checkPermissions","baseCheckPermissions","getSettings","settings","get","tenant","id","locale","code","updateModelLastChange","original","contentModelLastChange","Date","create","update","getModelLastChange","ex","console","log","error","message","data"],"sources":["settings.crud.ts"],"sourcesContent":["import {\n CmsContext,\n CmsSettingsPermission,\n CmsSettings,\n HeadlessCmsStorageOperations,\n CmsSettingsContext\n} from \"~/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { checkPermissions as baseCheckPermissions } from \"~/utils/permissions\";\n\nexport interface CreateSettingsCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n context: CmsContext;\n}\nexport const createSettingsCrud = (params: CreateSettingsCrudParams): CmsSettingsContext => {\n const { storageOperations, context, getTenant, getLocale } = params;\n\n const checkPermissions = (): Promise<CmsSettingsPermission> => {\n return baseCheckPermissions(context, \"cms.settings\");\n };\n\n return {\n getSettings: async (): Promise<CmsSettings | null> => {\n await checkPermissions();\n return await storageOperations.settings.get({\n tenant: getTenant().id,\n locale: getLocale().code\n });\n },\n updateModelLastChange: async (): Promise<void> => {\n const original = await storageOperations.settings.get({\n tenant: getTenant().id,\n locale: getLocale().code\n });\n\n const settings: CmsSettings = {\n ...(original || {}),\n contentModelLastChange: new Date(),\n tenant: getTenant().id,\n locale: getLocale().code\n };\n\n if (!original) {\n await storageOperations.settings.create({ settings });\n return;\n }\n\n await storageOperations.settings.update({\n settings\n });\n },\n getModelLastChange: async (): Promise<Date> => {\n try {\n const settings = await storageOperations.settings.get({\n tenant: getTenant().id,\n locale: getLocale().code\n });\n if (!settings?.contentModelLastChange) {\n return new Date();\n }\n return settings.contentModelLastChange;\n } catch (ex) {\n console.log({\n error: {\n message: ex.message,\n code: ex.code || \"COULD_NOT_FETCH_CONTENT_MODEL_LAST_CHANGE\",\n data: ex\n }\n });\n }\n return new Date();\n }\n };\n};\n"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