@dbml/parse 3.6.1 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/LICENSE +0 -0
  2. package/dist/compiler.d.ts +79 -0
  3. package/dist/constants.d.ts +2 -0
  4. package/dist/dbml-parse.js +1 -1
  5. package/dist/dbml-parse.mjs +1 -1
  6. package/dist/index.d.ts +5 -0
  7. package/dist/lib/analyzer/analyzer.d.ts +12 -0
  8. package/dist/lib/analyzer/binder/binder.d.ts +10 -0
  9. package/dist/lib/analyzer/binder/elementBinder/custom.d.ts +11 -0
  10. package/dist/lib/analyzer/binder/elementBinder/elementBinder.d.ts +22 -0
  11. package/dist/lib/analyzer/binder/elementBinder/enum.d.ts +13 -0
  12. package/dist/lib/analyzer/binder/elementBinder/indexes.d.ts +17 -0
  13. package/dist/lib/analyzer/binder/elementBinder/note.d.ts +13 -0
  14. package/dist/lib/analyzer/binder/elementBinder/project.d.ts +11 -0
  15. package/dist/lib/analyzer/binder/elementBinder/ref.d.ts +17 -0
  16. package/dist/lib/analyzer/binder/elementBinder/table.d.ts +32 -0
  17. package/dist/lib/analyzer/binder/elementBinder/tableGroup.d.ts +17 -0
  18. package/dist/lib/analyzer/binder/utils.d.ts +14 -0
  19. package/dist/lib/analyzer/symbol/factory.d.ts +9 -0
  20. package/dist/lib/analyzer/symbol/symbolIndex.d.ts +27 -0
  21. package/dist/lib/analyzer/symbol/symbolTable.d.ts +12 -0
  22. package/dist/lib/analyzer/symbol/symbols.d.ts +77 -0
  23. package/dist/lib/analyzer/symbol/utils.d.ts +3 -0
  24. package/dist/lib/analyzer/types.d.ts +9 -0
  25. package/dist/lib/analyzer/utils.d.ts +38 -0
  26. package/dist/lib/analyzer/validator/elementValidators/custom.d.ts +21 -0
  27. package/dist/lib/analyzer/validator/elementValidators/enum.d.ts +26 -0
  28. package/dist/lib/analyzer/validator/elementValidators/indexes.d.ts +25 -0
  29. package/dist/lib/analyzer/validator/elementValidators/note.d.ts +23 -0
  30. package/dist/lib/analyzer/validator/elementValidators/project.d.ts +22 -0
  31. package/dist/lib/analyzer/validator/elementValidators/ref.d.ts +24 -0
  32. package/dist/lib/analyzer/validator/elementValidators/table.d.ts +26 -0
  33. package/dist/lib/analyzer/validator/elementValidators/tableGroup.d.ts +25 -0
  34. package/dist/lib/analyzer/validator/utils.d.ts +54 -0
  35. package/dist/lib/analyzer/validator/validator.d.ts +12 -0
  36. package/dist/lib/errors.d.ts +92 -0
  37. package/dist/lib/interpreter/elementInterpreter/enum.d.ts +13 -0
  38. package/dist/lib/interpreter/elementInterpreter/project.d.ts +13 -0
  39. package/dist/lib/interpreter/elementInterpreter/ref.d.ts +15 -0
  40. package/dist/lib/interpreter/elementInterpreter/sticky_note.d.ts +15 -0
  41. package/dist/lib/interpreter/elementInterpreter/table.d.ts +21 -0
  42. package/dist/lib/interpreter/elementInterpreter/tableGroup.d.ts +13 -0
  43. package/dist/lib/interpreter/interpreter.d.ts +11 -0
  44. package/dist/lib/interpreter/utils.d.ts +29 -0
  45. package/dist/lib/lexer/lexer.d.ts +43 -0
  46. package/dist/lib/lexer/tokens.d.ts +46 -0
  47. package/dist/lib/lexer/utils.d.ts +8 -0
  48. package/dist/lib/option.d.ts +17 -0
  49. package/dist/lib/parser/contextStack.d.ts +21 -0
  50. package/dist/lib/parser/factory.d.ts +9 -0
  51. package/dist/lib/parser/nodes.d.ts +209 -0
  52. package/dist/lib/parser/parser.d.ts +54 -0
  53. package/dist/lib/parser/utils.d.ts +47 -0
  54. package/dist/lib/report.d.ts +9 -0
  55. package/dist/lib/serialization/serialize.d.ts +5 -0
  56. package/dist/lib/utils.d.ts +12 -0
  57. package/dist/services/definition/provider.d.ts +8 -0
  58. package/dist/services/index.d.ts +6 -0
  59. package/dist/services/references/provider.d.ts +8 -0
  60. package/dist/services/suggestions/provider.d.ts +9 -0
  61. package/dist/services/suggestions/utils.d.ts +9 -0
  62. package/dist/services/types.d.ts +60 -0
  63. package/dist/services/utils.d.ts +3 -0
  64. package/package.json +5 -3
