@malloydata/malloy 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.
Files changed (104) hide show
  1. package/README.md +39 -0
  2. package/dist/connection_utils.d.ts +1 -0
  3. package/dist/connection_utils.js +56 -0
  4. package/dist/dialect/dialect-map.d.ts +3 -0
  5. package/dist/dialect/dialect-map.js +33 -0
  6. package/dist/dialect/dialect.d.ts +64 -0
  7. package/dist/dialect/dialect.js +64 -0
  8. package/dist/dialect/dialect_map.d.ts +3 -0
  9. package/dist/dialect/dialect_map.js +35 -0
  10. package/dist/dialect/duckdb.d.ts +49 -0
  11. package/dist/dialect/duckdb.js +349 -0
  12. package/dist/dialect/index.d.ts +6 -0
  13. package/dist/dialect/index.js +27 -0
  14. package/dist/dialect/postgres.d.ts +49 -0
  15. package/dist/dialect/postgres.js +308 -0
  16. package/dist/dialect/standardsql.d.ts +46 -0
  17. package/dist/dialect/standardsql.js +361 -0
  18. package/dist/index.d.ts +9 -0
  19. package/dist/index.js +47 -0
  20. package/dist/lang/ast/apply-expr.d.ts +16 -0
  21. package/dist/lang/ast/apply-expr.js +215 -0
  22. package/dist/lang/ast/ast-expr.d.ts +291 -0
  23. package/dist/lang/ast/ast-expr.js +1056 -0
  24. package/dist/lang/ast/ast-main.d.ts +480 -0
  25. package/dist/lang/ast/ast-main.js +2096 -0
  26. package/dist/lang/ast/ast-time-expr.d.ts +109 -0
  27. package/dist/lang/ast/ast-time-expr.js +550 -0
  28. package/dist/lang/ast/ast-types.d.ts +83 -0
  29. package/dist/lang/ast/ast-types.js +215 -0
  30. package/dist/lang/ast/index.d.ts +5 -0
  31. package/dist/lang/ast/index.js +34 -0
  32. package/dist/lang/ast/time-utils.d.ts +8 -0
  33. package/dist/lang/ast/time-utils.js +83 -0
  34. package/dist/lang/field-space.d.ts +157 -0
  35. package/dist/lang/field-space.js +651 -0
  36. package/dist/lang/field-utils.d.ts +5 -0
  37. package/dist/lang/field-utils.js +33 -0
  38. package/dist/lang/index.d.ts +9 -0
  39. package/dist/lang/index.js +22 -0
  40. package/dist/lang/lib/Malloy/MalloyLexer.d.ts +156 -0
  41. package/dist/lang/lib/Malloy/MalloyLexer.js +1163 -0
  42. package/dist/lang/lib/Malloy/MalloyListener.d.ts +2026 -0
  43. package/dist/lang/lib/Malloy/MalloyListener.js +4 -0
  44. package/dist/lang/lib/Malloy/MalloyParser.d.ts +1920 -0
  45. package/dist/lang/lib/Malloy/MalloyParser.js +11790 -0
  46. package/dist/lang/lib/Malloy/MalloyVisitor.d.ts +1276 -0
  47. package/dist/lang/lib/Malloy/MalloyVisitor.js +4 -0
  48. package/dist/lang/parse-log.d.ts +27 -0
  49. package/dist/lang/parse-log.js +41 -0
  50. package/dist/lang/parse-malloy.d.ts +245 -0
  51. package/dist/lang/parse-malloy.js +729 -0
  52. package/dist/lang/parse-to-ast.d.ts +156 -0
  53. package/dist/lang/parse-to-ast.js +945 -0
  54. package/dist/lang/parse-tree-walkers/document-completion-walker.d.ts +10 -0
  55. package/dist/lang/parse-tree-walkers/document-completion-walker.js +136 -0
  56. package/dist/lang/parse-tree-walkers/document-help-context-walker.d.ts +9 -0
  57. package/dist/lang/parse-tree-walkers/document-help-context-walker.js +97 -0
  58. package/dist/lang/parse-tree-walkers/document-highlight-walker.d.ts +83 -0
  59. package/dist/lang/parse-tree-walkers/document-highlight-walker.js +375 -0
  60. package/dist/lang/parse-tree-walkers/document-symbol-walker.d.ts +11 -0
  61. package/dist/lang/parse-tree-walkers/document-symbol-walker.js +172 -0
  62. package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +34 -0
  63. package/dist/lang/parse-tree-walkers/explore-query-walker.js +64 -0
  64. package/dist/lang/parse-tree-walkers/find-external-references.d.ts +11 -0
  65. package/dist/lang/parse-tree-walkers/find-external-references.js +51 -0
  66. package/dist/lang/reference-list.d.ts +10 -0
  67. package/dist/lang/reference-list.js +80 -0
  68. package/dist/lang/space-field.d.ts +119 -0
  69. package/dist/lang/space-field.js +339 -0
  70. package/dist/lang/test/document-help-context-walker.spec.d.ts +1 -0
  71. package/dist/lang/test/document-help-context-walker.spec.js +45 -0
  72. package/dist/lang/test/document-symbol-walker.spec.d.ts +1 -0
  73. package/dist/lang/test/document-symbol-walker.spec.js +100 -0
  74. package/dist/lang/test/field-symbols.spec.d.ts +1 -0
  75. package/dist/lang/test/field-symbols.spec.js +172 -0
  76. package/dist/lang/test/parse.spec.d.ts +12 -0
  77. package/dist/lang/test/parse.spec.js +1936 -0
  78. package/dist/lang/test/test-translator.d.ts +38 -0
  79. package/dist/lang/test/test-translator.js +334 -0
  80. package/dist/lang/zone.d.ts +57 -0
  81. package/dist/lang/zone.js +97 -0
  82. package/dist/malloy.d.ts +1134 -0
  83. package/dist/malloy.js +2354 -0
  84. package/dist/model/index.d.ts +2 -0
  85. package/dist/model/index.js +34 -0
  86. package/dist/model/malloy-query.d.ts +313 -0
  87. package/dist/model/malloy-query.js +2603 -0
  88. package/dist/model/malloy-types.d.ts +404 -0
  89. package/dist/model/malloy-types.js +242 -0
  90. package/dist/model/malloy_query.d.ts +353 -0
  91. package/dist/model/malloy_query.js +2990 -0
  92. package/dist/model/malloy_types.d.ts +502 -0
  93. package/dist/model/malloy_types.js +283 -0
  94. package/dist/model/sql-block.d.ts +11 -0
  95. package/dist/model/sql-block.js +38 -0
  96. package/dist/model/sql_block.d.ts +11 -0
  97. package/dist/model/sql_block.js +41 -0
  98. package/dist/model/utils.d.ts +21 -0
  99. package/dist/model/utils.js +84 -0
  100. package/dist/runtime-types.d.ts +116 -0
  101. package/dist/runtime-types.js +40 -0
  102. package/dist/runtime_types.d.ts +119 -0
  103. package/dist/runtime_types.js +15 -0
  104. package/package.json +36 -0
