@prisma-next/psl-parser 0.3.0-dev.147 → 0.3.0-dev.149

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/README.md CHANGED
@@ -22,7 +22,7 @@ In the provider-based authoring model, PSL providers call this parser and then r
22
22
 
23
23
  `@prisma-next/psl-parser` parses attributes **generically**:
24
24
 
25
- - Attributes may be **non-namespaced** (for example `@id`) or **namespaced** (for example `@pgvector.column`).
25
+ - Attributes may be **non-namespaced** (for example `@id`) or **namespaced** (for example `@vendor.option`).
26
26
  - Attributes may include an **optional argument list**.
27
27
  - Arguments are parsed into positional/named entries with preserved raw values and source spans.
28
28
  - The parser owns **syntax + structure + spans**, not semantics.
@@ -73,4 +73,3 @@ flowchart LR
73
73
  - `docs/Architecture Overview.md`
74
74
  - `docs/architecture docs/subsystems/2. Contract Emitter & Types.md`
75
75
  - `docs/architecture docs/adrs/ADR 163 - Provider-invoked source interpretation packages.md`
76
-
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as PslPosition, E as PslTypesBlock, S as PslNamedTypeDeclaration, T as PslSpan, _ as PslField, a as PslAttributeNamedArgument, b as PslModel, c as PslCompositeType, d as PslDefaultValue, f as PslDiagnostic, g as PslEnumValue, h as PslEnum, i as PslAttributeArgument, l as PslDefaultFunctionValue, m as PslDocumentAst, n as ParsePslDocumentResult, o as PslAttributePositionalArgument, p as PslDiagnosticCode, r as PslAttribute, s as PslAttributeTarget, t as ParsePslDocumentInput, u as PslDefaultLiteralValue, v as PslFieldAttribute, x as PslModelAttribute } from "./types-B5Y_8Gl4.mjs";
2
- import { t as parsePslDocument } from "./parser-D-_7FY6a.mjs";
1
+ import { C as PslPosition, D as PslTypesBlock, E as PslTypeConstructorCall, S as PslNamedTypeDeclaration, T as PslSpan, _ as PslField, a as PslAttributeNamedArgument, b as PslModel, c as PslCompositeType, d as PslDefaultValue, f as PslDiagnostic, g as PslEnumValue, h as PslEnum, i as PslAttributeArgument, l as PslDefaultFunctionValue, m as PslDocumentAst, n as ParsePslDocumentResult, o as PslAttributePositionalArgument, p as PslDiagnosticCode, r as PslAttribute, s as PslAttributeTarget, t as ParsePslDocumentInput, u as PslDefaultLiteralValue, v as PslFieldAttribute, x as PslModelAttribute } from "./types-CYb3hCxS.mjs";
2
+ import { t as parsePslDocument } from "./parser-B_U8b1dE.mjs";
3
3
 
4
4
  //#region src/attribute-helpers.d.ts
5
5
  declare function getPositionalArgument(attribute: PslAttribute, index?: number): string | undefined;
6
6
  declare function parseQuotedStringLiteral(value: string): string | undefined;
7
7
  //#endregion
8
- export { type ParsePslDocumentInput, type ParsePslDocumentResult, 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 PslEnum, type PslEnumValue, type PslField, type PslFieldAttribute, type PslModel, type PslModelAttribute, type PslNamedTypeDeclaration, type PslPosition, type PslSpan, type PslTypesBlock, getPositionalArgument, parsePslDocument, parseQuotedStringLiteral };
8
+ export { type ParsePslDocumentInput, type ParsePslDocumentResult, 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 PslEnum, type PslEnumValue, type PslField, type PslFieldAttribute, type PslModel, type PslModelAttribute, type PslNamedTypeDeclaration, type PslPosition, type PslSpan, type PslTypeConstructorCall, type PslTypesBlock, getPositionalArgument, parsePslDocument, parseQuotedStringLiteral };
9
9
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as parsePslDocument } from "./parser-jCEw-qFr.mjs";
1
+ import { t as parsePslDocument } from "./parser-Cr64fw1E.mjs";
2
2
 
3
3
  //#region src/attribute-helpers.ts
