@prisma/orm-framework 8.0.0-rc.11-dev.33 → 8.0.0-rc.11-dev.34

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.
Files changed (54) hide show
  1. package/dist/{components-CIlPUXgy.d.mts → components-D5_c_jNC.d.mts} +2 -2
  2. package/dist/{components-CIlPUXgy.d.mts.map → components-D5_c_jNC.d.mts.map} +1 -1
  3. package/dist/components.d.mts +4 -4
  4. package/dist/components__components.d.mts +2 -2
  5. package/dist/components__control.d.mts +2 -2
  6. package/dist/components__execution.d.mts +1 -1
  7. package/dist/{config-types-fsf2M50T.d.mts → config-types-BKMblqZR.d.mts} +5 -5
  8. package/dist/{config-types-fsf2M50T.d.mts.map → config-types-BKMblqZR.d.mts.map} +1 -1
  9. package/dist/config.d.mts +1 -1
  10. package/dist/config__config-types.d.mts +1 -1
  11. package/dist/{control-ObcoBnYQ.d.mts → control-FPOrnOrH.d.mts} +2 -2
  12. package/dist/{control-ObcoBnYQ.d.mts.map → control-FPOrnOrH.d.mts.map} +1 -1
  13. package/dist/{declarations-DU8tJk4J-BAfPaIOL.mjs → declarations-SwNXosDu-D39d5EQ-.mjs} +8 -3
  14. package/dist/declarations-SwNXosDu-D39d5EQ-.mjs.map +1 -0
  15. package/dist/diagnostic-Esyl8Qw1-Cd6SnWPN.mjs +83 -0
  16. package/dist/diagnostic-Esyl8Qw1-Cd6SnWPN.mjs.map +1 -0
  17. package/dist/errors.d.mts +1 -1
  18. package/dist/errors__execution.d.mts +1 -1
  19. package/dist/{execution-yEk-_DKb.d.mts → execution-B5OFHjmC.d.mts} +2 -2
  20. package/dist/{execution-yEk-_DKb.d.mts.map → execution-B5OFHjmC.d.mts.map} +1 -1
  21. package/dist/{execution-DfMCQMDy.d.mts → execution-DdsbOiMs.d.mts} +2 -2
  22. package/dist/{execution-DfMCQMDy.d.mts.map → execution-DdsbOiMs.d.mts.map} +1 -1
  23. package/dist/{framework-components-Bu5LfryO-CAg5kbVT.d.mts → framework-components-Bak1o3Ye-C7hDfyXj.d.mts} +3 -3
  24. package/dist/{framework-components-Bu5LfryO-CAg5kbVT.d.mts.map → framework-components-Bak1o3Ye-C7hDfyXj.d.mts.map} +1 -1
  25. package/dist/{parse-D6t27bbJ-Bq4ihDy9.d.mts → parse-5HXALb4y-RUSJB688.d.mts} +67 -34
  26. package/dist/parse-5HXALb4y-RUSJB688.d.mts.map +1 -0
  27. package/dist/{parse-B4QY6R0c-CnBAH0Gd.mjs → parse-Cu6B62PC-BAPPRuso.mjs} +62 -12
  28. package/dist/parse-Cu6B62PC-BAPPRuso.mjs.map +1 -0
  29. package/dist/psl-parser.d.mts +9 -11
  30. package/dist/psl-parser.d.mts.map +1 -1
  31. package/dist/psl-parser.mjs +147 -161
  32. package/dist/psl-parser.mjs.map +1 -1
  33. package/dist/psl-parser__format.mjs +12 -12
  34. package/dist/psl-parser__format.mjs.map +1 -1
  35. package/dist/psl-parser__interpret.d.mts +7 -8
  36. package/dist/psl-parser__interpret.d.mts.map +1 -1
  37. package/dist/psl-parser__interpret.mjs +3 -3
  38. package/dist/psl-parser__interpret.mjs.map +1 -1
  39. package/dist/psl-parser__syntax.d.mts +2 -2
  40. package/dist/psl-parser__syntax.mjs +3 -3
  41. package/dist/psl-parser__syntax.mjs.map +1 -1
  42. package/dist/psl-parser__tokenizer.mjs +1 -1
  43. package/dist/psl-printer.mjs +4 -4
  44. package/dist/psl-printer.mjs.map +1 -1
  45. package/dist/{symbol-table-ajt1Djeq-ByUeoS_l.d.mts → symbol-table-CDtpZvfM-DSP_8jbB.d.mts} +12 -13
  46. package/dist/symbol-table-CDtpZvfM-DSP_8jbB.d.mts.map +1 -0
  47. package/dist/{tokenizer-D4sywyzm-gPsD7tYP.mjs → tokenizer-CFsbtfFw-BnfUBepb.mjs} +4 -3
  48. package/dist/tokenizer-CFsbtfFw-BnfUBepb.mjs.map +1 -0
  49. package/package.json +15 -15
  50. package/dist/declarations-DU8tJk4J-BAfPaIOL.mjs.map +0 -1
  51. package/dist/parse-B4QY6R0c-CnBAH0Gd.mjs.map +0 -1
  52. package/dist/parse-D6t27bbJ-Bq4ihDy9.d.mts.map +0 -1
  53. package/dist/symbol-table-ajt1Djeq-ByUeoS_l.d.mts.map +0 -1
  54. package/dist/tokenizer-D4sywyzm-gPsD7tYP.mjs.map +0 -1
@@ -3,7 +3,8 @@ import { t as InternalError } from "./internal-error-ChGYPVpq-DhUD05u0.mjs";
3
3
  import { n as ok, t as notOk } from "./result-C0NUq1Ok.mjs";
