turbine-orm 0.76.0 → 0.77.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.
Files changed (87) hide show
  1. package/dist/cjs/cli/index.js +2 -2
  2. package/dist/cjs/cli/migrate.js +8 -8
  3. package/dist/cjs/cli/studio.js +6 -3
  4. package/dist/cjs/client.js +10 -10
  5. package/dist/cjs/dialect.js +1 -1
  6. package/dist/cjs/errors.d.ts +2 -2
  7. package/dist/cjs/errors.js +21 -25
  8. package/dist/cjs/generate.js +1 -1
  9. package/dist/cjs/introspect.js +5 -5
  10. package/dist/cjs/mssql.js +12 -12
  11. package/dist/cjs/mysql.js +5 -5
  12. package/dist/cjs/nested-write.js +31 -31
  13. package/dist/cjs/observe.js +1 -1
  14. package/dist/cjs/pipeline-submittable.js +5 -1
  15. package/dist/cjs/pipeline.js +8 -0
  16. package/dist/cjs/powdb-introspect.d.ts +1 -1
  17. package/dist/cjs/powdb-introspect.js +4 -4
  18. package/dist/cjs/powdb-shared.d.ts +348 -0
  19. package/dist/cjs/powdb-shared.js +587 -0
  20. package/dist/cjs/powdb.d.ts +12 -299
  21. package/dist/cjs/powdb.js +106 -567
  22. package/dist/cjs/powql.d.ts +1 -1
  23. package/dist/cjs/powql.js +89 -89
  24. package/dist/cjs/prisma-compat.js +16 -16
  25. package/dist/cjs/query/aggregates.js +19 -20
  26. package/dist/cjs/query/batched-loader.js +8 -8
  27. package/dist/cjs/query/builder.js +8 -8
  28. package/dist/cjs/query/compound-unique.js +2 -2
  29. package/dist/cjs/query/filters.js +1 -1
  30. package/dist/cjs/query/relations.js +60 -48
  31. package/dist/cjs/query/types.js +4 -4
  32. package/dist/cjs/query/utils.js +5 -5
  33. package/dist/cjs/query/warn-registry.d.ts +7 -0
  34. package/dist/cjs/query/warn-registry.js +7 -0
  35. package/dist/cjs/query/where-compile.js +1 -1
  36. package/dist/cjs/query/where.js +30 -31
  37. package/dist/cjs/query/writes.js +7 -7
  38. package/dist/cjs/realtime.js +4 -4
  39. package/dist/cjs/schema-metadata.js +1 -1
  40. package/dist/cjs/schema-sql.js +3 -3
  41. package/dist/cjs/seed.js +1 -1
  42. package/dist/cjs/sqlite.js +7 -7
  43. package/dist/cjs/typed-sql.js +1 -1
  44. package/dist/cli/index.js +2 -2
  45. package/dist/cli/migrate.js +8 -8
  46. package/dist/cli/studio.js +6 -3
  47. package/dist/client.js +10 -10
  48. package/dist/dialect.js +1 -1
  49. package/dist/errors.d.ts +2 -2
  50. package/dist/errors.js +21 -25
  51. package/dist/generate.js +1 -1
  52. package/dist/introspect.js +5 -5
  53. package/dist/mssql.js +12 -12
  54. package/dist/mysql.js +5 -5
  55. package/dist/nested-write.js +31 -31
  56. package/dist/observe.js +1 -1
  57. package/dist/pipeline-submittable.js +6 -2
  58. package/dist/pipeline.js +9 -1
  59. package/dist/powdb-introspect.d.ts +1 -1
  60. package/dist/powdb-introspect.js +2 -2
  61. package/dist/powdb-shared.d.ts +348 -0
  62. package/dist/powdb-shared.js +570 -0
  63. package/dist/powdb.d.ts +12 -299
  64. package/dist/powdb.js +71 -534
  65. package/dist/powql.d.ts +1 -1
  66. package/dist/powql.js +43 -43
  67. package/dist/prisma-compat.js +16 -16
  68. package/dist/query/aggregates.js +19 -20
  69. package/dist/query/batched-loader.js +8 -8
  70. package/dist/query/builder.js +8 -8
  71. package/dist/query/compound-unique.js +2 -2
  72. package/dist/query/filters.js +1 -1
  73. package/dist/query/relations.js +60 -48
  74. package/dist/query/types.js +4 -4
  75. package/dist/query/utils.js +5 -5
  76. package/dist/query/warn-registry.d.ts +7 -0
  77. package/dist/query/warn-registry.js +7 -0
  78. package/dist/query/where-compile.js +1 -1
  79. package/dist/query/where.js +30 -31
  80. package/dist/query/writes.js +7 -7
  81. package/dist/realtime.js +4 -4
  82. package/dist/schema-metadata.js +1 -1
  83. package/dist/schema-sql.js +3 -3
  84. package/dist/seed.js +1 -1
  85. package/dist/sqlite.js +7 -7
  86. package/dist/typed-sql.js +1 -1
  87. package/package.json +15 -7
