@vibeorm/runtime 2.0.0-alpha.8 → 2.0.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 (73) hide show
  1. package/README.md +2 -2
  2. package/dist/adapter.d.ts +102 -4
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/bulk-upsert.d.ts +282 -0
  5. package/dist/bulk-upsert.d.ts.map +1 -0
  6. package/dist/client.d.ts +49 -18
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/codecs.d.ts.map +1 -1
  9. package/dist/diagnostics/index.d.ts +12 -0
  10. package/dist/diagnostics/index.d.ts.map +1 -0
  11. package/dist/diagnostics/insight.d.ts +63 -0
  12. package/dist/diagnostics/insight.d.ts.map +1 -0
  13. package/dist/diagnostics/plan.d.ts +88 -0
  14. package/dist/diagnostics/plan.d.ts.map +1 -0
  15. package/dist/diagnostics/preview.d.ts +43 -0
  16. package/dist/diagnostics/preview.d.ts.map +1 -0
  17. package/dist/diagnostics/types.d.ts +223 -0
  18. package/dist/diagnostics/types.d.ts.map +1 -0
  19. package/dist/diagnostics/workload.d.ts +32 -0
  20. package/dist/diagnostics/workload.d.ts.map +1 -0
  21. package/dist/index.d.ts +24 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +10637 -5008
  24. package/dist/index.js.map +34 -15
  25. package/dist/keyset-iterator.d.ts +73 -0
  26. package/dist/keyset-iterator.d.ts.map +1 -0
  27. package/dist/keyset.d.ts +121 -0
  28. package/dist/keyset.d.ts.map +1 -0
  29. package/dist/model-meta.d.ts +18 -2
  30. package/dist/model-meta.d.ts.map +1 -1
  31. package/dist/nested-writes.d.ts +0 -33
  32. package/dist/nested-writes.d.ts.map +1 -1
  33. package/dist/policy-operation.d.ts +14 -0
  34. package/dist/policy-operation.d.ts.map +1 -0
  35. package/dist/policy.d.ts +5 -28
  36. package/dist/policy.d.ts.map +1 -1
  37. package/dist/query-builder.d.ts +22 -1
  38. package/dist/query-builder.d.ts.map +1 -1
  39. package/dist/relation-key.d.ts +23 -0
  40. package/dist/relation-key.d.ts.map +1 -0
  41. package/dist/relation-loader.d.ts +0 -29
  42. package/dist/relation-loader.d.ts.map +1 -1
  43. package/dist/relation-plan.d.ts +45 -7
  44. package/dist/relation-plan.d.ts.map +1 -1
  45. package/dist/render-cache.d.ts.map +1 -1
  46. package/dist/rls-context.d.ts +14 -0
  47. package/dist/rls-context.d.ts.map +1 -0
  48. package/dist/rls-readiness.d.ts +114 -0
  49. package/dist/rls-readiness.d.ts.map +1 -0
  50. package/dist/scoped.d.ts +104 -0
  51. package/dist/scoped.d.ts.map +1 -0
  52. package/dist/strict-args.d.ts +47 -0
  53. package/dist/strict-args.d.ts.map +1 -0
  54. package/dist/telemetry/collector.d.ts +53 -0
  55. package/dist/telemetry/collector.d.ts.map +1 -0
  56. package/dist/telemetry/config.d.ts +53 -0
  57. package/dist/telemetry/config.d.ts.map +1 -0
  58. package/dist/telemetry/fingerprint.d.ts +38 -0
  59. package/dist/telemetry/fingerprint.d.ts.map +1 -0
  60. package/dist/telemetry/index.d.ts +18 -0
  61. package/dist/telemetry/index.d.ts.map +1 -0
  62. package/dist/telemetry/recorder.d.ts +93 -0
  63. package/dist/telemetry/recorder.d.ts.map +1 -0
  64. package/dist/telemetry/statement.d.ts +53 -0
  65. package/dist/telemetry/statement.d.ts.map +1 -0
  66. package/dist/telemetry/types.d.ts +265 -0
  67. package/dist/telemetry/types.d.ts.map +1 -0
  68. package/dist/validators.d.ts +5 -3
  69. package/dist/validators.d.ts.map +1 -1
  70. package/dist/views.d.ts.map +1 -1
  71. package/dist/write-scope.d.ts +14 -0
  72. package/dist/write-scope.d.ts.map +1 -0
  73. package/package.json +5 -4
package/README.md CHANGED
@@ -5,10 +5,10 @@
5
5
  The query engine behind the generated client: it turns delegate calls into SQL statements, loads relations, runs nested writes and moves values across the wire through the codec table. It is its own package because it is driver-agnostic — it talks to databases only through the `DatabaseAdapter` contract, so adapters and the generator can depend on it without depending on each other.
6
6
 