4
4
  function getPositionalArgument(attribute, index = 0) {
@@ -1,7 +1,7 @@
1
- import { n as ParsePslDocumentResult, t as ParsePslDocumentInput } from "./types-B5Y_8Gl4.mjs";
1
+ import { n as ParsePslDocumentResult, t as ParsePslDocumentInput } from "./types-CYb3hCxS.mjs";
2
2
 
3
3
  //#region src/parser.d.ts
4
4
  declare function parsePslDocument(input: ParsePslDocumentInput): ParsePslDocumentResult;
5
5
  //#endregion
6
6
  export { parsePslDocument as t };
7
- //# sourceMappingURL=parser-D-_7FY6a.d.mts.map
7
+ //# sourceMappingURL=parser-B_U8b1dE.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser-B_U8b1dE.d.mts","names":[],"sources":["../src/parser.ts"],"sourcesContent":[],"mappings":";;;iBAkDgB,gBAAA,QAAwB,wBAAwB"}
@@ -232,7 +232,7 @@ function parseTypesBlock(context, bounds) {
232
232
  const raw = context.lines[lineIndex] ?? "";
233
233
  const line = stripInlineComment(raw).trim();
234
234
  if (line.length === 0) continue;
235
- const declarationMatch = line.match(/^([A-Za-z_]\w*)\s*=\s*([A-Za-z_]\w*)(.*)$/);
235
+ const declarationMatch = line.match(/^([A-Za-z_]\w*)\s*=\s*(.+)$/);
236
236
  if (!declarationMatch) {
237
237
  pushDiagnostic(context, {
238
238
  code: "PSL_INVALID_TYPES_MEMBER",
@@ -242,13 +242,23 @@ function parseTypesBlock(context, bounds) {
242
242
  continue;
243
243
  }
244
244
  const declarationName = declarationMatch[1] ?? "";
245
- const baseType = declarationMatch[2] ?? "";
246
- const attributePart = declarationMatch[3] ?? "";
247
245
  const trimmedStartColumn = firstNonWhitespaceColumn(raw);
248
- const attributeOffset = line.length - attributePart.length;
249
- const attributeSource = attributePart.trimStart();
250
- const leadingAttributeWhitespace = attributePart.length - attributeSource.length;
251
- const attributeParse = extractAttributeTokensWithSpans(context, lineIndex, attributeSource, trimmedStartColumn + attributeOffset + leadingAttributeWhitespace);
246
+ const declarationValue = (declarationMatch[2] ?? "").trim();
247
+ const valueOffset = line.indexOf(declarationValue);
248
+ const declarationValueColumn = trimmedStartColumn + Math.max(valueOffset, 0);
249
+ const typeAndAttributeSplit = splitTypeAndAttributes(declarationValue);
250
+ const typeSource = typeAndAttributeSplit.typeSource.trim();
251
+ const attributeSource = typeAndAttributeSplit.attributeSource.trimStart();
252
+ const leadingAttributeWhitespace = typeAndAttributeSplit.attributeSource.length - attributeSource.length;
253
+ const typeConstructor = parseTypeConstructorCall(context, {
254
+ declarationValue: typeSource,
255
+ lineIndex,
256
+ startColumn: declarationValueColumn,
257
+ invalidCode: "PSL_INVALID_TYPES_MEMBER",
258
+ invalidMessage: (value) => `Invalid types declaration "${value}"`
259
+ });
260
+ if (typeConstructor === "malformed") continue;
261
+ const attributeParse = extractAttributeTokensWithSpans(context, lineIndex, attributeSource, declarationValueColumn + typeAndAttributeSplit.attributeOffset + leadingAttributeWhitespace);
252
262
  if (!attributeParse.ok) continue;
253
263
  const attributes = attributeParse.tokens.map((token) => parseAttributeToken(context, {
254
264
  token: token.text,
@@ -256,6 +266,26 @@ function parseTypesBlock(context, bounds) {
256
266
  lineIndex,
257
267
  span: token.span
258
268
  })).filter((attribute) => Boolean(attribute));
269
+ if (typeConstructor) {
270
+ declarations.push({
271
+ kind: "namedType",
272
+ name: declarationName,
273
+ typeConstructor,
274
+ attributes,
275
+ span: createTrimmedLineSpan(context, lineIndex)
276
+ });
277
+ continue;
278
+ }
279
+ const baseTypeMatch = typeSource.match(/^([A-Za-z_]\w*)$/);
280
+ if (!baseTypeMatch) {
281
+ pushDiagnostic(context, {
282
+ code: "PSL_INVALID_TYPES_MEMBER",
283
+ message: `Invalid types declaration "${line}"`,
284
+ span: createTrimmedLineSpan(context, lineIndex)
285
+ });
286
+ continue;
287
+ }
288
+ const baseType = baseTypeMatch[1] ?? "";
259
289
  declarations.push({
260
290
  kind: "namedType",
261
291
  name: declarationName,
@@ -270,6 +300,39 @@ function parseTypesBlock(context, bounds) {
270
300
  span: createLineRangeSpan(context, bounds.startLine, bounds.endLine)
271
301
  };
272
302
  }
303
+ function parseTypeConstructorCall(context, input) {
304
+ const value = input.declarationValue.trim();
305
+ const constructorMatch = value.match(/^([A-Za-z_][A-Za-z0-9_-]*(?:\.[A-Za-z_][A-Za-z0-9_-]*)*)\s*\(/);
306
+ if (!constructorMatch) return;
307
+ const openParen = value.indexOf("(");
308
+ const closeParen = value.lastIndexOf(")");
309
+ if (closeParen !== value.length - 1) {
310
+ pushDiagnostic(context, {
311
+ code: input.invalidCode,
312
+ message: input.invalidMessage(value),
313
+ span: createInlineSpan(context, input.lineIndex, input.startColumn, input.startColumn + value.length)
314
+ });
315
+ return "malformed";
316
+ }
317
+ const constructorPath = constructorMatch[1] ?? "";
318
+ const args = parseArgumentList(context, {
319
+ argsRaw: value.slice(openParen + 1, closeParen),
320
+ argsOffset: input.startColumn + openParen + 1,
321
+ lineIndex: input.lineIndex,
322
+ token: value,
323
+ span: createInlineSpan(context, input.lineIndex, input.startColumn, input.startColumn + value.length),
324
+ invalidCode: input.invalidCode,
325
+ invalidEmptyArgumentMessage: `Invalid empty argument in type constructor "${value}"`,
326
+ invalidNamedArgumentMessage: (part) => `Invalid named argument syntax "${part}" in type constructor "${value}"`
327
+ });
328
+ if (!args) return "malformed";
329
+ return {
330
+ kind: "typeConstructor",
331
+ path: constructorPath.split("."),
332
+ args,
333
+ span: createInlineSpan(context, input.lineIndex, input.startColumn, input.startColumn + value.length)
334
+ };
335
+ }
273
336
  function parseModelAttribute(context, line, lineIndex) {
274
337
  const tokenParse = extractAttributeTokensWithSpans(context, lineIndex, line, firstNonWhitespaceColumn(context.lines[lineIndex] ?? ""));
275
338
  if (!tokenParse.ok || tokenParse.tokens.length !== 1) {
@@ -319,7 +382,7 @@ function parseEnumAttribute(context, line, lineIndex) {
319
382
  return parsed;
320
383
  }
321
384
  function parseField(context, line, lineIndex) {
322
- const fieldMatch = line.match(/^([A-Za-z_]\w*)\s+([A-Za-z_]\w*(?:\[\])?)(\?)?(.*)$/);
385
+ const fieldMatch = line.match(/^([A-Za-z_]\w*)(\s+)(.+)$/);
323
386
  if (!fieldMatch) {
324
387
  pushDiagnostic(context, {
325
388
  code: "PSL_INVALID_MODEL_MEMBER",
@@ -329,22 +392,42 @@ function parseField(context, line, lineIndex) {
329
392
  return;
330
393
  }
331
394
  const fieldName = fieldMatch[1] ?? "";
332
- const rawTypeToken = fieldMatch[2] ?? "";
333
- const optionalMarker = fieldMatch[3] ?? "";
334
- const attributePart = fieldMatch[4] ?? "";
335
- const list = rawTypeToken.endsWith("[]");
336
- const typeName = list ? rawTypeToken.slice(0, -2) : rawTypeToken;
337
- const optional = optionalMarker === "?";
338
- const attributes = [];
395
+ const separator = fieldMatch[2] ?? "";
396
+ const typeAndAttributeSplit = splitTypeAndAttributes(fieldMatch[3] ?? "");
397
+ const rawTypeSource = typeAndAttributeSplit.typeSource.trim();
398
+ const attributePart = typeAndAttributeSplit.attributeSource;
399
+ const optional = rawTypeSource.endsWith("?");
400
+ const typeSourceWithoutOptional = optional ? rawTypeSource.slice(0, -1).trimEnd() : rawTypeSource;
401
+ const list = typeSourceWithoutOptional.endsWith("[]");
402
+ const baseTypeSource = list ? typeSourceWithoutOptional.slice(0, -2).trimEnd() : typeSourceWithoutOptional;
339
403
  const trimmedStartColumn = firstNonWhitespaceColumn(context.lines[lineIndex] ?? "");
340
- const attributeOffset = line.length - attributePart.length;
404
+ const typeConstructor = parseTypeConstructorCall(context, {
405
+ declarationValue: baseTypeSource,
406
+ lineIndex,
407
+ startColumn: trimmedStartColumn + fieldName.length + separator.length,
408
+ invalidCode: "PSL_INVALID_MODEL_MEMBER",
409
+ invalidMessage: (value) => `Invalid field type constructor "${value}"`
410
+ });
411
+ if (typeConstructor === "malformed") return;
412
+ const simpleTypeMatch = baseTypeSource.match(/^([A-Za-z_]\w*)$/);
413
+ const typeName = typeConstructor?.path.join(".") ?? simpleTypeMatch?.[1];
414
+ if (!typeName) {
415
+ pushDiagnostic(context, {
416
+ code: "PSL_INVALID_MODEL_MEMBER",
417
+ message: `Invalid model member declaration "${line}"`,
418
+ span: createTrimmedLineSpan(context, lineIndex)
419
+ });
420
+ return;
421
+ }
422
+ const attributes = [];
341
423
  const attributeSource = attributePart.trimStart();
342
424
  const leadingAttributeWhitespace = attributePart.length - attributeSource.length;
343
- const tokenParse = extractAttributeTokensWithSpans(context, lineIndex, attributeSource, trimmedStartColumn + attributeOffset + leadingAttributeWhitespace);
425
+ const tokenParse = extractAttributeTokensWithSpans(context, lineIndex, attributeSource, trimmedStartColumn + fieldName.length + separator.length + typeAndAttributeSplit.attributeOffset + leadingAttributeWhitespace);
344
426
  if (!tokenParse.ok) return {
345
427
  kind: "field",
346
428
  name: fieldName,
347
429
  typeName,
430
+ ...ifDefined("typeConstructor", typeConstructor),
348
431
  optional,
349
432
  list,
350
433
  attributes,
@@ -363,12 +446,69 @@ function parseField(context, line, lineIndex) {
363
446
  kind: "field",
364
447
  name: fieldName,
365
448
  typeName,
449
+ ...ifDefined("typeConstructor", typeConstructor),
366
450
  optional,
367
451
  list,
368
452
  attributes,
369
453
  span: createTrimmedLineSpan(context, lineIndex)
370
454
  };
371
455
  }
456
+ function isQuoteEscaped(value, quoteIndex) {
457
+ let backslashCount = 0;
458
+ for (let index = quoteIndex - 1; index >= 0 && value[index] === "\\"; index -= 1) backslashCount += 1;
459
+ return backslashCount % 2 === 1;
460
+ }
461
+ function splitTypeAndAttributes(value) {
462
+ let depthParen = 0;
463
+ let depthBracket = 0;
464
+ let depthBrace = 0;
465
+ let quote = null;
466
+ for (let index = 0; index < value.length; index += 1) {
467
+ const character = value[index] ?? "";
468
+ if (quote) {
469
+ if (character === quote && !isQuoteEscaped(value, index)) quote = null;
470
+ continue;
471
+ }
472
+ if (character === "\"" || character === "'") {
473
+ quote = character;
474
+ continue;
475
+ }
476
+ if (character === "(") {
477
+ depthParen += 1;
478
+ continue;
479
+ }
480
+ if (character === ")") {
481
+ depthParen = Math.max(0, depthParen - 1);
482
+ continue;
483
+ }
484
+ if (character === "[") {
485
+ depthBracket += 1;
486
+ continue;
487
+ }
488
+ if (character === "]") {
489
+ depthBracket = Math.max(0, depthBracket - 1);
490
+ continue;
491
+ }
492
+ if (character === "{") {
493
+ depthBrace += 1;
494
+ continue;
495
+ }
496
+ if (character === "}") {
497
+ depthBrace = Math.max(0, depthBrace - 1);
498
+ continue;
499
+ }
500
+ if (character === "@" && depthParen === 0 && depthBracket === 0 && depthBrace === 0) return {
501
+ typeSource: value.slice(0, index).trimEnd(),
502
+ attributeSource: value.slice(index),
503
+ attributeOffset: index
504
+ };
505
+ }
506
+ return {
507
+ typeSource: value.trimEnd(),
508
+ attributeSource: "",
509
+ attributeOffset: value.length
510
+ };
511
+ }
372
512
  function parseAttributeToken(context, input) {
373
513
  const expectsBlockPrefix = input.target === "model" || input.target === "enum";
374
514
  const targetLabel = input.target === "enum" ? "Enum" : "Model";
@@ -427,12 +567,15 @@ function parseAttributeToken(context, input) {
427
567
  });
428
568
  return;
429
569
  }
430
- const parsedArgs = parseAttributeArguments(context, {
570
+ const parsedArgs = parseArgumentList(context, {
431
571
  argsRaw: rawBody.slice(openParen + 1, closeParen),
432
572
  argsOffset: input.span.start.column - 1 + (expectsBlockPrefix ? 2 : 1) + openParen + 1,
433
573
  lineIndex: input.lineIndex,
434
574
  token: input.token,
435
- span: input.span
575
+ span: input.span,
576
+ invalidCode: "PSL_INVALID_ATTRIBUTE_SYNTAX",
577
+ invalidEmptyArgumentMessage: `Invalid empty argument in attribute "${input.token}"`,
578
+ invalidNamedArgumentMessage: (part) => `Invalid named argument syntax "${part}"`
436
579
  });
437
580
  if (!parsedArgs) return;
438
581
  args = parsedArgs;
@@ -445,7 +588,7 @@ function parseAttributeToken(context, input) {
445
588
  span: input.span
446
589
  };
447
590
  }
448
- function parseAttributeArguments(context, input) {
591
+ function parseArgumentList(context, input) {
449
592
  if (input.argsRaw.trim().length === 0) return [];
450
593
  const parts = splitTopLevelSegments(input.argsRaw, ",");
451
594
  const args = [];
@@ -454,8 +597,8 @@ function parseAttributeArguments(context, input) {
454
597
  const trimmedPart = original.trim();
455
598
  if (trimmedPart.length === 0) {
456
599
  pushDiagnostic(context, {
457
- code: "PSL_INVALID_ATTRIBUTE_SYNTAX",
458
- message: `Invalid empty argument in attribute "${input.token}"`,
600
+ code: input.invalidCode,
601
+ message: input.invalidEmptyArgumentMessage,
459
602
  span: input.span
460
603
  });
461
604
  return;
@@ -469,8 +612,8 @@ function parseAttributeArguments(context, input) {
469
612
  const first = namedSplit[0];
470
613
  if (!first) {
471
614
  pushDiagnostic(context, {
472
- code: "PSL_INVALID_ATTRIBUTE_SYNTAX",
473
- message: `Invalid named argument syntax "${trimmedPart}"`,
615
+ code: input.invalidCode,
616
+ message: input.invalidNamedArgumentMessage(trimmedPart),
474
617
  span: partSpan
475
618
  });
476
619
  return;
@@ -479,8 +622,8 @@ function parseAttributeArguments(context, input) {
479
622
  const rawValue = trimmedPart.slice(first.end + 1).trim();
480
623
  if (!name || rawValue.length === 0) {
481
624
  pushDiagnostic(context, {
482
- code: "PSL_INVALID_ATTRIBUTE_SYNTAX",
483
- message: `Invalid named argument syntax "${trimmedPart}"`,
625
+ code: input.invalidCode,
626
+ message: input.invalidNamedArgumentMessage(trimmedPart),
484
627
  span: partSpan
485
628
  });
486
629
  return;
@@ -509,16 +652,14 @@ function findBlockBounds(context, startLine) {
509
652
  for (let lineIndex = startLine; lineIndex < context.lines.length; lineIndex += 1) {
510
653
  const line = stripInlineComment(context.lines[lineIndex] ?? "");
511
654
  let quote = null;
512
- let previousCharacter = "";
513
- for (const character of line) {
655
+ for (let index = 0; index < line.length; index += 1) {
656
+ const character = line[index] ?? "";
514
657
  if (quote) {
515
- if (character === quote && previousCharacter !== "\\") quote = null;
516
- previousCharacter = character;
658
+ if (character === quote && !isQuoteEscaped(line, index)) quote = null;
517
659
  continue;
518
660
  }
519
661
  if (character === "\"" || character === "'") {
520
662
  quote = character;
521
- previousCharacter = character;
522
663
  continue;
523
664
  }
524
665
  if (character === "{") depth += 1;
@@ -530,7 +671,6 @@ function findBlockBounds(context, startLine) {
530
671
  closed: true
531
672
  };
532
673
  }
533
- previousCharacter = character;
534
674
  }
535
675
  }
536
676
  pushDiagnostic(context, {
@@ -548,12 +688,13 @@ function splitTopLevelSegments(value, separator) {
548
688
  const parts = [];
549
689
  let depthParen = 0;
550
690
  let depthBracket = 0;
691
+ let depthBrace = 0;
551
692
  let quote = null;
552
693
  let start = 0;
553
694
  for (let index = 0; index < value.length; index += 1) {
554
695
  const character = value[index] ?? "";
555
696
  if (quote) {
556
- if (character === quote && value[index - 1] !== "\\") quote = null;
697
+ if (character === quote && !isQuoteEscaped(value, index)) quote = null;
557
698
  continue;
558
699
  }
559
700
  if (character === "\"" || character === "'") {
@@ -576,7 +717,15 @@ function splitTopLevelSegments(value, separator) {
576
717
  depthBracket = Math.max(0, depthBracket - 1);
577
718
  continue;
578
719
  }
579
- if (character === separator && depthParen === 0 && depthBracket === 0) {
720
+ if (character === "{") {
721
+ depthBrace += 1;
722
+ continue;
723
+ }
724
+ if (character === "}") {
725
+ depthBrace = Math.max(0, depthBrace - 1);
726
+ continue;
727
+ }
728
+ if (character === separator && depthParen === 0 && depthBracket === 0 && depthBrace === 0) {
580
729
  parts.push({
581
730
  value: value.slice(start, index),
582
731
  start,
@@ -631,7 +780,7 @@ function extractAttributeTokensWithSpans(context, lineIndex, value, startColumn)
631
780
  while (index < value.length) {
632
781
  const char = value[index] ?? "";
633
782
  if (quote) {
634
- if (char === quote && value[index - 1] !== "\\") quote = null;
783
+ if (char === quote && !isQuoteEscaped(value, index)) quote = null;
635
784
  index += 1;
636
785
  continue;
637
786
  }
@@ -692,7 +841,7 @@ function stripInlineComment(line) {
692
841
  const current = line[index] ?? "";
693
842
  const next = line[index + 1] ?? "";
694
843
  if (quote) {
695
- if (current === quote && line[index - 1] !== "\\") quote = null;
844
+ if (current === quote && !isQuoteEscaped(line, index)) quote = null;
696
845
  continue;
697
846
  }
698
847
  if (current === "\"" || current === "'") {
@@ -752,4 +901,4 @@ function pushDiagnostic(context, diagnostic) {
752
901
 
753
902
  //#endregion
754
903
  export { parsePslDocument as t };
755
- //# sourceMappingURL=parser-jCEw-qFr.mjs.map
904
+ //# sourceMappingURL=parser-Cr64fw1E.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser-Cr64fw1E.mjs","names":["diagnostics: PslDiagnostic[]","context: ParserContext","models: PslModel[]","enums: PslEnum[]","compositeTypes: PslCompositeType[]","typesBlock: PslTypesBlock | undefined","fields: PslField[]","attributes: PslModelAttribute[]","attributes: PslAttribute[]","values: PslEnumValue[]","declarations: PslNamedTypeDeclaration[]","attributes: PslFieldAttribute[]","quote: '\"' | \"'\" | null","args: readonly PslAttributeArgument[]","args: PslAttributeArgument[]","parts: TopLevelSegment[]","tokens: { text: string; span: PslSpan }[]"],"sources":["../src/parser.ts"],"sourcesContent":["import { ifDefined } from '@prisma-next/utils/defined';\nimport type {\n ParsePslDocumentInput,\n ParsePslDocumentResult,\n PslAttribute,\n PslAttributeArgument,\n PslAttributeTarget,\n PslCompositeType,\n PslDiagnostic,\n PslDiagnosticCode,\n PslDocumentAst,\n PslEnum,\n PslEnumValue,\n PslField,\n PslFieldAttribute,\n PslModel,\n PslModelAttribute,\n PslNamedTypeDeclaration,\n PslPosition,\n PslSpan,\n PslTypeConstructorCall,\n PslTypesBlock,\n} from './types';\n\nconst SCALAR_TYPES = new Set([\n 'String',\n 'Boolean',\n 'Int',\n 'BigInt',\n 'Float',\n 'Decimal',\n 'DateTime',\n 'Json',\n 'Bytes',\n]);\n\ninterface BlockBounds {\n readonly startLine: number;\n readonly endLine: number;\n readonly closed: boolean;\n}\n\ninterface ParserContext {\n readonly schema: string;\n readonly sourceId: string;\n readonly lines: readonly string[];\n readonly lineOffsets: readonly number[];\n readonly diagnostics: PslDiagnostic[];\n}\n\nexport function parsePslDocument(input: ParsePslDocumentInput): ParsePslDocumentResult {\n const normalizedSchema = input.schema.replaceAll('\\r\\n', '\\n');\n const lines = normalizedSchema.split('\\n');\n const lineOffsets = computeLineOffsets(normalizedSchema);\n const diagnostics: PslDiagnostic[] = [];\n const context: ParserContext = {\n schema: normalizedSchema,\n sourceId: input.sourceId,\n lines,\n lineOffsets,\n diagnostics,\n };\n\n const models: PslModel[] = [];\n const enums: PslEnum[] = [];\n const compositeTypes: PslCompositeType[] = [];\n let typesBlock: PslTypesBlock | undefined;\n\n let lineIndex = 0;\n while (lineIndex < lines.length) {\n const rawLine = lines[lineIndex] ?? '';\n const line = stripInlineComment(rawLine).trim();\n if (line.length === 0) {\n lineIndex += 1;\n continue;\n }\n\n const modelMatch = line.match(/^model\\s+([A-Za-z_]\\w*)\\s*\\{$/);\n if (modelMatch) {\n const bounds = findBlockBounds(context, lineIndex);\n const name = modelMatch[1] ?? '';\n if (name.length === 0) {\n lineIndex = bounds.endLine + 1;\n continue;\n }\n models.push(parseModelBlock(context, name, bounds));\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n const enumMatch = line.match(/^enum\\s+([A-Za-z_]\\w*)\\s*\\{$/);\n if (enumMatch) {\n const bounds = findBlockBounds(context, lineIndex);\n const name = enumMatch[1] ?? '';\n if (name.length === 0) {\n lineIndex = bounds.endLine + 1;\n continue;\n }\n enums.push(parseEnumBlock(context, name, bounds));\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n const compositeTypeMatch = line.match(/^type\\s+([A-Za-z_]\\w*)\\s*\\{$/);\n if (compositeTypeMatch) {\n const bounds = findBlockBounds(context, lineIndex);\n const name = compositeTypeMatch[1] ?? '';\n if (name.length === 0) {\n lineIndex = bounds.endLine + 1;\n continue;\n }\n compositeTypes.push(parseCompositeTypeBlock(context, name, bounds));\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n if (/^types\\s*\\{$/.test(line)) {\n const bounds = findBlockBounds(context, lineIndex);\n typesBlock = parseTypesBlock(context, bounds);\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n if (line.includes('{')) {\n const blockName = line.split(/\\s+/)[0] ?? 'block';\n pushDiagnostic(context, {\n code: 'PSL_UNSUPPORTED_TOP_LEVEL_BLOCK',\n message: `Unsupported top-level block \"${blockName}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n const bounds = findBlockBounds(context, lineIndex);\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n pushDiagnostic(context, {\n code: 'PSL_UNSUPPORTED_TOP_LEVEL_BLOCK',\n message: `Unsupported top-level declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n lineIndex += 1;\n }\n\n const namedTypeNames = new Set(\n (typesBlock?.declarations ?? []).map((declaration) => declaration.name),\n );\n const modelNames = new Set(models.map((model) => model.name));\n const enumNames = new Set(enums.map((enumBlock) => enumBlock.name));\n const compositeTypeNames = new Set(compositeTypes.map((ct) => ct.name));\n for (const declaration of typesBlock?.declarations ?? []) {\n if (SCALAR_TYPES.has(declaration.name)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Named type \"${declaration.name}\" conflicts with scalar type \"${declaration.name}\"`,\n span: declaration.span,\n });\n continue;\n }\n if (modelNames.has(declaration.name)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Named type \"${declaration.name}\" conflicts with model name \"${declaration.name}\"`,\n span: declaration.span,\n });\n continue;\n }\n if (enumNames.has(declaration.name)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Named type \"${declaration.name}\" conflicts with enum name \"${declaration.name}\"`,\n span: declaration.span,\n });\n }\n }\n const normalizedModels = models.map((model) => ({\n ...model,\n fields: model.fields.map((field) => {\n if (!namedTypeNames.has(field.typeName)) {\n return field;\n }\n const hasRelationAttribute = field.attributes.some(\n (attribute) => attribute.name === 'relation',\n );\n if (\n hasRelationAttribute ||\n modelNames.has(field.typeName) ||\n enumNames.has(field.typeName) ||\n compositeTypeNames.has(field.typeName) ||\n SCALAR_TYPES.has(field.typeName)\n ) {\n return field;\n }\n return {\n ...field,\n typeRef: field.typeName,\n };\n }),\n }));\n\n const ast: PslDocumentAst = {\n kind: 'document',\n sourceId: input.sourceId,\n models: normalizedModels,\n enums,\n compositeTypes,\n ...ifDefined('types', typesBlock),\n span: {\n start: createPosition(context, 0, 0),\n end: createPosition(\n context,\n Math.max(lines.length - 1, 0),\n (lines[Math.max(lines.length - 1, 0)] ?? '').length,\n ),\n },\n };\n\n return {\n ast,\n diagnostics,\n ok: diagnostics.length === 0,\n };\n}\n\nfunction parseModelBlock(context: ParserContext, name: string, bounds: BlockBounds): PslModel {\n const fields: PslField[] = [];\n const attributes: PslModelAttribute[] = [];\n\n for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {\n const raw = context.lines[lineIndex] ?? '';\n const line = stripInlineComment(raw).trim();\n if (line.length === 0) {\n continue;\n }\n\n if (line.startsWith('@@')) {\n const attribute = parseModelAttribute(context, line, lineIndex);\n if (attribute) {\n attributes.push(attribute);\n }\n continue;\n }\n\n const field = parseField(context, line, lineIndex);\n if (field) {\n fields.push(field);\n }\n }\n\n return {\n kind: 'model',\n name,\n fields,\n attributes,\n span: createLineRangeSpan(context, bounds.startLine, bounds.endLine),\n };\n}\n\nfunction parseCompositeTypeBlock(\n context: ParserContext,\n name: string,\n bounds: BlockBounds,\n): PslCompositeType {\n const fields: PslField[] = [];\n const attributes: PslAttribute[] = [];\n\n for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {\n const raw = context.lines[lineIndex] ?? '';\n const line = stripInlineComment(raw).trim();\n if (line.length === 0) {\n continue;\n }\n\n if (line.startsWith('@@')) {\n const attribute = parseModelAttribute(context, line, lineIndex);\n if (attribute) {\n attributes.push(attribute);\n }\n continue;\n }\n\n const field = parseField(context, line, lineIndex);\n if (field) {\n fields.push(field);\n }\n }\n\n return {\n kind: 'compositeType',\n name,\n fields,\n attributes,\n span: createLineRangeSpan(context, bounds.startLine, bounds.endLine),\n };\n}\n\nfunction parseEnumBlock(context: ParserContext, name: string, bounds: BlockBounds): PslEnum {\n const values: PslEnumValue[] = [];\n const attributes: PslAttribute[] = [];\n\n for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {\n const raw = context.lines[lineIndex] ?? '';\n const line = stripInlineComment(raw).trim();\n if (line.length === 0) {\n continue;\n }\n\n if (line.startsWith('@@')) {\n const attribute = parseEnumAttribute(context, line, lineIndex);\n if (attribute) {\n attributes.push(attribute);\n }\n continue;\n }\n\n const valueMatch = line.match(/^([A-Za-z_]\\w*)$/);\n if (!valueMatch) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ENUM_MEMBER',\n message: `Invalid enum value declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n continue;\n }\n\n values.push({\n kind: 'enumValue',\n name: valueMatch[1] ?? '',\n span: createTrimmedLineSpan(context, lineIndex),\n });\n }\n\n return {\n kind: 'enum',\n name,\n values,\n attributes,\n span: createLineRangeSpan(context, bounds.startLine, bounds.endLine),\n };\n}\n\nfunction parseTypesBlock(context: ParserContext, bounds: BlockBounds): PslTypesBlock {\n const declarations: PslNamedTypeDeclaration[] = [];\n\n for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {\n const raw = context.lines[lineIndex] ?? '';\n const lineWithoutComment = stripInlineComment(raw);\n const line = lineWithoutComment.trim();\n if (line.length === 0) {\n continue;\n }\n\n const declarationMatch = line.match(/^([A-Za-z_]\\w*)\\s*=\\s*(.+)$/);\n if (!declarationMatch) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Invalid types declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n continue;\n }\n\n const declarationName = declarationMatch[1] ?? '';\n const trimmedStartColumn = firstNonWhitespaceColumn(raw);\n const declarationValue = (declarationMatch[2] ?? '').trim();\n const valueOffset = line.indexOf(declarationValue);\n const declarationValueColumn = trimmedStartColumn + Math.max(valueOffset, 0);\n\n const typeAndAttributeSplit = splitTypeAndAttributes(declarationValue);\n const typeSource = typeAndAttributeSplit.typeSource.trim();\n const attributeSource = typeAndAttributeSplit.attributeSource.trimStart();\n const leadingAttributeWhitespace =\n typeAndAttributeSplit.attributeSource.length - attributeSource.length;\n\n const typeConstructor = parseTypeConstructorCall(context, {\n declarationValue: typeSource,\n lineIndex,\n startColumn: declarationValueColumn,\n invalidCode: 'PSL_INVALID_TYPES_MEMBER',\n invalidMessage: (value) => `Invalid types declaration \"${value}\"`,\n });\n if (typeConstructor === 'malformed') {\n continue;\n }\n\n const attributeParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n attributeSource,\n declarationValueColumn + typeAndAttributeSplit.attributeOffset + leadingAttributeWhitespace,\n );\n if (!attributeParse.ok) {\n continue;\n }\n const attributes = attributeParse.tokens\n .map((token) =>\n parseAttributeToken(context, {\n token: token.text,\n target: 'namedType',\n lineIndex,\n span: token.span,\n }),\n )\n .filter((attribute): attribute is PslAttribute => Boolean(attribute));\n\n if (typeConstructor) {\n declarations.push({\n kind: 'namedType',\n name: declarationName,\n typeConstructor,\n attributes,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n continue;\n }\n\n const baseTypeMatch = typeSource.match(/^([A-Za-z_]\\w*)$/);\n if (!baseTypeMatch) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Invalid types declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n continue;\n }\n\n const baseType = baseTypeMatch[1] ?? '';\n\n declarations.push({\n kind: 'namedType',\n name: declarationName,\n baseType,\n attributes,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n }\n\n return {\n kind: 'types',\n declarations,\n span: createLineRangeSpan(context, bounds.startLine, bounds.endLine),\n };\n}\n\nfunction parseTypeConstructorCall(\n context: ParserContext,\n input: {\n readonly declarationValue: string;\n readonly lineIndex: number;\n readonly startColumn: number;\n readonly invalidCode: PslDiagnosticCode;\n readonly invalidMessage: (value: string) => string;\n },\n): PslTypeConstructorCall | 'malformed' | undefined {\n const value = input.declarationValue.trim();\n const constructorMatch = value.match(\n /^([A-Za-z_][A-Za-z0-9_-]*(?:\\.[A-Za-z_][A-Za-z0-9_-]*)*)\\s*\\(/,\n );\n if (!constructorMatch) {\n return undefined;\n }\n\n // constructorMatch already required `(`; openParen is guaranteed ≥ 0.\n const openParen = value.indexOf('(');\n const closeParen = value.lastIndexOf(')');\n\n if (closeParen !== value.length - 1) {\n pushDiagnostic(context, {\n code: input.invalidCode,\n message: input.invalidMessage(value),\n span: createInlineSpan(\n context,\n input.lineIndex,\n input.startColumn,\n input.startColumn + value.length,\n ),\n });\n return 'malformed';\n }\n\n const constructorPath = constructorMatch[1] ?? '';\n\n const argsRaw = value.slice(openParen + 1, closeParen);\n const args = parseArgumentList(context, {\n argsRaw,\n argsOffset: input.startColumn + openParen + 1,\n lineIndex: input.lineIndex,\n token: value,\n span: createInlineSpan(\n context,\n input.lineIndex,\n input.startColumn,\n input.startColumn + value.length,\n ),\n invalidCode: input.invalidCode,\n invalidEmptyArgumentMessage: `Invalid empty argument in type constructor \"${value}\"`,\n invalidNamedArgumentMessage: (part) =>\n `Invalid named argument syntax \"${part}\" in type constructor \"${value}\"`,\n });\n if (!args) {\n return 'malformed';\n }\n\n return {\n kind: 'typeConstructor',\n path: constructorPath.split('.'),\n args,\n span: createInlineSpan(\n context,\n input.lineIndex,\n input.startColumn,\n input.startColumn + value.length,\n ),\n };\n}\n\nfunction parseModelAttribute(\n context: ParserContext,\n line: string,\n lineIndex: number,\n): PslModelAttribute | undefined {\n const rawLine = context.lines[lineIndex] ?? '';\n const tokenParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n line,\n firstNonWhitespaceColumn(rawLine),\n );\n if (!tokenParse.ok || tokenParse.tokens.length !== 1) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid model attribute syntax \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n return undefined;\n }\n const token = tokenParse.tokens[0];\n if (!token) {\n return undefined;\n }\n return parseAttributeToken(context, {\n token: token.text,\n target: 'model',\n lineIndex,\n span: token.span,\n });\n}\n\nfunction parseEnumAttribute(\n context: ParserContext,\n line: string,\n lineIndex: number,\n): PslAttribute | undefined {\n const rawLine = context.lines[lineIndex] ?? '';\n const tokenParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n line,\n firstNonWhitespaceColumn(rawLine),\n );\n if (!tokenParse.ok || tokenParse.tokens.length !== 1) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ENUM_MEMBER',\n message: `Invalid enum value declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n return undefined;\n }\n const token = tokenParse.tokens[0];\n if (!token) {\n return undefined;\n }\n const parsed = parseAttributeToken(context, {\n token: token.text,\n target: 'enum',\n lineIndex,\n span: token.span,\n });\n if (!parsed) {\n return undefined;\n }\n if (parsed.name !== 'map') {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ENUM_MEMBER',\n message: `Invalid enum value declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n return undefined;\n }\n return parsed;\n}\n\nfunction parseField(context: ParserContext, line: string, lineIndex: number): PslField | undefined {\n const fieldMatch = line.match(/^([A-Za-z_]\\w*)(\\s+)(.+)$/);\n if (!fieldMatch) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_MODEL_MEMBER',\n message: `Invalid model member declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n return undefined;\n }\n\n const fieldName = fieldMatch[1] ?? '';\n const separator = fieldMatch[2] ?? '';\n const remainder = fieldMatch[3] ?? '';\n const typeAndAttributeSplit = splitTypeAndAttributes(remainder);\n const rawTypeSource = typeAndAttributeSplit.typeSource.trim();\n const attributePart = typeAndAttributeSplit.attributeSource;\n const optional = rawTypeSource.endsWith('?');\n const typeSourceWithoutOptional = optional ? rawTypeSource.slice(0, -1).trimEnd() : rawTypeSource;\n const list = typeSourceWithoutOptional.endsWith('[]');\n const baseTypeSource = list\n ? typeSourceWithoutOptional.slice(0, -2).trimEnd()\n : typeSourceWithoutOptional;\n const rawLine = context.lines[lineIndex] ?? '';\n const trimmedStartColumn = firstNonWhitespaceColumn(rawLine);\n const typeStartColumn = trimmedStartColumn + fieldName.length + separator.length;\n\n const typeConstructor = parseTypeConstructorCall(context, {\n declarationValue: baseTypeSource,\n lineIndex,\n startColumn: typeStartColumn,\n invalidCode: 'PSL_INVALID_MODEL_MEMBER',\n invalidMessage: (value) => `Invalid field type constructor \"${value}\"`,\n });\n if (typeConstructor === 'malformed') {\n return undefined;\n }\n\n const simpleTypeMatch = baseTypeSource.match(/^([A-Za-z_]\\w*)$/);\n const typeName = typeConstructor?.path.join('.') ?? simpleTypeMatch?.[1];\n if (!typeName) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_MODEL_MEMBER',\n message: `Invalid model member declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n return undefined;\n }\n\n const attributes: PslFieldAttribute[] = [];\n const attributeSource = attributePart.trimStart();\n const leadingAttributeWhitespace = attributePart.length - attributeSource.length;\n const tokenParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n attributeSource,\n trimmedStartColumn +\n fieldName.length +\n separator.length +\n typeAndAttributeSplit.attributeOffset +\n leadingAttributeWhitespace,\n );\n if (!tokenParse.ok) {\n return {\n kind: 'field',\n name: fieldName,\n typeName,\n ...ifDefined('typeConstructor', typeConstructor),\n optional,\n list,\n attributes,\n span: createTrimmedLineSpan(context, lineIndex),\n };\n }\n\n for (const token of tokenParse.tokens) {\n const parsed = parseAttributeToken(context, {\n token: token.text,\n target: 'field',\n lineIndex,\n span: token.span,\n });\n if (parsed) {\n attributes.push(parsed);\n }\n }\n\n return {\n kind: 'field',\n name: fieldName,\n typeName,\n ...ifDefined('typeConstructor', typeConstructor),\n optional,\n list,\n attributes,\n span: createTrimmedLineSpan(context, lineIndex),\n };\n}\n\nfunction isQuoteEscaped(value: string, quoteIndex: number): boolean {\n let backslashCount = 0;\n\n for (let index = quoteIndex - 1; index >= 0 && value[index] === '\\\\'; index -= 1) {\n backslashCount += 1;\n }\n\n return backslashCount % 2 === 1;\n}\n\nfunction splitTypeAndAttributes(value: string): {\n readonly typeSource: string;\n readonly attributeSource: string;\n readonly attributeOffset: number;\n} {\n let depthParen = 0;\n let depthBracket = 0;\n let depthBrace = 0;\n let quote: '\"' | \"'\" | null = null;\n\n for (let index = 0; index < value.length; index += 1) {\n const character = value[index] ?? '';\n if (quote) {\n if (character === quote && !isQuoteEscaped(value, index)) {\n quote = null;\n }\n continue;\n }\n\n if (character === '\"' || character === \"'\") {\n quote = character;\n continue;\n }\n if (character === '(') {\n depthParen += 1;\n continue;\n }\n if (character === ')') {\n depthParen = Math.max(0, depthParen - 1);\n continue;\n }\n if (character === '[') {\n depthBracket += 1;\n continue;\n }\n if (character === ']') {\n depthBracket = Math.max(0, depthBracket - 1);\n continue;\n }\n if (character === '{') {\n depthBrace += 1;\n continue;\n }\n if (character === '}') {\n depthBrace = Math.max(0, depthBrace - 1);\n continue;\n }\n\n if (character === '@' && depthParen === 0 && depthBracket === 0 && depthBrace === 0) {\n return {\n typeSource: value.slice(0, index).trimEnd(),\n attributeSource: value.slice(index),\n attributeOffset: index,\n };\n }\n }\n\n return {\n typeSource: value.trimEnd(),\n attributeSource: '',\n attributeOffset: value.length,\n };\n}\n\nfunction parseAttributeToken(\n context: ParserContext,\n input: {\n readonly token: string;\n readonly target: PslAttributeTarget;\n readonly lineIndex: number;\n readonly span: PslSpan;\n },\n): PslAttribute | undefined {\n const expectsBlockPrefix = input.target === 'model' || input.target === 'enum';\n const targetLabel = input.target === 'enum' ? 'Enum' : 'Model';\n if (expectsBlockPrefix && !input.token.startsWith('@@')) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `${targetLabel} attribute \"${input.token}\" must use @@ prefix`,\n span: input.span,\n });\n return undefined;\n }\n if (!expectsBlockPrefix && !input.token.startsWith('@')) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Attribute \"${input.token}\" must use @ prefix`,\n span: input.span,\n });\n return undefined;\n }\n if (!expectsBlockPrefix && input.token.startsWith('@@')) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Attribute \"${input.token}\" is not valid in ${input.target} context`,\n span: input.span,\n });\n return undefined;\n }\n\n const rawBody = expectsBlockPrefix ? input.token.slice(2) : input.token.slice(1);\n const openParen = rawBody.indexOf('(');\n const closeParen = rawBody.lastIndexOf(')');\n const hasArgs = openParen >= 0 || closeParen >= 0;\n if ((openParen >= 0 && closeParen === -1) || (openParen === -1 && closeParen >= 0)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute syntax \"${input.token}\"`,\n span: input.span,\n });\n return undefined;\n }\n\n const name = (openParen >= 0 ? rawBody.slice(0, openParen) : rawBody).trim();\n if (!/^[A-Za-z_][A-Za-z0-9_-]*(\\.[A-Za-z_][A-Za-z0-9_-]*)*$/.test(name)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute name \"${name || input.token}\"`,\n span: input.span,\n });\n return undefined;\n }\n\n let args: readonly PslAttributeArgument[] = [];\n if (hasArgs && openParen >= 0 && closeParen >= openParen) {\n if (closeParen !== rawBody.length - 1) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid trailing syntax in attribute \"${input.token}\"`,\n span: input.span,\n });\n return undefined;\n }\n const argsRaw = rawBody.slice(openParen + 1, closeParen);\n const parsedArgs = parseArgumentList(context, {\n argsRaw,\n argsOffset: input.span.start.column - 1 + (expectsBlockPrefix ? 2 : 1) + openParen + 1,\n lineIndex: input.lineIndex,\n token: input.token,\n span: input.span,\n invalidCode: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n invalidEmptyArgumentMessage: `Invalid empty argument in attribute \"${input.token}\"`,\n invalidNamedArgumentMessage: (part) => `Invalid named argument syntax \"${part}\"`,\n });\n if (!parsedArgs) {\n return undefined;\n }\n args = parsedArgs;\n }\n\n return {\n kind: 'attribute',\n target: input.target,\n name,\n args,\n span: input.span,\n };\n}\n\nfunction parseArgumentList(\n context: ParserContext,\n input: {\n readonly argsRaw: string;\n readonly argsOffset: number;\n readonly lineIndex: number;\n readonly token: string;\n readonly span: PslSpan;\n readonly invalidCode: PslDiagnosticCode;\n readonly invalidEmptyArgumentMessage: string;\n readonly invalidNamedArgumentMessage: (part: string) => string;\n },\n): readonly PslAttributeArgument[] | undefined {\n const trimmed = input.argsRaw.trim();\n if (trimmed.length === 0) {\n return [];\n }\n\n const parts = splitTopLevelSegments(input.argsRaw, ',');\n const args: PslAttributeArgument[] = [];\n\n for (const part of parts) {\n const original = part.value;\n const trimmedPart = original.trim();\n if (trimmedPart.length === 0) {\n pushDiagnostic(context, {\n code: input.invalidCode,\n message: input.invalidEmptyArgumentMessage,\n span: input.span,\n });\n return undefined;\n }\n\n const leadingWhitespace = original.length - original.trimStart().length;\n const partStart = input.argsOffset + part.start + leadingWhitespace;\n const partEnd = partStart + trimmedPart.length;\n const partSpan = createInlineSpan(context, input.lineIndex, partStart, partEnd);\n\n const namedSplit = splitTopLevelSegments(trimmedPart, ':');\n if (namedSplit.length > 1) {\n const first = namedSplit[0];\n if (!first) {\n pushDiagnostic(context, {\n code: input.invalidCode,\n message: input.invalidNamedArgumentMessage(trimmedPart),\n span: partSpan,\n });\n return undefined;\n }\n const name = first.value.trim();\n const rawValue = trimmedPart.slice(first.end + 1).trim();\n if (!name || rawValue.length === 0) {\n pushDiagnostic(context, {\n code: input.invalidCode,\n message: input.invalidNamedArgumentMessage(trimmedPart),\n span: partSpan,\n });\n return undefined;\n }\n args.push({\n kind: 'named',\n name,\n value: normalizeAttributeArgumentValue(rawValue),\n span: partSpan,\n });\n continue;\n }\n\n args.push({\n kind: 'positional',\n value: normalizeAttributeArgumentValue(trimmedPart),\n span: partSpan,\n });\n }\n\n return args;\n}\n\nfunction normalizeAttributeArgumentValue(value: string): string {\n return value.trim();\n}\n\nfunction findBlockBounds(context: ParserContext, startLine: number): BlockBounds {\n let depth = 0;\n\n for (let lineIndex = startLine; lineIndex < context.lines.length; lineIndex += 1) {\n const line = stripInlineComment(context.lines[lineIndex] ?? '');\n let quote: '\"' | \"'\" | null = null;\n for (let index = 0; index < line.length; index += 1) {\n const character = line[index] ?? '';\n if (quote) {\n if (character === quote && !isQuoteEscaped(line, index)) {\n quote = null;\n }\n continue;\n }\n\n if (character === '\"' || character === \"'\") {\n quote = character;\n continue;\n }\n\n if (character === '{') {\n depth += 1;\n }\n if (character === '}') {\n depth -= 1;\n if (depth === 0) {\n return { startLine, endLine: lineIndex, closed: true };\n }\n }\n }\n }\n\n pushDiagnostic(context, {\n code: 'PSL_UNTERMINATED_BLOCK',\n message: 'Unterminated block declaration',\n span: createTrimmedLineSpan(context, startLine),\n });\n return {\n startLine,\n endLine: context.lines.length - 1,\n closed: false,\n };\n}\n\ninterface TopLevelSegment {\n readonly value: string;\n readonly start: number;\n readonly end: number;\n}\n\nfunction splitTopLevelSegments(value: string, separator: ',' | ':'): TopLevelSegment[] {\n const parts: TopLevelSegment[] = [];\n let depthParen = 0;\n let depthBracket = 0;\n let depthBrace = 0;\n let quote: '\"' | \"'\" | null = null;\n let start = 0;\n\n for (let index = 0; index < value.length; index += 1) {\n const character = value[index] ?? '';\n if (quote) {\n if (character === quote && !isQuoteEscaped(value, index)) {\n quote = null;\n }\n continue;\n }\n\n if (character === '\"' || character === \"'\") {\n quote = character;\n continue;\n }\n\n if (character === '(') {\n depthParen += 1;\n continue;\n }\n if (character === ')') {\n depthParen = Math.max(0, depthParen - 1);\n continue;\n }\n if (character === '[') {\n depthBracket += 1;\n continue;\n }\n if (character === ']') {\n depthBracket = Math.max(0, depthBracket - 1);\n continue;\n }\n if (character === '{') {\n depthBrace += 1;\n continue;\n }\n if (character === '}') {\n depthBrace = Math.max(0, depthBrace - 1);\n continue;\n }\n\n if (character === separator && depthParen === 0 && depthBracket === 0 && depthBrace === 0) {\n parts.push({\n value: value.slice(start, index),\n start,\n end: index,\n });\n start = index + 1;\n }\n }\n\n parts.push({\n value: value.slice(start),\n start,\n end: value.length,\n });\n return parts;\n}\n\nfunction extractAttributeTokensWithSpans(\n context: ParserContext,\n lineIndex: number,\n value: string,\n startColumn: number,\n): { readonly ok: boolean; readonly tokens: readonly { text: string; span: PslSpan }[] } {\n const tokens: { text: string; span: PslSpan }[] = [];\n let index = 0;\n while (index < value.length) {\n while (index < value.length && /\\s/.test(value[index] ?? '')) {\n index += 1;\n }\n if (index >= value.length) {\n break;\n }\n\n if (value[index] !== '@') {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute syntax \"${value.trim()}\"`,\n span: createInlineSpan(context, lineIndex, startColumn + index, startColumn + value.length),\n });\n return { ok: false, tokens };\n }\n\n const start = index;\n index += 1;\n if (value[index] === '@') {\n index += 1;\n }\n\n const nameStart = index;\n while (index < value.length && /[A-Za-z0-9_.-]/.test(value[index] ?? '')) {\n index += 1;\n }\n\n if (index === nameStart) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute syntax \"${value.slice(start).trim()}\"`,\n span: createInlineSpan(context, lineIndex, startColumn + start, startColumn + value.length),\n });\n return { ok: false, tokens };\n }\n\n if (value[index] === '(') {\n let depth = 0;\n let quote: '\"' | \"'\" | null = null;\n while (index < value.length) {\n const char = value[index] ?? '';\n if (quote) {\n if (char === quote && !isQuoteEscaped(value, index)) {\n quote = null;\n }\n index += 1;\n continue;\n }\n\n if (char === '\"' || char === \"'\") {\n quote = char;\n index += 1;\n continue;\n }\n\n if (char === '(') {\n depth += 1;\n } else if (char === ')') {\n depth -= 1;\n if (depth === 0) {\n index += 1;\n break;\n }\n }\n index += 1;\n }\n if (depth !== 0) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Unterminated attribute argument list in \"${value.slice(start).trim()}\"`,\n span: createInlineSpan(\n context,\n lineIndex,\n startColumn + start,\n startColumn + value.length,\n ),\n });\n return { ok: false, tokens };\n }\n }\n\n const tokenText = value.slice(start, index).trim();\n tokens.push({\n text: tokenText,\n span: createInlineSpan(context, lineIndex, startColumn + start, startColumn + index),\n });\n\n while (index < value.length && /\\s/.test(value[index] ?? '')) {\n index += 1;\n }\n\n if (index < value.length && value[index] !== '@') {\n break;\n }\n }\n\n if (index < value.length && value[index] !== '@') {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute syntax \"${value.trim()}\"`,\n span: createInlineSpan(context, lineIndex, startColumn + index, startColumn + value.length),\n });\n return { ok: false, tokens };\n }\n\n return { ok: true, tokens };\n}\n\nfunction stripInlineComment(line: string): string {\n let quote: '\"' | \"'\" | null = null;\n for (let index = 0; index < line.length - 1; index += 1) {\n const current = line[index] ?? '';\n const next = line[index + 1] ?? '';\n\n if (quote) {\n if (current === quote && !isQuoteEscaped(line, index)) {\n quote = null;\n }\n continue;\n }\n\n if (current === '\"' || current === \"'\") {\n quote = current;\n continue;\n }\n\n if (current === '/' && next === '/') {\n return line.slice(0, index);\n }\n }\n\n return line;\n}\n\nfunction computeLineOffsets(schema: string): number[] {\n const offsets = [0];\n for (let index = 0; index < schema.length; index += 1) {\n if (schema[index] === '\\n') {\n offsets.push(index + 1);\n }\n }\n return offsets;\n}\n\nfunction firstNonWhitespaceColumn(line: string): number {\n const first = line.search(/\\S/);\n return first === -1 ? 0 : first;\n}\n\nfunction createInlineSpan(\n context: ParserContext,\n lineIndex: number,\n startColumn: number,\n endColumn: number,\n): PslSpan {\n return {\n start: createPosition(context, lineIndex, startColumn),\n end: createPosition(context, lineIndex, endColumn),\n };\n}\n\nfunction createTrimmedLineSpan(context: ParserContext, lineIndex: number): PslSpan {\n const line = context.lines[lineIndex] ?? '';\n const startColumn = firstNonWhitespaceColumn(line);\n return {\n start: createPosition(context, lineIndex, startColumn),\n end: createPosition(context, lineIndex, line.length),\n };\n}\n\nfunction createLineRangeSpan(context: ParserContext, startLine: number, endLine: number): PslSpan {\n const startLineText = context.lines[startLine] ?? '';\n const endLineText = context.lines[endLine] ?? '';\n const startColumn = firstNonWhitespaceColumn(startLineText);\n return {\n start: createPosition(context, startLine, startColumn),\n end: createPosition(context, endLine, endLineText.length),\n };\n}\n\nfunction createPosition(\n context: ParserContext,\n lineIndex: number,\n columnIndex: number,\n): PslPosition {\n const clampedLineIndex = Math.max(0, Math.min(lineIndex, context.lineOffsets.length - 1));\n const lineText = context.lines[clampedLineIndex] ?? '';\n const clampedColumnIndex = Math.max(0, Math.min(columnIndex, lineText.length));\n return {\n offset: (context.lineOffsets[clampedLineIndex] ?? 0) + clampedColumnIndex,\n line: clampedLineIndex + 1,\n column: clampedColumnIndex + 1,\n };\n}\n\nfunction pushDiagnostic(\n context: ParserContext,\n diagnostic: Omit<PslDiagnostic, 'sourceId'> & { readonly code: PslDiagnosticCode },\n): void {\n context.diagnostics.push({\n ...diagnostic,\n sourceId: context.sourceId,\n });\n}\n"],"mappings":";;;AAwBA,MAAM,eAAe,IAAI,IAAI;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAgBF,SAAgB,iBAAiB,OAAsD;CACrF,MAAM,mBAAmB,MAAM,OAAO,WAAW,QAAQ,KAAK;CAC9D,MAAM,QAAQ,iBAAiB,MAAM,KAAK;CAC1C,MAAM,cAAc,mBAAmB,iBAAiB;CACxD,MAAMA,cAA+B,EAAE;CACvC,MAAMC,UAAyB;EAC7B,QAAQ;EACR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C;AAC9E,QAAO;EACL,SAAS,QAAQ,YAAY,qBAAqB,KAAK;EACvD,MAAM,mBAAmB;EACzB,QAAQ,qBAAqB;EAC9B;;AAGH,SAAS,eACP,SACA,YACM;AACN,SAAQ,YAAY,KAAK;EACvB,GAAG;EACH,UAAU,QAAQ;EACnB,CAAC"}
package/dist/parser.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { t as parsePslDocument } from "./parser-D-_7FY6a.mjs";
1
+ import { t as parsePslDocument } from "./parser-B_U8b1dE.mjs";
2
2
  export { parsePslDocument };
package/dist/parser.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as parsePslDocument } from "./parser-jCEw-qFr.mjs";
1
+ import { t as parsePslDocument } from "./parser-Cr64fw1E.mjs";
2
2
 
3
3
  export { parsePslDocument };
@@ -37,6 +37,12 @@ interface PslAttributeNamedArgument {
37
37
  readonly span: PslSpan;
38
38
  }
39
39
  type PslAttributeArgument = PslAttributePositionalArgument | PslAttributeNamedArgument;
40
+ interface PslTypeConstructorCall {
41
+ readonly kind: 'typeConstructor';
42
+ readonly path: readonly string[];
43
+ readonly args: readonly PslAttributeArgument[];
44
+ readonly span: PslSpan;
45
+ }
40
46
  interface PslAttribute {
41
47
  readonly kind: 'attribute';
42
48
  readonly target: PslAttributeTarget;
@@ -50,6 +56,7 @@ interface PslField {
50
56
  readonly kind: 'field';
51
57
  readonly name: string;
52
58
  readonly typeName: string;
59
+ readonly typeConstructor?: PslTypeConstructorCall;
53
60
  readonly optional: boolean;
54
61
  readonly list: boolean;
55
62
  readonly typeRef?: string;
@@ -96,7 +103,13 @@ interface PslCompositeType {
96
103
  interface PslNamedTypeDeclaration {
97
104
  readonly kind: 'namedType';
98
105
  readonly name: string;
99
- readonly baseType: string;
106
+ /**
107
+ * Parser invariant: exactly one of `baseType` and `typeConstructor` is set.
108
+ * Expressing this as a discriminated union trips TypeScript narrowing when
109
+ * the declaration flows through helpers that accept the full union.
110
+ */
111
+ readonly baseType?: string;
112
+ readonly typeConstructor?: PslTypeConstructorCall;
100
113
  readonly attributes: readonly PslAttribute[];
101
114
  readonly span: PslSpan;
102
115
  }
@@ -124,5 +137,5 @@ interface ParsePslDocumentResult {
124
137
  readonly ok: boolean;
125
138
  }
126
139
  //#endregion
127
- export { PslPosition as C, PslUniqueConstraint as D, PslTypesBlock as E, PslNamedTypeDeclaration as S, PslSpan as T, PslField as _, PslAttributeNamedArgument as a, PslModel as b, PslCompositeType as c, PslDefaultValue as d, PslDiagnostic as f, PslEnumValue as g, PslEnum as h, PslAttributeArgument as i, PslDefaultFunctionValue as l, PslDocumentAst as m, ParsePslDocumentResult as n, PslAttributePositionalArgument as o, PslDiagnosticCode as p, PslAttribute as r, PslAttributeTarget as s, ParsePslDocumentInput as t, PslDefaultLiteralValue as u, PslFieldAttribute as v, PslReferentialAction as w, PslModelAttribute as x, PslIndexConstraint as y };
128
- //# sourceMappingURL=types-B5Y_8Gl4.d.mts.map
140
+ export { PslPosition as C, PslTypesBlock as D, PslTypeConstructorCall as E, PslUniqueConstraint as O, PslNamedTypeDeclaration as S, PslSpan as T, PslField as _, PslAttributeNamedArgument as a, PslModel as b, PslCompositeType as c, PslDefaultValue as d, PslDiagnostic as f, PslEnumValue as g, PslEnum as h, PslAttributeArgument as i, PslDefaultFunctionValue as l, PslDocumentAst as m, ParsePslDocumentResult as n, PslAttributePositionalArgument as o, PslDiagnosticCode as p, PslAttribute as r, PslAttributeTarget as s, ParsePslDocumentInput as t, PslDefaultLiteralValue as u, PslFieldAttribute as v, PslReferentialAction as w, PslModelAttribute as x, PslIndexConstraint as y };
141
+ //# sourceMappingURL=types-CYb3hCxS.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-CYb3hCxS.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";UAAiB,WAAA;EAAA,SAAA,MAAW,EAAA,MAAA;EAMX,SAAA,IAAO,EAAA,MACN;EAIN,SAAA,MAAA,EAAA,MAAiB;AAa7B;AAOi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oBAoEM,EAAA;EACf,SAAA,IAAA,EApEA,OAoEA;;AAGA,UApEA,YAAA,CAoEuB;EASX,SAAA,IAAA,EAAA,WAAA;EACG,SAAA,MAAA,EA5Eb,kBA4Ea;EACf,SAAA,IAAA,EAAA,MAAA;EAAO,SAAA,IAAA,EAAA,SA3EE,oBA2EF,EAAA;EAGP,SAAA,IAAA,EA7EA,OA6Ea;AAM9B;AAG4B,KAnFhB,oBAAA,GAmFgB,MAAA;AACD,KAlFf,iBAAA,GAAoB,YAkFL;AACS,UAjFnB,QAAA,CAiFmB;EACjB,SAAA,IAAA,EAAA,OAAA;EACF,SAAA,IAAA,EAAA,MAAA;EAAO,SAAA,QAAA,EAAA,MAAA;EAGP,SAAA,eAAqB,CAAA,EAlFT,sBAkFS;EAKrB,SAAA,QAAA,EAAA,OAAsB;;;gCAnFP;iBACf;;UAGA,mBAAA;;;iBAGA;;UAGA,kBAAA;;;iBAGA;;KAGL,iBAAA,GAAoB;UAEf,QAAA;;;4BAGW;gCACI;iBACf;;UAGA,YAAA;;;iBAGA;;UAGA,OAAA;;;4BAGW;gCACI;iBACf;;UAGA,gBAAA;;;4BAGW;gCACI;iBACf;;UAGA,uBAAA;;;;;;;;;6BASY;gCACG;iBACf;;UAGA,aAAA;;kCAEiB;iBACjB;;UAGA,cAAA;;;4BAGW;2BACD;oCACS;mBACjB;iBACF;;UAGA,qBAAA;;;;UAKA,sBAAA;gBACD;iCACiB"}
package/dist/types.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as PslPosition, D as PslUniqueConstraint, E as PslTypesBlock, S as PslNamedTypeDeclaration, T as PslSpan, _ as PslField, a as PslAttributeNamedArgument, b as PslModel, c as PslCompositeType, d as PslDefaultValue, f as PslDiagnostic, g as PslEnumValue, h as PslEnum, i as PslAttributeArgument, l as PslDefaultFunctionValue, m as PslDocumentAst, n as ParsePslDocumentResult, o as PslAttributePositionalArgument, p as PslDiagnosticCode, r as PslAttribute, s as PslAttributeTarget, t as ParsePslDocumentInput, u as PslDefaultLiteralValue, v as PslFieldAttribute, w as PslReferentialAction, x as PslModelAttribute, y as PslIndexConstraint } from "./types-B5Y_8Gl4.mjs";
1
+ import { C as PslPosition, D as PslTypesBlock, O as PslUniqueConstraint, S as PslNamedTypeDeclaration, T as PslSpan, _ as PslField, a as PslAttributeNamedArgument, b as PslModel, c as PslCompositeType, d as PslDefaultValue, f as PslDiagnostic, g as PslEnumValue, h as PslEnum, i as PslAttributeArgument, l as PslDefaultFunctionValue, m as PslDocumentAst, n as ParsePslDocumentResult, o as PslAttributePositionalArgument, p as PslDiagnosticCode, r as PslAttribute, s as PslAttributeTarget, t as ParsePslDocumentInput, u as PslDefaultLiteralValue, v as PslFieldAttribute, w as PslReferentialAction, x as PslModelAttribute, y as PslIndexConstraint } from "./types-CYb3hCxS.mjs";
2
2
  export { type ParsePslDocumentInput, type ParsePslDocumentResult, 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 PslEnum, type PslEnumValue, type PslField, type PslFieldAttribute, type PslIndexConstraint, type PslModel, type PslModelAttribute, type PslNamedTypeDeclaration, type PslPosition, type PslReferentialAction, type PslSpan, type PslTypesBlock, type PslUniqueConstraint };