@malloydata/malloy 0.0.335 → 0.0.337
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 +201 -0
- package/dist/api/foundation/compile.js +429 -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/index.d.ts +1 -0
- package/dist/connection/index.js +1 -0
- package/dist/connection/registry.d.ts +73 -0
- package/dist/connection/registry.js +106 -0
- package/dist/connection/types.d.ts +5 -15
- 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 +9 -4
- package/dist/index.js +37 -26
- package/dist/lang/ast/error-factory.js +3 -5
- 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/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.js +1 -0
- 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
package/dist/malloy.d.ts
DELETED
|
@@ -1,1365 +0,0 @@
|
|
|
1
|
-
import type { RunSQLOptions } from './run_sql_options';
|
|
2
|
-
import type { DocumentCompletion as DocumentCompletionDefinition, DocumentSymbol as DocumentSymbolDefinition, LogMessage } from './lang';
|
|
3
|
-
import { MalloyTranslator } from './lang';
|
|
4
|
-
import type { DocumentHelpContext } from './lang/parse-tree-walkers/document-help-context-walker';
|
|
5
|
-
import type { CompiledQuery, DocumentLocation, DocumentReference, BooleanFieldDef, JSONFieldDef, NumberFieldDef, StringFieldDef, FilterCondition, Query as InternalQuery, ModelDef, DocumentPosition as ModelDocumentPosition, NamedQuery, QueryData, QueryDataRow, QueryResult, SearchIndexResult, SearchValueMapResult, StructDef, TurtleDef, NativeUnsupportedFieldDef, QueryRunStats, ImportLocation, Annotation, SQLSourceDef, AtomicFieldDef, DateFieldDef, ATimestampFieldDef, SourceDef, QueryToMaterialize, Argument, TableSourceDef, SourceComponentInfo } from './model';
|
|
6
|
-
import type { EventStream, InvalidationKey, ModelString, ModelURL, QueryString, QueryURL, URLReader } from './runtime_types';
|
|
7
|
-
import type { Connection, FetchSchemaOptions, InfoConnection, LookupConnection } from './connection/types';
|
|
8
|
-
import type { Tag } from '@malloydata/malloy-tag';
|
|
9
|
-
import type { Dialect } from './dialect';
|
|
10
|
-
import type { PathInfo } from './lang/parse-tree-walkers/find-table-path-walker';
|
|
11
|
-
import type { MalloyTagParse, TagParseSpec } from './annotation';
|
|
12
|
-
export interface Taggable {
|
|
13
|
-
tagParse: (spec?: TagParseSpec) => MalloyTagParse;
|
|
14
|
-
getTaglines: (prefix?: RegExp) => string[];
|
|
15
|
-
}
|
|
16
|
-
export interface Loggable {
|
|
17
|
-
debug: (message?: any, ...optionalParams: any[]) => void;
|
|
18
|
-
info: (message?: any, ...optionalParams: any[]) => void;
|
|
19
|
-
warn: (message?: any, ...optionalParams: any[]) => void;
|
|
20
|
-
error: (message?: any, ...optionalParams: any[]) => void;
|
|
21
|
-
}
|
|
22
|
-
export interface ParseOptions {
|
|
23
|
-
importBaseURL?: URL;
|
|
24
|
-
testEnvironment?: boolean;
|
|
25
|
-
}
|
|
26
|
-
/** Options for how to run the Malloy semantic checker/translator */
|
|
27
|
-
export interface CompileOptions {
|
|
28
|
-
refreshSchemaCache?: boolean | number;
|
|
29
|
-
noThrowOnError?: boolean;
|
|
30
|
-
}
|
|
31
|
-
/** Options given to the Malloy compiler (QueryModel) */
|
|
32
|
-
interface CompileQueryOptions {
|
|
33
|
-
replaceMaterializedReferences?: boolean;
|
|
34
|
-
materializedTablePrefix?: string;
|
|
35
|
-
eventStream?: EventStream;
|
|
36
|
-
defaultRowLimit?: number;
|
|
37
|
-
}
|
|
38
|
-
type Compilable = {
|
|
39
|
-
parse: Parse;
|
|
40
|
-
url?: undefined;
|
|
41
|
-
source?: undefined;
|
|
42
|
-
} | {
|
|
43
|
-
url: URL;
|
|
44
|
-
parse?: undefined;
|
|
45
|
-
source?: undefined;
|
|
46
|
-
} | {
|
|
47
|
-
source: string;
|
|
48
|
-
parse?: undefined;
|
|
49
|
-
url?: undefined;
|
|
50
|
-
};
|
|
51
|
-
export declare class Malloy {
|
|
52
|
-
static get version(): string;
|
|
53
|
-
private static _parse;
|
|
54
|
-
/**
|
|
55
|
-
* Parse a Malloy document by URL.
|
|
56
|
-
*
|
|
57
|
-
* @param url The URL of the Malloy document to parse.
|
|
58
|
-
* @param urlReader Object capable of fetching URL contents.
|
|
59
|
-
* @return A (promise of a) `Parse` result.
|
|
60
|
-
*/
|
|
61
|
-
static parse({ url, urlReader, eventStream, options, }: {
|
|
62
|
-
url: URL;
|
|
63
|
-
urlReader: URLReader;
|
|
64
|
-
eventStream?: EventStream;
|
|
65
|
-
options?: ParseOptions;
|
|
66
|
-
}): Promise<Parse>;
|
|
67
|
-
/**
|
|
68
|
-
* Parse a Malloy document by contents.
|
|
69
|
-
*
|
|
70
|
-
* @param url The URL of the Malloy document to parse (optional).
|
|
71
|
-
* @param source The contents of the Malloy document to parse.
|
|
72
|
-
* @return A `Parse` result.
|
|
73
|
-
*/
|
|
74
|
-
static parse({ source, url, eventStream, options, }: {
|
|
75
|
-
url?: URL;
|
|
76
|
-
source: string;
|
|
77
|
-
eventStream?: EventStream;
|
|
78
|
-
options?: ParseOptions;
|
|
79
|
-
}): Parse;
|
|
80
|
-
/**
|
|
81
|
-
* Compile a parsed Malloy document.
|
|
82
|
-
*
|
|
83
|
-
* @param urlReader Object capable of reading contents of a URL.
|
|
84
|
-
* @param connections Mapping of connection names to objects capable of reading Malloy schemas.
|
|
85
|
-
* @param parse The parsed Malloy document.
|
|
86
|
-
* @param model A compiled model to build upon (optional).
|
|
87
|
-
* @return A (promise of a) compiled `Model`.
|
|
88
|
-
*/
|
|
89
|
-
static compile({ url, source, parse, urlReader, connections, model, refreshSchemaCache, noThrowOnError, eventStream, importBaseURL, cacheManager, }: {
|
|
90
|
-
urlReader: URLReader;
|
|
91
|
-
connections: LookupConnection<InfoConnection>;
|
|
92
|
-
model?: Model;
|
|
93
|
-
cacheManager?: CacheManager;
|
|
94
|
-
} & Compilable & CompileOptions & CompileQueryOptions & ParseOptions): Promise<Model>;
|
|
95
|
-
/**
|
|
96
|
-
* A dialect must provide a response for every table, or the translator loop
|
|
97
|
-
* will never exit. Because there was a time when this happened, we throw
|
|
98
|
-
* instead of looping forever, but the fix is to correct the dialect.
|
|
99
|
-
*/
|
|
100
|
-
static safelyFetchTableSchema(connection: InfoConnection, toFetch: Record<string, string>, opts: FetchSchemaOptions): Promise<{
|
|
101
|
-
schemas: Record<string, TableSourceDef>;
|
|
102
|
-
errors: Record<string, string>;
|
|
103
|
-
}>;
|
|
104
|
-
/**
|
|
105
|
-
* Run a fully-prepared query.
|
|
106
|
-
*
|
|
107
|
-
* @param get A mapping from connection names to objects capable of running SQL.
|
|
108
|
-
* @param preparedResult A fully-prepared query which is ready to run (a `PreparedResult`).
|
|
109
|
-
* @return Query result data and associated metadata.
|
|
110
|
-
*/
|
|
111
|
-
static run(params: {
|
|
112
|
-
connections: LookupConnection<Connection>;
|
|
113
|
-
preparedResult: PreparedResult;
|
|
114
|
-
options?: RunSQLOptions;
|
|
115
|
-
}): Promise<Result>;
|
|
116
|
-
static run(params: {
|
|
117
|
-
connection: Connection;
|
|
118
|
-
preparedResult: PreparedResult;
|
|
119
|
-
options?: RunSQLOptions;
|
|
120
|
-
}): Promise<Result>;
|
|
121
|
-
static run(params: {
|
|
122
|
-
connection: Connection;
|
|
123
|
-
sqlStruct: SQLSourceDef;
|
|
124
|
-
options?: RunSQLOptions;
|
|
125
|
-
}): Promise<Result>;
|
|
126
|
-
static run(params: {
|
|
127
|
-
connections: LookupConnection<Connection>;
|
|
128
|
-
sqlStruct: SQLSourceDef;
|
|
129
|
-
options?: RunSQLOptions;
|
|
130
|
-
}): Promise<Result>;
|
|
131
|
-
static run(params: {
|
|
132
|
-
connection: Connection;
|
|
133
|
-
sqlStruct: SQLSourceDef;
|
|
134
|
-
options?: RunSQLOptions;
|
|
135
|
-
}): Promise<Result>;
|
|
136
|
-
static run(params: {
|
|
137
|
-
connections: LookupConnection<Connection>;
|
|
138
|
-
sqlStruct: SQLSourceDef;
|
|
139
|
-
options?: RunSQLOptions;
|
|
140
|
-
}): Promise<Result>;
|
|
141
|
-
static runStream(params: {
|
|
142
|
-
connections: LookupConnection<Connection>;
|
|
143
|
-
preparedResult: PreparedResult;
|
|
144
|
-
options?: RunSQLOptions;
|
|
145
|
-
}): AsyncIterableIterator<DataRecord>;
|
|
146
|
-
static runStream(params: {
|
|
147
|
-
connection: Connection;
|
|
148
|
-
preparedResult: PreparedResult;
|
|
149
|
-
options?: RunSQLOptions;
|
|
150
|
-
}): AsyncIterableIterator<DataRecord>;
|
|
151
|
-
static runStream(params: {
|
|
152
|
-
connection: Connection;
|
|
153
|
-
sqlStruct: SQLSourceDef;
|
|
154
|
-
options?: RunSQLOptions;
|
|
155
|
-
}): AsyncIterableIterator<DataRecord>;
|
|
156
|
-
static runStream(params: {
|
|
157
|
-
connections: LookupConnection<Connection>;
|
|
158
|
-
sqlStruct: SQLSourceDef;
|
|
159
|
-
options?: RunSQLOptions;
|
|
160
|
-
}): AsyncIterableIterator<DataRecord>;
|
|
161
|
-
static estimateQueryCost(params: {
|
|
162
|
-
connections: LookupConnection<Connection>;
|
|
163
|
-
preparedResult: PreparedResult;
|
|
164
|
-
}): Promise<QueryRunStats>;
|
|
165
|
-
static estimateQueryCost(params: {
|
|
166
|
-
connections: LookupConnection<Connection>;
|
|
167
|
-
sqlStruct: SQLSourceDef;
|
|
168
|
-
}): Promise<QueryRunStats>;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* A Malloy error, which may contain log messages produced during compilation.
|
|
172
|
-
*/
|
|
173
|
-
export declare class MalloyError extends Error {
|
|
174
|
-
readonly problems: LogMessage[];
|
|
175
|
-
/**
|
|
176
|
-
* An array of log messages produced during compilation.
|
|
177
|
-
*/
|
|
178
|
-
constructor(message: string, problems?: LogMessage[]);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* A compiled Malloy document.
|
|
182
|
-
*/
|
|
183
|
-
export declare class Model implements Taggable {
|
|
184
|
-
private modelDef;
|
|
185
|
-
readonly problems: LogMessage[];
|
|
186
|
-
readonly fromSources: string[];
|
|
187
|
-
private readonly references;
|
|
188
|
-
constructor(modelDef: ModelDef, problems: LogMessage[], fromSources: string[]);
|
|
189
|
-
tagParse(spec?: TagParseSpec): MalloyTagParse;
|
|
190
|
-
getTaglines(prefix?: RegExp): string[];
|
|
191
|
-
/**
|
|
192
|
-
* Retrieve a document reference for the token at the given position within
|
|
193
|
-
* the document that produced this model.
|
|
194
|
-
*
|
|
195
|
-
* @param position A position within the document.
|
|
196
|
-
* @return A `DocumentReference` at that position if one exists.
|
|
197
|
-
*/
|
|
198
|
-
getReference(position: ModelDocumentPosition): DocumentReference | undefined;
|
|
199
|
-
/**
|
|
200
|
-
* Retrieve an import for the token at the given position within
|
|
201
|
-
* the document that produced this model.
|
|
202
|
-
*
|
|
203
|
-
* @param position A position within the document.
|
|
204
|
-
* @return An `ImportLocation` at that position if one exists.
|
|
205
|
-
*/
|
|
206
|
-
getImport(position: ModelDocumentPosition): ImportLocation | undefined;
|
|
207
|
-
/**
|
|
208
|
-
* Retrieve a prepared query by the name of a query at the top level of the model.
|
|
209
|
-
*
|
|
210
|
-
* @param queryName Name of the query to retrieve.
|
|
211
|
-
* @return A prepared query.
|
|
212
|
-
*/
|
|
213
|
-
getPreparedQueryByName(queryName: string): PreparedQuery;
|
|
214
|
-
/**
|
|
215
|
-
* Retrieve a prepared query by the index of an unnamed query at the top level of a model.
|
|
216
|
-
*
|
|
217
|
-
* @param index The index of the query to retrieve.
|
|
218
|
-
* @return A prepared query.
|
|
219
|
-
*/
|
|
220
|
-
getPreparedQueryByIndex(index: number): PreparedQuery;
|
|
221
|
-
/**
|
|
222
|
-
* Retrieve a prepared query for the final unnamed query at the top level of a model.
|
|
223
|
-
*
|
|
224
|
-
* @return A prepared query.
|
|
225
|
-
*/
|
|
226
|
-
get preparedQuery(): PreparedQuery;
|
|
227
|
-
/**
|
|
228
|
-
* Retrieve a prepared query for the final unnamed query at the top level of a model.
|
|
229
|
-
*
|
|
230
|
-
* @return A prepared query.
|
|
231
|
-
*/
|
|
232
|
-
getPreparedQuery(): PreparedQuery;
|
|
233
|
-
/**
|
|
234
|
-
* Retrieve an `Explore` from the model by name.
|
|
235
|
-
*
|
|
236
|
-
* @param name The name of the `Explore` to retrieve.
|
|
237
|
-
* @return An `Explore`.
|
|
238
|
-
*/
|
|
239
|
-
getExploreByName(name: string): Explore;
|
|
240
|
-
/**
|
|
241
|
-
* Get an array of `Explore`s contained in the model.
|
|
242
|
-
*
|
|
243
|
-
* @return An array of `Explore`s contained in the model.
|
|
244
|
-
*/
|
|
245
|
-
get explores(): Explore[];
|
|
246
|
-
/**
|
|
247
|
-
* Get an array of `NamedQuery`s contained in the model.
|
|
248
|
-
*
|
|
249
|
-
* @return An array of `NamedQuery`s contained in the model.
|
|
250
|
-
*/
|
|
251
|
-
get namedQueries(): NamedQuery[];
|
|
252
|
-
get exportedExplores(): Explore[];
|
|
253
|
-
get _modelDef(): ModelDef;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* A prepared query which has all the necessary information to produce its SQL.
|
|
257
|
-
*/
|
|
258
|
-
export declare class PreparedQuery implements Taggable {
|
|
259
|
-
problems: LogMessage[];
|
|
260
|
-
name?: string | undefined;
|
|
261
|
-
_modelDef: ModelDef;
|
|
262
|
-
_query: InternalQuery | NamedQuery;
|
|
263
|
-
constructor(query: InternalQuery, model: ModelDef, problems: LogMessage[], name?: string | undefined);
|
|
264
|
-
tagParse(spec?: TagParseSpec): MalloyTagParse;
|
|
265
|
-
getTaglines(prefix?: RegExp): string[];
|
|
266
|
-
/**
|
|
267
|
-
* Generate the SQL for this query.
|
|
268
|
-
*
|
|
269
|
-
* @return A fully-prepared query (which contains the generated SQL).
|
|
270
|
-
*/
|
|
271
|
-
get preparedResult(): PreparedResult;
|
|
272
|
-
/**
|
|
273
|
-
* Generate the SQL for this query.
|
|
274
|
-
*
|
|
275
|
-
* @return A fully-prepared query (which contains the generated SQL).
|
|
276
|
-
* @param options.eventStream An event stream to use when compiling the SQL
|
|
277
|
-
*/
|
|
278
|
-
getPreparedResult(options?: CompileQueryOptions): PreparedResult;
|
|
279
|
-
get dialect(): string;
|
|
280
|
-
/**
|
|
281
|
-
* Get the flattened version of a query -- one that does not have a `pipeHead`.
|
|
282
|
-
* @deprecated Because queries can no longer have `pipeHead`s.
|
|
283
|
-
*/
|
|
284
|
-
getFlattenedQuery(_defaultName: string): PreparedQuery;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* A parsed Malloy document.
|
|
288
|
-
*/
|
|
289
|
-
export declare class Parse {
|
|
290
|
-
private translator;
|
|
291
|
-
private invalidationKey?;
|
|
292
|
-
constructor(translator: MalloyTranslator, invalidationKey?: InvalidationKey | undefined);
|
|
293
|
-
/**
|
|
294
|
-
* Retrieve the symbols defined in the parsed document.
|
|
295
|
-
*
|
|
296
|
-
* These symbols represent any object defined (e.g. `Query`s and `Explore`s)
|
|
297
|
-
* in the document.
|
|
298
|
-
*
|
|
299
|
-
* @return An array of document symbols.
|
|
300
|
-
*/
|
|
301
|
-
get symbols(): DocumentSymbol[];
|
|
302
|
-
/**
|
|
303
|
-
* Retrieve the full table paths for tables defined in the parsed document.
|
|
304
|
-
* Derived tables i.e. a table that extends another table, table from a query
|
|
305
|
-
* are not included.
|
|
306
|
-
*
|
|
307
|
-
* @return An array of document table path info.
|
|
308
|
-
*/
|
|
309
|
-
get tablePathInfo(): DocumentTablePath[];
|
|
310
|
-
get _translator(): MalloyTranslator;
|
|
311
|
-
get _invalidationKey(): InvalidationKey | undefined;
|
|
312
|
-
completions(position: {
|
|
313
|
-
line: number;
|
|
314
|
-
character: number;
|
|
315
|
-
}): DocumentCompletion[];
|
|
316
|
-
helpContext(position: {
|
|
317
|
-
line: number;
|
|
318
|
-
character: number;
|
|
319
|
-
}): DocumentHelpContext | undefined;
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Path info for a table defined in a Malloy document.
|
|
323
|
-
*/
|
|
324
|
-
export declare class DocumentTablePath {
|
|
325
|
-
private _range;
|
|
326
|
-
private _connectionId;
|
|
327
|
-
private _tablePath;
|
|
328
|
-
constructor(tablePath: PathInfo);
|
|
329
|
-
/**
|
|
330
|
-
* @return The range of characters in the source Malloy document that defines
|
|
331
|
-
* this table.
|
|
332
|
-
*/
|
|
333
|
-
get range(): DocumentRange;
|
|
334
|
-
/** @return The Connection Id for this table. */
|
|
335
|
-
get connectionId(): string;
|
|
336
|
-
/** @return The full table path. */
|
|
337
|
-
get tablePath(): string;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* A range of characters within a Malloy document.
|
|
341
|
-
*/
|
|
342
|
-
export declare class DocumentRange {
|
|
343
|
-
private _start;
|
|
344
|
-
private _end;
|
|
345
|
-
constructor(start: DocumentPosition, end: DocumentPosition);
|
|
346
|
-
/**
|
|
347
|
-
* @return The position of the first character in the range.
|
|
348
|
-
*/
|
|
349
|
-
get start(): DocumentPosition;
|
|
350
|
-
/**
|
|
351
|
-
* @return The position of the last character in the range.
|
|
352
|
-
*/
|
|
353
|
-
get end(): DocumentPosition;
|
|
354
|
-
/**
|
|
355
|
-
* @return This range in JSON format.
|
|
356
|
-
*/
|
|
357
|
-
toJSON(): {
|
|
358
|
-
start: {
|
|
359
|
-
line: number;
|
|
360
|
-
character: number;
|
|
361
|
-
};
|
|
362
|
-
end: {
|
|
363
|
-
line: number;
|
|
364
|
-
character: number;
|
|
365
|
-
};
|
|
366
|
-
};
|
|
367
|
-
/**
|
|
368
|
-
* Construct a DocumentRange from JSON.
|
|
369
|
-
*/
|
|
370
|
-
static fromJSON(json: {
|
|
371
|
-
start: {
|
|
372
|
-
line: number;
|
|
373
|
-
character: number;
|
|
374
|
-
};
|
|
375
|
-
end: {
|
|
376
|
-
line: number;
|
|
377
|
-
character: number;
|
|
378
|
-
};
|
|
379
|
-
}): DocumentRange;
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* A position within a Malloy document.
|
|
383
|
-
*/
|
|
384
|
-
export declare class DocumentPosition {
|
|
385
|
-
private _line;
|
|
386
|
-
private _character;
|
|
387
|
-
constructor(line: number, character: number);
|
|
388
|
-
/**
|
|
389
|
-
* @return The line number of the position.
|
|
390
|
-
*/
|
|
391
|
-
get line(): number;
|
|
392
|
-
/**
|
|
393
|
-
* @return The character index on the line `this.getLine()`.
|
|
394
|
-
*/
|
|
395
|
-
get character(): number;
|
|
396
|
-
/**
|
|
397
|
-
* @return This position in JSON format.
|
|
398
|
-
*/
|
|
399
|
-
toJSON(): {
|
|
400
|
-
line: number;
|
|
401
|
-
character: number;
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* A symbol defined in a Malloy document.
|
|
406
|
-
*
|
|
407
|
-
* Represents any object defined (e.g. `Query`s and `Explore`s) in the document.
|
|
408
|
-
*/
|
|
409
|
-
export declare class DocumentSymbol {
|
|
410
|
-
private _range;
|
|
411
|
-
private _lensRange;
|
|
412
|
-
private _type;
|
|
413
|
-
private _name;
|
|
414
|
-
private _children;
|
|
415
|
-
constructor(documentSymbol: DocumentSymbolDefinition);
|
|
416
|
-
/**
|
|
417
|
-
* @return The range of characters in the source Malloy document that define this symbol.
|
|
418
|
-
*/
|
|
419
|
-
get range(): DocumentRange;
|
|
420
|
-
/**
|
|
421
|
-
* @return The range of characters in the source Malloy document that define this symbol,
|
|
422
|
-
* including tags. Note: "block tags" are included if there is exactly one
|
|
423
|
-
* definition in the block.
|
|
424
|
-
*/
|
|
425
|
-
get lensRange(): DocumentRange;
|
|
426
|
-
/**
|
|
427
|
-
* @return The type of symbol.
|
|
428
|
-
*
|
|
429
|
-
* Possible values are: `"explore"`, `"query"`, `"field"`, `"turtle"`, `"join"`, or `"unnamed_query"`.
|
|
430
|
-
*/
|
|
431
|
-
get type(): string;
|
|
432
|
-
/**
|
|
433
|
-
* @return The name of this symbol, e.g. the `Explore` name or `Query` name.
|
|
434
|
-
*
|
|
435
|
-
* For type `"unnamed_query"`, `getName()` is `"unnamed_query"`.
|
|
436
|
-
*/
|
|
437
|
-
get name(): string;
|
|
438
|
-
/**
|
|
439
|
-
* @return An array of document symbols defined inside this document symbol,
|
|
440
|
-
* e.g. fields in an `Explore`.
|
|
441
|
-
*/
|
|
442
|
-
get children(): DocumentSymbol[];
|
|
443
|
-
}
|
|
444
|
-
export declare class DocumentCompletion {
|
|
445
|
-
readonly type: string;
|
|
446
|
-
readonly text: string;
|
|
447
|
-
constructor(completion: DocumentCompletionDefinition);
|
|
448
|
-
}
|
|
449
|
-
export type PreparedResultJSON = {
|
|
450
|
-
query: CompiledQuery;
|
|
451
|
-
modelDef: ModelDef;
|
|
452
|
-
};
|
|
453
|
-
/**
|
|
454
|
-
* A fully-prepared query containing SQL and metadata required to run the query.
|
|
455
|
-
*/
|
|
456
|
-
export declare class PreparedResult implements Taggable {
|
|
457
|
-
protected modelDef: ModelDef;
|
|
458
|
-
protected inner: CompiledQuery;
|
|
459
|
-
constructor(query: CompiledQuery, modelDef: ModelDef);
|
|
460
|
-
static fromJson({ query, modelDef, }: PreparedResultJSON): PreparedResult;
|
|
461
|
-
tagParse(spec?: TagParseSpec): MalloyTagParse;
|
|
462
|
-
getTaglines(prefix?: RegExp): string[];
|
|
463
|
-
get annotation(): Annotation | undefined;
|
|
464
|
-
get modelAnnotation(): Annotation | undefined;
|
|
465
|
-
get modelTag(): Tag;
|
|
466
|
-
/**
|
|
467
|
-
* @return The name of the connection this query should be run against.
|
|
468
|
-
*/
|
|
469
|
-
get connectionName(): string;
|
|
470
|
-
get _rawQuery(): CompiledQuery;
|
|
471
|
-
get _modelDef(): ModelDef;
|
|
472
|
-
/**
|
|
473
|
-
* @return The SQL that should be run against the SQL runner
|
|
474
|
-
* with the connection name `this.getConnectionName()`.
|
|
475
|
-
*/
|
|
476
|
-
get sql(): string;
|
|
477
|
-
get dependenciesToMaterialize(): Record<string, QueryToMaterialize> | undefined;
|
|
478
|
-
get materialization(): QueryToMaterialize | undefined;
|
|
479
|
-
/**
|
|
480
|
-
* @return The `Explore` representing the data that will be returned by running this query.
|
|
481
|
-
*/
|
|
482
|
-
get resultExplore(): Explore;
|
|
483
|
-
get sourceExplore(): Explore | undefined;
|
|
484
|
-
get _sourceExploreName(): string;
|
|
485
|
-
get _sourceArguments(): Record<string, Argument> | undefined;
|
|
486
|
-
get _sourceFilters(): FilterCondition[];
|
|
487
|
-
/**
|
|
488
|
-
* @return Whether this result has a schema. DDL statements (INSTALL, LOAD,
|
|
489
|
-
* CREATE SECRET, etc.) do not return a schema.
|
|
490
|
-
*/
|
|
491
|
-
get hasSchema(): boolean;
|
|
492
|
-
}
|
|
493
|
-
/**
|
|
494
|
-
* A URL reader which always throws an error when a URL's contents is requested.
|
|
495
|
-
*
|
|
496
|
-
* Useful for scenarios in which `import` statements are not required.
|
|
497
|
-
*/
|
|
498
|
-
export declare class EmptyURLReader implements URLReader {
|
|
499
|
-
readURL(_url: URL): Promise<{
|
|
500
|
-
contents: string;
|
|
501
|
-
invalidationKey: InvalidationKey;
|
|
502
|
-
}>;
|
|
503
|
-
getInvalidationKey(_url: URL): Promise<InvalidationKey>;
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* A URL reader backed by an in-memory mapping of URL contents.
|
|
507
|
-
*/
|
|
508
|
-
export declare class InMemoryURLReader implements URLReader {
|
|
509
|
-
protected files: Map<string, string>;
|
|
510
|
-
constructor(files: Map<string, string>);
|
|
511
|
-
readURL(url: URL): Promise<{
|
|
512
|
-
contents: string;
|
|
513
|
-
invalidationKey: InvalidationKey;
|
|
514
|
-
}>;
|
|
515
|
-
getInvalidationKey(url: URL): Promise<InvalidationKey>;
|
|
516
|
-
private invalidationKey;
|
|
517
|
-
}
|
|
518
|
-
/**
|
|
519
|
-
* A fixed mapping of connection names to connections.
|
|
520
|
-
*/
|
|
521
|
-
export declare class FixedConnectionMap implements LookupConnection<Connection> {
|
|
522
|
-
private connections;
|
|
523
|
-
private defaultConnectionName?;
|
|
524
|
-
constructor(connections: Map<string, Connection>, defaultConnectionName?: string | undefined);
|
|
525
|
-
/**
|
|
526
|
-
* Get a connection by name.
|
|
527
|
-
*
|
|
528
|
-
* @param connectionName The name of the connection to look up.
|
|
529
|
-
* @return A `Connection`
|
|
530
|
-
* @throws An `Error` if no connection with the given name exists.
|
|
531
|
-
*/
|
|
532
|
-
getConnection(connectionName?: string): Promise<Connection>;
|
|
533
|
-
/**
|
|
534
|
-
* Gets a list of registered connections.
|
|
535
|
-
*
|
|
536
|
-
* @return The list of registered connections.
|
|
537
|
-
*/
|
|
538
|
-
listConnections(): Connection[];
|
|
539
|
-
lookupConnection(connectionName?: string): Promise<Connection>;
|
|
540
|
-
static fromArray(connections: Connection[]): FixedConnectionMap;
|
|
541
|
-
}
|
|
542
|
-
/**
|
|
543
|
-
* The relationship of an `Explore` to its source.
|
|
544
|
-
*/
|
|
545
|
-
export declare enum SourceRelationship {
|
|
546
|
-
/**
|
|
547
|
-
* The `Explore` is nested data within the source's rows.
|
|
548
|
-
*/
|
|
549
|
-
Nested = "nested",
|
|
550
|
-
/**
|
|
551
|
-
* The `Explore` is the base table.
|
|
552
|
-
*/
|
|
553
|
-
BaseTable = "base_table",
|
|
554
|
-
/**
|
|
555
|
-
* The `Explore` is joined to its source
|
|
556
|
-
*/
|
|
557
|
-
Cross = "cross",
|
|
558
|
-
One = "one",
|
|
559
|
-
Many = "many",
|
|
560
|
-
Inline = "inline"
|
|
561
|
-
}
|
|
562
|
-
declare abstract class Entity {
|
|
563
|
-
private readonly _name;
|
|
564
|
-
protected readonly _parent?: Explore;
|
|
565
|
-
private readonly _source?;
|
|
566
|
-
constructor(name: string, parent?: Explore, source?: Entity);
|
|
567
|
-
get source(): Entity | undefined;
|
|
568
|
-
get name(): string;
|
|
569
|
-
get sourceClasses(): string[];
|
|
570
|
-
get fieldPath(): string[];
|
|
571
|
-
hasParentExplore(): this is Field;
|
|
572
|
-
isExplore(): this is Explore;
|
|
573
|
-
isQuery(): this is Query;
|
|
574
|
-
abstract isIntrinsic(): boolean;
|
|
575
|
-
abstract get location(): DocumentLocation | undefined;
|
|
576
|
-
}
|
|
577
|
-
export type Field = AtomicField | QueryField | ExploreField;
|
|
578
|
-
export type SerializedExplore = {
|
|
579
|
-
_structDef: StructDef;
|
|
580
|
-
sourceExplore?: SerializedExplore;
|
|
581
|
-
_parentExplore?: SerializedExplore;
|
|
582
|
-
};
|
|
583
|
-
export type SortableField = {
|
|
584
|
-
field: Field;
|
|
585
|
-
dir: 'asc' | 'desc' | undefined;
|
|
586
|
-
};
|
|
587
|
-
export declare class Explore extends Entity implements Taggable {
|
|
588
|
-
protected readonly _structDef: StructDef;
|
|
589
|
-
protected readonly _parentExplore?: Explore;
|
|
590
|
-
private _fieldMap;
|
|
591
|
-
private sourceExplore;
|
|
592
|
-
private _allFieldsWithOrder;
|
|
593
|
-
constructor(structDef: StructDef, parentExplore?: Explore, source?: Explore);
|
|
594
|
-
get source(): Explore | undefined;
|
|
595
|
-
isIntrinsic(): boolean;
|
|
596
|
-
isExploreField(): this is ExploreField;
|
|
597
|
-
tagParse(spec?: TagParseSpec): MalloyTagParse;
|
|
598
|
-
getTaglines(prefix?: RegExp): string[];
|
|
599
|
-
private parsedModelTag?;
|
|
600
|
-
get modelTag(): Tag;
|
|
601
|
-
/**
|
|
602
|
-
* @return The name of the entity.
|
|
603
|
-
*/
|
|
604
|
-
get name(): string;
|
|
605
|
-
getQueryByName(name: string): PreparedQuery;
|
|
606
|
-
private get modelDef();
|
|
607
|
-
getSingleExploreModel(): Model;
|
|
608
|
-
private get fieldMap();
|
|
609
|
-
get allFields(): Field[];
|
|
610
|
-
get allFieldsWithOrder(): SortableField[];
|
|
611
|
-
get intrinsicFields(): Field[];
|
|
612
|
-
get dimensions(): SortableField[];
|
|
613
|
-
getFieldByName(fieldName: string): Field;
|
|
614
|
-
getFieldByNameIfExists(fieldName: string): Field | undefined;
|
|
615
|
-
get primaryKey(): string | undefined;
|
|
616
|
-
get parentExplore(): Explore | undefined;
|
|
617
|
-
hasParentExplore(): this is ExploreField;
|
|
618
|
-
get filters(): FilterCondition[];
|
|
619
|
-
get limit(): number | undefined;
|
|
620
|
-
get structDef(): StructDef;
|
|
621
|
-
get queryTimezone(): string | undefined;
|
|
622
|
-
get sourceStructDef(): SourceDef | undefined;
|
|
623
|
-
toJSON(): SerializedExplore;
|
|
624
|
-
static fromJSON(main_explore: SerializedExplore): Explore;
|
|
625
|
-
get location(): DocumentLocation | undefined;
|
|
626
|
-
private collectSourceComponents;
|
|
627
|
-
/**
|
|
628
|
-
* THIS IS A HIGHLY EXPERIMENTAL API AND MAY VANISH OR CHANGE WITHOUT NOTICE
|
|
629
|
-
*/
|
|
630
|
-
getSourceComponents(): SourceComponentInfo[];
|
|
631
|
-
}
|
|
632
|
-
export declare enum AtomicFieldType {
|
|
633
|
-
String = "string",
|
|
634
|
-
Number = "number",
|
|
635
|
-
Boolean = "boolean",
|
|
636
|
-
Date = "date",
|
|
637
|
-
Timestamp = "timestamp",
|
|
638
|
-
Timestamptz = "timestamptz",
|
|
639
|
-
Json = "json",
|
|
640
|
-
NativeUnsupported = "sql native",
|
|
641
|
-
Error = "error"
|
|
642
|
-
}
|
|
643
|
-
export declare class AtomicField extends Entity implements Taggable {
|
|
644
|
-
protected fieldTypeDef: AtomicFieldDef;
|
|
645
|
-
protected parent: Explore;
|
|
646
|
-
constructor(fieldTypeDef: AtomicFieldDef, parent: Explore, source?: AtomicField);
|
|
647
|
-
get type(): AtomicFieldType;
|
|
648
|
-
tagParse(spec?: TagParseSpec): MalloyTagParse;
|
|
649
|
-
getTaglines(prefix?: RegExp): string[];
|
|
650
|
-
isIntrinsic(): boolean;
|
|
651
|
-
isQueryField(): this is QueryField;
|
|
652
|
-
isExploreField(): this is ExploreField;
|
|
653
|
-
isAtomicField(): this is AtomicField;
|
|
654
|
-
isCalculation(): boolean;
|
|
655
|
-
get sourceField(): Field;
|
|
656
|
-
get sourceClasses(): string[];
|
|
657
|
-
/**
|
|
658
|
-
* A unique ID of this field within the context of a result; undefined
|
|
659
|
-
* for fields that are not derived from a Result.
|
|
660
|
-
*/
|
|
661
|
-
get referenceId(): string | undefined;
|
|
662
|
-
sourceWasMeasure(): boolean;
|
|
663
|
-
sourceWasMeasureLike(): boolean;
|
|
664
|
-
sourceWasDimension(): boolean;
|
|
665
|
-
hasParentExplore(): this is Field;
|
|
666
|
-
isString(): this is StringField;
|
|
667
|
-
isNumber(): this is NumberField;
|
|
668
|
-
isDate(): this is DateField;
|
|
669
|
-
isBoolean(): this is BooleanField;
|
|
670
|
-
isJSON(): this is JSONField;
|
|
671
|
-
isTimestamp(): this is TimestampField;
|
|
672
|
-
isUnsupported(): this is UnsupportedField;
|
|
673
|
-
get parentExplore(): Explore;
|
|
674
|
-
/**
|
|
675
|
-
* @return Field name for drill.
|
|
676
|
-
*/
|
|
677
|
-
get expression(): string;
|
|
678
|
-
get location(): DocumentLocation | undefined;
|
|
679
|
-
}
|
|
680
|
-
export declare enum DateTimeframe {
|
|
681
|
-
Day = "day",
|
|
682
|
-
Week = "week",
|
|
683
|
-
Month = "month",
|
|
684
|
-
Quarter = "quarter",
|
|
685
|
-
Year = "year"
|
|
686
|
-
}
|
|
687
|
-
export declare enum TimestampTimeframe {
|
|
688
|
-
Day = "day",
|
|
689
|
-
Week = "week",
|
|
690
|
-
Month = "month",
|
|
691
|
-
Quarter = "quarter",
|
|
692
|
-
Year = "year",
|
|
693
|
-
Second = "second",
|
|
694
|
-
Hour = "hour",
|
|
695
|
-
Minute = "minute"
|
|
696
|
-
}
|
|
697
|
-
export declare class DateField extends AtomicField {
|
|
698
|
-
private fieldDateDef;
|
|
699
|
-
constructor(fieldDateDef: DateFieldDef, parent: Explore, source?: AtomicField);
|
|
700
|
-
get timeframe(): DateTimeframe | undefined;
|
|
701
|
-
}
|
|
702
|
-
export declare class TimestampField extends AtomicField {
|
|
703
|
-
private fieldTimestampDef;
|
|
704
|
-
constructor(fieldTimestampDef: ATimestampFieldDef, parent: Explore, source?: AtomicField);
|
|
705
|
-
get timeframe(): TimestampTimeframe | undefined;
|
|
706
|
-
}
|
|
707
|
-
export declare class NumberField extends AtomicField {
|
|
708
|
-
private fieldNumberDef;
|
|
709
|
-
constructor(fieldNumberDef: NumberFieldDef, parent: Explore, source?: AtomicField);
|
|
710
|
-
}
|
|
711
|
-
export declare class BooleanField extends AtomicField {
|
|
712
|
-
private fieldBooleanDef;
|
|
713
|
-
constructor(fieldBooleanDef: BooleanFieldDef, parent: Explore, source?: AtomicField);
|
|
714
|
-
}
|
|
715
|
-
export declare class JSONField extends AtomicField {
|
|
716
|
-
private fieldJSONDef;
|
|
717
|
-
constructor(fieldJSONDef: JSONFieldDef, parent: Explore, source?: AtomicField);
|
|
718
|
-
}
|
|
719
|
-
export declare class UnsupportedField extends AtomicField {
|
|
720
|
-
private fieldUnsupportedDef;
|
|
721
|
-
constructor(fieldUnsupportedDef: NativeUnsupportedFieldDef, parent: Explore, source?: AtomicField);
|
|
722
|
-
get rawType(): string | undefined;
|
|
723
|
-
}
|
|
724
|
-
export declare class StringField extends AtomicField {
|
|
725
|
-
private fieldStringDef;
|
|
726
|
-
constructor(fieldStringDef: StringFieldDef, parent: Explore, source?: AtomicField);
|
|
727
|
-
}
|
|
728
|
-
export declare class Query extends Entity {
|
|
729
|
-
protected turtleDef: TurtleDef;
|
|
730
|
-
private sourceQuery?;
|
|
731
|
-
constructor(turtleDef: TurtleDef, parent?: Explore, source?: Query);
|
|
732
|
-
get source(): Query | undefined;
|
|
733
|
-
isIntrinsic(): boolean;
|
|
734
|
-
get location(): DocumentLocation | undefined;
|
|
735
|
-
}
|
|
736
|
-
export declare class QueryField extends Query implements Taggable {
|
|
737
|
-
protected parent: Explore;
|
|
738
|
-
constructor(turtleDef: TurtleDef, parent: Explore, source?: Query);
|
|
739
|
-
tagParse(spec?: TagParseSpec): MalloyTagParse;
|
|
740
|
-
getTaglines(prefix?: RegExp): string[];
|
|
741
|
-
isQueryField(): this is QueryField;
|
|
742
|
-
isExploreField(): this is ExploreField;
|
|
743
|
-
isAtomicField(): this is AtomicField;
|
|
744
|
-
get sourceClasses(): string[];
|
|
745
|
-
hasParentExplore(): this is Field;
|
|
746
|
-
get parentExplore(): Explore;
|
|
747
|
-
get expression(): string;
|
|
748
|
-
}
|
|
749
|
-
export declare enum JoinRelationship {
|
|
750
|
-
OneToOne = "one_to_one",
|
|
751
|
-
OneToMany = "one_to_many",
|
|
752
|
-
ManyToOne = "many_to_one"
|
|
753
|
-
}
|
|
754
|
-
export declare class ExploreField extends Explore {
|
|
755
|
-
protected _parentExplore: Explore;
|
|
756
|
-
constructor(structDef: StructDef, parentExplore: Explore, source?: Explore);
|
|
757
|
-
get joinRelationship(): JoinRelationship;
|
|
758
|
-
get isRecord(): boolean;
|
|
759
|
-
get isArray(): boolean;
|
|
760
|
-
tagParse(spec?: TagParseSpec): MalloyTagParse;
|
|
761
|
-
isQueryField(): this is QueryField;
|
|
762
|
-
isExploreField(): this is ExploreField;
|
|
763
|
-
isAtomicField(): this is AtomicField;
|
|
764
|
-
get parentExplore(): Explore;
|
|
765
|
-
get sourceClasses(): string[];
|
|
766
|
-
get queryTimezone(): string | undefined;
|
|
767
|
-
}
|
|
768
|
-
type Connectionable = {
|
|
769
|
-
connection: Connection;
|
|
770
|
-
connections?: undefined;
|
|
771
|
-
} | {
|
|
772
|
-
connections: LookupConnection<Connection>;
|
|
773
|
-
connection?: undefined;
|
|
774
|
-
};
|
|
775
|
-
/**
|
|
776
|
-
* An environment for compiling and running Malloy queries.
|
|
777
|
-
*/
|
|
778
|
-
export declare class Runtime {
|
|
779
|
-
isTestRuntime: boolean;
|
|
780
|
-
private _urlReader;
|
|
781
|
-
private _connections;
|
|
782
|
-
private _eventStream;
|
|
783
|
-
private _cacheManager;
|
|
784
|
-
constructor({ urlReader, connections, connection, eventStream, cacheManager, }: {
|
|
785
|
-
urlReader?: URLReader;
|
|
786
|
-
eventStream?: EventStream;
|
|
787
|
-
cacheManager?: CacheManager;
|
|
788
|
-
} & Connectionable);
|
|
789
|
-
/**
|
|
790
|
-
* @return The `CacheManager` for this runtime instance.
|
|
791
|
-
*/
|
|
792
|
-
get cacheManager(): CacheManager | undefined;
|
|
793
|
-
/**
|
|
794
|
-
* @return The `URLReader` for this runtime instance.
|
|
795
|
-
*/
|
|
796
|
-
get urlReader(): URLReader;
|
|
797
|
-
/**
|
|
798
|
-
* @return The `LookupConnection<Connection>` for this runtime instance.
|
|
799
|
-
*/
|
|
800
|
-
get connections(): LookupConnection<Connection>;
|
|
801
|
-
/**
|
|
802
|
-
* @return The `EventStream` for this runtime instance.
|
|
803
|
-
*/
|
|
804
|
-
get eventStream(): EventStream | undefined;
|
|
805
|
-
/**
|
|
806
|
-
* Load a Malloy model by URL or contents.
|
|
807
|
-
*
|
|
808
|
-
* @param source The model URL or contents to load and (eventually) compile.
|
|
809
|
-
* @return A `ModelMaterializer` capable of materializing the requested model,
|
|
810
|
-
* or loading further related objects.
|
|
811
|
-
*/
|
|
812
|
-
loadModel(source: ModelURL | ModelString, options?: ParseOptions & CompileOptions & CompileQueryOptions): ModelMaterializer;
|
|
813
|
-
_loadModelFromModelDef(modelDef: ModelDef, options?: CompileQueryOptions): ModelMaterializer;
|
|
814
|
-
/**
|
|
815
|
-
* Load a Malloy query by URL or contents.
|
|
816
|
-
*
|
|
817
|
-
* @param query The query URL or contents to load and (eventually) compile.
|
|
818
|
-
* @return A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
819
|
-
* or loading further related objects.
|
|
820
|
-
*/
|
|
821
|
-
loadQuery(query: QueryURL | QueryString, options?: ParseOptions & CompileOptions & CompileQueryOptions): QueryMaterializer;
|
|
822
|
-
/**
|
|
823
|
-
* Load a Malloy query by the URL or contents of a Malloy model document
|
|
824
|
-
* and the index of an unnamed query contained in the model.
|
|
825
|
-
*
|
|
826
|
-
* @param model The model URL or contents to load and (eventually) compile to retrieve the requested query.
|
|
827
|
-
* @param index The index of the query to use within the model.
|
|
828
|
-
* @return A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
829
|
-
* or loading further related objects.
|
|
830
|
-
*/
|
|
831
|
-
loadQueryByIndex(model: ModelURL | ModelString, index: number, options?: ParseOptions & CompileOptions & CompileQueryOptions): QueryMaterializer;
|
|
832
|
-
/**
|
|
833
|
-
* Load a Malloy query by the URL or contents of a Malloy model document
|
|
834
|
-
* and the name of a query contained in the model.
|
|
835
|
-
*
|
|
836
|
-
* @param model The model URL or contents to load and (eventually) compile to retrieve the requested query.
|
|
837
|
-
* @param name The name of the query to use within the model.
|
|
838
|
-
* @return A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
839
|
-
* or loading further related objects.
|
|
840
|
-
*/
|
|
841
|
-
loadQueryByName(model: ModelURL | ModelString, name: string, options?: ParseOptions & CompileOptions & CompileQueryOptions): QueryMaterializer;
|
|
842
|
-
/**
|
|
843
|
-
* Compile a Malloy model by URL or contents.
|
|
844
|
-
*
|
|
845
|
-
* @param source The URL or contents of a Malloy model document to compile.
|
|
846
|
-
* @return A promise of a compiled `Model`.
|
|
847
|
-
*/
|
|
848
|
-
getModel(source: ModelURL | ModelString, options?: ParseOptions & CompileOptions): Promise<Model>;
|
|
849
|
-
/**
|
|
850
|
-
* Compile a Malloy query by URL or contents.
|
|
851
|
-
*
|
|
852
|
-
* @param query The URL or contents of a Malloy query document to compile.
|
|
853
|
-
* @return A promise of a compiled `PreparedQuery`.
|
|
854
|
-
*/
|
|
855
|
-
getQuery(query: QueryURL | QueryString, options?: ParseOptions & CompileOptions): Promise<PreparedQuery>;
|
|
856
|
-
/**
|
|
857
|
-
* Compile a Malloy query by the URL or contents of a model document
|
|
858
|
-
* and the index of an unnamed query contained within the model.
|
|
859
|
-
*
|
|
860
|
-
* @param model The URL or contents of a Malloy model document to compile.
|
|
861
|
-
* @param index The index of an unnamed query contained within the model.
|
|
862
|
-
* @return A promise of a compiled `PreparedQuery`.
|
|
863
|
-
*/
|
|
864
|
-
getQueryByIndex(model: ModelURL | ModelString, index: number, options?: ParseOptions & CompileOptions): Promise<PreparedQuery>;
|
|
865
|
-
/**
|
|
866
|
-
* Compile a Malloy query by the URL or contents of a model document
|
|
867
|
-
* and the name of a query contained within the model.
|
|
868
|
-
*
|
|
869
|
-
* @param model The URL or contents of a Malloy model document to compile.
|
|
870
|
-
* @param name The name of a query contained within the model.
|
|
871
|
-
* @return A promise of a compiled `PreparedQuery`.
|
|
872
|
-
*/
|
|
873
|
-
getQueryByName(model: ModelURL | ModelString, name: string, options?: ParseOptions & CompileOptions): Promise<PreparedQuery>;
|
|
874
|
-
}
|
|
875
|
-
export declare class ConnectionRuntime extends Runtime {
|
|
876
|
-
readonly rawConnections: Connection[];
|
|
877
|
-
constructor({ urlReader, connections, }: {
|
|
878
|
-
urlReader?: URLReader;
|
|
879
|
-
connections: Connection[];
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
export declare class SingleConnectionRuntime<T extends Connection = Connection> extends Runtime {
|
|
883
|
-
readonly connection: T;
|
|
884
|
-
constructor({ urlReader, connection, eventStream, cacheManager, }: {
|
|
885
|
-
urlReader?: URLReader;
|
|
886
|
-
eventStream?: EventStream;
|
|
887
|
-
cacheManager?: CacheManager;
|
|
888
|
-
connection: T;
|
|
889
|
-
});
|
|
890
|
-
get supportsNesting(): boolean;
|
|
891
|
-
quote(column: string): string;
|
|
892
|
-
get dialect(): Dialect;
|
|
893
|
-
getQuoter(): (arg: TemplateStringsArray) => string;
|
|
894
|
-
}
|
|
895
|
-
declare class FluentState<T> {
|
|
896
|
-
protected runtime: Runtime;
|
|
897
|
-
private readonly _materialize;
|
|
898
|
-
private materialized;
|
|
899
|
-
constructor(runtime: Runtime, materialize: () => Promise<T>);
|
|
900
|
-
protected materialize(): Promise<T>;
|
|
901
|
-
protected rematerialize(): Promise<T>;
|
|
902
|
-
protected makeQueryMaterializer(materialize: () => Promise<PreparedQuery>, options?: CompileQueryOptions): QueryMaterializer;
|
|
903
|
-
protected makeExploreMaterializer(materialize: () => Promise<Explore>, options?: CompileQueryOptions): ExploreMaterializer;
|
|
904
|
-
protected makePreparedResultMaterializer(materialize: () => Promise<PreparedResult>): PreparedResultMaterializer;
|
|
905
|
-
}
|
|
906
|
-
/**
|
|
907
|
-
* An object representing the task of loading a `Model`, capable of
|
|
908
|
-
* materializing that model (via `getModel()`) or extending the task to load
|
|
909
|
-
* queries or explores (via e.g. `loadFinalQuery()`, `loadQuery`, `loadExploreByName`, etc.).
|
|
910
|
-
*/
|
|
911
|
-
export declare class ModelMaterializer extends FluentState<Model> {
|
|
912
|
-
protected runtime: Runtime;
|
|
913
|
-
private readonly compileQueryOptions;
|
|
914
|
-
constructor(runtime: Runtime, materialize: () => Promise<Model>, options?: CompileQueryOptions);
|
|
915
|
-
/**
|
|
916
|
-
* Load the final (unnamed) Malloy query contained within this loaded `Model`.
|
|
917
|
-
*
|
|
918
|
-
* @return A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
919
|
-
* or loading further related objects.
|
|
920
|
-
*/
|
|
921
|
-
loadFinalQuery(options?: CompileQueryOptions): QueryMaterializer;
|
|
922
|
-
/**
|
|
923
|
-
* Load an unnamed query contained within this loaded `Model` by index.
|
|
924
|
-
*
|
|
925
|
-
* @param index The index of the query to load.
|
|
926
|
-
* @return A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
927
|
-
* or loading further related objects.
|
|
928
|
-
*/
|
|
929
|
-
loadQueryByIndex(index: number, options?: CompileQueryOptions): QueryMaterializer;
|
|
930
|
-
/**
|
|
931
|
-
* Load a query contained within this loaded `Model` by its name.
|
|
932
|
-
*
|
|
933
|
-
* @param name The name of the query to load.
|
|
934
|
-
* @return A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
935
|
-
* or loading further related objects.
|
|
936
|
-
*/
|
|
937
|
-
loadQueryByName(name: string, options?: CompileQueryOptions): QueryMaterializer;
|
|
938
|
-
/**
|
|
939
|
-
* Load a query against this loaded `Model` by its URL or contents.
|
|
940
|
-
*
|
|
941
|
-
* @param query The URL or contents of the query to load and (eventually) compile.
|
|
942
|
-
* @return A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
943
|
-
* or loading further related objects.
|
|
944
|
-
*/
|
|
945
|
-
loadQuery(query: QueryString | QueryURL, options?: ParseOptions & CompileOptions & CompileQueryOptions): QueryMaterializer;
|
|
946
|
-
/**
|
|
947
|
-
* Extend a Malloy model by URL or contents.
|
|
948
|
-
*
|
|
949
|
-
* @param source The model URL or contents to load and (eventually) compile.
|
|
950
|
-
* @return A `ModelMaterializer` capable of materializing the requested model,
|
|
951
|
-
* or loading further related objects.
|
|
952
|
-
*/
|
|
953
|
-
extendModel(query: QueryString | QueryURL, options?: ParseOptions & CompileOptions & CompileQueryOptions): ModelMaterializer;
|
|
954
|
-
search(sourceName: string, searchTerm: string, limit?: number, searchField?: string | undefined, eventStream?: EventStream): Promise<SearchIndexResult[] | undefined>;
|
|
955
|
-
searchValueMap(sourceName: string, limit?: number, options?: ParseOptions): Promise<SearchValueMapResult[] | undefined>;
|
|
956
|
-
/**
|
|
957
|
-
* Materialize the final query contained within this loaded `Model`.
|
|
958
|
-
*
|
|
959
|
-
* @return A promise to a prepared query.
|
|
960
|
-
*/
|
|
961
|
-
getFinalQuery(): Promise<PreparedQuery>;
|
|
962
|
-
/**
|
|
963
|
-
* Materialize an unnamed query contained within this loaded `Model` by index.
|
|
964
|
-
*
|
|
965
|
-
* @param index The index of the query contained within this loaded `Model`.
|
|
966
|
-
* @return A promise to a prepared query.
|
|
967
|
-
*/
|
|
968
|
-
getQueryByIndex(index: number): Promise<PreparedQuery>;
|
|
969
|
-
/**
|
|
970
|
-
* Materialize a query contained within this loaded `Model` by name.
|
|
971
|
-
*
|
|
972
|
-
* @param name The name of the query contained within this loaded `Model`.
|
|
973
|
-
* @return A promise to a prepared query.
|
|
974
|
-
*/
|
|
975
|
-
getQueryByName(name: string): Promise<PreparedQuery>;
|
|
976
|
-
/**
|
|
977
|
-
* Materialize a query against this loaded `Model` by its URL or contents.
|
|
978
|
-
*
|
|
979
|
-
* @param query The URL or contents of a query document to compile.
|
|
980
|
-
* @return A promise to a prepared query.
|
|
981
|
-
*/
|
|
982
|
-
getQuery(query: QueryString | QueryURL, options?: ParseOptions): Promise<PreparedQuery>;
|
|
983
|
-
_loadQueryFromQueryDef(query: InternalQuery, options?: CompileQueryOptions): QueryMaterializer;
|
|
984
|
-
/**
|
|
985
|
-
* Load an explore contained within this loaded `Model` by name.
|
|
986
|
-
*
|
|
987
|
-
* @param name The name of the explore contained within this loaded `Model`.
|
|
988
|
-
* @return An `ExploreMaterializer` capable of materializing the requested explore,
|
|
989
|
-
* or loading further related objects.
|
|
990
|
-
*/
|
|
991
|
-
loadExploreByName(name: string): ExploreMaterializer;
|
|
992
|
-
/**
|
|
993
|
-
* Materialize an explore contained within this loaded `Model` by its name.
|
|
994
|
-
*
|
|
995
|
-
* @param query The name of an explore within this loaded `Model`.
|
|
996
|
-
* @return A promise to an explore.
|
|
997
|
-
*/
|
|
998
|
-
getExploreByName(name: string): Promise<Explore>;
|
|
999
|
-
/**
|
|
1000
|
-
* Compile and materialize this loaded `Model`.
|
|
1001
|
-
*
|
|
1002
|
-
* @return A promise to the compiled model that is loaded.
|
|
1003
|
-
*/
|
|
1004
|
-
getModel(): Promise<Model>;
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* An object representing the task of loading a `Query`, capable of
|
|
1008
|
-
* materializing the query (via `getPreparedQuery()`) or extending the task to load
|
|
1009
|
-
* prepared results or run the query (via e.g. `loadPreparedResult()` or `run()`).
|
|
1010
|
-
*/
|
|
1011
|
-
export declare class QueryMaterializer extends FluentState<PreparedQuery> {
|
|
1012
|
-
protected runtime: Runtime;
|
|
1013
|
-
private readonly compileQueryOptions;
|
|
1014
|
-
constructor(runtime: Runtime, materialize: () => Promise<PreparedQuery>, options?: CompileQueryOptions);
|
|
1015
|
-
/**
|
|
1016
|
-
* Run this loaded `Query`.
|
|
1017
|
-
*
|
|
1018
|
-
* @return The query results from running this loaded query.
|
|
1019
|
-
*/
|
|
1020
|
-
run(options?: RunSQLOptions & CompileQueryOptions): Promise<Result>;
|
|
1021
|
-
runStream(options?: RunSQLOptions & CompileQueryOptions): AsyncIterableIterator<DataRecord>;
|
|
1022
|
-
/**
|
|
1023
|
-
* Load the prepared result of this loaded query.
|
|
1024
|
-
*
|
|
1025
|
-
* @return A `PreparedResultMaterializer` capable of materializing the requested
|
|
1026
|
-
* prepared query or running it.
|
|
1027
|
-
*/
|
|
1028
|
-
loadPreparedResult(options?: CompileQueryOptions): PreparedResultMaterializer;
|
|
1029
|
-
/**
|
|
1030
|
-
* Materialize the prepared result of this loaded query.
|
|
1031
|
-
*
|
|
1032
|
-
* @return A promise of the prepared result of this loaded query.
|
|
1033
|
-
*/
|
|
1034
|
-
getPreparedResult(options?: CompileQueryOptions): Promise<PreparedResult>;
|
|
1035
|
-
/**
|
|
1036
|
-
* Materialize the SQL of this loaded query.
|
|
1037
|
-
*
|
|
1038
|
-
* @return A promise of the SQL string.
|
|
1039
|
-
*/
|
|
1040
|
-
getSQL(options?: CompileQueryOptions): Promise<string>;
|
|
1041
|
-
/**
|
|
1042
|
-
* Materialize this loaded query.
|
|
1043
|
-
*
|
|
1044
|
-
* @return A promise of the `PreparedQuery`.
|
|
1045
|
-
*/
|
|
1046
|
-
getPreparedQuery(): Promise<PreparedQuery>;
|
|
1047
|
-
/**
|
|
1048
|
-
* Estimates the cost of this loaded `Query`.
|
|
1049
|
-
*
|
|
1050
|
-
* @return The estimated cost of running this loaded query.
|
|
1051
|
-
*/
|
|
1052
|
-
estimateQueryCost(options?: CompileQueryOptions): Promise<QueryRunStats>;
|
|
1053
|
-
get eventStream(): EventStream | undefined;
|
|
1054
|
-
}
|
|
1055
|
-
/**
|
|
1056
|
-
* An object representing the task of loading a `PreparedResult`, capable of
|
|
1057
|
-
* materializing the prepared result (via `getPreparedResult()`) or extending the task run
|
|
1058
|
-
* the query.
|
|
1059
|
-
*/
|
|
1060
|
-
export declare class PreparedResultMaterializer extends FluentState<PreparedResult> {
|
|
1061
|
-
/**
|
|
1062
|
-
* Run this prepared result.
|
|
1063
|
-
*
|
|
1064
|
-
* @return A promise to the query result data.
|
|
1065
|
-
*/
|
|
1066
|
-
run(options?: RunSQLOptions): Promise<Result>;
|
|
1067
|
-
runStream(options?: {
|
|
1068
|
-
rowLimit?: number;
|
|
1069
|
-
}): AsyncIterableIterator<DataRecord>;
|
|
1070
|
-
/**
|
|
1071
|
-
* Materialize this loaded prepared result.
|
|
1072
|
-
*
|
|
1073
|
-
* @return A promise of a prepared result.
|
|
1074
|
-
*/
|
|
1075
|
-
getPreparedResult(): Promise<PreparedResult>;
|
|
1076
|
-
/**
|
|
1077
|
-
* Materialize the SQL of this loaded prepared result.
|
|
1078
|
-
*
|
|
1079
|
-
* @return A promise to the SQL string.
|
|
1080
|
-
*/
|
|
1081
|
-
getSQL(): Promise<string>;
|
|
1082
|
-
}
|
|
1083
|
-
/**
|
|
1084
|
-
* An object representing the task of loading an `Explore`, capable of
|
|
1085
|
-
* materializing the explore (via `getExplore()`) or extending the task to produce
|
|
1086
|
-
* related queries.
|
|
1087
|
-
*/
|
|
1088
|
-
export declare class ExploreMaterializer extends FluentState<Explore> {
|
|
1089
|
-
protected runtime: Runtime;
|
|
1090
|
-
private readonly replaceMaterializedReferences;
|
|
1091
|
-
constructor(runtime: Runtime, materialize: () => Promise<Explore>, options?: CompileQueryOptions);
|
|
1092
|
-
/**
|
|
1093
|
-
* Load a query contained within this loaded explore.
|
|
1094
|
-
*
|
|
1095
|
-
* @param name The name of the query to load.
|
|
1096
|
-
* @return A `QueryMaterializer` capable of materializing the requested query, running it,
|
|
1097
|
-
* or loading further related objects.
|
|
1098
|
-
*/
|
|
1099
|
-
loadQueryByName(name: string, options?: CompileQueryOptions): QueryMaterializer;
|
|
1100
|
-
/**
|
|
1101
|
-
* Materialize a query contained within this loaded explore.
|
|
1102
|
-
*
|
|
1103
|
-
* @param name The name of the query to materialize.
|
|
1104
|
-
* @return A promise to the requested prepared query.
|
|
1105
|
-
*/
|
|
1106
|
-
getQueryByName(name: string): Promise<PreparedQuery>;
|
|
1107
|
-
/**
|
|
1108
|
-
* Materialize this loaded explore.
|
|
1109
|
-
*
|
|
1110
|
-
* @return A promise to the compiled `Explore`.
|
|
1111
|
-
*/
|
|
1112
|
-
getExplore(): Promise<Explore>;
|
|
1113
|
-
}
|
|
1114
|
-
export type ResultJSON = {
|
|
1115
|
-
queryResult: QueryResult;
|
|
1116
|
-
modelDef: ModelDef;
|
|
1117
|
-
};
|
|
1118
|
-
/**
|
|
1119
|
-
* The result of running a Malloy query.
|
|
1120
|
-
*
|
|
1121
|
-
* A `Result` is a `PreparedResult` along with the data retrieved from running the query.
|
|
1122
|
-
*/
|
|
1123
|
-
export declare class Result extends PreparedResult {
|
|
1124
|
-
protected inner: QueryResult;
|
|
1125
|
-
constructor(queryResult: QueryResult, modelDef: ModelDef);
|
|
1126
|
-
get _queryResult(): QueryResult;
|
|
1127
|
-
/**
|
|
1128
|
-
* @return The result data.
|
|
1129
|
-
*/
|
|
1130
|
-
get data(): DataArray;
|
|
1131
|
-
get totalRows(): number;
|
|
1132
|
-
get runStats(): QueryRunStats | undefined;
|
|
1133
|
-
get profilingUrl(): string | undefined;
|
|
1134
|
-
toJSON(): ResultJSON;
|
|
1135
|
-
static fromJSON({ queryResult, modelDef }: ResultJSON): Result;
|
|
1136
|
-
}
|
|
1137
|
-
export type DataColumn = DataArray | DataRecord | DataString | DataBoolean | DataNumber | DataDate | DataTimestamp | DataNull | DataBytes | DataJSON | DataUnsupported;
|
|
1138
|
-
export type DataArrayOrRecord = DataArray | DataRecord;
|
|
1139
|
-
declare abstract class Data<T> {
|
|
1140
|
-
readonly parent: DataArrayOrRecord | undefined;
|
|
1141
|
-
readonly parentRecord: DataRecord | undefined;
|
|
1142
|
-
protected _field: Field | Explore;
|
|
1143
|
-
constructor(field: Field | Explore, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
|
|
1144
|
-
get field(): Field | Explore;
|
|
1145
|
-
abstract get value(): T;
|
|
1146
|
-
isString(): this is DataString;
|
|
1147
|
-
get string(): DataString;
|
|
1148
|
-
isBoolean(): this is DataBoolean;
|
|
1149
|
-
get boolean(): DataBoolean;
|
|
1150
|
-
isNumber(): this is DataNumber;
|
|
1151
|
-
get number(): DataNumber;
|
|
1152
|
-
isTimestamp(): this is DataTimestamp;
|
|
1153
|
-
get timestamp(): DataTimestamp;
|
|
1154
|
-
isDate(): this is DataDate;
|
|
1155
|
-
get date(): DataDate;
|
|
1156
|
-
isNull(): this is DataNull;
|
|
1157
|
-
isBytes(): this is DataBytes;
|
|
1158
|
-
get bytes(): DataBytes;
|
|
1159
|
-
isRecord(): this is DataRecord;
|
|
1160
|
-
get record(): DataRecord;
|
|
1161
|
-
isUnsupported(): this is DataUnsupported;
|
|
1162
|
-
get unsupported(): DataUnsupported;
|
|
1163
|
-
isArray(): this is DataArray;
|
|
1164
|
-
get array(): DataArray;
|
|
1165
|
-
isArrayOrRecord(): DataArrayOrRecord;
|
|
1166
|
-
isScalar(): this is ScalarData<T>;
|
|
1167
|
-
}
|
|
1168
|
-
declare abstract class ScalarData<T> extends Data<T> {
|
|
1169
|
-
protected _value: T;
|
|
1170
|
-
protected _field: AtomicField;
|
|
1171
|
-
constructor(value: T, field: AtomicField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
|
|
1172
|
-
get value(): T;
|
|
1173
|
-
get field(): AtomicField;
|
|
1174
|
-
abstract get key(): string;
|
|
1175
|
-
isScalar(): this is ScalarData<T>;
|
|
1176
|
-
abstract compareTo(other: ScalarData<T>): number;
|
|
1177
|
-
}
|
|
1178
|
-
declare class DataString extends ScalarData<string> {
|
|
1179
|
-
protected _field: StringField;
|
|
1180
|
-
constructor(value: string, field: StringField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
|
|
1181
|
-
get field(): StringField;
|
|
1182
|
-
get key(): string;
|
|
1183
|
-
compareTo(other: ScalarData<string>): number;
|
|
1184
|
-
}
|
|
1185
|
-
declare class DataUnsupported extends ScalarData<unknown> {
|
|
1186
|
-
protected _field: UnsupportedField;
|
|
1187
|
-
constructor(value: unknown, field: UnsupportedField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
|
|
1188
|
-
get field(): UnsupportedField;
|
|
1189
|
-
get key(): string;
|
|
1190
|
-
compareTo(_other: ScalarData<unknown>): number;
|
|
1191
|
-
}
|
|
1192
|
-
declare class DataBoolean extends ScalarData<boolean> {
|
|
1193
|
-
protected _field: BooleanField;
|
|
1194
|
-
constructor(value: boolean, field: BooleanField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
|
|
1195
|
-
get field(): BooleanField;
|
|
1196
|
-
get key(): string;
|
|
1197
|
-
compareTo(other: ScalarData<boolean>): 0 | 1 | -1;
|
|
1198
|
-
}
|
|
1199
|
-
declare class DataJSON extends ScalarData<string> {
|
|
1200
|
-
protected _field: JSONField;
|
|
1201
|
-
constructor(value: string, field: JSONField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
|
|
1202
|
-
get field(): JSONField;
|
|
1203
|
-
get key(): string;
|
|
1204
|
-
compareTo(other: ScalarData<string>): 0 | 1 | -1;
|
|
1205
|
-
}
|
|
1206
|
-
declare class DataNumber extends ScalarData<number> {
|
|
1207
|
-
protected _field: NumberField;
|
|
1208
|
-
constructor(value: unknown, field: NumberField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
|
|
1209
|
-
get field(): NumberField;
|
|
1210
|
-
get key(): string;
|
|
1211
|
-
compareTo(other: ScalarData<number>): 0 | 1 | -1;
|
|
1212
|
-
}
|
|
1213
|
-
declare class DataTimestamp extends ScalarData<Date> {
|
|
1214
|
-
protected _field: TimestampField;
|
|
1215
|
-
constructor(value: Date, field: TimestampField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
|
|
1216
|
-
get value(): Date;
|
|
1217
|
-
get field(): TimestampField;
|
|
1218
|
-
get key(): string;
|
|
1219
|
-
compareTo(other: ScalarData<Date>): 0 | 1 | -1;
|
|
1220
|
-
}
|
|
1221
|
-
declare class DataDate extends ScalarData<Date> {
|
|
1222
|
-
protected _field: DateField;
|
|
1223
|
-
constructor(value: Date, field: DateField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
|
|
1224
|
-
get value(): Date;
|
|
1225
|
-
get field(): DateField;
|
|
1226
|
-
get key(): string;
|
|
1227
|
-
compareTo(other: ScalarData<Date>): 0 | 1 | -1;
|
|
1228
|
-
}
|
|
1229
|
-
declare class DataBytes extends ScalarData<Buffer> {
|
|
1230
|
-
get key(): string;
|
|
1231
|
-
compareTo(other: ScalarData<Buffer>): 0 | 1 | -1;
|
|
1232
|
-
}
|
|
1233
|
-
declare class DataNull extends Data<null> {
|
|
1234
|
-
get value(): null;
|
|
1235
|
-
get key(): string;
|
|
1236
|
-
}
|
|
1237
|
-
export declare class DataArray extends Data<QueryData> implements Iterable<DataRecord> {
|
|
1238
|
-
private queryData;
|
|
1239
|
-
protected _field: Explore;
|
|
1240
|
-
private rowCache;
|
|
1241
|
-
constructor(queryData: QueryData, field: Explore, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
|
|
1242
|
-
/**
|
|
1243
|
-
* @return The `Explore` that describes the structure of this data.
|
|
1244
|
-
*/
|
|
1245
|
-
get field(): Explore;
|
|
1246
|
-
/**
|
|
1247
|
-
* @return The raw query data as returned by the database driver.
|
|
1248
|
-
* Values may be in various formats depending on the driver (wrapper objects, strings, etc.).
|
|
1249
|
-
* Use this for passing to mapData() which handles normalization itself.
|
|
1250
|
-
*/
|
|
1251
|
-
get rawData(): QueryData;
|
|
1252
|
-
/**
|
|
1253
|
-
* @return Normalized data with JS native types (number | bigint, Date).
|
|
1254
|
-
* Use this for CSV output, tests, and general programmatic access.
|
|
1255
|
-
*/
|
|
1256
|
-
toObject(): QueryData;
|
|
1257
|
-
/**
|
|
1258
|
-
* @return Normalized data with JSON-safe types (numbers as number | string, dates as ISO strings).
|
|
1259
|
-
* Use this for JSON serialization.
|
|
1260
|
-
*/
|
|
1261
|
-
toJSON(): QueryData;
|
|
1262
|
-
path(...path: (number | string)[]): DataColumn;
|
|
1263
|
-
row(index: number): DataRecord;
|
|
1264
|
-
get rowCount(): number;
|
|
1265
|
-
get value(): QueryData;
|
|
1266
|
-
[Symbol.iterator](): Iterator<DataRecord>;
|
|
1267
|
-
inMemoryStream(): AsyncIterableIterator<DataRecord>;
|
|
1268
|
-
}
|
|
1269
|
-
export declare class DataRecord extends Data<{
|
|
1270
|
-
[fieldName: string]: DataColumn;
|
|
1271
|
-
}> {
|
|
1272
|
-
private queryDataRow;
|
|
1273
|
-
protected _field: Explore;
|
|
1274
|
-
readonly index: number | undefined;
|
|
1275
|
-
private cellCache;
|
|
1276
|
-
constructor(queryDataRow: QueryDataRow, index: number | undefined, field: Explore, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
|
|
1277
|
-
/**
|
|
1278
|
-
* @return Normalized data with JS native types (number | bigint, Date).
|
|
1279
|
-
* Use this for CSV output, tests, and general programmatic access.
|
|
1280
|
-
*/
|
|
1281
|
-
toObject(): QueryDataRow;
|
|
1282
|
-
/**
|
|
1283
|
-
* @return Normalized data with JSON-safe types (numbers as number | string, dates as ISO strings).
|
|
1284
|
-
* Use this for JSON serialization.
|
|
1285
|
-
*/
|
|
1286
|
-
toJSON(): QueryDataRow;
|
|
1287
|
-
path(...path: (number | string)[]): DataColumn;
|
|
1288
|
-
cell(fieldOrName: string | Field): DataColumn;
|
|
1289
|
-
get value(): {
|
|
1290
|
-
[fieldName: string]: DataColumn;
|
|
1291
|
-
};
|
|
1292
|
-
get field(): Explore;
|
|
1293
|
-
[Symbol.iterator](): Iterator<DataRecord>;
|
|
1294
|
-
}
|
|
1295
|
-
export interface WriteStream {
|
|
1296
|
-
write: (text: string) => void;
|
|
1297
|
-
close: () => void;
|
|
1298
|
-
}
|
|
1299
|
-
export declare abstract class DataWriter {
|
|
1300
|
-
protected readonly stream: WriteStream;
|
|
1301
|
-
constructor(stream: WriteStream);
|
|
1302
|
-
abstract process(data: AsyncIterableIterator<DataRecord>): Promise<void>;
|
|
1303
|
-
}
|
|
1304
|
-
export declare class JSONWriter extends DataWriter {
|
|
1305
|
-
process(data: AsyncIterableIterator<DataRecord>): Promise<void>;
|
|
1306
|
-
}
|
|
1307
|
-
/**
|
|
1308
|
-
* CSV writer class that handles nested data.
|
|
1309
|
-
* This writer creates CSV using a DFS traversal of the result dataset.
|
|
1310
|
-
* Each trivial column value is converted to a CSV of 1x1 matrix and all the
|
|
1311
|
-
* columns are merged together to create a CSV that represents 1 QueryDataRow.
|
|
1312
|
-
* Since this follows DFS, each non trivial data is rendered into a NxM matrix
|
|
1313
|
-
* where N is the number of rows in the nested data and M is the number of
|
|
1314
|
-
* columns it has.
|
|
1315
|
-
* For any row with X number of columns, we end up with X number of NxM matrices
|
|
1316
|
-
* where the value of N,M pair may be different for each column.
|
|
1317
|
-
* We then merge the matrices so that we end up with a larger matrix of size
|
|
1318
|
-
* Max(N)xSum(M) by taking one row of csv from each matric at a time. For any
|
|
1319
|
-
* matrix with N<Max(N), we add a row of empty CSV cells of size N.
|
|
1320
|
-
*/
|
|
1321
|
-
export declare class CSVWriter extends DataWriter {
|
|
1322
|
-
private readonly columnSeparator;
|
|
1323
|
-
private readonly rowSeparator;
|
|
1324
|
-
private readonly quoteCharacter;
|
|
1325
|
-
private readonly includeHeader;
|
|
1326
|
-
private readonly emptyCell;
|
|
1327
|
-
private escape;
|
|
1328
|
-
private stringify;
|
|
1329
|
-
private getColWeight;
|
|
1330
|
-
private getHeaderRow;
|
|
1331
|
-
private mergeMatrices;
|
|
1332
|
-
private getChildMatrix;
|
|
1333
|
-
private getRowMatrix;
|
|
1334
|
-
process(data: AsyncIterableIterator<DataRecord>): Promise<void>;
|
|
1335
|
-
}
|
|
1336
|
-
interface CacheGetModelDefResponse {
|
|
1337
|
-
modelDef: ModelDef;
|
|
1338
|
-
invalidationKeys: {
|
|
1339
|
-
[url: string]: InvalidationKey;
|
|
1340
|
-
};
|
|
1341
|
-
}
|
|
1342
|
-
export interface ModelCache {
|
|
1343
|
-
getModel(url: URL): Promise<CachedModel | undefined>;
|
|
1344
|
-
setModel(url: URL, cachedModel: CachedModel): Promise<boolean>;
|
|
1345
|
-
}
|
|
1346
|
-
export declare class CacheManager {
|
|
1347
|
-
private modelCache;
|
|
1348
|
-
private modelDependencies;
|
|
1349
|
-
private modelInvalidationKeys;
|
|
1350
|
-
constructor(modelCache: ModelCache);
|
|
1351
|
-
getCachedModelDef(urlReader: URLReader, url: string): Promise<CacheGetModelDefResponse | undefined>;
|
|
1352
|
-
setCachedModelDef(url: string, cachedModel: CachedModel): Promise<boolean>;
|
|
1353
|
-
}
|
|
1354
|
-
export interface CachedModel {
|
|
1355
|
-
modelDef: ModelDef;
|
|
1356
|
-
invalidationKeys: {
|
|
1357
|
-
[url: string]: InvalidationKey;
|
|
1358
|
-
};
|
|
1359
|
-
}
|
|
1360
|
-
export declare class InMemoryModelCache implements ModelCache {
|
|
1361
|
-
private readonly models;
|
|
1362
|
-
getModel(url: URL): Promise<CachedModel | undefined>;
|
|
1363
|
-
setModel(url: URL, cachedModel: CachedModel): Promise<boolean>;
|
|
1364
|
-
}
|
|
1365
|
-
export {};
|