@prisma-next/psl-parser 0.16.0-dev.11 → 0.16.0-dev.13

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/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { C as AttributeArgAst, P as AstNode, T as ExpressionAst, b as FieldAttributeAst, et as SourceFile, x as ModelAttributeAst } from "./parse-Bl1gwWGn.mjs";
2
- import { S as readResolvedConstructorCall, _ as keywordPslSpan, a as ModelSymbol, b as readResolvedAttribute, c as ScalarSymbol, d as TopLevelScope, f as TypeAliasSymbol, g as ResolvedTypeConstructorCall, h as ResolvedAttributeArg, i as FieldSymbol, l as SymbolTable, m as ResolvedAttribute, n as BuildSymbolTableOptions, o as NamespaceSymbol, p as buildSymbolTable, r as CompositeTypeSymbol, s as ResolvedNamedTypeBinding, t as BlockSymbol, u as SymbolTableResult, v as nodePslSpan, x as readResolvedAttributes, y as rangeToPslSpan } from "./symbol-table-en_Bich3.mjs";
2
+ import { _ as nodePslSpan, a as ModelSymbol, b as readResolvedAttributes, c as ResolvedNamedTypeBinding, d as TopLevelScope, f as buildSymbolTable, g as keywordPslSpan, h as ResolvedTypeConstructorCall, i as FieldSymbol, l as SymbolTable, m as ResolvedAttributeArg, n as BuildSymbolTableOptions, o as NamedTypeSymbol, p as ResolvedAttribute, r as CompositeTypeSymbol, s as NamespaceSymbol, t as BlockSymbol, u as SymbolTableResult, v as rangeToPslSpan, x as readResolvedConstructorCall, y as readResolvedAttribute } from "./symbol-table-DVspQ58_.mjs";
3
3
  import { PslAttribute, PslAttribute as PslAttribute$1, PslAttributeArgument, PslAttributeNamedArgument, PslAttributePositionalArgument, PslAttributeTarget, PslCompositeType, PslDefaultFunctionValue, PslDefaultLiteralValue, PslDefaultValue, PslDiagnostic, PslDiagnostic as PslDiagnostic$1, PslDiagnosticCode, PslDiagnosticCode as PslDiagnosticCode$1, PslDocumentAst, PslExtensionBlock, PslExtensionBlockAttribute, PslExtensionBlockAttributeArg, PslExtensionBlockParamBare, PslExtensionBlockParamList, PslExtensionBlockParamOption, PslExtensionBlockParamRef, PslExtensionBlockParamScalarValue, PslExtensionBlockParamValue, PslField, PslFieldAttribute, PslModel, PslModelAttribute, PslNamedTypeDeclaration, PslNamespace, PslPosition, PslSpan, PslSpan as PslSpan$1, PslTypeConstructorCall, PslTypesBlock, flatPslModels, namespacePslExtensionBlocks } from "@prisma-next/framework-components/psl-ast";
4
4
  import { Result } from "@prisma-next/utils/result";
5
5
  import { AuthoringPslBlockDescriptor, AuthoringPslBlockDescriptorNamespace } from "@prisma-next/framework-components/authoring";
@@ -145,5 +145,5 @@ declare function validateExtensionBlockFromSymbol(input: {
145
145
  readonly codecLookup: CodecLookup;
146
146
  }): readonly PslDiagnostic$1[];
147
147
  //#endregion
148
- export { type ArgBindingSpec, type ArgType, type AttributeLevel, type AttributeOut, type AttributeSpec, type BlockSymbol, type BuildSymbolTableOptions, type CompositeTypeSymbol, type FieldRefArgType, type FieldRefScope, type FieldSymbol, type FuncCallSig, type InferAttr, type InterpretCtx, type ListOptions, type ModelSymbol, type NamedOut, type NamespaceSymbol, type OptionalArgType, type OutOf, type Param, type PosOut, type PositionalParam, type PslAttribute, type PslAttributeArgument, type PslAttributeNamedArgument, type PslAttributePositionalArgument, type PslAttributeTarget, type PslCompositeType, type PslDefaultFunctionValue, type PslDefaultLiteralValue, type PslDefaultValue, type PslDiagnostic, type PslDiagnosticCode, type PslDocumentAst, type PslExtensionBlock, type PslExtensionBlockAttribute, type PslExtensionBlockAttributeArg, type PslExtensionBlockParamBare, type PslExtensionBlockParamList, type PslExtensionBlockParamOption, type PslExtensionBlockParamRef, type PslExtensionBlockParamScalarValue, type PslExtensionBlockParamValue, type PslField, type PslFieldAttribute, type PslModel, type PslModelAttribute, type PslNamedTypeDeclaration, type PslNamespace, type PslPosition, type PslSpan, type PslTypeConstructorCall, type PslTypesBlock, type ResolvedAttribute, type ResolvedAttributeArg, type ResolvedNamedTypeBinding, type ResolvedTypeConstructorCall, type ScalarSymbol, type SymbolTable, type SymbolTableResult, type TopLevelScope, type TypeAliasSymbol, type TypedFuncCall, bool, buildSymbolTable, entityRef, fieldAttribute, fieldRef, findBlockDescriptor, flatPslModels, funcCall, getPositionalArgument, identifier, int, interpretArgs, interpretAttribute, keywordPslSpan, leafDiagnostic, list, modelAttribute, namespacePslExtensionBlocks, nodePslSpan, num, oneOf, optional, parseQuotedStringLiteral, rangeToPslSpan, readResolvedAttribute, readResolvedAttributes, readResolvedConstructorCall, record, str, validateExtensionBlockFromSymbol };
148
+ export { type ArgBindingSpec, type ArgType, type AttributeLevel, type AttributeOut, type AttributeSpec, type BlockSymbol, type BuildSymbolTableOptions, type CompositeTypeSymbol, type FieldRefArgType, type FieldRefScope, type FieldSymbol, type FuncCallSig, type InferAttr, type InterpretCtx, type ListOptions, type ModelSymbol, type NamedOut, type NamedTypeSymbol, type NamespaceSymbol, type OptionalArgType, type OutOf, type Param, type PosOut, type PositionalParam, type PslAttribute, type PslAttributeArgument, type PslAttributeNamedArgument, type PslAttributePositionalArgument, type PslAttributeTarget, type PslCompositeType, type PslDefaultFunctionValue, type PslDefaultLiteralValue, type PslDefaultValue, type PslDiagnostic, type PslDiagnosticCode, type PslDocumentAst, type PslExtensionBlock, type PslExtensionBlockAttribute, type PslExtensionBlockAttributeArg, type PslExtensionBlockParamBare, type PslExtensionBlockParamList, type PslExtensionBlockParamOption, type PslExtensionBlockParamRef, type PslExtensionBlockParamScalarValue, type PslExtensionBlockParamValue, type PslField, type PslFieldAttribute, type PslModel, type PslModelAttribute, type PslNamedTypeDeclaration, type PslNamespace, type PslPosition, type PslSpan, type PslTypeConstructorCall, type PslTypesBlock, type ResolvedAttribute, type ResolvedAttributeArg, type ResolvedNamedTypeBinding, type ResolvedTypeConstructorCall, type SymbolTable, type SymbolTableResult, type TopLevelScope, type TypedFuncCall, bool, buildSymbolTable, entityRef, fieldAttribute, fieldRef, findBlockDescriptor, flatPslModels, funcCall, getPositionalArgument, identifier, int, interpretArgs, interpretAttribute, keywordPslSpan, leafDiagnostic, list, modelAttribute, namespacePslExtensionBlocks, nodePslSpan, num, oneOf, optional, parseQuotedStringLiteral, rangeToPslSpan, readResolvedAttribute, readResolvedAttributes, readResolvedConstructorCall, record, str, validateExtensionBlockFromSymbol };
149
149
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -629,12 +629,10 @@ function reconstructFromExpression(value, param, span, sourceFile, diagnostics)
629
629
  * should consume first-wins symbols rather than re-emitting duplicate diagnostics.
630
630
  */
