@prisma-next/psl-parser 0.5.0-dev.9 → 0.5.0

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
@@ -38,10 +38,11 @@ Interpretation/validation (for example `@prisma-next/sql-contract-psl`) is respo
38
38
  ## Public API
39
39
 
40
40
  - `parsePslDocument(input)` in `src/parser.ts`
41
- - Exported AST/diagnostic/span types in `src/types.ts`
41
+ - AST/diagnostic/span types live in `@prisma-next/framework-components/psl-ast`
42
+ and are re-exported from this package's root entry for convenience.
42
43
  - Subpath exports:
43
44
  - `@prisma-next/psl-parser/parser`
44
- - `@prisma-next/psl-parser/types`
45
+ - `@prisma-next/psl-parser/tokenizer`
45
46
 
46
47
  ## Dependencies
47
48
 
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
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";
1
+ import { t as parsePslDocument } from "./parser-Bjdnhl7C.mjs";
2
+ import { ParsePslDocumentInput, ParsePslDocumentResult, PslAttribute, PslAttribute as PslAttribute$1, PslAttributeArgument, PslAttributeNamedArgument, PslAttributePositionalArgument, PslAttributeTarget, PslCompositeType, PslDefaultFunctionValue, PslDefaultLiteralValue, PslDefaultValue, PslDiagnostic, PslDiagnosticCode, PslDocumentAst, PslEnum, PslEnumValue, PslField, PslFieldAttribute, PslModel, PslModelAttribute, PslNamedTypeDeclaration, PslPosition, PslSpan, PslTypeConstructorCall, PslTypesBlock } from "@prisma-next/framework-components/psl-ast";
3
3
 
4
4
  //#region src/attribute-helpers.d.ts
5
- declare function getPositionalArgument(attribute: PslAttribute, index?: number): string | undefined;
5
+ declare function getPositionalArgument(attribute: PslAttribute$1, index?: number): string | undefined;
6
6
  declare function parseQuotedStringLiteral(value: string): string | undefined;
7
7
  //#endregion
8
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 };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/attribute-helpers.ts"],"sourcesContent":[],"mappings":";;;;iBAEgB,qBAAA,YAAiC;iBAKjC,wBAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/attribute-helpers.ts"],"mappings":";;;;iBAEgB,qBAAA,CAAsB,SAAA,EAAW,cAAA,EAAc,KAAA;AAAA,iBAK/C,wBAAA,CAAyB,KAAA"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import { t as parsePslDocument } from "./parser-Cr64fw1E.mjs";
2
-
1
+ import { t as parsePslDocument } from "./parser-1DZHweIq.mjs";
3
2
  //#region src/attribute-helpers.ts
