@prisma-next/psl-parser 0.14.0-dev.75 → 0.14.0-dev.77

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,6 +1,6 @@
1
- import { P as AstNode, T as ExpressionAst, b as FieldAttributeAst, et as SourceFile, x as ModelAttributeAst } from "./parse-BazJr7Ye.mjs";
1
+ import { C as AttributeArgAst, P as AstNode, T as ExpressionAst, b as FieldAttributeAst, et as SourceFile, x as ModelAttributeAst } from "./parse-BazJr7Ye.mjs";
2
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-C-AH04Ug.mjs";
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, PslTypeConstructorCall, PslTypesBlock, flatPslModels, namespacePslExtensionBlocks } from "@prisma-next/framework-components/psl-ast";
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";
6
6
  import { Simplify, UnionToIntersection } from "@prisma-next/utils/types";
@@ -66,11 +66,26 @@ interface FieldRefArgType extends ArgType<string> {
66
66
  }
67
67
  declare function fieldRef(scope: FieldRefScope): FieldRefArgType;
68
68
  //#endregion
69
+ //#region src/attribute-spec/combinators/func-call.d.ts
70
+ interface FuncCallSig {
71
+ readonly positional?: readonly PositionalParam<unknown>[];
72
+ readonly named?: Readonly<Record<string, Param<unknown>>>;
73
+ }
74
+ interface TypedFuncCall {
75
+ readonly fn: string;
76
+ readonly span: PslSpan$1;
77
+ readonly args: Readonly<Record<string, unknown>>;
78
+ }
79
+ declare function funcCall(name: string, sig: FuncCallSig): ArgType<TypedFuncCall>;
80
+ //#endregion
69
81
  //#region src/attribute-spec/combinators/identifier.d.ts
70
82
  declare function identifier<const N extends string>(name: N): ArgType<N>;
71
83
  //#endregion
72
84
  //#region src/attribute-spec/combinators/int.d.ts
73
- declare function int(): ArgType<number>;
85
+ declare function int(opts?: {
86
+ min?: number;
87
+ max?: number;
88
+ }): ArgType<number>;
74
89
  //#endregion
75
90
  //#region src/attribute-spec/combinators/list.d.ts
