@malloydata/malloy 0.0.335 → 0.0.336

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CONTEXT.md +4 -3
  2. package/MALLOY_API.md +129 -0
  3. package/dist/annotation.d.ts +0 -2
  4. package/dist/annotation.js +29 -23
  5. package/dist/api/asynchronous.d.ts +1 -1
  6. package/dist/api/foundation/cache.d.ts +32 -0
  7. package/dist/api/foundation/cache.js +92 -0
  8. package/dist/api/foundation/compile.d.ts +175 -0
  9. package/dist/api/foundation/compile.js +391 -0
  10. package/dist/api/foundation/core.d.ts +493 -0
  11. package/dist/api/foundation/core.js +1247 -0
  12. package/dist/api/foundation/document.d.ts +167 -0
  13. package/dist/api/foundation/document.js +206 -0
  14. package/dist/api/foundation/index.d.ts +10 -0
  15. package/dist/api/foundation/index.js +77 -0
  16. package/dist/api/foundation/readers.d.ts +53 -0
  17. package/dist/api/foundation/readers.js +134 -0
  18. package/dist/api/foundation/result.d.ts +185 -0
  19. package/dist/api/foundation/result.js +704 -0
  20. package/dist/api/foundation/runtime.d.ts +361 -0
  21. package/dist/api/foundation/runtime.js +733 -0
  22. package/dist/api/foundation/types.d.ts +54 -0
  23. package/dist/api/foundation/types.js +7 -0
  24. package/dist/api/foundation/writers.d.ts +42 -0
  25. package/dist/api/foundation/writers.js +230 -0
  26. package/dist/api/util.d.ts +1 -1
  27. package/dist/connection/base_connection.d.ts +5 -0
  28. package/dist/connection/types.d.ts +5 -0
  29. package/dist/dialect/duckdb/duckdb.js +2 -1
  30. package/dist/dialect/snowflake/snowflake.js +7 -1
  31. package/dist/dialect/trino/trino.js +7 -2
  32. package/dist/index.d.ts +6 -3
  33. package/dist/index.js +30 -26
  34. package/dist/lang/ast/error-factory.js +3 -5
  35. package/dist/lang/ast/source-elements/query-source.js +2 -7
  36. package/dist/lang/ast/source-elements/refined-source.js +11 -1
  37. package/dist/lang/ast/source-elements/sql-source.d.ts +1 -1
  38. package/dist/lang/ast/source-elements/sql-source.js +18 -3
  39. package/dist/lang/ast/sql-elements/sql-string.d.ts +2 -2
  40. package/dist/lang/ast/sql-elements/sql-string.js +18 -1
  41. package/dist/lang/ast/statements/define-source.js +7 -2
  42. package/dist/lang/ast/statements/import-statement.js +53 -21
  43. package/dist/lang/ast/types/document-compile-result.d.ts +1 -0
  44. package/dist/lang/ast/types/malloy-element.d.ts +3 -1
  45. package/dist/lang/ast/types/malloy-element.js +23 -7
  46. package/dist/lang/malloy-to-ast.d.ts +1 -1
  47. package/dist/lang/malloy-to-ast.js +1 -1
  48. package/dist/lang/parse-malloy.d.ts +3 -2
  49. package/dist/lang/parse-malloy.js +14 -25
  50. package/dist/lang/test/test-translator.js +1 -0
  51. package/dist/lang/translate-response.d.ts +1 -0
  52. package/dist/model/constant_expression_compiler.js +6 -7
  53. package/dist/model/index.d.ts +3 -1
  54. package/dist/model/index.js +15 -9
  55. package/dist/model/malloy_types.d.ts +89 -15
  56. package/dist/model/malloy_types.js +12 -0
  57. package/dist/model/persist_utils.d.ts +47 -0
  58. package/dist/model/persist_utils.js +257 -0
  59. package/dist/model/query_model_impl.d.ts +2 -4
  60. package/dist/model/query_model_impl.js +5 -13
  61. package/dist/model/query_node.d.ts +1 -2
  62. package/dist/model/query_node.js +3 -13
  63. package/dist/model/query_query.d.ts +17 -1
  64. package/dist/model/query_query.js +81 -36
  65. package/dist/model/source_def_utils.d.ts +50 -0
  66. package/dist/model/source_def_utils.js +154 -0
  67. package/dist/model/sql_block.d.ts +5 -1
  68. package/dist/model/sql_block.js +29 -4
  69. package/dist/model/sql_compiled.d.ts +29 -0
  70. package/dist/model/sql_compiled.js +102 -0
  71. package/dist/model/stage_writer.d.ts +1 -3
  72. package/dist/model/stage_writer.js +7 -25
  73. package/dist/model/utils.d.ts +20 -1
  74. package/dist/model/utils.js +40 -0
  75. package/dist/run_sql_options.d.ts +0 -1
  76. package/dist/taggable.d.ts +10 -0
  77. package/dist/taggable.js +7 -0
  78. package/dist/version.d.ts +1 -1
  79. package/dist/version.js +1 -1
  80. package/package.json +6 -4
  81. package/dist/malloy.d.ts +0 -1365
  82. package/dist/malloy.js +0 -3421
  83. package/dist/model/materialization/utils.d.ts +0 -3
  84. package/dist/model/materialization/utils.js +0 -41