631
631
  function buildSymbolTable(options) {
632
- const { document, sourceFile, scalarTypes, pslBlockDescriptors } = options;
632
+ const { document, sourceFile, pslBlockDescriptors } = options;
633
633
  const diagnostics = [];
634
- const scalarSet = new Set(scalarTypes);
635
634
  const namespaces = {};
636
- const scalars = {};
637
- const typeAliases = {};
635
+ const namedTypes = {};
638
636
  const blocks = {};
639
637
  const models = {};
640
638
  const compositeTypes = {};
@@ -670,27 +668,18 @@ function buildSymbolTable(options) {
670
668
  const name = claim(topLevelNames, binding.name());
671
669
  if (name === void 0) continue;
672
670
  const resolved = resolveNamedTypeBinding(binding, sourceFile);
673
- const span = nodePslSpan(binding.syntax, sourceFile);
674
- if (isScalarBinding(binding, scalarSet)) scalars[name] = {
675
- kind: "scalar",
671
+ namedTypes[name] = {
672
+ kind: "namedType",
676
673
  name,
677
674
  node: binding,
678
- span,
679
- ...resolved
680
- };
681
- else typeAliases[name] = {
682
- kind: "typeAlias",
683
- name,
684
- node: binding,
685
- span,
675
+ span: nodePslSpan(binding.syntax, sourceFile),
686
676
  ...resolved
687
677
  };
688
678
  }
689
679
  return {
690
680
  table: { topLevel: {
691
681
  namespaces,
692
- scalars,
693
- typeAliases,
682
+ namedTypes,
694
683
  blocks,
695
684
  models,
696
685
  compositeTypes
@@ -834,12 +823,6 @@ function resolveNamedTypeBinding(node, sourceFile) {
834
823
  attributes: readResolvedAttributes(node.attributes(), sourceFile)
835
824
  };
836
825
  }
837
- function isScalarBinding(node, scalarTypes) {
838
- const annotation = node.typeAnnotation();
839
- if (annotation === void 0 || annotation.isConstructor()) return false;
840
- const base = annotation.name()?.identifier()?.name();
841
- return base !== void 0 && scalarTypes.has(base);
842
- }
843
826
  function nameRange(name, sourceFile) {
844
827
  if (name === void 0) return void 0;
845
828
  for (const token of name.syntax.tokens()) if (token.kind === "Ident") return {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/attribute-helpers.ts","../src/resolve.ts","../src/attribute-spec/combinators/diagnostic.ts","../src/attribute-spec/combinators/bool.ts","../src/attribute-spec/combinators/entity-ref.ts","../src/attribute-spec/combinators/field-ref.ts","../src/attribute-spec/interpret.ts","../src/attribute-spec/combinators/func-call.ts","../src/attribute-spec/combinators/identifier.ts","../src/attribute-spec/combinators/int.ts","../src/attribute-spec/combinators/list.ts","../src/attribute-spec/combinators/num.ts","../src/attribute-spec/combinators/one-of.ts","../src/attribute-spec/combinators/record.ts","../src/attribute-spec/combinators/str.ts","../src/attribute-spec/field-attribute.ts","../src/attribute-spec/model-attribute.ts","../src/attribute-spec/optional.ts","../src/extension-block.ts","../src/block-reconstruction.ts","../src/symbol-table.ts"],"sourcesContent":["import type { PslAttribute } from '@prisma-next/framework-components/psl-ast';\n\nexport function getPositionalArgument(attribute: PslAttribute, index = 0): string | undefined {\n const entries = attribute.args.filter((arg) => arg.kind === 'positional');\n return entries[index]?.value;\n}\n\nexport function parseQuotedStringLiteral(value: string): string | undefined {\n const trimmed = value.trim();\n const match = trimmed.match(/^(['\"])(.*)\\1$/);\n if (!match) return undefined;\n return match[2] ?? '';\n}\n","import type { PslSpan } from '@prisma-next/framework-components/psl-ast';\nimport type { Position, Range, SourceFile } from './source-file';\nimport type {\n AttributeArgListAst,\n FieldAttributeAst,\n ModelAttributeAst,\n} from './syntax/ast/attributes';\nimport type { ExpressionAst } from './syntax/ast/expressions';\nimport type { QualifiedNameAst } from './syntax/ast/qualified-name';\nimport type { TypeAnnotationAst } from './syntax/ast/type-annotation';\nimport { printSyntax } from './syntax/ast-helpers';\nimport type { SyntaxNode } from './syntax/red';\n\nexport interface ResolvedAttributeArg {\n readonly kind: 'positional' | 'named';\n readonly name?: string;\n readonly value: string;\n readonly expression?: ExpressionAst;\n readonly span: PslSpan;\n}\n\nexport interface ResolvedAttribute {\n readonly name: string;\n readonly args: readonly ResolvedAttributeArg[];\n readonly span: PslSpan;\n}\n\nexport interface ResolvedTypeConstructorCall {\n readonly path: readonly string[];\n readonly args: readonly ResolvedAttributeArg[];\n readonly span: PslSpan;\n}\n\nexport function readResolvedAttribute(\n attribute: FieldAttributeAst | ModelAttributeAst,\n sourceFile: SourceFile,\n): ResolvedAttribute {\n return {\n name: attributeName(attribute.name()),\n args: readResolvedArgList(attribute.argList(), sourceFile),\n span: nodePslSpan(attribute.syntax, sourceFile),\n };\n}\n\nexport function readResolvedAttributes(\n attributes: Iterable<FieldAttributeAst | ModelAttributeAst>,\n sourceFile: SourceFile,\n): readonly ResolvedAttribute[] {\n return Array.from(attributes, (attribute) => readResolvedAttribute(attribute, sourceFile));\n}\n\nexport function readResolvedConstructorCall(\n annotation: TypeAnnotationAst | undefined,\n sourceFile: SourceFile,\n): ResolvedTypeConstructorCall | undefined {\n const argList = annotation?.argList();\n if (annotation === undefined || argList === undefined) return undefined;\n return {\n path: annotation.name()?.path() ?? [],\n args: readResolvedArgList(argList, sourceFile),\n span: nodePslSpan(annotation.syntax, sourceFile),\n };\n}\n\nfunction readResolvedArgList(\n argList: AttributeArgListAst | undefined,\n sourceFile: SourceFile,\n): readonly ResolvedAttributeArg[] {\n if (argList === undefined) return [];\n const args: ResolvedAttributeArg[] = [];\n for (const arg of argList.args()) {\n const name = arg.name()?.name();\n const expression = arg.value();\n args.push({\n kind: name !== undefined ? 'named' : 'positional',\n ...(name !== undefined ? { name } : {}),\n value: renderExpression(expression),\n ...(expression !== undefined ? { expression } : {}),\n span: nodePslSpan(arg.syntax, sourceFile),\n });\n }\n return args;\n}\n\nfunction attributeName(name: QualifiedNameAst | undefined): string {\n return name?.path().join('.') ?? '';\n}\n\nfunction renderExpression(expression: ExpressionAst | undefined): string {\n if (expression === undefined) return '';\n return printSyntax(expression.syntax).trim();\n}\n\nexport function nodePslSpan(node: SyntaxNode, sourceFile: SourceFile): PslSpan {\n const start = node.offset;\n const end = start + node.green.textLength;\n return {\n start: offsetToPslPosition(start, sourceFile),\n end: offsetToPslPosition(end, sourceFile),\n };\n}\n\n/** Unsupported-top-level-block diagnostics are anchored to the keyword token. */\nexport function keywordPslSpan(node: SyntaxNode, keyword: string, sourceFile: SourceFile): PslSpan {\n const start = node.offset;\n const end = start + keyword.length;\n return {\n start: offsetToPslPosition(start, sourceFile),\n end: offsetToPslPosition(end, sourceFile),\n };\n}\n\nexport function rangeToPslSpan(range: Range, sourceFile: SourceFile): PslSpan {\n return {\n start: offsetToPslPosition(sourceFile.offsetAt(range.start), sourceFile),\n end: offsetToPslPosition(sourceFile.offsetAt(range.end), sourceFile),\n };\n}\n\nfunction offsetToPslPosition(offset: number, sourceFile: SourceFile): PslSpan['start'] {\n const position: Position = sourceFile.positionAt(offset);\n return { offset, line: position.line + 1, column: position.character + 1 };\n}\n","import type { PslDiagnostic, PslDiagnosticCode } from '@prisma-next/framework-components/psl-ast';\nimport { nodePslSpan } from '../../resolve';\nimport type { AstNode } from '../../syntax/ast-helpers';\nimport type { InterpretCtx } from '../types';\n\nexport const ATTRIBUTE_DIAGNOSTIC_CODE: PslDiagnosticCode = 'PSL_INVALID_ATTRIBUTE_SYNTAX';\n\nexport function leafDiagnostic(ctx: InterpretCtx, node: AstNode, message: string): PslDiagnostic {\n return {\n code: ATTRIBUTE_DIAGNOSTIC_CODE,\n message,\n sourceId: ctx.sourceId,\n span: nodePslSpan(node.syntax, ctx.sourceFile),\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { BooleanLiteralExprAst } from '../../syntax/ast/expressions';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport function bool(): ArgType<boolean> {\n return {\n kind: 'bool',\n label: 'boolean',\n parse: (arg, ctx): Result<boolean, readonly PslDiagnostic[]> => {\n if (arg instanceof BooleanLiteralExprAst) {\n const value = arg.value();\n if (value !== undefined) return ok(value);\n }\n return notOk([leafDiagnostic(ctx, arg, 'Expected a boolean literal')]);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { IdentifierAst } from '../../syntax/ast/identifier';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\n// A bare model-name reference. Existence of a model with this name is resolved\n// downstream (e.g. `resolvePolymorphism`), not here.\nexport function entityRef(): ArgType<string> {\n return {\n kind: 'entityRef',\n label: 'model name',\n parse: (arg, ctx): Result<string, readonly PslDiagnostic[]> => {\n if (!(arg instanceof IdentifierAst)) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a model name')]);\n }\n const name = arg.name();\n if (name === undefined) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a model name')]);\n }\n return ok(name);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { IdentifierAst } from '../../syntax/ast/identifier';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport type FieldRefScope = 'self' | 'referenced';\n\nexport interface FieldRefArgType extends ArgType<string> {\n readonly scope: FieldRefScope;\n}\n\nexport function fieldRef(scope: FieldRefScope): FieldRefArgType {\n return {\n kind: 'fieldRef',\n label: 'field name',\n scope,\n parse: (arg, ctx): Result<string, readonly PslDiagnostic[]> => {\n if (!(arg instanceof IdentifierAst)) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a field name')]);\n }\n const name = arg.name();\n if (name === undefined) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a field name')]);\n }\n const model = scope === 'self' ? ctx.selfModel : ctx.resolveReferencedModel();\n // A referenced model in another space can't be resolved here (resolveReferencedModel returns undefined); skip the existence check — it runs where that model is known.\n if (model !== undefined && !Object.hasOwn(model.fields, name)) {\n return notOk([\n leafDiagnostic(ctx, arg, `Field \"${name}\" does not exist on model \"${model.name}\"`),\n ]);\n }\n return ok(name);\n },\n };\n}\n","import type { PslDiagnostic, PslSpan } from '@prisma-next/framework-components/psl-ast';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { nodePslSpan } from '../resolve';\nimport type { FieldAttributeAst, ModelAttributeAst } from '../syntax/ast/attributes';\nimport type { AttributeArgAst } from '../syntax/ast/expressions';\nimport { ATTRIBUTE_DIAGNOSTIC_CODE } from './combinators/diagnostic';\nimport type {\n ArgType,\n AttributeSpec,\n InterpretCtx,\n OptionalArgType,\n Param,\n PositionalParam,\n} from './types';\n\n// The positional/named argument-binding for an attribute or a function call. `name` labels the\n// callee in binding diagnostics (`Attribute \"<name>\" …`); `span` anchors the arity diagnostics\n// (too-many / missing) that have no per-argument node to point at.\nexport interface ArgBindingSpec {\n readonly name: string;\n readonly positional: readonly PositionalParam<unknown>[];\n readonly named: Readonly<Record<string, Param<unknown>>>;\n}\n\nexport function interpretArgs(\n args: Iterable<AttributeArgAst>,\n spec: ArgBindingSpec,\n ctx: InterpretCtx,\n span: PslSpan,\n): Result<Record<string, unknown>, readonly PslDiagnostic[]> {\n const diagnostics: PslDiagnostic[] = [];\n\n const output: Record<string, unknown> = {};\n const seen = new Set<string>();\n let positionalSlot = 0;\n let reportedExcess = false;\n\n for (const arg of args) {\n const name = arg.name()?.name();\n\n let key: string;\n let param: Param<unknown>;\n if (name === undefined) {\n const posParam = spec.positional[positionalSlot];\n if (posParam === undefined) {\n if (!reportedExcess) {\n diagnostics.push(\n diagnostic(\n `Attribute \"${spec.name}\" received too many positional arguments`,\n ctx,\n span,\n ),\n );\n reportedExcess = true;\n }\n continue;\n }\n positionalSlot += 1;\n key = posParam.key;\n param = posParam.type;\n } else {\n const namedParam = Object.hasOwn(spec.named, name) ? spec.named[name] : undefined;\n if (namedParam === undefined) {\n diagnostics.push(\n diagnostic(\n `Attribute \"${spec.name}\" received unknown argument \"${name}\"`,\n ctx,\n nodePslSpan(arg.syntax, ctx.sourceFile),\n ),\n );\n continue;\n }\n key = name;\n param = namedParam;\n }\n\n if (seen.has(key)) {\n diagnostics.push(\n diagnostic(\n `Attribute \"${spec.name}\" received duplicate argument \"${key}\"`,\n ctx,\n nodePslSpan(arg.syntax, ctx.sourceFile),\n ),\n );\n continue;\n }\n seen.add(key);\n const result = parseArgValue(arg, param, ctx, diagnostics);\n if (result.ok) output[key] = result.value;\n }\n\n const finalized = new Set<string>();\n const finalizeAbsentKey = (\n key: string,\n positionalParam: Param<unknown> | undefined,\n namedParam: Param<unknown> | undefined,\n ): void => {\n if (finalized.has(key) || seen.has(key)) return;\n finalized.add(key);\n const effective = namedParam ?? positionalParam;\n if (effective === undefined) return;\n if (isOptionalArgType(effective)) {\n if (effective.hasDefault) output[key] = effective.defaultValue;\n return;\n }\n diagnostics.push(\n diagnostic(`Attribute \"${spec.name}\" is missing required argument \"${key}\"`, ctx, span),\n );\n };\n\n for (const param of spec.positional) {\n const namedParam = Object.hasOwn(spec.named, param.key) ? spec.named[param.key] : undefined;\n finalizeAbsentKey(param.key, param.type, namedParam);\n }\n for (const key of Object.keys(spec.named)) {\n finalizeAbsentKey(key, undefined, spec.named[key]);\n }\n\n if (diagnostics.length > 0) {\n return notOk<readonly PslDiagnostic[]>(diagnostics);\n }\n return ok(output);\n}\n\nexport function interpretAttribute<Out>(\n attrNode: FieldAttributeAst | ModelAttributeAst,\n spec: AttributeSpec<Out>,\n ctx: InterpretCtx,\n): Result<Out, readonly PslDiagnostic[]> {\n const attributeSpan = nodePslSpan(attrNode.syntax, ctx.sourceFile);\n const bound = interpretArgs(attrNode.argList()?.args() ?? [], spec, ctx, attributeSpan);\n if (!bound.ok) return notOk<readonly PslDiagnostic[]>(bound.failure);\n\n const value = blindCast<\n Out,\n 'The engine builds the output object structurally from the spec; TypeScript cannot relate the dynamically-keyed record to the spec-inferred output type.'\n >(bound.value);\n if (spec.refine !== undefined) {\n const refineDiagnostics = spec.refine(value, ctx);\n if (refineDiagnostics.length > 0) {\n return notOk<readonly PslDiagnostic[]>(refineDiagnostics);\n }\n }\n return ok(value);\n}\n\nfunction parseArgValue(\n arg: AttributeArgAst,\n argType: ArgType<unknown>,\n ctx: InterpretCtx,\n diagnostics: PslDiagnostic[],\n): Result<unknown, readonly PslDiagnostic[]> {\n const value = arg.value();\n if (value === undefined) {\n const missing = diagnostic(\n 'Attribute argument is missing a value',\n ctx,\n nodePslSpan(arg.syntax, ctx.sourceFile),\n );\n diagnostics.push(missing);\n return notOk<readonly PslDiagnostic[]>([missing]);\n }\n const result = argType.parse(value, ctx);\n if (!result.ok) {\n for (const failure of result.failure) diagnostics.push(failure);\n }\n return result;\n}\n\nfunction isOptionalArgType(param: Param<unknown>): param is OptionalArgType<unknown> {\n return 'optional' in param && param.optional === true;\n}\n\nfunction diagnostic(message: string, ctx: InterpretCtx, span: PslSpan): PslDiagnostic {\n return { code: ATTRIBUTE_DIAGNOSTIC_CODE, message, sourceId: ctx.sourceId, span };\n}\n","import type { PslDiagnostic, PslSpan } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { nodePslSpan } from '../../resolve';\nimport type { ExpressionAst } from '../../syntax/ast/expressions';\nimport { FunctionCallAst } from '../../syntax/ast/expressions';\nimport { interpretArgs } from '../interpret';\nimport type { ArgType, InterpretCtx, Param, PositionalParam } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\n// The argument signature of a pinned function call — the same positional/named shape an attribute\n// spec uses. Omitted groups default to empty, so a nullary call needs neither key.\nexport interface FuncCallSig {\n readonly positional?: readonly PositionalParam<unknown>[];\n readonly named?: Readonly<Record<string, Param<unknown>>>;\n}\n\nexport interface TypedFuncCall {\n readonly fn: string;\n readonly span: PslSpan;\n readonly args: Readonly<Record<string, unknown>>;\n}\n\n// A name-pinned function-call argument — `funcCall('now', {})` matches `now()`, parsing the call's\n// arguments through `sig`.\nexport function funcCall(name: string, sig: FuncCallSig): ArgType<TypedFuncCall> {\n return {\n kind: 'funcCall',\n label: 'function call',\n parse: (arg, ctx): Result<TypedFuncCall, readonly PslDiagnostic[]> => {\n const guard = matchCallee(arg, name, ctx);\n if (!guard.ok) return guard;\n const span = nodePslSpan(guard.value.syntax, ctx.sourceFile);\n const bound = interpretArgs(\n guard.value.args(),\n { name, positional: sig.positional ?? [], named: sig.named ?? {} },\n ctx,\n span,\n );\n if (!bound.ok) return notOk<readonly PslDiagnostic[]>(bound.failure);\n return ok({ fn: name, span, args: bound.value });\n },\n };\n}\n\nfunction matchCallee(\n arg: ExpressionAst,\n name: string,\n ctx: InterpretCtx,\n): Result<FunctionCallAst, readonly PslDiagnostic[]> {\n if (!(arg instanceof FunctionCallAst)) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a function call')]);\n }\n const qname = arg.name();\n if (qname === undefined || qname.dot() !== undefined || qname.colon() !== undefined) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a function call')]);\n }\n const calleeName = qname.identifier()?.token()?.text;\n if (calleeName === undefined) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a function call')]);\n }\n if (calleeName !== name) {\n return notOk([leafDiagnostic(ctx, arg, `Expected ${name}()`)]);\n }\n return ok(arg);\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { IdentifierAst } from '../../syntax/ast/identifier';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport function identifier<const N extends string>(name: N): ArgType<N> {\n return {\n kind: 'identifier',\n label: name,\n parse: (arg, ctx): Result<N, readonly PslDiagnostic[]> => {\n if (arg instanceof IdentifierAst && arg.name() === name) return ok(name);\n return notOk([leafDiagnostic(ctx, arg, `Expected ${name}`)]);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { NumberLiteralExprAst } from '../../syntax/ast/expressions';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\n// An integer literal reduced to its numeric value. Passing `min`/`max` additionally rejects\n// out-of-range integers with a distinct range message, leaving the integer-only check intact.\nexport function int(opts?: { min?: number; max?: number }): ArgType<number> {\n const min = opts?.min;\n const max = opts?.max;\n return {\n kind: 'int',\n label: 'integer',\n parse: (arg, ctx): Result<number, readonly PslDiagnostic[]> => {\n if (arg instanceof NumberLiteralExprAst) {\n const value = arg.value();\n if (value !== undefined && Number.isInteger(value)) {\n if ((min === undefined || value >= min) && (max === undefined || value <= max)) {\n return ok(value);\n }\n return notOk([leafDiagnostic(ctx, arg, rangeMessage(min, max))]);\n }\n }\n return notOk([leafDiagnostic(ctx, arg, 'Expected an integer literal')]);\n },\n };\n}\n\nfunction rangeMessage(min: number | undefined, max: number | undefined): string {\n if (min !== undefined && max !== undefined)\n return `Expected an integer between ${min} and ${max}`;\n if (min !== undefined) return `Expected an integer greater than or equal to ${min}`;\n return `Expected an integer less than or equal to ${max}`;\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { ArrayLiteralAst, type ExpressionAst } from '../../syntax/ast/expressions';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport interface ListOptions {\n readonly nonEmpty?: boolean;\n readonly unique?: boolean;\n}\n\nexport function list<T>(of: ArgType<T>, opts?: ListOptions): ArgType<T[]> {\n return {\n kind: 'list',\n label: `${of.label}[]`,\n parse: (arg, ctx): Result<T[], readonly PslDiagnostic[]> => {\n if (!(arg instanceof ArrayLiteralAst)) {\n return notOk([leafDiagnostic(ctx, arg, `Expected a list of ${of.label}`)]);\n }\n const diagnostics: PslDiagnostic[] = [];\n const parsed: { node: ExpressionAst; value: T }[] = [];\n let count = 0;\n for (const element of arg.elements()) {\n count += 1;\n const result = of.parse(element, ctx);\n if (result.ok) parsed.push({ node: element, value: result.value });\n else diagnostics.push(...result.failure);\n }\n if (opts?.nonEmpty === true && count === 0) {\n diagnostics.push(leafDiagnostic(ctx, arg, 'Expected a non-empty list'));\n }\n if (opts?.unique === true) {\n const seen = new Set<T>();\n for (const { node, value } of parsed) {\n if (seen.has(value)) diagnostics.push(leafDiagnostic(ctx, node, 'Duplicate list entry'));\n else seen.add(value);\n }\n }\n if (diagnostics.length > 0) return notOk(diagnostics);\n return ok(parsed.map((entry) => entry.value));\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { NumberLiteralExprAst } from '../../syntax/ast/expressions';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\n// A general number literal — any number, including floats — reduced to its numeric value.\n// Passing `value` pins the combinator to that single literal (`num(4)` matches only `4`),\n// mirroring how `identifier(name)` pins a bare identifier. Use `int()` when only integer\n// literals are allowed.\nexport function num(): ArgType<number>;\nexport function num(value: number): ArgType<number>;\nexport function num(value?: number): ArgType<number> {\n return {\n kind: 'num',\n label: value === undefined ? 'number' : String(value),\n parse: (arg, ctx): Result<number, readonly PslDiagnostic[]> => {\n if (arg instanceof NumberLiteralExprAst) {\n const parsed = arg.value();\n if (parsed !== undefined && (value === undefined || parsed === value)) return ok(parsed);\n }\n const message = value === undefined ? 'Expected a number literal' : `Expected ${value}`;\n return notOk([leafDiagnostic(ctx, arg, message)]);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport type { ArgType, OutOf } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport function oneOf<Alts extends readonly [ArgType<unknown>, ...ArgType<unknown>[]]>(\n ...alts: Alts\n): ArgType<OutOf<Alts[number]>> {\n const label = alts.map((alt) => alt.label).join(' | ');\n return {\n kind: 'oneOf',\n label,\n parse: (arg, ctx): Result<OutOf<Alts[number]>, readonly PslDiagnostic[]> => {\n for (const alt of alts) {\n const result = alt.parse(arg, ctx);\n if (result.ok) {\n return ok(\n blindCast<\n OutOf<Alts[number]>,\n 'The matched value comes from an alternative whose output type is a member of the union, but iterating the tuple widens each element to ArgType<unknown>, erasing that relationship.'\n >(result.value),\n );\n }\n }\n return notOk([leafDiagnostic(ctx, arg, `Expected one of: ${label}`)]);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { ObjectLiteralExprAst } from '../../syntax/ast/expressions';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport function record<T>(of: ArgType<T>): ArgType<Record<string, T>> {\n return {\n kind: 'record',\n label: `{ [key]: ${of.label} }`,\n parse: (arg, ctx): Result<Record<string, T>, readonly PslDiagnostic[]> => {\n if (!(arg instanceof ObjectLiteralExprAst)) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected an object literal')]);\n }\n const diagnostics: PslDiagnostic[] = [];\n const result: Record<string, T> = {};\n for (const field of arg.fields()) {\n const key = field.keyName();\n if (key === undefined) {\n diagnostics.push(leafDiagnostic(ctx, field, 'Expected a key'));\n continue;\n }\n const value = field.value();\n if (value === undefined) {\n diagnostics.push(leafDiagnostic(ctx, field, `Expected a value for key \"${key}\"`));\n continue;\n }\n const parsed = of.parse(value, ctx);\n if (!parsed.ok) {\n diagnostics.push(...parsed.failure);\n continue;\n }\n if (Object.hasOwn(result, key)) {\n diagnostics.push(leafDiagnostic(ctx, field, `Duplicate key \"${key}\"`));\n continue;\n }\n result[key] = parsed.value;\n }\n if (diagnostics.length > 0) return notOk(diagnostics);\n return ok(result);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { StringLiteralExprAst } from '../../syntax/ast/expressions';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport function str(): ArgType<string> {\n return {\n kind: 'str',\n label: 'string',\n parse: (arg, ctx): Result<string, readonly PslDiagnostic[]> => {\n if (arg instanceof StringLiteralExprAst) {\n const value = arg.value();\n if (value !== undefined) return ok(value);\n }\n return notOk([leafDiagnostic(ctx, arg, 'Expected a string literal')]);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport type { AttributeOut, AttributeSpec, InterpretCtx, Param, PositionalParam } from './types';\n\ninterface FieldAttributeConfig<\n Pos extends readonly PositionalParam[],\n Named extends Record<string, Param<unknown>>,\n> {\n readonly positional?: Pos;\n readonly named?: Named;\n readonly refine?: (\n parsed: AttributeOut<Pos, Named>,\n ctx: InterpretCtx,\n ) => readonly PslDiagnostic[];\n}\n\nexport function fieldAttribute<\n const Pos extends readonly PositionalParam[] = readonly [],\n const Named extends Record<string, Param<unknown>> = Record<never, never>,\n>(name: string, config: FieldAttributeConfig<Pos, Named>): AttributeSpec<AttributeOut<Pos, Named>> {\n return {\n level: 'field',\n name,\n positional: config.positional ?? [],\n named: config.named ?? {},\n ...(config.refine !== undefined ? { refine: config.refine } : {}),\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport type { AttributeOut, AttributeSpec, InterpretCtx, Param, PositionalParam } from './types';\n\ninterface ModelAttributeConfig<\n Pos extends readonly PositionalParam[],\n Named extends Record<string, Param<unknown>>,\n> {\n readonly positional?: Pos;\n readonly named?: Named;\n readonly refine?: (\n parsed: AttributeOut<Pos, Named>,\n ctx: InterpretCtx,\n ) => readonly PslDiagnostic[];\n}\n\nexport function modelAttribute<\n const Pos extends readonly PositionalParam[] = readonly [],\n const Named extends Record<string, Param<unknown>> = Record<never, never>,\n>(name: string, config: ModelAttributeConfig<Pos, Named>): AttributeSpec<AttributeOut<Pos, Named>> {\n return {\n level: 'model',\n name,\n positional: config.positional ?? [],\n named: config.named ?? {},\n ...(config.refine !== undefined ? { refine: config.refine } : {}),\n };\n}\n","import type { ArgType, OptionalArgType } from './types';\n\nexport function optional<T>(type: ArgType<T>, ...rest: [defaultValue: T] | []): OptionalArgType<T> {\n if (rest.length === 0) {\n return { ...type, optional: true, hasDefault: false };\n }\n return { ...type, optional: true, hasDefault: true, defaultValue: rest[0] };\n}\n","import {\n type AuthoringPslBlockDescriptor,\n type AuthoringPslBlockDescriptorNamespace,\n isAuthoringPslBlockDescriptor,\n} from '@prisma-next/framework-components/authoring';\nimport type { CodecLookup } from '@prisma-next/framework-components/codec';\nimport {\n makePslNamespace,\n makePslNamespaceEntries,\n type PslDiagnostic,\n type PslModel,\n type PslSpan,\n UNSPECIFIED_PSL_NAMESPACE_ID,\n validateExtensionBlock,\n} from '@prisma-next/framework-components/psl-ast';\nimport type { SourceFile } from './source-file';\nimport type { BlockSymbol, ModelSymbol, SymbolTable } from './symbol-table';\n\nexport function findBlockDescriptor(\n descriptors: AuthoringPslBlockDescriptorNamespace | undefined,\n keyword: string,\n): AuthoringPslBlockDescriptor | undefined {\n if (descriptors === undefined) return undefined;\n for (const value of Object.values(descriptors)) {\n if (value === undefined) continue;\n if (isAuthoringPslBlockDescriptor(value)) {\n if (value.keyword === keyword) return value;\n continue;\n }\n const nested = findBlockDescriptor(value, keyword);\n if (nested !== undefined) return nested;\n }\n return undefined;\n}\n\nexport function validateExtensionBlockFromSymbol(input: {\n readonly block: BlockSymbol;\n readonly descriptor: AuthoringPslBlockDescriptor;\n readonly symbolTable: SymbolTable;\n readonly sourceFile: SourceFile;\n readonly sourceId: string;\n readonly codecLookup: CodecLookup;\n}): readonly PslDiagnostic[] {\n const refCtx = buildRefResolutionContext(input.symbolTable, input.block);\n return validateExtensionBlock(\n input.block.block,\n input.descriptor,\n input.sourceId,\n input.codecLookup,\n refCtx,\n );\n}\n\nconst ZERO_SPAN: PslSpan = {\n start: { offset: 0, line: 1, column: 1 },\n end: { offset: 0, line: 1, column: 1 },\n};\n\nfunction buildRefResolutionContext(\n symbolTable: SymbolTable,\n block: BlockSymbol,\n): {\n ownerNamespace: ReturnType<typeof makePslNamespace>;\n allNamespaces: readonly ReturnType<typeof makePslNamespace>[];\n} {\n const unspecifiedNamespace = makeNamespace(\n UNSPECIFIED_PSL_NAMESPACE_ID,\n Object.values(symbolTable.topLevel.models),\n );\n const namedNamespaces = Object.values(symbolTable.topLevel.namespaces).map((namespace) =>\n makeNamespace(namespace.name, Object.values(namespace.models)),\n );\n const allNamespaces = [unspecifiedNamespace, ...namedNamespaces];\n const ownerNamespaceName = findOwnerNamespaceName(symbolTable, block);\n const ownerNamespace =\n allNamespaces.find((namespace) => namespace.name === ownerNamespaceName) ??\n unspecifiedNamespace;\n return { ownerNamespace, allNamespaces };\n}\n\nfunction makeNamespace(\n name: string,\n models: readonly ModelSymbol[],\n): ReturnType<typeof makePslNamespace> {\n const modelStubs: PslModel[] = models.map((model) => ({\n kind: 'model',\n name: model.name,\n fields: [],\n attributes: [],\n span: ZERO_SPAN,\n }));\n return makePslNamespace({\n kind: 'namespace',\n name,\n entries: makePslNamespaceEntries(modelStubs, [], []),\n span: ZERO_SPAN,\n });\n}\n\nfunction findOwnerNamespaceName(symbolTable: SymbolTable, block: BlockSymbol): string {\n for (const namespace of Object.values(symbolTable.topLevel.namespaces)) {\n if (Object.values(namespace.blocks).some((candidate) => candidate === block)) {\n return namespace.name;\n }\n }\n return UNSPECIFIED_PSL_NAMESPACE_ID;\n}\n","import type { AuthoringPslBlockDescriptor } from '@prisma-next/framework-components/authoring';\nimport type {\n PslBlockParam,\n PslExtensionBlock,\n PslExtensionBlockAttribute,\n PslExtensionBlockParamValue,\n PslSpan,\n} from '@prisma-next/framework-components/psl-ast';\nimport type { ParseDiagnostic } from './parse';\nimport { nodePslSpan } from './resolve';\nimport type { SourceFile } from './source-file';\nimport type { GenericBlockDeclarationAst, KeyValuePairAst } from './syntax/ast/declarations';\nimport { ArrayLiteralAst, type ExpressionAst } from './syntax/ast/expressions';\nimport { printSyntax } from './syntax/ast-helpers';\n\n/**\n * Descriptor-free and unknown parameters become `value` stubs so validation can\n * report them via key-set comparison. Duplicate member names are first-wins.\n */\nexport function reconstructExtensionBlock(\n node: GenericBlockDeclarationAst,\n descriptor: AuthoringPslBlockDescriptor | undefined,\n sourceFile: SourceFile,\n diagnostics: ParseDiagnostic[],\n): PslExtensionBlock {\n const keyword = node.keyword()?.text ?? '';\n const blockName = node.name()?.name() ?? '';\n\n const blockAttributes: PslExtensionBlockAttribute[] = [];\n for (const attribute of node.attributes()) {\n const name = attribute.name()?.path().join('.') ?? '';\n const args = Array.from(attribute.argList()?.args() ?? [], (arg) => {\n const value = arg.value();\n return {\n kind: 'positional' as const,\n value: value === undefined ? '' : printSyntax(value.syntax).trim(),\n span: nodePslSpan(arg.syntax, sourceFile),\n };\n });\n blockAttributes.push({\n name,\n args,\n span: nodePslSpan(attribute.syntax, sourceFile),\n });\n }\n\n const parameters: Record<string, PslExtensionBlockParamValue> = {};\n for (const entry of node.entries()) {\n const key = entry.key()?.name();\n if (key === undefined) continue;\n const span = nodePslSpan(entry.syntax, sourceFile);\n if (Object.hasOwn(parameters, key)) {\n diagnostics.push({\n code: 'PSL_EXTENSION_DUPLICATE_PARAMETER',\n message: `Duplicate parameter \"${key}\" in \"${keyword}\" block \"${blockName}\"; first occurrence wins`,\n range: {\n start: sourceFile.positionAt(entry.syntax.offset),\n end: sourceFile.positionAt(entry.syntax.offset + entry.syntax.green.textLength),\n },\n });\n continue;\n }\n parameters[key] = reconstructParamValue(\n entry,\n descriptor?.parameters[key],\n span,\n sourceFile,\n diagnostics,\n );\n }\n\n return {\n kind: descriptor?.discriminator ?? keyword,\n keyword,\n name: blockName,\n parameters,\n blockAttributes,\n span: nodePslSpan(node.syntax, sourceFile),\n };\n}\n\nfunction reconstructParamValue(\n entry: KeyValuePairAst,\n param: PslBlockParam | undefined,\n span: PslSpan,\n sourceFile: SourceFile,\n diagnostics: ParseDiagnostic[],\n): PslExtensionBlockParamValue {\n const value = entry.value();\n if (value === undefined) {\n return { kind: 'bare', span };\n }\n return reconstructFromExpression(value, param, span, sourceFile, diagnostics);\n}\n\nfunction reconstructFromExpression(\n value: ExpressionAst,\n param: PslBlockParam | undefined,\n span: PslSpan,\n sourceFile: SourceFile,\n diagnostics?: ParseDiagnostic[],\n): PslExtensionBlockParamValue {\n const raw = printSyntax(value.syntax).trim();\n if (param?.kind === 'list') {\n const array = ArrayLiteralAst.cast(value.syntax);\n if (!array) {\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `List parameter expects an array literal, got ${raw}`,\n range: {\n start: sourceFile.positionAt(value.syntax.offset),\n end: sourceFile.positionAt(value.syntax.offset + value.syntax.green.textLength),\n },\n });\n return { kind: 'value', raw, span };\n }\n\n const items: PslExtensionBlockParamValue[] = [];\n for (const element of array.elements()) {\n items.push(\n reconstructFromExpression(\n element,\n param.of,\n nodePslSpan(element.syntax, sourceFile),\n sourceFile,\n diagnostics,\n ),\n );\n }\n return { kind: 'list', items, span };\n }\n switch (param?.kind) {\n case 'ref':\n return { kind: 'ref', identifier: raw, span };\n case 'option':\n return { kind: 'option', token: raw, span };\n default:\n return { kind: 'value', raw, span };\n }\n}\n","import type { AuthoringPslBlockDescriptorNamespace } from '@prisma-next/framework-components/authoring';\nimport type { PslExtensionBlock, PslSpan } from '@prisma-next/framework-components/psl-ast';\nimport { reconstructExtensionBlock } from './block-reconstruction';\nimport { findBlockDescriptor } from './extension-block';\nimport type { ParseDiagnostic } from './parse';\nimport {\n nodePslSpan,\n type ResolvedAttribute,\n type ResolvedTypeConstructorCall,\n readResolvedAttributes,\n readResolvedConstructorCall,\n} from './resolve';\nimport type { Range, SourceFile } from './source-file';\nimport {\n CompositeTypeDeclarationAst,\n type DocumentAst,\n type FieldDeclarationAst,\n GenericBlockDeclarationAst,\n ModelDeclarationAst,\n type NamedTypeDeclarationAst,\n NamespaceDeclarationAst,\n TypesBlockAst,\n} from './syntax/ast/declarations';\nimport type { IdentifierAst } from './syntax/ast/identifier';\nimport type { SyntaxNode } from './syntax/red';\n\nexport type {\n ResolvedAttribute,\n ResolvedAttributeArg,\n ResolvedTypeConstructorCall,\n} from './resolve';\n\nexport interface SymbolTable {\n readonly topLevel: TopLevelScope;\n}\n\nexport interface TopLevelScope {\n readonly namespaces: Record<string, NamespaceSymbol>;\n readonly scalars: Record<string, ScalarSymbol>;\n readonly typeAliases: Record<string, TypeAliasSymbol>;\n readonly blocks: Record<string, BlockSymbol>;\n readonly models: Record<string, ModelSymbol>;\n readonly compositeTypes: Record<string, CompositeTypeSymbol>;\n}\n\nexport interface NamespaceSymbol {\n readonly kind: 'namespace';\n readonly name: string;\n readonly node: NamespaceDeclarationAst;\n readonly span: PslSpan;\n readonly models: Record<string, ModelSymbol>;\n readonly compositeTypes: Record<string, CompositeTypeSymbol>;\n readonly blocks: Record<string, BlockSymbol>;\n}\n\nexport interface ModelSymbol {\n readonly kind: 'model';\n readonly name: string;\n readonly node: ModelDeclarationAst;\n readonly span: PslSpan;\n readonly fields: Record<string, FieldSymbol>;\n readonly attributes: readonly ResolvedAttribute[];\n}\n\nexport interface CompositeTypeSymbol {\n readonly kind: 'compositeType';\n readonly name: string;\n readonly node: CompositeTypeDeclarationAst;\n readonly span: PslSpan;\n readonly fields: Record<string, FieldSymbol>;\n readonly attributes: readonly ResolvedAttribute[];\n}\n\nexport interface BlockSymbol {\n readonly kind: 'block';\n readonly name: string;\n readonly keyword: string;\n readonly node: GenericBlockDeclarationAst;\n readonly span: PslSpan;\n /** Resolved once so consumers do not independently classify block parameters. */\n readonly block: PslExtensionBlock;\n}\n\nexport interface ResolvedNamedTypeBinding {\n readonly baseType?: string;\n readonly typeConstructor?: ResolvedTypeConstructorCall;\n readonly isConstructor: boolean;\n readonly attributes: readonly ResolvedAttribute[];\n}\n\nexport interface ScalarSymbol extends ResolvedNamedTypeBinding {\n readonly kind: 'scalar';\n readonly name: string;\n readonly node: NamedTypeDeclarationAst;\n readonly span: PslSpan;\n}\n\nexport interface TypeAliasSymbol extends ResolvedNamedTypeBinding {\n readonly kind: 'typeAlias';\n readonly name: string;\n readonly node: NamedTypeDeclarationAst;\n readonly span: PslSpan;\n}\n\nexport interface FieldSymbol {\n readonly kind: 'field';\n readonly name: string;\n readonly node: FieldDeclarationAst;\n readonly span: PslSpan;\n readonly typeName: string;\n readonly typeNamespaceId?: string;\n readonly typeContractSpaceId?: string;\n readonly optional: boolean;\n readonly list: boolean;\n readonly typeConstructor?: ResolvedTypeConstructorCall;\n readonly attributes: readonly ResolvedAttribute[];\n /** Prevents cascading unsupported-type diagnostics after invalid qualification. */\n readonly malformedType?: boolean;\n}\n\nexport interface BuildSymbolTableOptions {\n readonly document: DocumentAst;\n readonly sourceFile: SourceFile;\n readonly scalarTypes: readonly string[];\n readonly pslBlockDescriptors: AuthoringPslBlockDescriptorNamespace;\n}\n\nexport interface SymbolTableResult {\n readonly table: SymbolTable;\n readonly diagnostics: readonly ParseDiagnostic[];\n}\n\n/**\n * Owns duplicate-declaration detection for all PSL scopes; downstream consumers\n * should consume first-wins symbols rather than re-emitting duplicate diagnostics.\n */\nexport function buildSymbolTable(options: BuildSymbolTableOptions): SymbolTableResult {\n const { document, sourceFile, scalarTypes, pslBlockDescriptors } = options;\n const diagnostics: ParseDiagnostic[] = [];\n const scalarSet = new Set(scalarTypes);\n\n const namespaces: Record<string, NamespaceSymbol> = {};\n const scalars: Record<string, ScalarSymbol> = {};\n const typeAliases: Record<string, TypeAliasSymbol> = {};\n const blocks: Record<string, BlockSymbol> = {};\n const models: Record<string, ModelSymbol> = {};\n const compositeTypes: Record<string, CompositeTypeSymbol> = {};\n const topLevelNames = new Set<string>();\n\n const claim = (taken: Set<string>, name: IdentifierAst | undefined): string | undefined => {\n const text = name?.name();\n if (text === undefined) return undefined;\n if (taken.has(text)) {\n const range = nameRange(name, sourceFile);\n if (range) {\n diagnostics.push({\n code: 'PSL_DUPLICATE_DECLARATION',\n message: `Duplicate declaration of \"${text}\"`,\n range,\n });\n }\n return undefined;\n }\n taken.add(text);\n return text;\n };\n\n for (const declaration of document.declarations()) {\n if (declaration instanceof ModelDeclarationAst) {\n const name = claim(topLevelNames, declaration.name());\n if (name !== undefined) models[name] = buildModel(name, declaration, sourceFile, diagnostics);\n } else if (declaration instanceof CompositeTypeDeclarationAst) {\n const name = claim(topLevelNames, declaration.name());\n if (name !== undefined) {\n compositeTypes[name] = buildCompositeType(name, declaration, sourceFile, diagnostics);\n }\n } else if (declaration instanceof GenericBlockDeclarationAst) {\n const name = claim(topLevelNames, declaration.name());\n if (name !== undefined) {\n blocks[name] = buildBlock(name, declaration, sourceFile, pslBlockDescriptors, diagnostics);\n }\n } else if (declaration instanceof NamespaceDeclarationAst) {\n const name = claim(topLevelNames, declaration.name());\n if (name !== undefined) {\n namespaces[name] = buildNamespace(\n name,\n declaration,\n diagnostics,\n sourceFile,\n pslBlockDescriptors,\n );\n }\n } else if (declaration instanceof TypesBlockAst) {\n for (const binding of declaration.declarations()) {\n const name = claim(topLevelNames, binding.name());\n if (name === undefined) continue;\n const resolved = resolveNamedTypeBinding(binding, sourceFile);\n const span = nodePslSpan(binding.syntax, sourceFile);\n if (isScalarBinding(binding, scalarSet)) {\n scalars[name] = { kind: 'scalar', name, node: binding, span, ...resolved };\n } else {\n typeAliases[name] = { kind: 'typeAlias', name, node: binding, span, ...resolved };\n }\n }\n }\n }\n\n const table: SymbolTable = {\n topLevel: { namespaces, scalars, typeAliases, blocks, models, compositeTypes },\n };\n return { table, diagnostics };\n}\n\nfunction buildModel(\n name: string,\n node: ModelDeclarationAst,\n sourceFile: SourceFile,\n diagnostics: ParseDiagnostic[],\n): ModelSymbol {\n return {\n kind: 'model',\n name,\n node,\n span: nodePslSpan(node.syntax, sourceFile),\n fields: buildFields(name, node.fields(), sourceFile, diagnostics),\n attributes: readResolvedAttributes(node.attributes(), sourceFile),\n };\n}\n\nfunction buildCompositeType(\n name: string,\n node: CompositeTypeDeclarationAst,\n sourceFile: SourceFile,\n diagnostics: ParseDiagnostic[],\n): CompositeTypeSymbol {\n return {\n kind: 'compositeType',\n name,\n node,\n span: nodePslSpan(node.syntax, sourceFile),\n fields: buildFields(name, node.fields(), sourceFile, diagnostics),\n attributes: readResolvedAttributes(node.attributes(), sourceFile),\n };\n}\n\nfunction buildBlock(\n name: string,\n node: GenericBlockDeclarationAst,\n sourceFile: SourceFile,\n pslBlockDescriptors: AuthoringPslBlockDescriptorNamespace,\n diagnostics: ParseDiagnostic[],\n): BlockSymbol {\n const keyword = node.keyword()?.text ?? '';\n const descriptor = findBlockDescriptor(pslBlockDescriptors, keyword);\n return {\n kind: 'block',\n name,\n keyword,\n node,\n span: nodePslSpan(node.syntax, sourceFile),\n block: reconstructExtensionBlock(node, descriptor, sourceFile, diagnostics),\n };\n}\n\nfunction buildNamespace(\n name: string,\n node: NamespaceDeclarationAst,\n diagnostics: ParseDiagnostic[],\n sourceFile: SourceFile,\n pslBlockDescriptors: AuthoringPslBlockDescriptorNamespace,\n): NamespaceSymbol {\n const models: Record<string, ModelSymbol> = {};\n const compositeTypes: Record<string, CompositeTypeSymbol> = {};\n const blocks: Record<string, BlockSymbol> = {};\n const taken = new Set<string>();\n\n for (const member of node.declarations()) {\n const memberName = member.name()?.name();\n if (memberName === undefined) continue;\n if (taken.has(memberName)) {\n const range = nameRange(member.name(), sourceFile);\n if (range) {\n diagnostics.push({\n code: 'PSL_DUPLICATE_DECLARATION',\n message: `Duplicate declaration of \"${memberName}\"`,\n range,\n });\n }\n continue;\n }\n taken.add(memberName);\n if (member instanceof ModelDeclarationAst) {\n models[memberName] = buildModel(memberName, member, sourceFile, diagnostics);\n } else if (member instanceof CompositeTypeDeclarationAst) {\n compositeTypes[memberName] = buildCompositeType(memberName, member, sourceFile, diagnostics);\n } else if (member instanceof GenericBlockDeclarationAst) {\n blocks[memberName] = buildBlock(\n memberName,\n member,\n sourceFile,\n pslBlockDescriptors,\n diagnostics,\n );\n }\n }\n\n return {\n kind: 'namespace',\n name,\n node,\n span: nodePslSpan(node.syntax, sourceFile),\n models,\n compositeTypes,\n blocks,\n };\n}\n\nfunction buildFields(\n ownerName: string,\n fields: Iterable<FieldDeclarationAst>,\n sourceFile: SourceFile,\n diagnostics: ParseDiagnostic[],\n): Record<string, FieldSymbol> {\n const result: Record<string, FieldSymbol> = {};\n for (const field of fields) {\n const nameNode = field.name();\n const name = nameNode?.name();\n if (name === undefined) continue;\n if (Object.hasOwn(result, name)) {\n const range = nameRange(nameNode, sourceFile);\n if (range) {\n diagnostics.push({\n code: 'PSL_DUPLICATE_DECLARATION',\n message: `Duplicate declaration of \"${name}\"`,\n range,\n });\n }\n continue;\n }\n result[name] = buildField(ownerName, name, field, sourceFile, diagnostics);\n }\n return result;\n}\n\nfunction buildField(\n ownerName: string,\n name: string,\n node: FieldDeclarationAst,\n sourceFile: SourceFile,\n diagnostics: ParseDiagnostic[],\n): FieldSymbol {\n const attributes = readResolvedAttributes(node.attributes(), sourceFile);\n const span = nodePslSpan(node.syntax, sourceFile);\n const annotation = node.typeAnnotation();\n const typeName = annotation?.name();\n\n if (typeName?.isOverQualified()) {\n const path = typeName.path();\n diagnostics.push({\n code: 'PSL_INVALID_QUALIFIED_TYPE',\n message: `Field \"${ownerName}.${name}\" has an invalid qualified type \"${path.join('.')}\"; use at most one namespace qualifier (e.g. \"ns.TypeName\")`,\n range: nodeRange(typeName.syntax, sourceFile),\n });\n return {\n kind: 'field',\n name,\n node,\n span,\n typeName: path[path.length - 1] ?? '',\n optional: false,\n list: false,\n malformedType: true,\n attributes,\n };\n }\n\n const typeConstructor = annotation?.isConstructor()\n ? readResolvedConstructorCall(annotation, sourceFile)\n : undefined;\n const typeNamespaceId = typeName?.namespace()?.name();\n const typeContractSpaceId = typeName?.space()?.name();\n\n return {\n kind: 'field',\n name,\n node,\n span,\n typeName: typeName?.identifier()?.name() ?? '',\n ...(typeNamespaceId !== undefined ? { typeNamespaceId } : {}),\n ...(typeContractSpaceId !== undefined ? { typeContractSpaceId } : {}),\n optional: annotation?.isOptional() ?? false,\n list: annotation?.isList() ?? false,\n ...(typeConstructor !== undefined ? { typeConstructor } : {}),\n attributes,\n };\n}\n\nfunction resolveNamedTypeBinding(\n node: NamedTypeDeclarationAst,\n sourceFile: SourceFile,\n): {\n baseType?: string;\n typeConstructor?: ResolvedTypeConstructorCall;\n isConstructor: boolean;\n attributes: readonly ResolvedAttribute[];\n} {\n const annotation = node.typeAnnotation();\n const isConstructor = annotation?.isConstructor() ?? false;\n const baseType = annotation?.name()?.identifier()?.name();\n const typeConstructor = readResolvedConstructorCall(annotation, sourceFile);\n return {\n isConstructor,\n ...(!isConstructor && baseType !== undefined ? { baseType } : {}),\n ...(typeConstructor !== undefined ? { typeConstructor } : {}),\n attributes: readResolvedAttributes(node.attributes(), sourceFile),\n };\n}\n\nfunction isScalarBinding(node: NamedTypeDeclarationAst, scalarTypes: Set<string>): boolean {\n const annotation = node.typeAnnotation();\n if (annotation === undefined || annotation.isConstructor()) return false;\n const base = annotation.name()?.identifier()?.name();\n return base !== undefined && scalarTypes.has(base);\n}\n\nfunction nameRange(name: IdentifierAst | undefined, sourceFile: SourceFile): Range | undefined {\n if (name === undefined) return undefined;\n for (const token of name.syntax.tokens()) {\n if (token.kind === 'Ident') {\n return {\n start: sourceFile.positionAt(token.offset),\n end: sourceFile.positionAt(token.offset + token.text.length),\n };\n }\n }\n return undefined;\n}\n\nfunction nodeRange(node: SyntaxNode, sourceFile: SourceFile): Range {\n const start = node.offset;\n const end = start + node.green.textLength;\n return {\n start: sourceFile.positionAt(start),\n end: sourceFile.positionAt(end),\n };\n}\n"],"mappings":";;;;;;AAEA,SAAgB,sBAAsB,WAAyB,QAAQ,GAAuB;CAE5F,OADgB,UAAU,KAAK,QAA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SAAS,KAAA,KAAa,YAAY,IAAI,IAAI;AACnD;AAEA,SAAS,UAAU,MAAiC,YAA2C;CAC7F,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;CAC/B,KAAK,MAAM,SAAS,KAAK,OAAO,OAAO,GACrC,IAAI,MAAM,SAAS,SACjB,OAAO;EACL,OAAO,WAAW,WAAW,MAAM,MAAM;EACzC,KAAK,WAAW,WAAW,MAAM,SAAS,MAAM,KAAK,MAAM;CAC7D;AAIN;AAEA,SAAS,UAAU,MAAkB,YAA+B;CAClE,MAAM,QAAQ,KAAK;CACnB,MAAM,MAAM,QAAQ,KAAK,MAAM;CAC/B,OAAO;EACL,OAAO,WAAW,WAAW,KAAK;EAClC,KAAK,WAAW,WAAW,GAAG;CAChC;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/attribute-helpers.ts","../src/resolve.ts","../src/attribute-spec/combinators/diagnostic.ts","../src/attribute-spec/combinators/bool.ts","../src/attribute-spec/combinators/entity-ref.ts","../src/attribute-spec/combinators/field-ref.ts","../src/attribute-spec/interpret.ts","../src/attribute-spec/combinators/func-call.ts","../src/attribute-spec/combinators/identifier.ts","../src/attribute-spec/combinators/int.ts","../src/attribute-spec/combinators/list.ts","../src/attribute-spec/combinators/num.ts","../src/attribute-spec/combinators/one-of.ts","../src/attribute-spec/combinators/record.ts","../src/attribute-spec/combinators/str.ts","../src/attribute-spec/field-attribute.ts","../src/attribute-spec/model-attribute.ts","../src/attribute-spec/optional.ts","../src/extension-block.ts","../src/block-reconstruction.ts","../src/symbol-table.ts"],"sourcesContent":["import type { PslAttribute } from '@prisma-next/framework-components/psl-ast';\n\nexport function getPositionalArgument(attribute: PslAttribute, index = 0): string | undefined {\n const entries = attribute.args.filter((arg) => arg.kind === 'positional');\n return entries[index]?.value;\n}\n\nexport function parseQuotedStringLiteral(value: string): string | undefined {\n const trimmed = value.trim();\n const match = trimmed.match(/^(['\"])(.*)\\1$/);\n if (!match) return undefined;\n return match[2] ?? '';\n}\n","import type { PslSpan } from '@prisma-next/framework-components/psl-ast';\nimport type { Position, Range, SourceFile } from './source-file';\nimport type {\n AttributeArgListAst,\n FieldAttributeAst,\n ModelAttributeAst,\n} from './syntax/ast/attributes';\nimport type { ExpressionAst } from './syntax/ast/expressions';\nimport type { QualifiedNameAst } from './syntax/ast/qualified-name';\nimport type { TypeAnnotationAst } from './syntax/ast/type-annotation';\nimport { printSyntax } from './syntax/ast-helpers';\nimport type { SyntaxNode } from './syntax/red';\n\nexport interface ResolvedAttributeArg {\n readonly kind: 'positional' | 'named';\n readonly name?: string;\n readonly value: string;\n readonly expression?: ExpressionAst;\n readonly span: PslSpan;\n}\n\nexport interface ResolvedAttribute {\n readonly name: string;\n readonly args: readonly ResolvedAttributeArg[];\n readonly span: PslSpan;\n}\n\nexport interface ResolvedTypeConstructorCall {\n readonly path: readonly string[];\n readonly args: readonly ResolvedAttributeArg[];\n readonly span: PslSpan;\n}\n\nexport function readResolvedAttribute(\n attribute: FieldAttributeAst | ModelAttributeAst,\n sourceFile: SourceFile,\n): ResolvedAttribute {\n return {\n name: attributeName(attribute.name()),\n args: readResolvedArgList(attribute.argList(), sourceFile),\n span: nodePslSpan(attribute.syntax, sourceFile),\n };\n}\n\nexport function readResolvedAttributes(\n attributes: Iterable<FieldAttributeAst | ModelAttributeAst>,\n sourceFile: SourceFile,\n): readonly ResolvedAttribute[] {\n return Array.from(attributes, (attribute) => readResolvedAttribute(attribute, sourceFile));\n}\n\nexport function readResolvedConstructorCall(\n annotation: TypeAnnotationAst | undefined,\n sourceFile: SourceFile,\n): ResolvedTypeConstructorCall | undefined {\n const argList = annotation?.argList();\n if (annotation === undefined || argList === undefined) return undefined;\n return {\n path: annotation.name()?.path() ?? [],\n args: readResolvedArgList(argList, sourceFile),\n span: nodePslSpan(annotation.syntax, sourceFile),\n };\n}\n\nfunction readResolvedArgList(\n argList: AttributeArgListAst | undefined,\n sourceFile: SourceFile,\n): readonly ResolvedAttributeArg[] {\n if (argList === undefined) return [];\n const args: ResolvedAttributeArg[] = [];\n for (const arg of argList.args()) {\n const name = arg.name()?.name();\n const expression = arg.value();\n args.push({\n kind: name !== undefined ? 'named' : 'positional',\n ...(name !== undefined ? { name } : {}),\n value: renderExpression(expression),\n ...(expression !== undefined ? { expression } : {}),\n span: nodePslSpan(arg.syntax, sourceFile),\n });\n }\n return args;\n}\n\nfunction attributeName(name: QualifiedNameAst | undefined): string {\n return name?.path().join('.') ?? '';\n}\n\nfunction renderExpression(expression: ExpressionAst | undefined): string {\n if (expression === undefined) return '';\n return printSyntax(expression.syntax).trim();\n}\n\nexport function nodePslSpan(node: SyntaxNode, sourceFile: SourceFile): PslSpan {\n const start = node.offset;\n const end = start + node.green.textLength;\n return {\n start: offsetToPslPosition(start, sourceFile),\n end: offsetToPslPosition(end, sourceFile),\n };\n}\n\n/** Unsupported-top-level-block diagnostics are anchored to the keyword token. */\nexport function keywordPslSpan(node: SyntaxNode, keyword: string, sourceFile: SourceFile): PslSpan {\n const start = node.offset;\n const end = start + keyword.length;\n return {\n start: offsetToPslPosition(start, sourceFile),\n end: offsetToPslPosition(end, sourceFile),\n };\n}\n\nexport function rangeToPslSpan(range: Range, sourceFile: SourceFile): PslSpan {\n return {\n start: offsetToPslPosition(sourceFile.offsetAt(range.start), sourceFile),\n end: offsetToPslPosition(sourceFile.offsetAt(range.end), sourceFile),\n };\n}\n\nfunction offsetToPslPosition(offset: number, sourceFile: SourceFile): PslSpan['start'] {\n const position: Position = sourceFile.positionAt(offset);\n return { offset, line: position.line + 1, column: position.character + 1 };\n}\n","import type { PslDiagnostic, PslDiagnosticCode } from '@prisma-next/framework-components/psl-ast';\nimport { nodePslSpan } from '../../resolve';\nimport type { AstNode } from '../../syntax/ast-helpers';\nimport type { InterpretCtx } from '../types';\n\nexport const ATTRIBUTE_DIAGNOSTIC_CODE: PslDiagnosticCode = 'PSL_INVALID_ATTRIBUTE_SYNTAX';\n\nexport function leafDiagnostic(ctx: InterpretCtx, node: AstNode, message: string): PslDiagnostic {\n return {\n code: ATTRIBUTE_DIAGNOSTIC_CODE,\n message,\n sourceId: ctx.sourceId,\n span: nodePslSpan(node.syntax, ctx.sourceFile),\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { BooleanLiteralExprAst } from '../../syntax/ast/expressions';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport function bool(): ArgType<boolean> {\n return {\n kind: 'bool',\n label: 'boolean',\n parse: (arg, ctx): Result<boolean, readonly PslDiagnostic[]> => {\n if (arg instanceof BooleanLiteralExprAst) {\n const value = arg.value();\n if (value !== undefined) return ok(value);\n }\n return notOk([leafDiagnostic(ctx, arg, 'Expected a boolean literal')]);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { IdentifierAst } from '../../syntax/ast/identifier';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\n// A bare model-name reference. Existence of a model with this name is resolved\n// downstream (e.g. `resolvePolymorphism`), not here.\nexport function entityRef(): ArgType<string> {\n return {\n kind: 'entityRef',\n label: 'model name',\n parse: (arg, ctx): Result<string, readonly PslDiagnostic[]> => {\n if (!(arg instanceof IdentifierAst)) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a model name')]);\n }\n const name = arg.name();\n if (name === undefined) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a model name')]);\n }\n return ok(name);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { IdentifierAst } from '../../syntax/ast/identifier';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport type FieldRefScope = 'self' | 'referenced';\n\nexport interface FieldRefArgType extends ArgType<string> {\n readonly scope: FieldRefScope;\n}\n\nexport function fieldRef(scope: FieldRefScope): FieldRefArgType {\n return {\n kind: 'fieldRef',\n label: 'field name',\n scope,\n parse: (arg, ctx): Result<string, readonly PslDiagnostic[]> => {\n if (!(arg instanceof IdentifierAst)) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a field name')]);\n }\n const name = arg.name();\n if (name === undefined) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a field name')]);\n }\n const model = scope === 'self' ? ctx.selfModel : ctx.resolveReferencedModel();\n // A referenced model in another space can't be resolved here (resolveReferencedModel returns undefined); skip the existence check — it runs where that model is known.\n if (model !== undefined && !Object.hasOwn(model.fields, name)) {\n return notOk([\n leafDiagnostic(ctx, arg, `Field \"${name}\" does not exist on model \"${model.name}\"`),\n ]);\n }\n return ok(name);\n },\n };\n}\n","import type { PslDiagnostic, PslSpan } from '@prisma-next/framework-components/psl-ast';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { nodePslSpan } from '../resolve';\nimport type { FieldAttributeAst, ModelAttributeAst } from '../syntax/ast/attributes';\nimport type { AttributeArgAst } from '../syntax/ast/expressions';\nimport { ATTRIBUTE_DIAGNOSTIC_CODE } from './combinators/diagnostic';\nimport type {\n ArgType,\n AttributeSpec,\n InterpretCtx,\n OptionalArgType,\n Param,\n PositionalParam,\n} from './types';\n\n// The positional/named argument-binding for an attribute or a function call. `name` labels the\n// callee in binding diagnostics (`Attribute \"<name>\" …`); `span` anchors the arity diagnostics\n// (too-many / missing) that have no per-argument node to point at.\nexport interface ArgBindingSpec {\n readonly name: string;\n readonly positional: readonly PositionalParam<unknown>[];\n readonly named: Readonly<Record<string, Param<unknown>>>;\n}\n\nexport function interpretArgs(\n args: Iterable<AttributeArgAst>,\n spec: ArgBindingSpec,\n ctx: InterpretCtx,\n span: PslSpan,\n): Result<Record<string, unknown>, readonly PslDiagnostic[]> {\n const diagnostics: PslDiagnostic[] = [];\n\n const output: Record<string, unknown> = {};\n const seen = new Set<string>();\n let positionalSlot = 0;\n let reportedExcess = false;\n\n for (const arg of args) {\n const name = arg.name()?.name();\n\n let key: string;\n let param: Param<unknown>;\n if (name === undefined) {\n const posParam = spec.positional[positionalSlot];\n if (posParam === undefined) {\n if (!reportedExcess) {\n diagnostics.push(\n diagnostic(\n `Attribute \"${spec.name}\" received too many positional arguments`,\n ctx,\n span,\n ),\n );\n reportedExcess = true;\n }\n continue;\n }\n positionalSlot += 1;\n key = posParam.key;\n param = posParam.type;\n } else {\n const namedParam = Object.hasOwn(spec.named, name) ? spec.named[name] : undefined;\n if (namedParam === undefined) {\n diagnostics.push(\n diagnostic(\n `Attribute \"${spec.name}\" received unknown argument \"${name}\"`,\n ctx,\n nodePslSpan(arg.syntax, ctx.sourceFile),\n ),\n );\n continue;\n }\n key = name;\n param = namedParam;\n }\n\n if (seen.has(key)) {\n diagnostics.push(\n diagnostic(\n `Attribute \"${spec.name}\" received duplicate argument \"${key}\"`,\n ctx,\n nodePslSpan(arg.syntax, ctx.sourceFile),\n ),\n );\n continue;\n }\n seen.add(key);\n const result = parseArgValue(arg, param, ctx, diagnostics);\n if (result.ok) output[key] = result.value;\n }\n\n const finalized = new Set<string>();\n const finalizeAbsentKey = (\n key: string,\n positionalParam: Param<unknown> | undefined,\n namedParam: Param<unknown> | undefined,\n ): void => {\n if (finalized.has(key) || seen.has(key)) return;\n finalized.add(key);\n const effective = namedParam ?? positionalParam;\n if (effective === undefined) return;\n if (isOptionalArgType(effective)) {\n if (effective.hasDefault) output[key] = effective.defaultValue;\n return;\n }\n diagnostics.push(\n diagnostic(`Attribute \"${spec.name}\" is missing required argument \"${key}\"`, ctx, span),\n );\n };\n\n for (const param of spec.positional) {\n const namedParam = Object.hasOwn(spec.named, param.key) ? spec.named[param.key] : undefined;\n finalizeAbsentKey(param.key, param.type, namedParam);\n }\n for (const key of Object.keys(spec.named)) {\n finalizeAbsentKey(key, undefined, spec.named[key]);\n }\n\n if (diagnostics.length > 0) {\n return notOk<readonly PslDiagnostic[]>(diagnostics);\n }\n return ok(output);\n}\n\nexport function interpretAttribute<Out>(\n attrNode: FieldAttributeAst | ModelAttributeAst,\n spec: AttributeSpec<Out>,\n ctx: InterpretCtx,\n): Result<Out, readonly PslDiagnostic[]> {\n const attributeSpan = nodePslSpan(attrNode.syntax, ctx.sourceFile);\n const bound = interpretArgs(attrNode.argList()?.args() ?? [], spec, ctx, attributeSpan);\n if (!bound.ok) return notOk<readonly PslDiagnostic[]>(bound.failure);\n\n const value = blindCast<\n Out,\n 'The engine builds the output object structurally from the spec; TypeScript cannot relate the dynamically-keyed record to the spec-inferred output type.'\n >(bound.value);\n if (spec.refine !== undefined) {\n const refineDiagnostics = spec.refine(value, ctx);\n if (refineDiagnostics.length > 0) {\n return notOk<readonly PslDiagnostic[]>(refineDiagnostics);\n }\n }\n return ok(value);\n}\n\nfunction parseArgValue(\n arg: AttributeArgAst,\n argType: ArgType<unknown>,\n ctx: InterpretCtx,\n diagnostics: PslDiagnostic[],\n): Result<unknown, readonly PslDiagnostic[]> {\n const value = arg.value();\n if (value === undefined) {\n const missing = diagnostic(\n 'Attribute argument is missing a value',\n ctx,\n nodePslSpan(arg.syntax, ctx.sourceFile),\n );\n diagnostics.push(missing);\n return notOk<readonly PslDiagnostic[]>([missing]);\n }\n const result = argType.parse(value, ctx);\n if (!result.ok) {\n for (const failure of result.failure) diagnostics.push(failure);\n }\n return result;\n}\n\nfunction isOptionalArgType(param: Param<unknown>): param is OptionalArgType<unknown> {\n return 'optional' in param && param.optional === true;\n}\n\nfunction diagnostic(message: string, ctx: InterpretCtx, span: PslSpan): PslDiagnostic {\n return { code: ATTRIBUTE_DIAGNOSTIC_CODE, message, sourceId: ctx.sourceId, span };\n}\n","import type { PslDiagnostic, PslSpan } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { nodePslSpan } from '../../resolve';\nimport type { ExpressionAst } from '../../syntax/ast/expressions';\nimport { FunctionCallAst } from '../../syntax/ast/expressions';\nimport { interpretArgs } from '../interpret';\nimport type { ArgType, InterpretCtx, Param, PositionalParam } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\n// The argument signature of a pinned function call — the same positional/named shape an attribute\n// spec uses. Omitted groups default to empty, so a nullary call needs neither key.\nexport interface FuncCallSig {\n readonly positional?: readonly PositionalParam<unknown>[];\n readonly named?: Readonly<Record<string, Param<unknown>>>;\n}\n\nexport interface TypedFuncCall {\n readonly fn: string;\n readonly span: PslSpan;\n readonly args: Readonly<Record<string, unknown>>;\n}\n\n// A name-pinned function-call argument — `funcCall('now', {})` matches `now()`, parsing the call's\n// arguments through `sig`.\nexport function funcCall(name: string, sig: FuncCallSig): ArgType<TypedFuncCall> {\n return {\n kind: 'funcCall',\n label: 'function call',\n parse: (arg, ctx): Result<TypedFuncCall, readonly PslDiagnostic[]> => {\n const guard = matchCallee(arg, name, ctx);\n if (!guard.ok) return guard;\n const span = nodePslSpan(guard.value.syntax, ctx.sourceFile);\n const bound = interpretArgs(\n guard.value.args(),\n { name, positional: sig.positional ?? [], named: sig.named ?? {} },\n ctx,\n span,\n );\n if (!bound.ok) return notOk<readonly PslDiagnostic[]>(bound.failure);\n return ok({ fn: name, span, args: bound.value });\n },\n };\n}\n\nfunction matchCallee(\n arg: ExpressionAst,\n name: string,\n ctx: InterpretCtx,\n): Result<FunctionCallAst, readonly PslDiagnostic[]> {\n if (!(arg instanceof FunctionCallAst)) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a function call')]);\n }\n const qname = arg.name();\n if (qname === undefined || qname.dot() !== undefined || qname.colon() !== undefined) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a function call')]);\n }\n const calleeName = qname.identifier()?.token()?.text;\n if (calleeName === undefined) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected a function call')]);\n }\n if (calleeName !== name) {\n return notOk([leafDiagnostic(ctx, arg, `Expected ${name}()`)]);\n }\n return ok(arg);\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { IdentifierAst } from '../../syntax/ast/identifier';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport function identifier<const N extends string>(name: N): ArgType<N> {\n return {\n kind: 'identifier',\n label: name,\n parse: (arg, ctx): Result<N, readonly PslDiagnostic[]> => {\n if (arg instanceof IdentifierAst && arg.name() === name) return ok(name);\n return notOk([leafDiagnostic(ctx, arg, `Expected ${name}`)]);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { NumberLiteralExprAst } from '../../syntax/ast/expressions';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\n// An integer literal reduced to its numeric value. Passing `min`/`max` additionally rejects\n// out-of-range integers with a distinct range message, leaving the integer-only check intact.\nexport function int(opts?: { min?: number; max?: number }): ArgType<number> {\n const min = opts?.min;\n const max = opts?.max;\n return {\n kind: 'int',\n label: 'integer',\n parse: (arg, ctx): Result<number, readonly PslDiagnostic[]> => {\n if (arg instanceof NumberLiteralExprAst) {\n const value = arg.value();\n if (value !== undefined && Number.isInteger(value)) {\n if ((min === undefined || value >= min) && (max === undefined || value <= max)) {\n return ok(value);\n }\n return notOk([leafDiagnostic(ctx, arg, rangeMessage(min, max))]);\n }\n }\n return notOk([leafDiagnostic(ctx, arg, 'Expected an integer literal')]);\n },\n };\n}\n\nfunction rangeMessage(min: number | undefined, max: number | undefined): string {\n if (min !== undefined && max !== undefined)\n return `Expected an integer between ${min} and ${max}`;\n if (min !== undefined) return `Expected an integer greater than or equal to ${min}`;\n return `Expected an integer less than or equal to ${max}`;\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { ArrayLiteralAst, type ExpressionAst } from '../../syntax/ast/expressions';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport interface ListOptions {\n readonly nonEmpty?: boolean;\n readonly unique?: boolean;\n}\n\nexport function list<T>(of: ArgType<T>, opts?: ListOptions): ArgType<T[]> {\n return {\n kind: 'list',\n label: `${of.label}[]`,\n parse: (arg, ctx): Result<T[], readonly PslDiagnostic[]> => {\n if (!(arg instanceof ArrayLiteralAst)) {\n return notOk([leafDiagnostic(ctx, arg, `Expected a list of ${of.label}`)]);\n }\n const diagnostics: PslDiagnostic[] = [];\n const parsed: { node: ExpressionAst; value: T }[] = [];\n let count = 0;\n for (const element of arg.elements()) {\n count += 1;\n const result = of.parse(element, ctx);\n if (result.ok) parsed.push({ node: element, value: result.value });\n else diagnostics.push(...result.failure);\n }\n if (opts?.nonEmpty === true && count === 0) {\n diagnostics.push(leafDiagnostic(ctx, arg, 'Expected a non-empty list'));\n }\n if (opts?.unique === true) {\n const seen = new Set<T>();\n for (const { node, value } of parsed) {\n if (seen.has(value)) diagnostics.push(leafDiagnostic(ctx, node, 'Duplicate list entry'));\n else seen.add(value);\n }\n }\n if (diagnostics.length > 0) return notOk(diagnostics);\n return ok(parsed.map((entry) => entry.value));\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { NumberLiteralExprAst } from '../../syntax/ast/expressions';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\n// A general number literal — any number, including floats — reduced to its numeric value.\n// Passing `value` pins the combinator to that single literal (`num(4)` matches only `4`),\n// mirroring how `identifier(name)` pins a bare identifier. Use `int()` when only integer\n// literals are allowed.\nexport function num(): ArgType<number>;\nexport function num(value: number): ArgType<number>;\nexport function num(value?: number): ArgType<number> {\n return {\n kind: 'num',\n label: value === undefined ? 'number' : String(value),\n parse: (arg, ctx): Result<number, readonly PslDiagnostic[]> => {\n if (arg instanceof NumberLiteralExprAst) {\n const parsed = arg.value();\n if (parsed !== undefined && (value === undefined || parsed === value)) return ok(parsed);\n }\n const message = value === undefined ? 'Expected a number literal' : `Expected ${value}`;\n return notOk([leafDiagnostic(ctx, arg, message)]);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport type { ArgType, OutOf } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport function oneOf<Alts extends readonly [ArgType<unknown>, ...ArgType<unknown>[]]>(\n ...alts: Alts\n): ArgType<OutOf<Alts[number]>> {\n const label = alts.map((alt) => alt.label).join(' | ');\n return {\n kind: 'oneOf',\n label,\n parse: (arg, ctx): Result<OutOf<Alts[number]>, readonly PslDiagnostic[]> => {\n for (const alt of alts) {\n const result = alt.parse(arg, ctx);\n if (result.ok) {\n return ok(\n blindCast<\n OutOf<Alts[number]>,\n 'The matched value comes from an alternative whose output type is a member of the union, but iterating the tuple widens each element to ArgType<unknown>, erasing that relationship.'\n >(result.value),\n );\n }\n }\n return notOk([leafDiagnostic(ctx, arg, `Expected one of: ${label}`)]);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { ObjectLiteralExprAst } from '../../syntax/ast/expressions';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport function record<T>(of: ArgType<T>): ArgType<Record<string, T>> {\n return {\n kind: 'record',\n label: `{ [key]: ${of.label} }`,\n parse: (arg, ctx): Result<Record<string, T>, readonly PslDiagnostic[]> => {\n if (!(arg instanceof ObjectLiteralExprAst)) {\n return notOk([leafDiagnostic(ctx, arg, 'Expected an object literal')]);\n }\n const diagnostics: PslDiagnostic[] = [];\n const result: Record<string, T> = {};\n for (const field of arg.fields()) {\n const key = field.keyName();\n if (key === undefined) {\n diagnostics.push(leafDiagnostic(ctx, field, 'Expected a key'));\n continue;\n }\n const value = field.value();\n if (value === undefined) {\n diagnostics.push(leafDiagnostic(ctx, field, `Expected a value for key \"${key}\"`));\n continue;\n }\n const parsed = of.parse(value, ctx);\n if (!parsed.ok) {\n diagnostics.push(...parsed.failure);\n continue;\n }\n if (Object.hasOwn(result, key)) {\n diagnostics.push(leafDiagnostic(ctx, field, `Duplicate key \"${key}\"`));\n continue;\n }\n result[key] = parsed.value;\n }\n if (diagnostics.length > 0) return notOk(diagnostics);\n return ok(result);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { StringLiteralExprAst } from '../../syntax/ast/expressions';\nimport type { ArgType } from '../types';\nimport { leafDiagnostic } from './diagnostic';\n\nexport function str(): ArgType<string> {\n return {\n kind: 'str',\n label: 'string',\n parse: (arg, ctx): Result<string, readonly PslDiagnostic[]> => {\n if (arg instanceof StringLiteralExprAst) {\n const value = arg.value();\n if (value !== undefined) return ok(value);\n }\n return notOk([leafDiagnostic(ctx, arg, 'Expected a string literal')]);\n },\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport type { AttributeOut, AttributeSpec, InterpretCtx, Param, PositionalParam } from './types';\n\ninterface FieldAttributeConfig<\n Pos extends readonly PositionalParam[],\n Named extends Record<string, Param<unknown>>,\n> {\n readonly positional?: Pos;\n readonly named?: Named;\n readonly refine?: (\n parsed: AttributeOut<Pos, Named>,\n ctx: InterpretCtx,\n ) => readonly PslDiagnostic[];\n}\n\nexport function fieldAttribute<\n const Pos extends readonly PositionalParam[] = readonly [],\n const Named extends Record<string, Param<unknown>> = Record<never, never>,\n>(name: string, config: FieldAttributeConfig<Pos, Named>): AttributeSpec<AttributeOut<Pos, Named>> {\n return {\n level: 'field',\n name,\n positional: config.positional ?? [],\n named: config.named ?? {},\n ...(config.refine !== undefined ? { refine: config.refine } : {}),\n };\n}\n","import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';\nimport type { AttributeOut, AttributeSpec, InterpretCtx, Param, PositionalParam } from './types';\n\ninterface ModelAttributeConfig<\n Pos extends readonly PositionalParam[],\n Named extends Record<string, Param<unknown>>,\n> {\n readonly positional?: Pos;\n readonly named?: Named;\n readonly refine?: (\n parsed: AttributeOut<Pos, Named>,\n ctx: InterpretCtx,\n ) => readonly PslDiagnostic[];\n}\n\nexport function modelAttribute<\n const Pos extends readonly PositionalParam[] = readonly [],\n const Named extends Record<string, Param<unknown>> = Record<never, never>,\n>(name: string, config: ModelAttributeConfig<Pos, Named>): AttributeSpec<AttributeOut<Pos, Named>> {\n return {\n level: 'model',\n name,\n positional: config.positional ?? [],\n named: config.named ?? {},\n ...(config.refine !== undefined ? { refine: config.refine } : {}),\n };\n}\n","import type { ArgType, OptionalArgType } from './types';\n\nexport function optional<T>(type: ArgType<T>, ...rest: [defaultValue: T] | []): OptionalArgType<T> {\n if (rest.length === 0) {\n return { ...type, optional: true, hasDefault: false };\n }\n return { ...type, optional: true, hasDefault: true, defaultValue: rest[0] };\n}\n","import {\n type AuthoringPslBlockDescriptor,\n type AuthoringPslBlockDescriptorNamespace,\n isAuthoringPslBlockDescriptor,\n} from '@prisma-next/framework-components/authoring';\nimport type { CodecLookup } from '@prisma-next/framework-components/codec';\nimport {\n makePslNamespace,\n makePslNamespaceEntries,\n type PslDiagnostic,\n type PslModel,\n type PslSpan,\n UNSPECIFIED_PSL_NAMESPACE_ID,\n validateExtensionBlock,\n} from '@prisma-next/framework-components/psl-ast';\nimport type { SourceFile } from './source-file';\nimport type { BlockSymbol, ModelSymbol, SymbolTable } from './symbol-table';\n\nexport function findBlockDescriptor(\n descriptors: AuthoringPslBlockDescriptorNamespace | undefined,\n keyword: string,\n): AuthoringPslBlockDescriptor | undefined {\n if (descriptors === undefined) return undefined;\n for (const value of Object.values(descriptors)) {\n if (value === undefined) continue;\n if (isAuthoringPslBlockDescriptor(value)) {\n if (value.keyword === keyword) return value;\n continue;\n }\n const nested = findBlockDescriptor(value, keyword);\n if (nested !== undefined) return nested;\n }\n return undefined;\n}\n\nexport function validateExtensionBlockFromSymbol(input: {\n readonly block: BlockSymbol;\n readonly descriptor: AuthoringPslBlockDescriptor;\n readonly symbolTable: SymbolTable;\n readonly sourceFile: SourceFile;\n readonly sourceId: string;\n readonly codecLookup: CodecLookup;\n}): readonly PslDiagnostic[] {\n const refCtx = buildRefResolutionContext(input.symbolTable, input.block);\n return validateExtensionBlock(\n input.block.block,\n input.descriptor,\n input.sourceId,\n input.codecLookup,\n refCtx,\n );\n}\n\nconst ZERO_SPAN: PslSpan = {\n start: { offset: 0, line: 1, column: 1 },\n end: { offset: 0, line: 1, column: 1 },\n};\n\nfunction buildRefResolutionContext(\n symbolTable: SymbolTable,\n block: BlockSymbol,\n): {\n ownerNamespace: ReturnType<typeof makePslNamespace>;\n allNamespaces: readonly ReturnType<typeof makePslNamespace>[];\n} {\n const unspecifiedNamespace = makeNamespace(\n UNSPECIFIED_PSL_NAMESPACE_ID,\n Object.values(symbolTable.topLevel.models),\n );\n const namedNamespaces = Object.values(symbolTable.topLevel.namespaces).map((namespace) =>\n makeNamespace(namespace.name, Object.values(namespace.models)),\n );\n const allNamespaces = [unspecifiedNamespace, ...namedNamespaces];\n const ownerNamespaceName = findOwnerNamespaceName(symbolTable, block);\n const ownerNamespace =\n allNamespaces.find((namespace) => namespace.name === ownerNamespaceName) ??\n unspecifiedNamespace;\n return { ownerNamespace, allNamespaces };\n}\n\nfunction makeNamespace(\n name: string,\n models: readonly ModelSymbol[],\n): ReturnType<typeof makePslNamespace> {\n const modelStubs: PslModel[] = models.map((model) => ({\n kind: 'model',\n name: model.name,\n fields: [],\n attributes: [],\n span: ZERO_SPAN,\n }));\n return makePslNamespace({\n kind: 'namespace',\n name,\n entries: makePslNamespaceEntries(modelStubs, [], []),\n span: ZERO_SPAN,\n });\n}\n\nfunction findOwnerNamespaceName(symbolTable: SymbolTable, block: BlockSymbol): string {\n for (const namespace of Object.values(symbolTable.topLevel.namespaces)) {\n if (Object.values(namespace.blocks).some((candidate) => candidate === block)) {\n return namespace.name;\n }\n }\n return UNSPECIFIED_PSL_NAMESPACE_ID;\n}\n","import type { AuthoringPslBlockDescriptor } from '@prisma-next/framework-components/authoring';\nimport type {\n PslBlockParam,\n PslExtensionBlock,\n PslExtensionBlockAttribute,\n PslExtensionBlockParamValue,\n PslSpan,\n} from '@prisma-next/framework-components/psl-ast';\nimport type { ParseDiagnostic } from './parse';\nimport { nodePslSpan } from './resolve';\nimport type { SourceFile } from './source-file';\nimport type { GenericBlockDeclarationAst, KeyValuePairAst } from './syntax/ast/declarations';\nimport { ArrayLiteralAst, type ExpressionAst } from './syntax/ast/expressions';\nimport { printSyntax } from './syntax/ast-helpers';\n\n/**\n * Descriptor-free and unknown parameters become `value` stubs so validation can\n * report them via key-set comparison. Duplicate member names are first-wins.\n */\nexport function reconstructExtensionBlock(\n node: GenericBlockDeclarationAst,\n descriptor: AuthoringPslBlockDescriptor | undefined,\n sourceFile: SourceFile,\n diagnostics: ParseDiagnostic[],\n): PslExtensionBlock {\n const keyword = node.keyword()?.text ?? '';\n const blockName = node.name()?.name() ?? '';\n\n const blockAttributes: PslExtensionBlockAttribute[] = [];\n for (const attribute of node.attributes()) {\n const name = attribute.name()?.path().join('.') ?? '';\n const args = Array.from(attribute.argList()?.args() ?? [], (arg) => {\n const value = arg.value();\n return {\n kind: 'positional' as const,\n value: value === undefined ? '' : printSyntax(value.syntax).trim(),\n span: nodePslSpan(arg.syntax, sourceFile),\n };\n });\n blockAttributes.push({\n name,\n args,\n span: nodePslSpan(attribute.syntax, sourceFile),\n });\n }\n\n const parameters: Record<string, PslExtensionBlockParamValue> = {};\n for (const entry of node.entries()) {\n const key = entry.key()?.name();\n if (key === undefined) continue;\n const span = nodePslSpan(entry.syntax, sourceFile);\n if (Object.hasOwn(parameters, key)) {\n diagnostics.push({\n code: 'PSL_EXTENSION_DUPLICATE_PARAMETER',\n message: `Duplicate parameter \"${key}\" in \"${keyword}\" block \"${blockName}\"; first occurrence wins`,\n range: {\n start: sourceFile.positionAt(entry.syntax.offset),\n end: sourceFile.positionAt(entry.syntax.offset + entry.syntax.green.textLength),\n },\n });\n continue;\n }\n parameters[key] = reconstructParamValue(\n entry,\n descriptor?.parameters[key],\n span,\n sourceFile,\n diagnostics,\n );\n }\n\n return {\n kind: descriptor?.discriminator ?? keyword,\n keyword,\n name: blockName,\n parameters,\n blockAttributes,\n span: nodePslSpan(node.syntax, sourceFile),\n };\n}\n\nfunction reconstructParamValue(\n entry: KeyValuePairAst,\n param: PslBlockParam | undefined,\n span: PslSpan,\n sourceFile: SourceFile,\n diagnostics: ParseDiagnostic[],\n): PslExtensionBlockParamValue {\n const value = entry.value();\n if (value === undefined) {\n return { kind: 'bare', span };\n }\n return reconstructFromExpression(value, param, span, sourceFile, diagnostics);\n}\n\nfunction reconstructFromExpression(\n value: ExpressionAst,\n param: PslBlockParam | undefined,\n span: PslSpan,\n sourceFile: SourceFile,\n diagnostics?: ParseDiagnostic[],\n): PslExtensionBlockParamValue {\n const raw = printSyntax(value.syntax).trim();\n if (param?.kind === 'list') {\n const array = ArrayLiteralAst.cast(value.syntax);\n if (!array) {\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `List parameter expects an array literal, got ${raw}`,\n range: {\n start: sourceFile.positionAt(value.syntax.offset),\n end: sourceFile.positionAt(value.syntax.offset + value.syntax.green.textLength),\n },\n });\n return { kind: 'value', raw, span };\n }\n\n const items: PslExtensionBlockParamValue[] = [];\n for (const element of array.elements()) {\n items.push(\n reconstructFromExpression(\n element,\n param.of,\n nodePslSpan(element.syntax, sourceFile),\n sourceFile,\n diagnostics,\n ),\n );\n }\n return { kind: 'list', items, span };\n }\n switch (param?.kind) {\n case 'ref':\n return { kind: 'ref', identifier: raw, span };\n case 'option':\n return { kind: 'option', token: raw, span };\n default:\n return { kind: 'value', raw, span };\n }\n}\n","import type { AuthoringPslBlockDescriptorNamespace } from '@prisma-next/framework-components/authoring';\nimport type { PslExtensionBlock, PslSpan } from '@prisma-next/framework-components/psl-ast';\nimport { reconstructExtensionBlock } from './block-reconstruction';\nimport { findBlockDescriptor } from './extension-block';\nimport type { ParseDiagnostic } from './parse';\nimport {\n nodePslSpan,\n type ResolvedAttribute,\n type ResolvedTypeConstructorCall,\n readResolvedAttributes,\n readResolvedConstructorCall,\n} from './resolve';\nimport type { Range, SourceFile } from './source-file';\nimport {\n CompositeTypeDeclarationAst,\n type DocumentAst,\n type FieldDeclarationAst,\n GenericBlockDeclarationAst,\n ModelDeclarationAst,\n type NamedTypeDeclarationAst,\n NamespaceDeclarationAst,\n TypesBlockAst,\n} from './syntax/ast/declarations';\nimport type { IdentifierAst } from './syntax/ast/identifier';\nimport type { SyntaxNode } from './syntax/red';\n\nexport type {\n ResolvedAttribute,\n ResolvedAttributeArg,\n ResolvedTypeConstructorCall,\n} from './resolve';\n\nexport interface SymbolTable {\n readonly topLevel: TopLevelScope;\n}\n\nexport interface TopLevelScope {\n readonly namespaces: Record<string, NamespaceSymbol>;\n readonly namedTypes: Record<string, NamedTypeSymbol>;\n readonly blocks: Record<string, BlockSymbol>;\n readonly models: Record<string, ModelSymbol>;\n readonly compositeTypes: Record<string, CompositeTypeSymbol>;\n}\n\nexport interface NamespaceSymbol {\n readonly kind: 'namespace';\n readonly name: string;\n readonly node: NamespaceDeclarationAst;\n readonly span: PslSpan;\n readonly models: Record<string, ModelSymbol>;\n readonly compositeTypes: Record<string, CompositeTypeSymbol>;\n readonly blocks: Record<string, BlockSymbol>;\n}\n\nexport interface ModelSymbol {\n readonly kind: 'model';\n readonly name: string;\n readonly node: ModelDeclarationAst;\n readonly span: PslSpan;\n readonly fields: Record<string, FieldSymbol>;\n readonly attributes: readonly ResolvedAttribute[];\n}\n\nexport interface CompositeTypeSymbol {\n readonly kind: 'compositeType';\n readonly name: string;\n readonly node: CompositeTypeDeclarationAst;\n readonly span: PslSpan;\n readonly fields: Record<string, FieldSymbol>;\n readonly attributes: readonly ResolvedAttribute[];\n}\n\nexport interface BlockSymbol {\n readonly kind: 'block';\n readonly name: string;\n readonly keyword: string;\n readonly node: GenericBlockDeclarationAst;\n readonly span: PslSpan;\n /** Resolved once so consumers do not independently classify block parameters. */\n readonly block: PslExtensionBlock;\n}\n\nexport interface ResolvedNamedTypeBinding {\n readonly baseType?: string;\n readonly typeConstructor?: ResolvedTypeConstructorCall;\n readonly isConstructor: boolean;\n readonly attributes: readonly ResolvedAttribute[];\n}\n\n/**\n * A `types {}` binding, collected without classification: whether the binding\n * refines a target scalar is pronounced by the interpreter\n * (`resolveNamedTypeDeclarations`), not by the family-blind symbol table.\n */\nexport interface NamedTypeSymbol extends ResolvedNamedTypeBinding {\n readonly kind: 'namedType';\n readonly name: string;\n readonly node: NamedTypeDeclarationAst;\n readonly span: PslSpan;\n}\n\nexport interface FieldSymbol {\n readonly kind: 'field';\n readonly name: string;\n readonly node: FieldDeclarationAst;\n readonly span: PslSpan;\n readonly typeName: string;\n readonly typeNamespaceId?: string;\n readonly typeContractSpaceId?: string;\n readonly optional: boolean;\n readonly list: boolean;\n readonly typeConstructor?: ResolvedTypeConstructorCall;\n readonly attributes: readonly ResolvedAttribute[];\n /** Prevents cascading unsupported-type diagnostics after invalid qualification. */\n readonly malformedType?: boolean;\n}\n\nexport interface BuildSymbolTableOptions {\n readonly document: DocumentAst;\n readonly sourceFile: SourceFile;\n readonly pslBlockDescriptors: AuthoringPslBlockDescriptorNamespace;\n}\n\nexport interface SymbolTableResult {\n readonly table: SymbolTable;\n readonly diagnostics: readonly ParseDiagnostic[];\n}\n\n/**\n * Owns duplicate-declaration detection for all PSL scopes; downstream consumers\n * should consume first-wins symbols rather than re-emitting duplicate diagnostics.\n */\nexport function buildSymbolTable(options: BuildSymbolTableOptions): SymbolTableResult {\n const { document, sourceFile, pslBlockDescriptors } = options;\n const diagnostics: ParseDiagnostic[] = [];\n\n const namespaces: Record<string, NamespaceSymbol> = {};\n const namedTypes: Record<string, NamedTypeSymbol> = {};\n const blocks: Record<string, BlockSymbol> = {};\n const models: Record<string, ModelSymbol> = {};\n const compositeTypes: Record<string, CompositeTypeSymbol> = {};\n const topLevelNames = new Set<string>();\n\n const claim = (taken: Set<string>, name: IdentifierAst | undefined): string | undefined => {\n const text = name?.name();\n if (text === undefined) return undefined;\n if (taken.has(text)) {\n const range = nameRange(name, sourceFile);\n if (range) {\n diagnostics.push({\n code: 'PSL_DUPLICATE_DECLARATION',\n message: `Duplicate declaration of \"${text}\"`,\n range,\n });\n }\n return undefined;\n }\n taken.add(text);\n return text;\n };\n\n for (const declaration of document.declarations()) {\n if (declaration instanceof ModelDeclarationAst) {\n const name = claim(topLevelNames, declaration.name());\n if (name !== undefined) models[name] = buildModel(name, declaration, sourceFile, diagnostics);\n } else if (declaration instanceof CompositeTypeDeclarationAst) {\n const name = claim(topLevelNames, declaration.name());\n if (name !== undefined) {\n compositeTypes[name] = buildCompositeType(name, declaration, sourceFile, diagnostics);\n }\n } else if (declaration instanceof GenericBlockDeclarationAst) {\n const name = claim(topLevelNames, declaration.name());\n if (name !== undefined) {\n blocks[name] = buildBlock(name, declaration, sourceFile, pslBlockDescriptors, diagnostics);\n }\n } else if (declaration instanceof NamespaceDeclarationAst) {\n const name = claim(topLevelNames, declaration.name());\n if (name !== undefined) {\n namespaces[name] = buildNamespace(\n name,\n declaration,\n diagnostics,\n sourceFile,\n pslBlockDescriptors,\n );\n }\n } else if (declaration instanceof TypesBlockAst) {\n for (const binding of declaration.declarations()) {\n const name = claim(topLevelNames, binding.name());\n if (name === undefined) continue;\n const resolved = resolveNamedTypeBinding(binding, sourceFile);\n const span = nodePslSpan(binding.syntax, sourceFile);\n namedTypes[name] = { kind: 'namedType', name, node: binding, span, ...resolved };\n }\n }\n }\n\n const table: SymbolTable = {\n topLevel: { namespaces, namedTypes, blocks, models, compositeTypes },\n };\n return { table, diagnostics };\n}\n\nfunction buildModel(\n name: string,\n node: ModelDeclarationAst,\n sourceFile: SourceFile,\n diagnostics: ParseDiagnostic[],\n): ModelSymbol {\n return {\n kind: 'model',\n name,\n node,\n span: nodePslSpan(node.syntax, sourceFile),\n fields: buildFields(name, node.fields(), sourceFile, diagnostics),\n attributes: readResolvedAttributes(node.attributes(), sourceFile),\n };\n}\n\nfunction buildCompositeType(\n name: string,\n node: CompositeTypeDeclarationAst,\n sourceFile: SourceFile,\n diagnostics: ParseDiagnostic[],\n): CompositeTypeSymbol {\n return {\n kind: 'compositeType',\n name,\n node,\n span: nodePslSpan(node.syntax, sourceFile),\n fields: buildFields(name, node.fields(), sourceFile, diagnostics),\n attributes: readResolvedAttributes(node.attributes(), sourceFile),\n };\n}\n\nfunction buildBlock(\n name: string,\n node: GenericBlockDeclarationAst,\n sourceFile: SourceFile,\n pslBlockDescriptors: AuthoringPslBlockDescriptorNamespace,\n diagnostics: ParseDiagnostic[],\n): BlockSymbol {\n const keyword = node.keyword()?.text ?? '';\n const descriptor = findBlockDescriptor(pslBlockDescriptors, keyword);\n return {\n kind: 'block',\n name,\n keyword,\n node,\n span: nodePslSpan(node.syntax, sourceFile),\n block: reconstructExtensionBlock(node, descriptor, sourceFile, diagnostics),\n };\n}\n\nfunction buildNamespace(\n name: string,\n node: NamespaceDeclarationAst,\n diagnostics: ParseDiagnostic[],\n sourceFile: SourceFile,\n pslBlockDescriptors: AuthoringPslBlockDescriptorNamespace,\n): NamespaceSymbol {\n const models: Record<string, ModelSymbol> = {};\n const compositeTypes: Record<string, CompositeTypeSymbol> = {};\n const blocks: Record<string, BlockSymbol> = {};\n const taken = new Set<string>();\n\n for (const member of node.declarations()) {\n const memberName = member.name()?.name();\n if (memberName === undefined) continue;\n if (taken.has(memberName)) {\n const range = nameRange(member.name(), sourceFile);\n if (range) {\n diagnostics.push({\n code: 'PSL_DUPLICATE_DECLARATION',\n message: `Duplicate declaration of \"${memberName}\"`,\n range,\n });\n }\n continue;\n }\n taken.add(memberName);\n if (member instanceof ModelDeclarationAst) {\n models[memberName] = buildModel(memberName, member, sourceFile, diagnostics);\n } else if (member instanceof CompositeTypeDeclarationAst) {\n compositeTypes[memberName] = buildCompositeType(memberName, member, sourceFile, diagnostics);\n } else if (member instanceof GenericBlockDeclarationAst) {\n blocks[memberName] = buildBlock(\n memberName,\n member,\n sourceFile,\n pslBlockDescriptors,\n diagnostics,\n );\n }\n }\n\n return {\n kind: 'namespace',\n name,\n node,\n span: nodePslSpan(node.syntax, sourceFile),\n models,\n compositeTypes,\n blocks,\n };\n}\n\nfunction buildFields(\n ownerName: string,\n fields: Iterable<FieldDeclarationAst>,\n sourceFile: SourceFile,\n diagnostics: ParseDiagnostic[],\n): Record<string, FieldSymbol> {\n const result: Record<string, FieldSymbol> = {};\n for (const field of fields) {\n const nameNode = field.name();\n const name = nameNode?.name();\n if (name === undefined) continue;\n if (Object.hasOwn(result, name)) {\n const range = nameRange(nameNode, sourceFile);\n if (range) {\n diagnostics.push({\n code: 'PSL_DUPLICATE_DECLARATION',\n message: `Duplicate declaration of \"${name}\"`,\n range,\n });\n }\n continue;\n }\n result[name] = buildField(ownerName, name, field, sourceFile, diagnostics);\n }\n return result;\n}\n\nfunction buildField(\n ownerName: string,\n name: string,\n node: FieldDeclarationAst,\n sourceFile: SourceFile,\n diagnostics: ParseDiagnostic[],\n): FieldSymbol {\n const attributes = readResolvedAttributes(node.attributes(), sourceFile);\n const span = nodePslSpan(node.syntax, sourceFile);\n const annotation = node.typeAnnotation();\n const typeName = annotation?.name();\n\n if (typeName?.isOverQualified()) {\n const path = typeName.path();\n diagnostics.push({\n code: 'PSL_INVALID_QUALIFIED_TYPE',\n message: `Field \"${ownerName}.${name}\" has an invalid qualified type \"${path.join('.')}\"; use at most one namespace qualifier (e.g. \"ns.TypeName\")`,\n range: nodeRange(typeName.syntax, sourceFile),\n });\n return {\n kind: 'field',\n name,\n node,\n span,\n typeName: path[path.length - 1] ?? '',\n optional: false,\n list: false,\n malformedType: true,\n attributes,\n };\n }\n\n const typeConstructor = annotation?.isConstructor()\n ? readResolvedConstructorCall(annotation, sourceFile)\n : undefined;\n const typeNamespaceId = typeName?.namespace()?.name();\n const typeContractSpaceId = typeName?.space()?.name();\n\n return {\n kind: 'field',\n name,\n node,\n span,\n typeName: typeName?.identifier()?.name() ?? '',\n ...(typeNamespaceId !== undefined ? { typeNamespaceId } : {}),\n ...(typeContractSpaceId !== undefined ? { typeContractSpaceId } : {}),\n optional: annotation?.isOptional() ?? false,\n list: annotation?.isList() ?? false,\n ...(typeConstructor !== undefined ? { typeConstructor } : {}),\n attributes,\n };\n}\n\nfunction resolveNamedTypeBinding(\n node: NamedTypeDeclarationAst,\n sourceFile: SourceFile,\n): {\n baseType?: string;\n typeConstructor?: ResolvedTypeConstructorCall;\n isConstructor: boolean;\n attributes: readonly ResolvedAttribute[];\n} {\n const annotation = node.typeAnnotation();\n const isConstructor = annotation?.isConstructor() ?? false;\n const baseType = annotation?.name()?.identifier()?.name();\n const typeConstructor = readResolvedConstructorCall(annotation, sourceFile);\n return {\n isConstructor,\n ...(!isConstructor && baseType !== undefined ? { baseType } : {}),\n ...(typeConstructor !== undefined ? { typeConstructor } : {}),\n attributes: readResolvedAttributes(node.attributes(), sourceFile),\n };\n}\n\nfunction nameRange(name: IdentifierAst | undefined, sourceFile: SourceFile): Range | undefined {\n if (name === undefined) return undefined;\n for (const token of name.syntax.tokens()) {\n if (token.kind === 'Ident') {\n return {\n start: sourceFile.positionAt(token.offset),\n end: sourceFile.positionAt(token.offset + token.text.length),\n };\n }\n }\n return undefined;\n}\n\nfunction nodeRange(node: SyntaxNode, sourceFile: SourceFile): Range {\n const start = node.offset;\n const end = start + node.green.textLength;\n return {\n start: sourceFile.positionAt(start),\n end: sourceFile.positionAt(end),\n };\n}\n"],"mappings":";;;;;;AAEA,SAAgB,sBAAsB,WAAyB,QAAQ,GAAuB;CAE5F,OADgB,UAAU,KAAK,QAAQ,QAAQ,IAAI,SAAS,YAC/C,CAAC,CAAC,MAAM,EAAE;AACzB;AAEA,SAAgB,yBAAyB,OAAmC;CAE1E,MAAM,QADU,MAAM,KACF,CAAC,CAAC,MAAM,gBAAgB;CAC5C,IAAI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s";