76
91
  interface ListOptions {
@@ -79,6 +94,10 @@ interface ListOptions {
79
94
  }
80
95
  declare function list<T>(of: ArgType<T>, opts?: ListOptions): ArgType<T[]>;
81
96
  //#endregion
97
+ //#region src/attribute-spec/combinators/num.d.ts
98
+ declare function num(): ArgType<number>;
99
+ declare function num(value: number): ArgType<number>;
100
+ //#endregion
82
101
  //#region src/attribute-spec/combinators/one-of.d.ts
83
102
  declare function oneOf<Alts extends readonly [ArgType<unknown>, ...ArgType<unknown>[]]>(...alts: Alts): ArgType<OutOf<Alts[number]>>;
84
103
  //#endregion
@@ -97,6 +116,12 @@ interface FieldAttributeConfig<Pos extends readonly PositionalParam[], Named ext
97
116
  declare function fieldAttribute<const Pos extends readonly PositionalParam[] = readonly [], const Named extends Record<string, Param<unknown>> = Record<never, never>>(name: string, config: FieldAttributeConfig<Pos, Named>): AttributeSpec<AttributeOut<Pos, Named>>;
98
117
  //#endregion
99
118
  //#region src/attribute-spec/interpret.d.ts
119
+ interface ArgBindingSpec {
120
+ readonly name: string;
121
+ readonly positional: readonly PositionalParam<unknown>[];
122
+ readonly named: Readonly<Record<string, Param<unknown>>>;
123
+ }
124
+ declare function interpretArgs(args: Iterable<AttributeArgAst>, spec: ArgBindingSpec, ctx: InterpretCtx, span: PslSpan$1): Result<Record<string, unknown>, readonly PslDiagnostic$1[]>;
100
125
  declare function interpretAttribute<Out>(attrNode: FieldAttributeAst | ModelAttributeAst, spec: AttributeSpec<Out>, ctx: InterpretCtx): Result<Out, readonly PslDiagnostic$1[]>;
101
126
  //#endregion
102
127
  //#region src/attribute-spec/model-attribute.d.ts
@@ -121,5 +146,5 @@ declare function validateExtensionBlockFromSymbol(input: {
121
146
  readonly codecLookup: CodecLookup;
122
147
  }): readonly PslDiagnostic$1[];
123
148
  //#endregion
124
- export { type ArgType, type AttributeLevel, type AttributeOut, type AttributeSpec, type BlockSymbol, type BuildSymbolTableOptions, type CompositeTypeSymbol, type FieldRefArgType, type FieldRefScope, type FieldSymbol, 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, bool, buildSymbolTable, entityRef, fieldAttribute, fieldRef, findBlockDescriptor, flatPslModels, getPositionalArgument, identifier, int, interpretAttribute, keywordPslSpan, leafDiagnostic, list, modelAttribute, namespacePslExtensionBlocks, nodePslSpan, oneOf, optional, parseQuotedStringLiteral, rangeToPslSpan, readResolvedAttribute, readResolvedAttributes, readResolvedConstructorCall, record, str, validateExtensionBlockFromSymbol };
149
+ 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 };
125
150
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/attribute-helpers.ts","../src/attribute-spec/types.ts","../src/attribute-spec/combinators/bool.ts","../src/attribute-spec/combinators/diagnostic.ts","../src/attribute-spec/combinators/entity-ref.ts","../src/attribute-spec/combinators/field-ref.ts","../src/attribute-spec/combinators/identifier.ts","../src/attribute-spec/combinators/int.ts","../src/attribute-spec/combinators/list.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/interpret.ts","../src/attribute-spec/model-attribute.ts","../src/attribute-spec/optional.ts","../src/extension-block.ts"],"mappings":";;;;;;;;;iBAEgB,qBAAA,CAAsB,SAAA,EAAW,cAAY,EAAE,KAAA;AAAA,iBAK/C,wBAAA,CAAyB,KAAa;;;KCA1C,cAAA;AAAA,UAEK,OAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SAEA,IAAA,GAAO,CAAA;EAChB,KAAA,CAAM,GAAA,EAAK,aAAA,EAAe,GAAA,EAAK,YAAA,GAAe,MAAA,CAAO,CAAA,WAAY,eAAA;AAAA;AAAA,UAGlD,YAAA;EAAA,SACN,KAAA,EAAO,cAAA;EAAA,SACP,QAAA;EAAA,SACA,UAAA,EAAY,UAAA;EAAA,SACZ,SAAA,EAAW,WAAA;EACpB,sBAAA,IAA0B,WAAA;EAAA,SACjB,KAAA,GAAQ,WAAA;AAAA;AAAA,UAGF,eAAA,YAA2B,OAAA,CAAQ,CAAA;EAAA,SAEzC,QAAA;EAAA,SACA,UAAA;EAAA,SACA,YAAA,GAAe,CAAA;AAAA;AAAA,KAGd,KAAA,MAAW,OAAO,CAAC,CAAA;AAAA,UAEd,eAAA;EAAA,SACN,GAAA;EAAA,SACA,IAAA,EAAM,KAAK,CAAC,CAAA;AAAA;AAAA,UAGN,aAAA;EAAA,SACN,KAAA,EAAO,cAAA;EAAA,SACP,IAAA;EAAA,SACA,UAAA,WAAqB,eAAA;EAAA,SACrB,KAAA,EAAO,QAAA,CAAS,MAAA,SAAe,KAAA;EAAA,SAC/B,MAAA,IAAU,MAAA,EAAQ,GAAA,EAAK,GAAA,EAAK,YAAA,cAA0B,eAAA;AAAA;AAAA,KAGrD,KAAA,MAAW,CAAA,SAAU,OAAO,YAAY,CAAA;AAAA,KAExC,QAAA,WAAmB,MAAA,SAAe,KAAA,cAAmB,QAAA,eACjD,CAAA,IAAK,CAAA,CAAE,CAAA,U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A,cACb,OAAA,WACC,2BAA2B;AAAA,iBAcd,gCAAA,CAAiC,KAAA;EAAA,SACtC,KAAA,EAAO,WAAA;EAAA,SACP,UAAA,EAAY,2BAAA;EAAA,SACZ,WAAA,EAAa,WAAA;EAAA,SACb,UAAA,EAAY,UAAA;EAAA,SACZ,QAAA;EAAA,SACA,WAAA,EAAa,WAAA;AAAA,aACX,eAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/attribute-helpers.ts","../src/attribute-spec/types.ts","../src/attribute-spec/combinators/bool.ts","../src/attribute-spec/combinators/diagnostic.ts","../src/attribute-spec/combinators/entity-ref.ts","../src/attribute-spec/combinators/field-ref.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/interpret.ts","../src/attribute-spec/model-attribute.ts","../src/attribute-spec/optional.ts","../src/extension-block.ts"],"mappings":";;;;;;;;;iBAEgB,qBAAA,CAAsB,SAAA,EAAW,cAAY,EAAE,KAAA;AAAA,iBAK/C,wBAAA,CAAyB,KAAa;;;KCA1C,cAAA;AAAA,UAEK,OAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SAEA,IAAA,GAAO,CAAA;EAChB,KAAA,CAAM,GAAA,EAAK,aAAA,EAAe,GAAA,EAAK,YAAA,GAAe,MAAA,CAAO,CAAA,WAAY,eAAA;AAAA;AAAA,UAGlD,YAAA;EAAA,SACN,KAAA,EAAO,cAAA;EAAA,SACP,QAAA;EAAA,SACA,UAAA,EAAY,UAAA;EAAA,SACZ,SAAA,EAAW,WAAA;EACpB,sBAAA,IAA0B,WAAA;EAAA,SACjB,KAAA,GAAQ,WAAA;AAAA;AAAA,UAGF,eAAA,YAA2B,OA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CAAA,SAAU,eAAA,CAAgB,CAAA;;;iBCgBhF,mBAAA,CACd,WAAA,EAAa,oCAAA,cACb,OAAA,WACC,2BAA2B;AAAA,iBAcd,gCAAA,CAAiC,KAAA;EAAA,SACtC,KAAA,EAAO,WAAA;EAAA,SACP,UAAA,EAAY,2BAAA;EAAA,SACZ,WAAA,EAAa,WAAA;EAAA,SACb,UAAA,EAAY,UAAA;EAAA,SACZ,QAAA;EAAA,SACA,WAAA,EAAa,WAAA;AAAA,aACX,eAAA"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { b as ObjectLiteralExprAst, c as NamespaceDeclarationAst, g as BooleanLiteralExprAst, i as GenericBlockDeclarationAst, k as printSyntax, l as TypesBlockAst, m as ArrayLiteralAst, o as ModelDeclarationAst, t as CompositeTypeDeclarationAst, v as NumberLiteralExprAst, w as IdentifierAst, x as StringLiteralExprAst } from "./declarations-DR6To8_k.mjs";
1
+ import { _ as FunctionCallAst, b as ObjectLiteralExprAst, c as NamespaceDeclarationAst, g as BooleanLiteralExprAst, i as GenericBlockDeclarationAst, k as printSyntax, l as TypesBlockAst, m as ArrayLiteralAst, o as ModelDeclarationAst, t as CompositeTypeDeclarationAst, v as NumberLiteralExprAst, w as IdentifierAst, x as StringLiteralExprAst } from "./declarations-DR6To8_k.mjs";
2
2
  import { UNSPECIFIED_PSL_NAMESPACE_ID, flatPslModels, makePslNamespace, makePslNamespaceEntries, namespacePslExtensionBlocks, validateExtensionBlock } from "@prisma-next/framework-components/psl-ast";