4
3
  function getPositionalArgument(attribute, index = 0) {
5
4
  return attribute.args.filter((arg) => arg.kind === "positional")[index]?.value;
@@ -9,7 +8,7 @@ function parseQuotedStringLiteral(value) {
9
8
  if (!match) return void 0;
10
9
  return match[2] ?? "";
11
10
  }
12
-
13
11
  //#endregion
14
12
  export { getPositionalArgument, parsePslDocument, parseQuotedStringLiteral };
13
+
15
14
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/attribute-helpers.ts"],"sourcesContent":["import type { PslAttribute } from './types';\n\nexport function getPositionalArgument(attribute: PslAttribute, index = 0): string | undefined {\n const entries = attribute.args.filter((arg) => arg.kind === 'positional');\n return entries[index]?.value;\n}\n\nexport function parseQuotedStringLiteral(value: string): string | undefined {\n const trimmed = value.trim();\n const match = trimmed.match(/^(['\"])(.*)\\1$/);\n if (!match) return undefined;\n return match[2] ?? '';\n}\n"],"mappings":";;;AAEA,SAAgB,sBAAsB,WAAyB,QAAQ,GAAuB;AAE5F,QADgB,UAAU,KAAK,QAAQ,QAAQ,IAAI,SAAS,aAAa,CAC1D,QAAQ;;AAGzB,SAAgB,yBAAyB,OAAmC;CAE1E,MAAM,QADU,MAAM,MAAM,CACN,MAAM,iBAAiB;AAC7C,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO,MAAM,MAAM"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/attribute-helpers.ts"],"sourcesContent":["import type { PslAttribute } from '@prisma-next/framework-components/psl-ast';\n\nexport function getPositionalArgument(attribute: PslAttribute, index = 0): string | undefined {\n const entries = attribute.args.filter((arg) => arg.kind === 'positional');\n return entries[index]?.value;\n}\n\nexport function parseQuotedStringLiteral(value: string): string | undefined {\n const trimmed = value.trim();\n const match = trimmed.match(/^(['\"])(.*)\\1$/);\n if (!match) return undefined;\n return match[2] ?? '';\n}\n"],"mappings":";;AAEA,SAAgB,sBAAsB,WAAyB,QAAQ,GAAuB;CAE5F,OADgB,UAAU,KAAK,QAAQ,QAAQ,IAAI,SAAS,aAC9C,CAAC,QAAQ;;AAGzB,SAAgB,yBAAyB,OAAmC;CAE1E,MAAM,QADU,MAAM,MACD,CAAC,MAAM,iBAAiB;CAC7C,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,OAAO,MAAM,MAAM"}
@@ -1,5 +1,4 @@
1
1
  import { ifDefined } from "@prisma-next/utils/defined";
2
-
3
2
  //#region src/parser.ts
4
3
  const SCALAR_TYPES = new Set([
5
4
  "String",
@@ -203,7 +202,7 @@ function parseEnumBlock(context, name, bounds) {
203
202
  if (attribute) attributes.push(attribute);
204
203
  continue;
205
204
  }
206
- const valueMatch = line.match(/^([A-Za-z_]\w*)$/);
205
+ const valueMatch = line.match(/^([A-Za-z_]\w*)(?:\s+@map\(\s*"((?:[^"\\]|\\.)*)"\s*\))?$/);
207
206
  if (!valueMatch) {
208
207
  pushDiagnostic(context, {
209
208
  code: "PSL_INVALID_ENUM_MEMBER",
@@ -212,9 +211,11 @@ function parseEnumBlock(context, name, bounds) {
212
211
  });
213
212
  continue;
214
213
  }
214
+ const mapName = valueMatch[2] !== void 0 ? unescapePslString(valueMatch[2]) : void 0;
215
215
  values.push({
216
216
  kind: "enumValue",
217
217
  name: valueMatch[1] ?? "",
218
+ ...mapName !== void 0 ? { mapName } : {},
218
219
  span: createTrimmedLineSpan(context, lineIndex)
219
220
  });
220
221
  }
@@ -226,6 +227,32 @@ function parseEnumBlock(context, name, bounds) {
226
227
  span: createLineRangeSpan(context, bounds.startLine, bounds.endLine)
227
228
  };
228
229
  }
230
+ /**
231
+ * Decode PSL escape sequences (`\\`, `\"`, `\'`, `\n`, `\r`) inside a
232
+ * quoted-literal body. The argument is the body of the literal with the
233
+ * surrounding quotes already stripped by the caller. Mirrors the inverse
234
+ * helper in `@prisma-next/psl-printer`'s `escapePslString` so a string
235
+ * round-trips parser → printer → parser unchanged.
236
+ */
237
+ function unescapePslString(value) {
238
+ let result = "";
239
+ for (let i = 0; i < value.length; i++) {
240
+ if (value.charCodeAt(i) !== 92 || i + 1 >= value.length) {
241
+ result += value[i];
242
+ continue;
243
+ }
244
+ const next = value[i + 1];
245
+ if (next === "\\" || next === "\"" || next === "'") result += next;
246
+ else if (next === "n") result += "\n";
247
+ else if (next === "r") result += "\r";
248
+ else {
249
+ result += "\\";
250
+ result += next;
251
+ }
252
+ i++;
253
+ }
254
+ return result;
255
+ }
229
256
  function parseTypesBlock(context, bounds) {
230
257
  const declarations = [];
231
258
  for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {
@@ -898,7 +925,7 @@ function pushDiagnostic(context, diagnostic) {
898
925
  sourceId: context.sourceId
899
926
  });
900
927
  }
901
-
902
928
  //#endregion
903
929
  export { parsePslDocument as t };
904
- //# sourceMappingURL=parser-Cr64fw1E.mjs.map
930
+
931
+ //# sourceMappingURL=parser-1DZHweIq.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser-1DZHweIq.mjs","names":[],"sources":["../src/parser.ts"],"sourcesContent":["import 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 '@prisma-next/framework-components/psl-ast';\nimport { ifDefined } from '@prisma-next/utils/defined';\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 // An enum member line is the bare member identifier, optionally followed\n // by a `@map(\"storage-label\")` attribute. The map attribute lets the\n // printer round-trip enum values whose original storage label is not a\n // valid PSL identifier (e.g. PostgreSQL enum labels with hyphens).\n const valueMatch = line.match(/^([A-Za-z_]\\w*)(?:\\s+@map\\(\\s*\"((?:[^\"\\\\]|\\\\.)*)\"\\s*\\))?$/);\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 const mapName = valueMatch[2] !== undefined ? unescapePslString(valueMatch[2]) : undefined;\n\n values.push({\n kind: 'enumValue',\n name: valueMatch[1] ?? '',\n ...(mapName !== undefined ? { mapName } : {}),\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\n/**\n * Decode PSL escape sequences (`\\\\`, `\\\"`, `\\'`, `\\n`, `\\r`) inside a\n * quoted-literal body. The argument is the body of the literal with the\n * surrounding quotes already stripped by the caller. Mirrors the inverse\n * helper in `@prisma-next/psl-printer`'s `escapePslString` so a string\n * round-trips parser → printer → parser unchanged.\n */\nfunction unescapePslString(value: string): string {\n let result = '';\n for (let i = 0; i < value.length; i++) {\n const ch = value.charCodeAt(i);\n if (ch !== 0x5c /* '\\\\' */ || i + 1 >= value.length) {\n result += value[i];\n continue;\n }\n const next = value[i + 1];\n if (next === '\\\\' || next === '\"' || next === \"'\") {\n result += next;\n } else if (next === 'n') {\n result += '\\n';\n } else if (next === 'r') {\n result += '\\r';\n } else {\n result += '\\\\';\n result += next;\n }\n i++;\n }\n return result;\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,MAAM,cAA+B,EAAE;CACvC,MAAM,UAAyB;EAC7B,QAAQ;EACR,UAAU,MAAM;EAChB;EACA;EACA;EACD;CAED,MAAM,SAAqB,EAAE;CAC7B,MAAM,QAAmB,EAAE;CAC3B,MAAM,iBAAqC,EAAE;CAC7C,IAAI;CAEJ,IAAI,YAAY;CAChB,OAAO,YAAY,MAAM,QAAQ;EAE/B,MAAM,OAAO,mBADG,MAAM,cAAc,GACI,CAAC,MAAM;EAC/C,IAAI,KAAK,WAAW,GAAG;GACrB,aAAa;GACb;;EAGF,MAAM,aAAa,KAAK,MAAM,gCAAgC;EAC9D,IAAI,YAAY;GACd,MAAM,SAAS,gBAAgB,SAAS,UAAU;GAClD,MAAM,OAAO,WAAW,MAAM;GAC9B,IAAI,KAAK,WAAW,GAAG;IACrB,YAAY,OAAO,UAAU;IAC7B;;GAEF,OAAO,KAAK,gBAAgB,SAAS,MAAM,OAAO,CAAC;GACnD,YAAY,OAAO,UAAU;GAC7B;;EA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AGH,SAAS,eACP,SACA,YACM;CACN,QAAQ,YAAY,KAAK;EACvB,GAAG;EACH,UAAU,QAAQ;EACnB,CAAC"}
@@ -1,7 +1,7 @@
1
- import { n as ParsePslDocumentResult, t as ParsePslDocumentInput } from "./types-CYb3hCxS.mjs";
1
+ import { ParsePslDocumentInput, ParsePslDocumentResult } from "@prisma-next/framework-components/psl-ast";
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-B_U8b1dE.d.mts.map
7
+ //# sourceMappingURL=parser-Bjdnhl7C.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser-Bjdnhl7C.d.mts","names":[],"sources":["../src/parser.ts"],"mappings":";;;iBAkDgB,gBAAA,CAAiB,KAAA,EAAO,qBAAA,GAAwB,sBAAA"}
package/dist/parser.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { t as parsePslDocument } from "./parser-B_U8b1dE.mjs";
1
+ import { t as parsePslDocument } from "./parser-Bjdnhl7C.mjs";
2
2
  export { parsePslDocument };
package/dist/parser.mjs CHANGED
@@ -1,3 +1,2 @@
1
- import { t as parsePslDocument } from "./parser-Cr64fw1E.mjs";
2
-
3
- export { parsePslDocument };
1
+ import { t as parsePslDocument } from "./parser-1DZHweIq.mjs";
2
+ export { parsePslDocument };
@@ -1 +1 @@
1
- {"version":3,"file":"tokenizer.d.mts","names":[],"sources":["../src/tokenizer.ts"],"sourcesContent":[],"mappings":";KAAY,SAAA;AAAA,UAuBK,KAAA,CAvBI;EAuBJ,SAAK,IAAA,EACL,SAAA;EAIJ,SAAA,IAAS,EAAA,MAAA;;cAAT,SAAA;;;UAWH;yBAQU"}
1
+ {"version":3,"file":"tokenizer.d.mts","names":[],"sources":["../src/tokenizer.ts"],"mappings":";KAAY,SAAA;AAAA,UAuBK,KAAA;EAAA,SACN,IAAA,EAAM,SAAA;EAAA,SACN,IAAA;AAAA;AAAA,cAGE,SAAA;EAAA;cAKC,MAAA;EAMZ,IAAA,CAAA,GAAQ,KAAA;EAQR,IAAA,CAAK,MAAA,YAAa,KAAA;AAAA"}
@@ -21,9 +21,9 @@ var Tokenizer = class {
21
21
  const token = this.#buffer[offset];
22
22
  if (token) return token;
23
23
  while (this.#buffer.length <= offset) {
24
- const token$1 = this.#scanNext();
25
- if (token$1.kind === "Eof") return token$1;
26
- this.#buffer.push(token$1);
24
+ const token = this.#scanNext();
25
+ if (token.kind === "Eof") return token;
26
+ this.#buffer.push(token);
27
27
  }
28
28
  return this.#buffer[offset];
29
29
  }
@@ -185,7 +185,7 @@ const PUNCTUATION = {
185
185
  ",": "Comma",
186
186
  ":": "Colon"
187
187
  };
188
-
189
188
  //#endregion
190
189
  export { Tokenizer };
190
+
191
191
  //# sourceMappingURL=tokenizer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tokenizer.mjs","names":["#source","#buffer","#pos","#scanNext","token","PUNCTUATION: Record<string, TokenKind>"],"sources":["../src/tokenizer.ts"],"sourcesContent":["export type TokenKind =\n | 'Ident'\n | 'StringLiteral'\n | 'NumberLiteral'\n | 'At'\n | 'DoubleAt'\n | 'LBrace'\n | 'RBrace'\n | 'LParen'\n | 'RParen'\n | 'LBracket'\n | 'RBracket'\n | 'Equals'\n | 'Question'\n | 'Dot'\n | 'Comma'\n | 'Colon'\n | 'Whitespace'\n | 'Newline'\n | 'Comment'\n | 'Invalid'\n | 'Eof';\n\nexport interface Token {\n readonly kind: TokenKind;\n readonly text: string;\n}\n\nexport class Tokenizer {\n readonly #source: string;\n #pos: number;\n readonly #buffer: Token[];\n\n constructor(source: string) {\n this.#source = source;\n this.#pos = 0;\n this.#buffer = [];\n }\n\n next(): Token {\n const next = this.#buffer.shift();\n if (next) {\n return next;\n }\n return this.#scanNext();\n }\n\n peek(offset = 0): Token {\n if (offset > this.#buffer.length) {\n const last = this.#buffer.at(-1);\n if (last?.kind === 'Eof') {\n return last;\n }\n }\n\n const token = this.#buffer[offset];\n if (token) {\n return token;\n }\n\n while (this.#buffer.length <= offset) {\n const token = this.#scanNext();\n if (token.kind === 'Eof') {\n return token;\n }\n this.#buffer.push(token);\n }\n\n return this.#buffer[offset] as Token;\n }\n\n #scanNext(): Token {\n const token = scan(this.#source, this.#pos);\n this.#pos += token.text.length;\n return token;\n }\n}\n\nfunction scan(source: string, pos: number): Token {\n if (pos >= source.length) {\n return { kind: 'Eof', text: '' };\n }\n\n return (\n scanNewline(source, pos) ??\n scanWhitespace(source, pos) ??\n scanComment(source, pos) ??\n scanAt(source, pos) ??\n scanIdent(source, pos) ??\n scanNumber(source, pos) ??\n scanString(source, pos) ??\n scanPunctuation(source, pos) ?? {\n kind: 'Invalid' as const,\n text: readChar(source, pos),\n }\n );\n}\n\nfunction scanNewline(source: string, pos: number): Token | undefined {\n const ch = source.charAt(pos);\n if (ch !== '\\r' && ch !== '\\n') return undefined;\n if (ch === '\\r' && source.charAt(pos + 1) === '\\n') {\n return { kind: 'Newline', text: '\\r\\n' };\n }\n return { kind: 'Newline', text: ch };\n}\n\nfunction scanWhitespace(source: string, pos: number): Token | undefined {\n const ch = source.charAt(pos);\n if (ch !== ' ' && ch !== '\\t') return undefined;\n let end = pos + 1;\n while (end < source.length) {\n const c = source.charAt(end);\n if (c !== ' ' && c !== '\\t') break;\n end++;\n }\n return { kind: 'Whitespace', text: source.slice(pos, end) };\n}\n\nfunction scanComment(source: string, pos: number): Token | undefined {\n if (source.charAt(pos) !== '/' || source.charAt(pos + 1) !== '/') return undefined;\n let end = pos + 2;\n while (end < source.length) {\n const c = source.charAt(end);\n if (c === '\\n' || c === '\\r') break;\n end++;\n }\n return { kind: 'Comment', text: source.slice(pos, end) };\n}\n\nfunction scanAt(source: string, pos: number): Token | undefined {\n if (source.charAt(pos) !== '@') return undefined;\n if (source.charAt(pos + 1) === '@') {\n return { kind: 'DoubleAt', text: '@@' };\n }\n return { kind: 'At', text: '@' };\n}\n\nfunction scanIdent(source: string, pos: number): Token | undefined {\n const ch = readChar(source, pos);\n if (!isIdentStart(ch)) return undefined;\n let end = pos + ch.length;\n while (end < source.length) {\n const c = readChar(source, end);\n if (isIdentPart(c)) {\n end += c.length;\n } else {\n break;\n }\n }\n return { kind: 'Ident', text: source.slice(pos, end) };\n}\n\nfunction scanNumber(source: string, pos: number): Token | undefined {\n let end = pos;\n if (source.charAt(end) === '-') {\n if (end + 1 >= source.length || !isDigit(source.charAt(end + 1))) return undefined;\n end++;\n } else if (!isDigit(source.charAt(end))) {\n return undefined;\n }\n end++;\n while (end < source.length && isDigit(source.charAt(end))) {\n end++;\n }\n if (source.charAt(end) === '.' && end + 1 < source.length && isDigit(source.charAt(end + 1))) {\n end++; // consume the dot\n while (end < source.length && isDigit(source.charAt(end))) {\n end++;\n }\n }\n return { kind: 'NumberLiteral', text: source.slice(pos, end) };\n}\n\nfunction scanString(source: string, pos: number): Token | undefined {\n if (source.charAt(pos) !== '\"') return undefined;\n let end = pos + 1;\n while (end < source.length) {\n const c = source.charAt(end);\n if (c === '\\\\' && end + 1 < source.length) {\n end += 2; // skip escape sequence\n continue;\n }\n if (c === '\"') {\n end++; // include closing quote\n return { kind: 'StringLiteral', text: source.slice(pos, end) };\n }\n if (c === '\\n' || c === '\\r') {\n // Unterminated: stop before newline\n return { kind: 'StringLiteral', text: source.slice(pos, end) };\n }\n end++;\n }\n // Unterminated at EOF\n return { kind: 'StringLiteral', text: source.slice(pos, end) };\n}\n\nfunction scanPunctuation(source: string, pos: number): Token | undefined {\n const kind = PUNCTUATION[source.charAt(pos)];\n if (kind === undefined) return undefined;\n return { kind, text: source.charAt(pos) };\n}\n\nfunction readChar(source: string, pos: number): string {\n const cp = source.codePointAt(pos);\n return cp !== undefined ? String.fromCodePoint(cp) : '';\n}\n\nfunction isIdentStart(ch: string): boolean {\n return /\\p{L}/u.test(ch) || ch === '_';\n}\n\nfunction isIdentPart(ch: string): boolean {\n return isIdentStart(ch) || isDigit(ch) || ch === '-';\n}\n\nfunction isDigit(ch: string): boolean {\n return ch >= '0' && ch <= '9';\n}\n\nconst PUNCTUATION: Record<string, TokenKind> = {\n '{': 'LBrace',\n '}': 'RBrace',\n '(': 'LParen',\n ')': 'RParen',\n '[': 'LBracket',\n ']': 'RBracket',\n '=': 'Equals',\n '?': 'Question',\n '.': 'Dot',\n ',': 'Comma',\n ':': 'Colon',\n};\n"],"mappings":";AA4BA,IAAa,YAAb,MAAuB;CACrB,CAASA;CACT;CACA,CAASC;CAET,YAAY,QAAgB;AAC1B,QAAKD,SAAU;AACf,QAAKE,MAAO;AACZ,QAAKD,SAAU,EAAE;;CAGnB,OAAc;EACZ,MAAM,OAAO,MAAKA,OAAQ,OAAO;AACjC,MAAI,KACF,QAAO;AAET,SAAO,MAAKE,UAAW;;CAGzB,KAAK,SAAS,GAAU;AACtB,MAAI,SAAS,MAAKF,OAAQ,QAAQ;GAChC,MAAM,OAAO,MAAKA,OAAQ,GAAG,GAAG;AAChC,OAAI,MAAM,SAAS,MACjB,QAAO;;EAIX,MAAM,QAAQ,MAAKA,OAAQ;AAC3B,MAAI,MACF,QAAO;AAGT,SAAO,MAAKA,OAAQ,UAAU,QAAQ;GACpC,MAAMG,UAAQ,MAAKD,UAAW;AAC9B,OAAIC,QAAM,SAAS,MACjB,QAAOA;AAET,SAAKH,OAAQ,KAAKG,QAAM;;AAG1B,SAAO,MAAKH,OAAQ;;CAGtB,YAAmB;EACjB,MAAM,QAAQ,KAAK,MAAKD,QAAS,MAAKE,IAAK;AAC3C,QAAKA,OAAQ,MAAM,KAAK;AACxB,SAAO;;;AAIX,SAAS,KAAK,QAAgB,KAAoB;AAChD,KAAI,OAAO,OAAO,OAChB,QAAO;EAAE,MAAM;EAAO,MAAM;EAAI;AAGlC,QACE,YAAY,QAAQ,IAAI,IACxB,eAAe,QAAQ,IAAI,IAC3B,YAAY,QAAQ,IAAI,IACxB,OAAO,QAAQ,IAAI,IACnB,UAAU,QAAQ,IAAI,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AAM,KAAK,IAAI;IAAE;;AAEhE,MAAI,MAAM,QAAQ,MAAM,KAEtB,QAAO;GAAE,MAAM;GAAiB,MAAM,OAAO,MAAM,KAAK,IAAI;GAAE;AAEhE;;AAGF,QAAO;EAAE,MAAM;EAAiB,MAAM,OAAO,MAAM,KAAK,IAAI;EAAE;;AAGhE,SAAS,gBAAgB,QAAgB,KAAgC;CACvE,MAAM,OAAO,YAAY,OAAO,OAAO,IAAI;AAC3C,KAAI,SAAS,OAAW,QAAO;AAC/B,QAAO;EAAE;EAAM,MAAM,OAAO,OAAO,IAAI;EAAE;;AAG3C,SAAS,SAAS,QAAgB,KAAqB;CACrD,MAAM,KAAK,OAAO,YAAY,IAAI;AAClC,QAAO,OAAO,SAAY,OAAO,cAAc,GAAG,GAAG;;AAGvD,SAAS,aAAa,IAAqB;AACzC,QAAO,SAAS,KAAK,GAAG,IAAI,OAAO;;AAGrC,SAAS,YAAY,IAAqB;AACxC,QAAO,aAAa,GAAG,IAAI,QAAQ,GAAG,IAAI,OAAO;;AAGnD,SAAS,QAAQ,IAAqB;AACpC,QAAO,MAAM,OAAO,MAAM;;AAG5B,MAAMG,cAAyC;CAC7C,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACN"}
1
+ {"version":3,"file":"tokenizer.mjs","names":["#source","#buffer","#pos","#scanNext"],"sources":["../src/tokenizer.ts"],"sourcesContent":["export type TokenKind =\n | 'Ident'\n | 'StringLiteral'\n | 'NumberLiteral'\n | 'At'\n | 'DoubleAt'\n | 'LBrace'\n | 'RBrace'\n | 'LParen'\n | 'RParen'\n | 'LBracket'\n | 'RBracket'\n | 'Equals'\n | 'Question'\n | 'Dot'\n | 'Comma'\n | 'Colon'\n | 'Whitespace'\n | 'Newline'\n | 'Comment'\n | 'Invalid'\n | 'Eof';\n\nexport interface Token {\n readonly kind: TokenKind;\n readonly text: string;\n}\n\nexport class Tokenizer {\n readonly #source: string;\n #pos: number;\n readonly #buffer: Token[];\n\n constructor(source: string) {\n this.#source = source;\n this.#pos = 0;\n this.#buffer = [];\n }\n\n next(): Token {\n const next = this.#buffer.shift();\n if (next) {\n return next;\n }\n return this.#scanNext();\n }\n\n peek(offset = 0): Token {\n if (offset > this.#buffer.length) {\n const last = this.#buffer.at(-1);\n if (last?.kind === 'Eof') {\n return last;\n }\n }\n\n const token = this.#buffer[offset];\n if (token) {\n return token;\n }\n\n while (this.#buffer.length <= offset) {\n const token = this.#scanNext();\n if (token.kind === 'Eof') {\n return token;\n }\n this.#buffer.push(token);\n }\n\n return this.#buffer[offset] as Token;\n }\n\n #scanNext(): Token {\n const token = scan(this.#source, this.#pos);\n this.#pos += token.text.length;\n return token;\n }\n}\n\nfunction scan(source: string, pos: number): Token {\n if (pos >= source.length) {\n return { kind: 'Eof', text: '' };\n }\n\n return (\n scanNewline(source, pos) ??\n scanWhitespace(source, pos) ??\n scanComment(source, pos) ??\n scanAt(source, pos) ??\n scanIdent(source, pos) ??\n scanNumber(source, pos) ??\n scanString(source, pos) ??\n scanPunctuation(source, pos) ?? {\n kind: 'Invalid' as const,\n text: readChar(source, pos),\n }\n );\n}\n\nfunction scanNewline(source: string, pos: number): Token | undefined {\n const ch = source.charAt(pos);\n if (ch !== '\\r' && ch !== '\\n') return undefined;\n if (ch === '\\r' && source.charAt(pos + 1) === '\\n') {\n return { kind: 'Newline', text: '\\r\\n' };\n }\n return { kind: 'Newline', text: ch };\n}\n\nfunction scanWhitespace(source: string, pos: number): Token | undefined {\n const ch = source.charAt(pos);\n if (ch !== ' ' && ch !== '\\t') return undefined;\n let end = pos + 1;\n while (end < source.length) {\n const c = source.charAt(end);\n if (c !== ' ' && c !== '\\t') break;\n end++;\n }\n return { kind: 'Whitespace', text: source.slice(pos, end) };\n}\n\nfunction scanComment(source: string, pos: number): Token | undefined {\n if (source.charAt(pos) !== '/' || source.charAt(pos + 1) !== '/') return undefined;\n let end = pos + 2;\n while (end < source.length) {\n const c = source.charAt(end);\n if (c === '\\n' || c === '\\r') break;\n end++;\n }\n return { kind: 'Comment', text: source.slice(pos, end) };\n}\n\nfunction scanAt(source: string, pos: number): Token | undefined {\n if (source.charAt(pos) !== '@') return undefined;\n if (source.charAt(pos + 1) === '@') {\n return { kind: 'DoubleAt', text: '@@' };\n }\n return { kind: 'At', text: '@' };\n}\n\nfunction scanIdent(source: string, pos: number): Token | undefined {\n const ch = readChar(source, pos);\n if (!isIdentStart(ch)) return undefined;\n let end = pos + ch.length;\n while (end < source.length) {\n const c = readChar(source, end);\n if (isIdentPart(c)) {\n end += c.length;\n } else {\n break;\n }\n }\n return { kind: 'Ident', text: source.slice(pos, end) };\n}\n\nfunction scanNumber(source: string, pos: number): Token | undefined {\n let end = pos;\n if (source.charAt(end) === '-') {\n if (end + 1 >= source.length || !isDigit(source.charAt(end + 1))) return undefined;\n end++;\n } else if (!isDigit(source.charAt(end))) {\n return undefined;\n }\n end++;\n while (end < source.length && isDigit(source.charAt(end))) {\n end++;\n }\n if (source.charAt(end) === '.' && end + 1 < source.length && isDigit(source.charAt(end + 1))) {\n end++; // consume the dot\n while (end < source.length && isDigit(source.charAt(end))) {\n end++;\n }\n }\n return { kind: 'NumberLiteral', text: source.slice(pos, end) };\n}\n\nfunction scanString(source: string, pos: number): Token | undefined {\n if (source.charAt(pos) !== '\"') return undefined;\n let end = pos + 1;\n while (end < source.length) {\n const c = source.charAt(end);\n if (c === '\\\\' && end + 1 < source.length) {\n end += 2; // skip escape sequence\n continue;\n }\n if (c === '\"') {\n end++; // include closing quote\n return { kind: 'StringLiteral', text: source.slice(pos, end) };\n }\n if (c === '\\n' || c === '\\r') {\n // Unterminated: stop before newline\n return { kind: 'StringLiteral', text: source.slice(pos, end) };\n }\n end++;\n }\n // Unterminated at EOF\n return { kind: 'StringLiteral', text: source.slice(pos, end) };\n}\n\nfunction scanPunctuation(source: string, pos: number): Token | undefined {\n const kind = PUNCTUATION[source.charAt(pos)];\n if (kind === undefined) return undefined;\n return { kind, text: source.charAt(pos) };\n}\n\nfunction readChar(source: string, pos: number): string {\n const cp = source.codePointAt(pos);\n return cp !== undefined ? String.fromCodePoint(cp) : '';\n}\n\nfunction isIdentStart(ch: string): boolean {\n return /\\p{L}/u.test(ch) || ch === '_';\n}\n\nfunction isIdentPart(ch: string): boolean {\n return isIdentStart(ch) || isDigit(ch) || ch === '-';\n}\n\nfunction isDigit(ch: string): boolean {\n return ch >= '0' && ch <= '9';\n}\n\nconst PUNCTUATION: Record<string, TokenKind> = {\n '{': 'LBrace',\n '}': 'RBrace',\n '(': 'LParen',\n ')': 'RParen',\n '[': 'LBracket',\n ']': 'RBracket',\n '=': 'Equals',\n '?': 'Question',\n '.': 'Dot',\n ',': 'Comma',\n ':': 'Colon',\n};\n"],"mappings":";AA4BA,IAAa,YAAb,MAAuB;CACrB;CACA;CACA;CAEA,YAAY,QAAgB;EAC1B,KAAKA,UAAU;EACf,KAAKE,OAAO;EACZ,KAAKD,UAAU,EAAE;;CAGnB,OAAc;EACZ,MAAM,OAAO,KAAKA,QAAQ,OAAO;EACjC,IAAI,MACF,OAAO;EAET,OAAO,KAAKE,WAAW;;CAGzB,KAAK,SAAS,GAAU;EACtB,IAAI,SAAS,KAAKF,QAAQ,QAAQ;GAChC,MAAM,OAAO,KAAKA,QAAQ,GAAG,GAAG;GAChC,IAAI,MAAM,SAAS,OACjB,OAAO;;EAIX,MAAM,QAAQ,KAAKA,QAAQ;EAC3B,IAAI,OACF,OAAO;EAGT,OAAO,KAAKA,QAAQ,UAAU,QAAQ;GACpC,MAAM,QAAQ,KAAKE,WAAW;GAC9B,IAAI,MAAM,SAAS,OACjB,OAAO;GAET,KAAKF,QAAQ,KAAK,MAAM;;EAG1B,OAAO,KAAKA,QAAQ;;CAGtB,YAAmB;EACjB,MAAM,QAAQ,KAAK,KAAKD,SAAS,KAAKE,KAAK;EAC3C,KAAKA,QAAQ,MAAM,KAAK;EACxB,OAAO;;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dev.9",
3
+ "version": "0.5.0",
4
+ "license": "Apache-2.0",
4
5
  "type": "module",
5
6
  "sideEffects": false,
6
7
  "description": "Reusable parser for Prisma Schema Language (PSL)",
7
8
  "dependencies": {
8
- "@prisma-next/utils": "0.5.0-dev.9"
9
+ "@prisma-next/framework-components": "0.5.0",
10
+ "@prisma-next/utils": "0.5.0"
9
11
  },
10
12
  "devDependencies": {
11
- "tsdown": "0.18.4",
13
+ "tsdown": "0.22.0",
12
14
  "typescript": "5.9.3",
13
- "vitest": "4.0.17",
15
+ "vitest": "4.1.5",
14
16
  "@prisma-next/tsconfig": "0.0.0",
15
17
  "@prisma-next/tsdown": "0.0.0"
16
18
  },
@@ -22,7 +24,6 @@
22
24
  ".": "./dist/index.mjs",
23
25
  "./parser": "./dist/parser.mjs",
24
26
  "./tokenizer": "./dist/tokenizer.mjs",
25
- "./types": "./dist/types.mjs",
26
27
  "./package.json": "./package.json"
27
28
  },
28
29
  "main": "./dist/index.mjs",
@@ -1,4 +1,4 @@
1
- import type { PslAttribute } from './types';
1
+ import type { PslAttribute } from '@prisma-next/framework-components/psl-ast';
2
2
 
3
3
  export function getPositionalArgument(attribute: PslAttribute, index = 0): string | undefined {
4
4
  const entries = attribute.args.filter((arg) => arg.kind === 'positional');
@@ -1,5 +1,3 @@
1
- export { getPositionalArgument, parseQuotedStringLiteral } from '../attribute-helpers';
2
- export { parsePslDocument } from '../parser';
3
1
  export type {
4
2
  ParsePslDocumentInput,
5
3
  ParsePslDocumentResult,
@@ -26,4 +24,6 @@ export type {
26
24
  PslSpan,
27
25
  PslTypeConstructorCall,
28
26
  PslTypesBlock,
29
- } from '../types';
27
+ } from '@prisma-next/framework-components/psl-ast';
28
+ export { getPositionalArgument, parseQuotedStringLiteral } from '../attribute-helpers';
29
+ export { parsePslDocument } from '../parser';
package/src/parser.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { ifDefined } from '@prisma-next/utils/defined';
2
1
  import type {
3
2
  ParsePslDocumentInput,
4
3
  ParsePslDocumentResult,
@@ -20,7 +19,8 @@ import type {
20
19
  PslSpan,
21
20
  PslTypeConstructorCall,
22
21
  PslTypesBlock,
23
- } from './types';
22
+ } from '@prisma-next/framework-components/psl-ast';
23
+ import { ifDefined } from '@prisma-next/utils/defined';
24
24
 
25
25
  const SCALAR_TYPES = new Set([
26
26
  'String',
@@ -312,7 +312,11 @@ function parseEnumBlock(context: ParserContext, name: string, bounds: BlockBound
312
312
  continue;
313
313
  }
314
314
 
315
- const valueMatch = line.match(/^([A-Za-z_]\w*)$/);
315
+ // An enum member line is the bare member identifier, optionally followed
316
+ // by a `@map("storage-label")` attribute. The map attribute lets the
317
+ // printer round-trip enum values whose original storage label is not a
318
+ // valid PSL identifier (e.g. PostgreSQL enum labels with hyphens).
319
+ const valueMatch = line.match(/^([A-Za-z_]\w*)(?:\s+@map\(\s*"((?:[^"\\]|\\.)*)"\s*\))?$/);
316
320
  if (!valueMatch) {
317
321
  pushDiagnostic(context, {
318
322
  code: 'PSL_INVALID_ENUM_MEMBER',
@@ -322,9 +326,12 @@ function parseEnumBlock(context: ParserContext, name: string, bounds: BlockBound
322
326
  continue;
323
327
  }
324
328
 
329
+ const mapName = valueMatch[2] !== undefined ? unescapePslString(valueMatch[2]) : undefined;
330
+
325
331
  values.push({
326
332
  kind: 'enumValue',
327
333
  name: valueMatch[1] ?? '',
334
+ ...(mapName !== undefined ? { mapName } : {}),
328
335
  span: createTrimmedLineSpan(context, lineIndex),
329
336
  });
330
337
  }
@@ -338,6 +345,37 @@ function parseEnumBlock(context: ParserContext, name: string, bounds: BlockBound
338
345
  };
339
346
  }
340
347
 
348
+ /**
349
+ * Decode PSL escape sequences (`\\`, `\"`, `\'`, `\n`, `\r`) inside a
350
+ * quoted-literal body. The argument is the body of the literal with the
351
+ * surrounding quotes already stripped by the caller. Mirrors the inverse
352
+ * helper in `@prisma-next/psl-printer`'s `escapePslString` so a string
353
+ * round-trips parser → printer → parser unchanged.
354
+ */
355
+ function unescapePslString(value: string): string {
356
+ let result = '';
357
+ for (let i = 0; i < value.length; i++) {
358
+ const ch = value.charCodeAt(i);
359
+ if (ch !== 0x5c /* '\\' */ || i + 1 >= value.length) {
360
+ result += value[i];
361
+ continue;
362
+ }
363
+ const next = value[i + 1];
364
+ if (next === '\\' || next === '"' || next === "'") {
365
+ result += next;
366
+ } else if (next === 'n') {
367
+ result += '\n';
368
+ } else if (next === 'r') {
369
+ result += '\r';
370
+ } else {
371
+ result += '\\';
372
+ result += next;
373
+ }
374
+ i++;
375
+ }
376
+ return result;
377
+ }
378
+
341
379
  function parseTypesBlock(context: ParserContext, bounds: BlockBounds): PslTypesBlock {
342
380
  const declarations: PslNamedTypeDeclaration[] = [];
343
381
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser-B_U8b1dE.d.mts","names":[],"sources":["../src/parser.ts"],"sourcesContent":[],"mappings":";;;iBAkDgB,gBAAA,QAAwB,wBAAwB"}
@@ -1 +0,0 @@
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.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c,QAAQ,MAAM,YAAY;AAE9C,QAAO;EACL,OAAO,eAAe,SAAS,WAFb,yBAAyB,cAAc,CAEH;EACtD,KAAK,eAAe,SAAS,SAAS,YAAY,OAAO;EAC1D;;AAGH,SAAS,eACP,SACA,WACA,aACa;CACb,MAAM,mBAAmB,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,QAAQ,YAAY,SAAS,EAAE,CAAC;CACzF,MAAM,WAAW,QAAQ,MAAM,qBAAqB;CACpD,MAAM,qBAAqB,KAAK,IAAI,GAAG,KAAK,IAAI,aAAa,SAAS,OAAO,CAAC;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"}
@@ -1,141 +0,0 @@
1
- //#region src/types.d.ts
2
- interface PslPosition {
3
- readonly offset: number;
4
- readonly line: number;
5
- readonly column: number;
6
- }
7
- interface PslSpan {
8
- readonly start: PslPosition;
9
- readonly end: PslPosition;
10
- }
11
- type PslDiagnosticCode = 'PSL_UNTERMINATED_BLOCK' | 'PSL_UNSUPPORTED_TOP_LEVEL_BLOCK' | 'PSL_INVALID_ATTRIBUTE_SYNTAX' | 'PSL_INVALID_MODEL_MEMBER' | 'PSL_UNSUPPORTED_MODEL_ATTRIBUTE' | 'PSL_UNSUPPORTED_FIELD_ATTRIBUTE' | 'PSL_INVALID_RELATION_ATTRIBUTE' | 'PSL_INVALID_REFERENTIAL_ACTION' | 'PSL_INVALID_DEFAULT_VALUE' | 'PSL_INVALID_ENUM_MEMBER' | 'PSL_INVALID_TYPES_MEMBER';
12
- interface PslDiagnostic {
13
- readonly code: PslDiagnosticCode;
14
- readonly message: string;
15
- readonly sourceId: string;
16
- readonly span: PslSpan;
17
- }
18
- interface PslDefaultFunctionValue {
19
- readonly kind: 'function';
20
- readonly name: 'autoincrement' | 'now';
21
- }
22
- interface PslDefaultLiteralValue {
23
- readonly kind: 'literal';
24
- readonly value: string | number | boolean;
25
- }
26
- type PslDefaultValue = PslDefaultFunctionValue | PslDefaultLiteralValue;
27
- type PslAttributeTarget = 'field' | 'model' | 'enum' | 'namedType';
28
- interface PslAttributePositionalArgument {
29
- readonly kind: 'positional';
30
- readonly value: string;
31
- readonly span: PslSpan;
32
- }
33
- interface PslAttributeNamedArgument {
34
- readonly kind: 'named';
35
- readonly name: string;
36
- readonly value: string;
37
- readonly span: PslSpan;
38
- }
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
- }
46
- interface PslAttribute {
47
- readonly kind: 'attribute';
48
- readonly target: PslAttributeTarget;
49
- readonly name: string;
50
- readonly args: readonly PslAttributeArgument[];
51
- readonly span: PslSpan;
52
- }
53
- type PslReferentialAction = string;
54
- type PslFieldAttribute = PslAttribute;
55
- interface PslField {
56
- readonly kind: 'field';
57
- readonly name: string;
58
- readonly typeName: string;
59
- readonly typeConstructor?: PslTypeConstructorCall;
60
- readonly optional: boolean;
61
- readonly list: boolean;
62
- readonly typeRef?: string;
63
- readonly attributes: readonly PslFieldAttribute[];
64
- readonly span: PslSpan;
65
- }
66
- interface PslUniqueConstraint {
67
- readonly kind: 'unique';
68
- readonly fields: readonly string[];
69
- readonly span: PslSpan;
70
- }
71
- interface PslIndexConstraint {
72
- readonly kind: 'index';
73
- readonly fields: readonly string[];
74
- readonly span: PslSpan;
75
- }
76
- type PslModelAttribute = PslAttribute;
77
- interface PslModel {
78
- readonly kind: 'model';
79
- readonly name: string;
80
- readonly fields: readonly PslField[];
81
- readonly attributes: readonly PslModelAttribute[];
82
- readonly span: PslSpan;
83
- }
84
- interface PslEnumValue {
85
- readonly kind: 'enumValue';
86
- readonly name: string;
87
- readonly span: PslSpan;
88
- }
89
- interface PslEnum {
90
- readonly kind: 'enum';
91
- readonly name: string;
92
- readonly values: readonly PslEnumValue[];
93
- readonly attributes: readonly PslAttribute[];
94
- readonly span: PslSpan;
95
- }
96
- interface PslCompositeType {
97
- readonly kind: 'compositeType';
98
- readonly name: string;
99
- readonly fields: readonly PslField[];
100
- readonly attributes: readonly PslAttribute[];
101
- readonly span: PslSpan;
102
- }
103
- interface PslNamedTypeDeclaration {
104
- readonly kind: 'namedType';
105
- readonly name: 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;
113
- readonly attributes: readonly PslAttribute[];
114
- readonly span: PslSpan;
115
- }
116
- interface PslTypesBlock {
117
- readonly kind: 'types';
118
- readonly declarations: readonly PslNamedTypeDeclaration[];
119
- readonly span: PslSpan;
120
- }
121
- interface PslDocumentAst {
122
- readonly kind: 'document';
123
- readonly sourceId: string;
124
- readonly models: readonly PslModel[];
125
- readonly enums: readonly PslEnum[];
126
- readonly compositeTypes: readonly PslCompositeType[];
127
- readonly types?: PslTypesBlock;
128
- readonly span: PslSpan;
129
- }
130
- interface ParsePslDocumentInput {
131
- readonly schema: string;
132
- readonly sourceId: string;
133
- }
134
- interface ParsePslDocumentResult {
135
- readonly ast: PslDocumentAst;
136
- readonly diagnostics: readonly PslDiagnostic[];
137
- readonly ok: boolean;
138
- }
139
- //#endregion
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
@@ -1 +0,0 @@
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;AAOiB,UAzBA,OAAA,CAyBA;EAKA,SAAA,KAAA,EA7BC,WA6BqB;EAK3B,SAAA,GAAA,EAjCI,WAiCW;AAE3B;AAEiB,KAlCL,iBAAA,GAkCK,wBAGA,GAAO,iCAAA,GAAA,8BAAA,GAAA,0BAAA,GAAA,iCAAA,GAAA,iCAAA,GAAA,gCAAA,GAAA,gCAAA,GAAA,2BAAA,GAAA,yBAAA,GAAA,0BAAA;AAGP,UA3BA,aAAA,CA2BA;EAOL,SAAA,IAAA,EAjCK,iBAiCe;EAEf,SAAA,OAAA,EAAA,MAAA;EAOA,SAAA,QAAY,EAAA,MAAA;EAEV,SAAA,IAAA,EAzCF,OAyCE;;AAGF,UAzCA,uBAAA,CAyCA;EAAO,SAAA,IAAA,EAAA,UAAA;EAGZ,SAAA,IAAA,EAAA,eAAoB,GAAA,KAAA;AAEhC;AAEiB,UA3CA,sBAAA,CA2CQ;EAII,SAAA,IAAA,EAAA,SAAA;EAIG,SAAA,KAAA,EAAA,MAAA,GAAA,MAAA,GAAA,OAAA;;AACR,KA/CZ,eAAA,GAAkB,uBA+CN,GA/CgC,sBA+ChC;AAGP,KAhDL,kBAAA,GAgDwB,OAGnB,GAAA,OAAO,GAAA,MAAA,GAAA,WAAA;AAGP,UApDA,8BAAA,CAuDO;EAGZ,SAAA,IAAA,EAAA,YAAiB;EAEZ,S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ACjB;iBACF;;UAGA,qBAAA;;;;UAKA,sBAAA;gBACD;iCACiB"}
package/dist/types.d.mts DELETED
@@ -1,2 +0,0 @@
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
- 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 };
package/dist/types.mjs DELETED
@@ -1 +0,0 @@
1
- export { };
@@ -1,29 +0,0 @@
1
- export type {
2
- ParsePslDocumentInput,
3
- ParsePslDocumentResult,
4
- PslAttribute,
5
- PslAttributeArgument,
6
- PslAttributeNamedArgument,
7
- PslAttributePositionalArgument,
8
- PslAttributeTarget,
9
- PslCompositeType,
10
- PslDefaultFunctionValue,
11
- PslDefaultLiteralValue,
12
- PslDefaultValue,
13
- PslDiagnostic,
14
- PslDiagnosticCode,
15
- PslDocumentAst,
16
- PslEnum,
17
- PslEnumValue,
18
- PslField,
19
- PslFieldAttribute,
20
- PslIndexConstraint,
21
- PslModel,
22
- PslModelAttribute,
23
- PslNamedTypeDeclaration,
24
- PslPosition,
25
- PslReferentialAction,
26
- PslSpan,
27
- PslTypesBlock,
28
- PslUniqueConstraint,
29
- } from '../types';
package/src/types.ts DELETED
@@ -1,175 +0,0 @@
1
- export interface PslPosition {
2
- readonly offset: number;
3
- readonly line: number;
4
- readonly column: number;
5
- }
6
-
7
- export interface PslSpan {
8
- readonly start: PslPosition;
9
- readonly end: PslPosition;
10
- }
11
-
12
- export type PslDiagnosticCode =
13
- | 'PSL_UNTERMINATED_BLOCK'
14
- | 'PSL_UNSUPPORTED_TOP_LEVEL_BLOCK'
15
- | 'PSL_INVALID_ATTRIBUTE_SYNTAX'
16
- | 'PSL_INVALID_MODEL_MEMBER'
17
- | 'PSL_UNSUPPORTED_MODEL_ATTRIBUTE'
18
- | 'PSL_UNSUPPORTED_FIELD_ATTRIBUTE'
19
- | 'PSL_INVALID_RELATION_ATTRIBUTE'
20
- | 'PSL_INVALID_REFERENTIAL_ACTION'
21
- | 'PSL_INVALID_DEFAULT_VALUE'
22
- | 'PSL_INVALID_ENUM_MEMBER'
23
- | 'PSL_INVALID_TYPES_MEMBER';
24
-
25
- export interface PslDiagnostic {
26
- readonly code: PslDiagnosticCode;
27
- readonly message: string;
28
- readonly sourceId: string;
29
- readonly span: PslSpan;
30
- }
31
-
32
- export interface PslDefaultFunctionValue {
33
- readonly kind: 'function';
34
- readonly name: 'autoincrement' | 'now';
35
- }
36
-
37
- export interface PslDefaultLiteralValue {
38
- readonly kind: 'literal';
39
- readonly value: string | number | boolean;
40
- }
41
-
42
- export type PslDefaultValue = PslDefaultFunctionValue | PslDefaultLiteralValue;
43
-
44
- export type PslAttributeTarget = 'field' | 'model' | 'enum' | 'namedType';
45
-
46
- export interface PslAttributePositionalArgument {
47
- readonly kind: 'positional';
48
- readonly value: string;
49
- readonly span: PslSpan;
50
- }
51
-
52
- export interface PslAttributeNamedArgument {
53
- readonly kind: 'named';
54
- readonly name: string;
55
- readonly value: string;
56
- readonly span: PslSpan;
57
- }
58
-
59
- export type PslAttributeArgument = PslAttributePositionalArgument | PslAttributeNamedArgument;
60
-
61
- export interface PslTypeConstructorCall {
62
- readonly kind: 'typeConstructor';
63
- readonly path: readonly string[];
64
- readonly args: readonly PslAttributeArgument[];
65
- readonly span: PslSpan;
66
- }
67
-
68
- export interface PslAttribute {
69
- readonly kind: 'attribute';
70
- readonly target: PslAttributeTarget;
71
- readonly name: string;
72
- readonly args: readonly PslAttributeArgument[];
73
- readonly span: PslSpan;
74
- }
75
-
76
- export type PslReferentialAction = string;
77
-
78
- export type PslFieldAttribute = PslAttribute;
79
-
80
- export interface PslField {
81
- readonly kind: 'field';
82
- readonly name: string;
83
- readonly typeName: string;
84
- readonly typeConstructor?: PslTypeConstructorCall;
85
- readonly optional: boolean;
86
- readonly list: boolean;
87
- readonly typeRef?: string;
88
- readonly attributes: readonly PslFieldAttribute[];
89
- readonly span: PslSpan;
90
- }
91
-
92
- export interface PslUniqueConstraint {
93
- readonly kind: 'unique';
94
- readonly fields: readonly string[];
95
- readonly span: PslSpan;
96
- }
97
-
98
- export interface PslIndexConstraint {
99
- readonly kind: 'index';
100
- readonly fields: readonly string[];
101
- readonly span: PslSpan;
102
- }
103
-
104
- export type PslModelAttribute = PslAttribute;
105
-
106
- export interface PslModel {
107
- readonly kind: 'model';
108
- readonly name: string;
109
- readonly fields: readonly PslField[];
110
- readonly attributes: readonly PslModelAttribute[];
111
- readonly span: PslSpan;
112
- }
113
-
114
- export interface PslEnumValue {
115
- readonly kind: 'enumValue';
116
- readonly name: string;
117
- readonly span: PslSpan;
118
- }
119
-
120
- export interface PslEnum {
121
- readonly kind: 'enum';
122
- readonly name: string;
123
- readonly values: readonly PslEnumValue[];
124
- readonly attributes: readonly PslAttribute[];
125
- readonly span: PslSpan;
126
- }
127
-
128
- export interface PslCompositeType {
129
- readonly kind: 'compositeType';
130
- readonly name: string;
131
- readonly fields: readonly PslField[];
132
- readonly attributes: readonly PslAttribute[];
133
- readonly span: PslSpan;
134
- }
135
-
136
- export interface PslNamedTypeDeclaration {
137
- readonly kind: 'namedType';
138
- readonly name: string;
139
- /**
140
- * Parser invariant: exactly one of `baseType` and `typeConstructor` is set.
141
- * Expressing this as a discriminated union trips TypeScript narrowing when
142
- * the declaration flows through helpers that accept the full union.
143
- */
144
- readonly baseType?: string;
145
- readonly typeConstructor?: PslTypeConstructorCall;
146
- readonly attributes: readonly PslAttribute[];
147
- readonly span: PslSpan;
148
- }
149
-
150
- export interface PslTypesBlock {
151
- readonly kind: 'types';
152
- readonly declarations: readonly PslNamedTypeDeclaration[];
153
- readonly span: PslSpan;
154
- }
155
-
156
- export interface PslDocumentAst {
157
- readonly kind: 'document';
158
- readonly sourceId: string;
159
- readonly models: readonly PslModel[];
160
- readonly enums: readonly PslEnum[];
161
- readonly compositeTypes: readonly PslCompositeType[];
162
- readonly types?: PslTypesBlock;
163
- readonly span: PslSpan;
164
- }
165
-
166
- export interface ParsePslDocumentInput {
167
- readonly schema: string;
168
- readonly sourceId: string;
169
- }
170
-
171
- export interface ParsePslDocumentResult {
172
- readonly ast: PslDocumentAst;
173
- readonly diagnostics: readonly PslDiagnostic[];
174
- readonly ok: boolean;
175
- }