@prisma-next/psl-parser 0.3.0-dev.145 → 0.3.0-dev.147
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +9 -3
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +14 -2
- package/dist/index.mjs.map +1 -0
- package/dist/{parser-C7qeAcwZ.d.mts → parser-D-_7FY6a.d.mts} +2 -2
- package/dist/parser-D-_7FY6a.d.mts.map +1 -0
- package/dist/{parser-ClclNzzu.mjs → parser-jCEw-qFr.mjs} +39 -2
- package/dist/parser-jCEw-qFr.mjs.map +1 -0
- package/dist/parser.d.mts +1 -1
- package/dist/parser.mjs +1 -1
- package/dist/{types-0aHhDCP4.d.mts → types-B5Y_8Gl4.d.mts} +10 -2
- package/dist/{types-0aHhDCP4.d.mts.map → types-B5Y_8Gl4.d.mts.map} +1 -1
- package/dist/types.d.mts +2 -2
- package/package.json +4 -4
- package/src/attribute-helpers.ts +13 -0
- package/src/exports/index.ts +2 -0
- package/src/exports/types.ts +1 -0
- package/src/parser.ts +56 -0
- package/src/types.ts +9 -0
- package/dist/parser-C7qeAcwZ.d.mts.map +0 -1
- package/dist/parser-ClclNzzu.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as parsePslDocument } from "./parser-
|
|
3
|
-
|
|
1
|
+
import { C as PslPosition, E as PslTypesBlock, S as PslNamedTypeDeclaration, T as PslSpan, _ as PslField, a as PslAttributeNamedArgument, b as PslModel, c as PslCompositeType, d as PslDefaultValue, f as PslDiagnostic, g as PslEnumValue, h as PslEnum, i as PslAttributeArgument, l as PslDefaultFunctionValue, m as PslDocumentAst, n as ParsePslDocumentResult, o as PslAttributePositionalArgument, p as PslDiagnosticCode, r as PslAttribute, s as PslAttributeTarget, t as ParsePslDocumentInput, u as PslDefaultLiteralValue, v as PslFieldAttribute, x as PslModelAttribute } from "./types-B5Y_8Gl4.mjs";
|
|
2
|
+
import { t as parsePslDocument } from "./parser-D-_7FY6a.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/attribute-helpers.d.ts
|
|
5
|
+
declare function getPositionalArgument(attribute: PslAttribute, index?: number): string | undefined;
|
|
6
|
+
declare function parseQuotedStringLiteral(value: string): string | undefined;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { type ParsePslDocumentInput, type ParsePslDocumentResult, type PslAttribute, type PslAttributeArgument, type PslAttributeNamedArgument, type PslAttributePositionalArgument, type PslAttributeTarget, type PslCompositeType, type PslDefaultFunctionValue, type PslDefaultLiteralValue, type PslDefaultValue, type PslDiagnostic, type PslDiagnosticCode, type PslDocumentAst, type PslEnum, type PslEnumValue, type PslField, type PslFieldAttribute, type PslModel, type PslModelAttribute, type PslNamedTypeDeclaration, type PslPosition, type PslSpan, type PslTypesBlock, getPositionalArgument, parsePslDocument, parseQuotedStringLiteral };
|
|
9
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/attribute-helpers.ts"],"sourcesContent":[],"mappings":";;;;iBAEgB,qBAAA,YAAiC;iBAKjC,wBAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import { t as parsePslDocument } from "./parser-
|
|
1
|
+
import { t as parsePslDocument } from "./parser-jCEw-qFr.mjs";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/attribute-helpers.ts
|
|
4
|
+
function getPositionalArgument(attribute, index = 0) {
|
|
5
|
+
return attribute.args.filter((arg) => arg.kind === "positional")[index]?.value;
|
|
6
|
+
}
|
|
7
|
+
function parseQuotedStringLiteral(value) {
|
|
8
|
+
const match = value.trim().match(/^(['"])(.*)\1$/);
|
|
9
|
+
if (!match) return void 0;
|
|
10
|
+
return match[2] ?? "";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getPositionalArgument, parsePslDocument, parseQuotedStringLiteral };
|
|
15
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +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,7 +1,7 @@
|
|
|
1
|
-
import { n as ParsePslDocumentResult, t as ParsePslDocumentInput } from "./types-
|
|
1
|
+
import { n as ParsePslDocumentResult, t as ParsePslDocumentInput } from "./types-B5Y_8Gl4.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/parser.d.ts
|
|
4
4
|
declare function parsePslDocument(input: ParsePslDocumentInput): ParsePslDocumentResult;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { parsePslDocument as t };
|
|
7
|
-
//# sourceMappingURL=parser-
|
|
7
|
+
//# sourceMappingURL=parser-D-_7FY6a.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser-D-_7FY6a.d.mts","names":[],"sources":["../src/parser.ts"],"sourcesContent":[],"mappings":";;;iBAiDgB,gBAAA,QAAwB,wBAAwB"}
|
|
@@ -26,6 +26,7 @@ function parsePslDocument(input) {
|
|
|
26
26
|
};
|
|
27
27
|
const models = [];
|
|
28
28
|
const enums = [];
|
|
29
|
+
const compositeTypes = [];
|
|
29
30
|
let typesBlock;
|
|
30
31
|
let lineIndex = 0;
|
|
31
32
|
while (lineIndex < lines.length) {
|
|
@@ -58,6 +59,18 @@ function parsePslDocument(input) {
|
|
|
58
59
|
lineIndex = bounds.endLine + 1;
|
|
59
60
|
continue;
|
|
60
61
|
}
|
|
62
|
+
const compositeTypeMatch = line.match(/^type\s+([A-Za-z_]\w*)\s*\{$/);
|
|
63
|
+
if (compositeTypeMatch) {
|
|
64
|
+
const bounds = findBlockBounds(context, lineIndex);
|
|
65
|
+
const name = compositeTypeMatch[1] ?? "";
|
|
66
|
+
if (name.length === 0) {
|
|
67
|
+
lineIndex = bounds.endLine + 1;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
compositeTypes.push(parseCompositeTypeBlock(context, name, bounds));
|
|
71
|
+
lineIndex = bounds.endLine + 1;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
61
74
|
if (/^types\s*\{$/.test(line)) {
|
|
62
75
|
const bounds = findBlockBounds(context, lineIndex);
|
|
63
76
|
typesBlock = parseTypesBlock(context, bounds);
|
|
@@ -83,6 +96,7 @@ function parsePslDocument(input) {
|
|
|
83
96
|
const namedTypeNames = new Set((typesBlock?.declarations ?? []).map((declaration) => declaration.name));
|
|
84
97
|
const modelNames = new Set(models.map((model) => model.name));
|
|
85
98
|
const enumNames = new Set(enums.map((enumBlock) => enumBlock.name));
|
|
99
|
+
const compositeTypeNames = new Set(compositeTypes.map((ct) => ct.name));
|
|
86
100
|
for (const declaration of typesBlock?.declarations ?? []) {
|
|
87
101
|
if (SCALAR_TYPES.has(declaration.name)) {
|
|
88
102
|
pushDiagnostic(context, {
|
|
@@ -110,7 +124,7 @@ function parsePslDocument(input) {
|
|
|
110
124
|
...model,
|
|
111
125
|
fields: model.fields.map((field) => {
|
|
112
126
|
if (!namedTypeNames.has(field.typeName)) return field;
|
|
113
|
-
if (field.attributes.some((attribute) => attribute.name === "relation") || modelNames.has(field.typeName) || enumNames.has(field.typeName) || SCALAR_TYPES.has(field.typeName)) return field;
|
|
127
|
+
if (field.attributes.some((attribute) => attribute.name === "relation") || modelNames.has(field.typeName) || enumNames.has(field.typeName) || compositeTypeNames.has(field.typeName) || SCALAR_TYPES.has(field.typeName)) return field;
|
|
114
128
|
return {
|
|
115
129
|
...field,
|
|
116
130
|
typeRef: field.typeName
|
|
@@ -123,6 +137,7 @@ function parsePslDocument(input) {
|
|
|
123
137
|
sourceId: input.sourceId,
|
|
124
138
|
models: normalizedModels,
|
|
125
139
|
enums,
|
|
140
|
+
compositeTypes,
|
|
126
141
|
...ifDefined("types", typesBlock),
|
|
127
142
|
span: {
|
|
128
143
|
start: createPosition(context, 0, 0),
|
|
@@ -155,6 +170,28 @@ function parseModelBlock(context, name, bounds) {
|
|
|
155
170
|
span: createLineRangeSpan(context, bounds.startLine, bounds.endLine)
|
|
156
171
|
};
|
|
157
172
|
}
|
|
173
|
+
function parseCompositeTypeBlock(context, name, bounds) {
|
|
174
|
+
const fields = [];
|
|
175
|
+
const attributes = [];
|
|
176
|
+
for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {
|
|
177
|
+
const line = stripInlineComment(context.lines[lineIndex] ?? "").trim();
|
|
178
|
+
if (line.length === 0) continue;
|
|
179
|
+
if (line.startsWith("@@")) {
|
|
180
|
+
const attribute = parseModelAttribute(context, line, lineIndex);
|
|
181
|
+
if (attribute) attributes.push(attribute);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const field = parseField(context, line, lineIndex);
|
|
185
|
+
if (field) fields.push(field);
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
kind: "compositeType",
|
|
189
|
+
name,
|
|
190
|
+
fields,
|
|
191
|
+
attributes,
|
|
192
|
+
span: createLineRangeSpan(context, bounds.startLine, bounds.endLine)
|
|
193
|
+
};
|
|
194
|
+
}
|
|
158
195
|
function parseEnumBlock(context, name, bounds) {
|
|
159
196
|
const values = [];
|
|
160
197
|
const attributes = [];
|
|
@@ -715,4 +752,4 @@ function pushDiagnostic(context, diagnostic) {
|
|
|
715
752
|
|
|
716
753
|
//#endregion
|
|
717
754
|
export { parsePslDocument as t };
|
|
718
|
-
//# sourceMappingURL=parser-
|
|
755
|
+
//# sourceMappingURL=parser-jCEw-qFr.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser-jCEw-qFr.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[]","args: readonly PslAttributeArgument[]","args: PslAttributeArgument[]","quote: '\"' | \"'\" | null","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 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*([A-Za-z_]\\w*)(.*)$/);\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 baseType = declarationMatch[2] ?? '';\n const attributePart = declarationMatch[3] ?? '';\n const trimmedStartColumn = firstNonWhitespaceColumn(raw);\n const attributeOffset = line.length - attributePart.length;\n const attributeSource = attributePart.trimStart();\n const leadingAttributeWhitespace = attributePart.length - attributeSource.length;\n const attributeParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n attributeSource,\n trimmedStartColumn + 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 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 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+([A-Za-z_]\\w*(?:\\[\\])?)(\\?)?(.*)$/);\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 rawTypeToken = fieldMatch[2] ?? '';\n const optionalMarker = fieldMatch[3] ?? '';\n const attributePart = fieldMatch[4] ?? '';\n const list = rawTypeToken.endsWith('[]');\n const typeName = list ? rawTypeToken.slice(0, -2) : rawTypeToken;\n const optional = optionalMarker === '?';\n\n const attributes: PslFieldAttribute[] = [];\n const rawLine = context.lines[lineIndex] ?? '';\n const trimmedStartColumn = firstNonWhitespaceColumn(rawLine);\n const attributeOffset = line.length - attributePart.length;\n const attributeSource = attributePart.trimStart();\n const leadingAttributeWhitespace = attributePart.length - attributeSource.length;\n const tokenParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n attributeSource,\n trimmedStartColumn + attributeOffset + leadingAttributeWhitespace,\n );\n if (!tokenParse.ok) {\n return {\n kind: 'field',\n name: fieldName,\n typeName,\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 optional,\n list,\n attributes,\n span: createTrimmedLineSpan(context, lineIndex),\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 = parseAttributeArguments(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 });\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 parseAttributeArguments(\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 },\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: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid empty argument in attribute \"${input.token}\"`,\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: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid named argument syntax \"${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: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid named argument syntax \"${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 let previousCharacter = '';\n for (const character of line) {\n if (quote) {\n if (character === quote && previousCharacter !== '\\\\') {\n quote = null;\n }\n previousCharacter = character;\n continue;\n }\n\n if (character === '\"' || character === \"'\") {\n quote = character;\n previousCharacter = 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 previousCharacter = character;\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 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 && value[index - 1] !== '\\\\') {\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\n if (character === separator && depthParen === 0 && depthBracket === 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 && value[index - 1] !== '\\\\') {\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 && line[index - 1] !== '\\\\') {\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":";;;AAuBA,MA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,oBAAoB,SAAwB,WAAmB,SAA0B;CAChG,MAAM,gBAAgB,QAAQ,MAAM,cAAc;CAClD,MAAM,cAAc,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"}
|
package/dist/parser.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as parsePslDocument } from "./parser-
|
|
1
|
+
import { t as parsePslDocument } from "./parser-D-_7FY6a.mjs";
|
|
2
2
|
export { parsePslDocument };
|
package/dist/parser.mjs
CHANGED
|
@@ -86,6 +86,13 @@ interface PslEnum {
|
|
|
86
86
|
readonly attributes: readonly PslAttribute[];
|
|
87
87
|
readonly span: PslSpan;
|
|
88
88
|
}
|
|
89
|
+
interface PslCompositeType {
|
|
90
|
+
readonly kind: 'compositeType';
|
|
91
|
+
readonly name: string;
|
|
92
|
+
readonly fields: readonly PslField[];
|
|
93
|
+
readonly attributes: readonly PslAttribute[];
|
|
94
|
+
readonly span: PslSpan;
|
|
95
|
+
}
|
|
89
96
|
interface PslNamedTypeDeclaration {
|
|
90
97
|
readonly kind: 'namedType';
|
|
91
98
|
readonly name: string;
|
|
@@ -103,6 +110,7 @@ interface PslDocumentAst {
|
|
|
103
110
|
readonly sourceId: string;
|
|
104
111
|
readonly models: readonly PslModel[];
|
|
105
112
|
readonly enums: readonly PslEnum[];
|
|
113
|
+
readonly compositeTypes: readonly PslCompositeType[];
|
|
106
114
|
readonly types?: PslTypesBlock;
|
|
107
115
|
readonly span: PslSpan;
|
|
108
116
|
}
|
|
@@ -116,5 +124,5 @@ interface ParsePslDocumentResult {
|
|
|
116
124
|
readonly ok: boolean;
|
|
117
125
|
}
|
|
118
126
|
//#endregion
|
|
119
|
-
export {
|
|
120
|
-
//# sourceMappingURL=types-
|
|
127
|
+
export { PslPosition as C, PslUniqueConstraint as D, PslTypesBlock as E, PslNamedTypeDeclaration as S, PslSpan as T, PslField as _, PslAttributeNamedArgument as a, PslModel as b, PslCompositeType as c, PslDefaultValue as d, PslDiagnostic as f, PslEnumValue as g, PslEnum as h, PslAttributeArgument as i, PslDefaultFunctionValue as l, PslDocumentAst as m, ParsePslDocumentResult as n, PslAttributePositionalArgument as o, PslDiagnosticCode as p, PslAttribute as r, PslAttributeTarget as s, ParsePslDocumentInput as t, PslDefaultLiteralValue as u, PslFieldAttribute as v, PslReferentialAction as w, PslModelAttribute as x, PslIndexConstraint as y };
|
|
128
|
+
//# sourceMappingURL=types-B5Y_8Gl4.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-B5Y_8Gl4.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,GAA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P,SAAA,IAAA,EAAA,OAAA;EAKA,SAAA,IAAA,EAAA,MAAA;;;;;gCA7Ee;iBACf;;UAGA,mBAAA;;;iBAGA;;UAGA,kBAAA;;;iBAGA;;KAGL,iBAAA,GAAoB;UAEf,QAAA;;;4BAGW;gCACI;iBACf;;UAGA,YAAA;;;iBAGA;;UAGA,OAAA;;;4BAGW;gCACI;iBACf;;UAGA,gBAAA;;;4BAGW;gCACI;iBACf;;UAGA,uBAAA;;;;gCAIe;iBACf;;UAGA,aAAA;;kCAEiB;iBACjB;;UAGA,cAAA;;;4BAGW;2BACD;oCACS;mBACjB;iBACF;;UAGA,qBAAA;;;;UAKA,sBAAA;gBACD;iCACiB"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { type ParsePslDocumentInput, type ParsePslDocumentResult, type PslAttribute, type PslAttributeArgument, type PslAttributeNamedArgument, type PslAttributePositionalArgument, type PslAttributeTarget, 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 };
|
|
1
|
+
import { C as PslPosition, D as PslUniqueConstraint, E as PslTypesBlock, S as PslNamedTypeDeclaration, T as PslSpan, _ as PslField, a as PslAttributeNamedArgument, b as PslModel, c as PslCompositeType, d as PslDefaultValue, f as PslDiagnostic, g as PslEnumValue, h as PslEnum, i as PslAttributeArgument, l as PslDefaultFunctionValue, m as PslDocumentAst, n as ParsePslDocumentResult, o as PslAttributePositionalArgument, p as PslDiagnosticCode, r as PslAttribute, s as PslAttributeTarget, t as ParsePslDocumentInput, u as PslDefaultLiteralValue, v as PslFieldAttribute, w as PslReferentialAction, x as PslModelAttribute, y as PslIndexConstraint } from "./types-B5Y_8Gl4.mjs";
|
|
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/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/psl-parser",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.147",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Reusable parser for Prisma Schema Language (PSL)",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/utils": "0.3.0-dev.
|
|
8
|
+
"@prisma-next/utils": "0.3.0-dev.147"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"tsdown": "0.18.4",
|
|
12
12
|
"typescript": "5.9.3",
|
|
13
13
|
"vitest": "4.0.17",
|
|
14
|
-
"@prisma-next/
|
|
15
|
-
"@prisma-next/
|
|
14
|
+
"@prisma-next/tsdown": "0.0.0",
|
|
15
|
+
"@prisma-next/tsconfig": "0.0.0"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PslAttribute } from './types';
|
|
2
|
+
|
|
3
|
+
export function getPositionalArgument(attribute: PslAttribute, index = 0): string | undefined {
|
|
4
|
+
const entries = attribute.args.filter((arg) => arg.kind === 'positional');
|
|
5
|
+
return entries[index]?.value;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function parseQuotedStringLiteral(value: string): string | undefined {
|
|
9
|
+
const trimmed = value.trim();
|
|
10
|
+
const match = trimmed.match(/^(['"])(.*)\1$/);
|
|
11
|
+
if (!match) return undefined;
|
|
12
|
+
return match[2] ?? '';
|
|
13
|
+
}
|
package/src/exports/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { getPositionalArgument, parseQuotedStringLiteral } from '../attribute-helpers';
|
|
1
2
|
export { parsePslDocument } from '../parser';
|
|
2
3
|
export type {
|
|
3
4
|
ParsePslDocumentInput,
|
|
@@ -7,6 +8,7 @@ export type {
|
|
|
7
8
|
PslAttributeNamedArgument,
|
|
8
9
|
PslAttributePositionalArgument,
|
|
9
10
|
PslAttributeTarget,
|
|
11
|
+
PslCompositeType,
|
|
10
12
|
PslDefaultFunctionValue,
|
|
11
13
|
PslDefaultLiteralValue,
|
|
12
14
|
PslDefaultValue,
|
package/src/exports/types.ts
CHANGED
package/src/parser.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
PslAttribute,
|
|
6
6
|
PslAttributeArgument,
|
|
7
7
|
PslAttributeTarget,
|
|
8
|
+
PslCompositeType,
|
|
8
9
|
PslDiagnostic,
|
|
9
10
|
PslDiagnosticCode,
|
|
10
11
|
PslDocumentAst,
|
|
@@ -61,6 +62,7 @@ export function parsePslDocument(input: ParsePslDocumentInput): ParsePslDocument
|
|
|
61
62
|
|
|
62
63
|
const models: PslModel[] = [];
|
|
63
64
|
const enums: PslEnum[] = [];
|
|
65
|
+
const compositeTypes: PslCompositeType[] = [];
|
|
64
66
|
let typesBlock: PslTypesBlock | undefined;
|
|
65
67
|
|
|
66
68
|
let lineIndex = 0;
|
|
@@ -98,6 +100,19 @@ export function parsePslDocument(input: ParsePslDocumentInput): ParsePslDocument
|
|
|
98
100
|
continue;
|
|
99
101
|
}
|
|
100
102
|
|
|
103
|
+
const compositeTypeMatch = line.match(/^type\s+([A-Za-z_]\w*)\s*\{$/);
|
|
104
|
+
if (compositeTypeMatch) {
|
|
105
|
+
const bounds = findBlockBounds(context, lineIndex);
|
|
106
|
+
const name = compositeTypeMatch[1] ?? '';
|
|
107
|
+
if (name.length === 0) {
|
|
108
|
+
lineIndex = bounds.endLine + 1;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
compositeTypes.push(parseCompositeTypeBlock(context, name, bounds));
|
|
112
|
+
lineIndex = bounds.endLine + 1;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
|
|
101
116
|
if (/^types\s*\{$/.test(line)) {
|
|
102
117
|
const bounds = findBlockBounds(context, lineIndex);
|
|
103
118
|
typesBlock = parseTypesBlock(context, bounds);
|
|
@@ -130,6 +145,7 @@ export function parsePslDocument(input: ParsePslDocumentInput): ParsePslDocument
|
|
|
130
145
|
);
|
|
131
146
|
const modelNames = new Set(models.map((model) => model.name));
|
|
132
147
|
const enumNames = new Set(enums.map((enumBlock) => enumBlock.name));
|
|
148
|
+
const compositeTypeNames = new Set(compositeTypes.map((ct) => ct.name));
|
|
133
149
|
for (const declaration of typesBlock?.declarations ?? []) {
|
|
134
150
|
if (SCALAR_TYPES.has(declaration.name)) {
|
|
135
151
|
pushDiagnostic(context, {
|
|
@@ -168,6 +184,7 @@ export function parsePslDocument(input: ParsePslDocumentInput): ParsePslDocument
|
|
|
168
184
|
hasRelationAttribute ||
|
|
169
185
|
modelNames.has(field.typeName) ||
|
|
170
186
|
enumNames.has(field.typeName) ||
|
|
187
|
+
compositeTypeNames.has(field.typeName) ||
|
|
171
188
|
SCALAR_TYPES.has(field.typeName)
|
|
172
189
|
) {
|
|
173
190
|
return field;
|
|
@@ -184,6 +201,7 @@ export function parsePslDocument(input: ParsePslDocumentInput): ParsePslDocument
|
|
|
184
201
|
sourceId: input.sourceId,
|
|
185
202
|
models: normalizedModels,
|
|
186
203
|
enums,
|
|
204
|
+
compositeTypes,
|
|
187
205
|
...ifDefined('types', typesBlock),
|
|
188
206
|
span: {
|
|
189
207
|
start: createPosition(context, 0, 0),
|
|
@@ -236,6 +254,44 @@ function parseModelBlock(context: ParserContext, name: string, bounds: BlockBoun
|
|
|
236
254
|
};
|
|
237
255
|
}
|
|
238
256
|
|
|
257
|
+
function parseCompositeTypeBlock(
|
|
258
|
+
context: ParserContext,
|
|
259
|
+
name: string,
|
|
260
|
+
bounds: BlockBounds,
|
|
261
|
+
): PslCompositeType {
|
|
262
|
+
const fields: PslField[] = [];
|
|
263
|
+
const attributes: PslAttribute[] = [];
|
|
264
|
+
|
|
265
|
+
for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {
|
|
266
|
+
const raw = context.lines[lineIndex] ?? '';
|
|
267
|
+
const line = stripInlineComment(raw).trim();
|
|
268
|
+
if (line.length === 0) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (line.startsWith('@@')) {
|
|
273
|
+
const attribute = parseModelAttribute(context, line, lineIndex);
|
|
274
|
+
if (attribute) {
|
|
275
|
+
attributes.push(attribute);
|
|
276
|
+
}
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const field = parseField(context, line, lineIndex);
|
|
281
|
+
if (field) {
|
|
282
|
+
fields.push(field);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return {
|
|
287
|
+
kind: 'compositeType',
|
|
288
|
+
name,
|
|
289
|
+
fields,
|
|
290
|
+
attributes,
|
|
291
|
+
span: createLineRangeSpan(context, bounds.startLine, bounds.endLine),
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
239
295
|
function parseEnumBlock(context: ParserContext, name: string, bounds: BlockBounds): PslEnum {
|
|
240
296
|
const values: PslEnumValue[] = [];
|
|
241
297
|
const attributes: PslAttribute[] = [];
|
package/src/types.ts
CHANGED
|
@@ -117,6 +117,14 @@ export interface PslEnum {
|
|
|
117
117
|
readonly span: PslSpan;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
export interface PslCompositeType {
|
|
121
|
+
readonly kind: 'compositeType';
|
|
122
|
+
readonly name: string;
|
|
123
|
+
readonly fields: readonly PslField[];
|
|
124
|
+
readonly attributes: readonly PslAttribute[];
|
|
125
|
+
readonly span: PslSpan;
|
|
126
|
+
}
|
|
127
|
+
|
|
120
128
|
export interface PslNamedTypeDeclaration {
|
|
121
129
|
readonly kind: 'namedType';
|
|
122
130
|
readonly name: string;
|
|
@@ -136,6 +144,7 @@ export interface PslDocumentAst {
|
|
|
136
144
|
readonly sourceId: string;
|
|
137
145
|
readonly models: readonly PslModel[];
|
|
138
146
|
readonly enums: readonly PslEnum[];
|
|
147
|
+
readonly compositeTypes: readonly PslCompositeType[];
|
|
139
148
|
readonly types?: PslTypesBlock;
|
|
140
149
|
readonly span: PslSpan;
|
|
141
150
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser-C7qeAcwZ.d.mts","names":[],"sources":["../src/parser.ts"],"sourcesContent":[],"mappings":";;;iBAgDgB,gBAAA,QAAwB,wBAAwB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser-ClclNzzu.mjs","names":["diagnostics: PslDiagnostic[]","context: ParserContext","models: PslModel[]","enums: PslEnum[]","typesBlock: PslTypesBlock | undefined","fields: PslField[]","attributes: PslModelAttribute[]","values: PslEnumValue[]","attributes: PslAttribute[]","declarations: PslNamedTypeDeclaration[]","attributes: PslFieldAttribute[]","args: readonly PslAttributeArgument[]","args: PslAttributeArgument[]","quote: '\"' | \"'\" | null","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 PslDiagnostic,\n PslDiagnosticCode,\n PslDocumentAst,\n PslEnum,\n PslEnumValue,\n PslField,\n PslFieldAttribute,\n PslModel,\n PslModelAttribute,\n PslNamedTypeDeclaration,\n PslPosition,\n PslSpan,\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 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 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 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 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 ...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 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*([A-Za-z_]\\w*)(.*)$/);\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 baseType = declarationMatch[2] ?? '';\n const attributePart = declarationMatch[3] ?? '';\n const trimmedStartColumn = firstNonWhitespaceColumn(raw);\n const attributeOffset = line.length - attributePart.length;\n const attributeSource = attributePart.trimStart();\n const leadingAttributeWhitespace = attributePart.length - attributeSource.length;\n const attributeParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n attributeSource,\n trimmedStartColumn + 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 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 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+([A-Za-z_]\\w*(?:\\[\\])?)(\\?)?(.*)$/);\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 rawTypeToken = fieldMatch[2] ?? '';\n const optionalMarker = fieldMatch[3] ?? '';\n const attributePart = fieldMatch[4] ?? '';\n const list = rawTypeToken.endsWith('[]');\n const typeName = list ? rawTypeToken.slice(0, -2) : rawTypeToken;\n const optional = optionalMarker === '?';\n\n const attributes: PslFieldAttribute[] = [];\n const rawLine = context.lines[lineIndex] ?? '';\n const trimmedStartColumn = firstNonWhitespaceColumn(rawLine);\n const attributeOffset = line.length - attributePart.length;\n const attributeSource = attributePart.trimStart();\n const leadingAttributeWhitespace = attributePart.length - attributeSource.length;\n const tokenParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n attributeSource,\n trimmedStartColumn + attributeOffset + leadingAttributeWhitespace,\n );\n if (!tokenParse.ok) {\n return {\n kind: 'field',\n name: fieldName,\n typeName,\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 optional,\n list,\n attributes,\n span: createTrimmedLineSpan(context, lineIndex),\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 = parseAttributeArguments(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 });\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 parseAttributeArguments(\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 },\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: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid empty argument in attribute \"${input.token}\"`,\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: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid named argument syntax \"${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: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid named argument syntax \"${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 let previousCharacter = '';\n for (const character of line) {\n if (quote) {\n if (character === quote && previousCharacter !== '\\\\') {\n quote = null;\n }\n previousCharacter = character;\n continue;\n }\n\n if (character === '\"' || character === \"'\") {\n quote = character;\n previousCharacter = 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 previousCharacter = character;\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 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 && value[index - 1] !== '\\\\') {\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\n if (character === separator && depthParen === 0 && depthBracket === 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 && value[index - 1] !== '\\\\') {\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 && line[index - 1] !== '\\\\') {\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":";;;AAsBA,MAAM,eAAe,IAAI,IAAI;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAgBF,SAAgB,iBAAiB,OAAsD;CACrF,MAAM,mBAAmB,MAAM,OAAO,WAAW,QAAQ,KAAK;CAC9D,MAAM,QAAQ,iBAAiB,MAAM,KAAK;CAC1C,MAAM,cAAc,mBAAmB,iBAAiB;CACxD,MAAMA,cAA+B,EAAE;CACvC,MAAMC,UAAyB;EAC7B,QAAQ;EACR,UAAU,MAAM;EAChB;EACA;EACA;EACD;CAED,MAAMC,SAAqB,EAAE;CAC7B,MAAMC,QAAmB,EAAE;CAC3B,IAAIC;CAEJ,IAAI,YAAY;AAChB,QAAO,YAAY,MAAM,QAAQ;EAE/B,MAA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