3
3
  import { notOk, ok } from "@prisma-next/utils/result";
4
4
  import { blindCast } from "@prisma-next/utils/casts";
@@ -145,6 +145,133 @@ function fieldRef(scope) {
145
145
  };
146
146
  }
147
147
  //#endregion
148
+ //#region src/attribute-spec/interpret.ts
149
+ function interpretArgs(args, spec, ctx, span) {
150
+ const diagnostics = [];
151
+ const output = {};
152
+ const seen = /* @__PURE__ */ new Set();
153
+ let positionalSlot = 0;
154
+ let reportedExcess = false;
155
+ for (const arg of args) {
156
+ const name = arg.name()?.name();
157
+ let key;
158
+ let param;
159
+ if (name === void 0) {
160
+ const posParam = spec.positional[positionalSlot];
161
+ if (posParam === void 0) {
162
+ if (!reportedExcess) {
163
+ diagnostics.push(diagnostic(`Attribute "${spec.name}" received too many positional arguments`, ctx, span));
164
+ reportedExcess = true;
165
+ }
166
+ continue;
167
+ }
168
+ positionalSlot += 1;
169
+ key = posParam.key;
170
+ param = posParam.type;
171
+ } else {
172
+ const namedParam = Object.hasOwn(spec.named, name) ? spec.named[name] : void 0;
173
+ if (namedParam === void 0) {
174
+ diagnostics.push(diagnostic(`Attribute "${spec.name}" received unknown argument "${name}"`, ctx, nodePslSpan(arg.syntax, ctx.sourceFile)));
175
+ continue;
176
+ }
177
+ key = name;
178
+ param = namedParam;
179
+ }
180
+ if (seen.has(key)) {
181
+ diagnostics.push(diagnostic(`Attribute "${spec.name}" received duplicate argument "${key}"`, ctx, nodePslSpan(arg.syntax, ctx.sourceFile)));
182
+ continue;
183
+ }
184
+ seen.add(key);
185
+ const result = parseArgValue(arg, param, ctx, diagnostics);
186
+ if (result.ok) output[key] = result.value;
187
+ }
188
+ const finalized = /* @__PURE__ */ new Set();
189
+ const finalizeAbsentKey = (key, positionalParam, namedParam) => {
190
+ if (finalized.has(key) || seen.has(key)) return;
191
+ finalized.add(key);
192
+ const effective = namedParam ?? positionalParam;
193
+ if (effective === void 0) return;
194
+ if (isOptionalArgType(effective)) {
195
+ if (effective.hasDefault) output[key] = effective.defaultValue;
196
+ return;
197
+ }
198
+ diagnostics.push(diagnostic(`Attribute "${spec.name}" is missing required argument "${key}"`, ctx, span));
199
+ };
200
+ for (const param of spec.positional) {
201
+ const namedParam = Object.hasOwn(spec.named, param.key) ? spec.named[param.key] : void 0;
202
+ finalizeAbsentKey(param.key, param.type, namedParam);
203
+ }
204
+ for (const key of Object.keys(spec.named)) finalizeAbsentKey(key, void 0, spec.named[key]);
205
+ if (diagnostics.length > 0) return notOk(diagnostics);
206
+ return ok(output);
207
+ }
208
+ function interpretAttribute(attrNode, spec, ctx) {
209
+ const attributeSpan = nodePslSpan(attrNode.syntax, ctx.sourceFile);
210
+ const bound = interpretArgs(attrNode.argList()?.args() ?? [], spec, ctx, attributeSpan);
211
+ if (!bound.ok) return notOk(bound.failure);
212
+ const value = blindCast(bound.value);
213
+ if (spec.refine !== void 0) {
214
+ const refineDiagnostics = spec.refine(value, ctx);
215
+ if (refineDiagnostics.length > 0) return notOk(refineDiagnostics);
216
+ }
217
+ return ok(value);
218
+ }
219
+ function parseArgValue(arg, argType, ctx, diagnostics) {
220
+ const value = arg.value();
221
+ if (value === void 0) {
222
+ const missing = diagnostic("Attribute argument is missing a value", ctx, nodePslSpan(arg.syntax, ctx.sourceFile));
223
+ diagnostics.push(missing);
224
+ return notOk([missing]);
225
+ }
226
+ const result = argType.parse(value, ctx);
227
+ if (!result.ok) for (const failure of result.failure) diagnostics.push(failure);
228
+ return result;
229
+ }
230
+ function isOptionalArgType(param) {
231
+ return "optional" in param && param.optional === true;
232
+ }
233
+ function diagnostic(message, ctx, span) {
234
+ return {
235
+ code: ATTRIBUTE_DIAGNOSTIC_CODE,
236
+ message,
237
+ sourceId: ctx.sourceId,
238
+ span
239
+ };
240
+ }
241
+ //#endregion
242
+ //#region src/attribute-spec/combinators/func-call.ts
243
+ function funcCall(name, sig) {
244
+ return {
245
+ kind: "funcCall",
246
+ label: "function call",
247
+ parse: (arg, ctx) => {
248
+ const guard = matchCallee(arg, name, ctx);
249
+ if (!guard.ok) return guard;
250
+ const span = nodePslSpan(guard.value.syntax, ctx.sourceFile);
251
+ const bound = interpretArgs(guard.value.args(), {
252
+ name,
253
+ positional: sig.positional ?? [],
254
+ named: sig.named ?? {}
255
+ }, ctx, span);
256
+ if (!bound.ok) return notOk(bound.failure);
257
+ return ok({
258
+ fn: name,
259
+ span,
260
+ args: bound.value
261
+ });
262
+ }
263
+ };
264
+ }
265
+ function matchCallee(arg, name, ctx) {
266
+ if (!(arg instanceof FunctionCallAst)) return notOk([leafDiagnostic(ctx, arg, "Expected a function call")]);
267
+ const qname = arg.name();
268
+ if (qname === void 0 || qname.dot() !== void 0 || qname.colon() !== void 0) return notOk([leafDiagnostic(ctx, arg, "Expected a function call")]);
269
+ const calleeName = qname.identifier()?.token()?.text;
270
+ if (calleeName === void 0) return notOk([leafDiagnostic(ctx, arg, "Expected a function call")]);
271
+ if (calleeName !== name) return notOk([leafDiagnostic(ctx, arg, `Expected ${name}()`)]);
272
+ return ok(arg);
273
+ }
274
+ //#endregion
148
275
  //#region src/attribute-spec/combinators/identifier.ts