@@ -0,0 +1,43 @@
1
+ import { CompileError } from '../errors';
2
+ import { default as Report } from '../report';
3
+ import { SyntaxToken, SyntaxTokenKind } from './tokens';
4
+
5
+ export default class Lexer {
6
+ private start;
7
+ private current;
8
+ private text;
9
+ private tokens;
10
+ private errors;
11
+ constructor(text: string);
12
+ private isAtEnd;
13
+ private advance;
14
+ private peek;
15
+ check(sequence: string): boolean;
16
+ match(sequence: string): boolean;
17
+ private addToken;
18
+ private createToken;
19
+ lex(): Report<SyntaxToken[], CompileError>;
20
+ scanTokens(): void;
21
+ gatherTrivia(): void;
22
+ gatherInvalid(): void;
23
+ consumeUntil(tokenKind: SyntaxTokenKind, stopSequence: string, { allowNewline, // Whether newline is allowed
24
+ allowEof, // Whether EOF is allowed
25
+ raw, // Whether to interpret '\' as a backlash
26
+ consumeStopSequence, }: {
27
+ allowNewline: boolean;
28
+ allowEof: boolean;
29
+ raw: boolean;
30
+ consumeStopSequence?: boolean;
31
+ }): void;
32
+ singleLineStringLiteral(): void;
33
+ multilineStringLiteral(): void;
34
+ functionExpression(): void;
35
+ quotedVariable(): void;
36
+ singleLineComment(): void;
37
+ multilineComment(): void;
38
+ identifier(): void;
39
+ operator(): void;
40
+ numericLiteralOrIdentifier(): void;
41
+ colorLiteral(): void;
42
+ escapedString(): string;
43
+ }
@@ -0,0 +1,46 @@
1
+ import { Position } from '../types';
2
+
3
+ export declare enum SyntaxTokenKind {
4
+ SPACE = "<space>",
5
+ TAB = "<tab>",
6
+ NEWLINE = "<newline>",
7
+ COMMA = "<comma>",
8
+ LPAREN = "<lparen>",
9
+ RPAREN = "<rparen>",
10
+ LBRACE = "<lbrace>",
11
+ RBRACE = "<rbrace>",
12
+ LBRACKET = "<lbracket>",
13
+ RBRACKET = "<rbracket>",
14
+ LANGLE = "<langle>",
15
+ RANGLE = "<rangle>",
16
+ OP = "<op>",
17
+ EOF = "<eof>",
18
+ NUMERIC_LITERAL = "<number>",
19
+ STRING_LITERAL = "<string>",
20
+ COLOR_LITERAL = "<color>",
21
+ FUNCTION_EXPRESSION = "<function-expression>",
22
+ QUOTED_STRING = "<variable>",
23
+ IDENTIFIER = "<identifier>",
24
+ SEMICOLON = "<semicolon>",
25
+ COLON = "<colon>",
26
+ SINGLE_LINE_COMMENT = "<single-line-comment>",
27
+ MULTILINE_COMMENT = "<multiline-comment>"
28
+ }
29
+ export declare function isTriviaToken(token: SyntaxToken): boolean;
30
+ export declare function isOp(c?: string): boolean;
31
+ export declare function isOpToken(token?: SyntaxToken): boolean;
32
+ export declare class SyntaxToken {
33
+ kind: SyntaxTokenKind;
34
+ value: string;
35
+ leadingTrivia: SyntaxToken[];
36
+ trailingTrivia: SyntaxToken[];
37
+ leadingInvalid: SyntaxToken[];
38
+ trailingInvalid: SyntaxToken[];
39
+ startPos: Readonly<Position>;
40
+ start: Readonly<number>;
41
+ endPos: Readonly<Position>;
42
+ end: Readonly<number>;
43
+ isInvalid: boolean;
44
+ protected constructor(kind: SyntaxTokenKind, startPos: Position, endPos: Position, value: string, isInvalid: boolean);
45
+ static create(kind: SyntaxTokenKind, startPos: Position, endPos: Position, value: string, isInvalid: boolean): SyntaxToken;
46
+ }
@@ -0,0 +1,8 @@
1
+ import { SyntaxToken } from './tokens';
2
+
3
+ export declare function hasTrailingNewLines(token: SyntaxToken): boolean;
4
+ export declare function isAtStartOfLine(previous: SyntaxToken, token: SyntaxToken): boolean;
5
+ export declare function hasTrailingSpaces(token: SyntaxToken): boolean;
6
+ export declare function getTokenFullEnd(token: SyntaxToken): number;
7
+ export declare function getTokenFullStart(token: SyntaxToken): number;
8
+ export declare function isComment(token: SyntaxToken): boolean;
@@ -0,0 +1,17 @@
1
+ export type Option<T> = Some<T> | None<T>;
2
+ export declare class Some<T> {
3
+ value: T;
4
+ constructor(value: T);
5
+ unwrap(): T;
6
+ unwrap_or<S>(orValue: S): S | T;
7
+ and_then<S>(callback: (_: T) => Option<S>): Option<S>;
8
+ map<S>(callback: (_: T) => S): Option<S>;
9
+ isOk(): boolean;
10
+ }
11
+ export declare class None<T> {
12
+ unwrap(): T;
13
+ unwrap_or<S>(orValue: S): S | T;
14
+ and_then<S>(callback: (_: T) => Option<S>): Option<S>;
15
+ map<S>(callback: (_: T) => S): Option<S>;
16
+ isOk(): boolean;
17
+ }
@@ -0,0 +1,21 @@
1
+ import { SyntaxToken } from '../lexer/tokens';
2
+
3
+ export declare const enum ParsingContext {
4
+ ListExpression = 0,
5
+ GroupExpression = 1,
6
+ BlockExpression = 2
7
+ }
8
+ export declare class ParsingContextStack {
9
+ private stack;
10
+ private numberOfNestedLParens;
11
+ private numberOfNestedLBrackets;
12
+ private numberOfNestedLBraces;
13
+ push(ctx: ParsingContext): void;
14
+ pop(): ParsingContext | undefined;
15
+ top(): ParsingContext | undefined;
16
+ isWithinGroupExpressionContext(): boolean;
17
+ isWithinListExpressionContext(): boolean;
18
+ isWithinBlockExpressionContext(): boolean;
19
+ withContextDo<T>(context: ParsingContext, callback: () => T): () => T;
20
+ findHandlerContext(tokens: SyntaxToken[], curTokenId: number): ParsingContext | undefined;
21
+ }
@@ -0,0 +1,9 @@
1
+ import { SyntaxNode, SyntaxNodeId, SyntaxNodeIdGenerator } from './nodes';
2
+
3
+ export default class NodeFactory {
4
+ private generator;
5
+ constructor(generator: SyntaxNodeIdGenerator);
6
+ create<T extends SyntaxNode, A>(Type: {
7
+ new (args: A, id: SyntaxNodeId): T;
8
+ }, args: A): T;
9
+ }
@@ -0,0 +1,209 @@
1
+ import { SyntaxToken } from '../lexer/tokens';
2
+ import { NodeSymbol } from '../analyzer/symbol/symbols';
3
+ import { Position } from '../types';
4
+
5
+ export type SyntaxNodeId = number;
6
+ export declare class SyntaxNodeIdGenerator {
7
+ private id;
8
+ reset(): void;
9
+ nextId(): SyntaxNodeId;
10
+ }
11
+ export declare class SyntaxNode {
12
+ id: Readonly<SyntaxNodeId>;
13
+ kind: SyntaxNodeKind;
14
+ startPos: Readonly<Position>;
15
+ start: Readonly<number>;
16
+ fullStart: Readonly<number>;
17
+ endPos: Readonly<Position>;
18
+ end: Readonly<number>;
19
+ fullEnd: Readonly<number>;
20
+ symbol?: NodeSymbol;
21
+ referee?: NodeSymbol;
22
+ constructor(id: SyntaxNodeId, kind: SyntaxNodeKind, args: Readonly<SyntaxToken | SyntaxNode | undefined>[]);
23
+ }
24
+ export declare enum SyntaxNodeKind {
25
+ PROGRAM = "<program>",
26
+ ELEMENT_DECLARATION = "<element-declaration>",
27
+ ATTRIBUTE = "<attribute>",
28
+ IDENTIFIER_STREAM = "<identifer-stream>",
29
+ LITERAL = "<literal>",
30
+ VARIABLE = "<variable>",
31
+ PREFIX_EXPRESSION = "<prefix-expression>",
32
+ INFIX_EXPRESSION = "<infix-expression>",
33
+ POSTFIX_EXPRESSION = "<postfix-expression>",
34
+ FUNCTION_EXPRESSION = "<function-expression>",
35
+ FUNCTION_APPLICATION = "<function-application>",
36
+ BLOCK_EXPRESSION = "<block-expression>",
37
+ LIST_EXPRESSION = "<list-expression>",
38
+ TUPLE_EXPRESSION = "<tuple-expression>",
39
+ CALL_EXPRESSION = "<call-expression>",
40
+ PRIMARY_EXPRESSION = "<primary-expression>",
41
+ GROUP_EXPRESSION = "<group-expression>",
42
+ DUMMY = "<dummy>",
43
+ ARRAY = "<array>"
44
+ }
45
+ export declare class ProgramNode extends SyntaxNode {
46
+ body: ElementDeclarationNode[];
47
+ eof?: SyntaxToken;
48
+ constructor({ body, eof }: {
49
+ body?: ElementDeclarationNode[];
50
+ eof?: SyntaxToken;
51
+ }, id: SyntaxNodeId);
52
+ }
53
+ export declare class ElementDeclarationNode extends SyntaxNode {
54
+ type?: SyntaxToken;
55
+ name?: NormalExpressionNode;
56
+ as?: SyntaxToken;
57
+ alias?: NormalExpressionNode;
58
+ attributeList?: ListExpressionNode;
59
+ bodyColon?: SyntaxToken;
60
+ parent?: ElementDeclarationNode | ProgramNode;
61
+ body?: FunctionApplicationNode | BlockExpressionNode;
62
+ constructor({ type, name, as, alias, attributeList, bodyColon, body, }: {
63
+ type?: SyntaxToken;
64
+ name?: NormalExpressionNode;
65
+ as?: SyntaxToken;
66
+ alias?: NormalExpressionNode;
67
+ attributeList?: ListExpressionNode;
68
+ bodyColon?: SyntaxToken;
69
+ body?: BlockExpressionNode | FunctionApplicationNode;
70
+ }, id: SyntaxNodeId);
71
+ }
72
+ export declare class IdentiferStreamNode extends SyntaxNode {
73
+ identifiers: SyntaxToken[];
74
+ constructor({ identifiers }: {
75
+ identifiers?: SyntaxToken[];
76
+ }, id: SyntaxNodeId);
77
+ }
78
+ export declare class AttributeNode extends SyntaxNode {
79
+ name?: IdentiferStreamNode | PrimaryExpressionNode;
80
+ colon?: SyntaxToken;
81
+ value?: NormalExpressionNode | IdentiferStreamNode;
82
+ constructor({ name, colon, value, }: {
83
+ name?: IdentiferStreamNode | PrimaryExpressionNode;
84
+ colon?: SyntaxToken;
85
+ value?: NormalExpressionNode | IdentiferStreamNode;
86
+ }, id: SyntaxNodeId);
87
+ }
88
+ export type NormalExpressionNode = PrefixExpressionNode | InfixExpressionNode | PostfixExpressionNode | BlockExpressionNode | ListExpressionNode | TupleExpressionNode | CallExpressionNode | PrimaryExpressionNode | FunctionExpressionNode | DummyNode | ArrayNode;
89
+ export type ExpressionNode = ElementDeclarationNode | NormalExpressionNode | FunctionApplicationNode;
90
+ export declare class PrefixExpressionNode extends SyntaxNode {
91
+ op?: SyntaxToken;
92
+ expression?: NormalExpressionNode;
93
+ constructor({ op, expression }: {
94
+ op?: SyntaxToken;
95
+ expression?: NormalExpressionNode;
96
+ }, id: SyntaxNodeId);
97
+ }
98
+ export declare class InfixExpressionNode extends SyntaxNode {
99
+ op?: SyntaxToken;
100
+ leftExpression?: NormalExpressionNode;
101
+ rightExpression?: NormalExpressionNode;
102
+ constructor({ op, leftExpression, rightExpression, }: {
103
+ op?: SyntaxToken;
104
+ leftExpression?: NormalExpressionNode;
105
+ rightExpression?: NormalExpressionNode;
106
+ }, id: SyntaxNodeId);
107
+ }
108
+ export declare class PostfixExpressionNode extends SyntaxNode {
109
+ op?: SyntaxToken;
110
+ expression?: NormalExpressionNode;
111
+ constructor({ op, expression }: {
112
+ op?: SyntaxToken;
113
+ expression?: NormalExpressionNode;
114
+ }, id: SyntaxNodeId);
115
+ }
116
+ export declare class FunctionExpressionNode extends SyntaxNode {
117
+ value?: SyntaxToken;
118
+ constructor({ value }: {
119
+ value?: SyntaxToken;
120
+ }, id: SyntaxNodeId);
121
+ }
122
+ export declare class FunctionApplicationNode extends SyntaxNode {
123
+ callee?: ExpressionNode;
124
+ args: ExpressionNode[];
125
+ constructor({ callee, args }: {
126
+ callee?: ExpressionNode;
127
+ args?: ExpressionNode[];
128
+ }, id: SyntaxNodeId);
129
+ }
130
+ export declare class BlockExpressionNode extends SyntaxNode {
131
+ blockOpenBrace?: SyntaxToken;
132
+ body: (ElementDeclarationNode | FunctionApplicationNode)[];
133
+ blockCloseBrace?: SyntaxToken;
134
+ constructor({ blockOpenBrace, body, blockCloseBrace, }: {
135
+ blockOpenBrace?: SyntaxToken;
136
+ body?: (ElementDeclarationNode | FunctionApplicationNode)[];
137
+ blockCloseBrace?: SyntaxToken;
138
+ }, id: SyntaxNodeId);
139
+ }
140
+ export declare class ListExpressionNode extends SyntaxNode {
141
+ listOpenBracket?: SyntaxToken;
142
+ elementList: AttributeNode[];
143
+ commaList: SyntaxToken[];
144
+ listCloseBracket?: SyntaxToken;
145
+ constructor({ listOpenBracket, elementList, commaList, listCloseBracket, }: {
146
+ listOpenBracket?: SyntaxToken;
147
+ elementList?: AttributeNode[];
148
+ commaList?: SyntaxToken[];
149
+ listCloseBracket?: SyntaxToken;
150
+ }, id: SyntaxNodeId);
151
+ }
152
+ export declare class TupleExpressionNode extends SyntaxNode {
153
+ tupleOpenParen?: SyntaxToken;
154
+ elementList: NormalExpressionNode[];
155
+ commaList: SyntaxToken[];
156
+ tupleCloseParen?: SyntaxToken;
157
+ constructor({ tupleOpenParen, elementList, commaList, tupleCloseParen, }: {
158
+ tupleOpenParen?: SyntaxToken;
159
+ elementList?: NormalExpressionNode[];
160
+ commaList?: SyntaxToken[];
161
+ tupleCloseParen?: SyntaxToken;
162
+ }, id: SyntaxNodeId);
163
+ }
164
+ export declare class GroupExpressionNode extends TupleExpressionNode {
165
+ constructor({ groupOpenParen, expression, groupCloseParen, }: {
166
+ groupOpenParen?: SyntaxToken;
167
+ expression?: NormalExpressionNode;
168
+ groupCloseParen?: SyntaxToken;
169
+ }, id: SyntaxNodeId);
170
+ }
171
+ export declare class CallExpressionNode extends SyntaxNode {
172
+ callee?: NormalExpressionNode;
173
+ argumentList?: TupleExpressionNode;
174
+ constructor({ callee, argumentList, }: {
175
+ callee?: NormalExpressionNode;
176
+ argumentList?: TupleExpressionNode;
177
+ }, id: SyntaxNodeId);
178
+ }
179
+ export declare class LiteralNode extends SyntaxNode {
180
+ literal?: SyntaxToken;
181
+ constructor({ literal }: {
182
+ literal?: SyntaxToken;
183
+ }, id: SyntaxNodeId);
184
+ }
185
+ export declare class VariableNode extends SyntaxNode {
186
+ variable?: SyntaxToken;
187
+ constructor({ variable }: {
188
+ variable?: SyntaxToken;
189
+ }, id: SyntaxNodeId);
190
+ }
191
+ export declare class PrimaryExpressionNode extends SyntaxNode {
192
+ expression?: LiteralNode | VariableNode;
193
+ constructor({ expression }: {
194
+ expression?: LiteralNode | VariableNode;
195
+ }, id: SyntaxNodeId);
196
+ }
197
+ export declare class DummyNode extends SyntaxNode {
198
+ constructor({ pre }: {
199
+ pre: Readonly<SyntaxNode> | Readonly<SyntaxToken>;
200
+ }, id: SyntaxNodeId);
201
+ }
202
+ export declare class ArrayNode extends SyntaxNode {
203
+ array?: NormalExpressionNode;
204
+ indexer?: ListExpressionNode;
205
+ constructor({ expression, indexer }: {
206
+ expression?: NormalExpressionNode;
207
+ indexer: ListExpressionNode;
208
+ }, id: SyntaxNodeId);
209
+ }
@@ -0,0 +1,54 @@
1
+ import { CompileError } from '../errors';
2
+ import { SyntaxToken } from '../lexer/tokens';
3
+ import { default as Report } from '../report';
4
+ import { ProgramNode, SyntaxNodeIdGenerator } from './nodes';
5
+
6
+ export default class Parser {
7
+ private tokens;
8
+ private current;
9
+ private errors;
10
+ private contextStack;
11
+ private nodeFactory;
12
+ constructor(tokens: SyntaxToken[], nodeIdGenerator: SyntaxNodeIdGenerator);
13
+ private isAtEnd;
14
+ private advance;
15
+ private peek;
16
+ private match;
17
+ private check;
18
+ private previous;
19
+ private canHandle;
20
+ private consume;
21
+ private discardUntil;
22
+ private gatherInvalid;
23
+ parse(): Report<{
24
+ ast: ProgramNode;
25
+ tokens: SyntaxToken[];
26
+ }, CompileError>;
27
+ private program;
28
+ private synchronizeProgram;
29
+ private elementDeclaration;
30
+ private synchronizeElementDeclarationName;
31
+ private synchronizeElementDeclarationAlias;
32
+ private fieldDeclaration;
33
+ private expression;
34
+ private shouldStopExpression;
35
+ private normalExpression;
36
+ private expression_bp;
37
+ private leftExpression_bp;
38
+ private extractOperand;
39
+ private functionExpression;
40
+ private blockExpression;
41
+ private canBeField;
42
+ private synchronizeBlock;
43
+ private primaryExpression;
44
+ private tupleExpression;
45
+ private synchronizeTuple;
46
+ private listExpression;
47
+ private synchronizeList;
48
+ private attribute;
49
+ private synchronizeAttributeName;
50
+ private attributeValue;
51
+ private synchronizeAttributeValue;
52
+ private attributeName;
53
+ private logError;
54
+ }
@@ -0,0 +1,47 @@
1
+ import { SyntaxToken, SyntaxTokenKind } from '../lexer/tokens';
2
+ import { Option } from '../option';
3
+ import { default as NodeFactory } from './factory';
4
+ import { ElementDeclarationNode, ExpressionNode, IdentiferStreamNode, InfixExpressionNode, LiteralNode, NormalExpressionNode, PrimaryExpressionNode, SyntaxNode, VariableNode } from './nodes';
5
+
6
+ export declare function convertFuncAppToElem(callee: ExpressionNode | undefined, args: NormalExpressionNode[], factory: NodeFactory): Option<ElementDeclarationNode>;
7
+ export declare function isAsKeyword(token: SyntaxToken): token is SyntaxToken & {
8
+ kind: SyntaxTokenKind.IDENTIFIER;
9
+ value: 'as';
10
+ };
11
+ export declare function markInvalid(nodeOrToken?: SyntaxNode | SyntaxToken): void;
12
+ export declare function isInvalidToken(token?: SyntaxToken): boolean;
13
+ export declare function getMemberChain(node: SyntaxNode): Readonly<(SyntaxNode | SyntaxToken)[]>;
14
+ export declare function extractVariableNode(value?: unknown): Option<SyntaxToken>;
15
+ export declare function isExpressionAQuotedString(value?: unknown): value is PrimaryExpressionNode & ({
16
+ expression: VariableNode & {
17
+ variable: SyntaxToken & {
18
+ kind: SyntaxTokenKind.QUOTED_STRING;
19
+ };
20
+ };
21
+ } | {
22
+ expression: LiteralNode & {
23
+ literal: SyntaxToken & {
24
+ kind: SyntaxTokenKind.STRING_LITERAL;
25
+ };
26
+ };
27
+ });
28
+ export declare function isExpressionAVariableNode(value?: unknown): value is PrimaryExpressionNode & {
29
+ expression: VariableNode & {
30
+ variable: SyntaxToken;
31
+ };
32
+ };
33
+ export declare function isExpressionAnIdentifierNode(value?: unknown): value is PrimaryExpressionNode & {
34
+ expression: VariableNode & {
35
+ variable: {
36
+ kind: SyntaxTokenKind.IDENTIFIER;
37
+ };
38
+ };
39
+ };
40
+ export declare function isAccessExpression(node: SyntaxNode): node is InfixExpressionNode & {
41
+ leftExpression: SyntaxNode;
42
+ rightExpression: SyntaxNode;
43
+ op: SyntaxToken & {
44
+ value: '.';
45
+ };
46
+ };
47
+ export declare function extractStringFromIdentifierStream(stream?: IdentiferStreamNode): Option<string>;
@@ -0,0 +1,9 @@
1
+ export default class Report<T, E> {
2
+ private value;
3
+ private errors;
4
+ constructor(value: T, errors?: E[]);
5
+ getValue(): T;
6
+ getErrors(): E[];
7
+ chain<U>(fn: (_: T) => Report<U, E>): Report<U, E>;
8
+ map<U>(fn: (_: T) => U): Report<U, E>;
9
+ }
@@ -0,0 +1,5 @@
1
+ import { ProgramNode } from '../parser/nodes';
2
+ import { default as Report } from '../report';
3
+ import { CompileError } from '../errors';
4
+
5
+ export declare function serialize(report: Readonly<Report<ProgramNode, CompileError>>, pretty?: boolean): string;
@@ -0,0 +1,12 @@
1
+ import { SyntaxToken } from './lexer/tokens';
2
+ import { SyntaxNode } from './parser/nodes';
3
+
4
+ export declare function isAlphaOrUnderscore(char: string): boolean;
5
+ export declare function isDigit(char: string): boolean;
6
+ export declare function isHexChar(char: string): boolean;
7
+ export declare function isAlphaNumeric(char: string): boolean;
8
+ export declare function alternateLists<T, S>(firstList: T[], secondList: S[]): (T | S)[];
9
+ export declare function isOffsetWithinFullSpan(offset: number, nodeOrToken: SyntaxNode | SyntaxToken): boolean;
10
+ export declare function isOffsetWithinSpan(offset: number, nodeOrToken: SyntaxNode | SyntaxToken): boolean;
11
+ export declare function returnIfIsOffsetWithinFullSpan(offset: number, node?: SyntaxNode): SyntaxNode | undefined;
12
+ export declare function returnIfIsOffsetWithinFullSpan(offset: number, token?: SyntaxToken): SyntaxToken | undefined;
@@ -0,0 +1,8 @@
1
+ import { Definition, DefinitionProvider, TextModel, Position } from '../types';
2
+ import { default as Compiler } from '../../compiler';
3
+
4
+ export default class DBMLDefinitionProvider implements DefinitionProvider {
5
+ private compiler;
6
+ constructor(compiler: Compiler);
7
+ provideDefinition(model: TextModel, position: Position): Definition;
8
+ }
@@ -0,0 +1,6 @@
1
+ import { default as DBMLCompletionItemProvider } from './suggestions/provider';
2
+ import { default as DBMLDefinitionProvider } from './definition/provider';
3
+ import { default as DBMLReferencesProvider } from './references/provider';
4
+
5
+ export * from './types';
6
+ export { DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLReferencesProvider, };
@@ -0,0 +1,8 @@
1
+ import { default as Compiler } from '../../compiler';
2
+ import { Location, ReferenceProvider, TextModel, Position } from '../types';
3
+
4
+ export default class DBMLReferencesProvider implements ReferenceProvider {
5
+ private compiler;
6
+ constructor(compiler: Compiler);
7
+ provideReferences(model: TextModel, position: Position): Location[];
8
+ }
@@ -0,0 +1,9 @@
1
+ import { default as Compiler } from '../../compiler';
2
+ import { CompletionList, TextModel, CompletionItemProvider, Position } from '../types';
3
+
4
+ export default class DBMLCompletionItemProvider implements CompletionItemProvider {
5
+ private compiler;
6
+ triggerCharacters: string[];
7
+ constructor(compiler: Compiler, triggerCharacters?: string[]);
8
+ provideCompletionItems(model: TextModel, position: Position): CompletionList;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { SymbolKind } from '../../lib/analyzer/symbol/symbolIndex';
2
+ import { CompletionItemKind, CompletionList } from '../types';
3
+ import { SyntaxToken } from '../../lib/lexer/tokens';
4
+
5
+ export declare function pickCompletionItemKind(symbolKind: SymbolKind): CompletionItemKind;
6
+ export declare function shouldPrependSpace(token: SyntaxToken | undefined, offset: number): boolean;
7
+ export declare function noSuggestions(): CompletionList;
8
+ export declare function prependSpace(completionList: CompletionList): CompletionList;
9
+ export declare function addQuoteIfNeeded(completionList: CompletionList): CompletionList;
@@ -0,0 +1,60 @@
1
+ import { Position as IPosition, editor, languages, IRange, IDisposable, CancellationToken as ICancellationToken } from 'monaco-editor-core';
2
+
3
+ export type Position = IPosition;
4
+ export type TextModel = editor.ITextModel;
5
+ export type ProviderResult<T> = languages.ProviderResult<T>;
6
+ export type Range = IRange;
7
+ export type Location = languages.Location;
8
+ export type Disposable = IDisposable;
9
+ export type CompletionContext = languages.CompletionContext;
10
+ export type CancellationToken = ICancellationToken;
11
+ export interface CompletionItemProvider {
12
+ triggerCharacters?: string[];
13
+ provideCompletionItems(model: TextModel, position: Position, context: CompletionContext, token: CancellationToken): ProviderResult<CompletionList>;
14
+ resolveCompletionItem?(item: CompletionItem, token: CancellationToken): ProviderResult<CompletionItem>;
15
+ }
16
+ export type CompletionItem = languages.CompletionItem;
17
+ export type CompletionList = languages.CompletionList;
18
+ export declare enum CompletionItemKind {
19
+ Function = 1,
20
+ Constructor = 2,
21
+ Field = 3,
22
+ Variable = 4,
23
+ Class = 5,
24
+ Struct = 6,
25
+ Interface = 7,
26
+ Module = 8,
27
+ Property = 9,
28
+ Event = 10,
29
+ Operator = 11,
30
+ Unit = 12,
31
+ Value = 13,
32
+ Constant = 14,
33
+ Enum = 15,
34
+ EnumMember = 16,
35
+ Keyword = 17,
36
+ Text = 18,
37
+ Color = 19,
38
+ File = 20,
39
+ Reference = 21,
40
+ Customcolor = 22,
41
+ Folder = 23,
42
+ TypeParameter = 24,
43
+ User = 25,
44
+ Issue = 26,
45
+ Snippet = 27
46
+ }
47
+ export declare enum CompletionItemInsertTextRule {
48
+ None = 0,
49
+ KeepWhitespace = 1,
50
+ InsertAsSnippet = 4
51
+ }
52
+ export type DocumentColorProvider = languages.DocumentColorProvider;
53
+ export type ColorInformation = languages.IColorInformation;
54
+ export type ColorPresentation = languages.IColorPresentation;
55
+ export type Color = languages.IColor;
56
+ export type DefinitionProvider = languages.DefinitionProvider;
57
+ export type Definition = languages.Definition;
58
+ export type CodeActionList = languages.CodeActionList;
59
+ export type SignatureHelpResult = languages.SignatureHelpResult;
60
+ export type ReferenceProvider = languages.ReferenceProvider;
@@ -0,0 +1,3 @@
1
+ import { TextModel, Position } from './types';
2
+
3
+ export declare function getOffsetFromMonacoPosition(model: TextModel, position: Position): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbml/parse",
3
- "version": "3.6.1",
3
+ "version": "3.6.2",
4
4
  "description": "> TODO: description",
5
5
  "author": "Holistics <dev@holistics.io>",
6
6
  "license": "Apache-2.0",
@@ -12,6 +12,7 @@
12
12
  ],
