@webiny/api-headless-cms 0.0.0-ee-vpcs.549378cf03
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/LICENSE +21 -0
- package/README.md +73 -0
- package/context.d.ts +3 -0
- package/context.js +60 -0
- package/context.js.map +1 -0
- package/crud/contentEntry/afterDelete.d.ts +8 -0
- package/crud/contentEntry/afterDelete.js +41 -0
- package/crud/contentEntry/afterDelete.js.map +1 -0
- package/crud/contentEntry/beforeCreate.d.ts +8 -0
- package/crud/contentEntry/beforeCreate.js +28 -0
- package/crud/contentEntry/beforeCreate.js.map +1 -0
- package/crud/contentEntry/beforeUpdate.d.ts +8 -0
- package/crud/contentEntry/beforeUpdate.js +28 -0
- package/crud/contentEntry/beforeUpdate.js.map +1 -0
- package/crud/contentEntry/entryDataValidation.d.ts +10 -0
- package/crud/contentEntry/entryDataValidation.js +200 -0
- package/crud/contentEntry/entryDataValidation.js.map +1 -0
- package/crud/contentEntry/markLockedFields.d.ts +13 -0
- package/crud/contentEntry/markLockedFields.js +116 -0
- package/crud/contentEntry/markLockedFields.js.map +1 -0
- package/crud/contentEntry/referenceFieldsMapping.d.ts +13 -0
- package/crud/contentEntry/referenceFieldsMapping.js +292 -0
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -0
- package/crud/contentEntry/searchableFields.d.ts +9 -0
- package/crud/contentEntry/searchableFields.js +83 -0
- package/crud/contentEntry/searchableFields.js.map +1 -0
- package/crud/contentEntry.crud.d.ts +13 -0
- package/crud/contentEntry.crud.js +1277 -0
- package/crud/contentEntry.crud.js.map +1 -0
- package/crud/contentModel/afterCreate.d.ts +8 -0
- package/crud/contentModel/afterCreate.js +18 -0
- package/crud/contentModel/afterCreate.js.map +1 -0
- package/crud/contentModel/afterCreateFrom.d.ts +8 -0
- package/crud/contentModel/afterCreateFrom.js +18 -0
- package/crud/contentModel/afterCreateFrom.js.map +1 -0
- package/crud/contentModel/afterDelete.d.ts +8 -0
- package/crud/contentModel/afterDelete.js +18 -0
- package/crud/contentModel/afterDelete.js.map +1 -0
- package/crud/contentModel/afterUpdate.d.ts +8 -0
- package/crud/contentModel/afterUpdate.js +18 -0
- package/crud/contentModel/afterUpdate.js.map +1 -0
- package/crud/contentModel/beforeCreate.d.ts +15 -0
- package/crud/contentModel/beforeCreate.js +194 -0
- package/crud/contentModel/beforeCreate.js.map +1 -0
- package/crud/contentModel/beforeDelete.d.ts +10 -0
- package/crud/contentModel/beforeDelete.js +60 -0
- package/crud/contentModel/beforeDelete.js.map +1 -0
- package/crud/contentModel/beforeUpdate.d.ts +10 -0
- package/crud/contentModel/beforeUpdate.js +37 -0
- package/crud/contentModel/beforeUpdate.js.map +1 -0
- package/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
- package/crud/contentModel/contentModelManagerFactory.js +29 -0
- package/crud/contentModel/contentModelManagerFactory.js.map +1 -0
- package/crud/contentModel/createFieldModels.d.ts +2 -0
- package/crud/contentModel/createFieldModels.js +26 -0
- package/crud/contentModel/createFieldModels.js.map +1 -0
- package/crud/contentModel/createFieldStorageId.d.ts +2 -0
- package/crud/contentModel/createFieldStorageId.js +20 -0
- package/crud/contentModel/createFieldStorageId.js.map +1 -0
- package/crud/contentModel/fieldIdValidation.d.ts +1 -0
- package/crud/contentModel/fieldIdValidation.js +25 -0
- package/crud/contentModel/fieldIdValidation.js.map +1 -0
- package/crud/contentModel/idValidation.d.ts +1 -0
- package/crud/contentModel/idValidation.js +22 -0
- package/crud/contentModel/idValidation.js.map +1 -0
- package/crud/contentModel/models.d.ts +4 -0
- package/crud/contentModel/models.js +192 -0
- 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/crud/contentModel/validateLayout.js +36 -0
- 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 +371 -0
- package/crud/contentModel/validateModelFields.js.map +1 -0
- package/crud/contentModel.crud.d.ts +12 -0
- package/crud/contentModel.crud.js +650 -0
- package/crud/contentModel.crud.js.map +1 -0
- package/crud/contentModelGroup/beforeCreate.d.ts +10 -0
- package/crud/contentModelGroup/beforeCreate.js +66 -0
- package/crud/contentModelGroup/beforeCreate.js.map +1 -0
- package/crud/contentModelGroup/beforeDelete.d.ts +10 -0
- package/crud/contentModelGroup/beforeDelete.js +48 -0
- package/crud/contentModelGroup/beforeDelete.js.map +1 -0
- package/crud/contentModelGroup/beforeUpdate.d.ts +9 -0
- package/crud/contentModelGroup/beforeUpdate.js +28 -0
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -0
- package/crud/contentModelGroup.crud.d.ts +12 -0
- package/crud/contentModelGroup.crud.js +396 -0
- package/crud/contentModelGroup.crud.js.map +1 -0
- package/crud/index.d.ts +6 -0
- package/crud/index.js +85 -0
- package/crud/index.js.map +1 -0
- package/crud/settings.crud.d.ts +10 -0
- package/crud/settings.crud.js +83 -0
- package/crud/settings.crud.js.map +1 -0
- package/crud/system.crud.d.ts +13 -0
- package/crud/system.crud.js +221 -0
- package/crud/system.crud.js.map +1 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +7 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +66 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +239 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +304 -0
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/index.d.ts +4 -0
- package/fieldConverters/index.js +18 -0
- package/fieldConverters/index.js.map +1 -0
- package/graphql/buildSchemaPlugins.d.ts +6 -0
- package/graphql/buildSchemaPlugins.js +27 -0
- package/graphql/buildSchemaPlugins.js.map +1 -0
- package/graphql/graphQLHandlerFactory.d.ts +5 -0
- package/graphql/graphQLHandlerFactory.js +202 -0
- package/graphql/graphQLHandlerFactory.js.map +1 -0
- package/graphql/index.d.ts +5 -0
- package/graphql/index.js +57 -0
- package/graphql/index.js.map +1 -0
- package/graphql/schema/baseContentSchema.d.ts +3 -0
- package/graphql/schema/baseContentSchema.js +76 -0
- 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/graphql/schema/contentModelGroups.js +172 -0
- package/graphql/schema/contentModelGroups.js.map +1 -0
- package/graphql/schema/contentModels.d.ts +3 -0
- package/graphql/schema/contentModels.js +300 -0
- package/graphql/schema/contentModels.js.map +1 -0
- package/graphql/schema/createFieldResolvers.d.ts +20 -0
- package/graphql/schema/createFieldResolvers.js +121 -0
- package/graphql/schema/createFieldResolvers.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +12 -0
- package/graphql/schema/createManageResolvers.js +137 -0
- package/graphql/schema/createManageResolvers.js.map +1 -0
- package/graphql/schema/createManageSDL.d.ts +10 -0
- package/graphql/schema/createManageSDL.js +161 -0
- package/graphql/schema/createManageSDL.js.map +1 -0
- package/graphql/schema/createPreviewResolvers.d.ts +12 -0
- package/graphql/schema/createPreviewResolvers.js +58 -0
- package/graphql/schema/createPreviewResolvers.js.map +1 -0
- package/graphql/schema/createReadResolvers.d.ts +12 -0
- package/graphql/schema/createReadResolvers.js +58 -0
- package/graphql/schema/createReadResolvers.js.map +1 -0
- package/graphql/schema/createReadSDL.d.ts +10 -0
- package/graphql/schema/createReadSDL.js +104 -0
- package/graphql/schema/createReadSDL.js.map +1 -0
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +6 -0
- package/graphql/schema/resolvers/commonFieldResolvers.js +14 -0
- package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveCreate.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveCreate.js +21 -0
- package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +8 -0
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js +21 -0
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveDelete.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveDelete.js +32 -0
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGet.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveGet.js +79 -0
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveGetByIds.js +21 -0
- package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetRevisions.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js +21 -0
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveList.d.ts +4 -0
- package/graphql/schema/resolvers/manage/resolveList.js +21 -0
- package/graphql/schema/resolvers/manage/resolveList.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolvePublish.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolvePublish.js +21 -0
- package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveRepublish.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveRepublish.js +21 -0
- package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveUnpublish.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveUnpublish.js +21 -0
- package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +8 -0
- package/graphql/schema/resolvers/manage/resolveUpdate.js +21 -0
- package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveGet.d.ts +4 -0
- package/graphql/schema/resolvers/preview/resolveGet.js +34 -0
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveList.d.ts +4 -0
- package/graphql/schema/resolvers/preview/resolveList.js +21 -0
- package/graphql/schema/resolvers/preview/resolveList.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveGet.d.ts +4 -0
- package/graphql/schema/resolvers/read/resolveGet.js +34 -0
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -0
- package/graphql/schema/resolvers/read/resolveList.d.ts +4 -0
- package/graphql/schema/resolvers/read/resolveList.js +21 -0
- package/graphql/schema/resolvers/read/resolveList.js.map +1 -0
- package/graphql/schema/schemaPlugins.d.ts +3 -0
- package/graphql/schema/schemaPlugins.js +111 -0
- 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/dynamicZone/dynamicZoneField.d.ts +2 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js +234 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js +79 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
- package/graphqlFields/dynamicZone/index.d.ts +2 -0
- package/graphqlFields/dynamicZone/index.js +21 -0
- package/graphqlFields/dynamicZone/index.js.map +1 -0
- package/graphqlFields/file.d.ts +2 -0
- package/graphqlFields/file.js +50 -0
- package/graphqlFields/file.js.map +1 -0
- package/graphqlFields/helpers.d.ts +6 -0
- package/graphqlFields/helpers.js +49 -0
- package/graphqlFields/helpers.js.map +1 -0
- package/graphqlFields/index.d.ts +2 -0
- package/graphqlFields/index.js +30 -0
- package/graphqlFields/index.js.map +1 -0
- package/graphqlFields/longText.d.ts +2 -0
- package/graphqlFields/longText.js +63 -0
- package/graphqlFields/longText.js.map +1 -0
- package/graphqlFields/number.d.ts +2 -0
- package/graphqlFields/number.js +79 -0
- package/graphqlFields/number.js.map +1 -0
- package/graphqlFields/object.d.ts +2 -0
- package/graphqlFields/object.js +275 -0
- package/graphqlFields/object.js.map +1 -0
- package/graphqlFields/ref.d.ts +2 -0
- package/graphqlFields/ref.js +257 -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 -0
- package/index.js +111 -0
- package/index.js.map +1 -0
- package/modelManager/DefaultCmsModelManager.d.ts +14 -0
- package/modelManager/DefaultCmsModelManager.js +64 -0
- package/modelManager/DefaultCmsModelManager.js.map +1 -0
- package/modelManager/index.d.ts +2 -0
- package/modelManager/index.js +20 -0
- package/modelManager/index.js.map +1 -0
- package/package.json +81 -0
- package/parameters/context.d.ts +2 -0
- package/parameters/context.js +22 -0
- package/parameters/context.js.map +1 -0
- package/parameters/header.d.ts +2 -0
- package/parameters/header.js +55 -0
- package/parameters/header.js.map +1 -0
- package/parameters/index.d.ts +4 -0
- package/parameters/index.js +57 -0
- package/parameters/index.js.map +1 -0
- package/parameters/manual.d.ts +6 -0
- package/parameters/manual.js +44 -0
- package/parameters/manual.js.map +1 -0
- package/parameters/path.d.ts +2 -0
- package/parameters/path.js +51 -0
- package/parameters/path.js.map +1 -0
- package/plugins/CmsGroupPlugin.d.ts +13 -0
- package/plugins/CmsGroupPlugin.js +30 -0
- package/plugins/CmsGroupPlugin.js.map +1 -0
- package/plugins/CmsModelFieldConverterPlugin.d.ts +14 -0
- package/plugins/CmsModelFieldConverterPlugin.js +17 -0
- package/plugins/CmsModelFieldConverterPlugin.js.map +1 -0
- package/plugins/CmsModelPlugin.d.ts +45 -0
- package/plugins/CmsModelPlugin.js +194 -0
- package/plugins/CmsModelPlugin.js.map +1 -0
- package/plugins/CmsParametersPlugin.d.ts +20 -0
- package/plugins/CmsParametersPlugin.js +28 -0
- package/plugins/CmsParametersPlugin.js.map +1 -0
- package/plugins/StorageTransformPlugin.d.ts +31 -0
- package/plugins/StorageTransformPlugin.js +37 -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 +127 -0
- package/storage/object.js.map +1 -0
- package/types.d.ts +2600 -0
- package/types.js +459 -0
- package/types.js.map +1 -0
- package/upgrades/5.33.0/index.d.ts +3 -0
- package/upgrades/5.33.0/index.js +182 -0
- package/upgrades/5.33.0/index.js.map +1 -0
- package/upgrades/index.d.ts +1 -0
- package/upgrades/index.js +12 -0
- package/upgrades/index.js.map +1 -0
- package/utils/access.d.ts +8 -0
- package/utils/access.js +90 -0
- package/utils/access.js.map +1 -0
- package/utils/converters/Converter.d.ts +27 -0
- package/utils/converters/Converter.js +71 -0
- package/utils/converters/Converter.js.map +1 -0
- package/utils/converters/ConverterCollection.d.ts +31 -0
- package/utils/converters/ConverterCollection.js +143 -0
- package/utils/converters/ConverterCollection.js.map +1 -0
- package/utils/converters/valueKeyStorageConverter.d.ts +18 -0
- package/utils/converters/valueKeyStorageConverter.js +148 -0
- package/utils/converters/valueKeyStorageConverter.js.map +1 -0
- package/utils/createTypeFromFields.d.ts +15 -0
- package/utils/createTypeFromFields.js +75 -0
- package/utils/createTypeFromFields.js.map +1 -0
- package/utils/createTypeName.d.ts +3 -0
- package/utils/createTypeName.js +30 -0
- package/utils/createTypeName.js.map +1 -0
- package/utils/entryStorage.d.ts +17 -0
- package/utils/entryStorage.js +120 -0
- 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 +77 -0
- package/utils/filterModelFields.js.map +1 -0
- package/utils/getBaseFieldType.d.ts +4 -0
- package/utils/getBaseFieldType.js +12 -0
- package/utils/getBaseFieldType.js.map +1 -0
- package/utils/getEntryTitle.d.ts +2 -0
- package/utils/getEntryTitle.js +43 -0
- 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 +106 -0
- package/utils/permissions.js.map +1 -0
- package/utils/pluralizedTypeName.d.ts +1 -0
- package/utils/pluralizedTypeName.js +26 -0
- package/utils/pluralizedTypeName.js.map +1 -0
- package/utils/renderFields.d.ts +15 -0
- package/utils/renderFields.js +55 -0
- package/utils/renderFields.js.map +1 -0
- package/utils/renderGetFilterFields.d.ts +10 -0
- package/utils/renderGetFilterFields.js +61 -0
- package/utils/renderGetFilterFields.js.map +1 -0
- package/utils/renderInputFields.d.ts +14 -0
- package/utils/renderInputFields.js +55 -0
- package/utils/renderInputFields.js.map +1 -0
- package/utils/renderListFilterFields.d.ts +11 -0
- package/utils/renderListFilterFields.js +62 -0
- package/utils/renderListFilterFields.js.map +1 -0
- package/utils/renderSortEnum.d.ts +9 -0
- package/utils/renderSortEnum.js +34 -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/validators/dateGte.js +37 -0
- package/validators/dateGte.js.map +1 -0
- package/validators/dateLte.d.ts +2 -0
- package/validators/dateLte.js +37 -0
- package/validators/dateLte.js.map +1 -0
- package/validators/dynamicZone.d.ts +2 -0
- package/validators/dynamicZone.js +24 -0
- package/validators/dynamicZone.js.map +1 -0
- package/validators/gte.d.ts +2 -0
- package/validators/gte.js +36 -0
- package/validators/gte.js.map +1 -0
- package/validators/in.d.ts +2 -0
- package/validators/in.js +36 -0
- package/validators/in.js.map +1 -0
- package/validators/index.d.ts +1 -0
- package/validators/index.js +38 -0
- package/validators/index.js.map +1 -0
- package/validators/lte.d.ts +2 -0
- package/validators/lte.js +36 -0
- package/validators/lte.js.map +1 -0
- package/validators/maxLength.d.ts +2 -0
- package/validators/maxLength.js +36 -0
- package/validators/maxLength.js.map +1 -0
- package/validators/minLength.d.ts +2 -0
- package/validators/minLength.js +36 -0
- package/validators/minLength.js.map +1 -0
- package/validators/pattern.d.ts +2 -0
- package/validators/pattern.js +50 -0
- package/validators/pattern.js.map +1 -0
- package/validators/patternPlugins/email.d.ts +2 -0
- package/validators/patternPlugins/email.js +20 -0
- package/validators/patternPlugins/email.js.map +1 -0
- package/validators/patternPlugins/index.d.ts +2 -0
- package/validators/patternPlugins/index.js +24 -0
- package/validators/patternPlugins/index.js.map +1 -0
- package/validators/patternPlugins/lowerCase.d.ts +2 -0
- package/validators/patternPlugins/lowerCase.js +20 -0
- package/validators/patternPlugins/lowerCase.js.map +1 -0
- package/validators/patternPlugins/lowerCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/lowerCaseSpace.js +20 -0
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -0
- package/validators/patternPlugins/upperCase.d.ts +2 -0
- package/validators/patternPlugins/upperCase.js +20 -0
- package/validators/patternPlugins/upperCase.js.map +1 -0
- package/validators/patternPlugins/upperCaseSpace.d.ts +2 -0
- package/validators/patternPlugins/upperCaseSpace.js +20 -0
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -0
- package/validators/patternPlugins/url.d.ts +2 -0
- package/validators/patternPlugins/url.js +20 -0
- package/validators/patternPlugins/url.js.map +1 -0
- package/validators/required.d.ts +2 -0
- package/validators/required.js +27 -0
- package/validators/required.js.map +1 -0
- package/validators/timeGte.d.ts +2 -0
- package/validators/timeGte.js +34 -0
- package/validators/timeGte.js.map +1 -0
- package/validators/timeLte.d.ts +2 -0
- package/validators/timeLte.js +34 -0
- 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
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEntryTitle = getEntryTitle;
|
|
7
|
+
|
|
8
|
+
function getEntryTitle(model, entry) {
|
|
9
|
+
if (!model.titleFieldId) {
|
|
10
|
+
return entry.id;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const field = model.fields.find(f => f.fieldId === model.titleFieldId);
|
|
14
|
+
|
|
15
|
+
if (!field) {
|
|
16
|
+
return entry.id;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const titleFieldId = field.fieldId;
|
|
20
|
+
const titleValue = entry.values[titleFieldId];
|
|
21
|
+
|
|
22
|
+
if (!titleValue) {
|
|
23
|
+
return entry.id;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
enabled = false,
|
|
28
|
+
values
|
|
29
|
+
} = field.predefinedValues || {};
|
|
30
|
+
|
|
31
|
+
if (!enabled || !values || Array.isArray(values) === false) {
|
|
32
|
+
return titleValue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
for (const value of values) {
|
|
36
|
+
// needs to be loose because titleValue can be a number and value can be a string - but it must match
|
|
37
|
+
if (value.value == titleValue) {
|
|
38
|
+
return value.label;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return titleValue;
|
|
43
|
+
}
|
|
@@ -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,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hasRwd = exports.hasPw = exports.checkPermissions = void 0;
|
|
7
|
+
|
|
8
|
+
var _apiSecurity = require("@webiny/api-security");
|
|
9
|
+
|
|
10
|
+
const hasRwd = (permission, rwd) => {
|
|
11
|
+
if (typeof permission.rwd !== "string") {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return permission.rwd.includes(rwd);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.hasRwd = hasRwd;
|
|
19
|
+
|
|
20
|
+
const hasPw = (permission, pw) => {
|
|
21
|
+
const isCustom = Object.keys(permission).length > 1; // "name" key is always present
|
|
22
|
+
|
|
23
|
+
if (!isCustom) {
|
|
24
|
+
// Means it's a "full-access" permission.
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (typeof permission.pw !== "string") {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return permission.pw.includes(pw);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.hasPw = hasPw;
|
|
36
|
+
const PW = {
|
|
37
|
+
p: "publish",
|
|
38
|
+
u: "unpublish"
|
|
39
|
+
};
|
|
40
|
+
const RWD = {
|
|
41
|
+
r: "read",
|
|
42
|
+
w: "write",
|
|
43
|
+
d: "delete"
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const checkPermissions = async (context, name, check) => {
|
|
47
|
+
// Check if user is allowed to edit content in current language
|
|
48
|
+
const contentPermission = await context.security.getPermission("content.i18n");
|
|
49
|
+
|
|
50
|
+
if (!contentPermission) {
|
|
51
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
52
|
+
data: {
|
|
53
|
+
reason: "Missing access to content in any locale."
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
} // We need to check this manually as CMS locale comes from the URL and not the default i18n app.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
const code = context.cms.getLocale().code;
|
|
60
|
+
const locales = contentPermission.locales; // IMPORTANT: If we have a `contentPermission`, and `locales` key is NOT SET - it means the user has access to all locales.
|
|
61
|
+
// However, if the the `locales` IS SET - check that it contains the required locale.
|
|
62
|
+
|
|
63
|
+
if (Array.isArray(locales) && !locales.includes(code)) {
|
|
64
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
65
|
+
data: {
|
|
66
|
+
reason: `Not allowed to access content in "${code}."`
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const permission = await context.security.getPermission(name);
|
|
72
|
+
|
|
73
|
+
if (!permission) {
|
|
74
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
75
|
+
data: {
|
|
76
|
+
reason: `Missing permission "${name}".`
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!check) {
|
|
82
|
+
return permission;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (check.rwd && !hasRwd(permission, check.rwd)) {
|
|
86
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
87
|
+
data: {
|
|
88
|
+
reason: `Not allowed to perform "${RWD[check.rwd]}" on "${name}".`
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
} // p = publish
|
|
92
|
+
// u = unpublish
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
if (check.pw && !hasPw(permission, check.pw)) {
|
|
96
|
+
throw new _apiSecurity.NotAuthorizedError({
|
|
97
|
+
data: {
|
|
98
|
+
reason: `Not allowed to perform "${PW[check.pw]}" on "${name}".`
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return permission;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
exports.checkPermissions = checkPermissions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["hasRwd","permission","rwd","includes","hasPw","pw","isCustom","Object","keys","length","PW","p","u","RWD","r","w","d","checkPermissions","context","name","check","contentPermission","security","getPermission","NotAuthorizedError","data","reason","code","cms","getLocale","locales","Array","isArray"],"sources":["permissions.ts"],"sourcesContent":["import { BaseCmsSecurityPermission, CmsContext, CmsEntryPermission } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\nexport const hasRwd = (permission: BaseCmsSecurityPermission, rwd: string): boolean => {\n if (typeof permission.rwd !== \"string\") {\n return true;\n }\n\n return permission.rwd.includes(rwd);\n};\n\nexport const hasPw = (permission: CmsEntryPermission, pw: string): boolean => {\n const isCustom = Object.keys(permission).length > 1; // \"name\" key is always present\n\n if (!isCustom) {\n // Means it's a \"full-access\" permission.\n return true;\n }\n\n if (typeof permission.pw !== \"string\") {\n return false;\n }\n\n return permission.pw.includes(pw);\n};\n\nconst PW: Record<string, string> = {\n p: \"publish\",\n u: \"unpublish\"\n};\n\nconst RWD: Record<string, string> = {\n r: \"read\",\n w: \"write\",\n d: \"delete\"\n};\n\nexport const checkPermissions = async <\n TPermission extends BaseCmsSecurityPermission = BaseCmsSecurityPermission\n>(\n context: CmsContext,\n name: string,\n check?: { rwd?: string; pw?: string }\n): Promise<TPermission> => {\n // Check if user is allowed to edit content in current language\n const contentPermission = await context.security.getPermission(\"content.i18n\");\n\n if (!contentPermission) {\n throw new NotAuthorizedError({\n data: {\n reason: \"Missing access to content in any locale.\"\n }\n });\n }\n\n // We need to check this manually as CMS locale comes from the URL and not the default i18n app.\n const code = context.cms.getLocale().code;\n\n const locales: string[] = contentPermission.locales;\n\n // IMPORTANT: If we have a `contentPermission`, and `locales` key is NOT SET - it means the user has access to all locales.\n // However, if the the `locales` IS SET - check that it contains the required locale.\n if (Array.isArray(locales) && !locales.includes(code)) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to access content in \"${code}.\"`\n }\n });\n }\n\n const permission = await context.security.getPermission<TPermission>(name);\n\n if (!permission) {\n throw new NotAuthorizedError({\n data: {\n reason: `Missing permission \"${name}\".`\n }\n });\n }\n\n if (!check) {\n return permission;\n }\n\n if (check.rwd && !hasRwd(permission, check.rwd)) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to perform \"${RWD[check.rwd]}\" on \"${name}\".`\n }\n });\n }\n\n // p = publish\n // u = unpublish\n if (check.pw && !hasPw(permission, check.pw)) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to perform \"${PW[check.pw]}\" on \"${name}\".`\n }\n });\n }\n\n return permission;\n};\n"],"mappings":";;;;;;;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,SAD4B;EAE/BC,CAAC,EAAE;AAF4B,CAAnC;AAKA,MAAMC,GAA2B,GAAG;EAChCC,CAAC,EAAE,MAD6B;EAEhCC,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,CAAC3B,QAAR,CAAiBwB,IAAjB,CAA/B,EAAuD;IACnD,MAAM,IAAIH,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,qCAAoCC,IAAK;MADhD;IADmB,CAAvB,CAAN;EAKH;;EAED,MAAM1B,UAAU,GAAG,MAAMiB,OAAO,CAACI,QAAR,CAAiBC,aAAjB,CAA4CJ,IAA5C,CAAzB;;EAEA,IAAI,CAAClB,UAAL,EAAiB;IACb,MAAM,IAAIuB,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,uBAAsBP,IAAK;MADlC;IADmB,CAAvB,CAAN;EAKH;;EAED,IAAI,CAACC,KAAL,EAAY;IACR,OAAOnB,UAAP;EACH;;EAED,IAAImB,KAAK,CAAClB,GAAN,IAAa,CAACF,MAAM,CAACC,UAAD,EAAamB,KAAK,CAAClB,GAAnB,CAAxB,EAAiD;IAC7C,MAAM,IAAIsB,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,2BAA0Bb,GAAG,CAACO,KAAK,CAAClB,GAAP,CAAY,SAAQiB,IAAK;MAD7D;IADmB,CAAvB,CAAN;EAKH,CA/CsB,CAiDvB;EACA;;;EACA,IAAIC,KAAK,CAACf,EAAN,IAAY,CAACD,KAAK,CAACH,UAAD,EAAamB,KAAK,CAACf,EAAnB,CAAtB,EAA8C;IAC1C,MAAM,IAAImB,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,2BAA0BhB,EAAE,CAACU,KAAK,CAACf,EAAP,CAAW,SAAQc,IAAK;MAD3D;IADmB,CAAvB,CAAN;EAKH;;EAED,OAAOlB,UAAP;AACH,CAlEM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pluralizedTypeName: (typeName: string) => string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.pluralizedTypeName = void 0;
|
|
9
|
+
|
|
10
|
+
var _pluralize = _interopRequireDefault(require("pluralize"));
|
|
11
|
+
|
|
12
|
+
// This will make it so if the content model name is a single capitalized letter
|
|
13
|
+
// Ex. A, pluralizedTypeName will capitalize the name to As, instead of AS
|
|
14
|
+
const pluralizedTypeName = typeName => {
|
|
15
|
+
let pluralizedTypeName;
|
|
16
|
+
|
|
17
|
+
if (typeName.length === 1) {
|
|
18
|
+
pluralizedTypeName = `${typeName}s`;
|
|
19
|
+
} else {
|
|
20
|
+
pluralizedTypeName = (0, _pluralize.default)(typeName);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return pluralizedTypeName;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.pluralizedTypeName = pluralizedTypeName;
|
|
@@ -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 {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderFields = exports.renderField = void 0;
|
|
7
|
+
|
|
8
|
+
var _getBaseFieldType = require("./getBaseFieldType");
|
|
9
|
+
|
|
10
|
+
const renderFields = ({
|
|
11
|
+
model,
|
|
12
|
+
type,
|
|
13
|
+
fieldTypePlugins
|
|
14
|
+
}) => {
|
|
15
|
+
return model.fields.map(field => renderField({
|
|
16
|
+
model,
|
|
17
|
+
type,
|
|
18
|
+
field,
|
|
19
|
+
fieldTypePlugins
|
|
20
|
+
})).filter(Boolean);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.renderFields = renderFields;
|
|
24
|
+
|
|
25
|
+
const renderField = ({
|
|
26
|
+
model,
|
|
27
|
+
type,
|
|
28
|
+
field,
|
|
29
|
+
fieldTypePlugins
|
|
30
|
+
}) => {
|
|
31
|
+
const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
|
|
32
|
+
|
|
33
|
+
if (!plugin) {
|
|
34
|
+
// Let's not render the field if it does not exist in the field plugins.
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const defs = plugin[type].createTypeField({
|
|
39
|
+
model,
|
|
40
|
+
field,
|
|
41
|
+
fieldTypePlugins
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (!defs) {
|
|
45
|
+
return null;
|
|
46
|
+
} else if (typeof defs === "string") {
|
|
47
|
+
return {
|
|
48
|
+
fields: defs
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return defs;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.renderField = renderField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["renderFields","model","type","fieldTypePlugins","fields","map","field","renderField","filter","Boolean","plugin","getBaseFieldType","defs","createTypeField"],"sources":["renderFields.ts"],"sourcesContent":["import {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\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[getBaseFieldType(field)];\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":";;;;;;;AAQA;;AAWO,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,CAAC,IAAAQ,kCAAA,EAAiBL,KAAjB,CAAD,CAA7D;;EACA,IAAI,CAACI,MAAL,EAAa;IACT;IACA,OAAO,IAAP;EACH;;EACD,MAAME,IAAI,GAAGF,MAAM,CAACR,IAAD,CAAN,CAAaW,eAAb,CAA6B;IACtCZ,KADsC;IAEtCK,KAFsC;IAGtCH;EAHsC,CAA7B,CAAb;;EAMA,IAAI,CAACS,IAAL,EAAW;IACP,OAAO,IAAP;EACH,CAFD,MAEO,IAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;IACjC,OAAO;MACHR,MAAM,EAAEQ;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 {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderGetFilterFields = void 0;
|
|
7
|
+
|
|
8
|
+
var _getBaseFieldType = require("./getBaseFieldType");
|
|
9
|
+
|
|
10
|
+
const getCreateFilters = (plugins, fieldType) => {
|
|
11
|
+
if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return plugins[fieldType].read.createGetFilters;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const renderGetFilterFields = ({
|
|
19
|
+
model,
|
|
20
|
+
fieldTypePlugins
|
|
21
|
+
}) => {
|
|
22
|
+
const fieldIdList = model.fields.filter(field => {
|
|
23
|
+
// Every time a client updates content model's fields, we check the type of each field. If a field plugin
|
|
24
|
+
// for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
|
|
25
|
+
// want to be careful when accessing the field plugin here too. It is still possible to have a content model
|
|
26
|
+
// that contains a field, for which we don't have a plugin registered on the backend. For example, user
|
|
27
|
+
// could've just removed the plugin from the backend.
|
|
28
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
29
|
+
|
|
30
|
+
if (!fieldTypePlugins[baseType]) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return fieldTypePlugins[baseType].isSearchable;
|
|
35
|
+
}).map(f => f.fieldId);
|
|
36
|
+
const filters = ["id: ID", "entryId: String"];
|
|
37
|
+
|
|
38
|
+
for (const fieldId of fieldIdList) {
|
|
39
|
+
const field = model.fields.find(item => item.fieldId === fieldId);
|
|
40
|
+
|
|
41
|
+
if (!field) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
46
|
+
const createGetFilters = getCreateFilters(fieldTypePlugins, baseType);
|
|
47
|
+
|
|
48
|
+
if (typeof createGetFilters !== "function") {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
filters.push(createGetFilters({
|
|
53
|
+
model,
|
|
54
|
+
field
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return filters.filter(Boolean).join("\n");
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
exports.renderGetFilterFields = renderGetFilterFields;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getCreateFilters","plugins","fieldType","read","createGetFilters","renderGetFilterFields","model","fieldTypePlugins","fieldIdList","fields","filter","field","baseType","getBaseFieldType","isSearchable","map","f","fieldId","filters","find","item","push","Boolean","join"],"sources":["renderGetFilterFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\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 const baseType = getBaseFieldType(field);\n if (!fieldTypePlugins[baseType]) {\n return false;\n }\n return fieldTypePlugins[baseType].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 baseType = getBaseFieldType(field);\n const createGetFilters = getCreateFilters(fieldTypePlugins, baseType);\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":";;;;;;;AACA;;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,MAAMC,QAAQ,GAAG,IAAAC,kCAAA,EAAiBF,KAAjB,CAAjB;;IACA,IAAI,CAACJ,gBAAgB,CAACK,QAAD,CAArB,EAAiC;MAC7B,OAAO,KAAP;IACH;;IACD,OAAOL,gBAAgB,CAACK,QAAD,CAAhB,CAA2BE,YAAlC;EACH,CAZe,EAafC,GAbe,CAaXC,CAAC,IAAIA,CAAC,CAACC,OAbI,CAApB;EAeA,MAAMC,OAAiB,GAAG,CAAC,QAAD,EAAW,iBAAX,CAA1B;;EAEA,KAAK,MAAMD,OAAX,IAAsBT,WAAtB,EAAmC;IAC/B,MAAMG,KAAK,GAAGL,KAAK,CAACG,MAAN,CAAaU,IAAb,CAAkBC,IAAI,IAAIA,IAAI,CAACH,OAAL,KAAiBA,OAA3C,CAAd;;IACA,IAAI,CAACN,KAAL,EAAY;MACR;IACH;;IACD,MAAMC,QAAQ,GAAG,IAAAC,kCAAA,EAAiBF,KAAjB,CAAjB;IACA,MAAMP,gBAAgB,GAAGJ,gBAAgB,CAACO,gBAAD,EAAmBK,QAAnB,CAAzC;;IACA,IAAI,OAAOR,gBAAP,KAA4B,UAAhC,EAA4C;MACxC;IACH;;IACDc,OAAO,CAACG,IAAR,CAAajB,gBAAgB,CAAC;MAAEE,KAAF;MAASK;IAAT,CAAD,CAA7B;EACH;;EAED,OAAOO,OAAO,CAACR,MAAR,CAAeY,OAAf,EAAwBC,IAAxB,CAA6B,IAA7B,CAAP;AACH,CAhCM"}
|
|
@@ -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,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderInputFields = exports.renderInputField = void 0;
|
|
7
|
+
|
|
8
|
+
var _getBaseFieldType = require("./getBaseFieldType");
|
|
9
|
+
|
|
10
|
+
const renderInputFields = ({
|
|
11
|
+
model,
|
|
12
|
+
fieldTypePlugins
|
|
13
|
+
}) => {
|
|
14
|
+
return model.fields.map(field => renderInputField({
|
|
15
|
+
model,
|
|
16
|
+
field,
|
|
17
|
+
fieldTypePlugins
|
|
18
|
+
})).filter(Boolean);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.renderInputFields = renderInputFields;
|
|
22
|
+
|
|
23
|
+
const renderInputField = ({
|
|
24
|
+
model,
|
|
25
|
+
field,
|
|
26
|
+
fieldTypePlugins
|
|
27
|
+
}) => {
|
|
28
|
+
// Every time a client updates content model's fields, we check the type of each field. If a field plugin
|
|
29
|
+
// for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
|
|
30
|
+
// want to be careful when accessing the field plugin here too. It is still possible to have a content model
|
|
31
|
+
// that contains a field, for which we don't have a plugin registered on the backend. For example, user
|
|
32
|
+
// could've just removed the plugin from the backend.
|
|
33
|
+
const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
|
|
34
|
+
|
|
35
|
+
if (!plugin) {
|
|
36
|
+
// Let's not render the field if it does not exist in the field plugins.
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const def = plugin.manage.createInputField({
|
|
41
|
+
model,
|
|
42
|
+
field,
|
|
43
|
+
fieldTypePlugins
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
if (typeof def === "string") {
|
|
47
|
+
return {
|
|
48
|
+
fields: def
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return def;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.renderInputField = renderInputField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["renderInputFields","model","fieldTypePlugins","fields","map","field","renderInputField","filter","Boolean","plugin","getBaseFieldType","def","manage","createInputField"],"sources":["renderInputFields.ts"],"sourcesContent":["import {\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\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[getBaseFieldType(field)];\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":";;;;;;;AAOA;;AAaO,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,CAAC,IAAAQ,kCAAA,EAAiBL,KAAjB,CAAD,CAA7D;;EAEA,IAAI,CAACI,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 {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderListFilterFields = void 0;
|
|
7
|
+
|
|
8
|
+
var _getBaseFieldType = require("./getBaseFieldType");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* We cast as read type, because input and output of read and manage are same. This way we ease things.
|
|
12
|
+
* Internal stuff so it should be ok.
|
|
13
|
+
* TODO note that if changing read/manage types, change this as well.
|
|
14
|
+
*/
|
|
15
|
+
const getCreateListFilters = (plugins, fieldType, type) => {
|
|
16
|
+
if (!plugins[fieldType]) {
|
|
17
|
+
return null;
|
|
18
|
+
} else if (!plugins[fieldType][type]) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return plugins[fieldType][type].createListFilters;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const renderListFilterFields = params => {
|
|
26
|
+
const {
|
|
27
|
+
model,
|
|
28
|
+
type,
|
|
29
|
+
fieldTypePlugins
|
|
30
|
+
} = params;
|
|
31
|
+
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")];
|
|
32
|
+
/**
|
|
33
|
+
* We can find different statuses only in the manage API endpoint.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
if (type === "manage") {
|
|
37
|
+
fields.push(...["status: String", "status_not: String", "status_in: [String!]", "status_not_in: [String!]"]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
for (const field of model.fields) {
|
|
41
|
+
// Every time a client updates content model's fields, we check the type of each field. If a field plugin
|
|
42
|
+
// for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
|
|
43
|
+
// want to be careful when accessing the field plugin here too. It is still possible to have a content model
|
|
44
|
+
// that contains a field, for which we don't have a plugin registered on the backend. For example, user
|
|
45
|
+
// could've just removed the plugin from the backend.
|
|
46
|
+
const createListFilters = getCreateListFilters(fieldTypePlugins, (0, _getBaseFieldType.getBaseFieldType)(field), type);
|
|
47
|
+
|
|
48
|
+
if (typeof createListFilters !== "function") {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fields.push(createListFilters({
|
|
53
|
+
model,
|
|
54
|
+
field,
|
|
55
|
+
plugins: fieldTypePlugins
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return fields.filter(Boolean).join("\n");
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
exports.renderListFilterFields = renderListFilterFields;
|