@prisma-next/psl-parser 0.0.1
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 +75 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +3 -0
- package/dist/parser-BP2RP4rk.mjs +681 -0
- package/dist/parser-BP2RP4rk.mjs.map +1 -0
- package/dist/parser-CUqO9VeG.d.mts +7 -0
- package/dist/parser-CUqO9VeG.d.mts.map +1 -0
- package/dist/parser.d.mts +2 -0
- package/dist/parser.mjs +3 -0
- package/dist/types-QqDFOzNR.d.mts +119 -0
- package/dist/types-QqDFOzNR.d.mts.map +1 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +45 -0
- package/src/exports/index.ts +26 -0
- package/src/exports/parser.ts +1 -0
- package/src/exports/types.ts +28 -0
- package/src/parser.ts +927 -0
- package/src/types.ts +151 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
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' | '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 PslAttribute {
|
|
62
|
+
readonly kind: 'attribute';
|
|
63
|
+
readonly target: PslAttributeTarget;
|
|
64
|
+
readonly name: string;
|
|
65
|
+
readonly args: readonly PslAttributeArgument[];
|
|
66
|
+
readonly span: PslSpan;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type PslReferentialAction = string;
|
|
70
|
+
|
|
71
|
+
export type PslFieldAttribute = PslAttribute;
|
|
72
|
+
|
|
73
|
+
export interface PslField {
|
|
74
|
+
readonly kind: 'field';
|
|
75
|
+
readonly name: string;
|
|
76
|
+
readonly typeName: string;
|
|
77
|
+
readonly optional: boolean;
|
|
78
|
+
readonly list: boolean;
|
|
79
|
+
readonly typeRef?: string;
|
|
80
|
+
readonly attributes: readonly PslFieldAttribute[];
|
|
81
|
+
readonly span: PslSpan;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface PslUniqueConstraint {
|
|
85
|
+
readonly kind: 'unique';
|
|
86
|
+
readonly fields: readonly string[];
|
|
87
|
+
readonly span: PslSpan;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface PslIndexConstraint {
|
|
91
|
+
readonly kind: 'index';
|
|
92
|
+
readonly fields: readonly string[];
|
|
93
|
+
readonly span: PslSpan;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type PslModelAttribute = PslAttribute;
|
|
97
|
+
|
|
98
|
+
export interface PslModel {
|
|
99
|
+
readonly kind: 'model';
|
|
100
|
+
readonly name: string;
|
|
101
|
+
readonly fields: readonly PslField[];
|
|
102
|
+
readonly attributes: readonly PslModelAttribute[];
|
|
103
|
+
readonly span: PslSpan;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface PslEnumValue {
|
|
107
|
+
readonly kind: 'enumValue';
|
|
108
|
+
readonly name: string;
|
|
109
|
+
readonly span: PslSpan;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface PslEnum {
|
|
113
|
+
readonly kind: 'enum';
|
|
114
|
+
readonly name: string;
|
|
115
|
+
readonly values: readonly PslEnumValue[];
|
|
116
|
+
readonly span: PslSpan;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface PslNamedTypeDeclaration {
|
|
120
|
+
readonly kind: 'namedType';
|
|
121
|
+
readonly name: string;
|
|
122
|
+
readonly baseType: string;
|
|
123
|
+
readonly attributes: readonly PslAttribute[];
|
|
124
|
+
readonly span: PslSpan;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface PslTypesBlock {
|
|
128
|
+
readonly kind: 'types';
|
|
129
|
+
readonly declarations: readonly PslNamedTypeDeclaration[];
|
|
130
|
+
readonly span: PslSpan;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface PslDocumentAst {
|
|
134
|
+
readonly kind: 'document';
|
|
135
|
+
readonly sourceId: string;
|
|
136
|
+
readonly models: readonly PslModel[];
|
|
137
|
+
readonly enums: readonly PslEnum[];
|
|
138
|
+
readonly types?: PslTypesBlock;
|
|
139
|
+
readonly span: PslSpan;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface ParsePslDocumentInput {
|
|
143
|
+
readonly schema: string;
|
|
144
|
+
readonly sourceId: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface ParsePslDocumentResult {
|
|
148
|
+
readonly ast: PslDocumentAst;
|
|
149
|
+
readonly diagnostics: readonly PslDiagnostic[];
|
|
150
|
+
readonly ok: boolean;
|
|
151
|
+
}
|