@wavehouse/chtypes 0.2.1 → 0.3.0

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/library.js CHANGED
@@ -2,6 +2,7 @@
2
2
  * One loaded ClickHouse build. It names itself — `chs_clickhouse_version()` —
3
3
  * and nothing is ever inferred from the directory or the file name.
4
4
  */
5
+ import { reconstructDdlWith } from './discover.js';
5
6
  import { schemaErrorFor } from './errors.js';
6
7
  import { Schema } from './schema.js';
7
8
  import { encodeSettings } from './settings.js';
@@ -188,6 +189,79 @@ export class Library {
188
189
  referenceType(typeExpr) {
189
190
  return this.native.referenceType(typeExpr);
190
191
  }
192
+ /**
193
+ * Spell `name` as a back-quoted identifier — ALWAYS quoted, which is the
194
+ * safe default and the one to reach for without thinking
195
+ * (`chs_quote_identifier`, the vendored `backQuote`).
196
+ *
197
+ * The bytes are this library's own: an embedded back-quote comes back in the
198
+ * spelling the server's formatter prints, not in a spelling of ours. Reach
199
+ * for `quoteIdentifierIfNeeded` only when the bare spelling matters to
200
+ * something downstream.
201
+ *
202
+ * @param name - a table, column or alias name.
203
+ * @returns the quoted identifier.
204
+ * @throws {UnsupportedError} when the artifact predates
205
+ * `chs_quote_identifier`.
206
+ */
207
+ quoteIdentifier(name) {
208
+ return this.quote('chs_quote_identifier', name);
209
+ }
210
+ /**
211
+ * Spell `name` bare where THIS library's ClickHouse says a bare spelling is
212
+ * legal, and back-quote it otherwise (`chs_quote_identifier_if_needed`, the
213
+ * vendored `backQuoteIfNeed`).
214
+ *
215
+ * Which names it leaves bare is a property of the vendored build, not of
216
+ * this package, and it CHANGES between builds — ask the library you will
217
+ * compile against rather than caching an answer across versions.
218
+ *
219
+ * @param name - a table, column or alias name.
220
+ * @returns the identifier, bare or quoted.
221
+ * @throws {UnsupportedError} when the artifact predates
222
+ * `chs_quote_identifier_if_needed`.
223
+ */
224
+ quoteIdentifierIfNeeded(name) {
225
+ return this.quote('chs_quote_identifier_if_needed', name);
226
+ }
227
+ /**
228
+ * Spell `text` as a ClickHouse string literal, quotes and escapes included
229
+ * (`chs_quote_literal`, the vendored `quoteString`) — the call to reach for
230
+ * when a value is spliced into DDL, e.g. a DEFAULT expression.
231
+ *
232
+ * The input is counted, so a value carrying a NUL byte is quoted correctly;
233
+ * the answer is escaped and therefore NUL-free.
234
+ *
235
+ * @param text - the string value.
236
+ * @returns the ClickHouse string literal.
237
+ * @throws {UnsupportedError} when the artifact predates `chs_quote_literal`.
238
+ */
239
+ quoteLiteral(text) {
240
+ return this.quote('chs_quote_literal', text);
241
+ }
242
+ quote(symbol, text) {
243
+ const r = this.native.quote(symbol, text);
244
+ if (!r.ok)
245
+ throw schemaErrorFor(r.code, r.message || `${symbol} refused the input`);
246
+ return r.quoted;
247
+ }
248
+ /**
249
+ * Turn `QUERY_TABLE_COLUMNS`' rows back into the column-declaration list
250
+ * `compileDdl` takes.
251
+ *
252
+ * It hangs off a Library because the one thing it spells — the column NAME —
253
+ * is spelled by this library's own `quoteIdentifier`; see `discover.ts` for
254
+ * what reconstruction does and does not promise.
255
+ *
256
+ * @param cols - the discovered columns, e.g. from `parseColumnsResult`.
257
+ * @returns the column-declaration list for `compileDdl`.
258
+ * @throws {ChtypesError} when a column is inconsistent, or there are none.
259
+ * @throws {UnsupportedError} when the artifact predates
260
+ * `chs_quote_identifier`.
261
+ */
262
+ reconstructDdl(cols) {
263
+ return reconstructDdlWith(cols, (name) => this.quoteIdentifier(name));
264
+ }
191
265
  /**
192
266
  * Every type family in this build's own runtime registry (139 entries on
193
267
  * 25.8) — the answer to "does this build track upstream type families?"
@@ -1 +1 @@
1
- {"version":3,"file":"library.js","sourceRoot":"","sources":["../src/library.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAiB,MAAM,eAAe,CAAC;AA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AEZ,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,CAAC,CAAC,EAAE;YAAE,MAAM,cAAc,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,IAAI,GAAG,MAAM,oBAAoB,CAAC,CAAC;QACpF,OAAO,CAAC,CAAC,MAAM,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,IAAiC;QAC9C,OAAO,kBAAkB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IACxE,CAAC;IAED;;;;;;;;;OASG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;IAC1C,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IACrC,CAAC;IAED;;;;;;;;OAQG;IACH,QAAQ;QACN,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -20,11 +20,10 @@
20
20
  *
21
21
  * Where a registry IS follows the search path of docs/guides/fetch.md §1 (`paths.ts`):
22
22
  * the explicit directory, `CHTYPES_REGISTRY`, the per-user cache, then the
23
- * reserved system locations. The first directory holding artifacts is scanned
24
- * and loaded at construction; a line it lacks is taken, on request, from the
25
- * first later directory that has it. A line no directory has is the one §7
26
- * error, `ArtifactMissingError` — or, with `autofetch`, a fetch on first
27
- * `open()`.
23
+ * reserved system locations. Construction READS THE MANIFESTS on that path and
24
+ * `dlopen`s nothing; a line is taken, on request, from the first directory that
25
+ * has it. A line no directory has is the one §7 error,
26
+ * `ArtifactMissingError` — or, with `autofetch`, a fetch on first `open()`.
28
27
  */
29
28
  import { type EnsureOptions } from './fetch.js';
30
29
  import { Library } from './library.js';
@@ -52,8 +51,40 @@ export interface RegistryOptions {
52
51
  * Re-hash each library and compare against `manifest.library_sha256` before
53
52
  * loading. SHOULD be on for an artifact that came from anywhere but a local
54
53
  * build, and MUST be on for one that came over a network.
54
+ *
55
+ * A policy on the REGISTRY, not a property of `preload`: a library's
56
+ * checksum is computed immediately before that library is `dlopen`ed and at
57
+ * no other time — at construction for the preloaded lines, at first use for
58
+ * the rest, never for a line nobody asks for.
59
+ *
60
+ * What this option ADDS is the sha256 comparison. The cheaper
61
+ * `manifest.library_bytes` size check that runs just before it is NOT
62
+ * conditional on this option — `load()` below always makes it, on every
63
+ * open, regardless (issue #82). Its timing is the same as the checksum's:
64
+ * at construction for the preloaded lines, at first use for the rest.
55
65
  */
56
66
  verifyChecksums?: boolean;
67
+ /**
68
+ * Open these lines AT CONSTRUCTION — the one eager path, and the same option
69
+ * Go spells `WithPreload(...)`, Python `preload=[...]` and Rust
70
+ * `RegistryOptions::preload`.
71
+ *
72
+ * Each entry is a version spelling resolved exactly as `for()` resolves one:
73
+ * a minor line (`'25.8'`) or an exact patch (`'25.8.28.1-lts'`), never a
74
+ * path. They are opened in the order given, before the constructor returns,
75
+ * and an entry no directory on the §1 search path holds is
76
+ * `ArtifactMissingError` — the same §7 error the first `for()` would have
77
+ * thrown, thrown earlier.
78
+ *
79
+ * It NEVER fetches, even with `autofetch` on: this constructor is
80
+ * synchronous and `ensure()` is not, and autofetch is a first-use behavior
81
+ * in all four bindings. An empty list is exactly the default.
82
+ *
83
+ * Deliberately a list of lines rather than "everything in the directory": a
84
+ * registry directory is whatever a fetch left behind, and each open costs
85
+ * about 120 MB resident.
86
+ */
87
+ preload?: readonly string[] | undefined;
57
88
  /**
58
89
  * Lazy fetch on first open (docs/guides/fetch.md §6): `open()` of a line no
59
90
  * directory on the search path holds runs `ensure()` first, into the
@@ -68,13 +99,20 @@ export interface RegistryOptions {
68
99
  }
69
100
  /**
70
101
  * The artifact-directory loader — the multi-version entry point of this
71
- * package. Construction scans one subdirectory per ClickHouse version, dlopens
72
- * each artifact into its own symbol scope (`RTLD_LOCAL`, ~120 MB resident per
73
- * version), verifies its ABI revision against this binding's `ABI_REVISION`
74
- * (a different nonzero revision is refused; 0 means the artifact predates the
75
- * probe and degrades per symbol), and runs each library's one-time
76
- * `chs_init` with the UTC default timezone and the artifact's own
77
- * `unsafe_families.txt`.
102
+ * package.
103
+ *
104
+ * **Construction reads `manifest.json` files and `dlopen`s nothing**, with or
105
+ * without a directory. Nothing in this package opens an artifact except a
106
+ * request for a specific version (`for()` / `open()`) or an explicit
107
+ * `preload` — not `versions()`, not `libraries()`, not `has()`. An open costs
108
+ * about 120 MB resident per version, which a listing call must not spend on a
109
+ * caller's behalf.
110
+ *
111
+ * An open dlopens the artifact into its own symbol scope (`RTLD_LOCAL`),
112
+ * verifies its ABI revision against this binding's `ABI_REVISION` (a different
113
+ * nonzero revision is refused; 0 means the artifact predates the probe and
114
+ * degrades per symbol), and runs that library's one-time `chs_init` with the
115
+ * registry's timezone and the artifact's own `unsafe_families.txt`.
78
116
  *
79
117
  * Libraries are never dlclosed; `close()` joins background threads only.
80
118
  * Loading the same artifact path from two `Registry` instances shares one
@@ -82,9 +120,9 @@ export interface RegistryOptions {
82
120
  */
83
121
  export declare class Registry {
84
122
  /**
85
- * The primary registry directory: the first on the search path that held
86
- * artifacts, scanned and loaded at construction — or, with `autofetch` and
87
- * nothing installed anywhere, the directory the first fetch will create.
123
+ * The primary registry directory: the first on the search path that holds
124
+ * artifacts — or, with `autofetch` and nothing installed anywhere, the
125
+ * directory the first fetch will create.
88
126
  */
89
127
  readonly dir: string;
90
128
  /** The §1 search path, in order, every candidate whether or not it exists. */
@@ -94,47 +132,88 @@ export declare class Registry {
94
132
  private readonly byId;
95
133
  private readonly byPath;
96
134
  private readonly loaded;
135
+ /**
136
+ * Minor line -> the FIRST directory on the search path that holds it, as the
137
+ * construction-time manifest scan found it. What `versions()` answers from,
138
+ * and what makes "no artifact anywhere" and a bad `preload` entry decidable
139
+ * at construction without a single `dlopen`.
140
+ */
141
+ private readonly known;
97
142
  private readonly timezone;
98
143
  private readonly verifyChecksums;
99
144
  private readonly autofetch;
100
145
  private readonly fetchOptions;
101
146
  private readonly explicit;
102
147
  /**
103
- * Scan and load a registry.
148
+ * Scan a registry. Reads manifests; opens nothing unless `preload` names a
149
+ * line.
104
150
  *
105
151
  * @param dir - the registry root; the head of the search path. Absent, the
106
152
  * path is `CHTYPES_REGISTRY`, the per-user artifact cache, then the system
107
153
  * locations (see `registrySearchPath` / `defaultRegistryDir`).
108
- * @param options - timezone, checksum verification, autofetch — see `RegistryOptions`.
109
- * @throws {RegistryError} when a directory named explicitly (the argument or
110
- * `CHTYPES_REGISTRY`) does not exist and autofetch is off, when no
111
- * directory on the search path holds an artifact (and autofetch is off),
112
- * the primary directory cannot be read, an artifact fails its checksum,
113
- * fails to load, or reports a ClickHouse version different from its
114
- * manifest's.
154
+ * @param options - timezone, checksum verification, autofetch, preload — see
155
+ * `RegistryOptions`.
156
+ * @throws {RegistryError} for what manifests can decide, and only that: a
157
+ * directory named explicitly (the argument or `CHTYPES_REGISTRY`) that does
158
+ * not exist, and no directory on the search path holding a readable
159
+ * `<minor>/manifest.json` — both suppressed when autofetch is on. A
160
+ * `preload` entry no directory holds is `ArtifactMissingError`. Everything
161
+ * a bad artifact can be wrong about — a failed checksum, a load failure, a
162
+ * library whose ClickHouse version disagrees with its manifest — is
163
+ * reported by the call that opens it, which is `preload`'s open at
164
+ * construction or the first `for()` otherwise.
115
165
  * @throws {ChtypesError} when an artifact reports a different nonzero ABI
116
166
  * revision than this binding speaks, or `chs_init` fails (e.g. an unknown
117
- * timezone — the message names it).
167
+ * timezone — the message names it); again, from the call that opens it.
118
168
  */
119
169
  constructor(dir?: string, options?: RegistryOptions);
170
+ /**
171
+ * Open one `preload` entry, before the constructor returns, without
172
+ * fetching. Resolution is `for()`'s, and so is the failure: a line no
173
+ * directory holds is the same `ArtifactMissingError`, raised earlier.
174
+ */
175
+ private preloadLine;
120
176
  /** dlopen one artifact directory, cross-check it, `chs_init` it, index it. */
121
177
  private load;
122
178
  /** Load `<dir>/<minor>/` if it is an artifact directory; null when it is not. */
123
179
  private loadLine;
124
180
  private lookup;
125
- /** The ClickHouse minor lines this registry has loaded, oldest first. */
181
+ /**
182
+ * Resolve without fetching: what is already open, then the line's directory
183
+ * as the construction-time scan recorded it, then a fresh walk of the search
184
+ * path for a line installed since. `undefined` means no directory holds it,
185
+ * which is a fetch's cue on `open()` and the §7 error everywhere else —
186
+ * `preload` never fetches, and this is the one function that makes the
187
+ * preload path and the first-use path identical in everything else.
188
+ */
189
+ private resolve;
190
+ /**
191
+ * Every ClickHouse minor line this registry CAN ANSWER FOR, oldest first —
192
+ * the ones it has opened plus the ones its construction-time manifest scan
193
+ * discovered on the search path.
194
+ *
195
+ * That is one meaning in all four bindings, and it is the meaning that
196
+ * survives lazy loading: "the lines that happen to be open" would read as an
197
+ * empty registry until the first `for()`. It opens nothing.
198
+ */
126
199
  versions(): string[];
127
- /** Every loaded library, in release order (oldest minor line first). */
200
+ /**
201
+ * The libraries this registry has OPENED, in release order (oldest minor
202
+ * line first) — what is open right now, never what could be. A discovered
203
+ * line that no `for()` and no `preload` has opened appears in `versions()`
204
+ * and not here. It opens nothing.
205
+ */
128
206
  libraries(): readonly Library[];
129
207
  /**
130
208
  * Resolve a version to its library. A minor line ("25.8") or an exact patch
131
209
  * ("25.8.28.1-lts") both work, and an unknown patch inside a loaded minor line
132
210
  * resolves to that line — asking for "25.8.30.16" finds the loaded 25.8.
133
211
  *
134
- * A line the primary directory lacks is loaded from the first later
135
- * directory on the search path that holds it (docs/guides/fetch.md §1), and joins
136
- * `versions()` / `libraries()` from then on. Never a fetch: this call is
137
- * synchronous; `open()` is the one that may fetch.
212
+ * **This is what opens an artifact.** Construction does not: the line is
213
+ * taken from the first directory on the search path that holds it
214
+ * (docs/guides/fetch.md §1), `dlopen`ed once, and joins `libraries()` from
215
+ * then on. Never a fetch: this call is synchronous; `open()` is the one that
216
+ * may fetch.
138
217
  *
139
218
  * Failure is the one §7 error, never a fallback to the nearest version:
140
219
  * answering 26.7 semantics from a 25.8 artifact is a lie, and silent
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,OAAO,EAAW,MAAM,cAAc,CAAC;AAWhD,yEAAyE;AACzE,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,6FAA6F;IAC7F,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CACnC;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,QAAQ;IACnB;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,+FAA+F;IAC/F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAA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