7
7
  ```bash
8
- bun add @vibeorm/runtime@alpha
8
+ bun add @vibeorm/runtime
9
9
  ```
10
10
 
11
- > **Pre-release.** `2.0.0-alpha.x`, published under the `alpha` dist-tag. `npm i vibeorm` still resolves to the stable v1 line.
11
+ > **Stable.** `2.0.0`, published under the `latest` dist-tag. The v1 line stays installable as `vibeorm@1`.
12
12
 
13
13
  Most users never install this directly — it ships as a dependency of [`vibeorm`](https://www.npmjs.com/package/vibeorm) and of the generated client. Reach for it when you are writing an adapter or tooling against the runtime.
14
14
 
package/dist/adapter.d.ts CHANGED
@@ -14,6 +14,39 @@ import type { Dialect, Provider } from "@vibeorm/schema";
14
14
  import type { WireFidelity } from "@vibeorm/sql";
15
15
  /** Transaction isolation levels (mapped per dialect by the adapter). */
16
16
  export type IsolationLevel = "ReadCommitted" | "RepeatableRead" | "Serializable";
17
+ /**
18
+ * What a caller REQUIRES of a transaction deadline (EPIC 6).
19
+ *
20
+ * - `"between-statements"` (the default, deliverable by every adapter): an
21
+ * expired budget refuses the next statement, refuses the `COMMIT`, and rolls
22
+ * back. A statement already in flight is NOT interrupted.
23
+ * - `"cancel-running-statements"`: additionally hands the engine the remaining
24
+ * budget as `statement_timeout`, so the SERVER cancels an over-long
25
+ * statement. Postgres servers only (`adapter-pg`, `adapter-bun`); every other
26
+ * adapter refuses the request with `VIBE_UNSUPPORTED_CAPABILITY` rather than
27
+ * quietly delivering the weaker level.
28
+ */
29
+ export type TransactionDeadlineEnforcement = "between-statements" | "cancel-running-statements";
30
+ /**
31
+ * A TOTAL wall-clock budget for one top-level transaction (EPIC 6) — distinct
32
+ * from {@link TransactionOptions.timeout}, which bounds a single statement.
33
+ *
34
+ * The clock starts immediately before `BEGIN` is sent, so acquiring a
35
+ * connection (bounded separately by the pooled adapters' own acquire timeout)
36
+ * is NOT counted against it.
37
+ *
38
+ * On expiry the adapter refuses the next statement, refuses the commit and
39
+ * rolls back, and every handle of that transaction becomes unusable. Nothing
40
+ * is retried automatically: a callback's external side effects (an SMS, a
41
+ * payment, a queued job) may already have happened. JavaScript cannot forcibly
42
+ * stop a running callback — it can only refuse its later database calls.
43
+ */
44
+ export type TransactionDeadline = {
45
+ /** Whole milliseconds, greater than zero. */
46
+ readonly totalMs: number;
47
+ /** Defaults to `"between-statements"`. */
48
+ readonly enforcement?: TransactionDeadlineEnforcement;
49
+ };
17
50
  /**
18
51
  * Options for `$transaction` / `adapter.transaction`.
19
52
  *
@@ -23,16 +56,50 @@ export type IsolationLevel = "ReadCommitted" | "RepeatableRead" | "Serializable"
23
56
  * honesty: an adapter whose engine CANNOT enforce it refuses loudly instead
24
57
  * of no-opping — sqlite adapters throw `VIBE_VALIDATION` (busy_timeout only
25
58
  * bounds lock acquisition), pglite throws `VIBE_UNSUPPORTED_CAPABILITY` (the
26
- * WASM build accepts statement_timeout but never fires it).
59
+ * WASM build accepts statement_timeout but never fires it). Its meaning is
60
+ * UNCHANGED by the deadline work below: it is a PER-STATEMENT bound.
61
+ *
62
+ * `deadline` is the TOTAL budget for the whole transaction — see
63
+ * {@link TransactionDeadline}.
27
64
  *
28
65
  * Options are TOP-LEVEL only: a nested `transaction()` call (a savepoint)
29
- * refuses BOTH fields with `VIBE_VALIDATION` on every adapter — a savepoint
30
- * cannot change the isolation level of the transaction it joins, and a
31
- * nested timeout is not enforceable.
66
+ * refuses ALL THREE fields with `VIBE_VALIDATION` on every adapter — a
67
+ * savepoint cannot change the isolation level of the transaction it joins,
68
+ * a nested timeout is not enforceable, and a nested deadline would need an
69
+ * independent session setting on a connection it does not own. A nested
70
+ * savepoint instead INHERITS the top-level deadline, by reference.
32
71
  */
33
72
  export type TransactionOptions = {
34
73
  isolationLevel?: IsolationLevel;
35
74
  timeout?: number;
75
+ deadline?: TransactionDeadline;
76
+ };
77
+ /**
78
+ * How far an engine's per-statement timeout actually reaches.
79
+ *
80
+ * Tri-state rather than boolean because MySQL's `MAX_EXECUTION_TIME` bounds
81
+ * **SELECT statements only** — INSERT/UPDATE/DELETE run unbounded there, so
82
+ * declaring `true` would be exactly the silent misbehaviour constitution rule 4
83
+ * forbids.
84
+ */
85
+ export type StatementTimeoutSupport = "all-statements" | "select-only" | "unsupported";
86
+ /** The strongest transaction-deadline guarantee an adapter can honestly deliver. */
87
+ export type TransactionDeadlineSupport = "cancel-running-statements" | "between-statements" | "unsupported";
88
+ /**
89
+ * What timing budgets this adapter genuinely enforces (EPIC 6). Read it to
90
+ * decide what to ask for; the adapter refuses anything beyond it rather than
91
+ * degrading silently.
92
+ */
93
+ export type AdapterBudgetSupport = {
94
+ /**
95
+ * The wait for a pooled connection is bounded. False on the single-connection
96
+ * engines (pglite, both sqlite adapters), which have no pool to exhaust.
97
+ */
98
+ readonly acquireTimeout: boolean;
99
+ /** What `TransactionOptions.timeout` reaches on this engine. */
100
+ readonly statementTimeout: StatementTimeoutSupport;
101
+ /** What `TransactionOptions.deadline.enforcement` may ask for on this engine. */
102
+ readonly transactionDeadline: TransactionDeadlineSupport;
36
103
  };
37
104
  /** Result of an unsafe/raw execution: rows plus affected-row count. */
38
105
  export type QueryResult = {
@@ -88,6 +155,37 @@ export type DatabaseAdapter = {
88
155
  text: string;
89
156
  values?: unknown[];
90
157
  }): Promise<QueryResult>;
158
+ /**
159
+ * ORM-path execution (same protocol and parameter serialization as
160
+ * {@link DatabaseAdapter.execute}) that ALSO reports the affected-row count.
161
+ *
162
+ * WHY IT EXISTS (F01): bulk mutations need a row count, and `executeUnsafe`
163
+ * used to be the only entry point that surfaces one — but `executeUnsafe` is
164
+ * the RAW path, and a driver is free to implement it with client-side text
165
+ * escaping. mysql2 does (`pool.query`), and client-side escaping cannot know
166
+ * the server's `sql_mode`: under `NO_BACKSLASH_ESCAPES` a hostile string
167
+ * predicate breaks out of its literal. Generated statements must never take
168
+ * that route, so the runtime prefers this entry point and only falls back to
169
+ * `executeUnsafe` for an adapter that does not implement it.
170
+ *
171
+ * OPTIONAL, so the frozen contract stays additive: an adapter whose raw path
172
+ * already binds parameters (pg, pglite, bun, both sqlite adapters) is equally
173
+ * safe without it. An implementation MUST bind — never interpolate, and never
174
+ * fall back to text interpolation when preparation fails.
175
+ */
176
+ executeAffected?(params: {
177
+ text: string;
178
+ values: unknown[];
179
+ }): Promise<QueryResult>;
180
+ /**
181
+ * What timing budgets this adapter actually enforces (EPIC 6).
182
+ *
183
+ * OPTIONAL, so the frozen contract stays additive — exactly like
184
+ * {@link DatabaseAdapter.executeAffected}. An adapter that declares nothing
185
+ * is treated as declaring nothing: callers must not infer support from a
186
+ * provider name. Every adapter in this repository declares it.
187
+ */
188
+ readonly budgets?: AdapterBudgetSupport;
91
189
  /**
92
190
  * Run `fn` inside a transaction; the callback receives a transactional
93
191
  * adapter with this same interface. Nested calls create savepoints. Throwing
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAEjF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAIF,uEAAuE;AACvE,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,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AAO,CAAC,IAAI,CAAC,CAAC;IAE5B;;;;OAIG;IACH,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;CAC9C,CAAC;AAIF,gEAAgE;AAChE,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,eAAe,CAAA;CAAE,GAAG,WAAW,CAS/E"}
@@ -0,0 +1,282 @@
1
+ /**
2
+ * EPIC 10 — batched upsert for ingestion (`upsertMany`).
3
+ *
4
+ * The whole logical input is validated HERE, before the query builder assembles
5
+ * a single statement, so a malformed feed never reaches the database as a
6
+ * partial write. Everything in this module is a pure function over the runtime
7
+ * metadata and the already-compiled rows: the rows themselves are compiled by
8
+ * the query builder's existing `compileCreateRows`, so validators, string-enum
9
+ * membership checks, app-side defaults and `@updatedAt` stamping all come from
10
+ * the one write path (constitution rule 6 — no second coercion path).
11
+ *
12
+ * The two decisions this file exists to keep honest:
13
+ *
14
+ * 1. **Duplicate conflict keys are refused, not resolved — and "duplicate"
15
+ * means what the DATABASE means.** A batch is accepted only when its
16
+ * conflict keys are provably distinct under the database's own equality.
17
+ * Two routes get there, and {@link assertConflictKeysAreComparable} picks
18
+ * one per call:
19
+ *
20
+ * - **Route 1 — the ORM's own check, which spans parameter chunks.**
21
+ * {@link assertNoDuplicateConflictKeys} compares the encoded values of
22
+ * every row in the batch, in input order, before it is split into
23
+ * statements. That answer is the database's answer only where the
24
+ * column's equality IS byte equality, so route 1 is available only when
25
+ * {@link conflictKeyComparisonOf} says so for every target column: no
26
+ * folding collation, no folding scalar, and no `@db.*` native type
27
+ * outside the measured {@link BYTE_EXACT_NATIVE_TYPES}.
28
+ * - **Route 2 — the engine's own comparison, inside ONE statement.**
29
+ * Postgres refuses a doubled key with SQLSTATE 21000 under the real
30
+ * column, which catches every fold the ORM cannot see: a `char(n)` pad,
31
+ * a `uuid` case difference, `numeric` scale, `timestamp(0)` and `date`
32
+ * truncation, `real` narrowing, `citext`, a nondeterministic collation.
33
+ * It ends at the statement boundary. Rows in two statements are never
34
+ * compared, and the second statement silently updates what the first
35
+ * inserted.
36
+ *
37
+ * Neither route available means the batch is refused before a statement is
38
+ * built. Mysql's default `utf8mb4_0900_ai_ci` and a sqlite `COLLATE NOCASE`
39
+ * column both fold keys and both keep the LAST row without an error, so
40
+ * those calls now refuse instead of guessing.
41
+ *
42
+ * **The strength of that guarantee, stated exactly.** Route 2 is the
43
+ * database's own answer and carries no condition. Route 1 is only as true
44
+ * as the schema: it reads `@collation` and `@db.*` and never asks the live
45
+ * database what the column really is. Where the physical column disagrees
46
+ * with what the schema declares — a table or database default, an ALTER
47
+ * applied outside migrations, a restored dump, a column created before the
48
+ * annotation — route 1 can accept a batch the database then folds. Nothing
49
+ * in this module detects that, and nothing here claims to.
50
+ * 2. **The affected count is not the driver's number.** Mysql's ON DUPLICATE
51
+ * KEY convention counts an insert 1, a changed update 2 and an unchanged
52
+ * update 0 — measured 3 for a four-row batch on 8.4.11. That is not a row
53
+ * count and is never presented as one.
54
+ */
55
+ import type { SqlDialect } from "@vibeorm/sql";
56
+ import type { FieldMeta, ModelMeta } from "./model-meta.ts";
57
+ /** What `upsertMany` resolves to. */
58
+ export type UpsertManyResult = {
59
+ /**
60
+ * Rows the database was asked to insert-or-update: one per input row, after
61
+ * duplicate-conflict-key validation. Every one of them was either inserted or
62
+ * updated — the statement carries no DO NOTHING arm and the whole operation
63
+ * is atomic. NOT a count of rows whose values changed, and it does not
64
+ * distinguish inserts from updates.
65
+ */
66
+ readonly count: number;
67
+ /**
68
+ * The driver's raw affected-row number, and only where that number IS a row
69
+ * count ({@link affectedRowsAreRowCounts}). `null` on mysql.
70
+ */
71
+ readonly affectedRows: number | null;
72
+ };
73
+ /**
74
+ * Does this dialect's affected-row number mean "rows written"?
75
+ *
76
+ * Postgres/pglite/sqlite: yes — a four-row `ON CONFLICT DO UPDATE` batch of
77
+ * 2 unchanged + 1 changed + 1 insert reports 4. Mysql: no — the same batch
78
+ * reports 3, because ON DUPLICATE KEY scores an insert 1, a changed update 2
79
+ * and an unchanged update 0. Both measured, see notes-epic10.md.
80
+ */
81
+ export declare function affectedRowsAreRowCounts(params: {
82
+ dialect: SqlDialect;
83
+ }): boolean;
84
+ /** The arbiter an `upsertMany` call selected. */
85
+ export type UpsertConflictTarget = {
86
+ readonly kind: "columns";
87
+ readonly fields: readonly FieldMeta[];
88
+ } | {
89
+ readonly kind: "constraint";
90
+ readonly constraint: string;
91
+ };
92
+ /**
93
+ * Every distinct way this model can address one row, as a column-set signature.
94
+ * Used to check that a conflict target names a REAL unique group, and to decide
95
+ * whether mysql's untargetable ON DUPLICATE KEY could fire on something else.
96
+ */
97
+ export declare function uniqueGroupSignatures(params: {
98
+ model: ModelMeta;
99
+ }): ReadonlySet<string>;
100
+ /**
101
+ * `conflictTarget` → the arbiter. A field-name array must name a DECLARED
102
+ * unique group: a target the database has no unique index for cannot arbitrate
103
+ * anything, and postgres would refuse it at execution time anyway ("there is no
104
+ * unique or exclusion constraint matching the ON CONFLICT specification") —
105
+ * refusing at build time is the same answer, earlier and typed.
106
+ */
107
+ export declare function resolveUpsertConflictTarget(params: {
108
+ model: ModelMeta;
109
+ target: unknown;
110
+ }): UpsertConflictTarget;
111
+ /**
112
+ * Mysql's `ON DUPLICATE KEY UPDATE` fires on ANY unique index, so a selected
113
+ * conflict target is not enforceable there. With exactly one unique group there
114
+ * is nothing else it could fire on and the contract holds; with more, the call
115
+ * is refused unless the caller acknowledges the widening. This EPIC never
116
+ * claims mysql enforces the target.
117
+ */
118
+ export declare function assertConflictTargetIsEnforceable(params: {
119
+ dialect: SqlDialect;
120
+ model: ModelMeta;
121
+ allowAnyUniqueConflict: boolean;
122
+ }): void;
123
+ /**
124
+ * `update` → the fields the conflict arm overwrites from the incoming row.
125
+ *
126
+ * Refused: a conflict-target column (the arbiter is not a mutable field) and
127
+ * the `@@policy` tenant field (tenant identity is not a mutable field). The
128
+ * list is explicit by design — a "everything else" default would rewrite
129
+ * columns a caller never mentioned.
130
+ */
131
+ export declare function resolveUpsertUpdateFields(params: {
132
+ model: ModelMeta;
133
+ update: unknown;
134
+ targetColumns: ReadonlySet<string>;
135
+ skipUpdatedAt: boolean;
136
+ }): readonly FieldMeta[];
137
+ /**
138
+ * Every row must BIND every conflict-target column and every updated column.
139
+ *
140
+ * The target columns are the B1 rule batched: a row that does not bind the
141
+ * arbiter can never conflict on the row the caller meant. The update columns
142
+ * are the destructive case — `SET col = <incoming row>.col` on a row that
143
+ * omitted the column would write the column DEFAULT (or NULL) over a live
144
+ * value. Columns that are neither may still be omitted per row: they take the
145
+ * column default on insert and keep their stored value on conflict.
146
+ */
147
+ export declare function assertUpsertRowsBindColumns(params: {
148
+ model: ModelMeta;
149
+ compiled: readonly Readonly<Record<string, unknown>>[];
150
+ targetColumns: readonly string[];
151
+ updateFields: readonly FieldMeta[];
152
+ }): void;
153
+ /**
154
+ * Refuse a batch that proposes the same conflict key twice, BYTE-wise.
155
+ *
156
+ * Not a `firstWins`/`lastWins` resolution, because the engines disagree about
157
+ * what such a batch even means (postgres: SQLSTATE 21000; mysql and sqlite:
158
+ * silent last-wins). Byte equality is a SUBSET of every collation's equality —
159
+ * no collation can call two identical byte strings different — so this check
160
+ * never refuses a batch the database would have accepted, and it covers the
161
+ * whole batch, parameter chunks included. Where it is not the WHOLE answer,
162
+ * {@link assertConflictKeysAreComparable} refuses rather than guessing.
163
+ */
164
+ export declare function assertNoDuplicateConflictKeys(params: {
165
+ model: ModelMeta;
166
+ compiled: readonly Readonly<Record<string, unknown>>[];
167
+ targetColumns: readonly string[];
168
+ }): void;
169
+ /**
170
+ * Refuse a batch that doubles a unique group the arbiter does NOT name, on a
171
+ * dialect whose upsert has no arbiter at all.
172
+ *
173
+ * `ON DUPLICATE KEY UPDATE` resolves through whichever unique index the
174
+ * incoming row happens to match, so two rows carrying one `email` — distinct
175
+ * `id`s, an untouched conflict target — are not two rows: the second UPDATES
176
+ * the first and one of them silently disappears, with `ROW_COUNT()` reporting
177
+ * a number that hides it. Postgres and sqlite arbitrate on the named target
178
+ * only, so the second row violates the other index and the whole batch fails
179
+ * loudly; nothing is refused for them here.
180
+ *
181
+ * `allowAnyUniqueConflict` does NOT authorise this. That flag acknowledges
182
+ * that a SINGLE incoming row may be resolved through an index other than the
183
+ * one named — a widening of which stored row is replaced. It was never an
184
+ * acceptance of two submitted rows collapsing into one, which is a row the
185
+ * caller sent and the database does not have.
186
+ *
187
+ * Comparison is byte equality, deliberately: byte-identical values are equal
188
+ * under every collation and every native type, so this can only refuse a batch
189
+ * the database would itself have folded. Values a collation might fold while
190
+ * their bytes differ are the opaque case, and
191
+ * {@link assertConflictKeysAreComparable} already governs it.
192
+ *
193
+ * Rows that leave any of the group's columns unbound or NULL are skipped: an
194
+ * unbound column takes a default this layer cannot know, and mysql's unique
195
+ * indexes never collide on NULL.
196
+ */
197
+ export declare function assertNoDuplicateSecondaryUniques(params: {
198
+ dialect: SqlDialect;
199
+ model: ModelMeta;
200
+ compiled: readonly Readonly<Record<string, unknown>>[];
201
+ targetColumns: readonly string[];
202
+ }): void;
203
+ /** How a single conflict-target column's equality can be established. */
204
+ export type ConflictKeyComparison =
205
+ /** The encoded JavaScript values compare exactly as the column does. */
206
+ "byte"
207
+ /** Only the database knows: a collation, a scale or a precision decides. */
208
+ | "database";
209
+ /**
210
+ * Which comparison decides whether two rows address the same stored row
211
+ * through this column.
212
+ *
213
+ * A declared `@db.*` native type is read FIRST and outranks everything the
214
+ * scalar implies, because the physical column pads, rounds, narrows or
215
+ * case-folds before a collation is ever consulted — and no annotation
216
+ * elsewhere can undo that. Only the measured types in
217
+ * {@link BYTE_EXACT_NATIVE_TYPES} pass; anything else is opaque, including a
218
+ * type this project has never run.
219
+ *
220
+ * Text (and enum members, which live in a text column on sqlite and mysql)
221
+ * then follows the column's collation: a declared `@collation` is believed on
222
+ * every dialect, because it is the schema's own statement about the column,
223
+ * and an undeclared one falls back to the dialect's default. Other scalars
224
+ * follow the dialect's folding list — `Decimal` is there on postgres and mysql
225
+ * because `numeric`/`DECIMAL` equality ignores trailing zeros while the
226
+ * encoded value is the string the caller wrote.
227
+ *
228
+ * Everything here reads the SCHEMA. It is a claim about what the column was
229
+ * declared to be, never a reading of what it is.
230
+ */
231
+ export declare function conflictKeyComparisonOf(params: {
232
+ dialect: SqlDialect;
233
+ field: FieldMeta;
234
+ }): ConflictKeyComparison;
235
+ /**
236
+ * Refuse a batch whose conflict keys neither side can compare.
237
+ *
238
+ * Runs after {@link assertNoDuplicateConflictKeys} and before any statement is
239
+ * executed. Two things make a batch safe, and one of them has to hold:
240
+ *
241
+ * 1. **Every target column compares BYTES.** Then the whole-batch JavaScript
242
+ * check already saw every pair, across parameter chunks, and is the same
243
+ * answer the database would give.
244
+ * 2. **The engine compares the pairs itself, in ONE statement.** Postgres does
245
+ * (SQLSTATE 21000) and it does so under the real collation, scale and
246
+ * precision — including the ones the ORM cannot see, such as a `@db.Char`
247
+ * pad or a `uuid` column's case folding. A SECOND statement breaks it: rows
248
+ * in different statements are never compared, and the second one quietly
249
+ * updates what the first inserted.
250
+ *
251
+ * A named-constraint arbiter hides its column list, so route 1 is unavailable
252
+ * by construction and route 2 is the only one left.
253
+ *
254
+ * **What route 1 does NOT establish.** It reads the SCHEMA. `@collation` and
255
+ * `@db.*` are what the schema intends the column to be, and nothing here reads
256
+ * the live database to confirm either. A table or database default, an ALTER
257
+ * applied outside migrations, a restored dump, or a column created before the
258
+ * annotation was added all leave the physical column carrying something else.
259
+ * On mysql that gap is the normal case rather than the exception for a
260
+ * collation: the differ compares a column's type, nullability and default,
261
+ * never its collation, so adding `@collation` to an existing column generates
262
+ * no migration step at all. Where the schema and the column disagree, route
263
+ * 1's guarantee is the schema's, not the database's.
264
+ *
265
+ * **What route 1 now also refuses.** A conflict-target column carrying a
266
+ * `@db.*` native type is opaque unless that exact type was measured to leave
267
+ * equality alone ({@link BYTE_EXACT_NATIVE_TYPES}). This closes the case where
268
+ * a `@db.Char(10)` or `@db.Uuid` key classified as byte-comparable, took route
269
+ * 1, and let a chunked batch through: measured on postgres, `'pad'` and
270
+ * `'pad '` submitted as two statements against a `char(10)` key stored ONE row
271
+ * and kept the last, with no error, while the same pair inside one statement
272
+ * raised 21000.
273
+ */
274
+ export declare function assertConflictKeysAreComparable(params: {
275
+ dialect: SqlDialect;
276
+ model: ModelMeta;
277
+ target: UpsertConflictTarget;
278
+ /** Statements this batch will run; more than one means uncompared pairs. */
279
+ statementCount: number;
280
+ compiled: readonly Readonly<Record<string, unknown>>[];
281
+ }): void;
282
+ //# sourceMappingURL=bulk-upsert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulk-upsert.d.ts","sourceRoot":"","sources":["../src/bulk-upsert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAa5D,qCAAqC;AACrC,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,UAAU,CAAA;CAAE,GAAG,OAAO,CAEjF;AAID,iDAAiD;AACjD,MAAM,MAAM,oBAAoB,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- * Schema IR at runtime.
4
- *
5
- * This is the engine the generated client wraps in P2 proper. It is deliberately
6
- * untyped-per-model — the generator emits a `.d.ts` that declares each delegate
7
- * with precise argument and result types, and casts to it. Nothing about the
8
- * shape of a query lives here: `query-builder.ts` builds statements,
9
- * `@vibeorm/sql` renders them, `codecs.ts` moves values across the wire,
10
- * `relation-loader.ts` attaches included relations, `nested-writes.ts`
11
- * orchestrates relation verbs inside create/update data.
12
- *
13
- * Execution split:
14
- * - row-returning statements use `adapter.execute` (the cached hot path),
15
- * - count-returning mutations (createMany/updateMany/deleteMany) use
16
- * `adapter.executeUnsafe`, the only place the frozen adapter contract
17
- * surfaces `affectedRows`.
18
- */
19
1
  import type { SchemaIR } from "@vibeorm/schema";
20
2
  import type { DatabaseAdapter, TransactionOptions } from "./adapter.ts";
21
3
  import type { RelationStrategy } from "./query-builder.ts";
@@ -24,6 +6,9 @@ import type { ClientExtensionsOptions } from "./extensions.ts";
24
6
  import type { DefineViewFn } from "./views.ts";
25
7
  import type { WriteValidators } from "./validators.ts";
26
8
  import type { PolicyContextValue } from "./policy.ts";
9
+ import type { ScopedClientConfig } from "./scoped.ts";
10
+ import type { UpsertManyResult } from "./bulk-upsert.ts";
11
+ import type { TelemetryOptions } from "./telemetry/types.ts";
27
12
  /** One executed statement, reported to `ClientOptions.onQuery`. */
28
13
  export type QueryEvent = {
29
14
  /** Model name, or `null` for raw queries. */
@@ -35,6 +20,14 @@ export type QueryEvent = {
35
20
  readonly durationMs: number;
36
21
  };
37
22
  export type ClientOptions = {
23
+ /** Trusted infrastructure configuration. PGlite requires a pre-existing restricted role;
24
+ * embedded role binding is not a security boundary against the host process.
25
+ * Desired policy deparse is probed once per backend generation (bounded cache);
26
+ * live expressions/privileges are still checked every transaction. Privileged
27
+ * dependency changes retaining identical deparse need a fresh client/doctor check. */
28
+ readonly nativeRls?: {
29
+ readonly runtimeRole?: string;
30
+ };
38
31
  /** Called after every statement — logging, tracing, test assertions. */
39
32
  readonly onQuery?: (event: QueryEvent) => void;
40
33
  /**
@@ -61,6 +54,26 @@ export type ClientOptions = {
61
54
  * the validator's issues in `meta`. Reads are never taxed.
62
55
  */
63
56
  readonly validate?: WriteValidators;
57
+ /**
58
+ * Opt-in operation tracing. One event per public ORM call, with the
59
+ * statements it ran; parameter values are redacted and raw SQL text is not
60
+ * captured unless separately asked for. The exporter is the host's — a throw
61
+ * from it can never change a database outcome, and `$disconnect()` flushes it
62
+ * but never shuts it down.
63
+ */
64
+ readonly telemetry?: TelemetryOptions;
65
+ /**
66
+ * Strict argument handling (EPIC 2), **on by default**: an explicit
67
+ * `undefined` anywhere in ORM argument syntax is refused BEFORE a statement
68
+ * is built, instead of silently dropping the property (which widens a filter
69
+ * or loses a write). `SKIP` (`@vibeorm/runtime`) omits a property
70
+ * deliberately.
71
+ *
72
+ * Set `false` to opt OUT and restore legacy/Prisma semantics, where an
73
+ * explicit `undefined` member simply vanishes. Only an explicit `false` does
74
+ * that: an options object that does not mention this stays strict.
75
+ */
76
+ readonly strictArguments?: boolean;
64
77
  };
65
78
  /** Rows are plain objects keyed by field name; the generated client narrows them. */
66
79
  export type ClientRow = Record<string, unknown>;
@@ -85,6 +98,16 @@ export type ModelDelegate = {
85
98
  readonly createManyAndReturn: (args: ClientRow) => Promise<ClientRow[]>;
86
99
  readonly update: (args: ClientRow) => Promise<ClientRow>;
87
100
  readonly updateMany: (args: ClientRow) => Promise<BatchResult>;
101
+ /**
102
+ * Bulk update that returns the rows it changed (dialects with RETURNING).
103
+ *
104
+ * OPTIONAL on purpose: the base client always provides it, but the rewriting
105
+ * handles (`$scoped`, `$withPolicy`) build explicit delegate literals and do
106
+ * not implement it yet, and a required member would make the type claim a
107
+ * method those handles do not have. See notes-epic2.md `## Hand-off`.
108
+ */
109
+ readonly updateManyAndReturn: (args: ClientRow) => Promise<ClientRow[]>;
110
+ readonly upsertMany: (args: ClientRow) => Promise<UpsertManyResult>;
88
111
  readonly upsert: (args: ClientRow) => Promise<ClientRow>;
89
112
  readonly delete: (args: ClientRow) => Promise<ClientRow>;
90
113
  readonly deleteMany: (args?: ClientRow) => Promise<BatchResult>;
@@ -101,6 +124,8 @@ export type ModelDelegate = {
101
124
  * `$`-prefixed (see `RESERVED_CLIENT_NAMES` in @vibeorm/schema).
102
125
  */
103
126
  export type DynamicClient = {
127
+ /** Copy and freeze the required native-RLS identity without acquiring a connection. */
128
+ readonly $withContext?: (context: Readonly<Record<string, unknown>>) => DynamicClient;
104
129
  /** Delegates keyed by BOTH camelCase client name and model name. */
105
130
  readonly $models: Readonly<Record<string, ModelDelegate>>;
106
131
  /**
@@ -145,6 +170,12 @@ export type DynamicClient = {
145
170
  readonly $withPolicy?: (context: Readonly<Record<string, PolicyContextValue>>) => DynamicClient;
146
171
  /** Deliberate, greppable full-access escape from policy scoping. */
147
172
  readonly $bypassPolicy?: () => DynamicClient;
173
+ /**
174
+ * Tenant scoping (framework handoff): base client + total per-model tenancy
175
+ * map + scope value → a NEW handle whose every call is confined to that
176
+ * tenant (raw SQL refused). Always attached; refuses on @@policy schemas.
177
+ */
178
+ readonly $scoped?: (config: ScopedClientConfig) => DynamicClient;
148
179
  };
149
180
  /**
150
181
  * Build a client for a schema over an adapter.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAW,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGzD,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAMxE,OAAO,KAAK,EAAyC,gBAAgB,EAAa,MAAM,oBAAoB,CAAC;AAO7G,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAM3D,OAAO,KAAK,EAEV,uBAAuB,EAGxB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,K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AAC,MAAM,EAAE;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACzC,6FAA6F;IAC7F,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAI5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,6FAA6F;IAC7F,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAkB5B;AA2CD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;CACjC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAkB5B;AAID;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAClD,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAgBV"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `@vibeorm/runtime` diagnostics (EPIC 5): SQL preview, PostgreSQL plan
3
+ * inspection, read-only workload statistics and deterministic evidence reading.
4
+ *
5
+ * Module barrel — the package's root barrel re-exports from here.
6
+ */
7
+ export { parameterTypeTag, previewOperation } from "./preview.ts";
8
+ export { PLAN_DEFAULTS, explainOperation, explainSql, parsePostgresPlan } from "./plan.ts";
9
+ export { readWorkloadStatistics } from "./workload.ts";
10
+ export { DIAGNOSTIC_THRESHOLDS, analyzeOperationTelemetry, recommendFromPlan } from "./insight.ts";
11
+ export type { DiagnosticFinding, DiagnosticFindingCode, ExplainMode, IndexCandidate, IndexFacts, OperationPreview, ParsedPlan, PlanContext, PlanNode, PreviewLimitation, PreviewLimitationCode, PreviewStatement, QueryPlanReport, SlowOperation, SuspectedPattern, TableFacts, TelemetryDiagnosticReport, WorkloadAvailability, WorkloadReport, WorkloadStatement, } from "./types.ts";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnG,YAAY,EACV,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,EACX,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,yBAAyB,EACzB,oBAAoB,EACpB,cAAc,EACd,iBAAiB,GAClB,MAAM,YAAY,CAAC"}