import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast'; import type { AttributeOut, AttributeSpec, InterpretCtx, Param, PositionalParam } from './types'; interface FieldAttributeConfig< Pos extends readonly PositionalParam[], Named extends Record>, > { readonly positional?: Pos; readonly named?: Named; readonly refine?: ( parsed: AttributeOut, ctx: InterpretCtx, ) => readonly PslDiagnostic[]; } export function fieldAttribute< const Pos extends readonly PositionalParam[] = readonly [], const Named extends Record> = Record, >(name: string, config: FieldAttributeConfig): AttributeSpec> { return { level: 'field', name, positional: config.positional ?? [], named: config.named ?? {}, ...(config.refine !== undefined ? { refine: config.refine } : {}), }; }