package/CONTEXT.md CHANGED
@@ -10,9 +10,9 @@ packages/malloy/
10
10
  │ ├── lang/ # Translator: Parse tree → AST → IR (see src/lang/CONTEXT.md)
11
11
  │ ├── model/ # Compiler: IR → SQL (see src/model/CONTEXT.md)
12
12
  │ ├── dialect/ # Database-specific SQL generation
13
- │ ├── api/ # Public API interfaces
14
- ├── connection/ # Database connection abstractions
15
- │ └── malloy.ts # Main entry point
13
+ │ ├── api/ # API layers (see src/api/CONTEXT.md)
14
+ │ └── foundation/ # Public API classes (see MALLOY_API.md)
15
+ │ └── connection/ # Database connection abstractions
16
16
  ```
17
17
 
18
18
  ## Two-Phase Architecture
@@ -53,5 +53,6 @@ For detailed information about the compiler, see [src/model/CONTEXT.md](src/mode
53
53
  ## Subsystem Context
54
54
 
55
55
  For deeper details on specific subsystems:
56
+ - [MALLOY_API.md](MALLOY_API.md) - Public API classes (Model, PreparedQuery, Runtime, Materializers)
56
57
  - [src/lang/CONTEXT.md](src/lang/CONTEXT.md) - Translator architecture (grammar, AST, IR generation)
57
58
  - [src/model/CONTEXT.md](src/model/CONTEXT.md) - Compiler architecture (SQL generation, expression compilation)
package/MALLOY_API.md ADDED
@@ -0,0 +1,129 @@
1
+ # Foundation API - Public API Classes
2
+
3
+ The directory `src/api/foundation/` is the main public API surface for the Malloy package. It exports classes that wrap internal IR types and provide user-facing functionality. See `src/api/CONTEXT.md` for a complete overview of all API layers.
4
+
5
+ ## Core Data Classes
6
+
7
+ ### `Model`
8
+ Wraps `ModelDef` (internal IR). Represents a compiled Malloy model.
9
+
10
+ - `explores: Explore[]` - All sources in the model (wrapped)
11
+ - `getPreparedQueryByName(name): PreparedQuery`
12
+ - `getPreparedQueryByIndex(index): PreparedQuery`
13
+ - `getExploreByName(name): Explore`
14
+ - `_modelDef` - Escape hatch to raw IR
15
+
16
+ ### `PreparedQuery`
17
+ Wraps `Query` (internal IR) + `ModelDef`. A query that can be compiled to SQL.
18
+
19
+ - `getPreparedResult(options?): PreparedResult` - Compile to SQL
20
+ - `dialect: string`
21
+ - `name?: string`
22
+ - `_query`, `_modelDef` - Escape hatches
23
+
24
+ **Issue:** Each `getPreparedResult()` call creates a new `QueryModel`, reprocessing the ModelDef.
25
+
26
+ ### `PreparedResult`
27
+ Wraps `CompiledQuery` (internal). The compiled SQL and metadata.
28
+
29
+ - `sql: string` - The generated SQL
30
+ - `connectionName: string` - Which connection to run against
31
+ - `resultExplore: Explore` - Schema of the result
32
+
33
+ ### `Result`
34
+ Extends `PreparedResult`. Adds actual query result data.
35
+
36
+ - `data: DataArray` - The result rows
37
+ - `totalRows: number`
38
+ - `runStats: QueryRunStats`
39
+
40
+ ### `Explore`
41
+ Wraps `StructDef` (internal). Represents a source (historical name was "explore").
42
+
43
+ - `name: string`
44
+ - `allFields: Field[]`
45
+ - `getFieldByName(name): Field`
46
+ - `getQueryByName(name): PreparedQuery` - Get a view as a query
47
+
48
+ ### `ExploreField`
49
+ Extends `Explore`. A joined source (appears as a field in parent).
50
+
51
+ ### `Query`
52
+ Wraps `TurtleDef`. Represents a view definition. **Different from `PreparedQuery`.**
53
+
54
+ ### `QueryField`
55
+ Extends `Query`. A view that appears as a field in an explore.
56
+
57
+ ### `AtomicField` and subclasses
58
+ Field wrappers: `StringField`, `NumberField`, `DateField`, `TimestampField`, `BooleanField`, `JSONField`, `UnsupportedField`
59
+
60
+ ## Runtime & Materializer Classes
61
+
62
+ ### `Runtime`
63
+ Entry point for loading and running Malloy. Holds URLReader, connections, event stream.
64
+
65
+ - `loadModel(source): ModelMaterializer`
66
+ - `loadQuery(query): QueryMaterializer`
67
+ - `getModel(source): Promise<Model>`
68
+ - `getQuery(query): Promise<PreparedQuery>`
69
+
70
+ ### `SingleConnectionRuntime`
71
+ Extends `Runtime`. For single-connection use cases.
72
+
73
+ ### `ConnectionRuntime`
74
+ Extends `Runtime`. Holds array of connections.
75
+
76
+ ### `ModelMaterializer`
77
+ Fluent builder for loading models. Returned by `runtime.loadModel()`.
78
+
79
+ - `getModel(): Promise<Model>`
80
+ - `loadQueryByName(name): QueryMaterializer`
81
+ - `loadExploreByName(name): ExploreMaterializer`
82
+ - `extendModel(source): ModelMaterializer`
83
+
84
+ ### `QueryMaterializer`
85
+ Fluent builder for queries. Returned by `modelMaterializer.loadQueryByName()`.
86
+
87
+ - `getPreparedQuery(): Promise<PreparedQuery>`
88
+ - `getPreparedResult(): Promise<PreparedResult>`
89
+ - `getSQL(): Promise<string>`
90
+ - `run(options?): Promise<Result>`
91
+
92
+ ### `PreparedResultMaterializer`
93
+ Fluent builder for prepared results.
94
+
95
+ ### `ExploreMaterializer`
96
+ Fluent builder for explores/sources.
97
+
98
+ ## Result Data Classes
99
+
100
+ ### `DataArray`
101
+ Iterable array of `DataRecord`. Query result rows.
102
+
103
+ ### `DataRecord`
104
+ Single result row. Field values accessed by name.
105
+
106
+ ## Utility Classes
107
+
108
+ - `Parse` - Parsed (not compiled) Malloy document
109
+ - `Malloy` - Static methods: `parse()`, `compile()`, `run()`
110
+ - `MalloyError` - Error with structured problems
111
+ - `EmptyURLReader`, `InMemoryURLReader` - URLReader implementations
112
+ - `FixedConnectionMap` - LookupConnection implementation
113
+ - `CacheManager`, `InMemoryModelCache` - Caching
114
+ - `JSONWriter`, `CSVWriter` - Result writers
115
+ - `DocumentSymbol`, `DocumentPosition`, `DocumentRange`, etc. - IDE support
116
+
117
+ ## Naming Issues
118
+
119
+ | Current Name | What It Actually Is |
120
+ |--------------|---------------------|
121
+ | `Explore` | A source (historical name) |
122
+ | `PreparedQuery` | Uncompiled query holding IR |
123
+ | `PreparedResult` | Compiled query with SQL (not a "result") |
124
+ | `Query` | A view/turtle definition |
125
+
126
+ ## Known Architectural Issues
127
+
128
+ 1. **Transient QueryModel**: `PreparedQuery.getPreparedResult()` creates new `QueryModel` each call - expensive.
129
+ 3. **Name collision**: `Query` class (view wrapper) vs internal `Query` type vs `PreparedQuery`
@@ -4,9 +4,7 @@ import type { LogMessage } from './lang';
4
4
  export interface TagParseSpec {
5
5
  prefix?: RegExp;
6
6
  extending?: Tag;
7
- scopes?: Tag[];
8
7
  }
9
- export declare function addModelScope(spec: TagParseSpec | undefined, modelScope: Tag): TagParseSpec;
10
8
  export declare function annotationToTaglines(annote: Annotation | undefined, prefix?: RegExp): string[];
11
9
  export interface MalloyTagParse {
12
10
  tag: Tag;
@@ -1,19 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addModelScope = addModelScope;
4
3
  exports.annotationToTaglines = annotationToTaglines;
5
4
  exports.annotationToTag = annotationToTag;
6
5
  const malloy_tag_1 = require("@malloydata/malloy-tag");
7
- function addModelScope(spec, modelScope) {
8
- const useSpec = spec ? { ...spec } : {};
9
- if (useSpec.scopes) {
10
- useSpec.scopes = useSpec.scopes.concat(modelScope);
11
- }
12
- else {
13
- useSpec.scopes = [modelScope];
14
- }
15
- return useSpec;
16
- }
17
6
  function annotationToTaglines(annote, prefix) {
18
7
  annote || (annote = {});
19
8
  const tagLines = annote.inherits
@@ -31,7 +20,6 @@ function annotationToTaglines(annote, prefix) {
31
20
  return tagLines.concat(prefixed(annote.blockNotes), prefixed(annote.notes));
32
21
  }
33
22
  function annotationToTag(annote, spec = {}) {
34
- var _a;
35
23
  let extending = spec.extending || new malloy_tag_1.Tag();
36
24
  const prefix = spec.prefix || /^##? /;
37
25
  annote || (annote = {});
@@ -54,21 +42,39 @@ function annotationToTag(annote, spec = {}) {
54
42
  matchingNotes.push(note);
55
43
  }
56
44
  }
57
- for (let i = 0; i < matchingNotes.length; i++) {
58
- const note = matchingNotes[i];
59
- if (note.text.match(prefix)) {
60
- const noteParse = malloy_tag_1.Tag.fromTagLine(note.text, i, extending, ...((_a = spec.scopes) !== null && _a !== void 0 ? _a : []));
61
- extending = noteParse.tag;
62
- allErrs.push(...noteParse.log.map((e) => mapMalloyError(e, note)));
63
- }
45
+ for (const note of matchingNotes) {
46
+ const noteParse = (0, malloy_tag_1.parseTag)(note.text, extending);
47
+ extending = noteParse.tag;
48
+ allErrs.push(...noteParse.log.map((e) => mapMalloyError(e, note)));
49
+ }
50
+ // Validate references and add any warnings
51
+ const refErrors = extending.validateReferences();
52
+ for (const refError of refErrors) {
53
+ allErrs.push({
54
+ code: 'tag-reference-error',
55
+ severity: 'warn',
56
+ message: refError,
57
+ });
64
58
  }
65
59
  return { tag: extending, log: allErrs };
66
60
  }
67
61
  function mapMalloyError(e, note) {
68
- const loc = {
69
- line: note.at.range.start.line,
70
- character: note.at.range.start.character + e.offset,
71
- };
62
+ // Calculate prefix length (same logic as parseTagLine)
63
+ let prefixLen = 0;
64
+ if (note.text[0] === '#') {
65
+ const skipTo = note.text.indexOf(' ');
66
+ if (skipTo > 0) {
67
+ prefixLen = skipTo;
68
+ }
69
+ }
70
+ // Map error position to source location
71
+ // e.line is 0-based line within the (stripped) input
72
+ // e.offset is 0-based column within that line
73
+ const line = note.at.range.start.line + e.line;
74
+ const character = e.line === 0
75
+ ? note.at.range.start.character + prefixLen + e.offset
76
+ : e.offset;
77
+ const loc = { line, character };
72
78
  return {
73
79
  code: 'tag-parse-error',
74
80
  severity: 'error',
@@ -1,7 +1,7 @@
1
1
  import type * as Malloy from '@malloydata/malloy-interfaces';
2
2
  import type { InfoConnection, Connection, LookupConnection } from './connection';
3
3
  import type { URLReader } from '../runtime_types';
4
- import type { CacheManager } from '../malloy';
4
+ import type { CacheManager } from './foundation';
5
5
  export interface CompilerNeedFetch<T extends InfoConnection> {
6
6
  connections: LookupConnection<T>;
7
7
  urls: URLReader;
@@ -0,0 +1,32 @@
1
+ import type { ModelDef } from '../../model';
2
+ import type { InvalidationKey, URLReader } from '../../runtime_types';
3
+ interface CacheGetModelDefResponse {
4
+ modelDef: ModelDef;
5
+ invalidationKeys: {
6
+ [url: string]: InvalidationKey;
7
+ };
8
+ }
9
+ export interface ModelCache {
10
+ getModel(url: URL): Promise<CachedModel | undefined>;
11
+ setModel(url: URL, cachedModel: CachedModel): Promise<boolean>;
12
+ }
13
+ export interface CachedModel {
14
+ modelDef: ModelDef;
15
+ invalidationKeys: {
16
+ [url: string]: InvalidationKey;
17
+ };
18
+ }
19
+ export declare class CacheManager {
20
+ private modelCache;
21
+ private modelDependencies;
22
+ private modelInvalidationKeys;
23
+ constructor(modelCache: ModelCache);
24
+ getCachedModelDef(urlReader: URLReader, url: string): Promise<CacheGetModelDefResponse | undefined>;
25
+ setCachedModelDef(url: string, cachedModel: CachedModel): Promise<boolean>;
26
+ }
27
+ export declare class InMemoryModelCache implements ModelCache {
28
+ private readonly models;
29
+ getModel(url: URL): Promise<CachedModel | undefined>;
30
+ setModel(url: URL, cachedModel: CachedModel): Promise<boolean>;
31
+ }
32
+ export {};
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Contributors to the Malloy project
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.InMemoryModelCache = exports.CacheManager = void 0;
8
+ const readers_1 = require("./readers");
9
+ class CacheManager {
10
+ constructor(modelCache) {
11
+ this.modelCache = modelCache;
12
+ this.modelDependencies = new Map();
13
+ this.modelInvalidationKeys = new Map();
14
+ }
15
+ async getCachedModelDef(urlReader, url) {
16
+ const _dependencies = this.modelDependencies.get(url);
17
+ if (_dependencies === undefined) {
18
+ return undefined;
19
+ }
20
+ const dependencies = [url, ...flatDeps(_dependencies)];
21
+ const invalidationKeys = {};
22
+ for (const dependency of dependencies) {
23
+ const invalidationKey = this.modelInvalidationKeys.get(dependency);
24
+ if (invalidationKey === undefined || invalidationKey === null) {
25
+ return undefined;
26
+ }
27
+ invalidationKeys[dependency] = invalidationKey;
28
+ }
29
+ for (const dependency of dependencies) {
30
+ const invalidationKey = await (0, readers_1.getInvalidationKey)(urlReader, new URL(dependency));
31
+ if (invalidationKey !== invalidationKeys[dependency]) {
32
+ return undefined;
33
+ }
34
+ }
35
+ const cached = await this.modelCache.getModel(new URL(url));
36
+ if (cached === undefined) {
37
+ return undefined;
38
+ }
39
+ for (const dependency of dependencies) {
40
+ if (cached.invalidationKeys[dependency] !== invalidationKeys[dependency]) {
41
+ return undefined;
42
+ }
43
+ }
44
+ // Return the cached model def and the invalidation keys for this
45
+ // model def's dependencies
46
+ return { modelDef: cached.modelDef, invalidationKeys };
47
+ }
48
+ async setCachedModelDef(url, cachedModel) {
49
+ this.modelDependencies.set(url, cachedModel.modelDef.dependencies);
50
+ const invalidationKeys = {};
51
+ for (const dependency of [
52
+ url,
53
+ ...flatDeps(cachedModel.modelDef.dependencies),
54
+ ]) {
55
+ if (cachedModel.invalidationKeys[dependency] === null) {
56
+ return false;
57
+ }
58
+ if (cachedModel.invalidationKeys[dependency] === undefined) {
59
+ throw new Error(`Missing invalidation key for dependency ${dependency}`);
60
+ }
61
+ this.modelInvalidationKeys.set(dependency, cachedModel.invalidationKeys[dependency]);
62
+ invalidationKeys[dependency] = cachedModel.invalidationKeys[dependency];
63
+ }
64
+ const result = await this.modelCache.setModel(new URL(url), {
65
+ modelDef: cachedModel.modelDef,
66
+ invalidationKeys,
67
+ });
68
+ if (result) {
69
+ return true; // TODO just return `result` when it's a boolean
70
+ }
71
+ return false;
72
+ }
73
+ }
74
+ exports.CacheManager = CacheManager;
75
+ function flatDeps(tree) {
76
+ return [...Object.keys(tree), ...Object.values(tree).map(flatDeps).flat()];
77
+ }
78
+ // TODO maybe make this memory bounded....
79
+ class InMemoryModelCache {
80
+ constructor() {
81
+ this.models = new Map();
82
+ }
83
+ async getModel(url) {
84
+ return Promise.resolve(this.models.get(url.toString()));
85
+ }
86
+ async setModel(url, cachedModel) {
87
+ this.models.set(url.toString(), cachedModel);
88
+ return Promise.resolve(true);
89
+ }
90
+ }
91
+ exports.InMemoryModelCache = InMemoryModelCache;
92
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1,175 @@
1
+ import type { LogMessage } from '../../lang';
2
+ import type { Connection, InfoConnection, LookupConnection, FetchSchemaOptions } from '../../connection/types';
3
+ import type { URLReader, EventStream } from '../../runtime_types';
4
+ import type { SQLSourceDef, QueryRunStats } from '../../model';
5
+ import type { RunSQLOptions } from '../../run_sql_options';
6
+ import type { CacheManager } from './cache';
7
+ import { Parse } from './document';
8
+ import type { ParseOptions, CompileOptions, CompileQueryOptions } from './types';
9
+ import type { PreparedResult } from './core';
10
+ import { Model } from './core';
11
+ import { Result, DataRecord } from './result';
12
+ type Compilable = {
13
+ url: URL;
14
+ source?: undefined;
15
+ parse?: undefined;
16
+ } | {
17
+ source: string;
18
+ url?: URL;
19
+ parse?: undefined;
20
+ } | {
21
+ parse: Parse;
22
+ url?: URL;
23
+ source?: undefined;
24
+ };
25
+ export interface MalloyCompileOptions {
26
+ url?: URL;
27
+ source?: string;
28
+ parse?: Parse;
29
+ urlReader: URLReader;
30
+ connections: LookupConnection<InfoConnection>;
31
+ model?: Model;
32
+ cacheManager?: CacheManager;
33
+ refreshSchemaCache?: boolean | number;
34
+ noThrowOnError?: boolean;
35
+ eventStream?: EventStream;
36
+ importBaseURL?: URL;
37
+ testEnvironment?: boolean;
38
+ }
39
+ export interface MalloyRunOptions {
40
+ connection?: Connection;
41
+ preparedResult?: PreparedResult;
42
+ sqlStruct?: SQLSourceDef;
43
+ connections?: LookupConnection<Connection>;
44
+ options?: RunSQLOptions;
45
+ }
46
+ /**
47
+ * A Malloy error, which may contain log messages produced during compilation.
48
+ */
49
+ export declare class MalloyError extends Error {
50
+ readonly problems: LogMessage[];
51
+ /**
52
+ * An array of log messages produced during compilation.
53
+ */
54
+ constructor(message: string, problems?: LogMessage[]);
55
+ }
56
+ export declare class Malloy {
57
+ static get version(): string;
58
+ private static _parse;
59
+ /**
60
+ * Parse a Malloy document by URL.
61
+ *
62
+ * @param url The URL of the Malloy document to parse.
63
+ * @param urlReader Object capable of fetching URL contents.
64
+ * @return A (promise of a) `Parse` result.
65
+ */
66
+ static parse({ url, urlReader, eventStream, options, }: {
67
+ url: URL;
68
+ urlReader: URLReader;
69
+ eventStream?: EventStream;
70
+ options?: ParseOptions;
71
+ }): Promise<Parse>;
72
+ /**
73
+ * Parse a Malloy document by contents.
74
+ *
75
+ * @param url The URL of the Malloy document to parse (optional).
76
+ * @param source The contents of the Malloy document to parse.
77
+ * @return A `Parse` result.
78
+ */
79
+ static parse({ source, url, eventStream, options, }: {
80
+ url?: URL;
81
+ source: string;
82
+ eventStream?: EventStream;
83
+ options?: ParseOptions;
84
+ }): Parse;
85
+ /**
86
+ * Compile a parsed Malloy document.
87
+ *
88
+ * @param urlReader Object capable of reading contents of a URL.
89
+ * @param connections Mapping of connection names to objects capable of reading Malloy schemas.
90
+ * @param parse The parsed Malloy document.
91
+ * @param model A compiled model to build upon (optional).
92
+ * @return A (promise of a) compiled `Model`.
93
+ */
94
+ static compile({ url, source, parse, urlReader, connections, model, refreshSchemaCache, noThrowOnError, eventStream, importBaseURL, cacheManager, }: {
95
+ urlReader: URLReader;
96
+ connections: LookupConnection<InfoConnection>;
97
+ model?: Model;
98
+ cacheManager?: CacheManager;
99
+ } & Compilable & CompileOptions & CompileQueryOptions & ParseOptions): Promise<Model>;
100
+ /**
101
+ * A dialect must provide a response for every table, or the translator loop
102
+ * will never exit. Because there was a time when this happened, we throw
103
+ * instead of looping forever, but the fix is to correct the dialect.
104
+ */
105
+ static safelyFetchTableSchema(connection: InfoConnection, toFetch: Record<string, string>, opts: FetchSchemaOptions): Promise<{
106
+ schemas: Record<string, import("../../model").TableSourceDef>;
107
+ errors: Record<string, string>;
108
+ }>;
109
+ /**
110
+ * Run a fully-prepared query.
111
+ *
112
+ * @param get A mapping from connection names to objects capable of running SQL.
113
+ * @param preparedResult A fully-prepared query which is ready to run (a `PreparedResult`).
114
+ * @return Query result data and associated metadata.
115
+ */
116
+ static run(params: {
117
+ connections: LookupConnection<Connection>;
118
+ preparedResult: PreparedResult;
119
+ options?: RunSQLOptions;
120
+ }): Promise<Result>;
121
+ static run(params: {
122
+ connection: Connection;
123
+ preparedResult: PreparedResult;
124
+ options?: RunSQLOptions;
125
+ }): Promise<Result>;
126
+ static run(params: {
127
+ connection: Connection;
128
+ sqlStruct: SQLSourceDef;
129
+ options?: RunSQLOptions;
130
+ }): Promise<Result>;
131
+ static run(params: {
132
+ connections: LookupConnection<Connection>;
133
+ sqlStruct: SQLSourceDef;
134
+ options?: RunSQLOptions;
135
+ }): Promise<Result>;
136
+ static run(params: {
137
+ connection: Connection;
138
+ sqlStruct: SQLSourceDef;
139
+ options?: RunSQLOptions;
140
+ }): Promise<Result>;
141
+ static run(params: {
142
+ connections: LookupConnection<Connection>;
143
+ sqlStruct: SQLSourceDef;
144
+ options?: RunSQLOptions;
145
+ }): Promise<Result>;
146
+ static runStream(params: {
147
+ connections: LookupConnection<Connection>;
148
+ preparedResult: PreparedResult;
149
+ options?: RunSQLOptions;
150
+ }): AsyncIterableIterator<DataRecord>;
151
+ static runStream(params: {
152
+ connection: Connection;
153
+ preparedResult: PreparedResult;
154
+ options?: RunSQLOptions;
155
+ }): AsyncIterableIterator<DataRecord>;
156
+ static runStream(params: {
157
+ connection: Connection;
158
+ sqlStruct: SQLSourceDef;
159
+ options?: RunSQLOptions;
160
+ }): AsyncIterableIterator<DataRecord>;
161
+ static runStream(params: {
162
+ connections: LookupConnection<Connection>;
163
+ sqlStruct: SQLSourceDef;
164
+ options?: RunSQLOptions;
165
+ }): AsyncIterableIterator<DataRecord>;
166
+ static estimateQueryCost(params: {
167
+ connections: LookupConnection<Connection>;
168
+ preparedResult: PreparedResult;
169
+ }): Promise<QueryRunStats>;
170
+ static estimateQueryCost(params: {
171
+ connections: LookupConnection<Connection>;
172
+ sqlStruct: SQLSourceDef;
173
+ }): Promise<QueryRunStats>;
174
+ }
175
+ export {};