@@ -0,0 +1,348 @@
1
+ /**
2
+ * Shared PowDB primitives: identifier quoting, capability gating, type mapping
3
+ * and value coercion.
4
+ *
5
+ * KEEP THIS FILE FREE OF IMPORTS FROM powdb.ts / powql.ts / powdb-introspect.ts.
6
+ * That is the whole point: those three formed a runtime cycle because powdb.ts
7
+ * re-exported from the other two while both imported values back from it. This
8
+ * is the same shape pg-types.ts and connection-url.ts already use to keep
9
+ * client.ts and query/ acyclic.
10
+ *
11
+ * A cycle is not a style complaint. `dist/powdb.js` is the largest engine
12
+ * entry, and in a cycle one of its three modules always executes while another
13
+ * is half-initialized: whichever module the loader reaches first decides, so
14
+ * the same code can work under ESM and fail under CJS, or work until an import
15
+ * is reordered. The failure surfaces far from its cause, as an undefined
16
+ * binding at call time. `scripts/check-import-cycles.mjs` now fails the build
17
+ * on any such cycle under `src/`, so this file is what keeps that gate green
18
+ * for the PowDB engine.
19
+ *
20
+ * Everything here is re-exported by powdb.ts under its original name, so the
21
+ * public `turbine-orm/powdb` surface is byte-identical to before the split.
22
+ * The few helpers powdb.ts consumes but never published (`isDateColumn`) are
23
+ * exported from this module and NOT re-exported from powdb.ts.
24
+ *
25
+ * @module
26
+ */
27
+ import type { ColumnMetadata, TableMetadata } from './schema.js';
28
+ /**
29
+ * Marker wrapper for a value bound to a `float` column. The networked driver
30
+ * unwraps it to the plain number (the wire param is unchanged), but the
31
+ * *embedded* literal encoder reads it to emit a float-form PowQL literal (`42`
32
+ * → `42.0`) so an integer-valued float column stays unambiguously a float.
33
+ * Constructed in {@link PowqlInterface.param}.
34
+ */
35
+ export declare class PowdbFloatParam {
36
+ readonly value: number;
37
+ constructor(value: number);
38
+ }
39
+ /**
40
+ * Marker wrapper for a JS object/array bound to a `json` document column. Both
41
+ * transports serialize `value` with `JSON.stringify` and send the text as a
42
+ * `str` param / string literal, exactly how the PowDB docs insert a json
43
+ * document (the engine validates it as JSON text and stores the canonical
44
+ * binary form). Constructed in {@link PowqlInterface.param} when the target
45
+ * column is `json` and the value is a non-null object/array; a JS string
46
+ * written to a json column passes through RAW (same contract as pg jsonb,
47
+ * pass `'"x"'` to store the JSON string `"x"`), and `null` stays `null`.
48
+ */
49
+ export declare class PowdbJsonParam {
50
+ readonly value: unknown;
51
+ readonly column?: string | undefined;
52
+ /** `column` is diagnostic only: it names the target column when serialization fails. */
53
+ constructor(value: unknown, column?: string | undefined);
54
+ }
55
+ /**
56
+ * Feature capabilities of a bound PowDB connection. Resolved once (from the
57
+ * probed server version on the networked transport, or the addon package
58
+ * version on embedded) and carried on the pool so {@link PowqlInterface} can
59
+ * gate PowQL features that only exist on newer engines, an old engine gets a
60
+ * typed {@link UnsupportedFeatureError} (E017) with a version hint instead of a
61
+ * raw PowQL parse error.
62
+ */
63
+ export interface PowdbCapabilities {
64
+ /** Best-known engine version (e.g. `'0.13.0'`), or `null` when unknowable. */
65
+ engineVersion: string | null;
66
+ /** ≥ 0.12: `json` column type, `->` path filters / ordering / grouping. */
67
+ jsonDocs: boolean;
68
+ /** ≥ 0.13: `alter T add index (.col->seg)` expression indexes. */
69
+ docFieldIndexes: boolean;
70
+ /** ≥ 0.10: `schema` / `describe` introspection statements. */
71
+ introspection: boolean;
72
+ /** ≥ 0.13: server-side joins, hash-accelerated and bounded. */
73
+ serverJoins: boolean;
74
+ /**
75
+ * ≥ 0.18: nested projections (shaped results), a projection field may be a
76
+ * whole correlated child query returning a per-parent JSON array. When set,
77
+ * eligible `with` clauses compile into the parent statement instead of the
78
+ * batched loaders.
79
+ */
80
+ nestedProjections: boolean;
81
+ /**
82
+ * ≥ 0.19: entity links (`link` DDL, scalar/block traversal). Capability is
83
+ * recognized (probe-only), but query generation deliberately does NOT consume
84
+ * links yet: turbine keeps composing its own nested projections (see the
85
+ * PowDB engine page for the rationale). Declaring a link permanently upgrades
86
+ * the on-disk catalog to v7, so this stays FALSE in ALL_POWDB_CAPABILITIES.
87
+ */
88
+ entityLinks: boolean;
89
+ /**
90
+ * ≥ 0.19.1: link INTROSPECTION, the `schema links` listing statement and the
91
+ * appended link rows in `describe <T>`. Only meaningful when probed (there is
92
+ * no query-generation flip behind it), so it stays FALSE in
93
+ * ALL_POWDB_CAPABILITIES like the other probe-only gates. Floored at the PATCH
94
+ * 0.19.1: the listing statement shipped there, not in 0.19.0.
95
+ */
96
+ linkIntrospection: boolean;
97
+ /**
98
+ * ≥ 0.19.1: scalar to-one link PATHS in query generation. Floored at the PATCH
99
+ * 0.19.1 (never 0.19.0) because 0.19.0 had silent-wrong-results link bugs
100
+ * (bare-dotted-path split, wrong aggregates over links) that make traversal
101
+ * unsafe; 0.19.1 turned those into hard errors. This flag flips real query
102
+ * generation (a to-one `with` whose child carries bigint/bytes compiles to
103
+ * link-path projections instead of a loader), so it stays FALSE in
104
+ * ALL_POWDB_CAPABILITIES: it must only light up behind a real version probe.
105
+ */
106
+ linkPaths: boolean;
107
+ /**
108
+ * ≥ 0.20: a comparison between a `datetime` column and an integer timestamp
109
+ * literal evaluates as microseconds. Below 0.20 that pairing was unhandled and
110
+ * fell back to comparing TYPE TAGS (every DateTime sorted above every Int), so
111
+ * `>` matched every non-null row, `=` and `<` matched none, and the answer
112
+ * additionally depended on whether the column carried an index. Turbine binds
113
+ * a JS `Date` as int micros, so that is exactly the shape it emits: every
114
+ * datetime predicate was silently wrong on an older engine.
115
+ *
116
+ * The `in` / `not in` LIST form is a separate, still-open engine bug that 0.20
117
+ * did NOT fix, so this flag does not unlock it: a datetime `in` list is
118
+ * COMPILED AWAY into the equality chain the engine does answer correctly (see
119
+ * `PowqlInterface.buildInList`). That expansion needs working binary
120
+ * comparisons, so it too sits behind this flag.
121
+ *
122
+ * Predominantly a refusal gate, but the `in` rewrite makes it a (bounded)
123
+ * generation flip as well. It stays ON in {@link ALL_POWDB_CAPABILITIES}
124
+ * anyway: with the flag OFF the datetime paths do not fall back to some other
125
+ * SQL, they refuse outright, so a hand-constructed pool defaulting to OFF
126
+ * would break datetime queries that work rather than protect anything.
127
+ */
128
+ datetimeCompare: boolean;
129
+ /**
130
+ * ≥ 0.20: `count(T { .col })` counts non-null values of `.col` (SQL's
131
+ * `COUNT(col)`), which is what Turbine's per-field `_count` means. Below 0.20
132
+ * both frontends ignored the projection and returned the ROW count, so
133
+ * `aggregate({ _count: { field: true } })` silently disagreed with every SQL
134
+ * engine on a nullable column. `count(T)` / `_count: true` is unaffected on
135
+ * every version. Refusal-only gate (the emitted PowQL does not change).
136
+ */
137
+ projectedCountNonNull: boolean;
138
+ /** Networked only: server ≥ 0.13 AND the client exposes `queryNativeRaw`. */
139
+ nativeRaw: boolean;
140
+ }
141
+ /** The feature-gate capability keys (everything except the version/nativeRaw metadata). */
142
+ type PowdbFeatureKey = 'jsonDocs' | 'docFieldIndexes' | 'introspection' | 'serverJoins' | 'nestedProjections' | 'entityLinks' | 'linkIntrospection' | 'linkPaths' | 'datetimeCompare' | 'projectedCountNonNull';
143
+ /**
144
+ * Trusted-caller default: every FEATURE gate on, engine version unknown. Used
145
+ * for a directly-constructed {@link PowdbPool} / {@link PowdbEmbeddedPool} that
146
+ * did not go through {@link turbinePowDB}'s version probe (e.g. an injected
147
+ * pool, or a unit-test pool). `nativeRaw` stays OFF here because it flips the
148
+ * actual wire path and must only be enabled after a real server-version probe,
149
+ * never inferred from a bare construction. `nestedProjections` stays OFF for
150
+ * the same reason: it changes the generated PowQL for every `with` query, and
151
+ * an unprobed engine below 0.18 would reject the syntax outright.
152
+ * `entityLinks` stays OFF for a stronger reason still: declaring a link
153
+ * one-way-upgrades the on-disk catalog to v7 and locks out pre-0.19 binaries,
154
+ * so it must only ever light up behind a real version probe.
155
+ * `linkIntrospection` / `linkPaths` stay OFF for the same probe-only discipline:
156
+ * `linkPaths` flips real query generation (a to-one `with` compiling to link
157
+ * projections), and `linkIntrospection` is only meaningful once genuinely
158
+ * probed, so both must come from a real version resolution, never a bare
159
+ * construction.
160
+ * `datetimeCompare` / `projectedCountNonNull` stay ON here for the same
161
+ * trusted-caller reason as `jsonDocs` and `serverJoins`. Neither is a fallback
162
+ * gate: with the flag OFF the affected query is REFUSED, not served by some
163
+ * other statement, so defaulting them off would break working queries rather
164
+ * than protect anything. Every path that can learn the engine version
165
+ * (`turbinePowDB`, embedded or networked) resolves them from a real probe; this
166
+ * fallback only covers a hand-constructed or injected pool, whose owner is
167
+ * asserting the engine is current.
168
+ */
169
+ export declare const ALL_POWDB_CAPABILITIES: PowdbCapabilities;
170
+ /**
171
+ * Throw a version-hinting {@link UnsupportedFeatureError} (E017) when a gated
172
+ * PowQL feature is used on an engine that does not support it. Keeps old engines
173
+ * getting clean typed errors instead of raw PowQL parse failures.
174
+ *
175
+ * The error's first sentence already names the feature (`<feature> is
176
+ * unsupported on "PowDB".`), so the hint says "Requires PowDB >= x" rather than
177
+ * repeating the label: a long feature description read twice in one message
178
+ * (`per-field \`_count\` … is unsupported … per-field \`_count\` … requires …`)
179
+ * buries the version floor that is the actionable part.
180
+ *
181
+ * `extra` appends one more sentence for gates that have a workaround worth
182
+ * naming (e.g. the read path that answers the same query without the gated
183
+ * comparison).
184
+ */
185
+ export declare function requireCapability(caps: PowdbCapabilities, key: PowdbFeatureKey, feature: string, extra?: string): void;
186
+ /**
187
+ * PowQL column types Turbine emits: the four writable scalars plus PowDB's
188
+ * native `json` document type (added to the map in the 0.12/0.13 parity round,
189
+ * see {@link isJsonColumn}). A `json` column stores a canonical binary document
190
+ * (sorted keys, int/float distinction preserved) that Turbine writes as a JSON
191
+ * string literal and reads back by parsing the canonical JSON text.
192
+ */
193
+ export type PowqlType = 'str' | 'int' | 'float' | 'bool' | 'json';
194
+ /**
195
+ * Strip a trailing `| null` union from a generated tsType and trim.
196
+ *
197
+ * THE ONE AUTHORITY for that question, and deliberately not a regular
198
+ * expression. The obvious spelling, `tsType.replace(/\s*\|\s*null$/i, '')`,
199
+ * is POLYNOMIAL: `\s*` can start at every position, so an input of N spaces
200
+ * with no `|` costs O(N^2). Measured on Node 24 before this change: 10,000
201
+ * spaces took 39.6 ms, 20,000 took 150.3 ms and 40,000 took 617.5 ms, the
202
+ * quadratic signature. It was written eight times across powdb.ts and powql.ts.
203
+ *
204
+ * `tsType` comes from a generated `metadata.ts` or from `defineSchema`, so it
205
+ * is not request input and this was never remotely reachable. It is fixed
206
+ * anyway, in one place, because eight hand-copied spellings of a hot predicate
207
+ * is the drift shape this codebase keeps paying for, and because the linear
208
+ * version is not harder to read.
209
+ *
210
+ * Semantics are byte-for-byte those of the regex it replaces, including the
211
+ * `$` anchor: `"string | null "` has trailing space so the union does NOT
212
+ * match, and the value only gets trimmed. `src/test/tstype-null-union.test.ts`
213
+ * asserts the equivalence over a corpus rather than asserting my reading of it.
214
+ */
215
+ export declare function baseTsType(tsType: string): string;
216
+ /**
217
+ * Does this column map to PowDB's native `json` document type? A Postgres
218
+ * `json`/`jsonb` type (via `dialectType`/`pgType`) is authoritative; otherwise
219
+ * the tsType heuristic (`Record<…>`, `object`, `unknown`, an object/array
220
+ * literal) that the four scalar branches do not claim. Array columns never map
221
+ * to json, a PowDB array only exists INSIDE a json document, so a Postgres
222
+ * array column has no PowDB shape and still throws in {@link powqlColumnType}.
223
+ */
224
+ export declare function isJsonColumn(col: ColumnMetadata): boolean;
225
+ /**
226
+ * Map a Turbine column to the PowQL DDL type used in `defineSchema` →
227
+ * `type T { … }`. Turbine never emits PowDB's `uuid`/`datetime`/`bytes` types,
228
+ * which cannot hold client-supplied values on the wire (no literal, no cast):
229
+ * - `Date` → `int` (epoch micros) - `boolean` → `bool`
230
+ * - integral `number`/`bigint` → `int` - fractional `number` → `float`
231
+ * - JSON / object columns → `json` (native PowDB document type, ≥ 0.12)
232
+ * - everything else (incl. UUID/PK strings) → `str`
233
+ * Array (non-json) and bytes columns throw, they have no PowDB equivalent.
234
+ */
235
+ export declare function powqlColumnType(col: ColumnMetadata): PowqlType;
236
+ /**
237
+ * Is a column stored as `int` epoch micros but surfaced as a JS `Date`?
238
+ *
239
+ * Exported because powdb.ts's parameter encoder asks the same question on the
240
+ * write side, and one definition of "this column is a Date" is the point of a
241
+ * shared leaf. Deliberately NOT re-exported from powdb.ts: the
242
+ * `turbine-orm/powdb` surface is unchanged by this split.
243
+ */
244
+ export declare function isDateColumn(col: ColumnMetadata): boolean;
245
+ /**
246
+ * Is this column stored in PowDB's NATIVE `datetime` type (as opposed to the
247
+ * `int` epoch micros Turbine's own DDL emits for a `Date` column)?
248
+ *
249
+ * Only the literal PowQL type name counts. `powqlColumnType` never returns
250
+ * `datetime`, so a Turbine-provisioned table can never have one; the shapes that
251
+ * do are a table created outside Turbine and read back through
252
+ * `introspectPowdbDatabase` (which maps `datetime` → `{ tsType: 'Date',
253
+ * dialectType: 'datetime' }`), or hand-written metadata declaring it. Deliberately
254
+ * strict: a Postgres-sourced `timestamptz` column is DDL'd as PowQL `int`, so it
255
+ * is NOT a PowDB datetime and must not be caught here.
256
+ *
257
+ * Matters because comparing a datetime column against the integer timestamp
258
+ * literal Turbine binds was silently wrong below engine 0.20 (see
259
+ * {@link PowdbCapabilities.datetimeCompare}).
260
+ */
261
+ export declare function isPowdbDatetimeColumn(col: ColumnMetadata): boolean;
262
+ /**
263
+ * PowQL reserved words, the v0.10 lexer keyword table from POWQL.md's
264
+ * "Reserved Words and Quoting" section, including the v0.10 additions
265
+ * `schema` and `describe`. Keyword matching is case-sensitive in the lexer,
266
+ * so only the exact lowercase form collides.
267
+ */
268
+ export declare const POWQL_KEYWORDS: ReadonlySet<string>;
269
+ /**
270
+ * Backtick-quote an identifier when PowQL would otherwise lex it as a keyword
271
+ * (or when it contains characters outside the bare-identifier grammar).
272
+ * Applied only in bare-identifier positions, DDL type/field names, index DDL,
273
+ * and `insert`/`update`/`upsert` assignment targets. Dotted references
274
+ * (`.col` in filters/projections/ordering) bypass keyword lookup on every
275
+ * engine version and deliberately stay bare for ≤0.9 compatibility. Backticks
276
+ * parse on PowDB ≥ 0.10; on older engines these names were already parse
277
+ * errors when emitted bare, so quoting is strictly an improvement.
278
+ */
279
+ export declare function quotePowqlIdent(name: string): string;
280
+ /**
281
+ * The DOTTED-position spelling of {@link quotePowqlIdent}: quote a name that
282
+ * falls outside the bare-identifier grammar, and only that.
283
+ *
284
+ * A dotted reference (`.col` in a filter, projection, `order`, `group`, or an
285
+ * `upsert on`) bypasses keyword lookup, so `.order` parses on every engine
286
+ * version and stays bare here, which is the ≤0.9 compatibility decision
287
+ * {@link quotePowqlIdent} documents and which this must not undo.
288
+ *
289
+ * What it does NOT excuse is interpolating the name RAW, which is what these
290
+ * sites used to do. Keyword-ness is a parsing question; a name outside
291
+ * `POWQL_BARE_IDENT` is a statement-integrity one, and that name is the only
292
+ * thing that can carry PowQL syntax into a statement whose values are all bound
293
+ * as `$N` params. Reaching it needs a hostile column name (an introspected
294
+ * database, a generator, a migration authored elsewhere) since names come from
295
+ * schema metadata, but "the names are trusted" is not the invariant the rest of
296
+ * this engine is written to. So: bare when the grammar allows it (byte-identical
297
+ * output for every ordinary and every keyword name), quoted when it does not,
298
+ * where the bare form was a parse error anyway. Verified against the engine that
299
+ * a quoted dotted reference parses everywhere the bare one does and yields the
300
+ * same result-column name.
301
+ */
302
+ export declare function quotePowqlDotted(name: string): string;
303
+ /**
304
+ * Coerce a single PowDB wire string into the JS value its column type implies.
305
+ * Every PowDB value arrives as a string; NULL arrives as the bareword `"null"`.
306
+ * Metadata resolves the `"null"` ambiguity for nullable non-string columns.
307
+ */
308
+ export declare function coerceValue(raw: string, col: ColumnMetadata): unknown;
309
+ /**
310
+ * Coerce a single cell that arrived over the NATIVE typed wire (decoded from a
311
+ * {@link PowdbWireValue}, so already a JS `bigint`/`number`/`boolean`/`string`/
312
+ * `NativeJson`/`Uint8Array`/`null`, never a bare `"null"` string). Unlike
313
+ * {@link coerceValue} this NEVER collapses the string `"null"` to `null`: an
314
+ * absent value already decoded to `null` (from the `empty` cell), so a genuine
315
+ * str `"null"` stays the string `"null"` (fixes the legacy-wire wart on the
316
+ * native transport). `datetime`-shaped cells (int micros) become `Date`; a
317
+ * bigint on a `number` column follows the int8 safe-integer policy.
318
+ *
319
+ * A date cell can also arrive as a DIGIT STRING: a nested-projection block's
320
+ * children ride a JSON array, and micros exceed `Number.MAX_SAFE_INTEGER`'s
321
+ * decimal comfort, so the engine renders them as a JSON string. Before that
322
+ * string was parsed here, a nested `with` handed back the raw micros text while
323
+ * the batched loader and the native join both handed back a `Date` (the same
324
+ * relation, three answers). Only an all-digit string is parsed; any other text
325
+ * on a date column passes through untouched.
326
+ */
327
+ export declare function coerceNativeValue(value: unknown, col: ColumnMetadata): unknown;
328
+ /**
329
+ * Map one raw PowDB row into a typed entity (camelCase fields, coerced values).
330
+ * Only the columns present in `raw` are emitted, so partial `select`
331
+ * projections round-trip unchanged. `native` selects the coercion policy: the
332
+ * default `false` handles the legacy string wire (every cell is a string, via
333
+ * {@link coerceValue}); `true` handles the native typed wire, where non-string
334
+ * cells arrive pre-typed and go through {@link coerceNativeValue} (see F3).
335
+ * Callers on the native transport pass `this.pool.capabilities.nativeRaw`.
336
+ */
337
+ export declare function rowToEntity(raw: Record<string, unknown>, meta: TableMetadata, native?: boolean): Record<string, unknown>;
338
+ /**
339
+ * True when `err` is the stale-wire-frame {@link ConnectionError} produced by
340
+ * {@link wrapPowdbError} (its `.cause` is a `protocol_error` PowDBError, or the
341
+ * message carries the invalid-state signature). The opt-in read retry
342
+ * (`retryStaleReads`, evaluated in {@link PowqlInterface}'s exec seam) uses this
343
+ * to decide whether a first-statement READ may be replayed once on a fresh
344
+ * connection; writes are NEVER retried (an ambiguous mutation reply is unsafe
345
+ * to replay, matching the client's own native-path policy).
346
+ */
347
+ export declare function isStaleFramePowdbError(err: unknown): boolean;
348
+ export {};