149
276
  function identifier(name) {
150
277
  return {
@@ -158,19 +285,29 @@ function identifier(name) {
158
285
  }
159
286
  //#endregion
160
287
  //#region src/attribute-spec/combinators/int.ts
161
- function int() {
288
+ function int(opts) {
289
+ const min = opts?.min;
290
+ const max = opts?.max;
162
291
  return {
163
292
  kind: "int",
164
293
  label: "integer",
165
294
  parse: (arg, ctx) => {
166
295
  if (arg instanceof NumberLiteralExprAst) {
167
296
  const value = arg.value();
168
- if (value !== void 0 && Number.isInteger(value)) return ok(value);
297
+ if (value !== void 0 && Number.isInteger(value)) {
298
+ if ((min === void 0 || value >= min) && (max === void 0 || value <= max)) return ok(value);
299
+ return notOk([leafDiagnostic(ctx, arg, rangeMessage(min, max))]);
300
+ }
169
301
  }
170
302
  return notOk([leafDiagnostic(ctx, arg, "Expected an integer literal")]);
171
303
  }
172
304
  };
173
305
  }
306
+ function rangeMessage(min, max) {
307
+ if (min !== void 0 && max !== void 0) return `Expected an integer between ${min} and ${max}`;
308
+ if (min !== void 0) return `Expected an integer greater than or equal to ${min}`;
309
+ return `Expected an integer less than or equal to ${max}`;
310
+ }
174
311
  //#endregion
175
312
  //#region src/attribute-spec/combinators/list.ts
176
313
  function list(of, opts) {
@@ -203,6 +340,21 @@ function list(of, opts) {
203
340
  };
204
341
  }
205
342
  //#endregion
343
+ //#region src/attribute-spec/combinators/num.ts
344
+ function num(value) {
345
+ return {
346
+ kind: "num",
347
+ label: value === void 0 ? "number" : String(value),
348
+ parse: (arg, ctx) => {
349
+ if (arg instanceof NumberLiteralExprAst) {
350
+ const parsed = arg.value();
351
+ if (parsed !== void 0 && (value === void 0 || parsed === value)) return ok(parsed);
352
+ }
353
+ return notOk([leafDiagnostic(ctx, arg, value === void 0 ? "Expected a number literal" : `Expected ${value}`)]);
354
+ }
355
+ };
356
+ }
357
+ //#endregion
206
358
  //#region src/attribute-spec/combinators/one-of.ts
207
359
  function oneOf(...alts) {
208
360
  const label = alts.map((alt) => alt.label).join(" | ");
@@ -282,95 +434,6 @@ function fieldAttribute(name, config) {
282
434
  };
283
435
  }
284
436
  //#endregion
285
- //#region src/attribute-spec/interpret.ts
286
- function interpretAttribute(attrNode, spec, ctx) {
287
- const diagnostics = [];
288
- const attributeSpan = nodePslSpan(attrNode.syntax, ctx.sourceFile);
289
- const output = {};
290
- const seen = /* @__PURE__ */ new Set();
291
- let positionalSlot = 0;
292
- let reportedExcess = false;
293
- for (const arg of attrNode.argList()?.args() ?? []) {
294
- const name = arg.name()?.name();
295
- let key;
296
- let param;
297
- if (name === void 0) {
298
- const posParam = spec.positional[positionalSlot];
299
- if (posParam === void 0) {
300
- if (!reportedExcess) {
301
- diagnostics.push(diagnostic(`Attribute "${spec.name}" received too many positional arguments`, ctx, attributeSpan));
302
- reportedExcess = true;
303
- }
304
- continue;
305
- }
306
- positionalSlot += 1;
307
- key = posParam.key;
308
- param = posParam.type;
309
- } else {
310
- const namedParam = Object.hasOwn(spec.named, name) ? spec.named[name] : void 0;
311
- if (namedParam === void 0) {
312
- diagnostics.push(diagnostic(`Attribute "${spec.name}" received unknown argument "${name}"`, ctx, nodePslSpan(arg.syntax, ctx.sourceFile)));
313
- continue;
314
- }
315
- key = name;
316
- param = namedParam;
317
- }
318
- if (seen.has(key)) {
319
- diagnostics.push(diagnostic(`Attribute "${spec.name}" received duplicate argument "${key}"`, ctx, nodePslSpan(arg.syntax, ctx.sourceFile)));
320
- continue;
321
- }
322
- seen.add(key);
323
- const result = parseArgValue(arg, param, ctx, diagnostics);
324
- if (result.ok) output[key] = result.value;
325
- }
326
- const finalized = /* @__PURE__ */ new Set();
327
- const finalizeAbsentKey = (key, positionalParam, namedParam) => {
328
- if (finalized.has(key) || seen.has(key)) return;
329
- finalized.add(key);
330
- const effective = namedParam ?? positionalParam;
331
- if (effective === void 0) return;
332
- if (isOptionalArgType(effective)) {
333
- if (effective.hasDefault) output[key] = effective.defaultValue;
334
- return;
335
- }
336
- diagnostics.push(diagnostic(`Attribute "${spec.name}" is missing required argument "${key}"`, ctx, attributeSpan));
337
- };
338
- for (const param of spec.positional) {
339
- const namedParam = Object.hasOwn(spec.named, param.key) ? spec.named[param.key] : void 0;
340
- finalizeAbsentKey(param.key, param.type, namedParam);
341
- }
342
- for (const key of Object.keys(spec.named)) finalizeAbsentKey(key, void 0, spec.named[key]);
343
- if (diagnostics.length > 0) return notOk(diagnostics);
344
- const value = blindCast(output);
345
- if (spec.refine !== void 0) {
346
- const refineDiagnostics = spec.refine(value, ctx);
347
- if (refineDiagnostics.length > 0) return notOk(refineDiagnostics);
348
- }
349
- return ok(value);
350
- }
351
- function parseArgValue(arg, argType, ctx, diagnostics) {
352
- const value = arg.value();
353
- if (value === void 0) {
354
- const missing = diagnostic("Attribute argument is missing a value", ctx, nodePslSpan(arg.syntax, ctx.sourceFile));
355
- diagnostics.push(missing);
356
- return notOk([missing]);
357
- }
358
- const result = argType.parse(value, ctx);
359
- if (!result.ok) for (const failure of result.failure) diagnostics.push(failure);
360
- return result;
361
- }
362
- function isOptionalArgType(param) {
363
- return "optional" in param && param.optional === true;
364
- }
365
- function diagnostic(message, ctx, span) {
366
- return {
367
- code: ATTRIBUTE_DIAGNOSTIC_CODE,
368
- message,
369
- sourceId: ctx.sourceId,
370
- span
371
- };
372
- }
373
- //#endregion
374
437
  //#region src/attribute-spec/model-attribute.ts
375
438
  function modelAttribute(name, config) {
376
439
  return {
@@ -793,6 +856,6 @@ function nodeRange(node, sourceFile) {
793
856
  };
794
857
  }
795
858
  //#endregion
796
- export { bool, buildSymbolTable, entityRef, fieldAttribute, fieldRef, findBlockDescriptor, flatPslModels, getPositionalArgument, identifier, int, interpretAttribute, keywordPslSpan, leafDiagnostic, list, modelAttribute, namespacePslExtensionBlocks, nodePslSpan, oneOf, optional, parseQuotedStringLiteral, rangeToPslSpan, readResolvedAttribute, readResolvedAttributes, readResolvedConstructorCall, record, str, validateExtensionBlockFromSymbol };
859
+ export { 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 };
797
860
 
798
861
  //# sourceMappingURL=index.mjs.map
@@ -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/combinators/identifier.ts","../src/attribute-spec/combinators/int.ts","../src/attribute-spec/combinators/list.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/interpret.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 } 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\nexport function int(): ArgType<number> {\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)) return ok(value);\n }\n return notOk([leafDiagnostic(ctx, arg, 'Expected an integer 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 { 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 { 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, 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 { ArgType, AttributeSpec, InterpretCtx, OptionalArgType, Param } from './types';\n\nexport function interpretAttribute<Out>(\n attrNode: FieldAttributeAst | ModelAttributeAst,\n spec: AttributeSpec<Out>,\n ctx: InterpretCtx,\n): Result<Out, readonly PslDiagnostic[]> {\n const diagnostics: PslDiagnostic[] = [];\n const attributeSpan = nodePslSpan(attrNode.syntax, ctx.sourceFile);\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 attrNode.argList()?.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 attributeSpan,\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(\n `Attribute \"${spec.name}\" is missing required argument \"${key}\"`,\n ctx,\n attributeSpan,\n ),\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\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 >(output);\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 } 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,QAAQ,QAAQ,IAAI,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B,YAAY,UAAU;CAC1E,OAAO;EACL;EACA,GAAI,CAAC,iBAAiB,aAAa,KAAA,IAAY,EAAE,SAAS,IAAI,CAAC;EAC/D,GAAI,oBAAoB,KAAA,IAAY,EAAE,gBAAgB,IAAI,CAAC;EAC3D,YAAY,uBAAuB,KAAK,WAAW,GAAG,UAAU;CAClE;AACF;AAEA,SAAS,gBAAgB,MAA+B,aAAmC;CACzF,MAAM,aAAa,KAAK,eAAe;CACvC,IAAI,eAAe,KAAA,KAAa,WAAW,cAAc,GAAG,OAAO;CACnE,MAAM,OAAO,WAAW,KAAK,CAAC,EAAE,WAAW,CAAC,EAAE,KAAK;CACnD,OAAO,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 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,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,CAAC,OAAO,OAAO,KAAA;CACnB,OAAO,MAAM,MAAM;AACrB;;;ACqBA,SAAgB,sBACd,WACA,YACmB;CACnB,OAAO;EACL,MAAM,cAAc,UAAU,KAAK,CAAC;EACpC,MAAM,oBAAoB,UAAU,QAAQ,GAAG,UAAU;EACzD,MAAM,YAAY,UAAU,QAAQ,UAAU;CAChD;AACF;AAEA,SAAgB,uBACd,YACA,YAC8B;CAC9B,OAAO,MAAM,KAAK,aAAa,cAAc,sBAAsB,WAAW,UAAU,CAAC;AAC3F;AAEA,SAAgB,4BACd,YACA,YACyC;CACzC,MAAM,UAAU,YAAY,QAAQ;CACpC,IAAI,eAAe,KAAA,KAAa,YAAY,KAAA,GAAW,OA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  "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.14.0-dev.75",
10
- "@prisma-next/contract": "0.14.0-dev.75",
11
- "@prisma-next/framework-components": "0.14.0-dev.75",
12
- "@prisma-next/utils": "0.14.0-dev.75"
9
+ "@prisma-next/config": "0.14.0-dev.77",
10
+ "@prisma-next/contract": "0.14.0-dev.77",
11
+ "@prisma-next/framework-components": "0.14.0-dev.77",
12
+ "@prisma-next/utils": "0.14.0-dev.77"
13
13
  },
14
14
  "devDependencies": {
15
- "@prisma-next/tsconfig": "0.14.0-dev.75",
16
- "@prisma-next/tsdown": "0.14.0-dev.75",
15
+ "@prisma-next/tsconfig": "0.14.0-dev.77",
16
+ "@prisma-next/tsdown": "0.14.0-dev.77",
17
17
  "tsdown": "0.22.3",
18
18
  "typescript": "5.9.3",
19
19
  "vitest": "4.1.10"
@@ -0,0 +1,65 @@
1
+ import type { PslDiagnostic, PslSpan } from '@prisma-next/framework-components/psl-ast';
2
+ import { notOk, ok, type Result } from '@prisma-next/utils/result';
3
+ import { nodePslSpan } from '../../resolve';
4
+ import type { ExpressionAst } from '../../syntax/ast/expressions';
5
+ import { FunctionCallAst } from '../../syntax/ast/expressions';
6
+ import { interpretArgs } from '../interpret';
7
+ import type { ArgType, InterpretCtx, Param, PositionalParam } from '../types';
8
+ import { leafDiagnostic } from './diagnostic';
9
+
10
+ // The argument signature of a pinned function call — the same positional/named shape an attribute
11
+ // spec uses. Omitted groups default to empty, so a nullary call needs neither key.
12
+ export interface FuncCallSig {
13
+ readonly positional?: readonly PositionalParam<unknown>[];
14
+ readonly named?: Readonly<Record<string, Param<unknown>>>;
15
+ }
16
+
17
+ export interface TypedFuncCall {
18
+ readonly fn: string;
19
+ readonly span: PslSpan;
20
+ readonly args: Readonly<Record<string, unknown>>;
21
+ }
22
+
23
+ // A name-pinned function-call argument — `funcCall('now', {})` matches `now()`, parsing the call's
24
+ // arguments through `sig`.
25
+ export function funcCall(name: string, sig: FuncCallSig): ArgType<TypedFuncCall> {
26
+ return {
27
+ kind: 'funcCall',
28
+ label: 'function call',
29
+ parse: (arg, ctx): Result<TypedFuncCall, readonly PslDiagnostic[]> => {
30
+ const guard = matchCallee(arg, name, ctx);
31
+ if (!guard.ok) return guard;
32
+ const span = nodePslSpan(guard.value.syntax, ctx.sourceFile);
33
+ const bound = interpretArgs(
34
+ guard.value.args(),
35
+ { name, positional: sig.positional ?? [], named: sig.named ?? {} },
36
+ ctx,
37
+ span,
38
+ );
39
+ if (!bound.ok) return notOk<readonly PslDiagnostic[]>(bound.failure);
40
+ return ok({ fn: name, span, args: bound.value });
41
+ },
42
+ };
43
+ }
44
+
45
+ function matchCallee(
46
+ arg: ExpressionAst,
47
+ name: string,
48
+ ctx: InterpretCtx,
49
+ ): Result<FunctionCallAst, readonly PslDiagnostic[]> {
50
+ if (!(arg instanceof FunctionCallAst)) {
51
+ return notOk([leafDiagnostic(ctx, arg, 'Expected a function call')]);
52
+ }
53
+ const qname = arg.name();
54
+ if (qname === undefined || qname.dot() !== undefined || qname.colon() !== undefined) {
55
+ return notOk([leafDiagnostic(ctx, arg, 'Expected a function call')]);
56
+ }
57
+ const calleeName = qname.identifier()?.token()?.text;
58
+ if (calleeName === undefined) {
59
+ return notOk([leafDiagnostic(ctx, arg, 'Expected a function call')]);
60
+ }
61
+ if (calleeName !== name) {
62
+ return notOk([leafDiagnostic(ctx, arg, `Expected ${name}()`)]);
63
+ }
64
+ return ok(arg);
65
+ }
@@ -4,16 +4,32 @@ import { NumberLiteralExprAst } from '../../syntax/ast/expressions';
4
4
  import type { ArgType } from '../types';
5
5
  import { leafDiagnostic } from './diagnostic';
6
6
 
7
- export function int(): ArgType<number> {
7
+ // An integer literal reduced to its numeric value. Passing `min`/`max` additionally rejects
8
+ // out-of-range integers with a distinct range message, leaving the integer-only check intact.
9
+ export function int(opts?: { min?: number; max?: number }): ArgType<number> {
10
+ const min = opts?.min;
11
+ const max = opts?.max;
8
12
  return {
9
13
  kind: 'int',
10
14
  label: 'integer',
11
15
  parse: (arg, ctx): Result<number, readonly PslDiagnostic[]> => {
12
16
  if (arg instanceof NumberLiteralExprAst) {
13
17
  const value = arg.value();
14
- if (value !== undefined && Number.isInteger(value)) return ok(value);
18
+ if (value !== undefined && Number.isInteger(value)) {
19
+ if ((min === undefined || value >= min) && (max === undefined || value <= max)) {
20
+ return ok(value);
21
+ }
22
+ return notOk([leafDiagnostic(ctx, arg, rangeMessage(min, max))]);
23
+ }
15
24
  }
16
25
  return notOk([leafDiagnostic(ctx, arg, 'Expected an integer literal')]);
17
26
  },
18
27
  };
19
28
  }
29
+
30
+ function rangeMessage(min: number | undefined, max: number | undefined): string {
31
+ if (min !== undefined && max !== undefined)
32
+ return `Expected an integer between ${min} and ${max}`;
33
+ if (min !== undefined) return `Expected an integer greater than or equal to ${min}`;
34
+ return `Expected an integer less than or equal to ${max}`;
35
+ }
@@ -0,0 +1,26 @@
1
+ import type { PslDiagnostic } from '@prisma-next/framework-components/psl-ast';
2
+ import { notOk, ok, type Result } from '@prisma-next/utils/result';
3
+ import { NumberLiteralExprAst } from '../../syntax/ast/expressions';
4
+ import type { ArgType } from '../types';
5
+ import { leafDiagnostic } from './diagnostic';
6
+
7
+ // A general number literal — any number, including floats — reduced to its numeric value.
8
+ // Passing `value` pins the combinator to that single literal (`num(4)` matches only `4`),
9
+ // mirroring how `identifier(name)` pins a bare identifier. Use `int()` when only integer
10
+ // literals are allowed.
11
+ export function num(): ArgType<number>;
12
+ export function num(value: number): ArgType<number>;
13
+ export function num(value?: number): ArgType<number> {
14
+ return {
15
+ kind: 'num',
16
+ label: value === undefined ? 'number' : String(value),
17
+ parse: (arg, ctx): Result<number, readonly PslDiagnostic[]> => {
18
+ if (arg instanceof NumberLiteralExprAst) {
19
+ const parsed = arg.value();
20
+ if (parsed !== undefined && (value === undefined || parsed === value)) return ok(parsed);
21
+ }
22
+ const message = value === undefined ? 'Expected a number literal' : `Expected ${value}`;
23
+ return notOk([leafDiagnostic(ctx, arg, message)]);
24
+ },
25
+ };
26
+ }
@@ -5,22 +5,38 @@ import { nodePslSpan } from '../resolve';
5
5
  import type { FieldAttributeAst, ModelAttributeAst } from '../syntax/ast/attributes';
6
6
  import type { AttributeArgAst } from '../syntax/ast/expressions';
7
7
  import { ATTRIBUTE_DIAGNOSTIC_CODE } from './combinators/diagnostic';
8
- import type { ArgType, AttributeSpec, InterpretCtx, OptionalArgType, Param } from './types';
8
+ import type {
9
+ ArgType,
10
+ AttributeSpec,
11
+ InterpretCtx,
12
+ OptionalArgType,
13
+ Param,
14
+ PositionalParam,
15
+ } from './types';
9
16
 
10
- export function interpretAttribute<Out>(
11
- attrNode: FieldAttributeAst | ModelAttributeAst,
12
- spec: AttributeSpec<Out>,
17
+ // The positional/named argument-binding for an attribute or a function call. `name` labels the
18
+ // callee in binding diagnostics (`Attribute "<name>" …`); `span` anchors the arity diagnostics
19
+ // (too-many / missing) that have no per-argument node to point at.
20
+ export interface ArgBindingSpec {
21
+ readonly name: string;
22
+ readonly positional: readonly PositionalParam<unknown>[];
23
+ readonly named: Readonly<Record<string, Param<unknown>>>;
24
+ }
25
+
26
+ export function interpretArgs(
27
+ args: Iterable<AttributeArgAst>,
28
+ spec: ArgBindingSpec,
13
29
  ctx: InterpretCtx,
14
- ): Result<Out, readonly PslDiagnostic[]> {
30
+ span: PslSpan,
31
+ ): Result<Record<string, unknown>, readonly PslDiagnostic[]> {
15
32
  const diagnostics: PslDiagnostic[] = [];
16
- const attributeSpan = nodePslSpan(attrNode.syntax, ctx.sourceFile);
17
33
 
18
34
  const output: Record<string, unknown> = {};
19
35
  const seen = new Set<string>();
20
36
  let positionalSlot = 0;
21
37
  let reportedExcess = false;
22
38
 
23
- for (const arg of attrNode.argList()?.args() ?? []) {
39
+ for (const arg of args) {
24
40
  const name = arg.name()?.name();
25
41
 
26
42
  let key: string;
@@ -33,7 +49,7 @@ export function interpretAttribute<Out>(
33
49
  diagnostic(
34
50
  `Attribute "${spec.name}" received too many positional arguments`,
35
51
  ctx,
36
- attributeSpan,
52
+ span,
37
53
  ),
38
54
  );
39
55
  reportedExcess = true;
@@ -89,11 +105,7 @@ export function interpretAttribute<Out>(
89
105
  return;
90
106
  }
91
107
  diagnostics.push(
92
- diagnostic(
93
- `Attribute "${spec.name}" is missing required argument "${key}"`,
94
- ctx,
95
- attributeSpan,
96
- ),
108
+ diagnostic(`Attribute "${spec.name}" is missing required argument "${key}"`, ctx, span),
97
109
  );
98
110
  };
99
111
 
@@ -108,11 +120,22 @@ export function interpretAttribute<Out>(
108
120
  if (diagnostics.length > 0) {
109
121
  return notOk<readonly PslDiagnostic[]>(diagnostics);
110
122
  }
123
+ return ok(output);
124
+ }
125
+
126
+ export function interpretAttribute<Out>(
127
+ attrNode: FieldAttributeAst | ModelAttributeAst,
128
+ spec: AttributeSpec<Out>,
129
+ ctx: InterpretCtx,
130
+ ): Result<Out, readonly PslDiagnostic[]> {
131
+ const attributeSpan = nodePslSpan(attrNode.syntax, ctx.sourceFile);
132
+ const bound = interpretArgs(attrNode.argList()?.args() ?? [], spec, ctx, attributeSpan);
133
+ if (!bound.ok) return notOk<readonly PslDiagnostic[]>(bound.failure);
111
134
 
112
135
  const value = blindCast<
113
136
  Out,
114
137
  'The engine builds the output object structurally from the spec; TypeScript cannot relate the dynamically-keyed record to the spec-inferred output type.'
115
- >(output);
138
+ >(bound.value);
116
139
  if (spec.refine !== undefined) {
117
140
  const refineDiagnostics = spec.refine(value, ctx);
118
141
  if (refineDiagnostics.length > 0) {
@@ -41,15 +41,19 @@ export { leafDiagnostic } from '../attribute-spec/combinators/diagnostic';
41
41
  export { entityRef } from '../attribute-spec/combinators/entity-ref';
42
42
  export type { FieldRefArgType, FieldRefScope } from '../attribute-spec/combinators/field-ref';
43
43
  export { fieldRef } from '../attribute-spec/combinators/field-ref';
44
+ export type { FuncCallSig, TypedFuncCall } from '../attribute-spec/combinators/func-call';
45
+ export { funcCall } from '../attribute-spec/combinators/func-call';
44
46
  export { identifier } from '../attribute-spec/combinators/identifier';
45
47
  export { int } from '../attribute-spec/combinators/int';
46
48
  export type { ListOptions } from '../attribute-spec/combinators/list';
47
49
  export { list } from '../attribute-spec/combinators/list';
50
+ export { num } from '../attribute-spec/combinators/num';
48
51
  export { oneOf } from '../attribute-spec/combinators/one-of';
49
52
  export { record } from '../attribute-spec/combinators/record';
50
53
  export { str } from '../attribute-spec/combinators/str';
51
54
  export { fieldAttribute } from '../attribute-spec/field-attribute';
52
- export { interpretAttribute } from '../attribute-spec/interpret';
55
+ export type { ArgBindingSpec } from '../attribute-spec/interpret';
56
+ export { interpretArgs, interpretAttribute } from '../attribute-spec/interpret';
53
57
  export { modelAttribute } from '../attribute-spec/model-attribute';
54
58
  export { optional } from '../attribute-spec/optional';
55
59
  export type {