import type { ConstraintValidator } from '@/types' import { PluginType } from '@/enums' export const scope: ConstraintValidator = (targetPluginType) => async ({ pluginConfig, type: moduleType }) => { const currentPluginType = pluginConfig.service.scope || PluginType.Team const LEVEL = { [PluginType.Team]: 'team-level', [PluginType.Organization]: 'organization-level', } if (targetPluginType !== currentPluginType) { throw `${moduleType} is not allowed to be declared in ${LEVEL[currentPluginType]} plugins` } }