2
+ import { l as SymbolTable } from "./symbol-table-DVspQ58_.mjs";
3
3
  import { Result } from "@prisma-next/utils/result";
4
4
  import { ContractSourceContext, ContractSourceDiagnostic, ContractSourceDiagnostics, ContractSourceProvider, PslContractSourceProvider } from "@prisma-next/config/config-types";
5
5
  import { Contract } from "@prisma-next/contract/types";
@@ -33,8 +33,7 @@ interface SymbolTable {
33
33
  }
34
34
  interface TopLevelScope {
35
35
  readonly namespaces: Record<string, NamespaceSymbol>;
36
- readonly scalars: Record<string, ScalarSymbol>;
37
- readonly typeAliases: Record<string, TypeAliasSymbol>;
36
+ readonly namedTypes: Record<string, NamedTypeSymbol>;
38
37
  readonly blocks: Record<string, BlockSymbol>;
39
38
  readonly models: Record<string, ModelSymbol>;
40
39
  readonly compositeTypes: Record<string, CompositeTypeSymbol>;
@@ -79,14 +78,13 @@ interface ResolvedNamedTypeBinding {
79
78
  readonly isConstructor: boolean;
80
79
  readonly attributes: readonly ResolvedAttribute[];
81
80
  }
82
- interface ScalarSymbol extends ResolvedNamedTypeBinding {
83
- readonly kind: 'scalar';
84
- readonly name: string;
85
- readonly node: NamedTypeDeclarationAst;
86
- readonly span: PslSpan;
87
- }
88
- interface TypeAliasSymbol extends ResolvedNamedTypeBinding {
89
- readonly kind: 'typeAlias';
81
+ /**
82
+ * A `types {}` binding, collected without classification: whether the binding
83
+ * refines a target scalar is pronounced by the interpreter
84
+ * (`resolveNamedTypeDeclarations`), not by the family-blind symbol table.
85
+ */
86
+ interface NamedTypeSymbol extends ResolvedNamedTypeBinding {
87
+ readonly kind: 'namedType';
90
88
  readonly name: string;
91
89
  readonly node: NamedTypeDeclarationAst;
92
90
  readonly span: PslSpan;
@@ -109,7 +107,6 @@ interface FieldSymbol {
109
107
  interface BuildSymbolTableOptions {
110
108
  readonly document: DocumentAst;
111
109
  readonly sourceFile: SourceFile;
112
- readonly scalarTypes: readonly string[];
113
110
  readonly pslBlockDescriptors: AuthoringPslBlockDescriptorNamespace;
114
111
  }
115
112
  interface SymbolTableResult {
@@ -122,5 +119,5 @@ interface SymbolTableResult {
122
119
  */
123
120
  declare function buildSymbolTable(options: BuildSymbolTableOptions): SymbolTableResult;
124
121
  //#endregion
125
- export { readResolvedConstructorCall as S, keywordPslSpan as _, ModelSymbol as a, readResolvedAttribute as b, ScalarSymbol as c, TopLevelScope as d, TypeAliasSymbol as f, ResolvedTypeConstructorCall as g, ResolvedAttributeArg as h, FieldSymbol as i, SymbolTable as l, ResolvedAttribute as m, BuildSymbolTableOptions as n, NamespaceSymbol as o, buildSymbolTable as p, CompositeTypeSymbol as r, ResolvedNamedTypeBinding as s, BlockSymbol as t, SymbolTableResult as u, nodePslSpan as v, readResolvedAttributes as x, rangeToPslSpan as y };
126
- //# sourceMappingURL=symbol-table-en_Bich3.d.mts.map
122
+ export { nodePslSpan as _, ModelSymbol as a, readResolvedAttributes as b, ResolvedNamedTypeBinding as c, TopLevelScope as d, buildSymbolTable as f, keywordPslSpan as g, ResolvedTypeConstructorCall as h, FieldSymbol as i, SymbolTable as l, ResolvedAttributeArg as m, BuildSymbolTableOptions as n, NamedTypeSymbol as o, ResolvedAttribute as p, CompositeTypeSymbol as r, NamespaceSymbol as s, BlockSymbol as t, SymbolTableResult as u, rangeToPslSpan as v, readResolvedConstructorCall as x, readResolvedAttribute as y };
123
+ //# sourceMappingURL=symbol-table-DVspQ58_.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symbol-table-DVspQ58_.d.mts","names":[],"sources":["../src/resolve.ts","../src/symbol-table.ts"],"mappings":";;;;UAaiB;WACN;WACA;WACA;WACA,aAAa;WACb,MAAM;;UAGA;WACN;WACA,eAAe;WACf,MAAM;;UAGA;WACN;WACA,eAAe;WACf,MAAM;;iBAGD,sBACd,WAAW,oBAAoB,mBAC/B,YAAY,aACX;iBAQa,uBACd,YAAY,SAAS,oBAAoB,oBACzC,YAAY,sBACF;iBAII,4BACd,YAAY,+BACZ,YAAY,aACX;iBAuCa,YAAY,MAAM,YAAY,YAAY,aAAa;;iBAUvD,eAAe,MAAM,YAAY,iBAAiB,YAAY,aAAa;iBAS3E,eAAe,OAAO,OAAO,YAAY,aAAa;;;UChFrD;WACN,UAAU;;UAGJ;WACN,YAAY,eAAe;WAC3B,YAAY,eAAe;WAC3B,QAAQ,eAAe;WACvB,QAAQ,eAAe;WACvB,gBAAgB,eAAe;;UAGzB;WACN;WACA;WACA,MAAM;WACN,MAAM;WACN,QAAQ,eAAe;WACvB,gBAAgB,eAAe;WAC/B,QAAQ,eAAe;;UAGjB;WACN;WACA;WACA,MAAM;WACN,MAAM;WACN,QAAQ,eAAe;WACvB,qBAAqB;;UAGf;WACN;WACA;WACA,MAAM;WACN,MAAM;WACN,QAAQ,eAAe;WACvB,qBAAqB;;UAGf;WACN;WACA;WACA;WACA,MAAM;WACN,MAAM;;WAEN,OAAO;;UAGD;WACN;WACA,kBAAkB;WAClB;WACA,qBAAqB;;;;;;;UAQf,wBAAwB;WAC9B;WACA;WACA,MAAM;WACN,MAAM;;UAGA;WACN;WACA;WACA,MAAM;WACN,MAAM;WACN;WACA;WACA;WACA;WACA;WACA,kBAAkB;WAClB,qBAAqB;;WAErB;;UAGM;WACN,UAAU;WACV,YAAY;WACZ,qBAAqB;;UAGf;WACN,OAAO;WACP,sBAAsB;;;;;;iBAOjB,iBAAiB,SAAS,0BAA0B"}
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@prisma-next/psl-parser",
3
- "version": "0.16.0-dev.11",
3
+ "version": "0.16.0-dev.13",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "Reusable parser for Prisma Schema Language (PSL)",
8
8
  "dependencies": {
9
- "@prisma-next/config": "0.16.0-dev.11",
10
- "@prisma-next/contract": "0.16.0-dev.11",
11
- "@prisma-next/framework-components": "0.16.0-dev.11",
12
- "@prisma-next/utils": "0.16.0-dev.11"
9
+ "@prisma-next/config": "0.16.0-dev.13",
10
+ "@prisma-next/contract": "0.16.0-dev.13",
11
+ "@prisma-next/framework-components": "0.16.0-dev.13",
12
+ "@prisma-next/utils": "0.16.0-dev.13"
13
13
  },
14
14
  "devDependencies": {
15
- "@prisma-next/tsconfig": "0.16.0-dev.11",
16
- "@prisma-next/tsdown": "0.16.0-dev.11",
15
+ "@prisma-next/tsconfig": "0.16.0-dev.13",
16
+ "@prisma-next/tsdown": "0.16.0-dev.13",
17
17
  "tsdown": "0.22.8",
18
18
  "typescript": "5.9.3",
19
19
  "vitest": "4.1.10"
@@ -85,15 +85,14 @@ export type {
85
85
  CompositeTypeSymbol,
86
86
  FieldSymbol,
87
87
  ModelSymbol,
88
+ NamedTypeSymbol,
88
89
  NamespaceSymbol,
89
90
  ResolvedAttribute,
90
91
  ResolvedAttributeArg,
91
92
  ResolvedNamedTypeBinding,
92
93
  ResolvedTypeConstructorCall,
93
- ScalarSymbol,
94
94
  SymbolTable,
95
95
  SymbolTableResult,
96
96
  TopLevelScope,
97
- TypeAliasSymbol,
98
97
  } from '../symbol-table';
99
98
  export { buildSymbolTable } from '../symbol-table';
@@ -36,8 +36,7 @@ export interface SymbolTable {
36
36
 
37
37
  export interface TopLevelScope {
38
38
  readonly namespaces: Record<string, NamespaceSymbol>;
39
- readonly scalars: Record<string, ScalarSymbol>;
40
- readonly typeAliases: Record<string, TypeAliasSymbol>;
39
+ readonly namedTypes: Record<string, NamedTypeSymbol>;
41
40
  readonly blocks: Record<string, BlockSymbol>;
42
41
  readonly models: Record<string, ModelSymbol>;
43
42
  readonly compositeTypes: Record<string, CompositeTypeSymbol>;
@@ -88,15 +87,13 @@ export interface ResolvedNamedTypeBinding {
88
87
  readonly attributes: readonly ResolvedAttribute[];
89
88
  }
90
89
 
91
- export interface ScalarSymbol extends ResolvedNamedTypeBinding {
92
- readonly kind: 'scalar';
93
- readonly name: string;
94
- readonly node: NamedTypeDeclarationAst;
95
- readonly span: PslSpan;
96
- }
97
-
98
- export interface TypeAliasSymbol extends ResolvedNamedTypeBinding {
99
- readonly kind: 'typeAlias';
90
+ /**
91
+ * A `types {}` binding, collected without classification: whether the binding
92
+ * refines a target scalar is pronounced by the interpreter
93
+ * (`resolveNamedTypeDeclarations`), not by the family-blind symbol table.
94
+ */
95
+ export interface NamedTypeSymbol extends ResolvedNamedTypeBinding {
96
+ readonly kind: 'namedType';
100
97
  readonly name: string;
101
98
  readonly node: NamedTypeDeclarationAst;
102
99
  readonly span: PslSpan;
@@ -121,7 +118,6 @@ export interface FieldSymbol {
121
118
  export interface BuildSymbolTableOptions {
122
119
  readonly document: DocumentAst;
123
120
  readonly sourceFile: SourceFile;
124
- readonly scalarTypes: readonly string[];
125
121
  readonly pslBlockDescriptors: AuthoringPslBlockDescriptorNamespace;
126
122
  }
127
123
 
@@ -135,13 +131,11 @@ export interface SymbolTableResult {
135
131
  * should consume first-wins symbols rather than re-emitting duplicate diagnostics.
136
132
  */
137
133
  export function buildSymbolTable(options: BuildSymbolTableOptions): SymbolTableResult {
138
- const { document, sourceFile, scalarTypes, pslBlockDescriptors } = options;
134
+ const { document, sourceFile, pslBlockDescriptors } = options;
139
135
  const diagnostics: ParseDiagnostic[] = [];
140
- const scalarSet = new Set(scalarTypes);
141
136
 
142
137
  const namespaces: Record<string, NamespaceSymbol> = {};
143
- const scalars: Record<string, ScalarSymbol> = {};
144
- const typeAliases: Record<string, TypeAliasSymbol> = {};
138
+ const namedTypes: Record<string, NamedTypeSymbol> = {};
145
139
  const blocks: Record<string, BlockSymbol> = {};
146
140
  const models: Record<string, ModelSymbol> = {};
147
141
  const compositeTypes: Record<string, CompositeTypeSymbol> = {};
@@ -196,17 +190,13 @@ export function buildSymbolTable(options: BuildSymbolTableOptions): SymbolTableR
196
190
  if (name === undefined) continue;
197
191
  const resolved = resolveNamedTypeBinding(binding, sourceFile);
198
192
  const span = nodePslSpan(binding.syntax, sourceFile);
199
- if (isScalarBinding(binding, scalarSet)) {
200
- scalars[name] = { kind: 'scalar', name, node: binding, span, ...resolved };
201
- } else {
202
- typeAliases[name] = { kind: 'typeAlias', name, node: binding, span, ...resolved };
203
- }
193
+ namedTypes[name] = { kind: 'namedType', name, node: binding, span, ...resolved };
204
194
  }
205
195
  }
206
196
  }
207
197
 
208
198
  const table: SymbolTable = {
209
- topLevel: { namespaces, scalars, typeAliases, blocks, models, compositeTypes },
199
+ topLevel: { namespaces, namedTypes, blocks, models, compositeTypes },
210
200
  };
211
201
  return { table, diagnostics };
212
202
  }
@@ -416,13 +406,6 @@ function resolveNamedTypeBinding(
416
406
  };
417
407
  }
418
408
 
419
- function isScalarBinding(node: NamedTypeDeclarationAst, scalarTypes: Set<string>): boolean {
420
- const annotation = node.typeAnnotation();
421
- if (annotation === undefined || annotation.isConstructor()) return false;
422
- const base = annotation.name()?.identifier()?.name();
423
- return base !== undefined && scalarTypes.has(base);
424
- }
425
-
426
409
  function nameRange(name: IdentifierAst | undefined, sourceFile: SourceFile): Range | undefined {
427
410
  if (name === undefined) return undefined;
428
411
  for (const token of name.syntax.tokens()) {
@@ -1 +0,0 @@
1
- {"version":3,"file":"symbol-table-en_Bich3.d.mts","names":[],"sources":["../src/resolve.ts","../src/symbol-table.ts"],"mappings":";;;;UAaiB;WACN;WACA;WACA;WACA,aAAa;WACb,MAAM;;UAGA;WACN;WACA,eAAe;WACf,MAAM;;UAGA;WACN;WACA,eAAe;WACf,MAAM;;iBAGD,sBACd,WAAW,oBAAoB,mBAC/B,YAAY,aACX;iBAQa,uBACd,YAAY,SAAS,oBAAoB,oBACzC,YAAY,sBACF;iBAII,4BACd,YAAY,+BACZ,YAAY,aACX;iBAuCa,YAAY,MAAM,YAAY,YAAY,aAAa;;iBAUvD,eAAe,MAAM,YAAY,iBAAiB,YAAY,aAAa;iBAS3E,eAAe,OAAO,OAAO,YAAY,aAAa;;;UChFrD;WACN,UAAU;;UAGJ;WACN,YAAY,eAAe;WAC3B,SAAS,eAAe;WACxB,aAAa,eAAe;WAC5B,QAAQ,eAAe;WACvB,QAAQ,eAAe;WACvB,gBAAgB,eAAe;;UAGzB;WACN;WACA;WACA,MAAM;WACN,MAAM;WACN,QAAQ,eAAe;WACvB,gBAAgB,eAAe;WAC/B,QAAQ,eAAe;;UAGjB;WACN;WACA;WACA,MAAM;WACN,MAAM;WACN,QAAQ,eAAe;WACvB,qBAAqB;;UAGf;WACN;WACA;WACA,MAAM;WACN,MAAM;WACN,QAAQ,eAAe;WACvB,qBAAqB;;UAGf;WACN;WACA;WACA;WACA,MAAM;WACN,MAAM;;WAEN,OAAO;;UAGD;WACN;WACA,kBAAkB;WAClB;WACA,qBAAqB;;UAGf,qBAAqB;WAC3B;WACA;WACA,MAAM;WACN,MAAM;;UAGA,wBAAwB;WAC9B;WACA;WACA,MAAM;WACN,MAAM;;UAGA;WACN;WACA;WACA,MAAM;WACN,MAAM;WACN;WACA;WACA;WACA;WACA;WACA,kBAAkB;WAClB,qBAAqB;;WAErB;;UAGM;WACN,UAAU;WACV,YAAY;WACZ;WACA,qBAAqB;;UAGf;WACN,OAAO;WACP,sBAAsB;;;;;;iBAOjB,iBAAiB,SAAS,0BAA0B"}