@gooddata/maql-antlr4ts 0.5.1-b239d365.0 → 0.5.1-bd5837e7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +5 -5
  3. package/esm/antlr/CaseInsensitiveCharStream.d.ts +13 -0
  4. package/esm/antlr/CaseInsensitiveCharStream.js +32 -0
  5. package/esm/antlr/SyntaxErrorListener.d.ts +16 -0
  6. package/esm/antlr/SyntaxErrorListener.js +17 -0
  7. package/esm/ast/AstNode.d.ts +46 -0
  8. package/esm/ast/AstNode.js +42 -0
  9. package/esm/ast/CaseNode.d.ts +28 -0
  10. package/esm/ast/CaseNode.js +46 -0
  11. package/esm/ast/FunctionNode.d.ts +109 -0
  12. package/esm/ast/FunctionNode.js +192 -0
  13. package/esm/ast/IdentifierNode.d.ts +19 -0
  14. package/esm/ast/IdentifierNode.js +24 -0
  15. package/esm/ast/LiteralNode.d.ts +42 -0
  16. package/esm/ast/LiteralNode.js +107 -0
  17. package/esm/ast/OperatorNode.d.ts +11 -0
  18. package/esm/ast/OperatorNode.js +29 -0
  19. package/esm/ast/Range.d.ts +17 -0
  20. package/esm/ast/Range.js +12 -0
  21. package/esm/ast/SelectNode.d.ts +82 -0
  22. package/esm/ast/SelectNode.js +138 -0
  23. package/esm/gen/antlr/MaqlLexer.d.ts +172 -0
  24. package/esm/gen/antlr/MaqlLexer.js +1028 -0
  25. package/esm/gen/antlr/MaqlParser.d.ts +1427 -0
  26. package/{dist/index.js → esm/gen/antlr/MaqlParser.js} +122 -3740
  27. package/esm/gen/antlr/MaqlParserListener.d.ts +1262 -0
  28. package/esm/gen/antlr/MaqlParserListener.js +2 -0
  29. package/esm/gen/antlr/MaqlParserVisitor.d.ts +801 -0
  30. package/esm/gen/antlr/MaqlParserVisitor.js +2 -0
  31. package/esm/gen/type/functions.d.ts +850 -0
  32. package/esm/gen/type/functions.js +1237 -0
  33. package/esm/gen.d.ts +5 -0
  34. package/esm/gen.js +7 -0
  35. package/esm/index.d.ts +14 -0
  36. package/esm/index.js +17 -0
  37. package/esm/visitor/ast/AbstractAstVisitor.d.ts +49 -0
  38. package/esm/visitor/ast/AbstractAstVisitor.js +130 -0
  39. package/esm/visitor/ast/AstNormalizer.d.ts +13 -0
  40. package/esm/visitor/ast/AstNormalizer.js +38 -0
  41. package/esm/visitor/parser/MaqlAstVisitor.d.ts +124 -0
  42. package/esm/visitor/parser/MaqlAstVisitor.js +581 -0
  43. package/package.json +33 -27
  44. package/dist/index.d.ts +0 -4835
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2020-2022 GoodData Corporation
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -86,11 +86,11 @@ This section records how it was set up, so that you can change it or set it up a
86
86
 
87
87
  You can set it up in one of these ways:
88
88
 
89
- - **In the npm UI** at https://www.npmjs.com/package/@gooddata/maql-antlr4ts/access.
90
- - **With the npm CLI.** Use npm 11.10.0 or newer, which has the `npm trust` command.
91
- Log in to npm (`npm login`) as user `gooddata-ci`.
92
- The user must have publish access to `@gooddata/maql-antlr4ts` and two-factor authentication.
93
- Then run:
89
+ - **In the npm UI** at https://www.npmjs.com/package/@gooddata/maql-antlr4ts/access.
90
+ - **With the npm CLI.** Use npm 11.10.0 or newer, which has the `npm trust` command.
91
+ Log in to npm (`npm login`) as user `gooddata-ci`.
92
+ The user must have publish access to `@gooddata/maql-antlr4ts` and two-factor authentication.
93
+ Then run:
94
94
 
