@wavehouse/chtypes 0.5.2 → 1.0.2
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/CHANGELOG.md +34 -0
- package/README.md +34 -38
- package/dist/abi1/buildinfo.d.ts +40 -0
- package/dist/abi1/buildinfo.d.ts.map +1 -0
- package/dist/abi1/buildinfo.js +83 -0
- package/dist/abi1/buildinfo.js.map +1 -0
- package/dist/abi1/calls.gen.d.ts +55 -0
- package/dist/abi1/calls.gen.d.ts.map +1 -0
- package/dist/abi1/calls.gen.js +110 -0
- package/dist/abi1/calls.gen.js.map +1 -0
- package/dist/abi1/decls.gen.d.ts +115 -0
- package/dist/abi1/decls.gen.d.ts.map +1 -0
- package/dist/abi1/decls.gen.js +1613 -0
- package/dist/abi1/decls.gen.js.map +1 -0
- package/dist/abi1/errmap.gen.d.ts +18 -0
- package/dist/abi1/errmap.gen.d.ts.map +1 -0
- package/dist/abi1/errmap.gen.js +66 -0
- package/dist/abi1/errmap.gen.js.map +1 -0
- package/dist/abi1/errors.d.ts +107 -0
- package/dist/abi1/errors.d.ts.map +1 -0
- package/dist/abi1/errors.js +134 -0
- package/dist/abi1/errors.js.map +1 -0
- package/dist/abi1/handles.d.ts +31 -0
- package/dist/abi1/handles.d.ts.map +1 -0
- package/dist/abi1/handles.js +76 -0
- package/dist/abi1/handles.js.map +1 -0
- package/dist/abi1/index.d.ts +17 -0
- package/dist/abi1/index.d.ts.map +1 -0
- package/dist/abi1/index.js +17 -0
- package/dist/abi1/index.js.map +1 -0
- package/dist/abi1/libc.d.ts +54 -0
- package/dist/abi1/libc.d.ts.map +1 -0
- package/dist/abi1/libc.gen.d.ts +12 -0
- package/dist/abi1/libc.gen.d.ts.map +1 -0
- package/dist/abi1/libc.gen.js +75 -0
- package/dist/abi1/libc.gen.js.map +1 -0
- package/dist/abi1/libc.js +109 -0
- package/dist/abi1/libc.js.map +1 -0
- package/dist/abi1/loader.d.ts +101 -0
- package/dist/abi1/loader.d.ts.map +1 -0
- package/dist/abi1/loader.js +274 -0
- package/dist/abi1/loader.js.map +1 -0
- package/dist/abi1/raw.d.ts +104 -0
- package/dist/abi1/raw.d.ts.map +1 -0
- package/dist/abi1/raw.js +296 -0
- package/dist/abi1/raw.js.map +1 -0
- package/dist/abi1/strictjson.d.ts +19 -0
- package/dist/abi1/strictjson.d.ts.map +1 -0
- package/dist/abi1/strictjson.js +78 -0
- package/dist/abi1/strictjson.js.map +1 -0
- package/dist/abi1/vocab.gen.d.ts +169 -0
- package/dist/abi1/vocab.gen.d.ts.map +1 -0
- package/dist/abi1/vocab.gen.js +306 -0
- package/dist/abi1/vocab.gen.js.map +1 -0
- package/dist/cli.d.ts +25 -26
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +206 -218
- package/dist/cli.js.map +1 -1
- package/dist/documents.d.ts +195 -0
- package/dist/documents.d.ts.map +1 -0
- package/dist/documents.js +389 -0
- package/dist/documents.js.map +1 -0
- package/dist/env.d.ts +16 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +57 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +19 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -23
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +11 -89
- package/dist/json.d.ts.map +1 -1
- package/dist/json.js +16 -180
- package/dist/json.js.map +1 -1
- package/dist/library.d.ts +53 -309
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +77 -315
- package/dist/library.js.map +1 -1
- package/dist/ocifetch/constants.gen.d.ts +84 -0
- package/dist/ocifetch/constants.gen.d.ts.map +1 -0
- package/dist/ocifetch/constants.gen.js +92 -0
- package/dist/ocifetch/constants.gen.js.map +1 -0
- package/dist/ocifetch/dsse.d.ts +114 -0
- package/dist/ocifetch/dsse.d.ts.map +1 -0
- package/dist/ocifetch/dsse.js +331 -0
- package/dist/ocifetch/dsse.js.map +1 -0
- package/dist/ocifetch/ensure.d.ts +65 -0
- package/dist/ocifetch/ensure.d.ts.map +1 -0
- package/dist/ocifetch/ensure.js +775 -0
- package/dist/ocifetch/ensure.js.map +1 -0
- package/dist/ocifetch/errors.d.ts +92 -0
- package/dist/ocifetch/errors.d.ts.map +1 -0
- package/dist/ocifetch/errors.js +101 -0
- package/dist/ocifetch/errors.js.map +1 -0
- package/dist/ocifetch/goldens.d.ts +44 -0
- package/dist/ocifetch/goldens.d.ts.map +1 -0
- package/dist/ocifetch/goldens.js +62 -0
- package/dist/ocifetch/goldens.js.map +1 -0
- package/dist/ocifetch/http.d.ts +124 -0
- package/dist/ocifetch/http.d.ts.map +1 -0
- package/dist/ocifetch/http.js +549 -0
- package/dist/ocifetch/http.js.map +1 -0
- package/dist/ocifetch/index.d.ts +17 -0
- package/dist/ocifetch/index.d.ts.map +1 -0
- package/dist/ocifetch/index.js +14 -0
- package/dist/ocifetch/index.js.map +1 -0
- package/dist/ocifetch/layout.d.ts +126 -0
- package/dist/ocifetch/layout.d.ts.map +1 -0
- package/dist/ocifetch/layout.js +375 -0
- package/dist/ocifetch/layout.js.map +1 -0
- package/dist/ocifetch/localverify.d.ts +43 -0
- package/dist/ocifetch/localverify.d.ts.map +1 -0
- package/dist/ocifetch/localverify.js +164 -0
- package/dist/ocifetch/localverify.js.map +1 -0
- package/dist/ocifetch/lock.d.ts +39 -0
- package/dist/ocifetch/lock.d.ts.map +1 -0
- package/dist/ocifetch/lock.js +140 -0
- package/dist/ocifetch/lock.js.map +1 -0
- package/dist/ocifetch/oci.d.ts +100 -0
- package/dist/ocifetch/oci.d.ts.map +1 -0
- package/dist/ocifetch/oci.js +323 -0
- package/dist/ocifetch/oci.js.map +1 -0
- package/dist/ocifetch/referrers.d.ts +55 -0
- package/dist/ocifetch/referrers.d.ts.map +1 -0
- package/dist/ocifetch/referrers.js +132 -0
- package/dist/ocifetch/referrers.js.map +1 -0
- package/dist/ocifetch/types.d.ts +167 -0
- package/dist/ocifetch/types.d.ts.map +1 -0
- package/dist/ocifetch/types.js +88 -0
- package/dist/ocifetch/types.js.map +1 -0
- package/dist/ocifetch/unpack.d.ts +55 -0
- package/dist/ocifetch/unpack.d.ts.map +1 -0
- package/dist/ocifetch/unpack.js +205 -0
- package/dist/ocifetch/unpack.js.map +1 -0
- package/dist/registry.d.ts +38 -387
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +95 -819
- package/dist/registry.js.map +1 -1
- package/dist/schema.d.ts +77 -588
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +87 -549
- package/dist/schema.js.map +1 -1
- package/dist/settings.d.ts +27 -36
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +75 -25
- package/dist/settings.js.map +1 -1
- package/dist/setup.d.ts +46 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +79 -0
- package/dist/setup.js.map +1 -0
- package/dist/tar.d.ts +27 -11
- package/dist/tar.d.ts.map +1 -1
- package/dist/tar.js +54 -32
- package/dist/tar.js.map +1 -1
- package/package.json +2 -2
- package/dist/discover.d.ts +0 -142
- package/dist/discover.d.ts.map +0 -1
- package/dist/discover.js +0 -288
- package/dist/discover.js.map +0 -1
- package/dist/error-codes.d.ts +0 -80
- package/dist/error-codes.d.ts.map +0 -1
- package/dist/error-codes.js +0 -139
- package/dist/error-codes.js.map +0 -1
- package/dist/errors.d.ts +0 -284
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -321
- package/dist/errors.js.map +0 -1
- package/dist/fetch.d.ts +0 -382
- package/dist/fetch.d.ts.map +0 -1
- package/dist/fetch.js +0 -1498
- package/dist/fetch.js.map +0 -1
- package/dist/ffi.d.ts +0 -410
- package/dist/ffi.d.ts.map +0 -1
- package/dist/ffi.js +0 -1154
- package/dist/ffi.js.map +0 -1
- package/dist/format.d.ts +0 -128
- package/dist/format.d.ts.map +0 -1
- package/dist/format.js +0 -132
- package/dist/format.js.map +0 -1
- package/dist/numeric.d.ts +0 -20
- package/dist/numeric.d.ts.map +0 -1
- package/dist/numeric.js +0 -107
- package/dist/numeric.js.map +0 -1
- package/dist/paths.d.ts +0 -55
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js +0 -87
- package/dist/paths.js.map +0 -1
- package/dist/results.d.ts +0 -495
- package/dist/results.d.ts.map +0 -1
- package/dist/results.js +0 -406
- package/dist/results.js.map +0 -1
- package/dist/transform.d.ts +0 -73
- package/dist/transform.d.ts.map +0 -1
- package/dist/transform.js +0 -533
- package/dist/transform.js.map +0 -1
package/dist/results.js
DELETED
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The result types and the document parsers. Field for field the same concepts
|
|
3
|
-
* as the reference implementation's `RowResult` / `BatchResult`
|
|
4
|
-
* (docs/reference/bindings.md §Result types), in TypeScript spelling.
|
|
5
|
-
*
|
|
6
|
-
* ---------------------------------------------------------------- text vs bytes
|
|
7
|
-
* Every rendered value here comes in both spellings, and which one is
|
|
8
|
-
* authoritative is not a matter of taste:
|
|
9
|
-
*
|
|
10
|
-
* `bytes` the exact slice ClickHouse emitted — the answer. Equivalent to the
|
|
11
|
-
* reference's `json.RawMessage`, and the only form a `String`,
|
|
12
|
-
* `FixedString` or `AggregateFunction` value survives (it holds
|
|
13
|
-
* arbitrary bytes; base64 or `Buffer` it, never a JS string).
|
|
14
|
-
* `text` those bytes decoded as UTF-8, for logs, comparisons and previews.
|
|
15
|
-
* **Lossy exactly when the bytes are not valid UTF-8**, where a JS
|
|
16
|
-
* string can only hold U+FFFD. `isValidUtf8(bytes)` says so.
|
|
17
|
-
*
|
|
18
|
-
* A caller that echoes a value back into an INSERT, hashes it, or compares it
|
|
19
|
-
* against a real server MUST use `bytes`: reporting U+FFFD where the table holds
|
|
20
|
-
* `0xff` is an invented transformation, which is the one thing this product may
|
|
21
|
-
* never do.
|
|
22
|
-
*/
|
|
23
|
-
import { asBool, asBytes, asInt, asString, asStringArray, field, hasField, items, rawBytes, rawText, } from './json.js';
|
|
24
|
-
import { classify, isLossyReason } from './transform.js';
|
|
25
|
-
/**
|
|
26
|
-
* The verdict on a row or a batch — the error taxonomy in one string, and
|
|
27
|
-
* conflating any two arms is a scoring error (the C ABI contract §Error model):
|
|
28
|
-
*
|
|
29
|
-
* - `'accepted'` — the server would take this, possibly with silent coercions
|
|
30
|
-
* (read `transformed`), defaults filled and volatile DEFAULTs substituted
|
|
31
|
-
* (read `substituted` — the caller MUST send those columns explicitly).
|
|
32
|
-
* - `'rejected'` — the server itself would refuse; `errCode` is ClickHouse's
|
|
33
|
-
* own code (27, 117, 455, …) and `errMsg` its own message. Tell the tenant.
|
|
34
|
-
* - `'accepted_poisoned'` — the insert is ACCEPTED (rc = 0) but the stored
|
|
35
|
-
* value can never be read back (`errCode` is the readback's code, usually
|
|
36
|
-
* 691). Never report it as a
|
|
37
|
-
* rejection.
|
|
38
|
-
* - `'unsupported'` — chtypes declines to answer ("a real server might well
|
|
39
|
-
* have accepted this; I will not guess"). NOT a rejection: fall back to the
|
|
40
|
-
* server. Mapping it onto either other arm manufactures an over-reject or an
|
|
41
|
-
* over-accept, both budgeted at zero.
|
|
42
|
-
* - `'skipped'` (2026-08-27) — the row was dropped under
|
|
43
|
-
* `input_format_allow_errors_*` and the batch continued: the server's own
|
|
44
|
-
* skip, itemized. `errCode`/`errMsg` carry the error the vendored reader
|
|
45
|
-
* caught before resyncing, verbatim; `values` is empty — the row is NOT
|
|
46
|
-
* stored. Only ever seen on rows inside a `BatchResult`, never as a batch
|
|
47
|
-
* verdict and never from `Schema#row`.
|
|
48
|
-
*/
|
|
49
|
-
export const Outcome = {
|
|
50
|
-
Accepted: 'accepted',
|
|
51
|
-
Rejected: 'rejected',
|
|
52
|
-
AcceptedPoisoned: 'accepted_poisoned',
|
|
53
|
-
Unsupported: 'unsupported',
|
|
54
|
-
Skipped: 'skipped',
|
|
55
|
-
};
|
|
56
|
-
const EMPTY = Buffer.alloc(0);
|
|
57
|
-
/**
|
|
58
|
-
* The two revision-5 `source` provenances `columns_json` introduces (issue
|
|
59
|
-
* #53), plus the pre-existing `Skipped` provenance named alongside them
|
|
60
|
-
* (issue #90). A plain const object, not a closed union: `source` is a
|
|
61
|
-
* growing vocabulary arriving from the C layer, and an unrecognized spelling
|
|
62
|
-
* from a newer artifact must pass through unchanged, not be rejected.
|
|
63
|
-
*/
|
|
64
|
-
export const Source = {
|
|
65
|
-
/**
|
|
66
|
-
* MATERIALIZED / ALIAS / EPHEMERAL, never read from an input row.
|
|
67
|
-
* Predates revision 5 — unlike the two provenances below — but
|
|
68
|
-
* `rowResultOf` has excluded it from `values` from the start, the same
|
|
69
|
-
* exclusion `EphemeralInput` was modeled on. Named here, in the same
|
|
70
|
-
* idiom, so the exclusion can be keyed on a symbol rather than a bare
|
|
71
|
-
* string literal.
|
|
72
|
-
*/
|
|
73
|
-
Skipped: 'skipped',
|
|
74
|
-
/**
|
|
75
|
-
* A listed EPHEMERAL column's read value. The server reads it — it is in
|
|
76
|
-
* scope for the DEFAULT expressions that reference it — and it is never
|
|
77
|
-
* stored and never exported. `rowResultOf` excludes it from `values`
|
|
78
|
-
* exactly as it already excludes `Source.Skipped`: a value that is never
|
|
79
|
-
* stored must not sit where a caller reads the stored row (a hash, a
|
|
80
|
-
* signature).
|
|
81
|
-
*/
|
|
82
|
-
EphemeralInput: 'ephemeral_input',
|
|
83
|
-
/**
|
|
84
|
-
* A listed MATERIALIZED column's supplied value under
|
|
85
|
-
* `insert_allow_materialized_columns=1`. The supplied value REPLACES the
|
|
86
|
-
* column's expression and IS stored — unlike `EphemeralInput`, it stays
|
|
87
|
-
* IN `values`.
|
|
88
|
-
*/
|
|
89
|
-
MaterializedInput: 'materialized_input',
|
|
90
|
-
/**
|
|
91
|
-
* A VOLATILE DEFAULT (`now()`/`now64(n)`/`today()`/`yesterday()`, or an
|
|
92
|
-
* expression over one) this library resolved locally rather than
|
|
93
|
-
* ClickHouse — the caller MUST send it as an explicit column on any later
|
|
94
|
-
* INSERT, or the value silently drifts each attempt. `rowResultOf` has
|
|
95
|
-
* always populated `substituted` for exactly this src value; like
|
|
96
|
-
* `Skipped` before issue #90, it had no named constant of its own (issue
|
|
97
|
-
* #122).
|
|
98
|
-
*/
|
|
99
|
-
DefaultSubstituted: 'default_substituted',
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Map a document's outcome string. An outcome this binding does not recognize
|
|
103
|
-
* degrades to `unsupported`, never to `rejected` (docs/reference/bindings.md
|
|
104
|
-
* §RowResult, rule added 2026-08-26): a future artifact's new verdict is an
|
|
105
|
-
* answer this binding cannot interpret, and `unsupported` is the arm that is
|
|
106
|
-
* never scored as agreement, while a default of `rejected` would manufacture
|
|
107
|
-
* an over-reject — the zero-budget failure — out of pure vocabulary drift.
|
|
108
|
-
*/
|
|
109
|
-
function outcomeOf(s) {
|
|
110
|
-
switch (s) {
|
|
111
|
-
case 'accepted':
|
|
112
|
-
return 'accepted';
|
|
113
|
-
case 'rejected':
|
|
114
|
-
return 'rejected';
|
|
115
|
-
case 'accepted_poisoned':
|
|
116
|
-
return 'accepted_poisoned';
|
|
117
|
-
case 'unsupported':
|
|
118
|
-
return 'unsupported';
|
|
119
|
-
case 'skipped':
|
|
120
|
-
return 'skipped';
|
|
121
|
-
default:
|
|
122
|
-
return 'unsupported';
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// Exported (but not re-exported from index.ts, so the public surface is
|
|
126
|
-
// unchanged) so tests can parse a single `cols[]` entry the way `rowResultOf`
|
|
127
|
-
// does and call `classify()` on it directly — see transform-ephemeral.test.ts, #97.
|
|
128
|
-
export function columnDocOf(raw) {
|
|
129
|
-
const poison = asBool(field(raw, 'poison'));
|
|
130
|
-
const inputNode = field(raw, 'input');
|
|
131
|
-
const storedNode = field(raw, 'stored');
|
|
132
|
-
const storedIsNull = storedNode !== undefined && storedNode.kind === 'null';
|
|
133
|
-
const refNode = field(raw, 'ref');
|
|
134
|
-
// Absent, or a literal null: no reference parse applies (the reference
|
|
135
|
-
// implementation's `Ref()` folds both onto "").
|
|
136
|
-
const refPresent = refNode !== undefined && refNode.kind !== 'null';
|
|
137
|
-
// A JSON null in `stored` is a real stored value (a Nullable column holding
|
|
138
|
-
// null), not the absence of one. Only the poison case has no renderable value.
|
|
139
|
-
const storedPresent = storedNode !== undefined && !poison;
|
|
140
|
-
return {
|
|
141
|
-
name: asString(field(raw, 'name')),
|
|
142
|
-
type: asString(field(raw, 'type')),
|
|
143
|
-
base: asString(field(raw, 'base')),
|
|
144
|
-
src: asString(field(raw, 'src')),
|
|
145
|
-
input: asString(inputNode),
|
|
146
|
-
refType: asString(field(raw, 'ref_type')),
|
|
147
|
-
stored: storedPresent ? rawText(storedNode) : '',
|
|
148
|
-
ref: refPresent ? rawText(refNode) : '',
|
|
149
|
-
inputBytes: asBytes(inputNode),
|
|
150
|
-
storedBytes: storedPresent ? rawBytes(storedNode) : EMPTY,
|
|
151
|
-
refBytes: refPresent ? rawBytes(refNode) : EMPTY,
|
|
152
|
-
nullable: asBool(field(raw, 'nullable')),
|
|
153
|
-
poison,
|
|
154
|
-
nullInput: asBool(field(raw, 'null_input')),
|
|
155
|
-
dupDropped: asBool(field(raw, 'dup_dropped')),
|
|
156
|
-
refUnclassified: asBool(field(raw, 'ref_unclassified')),
|
|
157
|
-
storedIsNull,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/** Turn one row document into a `RowResult`. */
|
|
161
|
-
export function rowResultOf(doc) {
|
|
162
|
-
const unknownFields = asStringArray(field(doc, 'unknown_fields'));
|
|
163
|
-
const unsupportedSettings = asStringArray(field(doc, 'unsupported_settings'));
|
|
164
|
-
let outcome = outcomeOf(asString(field(doc, 'outcome')));
|
|
165
|
-
// A declined setting must never be scored as agreement.
|
|
166
|
-
if (unsupportedSettings.length > 0 && outcome !== 'rejected')
|
|
167
|
-
outcome = 'unsupported';
|
|
168
|
-
const values = [];
|
|
169
|
-
const transformed = [];
|
|
170
|
-
const substituted = [];
|
|
171
|
-
for (const rawCol of items(field(doc, 'cols'))) {
|
|
172
|
-
const c = columnDocOf(rawCol);
|
|
173
|
-
// Source.Skipped (MATERIALIZED/ALIAS/EPHEMERAL, never read) and
|
|
174
|
-
// Source.EphemeralInput (a LISTED EPHEMERAL column: read, but never
|
|
175
|
-
// stored — see the `source` doc on `Value`) are both excluded from
|
|
176
|
-
// `values`, which is the stored row. Source.MaterializedInput stays IN:
|
|
177
|
-
// under insert_allow_materialized_columns=1 the supplied value genuinely
|
|
178
|
-
// IS stored, replacing the column's expression (issue #53).
|
|
179
|
-
if (c.src === Source.Skipped || c.src === Source.EphemeralInput)
|
|
180
|
-
continue;
|
|
181
|
-
values.push({
|
|
182
|
-
column: c.name,
|
|
183
|
-
text: c.stored,
|
|
184
|
-
bytes: c.storedBytes,
|
|
185
|
-
isNull: c.storedIsNull && !c.poison,
|
|
186
|
-
source: c.src,
|
|
187
|
-
});
|
|
188
|
-
if (c.src === Source.DefaultSubstituted) {
|
|
189
|
-
substituted.push({ column: c.name, expr: c.input, text: c.stored, bytes: c.storedBytes });
|
|
190
|
-
}
|
|
191
|
-
transformed.push(...classify(c));
|
|
192
|
-
}
|
|
193
|
-
const computed = items(field(doc, 'computed')).map((raw) => ({
|
|
194
|
-
column: asString(field(raw, 'name')),
|
|
195
|
-
kind: asString(field(raw, 'kind')),
|
|
196
|
-
text: rawText(field(raw, 'stored')),
|
|
197
|
-
bytes: rawBytes(field(raw, 'stored')),
|
|
198
|
-
}));
|
|
199
|
-
// `verdict` (RowsExportWith's TypeScript spelling: `rows(..., { rowFilter })`)
|
|
200
|
-
// is present exactly when a filter was attached to the call that produced
|
|
201
|
-
// this document — absent from every Row/Rows document and from `rows()`
|
|
202
|
-
// with no `rowFilter`. `verdictOf` degrades an unrecognized character to
|
|
203
|
-
// `'d'`, never to an invented answer.
|
|
204
|
-
const verdictNode = field(doc, 'verdict');
|
|
205
|
-
const verdict = verdictNode === undefined ? undefined : verdictOf(asString(verdictNode));
|
|
206
|
-
const verdictCode = asInt(field(doc, 'verdict_code'));
|
|
207
|
-
const verdictErr = asString(field(doc, 'verdict_err'));
|
|
208
|
-
// `partition_id` (revision 6) is present exactly when the schema declared a
|
|
209
|
-
// partition key and this row would be stored; absent stays absent.
|
|
210
|
-
const partitionNode = field(doc, 'partition_id');
|
|
211
|
-
return {
|
|
212
|
-
values,
|
|
213
|
-
transformed,
|
|
214
|
-
outcome,
|
|
215
|
-
errCode: asInt(field(doc, 'code')),
|
|
216
|
-
errMsg: asString(field(doc, 'err')),
|
|
217
|
-
unknownFields,
|
|
218
|
-
unsupportedSettings,
|
|
219
|
-
substituted,
|
|
220
|
-
computed,
|
|
221
|
-
verdict,
|
|
222
|
-
verdictCode,
|
|
223
|
-
verdictErr,
|
|
224
|
-
...(partitionNode !== undefined && partitionNode.kind === 'string' ? { partitionId: asString(partitionNode) } : {}),
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Turn one batch document into a `BatchResult`. `payload` is the export
|
|
229
|
-
* channel's copy from the FFI layer (`null` = the ABI's `{NULL, 0}` — mapped
|
|
230
|
-
* to `undefined`; a zero-length Buffer is emitted-empty and kept), which the
|
|
231
|
-
* document itself never carries.
|
|
232
|
-
*/
|
|
233
|
-
export function batchResultOf(doc, payload = null) {
|
|
234
|
-
const rows = [];
|
|
235
|
-
const transformed = [];
|
|
236
|
-
items(field(doc, 'rows')).forEach((rawRow, index) => {
|
|
237
|
-
const row = rowResultOf(rawRow);
|
|
238
|
-
for (const t of row.transformed)
|
|
239
|
-
t.row = index;
|
|
240
|
-
transformed.push(...row.transformed);
|
|
241
|
-
rows.push(row);
|
|
242
|
-
});
|
|
243
|
-
// storage_transforms is what the STORAGE layer did to rows the type layer
|
|
244
|
-
// accepted: ttl_expired (the row is not stored at all) and ttl_column_expired
|
|
245
|
-
// (the value was reset to the column DEFAULT). Both are lossy by construction
|
|
246
|
-
// and both must be folded in here.
|
|
247
|
-
for (const rawSt of items(field(doc, 'storage_transforms'))) {
|
|
248
|
-
const reason = asString(field(rawSt, 'reason'));
|
|
249
|
-
const stored = hasField(rawSt, 'stored') ? field(rawSt, 'stored') : undefined;
|
|
250
|
-
transformed.push({
|
|
251
|
-
column: asString(field(rawSt, 'column')),
|
|
252
|
-
input: '',
|
|
253
|
-
stored: stored === undefined ? '' : rawText(stored),
|
|
254
|
-
inputBytes: EMPTY,
|
|
255
|
-
storedBytes: rawBytes(stored),
|
|
256
|
-
reason,
|
|
257
|
-
row: asInt(field(rawSt, 'row')),
|
|
258
|
-
// ttl_expired and ttl_column_expired are both lossy by construction.
|
|
259
|
-
lossy: isLossyReason(reason),
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
const engineNode = field(doc, 'engine_rows');
|
|
263
|
-
const enginePresent = engineNode !== undefined && engineNode.kind === 'array';
|
|
264
|
-
const engineRowsBytes = enginePresent ? engineNode.items.map((r) => rawBytes(r)) : null;
|
|
265
|
-
// row_spans is present exactly when export bytes were emitted;
|
|
266
|
-
// export_declined exactly when an export was requested and withheld
|
|
267
|
-
// (the C ABI contract §Rows). Both absent = no export requested.
|
|
268
|
-
const spansNode = field(doc, 'row_spans');
|
|
269
|
-
const spans = spansNode === undefined
|
|
270
|
-
? undefined
|
|
271
|
-
: items(spansNode).map((s) => ({ off: asInt(field(s, 'off')), len: asInt(field(s, 'len')) }));
|
|
272
|
-
const declinedNode = field(doc, 'export_declined');
|
|
273
|
-
const exportDeclined = declinedNode === undefined ? undefined : asString(declinedNode);
|
|
274
|
-
const partitionCountNode = field(doc, 'partition_count');
|
|
275
|
-
return {
|
|
276
|
-
rows,
|
|
277
|
-
outcome: outcomeOf(asString(field(doc, 'outcome'))),
|
|
278
|
-
errCode: asInt(field(doc, 'code')),
|
|
279
|
-
errMsg: asString(field(doc, 'err')),
|
|
280
|
-
rowsRead: asInt(field(doc, 'rows_read')),
|
|
281
|
-
rowsSkipped: asInt(field(doc, 'rows_skipped')),
|
|
282
|
-
transformed,
|
|
283
|
-
engineRows: engineRowsBytes === null ? null : engineRowsBytes.map((b) => b.toString('utf8')),
|
|
284
|
-
engineRowsBytes,
|
|
285
|
-
payload: payload ?? undefined,
|
|
286
|
-
spans,
|
|
287
|
-
exportDeclined,
|
|
288
|
-
rowsPassed: asInt(field(doc, 'rows_passed')),
|
|
289
|
-
rowsCut: asInt(field(doc, 'rows_cut')),
|
|
290
|
-
// Revision 6: present exactly when the schema declared a partition key;
|
|
291
|
-
// absent stays absent, never a guessed 0.
|
|
292
|
-
...(partitionCountNode !== undefined && partitionCountNode.kind === 'number'
|
|
293
|
-
? { partitionCount: asInt(partitionCountNode) }
|
|
294
|
-
: {}),
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
// ------------------------------------------------------------------ filters
|
|
298
|
-
/**
|
|
299
|
-
* One row's answer from `Filter#rows`. Two of the four states are ANSWERS and
|
|
300
|
-
* two are NOT, and the split is load-bearing: a caller enforcing visibility
|
|
301
|
-
* MUST fail closed (hide the row / fail the request) on `'e'` AND
|
|
302
|
-
* `'d'` — collapsing either into `'f'`-the-answer inverts
|
|
303
|
-
* fail-closed into fail-open under NOT, the measured leak class
|
|
304
|
-
* (docs/reference/bindings.md §Revision 3).
|
|
305
|
-
*
|
|
306
|
-
* Rendered as the wire character the C result document carries — the same
|
|
307
|
-
* spelling Go and Python use — rather than a word (docs/reference/bindings.md
|
|
308
|
-
* §Revision 3; aligned 2026-09-15, chtypes-sdk#13 A1).
|
|
309
|
-
*
|
|
310
|
-
* - `'t'` the predicate is non-NULL and non-zero for this row.
|
|
311
|
-
* - `'f'` false OR NULL — SQL's three-valued logic collapsed at the
|
|
312
|
-
* WHERE boundary, computed by the vendored functions.
|
|
313
|
-
* - `'e'` the predicate THREW on this row's values (e.g. NO_COMMON_TYPE
|
|
314
|
-
* 386 from `s = 257` over String). On a real server a WHERE
|
|
315
|
-
* that throws fails the WHOLE query. NOT an answer.
|
|
316
|
-
* - `'d'` this library declines to answer for this row — unparseable
|
|
317
|
-
* under the schema, poisoned, or the admission envelope
|
|
318
|
-
* tripped. NOT an answer, and the state an unknown verdict
|
|
319
|
-
* character degrades to.
|
|
320
|
-
*/
|
|
321
|
-
export const Verdict = {
|
|
322
|
-
True: 't',
|
|
323
|
-
False: 'f',
|
|
324
|
-
Error: 'e',
|
|
325
|
-
Decline: 'd',
|
|
326
|
-
};
|
|
327
|
-
/** Whether a verdict is an ANSWER (`'t'`/`'f'`) rather than an error
|
|
328
|
-
* or a decline. A security-enforcing caller hides the row when this is false. */
|
|
329
|
-
export function isAnswer(v) {
|
|
330
|
-
return v === 't' || v === 'f';
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Map ONE wire verdict character to a `Verdict` — the single place that
|
|
334
|
-
* decision is made, shared by `filterResultOf` (`chs_filter_rows`'s /
|
|
335
|
-
* `chs_block_parse`'s `verdicts` string, one char per row) and `rowResultOf`
|
|
336
|
-
* (`chs_rows`'s per-row `verdict` field, the revision-5 attached filter). A
|
|
337
|
-
* second, drifted copy of this switch is exactly how `'e'` or `'d'` could
|
|
338
|
-
* get silently collapsed into `'f'` in one call path and not the other —
|
|
339
|
-
* the fail-open bug this vocabulary exists to prevent.
|
|
340
|
-
*/
|
|
341
|
-
function verdictOf(ch) {
|
|
342
|
-
switch (ch) {
|
|
343
|
-
case 't':
|
|
344
|
-
return 't';
|
|
345
|
-
case 'f':
|
|
346
|
-
return 'f';
|
|
347
|
-
case 'e':
|
|
348
|
-
return 'e';
|
|
349
|
-
default:
|
|
350
|
-
// 'd', and any character this binding does not know: decline — fail
|
|
351
|
-
// closed, mirroring the unknown-outcome rule.
|
|
352
|
-
return 'd';
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* The CALL-level verdict of `Filter#rows` — whether evaluation completed at
|
|
357
|
-
* all; per-row failures live in the verdicts, not here. An outcome spelling
|
|
358
|
-
* this binding does not recognize degrades to `'unsupported'`, never to
|
|
359
|
-
* `'rejected'` (the unknown-outcome rule, docs/reference/bindings.md §RowResult).
|
|
360
|
-
*/
|
|
361
|
-
export const FilterOutcome = {
|
|
362
|
-
Ok: 'ok',
|
|
363
|
-
Rejected: 'rejected',
|
|
364
|
-
Unsupported: 'unsupported',
|
|
365
|
-
};
|
|
366
|
-
/**
|
|
367
|
-
* `chs_schema_column_default_kind`'s five answers, as `ColumnInfo#defaultKind`
|
|
368
|
-
* carries them. Named here because the Go, Python and Rust bindings all name
|
|
369
|
-
* them and a TypeScript caller was otherwise typing the strings by hand — and
|
|
370
|
-
* one of them is load-bearing: `EPHEMERAL` is the column a gateway must DECLINE
|
|
371
|
-
* to preview rather than mispreview (docs/reference/bindings.md §EPHEMERAL columns).
|
|
372
|
-
*/
|
|
373
|
-
export const DefaultKind = {
|
|
374
|
-
None: '',
|
|
375
|
-
Default: 'DEFAULT',
|
|
376
|
-
Materialized: 'MATERIALIZED',
|
|
377
|
-
Alias: 'ALIAS',
|
|
378
|
-
Ephemeral: 'EPHEMERAL',
|
|
379
|
-
};
|
|
380
|
-
/** Turn one filter document into a `FilterResult`. */
|
|
381
|
-
export function filterResultOf(doc) {
|
|
382
|
-
const rawOutcome = asString(field(doc, 'outcome'));
|
|
383
|
-
// 'unsupported', and every spelling this binding does not know, degrades to
|
|
384
|
-
// the decline arm — never the rejection arm.
|
|
385
|
-
const outcome = rawOutcome === 'ok' ? 'ok' : rawOutcome === 'rejected' ? 'rejected' : 'unsupported';
|
|
386
|
-
const base = {
|
|
387
|
-
outcome,
|
|
388
|
-
errCode: asInt(field(doc, 'code')),
|
|
389
|
-
errMsg: asString(field(doc, 'err')),
|
|
390
|
-
rowsRead: asInt(field(doc, 'rows_read')),
|
|
391
|
-
unsupportedSettings: asStringArray(field(doc, 'unsupported_settings')),
|
|
392
|
-
};
|
|
393
|
-
if (outcome !== 'ok')
|
|
394
|
-
return { ...base, verdicts: [], errors: [] };
|
|
395
|
-
const verdicts = [];
|
|
396
|
-
for (const ch of asString(field(doc, 'verdicts'))) {
|
|
397
|
-
verdicts.push(verdictOf(ch));
|
|
398
|
-
}
|
|
399
|
-
const errors = items(field(doc, 'errors')).map((e) => ({
|
|
400
|
-
row: asInt(field(e, 'row')),
|
|
401
|
-
code: asInt(field(e, 'code')),
|
|
402
|
-
err: asString(field(e, 'err')),
|
|
403
|
-
}));
|
|
404
|
-
return { ...base, verdicts, errors };
|
|
405
|
-
}
|
|
406
|
-
//# sourceMappingURL=results.js.map
|
package/dist/results.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"results.js","sourceRoot":"","sources":["../src/results.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,MAAM,EACN,OAAO,EACP,KAAK,EACL,QAAQ,EACR,aAAa,EACb,KAAK,EACL,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,OAAO,GAER,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,gBAAgB,EAAE,mBAAmB;IACrC,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,SAAS;CACV,CAAC;AAGX,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AA8B9B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB;;;;;;;OAOG;IACH,OAAO,EAAE,SAAS;IAClB;;;;;;;OAOG;IACH,cAAc,EAAE,iBAAiB;IACjC;;;;;OAKG;IACH,iBAAiB,EAAE,oBAAoB;IACvC;;;;;;;;OAQG;IACH,kBAAkB,EAAE,qBAAqB;CACjC,CAAC;AAoRX;;;;;;;GAOG;AACH,SAAS,SAAS,CAAC,CAAS;IAC1B,QAAQ,CAAC,EAAE,CAAC;QACV,KAAK,UAAU;YACb,OAAO,UAAU,CAAC;QACpB,KAAK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C;QAClC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACnC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QACxC,mBAAmB,EAAE,aAAa,CAAC,KAAK,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC;KACvE,CAAC;IACF,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAEnE,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;QAClD,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,MAAM,MAAM,GAAqB,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvE,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAC3B,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QAC7B,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;KAC/B,CAAC,CAAC,CAAC;IACJ,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACvC,CAAC"}
|
package/dist/transform.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Silent-transformation detection — a port of `go/chtypes/transform.go`.
|
|
3
|
-
*
|
|
4
|
-
* ClickHouse has no notion of "I changed your value": `readIntText` wraps mod
|
|
5
|
-
* 2^N, `SerializationDateTime` truncates, `parseUUID` maps every non-hex byte to
|
|
6
|
-
* 0xff, and all of it returns success. So the fact of a change has to be
|
|
7
|
-
* established from outside, and this is the one part of chtypes that is derived
|
|
8
|
-
* rather than executed by ClickHouse — which makes it the one part a binding can
|
|
9
|
-
* get wrong without the C library noticing. Omitting it scores 0 % recall on the
|
|
10
|
-
* arbiter's transformation axis regardless of everything else.
|
|
11
|
-
*
|
|
12
|
-
* Two independent detectors run and their union is reported:
|
|
13
|
-
*
|
|
14
|
-
* 1. **Supplied vs stored** — the raw input text against ClickHouse's rendering
|
|
15
|
-
* of what it kept. Models nothing; catches changes a widened type makes
|
|
16
|
-
* identically (2024-02-30 -> 2024-03-01) and types with no wider type to
|
|
17
|
-
* compare against (Float64, Int256, String).
|
|
18
|
-
* 2. **Reference type** — the C layer already parsed each field a second time
|
|
19
|
-
* through a structurally identical type with widened leaves and reported it
|
|
20
|
-
* as `ref` / `ref_type`. This names the reason precisely (an overflow wrap
|
|
21
|
-
* versus a decimal truncation) and still fires where the supplied text is
|
|
22
|
-
* not comparable (a CSV field, a base64 blob).
|
|
23
|
-
*
|
|
24
|
-
* Neither reimplements a coercion rule: the first compares two values already in
|
|
25
|
-
* hand, the second compares two ClickHouse answers.
|
|
26
|
-
*
|
|
27
|
-
* Both compare **bytes**. A supplied field and a stored `String` can each be any
|
|
28
|
-
* byte sequence, and two different byte sequences that both decode to U+FFFD are
|
|
29
|
-
* not the same value — deciding on decoded text would silently merge them, and
|
|
30
|
-
* `equivalent`'s fast path would then call a real change identical.
|
|
31
|
-
*/
|
|
32
|
-
import type { ColumnDoc, Transform } from './results.js';
|
|
33
|
-
/** The stable reason vocabulary. The harness groups on these strings. */
|
|
34
|
-
export declare const Reason: {
|
|
35
|
-
readonly OverflowWrap: 'overflow_wrap';
|
|
36
|
-
readonly NullToDefault: 'null_to_default';
|
|
37
|
-
readonly NullLoss: 'null_loss';
|
|
38
|
-
readonly DecimalTruncate: 'decimal_truncate';
|
|
39
|
-
readonly DateClamp: 'date_clamp';
|
|
40
|
-
readonly DateTimeWrap: 'datetime_wrap';
|
|
41
|
-
readonly DateShift: 'date_shift';
|
|
42
|
-
readonly UuidMangle: 'uuid_mangle';
|
|
43
|
-
readonly IpMangle: 'ip_mangle';
|
|
44
|
-
readonly FloatPrecision: 'float_precision';
|
|
45
|
-
readonly LossyNumeric: 'lossy_numeric';
|
|
46
|
-
readonly FixedStringPad: 'fixedstring_pad';
|
|
47
|
-
readonly Emptied: 'emptied';
|
|
48
|
-
readonly ElementChanged: 'element_changed';
|
|
49
|
-
readonly EnumCoerce: 'enum_coerce';
|
|
50
|
-
readonly ValueChanged: 'value_changed';
|
|
51
|
-
readonly Poisoned: 'poisoned';
|
|
52
|
-
readonly DuplicateKeyDropped: 'duplicate_key_dropped';
|
|
53
|
-
readonly Reformat: 'reformat';
|
|
54
|
-
readonly DefaultFilled: 'default_filled';
|
|
55
|
-
readonly ZeroFilled: 'zero_filled';
|
|
56
|
-
readonly DefaultMaterialized: 'default_materialized';
|
|
57
|
-
readonly TtlExpired: 'ttl_expired';
|
|
58
|
-
readonly TtlColumnExpired: 'ttl_column_expired';
|
|
59
|
-
};
|
|
60
|
-
/** One of the stable reason strings — see the `Reason` constant object. */
|
|
61
|
-
export type Reason = (typeof Reason)[keyof typeof Reason];
|
|
62
|
-
/**
|
|
63
|
-
* Whether a transform reason means information was LOST (a warning to raise to
|
|
64
|
-
* the tenant) rather than merely re-spelled or filled in. False for exactly
|
|
65
|
-
* four reasons — `reformat`, `default_filled`, `zero_filled`,
|
|
66
|
-
* `default_materialized` — true for everything else, unknown strings included:
|
|
67
|
-
* a reason nobody has audited must degrade to a warning, never to silence.
|
|
68
|
-
* Mirrors `Transform#lossy`. Never throws.
|
|
69
|
-
*/
|
|
70
|
-
export declare function isLossyReason(reason: string): boolean;
|
|
71
|
-
/** Classify one column of a row document. */
|
|
72
|
-
export declare function classify(c: ColumnDoc): Transform[];
|
|
73
|
-
//# sourceMappingURL=transform.d.ts.map
|
package/dist/transform.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,yEAAyE;AACzE,eAAO,MAAM,MAAM;aACjB,YAAY,EAAE,eAAe;aAC7B,aAAa,EAAE,iBAAiB;aAChC,QAAQ,EAAE,WAAW;aACrB,eAAe,EAAE,kBAAkB;aACnC,SAAS,EAAE,YAAY;aACvB,YAAY,EAAE,eAAe;aAC7B,SAAS,EAAE,YAAY;aACvB,UAAU,EAAE,aAAa;aACzB,QAAQ,EAAE,WAAW;aACrB,cAAc,EAAE,iBAAiB;aACjC,YAAY,EAAE,eAAe;aAC7B,cAAc,EAAE,iBAAiB;aACjC,OAAO,EAAE,SAAS;aAClB,cAAc,EAAE,iBAAiB;aACjC,UAAU,EAAE,aAAa;aACzB,YAAY,EAAE,eAAe;aAC7B,QAAQ,EAAE,UAAU;aACpB,mBAAmB,EAAE,uBAAuB;aAC5C,QAAQ,EAAE,UAAU;aACpB,aAAa,EAAE,gBAAgB;aAC/B,UAAU,EAAE,aAAa;aACzB,mBAAmB,EAAE,sBAAsB;aAC3C,UAAU,EAAE,aAAa;aACzB,gBAAgB,EAAE,oBAAoB;CAC9B,CAAC;AAEX,2EAA2E;AAC3E,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC;AAe1D;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD;AAsBD,6CAA6C;AAC7C,wBAAgB,QAAQ,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAwFlD"}
|