@@ -0,0 +1,10 @@
1
+ import { CommonTokenStream } from "antlr4ts";
2
+ import { ParseTree } from "antlr4ts/tree";
3
+ export interface DocumentCompletion {
4
+ type: string;
5
+ text: string;
6
+ }
7
+ export declare function walkForDocumentCompletions(tokens: CommonTokenStream, parseTree: ParseTree, position: {
8
+ line: number;
9
+ character: number;
10
+ }): DocumentCompletion[];
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * version 2 as published by the Free Software Foundation.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.walkForDocumentCompletions = void 0;
16
+ const ParseTreeWalker_1 = require("antlr4ts/tree/ParseTreeWalker");
17
+ const EXPLORE_PROPERTIES = [
18
+ "dimension",
19
+ "measure",
20
+ "join_one",
21
+ "join_many",
22
+ "join_cross",
23
+ "where",
24
+ "primary_key",
25
+ "rename",
26
+ "accept",
27
+ "except",
28
+ "query",
29
+ ];
30
+ const QUERY_PROPERTIES = [
31
+ "group_by",
32
+ "project",
33
+ "index",
34
+ "aggregate",
35
+ "top",
36
+ "limit",
37
+ "order_by",
38
+ "where",
39
+ "having",
40
+ "nest",
41
+ ];
42
+ const MODEL_PROPERTIES = ["source", "explore", "query", "sql"];
43
+ class DocumentCompletionWalker {
44
+ constructor(tokens, completions, position) {
45
+ this.tokens = tokens;
46
+ this.completions = completions;
47
+ this.position = position;
48
+ }
49
+ rangeOf(pcx) {
50
+ const stopToken = pcx.stop || pcx.start;
51
+ return {
52
+ start: {
53
+ line: pcx.start.line - 1,
54
+ character: pcx.start.charPositionInLine,
55
+ },
56
+ end: {
57
+ line: stopToken.line - 1,
58
+ character: stopToken.stopIndex -
59
+ (stopToken.startIndex - stopToken.charPositionInLine) +
60
+ 1,
61
+ },
62
+ };
63
+ }
64
+ inRange(range) {
65
+ const { start, end } = range;
66
+ const afterStart = this.position.line > start.line ||
67
+ (this.position.line === start.line &&
68
+ this.position.character >= start.character);
69
+ const beforeEnd = this.position.line < end.line ||
70
+ (this.position.line === end.line &&
71
+ this.position.character <= end.character);
72
+ return afterStart && beforeEnd;
73
+ }
74
+ enterExploreProperties(ctx) {
75
+ if (this.inRange(this.rangeOf(ctx))) {
76
+ let insideStatement = false;
77
+ for (const exploreStatementContext of ctx.exploreStatement()) {
78
+ if (this.inRange(this.rangeOf(exploreStatementContext))) {
79
+ insideStatement = true;
80
+ }
81
+ }
82
+ if (!insideStatement) {
83
+ for (const property of EXPLORE_PROPERTIES) {
84
+ this.completions.push({
85
+ type: "explore_property",
86
+ text: `${property}: `,
87
+ });
88
+ }
89
+ }
90
+ }
91
+ }
92
+ enterQueryProperties(ctx) {
93
+ if (this.inRange(this.rangeOf(ctx))) {
94
+ let insideStatement = false;
95
+ for (const exploreStatementContext of ctx.queryStatement()) {
96
+ if (this.inRange(this.rangeOf(exploreStatementContext))) {
97
+ insideStatement = true;
98
+ }
99
+ }
100
+ if (!insideStatement) {
101
+ for (const property of QUERY_PROPERTIES) {
102
+ this.completions.push({
103
+ type: "query_property",
104
+ text: `${property}: `,
105
+ });
106
+ }
107
+ }
108
+ }
109
+ }
110
+ enterMalloyDocument(ctx) {
111
+ if (this.inRange(this.rangeOf(ctx))) {
112
+ let insideStatement = false;
113
+ for (const modelStatementContext of ctx.malloyStatement()) {
114
+ if (this.inRange(this.rangeOf(modelStatementContext))) {
115
+ insideStatement = true;
116
+ }
117
+ }
118
+ if (!insideStatement) {
119
+ for (const property of MODEL_PROPERTIES) {
120
+ this.completions.push({
121
+ type: "model_property",
122
+ text: `${property}: `,
123
+ });
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
129
+ function walkForDocumentCompletions(tokens, parseTree, position) {
130
+ const finder = new DocumentCompletionWalker(tokens, [], position);
131
+ const listener = finder;
132
+ ParseTreeWalker_1.ParseTreeWalker.DEFAULT.walk(listener, parseTree);
133
+ return finder.completions;
134
+ }
135
+ exports.walkForDocumentCompletions = walkForDocumentCompletions;
136
+ //# sourceMappingURL=document-completion-walker.js.map
@@ -0,0 +1,9 @@
1
+ import { ParseTree } from "antlr4ts/tree";
2
+ export interface DocumentHelpContext {
3
+ type: string;
4
+ token: string | undefined;
5
+ }
6
+ export declare function walkForDocumentHelpContext(parseTree: ParseTree, position: {
7
+ line: number;
8
+ character: number;
9
+ }): DocumentHelpContext | undefined;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * version 2 as published by the Free Software Foundation.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.walkForDocumentHelpContext = void 0;
16
+ const tree_1 = require("antlr4ts/tree");
17
+ class HelpContextVisitor extends tree_1.AbstractParseTreeVisitor {
18
+ constructor(position) {
19
+ super();
20
+ this.position = position;
21
+ this.type = "";
22
+ }
23
+ rangeOf(ctx) {
24
+ const stopToken = ctx.stop || ctx.start;
25
+ return {
26
+ start: {
27
+ line: ctx.start.line - 1,
28
+ character: ctx.start.charPositionInLine,
29
+ },
30
+ end: {
31
+ line: stopToken.line - 1,
32
+ character: stopToken.stopIndex -
33
+ (stopToken.startIndex - stopToken.charPositionInLine) +
34
+ 1,
35
+ },
36
+ };
37
+ }
38
+ inRange(range) {
39
+ return (range.start.line <= this.position.line &&
40
+ range.end.line >= this.position.line &&
41
+ (this.position.line !== range.start.line ||
42
+ this.position.character >= range.start.character) &&
43
+ (this.position.line !== range.end.line ||
44
+ this.position.character <= range.end.character));
45
+ }
46
+ defaultResult() {
47
+ return undefined;
48
+ }
49
+ visitChildren(ctx) {
50
+ let result = this.defaultResult();
51
+ if (this.inRange(this.rangeOf(ctx))) {
52
+ result = {
53
+ type: this.type,
54
+ token: ctx.start.text,
55
+ };
56
+ const n = ctx.childCount;
57
+ for (let i = 0; i < n; i++) {
58
+ const c = ctx.getChild(i);
59
+ const childResult = c.accept(this);
60
+ if (childResult) {
61
+ result = this.aggregateResult(result, childResult);
62
+ }
63
+ }
64
+ }
65
+ return result;
66
+ }
67
+ visitMalloyDocument(ctx) {
68
+ if (this.inRange(this.rangeOf(ctx))) {
69
+ this.type = "model_property";
70
+ return this.visitChildren(ctx);
71
+ }
72
+ return this.defaultResult();
73
+ }
74
+ visitExploreProperties(ctx) {
75
+ if (this.inRange(this.rangeOf(ctx))) {
76
+ this.type = "explore_property";
77
+ return this.visitChildren(ctx);
78
+ }
79
+ return this.defaultResult();
80
+ }
81
+ visitQueryProperties(ctx) {
82
+ if (this.inRange(this.rangeOf(ctx))) {
83
+ this.type = "query_property";
84
+ return this.visitChildren(ctx);
85
+ }
86
+ return this.defaultResult();
87
+ }
88
+ aggregateResult(aggregate, nextResult) {
89
+ return nextResult;
90
+ }
91
+ }
92
+ function walkForDocumentHelpContext(parseTree, position) {
93
+ const visitor = new HelpContextVisitor(position);
94
+ return visitor.visit(parseTree);
95
+ }
96
+ exports.walkForDocumentHelpContext = walkForDocumentHelpContext;
97
+ //# sourceMappingURL=document-help-context-walker.js.map
@@ -0,0 +1,83 @@
1
+ import { CommonTokenStream } from "antlr4ts";
2
+ import { ParseTree } from "antlr4ts/tree";
3
+ import { DocumentRange } from "../../model/malloy_types";
4
+ export interface DocumentHighlight {
5
+ range: DocumentRange;
6
+ type: string;
7
+ }
8
+ export declare const HighlightType: {
9
+ Identifier: string;
10
+ Type: string;
11
+ Literal: {
12
+ Date: string;
13
+ Number: string;
14
+ String: string;
15
+ RegularExpression: string;
16
+ Boolean: string;
17
+ Null: string;
18
+ };
19
+ Call: {
20
+ Aggregate: string;
21
+ TimeFrame: string;
22
+ Cast: string;
23
+ Table: string;
24
+ From: string;
25
+ Function: string;
26
+ FromSQL: string;
27
+ };
28
+ Keyword: {
29
+ AggregateModifier: {
30
+ Distinct: string;
31
+ };
32
+ CastModifier: {
33
+ As: string;
34
+ };
35
+ Is: string;
36
+ On: string;
37
+ Desc: string;
38
+ Asc: string;
39
+ Pick: string;
40
+ When: string;
41
+ Else: string;
42
+ With: string;
43
+ JSON: string;
44
+ Turtle: string;
45
+ Import: string;
46
+ };
47
+ Operator: {
48
+ Comparison: string;
49
+ Boolean: string;
50
+ Date: string;
51
+ };
52
+ Comment: {
53
+ Line: string;
54
+ Block: string;
55
+ };
56
+ Property: {
57
+ Accept: string;
58
+ Aggregate: string;
59
+ Dimension: string;
60
+ Except: string;
61
+ Source: string;
62
+ GroupBy: string;
63
+ Having: string;
64
+ Index: string;
65
+ JoinOne: string;
66
+ JoinMany: string;
67
+ JoinCross: string;
68
+ Limit: string;
69
+ Measure: string;
70
+ Nest: string;
71
+ OrderBy: string;
72
+ PrimaryKey: string;
73
+ Project: string;
74
+ Query: string;
75
+ Rename: string;
76
+ Top: string;
77
+ Where: string;
78
+ SQL: string;
79
+ };
80
+ };
81
+ export declare function passForHighlights(tokens: CommonTokenStream): DocumentHighlight[];
82
+ export declare function walkForDocumentHighlights(tokens: CommonTokenStream, parseTree: ParseTree): DocumentHighlight[];
83
+ export declare function sortHighlights(highlights: DocumentHighlight[]): DocumentHighlight[];