4
4
  import { h as isAuthoringPslBlockDescriptor, m as isAuthoringModelAttributeDescriptor } from "./framework-authoring-BvxZnsPY-DlD1nwU5.mjs";
5
5
  import { a as makePslNamespace, c as validateExtensionBlock, i as flatPslModels, n as UNSPECIFIED_PSL_NAMESPACE_ID, o as makePslNamespaceEntries, s as namespacePslExtensionBlocks } from "./psl-ast-DUCvVXbB.mjs";
6
- import { D as TypesBlockAst, P as printSyntax, _ as NumberLiteralExprAst, a as CompositeTypeDeclarationAst, d as IdentifierAst, g as NamespaceDeclarationAst, i as BooleanLiteralExprAst, l as FunctionCallAst, m as ModelDeclarationAst, t as ArrayLiteralAst, u as GenericBlockDeclarationAst, w as TaggedLiteralExprAst, x as StringLiteralExprAst, y as ObjectLiteralExprAst } from "./declarations-DU8tJk4J-BAfPaIOL.mjs";
6
+ import { D as TypesBlockAst, P as printSyntax, _ as NumberLiteralExprAst, a as CompositeTypeDeclarationAst, d as IdentifierAst, g as NamespaceDeclarationAst, i as BooleanLiteralExprAst, l as FunctionCallAst, m as ModelDeclarationAst, t as ArrayLiteralAst, u as GenericBlockDeclarationAst, w as TaggedLiteralExprAst, x as StringLiteralExprAst, y as ObjectLiteralExprAst } from "./declarations-SwNXosDu-D39d5EQ-.mjs";
7
+ import { i as mapPslDiagnostics, n as diagnosticFromSpan, r as diagnosticSource, t as createPslDiagnosticCollector } from "./diagnostic-Esyl8Qw1-Cd6SnWPN.mjs";
7
8
  //#region ../../../1-framework/2-authoring/psl-parser/dist/index.mjs
8
9
  function getPositionalArgument(attribute, index = 0) {
9
10
  return attribute.args.filter((arg) => arg.kind === "positional")[index]?.value;
@@ -45,26 +46,26 @@ function blockAttribute(name, config) {
45
46
  ...config.refine !== void 0 ? { refine: config.refine } : {}
46
47
  };
47
48
  }