95
95
  ```sh
96
96
  npm trust github @gooddata/maql-antlr4ts \
@@ -0,0 +1,13 @@
1
+ import { CodePointCharStream } from "antlr4ts";
2
+ /**
3
+ * ANTLR4 CharStream extension that sees all characters as lowercase
4
+ */
5
+ export declare class CaseInsensitiveCharStream extends CodePointCharStream {
6
+ constructor(s: string, sourceName?: string);
7
+ /**
8
+ * Modified lookahead method.
9
+ * Transform the character to lowercase before passing it to the caller.
10
+ * The input string is not modified.
11
+ */
12
+ LA(i: number): number;
13
+ }
@@ -0,0 +1,32 @@
1
+ // (C) 2022 GoodData Corporation
2
+ import { CodePointBuffer, CodePointCharStream, IntStream } from "antlr4ts";
3
+ /**
4
+ * ANTLR4 CharStream extension that sees all characters as lowercase
5
+ */
6
+ export class CaseInsensitiveCharStream extends CodePointCharStream {
7
+ constructor(s, sourceName) {
8
+ // buffer creation inspired by CharStreams.fromString implementation
9
+ const bufferBuilder = CodePointBuffer.builder(s.length);
10
+ const chars = new Uint16Array(s.length);
11
+ for (let i = 0; i < s.length; i++) {
12
+ // as we are within the string length the result of codePointAt will never be undefined
13
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
14
+ chars[i] = s.codePointAt(i);
15
+ }
16
+ bufferBuilder.append(chars);
17
+ const buffer = bufferBuilder.build();
18
+ super(buffer.array(), buffer.position, buffer.remaining, sourceName ?? IntStream.UNKNOWN_SOURCE_NAME);
19
+ }
20
+ /**
21
+ * Modified lookahead method.
22
+ * Transform the character to lowercase before passing it to the caller.
23
+ * The input string is not modified.
24
+ */
25
+ LA(i) {
26
+ const c = super.LA(i);
27
+ if (c < 0) {
28
+ return c;
29
+ }
30
+ return String.fromCodePoint(c).toLowerCase().codePointAt(0) ?? c;
31
+ }
32
+ }
@@ -0,0 +1,16 @@
1
+ import type { ANTLRErrorListener, Recognizer, Token } from "antlr4ts";
2
+ import type { RecognitionException } from "antlr4ts/RecognitionException.js";
3
+ import type { IPosition } from "../ast/Range.js";
4
+ /**
5
+ * ANTLR error listener that saves encountered errors
6
+ */
7
+ export declare class SyntaxErrorListener implements ANTLRErrorListener<Token> {
8
+ readonly antlrErrors: IAntlrError[];
9
+ syntaxError(_recognizer: Recognizer<Token, any>, offendingToken: Token | undefined, line: number, startCharacter: number, msg: string, error: RecognitionException | undefined): void;
10
+ }
11
+ export interface IAntlrError {
12
+ position: IPosition;
13
+ message: string;
14
+ offendingToken?: Token;
15
+ error?: RecognitionException;
16
+ }
@@ -0,0 +1,17 @@
1
+ // (C) 2022 GoodData Corporation
2
+ /**
3
+ * ANTLR error listener that saves encountered errors
4
+ */
5
+ export class SyntaxErrorListener {
6
+ antlrErrors = [];
7
+ syntaxError(
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ _recognizer, offendingToken, line, startCharacter, msg, error) {
10
+ this.antlrErrors.push({
11
+ position: { line: line - 1, character: startCharacter },
12
+ message: msg,
13
+ offendingToken,
14
+ error,
15
+ });
16
+ }
17
+ }
@@ -0,0 +1,46 @@
1
+ import type { AbstractAstVisitor } from "../visitor/ast/AbstractAstVisitor.js";
2
+ import type { Case, Conditional, Else } from "./CaseNode.js";
3
+ import type { Direction, Image, LastFirstValueFunction, List, MaqlFunction, MetricReference, OrderBy, OrderByElement, RankFunction, RankingFilter, RunningFunction, Window, WindowBound } from "./FunctionNode.js";
4
+ import type { Identifier, ObjectId, ObjectSpace, ObjectType } from "./IdentifierNode.js";
5
+ import type { BooleanLiteral, Granularity, NullLiteral, NumberLiteral, StringLiteral } from "./LiteralNode.js";
6
+ import type { Operator } from "./OperatorNode.js";
7
+ import type { IRange } from "./Range.js";
8
+ import type { By, DatetimeTransformation, DimensionOperator, Expression, Filter, ForEach, ModificationOperator, ParentFilterModification, Select, Using } from "./SelectNode.js";
9
+ /**
10
+ * AST node interface compatible with the AST nodes from the Kotlin implementation of MAQL Parser
11
+ */
12
+ export interface IAstNode {
13
+ readonly type: AstType;
14
+ readonly value: string;
15
+ readonly content: IAstNode[];
16
+ }
17
+ /**
18
+ * Base class for MAQL AST nodes
19
+ */
20
+ export declare class AstNode implements IAstNode {
21
+ readonly type: AstType;
22
+ readonly value: string;
23
+ readonly content: AstNode[];
24
+ /**
25
+ * Range in the original query with only meaningful tokens. Does not overlap with sibling nodes
26
+ */
27
+ range?: IRange;
28
+ /**
29
+ * Range in the original query with meaningful and adjacent tokens e.g. whitespace. May overlap with sibling nodes
30
+ */
31
+ contextRange?: IRange;
32
+ constructor(type?: AstType, value?: string, content?: AstNode[]);
33
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
34
+ }
35
+ export type AstType = Empty | Select | Expression | By | DimensionOperator | DatetimeTransformation | Filter | Using | ParentFilterModification | ModificationOperator | Case | Conditional | Else | MaqlFunction | RunningFunction | Window | WindowBound | RankFunction | Direction | LastFirstValueFunction | OrderBy | OrderByElement | Image | RankingFilter | MetricReference | BooleanLiteral | Identifier | ObjectType | ObjectSpace | ObjectId | NumberLiteral | StringLiteral | NullLiteral | Granularity | Operator | List | ForEach;
36
+ type Empty = "";
37
+ /**
38
+ * Empty node serves as a placeholder or as an error node. It should never appear from a well-formed query
39
+ */
40
+ export declare class EmptyNode extends AstNode {
41
+ type: Empty;
42
+ constructor(value?: string, content?: AstNode[]);
43
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
44
+ }
45
+ export declare function nonNullContent<T extends IAstNode>(...nodes: (T | undefined)[]): T[];
46
+ export {};
@@ -0,0 +1,42 @@
1
+ // (C) 2022 GoodData Corporation
2
+ /**
3
+ * Base class for MAQL AST nodes
4
+ */
5
+ export class AstNode {
6
+ type;
7
+ value;
8
+ content;
9
+ /**
10
+ * Range in the original query with only meaningful tokens. Does not overlap with sibling nodes
11
+ */
12
+ range;
13
+ /**
14
+ * Range in the original query with meaningful and adjacent tokens e.g. whitespace. May overlap with sibling nodes
15
+ */
16
+ contextRange;
17
+ constructor(type = "", value = "", content = []) {
18
+ this.type = type;
19
+ this.value = value;
20
+ this.content = content;
21
+ }
22
+ accept(visitor) {
23
+ return visitor.visitChildren(this);
24
+ }
25
+ }
26
+ /**
27
+ * Empty node serves as a placeholder or as an error node. It should never appear from a well-formed query
28
+ */
29
+ export class EmptyNode extends AstNode {
30
+ type;
31
+ constructor(value, content) {
32
+ const type = "";
33
+ super(type, value, content);
34
+ this.type = type;
35
+ }
36
+ accept(visitor) {
37
+ return visitor.visitEmptyNode(this);
38
+ }
39
+ }
40
+ export function nonNullContent(...nodes) {
41
+ return nodes.filter((node) => node !== undefined);
42
+ }
@@ -0,0 +1,28 @@
1
+ import type { AbstractAstVisitor } from "../visitor/ast/AbstractAstVisitor.js";
2
+ import { AstNode } from "./AstNode.js";
3
+ declare const _caseTypes: readonly ["case"];
4
+ export type Case = (typeof _caseTypes)[number];
5
+ export declare class CaseNode extends AstNode {
6
+ readonly branches: AstNode[];
7
+ readonly elseBranch?: AstNode | undefined;
8
+ type: Case;
9
+ constructor(branches: AstNode[], elseBranch?: AstNode | undefined);
10
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
11
+ }
12
+ declare const _conditionalTypes: readonly ["when"];
13
+ export type Conditional = (typeof _conditionalTypes)[number];
14
+ export declare class ConditionalNode extends AstNode {
15
+ readonly condition: AstNode;
16
+ readonly expression: AstNode;
17
+ type: Conditional;
18
+ constructor(condition: AstNode, expression: AstNode);
19
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
20
+ }
21
+ declare const _elseTypes: readonly ["else"];
22
+ export type Else = (typeof _elseTypes)[number];
23
+ export declare class ElseNode extends AstNode {
24
+ type: Else;
25
+ constructor(expression: AstNode);
26
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
27
+ }
28
+ export {};
@@ -0,0 +1,46 @@
1
+ // (C) 2022 GoodData Corporation
2
+ import { AstNode, nonNullContent } from "./AstNode.js";
3
+ const _caseTypes = ["case"];
4
+ export class CaseNode extends AstNode {
5
+ branches;
6
+ elseBranch;
7
+ type;
8
+ constructor(branches, elseBranch) {
9
+ const type = "case";
10
+ super(type, undefined, nonNullContent(...branches, elseBranch));
11
+ this.branches = branches;
12
+ this.elseBranch = elseBranch;
13
+ this.type = type;
14
+ }
15
+ accept(visitor) {
16
+ return visitor.visitCaseNode(this);
17
+ }
18
+ }
19
+ const _conditionalTypes = ["when"];
20
+ export class ConditionalNode extends AstNode {
21
+ condition;
22
+ expression;
23
+ type;
24
+ constructor(condition, expression) {
25
+ const type = "when";
26
+ super(type, undefined, nonNullContent(condition, expression));
27
+ this.condition = condition;
28
+ this.expression = expression;
29
+ this.type = type;
30
+ }
31
+ accept(visitor) {
32
+ return visitor.visitConditionalNode(this);
33
+ }
34
+ }
35
+ const _elseTypes = ["else"];
36
+ export class ElseNode extends AstNode {
37
+ type;
38
+ constructor(expression) {
39
+ const type = "else";
40
+ super(type, undefined, [expression]);
41
+ this.type = type;
42
+ }
43
+ accept(visitor) {
44
+ return visitor.visitElseNode(this);
45
+ }
46
+ }
@@ -0,0 +1,109 @@
1
+ import type { AbstractAstVisitor } from "../visitor/ast/AbstractAstVisitor.js";
2
+ import { AstNode } from "./AstNode.js";
3
+ declare const functionTypes: readonly ["function", "time macro"];
4
+ export type MaqlFunction = (typeof functionTypes)[number];
5
+ export declare function isMaqlFunction(type: string): type is MaqlFunction;
6
+ export declare class FunctionNode extends AstNode {
7
+ readonly name: string;
8
+ type: MaqlFunction;
9
+ constructor(type: MaqlFunction, name: string, operands: AstNode[]);
10
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
11
+ }
12
+ declare const _runningFunctionTypes: readonly ["running function"];
13
+ export type RunningFunction = (typeof _runningFunctionTypes)[number];
14
+ export declare class RunningFunctionNode extends AstNode {
15
+ readonly within?: AstNode | undefined;
16
+ readonly rollWindow?: AstNode | undefined;
17
+ type: RunningFunction;
18
+ readonly functionNode: FunctionNode;
19
+ constructor(name: string, operand: AstNode, within?: AstNode | undefined, rollWindow?: AstNode | undefined);
20
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
21
+ }
22
+ declare const _windowTypes: readonly ["window"];
23
+ export type Window = (typeof _windowTypes)[number];
24
+ export declare class WindowNode extends AstNode {
25
+ type: Window;
26
+ constructor(bounds: AstNode[]);
27
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
28
+ }
29
+ declare const windowBoundTypes: readonly ["preceding", "following", "current"];
30
+ export type WindowBound = (typeof windowBoundTypes)[number];
31
+ export declare function isWindowBound(type: string): type is WindowBound;
32
+ export declare class WindowBoundNode extends AstNode {
33
+ type: WindowBound;
34
+ constructor(type: WindowBound, value?: "unbounded" | string);
35
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
36
+ }
37
+ declare const _rankFunctionTypes: readonly ["rank function"];
38
+ export type RankFunction = (typeof _rankFunctionTypes)[number];
39
+ export declare class RankFunctionNode extends AstNode {
40
+ readonly within?: AstNode | undefined;
41
+ type: RankFunction;
42
+ readonly functionNode: FunctionNode;
43
+ constructor(name: string, operands: AstNode[], rankDir?: string, within?: AstNode | undefined);
44
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
45
+ }
46
+ declare const _directionTypes: readonly ["direction"];
47
+ export type Direction = (typeof _directionTypes)[number];
48
+ export declare class DirectionNode extends AstNode {
49
+ type: Direction;
50
+ constructor(direction: string);
51
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
52
+ }
53
+ declare const _lastFirstValueFunctionTypes: readonly ["lastfirstvalue function"];
54
+ export type LastFirstValueFunction = (typeof _lastFirstValueFunctionTypes)[number];
55
+ export declare class LastFirstValueFunctionNode extends AstNode {
56
+ readonly orderBy: AstNode;
57
+ readonly within?: AstNode | undefined;
58
+ type: LastFirstValueFunction;
59
+ readonly functionNode: FunctionNode;
60
+ constructor(name: string, operands: AstNode[], orderBy: AstNode, within?: AstNode | undefined);
61
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
62
+ }
63
+ declare const _orderByTypes: readonly ["order by"];
64
+ export type OrderBy = (typeof _orderByTypes)[number];
65
+ export declare class OrderByNode extends AstNode {
66
+ type: OrderBy;
67
+ constructor(operands: AstNode[]);
68
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
69
+ }
70
+ declare const _orderByElementTypes: readonly ["order by element"];
71
+ export type OrderByElement = (typeof _orderByElementTypes)[number];
72
+ export declare class OrderByElementNode extends AstNode {
73
+ type: OrderByElement;
74
+ constructor(operand: AstNode, rankDir?: string);
75
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
76
+ }
77
+ declare const _metricReferenceTypes: readonly ["report metric"];
78
+ export type MetricReference = (typeof _metricReferenceTypes)[number];
79
+ export declare class MetricReferenceNode extends AstNode {
80
+ type: MetricReference;
81
+ constructor(operand: AstNode);
82
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
83
+ }
84
+ declare const _listTypes: readonly ["list", "()", "of"];
85
+ export type List = (typeof _listTypes)[number];
86
+ export declare class ListNode extends AstNode {
87
+ type: List;
88
+ constructor(type: List, operands: AstNode[]);
89
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
90
+ }
91
+ declare const _imageTypes: readonly ["image"];
92
+ export type Image = (typeof _imageTypes)[number];
93
+ export declare class ImageNode extends AstNode {
94
+ type: Image;
95
+ constructor(expression: AstNode, mapping: AstNode[]);
96
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
97
+ }
98
+ declare const rankingFilterTypes: readonly ["top", "bottom"];
99
+ export type RankingFilter = (typeof rankingFilterTypes)[number];
100
+ export declare function isRankingFilter(type: string): type is RankingFilter;
101
+ export declare class RankingFilterNode extends AstNode {
102
+ readonly rankSpec: AstNode;
103
+ readonly operands: AstNode[];
104
+ readonly within?: AstNode | undefined;
105
+ type: RankingFilter;
106
+ constructor(type: RankingFilter, rankSpec: AstNode, operands: AstNode[], within?: AstNode | undefined);
107
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
108
+ }
109
+ export {};
@@ -0,0 +1,192 @@
1
+ // (C) 2022 GoodData Corporation
2
+ import { AstNode, nonNullContent } from "./AstNode.js";
3
+ const functionTypes = ["function", "time macro"];
4
+ export function isMaqlFunction(type) {
5
+ return functionTypes.includes(type);
6
+ }
7
+ export class FunctionNode extends AstNode {
8
+ name;
9
+ type;
10
+ constructor(type, name, operands) {
11
+ super(type, name, operands);
12
+ this.name = name;
13
+ this.type = type;
14
+ }
15
+ accept(visitor) {
16
+ return visitor.visitFunctionNode(this);
17
+ }
18
+ }
19
+ const _runningFunctionTypes = ["running function"];
20
+ export class RunningFunctionNode extends AstNode {
21
+ within;
22
+ rollWindow;
23
+ type;
24
+ functionNode;
25
+ constructor(name, operand, within, rollWindow) {
26
+ const type = "running function";
27
+ const functionNode = new FunctionNode("function", name, [operand]);
28
+ super(type, undefined, nonNullContent(functionNode, within, rollWindow));
29
+ this.within = within;
30
+ this.rollWindow = rollWindow;
31
+ this.type = type;
32
+ this.functionNode = functionNode;
33
+ }
34
+ accept(visitor) {
35
+ return visitor.visitRunningFunctionNode(this);
36
+ }
37
+ }
38
+ const _windowTypes = ["window"];
39
+ export class WindowNode extends AstNode {
40
+ type;
41
+ constructor(bounds) {
42
+ const type = "window";
43
+ super(type, undefined, bounds);
44
+ this.type = type;
45
+ }
46
+ accept(visitor) {
47
+ return visitor.visitWindowNode(this);
48
+ }
49
+ }
50
+ const windowBoundTypes = ["preceding", "following", "current"];
51
+ export function isWindowBound(type) {
52
+ return windowBoundTypes.includes(type);
53
+ }
54
+ export class WindowBoundNode extends AstNode {
55
+ type;
56
+ constructor(type, value) {
57
+ super(type, value);
58
+ this.type = type;
59
+ }
60
+ accept(visitor) {
61
+ return visitor.visitWindowBoundNode(this);
62
+ }
63
+ }
64
+ const _rankFunctionTypes = ["rank function"];
65
+ export class RankFunctionNode extends AstNode {
66
+ within;
67
+ type;
68
+ functionNode;
69
+ constructor(name, operands, rankDir, within) {
70
+ const type = "rank function";
71
+ const functionNode = new FunctionNode("function", name, operands);
72
+ const directionNode = rankDir ? new DirectionNode(rankDir) : undefined;
73
+ super(type, undefined, nonNullContent(functionNode, directionNode, within));
74
+ this.within = within;
75
+ this.type = type;
76
+ this.functionNode = functionNode;
77
+ }
78
+ accept(visitor) {
79
+ return visitor.visitRankFunctionNode(this);
80
+ }
81
+ }
82
+ const _directionTypes = ["direction"];
83
+ export class DirectionNode extends AstNode {
84
+ type;
85
+ constructor(direction) {
86
+ const type = "direction";
87
+ super(type, direction);
88
+ this.type = type;
89
+ }
90
+ accept(visitor) {
91
+ return visitor.visitDirectionNode(this);
92
+ }
93
+ }
94
+ const _lastFirstValueFunctionTypes = ["lastfirstvalue function"];
95
+ export class LastFirstValueFunctionNode extends AstNode {
96
+ orderBy;
97
+ within;
98
+ type;
99
+ functionNode;
100
+ constructor(name, operands, orderBy, within) {
101
+ const type = "lastfirstvalue function";
102
+ const functionNode = new FunctionNode("function", name, operands);
103
+ super(type, undefined, nonNullContent(functionNode, orderBy, within));
104
+ this.orderBy = orderBy;
105
+ this.within = within;
106
+ this.type = type;
107
+ this.functionNode = functionNode;
108
+ }
109
+ accept(visitor) {
110
+ return visitor.visitLastFirstValueFunctionNode(this);
111
+ }
112
+ }
113
+ const _orderByTypes = ["order by"];
114
+ export class OrderByNode extends AstNode {
115
+ type;
116
+ constructor(operands) {
117
+ const type = "order by";
118
+ super(type, undefined, operands);
119
+ this.type = type;
120
+ }
121
+ accept(visitor) {
122
+ return visitor.visitOrderBy(this);
123
+ }
124
+ }
125
+ const _orderByElementTypes = ["order by element"];
126
+ export class OrderByElementNode extends AstNode {
127
+ type;
128
+ constructor(operand, rankDir) {
129
+ const type = "order by element";
130
+ const directionNode = rankDir ? new DirectionNode(rankDir) : undefined;
131
+ super(type, undefined, nonNullContent(operand, directionNode));
132
+ this.type = type;
133
+ }
134
+ accept(visitor) {
135
+ return visitor.visitOrderByElement(this);
136
+ }
137
+ }
138
+ const _metricReferenceTypes = ["report metric"];
139
+ export class MetricReferenceNode extends AstNode {
140
+ type;
141
+ constructor(operand) {
142
+ const type = "report metric";
143
+ super(type, undefined, [operand]);
144
+ this.type = type;
145
+ }
146
+ accept(visitor) {
147
+ return visitor.visitMetricReferenceNode(this);
148
+ }
149
+ }
150
+ const _listTypes = ["list", "()", "of"];
151
+ export class ListNode extends AstNode {
152
+ type;
153
+ constructor(type, operands) {
154
+ super(type, undefined, operands);
155
+ this.type = type;
156
+ }
157
+ accept(visitor) {
158
+ return visitor.visitListNode(this);
159
+ }
160
+ }
161
+ const _imageTypes = ["image"];
162
+ export class ImageNode extends AstNode {
163
+ type;
164
+ constructor(expression, mapping) {
165
+ const type = "image";
166
+ super(type, undefined, nonNullContent(expression, ...mapping));
167
+ this.type = type;
168
+ }
169
+ accept(visitor) {
170
+ return visitor.visitImageNode(this);
171
+ }
172
+ }
173
+ const rankingFilterTypes = ["top", "bottom"];
174
+ export function isRankingFilter(type) {
175
+ return rankingFilterTypes.includes(type);
176
+ }
177
+ export class RankingFilterNode extends AstNode {
178
+ rankSpec;
179
+ operands;
180
+ within;
181
+ type;
182
+ constructor(type, rankSpec, operands, within) {
183
+ super(type, undefined, nonNullContent(rankSpec, ...operands, within));
184
+ this.rankSpec = rankSpec;
185
+ this.operands = operands;
186
+ this.within = within;
187
+ this.type = type;
188
+ }
189
+ accept(visitor) {
190
+ return visitor.visitRankingFilterNode(this);
191
+ }
192
+ }
@@ -0,0 +1,19 @@
1
+ import type { AbstractAstVisitor } from "../visitor/ast/AbstractAstVisitor.js";
2
+ import { AstNode } from "./AstNode.js";
3
+ declare const _identifierTypes: readonly ["identifier", "raw identifier"];
4
+ export type Identifier = (typeof _identifierTypes)[number];
5
+ declare const _objectTypeTypes: readonly ["type"];
6
+ export type ObjectType = (typeof _objectTypeTypes)[number];
7
+ declare const _objectIdTypes: readonly ["id"];
8
+ export type ObjectId = (typeof _objectIdTypes)[number];
9
+ declare const _objectSpaceTypes: readonly ["space"];
10
+ export type ObjectSpace = (typeof _objectSpaceTypes)[number];
11
+ export declare class IdentifierNode extends AstNode {
12
+ readonly objectType: string;
13
+ readonly id: string;
14
+ readonly space?: string | undefined;
15
+ type: Identifier;
16
+ constructor(type: Identifier, objectType: string, id: string, space?: string | undefined);
17
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
18
+ }
19
+ export {};
@@ -0,0 +1,24 @@
1
+ // (C) 2022 GoodData Corporation
2
+ import { AstNode, nonNullContent } from "./AstNode.js";
3
+ const _identifierTypes = ["identifier", "raw identifier"];
4
+ const _objectTypeTypes = ["type"];
5
+ const _objectIdTypes = ["id"];
6
+ const _objectSpaceTypes = ["space"];
7
+ export class IdentifierNode extends AstNode {
8
+ objectType;
9
+ id;
10
+ space;
11
+ type;
12
+ constructor(type, objectType, id, space) {
13
+ const typeNode = new AstNode("type", objectType);
14
+ const idNode = new AstNode("id", id);
15
+ super(type, undefined, nonNullContent(typeNode, idNode));
16
+ this.objectType = objectType;
17
+ this.id = id;
18
+ this.space = space;
19
+ this.type = type;
20
+ }
21
+ accept(visitor) {
22
+ return visitor.visitIdentifierNode(this);
23
+ }
24
+ }
@@ -0,0 +1,42 @@
1
+ import type { AbstractAstVisitor } from "../visitor/ast/AbstractAstVisitor.js";
2
+ import { AstNode } from "./AstNode.js";
3
+ declare const _booleanLiteralTypes: readonly ["true", "false"];
4
+ export type BooleanLiteral = (typeof _booleanLiteralTypes)[number];
5
+ export declare class BooleanLiteralNode extends AstNode {
6
+ type: BooleanLiteral;
7
+ constructor(type: BooleanLiteral);
8
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
9
+ }
10
+ declare const _numberLiteralTypes: readonly ["number", "percentage", "count"];
11
+ export type NumberLiteral = (typeof _numberLiteralTypes)[number];
12
+ export type NumberLiteralFormat = "float" | "integer";
13
+ export declare class NumberLiteralNode extends AstNode {
14
+ readonly format: NumberLiteralFormat;
15
+ type: NumberLiteral;
16
+ constructor(type: NumberLiteral, value: string, format?: NumberLiteralFormat);
17
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
18
+ }
19
+ declare const _stringLiteralTypes: readonly ["string"];
20
+ export type StringLiteral = (typeof _stringLiteralTypes)[number];
21
+ export declare class StringLiteralNode extends AstNode {
22
+ type: StringLiteral;
23
+ constructor(rawString: string);
24
+ static fromUnterminated(rawUnterminatedString: string): StringLiteralNode;
25
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
26
+ }
27
+ export declare function escapeString(string: string, surroundChar?: string): string;
28
+ declare const _nullLiteralTypes: readonly ["null"];
29
+ export type NullLiteral = (typeof _nullLiteralTypes)[number];
30
+ export declare class NullLiteralNode extends AstNode {
31
+ type: NullLiteral;
32
+ constructor();
33
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
34
+ }
35
+ declare const _granularityTypes: readonly ["granularity"];
36
+ export type Granularity = (typeof _granularityTypes)[number];
37
+ export declare class GranularityNode extends AstNode {
38
+ type: Granularity;
39
+ constructor(value: string);
40
+ accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
41
+ }
42
+ export {};