@malloydata/malloy 0.0.372 → 0.0.373
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/dist/api/foundation/config.d.ts +109 -108
- package/dist/api/foundation/config.js +205 -364
- package/dist/api/foundation/config_compile.d.ts +34 -0
- package/dist/api/foundation/config_compile.js +247 -0
- package/dist/api/foundation/config_discover.d.ts +37 -0
- package/dist/api/foundation/config_discover.js +154 -0
- package/dist/api/foundation/config_overlays.d.ts +54 -0
- package/dist/api/foundation/config_overlays.js +51 -0
- package/dist/api/foundation/config_resolve.d.ts +49 -0
- package/dist/api/foundation/config_resolve.js +230 -0
- package/dist/api/foundation/index.d.ts +3 -0
- package/dist/api/foundation/index.js +7 -1
- package/dist/api/foundation/runtime.d.ts +54 -9
- package/dist/api/foundation/runtime.js +98 -14
- package/dist/connection/registry.d.ts +14 -23
- package/dist/connection/registry.js +5 -30
- package/dist/index.d.ts +4 -3
- package/dist/index.js +5 -3
- package/dist/model/malloy_types.d.ts +8 -0
- package/dist/model/query_query.js +4 -1
- package/dist/model/sql_compiled.js +4 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
|
@@ -1,51 +1,37 @@
|
|
|
1
|
-
import type { URLReader } from '../../runtime_types';
|
|
2
1
|
import type { Connection, LookupConnection } from '../../connection/types';
|
|
3
|
-
import type { ConnectionConfigEntry } from '../../connection/registry';
|
|
4
2
|
import type { LogMessage } from '../../lang/parse-log';
|
|
5
3
|
import type { BuildID, BuildManifest, BuildManifestEntry, VirtualMap } from '../../model/malloy_types';
|
|
6
|
-
|
|
7
|
-
* The parsed contents of a malloy-config.json file.
|
|
8
|
-
*/
|
|
9
|
-
export interface MalloyProjectConfig {
|
|
10
|
-
connections?: Record<string, ConnectionConfigEntry>;
|
|
11
|
-
manifestPath?: string;
|
|
12
|
-
virtualMap?: VirtualMap;
|
|
13
|
-
}
|
|
4
|
+
import type { ConfigOverlays } from './config_overlays';
|
|
14
5
|
/**
|
|
15
6
|
* In-memory manifest store. Reads, updates, and serializes manifest data.
|
|
16
7
|
*
|
|
17
|
-
* Always valid — starts empty
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
8
|
+
* Always valid — starts empty. Populate by calling `loadText(jsonText)` with
|
|
9
|
+
* the manifest file contents, which the caller reads themselves (typically
|
|
10
|
+
* through a `URLReader` they already have). The `Manifest` class deliberately
|
|
11
|
+
* does no IO — it exists so that applications that want to build or mutate
|
|
12
|
+
* manifest state have a typed handle with a stable `buildManifest` reference.
|
|
21
13
|
*
|
|
22
|
-
* The `
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* a
|
|
14
|
+
* The `BuildManifest` returned by `buildManifest` is stable: `loadText()` and
|
|
15
|
+
* `update()` mutate the same entries object, so any reference obtained via
|
|
16
|
+
* `buildManifest` stays current without re-assignment.
|
|
17
|
+
*
|
|
18
|
+
* The `strict` flag controls what happens when a persist source's BuildID is
|
|
19
|
+
* not found in the manifest. When strict, the compiler throws an error
|
|
20
|
+
* instead of falling through to inline SQL. Loaded from the manifest file by
|
|
21
|
+
* `loadText()`; applications may override it at any time.
|
|
27
22
|
*/
|
|
28
23
|
export declare class Manifest {
|
|
29
|
-
private readonly _urlReader?;
|
|
30
24
|
private readonly _manifest;
|
|
31
25
|
private readonly _touched;
|
|
32
|
-
constructor(urlReader?: URLReader);
|
|
33
|
-
/**
|
|
34
|
-
* Load manifest data from a manifest root directory.
|
|
35
|
-
* Reads `<manifestRoot>/malloy-manifest.json` via the URLReader.
|
|
36
|
-
* Replaces any existing data. If the file doesn't exist or no URLReader
|
|
37
|
-
* is available, clears to empty.
|
|
38
|
-
*/
|
|
39
|
-
load(manifestRoot: URL): Promise<void>;
|
|
40
26
|
/**
|
|
41
27
|
* Load manifest data from a JSON string.
|
|
42
28
|
* Replaces any existing data.
|
|
43
29
|
*/
|
|
44
30
|
loadText(jsonText: string): void;
|
|
45
31
|
/**
|
|
46
|
-
* The live BuildManifest. This is a stable reference —
|
|
47
|
-
* mutate the same object, so passing this to a Runtime means
|
|
48
|
-
* always sees current data including the strict flag.
|
|
32
|
+
* The live BuildManifest. This is a stable reference — `loadText()` and
|
|
33
|
+
* `update()` mutate the same object, so passing this to a Runtime means
|
|
34
|
+
* the Runtime always sees current data including the strict flag.
|
|
49
35
|
*/
|
|
50
36
|
get buildManifest(): BuildManifest;
|
|
51
37
|
/**
|
|
@@ -73,97 +59,112 @@ export declare class Manifest {
|
|
|
73
59
|
private _loadParsed;
|
|
74
60
|
}
|
|
75
61
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
62
|
+
* A resolved Malloy runtime configuration. The constructor takes either a
|
|
63
|
+
* JSON string (legacy/compat) or a POJO plus an optional `ConfigOverlays`
|
|
64
|
+
* dict, compiles the input into a typed tree, resolves all overlay
|
|
65
|
+
* references, and builds the connection lookup via the connection registry.
|
|
78
66
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
67
|
+
* After construction:
|
|
68
|
+
* - `connections` — the `LookupConnection` runtime consumes. Starts as the
|
|
69
|
+
* lookup created from the resolved connections; `wrapConnections()` replaces
|
|
70
|
+
* it with a wrapped version for host-specific behavior.
|
|
71
|
+
* - `virtualMap` — extracted from the POJO as-is.
|
|
72
|
+
* - `manifestPath` — extracted from the POJO as-is (the raw string).
|
|
73
|
+
* - `manifestURL` — resolved URL of `malloy-manifest.json`, computed from
|
|
74
|
+
* `manifestPath` + the `configURL` carried on the `config` overlay (if
|
|
75
|
+
* any). `undefined` when no `configURL` is available. Runtime uses this
|
|
76
|
+
* to lazily read the manifest on the first persistence query. Builders
|
|
77
|
+
* that want to construct or mutate manifest state use the standalone
|
|
78
|
+
* `Manifest` class directly — they don't go through MalloyConfig.
|
|
79
|
+
* - `log` — validation warnings and overlay-resolution warnings.
|
|
82
80
|
*
|
|
83
|
-
*
|
|
84
|
-
* const config = new MalloyConfig(configText);
|
|
81
|
+
* Typical usage:
|
|
85
82
|
*
|
|
86
|
-
* //
|
|
87
|
-
*
|
|
83
|
+
* // From a pre-loaded POJO (e.g. from `discoverConfig` or Publisher):
|
|
84
|
+
* const config = new MalloyConfig(pojo);
|
|
88
85
|
* const runtime = new Runtime({config, urlReader});
|
|
89
86
|
*
|
|
90
|
-
*
|
|
91
|
-
* config
|
|
87
|
+
* // From a JSON string:
|
|
88
|
+
* const config = new MalloyConfig(configText);
|
|
89
|
+
*
|
|
90
|
+
* // With host-supplied overlays (local hosts after discovery):
|
|
91
|
+
* const config = new MalloyConfig(pojo, {
|
|
92
|
+
* config: contextOverlay({rootDirectory: ceilingURL}),
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* // Wrap the connection lookup for host-specific behavior:
|
|
96
|
+
* config.wrapConnections(base => name => base(name) ?? fallback(name));
|
|
97
|
+
*
|
|
98
|
+
* The old async `new MalloyConfig(urlReader, configURL)` form has been
|
|
99
|
+
* removed. Callers that need to load from a URL should pre-load via
|
|
100
|
+
* `urlReader.readURL()` / `JSON.parse()` and pass the POJO, or use the
|
|
101
|
+
* sync string form after reading the file.
|
|
92
102
|
*/
|
|
93
103
|
export declare class MalloyConfig {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*/
|
|
114
|
-
loadConfig(): Promise<void>;
|
|
115
|
-
/**
|
|
116
|
-
* The parsed config data. Undefined if created from URL and not yet loaded.
|
|
104
|
+
readonly virtualMap?: VirtualMap;
|
|
105
|
+
readonly manifestPath?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Resolved URL of the manifest file (`malloy-manifest.json`), if a
|
|
108
|
+
* `configURL` was provided in the `config` overlay. Computed once in the
|
|
109
|
+
* constructor from `manifestPath` (default `'MANIFESTS'`) joined to
|
|
110
|
+
* `configURL`. Stays `undefined` for callers that didn't supply a
|
|
111
|
+
* `configURL` — Runtime treats that as "no auto-read."
|
|
112
|
+
*/
|
|
113
|
+
readonly manifestURL?: URL;
|
|
114
|
+
readonly log: readonly LogMessage[];
|
|
115
|
+
private _connections;
|
|
116
|
+
private readonly _managedLookup;
|
|
117
|
+
private readonly _overlays;
|
|
118
|
+
constructor(source: string);
|
|
119
|
+
constructor(pojo: object, overlays?: ConfigOverlays);
|
|
120
|
+
/**
|
|
121
|
+
* The live `LookupConnection` consumed by Runtime. Stable until
|
|
122
|
+
* `wrapConnections()` is called; after that, returns the wrapped lookup.
|
|
117
123
|
*/
|
|
118
|
-
get
|
|
124
|
+
get connections(): LookupConnection<Connection>;
|
|
119
125
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
126
|
+
* Wrap the current connection lookup with a host-supplied wrapper.
|
|
127
|
+
* Mutates in place — subsequent `connections` accesses return the new
|
|
128
|
+
* wrapped lookup. Runtime never needs to know whether wrapping happened.
|
|
129
|
+
*
|
|
130
|
+
* Typical uses:
|
|
131
|
+
* - VS Code layers settings + defaults below the config lookup
|
|
132
|
+
* - Publisher attaches session-specific behavior to resolved connections
|
|
122
133
|
*/
|
|
123
|
-
|
|
124
|
-
set connectionMap(map: Record<string, ConnectionConfigEntry>);
|
|
134
|
+
wrapConnections(wrapper: (base: LookupConnection<Connection>) => LookupConnection<Connection>): void;
|
|
125
135
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* returns the same object (and the same underlying connections).
|
|
136
|
+
* Notify every connection this config has handed out that it is time to
|
|
137
|
+
* release its resources, then drop them from the internal cache.
|
|
129
138
|
*
|
|
130
|
-
*
|
|
139
|
+
* Most callers should use `Runtime.releaseConnections()` instead — the
|
|
140
|
+
* expected contract is one MalloyConfig per Runtime, and the runtime is
|
|
141
|
+
* the natural handle for lifecycle. This method exists because Runtime
|
|
142
|
+
* forwards to it, and for the rare case of a MalloyConfig constructed
|
|
143
|
+
* without an accompanying Runtime.
|
|
131
144
|
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
* Callback invoked once per connection immediately after factory creation.
|
|
145
|
-
* Use for post-creation setup (e.g., registering WASM file handlers).
|
|
146
|
-
* Must be set before the first connection is looked up.
|
|
147
|
-
*/
|
|
148
|
-
set onConnectionCreated(cb: ((name: string, connection: Connection) => void) | undefined);
|
|
149
|
-
/**
|
|
150
|
-
* Close all connections created by this config's internal managed lookup.
|
|
151
|
-
* Does nothing if connections were overridden via `connectionLookup`.
|
|
152
|
-
*/
|
|
153
|
-
close(): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* The Manifest object. Always exists, may be empty if not yet loaded.
|
|
156
|
-
*/
|
|
157
|
-
get manifest(): Manifest;
|
|
158
|
-
/**
|
|
159
|
-
* The VirtualMap parsed from config, if present.
|
|
145
|
+
* MalloyConfig does not own any connection resources itself — pools,
|
|
146
|
+
* sockets, file handles, and in-process databases all live inside the
|
|
147
|
+
* individual Connection objects. What the managed lookup owns is a cache
|
|
148
|
+
* of `name → Connection` populated lazily as callers request connections.
|
|
149
|
+
* This method walks that cache and calls `Connection.close()` on each
|
|
150
|
+
* entry, which is the signal each connection uses to shut down whatever
|
|
151
|
+
* resources it actually holds.
|
|
152
|
+
*
|
|
153
|
+
* Connections that were never looked up were never constructed and have
|
|
154
|
+
* nothing to release; they are skipped. Wrapping lookups installed via
|
|
155
|
+
* `wrapConnections()` do not interfere — the managed lookup under the
|
|
156
|
+
* wrap is the one holding the cache.
|
|
160
157
|
*/
|
|
161
|
-
|
|
158
|
+
releaseConnections(): Promise<void>;
|
|
162
159
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
160
|
+
* Query a value from the overlays used to resolve this config.
|
|
161
|
+
*
|
|
162
|
+
* Returns the value the named overlay produces for the given path,
|
|
163
|
+
* or `undefined` if the overlay doesn't exist or the path has no value.
|
|
164
|
+
*
|
|
165
|
+
* config.readOverlay('config', 'rootDirectory')
|
|
166
|
+
* config.readOverlay('config', 'configURL')
|
|
167
|
+
* config.readOverlay('env', 'PG_PASSWORD')
|
|
167
168
|
*/
|
|
168
|
-
|
|
169
|
+
readOverlay(overlayName: string, ...path: string[]): unknown;
|
|
169
170
|
}
|