@malloydata/malloy 0.0.334 → 0.0.336
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/CONTEXT.md +4 -3
- package/MALLOY_API.md +129 -0
- package/dist/annotation.d.ts +0 -2
- package/dist/annotation.js +29 -23
- package/dist/api/asynchronous.d.ts +1 -1
- package/dist/api/foundation/cache.d.ts +32 -0
- package/dist/api/foundation/cache.js +92 -0
- package/dist/api/foundation/compile.d.ts +175 -0
- package/dist/api/foundation/compile.js +391 -0
- package/dist/api/foundation/core.d.ts +493 -0
- package/dist/api/foundation/core.js +1247 -0
- package/dist/api/foundation/document.d.ts +167 -0
- package/dist/api/foundation/document.js +206 -0
- package/dist/api/foundation/index.d.ts +10 -0
- package/dist/api/foundation/index.js +77 -0
- package/dist/api/foundation/readers.d.ts +53 -0
- package/dist/api/foundation/readers.js +134 -0
- package/dist/api/foundation/result.d.ts +185 -0
- package/dist/api/foundation/result.js +704 -0
- package/dist/api/foundation/runtime.d.ts +361 -0
- package/dist/api/foundation/runtime.js +733 -0
- package/dist/api/foundation/types.d.ts +54 -0
- package/dist/api/foundation/types.js +7 -0
- package/dist/api/foundation/writers.d.ts +42 -0
- package/dist/api/foundation/writers.js +230 -0
- package/dist/api/util.d.ts +1 -1
- package/dist/connection/base_connection.d.ts +5 -0
- package/dist/connection/types.d.ts +5 -0
- package/dist/dialect/duckdb/duckdb.js +2 -1
- package/dist/dialect/snowflake/snowflake.js +7 -1
- package/dist/dialect/trino/trino.js +7 -2
- package/dist/index.d.ts +6 -3
- package/dist/index.js +30 -26
- package/dist/lang/ast/error-factory.js +3 -5
- package/dist/lang/ast/expressions/expr-count-distinct.js +7 -1
- package/dist/lang/ast/expressions/expr-granular-time.js +1 -1
- package/dist/lang/ast/expressions/expr-max.js +7 -1
- package/dist/lang/ast/expressions/expr-min.js +7 -1
- package/dist/lang/ast/expressions/for-range.js +1 -1
- package/dist/lang/ast/source-elements/query-source.js +2 -7
- package/dist/lang/ast/source-elements/refined-source.js +11 -1
- package/dist/lang/ast/source-elements/sql-source.d.ts +1 -1
- package/dist/lang/ast/source-elements/sql-source.js +18 -3
- package/dist/lang/ast/sql-elements/sql-string.d.ts +2 -2
- package/dist/lang/ast/sql-elements/sql-string.js +18 -1
- package/dist/lang/ast/statements/define-source.js +7 -2
- package/dist/lang/ast/statements/import-statement.js +53 -21
- package/dist/lang/ast/types/document-compile-result.d.ts +1 -0
- package/dist/lang/ast/types/expression-def.js +1 -1
- package/dist/lang/ast/types/malloy-element.d.ts +3 -1
- package/dist/lang/ast/types/malloy-element.js +23 -7
- package/dist/lang/malloy-to-ast.d.ts +1 -1
- package/dist/lang/malloy-to-ast.js +1 -1
- package/dist/lang/parse-malloy.d.ts +3 -2
- package/dist/lang/parse-malloy.js +14 -25
- package/dist/lang/test/test-translator.d.ts +9 -2
- package/dist/lang/test/test-translator.js +103 -77
- package/dist/lang/translate-response.d.ts +1 -0
- package/dist/model/constant_expression_compiler.js +6 -7
- package/dist/model/index.d.ts +3 -1
- package/dist/model/index.js +15 -9
- package/dist/model/malloy_types.d.ts +89 -15
- package/dist/model/malloy_types.js +12 -0
- package/dist/model/persist_utils.d.ts +47 -0
- package/dist/model/persist_utils.js +257 -0
- package/dist/model/query_model_impl.d.ts +2 -4
- package/dist/model/query_model_impl.js +5 -13
- package/dist/model/query_node.d.ts +1 -2
- package/dist/model/query_node.js +3 -13
- package/dist/model/query_query.d.ts +17 -1
- package/dist/model/query_query.js +81 -36
- package/dist/model/source_def_utils.d.ts +50 -0
- package/dist/model/source_def_utils.js +154 -0
- package/dist/model/sql_block.d.ts +5 -1
- package/dist/model/sql_block.js +29 -4
- package/dist/model/sql_compiled.d.ts +29 -0
- package/dist/model/sql_compiled.js +102 -0
- package/dist/model/stage_writer.d.ts +1 -3
- package/dist/model/stage_writer.js +7 -25
- package/dist/model/utils.d.ts +20 -1
- package/dist/model/utils.js +40 -0
- package/dist/run_sql_options.d.ts +0 -1
- package/dist/taggable.d.ts +10 -0
- package/dist/taggable.js +7 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -4
- package/dist/malloy.d.ts +0 -1365
- package/dist/malloy.js +0 -3421
- package/dist/model/materialization/utils.d.ts +0 -3
- package/dist/model/materialization/utils.js +0 -41
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { DocumentCompletion as DocumentCompletionDefinition, DocumentSymbol as DocumentSymbolDefinition, MalloyTranslator } from '../../lang';
|
|
2
|
+
import type { DocumentHelpContext } from '../../lang/parse-tree-walkers/document-help-context-walker';
|
|
3
|
+
import type { PathInfo } from '../../lang/parse-tree-walkers/find-table-path-walker';
|
|
4
|
+
import type { InvalidationKey } from '../../runtime_types';
|
|
5
|
+
/**
|
|
6
|
+
* A parsed Malloy document.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Parse {
|
|
9
|
+
private translator;
|
|
10
|
+
private invalidationKey?;
|
|
11
|
+
constructor(translator: MalloyTranslator, invalidationKey?: InvalidationKey | undefined);
|
|
12
|
+
/**
|
|
13
|
+
* Retrieve the symbols defined in the parsed document.
|
|
14
|
+
*
|
|
15
|
+
* These symbols represent any object defined (e.g. `Query`s and `Explore`s)
|
|
16
|
+
* in the document.
|
|
17
|
+
*
|
|
18
|
+
* @return An array of document symbols.
|
|
19
|
+
*/
|
|
20
|
+
get symbols(): DocumentSymbol[];
|
|
21
|
+
/**
|
|
22
|
+
* Retrieve the full table paths for tables defined in the parsed document.
|
|
23
|
+
* Derived tables i.e. a table that extends another table, table from a query
|
|
24
|
+
* are not included.
|
|
25
|
+
*
|
|
26
|
+
* @return An array of document table path info.
|
|
27
|
+
*/
|
|
28
|
+
get tablePathInfo(): DocumentTablePath[];
|
|
29
|
+
get _translator(): MalloyTranslator;
|
|
30
|
+
get _invalidationKey(): InvalidationKey | undefined;
|
|
31
|
+
completions(position: {
|
|
32
|
+
line: number;
|
|
33
|
+
character: number;
|
|
34
|
+
}): DocumentCompletion[];
|
|
35
|
+
helpContext(position: {
|
|
36
|
+
line: number;
|
|
37
|
+
character: number;
|
|
38
|
+
}): DocumentHelpContext | undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Path info for a table defined in a Malloy document.
|
|
42
|
+
*/
|
|
43
|
+
export declare class DocumentTablePath {
|
|
44
|
+
private _range;
|
|
45
|
+
private _connectionId;
|
|
46
|
+
private _tablePath;
|
|
47
|
+
constructor(tablePath: PathInfo);
|
|
48
|
+
/**
|
|
49
|
+
* @return The range of characters in the source Malloy document that defines
|
|
50
|
+
* this table.
|
|
51
|
+
*/
|
|
52
|
+
get range(): DocumentRange;
|
|
53
|
+
/** @return The Connection Id for this table. */
|
|
54
|
+
get connectionId(): string;
|
|
55
|
+
/** @return The full table path. */
|
|
56
|
+
get tablePath(): string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A range of characters within a Malloy document.
|
|
60
|
+
*/
|
|
61
|
+
export declare class DocumentRange {
|
|
62
|
+
private _start;
|
|
63
|
+
private _end;
|
|
64
|
+
constructor(start: DocumentPosition, end: DocumentPosition);
|
|
65
|
+
/**
|
|
66
|
+
* @return The position of the first character in the range.
|
|
67
|
+
*/
|
|
68
|
+
get start(): DocumentPosition;
|
|
69
|
+
/**
|
|
70
|
+
* @return The position of the last character in the range.
|
|
71
|
+
*/
|
|
72
|
+
get end(): DocumentPosition;
|
|
73
|
+
/**
|
|
74
|
+
* @return This range in JSON format.
|
|
75
|
+
*/
|
|
76
|
+
toJSON(): {
|
|
77
|
+
start: {
|
|
78
|
+
line: number;
|
|
79
|
+
character: number;
|
|
80
|
+
};
|
|
81
|
+
end: {
|
|
82
|
+
line: number;
|
|
83
|
+
character: number;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Construct a DocumentRange from JSON.
|
|
88
|
+
*/
|
|
89
|
+
static fromJSON(json: {
|
|
90
|
+
start: {
|
|
91
|
+
line: number;
|
|
92
|
+
character: number;
|
|
93
|
+
};
|
|
94
|
+
end: {
|
|
95
|
+
line: number;
|
|
96
|
+
character: number;
|
|
97
|
+
};
|
|
98
|
+
}): DocumentRange;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A position within a Malloy document.
|
|
102
|
+
*/
|
|
103
|
+
export declare class DocumentPosition {
|
|
104
|
+
private _line;
|
|
105
|
+
private _character;
|
|
106
|
+
constructor(line: number, character: number);
|
|
107
|
+
/**
|
|
108
|
+
* @return The line number of the position.
|
|
109
|
+
*/
|
|
110
|
+
get line(): number;
|
|
111
|
+
/**
|
|
112
|
+
* @return The character index on the line `this.getLine()`.
|
|
113
|
+
*/
|
|
114
|
+
get character(): number;
|
|
115
|
+
/**
|
|
116
|
+
* @return This position in JSON format.
|
|
117
|
+
*/
|
|
118
|
+
toJSON(): {
|
|
119
|
+
line: number;
|
|
120
|
+
character: number;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* A symbol defined in a Malloy document.
|
|
125
|
+
*
|
|
126
|
+
* Represents any object defined (e.g. `Query`s and `Explore`s) in the document.
|
|
127
|
+
*/
|
|
128
|
+
export declare class DocumentSymbol {
|
|
129
|
+
private _range;
|
|
130
|
+
private _lensRange;
|
|
131
|
+
private _type;
|
|
132
|
+
private _name;
|
|
133
|
+
private _children;
|
|
134
|
+
constructor(documentSymbol: DocumentSymbolDefinition);
|
|
135
|
+
/**
|
|
136
|
+
* @return The range of characters in the source Malloy document that define this symbol.
|
|
137
|
+
*/
|
|
138
|
+
get range(): DocumentRange;
|
|
139
|
+
/**
|
|
140
|
+
* @return The range of characters in the source Malloy document that define this symbol,
|
|
141
|
+
* including tags. Note: "block tags" are included if there is exactly one
|
|
142
|
+
* definition in the block.
|
|
143
|
+
*/
|
|
144
|
+
get lensRange(): DocumentRange;
|
|
145
|
+
/**
|
|
146
|
+
* @return The type of symbol.
|
|
147
|
+
*
|
|
148
|
+
* Possible values are: `"explore"`, `"query"`, `"field"`, `"turtle"`, `"join"`, or `"unnamed_query"`.
|
|
149
|
+
*/
|
|
150
|
+
get type(): string;
|
|
151
|
+
/**
|
|
152
|
+
* @return The name of this symbol, e.g. the `Explore` name or `Query` name.
|
|
153
|
+
*
|
|
154
|
+
* For type `"unnamed_query"`, `getName()` is `"unnamed_query"`.
|
|
155
|
+
*/
|
|
156
|
+
get name(): string;
|
|
157
|
+
/**
|
|
158
|
+
* @return An array of document symbols defined inside this document symbol,
|
|
159
|
+
* e.g. fields in an `Explore`.
|
|
160
|
+
*/
|
|
161
|
+
get children(): DocumentSymbol[];
|
|
162
|
+
}
|
|
163
|
+
export declare class DocumentCompletion {
|
|
164
|
+
readonly type: string;
|
|
165
|
+
readonly text: string;
|
|
166
|
+
constructor(completion: DocumentCompletionDefinition);
|
|
167
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Contributors to the Malloy project
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DocumentCompletion = exports.DocumentSymbol = exports.DocumentPosition = exports.DocumentRange = exports.DocumentTablePath = exports.Parse = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* A parsed Malloy document.
|
|
10
|
+
*/
|
|
11
|
+
class Parse {
|
|
12
|
+
constructor(translator, invalidationKey) {
|
|
13
|
+
this.translator = translator;
|
|
14
|
+
this.invalidationKey = invalidationKey;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Retrieve the symbols defined in the parsed document.
|
|
18
|
+
*
|
|
19
|
+
* These symbols represent any object defined (e.g. `Query`s and `Explore`s)
|
|
20
|
+
* in the document.
|
|
21
|
+
*
|
|
22
|
+
* @return An array of document symbols.
|
|
23
|
+
*/
|
|
24
|
+
get symbols() {
|
|
25
|
+
return (this.translator.metadata().symbols || []).map(symbol => new DocumentSymbol(symbol));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Retrieve the full table paths for tables defined in the parsed document.
|
|
29
|
+
* Derived tables i.e. a table that extends another table, table from a query
|
|
30
|
+
* are not included.
|
|
31
|
+
*
|
|
32
|
+
* @return An array of document table path info.
|
|
33
|
+
*/
|
|
34
|
+
get tablePathInfo() {
|
|
35
|
+
var _a;
|
|
36
|
+
const paths = (_a = this.translator.tablePathInfo().pathInfo) !== null && _a !== void 0 ? _a : [];
|
|
37
|
+
return paths.map(path => new DocumentTablePath(path));
|
|
38
|
+
}
|
|
39
|
+
get _translator() {
|
|
40
|
+
return this.translator;
|
|
41
|
+
}
|
|
42
|
+
get _invalidationKey() {
|
|
43
|
+
return this.invalidationKey;
|
|
44
|
+
}
|
|
45
|
+
completions(position) {
|
|
46
|
+
return (this.translator.completions(position).completions || []).map(completion => new DocumentCompletion(completion));
|
|
47
|
+
}
|
|
48
|
+
helpContext(position) {
|
|
49
|
+
return this.translator.helpContext(position).helpContext;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.Parse = Parse;
|
|
53
|
+
/**
|
|
54
|
+
* Path info for a table defined in a Malloy document.
|
|
55
|
+
*/
|
|
56
|
+
class DocumentTablePath {
|
|
57
|
+
constructor(tablePath) {
|
|
58
|
+
this._range = DocumentRange.fromJSON(tablePath.range);
|
|
59
|
+
this._connectionId = tablePath.connectionId;
|
|
60
|
+
this._tablePath = tablePath.tablePath;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @return The range of characters in the source Malloy document that defines
|
|
64
|
+
* this table.
|
|
65
|
+
*/
|
|
66
|
+
get range() {
|
|
67
|
+
return this._range;
|
|
68
|
+
}
|
|
69
|
+
/** @return The Connection Id for this table. */
|
|
70
|
+
get connectionId() {
|
|
71
|
+
return this._connectionId;
|
|
72
|
+
}
|
|
73
|
+
/** @return The full table path. */
|
|
74
|
+
get tablePath() {
|
|
75
|
+
return this._tablePath;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.DocumentTablePath = DocumentTablePath;
|
|
79
|
+
/**
|
|
80
|
+
* A range of characters within a Malloy document.
|
|
81
|
+
*/
|
|
82
|
+
class DocumentRange {
|
|
83
|
+
constructor(start, end) {
|
|
84
|
+
this._start = start;
|
|
85
|
+
this._end = end;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @return The position of the first character in the range.
|
|
89
|
+
*/
|
|
90
|
+
get start() {
|
|
91
|
+
return this._start;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @return The position of the last character in the range.
|
|
95
|
+
*/
|
|
96
|
+
get end() {
|
|
97
|
+
return this._end;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @return This range in JSON format.
|
|
101
|
+
*/
|
|
102
|
+
toJSON() {
|
|
103
|
+
return {
|
|
104
|
+
start: this.start.toJSON(),
|
|
105
|
+
end: this.end.toJSON(),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Construct a DocumentRange from JSON.
|
|
110
|
+
*/
|
|
111
|
+
static fromJSON(json) {
|
|
112
|
+
return new DocumentRange(new DocumentPosition(json.start.line, json.start.character), new DocumentPosition(json.end.line, json.end.character));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.DocumentRange = DocumentRange;
|
|
116
|
+
/**
|
|
117
|
+
* A position within a Malloy document.
|
|
118
|
+
*/
|
|
119
|
+
class DocumentPosition {
|
|
120
|
+
constructor(line, character) {
|
|
121
|
+
this._line = line;
|
|
122
|
+
this._character = character;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* @return The line number of the position.
|
|
126
|
+
*/
|
|
127
|
+
get line() {
|
|
128
|
+
return this._line;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @return The character index on the line `this.getLine()`.
|
|
132
|
+
*/
|
|
133
|
+
get character() {
|
|
134
|
+
return this._character;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @return This position in JSON format.
|
|
138
|
+
*/
|
|
139
|
+
toJSON() {
|
|
140
|
+
return { line: this.line, character: this.character };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.DocumentPosition = DocumentPosition;
|
|
144
|
+
/**
|
|
145
|
+
* A symbol defined in a Malloy document.
|
|
146
|
+
*
|
|
147
|
+
* Represents any object defined (e.g. `Query`s and `Explore`s) in the document.
|
|
148
|
+
*/
|
|
149
|
+
class DocumentSymbol {
|
|
150
|
+
constructor(documentSymbol) {
|
|
151
|
+
this._range = DocumentRange.fromJSON(documentSymbol.range);
|
|
152
|
+
this._lensRange = documentSymbol.lensRange
|
|
153
|
+
? DocumentRange.fromJSON(documentSymbol.lensRange)
|
|
154
|
+
: undefined;
|
|
155
|
+
this._type = documentSymbol.type;
|
|
156
|
+
this._name = documentSymbol.name;
|
|
157
|
+
this._children = documentSymbol.children.map(child => new DocumentSymbol(child));
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* @return The range of characters in the source Malloy document that define this symbol.
|
|
161
|
+
*/
|
|
162
|
+
get range() {
|
|
163
|
+
return this._range;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* @return The range of characters in the source Malloy document that define this symbol,
|
|
167
|
+
* including tags. Note: "block tags" are included if there is exactly one
|
|
168
|
+
* definition in the block.
|
|
169
|
+
*/
|
|
170
|
+
get lensRange() {
|
|
171
|
+
var _a;
|
|
172
|
+
return (_a = this._lensRange) !== null && _a !== void 0 ? _a : this._range;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* @return The type of symbol.
|
|
176
|
+
*
|
|
177
|
+
* Possible values are: `"explore"`, `"query"`, `"field"`, `"turtle"`, `"join"`, or `"unnamed_query"`.
|
|
178
|
+
*/
|
|
179
|
+
get type() {
|
|
180
|
+
return this._type;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @return The name of this symbol, e.g. the `Explore` name or `Query` name.
|
|
184
|
+
*
|
|
185
|
+
* For type `"unnamed_query"`, `getName()` is `"unnamed_query"`.
|
|
186
|
+
*/
|
|
187
|
+
get name() {
|
|
188
|
+
return this._name;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* @return An array of document symbols defined inside this document symbol,
|
|
192
|
+
* e.g. fields in an `Explore`.
|
|
193
|
+
*/
|
|
194
|
+
get children() {
|
|
195
|
+
return this._children;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.DocumentSymbol = DocumentSymbol;
|
|
199
|
+
class DocumentCompletion {
|
|
200
|
+
constructor(completion) {
|
|
201
|
+
this.type = completion.type;
|
|
202
|
+
this.text = completion.text;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.DocumentCompletion = DocumentCompletion;
|
|
206
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { Taggable, Loggable, ParseOptions, CompileOptions, CompileQueryOptions, BuildNode, BuildGraph, } from './types';
|
|
2
|
+
export { EmptyURLReader, InMemoryURLReader, FixedConnectionMap, hashForInvalidationKey, isInternalURL, readURL, getInvalidationKey, } from './readers';
|
|
3
|
+
export type { ModelCache, CachedModel } from './cache';
|
|
4
|
+
export { CacheManager, InMemoryModelCache } from './cache';
|
|
5
|
+
export { Parse, DocumentTablePath, DocumentRange, DocumentPosition, DocumentSymbol, DocumentCompletion, } from './document';
|
|
6
|
+
export { SourceRelationship, AtomicFieldType, DateTimeframe, TimestampTimeframe, JoinRelationship, type Field, type SerializedExplore, type SortableField, type PreparedResultJSON, type BuildPlan, Explore, ExploreField, AtomicField, DateField, TimestampField, NumberField, BooleanField, JSONField, UnsupportedField, StringField, Query, QueryField, Model, PersistSource, PreparedQuery, PreparedResult, } from './core';
|
|
7
|
+
export { type ResultJSON, type DataColumn, type DataArrayOrRecord, Result, DataArray, DataRecord, } from './result';
|
|
8
|
+
export { type WriteStream, DataWriter, JSONWriter, CSVWriter } from './writers';
|
|
9
|
+
export { Runtime, ConnectionRuntime, SingleConnectionRuntime, ModelMaterializer, QueryMaterializer, PreparedResultMaterializer, ExploreMaterializer, } from './runtime';
|
|
10
|
+
export { Malloy, MalloyError, type MalloyCompileOptions, type MalloyRunOptions, } from './compile';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Contributors to the Malloy project
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.Malloy = exports.ExploreMaterializer = exports.PreparedResultMaterializer = exports.QueryMaterializer = exports.ModelMaterializer = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.Runtime = exports.CSVWriter = exports.JSONWriter = exports.DataWriter = exports.DataRecord = exports.DataArray = exports.Result = exports.PreparedResult = exports.PreparedQuery = exports.PersistSource = exports.Model = exports.QueryField = exports.Query = exports.StringField = exports.UnsupportedField = exports.JSONField = exports.BooleanField = exports.NumberField = exports.TimestampField = exports.DateField = exports.AtomicField = exports.ExploreField = exports.Explore = exports.JoinRelationship = exports.TimestampTimeframe = exports.DateTimeframe = exports.AtomicFieldType = exports.SourceRelationship = exports.DocumentCompletion = exports.DocumentSymbol = exports.DocumentPosition = exports.DocumentRange = exports.DocumentTablePath = exports.Parse = exports.InMemoryModelCache = exports.CacheManager = exports.getInvalidationKey = exports.readURL = exports.isInternalURL = exports.hashForInvalidationKey = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = void 0;
|
|
8
|
+
exports.MalloyError = void 0;
|
|
9
|
+
// URL readers and connection helpers
|
|
10
|
+
var readers_1 = require("./readers");
|
|
11
|
+
Object.defineProperty(exports, "EmptyURLReader", { enumerable: true, get: function () { return readers_1.EmptyURLReader; } });
|
|
12
|
+
Object.defineProperty(exports, "InMemoryURLReader", { enumerable: true, get: function () { return readers_1.InMemoryURLReader; } });
|
|
13
|
+
Object.defineProperty(exports, "FixedConnectionMap", { enumerable: true, get: function () { return readers_1.FixedConnectionMap; } });
|
|
14
|
+
Object.defineProperty(exports, "hashForInvalidationKey", { enumerable: true, get: function () { return readers_1.hashForInvalidationKey; } });
|
|
15
|
+
Object.defineProperty(exports, "isInternalURL", { enumerable: true, get: function () { return readers_1.isInternalURL; } });
|
|
16
|
+
Object.defineProperty(exports, "readURL", { enumerable: true, get: function () { return readers_1.readURL; } });
|
|
17
|
+
Object.defineProperty(exports, "getInvalidationKey", { enumerable: true, get: function () { return readers_1.getInvalidationKey; } });
|
|
18
|
+
var cache_1 = require("./cache");
|
|
19
|
+
Object.defineProperty(exports, "CacheManager", { enumerable: true, get: function () { return cache_1.CacheManager; } });
|
|
20
|
+
Object.defineProperty(exports, "InMemoryModelCache", { enumerable: true, get: function () { return cache_1.InMemoryModelCache; } });
|
|
21
|
+
// Document/Parse
|
|
22
|
+
var document_1 = require("./document");
|
|
23
|
+
Object.defineProperty(exports, "Parse", { enumerable: true, get: function () { return document_1.Parse; } });
|
|
24
|
+
Object.defineProperty(exports, "DocumentTablePath", { enumerable: true, get: function () { return document_1.DocumentTablePath; } });
|
|
25
|
+
Object.defineProperty(exports, "DocumentRange", { enumerable: true, get: function () { return document_1.DocumentRange; } });
|
|
26
|
+
Object.defineProperty(exports, "DocumentPosition", { enumerable: true, get: function () { return document_1.DocumentPosition; } });
|
|
27
|
+
Object.defineProperty(exports, "DocumentSymbol", { enumerable: true, get: function () { return document_1.DocumentSymbol; } });
|
|
28
|
+
Object.defineProperty(exports, "DocumentCompletion", { enumerable: true, get: function () { return document_1.DocumentCompletion; } });
|
|
29
|
+
// Core classes (tightly coupled)
|
|
30
|
+
var core_1 = require("./core");
|
|
31
|
+
// Enums
|
|
32
|
+
Object.defineProperty(exports, "SourceRelationship", { enumerable: true, get: function () { return core_1.SourceRelationship; } });
|
|
33
|
+
Object.defineProperty(exports, "AtomicFieldType", { enumerable: true, get: function () { return core_1.AtomicFieldType; } });
|
|
34
|
+
Object.defineProperty(exports, "DateTimeframe", { enumerable: true, get: function () { return core_1.DateTimeframe; } });
|
|
35
|
+
Object.defineProperty(exports, "TimestampTimeframe", { enumerable: true, get: function () { return core_1.TimestampTimeframe; } });
|
|
36
|
+
Object.defineProperty(exports, "JoinRelationship", { enumerable: true, get: function () { return core_1.JoinRelationship; } });
|
|
37
|
+
// Classes
|
|
38
|
+
Object.defineProperty(exports, "Explore", { enumerable: true, get: function () { return core_1.Explore; } });
|
|
39
|
+
Object.defineProperty(exports, "ExploreField", { enumerable: true, get: function () { return core_1.ExploreField; } });
|
|
40
|
+
Object.defineProperty(exports, "AtomicField", { enumerable: true, get: function () { return core_1.AtomicField; } });
|
|
41
|
+
Object.defineProperty(exports, "DateField", { enumerable: true, get: function () { return core_1.DateField; } });
|
|
42
|
+
Object.defineProperty(exports, "TimestampField", { enumerable: true, get: function () { return core_1.TimestampField; } });
|
|
43
|
+
Object.defineProperty(exports, "NumberField", { enumerable: true, get: function () { return core_1.NumberField; } });
|
|
44
|
+
Object.defineProperty(exports, "BooleanField", { enumerable: true, get: function () { return core_1.BooleanField; } });
|
|
45
|
+
Object.defineProperty(exports, "JSONField", { enumerable: true, get: function () { return core_1.JSONField; } });
|
|
46
|
+
Object.defineProperty(exports, "UnsupportedField", { enumerable: true, get: function () { return core_1.UnsupportedField; } });
|
|
47
|
+
Object.defineProperty(exports, "StringField", { enumerable: true, get: function () { return core_1.StringField; } });
|
|
48
|
+
Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return core_1.Query; } });
|
|
49
|
+
Object.defineProperty(exports, "QueryField", { enumerable: true, get: function () { return core_1.QueryField; } });
|
|
50
|
+
Object.defineProperty(exports, "Model", { enumerable: true, get: function () { return core_1.Model; } });
|
|
51
|
+
Object.defineProperty(exports, "PersistSource", { enumerable: true, get: function () { return core_1.PersistSource; } });
|
|
52
|
+
Object.defineProperty(exports, "PreparedQuery", { enumerable: true, get: function () { return core_1.PreparedQuery; } });
|
|
53
|
+
Object.defineProperty(exports, "PreparedResult", { enumerable: true, get: function () { return core_1.PreparedResult; } });
|
|
54
|
+
// Result and Data classes
|
|
55
|
+
var result_1 = require("./result");
|
|
56
|
+
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return result_1.Result; } });
|
|
57
|
+
Object.defineProperty(exports, "DataArray", { enumerable: true, get: function () { return result_1.DataArray; } });
|
|
58
|
+
Object.defineProperty(exports, "DataRecord", { enumerable: true, get: function () { return result_1.DataRecord; } });
|
|
59
|
+
// Writers
|
|
60
|
+
var writers_1 = require("./writers");
|
|
61
|
+
Object.defineProperty(exports, "DataWriter", { enumerable: true, get: function () { return writers_1.DataWriter; } });
|
|
62
|
+
Object.defineProperty(exports, "JSONWriter", { enumerable: true, get: function () { return writers_1.JSONWriter; } });
|
|
63
|
+
Object.defineProperty(exports, "CSVWriter", { enumerable: true, get: function () { return writers_1.CSVWriter; } });
|
|
64
|
+
// Runtime and Materializers
|
|
65
|
+
var runtime_1 = require("./runtime");
|
|
66
|
+
Object.defineProperty(exports, "Runtime", { enumerable: true, get: function () { return runtime_1.Runtime; } });
|
|
67
|
+
Object.defineProperty(exports, "ConnectionRuntime", { enumerable: true, get: function () { return runtime_1.ConnectionRuntime; } });
|
|
68
|
+
Object.defineProperty(exports, "SingleConnectionRuntime", { enumerable: true, get: function () { return runtime_1.SingleConnectionRuntime; } });
|
|
69
|
+
Object.defineProperty(exports, "ModelMaterializer", { enumerable: true, get: function () { return runtime_1.ModelMaterializer; } });
|
|
70
|
+
Object.defineProperty(exports, "QueryMaterializer", { enumerable: true, get: function () { return runtime_1.QueryMaterializer; } });
|
|
71
|
+
Object.defineProperty(exports, "PreparedResultMaterializer", { enumerable: true, get: function () { return runtime_1.PreparedResultMaterializer; } });
|
|
72
|
+
Object.defineProperty(exports, "ExploreMaterializer", { enumerable: true, get: function () { return runtime_1.ExploreMaterializer; } });
|
|
73
|
+
// Compile (Malloy static class)
|
|
74
|
+
var compile_1 = require("./compile");
|
|
75
|
+
Object.defineProperty(exports, "Malloy", { enumerable: true, get: function () { return compile_1.Malloy; } });
|
|
76
|
+
Object.defineProperty(exports, "MalloyError", { enumerable: true, get: function () { return compile_1.MalloyError; } });
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { InvalidationKey, URLReader } from '../../runtime_types';
|
|
2
|
+
import type { Connection, LookupConnection } from '../../connection/types';
|
|
3
|
+
export declare function hashForInvalidationKey(input: string): string;
|
|
4
|
+
export declare function isInternalURL(url: string): boolean;
|
|
5
|
+
export declare function readURL(urlReader: URLReader, url: URL): Promise<{
|
|
6
|
+
contents: string;
|
|
7
|
+
invalidationKey: InvalidationKey;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function getInvalidationKey(urlReader: URLReader, url: URL): Promise<InvalidationKey>;
|
|
10
|
+
export declare class EmptyURLReader implements URLReader {
|
|
11
|
+
readURL(_url: URL): Promise<{
|
|
12
|
+
contents: string;
|
|
13
|
+
invalidationKey: InvalidationKey;
|
|
14
|
+
}>;
|
|
15
|
+
getInvalidationKey(_url: URL): Promise<InvalidationKey>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A URL reader backed by an in-memory mapping of URL contents.
|
|
19
|
+
*/
|
|
20
|
+
export declare class InMemoryURLReader implements URLReader {
|
|
21
|
+
protected files: Map<string, string>;
|
|
22
|
+
constructor(files: Map<string, string>);
|
|
23
|
+
readURL(url: URL): Promise<{
|
|
24
|
+
contents: string;
|
|
25
|
+
invalidationKey: InvalidationKey;
|
|
26
|
+
}>;
|
|
27
|
+
getInvalidationKey(url: URL): Promise<InvalidationKey>;
|
|
28
|
+
private invalidationKey;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A fixed mapping of connection names to connections.
|
|
32
|
+
*/
|
|
33
|
+
export declare class FixedConnectionMap implements LookupConnection<Connection> {
|
|
34
|
+
private connections;
|
|
35
|
+
private defaultConnectionName?;
|
|
36
|
+
constructor(connections: Map<string, Connection>, defaultConnectionName?: string | undefined);
|
|
37
|
+
/**
|
|
38
|
+
* Get a connection by name.
|
|
39
|
+
*
|
|
40
|
+
* @param connectionName The name of the connection to look up.
|
|
41
|
+
* @return A `Connection`
|
|
42
|
+
* @throws An `Error` if no connection with the given name exists.
|
|
43
|
+
*/
|
|
44
|
+
getConnection(connectionName?: string): Promise<Connection>;
|
|
45
|
+
/**
|
|
46
|
+
* Gets a list of registered connections.
|
|
47
|
+
*
|
|
48
|
+
* @return The list of registered connections.
|
|
49
|
+
*/
|
|
50
|
+
listConnections(): Connection[];
|
|
51
|
+
lookupConnection(connectionName?: string): Promise<Connection>;
|
|
52
|
+
static fromArray(connections: Connection[]): FixedConnectionMap;
|
|
53
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Contributors to the Malloy project
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = void 0;
|
|
8
|
+
exports.hashForInvalidationKey = hashForInvalidationKey;
|
|
9
|
+
exports.isInternalURL = isInternalURL;
|
|
10
|
+
exports.readURL = readURL;
|
|
11
|
+
exports.getInvalidationKey = getInvalidationKey;
|
|
12
|
+
const uuid_1 = require("uuid");
|
|
13
|
+
function hashForInvalidationKey(input) {
|
|
14
|
+
const MALLOY_UUID = '76c17e9d-f3ce-5f2d-bfde-98ad3d2a37f6';
|
|
15
|
+
return (0, uuid_1.v5)(input, MALLOY_UUID);
|
|
16
|
+
}
|
|
17
|
+
function isInternalURL(url) {
|
|
18
|
+
return url.startsWith('internal://');
|
|
19
|
+
}
|
|
20
|
+
async function readURL(urlReader, url) {
|
|
21
|
+
const result = await urlReader.readURL(url);
|
|
22
|
+
const { contents, invalidationKey } = typeof result === 'string'
|
|
23
|
+
? { contents: result, invalidationKey: undefined }
|
|
24
|
+
: result;
|
|
25
|
+
return {
|
|
26
|
+
contents,
|
|
27
|
+
invalidationKey: isInternalURL(url.toString())
|
|
28
|
+
? null
|
|
29
|
+
: invalidationKey !== null && invalidationKey !== void 0 ? invalidationKey : hashForInvalidationKey(contents),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
async function getInvalidationKey(urlReader, url) {
|
|
33
|
+
if (isInternalURL(url.toString())) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (urlReader.getInvalidationKey !== undefined) {
|
|
37
|
+
return await urlReader.getInvalidationKey(url);
|
|
38
|
+
}
|
|
39
|
+
return (await readURL(urlReader, url)).invalidationKey;
|
|
40
|
+
}
|
|
41
|
+
class EmptyURLReader {
|
|
42
|
+
async readURL(_url) {
|
|
43
|
+
throw new Error('No files.');
|
|
44
|
+
}
|
|
45
|
+
async getInvalidationKey(_url) {
|
|
46
|
+
throw new Error('No files.');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.EmptyURLReader = EmptyURLReader;
|
|
50
|
+
/**
|
|
51
|
+
* A URL reader backed by an in-memory mapping of URL contents.
|
|
52
|
+
*/
|
|
53
|
+
class InMemoryURLReader {
|
|
54
|
+
constructor(files) {
|
|
55
|
+
this.files = files;
|
|
56
|
+
}
|
|
57
|
+
async readURL(url) {
|
|
58
|
+
const file = this.files.get(url.toString());
|
|
59
|
+
if (file !== undefined) {
|
|
60
|
+
return Promise.resolve({
|
|
61
|
+
contents: file,
|
|
62
|
+
invalidationKey: this.invalidationKey(url, file),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
throw new Error(`File not found '${url}'`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async getInvalidationKey(url) {
|
|
70
|
+
const file = this.files.get(url.toString());
|
|
71
|
+
if (file !== undefined) {
|
|
72
|
+
return Promise.resolve(this.invalidationKey(url, file));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
throw new Error(`File not found '${url}'`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
invalidationKey(url, contents) {
|
|
79
|
+
if (isInternalURL(url.toString())) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return hashForInvalidationKey(contents);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.InMemoryURLReader = InMemoryURLReader;
|
|
86
|
+
/**
|
|
87
|
+
* A fixed mapping of connection names to connections.
|
|
88
|
+
*/
|
|
89
|
+
class FixedConnectionMap {
|
|
90
|
+
constructor(connections, defaultConnectionName) {
|
|
91
|
+
this.connections = connections;
|
|
92
|
+
this.defaultConnectionName = defaultConnectionName;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get a connection by name.
|
|
96
|
+
*
|
|
97
|
+
* @param connectionName The name of the connection to look up.
|
|
98
|
+
* @return A `Connection`
|
|
99
|
+
* @throws An `Error` if no connection with the given name exists.
|
|
100
|
+
*/
|
|
101
|
+
async getConnection(connectionName) {
|
|
102
|
+
if (connectionName === undefined) {
|
|
103
|
+
if (this.defaultConnectionName !== undefined) {
|
|
104
|
+
connectionName = this.defaultConnectionName;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
throw new Error('No default connection.');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const connection = this.connections.get(connectionName);
|
|
111
|
+
if (connection !== undefined) {
|
|
112
|
+
return Promise.resolve(connection);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
throw new Error(`No connection found with name ${connectionName}.`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Gets a list of registered connections.
|
|
120
|
+
*
|
|
121
|
+
* @return The list of registered connections.
|
|
122
|
+
*/
|
|
123
|
+
listConnections() {
|
|
124
|
+
return Array.from(this.connections.values());
|
|
125
|
+
}
|
|
126
|
+
async lookupConnection(connectionName) {
|
|
127
|
+
return this.getConnection(connectionName);
|
|
128
|
+
}
|
|
129
|
+
static fromArray(connections) {
|
|
130
|
+
return new FixedConnectionMap(new Map(connections.map(connection => [connection.name, connection])));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.FixedConnectionMap = FixedConnectionMap;
|
|
134
|
+
//# sourceMappingURL=readers.js.map
|