13
13
  "main": "./dist/dbml-parse.js",
14
14
  "module": "./dist/dbml-parse.mjs",
15
+ "types": "./dist/index.d.ts",
15
16
  "exports": {
16
17
  ".": {
17
18
  "import": "./dist/dbml-parse.mjs",
@@ -22,7 +23,7 @@
22
23
  "dist"
23
24
  ],
24
25
  "scripts": {
25
- "build": "vite build",
26
+ "build": "tsc --noEmit && vite build",
26
27
  "dev": "vite build --watch",
27
28
  "test": "vitest run",
28
29
  "test:watch": "vitest tests",
@@ -37,6 +38,7 @@
37
38
  "typescript": "^5.2.2",
38
39
  "vite": "^4.5.0",
39
40
  "vite-dts": "^1.0.4",
41
+ "vite-plugin-dts": "^3.9.1",
40
42
  "vitest": "^0.34.6"
41
43
  },
42
44
  "dependencies": {
@@ -45,5 +47,5 @@
45
47
  "peerDependencies": {
46
48
  "lodash": "^4.17.21"
47
49
  },
48
- "gitHead": "2d7bc464a2e56cbe1555347c3292456cc2ddc4f7"
50
+ "gitHead": "d3d82a3e8260f733098edc5fbfdbd3f8a381c6e3"
49
51
  }