@webiny/api-headless-cms 0.0.0-mt-3 → 0.0.0-unstable.8c4d9f045a
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
|
@@ -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,12 @@
|
|
|
1
|
+
import { CmsModel, CmsContext, CmsFieldTypePlugins, ApiEndpoint } from "../types";
|
|
2
|
+
import { GraphQLSchemaDefinition } from "@webiny/handler-graphql/types";
|
|
3
|
+
interface RenderTypesFromFieldPluginsParams {
|
|
4
|
+
models: CmsModel[];
|
|
5
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
|
+
type: ApiEndpoint;
|
|
7
|
+
}
|
|
8
|
+
interface RenderTypesFromFieldPlugins {
|
|
9
|
+
(params: RenderTypesFromFieldPluginsParams): GraphQLSchemaDefinition<CmsContext>[];
|
|
10
|
+
}
|
|
11
|
+
export declare const getSchemaFromFieldPlugins: RenderTypesFromFieldPlugins;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSchemaFromFieldPlugins = void 0;
|
|
7
|
+
const TYPE_MAP = {
|
|
8
|
+
preview: "read",
|
|
9
|
+
read: "read",
|
|
10
|
+
manage: "manage"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const getSchemaFromFieldPlugins = ({
|
|
14
|
+
models,
|
|
15
|
+
fieldTypePlugins,
|
|
16
|
+
type
|
|
17
|
+
}) => {
|
|
18
|
+
return Object.values(fieldTypePlugins).map(plugin => {
|
|
19
|
+
if (!TYPE_MAP[type] || !plugin[TYPE_MAP[type]]) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const createSchema = plugin[TYPE_MAP[type]].createSchema; // Render gql types generated by field type plugins
|
|
24
|
+
|
|
25
|
+
if (!createSchema) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return createSchema({
|
|
30
|
+
models
|
|
31
|
+
});
|
|
32
|
+
}).filter(Boolean);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.getSchemaFromFieldPlugins = getSchemaFromFieldPlugins;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TYPE_MAP","preview","read","manage","getSchemaFromFieldPlugins","models","fieldTypePlugins","type","Object","values","map","plugin","createSchema","filter","Boolean"],"sources":["getSchemaFromFieldPlugins.ts"],"sourcesContent":["import { CmsModel, CmsContext, CmsFieldTypePlugins, ApiEndpoint } from \"~/types\";\nimport { GraphQLSchemaDefinition } from \"@webiny/handler-graphql/types\";\n\ninterface RenderTypesFromFieldPluginsParams {\n models: CmsModel[];\n fieldTypePlugins: CmsFieldTypePlugins;\n type: ApiEndpoint;\n}\ninterface RenderTypesFromFieldPlugins {\n (params: RenderTypesFromFieldPluginsParams): GraphQLSchemaDefinition<CmsContext>[];\n}\n\nconst TYPE_MAP: Record<string, \"manage\" | \"read\"> = {\n preview: \"read\",\n read: \"read\",\n manage: \"manage\"\n};\n\nexport const getSchemaFromFieldPlugins: RenderTypesFromFieldPlugins = ({\n models,\n fieldTypePlugins,\n type\n}) => {\n return Object.values(fieldTypePlugins)\n .map(plugin => {\n if (!TYPE_MAP[type] || !plugin[TYPE_MAP[type]]) {\n return null;\n }\n const createSchema = plugin[TYPE_MAP[type]].createSchema;\n // Render gql types generated by field type plugins\n if (!createSchema) {\n return null;\n }\n return createSchema({ models });\n })\n .filter(Boolean) as GraphQLSchemaDefinition<CmsContext>[];\n};\n"],"mappings":";;;;;;AAYA,MAAMA,QAA2C,GAAG;EAChDC,OAAO,EAAE,MADuC;EAEhDC,IAAI,EAAE,MAF0C;EAGhDC,MAAM,EAAE;AAHwC,CAApD;;AAMO,MAAMC,yBAAsD,GAAG,CAAC;EACnEC,MADmE;EAEnEC,gBAFmE;EAGnEC;AAHmE,CAAD,KAIhE;EACF,OAAOC,MAAM,CAACC,MAAP,CAAcH,gBAAd,EACFI,GADE,CACEC,MAAM,IAAI;IACX,IAAI,CAACX,QAAQ,CAACO,IAAD,CAAT,IAAmB,CAACI,MAAM,CAACX,QAAQ,CAACO,IAAD,CAAT,CAA9B,EAAgD;MAC5C,OAAO,IAAP;IACH;;IACD,MAAMK,YAAY,GAAGD,MAAM,CAACX,QAAQ,CAACO,IAAD,CAAT,CAAN,CAAuBK,YAA5C,CAJW,CAKX;;IACA,IAAI,CAACA,YAAL,EAAmB;MACf,OAAO,IAAP;IACH;;IACD,OAAOA,YAAY,CAAC;MAAEP;IAAF,CAAD,CAAnB;EACH,CAXE,EAYFQ,MAZE,CAYKC,OAZL,CAAP;AAaH,CAlBM"}
|
|
@@ -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,110 @@
|
|
|
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
|
+
r: "request review",
|
|
38
|
+
c: "request change",
|
|
39
|
+
p: "publish",
|
|
40
|
+
u: "unpublish"
|
|
41
|
+
};
|
|
42
|
+
const RWD = {
|
|
43
|
+
r: "read",
|
|
44
|
+
w: "write",
|
|
45
|
+
d: "delete"
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const checkPermissions = async (context, name, check) => {
|
|
49
|
+
// Check if user is allowed to edit content in current language
|
|
50
|
+
const contentPermission = await context.security.getPermission("content.i18n");
|
|
51
|
+
|
|
52
|
+
if (!contentPermission) {
|
|
53
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
54
|
+
data: {
|
|
55
|
+
reason: "Missing access to content in any locale."
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
} // We need to check this manually as CMS locale comes from the URL and not the default i18n app.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const code = context.cms.getLocale().code;
|
|
62
|
+
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.
|
|
63
|
+
// However, if the the `locales` IS SET - check that it contains the required locale.
|
|
64
|
+
|
|
65
|
+
if (Array.isArray(locales) && !locales.includes(code)) {
|
|
66
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
67
|
+
data: {
|
|
68
|
+
reason: `Not allowed to access content in "${code}."`
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const permission = await context.security.getPermission(name);
|
|
74
|
+
|
|
75
|
+
if (!permission) {
|
|
76
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
77
|
+
data: {
|
|
78
|
+
reason: `Missing permission "${name}".`
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!check) {
|
|
84
|
+
return permission;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (check.rwd && !hasRwd(permission, check.rwd)) {
|
|
88
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
89
|
+
data: {
|
|
90
|
+
reason: `Not allowed to perform "${RWD[check.rwd]}" on "${name}".`
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
} // r = request review
|
|
94
|
+
// c = request change
|
|
95
|
+
// p = publish
|
|
96
|
+
// u = unpublish
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if (check.pw && !hasPw(permission, check.pw)) {
|
|
100
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
101
|
+
data: {
|
|
102
|
+
reason: `Not allowed to perform "${PW[check.pw]}" on "${name}".`
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return permission;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
exports.checkPermissions = checkPermissions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["hasRwd","permission","rwd","includes","hasPw","pw","isCustom","Object","keys","length","PW","r","c","p","u","RWD","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 r: \"request review\",\n c: \"request change\",\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 // r = request review\n // c = request change\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":";;;;;;;AACA;;AAEO,MAAMA,MAAM,GAAG,CAACC,UAAD,EAAwCC,GAAxC,KAAiE;EACnF,IAAI,OAAOD,UAAU,CAACC,GAAlB,KAA0B,QAA9B,EAAwC;IACpC,OAAO,IAAP;EACH;;EAED,OAAOD,UAAU,CAACC,GAAX,CAAeC,QAAf,CAAwBD,GAAxB,CAAP;AACH,CANM;;;;AAQA,MAAME,KAAK,GAAG,CAACH,UAAD,EAAiCI,EAAjC,KAAyD;EAC1E,MAAMC,QAAQ,GAAGC,MAAM,CAACC,IAAP,CAAYP,UAAZ,EAAwBQ,MAAxB,GAAiC,CAAlD,CAD0E,CACrB;;EAErD,IAAI,CAACH,QAAL,EAAe;IACX;IACA,OAAO,IAAP;EACH;;EAED,IAAI,OAAOL,UAAU,CAACI,EAAlB,KAAyB,QAA7B,EAAuC;IACnC,OAAO,KAAP;EACH;;EAED,OAAOJ,UAAU,CAACI,EAAX,CAAcF,QAAd,CAAuBE,EAAvB,CAAP;AACH,CAbM;;;AAeP,MAAMK,EAA0B,GAAG;EAC/BC,CAAC,EAAE,gBAD4B;EAE/BC,CAAC,EAAE,gBAF4B;EAG/BC,CAAC,EAAE,SAH4B;EAI/BC,CAAC,EAAE;AAJ4B,CAAnC;AAOA,MAAMC,GAA2B,GAAG;EAChCJ,CAAC,EAAE,MAD6B;EAEhCK,CAAC,EAAE,OAF6B;EAGhCC,CAAC,EAAE;AAH6B,CAApC;;AAMO,MAAMC,gBAAgB,GAAG,OAG5BC,OAH4B,EAI5BC,IAJ4B,EAK5BC,KAL4B,KAML;EACvB;EACA,MAAMC,iBAAiB,GAAG,MAAMH,OAAO,CAACI,QAAR,CAAiBC,aAAjB,CAA+B,cAA/B,CAAhC;;EAEA,IAAI,CAACF,iBAAL,EAAwB;IACpB,MAAM,IAAIG,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAE;MADN;IADmB,CAAvB,CAAN;EAKH,CAVsB,CAYvB;;;EACA,MAAMC,IAAI,GAAGT,OAAO,CAACU,GAAR,CAAYC,SAAZ,GAAwBF,IAArC;EAEA,MAAMG,OAAiB,GAAGT,iBAAiB,CAACS,OAA5C,CAfuB,CAiBvB;EACA;;EACA,IAAIC,KAAK,CAACC,OAAN,CAAcF,OAAd,KAA0B,CAACA,OAAO,CAAC5B,QAAR,CAAiByB,IAAjB,CAA/B,EAAuD;IACnD,MAAM,IAAIH,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,qCAAoCC,IAAK;MADhD;IADmB,CAAvB,CAAN;EAKH;;EAED,MAAM3B,UAAU,GAAG,MAAMkB,OAAO,CAACI,QAAR,CAAiBC,aAAjB,CAA4CJ,IAA5C,CAAzB;;EAEA,IAAI,CAACnB,UAAL,EAAiB;IACb,MAAM,IAAIwB,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,uBAAsBP,IAAK;MADlC;IADmB,CAAvB,CAAN;EAKH;;EAED,IAAI,CAACC,KAAL,EAAY;IACR,OAAOpB,UAAP;EACH;;EAED,IAAIoB,KAAK,CAACnB,GAAN,IAAa,CAACF,MAAM,CAACC,UAAD,EAAaoB,KAAK,CAACnB,GAAnB,CAAxB,EAAiD;IAC7C,MAAM,IAAIuB,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,2BAA0BZ,GAAG,CAACM,KAAK,CAACnB,GAAP,CAAY,SAAQkB,IAAK;MAD7D;IADmB,CAAvB,CAAN;EAKH,CA/CsB,CAiDvB;EACA;EACA;EACA;;;EACA,IAAIC,KAAK,CAAChB,EAAN,IAAY,CAACD,KAAK,CAACH,UAAD,EAAaoB,KAAK,CAAChB,EAAnB,CAAtB,EAA8C;IAC1C,MAAM,IAAIoB,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,2BAA0BjB,EAAE,CAACW,KAAK,CAAChB,EAAP,CAAW,SAAQe,IAAK;MAD3D;IADmB,CAAvB,CAAN;EAKH;;EAED,OAAOnB,UAAP;AACH,CApEM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pluralizedTypeName: (typeName: string) => string;
|
|
File without changes
|
|
@@ -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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from "../types";
|
|
2
|
+
interface RenderFieldsParams {
|
|
3
|
+
model: CmsModel;
|
|
4
|
+
type: ApiEndpoint;
|
|
5
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
|
+
}
|
|
7
|
+
interface RenderFields {
|
|
8
|
+
(params: RenderFieldsParams): CmsModelFieldDefinition[];
|
|
9
|
+
}
|
|
10
|
+
export declare const renderFields: RenderFields;
|
|
11
|
+
interface RenderFieldParams extends RenderFieldsParams {
|
|
12
|
+
field: CmsModelField;
|
|
13
|
+
}
|
|
14
|
+
export declare const renderField: ({ model, type, field, fieldTypePlugins }: RenderFieldParams) => CmsModelFieldDefinition | null;
|
|
15
|
+
export {};
|
|
@@ -30,7 +30,7 @@ const renderField = ({
|
|
|
30
30
|
|
|
31
31
|
if (!plugin) {
|
|
32
32
|
// Let's not render the field if it does not exist in the field plugins.
|
|
33
|
-
return;
|
|
33
|
+
return null;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const defs = plugin[type].createTypeField({
|
|
@@ -39,7 +39,9 @@ const renderField = ({
|
|
|
39
39
|
fieldTypePlugins
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
if (
|
|
42
|
+
if (!defs) {
|
|
43
|
+
return null;
|
|
44
|
+
} else if (typeof defs === "string") {
|
|
43
45
|
return {
|
|
44
46
|
fields: defs
|
|
45
47
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["renderFields","model","type","fieldTypePlugins","fields","map","field","renderField","filter","Boolean","plugin","defs","createTypeField"],"sources":["renderFields.ts"],"sourcesContent":["import {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\n\ninterface RenderFieldsParams {\n model: CmsModel;\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderFields {\n (params: RenderFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderFields: RenderFields = ({\n model,\n type,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return model.fields\n .map(field => renderField({ model, type, field, fieldTypePlugins }))\n .filter(Boolean) as CmsModelFieldDefinition[];\n};\n\ninterface RenderFieldParams extends RenderFieldsParams {\n field: CmsModelField;\n}\n\nexport const renderField = ({\n model,\n type,\n field,\n fieldTypePlugins\n}: RenderFieldParams): CmsModelFieldDefinition | null => {\n const plugin: CmsModelFieldToGraphQLPlugin = fieldTypePlugins[field.type];\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n }\n const defs = plugin[type].createTypeField({\n model,\n field,\n fieldTypePlugins\n });\n\n if (!defs) {\n return null;\n } else if (typeof defs === \"string\") {\n return {\n fields: defs\n };\n }\n\n return defs;\n};\n"],"mappings":";;;;;;;AAkBO,MAAMA,YAA0B,GAAG,CAAC;EACvCC,KADuC;EAEvCC,IAFuC;EAGvCC;AAHuC,CAAD,KAIT;EAC7B,OAAOF,KAAK,CAACG,MAAN,CACFC,GADE,CACEC,KAAK,IAAIC,WAAW,CAAC;IAAEN,KAAF;IAASC,IAAT;IAAeI,KAAf;IAAsBH;EAAtB,CAAD,CADtB,EAEFK,MAFE,CAEKC,OAFL,CAAP;AAGH,CARM;;;;AAcA,MAAMF,WAAW,GAAG,CAAC;EACxBN,KADwB;EAExBC,IAFwB;EAGxBI,KAHwB;EAIxBH;AAJwB,CAAD,KAK8B;EACrD,MAAMO,MAAoC,GAAGP,gBAAgB,CAACG,KAAK,CAACJ,IAAP,CAA7D;;EACA,IAAI,CAACQ,MAAL,EAAa;IACT;IACA,OAAO,IAAP;EACH;;EACD,MAAMC,IAAI,GAAGD,MAAM,CAACR,IAAD,CAAN,CAAaU,eAAb,CAA6B;IACtCX,KADsC;IAEtCK,KAFsC;IAGtCH;EAHsC,CAA7B,CAAb;;EAMA,IAAI,CAACQ,IAAL,EAAW;IACP,OAAO,IAAP;EACH,CAFD,MAEO,IAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;IACjC,OAAO;MACHP,MAAM,EAAEO;IADL,CAAP;EAGH;;EAED,OAAOA,IAAP;AACH,CA1BM"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CmsFieldTypePlugins, CmsModel } from "../types";
|
|
2
|
+
interface RenderGetFilterFieldsParams {
|
|
3
|
+
model: CmsModel;
|
|
4
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
5
|
+
}
|
|
6
|
+
interface RenderGetFilterFields {
|
|
7
|
+
(params: RenderGetFilterFieldsParams): string;
|
|
8
|
+
}
|
|
9
|
+
export declare const renderGetFilterFields: RenderGetFilterFields;
|
|
10
|
+
export {};
|
|
@@ -1,38 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.renderGetFilterFields = void 0;
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
const getCreateFilters = (plugins, fieldType) => {
|
|
9
|
+
if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return plugins[fieldType].read.createGetFilters;
|
|
14
|
+
};
|
|
11
15
|
|
|
12
16
|
const renderGetFilterFields = ({
|
|
13
17
|
model,
|
|
14
18
|
fieldTypePlugins
|
|
15
19
|
}) => {
|
|
16
|
-
const
|
|
20
|
+
const fieldIdList = model.fields.filter(field => {
|
|
17
21
|
// Every time a client updates content model's fields, we check the type of each field. If a field plugin
|
|
18
22
|
// for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
|
|
19
23
|
// want to be careful when accessing the field plugin here too. It is still possible to have a content model
|
|
20
24
|
// that contains a field, for which we don't have a plugin registered on the backend. For example, user
|
|
21
25
|
// could've just removed the plugin from the backend.
|
|
22
|
-
|
|
26
|
+
if (!fieldTypePlugins[field.type]) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return fieldTypePlugins[field.type].isSearchable;
|
|
23
31
|
}).map(f => f.fieldId);
|
|
24
32
|
const filters = ["id: ID", "entryId: String"];
|
|
25
33
|
|
|
26
|
-
for (
|
|
27
|
-
const field = model.fields.find(item => item.fieldId ===
|
|
28
|
-
const createGetFilters = (0, _get.default)(fieldTypePlugins, `${field.type}.read.createGetFilters`);
|
|
34
|
+
for (const fieldId of fieldIdList) {
|
|
35
|
+
const field = model.fields.find(item => item.fieldId === fieldId);
|
|
29
36
|
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
model,
|
|
33
|
-
field
|
|
34
|
-
}));
|
|
37
|
+
if (!field) {
|
|
38
|
+
continue;
|
|
35
39
|
}
|
|
40
|
+
|
|
41
|
+
const createGetFilters = getCreateFilters(fieldTypePlugins, field.type);
|
|
42
|
+
|
|
43
|
+
if (typeof createGetFilters !== "function") {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
filters.push(createGetFilters({
|
|
48
|
+
model,
|
|
49
|
+
field
|
|
50
|
+
}));
|
|
36
51
|
}
|
|
37
52
|
|
|
38
53
|
return filters.filter(Boolean).join("\n");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getCreateFilters","plugins","fieldType","read","createGetFilters","renderGetFilterFields","model","fieldTypePlugins","fieldIdList","fields","filter","field","type","isSearchable","map","f","fieldId","filters","find","item","push","Boolean","join"],"sources":["renderGetFilterFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelFieldToGraphQLPlugin } from \"~/types\";\n\ninterface RenderGetFilterFieldsParams {\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderGetFilterFields {\n (params: RenderGetFilterFieldsParams): string;\n}\n\nconst getCreateFilters = (\n plugins: CmsFieldTypePlugins,\n fieldType: string\n): CmsModelFieldToGraphQLPlugin[\"read\"][\"createGetFilters\"] | null => {\n if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {\n return null;\n }\n return plugins[fieldType].read.createGetFilters;\n};\n\nexport const renderGetFilterFields: RenderGetFilterFields = ({ model, fieldTypePlugins }) => {\n const fieldIdList = model.fields\n .filter(field => {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n if (!fieldTypePlugins[field.type]) {\n return false;\n }\n return fieldTypePlugins[field.type].isSearchable;\n })\n .map(f => f.fieldId);\n\n const filters: string[] = [\"id: ID\", \"entryId: String\"];\n\n for (const fieldId of fieldIdList) {\n const field = model.fields.find(item => item.fieldId === fieldId);\n if (!field) {\n continue;\n }\n const createGetFilters = getCreateFilters(fieldTypePlugins, field.type);\n if (typeof createGetFilters !== \"function\") {\n continue;\n }\n filters.push(createGetFilters({ model, field }));\n }\n\n return filters.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;;AAUA,MAAMA,gBAAgB,GAAG,CACrBC,OADqB,EAErBC,SAFqB,KAG6C;EAClE,IAAI,CAACD,OAAO,CAACC,SAAD,CAAR,IAAuB,CAACD,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAwBC,gBAApD,EAAsE;IAClE,OAAO,IAAP;EACH;;EACD,OAAOH,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAwBC,gBAA/B;AACH,CARD;;AAUO,MAAMC,qBAA4C,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAiC;EACzF,MAAMC,WAAW,GAAGF,KAAK,CAACG,MAAN,CACfC,MADe,CACRC,KAAK,IAAI;IACb;IACA;IACA;IACA;IACA;IACA,IAAI,CAACJ,gBAAgB,CAACI,KAAK,CAACC,IAAP,CAArB,EAAmC;MAC/B,OAAO,KAAP;IACH;;IACD,OAAOL,gBAAgB,CAACI,KAAK,CAACC,IAAP,CAAhB,CAA6BC,YAApC;EACH,CAXe,EAYfC,GAZe,CAYXC,CAAC,IAAIA,CAAC,CAACC,OAZI,CAApB;EAcA,MAAMC,OAAiB,GAAG,CAAC,QAAD,EAAW,iBAAX,CAA1B;;EAEA,KAAK,MAAMD,OAAX,IAAsBR,WAAtB,EAAmC;IAC/B,MAAMG,KAAK,GAAGL,KAAK,CAACG,MAAN,CAAaS,IAAb,CAAkBC,IAAI,IAAIA,IAAI,CAACH,OAAL,KAAiBA,OAA3C,CAAd;;IACA,IAAI,CAACL,KAAL,EAAY;MACR;IACH;;IACD,MAAMP,gBAAgB,GAAGJ,gBAAgB,CAACO,gBAAD,EAAmBI,KAAK,CAACC,IAAzB,CAAzC;;IACA,IAAI,OAAOR,gBAAP,KAA4B,UAAhC,EAA4C;MACxC;IACH;;IACDa,OAAO,CAACG,IAAR,CAAahB,gBAAgB,CAAC;MAAEE,KAAF;MAASK;IAAT,CAAD,CAA7B;EACH;;EAED,OAAOM,OAAO,CAACP,MAAR,CAAeW,OAAf,EAAwBC,IAAxB,CAA6B,IAA7B,CAAP;AACH,CA9BM"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from "../types";
|
|
2
|
+
interface RenderInputFieldsParams {
|
|
3
|
+
model: CmsModel;
|
|
4
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
5
|
+
}
|
|
6
|
+
interface RenderInputFieldParams extends RenderInputFieldsParams {
|
|
7
|
+
field: CmsModelField;
|
|
8
|
+
}
|
|
9
|
+
interface RenderInputFields {
|
|
10
|
+
(params: RenderInputFieldsParams): CmsModelFieldDefinition[];
|
|
11
|
+
}
|
|
12
|
+
export declare const renderInputFields: RenderInputFields;
|
|
13
|
+
export declare const renderInputField: ({ model, field, fieldTypePlugins }: RenderInputFieldParams) => CmsModelFieldDefinition | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["renderInputFields","model","fieldTypePlugins","fields","map","field","renderInputField","filter","Boolean","plugin","type","def","manage","createInputField"],"sources":["renderInputFields.ts"],"sourcesContent":["import {\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\n\ninterface RenderInputFieldsParams {\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderInputFieldParams extends RenderInputFieldsParams {\n field: CmsModelField;\n}\ninterface RenderInputFields {\n (params: RenderInputFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderInputFields: RenderInputFields = ({\n model,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return model.fields\n .map(field => renderInputField({ model, field, fieldTypePlugins }))\n .filter(Boolean) as CmsModelFieldDefinition[];\n};\n\nexport const renderInputField = ({\n model,\n field,\n fieldTypePlugins\n}: RenderInputFieldParams): CmsModelFieldDefinition | null => {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const plugin: CmsModelFieldToGraphQLPlugin = fieldTypePlugins[field.type];\n\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n }\n\n const def = plugin.manage.createInputField({\n model,\n field,\n fieldTypePlugins\n });\n if (typeof def === \"string\") {\n return {\n fields: def\n };\n }\n\n return def;\n};\n"],"mappings":";;;;;;;AAmBO,MAAMA,iBAAoC,GAAG,CAAC;EACjDC,KADiD;EAEjDC;AAFiD,CAAD,KAGnB;EAC7B,OAAOD,KAAK,CAACE,MAAN,CACFC,GADE,CACEC,KAAK,IAAIC,gBAAgB,CAAC;IAAEL,KAAF;IAASI,KAAT;IAAgBH;EAAhB,CAAD,CAD3B,EAEFK,MAFE,CAEKC,OAFL,CAAP;AAGH,CAPM;;;;AASA,MAAMF,gBAAgB,GAAG,CAAC;EAC7BL,KAD6B;EAE7BI,KAF6B;EAG7BH;AAH6B,CAAD,KAI8B;EAC1D;EACA;EACA;EACA;EACA;EACA,MAAMO,MAAoC,GAAGP,gBAAgB,CAACG,KAAK,CAACK,IAAP,CAA7D;;EAEA,IAAI,CAACD,MAAL,EAAa;IACT;IACA,OAAO,IAAP;EACH;;EAED,MAAME,GAAG,GAAGF,MAAM,CAACG,MAAP,CAAcC,gBAAd,CAA+B;IACvCZ,KADuC;IAEvCI,KAFuC;IAGvCH;EAHuC,CAA/B,CAAZ;;EAKA,IAAI,OAAOS,GAAP,KAAe,QAAnB,EAA6B;IACzB,OAAO;MACHR,MAAM,EAAEQ;IADL,CAAP;EAGH;;EAED,OAAOA,GAAP;AACH,CA7BM"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ApiEndpoint, CmsFieldTypePlugins, CmsModel } from "../types";
|
|
2
|
+
interface RenderListFilterFieldsParams {
|
|
3
|
+
model: CmsModel;
|
|
4
|
+
type: ApiEndpoint;
|
|
5
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
|
+
}
|
|
7
|
+
interface RenderListFilterFields {
|
|
8
|
+
(params: RenderListFilterFieldsParams): string;
|
|
9
|
+
}
|
|
10
|
+
export declare const renderListFilterFields: RenderListFilterFields;
|
|
11
|
+
export {};
|
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.renderListFilterFields = void 0;
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
/**
|
|
9
|
+
* We cast as read type, because input and output of read and manage are same. This way we ease things.
|
|
10
|
+
* Internal stuff so it should be ok.
|
|
11
|
+
* TODO note that if changing read/manage types, change this as well.
|
|
12
|
+
*/
|
|
13
|
+
const getCreateListFilters = (plugins, fieldType, type) => {
|
|
14
|
+
if (!plugins[fieldType]) {
|
|
15
|
+
return null;
|
|
16
|
+
} else if (!plugins[fieldType][type]) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return plugins[fieldType][type].createListFilters;
|
|
21
|
+
};
|
|
11
22
|
|
|
12
|
-
const renderListFilterFields =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
const renderListFilterFields = params => {
|
|
24
|
+
const {
|
|
25
|
+
model,
|
|
26
|
+
type,
|
|
27
|
+
fieldTypePlugins
|
|
28
|
+
} = params;
|
|
17
29
|
const fields = [["id: ID", "id_not: ID", "id_in: [ID!]", "id_not_in: [ID!]", "entryId: String", "entryId_not: String", "entryId_in: [String!]", "entryId_not_in: [String!]", "createdOn: DateTime", "createdOn_gt: DateTime", "createdOn_gte: DateTime", "createdOn_lt: DateTime", "createdOn_lte: DateTime", "createdOn_between: [DateTime!]", "createdOn_not_between: [DateTime!]", "savedOn: DateTime", "savedOn_gt: DateTime", "savedOn_gte: DateTime", "savedOn_lt: DateTime", "savedOn_lte: DateTime", "savedOn_between: [DateTime!]", "savedOn_not_between: [DateTime!]", "createdBy: String", "createdBy_not: String", "createdBy_in: [String!]", "createdBy_not_in: [String!]", "ownedBy: String", "ownedBy_not: String", "ownedBy_in: [String!]", "ownedBy_not_in: [String!]"].join("\n")];
|
|
18
30
|
|
|
19
|
-
for (
|
|
20
|
-
|
|
31
|
+
for (const field of model.fields) {
|
|
32
|
+
// Every time a client updates content model's fields, we check the type of each field. If a field plugin
|
|
21
33
|
// for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
|
|
22
34
|
// want to be careful when accessing the field plugin here too. It is still possible to have a content model
|
|
23
35
|
// that contains a field, for which we don't have a plugin registered on the backend. For example, user
|
|
24
36
|
// could've just removed the plugin from the backend.
|
|
37
|
+
const createListFilters = getCreateListFilters(fieldTypePlugins, field.type, type);
|
|
25
38
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (typeof createListFilters === "function") {
|
|
29
|
-
fields.push(createListFilters({
|
|
30
|
-
model,
|
|
31
|
-
field
|
|
32
|
-
}));
|
|
39
|
+
if (typeof createListFilters !== "function") {
|
|
40
|
+
continue;
|
|
33
41
|
}
|
|
42
|
+
|
|
43
|
+
fields.push(createListFilters({
|
|
44
|
+
model,
|
|
45
|
+
field
|
|
46
|
+
}));
|
|
34
47
|
}
|
|
35
48
|
|
|
36
49
|
return fields.filter(Boolean).join("\n");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getCreateListFilters","plugins","fieldType","type","createListFilters","renderListFilterFields","params","model","fieldTypePlugins","fields","join","field","push","filter","Boolean"],"sources":["renderListFilterFields.ts"],"sourcesContent":["import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelFieldToGraphQLPlugin } from \"~/types\";\n\ninterface RenderListFilterFieldsParams {\n model: CmsModel;\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderListFilterFields {\n (params: RenderListFilterFieldsParams): string;\n}\n\ntype CreateListFiltersType =\n | CmsModelFieldToGraphQLPlugin[\"read\"][\"createListFilters\"]\n | CmsModelFieldToGraphQLPlugin[\"manage\"][\"createListFilters\"];\n/**\n * We cast as read type, because input and output of read and manage are same. This way we ease things.\n * Internal stuff so it should be ok.\n * TODO note that if changing read/manage types, change this as well.\n */\nconst getCreateListFilters = (\n plugins: CmsFieldTypePlugins,\n fieldType: string,\n type: ApiEndpoint\n): CreateListFiltersType | null => {\n if (!plugins[fieldType]) {\n return null;\n } else if (!plugins[fieldType][type]) {\n return null;\n }\n return plugins[fieldType][type].createListFilters;\n};\n\nexport const renderListFilterFields: RenderListFilterFields = (params): string => {\n const { model, type, fieldTypePlugins } = params;\n const fields: string[] = [\n [\n \"id: ID\",\n \"id_not: ID\",\n \"id_in: [ID!]\",\n \"id_not_in: [ID!]\",\n \"entryId: String\",\n \"entryId_not: String\",\n \"entryId_in: [String!]\",\n \"entryId_not_in: [String!]\",\n \"createdOn: DateTime\",\n \"createdOn_gt: DateTime\",\n \"createdOn_gte: DateTime\",\n \"createdOn_lt: DateTime\",\n \"createdOn_lte: DateTime\",\n \"createdOn_between: [DateTime!]\",\n \"createdOn_not_between: [DateTime!]\",\n \"savedOn: DateTime\",\n \"savedOn_gt: DateTime\",\n \"savedOn_gte: DateTime\",\n \"savedOn_lt: DateTime\",\n \"savedOn_lte: DateTime\",\n \"savedOn_between: [DateTime!]\",\n \"savedOn_not_between: [DateTime!]\",\n \"createdBy: String\",\n \"createdBy_not: String\",\n \"createdBy_in: [String!]\",\n \"createdBy_not_in: [String!]\",\n \"ownedBy: String\",\n \"ownedBy_not: String\",\n \"ownedBy_in: [String!]\",\n \"ownedBy_not_in: [String!]\"\n ].join(\"\\n\")\n ];\n\n for (const field of model.fields) {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n\n const createListFilters = getCreateListFilters(fieldTypePlugins, field.type, type);\n if (typeof createListFilters !== \"function\") {\n continue;\n }\n fields.push(createListFilters({ model, field }));\n }\n\n return fields.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;;AAcA;AACA;AACA;AACA;AACA;AACA,MAAMA,oBAAoB,GAAG,CACzBC,OADyB,EAEzBC,SAFyB,EAGzBC,IAHyB,KAIM;EAC/B,IAAI,CAACF,OAAO,CAACC,SAAD,CAAZ,EAAyB;IACrB,OAAO,IAAP;EACH,CAFD,MAEO,IAAI,CAACD,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAL,EAA+B;IAClC,OAAO,IAAP;EACH;;EACD,OAAOF,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,EAAyBC,iBAAhC;AACH,CAXD;;AAaO,MAAMC,sBAA8C,GAAIC,MAAD,IAAoB;EAC9E,MAAM;IAAEC,KAAF;IAASJ,IAAT;IAAeK;EAAf,IAAoCF,MAA1C;EACA,MAAMG,MAAgB,GAAG,CACrB,CACI,QADJ,EAEI,YAFJ,EAGI,cAHJ,EAII,kBAJJ,EAKI,iBALJ,EAMI,qBANJ,EAOI,uBAPJ,EAQI,2BARJ,EASI,qBATJ,EAUI,wBAVJ,EAWI,yBAXJ,EAYI,wBAZJ,EAaI,yBAbJ,EAcI,gCAdJ,EAeI,oCAfJ,EAgBI,mBAhBJ,EAiBI,sBAjBJ,EAkBI,uBAlBJ,EAmBI,sBAnBJ,EAoBI,uBApBJ,EAqBI,8BArBJ,EAsBI,kCAtBJ,EAuBI,mBAvBJ,EAwBI,uBAxBJ,EAyBI,yBAzBJ,EA0BI,6BA1BJ,EA2BI,iBA3BJ,EA4BI,qBA5BJ,EA6BI,uBA7BJ,EA8BI,2BA9BJ,EA+BEC,IA/BF,CA+BO,IA/BP,CADqB,CAAzB;;EAmCA,KAAK,MAAMC,KAAX,IAAoBJ,KAAK,CAACE,MAA1B,EAAkC;IAC9B;IACA;IACA;IACA;IACA;IAEA,MAAML,iBAAiB,GAAGJ,oBAAoB,CAACQ,gBAAD,EAAmBG,KAAK,CAACR,IAAzB,EAA+BA,IAA/B,CAA9C;;IACA,IAAI,OAAOC,iBAAP,KAA6B,UAAjC,EAA6C;MACzC;IACH;;IACDK,MAAM,CAACG,IAAP,CAAYR,iBAAiB,CAAC;MAAEG,KAAF;MAASI;IAAT,CAAD,CAA7B;EACH;;EAED,OAAOF,MAAM,CAACI,MAAP,CAAcC,OAAd,EAAuBJ,IAAvB,CAA4B,IAA5B,CAAP;AACH,CApDM"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderSortEnum = void 0;
|
|
7
|
+
|
|
8
|
+
const renderSortEnum = ({
|
|
9
|
+
model,
|
|
10
|
+
fieldTypePlugins
|
|
11
|
+
}) => {
|
|
12
|
+
const sorters = [`id_ASC`, `id_DESC`, "savedOn_ASC", "savedOn_DESC", "createdOn_ASC", "createdOn_DESC"];
|
|
13
|
+
|
|
14
|
+
for (const field of model.fields) {
|
|
15
|
+
const plugin = fieldTypePlugins[field.type];
|
|
16
|
+
|
|
17
|
+
if (!plugin) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!plugin.isSortable) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
sorters.push(`${field.fieldId}_ASC`);
|
|
26
|
+
sorters.push(`${field.fieldId}_DESC`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return sorters.join("\n");
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.renderSortEnum = renderSortEnum;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["renderSortEnum","model","fieldTypePlugins","sorters","field","fields","plugin","type","isSortable","push","fieldId","join"],"sources":["renderSortEnum.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel } from \"~/types\";\n\ninterface RenderSortEnum {\n (params: { model: CmsModel; fieldTypePlugins: CmsFieldTypePlugins }): string;\n}\n\nexport const renderSortEnum: RenderSortEnum = ({ model, fieldTypePlugins }): string => {\n const sorters: string[] = [\n `id_ASC`,\n `id_DESC`,\n \"savedOn_ASC\",\n \"savedOn_DESC\",\n \"createdOn_ASC\",\n \"createdOn_DESC\"\n ];\n\n for (const field of model.fields) {\n const plugin = fieldTypePlugins[field.type];\n if (!plugin) {\n continue;\n }\n if (!plugin.isSortable) {\n continue;\n }\n sorters.push(`${field.fieldId}_ASC`);\n sorters.push(`${field.fieldId}_DESC`);\n }\n\n return sorters.join(\"\\n\");\n};\n"],"mappings":";;;;;;;AAMO,MAAMA,cAA8B,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAyC;EACnF,MAAMC,OAAiB,GAAG,CACrB,QADqB,EAErB,SAFqB,EAGtB,aAHsB,EAItB,cAJsB,EAKtB,eALsB,EAMtB,gBANsB,CAA1B;;EASA,KAAK,MAAMC,KAAX,IAAoBH,KAAK,CAACI,MAA1B,EAAkC;IAC9B,MAAMC,MAAM,GAAGJ,gBAAgB,CAACE,KAAK,CAACG,IAAP,CAA/B;;IACA,IAAI,CAACD,MAAL,EAAa;MACT;IACH;;IACD,IAAI,CAACA,MAAM,CAACE,UAAZ,EAAwB;MACpB;IACH;;IACDL,OAAO,CAACM,IAAR,CAAc,GAAEL,KAAK,CAACM,OAAQ,MAA9B;IACAP,OAAO,CAACM,IAAR,CAAc,GAAEL,KAAK,CAACM,OAAQ,OAA9B;EACH;;EAED,OAAOP,OAAO,CAACQ,IAAR,CAAa,IAAb,CAAP;AACH,CAvBM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toSlug: (text: string) => string;
|
package/utils/toSlug.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.toSlug = void 0;
|
|
9
|
+
|
|
10
|
+
var _slugify = _interopRequireDefault(require("slugify"));
|
|
11
|
+
|
|
12
|
+
const toSlug = text => {
|
|
13
|
+
return (0, _slugify.default)(text, {
|
|
14
|
+
replacement: "-",
|
|
15
|
+
lower: true,
|
|
16
|
+
remove: /[*#\?<>_\{\}\[\]+~.()'"!:;@]/g
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.toSlug = toSlug;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["toSlug","text","slugify","replacement","lower","remove"],"sources":["toSlug.ts"],"sourcesContent":["import slugify from \"slugify\";\n\nexport const toSlug = (text: string): string => {\n return slugify(text, {\n replacement: \"-\",\n lower: true,\n remove: /[*#\\?<>_\\{\\}\\[\\]+~.()'\"!:;@]/g\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEO,MAAMA,MAAM,GAAIC,IAAD,IAA0B;EAC5C,OAAO,IAAAC,gBAAA,EAAQD,IAAR,EAAc;IACjBE,WAAW,EAAE,GADI;IAEjBC,KAAK,EAAE,IAFU;IAGjBC,MAAM,EAAE;EAHS,CAAd,CAAP;AAKH,CANM"}
|