48
- function readResolvedAttribute(attribute, sourceFile) {
49
+ function readResolvedAttribute(attribute, sources) {
49
50
  return {
50
51
  name: attributeName(attribute.name()),
51
- args: readResolvedArgList(attribute.argList(), sourceFile),
52
- span: nodePslSpan(attribute.syntax, sourceFile)
52
+ args: readResolvedArgList(attribute.argList(), sources),
53
+ span: nodePslSpan(attribute.syntax, sources)
53
54
  };
54
55
  }
55
- function readResolvedAttributes(attributes, sourceFile) {
56
- return Array.from(attributes, (attribute) => readResolvedAttribute(attribute, sourceFile));
56
+ function readResolvedAttributes(attributes, sources) {
57
+ return Array.from(attributes, (attribute) => readResolvedAttribute(attribute, sources));
57
58
  }
58
- function readResolvedConstructorCall(annotation, sourceFile) {
59
+ function readResolvedConstructorCall(annotation, sources) {
59
60
  const argList = annotation?.argList();
60
61
  if (annotation === void 0 || argList === void 0) return void 0;
61
62
  return {
62
63
  path: annotation.name()?.path() ?? [],
63
- args: readResolvedArgList(argList, sourceFile),
64
- span: nodePslSpan(annotation.syntax, sourceFile)
64
+ args: readResolvedArgList(argList, sources),
65
+ span: nodePslSpan(annotation.syntax, sources)
65
66
  };
66
67
  }
67
- function readResolvedArgList(argList, sourceFile) {
68
+ function readResolvedArgList(argList, sources) {
68
69
  if (argList === void 0) return [];
69
70
  const args = [];
70
71
  for (const arg of argList.args()) {
@@ -75,7 +76,7 @@ function readResolvedArgList(argList, sourceFile) {
75
76
  ...name !== void 0 ? { name } : {},
76
77
  value: renderExpression(expression),
77
78
  ...expression !== void 0 ? { expression } : {},
78
- span: nodePslSpan(arg.syntax, sourceFile)
79
+ span: nodePslSpan(arg.syntax, sources)
79
80
  });
80
81
  }
81
82
  return args;
@@ -87,35 +88,23 @@ function renderExpression(expression) {
87
88
  if (expression === void 0) return "";
88
89
  return printSyntax(expression.syntax).trim();
89
90
  }
90
- function nodePslSpan(node, sourceFile) {
91
+ function nodePslSpan(node, sources) {
92
+ const sourceFile = sources.sourceFileFor(node);
91
93
  const start = node.offset;
92
94
  const end = start + node.green.textLength;
93
95
  return {
94
- start: offsetToPslPosition(start, sourceFile),
95
- end: offsetToPslPosition(end, sourceFile)
96
+ start: sourceFile.offsetToPslPosition(start),
97
+ end: sourceFile.offsetToPslPosition(end)
96
98
  };
97
99
  }
98
100
  /** Unsupported-top-level-block diagnostics are anchored to the keyword token. */
99
- function keywordPslSpan(node, keyword, sourceFile) {
101
+ function keywordPslSpan(node, keyword, sources) {
102
+ const sourceFile = sources.sourceFileFor(node);
100
103
  const start = node.offset;
101
104
  const end = start + keyword.length;
102
105
  return {
103
- start: offsetToPslPosition(start, sourceFile),
104
- end: offsetToPslPosition(end, sourceFile)
105
- };
106
- }
107
- function rangeToPslSpan(range, sourceFile) {
108
- return {
109
- start: offsetToPslPosition(sourceFile.offsetAt(range.start), sourceFile),
110
- end: offsetToPslPosition(sourceFile.offsetAt(range.end), sourceFile)
111
- };
112
- }
113
- function offsetToPslPosition(offset, sourceFile) {
114
- const position = sourceFile.positionAt(offset);
115
- return {
116
- offset,
117
- line: position.line + 1,
118
- column: position.character + 1
106
+ start: sourceFile.offsetToPslPosition(start),
107
+ end: sourceFile.offsetToPslPosition(end)
119
108
  };
120
109
  }
121
110
  const ATTRIBUTE_DIAGNOSTIC_CODE = "PSL_INVALID_ATTRIBUTE_SYNTAX";
@@ -123,8 +112,7 @@ function leafDiagnostic(ctx, node, message, code = ATTRIBUTE_DIAGNOSTIC_CODE) {
123
112
  return {
124
113
  code,
125
114
  message,
126
- sourceId: ctx.sourceId,
127
- span: nodePslSpan(node.syntax, ctx.sourceFile)
115
+ ...diagnosticSource(ctx.sources, node.syntax).at(nodePslSpan(node.syntax, ctx.sources))
128
116
  };
129
117
  }
130
118
  function bool() {
@@ -176,7 +164,7 @@ function referencedFieldRef() {
176
164
  parse: (arg, ctx) => parseFieldName(arg, ctx, ctx.resolveReferencedModel())
177
165
  };
178
166
  }
179
- function interpretArgs(args, spec, ctx, span) {
167
+ function interpretArgs(args, spec, ctx, span, sourceNode) {
180
168
  const diagnostics = [];
181
169
  const output = {};
182
170
  const seen = /* @__PURE__ */ new Set();
@@ -190,7 +178,7 @@ function interpretArgs(args, spec, ctx, span) {
190
178
  const posParam = spec.positional[positionalSlot];
191
179
  if (posParam === void 0) {
192
180
  if (!reportedExcess) {
193
- diagnostics.push(diagnostic(`Attribute "${spec.name}" received too many positional arguments`, ctx, span));
181
+ diagnostics.push(diagnostic(`Attribute "${spec.name}" received too many positional arguments`, ctx, span, sourceNode));
194
182
  reportedExcess = true;
195
183
  }
196
184
  continue;
@@ -201,14 +189,14 @@ function interpretArgs(args, spec, ctx, span) {
201
189
  } else {
202
190
  const namedParam = Object.hasOwn(spec.named, name) ? spec.named[name] : void 0;
203
191
  if (namedParam === void 0) {
204
- diagnostics.push(diagnostic(`Attribute "${spec.name}" received unknown argument "${name}"`, ctx, nodePslSpan(arg.syntax, ctx.sourceFile)));
192
+ diagnostics.push(diagnostic(`Attribute "${spec.name}" received unknown argument "${name}"`, ctx, nodePslSpan(arg.syntax, ctx.sources), arg.syntax));
205
193
  continue;
206
194
  }
207
195
  key = name;
208
196
  param = namedParam.type;
209
197
  }
210
198
  if (seen.has(key)) {
211
- diagnostics.push(diagnostic(`Attribute "${spec.name}" received duplicate argument "${key}"`, ctx, nodePslSpan(arg.syntax, ctx.sourceFile)));
199
+ diagnostics.push(diagnostic(`Attribute "${spec.name}" received duplicate argument "${key}"`, ctx, nodePslSpan(arg.syntax, ctx.sources), arg.syntax));
212
200
  continue;
213
201
  }
214
202
  seen.add(key);
@@ -225,7 +213,7 @@ function interpretArgs(args, spec, ctx, span) {
225
213
  if (effective.hasDefault) output[key] = effective.defaultValue;
226
214
  return;
227
215
  }
228
- diagnostics.push(diagnostic(`Attribute "${spec.name}" is missing required argument "${key}"`, ctx, span));
216
+ diagnostics.push(diagnostic(`Attribute "${spec.name}" is missing required argument "${key}"`, ctx, span, sourceNode));
229
217
  };
230
218
  for (const param of spec.positional) {
231
219
  const namedParam = Object.hasOwn(spec.named, param.key) ? spec.named[param.key] : void 0;
@@ -236,8 +224,8 @@ function interpretArgs(args, spec, ctx, span) {
236
224
  return ok(output);
237
225
  }
238
226
  function interpretAttribute(attrNode, spec, ctx) {
239
- const attributeSpan = nodePslSpan(attrNode.syntax, ctx.sourceFile);
240
- const bound = interpretArgs(attrNode.argList()?.args() ?? [], spec, ctx, attributeSpan);
227
+ const attributeSpan = nodePslSpan(attrNode.syntax, ctx.sources);
228
+ const bound = interpretArgs(attrNode.argList()?.args() ?? [], spec, ctx, attributeSpan, attrNode.syntax);
241
229
  if (!bound.ok) return notOk(bound.failure);
242
230
  const value = blindCast(bound.value);
243
231
  if (spec.refine !== void 0) {
@@ -249,7 +237,7 @@ function interpretAttribute(attrNode, spec, ctx) {
249
237
  function parseArgValue(arg, argType, ctx, diagnostics) {
250
238
  const value = arg.value();
251
239
  if (value === void 0) {
252
- const missing = diagnostic("Attribute argument is missing a value", ctx, nodePslSpan(arg.syntax, ctx.sourceFile));
240
+ const missing = diagnostic("Attribute argument is missing a value", ctx, nodePslSpan(arg.syntax, ctx.sources), arg.syntax);
253
241
  diagnostics.push(missing);
254
242
  return notOk([missing]);
255
243
  }
@@ -260,12 +248,11 @@ function parseArgValue(arg, argType, ctx, diagnostics) {
260
248
  function isOptionalArgType(param) {
261
249
  return "optional" in param && param.optional === true;
262
250
  }
263
- function diagnostic(message, ctx, span) {
251
+ function diagnostic(message, ctx, span, sourceNode) {
264
252
  return {
265
253
  code: ATTRIBUTE_DIAGNOSTIC_CODE,
266
254
  message,
267
- sourceId: ctx.sourceId,
268
- span
255
+ ...diagnosticSource(ctx.sources, sourceNode).at(span)
269
256
  };
270
257
  }
271
258
  function funcCall(name, sig) {
@@ -277,12 +264,12 @@ function funcCall(name, sig) {
277
264
  parse: (arg, ctx) => {
278
265
  const guard = matchCallee(arg, name, ctx);
279
266
  if (!guard.ok) return guard;
280
- const span = nodePslSpan(guard.value.syntax, ctx.sourceFile);
267
+ const span = nodePslSpan(guard.value.syntax, ctx.sources);
281
268
  const bound = interpretArgs(guard.value.args(), {
282
269
  name,
283
270
  positional: sig.positional ?? [],
284
271
  named: sig.named ?? {}
285
- }, ctx, span);
272
+ }, ctx, span, guard.value.syntax);
286
273
  if (!bound.ok) return notOk(bound.failure);
287
274
  return ok({
288
275
  fn: name,
@@ -534,7 +521,7 @@ function taggedLiteral(tags, options) {
534
521
  return ok({
535
522
  tag: literal.tagName(),
536
523
  canonicalization: literal.canonicalization(),
537
- span: nodePslSpan(literal.syntax, ctx.sourceFile)
524
+ span: nodePslSpan(literal.syntax, ctx.sources)
538
525
  });
539
526
  }
540
527
  };
@@ -586,7 +573,7 @@ function findBlockDescriptor(descriptors, keyword) {
586
573
  }
587
574
  function validateExtensionBlockFromSymbol(input) {
588
575
  const refCtx = buildRefResolutionContext(input.symbolTable, input.block);
589
- return validateExtensionBlock(input.block.block, input.descriptor, input.sourceId, input.codecLookup, refCtx);
576
+ return validateExtensionBlock(input.block.block, input.descriptor, input.sources.sourceFileFor(input.block.node.syntax).filename, input.codecLookup, refCtx).map((diagnostic) => diagnosticFromSpan(diagnostic, diagnosticSource(input.sources, input.block.node.syntax)));
590
577
  }
591
578
  const ZERO_SPAN = {
592
579
  start: {
@@ -627,12 +614,12 @@ function findOwnerNamespaceName(symbolTable, block) {
627
614
  for (const namespace of Object.values(symbolTable.topLevel.namespaces)) if (Object.values(namespace.blocks).some((candidate) => candidate === block)) return namespace.name;
628
615
  return UNSPECIFIED_PSL_NAMESPACE_ID;
629
616
  }
630
- const BLOCK_ATTRIBUTE_SOURCE_ID = "unknown";
631
617
  /**
632
618
  * Descriptor-free and unknown parameters become `value` stubs so validation can
633
619
  * report them via key-set comparison. Duplicate member names are first-wins.
634
620
  */
635
- function reconstructExtensionBlock(node, descriptor, sourceFile, diagnostics) {
621
+ function reconstructExtensionBlock(node, descriptor, sources, diagnostics) {
622
+ const sourceFile = sources.sourceFileFor(node.syntax);
636
623
  const keyword = node.keyword()?.text ?? "";
637
624
  const blockName = node.name()?.name() ?? "";
638
625
  const blockAttributes = [];
@@ -645,17 +632,17 @@ function reconstructExtensionBlock(node, descriptor, sourceFile, diagnostics) {
645
632
  return {
646
633
  kind: "positional",
647
634
  value: value === void 0 ? "" : printSyntax(value.syntax).trim(),
648
- span: nodePslSpan(arg.syntax, sourceFile)
635
+ span: nodePslSpan(arg.syntax, sources)
649
636
  };
650
637
  });
651
- const span = nodePslSpan(attribute.syntax, sourceFile);
638
+ const span = nodePslSpan(attribute.syntax, sources);
652
639
  blockAttributes.push({
653
640
  name,
654
641
  args,
655
642
  span
656
643
  });
657
644
  if (descriptor === void 0) continue;
658
- const parsed = parseBlockAttribute(attribute, name, span, descriptor, seenAttributeNames, keyword, blockName, sourceFile);
645
+ const parsed = parseBlockAttribute(attribute, name, span, descriptor, seenAttributeNames, keyword, blockName, sources);
659
646
  if (parsed.ok) attributes[name] = parsed.value;
660
647
  else diagnostics.push(...parsed.diagnostics);
661
648
  }
@@ -663,9 +650,10 @@ function reconstructExtensionBlock(node, descriptor, sourceFile, diagnostics) {
663
650
  for (const entry of node.entries()) {
664
651
  const key = entry.key()?.name();
665
652
  if (key === void 0) continue;
666
- const span = nodePslSpan(entry.syntax, sourceFile);
653
+ const span = nodePslSpan(entry.syntax, sources);
667
654
  if (Object.hasOwn(parameters, key)) {
668
655
  diagnostics.push({
656
+ filename: sourceFile.filename,
669
657
  code: "PSL_EXTENSION_DUPLICATE_PARAMETER",
670
658
  message: `Duplicate parameter "${key}" in "${keyword}" block "${blockName}"; first occurrence wins`,
671
659
  range: {
@@ -675,7 +663,7 @@ function reconstructExtensionBlock(node, descriptor, sourceFile, diagnostics) {
675
663
  });
676
664
  continue;
677
665
  }
678
- parameters[key] = reconstructParamValue(entry, descriptor?.parameters[key], span, sourceFile, diagnostics);
666
+ parameters[key] = reconstructParamValue(entry, descriptor?.parameters[key], span, sources, diagnostics);
679
667
  }
680
668
  return {
681
669
  kind: descriptor?.discriminator ?? keyword,
@@ -684,15 +672,17 @@ function reconstructExtensionBlock(node, descriptor, sourceFile, diagnostics) {
684
672
  parameters,
685
673
  blockAttributes,
686
674
  attributes,
687
- span: nodePslSpan(node.syntax, sourceFile)
675
+ span: nodePslSpan(node.syntax, sources)
688
676
  };
689
677
  }
690
- function parseBlockAttribute(attribute, name, span, descriptor, seenNames, keyword, blockName, sourceFile) {
691
- const range = pslSpanToRange(span, sourceFile);
678
+ function parseBlockAttribute(attribute, name, span, descriptor, seenNames, keyword, blockName, sources) {
679
+ const sourceFile = sources.sourceFileFor(attribute.syntax);
680
+ const range = sourceFile.pslSpanToRange(span);
692
681
  const declared = descriptor.attributes ?? {};
693
682
  if (!Object.hasOwn(declared, name)) return {
694
683
  ok: false,
695
684
  diagnostics: [{
685
+ filename: sourceFile.filename,
696
686
  code: "PSL_EXTENSION_UNKNOWN_BLOCK_ATTRIBUTE",
697
687
  message: `Unknown attribute "@@${name}" in "${keyword}" block "${blockName}"`,
698
688
  range
@@ -701,19 +691,17 @@ function parseBlockAttribute(attribute, name, span, descriptor, seenNames, keywo
701
691
  if (seenNames.has(name)) return {
702
692
  ok: false,
703
693
  diagnostics: [{
694
+ filename: sourceFile.filename,
704
695
  code: "PSL_INVALID_EXTENSION_BLOCK_ATTRIBUTE",
705
696
  message: `Duplicate attribute "@@${name}" in "${keyword}" block "${blockName}"; first occurrence wins`,
706
697
  range
707
698
  }]
708
699
  };
709
700
  seenNames.add(name);
710
- const result = interpretAttribute(attribute, blindCast(declared[name])(), {
711
- sourceId: BLOCK_ATTRIBUTE_SOURCE_ID,
712
- sourceFile
713
- });
701
+ const result = interpretAttribute(attribute, blindCast(declared[name])(), { sources });
714
702
  if (!result.ok) return {
715
703
  ok: false,
716
- diagnostics: result.failure.map((diagnostic) => toParseDiagnostic(diagnostic, sourceFile))
704
+ diagnostics: result.failure
717
705
  };
718
706
  return {
719
707
  ok: true,
@@ -723,33 +711,22 @@ function parseBlockAttribute(attribute, name, span, descriptor, seenNames, keywo
723
711
  }
724
712
  };
725
713
  }
726
- function toParseDiagnostic(diagnostic, sourceFile) {
727
- return {
728
- code: diagnostic.code,
729
- message: diagnostic.message,
730
- range: pslSpanToRange(diagnostic.span, sourceFile)
731
- };
732
- }
733
- function pslSpanToRange(span, sourceFile) {
734
- return {
735
- start: sourceFile.positionAt(span.start.offset),
736
- end: sourceFile.positionAt(span.end.offset)
737
- };
738
- }
739
- function reconstructParamValue(entry, param, span, sourceFile, diagnostics) {
714
+ function reconstructParamValue(entry, param, span, sources, diagnostics) {
740
715
  const value = entry.value();
741
716
  if (value === void 0) return {
742
717
  kind: "bare",
743
718
  span
744
719
  };
745
- return reconstructFromExpression(value, param, span, sourceFile, diagnostics);
720
+ return reconstructFromExpression(value, param, span, sources, diagnostics);
746
721
  }
747
- function reconstructFromExpression(value, param, span, sourceFile, diagnostics) {
722
+ function reconstructFromExpression(value, param, span, sources, diagnostics) {
748
723
  const raw = printSyntax(value.syntax).trim();
749
724
  if (param?.kind === "list") {
725
+ const sourceFile = sources.sourceFileFor(value.syntax);
750
726
  const array = ArrayLiteralAst.cast(value.syntax);
751
727
  if (!array) {
752
728
  diagnostics?.push({
729
+ filename: sourceFile.filename,
753
730
  code: "PSL_EXTENSION_INVALID_VALUE",
754
731
  message: `List parameter expects an array literal, got ${raw}`,
755
732
  range: {
@@ -764,7 +741,7 @@ function reconstructFromExpression(value, param, span, sourceFile, diagnostics)
764
741
  };
765
742
  }
766
743
  const items = [];
767
- for (const element of array.elements()) items.push(reconstructFromExpression(element, param.of, nodePslSpan(element.syntax, sourceFile), sourceFile, diagnostics));
744
+ for (const element of array.elements()) items.push(reconstructFromExpression(element, param.of, nodePslSpan(element.syntax, sources), sources, diagnostics));
768
745
  return {
769
746
  kind: "list",
770
747
  items,
@@ -794,7 +771,7 @@ function reconstructFromExpression(value, param, span, sourceFile, diagnostics)
794
771
  * should consume first-wins symbols rather than re-emitting duplicate diagnostics.
795
772
  */
796
773
  function buildSymbolTable(options) {
797
- const { document, sourceFile, pslBlockDescriptors } = options;
774
+ const { documents, sources, pslBlockDescriptors } = options;
798
775
  const diagnostics = [];
799
776
  const namespaces = Object.create(null);
800
777
  const namedTypes = {};
@@ -802,62 +779,66 @@ function buildSymbolTable(options) {
802
779
  const models = {};
803
780
  const compositeTypes = {};
804
781
  const topLevelNames = /* @__PURE__ */ new Set();
805
- const claim = (taken, name) => {
806
- const text = name?.name();
807
- if (text === void 0) return void 0;
808
- if (taken.has(text)) {
809
- const range = nameRange(name, sourceFile);
810
- if (range) diagnostics.push({
811
- code: "PSL_DUPLICATE_DECLARATION",
812
- message: `Duplicate declaration of "${text}"`,
813
- range
814
- });
815
- return;
816
- }
817
- taken.add(text);
818
- return text;
819
- };
820
- for (const declaration of document.declarations()) if (declaration instanceof ModelDeclarationAst) {
821
- const name = claim(topLevelNames, declaration.name());
822
- if (name !== void 0) models[name] = buildModel(name, declaration, sourceFile, diagnostics);
823
- } else if (declaration instanceof CompositeTypeDeclarationAst) {
824
- const name = claim(topLevelNames, declaration.name());
825
- if (name !== void 0) compositeTypes[name] = buildCompositeType(name, declaration, sourceFile, diagnostics);
826
- } else if (declaration instanceof GenericBlockDeclarationAst) {
827
- const name = claim(topLevelNames, declaration.name());
828
- if (name !== void 0) blocks[name] = buildBlock(name, declaration, sourceFile, pslBlockDescriptors, diagnostics);
829
- } else if (declaration instanceof NamespaceDeclarationAst) {
830
- const declaredName = declaration.name()?.name();
831
- if (declaredName === void 0) continue;
832
- let namespace = namespaces[declaredName];
833
- if (namespace === void 0) {
782
+ for (const document of documents) {
783
+ const sourceFile = sources.sourceFileFor(document.syntax);
784
+ const claim = (taken, name) => {
785
+ const text = name?.name();
786
+ if (text === void 0) return void 0;
787
+ if (taken.has(text)) {
788
+ const range = nameRange(name, sources);
789
+ if (range) diagnostics.push({
790
+ code: "PSL_DUPLICATE_DECLARATION",
791
+ message: `Duplicate declaration of "${text}"`,
792
+ filename: sourceFile.filename,
793
+ range
794
+ });
795
+ return;
796
+ }
797
+ taken.add(text);
798
+ return text;
799
+ };
800
+ for (const declaration of document.declarations()) if (declaration instanceof ModelDeclarationAst) {
801
+ const name = claim(topLevelNames, declaration.name());
802
+ if (name !== void 0) models[name] = buildModel(name, declaration, sources, diagnostics);
803
+ } else if (declaration instanceof CompositeTypeDeclarationAst) {
834
804
  const name = claim(topLevelNames, declaration.name());
805
+ if (name !== void 0) compositeTypes[name] = buildCompositeType(name, declaration, sources, diagnostics);
806
+ } else if (declaration instanceof GenericBlockDeclarationAst) {
807
+ const name = claim(topLevelNames, declaration.name());
808
+ if (name !== void 0) blocks[name] = buildBlock(name, declaration, sources, pslBlockDescriptors, diagnostics);
809
+ } else if (declaration instanceof NamespaceDeclarationAst) {
810
+ const declaredName = declaration.name()?.name();
811
+ if (declaredName === void 0) continue;
812
+ let namespace = namespaces[declaredName];
813
+ if (namespace === void 0) {
814
+ const name = claim(topLevelNames, declaration.name());
815
+ if (name === void 0) continue;
816
+ namespace = {
817
+ kind: "namespace",
818
+ name,
819
+ declarations: [],
820
+ models: Object.create(null),
821
+ compositeTypes: Object.create(null),
822
+ blocks: Object.create(null)
823
+ };
824
+ namespaces[name] = namespace;
825
+ }
826
+ extendNamespace(namespace, declaration, diagnostics, sources, pslBlockDescriptors);
827
+ } else if (declaration instanceof TypesBlockAst) for (const binding of declaration.declarations()) {
828
+ const name = claim(topLevelNames, binding.name());
835
829
  if (name === void 0) continue;
836
- namespace = {
837
- kind: "namespace",
830
+ const resolved = resolveNamedTypeBinding(binding, sources);
831
+ namedTypes[name] = {
832
+ kind: "namedType",
838
833
  name,
839
- declarations: [],
840
- models: Object.create(null),
841
- compositeTypes: Object.create(null),
842
- blocks: Object.create(null)
834
+ node: binding,
835
+ span: nodePslSpan(binding.syntax, sources),
836
+ ...resolved
843
837
  };
844
- namespaces[name] = namespace;
845
838
  }
846
- extendNamespace(namespace, declaration, diagnostics, sourceFile, pslBlockDescriptors);
847
- } else if (declaration instanceof TypesBlockAst) for (const binding of declaration.declarations()) {
848
- const name = claim(topLevelNames, binding.name());
849
- if (name === void 0) continue;
850
- const resolved = resolveNamedTypeBinding(binding, sourceFile);
851
- namedTypes[name] = {
852
- kind: "namedType",
853
- name,
854
- node: binding,
855
- span: nodePslSpan(binding.syntax, sourceFile),
856
- ...resolved
857
- };
858
839
  }
859
840
  return {
860
- table: { topLevel: {
841
+ symbolTable: { topLevel: {
861
842
  namespaces,
862
843
  namedTypes,
863
844
  blocks,
@@ -867,27 +848,27 @@ function buildSymbolTable(options) {
867
848
  diagnostics
868
849
  };
869
850
  }
870
- function buildModel(name, node, sourceFile, diagnostics) {
851
+ function buildModel(name, node, sources, diagnostics) {
871
852
  return {
872
853
  kind: "model",
873
854
  name,
874
855
  node,
875
- span: nodePslSpan(node.syntax, sourceFile),
876
- fields: buildFields(name, node.fields(), sourceFile, diagnostics),
877
- attributes: readResolvedAttributes(node.attributes(), sourceFile)
856
+ span: nodePslSpan(node.syntax, sources),
857
+ fields: buildFields(name, node.fields(), sources, diagnostics),
858
+ attributes: readResolvedAttributes(node.attributes(), sources)
878
859
  };
879
860
  }
880
- function buildCompositeType(name, node, sourceFile, diagnostics) {
861
+ function buildCompositeType(name, node, sources, diagnostics) {
881
862
  return {
882
863
  kind: "compositeType",
883
864
  name,
884
865
  node,
885
- span: nodePslSpan(node.syntax, sourceFile),
886
- fields: buildFields(name, node.fields(), sourceFile, diagnostics),
887
- attributes: readResolvedAttributes(node.attributes(), sourceFile)
866
+ span: nodePslSpan(node.syntax, sources),
867
+ fields: buildFields(name, node.fields(), sources, diagnostics),
868
+ attributes: readResolvedAttributes(node.attributes(), sources)
888
869
  };
889
870
  }
890
- function buildBlock(name, node, sourceFile, pslBlockDescriptors, diagnostics) {
871
+ function buildBlock(name, node, sources, pslBlockDescriptors, diagnostics) {
891
872
  const keyword = node.keyword()?.text ?? "";
892
873
  const descriptor = findBlockDescriptor(pslBlockDescriptors, keyword);
893
874
  return {
@@ -895,55 +876,57 @@ function buildBlock(name, node, sourceFile, pslBlockDescriptors, diagnostics) {
895
876
  name,
896
877
  keyword,
897
878
  node,
898
- span: nodePslSpan(node.syntax, sourceFile),
899
- block: reconstructExtensionBlock(node, descriptor, sourceFile, diagnostics)
879
+ span: nodePslSpan(node.syntax, sources),
880
+ block: reconstructExtensionBlock(node, descriptor, sources, diagnostics)
900
881
  };
901
882
  }
902
- function extendNamespace(namespace, node, diagnostics, sourceFile, pslBlockDescriptors) {
883
+ function extendNamespace(namespace, node, diagnostics, sources, pslBlockDescriptors) {
903
884
  const { models, compositeTypes, blocks } = namespace;
904
885
  namespace.declarations.push({
905
886
  node,
906
- span: nodePslSpan(node.syntax, sourceFile)
887
+ span: nodePslSpan(node.syntax, sources)
907
888
  });
908
889
  for (const member of node.declarations()) {
909
890
  const memberName = member.name()?.name();
910
891
  if (memberName === void 0) continue;
911
892
  if (Object.hasOwn(models, memberName) || Object.hasOwn(compositeTypes, memberName) || Object.hasOwn(blocks, memberName)) {
912
- const range = nameRange(member.name(), sourceFile);
893
+ const range = nameRange(member.name(), sources);
913
894
  if (range) diagnostics.push({
914
895
  code: "PSL_DUPLICATE_DECLARATION",
915
896
  message: `Duplicate declaration of "${memberName}"`,
897
+ filename: sources.sourceFileFor(member.syntax).filename,
916
898
  range
917
899
  });
918
900
  continue;
919
901
  }
920
- if (member instanceof ModelDeclarationAst) models[memberName] = buildModel(memberName, member, sourceFile, diagnostics);
921
- else if (member instanceof CompositeTypeDeclarationAst) compositeTypes[memberName] = buildCompositeType(memberName, member, sourceFile, diagnostics);
922
- else if (member instanceof GenericBlockDeclarationAst) blocks[memberName] = buildBlock(memberName, member, sourceFile, pslBlockDescriptors, diagnostics);
902
+ if (member instanceof ModelDeclarationAst) models[memberName] = buildModel(memberName, member, sources, diagnostics);
903
+ else if (member instanceof CompositeTypeDeclarationAst) compositeTypes[memberName] = buildCompositeType(memberName, member, sources, diagnostics);
904
+ else if (member instanceof GenericBlockDeclarationAst) blocks[memberName] = buildBlock(memberName, member, sources, pslBlockDescriptors, diagnostics);
923
905
  }
924
906
  }
925
- function buildFields(ownerName, fields, sourceFile, diagnostics) {
907
+ function buildFields(ownerName, fields, sources, diagnostics) {
926
908
  const result = {};
927
909
  for (const field of fields) {
928
910
  const nameNode = field.name();
929
911
  const name = nameNode?.name();
930
912
  if (name === void 0) continue;
931
913
  if (Object.hasOwn(result, name)) {
932
- const range = nameRange(nameNode, sourceFile);
914
+ const range = nameRange(nameNode, sources);
933
915
  if (range) diagnostics.push({
934
916
  code: "PSL_DUPLICATE_DECLARATION",
935
917
  message: `Duplicate declaration of "${name}"`,
918
+ filename: sources.sourceFileFor(field.syntax).filename,
936
919
  range
937
920
  });
938
921
  continue;
939
922
  }
940
- result[name] = buildField(ownerName, name, field, sourceFile, diagnostics);
923
+ result[name] = buildField(ownerName, name, field, sources, diagnostics);
941
924
  }
942
925
  return result;
943
926
  }
944
- function buildField(ownerName, name, node, sourceFile, diagnostics) {
945
- const attributes = readResolvedAttributes(node.attributes(), sourceFile);
946
- const span = nodePslSpan(node.syntax, sourceFile);
927
+ function buildField(ownerName, name, node, sources, diagnostics) {
928
+ const attributes = readResolvedAttributes(node.attributes(), sources);
929
+ const span = nodePslSpan(node.syntax, sources);
947
930
  const annotation = node.typeAnnotation();
948
931
  const typeName = annotation?.name();
949
932
  if (typeName?.isOverQualified()) {
@@ -951,7 +934,8 @@ function buildField(ownerName, name, node, sourceFile, diagnostics) {
951
934
  diagnostics.push({
952
935
  code: "PSL_INVALID_QUALIFIED_TYPE",
953
936
  message: `Field "${ownerName}.${name}" has an invalid qualified type "${path.join(".")}"; use at most one namespace qualifier (e.g. "ns.TypeName")`,
954
- range: nodeRange(typeName.syntax, sourceFile)
937
+ filename: sources.sourceFileFor(typeName.syntax).filename,
938
+ range: nodeRange(typeName.syntax, sources)
955
939
  });
956
940
  return {
957
941
  kind: "field",
@@ -965,7 +949,7 @@ function buildField(ownerName, name, node, sourceFile, diagnostics) {
965
949
  attributes
966
950
  };
967
951
  }
968
- const typeConstructor = annotation?.isConstructor() ? readResolvedConstructorCall(annotation, sourceFile) : void 0;
952
+ const typeConstructor = annotation?.isConstructor() ? readResolvedConstructorCall(annotation, sources) : void 0;
969
953
  const typeNamespaceId = typeName?.namespace()?.name();
970
954
  const typeContractSpaceId = typeName?.space()?.name();
971
955
  return {
@@ -982,26 +966,28 @@ function buildField(ownerName, name, node, sourceFile, diagnostics) {
982
966
  attributes
983
967
  };
984
968
  }
985
- function resolveNamedTypeBinding(node, sourceFile) {
969
+ function resolveNamedTypeBinding(node, sources) {
986
970
  const annotation = node.typeAnnotation();
987
971
  const isConstructor = annotation?.isConstructor() ?? false;
988
972
  const baseType = annotation?.name()?.identifier()?.name();
989
- const typeConstructor = readResolvedConstructorCall(annotation, sourceFile);
973
+ const typeConstructor = readResolvedConstructorCall(annotation, sources);
990
974
  return {
991
975
  isConstructor,
992
976
  ...!isConstructor && baseType !== void 0 ? { baseType } : {},
993
977
  ...typeConstructor !== void 0 ? { typeConstructor } : {},
994
- attributes: readResolvedAttributes(node.attributes(), sourceFile)
978
+ attributes: readResolvedAttributes(node.attributes(), sources)
995
979
  };
996
980
  }
997
- function nameRange(name, sourceFile) {
981
+ function nameRange(name, sources) {
998
982
  if (name === void 0) return void 0;
983
+ const sourceFile = sources.sourceFileFor(name.syntax);
999
984
  for (const token of name.syntax.tokens()) if (token.kind === "Ident") return {
1000
985
  start: sourceFile.positionAt(token.offset),
1001
986
  end: sourceFile.positionAt(token.offset + token.text.length)
1002
987
  };
1003
988
  }
1004
- function nodeRange(node, sourceFile) {
989
+ function nodeRange(node, sources) {
990
+ const sourceFile = sources.sourceFileFor(node);
1005
991
  const start = node.offset;
1006
992
  const end = start + node.green.textLength;
1007
993
  return {
@@ -1010,6 +996,6 @@ function nodeRange(node, sourceFile) {
1010
996
  };
1011
997
  }
1012
998
  //#endregion
1013
- export { assembleAttributeSpecs, blockAttribute, bool, buildSymbolTable, entityRef, fieldAttribute, fieldRef, findBlockDescriptor, flatPslModels, funcCall, getPositionalArgument, identifier, int, interpretArgs, interpretAttribute, json, keywordPslSpan, leafDiagnostic, list, modelAttribute, namespacePslExtensionBlocks, nodePslSpan, num, numLiteral, oneOf, optional, parseQuotedStringLiteral, rangeToPslSpan, readResolvedAttribute, readResolvedAttributes, readResolvedConstructorCall, record, referencedFieldRef, str, taggedLiteral, validateExtensionBlockFromSymbol };
999
+ export { assembleAttributeSpecs, blockAttribute, bool, buildSymbolTable, createPslDiagnosticCollector, diagnosticFromSpan, diagnosticSource, entityRef, fieldAttribute, fieldRef, findBlockDescriptor, flatPslModels, funcCall, getPositionalArgument, identifier, int, interpretArgs, interpretAttribute, json, keywordPslSpan, leafDiagnostic, list, mapPslDiagnostics, modelAttribute, namespacePslExtensionBlocks, nodePslSpan, num, numLiteral, oneOf, optional, parseQuotedStringLiteral, readResolvedAttribute, readResolvedAttributes, readResolvedConstructorCall, record, referencedFieldRef, str, taggedLiteral, validateExtensionBlockFromSymbol };
1014
1000
 
1015
1001
  //# sourceMappingURL=psl-parser.mjs.map