@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.
- package/README.md +39 -0
- package/dist/connection_utils.d.ts +1 -0
- package/dist/connection_utils.js +56 -0
- package/dist/dialect/dialect-map.d.ts +3 -0
- package/dist/dialect/dialect-map.js +33 -0
- package/dist/dialect/dialect.d.ts +64 -0
- package/dist/dialect/dialect.js +64 -0
- package/dist/dialect/dialect_map.d.ts +3 -0
- package/dist/dialect/dialect_map.js +35 -0
- package/dist/dialect/duckdb.d.ts +49 -0
- package/dist/dialect/duckdb.js +349 -0
- package/dist/dialect/index.d.ts +6 -0
- package/dist/dialect/index.js +27 -0
- package/dist/dialect/postgres.d.ts +49 -0
- package/dist/dialect/postgres.js +308 -0
- package/dist/dialect/standardsql.d.ts +46 -0
- package/dist/dialect/standardsql.js +361 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +47 -0
- package/dist/lang/ast/apply-expr.d.ts +16 -0
- package/dist/lang/ast/apply-expr.js +215 -0
- package/dist/lang/ast/ast-expr.d.ts +291 -0
- package/dist/lang/ast/ast-expr.js +1056 -0
- package/dist/lang/ast/ast-main.d.ts +480 -0
- package/dist/lang/ast/ast-main.js +2096 -0
- package/dist/lang/ast/ast-time-expr.d.ts +109 -0
- package/dist/lang/ast/ast-time-expr.js +550 -0
- package/dist/lang/ast/ast-types.d.ts +83 -0
- package/dist/lang/ast/ast-types.js +215 -0
- package/dist/lang/ast/index.d.ts +5 -0
- package/dist/lang/ast/index.js +34 -0
- package/dist/lang/ast/time-utils.d.ts +8 -0
- package/dist/lang/ast/time-utils.js +83 -0
- package/dist/lang/field-space.d.ts +157 -0
- package/dist/lang/field-space.js +651 -0
- package/dist/lang/field-utils.d.ts +5 -0
- package/dist/lang/field-utils.js +33 -0
- package/dist/lang/index.d.ts +9 -0
- package/dist/lang/index.js +22 -0
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +156 -0
- package/dist/lang/lib/Malloy/MalloyLexer.js +1163 -0
- package/dist/lang/lib/Malloy/MalloyListener.d.ts +2026 -0
- package/dist/lang/lib/Malloy/MalloyListener.js +4 -0
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +1920 -0
- package/dist/lang/lib/Malloy/MalloyParser.js +11790 -0
- package/dist/lang/lib/Malloy/MalloyVisitor.d.ts +1276 -0
- package/dist/lang/lib/Malloy/MalloyVisitor.js +4 -0
- package/dist/lang/parse-log.d.ts +27 -0
- package/dist/lang/parse-log.js +41 -0
- package/dist/lang/parse-malloy.d.ts +245 -0
- package/dist/lang/parse-malloy.js +729 -0
- package/dist/lang/parse-to-ast.d.ts +156 -0
- package/dist/lang/parse-to-ast.js +945 -0
- package/dist/lang/parse-tree-walkers/document-completion-walker.d.ts +10 -0
- package/dist/lang/parse-tree-walkers/document-completion-walker.js +136 -0
- package/dist/lang/parse-tree-walkers/document-help-context-walker.d.ts +9 -0
- package/dist/lang/parse-tree-walkers/document-help-context-walker.js +97 -0
- package/dist/lang/parse-tree-walkers/document-highlight-walker.d.ts +83 -0
- package/dist/lang/parse-tree-walkers/document-highlight-walker.js +375 -0
- package/dist/lang/parse-tree-walkers/document-symbol-walker.d.ts +11 -0
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +172 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +34 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.js +64 -0
- package/dist/lang/parse-tree-walkers/find-external-references.d.ts +11 -0
- package/dist/lang/parse-tree-walkers/find-external-references.js +51 -0
- package/dist/lang/reference-list.d.ts +10 -0
- package/dist/lang/reference-list.js +80 -0
- package/dist/lang/space-field.d.ts +119 -0
- package/dist/lang/space-field.js +339 -0
- package/dist/lang/test/document-help-context-walker.spec.d.ts +1 -0
- package/dist/lang/test/document-help-context-walker.spec.js +45 -0
- package/dist/lang/test/document-symbol-walker.spec.d.ts +1 -0
- package/dist/lang/test/document-symbol-walker.spec.js +100 -0
- package/dist/lang/test/field-symbols.spec.d.ts +1 -0
- package/dist/lang/test/field-symbols.spec.js +172 -0
- package/dist/lang/test/parse.spec.d.ts +12 -0
- package/dist/lang/test/parse.spec.js +1936 -0
- package/dist/lang/test/test-translator.d.ts +38 -0
- package/dist/lang/test/test-translator.js +334 -0
- package/dist/lang/zone.d.ts +57 -0
- package/dist/lang/zone.js +97 -0
- package/dist/malloy.d.ts +1134 -0
- package/dist/malloy.js +2354 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/index.js +34 -0
- package/dist/model/malloy-query.d.ts +313 -0
- package/dist/model/malloy-query.js +2603 -0
- package/dist/model/malloy-types.d.ts +404 -0
- package/dist/model/malloy-types.js +242 -0
- package/dist/model/malloy_query.d.ts +353 -0
- package/dist/model/malloy_query.js +2990 -0
- package/dist/model/malloy_types.d.ts +502 -0
- package/dist/model/malloy_types.js +283 -0
- package/dist/model/sql-block.d.ts +11 -0
- package/dist/model/sql-block.js +38 -0
- package/dist/model/sql_block.d.ts +11 -0
- package/dist/model/sql_block.js +41 -0
- package/dist/model/utils.d.ts +21 -0
- package/dist/model/utils.js +84 -0
- package/dist/runtime-types.d.ts +116 -0
- package/dist/runtime-types.js +40 -0
- package/dist/runtime_types.d.ts +119 -0
- package/dist/runtime_types.js +15 -0
- package/package.json +36 -0
package/dist/malloy.d.ts
ADDED
|
@@ -0,0 +1,1134 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { InfoConnection } from ".";
|
|
3
|
+
import { DocumentHighlight as DocumentHighlightDefinition, DocumentSymbol as DocumentSymbolDefinition, DocumentCompletion as DocumentCompletionDefinition, LogMessage, MalloyTranslator } from "./lang";
|
|
4
|
+
import { DocumentHelpContext } from "./lang/parse-tree-walkers/document-help-context-walker";
|
|
5
|
+
import { CompiledQuery, FieldBooleanDef, FieldDateDef, FieldNumberDef, FieldStringDef, FieldTimestampDef, FieldTypeDef, FilterExpression, ModelDef, Query as InternalQuery, QueryData, QueryDataRow, QueryResult, StructDef, TurtleDef, SQLBlock, DocumentReference, DocumentPosition as ModelDocumentPosition, SearchIndexResult, SearchValueMapResult } from "./model";
|
|
6
|
+
import { LookupConnection, ModelString, ModelURL, QueryString, QueryURL, URLReader, Connection } from "./runtime_types";
|
|
7
|
+
export interface Loggable {
|
|
8
|
+
debug: (message?: any, ...optionalParams: any[]) => void;
|
|
9
|
+
info: (message?: any, ...optionalParams: any[]) => void;
|
|
10
|
+
warn: (message?: any, ...optionalParams: any[]) => void;
|
|
11
|
+
error: (message?: any, ...optionalParams: any[]) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface RunSQLOptions {
|
|
14
|
+
rowLimit?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare class Malloy {
|
|
17
|
+
static get version(): string;
|
|
18
|
+
private static _log;
|
|
19
|
+
static get log(): Loggable;
|
|
20
|
+
static setLogger(log: Loggable): void;
|
|
21
|
+
private static _parse;
|
|
22
|
+
/**
|
|
23
|
+
* Parse a Malloy document by URL.
|
|
24
|
+
*
|
|
25
|
+
* @param url The URL of the Malloy document to parse.
|
|
26
|
+
* @param urlReader Object capable of fetching URL contents.
|
|
27
|
+
* @returns A (promise of a) `Parse` result.
|
|
28
|
+
*/
|
|
29
|
+
static parse({ url, urlReader, }: {
|
|
30
|
+
url: URL;
|
|
31
|
+
urlReader: URLReader;
|
|
32
|
+
}): Promise<Parse>;
|
|
33
|
+
/**
|
|
34
|
+
* Parse a Malloy document by contents.
|
|
35
|
+
*
|
|
36
|
+
* @param url The URL of the Malloy document to parse (optional).
|
|
37
|
+
* @param source The contents of the Malloy document to parse.
|
|
38
|
+
* @returns A `Parse` result.
|
|
39
|
+
*/
|
|
40
|
+
static parse({ source, url }: {
|
|
41
|
+
url?: URL;
|
|
42
|
+
source: string;
|
|
43
|
+
}): Parse;
|
|
44
|
+
/**
|
|
45
|
+
* Compile a parsed Malloy document.
|
|
46
|
+
*
|
|
47
|
+
* @param urlReader Object capable of reading contents of a URL.
|
|
48
|
+
* @param connections Mapping of connection names to objects capable of reading Malloy schemas.
|
|
49
|
+
* @param parse The parsed Malloy document.
|
|
50
|
+
* @param model A compiled model to build upon (optional).
|
|
51
|
+
* @returns A (promise of a) compiled `Model`.
|
|
52
|
+
*/
|
|
53
|
+
static compile({ urlReader, connections, parse, model, }: {
|
|
54
|
+
urlReader: URLReader;
|
|
55
|
+
connections: LookupConnection<InfoConnection>;
|
|
56
|
+
parse: Parse;
|
|
57
|
+
model?: Model;
|
|
58
|
+
}): Promise<Model>;
|
|
59
|
+
private static runSQLBlockAndFetchResultSchema;
|
|
60
|
+
/**
|
|
61
|
+
* Run a fully-prepared query.
|
|
62
|
+
*
|
|
63
|
+
* @param get A mapping from connection names to objects capable of running SQL.
|
|
64
|
+
* @param preparedResult A fully-prepared query which is ready to run (a `PreparedResult`).
|
|
65
|
+
* @returns Query result data and associated metadata.
|
|
66
|
+
*/
|
|
67
|
+
static run(params: {
|
|
68
|
+
connections: LookupConnection<Connection>;
|
|
69
|
+
preparedResult: PreparedResult;
|
|
70
|
+
options?: RunSQLOptions;
|
|
71
|
+
}): Promise<Result>;
|
|
72
|
+
static run(params: {
|
|
73
|
+
connection: Connection;
|
|
74
|
+
preparedResult: PreparedResult;
|
|
75
|
+
options?: RunSQLOptions;
|
|
76
|
+
}): Promise<Result>;
|
|
77
|
+
static run(params: {
|
|
78
|
+
connection: Connection;
|
|
79
|
+
sqlBlock: SQLBlock;
|
|
80
|
+
options?: RunSQLOptions;
|
|
81
|
+
}): Promise<Result>;
|
|
82
|
+
static run(params: {
|
|
83
|
+
connections: LookupConnection<Connection>;
|
|
84
|
+
sqlBlock: SQLBlock;
|
|
85
|
+
options?: RunSQLOptions;
|
|
86
|
+
}): Promise<Result>;
|
|
87
|
+
static run(params: {
|
|
88
|
+
connection: Connection;
|
|
89
|
+
sqlBlock: SQLBlock;
|
|
90
|
+
options?: RunSQLOptions;
|
|
91
|
+
}): Promise<Result>;
|
|
92
|
+
static run(params: {
|
|
93
|
+
connections: LookupConnection<Connection>;
|
|
94
|
+
sqlBlock: SQLBlock;
|
|
95
|
+
options?: RunSQLOptions;
|
|
96
|
+
}): Promise<Result>;
|
|
97
|
+
static runStream(params: {
|
|
98
|
+
connections: LookupConnection<Connection>;
|
|
99
|
+
preparedResult: PreparedResult;
|
|
100
|
+
options?: RunSQLOptions;
|
|
101
|
+
}): AsyncIterableIterator<DataRecord>;
|
|
102
|
+
static runStream(params: {
|
|
103
|
+
connection: Connection;
|
|
104
|
+
preparedResult: PreparedResult;
|
|
105
|
+
options?: RunSQLOptions;
|
|
106
|
+
}): AsyncIterableIterator<DataRecord>;
|
|
107
|
+
static runStream(params: {
|
|
108
|
+
connection: Connection;
|
|
109
|
+
sqlBlock: SQLBlock;
|
|
110
|
+
options?: RunSQLOptions;
|
|
111
|
+
}): AsyncIterableIterator<DataRecord>;
|
|
112
|
+
static runStream(params: {
|
|
113
|
+
connections: LookupConnection<Connection>;
|
|
114
|
+
sqlBlock: SQLBlock;
|
|
115
|
+
options?: RunSQLOptions;
|
|
116
|
+
}): AsyncIterableIterator<DataRecord>;
|
|
117
|
+
static runStream(params: {
|
|
118
|
+
connection: Connection;
|
|
119
|
+
sqlBlock: SQLBlock;
|
|
120
|
+
options?: RunSQLOptions;
|
|
121
|
+
}): AsyncIterableIterator<DataRecord>;
|
|
122
|
+
static runStream(params: {
|
|
123
|
+
connections: LookupConnection<Connection>;
|
|
124
|
+
sqlBlock: SQLBlock;
|
|
125
|
+
options?: RunSQLOptions;
|
|
126
|
+
}): AsyncIterableIterator<DataRecord>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A Malloy error, which may contain log messages produced during compilation.
|
|
130
|
+
*/
|
|
131
|
+
export declare class MalloyError extends Error {
|
|
132
|
+
/**
|
|
133
|
+
* An array of log messages produced during compilation.
|
|
134
|
+
*/
|
|
135
|
+
readonly log: LogMessage[];
|
|
136
|
+
constructor(message: string, log?: LogMessage[]);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A compiled Malloy document.
|
|
140
|
+
*/
|
|
141
|
+
export declare class Model {
|
|
142
|
+
private modelDef;
|
|
143
|
+
private queryList;
|
|
144
|
+
private sqlBlocks;
|
|
145
|
+
_referenceAt: (location: ModelDocumentPosition) => DocumentReference | undefined;
|
|
146
|
+
constructor(modelDef: ModelDef, queryList: InternalQuery[], sqlBlocks: SQLBlock[], referenceAt?: (location: ModelDocumentPosition) => DocumentReference | undefined);
|
|
147
|
+
/**
|
|
148
|
+
* Retrieve a document reference for the token at the given position within
|
|
149
|
+
* the document that produced this model.
|
|
150
|
+
*
|
|
151
|
+
* @param position A position within the document.
|
|
152
|
+
* @returns A `DocumentReference` at that position if one exists.
|
|
153
|
+
*/
|
|
154
|
+
getReference(position: ModelDocumentPosition): DocumentReference | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* Retrieve a prepared query by the name of a query at the top level of the model.
|
|
157
|
+
*
|
|
158
|
+
* @param queryName Name of the query to retrieve.
|
|
159
|
+
* @returns A prepared query.
|
|
160
|
+
*/
|
|
161
|
+
getPreparedQueryByName(queryName: string): PreparedQuery;
|
|
162
|
+
/**
|
|
163
|
+
* Retrieve a prepared query by the index of an unnamed query at the top level of a model.
|
|
164
|
+
*
|
|
165
|
+
* @param index The index of the query to retrieve.
|
|
166
|
+
* @returns A prepared query.
|
|
167
|
+
*/
|
|
168
|
+
getPreparedQueryByIndex(index: number): PreparedQuery;
|
|
169
|
+
/**
|
|
170
|
+
* Retrieve a prepared query by the name of a query at the top level of the model.
|
|
171
|
+
*
|
|
172
|
+
* @param queryName Name of the query to retrieve.
|
|
173
|
+
* @returns A prepared query.
|
|
174
|
+
*/
|
|
175
|
+
getSQLBlockByName(sqlBlockName: string): SQLBlock;
|
|
176
|
+
/**
|
|
177
|
+
* Retrieve a prepared query by the name of a query at the top level of the model.
|
|
178
|
+
*
|
|
179
|
+
* @param index Index of the SQL Block to retrieve.
|
|
180
|
+
* @returns A prepared query.
|
|
181
|
+
*/
|
|
182
|
+
getSQLBlockByIndex(index: number): SQLBlock;
|
|
183
|
+
/**
|
|
184
|
+
* Retrieve a prepared query for the final unnamed query at the top level of a model.
|
|
185
|
+
*
|
|
186
|
+
* @returns A prepared query.
|
|
187
|
+
*/
|
|
188
|
+
get preparedQuery(): PreparedQuery;
|
|
189
|
+
/**
|
|
190
|
+
* Retrieve an `Explore` from the model by name.
|
|
191
|
+
*
|
|
192
|
+
* @param name The name of the `Explore` to retrieve.
|
|
193
|
+
* @returns An `Explore`.
|
|
194
|
+
*/
|
|
195
|
+
getExploreByName(name: string): Explore;
|
|
196
|
+
/**
|
|
197
|
+
* Get an array of `Explore`s contained in the model.
|
|
198
|
+
*
|
|
199
|
+
* @returns An array of `Explore`s contained in the model.
|
|
200
|
+
*/
|
|
201
|
+
get explores(): Explore[];
|
|
202
|
+
get exportedExplores(): Explore[];
|
|
203
|
+
get _modelDef(): ModelDef;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* A prepared query which has all the necessary information to produce its SQL.
|
|
207
|
+
*/
|
|
208
|
+
export declare class PreparedQuery {
|
|
209
|
+
private _modelDef;
|
|
210
|
+
private _query;
|
|
211
|
+
private name?;
|
|
212
|
+
constructor(query: InternalQuery, model: ModelDef, name?: string);
|
|
213
|
+
/**
|
|
214
|
+
* Generate the SQL for this query.
|
|
215
|
+
*
|
|
216
|
+
* @returns A fully-prepared query (which contains the generated SQL).
|
|
217
|
+
*/
|
|
218
|
+
get preparedResult(): PreparedResult;
|
|
219
|
+
get dialect(): string;
|
|
220
|
+
}
|
|
221
|
+
export declare function parseTableURL(tableURL: string): {
|
|
222
|
+
connectionName?: string;
|
|
223
|
+
tablePath: string;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* A parsed Malloy document.
|
|
227
|
+
*/
|
|
228
|
+
export declare class Parse {
|
|
229
|
+
private translator;
|
|
230
|
+
constructor(translator: MalloyTranslator);
|
|
231
|
+
/**
|
|
232
|
+
* Retrieve the document highlights for the parsed document.
|
|
233
|
+
*
|
|
234
|
+
* These highlights represent the parsed tokens contained in the document,
|
|
235
|
+
* and may be used for syntax highlighting in an IDE, for example.
|
|
236
|
+
*
|
|
237
|
+
* @returns An array of document highlights.
|
|
238
|
+
*/
|
|
239
|
+
get highlights(): DocumentHighlight[];
|
|
240
|
+
/**
|
|
241
|
+
* Retrieve the symbols defined in the parsed document.
|
|
242
|
+
*
|
|
243
|
+
* These symbols represent any object defined (e.g. `Query`s and `Explore`s)
|
|
244
|
+
* in the document.
|
|
245
|
+
*
|
|
246
|
+
* @returns An array of document symbols.
|
|
247
|
+
*/
|
|
248
|
+
get symbols(): DocumentSymbol[];
|
|
249
|
+
get _translator(): MalloyTranslator;
|
|
250
|
+
completions(position: {
|
|
251
|
+
line: number;
|
|
252
|
+
character: number;
|
|
253
|
+
}): DocumentCompletion[];
|
|
254
|
+
helpContext(position: {
|
|
255
|
+
line: number;
|
|
256
|
+
character: number;
|
|
257
|
+
}): DocumentHelpContext | undefined;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* A document highlight.
|
|
261
|
+
*
|
|
262
|
+
* Represents a parsed token contained in a Malloy document
|
|
263
|
+
* and may be used for syntax highlighting in an IDE, for example.
|
|
264
|
+
*/
|
|
265
|
+
export declare class DocumentHighlight {
|
|
266
|
+
private _range;
|
|
267
|
+
private _type;
|
|
268
|
+
constructor(documentHighlight: DocumentHighlightDefinition);
|
|
269
|
+
/**
|
|
270
|
+
* @returns The range of characters this highlight spans within its source document.
|
|
271
|
+
*/
|
|
272
|
+
get range(): DocumentRange;
|
|
273
|
+
/**
|
|
274
|
+
* @returns The type of highlight, which may be any `HighlightType`.
|
|
275
|
+
*/
|
|
276
|
+
get type(): string;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* A range of characters within a Malloy document.
|
|
280
|
+
*/
|
|
281
|
+
export declare class DocumentRange {
|
|
282
|
+
private _start;
|
|
283
|
+
private _end;
|
|
284
|
+
constructor(start: DocumentPosition, end: DocumentPosition);
|
|
285
|
+
/**
|
|
286
|
+
* @returns The position of the first character in the range.
|
|
287
|
+
*/
|
|
288
|
+
get start(): DocumentPosition;
|
|
289
|
+
/**
|
|
290
|
+
* @returns The position of the last character in the range.
|
|
291
|
+
*/
|
|
292
|
+
get end(): DocumentPosition;
|
|
293
|
+
/**
|
|
294
|
+
* @returns This range in JSON format.
|
|
295
|
+
*/
|
|
296
|
+
toJSON(): {
|
|
297
|
+
start: {
|
|
298
|
+
line: number;
|
|
299
|
+
character: number;
|
|
300
|
+
};
|
|
301
|
+
end: {
|
|
302
|
+
line: number;
|
|
303
|
+
character: number;
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* A position within a Malloy document.
|
|
309
|
+
*/
|
|
310
|
+
export declare class DocumentPosition {
|
|
311
|
+
private _line;
|
|
312
|
+
private _character;
|
|
313
|
+
constructor(line: number, character: number);
|
|
314
|
+
/**
|
|
315
|
+
* @returns The line number of the position.
|
|
316
|
+
*/
|
|
317
|
+
get line(): number;
|
|
318
|
+
/**
|
|
319
|
+
* @returns The character index on the line `this.getLine()`.
|
|
320
|
+
*/
|
|
321
|
+
get character(): number;
|
|
322
|
+
/**
|
|
323
|
+
* @returns This position in JSON format.
|
|
324
|
+
*/
|
|
325
|
+
toJSON(): {
|
|
326
|
+
line: number;
|
|
327
|
+
character: number;
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* A symbol defined in a Malloy document.
|
|
332
|
+
*
|
|
333
|
+
* Represents any object defined (e.g. `Query`s and `Explore`s) in the document.
|
|
334
|
+
*/
|
|
335
|
+
export declare class DocumentSymbol {
|
|
336
|
+
private _range;
|
|
337
|
+
private _type;
|
|
338
|
+
private _name;
|
|
339
|
+
private _children;
|
|
340
|
+
constructor(documentSymbol: DocumentSymbolDefinition);
|
|
341
|
+
/**
|
|
342
|
+
* @returns The range of characters in the source Malloy document that define this symbol.
|
|
343
|
+
*/
|
|
344
|
+
get range(): DocumentRange;
|
|
345
|
+
/**
|
|
346
|
+
* @returns The type of symbol.
|
|
347
|
+
*
|
|
348
|
+
* Possible values are: `"explore"`, `"query"`, `"field"`, `"turtle"`, `"join"`, or `"unnamed_query"`.
|
|
349
|
+
*/
|
|
350
|
+
get type(): string;
|
|
351
|
+
/**
|
|
352
|
+
* @returns The name of this symbol, e.g. the `Explore` name or `Query` name.
|
|
353
|
+
*
|
|
354
|
+
* For type `"unnamed_query"`, `getName()` is `"unnamed_query"`.
|
|
355
|
+
*/
|
|
356
|
+
get name(): string;
|
|
357
|
+
/**
|
|
358
|
+
* @returns An array of document symbols defined inside this document symbol,
|
|
359
|
+
* e.g. fields in an `Explore`.
|
|
360
|
+
*/
|
|
361
|
+
get children(): DocumentSymbol[];
|
|
362
|
+
}
|
|
363
|
+
export declare class DocumentCompletion {
|
|
364
|
+
readonly type: string;
|
|
365
|
+
readonly text: string;
|
|
366
|
+
constructor(completion: DocumentCompletionDefinition);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* A fully-prepared query containing SQL and metadata required to run the query.
|
|
370
|
+
*/
|
|
371
|
+
export declare class PreparedResult {
|
|
372
|
+
protected inner: CompiledQuery;
|
|
373
|
+
protected modelDef: ModelDef;
|
|
374
|
+
constructor(query: CompiledQuery, modelDef: ModelDef);
|
|
375
|
+
/**
|
|
376
|
+
* @returns The name of the connection this query should be run against.
|
|
377
|
+
*/
|
|
378
|
+
get connectionName(): string;
|
|
379
|
+
get _rawQuery(): CompiledQuery;
|
|
380
|
+
get _modelDef(): ModelDef;
|
|
381
|
+
/**
|
|
382
|
+
* @returns The SQL that should be run against the SQL runner
|
|
383
|
+
* with the connection name `this.getConnectionName()`.
|
|
384
|
+
*/
|
|
385
|
+
get sql(): string;
|
|
386
|
+
/**
|
|
387
|
+
* @returns The `Explore` representing the data that will be returned by running this query.
|
|
388
|
+
*/
|
|
389
|
+
get resultExplore(): Explore;
|
|
390
|
+
get sourceExplore(): Explore;
|
|
391
|
+
get _sourceExploreName(): string;
|
|
392
|
+
get _sourceFilters(): FilterExpression[];
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* A URL reader which always throws an error when a URL's contents is requested.
|
|
396
|
+
*
|
|
397
|
+
* Useful for scenarios in which `import` statements are not required.
|
|
398
|
+
*/
|
|
399
|
+
export declare class EmptyURLReader implements URLReader {
|
|
400
|
+
readURL(_url: URL): Promise<string>;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* A URL reader backed by an in-memory mapping of URL contents.
|
|
404
|
+
*/
|
|
405
|
+
export declare class InMemoryURLReader implements URLReader {
|
|
406
|
+
private files;
|
|
407
|
+
constructor(files: Map<string, string>);
|
|
408
|
+
readURL(url: URL): Promise<string>;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* A fixed mapping of connection names to connections.
|
|
412
|
+
*/
|
|
413
|
+
export declare class FixedConnectionMap implements LookupConnection<Connection> {
|
|
414
|
+
private connections;
|
|
415
|
+
private defaultConnectionName?;
|
|
416
|
+
constructor(connections: Map<string, Connection>, defaultConnectionName?: string);
|
|
417
|
+
/**
|
|
418
|
+
* Get a connection by name.
|
|
419
|
+
*
|
|
420
|
+
* @param connectionName The name of the connection to look up.
|
|
421
|
+
* @returns A `Connection`
|
|
422
|
+
* @throws An `Error` if no connection with the given name exists.
|
|
423
|
+
*/
|
|
424
|
+
getConnection(connectionName?: string): Promise<Connection>;
|
|
425
|
+
lookupConnection(connectionName?: string): Promise<Connection>;
|
|
426
|
+
static fromArray(connections: Connection[]): FixedConnectionMap;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* The relationship of an `Explore` to its source.
|
|
430
|
+
*/
|
|
431
|
+
export declare enum SourceRelationship {
|
|
432
|
+
/**
|
|
433
|
+
* The `Explore` is nested data within the source's rows.
|
|
434
|
+
*/
|
|
435
|
+
Nested = "nested",
|
|
436
|
+
/**
|
|
437
|
+
* The `Explore` is the base table.
|
|
438
|
+
*/
|
|
439
|
+
BaseTable = "base_table",
|
|
440
|
+
/**
|
|
441
|
+
* The `Explore` is joined to its source
|
|
442
|
+
*/
|
|
443
|
+
Cross = "cross",
|
|
444
|
+
One = "one",
|
|
445
|
+
Many = "many",
|
|
446
|
+
Inline = "inline"
|
|
447
|
+
}
|
|
448
|
+
declare abstract class Entity {
|
|
449
|
+
private readonly _name;
|
|
450
|
+
protected readonly _parent?: Explore;
|
|
451
|
+
private readonly _source?;
|
|
452
|
+
constructor(name: string, parent?: Explore, source?: Entity);
|
|
453
|
+
get source(): Entity | undefined;
|
|
454
|
+
get name(): string;
|
|
455
|
+
get sourceClasses(): string[];
|
|
456
|
+
hasParentExplore(): this is Field;
|
|
457
|
+
isExplore(): this is Explore;
|
|
458
|
+
isQuery(): this is Query;
|
|
459
|
+
abstract isIntrinsic(): boolean;
|
|
460
|
+
}
|
|
461
|
+
export declare type Field = AtomicField | QueryField | ExploreField;
|
|
462
|
+
export declare class Explore extends Entity {
|
|
463
|
+
protected readonly _structDef: StructDef;
|
|
464
|
+
protected readonly _parentExplore?: Explore;
|
|
465
|
+
private _fieldMap;
|
|
466
|
+
private sourceExplore;
|
|
467
|
+
constructor(structDef: StructDef, parentExplore?: Explore, source?: Explore);
|
|
468
|
+
get source(): Explore | undefined;
|
|
469
|
+
isIntrinsic(): boolean;
|
|
470
|
+
/**
|
|
471
|
+
* @returns The name of the entity.
|
|
472
|
+
*/
|
|
473
|
+
get name(): string;
|
|
474
|
+
getQueryByName(name: string): PreparedQuery;
|
|
475
|
+
private get modelDef();
|
|
476
|
+
getSingleExploreModel(): Model;
|
|
477
|
+
private get fieldMap();
|
|
478
|
+
get allFields(): Field[];
|
|
479
|
+
get intrinsicFields(): Field[];
|
|
480
|
+
getFieldByName(fieldName: string): Field;
|
|
481
|
+
getFieldByNameIfExists(fieldName: string): Field | undefined;
|
|
482
|
+
get primaryKey(): string | undefined;
|
|
483
|
+
get parentExplore(): Explore | undefined;
|
|
484
|
+
get sourceRelationship(): SourceRelationship;
|
|
485
|
+
hasParentExplore(): this is ExploreField;
|
|
486
|
+
get filters(): FilterExpression[];
|
|
487
|
+
get limit(): number | undefined;
|
|
488
|
+
get structDef(): StructDef;
|
|
489
|
+
}
|
|
490
|
+
export declare enum AtomicFieldType {
|
|
491
|
+
String = "string",
|
|
492
|
+
Number = "number",
|
|
493
|
+
Boolean = "boolean",
|
|
494
|
+
Date = "date",
|
|
495
|
+
Timestamp = "timestamp"
|
|
496
|
+
}
|
|
497
|
+
export declare class AtomicField extends Entity {
|
|
498
|
+
protected fieldTypeDef: FieldTypeDef;
|
|
499
|
+
protected parent: Explore;
|
|
500
|
+
constructor(fieldTypeDef: FieldTypeDef, parent: Explore, source?: AtomicField);
|
|
501
|
+
get type(): AtomicFieldType;
|
|
502
|
+
isIntrinsic(): boolean;
|
|
503
|
+
isQueryField(): this is QueryField;
|
|
504
|
+
isExploreField(): this is ExploreField;
|
|
505
|
+
isAtomicField(): this is AtomicField;
|
|
506
|
+
isAggregate(): boolean;
|
|
507
|
+
get sourceField(): Field;
|
|
508
|
+
get sourceClasses(): string[];
|
|
509
|
+
sourceWasMeasure(): boolean;
|
|
510
|
+
sourceWasMeasureLike(): boolean;
|
|
511
|
+
sourceWasDimension(): boolean;
|
|
512
|
+
hasParentExplore(): this is Field;
|
|
513
|
+
isString(): this is StringField;
|
|
514
|
+
isNumber(): this is NumberField;
|
|
515
|
+
isDate(): this is DateField;
|
|
516
|
+
isBoolean(): this is BooleanField;
|
|
517
|
+
isTimestamp(): this is TimestampField;
|
|
518
|
+
get parentExplore(): Explore;
|
|
519
|
+
get expression(): string;
|
|
520
|
+
}
|
|
521
|
+
export declare enum DateTimeframe {
|
|
522
|
+
Day = "day",
|
|
523
|
+
Week = "week",
|
|
524
|
+
Month = "month",
|
|
525
|
+
Quarter = "quarter",
|
|
526
|
+
Year = "year"
|
|
527
|
+
}
|
|
528
|
+
export declare enum TimestampTimeframe {
|
|
529
|
+
Day = "day",
|
|
530
|
+
Week = "week",
|
|
531
|
+
Month = "month",
|
|
532
|
+
Quarter = "quarter",
|
|
533
|
+
Year = "year",
|
|
534
|
+
Second = "second",
|
|
535
|
+
Hour = "hour",
|
|
536
|
+
Minute = "minute"
|
|
537
|
+
}
|
|
538
|
+
export declare class DateField extends AtomicField {
|
|
539
|
+
private fieldDateDef;
|
|
540
|
+
constructor(fieldDateDef: FieldDateDef, parent: Explore, source?: AtomicField);
|
|
541
|
+
get timeframe(): DateTimeframe | undefined;
|
|
542
|
+
}
|
|
543
|
+
export declare class TimestampField extends AtomicField {
|
|
544
|
+
private fieldTimestampDef;
|
|
545
|
+
constructor(fieldTimestampDef: FieldTimestampDef, parent: Explore, source?: AtomicField);
|
|
546
|
+
get timeframe(): TimestampTimeframe | undefined;
|
|
547
|
+
}
|
|
548
|
+
export declare class NumberField extends AtomicField {
|
|
549
|
+
private fieldNumberDef;
|
|
550
|
+
constructor(fieldNumberDef: FieldNumberDef, parent: Explore, source?: AtomicField);
|
|
551
|
+
}
|
|
552
|
+
export declare class BooleanField extends AtomicField {
|
|
553
|
+
private fieldBooleanDef;
|
|
554
|
+
constructor(fieldBooleanDef: FieldBooleanDef, parent: Explore, source?: AtomicField);
|
|
555
|
+
}
|
|
556
|
+
export declare class StringField extends AtomicField {
|
|
557
|
+
private fieldStringDef;
|
|
558
|
+
constructor(fieldStringDef: FieldStringDef, parent: Explore, source?: AtomicField);
|
|
559
|
+
}
|
|
560
|
+
export declare class Query extends Entity {
|
|
561
|
+
protected turtleDef: TurtleDef;
|
|
562
|
+
private sourceQuery?;
|
|
563
|
+
constructor(turtleDef: TurtleDef, parent?: Explore, source?: Query);
|
|
564
|
+
get source(): Query | undefined;
|
|
565
|
+
isIntrinsic(): boolean;
|
|
566
|
+
}
|
|
567
|
+
export declare class QueryField extends Query {
|
|
568
|
+
protected parent: Explore;
|
|
569
|
+
constructor(turtleDef: TurtleDef, parent: Explore, source?: Query);
|
|
570
|
+
isQueryField(): this is QueryField;
|
|
571
|
+
isExploreField(): this is ExploreField;
|
|
572
|
+
isAtomicField(): this is AtomicField;
|
|
573
|
+
get sourceClasses(): string[];
|
|
574
|
+
hasParentExplore(): this is Field;
|
|
575
|
+
get parentExplore(): Explore;
|
|
576
|
+
get expression(): string;
|
|
577
|
+
}
|
|
578
|
+
export declare enum JoinRelationship {
|
|
579
|
+
OneToOne = "one_to_one",
|
|
580
|
+
OneToMany = "one_to_many",
|
|
581
|
+
ManyToOne = "many_to_one"
|
|
582
|
+
}
|
|
583
|
+
export declare class ExploreField extends Explore {
|
|
584
|
+
protected _parentExplore: Explore;
|
|
585
|
+
constructor(structDef: StructDef, parentExplore: Explore, source?: Explore);
|
|
586
|
+
get joinRelationship(): JoinRelationship;
|
|
587
|
+
isQueryField(): this is QueryField;
|
|
588
|
+
isExploreField(): this is ExploreField;
|
|
589
|
+
isAtomicField(): this is AtomicField;
|
|
590
|
+
get parentExplore(): Explore;
|
|
591
|
+
get sourceClasses(): string[];
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* An environment for compiling and running Malloy queries.
|
|
595
|
+
*/
|
|
596
|
+
export declare class Runtime {
|
|
597
|
+
private _urlReader;
|
|
598
|
+
private _connections;
|
|
599
|
+
constructor(runtime: LookupConnection<Connection> & URLReader);
|
|
600
|
+
constructor(urls: URLReader, connections: LookupConnection<Connection>);
|
|
601
|
+
constructor(urls: URLReader, connection: Connection);
|
|
602
|
+
constructor(connection: Connection);
|
|
603
|
+
constructor(connections: LookupConnection<Connection>);
|
|
604
|
+
/**
|
|
605
|
+
* @returns The `URLReader` for this runtime instance.
|
|
606
|
+
*/
|
|
607
|
+
get urlReader(): URLReader;
|
|
608
|
+
/**
|
|
609
|
+
* @returns The `LookupConnection<Connection>` for this runtime instance.
|
|
610
|
+
*/
|
|
611
|
+
get connections(): LookupConnection<Connection>;
|
|
612
|
+
/**
|
|
613
|
+
* Load a Malloy model by URL or contents.
|
|
614
|
+
*
|
|
615
|
+
* @param source The model URL or contents to load and (eventually) compile.
|
|
616
|
+
* @returns A `ModelMaterializer` capable of materializing the requested model,
|
|
617
|
+
* or loading further related objects.
|
|
618
|
+
*/
|
|
619
|
+
loadModel(source: ModelURL | ModelString): ModelMaterializer;
|
|
620
|
+
_loadModelFromModelDef(modelDef: ModelDef): ModelMaterializer;
|
|
621
|
+
/**
|
|
622
|
+
* Load a Malloy query by URL or contents.
|
|
623
|
+
*
|
|
624
|
+
* @param query The query URL or contents to load and (eventually) compile.
|
|
625
|
+
* @returns A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
626
|
+
* or loading further related objects.
|
|
627
|
+
*/
|
|
628
|
+
loadQuery(query: QueryURL | QueryString): QueryMaterializer;
|
|
629
|
+
/**
|
|
630
|
+
* Load a Malloy query by the URL or contents of a Malloy model document
|
|
631
|
+
* and the index of an unnamed query contained in the model.
|
|
632
|
+
*
|
|
633
|
+
* @param model The model URL or contents to load and (eventually) compile to retrieve the requested query.
|
|
634
|
+
* @param index The index of the query to use within the model.
|
|
635
|
+
* @returns A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
636
|
+
* or loading further related objects.
|
|
637
|
+
*/
|
|
638
|
+
loadQueryByIndex(model: ModelURL | ModelString, index: number): QueryMaterializer;
|
|
639
|
+
/**
|
|
640
|
+
* Load a Malloy query by the URL or contents of a Malloy model document
|
|
641
|
+
* and the name of a query contained in the model.
|
|
642
|
+
*
|
|
643
|
+
* @param model The model URL or contents to load and (eventually) compile to retrieve the requested query.
|
|
644
|
+
* @param name The name of the query to use within the model.
|
|
645
|
+
* @returns A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
646
|
+
* or loading further related objects.
|
|
647
|
+
*/
|
|
648
|
+
loadQueryByName(model: ModelURL | ModelString, name: string): QueryMaterializer;
|
|
649
|
+
/**
|
|
650
|
+
* Load a SQL block by the URL or contents of a Malloy model document
|
|
651
|
+
* and the name of a query contained in the model.
|
|
652
|
+
*
|
|
653
|
+
* @param model The model URL or contents to load and (eventually) compile to retrieve the requested query.
|
|
654
|
+
* @param name The name of the sql block to use within the model.
|
|
655
|
+
* @returns A `SQLBlockMaterializer` capable of materializing the requested query, running it,
|
|
656
|
+
* or loading further related objects.
|
|
657
|
+
*/
|
|
658
|
+
loadSQLBlockByName(model: ModelURL | ModelString, name: string): SQLBlockMaterializer;
|
|
659
|
+
/**
|
|
660
|
+
* Load a SQL block by the URL or contents of a Malloy model document
|
|
661
|
+
* and the name of a query contained in the model.
|
|
662
|
+
*
|
|
663
|
+
* @param model The model URL or contents to load and (eventually) compile to retrieve the requested query.
|
|
664
|
+
* @param index The index of the SQL block to use within the model. Note: named blocks are indexable, too.
|
|
665
|
+
* @returns A `SQLBlockMaterializer` capable of materializing the requested query, running it,
|
|
666
|
+
* or loading further related objects.
|
|
667
|
+
*/
|
|
668
|
+
loadSQLBlockByIndex(model: ModelURL | ModelString, index: number): SQLBlockMaterializer;
|
|
669
|
+
/**
|
|
670
|
+
* Compile a Malloy model by URL or contents.
|
|
671
|
+
*
|
|
672
|
+
* @param source The URL or contents of a Malloy model document to compile.
|
|
673
|
+
* @returns A promise of a compiled `Model`.
|
|
674
|
+
*/
|
|
675
|
+
getModel(source: ModelURL | ModelString): Promise<Model>;
|
|
676
|
+
/**
|
|
677
|
+
* Compile a Malloy query by URL or contents.
|
|
678
|
+
*
|
|
679
|
+
* @param query The URL or contents of a Malloy query document to compile.
|
|
680
|
+
* @returns A promise of a compiled `PreparedQuery`.
|
|
681
|
+
*/
|
|
682
|
+
getQuery(query: QueryURL | QueryString): Promise<PreparedQuery>;
|
|
683
|
+
/**
|
|
684
|
+
* Compile a Malloy query by the URL or contents of a model document
|
|
685
|
+
* and the index of an unnamed query contained within the model.
|
|
686
|
+
*
|
|
687
|
+
* @param model The URL or contents of a Malloy model document to compile.
|
|
688
|
+
* @param index The index of an unnamed query contained within the model.
|
|
689
|
+
* @returns A promise of a compiled `PreparedQuery`.
|
|
690
|
+
*/
|
|
691
|
+
getQueryByIndex(model: ModelURL | ModelString, index: number): Promise<PreparedQuery>;
|
|
692
|
+
/**
|
|
693
|
+
* Compile a Malloy query by the URL or contents of a model document
|
|
694
|
+
* and the name of a query contained within the model.
|
|
695
|
+
*
|
|
696
|
+
* @param model The URL or contents of a Malloy model document to compile.
|
|
697
|
+
* @param name The name of a query contained within the model.
|
|
698
|
+
* @returns A promise of a compiled `PreparedQuery`.
|
|
699
|
+
*/
|
|
700
|
+
getQueryByName(model: ModelURL | ModelString, name: string): Promise<PreparedQuery>;
|
|
701
|
+
/**
|
|
702
|
+
* Get a SQL block by the URL or contents of a Malloy model document
|
|
703
|
+
* and the name of a SQL block contained in the model.
|
|
704
|
+
*
|
|
705
|
+
* @param model The model URL or contents to load and (eventually) compile to retrieve the requested query.
|
|
706
|
+
* @param name The name of the sql block to use within the model.
|
|
707
|
+
* @returns A promise of a `SQLBlock`.
|
|
708
|
+
*/
|
|
709
|
+
getSQLBlockByName(model: ModelURL | ModelString, name: string): Promise<SQLBlock>;
|
|
710
|
+
/**
|
|
711
|
+
* Get a SQL block by the URL or contents of a Malloy model document
|
|
712
|
+
* and the name of a query contained in the model.
|
|
713
|
+
*
|
|
714
|
+
* @param model The model URL or contents to load and (eventually) compile to retrieve the requested query.
|
|
715
|
+
* @param index The index of the SQL block to use within the model. Note: named blocks are indexable, too.
|
|
716
|
+
* @returns A promise of a `SQLBlock`.
|
|
717
|
+
*/
|
|
718
|
+
getSQLBlockByIndex(model: ModelURL | ModelString, index: number): Promise<SQLBlock>;
|
|
719
|
+
}
|
|
720
|
+
export declare class ConnectionRuntime extends Runtime {
|
|
721
|
+
readonly rawConnections: Connection[];
|
|
722
|
+
constructor(urls: URLReader, connections: Connection[]);
|
|
723
|
+
constructor(connections: Connection[]);
|
|
724
|
+
}
|
|
725
|
+
export declare class SingleConnectionRuntime<T extends Connection = Connection> extends Runtime {
|
|
726
|
+
readonly connection: T;
|
|
727
|
+
constructor(urls: URLReader, connection: T);
|
|
728
|
+
constructor(connection: T);
|
|
729
|
+
}
|
|
730
|
+
declare class FluentState<T> {
|
|
731
|
+
protected runtime: Runtime;
|
|
732
|
+
private readonly _materialize;
|
|
733
|
+
private materialized;
|
|
734
|
+
constructor(runtime: Runtime, materialize: () => Promise<T>);
|
|
735
|
+
protected materialize(): Promise<T>;
|
|
736
|
+
protected rematerialize(): Promise<T>;
|
|
737
|
+
protected makeQueryMaterializer(materialize: () => Promise<PreparedQuery>): QueryMaterializer;
|
|
738
|
+
protected makeExploreMaterializer(materialize: () => Promise<Explore>): ExploreMaterializer;
|
|
739
|
+
protected makePreparedResultMaterializer(materialize: () => Promise<PreparedResult>): PreparedResultMaterializer;
|
|
740
|
+
protected makeSQLBlockMaterializer(materialize: () => Promise<SQLBlock>): SQLBlockMaterializer;
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* An object representing the task of loading a `Model`, capable of
|
|
744
|
+
* materializing that model (via `getModel()`) or extending the task to load
|
|
745
|
+
* queries or explores (via e.g. `loadFinalQuery()`, `loadQuery`, `loadExploreByName`, etc.).
|
|
746
|
+
*/
|
|
747
|
+
export declare class ModelMaterializer extends FluentState<Model> {
|
|
748
|
+
/**
|
|
749
|
+
* Load the final (unnamed) Malloy query contained within this loaded `Model`.
|
|
750
|
+
*
|
|
751
|
+
* @returns A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
752
|
+
* or loading further related objects.
|
|
753
|
+
*/
|
|
754
|
+
loadFinalQuery(): QueryMaterializer;
|
|
755
|
+
/**
|
|
756
|
+
* Load an unnamed query contained within this loaded `Model` by index.
|
|
757
|
+
*
|
|
758
|
+
* @param index The index of the query to load.
|
|
759
|
+
* @returns A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
760
|
+
* or loading further related objects.
|
|
761
|
+
*/
|
|
762
|
+
loadQueryByIndex(index: number): QueryMaterializer;
|
|
763
|
+
/**
|
|
764
|
+
* Load a query contained within this loaded `Model` by its name.
|
|
765
|
+
*
|
|
766
|
+
* @param name The name of the query to load.
|
|
767
|
+
* @returns A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
768
|
+
* or loading further related objects.
|
|
769
|
+
*/
|
|
770
|
+
loadQueryByName(name: string): QueryMaterializer;
|
|
771
|
+
/**
|
|
772
|
+
* Load a query against this loaded `Model` by its URL or contents.
|
|
773
|
+
*
|
|
774
|
+
* @param query The URL or contents of the query to load and (eventually) compile.
|
|
775
|
+
* @returns A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
776
|
+
* or loading further related objects.
|
|
777
|
+
*/
|
|
778
|
+
loadQuery(query: QueryString | QueryURL): QueryMaterializer;
|
|
779
|
+
search(sourceName: string, searchTerm: string, limit?: number, searchField?: string | undefined): Promise<SearchIndexResult[] | undefined>;
|
|
780
|
+
searchValueMap(sourceName: string, limit?: number): Promise<SearchValueMapResult[] | undefined>;
|
|
781
|
+
/**
|
|
782
|
+
* Load a SQL Block by name.
|
|
783
|
+
*
|
|
784
|
+
* @param name The name of the SQL Block to load.
|
|
785
|
+
* @returns A `SQLBlockMaterializer` capable of materializing the requested sql block, running it,
|
|
786
|
+
* or loading further related objects.
|
|
787
|
+
*/
|
|
788
|
+
loadSQLBlockByName(name: string): SQLBlockMaterializer;
|
|
789
|
+
/**
|
|
790
|
+
* Load a SQL Block by index.
|
|
791
|
+
*
|
|
792
|
+
* @param index The index of the SQL Block to load. Note: named SQL blocks are indexable, too.
|
|
793
|
+
* @returns A `SQLBlockMaterializer` capable of materializing the requested sql block, running it,
|
|
794
|
+
* or loading further related objects.
|
|
795
|
+
*
|
|
796
|
+
* TODO feature-sql-block Should named SQL blocks be indexable? This is not the way unnamed queries work.
|
|
797
|
+
*/
|
|
798
|
+
loadSQLBlockByIndex(index: number): SQLBlockMaterializer;
|
|
799
|
+
/**
|
|
800
|
+
* Materialize the final query contained within this loaded `Model`.
|
|
801
|
+
*
|
|
802
|
+
* @returns A promise to a prepared query.
|
|
803
|
+
*/
|
|
804
|
+
getFinalQuery(): Promise<PreparedQuery>;
|
|
805
|
+
/**
|
|
806
|
+
* Materialize an unnamed query contained within this loaded `Model` by index.
|
|
807
|
+
*
|
|
808
|
+
* @param index The index of the query contained within this loaded `Model`.
|
|
809
|
+
* @returns A promise to a prepared query.
|
|
810
|
+
*/
|
|
811
|
+
getQueryByIndex(index: number): Promise<PreparedQuery>;
|
|
812
|
+
/**
|
|
813
|
+
* Materialize a query contained within this loaded `Model` by name.
|
|
814
|
+
*
|
|
815
|
+
* @param name The name of the query contained within this loaded `Model`.
|
|
816
|
+
* @returns A promise to a prepared query.
|
|
817
|
+
*/
|
|
818
|
+
getQueryByName(name: string): Promise<PreparedQuery>;
|
|
819
|
+
/**
|
|
820
|
+
* Materialize a query against this loaded `Model` by its URL or contents.
|
|
821
|
+
*
|
|
822
|
+
* @param query The URL or contents of a query document to compile.
|
|
823
|
+
* @returns A promise to a prepared query.
|
|
824
|
+
*/
|
|
825
|
+
getQuery(query: QueryString | QueryURL): Promise<PreparedQuery>;
|
|
826
|
+
/**
|
|
827
|
+
* Get a SQL Block by name.
|
|
828
|
+
*
|
|
829
|
+
* @param name The name of the SQL Block to load.
|
|
830
|
+
* @returns A promise of a `SQLBlock`.
|
|
831
|
+
*/
|
|
832
|
+
getSQLBlockByName(name: string): Promise<SQLBlock>;
|
|
833
|
+
/**
|
|
834
|
+
* Get a SQL Block by index.
|
|
835
|
+
*
|
|
836
|
+
* @param index The index of the SQL Block to load. Note: named SQL blocks are indexable, too.
|
|
837
|
+
* @returns A promise of a `SQLBlock`.
|
|
838
|
+
*
|
|
839
|
+
* TODO feature-sql-block Should named SQL blocks be indexable? This is not the way unnamed queries work.
|
|
840
|
+
*/
|
|
841
|
+
getSQLBlockByIndex(index: number): Promise<SQLBlock>;
|
|
842
|
+
_loadQueryFromQueryDef(query: InternalQuery): QueryMaterializer;
|
|
843
|
+
/**
|
|
844
|
+
* Load an explore contained within this loaded `Model` by name.
|
|
845
|
+
*
|
|
846
|
+
* @param name The name of the explore contained within this loaded `Model`.
|
|
847
|
+
* @returns An `ExploreMaterializer` capable of materializing the requested explore,
|
|
848
|
+
* or loading further related objects.
|
|
849
|
+
*/
|
|
850
|
+
loadExploreByName(name: string): ExploreMaterializer;
|
|
851
|
+
/**
|
|
852
|
+
* Materialize an explore contained within this loaded `Model` by its name.
|
|
853
|
+
*
|
|
854
|
+
* @param query The name of an explore within this loaded `Model`.
|
|
855
|
+
* @returns A promise to an explore.
|
|
856
|
+
*/
|
|
857
|
+
getExploreByName(name: string): Promise<Explore>;
|
|
858
|
+
/**
|
|
859
|
+
* Compile and materialize this loaded `Model`.
|
|
860
|
+
*
|
|
861
|
+
* @returns A promise to the compiled model that is loaded.
|
|
862
|
+
*/
|
|
863
|
+
getModel(): Promise<Model>;
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* An object representing the task of loading a `Query`, capable of
|
|
867
|
+
* materializing the query (via `getPreparedQuery()`) or extending the task to load
|
|
868
|
+
* prepared results or run the query (via e.g. `loadPreparedResult()` or `run()`).
|
|
869
|
+
*/
|
|
870
|
+
export declare class QueryMaterializer extends FluentState<PreparedQuery> {
|
|
871
|
+
/**
|
|
872
|
+
* Run this loaded `Query`.
|
|
873
|
+
*
|
|
874
|
+
* @returns The query results from running this loaded query.
|
|
875
|
+
*/
|
|
876
|
+
run(options?: RunSQLOptions): Promise<Result>;
|
|
877
|
+
runStream(options?: {
|
|
878
|
+
rowLimit?: number;
|
|
879
|
+
}): AsyncIterableIterator<DataRecord>;
|
|
880
|
+
/**
|
|
881
|
+
* Load the prepared result of this loaded query.
|
|
882
|
+
*
|
|
883
|
+
* @returns A `PreparedResultMaterializer` capable of materializing the requested
|
|
884
|
+
* prepared query or running it.
|
|
885
|
+
*/
|
|
886
|
+
loadPreparedResult(): PreparedResultMaterializer;
|
|
887
|
+
/**
|
|
888
|
+
* Materialize the prepared result of this loaded query.
|
|
889
|
+
*
|
|
890
|
+
* @returns A promise of the prepared result of this loaded query.
|
|
891
|
+
*/
|
|
892
|
+
getPreparedResult(): Promise<PreparedResult>;
|
|
893
|
+
/**
|
|
894
|
+
* Materialize the SQL of this loaded query.
|
|
895
|
+
*
|
|
896
|
+
* @returns A promise of the SQL string.
|
|
897
|
+
*/
|
|
898
|
+
getSQL(): Promise<string>;
|
|
899
|
+
/**
|
|
900
|
+
* Materialize this loaded query.
|
|
901
|
+
*
|
|
902
|
+
* @returns A promise of the `PreparedQuery`.
|
|
903
|
+
*/
|
|
904
|
+
getPreparedQuery(): Promise<PreparedQuery>;
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* An object representing the task of loading a `PreparedResult`, capable of
|
|
908
|
+
* materializing the prepared result (via `getPreparedResult()`) or extending the task run
|
|
909
|
+
* the query.
|
|
910
|
+
*/
|
|
911
|
+
export declare class PreparedResultMaterializer extends FluentState<PreparedResult> {
|
|
912
|
+
/**
|
|
913
|
+
* Run this prepared result.
|
|
914
|
+
*
|
|
915
|
+
* @returns A promise to the query result data.
|
|
916
|
+
*/
|
|
917
|
+
run(options?: RunSQLOptions): Promise<Result>;
|
|
918
|
+
runStream(options?: {
|
|
919
|
+
rowLimit?: number;
|
|
920
|
+
}): AsyncIterableIterator<DataRecord>;
|
|
921
|
+
/**
|
|
922
|
+
* Materialize this loaded prepared result.
|
|
923
|
+
*
|
|
924
|
+
* @returns A promise of a prepared result.
|
|
925
|
+
*/
|
|
926
|
+
getPreparedResult(): Promise<PreparedResult>;
|
|
927
|
+
/**
|
|
928
|
+
* Materialize the SQL of this loaded prepared result.
|
|
929
|
+
*
|
|
930
|
+
* @returns A promise to the SQL string.
|
|
931
|
+
*/
|
|
932
|
+
getSQL(): Promise<string>;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* An object representing the task of loading a `SQLBlock`, capable of
|
|
936
|
+
* materializing the SQLBlock (via `getSQLBlock()`) or extending the task run
|
|
937
|
+
* the query.
|
|
938
|
+
*/
|
|
939
|
+
export declare class SQLBlockMaterializer extends FluentState<SQLBlock> {
|
|
940
|
+
/**
|
|
941
|
+
* Run this SQL block.
|
|
942
|
+
*
|
|
943
|
+
* @returns A promise to the query result data.
|
|
944
|
+
*/
|
|
945
|
+
run(options?: RunSQLOptions): Promise<Result>;
|
|
946
|
+
runStream(options?: {
|
|
947
|
+
rowLimit?: number;
|
|
948
|
+
}): AsyncIterableIterator<DataRecord>;
|
|
949
|
+
/**
|
|
950
|
+
* Materialize this loaded SQL block.
|
|
951
|
+
*
|
|
952
|
+
* @returns A promise of a SQL block.
|
|
953
|
+
*/
|
|
954
|
+
getSQLBlock(): Promise<SQLBlock>;
|
|
955
|
+
/**
|
|
956
|
+
* Materialize the SQL of this loaded SQL block.
|
|
957
|
+
*
|
|
958
|
+
* @returns A promise to the SQL string.
|
|
959
|
+
*/
|
|
960
|
+
getSQL(): Promise<string>;
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* An object representing the task of loading an `Explore`, capable of
|
|
964
|
+
* materializing the explore (via `getExplore()`) or extending the task to produce
|
|
965
|
+
* related queries.
|
|
966
|
+
*/
|
|
967
|
+
export declare class ExploreMaterializer extends FluentState<Explore> {
|
|
968
|
+
/**
|
|
969
|
+
* Load a query contained within this loaded explore.
|
|
970
|
+
*
|
|
971
|
+
* @param name The name of the query to load.
|
|
972
|
+
* @returns A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
973
|
+
* or loading further related objects.
|
|
974
|
+
*/
|
|
975
|
+
loadQueryByName(name: string): QueryMaterializer;
|
|
976
|
+
/**
|
|
977
|
+
* Materialize a query contained within this loaded explore.
|
|
978
|
+
*
|
|
979
|
+
* @param name The name of the query to materialize.
|
|
980
|
+
* @returns A promise to the requested prepared query.
|
|
981
|
+
*/
|
|
982
|
+
getQueryByName(name: string): Promise<PreparedQuery>;
|
|
983
|
+
/**
|
|
984
|
+
* Materialize this loaded explore.
|
|
985
|
+
*
|
|
986
|
+
* @returns A promise to the compiled `Explore`.
|
|
987
|
+
*/
|
|
988
|
+
getExplore(): Promise<Explore>;
|
|
989
|
+
}
|
|
990
|
+
export declare type ResultJSON = {
|
|
991
|
+
queryResult: QueryResult;
|
|
992
|
+
modelDef: ModelDef;
|
|
993
|
+
};
|
|
994
|
+
/**
|
|
995
|
+
* The result of running a Malloy query.
|
|
996
|
+
*
|
|
997
|
+
* A `Result` is a `PreparedResult` along with the data retrieved from running the query.
|
|
998
|
+
*/
|
|
999
|
+
export declare class Result extends PreparedResult {
|
|
1000
|
+
protected inner: QueryResult;
|
|
1001
|
+
constructor(queryResult: QueryResult, modelDef: ModelDef);
|
|
1002
|
+
get _queryResult(): QueryResult;
|
|
1003
|
+
/**
|
|
1004
|
+
* @returns The result data.
|
|
1005
|
+
*/
|
|
1006
|
+
get data(): DataArray;
|
|
1007
|
+
get totalRows(): number;
|
|
1008
|
+
toJSON(): ResultJSON;
|
|
1009
|
+
static fromJSON({ queryResult, modelDef }: ResultJSON): Result;
|
|
1010
|
+
}
|
|
1011
|
+
export declare type DataColumn = DataArray | DataRecord | DataString | DataBoolean | DataNumber | DataDate | DataTimestamp | DataNull | DataBytes;
|
|
1012
|
+
export declare type DataArrayOrRecord = DataArray | DataRecord;
|
|
1013
|
+
declare abstract class Data<T> {
|
|
1014
|
+
protected _field: Field | Explore;
|
|
1015
|
+
constructor(field: Field | Explore);
|
|
1016
|
+
get field(): Field | Explore;
|
|
1017
|
+
abstract get value(): T;
|
|
1018
|
+
isString(): this is DataString;
|
|
1019
|
+
get string(): DataString;
|
|
1020
|
+
isBoolean(): this is DataBoolean;
|
|
1021
|
+
get boolean(): DataBoolean;
|
|
1022
|
+
isNumber(): this is DataNumber;
|
|
1023
|
+
get number(): DataNumber;
|
|
1024
|
+
isTimestamp(): this is DataTimestamp;
|
|
1025
|
+
get timestamp(): DataTimestamp;
|
|
1026
|
+
isDate(): this is DataDate;
|
|
1027
|
+
get date(): DataDate;
|
|
1028
|
+
isNull(): this is DataNull;
|
|
1029
|
+
isBytes(): this is DataBytes;
|
|
1030
|
+
get bytes(): DataBytes;
|
|
1031
|
+
isRecord(): this is DataRecord;
|
|
1032
|
+
get record(): DataRecord;
|
|
1033
|
+
isArray(): this is DataArray;
|
|
1034
|
+
get array(): DataArray;
|
|
1035
|
+
isArrayOrRecord(): DataArrayOrRecord;
|
|
1036
|
+
}
|
|
1037
|
+
declare class ScalarData<T> extends Data<T> {
|
|
1038
|
+
protected _value: T;
|
|
1039
|
+
protected _field: AtomicField;
|
|
1040
|
+
constructor(value: T, field: AtomicField);
|
|
1041
|
+
get value(): T;
|
|
1042
|
+
get field(): AtomicField;
|
|
1043
|
+
}
|
|
1044
|
+
declare class DataString extends ScalarData<string> {
|
|
1045
|
+
protected _field: StringField;
|
|
1046
|
+
constructor(value: string, field: StringField);
|
|
1047
|
+
get field(): StringField;
|
|
1048
|
+
}
|
|
1049
|
+
declare class DataBoolean extends ScalarData<boolean> {
|
|
1050
|
+
protected _field: BooleanField;
|
|
1051
|
+
constructor(value: boolean, field: BooleanField);
|
|
1052
|
+
get field(): BooleanField;
|
|
1053
|
+
}
|
|
1054
|
+
declare class DataNumber extends ScalarData<number> {
|
|
1055
|
+
protected _field: NumberField;
|
|
1056
|
+
constructor(value: number, field: NumberField);
|
|
1057
|
+
get field(): NumberField;
|
|
1058
|
+
}
|
|
1059
|
+
declare class DataTimestamp extends ScalarData<Date> {
|
|
1060
|
+
protected _field: TimestampField;
|
|
1061
|
+
constructor(value: Date, field: TimestampField);
|
|
1062
|
+
get value(): Date;
|
|
1063
|
+
get field(): TimestampField;
|
|
1064
|
+
}
|
|
1065
|
+
declare class DataDate extends ScalarData<Date> {
|
|
1066
|
+
protected _field: DateField;
|
|
1067
|
+
constructor(value: Date, field: DateField);
|
|
1068
|
+
get value(): Date;
|
|
1069
|
+
get field(): DateField;
|
|
1070
|
+
}
|
|
1071
|
+
declare class DataBytes extends ScalarData<Buffer> {
|
|
1072
|
+
}
|
|
1073
|
+
declare class DataNull extends Data<null> {
|
|
1074
|
+
get value(): null;
|
|
1075
|
+
}
|
|
1076
|
+
export declare class DataArray extends Data<QueryData> implements Iterable<DataRecord> {
|
|
1077
|
+
readonly parent: DataArrayOrRecord | undefined;
|
|
1078
|
+
private queryData;
|
|
1079
|
+
protected _field: Explore;
|
|
1080
|
+
constructor(queryData: QueryData, field: Explore, parent: DataArrayOrRecord | undefined);
|
|
1081
|
+
/**
|
|
1082
|
+
* @returns The `Explore` that describes the structure of this data.
|
|
1083
|
+
*/
|
|
1084
|
+
get field(): Explore;
|
|
1085
|
+
/**
|
|
1086
|
+
* @returns The raw object form of the data.
|
|
1087
|
+
*/
|
|
1088
|
+
toObject(): QueryData;
|
|
1089
|
+
path(...path: (number | string)[]): DataColumn;
|
|
1090
|
+
row(index: number): DataRecord;
|
|
1091
|
+
get rowCount(): number;
|
|
1092
|
+
get value(): QueryData;
|
|
1093
|
+
[Symbol.iterator](): Iterator<DataRecord>;
|
|
1094
|
+
inMemoryStream(): AsyncIterableIterator<DataRecord>;
|
|
1095
|
+
}
|
|
1096
|
+
export declare class DataRecord extends Data<{
|
|
1097
|
+
[fieldName: string]: DataColumn;
|
|
1098
|
+
}> {
|
|
1099
|
+
readonly parent: DataArrayOrRecord | undefined;
|
|
1100
|
+
private queryDataRow;
|
|
1101
|
+
protected _field: Explore;
|
|
1102
|
+
readonly index: number | undefined;
|
|
1103
|
+
constructor(queryDataRow: QueryDataRow, index: number | undefined, field: Explore, parent: DataArrayOrRecord | undefined);
|
|
1104
|
+
toObject(): QueryDataRow;
|
|
1105
|
+
path(...path: (number | string)[]): DataColumn;
|
|
1106
|
+
cell(fieldOrName: string | Field): DataColumn;
|
|
1107
|
+
get value(): {
|
|
1108
|
+
[fieldName: string]: DataColumn;
|
|
1109
|
+
};
|
|
1110
|
+
get field(): Explore;
|
|
1111
|
+
[Symbol.iterator](): Iterator<DataRecord>;
|
|
1112
|
+
}
|
|
1113
|
+
export interface WriteStream {
|
|
1114
|
+
write: (text: string) => void;
|
|
1115
|
+
close: () => void;
|
|
1116
|
+
}
|
|
1117
|
+
export declare abstract class DataWriter {
|
|
1118
|
+
protected readonly stream: WriteStream;
|
|
1119
|
+
constructor(stream: WriteStream);
|
|
1120
|
+
abstract process(data: AsyncIterableIterator<DataRecord>): Promise<void>;
|
|
1121
|
+
}
|
|
1122
|
+
export declare class JSONWriter extends DataWriter {
|
|
1123
|
+
process(data: AsyncIterableIterator<DataRecord>): Promise<void>;
|
|
1124
|
+
}
|
|
1125
|
+
export declare class CSVWriter extends DataWriter {
|
|
1126
|
+
private readonly columnSeparator;
|
|
1127
|
+
private readonly rowSeparator;
|
|
1128
|
+
private readonly quoteCharacter;
|
|
1129
|
+
private readonly includeHeader;
|
|
1130
|
+
private escape;
|
|
1131
|
+
private stringify;
|
|
1132
|
+
process(data: AsyncIterableIterator<DataRecord>): Promise<void>;
|
|
1133
|
+
}
|
|
1134
|
+
export {};
|