@vibeorm/adapter-bun 2.2.1 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +4 -4
- package/package.json +4 -4
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhE;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhE;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAyC3E,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMhE,CAAC;AAYH;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,GAAG,SAAS,CAS/E;AAID;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CA8BvE;AAED,wEAAwE;AACxE,wBAAsB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMnE"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAEV,eAAe,EAIhB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAEV,eAAe,EAIhB,MAAM,kBAAkB,CAAC;AAkB1B,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAyEnG,sCAAsC;AACtC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,oGAAoG;IACpG,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC;;;;;;OAMG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IACtC,2EAA2E;IAC3E,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,uFAAuF;IACvF,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;CACxC,CAAC;AA8CF;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAohBvE;AAgCD,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzF,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1E,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,6BAA6B,EAC7B,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var SESSION_CONNECTION = Object.freeze({
|
|
|
14
14
|
// packages/adapter-bun/src/index.ts
|
|
15
15
|
import { postgresDialect, renderDiagnostic } from "@vibeorm/sql";
|
|
16
16
|
import {
|
|
17
|
+
abortTransactionOnServerFailure,
|
|
17
18
|
runPinnedSession,
|
|
18
19
|
createSavepointScope,
|
|
19
20
|
savepointRollbackFailedError,
|
|
@@ -68,6 +69,10 @@ var BUN_SQLSTATE_ERROR_CODES = Object.freeze({
|
|
|
68
69
|
"23502": "VIBE_VALIDATION",
|
|
69
70
|
"23514": "VIBE_VALIDATION",
|
|
70
71
|
"22P02": "VIBE_VALIDATION",
|
|
72
|
+
"22001": "VIBE_VALIDATION",
|
|
73
|
+
"22003": "VIBE_VALIDATION",
|
|
74
|
+
"22007": "VIBE_VALIDATION",
|
|
75
|
+
"22008": "VIBE_VALIDATION",
|
|
71
76
|
"42501": "VIBE_PERMISSION_DENIED",
|
|
72
77
|
"40001": "VIBE_TRANSACTION",
|
|
73
78
|
"40P01": "VIBE_TRANSACTION",
|
|
@@ -644,7 +649,8 @@ function bunAdapter(options) {
|
|
|
644
649
|
if (turn !== undefined)
|
|
645
650
|
await turn;
|
|
646
651
|
assertHandle();
|
|
647
|
-
|
|
652
|
+
const result = runExecute({ source: guardedSource, ...execParams });
|
|
653
|
+
return parentMode === "pool" ? result : result.catch((error) => abortTransactionOnServerFailure({ scope, error }));
|
|
648
654
|
},
|
|
649
655
|
async executeUnsafe(execParams) {
|
|
650
656
|
assertHandle();
|
|
@@ -652,7 +658,8 @@ function bunAdapter(options) {
|
|
|
652
658
|
if (turn !== undefined)
|
|
653
659
|
await turn;
|
|
654
660
|
assertHandle();
|
|
655
|
-
|
|
661
|
+
const result = runExecuteUnsafe({ source: guardedSource, ...execParams });
|
|
662
|
+
return parentMode === "pool" ? result : result.catch((error) => abortTransactionOnServerFailure({ scope, error }));
|
|
656
663
|
},
|
|
657
664
|
async transaction(fn, transactionOptions) {
|
|
658
665
|
return parentMode === "pool" ? transactionViaPool(fn, transactionOptions) : transactionViaSavepoint(fn, transactionOptions);
|
|
@@ -810,4 +817,4 @@ export {
|
|
|
810
817
|
validateTransactionDeadline2 as validateTransactionDeadline
|
|
811
818
|
};
|
|
812
819
|
|
|
813
|
-
//# debugId=
|
|
820
|
+
//# debugId=014C6E379183B00C64756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import { SQL } from \"bun\";\n\n/** Internal constructor boundary; keeps the driver double out of the public adapter API. */\nexport function createBunSql(params: { url?: string; options: Record<string, unknown> }): SQL {\n return params.url === undefined ? new SQL(params.options) : new SQL(params.url, params.options);\n}\n",
|
|
6
6
|
"/** Migration-only driver instance; never force-close the application's pool. */\nexport const SESSION_CONNECTION: Readonly<{ max: number; closeGraceSeconds: number }> = Object.freeze({\n max: 1,\n // Bun 1.3 treats timeout: 0 as unbounded. A positive millisecond closes only\n // this private instance after the session gate has drained dispatched work.\n closeGraceSeconds: 0.001,\n});\n",
|
|
7
|
-
"/**\n * @vibeorm/adapter-bun — bun:sql (PostgreSQL) adapter for VibeORM v2.\n *\n * Uses Bun's built-in SQL driver and its internal connection pool. Owns\n * optional prepared statements (synthetic tagged templates), transactions\n * (nested → savepoints), array-literal parameter formatting and driver-error\n * mapping. Only `VibeError` ever escapes.\n */\n\nimport { createBunSql } from \"./driver.ts\";\nimport { SESSION_CONNECTION } from \"./config.ts\";\nimport { postgresDialect, renderDiagnostic } from \"@vibeorm/sql\";\nimport type {\n AdapterBudgetSupport,\n DatabaseAdapter,\n QueryResult,\n TransactionOptions,\n WireFidelity,\n} from \"@vibeorm/runtime\";\nimport {\n runPinnedSession,\n createSavepointScope,\n savepointRollbackFailedError,\n engineStatementBudgetMs,\n isTransactionDeadlineError,\n runNestedSavepoint,\n runRootScope,\n type SavepointScope,\n scopeTurn,\n startTransactionBudget,\n type TransactionBudget,\n transactionOutcomeUnknownError,\n validateTransactionDeadline,\n} from \"@vibeorm/runtime/adapter-kit\";\nimport { VibeError, type Dialect, type Provider } from \"@vibeorm/schema\";\nimport { applyStartupOptions, buildStartupOptions, type PlanCacheMode } from \"./connection-url.ts\";\nimport { mapBunDriverError, runMapped } from \"./errors.ts\";\nimport { serializeParams, serializeParamsRaw, toPgArrayLiteral } from \"./params.ts\";\nimport { bindTemplateValues, createTemplateCache } from \"./template-cache.ts\";\nimport {\n beginStatement,\n classifyRawTransactionControl,\n refuseNestedTransactionOptions,\n statementTimeoutStatement,\n} from \"./transaction-sql.ts\";\n\n// ─── Minimal bun:sql surface ──────────────────────────────────────\n\n/**\n * What bun:sql resolves a query to: the row array, with driver metadata\n * (`count`, `command`) attached as properties.\n */\ntype BunRows = Record<string, unknown>[] & { count?: number; affectedRows?: number };\n\ntype BunResults = BunRows | BunRows[] | null;\n\n/** Anything that executes SQL through bun:sql. */\ntype BunExecutor = {\n (strings: TemplateStringsArray, ...values: unknown[]): Promise<BunResults>;\n unsafe(text: string, values?: unknown[]): Promise<BunResults>;\n};\n\n/**\n * The handle passed to `sql.begin(cb)`. Modern bun:sql exposes `savepoint(fn)`\n * for sub-transactions; `begin()` throws inside a transaction (\"use\n * savepoint() instead\"), so it is never called here. Older builds lack\n * `savepoint`, which is why it is optional and probed at runtime.\n */\ntype BunTransaction = BunExecutor & {\n savepoint?: <T>(fn: (sp: BunTransaction) => Promise<T>) => Promise<T>;\n};\n\n/** A connection checked out with `sql.reserve()` — no `savepoint`, must be released. */\ntype BunReserved = BunExecutor & { release(): void; close(): Promise<void> };\n\n/** The pool-level bun:sql client. */\ntype BunInstance = BunExecutor & {\n begin<T>(fn: (tx: BunTransaction) => Promise<T>): Promise<T>;\n reserve(): Promise<BunReserved>;\n close(options?: { timeout: number }): Promise<void>;\n};\n\n/** Any bun:sql handle the adapter can be built on top of. */\ntype BunSource = BunInstance | BunReserved | BunTransaction;\n\n/**\n * Whether a handle is the pool (can open a real transaction) or is already\n * inside one (must nest through savepoints).\n */\ntype ParentMode = \"pool\" | \"tx\";\n\n/**\n * Wrapper that marks an error as \"thrown by the user's transaction callback\",\n * so it can be rethrown untouched instead of being mapped as a driver failure\n * after bun:sql has passed it back out of `begin()` / `savepoint()`.\n */\nclass CallbackError extends Error {\n readonly inner: unknown;\n\n constructor(inner: unknown) {\n super(\"vibeorm: transaction callback failed\");\n this.name = \"CallbackError\";\n this.inner = inner;\n }\n}\n\n// ─── Options ──────────────────────────────────────────────────────\n\n/** Options for {@link bunAdapter}. */\nexport type BunAdapterOptions = {\n /** PostgreSQL connection URL. Defaults to `process.env.DATABASE_URL`, then bun's `PG*` env vars. */\n readonly url?: string;\n /** Maximum pooled connections (default 10). */\n readonly max?: number;\n /**\n * Pool-wide `statement_timeout` in milliseconds, sent as a startup parameter\n * so every connection inherits it. A per-transaction `timeout` overrides it\n * for that transaction.\n */\n readonly statementTimeout?: number;\n /**\n * Milliseconds to wait for a connection to be established. Passed to bun:sql\n * as `connectionTimeout` (which expects **seconds**; converted here).\n */\n readonly connectionTimeout?: number;\n /**\n * Execute ORM-path queries as tagged templates, creating named prepared\n * statements (default false). Saves planning time but lets PostgreSQL fall\n * back to a generic plan after ~5 executions — leave off unless profiling\n * says otherwise. bun:sql's `prepare: false` constructor option is never set\n * (it triggers a known bun:sql performance regression).\n */\n readonly preparedStatements?: boolean;\n /** Maximum entries in the synthetic template cache (default 1000, LRU). */\n readonly stmtCacheMax?: number;\n /** PostgreSQL `plan_cache_mode` for every connection (default `force_custom_plan`). */\n readonly planCacheMode?: PlanCacheMode;\n};\n\n// ─── Adapter ──────────────────────────────────────────────────────\n\nconst DIALECT: Dialect = \"postgres\";\nconst PROVIDER: Provider = \"postgresql\";\n\n/**\n * bun:sql wire (board #30, live-verified on both execute paths): timestamptz\n * → `Date`, int4/float8 → numbers. (int8 arrives as a string — BigInt\n * decoding is real work and never pruned.)\n *\n * The `json` half is NOT a constant, because bun:sql's answer changed between\n * Bun versions and this package supports a range of them: on Bun 1.3.14 the\n * tagged-template path parsed json/jsonb while `sql.unsafe` did not (board\n * #34 — declaring \"parsed\" there made the runtime prune the Json decoder and\n * leak raw strings), and on Bun 1.4.1 BOTH paths parse (leaving \"text\" makes\n * the guarded decode re-parse a stored top-level JSON string: `\"123\"` becomes\n * the number 123, `\"hello\"` throws). Either constant is wrong on one of those\n * runtimes, so the adapter OBSERVES its own driver once instead of guessing —\n * see {@link probeJsonWire}. {@link WIRE_TEXT} is the conservative claim it\n * starts from; no ORM rows are returned until the probe succeeds.\n */\n/**\n * Timing budgets this adapter genuinely enforces (EPIC 6).\n *\n * - `acquireTimeout: false` — `connectionTimeout` bounds establishment only.\n * Modern Bun supports reserve({ signal }), but implicit query/begin checkout\n * and older supported Bun versions do not provide that cancellation contract.\n * - `statementTimeout: \"all-statements\"` — a real PostgreSQL server, so\n * `statement_timeout` cancels ANY over-long statement, writes included.\n * - `transactionDeadline: \"cancel-running-statements\"` — the remaining budget\n * is handed to the SERVER before each statement, so the database itself stops\n * work that would outlive the deadline.\n */\nconst BUDGETS: AdapterBudgetSupport = Object.freeze({\n acquireTimeout: false,\n statementTimeout: \"all-statements\",\n transactionDeadline: \"cancel-running-statements\",\n} as const);\n\nconst WIRE_TEXT: WireFidelity = Object.freeze({ dateTime: \"native\", json: \"text\", numbers: \"native\" } as const);\n\n/** The same wire, for a driver observed to hand back parsed json. */\nconst WIRE_PARSED: WireFidelity = Object.freeze({ dateTime: \"native\", json: \"parsed\", numbers: \"native\" } as const);\n\n/**\n * Create a VibeORM adapter backed by bun:sql.\n *\n * @example\n * ```ts\n * const adapter = bunAdapter({ url: process.env.DATABASE_URL, max: 10 });\n * await adapter.connect();\n * const rows = await adapter.execute({ text: 'SELECT * FROM \"User\" WHERE \"id\" = $1', values: [1] });\n * ```\n */\nexport function bunAdapter(options?: BunAdapterOptions): DatabaseAdapter {\n const usePrepared = options?.preparedStatements ?? false;\n const templates = createTemplateCache({ max: options?.stmtCacheMax ?? 1000 });\n\n /**\n * The wire claim this adapter currently makes. Starts conservative and is\n * replaced at most once, by {@link probeJsonWire}'s observation. Every handle\n * this factory builds — pool, transaction, savepoint, reserved session —\n * reads this one variable, so a transaction can never disagree with its\n * parent (the contract requires transactional adapters to carry the same\n * declaration).\n */\n let activeWire: WireFidelity = WIRE_TEXT;\n let wireSettled = false;\n let wireProbe: Promise<void> | null = null;\n\n let instance: BunInstance | null = null;\n const deadlineTurns = new WeakMap<TransactionBudget, Promise<void>>();\n\n // Only deadline-bearing connections need a queue. Share it across every\n // nested facade, not one queue per handle. Probe, statement and COMMIT each\n // receive a fresh bound after preceding work finishes.\n function budgetTurn<T>(params: {\n source: BunExecutor;\n budget?: TransactionBudget;\n stage?: \"statement\" | \"commit\";\n cleanup?: boolean;\n guard?: () => void;\n body: () => Promise<T>;\n }): Promise<T> {\n const { source, budget, body, guard } = params;\n const run = async (): Promise<T> => {\n if (params.cleanup === true) return body();\n budget?.assertUsable({ stage: params.stage ?? \"statement\" });\n guard?.();\n const ms = budget === undefined ? null : engineStatementBudgetMs({ budget });\n if (ms !== null) {\n await runMapped(() => source.unsafe(statementTimeoutStatement({ timeout: ms })));\n budget?.assertUsable({ stage: params.stage ?? \"statement\" });\n guard?.();\n }\n return body();\n };\n if (budget === undefined || budget.totalMs === null) return run();\n const result = (deadlineTurns.get(budget) ?? Promise.resolve()).then(run);\n deadlineTurns.set(budget, result.then(() => undefined, () => undefined));\n return result;\n }\n\n /**\n * The reserved connection of an OPEN raw transaction — session affinity for\n * the raw path. @vibeorm/migrate wraps transactional DDL in literal `BEGIN`\n * / `COMMIT` / `ROLLBACK` sent through `executeUnsafe`; bun:sql refuses\n * transaction control through `sql.unsafe()` on a pooled instance\n * (`ERR_POSTGRES_UNSAFE_TRANSACTION`), so a pure `BEGIN` reserves one\n * connection, every raw statement until the matching `COMMIT`/`ROLLBACK`\n * rides it, and the close releases it. The ORM path (`execute`) and\n * `transaction()` stay on the pool — they never participate in a raw\n * transaction. Concurrent raw transactions on one adapter are unsupported\n * (they were driver-refused before this pinning existed).\n */\n let rawSession: BunReserved | null = null;\n\n function createSqlInstance(params: { max: number }): BunInstance {\n const sqlOptions: Record<string, unknown> = { max: params.max };\n if (options?.connectionTimeout !== undefined) {\n // bun:sql expects seconds; the VibeORM surface is milliseconds everywhere.\n sqlOptions.connectionTimeout = Math.max(1, Math.ceil(options.connectionTimeout / 1000));\n }\n\n const startupOptions = buildStartupOptions({\n planCacheMode: options?.planCacheMode ?? \"force_custom_plan\",\n statementTimeout: options?.statementTimeout,\n });\n const baseUrl = options?.url ?? process.env.DATABASE_URL;\n const url =\n baseUrl === undefined || startupOptions === undefined\n ? baseUrl\n : applyStartupOptions({ url: baseUrl, startupOptions });\n\n // Bun's constructor connection object also supports PG*-only configuration.\n if (url === undefined && startupOptions !== undefined) {\n sqlOptions.connection = { options: startupOptions };\n }\n return createBunSql({ url, options: sqlOptions }) as unknown as BunInstance;\n }\n\n function getSql(): BunInstance {\n instance ??= createSqlInstance({ max: options?.max ?? 10 });\n return instance;\n }\n\n /**\n * Ask THIS driver, once, whether it parses json on the path the ORM reads\n * rows over — the same `execute` path, prepared or unsafe as configured, so\n * the answer describes the traffic the claim is applied to.\n *\n * Runs on the handle that is already in hand (pool, transaction or reserved\n * session): a `SELECT` is harmless inside a transaction, and probing the pool\n * from inside one could deadlock an adapter configured with `max: 1`.\n * Failure refuses this operation. A later call can observe the wire again;\n * no user statement or transaction is retried.\n */\n async function probeJsonWire(source: BunExecutor): Promise<void> {\n const probe = renderDiagnostic({ dialect: postgresDialect, query: \"postgresJsonWire\" });\n const rows = finalRows({ result: await runMapped(() => usePrepared\n ? source(templates.getTemplate({ text: probe.text }).template)\n : source.unsafe(probe.text, [])) });\n const probed = rows[0]?.probe;\n if (typeof probed === \"object\" && probed !== null && \"__vibeorm\" in probed && probed.__vibeorm === 1) activeWire = WIRE_PARSED;\n else if (typeof probed === \"string\" && /^\\{\\s*\"__vibeorm\"\\s*:\\s*1\\s*\\}$/.test(probed)) activeWire = WIRE_TEXT;\n else {\n throw new VibeError({\n code: \"VIBE_ADAPTER\",\n message: \"Bun returned an unrecognized JSON wire probe result; no ORM statement was sent\",\n meta: { reason: \"json-wire-probe\" },\n });\n }\n wireSettled = true;\n }\n\n async function runExecute(params: {\n source: BunExecutor;\n text: string;\n values: unknown[];\n }): Promise<Record<string, unknown>[]> {\n // One extra round trip on the first ORM query of this adapter's life; a\n // single boolean test on every one after it. It must complete BEFORE the\n // first rows are handed back, because the runtime reads `wire` to build\n // that read's decode plan.\n if (!wireSettled) {\n wireProbe ??= probeJsonWire(params.source).finally(() => { wireProbe = null; });\n await wireProbe;\n }\n const values = serializeParams({ values: params.values });\n if (usePrepared) {\n // F19: a tagged template binds POSITIONALLY, one value per gap — so the\n // values follow the placeholder ORDER found in the text (`$2, $1` binds\n // backwards otherwise, and a repeated `$1` needs its value twice).\n const prepared = templates.getTemplate({ text: params.text });\n const bound = bindTemplateValues({ text: params.text, indices: prepared.indices, values });\n return finalRows({ result: await runMapped(() => params.source(prepared.template, ...bound)) });\n }\n return finalRows({ result: await runMapped(() => params.source.unsafe(params.text, values)) });\n }\n\n async function runExecuteUnsafe(params: {\n source: BunExecutor;\n text: string;\n values?: unknown[];\n }): Promise<QueryResult> {\n const values = params.values === undefined ? undefined : serializeParamsRaw({ values: params.values });\n const rows = finalRows({ result: await runMapped(() => params.source.unsafe(params.text, values)) });\n return { rows, affectedRows: readAffectedRows({ rows }) };\n }\n\n /**\n * Build the adapter facade over any bun:sql handle. `parentMode` decides\n * whether a nested `transaction()` opens a real transaction or a savepoint;\n * `scope` is shared by reference across one top-level transaction, and the\n * savepoint gate serializes overlapping sibling savepoints (F14) on BOTH the\n * driver-managed and the manual path.\n */\n function createAdapter(params: {\n source: BunSource;\n parentMode: ParentMode;\n scope: SavepointScope;\n /** The enclosing transaction's budget; absent on the pool-level adapter. */\n budget?: TransactionBudget;\n lifetime?: { active: boolean };\n }): DatabaseAdapter {\n const { source, parentMode, scope, budget, lifetime } = params;\n\n function assertHandle(): void {\n budget?.assertUsable({ stage: \"statement\" });\n if (lifetime?.active === false) {\n throw new VibeError({\n code: \"VIBE_TRANSACTION\",\n message: \"this savepoint callback has finished; its transaction handle has expired\",\n meta: { reason: \"expired\" },\n });\n }\n if (scope.state.poisoned !== null) throw scope.state.poisoned;\n }\n\n const guardedSource: BunExecutor = Object.assign(\n (strings: TemplateStringsArray, ...values: unknown[]): Promise<BunResults> =>\n budgetTurn({ source, budget, guard: assertHandle, body: () => source(strings, ...values) }),\n { unsafe: (text: string, values?: unknown[]): Promise<BunResults> =>\n budgetTurn({ source, budget, guard: assertHandle, body: () => source.unsafe(text, values) }) },\n );\n\n /** Nested transaction: a savepoint on the connection we are already on. */\n async function transactionViaSavepoint<T>(\n fn: (txAdapter: DatabaseAdapter) => Promise<T>,\n nestedOptions?: TransactionOptions,\n ): Promise<T> {\n refuseNestedTransactionOptions({ options: nestedOptions, provider: PROVIDER });\n assertHandle();\n budget?.assertUsable({ stage: \"nested\" });\n const transactional = source as BunTransaction;\n const runChild = async (child: SavepointScope, childSource: BunTransaction): Promise<T> => {\n assertHandle();\n const childLifetime = { active: true };\n try {\n return await fn(createAdapter({ source: childSource, parentMode: \"tx\", scope: child, budget, lifetime: childLifetime }));\n } finally {\n childLifetime.active = false;\n }\n };\n\n // Modern bun:sql: the in-transaction handle drives savepoints itself —\n // the gate then owns only the LIFETIME, not the SQL. Captured before the\n // callback because narrowing does not reach into a nested closure.\n const driverSavepoint = transactional.savepoint?.bind(transactional);\n if (driverSavepoint !== undefined) {\n return runNestedSavepoint({\n scope,\n body: async (child) => {\n let callbackFailure: CallbackError | undefined;\n try {\n return await driverSavepoint(async (savepointSql) => {\n try {\n return await runChild(child, savepointSql);\n } catch (error) {\n callbackFailure = new CallbackError(error);\n throw callbackFailure;\n }\n });\n } catch (error) {\n // Bun rethrows the identical callback marker only after successful\n // rollback. A replacement error loses that proof. Creation/release\n // errors likewise do not expose whether recovery succeeded.\n if (callbackFailure !== undefined && error === callbackFailure) throw callbackFailure.inner;\n const poisoned = callbackFailure !== undefined\n ? savepointRollbackFailedError({ cause: callbackFailure.inner, rollbackFailure: mapBunDriverError({ error }) })\n : unknownOutcome({ cause: mapBunDriverError({ error }), reason: \"savepoint-outcome-unknown\" });\n scope.state.poisoned = poisoned;\n throw poisoned;\n }\n },\n });\n }\n\n // Reserved connections (and older bun:sql) expose no savepoint helper —\n // drive SAVEPOINT / RELEASE / ROLLBACK TO by hand.\n return runNestedSavepoint({\n scope,\n execute: (statement) => budgetTurn({\n source, budget, cleanup: statement.startsWith(\"ROLLBACK TO SAVEPOINT \"),\n body: () => runMapped(() => transactional.unsafe(statement)),\n }),\n body: (child) => runChild(child, transactional),\n });\n }\n\n /** Top-level transaction on the pool. */\n async function transactionViaPool<T>(\n fn: (txAdapter: DatabaseAdapter) => Promise<T>,\n transactionOptions?: TransactionOptions,\n ): Promise<T> {\n const pool = source as BunInstance;\n\n // Refuse an unsupportable budget before any connection is taken.\n validateTransactionDeadline({\n options: transactionOptions,\n support: BUDGETS.transactionDeadline,\n provider: PROVIDER,\n });\n\n // Fast path: bun:sql drives BEGIN/COMMIT itself. A DEADLINE opts out of\n // it deliberately — the clock must start after the connection is in hand,\n // and only the reserved path below gives that seam.\n if (\n transactionOptions?.isolationLevel === undefined &&\n transactionOptions?.timeout === undefined &&\n transactionOptions?.deadline === undefined\n ) {\n // A budget with no deadline: it still closes the handle at the end, so\n // an escaped transaction client cannot run on a pooled connection.\n const budget = startTransactionBudget({ provider: PROVIDER });\n const txScope = createSavepointScope();\n let callbackFailure: CallbackError | undefined;\n try {\n const result = await pool.begin(async (txSql) => {\n const txAdapter = createAdapter({\n source: txSql,\n parentMode: \"tx\",\n scope: txScope,\n budget,\n });\n try {\n return await runRootScope({ scope: txScope, body: () => fn(txAdapter) });\n } catch (error) {\n callbackFailure = new CallbackError(error);\n throw callbackFailure;\n }\n });\n budget.close({ outcome: \"committed\" });\n return result;\n } catch (error) {\n const knownRollback = callbackFailure !== undefined && error === callbackFailure && txScope.state.poisoned === null;\n budget.close({ outcome: knownRollback ? \"rolled-back\" : \"unknown\" });\n if (callbackFailure !== undefined && error === callbackFailure) throw callbackFailure.inner;\n throw unknownOutcome({ cause: callbackFailure?.inner ?? mapBunDriverError({ error }) });\n }\n }\n\n // Options path: reserve one connection and drive the transaction by hand,\n // because bun:sql's begin() takes no isolation/timeout options.\n const timeoutText =\n transactionOptions.timeout === undefined\n ? undefined\n : statementTimeoutStatement({ timeout: transactionOptions.timeout });\n const reserved = await runMapped(() => pool.reserve());\n // The deadline clock starts HERE: the connection is reserved, so waiting\n // for it is not charged against the caller's transaction budget.\n const budget = startTransactionBudget({ options: transactionOptions, provider: PROVIDER });\n const txScope = createSavepointScope();\n let commitSent = false;\n let discard = false;\n try {\n await runMapped(() =>\n reserved.unsafe(beginStatement({ isolationLevel: transactionOptions.isolationLevel })),\n );\n if (timeoutText !== undefined) await runMapped(() => reserved.unsafe(timeoutText));\n const txAdapter = createAdapter({\n source: reserved,\n parentMode: \"tx\",\n scope: txScope,\n budget,\n });\n const result = await runRootScope({ scope: txScope, body: () => fn(txAdapter) });\n // An expired budget must never commit, however the callback ended.\n await budgetTurn({ source: reserved, budget, stage: \"commit\", body: () => {\n commitSent = true;\n return runMapped(() => reserved.unsafe(\"COMMIT\"));\n } });\n budget.close({ outcome: \"committed\" });\n return result;\n } catch (error) {\n try {\n await reserved.unsafe(\"ROLLBACK\");\n budget.close({ outcome: commitSent || txScope.state.poisoned !== null ? \"unknown\" : \"rolled-back\" });\n } catch {\n // The rollback that should have cleaned up failed: the commit state is\n // genuinely unknown. `SET LOCAL` reverts with the transaction, but\n // this session's transaction state can no longer be asserted.\n discard = true;\n budget.close({ outcome: \"unknown\" });\n if (budget.totalMs !== null && isTransactionDeadlineError(error)) {\n throw transactionOutcomeUnknownError({\n provider: PROVIDER,\n totalMs: budget.totalMs,\n cause: error,\n });\n }\n }\n if (budget.outcome === \"unknown\" && txScope.state.poisoned === null) throw unknownOutcome({ cause: error });\n throw error;\n } finally {\n if (discard) await runMapped(() => reserved.close());\n else reserved.release();\n }\n }\n\n return {\n dialect: DIALECT,\n provider: PROVIDER,\n budgets: BUDGETS,\n get wire(): WireFidelity {\n return activeWire;\n },\n\n async execute(execParams) {\n assertHandle();\n const turn = scopeTurn({ scope });\n if (turn !== undefined) await turn;\n assertHandle();\n return runExecute({ source: guardedSource, ...execParams });\n },\n\n async executeUnsafe(execParams) {\n assertHandle();\n const turn = scopeTurn({ scope });\n if (turn !== undefined) await turn;\n assertHandle();\n return runExecuteUnsafe({ source: guardedSource, ...execParams });\n },\n\n async transaction<T>(\n fn: (txAdapter: DatabaseAdapter) => Promise<T>,\n transactionOptions?: TransactionOptions,\n ): Promise<T> {\n return parentMode === \"pool\"\n ? transactionViaPool(fn, transactionOptions)\n : transactionViaSavepoint(fn, transactionOptions);\n },\n\n async connect(): Promise<void> {\n if (parentMode !== \"pool\") return;\n const reserved = await runMapped(() => (source as BunInstance).reserve());\n reserved.release();\n },\n\n async disconnect(): Promise<void> {\n if (parentMode !== \"pool\") return;\n await runMapped(() => (source as BunInstance).close());\n instance = null;\n },\n\n formatArrayParam(values: unknown[]): unknown {\n return toPgArrayLiteral(values);\n },\n };\n }\n\n /** Pool-level facade — the bun:sql client is created on first use. */\n function poolAdapter(): DatabaseAdapter {\n return createAdapter({\n source: getSql(),\n parentMode: \"pool\",\n scope: createSavepointScope(),\n });\n }\n\n return {\n dialect: DIALECT,\n provider: PROVIDER,\n budgets: BUDGETS,\n get wire(): WireFidelity {\n return activeWire;\n },\n\n async withSession({ run }) {\n // Bun 1.3 does not decrement its pool's pending counter when a reserved\n // connection closes or dies. Own a private one-connection driver instance\n // so cleanup cannot hang or force-close unrelated application work.\n const sessionPool = createSqlInstance({ max: SESSION_CONNECTION.max });\n const close = (): Promise<void> => runMapped(() => sessionPool.close({ timeout: SESSION_CONNECTION.closeGraceSeconds }));\n const reserved = await runMapped(() => sessionPool.reserve()).catch(async (cause: unknown) => {\n await close();\n throw cause;\n });\n return runPinnedSession({\n run,\n execute: async (query) => (await runExecuteUnsafe({ source: reserved, ...query })).rows,\n isLost: (error) => error instanceof VibeError && (\n typeof error.meta.sqlstate !== \"string\" || error.meta.sqlstate.startsWith(\"08\") ||\n [\"57P01\", \"57P02\", \"57P03\"].includes(error.meta.sqlstate)\n ),\n release: close,\n });\n },\n\n async execute(params) {\n return poolAdapter().execute(params);\n },\n\n async executeUnsafe(params) {\n const control = classifyRawTransactionControl({ text: params.text });\n if (rawSession !== null) {\n if (control === \"close\") {\n const session = rawSession;\n rawSession = null;\n try {\n return await runExecuteUnsafe({ source: session, ...params });\n } finally {\n session.release();\n }\n }\n // A nested raw BEGIN lands here too — postgres treats it as a warning\n // no-op on the open session, exactly like a single connection would.\n return runExecuteUnsafe({ source: rawSession, ...params });\n }\n if (control === \"open\") {\n const reserved = await runMapped(() => getSql().reserve());\n try {\n const result = await runExecuteUnsafe({ source: reserved, ...params });\n rawSession = reserved;\n return result;\n } catch (error) {\n reserved.release();\n throw error;\n }\n }\n return poolAdapter().executeUnsafe(params);\n },\n\n async transaction<T>(\n fn: (txAdapter: DatabaseAdapter) => Promise<T>,\n transactionOptions?: TransactionOptions,\n ): Promise<T> {\n return poolAdapter().transaction(fn, transactionOptions);\n },\n\n async connect(): Promise<void> {\n return poolAdapter().connect();\n },\n\n async disconnect(): Promise<void> {\n if (rawSession !== null) {\n // An abandoned raw transaction must not leak an in-transaction\n // connection; roll it back best-effort before the pool closes.\n const session = rawSession;\n rawSession = null;\n try {\n await session.unsafe(\"ROLLBACK\");\n } catch {\n /* the pool is closing; the session is going away regardless */\n }\n session.release();\n }\n if (instance === null) return;\n const closing = instance;\n instance = null;\n await runMapped(() => closing.close());\n },\n\n formatArrayParam(values: unknown[]): unknown {\n return toPgArrayLiteral(values);\n },\n };\n}\n\n/**\n * Rows affected by a bun:sql statement: the driver attaches `count` (and, on\n * some versions, `affectedRows`) to the returned array; otherwise the number of\n * returned rows is the best available answer.\n */\nfunction readAffectedRows(params: { rows: BunRows }): number {\n const { rows } = params;\n if (typeof rows.count === \"number\") return rows.count;\n if (typeof rows.affectedRows === \"number\") return rows.affectedRows;\n return rows.length;\n}\n\n/** Bun's simple protocol returns an outer array for scripts; final command wins. */\nfunction finalRows(params: { result: BunResults }): BunRows {\n const { result } = params;\n if (result === null) return [];\n return Array.isArray(result[0]) ? (result as BunRows[]).at(-1) ?? [] : result as BunRows;\n}\n\nfunction unknownOutcome(params: { cause: unknown; reason?: string }): VibeError {\n return new VibeError({\n code: \"VIBE_TRANSACTION\",\n message: \"Bun could not confirm transaction recovery or completion; the outcome is unknown. Nothing is retried automatically.\",\n meta: { reason: params.reason ?? \"transaction-outcome-unknown\", outcome: \"unknown\" },\n cause: params.cause,\n });\n}\n\n// ─── Re-exports (driver-error table, params, helpers) ─────────────\n\nexport {\n BUN_SQLSTATE_ERROR_CODES,\n BUN_SQLSTATE_REASONS,\n bunErrorSqlstate,\n mapBunDriverError,\n} from \"./errors.ts\";\nexport { serializeParams, serializeParamsRaw, toPgArrayLiteral } from \"./params.ts\";\nexport { applyStartupOptions, buildStartupOptions } from \"./connection-url.ts\";\nexport type { PlanCacheMode } from \"./connection-url.ts\";\nexport { createSavepointCounter, nextSavepointName } from \"@vibeorm/runtime/adapter-kit\";\nexport type { SavepointCounter } from \"@vibeorm/runtime/adapter-kit\";\nexport { createTemplateCache, templateChunks } from \"./template-cache.ts\";\nexport type { TemplateCache } from \"./template-cache.ts\";\nexport {\n ISOLATION_LEVEL_SQL,\n beginStatement,\n classifyRawTransactionControl,\n refuseNestedTransactionOptions,\n statementTimeoutStatement,\n} from \"./transaction-sql.ts\";\nexport type { RawTransactionControl } from \"./transaction-sql.ts\";\n// ─── EPIC 6: transaction budgets (shared, @vibeorm/runtime/adapter-kit) ───\nexport {\n DEFAULT_DEADLINE_CLOCK,\n engineStatementBudgetMs,\n isTransactionDeadlineError,\n startTransactionBudget,\n transactionClosedError,\n transactionDeadlineError,\n transactionOutcomeUnknownError,\n validateTransactionDeadline,\n} from \"@vibeorm/runtime/adapter-kit\";\nexport type { BudgetStage, DeadlineClock, TransactionBudget, TransactionOutcome } from \"@vibeorm/runtime/adapter-kit\";\n",
|
|
7
|
+
"/**\n * @vibeorm/adapter-bun — bun:sql (PostgreSQL) adapter for VibeORM v2.\n *\n * Uses Bun's built-in SQL driver and its internal connection pool. Owns\n * optional prepared statements (synthetic tagged templates), transactions\n * (nested → savepoints), array-literal parameter formatting and driver-error\n * mapping. Only `VibeError` ever escapes.\n */\n\nimport { createBunSql } from \"./driver.ts\";\nimport { SESSION_CONNECTION } from \"./config.ts\";\nimport { postgresDialect, renderDiagnostic } from \"@vibeorm/sql\";\nimport type {\n AdapterBudgetSupport,\n DatabaseAdapter,\n QueryResult,\n TransactionOptions,\n WireFidelity,\n} from \"@vibeorm/runtime\";\nimport {\n abortTransactionOnServerFailure,\n runPinnedSession,\n createSavepointScope,\n savepointRollbackFailedError,\n engineStatementBudgetMs,\n isTransactionDeadlineError,\n runNestedSavepoint,\n runRootScope,\n type SavepointScope,\n scopeTurn,\n startTransactionBudget,\n type TransactionBudget,\n transactionOutcomeUnknownError,\n validateTransactionDeadline,\n} from \"@vibeorm/runtime/adapter-kit\";\nimport { VibeError, type Dialect, type Provider } from \"@vibeorm/schema\";\nimport { applyStartupOptions, buildStartupOptions, type PlanCacheMode } from \"./connection-url.ts\";\nimport { mapBunDriverError, runMapped } from \"./errors.ts\";\nimport { serializeParams, serializeParamsRaw, toPgArrayLiteral } from \"./params.ts\";\nimport { bindTemplateValues, createTemplateCache } from \"./template-cache.ts\";\nimport {\n beginStatement,\n classifyRawTransactionControl,\n refuseNestedTransactionOptions,\n statementTimeoutStatement,\n} from \"./transaction-sql.ts\";\n\n// ─── Minimal bun:sql surface ──────────────────────────────────────\n\n/**\n * What bun:sql resolves a query to: the row array, with driver metadata\n * (`count`, `command`) attached as properties.\n */\ntype BunRows = Record<string, unknown>[] & { count?: number; affectedRows?: number };\n\ntype BunResults = BunRows | BunRows[] | null;\n\n/** Anything that executes SQL through bun:sql. */\ntype BunExecutor = {\n (strings: TemplateStringsArray, ...values: unknown[]): Promise<BunResults>;\n unsafe(text: string, values?: unknown[]): Promise<BunResults>;\n};\n\n/**\n * The handle passed to `sql.begin(cb)`. Modern bun:sql exposes `savepoint(fn)`\n * for sub-transactions; `begin()` throws inside a transaction (\"use\n * savepoint() instead\"), so it is never called here. Older builds lack\n * `savepoint`, which is why it is optional and probed at runtime.\n */\ntype BunTransaction = BunExecutor & {\n savepoint?: <T>(fn: (sp: BunTransaction) => Promise<T>) => Promise<T>;\n};\n\n/** A connection checked out with `sql.reserve()` — no `savepoint`, must be released. */\ntype BunReserved = BunExecutor & { release(): void; close(): Promise<void> };\n\n/** The pool-level bun:sql client. */\ntype BunInstance = BunExecutor & {\n begin<T>(fn: (tx: BunTransaction) => Promise<T>): Promise<T>;\n reserve(): Promise<BunReserved>;\n close(options?: { timeout: number }): Promise<void>;\n};\n\n/** Any bun:sql handle the adapter can be built on top of. */\ntype BunSource = BunInstance | BunReserved | BunTransaction;\n\n/**\n * Whether a handle is the pool (can open a real transaction) or is already\n * inside one (must nest through savepoints).\n */\ntype ParentMode = \"pool\" | \"tx\";\n\n/**\n * Wrapper that marks an error as \"thrown by the user's transaction callback\",\n * so it can be rethrown untouched instead of being mapped as a driver failure\n * after bun:sql has passed it back out of `begin()` / `savepoint()`.\n */\nclass CallbackError extends Error {\n readonly inner: unknown;\n\n constructor(inner: unknown) {\n super(\"vibeorm: transaction callback failed\");\n this.name = \"CallbackError\";\n this.inner = inner;\n }\n}\n\n// ─── Options ──────────────────────────────────────────────────────\n\n/** Options for {@link bunAdapter}. */\nexport type BunAdapterOptions = {\n /** PostgreSQL connection URL. Defaults to `process.env.DATABASE_URL`, then bun's `PG*` env vars. */\n readonly url?: string;\n /** Maximum pooled connections (default 10). */\n readonly max?: number;\n /**\n * Pool-wide `statement_timeout` in milliseconds, sent as a startup parameter\n * so every connection inherits it. A per-transaction `timeout` overrides it\n * for that transaction.\n */\n readonly statementTimeout?: number;\n /**\n * Milliseconds to wait for a connection to be established. Passed to bun:sql\n * as `connectionTimeout` (which expects **seconds**; converted here).\n */\n readonly connectionTimeout?: number;\n /**\n * Execute ORM-path queries as tagged templates, creating named prepared\n * statements (default false). Saves planning time but lets PostgreSQL fall\n * back to a generic plan after ~5 executions — leave off unless profiling\n * says otherwise. bun:sql's `prepare: false` constructor option is never set\n * (it triggers a known bun:sql performance regression).\n */\n readonly preparedStatements?: boolean;\n /** Maximum entries in the synthetic template cache (default 1000, LRU). */\n readonly stmtCacheMax?: number;\n /** PostgreSQL `plan_cache_mode` for every connection (default `force_custom_plan`). */\n readonly planCacheMode?: PlanCacheMode;\n};\n\n// ─── Adapter ──────────────────────────────────────────────────────\n\nconst DIALECT: Dialect = \"postgres\";\nconst PROVIDER: Provider = \"postgresql\";\n\n/**\n * bun:sql wire (board #30, live-verified on both execute paths): timestamptz\n * → `Date`, int4/float8 → numbers. (int8 arrives as a string — BigInt\n * decoding is real work and never pruned.)\n *\n * The `json` half is NOT a constant, because bun:sql's answer changed between\n * Bun versions and this package supports a range of them: on Bun 1.3.14 the\n * tagged-template path parsed json/jsonb while `sql.unsafe` did not (board\n * #34 — declaring \"parsed\" there made the runtime prune the Json decoder and\n * leak raw strings), and on Bun 1.4.1 BOTH paths parse (leaving \"text\" makes\n * the guarded decode re-parse a stored top-level JSON string: `\"123\"` becomes\n * the number 123, `\"hello\"` throws). Either constant is wrong on one of those\n * runtimes, so the adapter OBSERVES its own driver once instead of guessing —\n * see {@link probeJsonWire}. {@link WIRE_TEXT} is the conservative claim it\n * starts from; no ORM rows are returned until the probe succeeds.\n */\n/**\n * Timing budgets this adapter genuinely enforces (EPIC 6).\n *\n * - `acquireTimeout: false` — `connectionTimeout` bounds establishment only.\n * Modern Bun supports reserve({ signal }), but implicit query/begin checkout\n * and older supported Bun versions do not provide that cancellation contract.\n * - `statementTimeout: \"all-statements\"` — a real PostgreSQL server, so\n * `statement_timeout` cancels ANY over-long statement, writes included.\n * - `transactionDeadline: \"cancel-running-statements\"` — the remaining budget\n * is handed to the SERVER before each statement, so the database itself stops\n * work that would outlive the deadline.\n */\nconst BUDGETS: AdapterBudgetSupport = Object.freeze({\n acquireTimeout: false,\n statementTimeout: \"all-statements\",\n transactionDeadline: \"cancel-running-statements\",\n} as const);\n\nconst WIRE_TEXT: WireFidelity = Object.freeze({ dateTime: \"native\", json: \"text\", numbers: \"native\" } as const);\n\n/** The same wire, for a driver observed to hand back parsed json. */\nconst WIRE_PARSED: WireFidelity = Object.freeze({ dateTime: \"native\", json: \"parsed\", numbers: \"native\" } as const);\n\n/**\n * Create a VibeORM adapter backed by bun:sql.\n *\n * @example\n * ```ts\n * const adapter = bunAdapter({ url: process.env.DATABASE_URL, max: 10 });\n * await adapter.connect();\n * const rows = await adapter.execute({ text: 'SELECT * FROM \"User\" WHERE \"id\" = $1', values: [1] });\n * ```\n */\nexport function bunAdapter(options?: BunAdapterOptions): DatabaseAdapter {\n const usePrepared = options?.preparedStatements ?? false;\n const templates = createTemplateCache({ max: options?.stmtCacheMax ?? 1000 });\n\n /**\n * The wire claim this adapter currently makes. Starts conservative and is\n * replaced at most once, by {@link probeJsonWire}'s observation. Every handle\n * this factory builds — pool, transaction, savepoint, reserved session —\n * reads this one variable, so a transaction can never disagree with its\n * parent (the contract requires transactional adapters to carry the same\n * declaration).\n */\n let activeWire: WireFidelity = WIRE_TEXT;\n let wireSettled = false;\n let wireProbe: Promise<void> | null = null;\n\n let instance: BunInstance | null = null;\n const deadlineTurns = new WeakMap<TransactionBudget, Promise<void>>();\n\n // Only deadline-bearing connections need a queue. Share it across every\n // nested facade, not one queue per handle. Probe, statement and COMMIT each\n // receive a fresh bound after preceding work finishes.\n function budgetTurn<T>(params: {\n source: BunExecutor;\n budget?: TransactionBudget;\n stage?: \"statement\" | \"commit\";\n cleanup?: boolean;\n guard?: () => void;\n body: () => Promise<T>;\n }): Promise<T> {\n const { source, budget, body, guard } = params;\n const run = async (): Promise<T> => {\n if (params.cleanup === true) return body();\n budget?.assertUsable({ stage: params.stage ?? \"statement\" });\n guard?.();\n const ms = budget === undefined ? null : engineStatementBudgetMs({ budget });\n if (ms !== null) {\n await runMapped(() => source.unsafe(statementTimeoutStatement({ timeout: ms })));\n budget?.assertUsable({ stage: params.stage ?? \"statement\" });\n guard?.();\n }\n return body();\n };\n if (budget === undefined || budget.totalMs === null) return run();\n const result = (deadlineTurns.get(budget) ?? Promise.resolve()).then(run);\n deadlineTurns.set(budget, result.then(() => undefined, () => undefined));\n return result;\n }\n\n /**\n * The reserved connection of an OPEN raw transaction — session affinity for\n * the raw path. @vibeorm/migrate wraps transactional DDL in literal `BEGIN`\n * / `COMMIT` / `ROLLBACK` sent through `executeUnsafe`; bun:sql refuses\n * transaction control through `sql.unsafe()` on a pooled instance\n * (`ERR_POSTGRES_UNSAFE_TRANSACTION`), so a pure `BEGIN` reserves one\n * connection, every raw statement until the matching `COMMIT`/`ROLLBACK`\n * rides it, and the close releases it. The ORM path (`execute`) and\n * `transaction()` stay on the pool — they never participate in a raw\n * transaction. Concurrent raw transactions on one adapter are unsupported\n * (they were driver-refused before this pinning existed).\n */\n let rawSession: BunReserved | null = null;\n\n function createSqlInstance(params: { max: number }): BunInstance {\n const sqlOptions: Record<string, unknown> = { max: params.max };\n if (options?.connectionTimeout !== undefined) {\n // bun:sql expects seconds; the VibeORM surface is milliseconds everywhere.\n sqlOptions.connectionTimeout = Math.max(1, Math.ceil(options.connectionTimeout / 1000));\n }\n\n const startupOptions = buildStartupOptions({\n planCacheMode: options?.planCacheMode ?? \"force_custom_plan\",\n statementTimeout: options?.statementTimeout,\n });\n const baseUrl = options?.url ?? process.env.DATABASE_URL;\n const url =\n baseUrl === undefined || startupOptions === undefined\n ? baseUrl\n : applyStartupOptions({ url: baseUrl, startupOptions });\n\n // Bun's constructor connection object also supports PG*-only configuration.\n if (url === undefined && startupOptions !== undefined) {\n sqlOptions.connection = { options: startupOptions };\n }\n return createBunSql({ url, options: sqlOptions }) as unknown as BunInstance;\n }\n\n function getSql(): BunInstance {\n instance ??= createSqlInstance({ max: options?.max ?? 10 });\n return instance;\n }\n\n /**\n * Ask THIS driver, once, whether it parses json on the path the ORM reads\n * rows over — the same `execute` path, prepared or unsafe as configured, so\n * the answer describes the traffic the claim is applied to.\n *\n * Runs on the handle that is already in hand (pool, transaction or reserved\n * session): a `SELECT` is harmless inside a transaction, and probing the pool\n * from inside one could deadlock an adapter configured with `max: 1`.\n * Failure refuses this operation. A later call can observe the wire again;\n * no user statement or transaction is retried.\n */\n async function probeJsonWire(source: BunExecutor): Promise<void> {\n const probe = renderDiagnostic({ dialect: postgresDialect, query: \"postgresJsonWire\" });\n const rows = finalRows({ result: await runMapped(() => usePrepared\n ? source(templates.getTemplate({ text: probe.text }).template)\n : source.unsafe(probe.text, [])) });\n const probed = rows[0]?.probe;\n if (typeof probed === \"object\" && probed !== null && \"__vibeorm\" in probed && probed.__vibeorm === 1) activeWire = WIRE_PARSED;\n else if (typeof probed === \"string\" && /^\\{\\s*\"__vibeorm\"\\s*:\\s*1\\s*\\}$/.test(probed)) activeWire = WIRE_TEXT;\n else {\n throw new VibeError({\n code: \"VIBE_ADAPTER\",\n message: \"Bun returned an unrecognized JSON wire probe result; no ORM statement was sent\",\n meta: { reason: \"json-wire-probe\" },\n });\n }\n wireSettled = true;\n }\n\n async function runExecute(params: {\n source: BunExecutor;\n text: string;\n values: unknown[];\n }): Promise<Record<string, unknown>[]> {\n // One extra round trip on the first ORM query of this adapter's life; a\n // single boolean test on every one after it. It must complete BEFORE the\n // first rows are handed back, because the runtime reads `wire` to build\n // that read's decode plan.\n if (!wireSettled) {\n wireProbe ??= probeJsonWire(params.source).finally(() => { wireProbe = null; });\n await wireProbe;\n }\n const values = serializeParams({ values: params.values });\n if (usePrepared) {\n // F19: a tagged template binds POSITIONALLY, one value per gap — so the\n // values follow the placeholder ORDER found in the text (`$2, $1` binds\n // backwards otherwise, and a repeated `$1` needs its value twice).\n const prepared = templates.getTemplate({ text: params.text });\n const bound = bindTemplateValues({ text: params.text, indices: prepared.indices, values });\n return finalRows({ result: await runMapped(() => params.source(prepared.template, ...bound)) });\n }\n return finalRows({ result: await runMapped(() => params.source.unsafe(params.text, values)) });\n }\n\n async function runExecuteUnsafe(params: {\n source: BunExecutor;\n text: string;\n values?: unknown[];\n }): Promise<QueryResult> {\n const values = params.values === undefined ? undefined : serializeParamsRaw({ values: params.values });\n const rows = finalRows({ result: await runMapped(() => params.source.unsafe(params.text, values)) });\n return { rows, affectedRows: readAffectedRows({ rows }) };\n }\n\n /**\n * Build the adapter facade over any bun:sql handle. `parentMode` decides\n * whether a nested `transaction()` opens a real transaction or a savepoint;\n * `scope` is shared by reference across one top-level transaction, and the\n * savepoint gate serializes overlapping sibling savepoints (F14) on BOTH the\n * driver-managed and the manual path.\n */\n function createAdapter(params: {\n source: BunSource;\n parentMode: ParentMode;\n scope: SavepointScope;\n /** The enclosing transaction's budget; absent on the pool-level adapter. */\n budget?: TransactionBudget;\n lifetime?: { active: boolean };\n }): DatabaseAdapter {\n const { source, parentMode, scope, budget, lifetime } = params;\n\n function assertHandle(): void {\n budget?.assertUsable({ stage: \"statement\" });\n if (lifetime?.active === false) {\n throw new VibeError({\n code: \"VIBE_TRANSACTION\",\n message: \"this savepoint callback has finished; its transaction handle has expired\",\n meta: { reason: \"expired\" },\n });\n }\n if (scope.state.poisoned !== null) throw scope.state.poisoned;\n }\n\n const guardedSource: BunExecutor = Object.assign(\n (strings: TemplateStringsArray, ...values: unknown[]): Promise<BunResults> =>\n budgetTurn({ source, budget, guard: assertHandle, body: () => source(strings, ...values) }),\n { unsafe: (text: string, values?: unknown[]): Promise<BunResults> =>\n budgetTurn({ source, budget, guard: assertHandle, body: () => source.unsafe(text, values) }) },\n );\n\n /** Nested transaction: a savepoint on the connection we are already on. */\n async function transactionViaSavepoint<T>(\n fn: (txAdapter: DatabaseAdapter) => Promise<T>,\n nestedOptions?: TransactionOptions,\n ): Promise<T> {\n refuseNestedTransactionOptions({ options: nestedOptions, provider: PROVIDER });\n assertHandle();\n budget?.assertUsable({ stage: \"nested\" });\n const transactional = source as BunTransaction;\n const runChild = async (child: SavepointScope, childSource: BunTransaction): Promise<T> => {\n assertHandle();\n const childLifetime = { active: true };\n try {\n return await fn(createAdapter({ source: childSource, parentMode: \"tx\", scope: child, budget, lifetime: childLifetime }));\n } finally {\n childLifetime.active = false;\n }\n };\n\n // Modern bun:sql: the in-transaction handle drives savepoints itself —\n // the gate then owns only the LIFETIME, not the SQL. Captured before the\n // callback because narrowing does not reach into a nested closure.\n const driverSavepoint = transactional.savepoint?.bind(transactional);\n if (driverSavepoint !== undefined) {\n return runNestedSavepoint({\n scope,\n body: async (child) => {\n let callbackFailure: CallbackError | undefined;\n try {\n return await driverSavepoint(async (savepointSql) => {\n try {\n return await runChild(child, savepointSql);\n } catch (error) {\n callbackFailure = new CallbackError(error);\n throw callbackFailure;\n }\n });\n } catch (error) {\n // Bun rethrows the identical callback marker only after successful\n // rollback. A replacement error loses that proof. Creation/release\n // errors likewise do not expose whether recovery succeeded.\n if (callbackFailure !== undefined && error === callbackFailure) throw callbackFailure.inner;\n const poisoned = callbackFailure !== undefined\n ? savepointRollbackFailedError({ cause: callbackFailure.inner, rollbackFailure: mapBunDriverError({ error }) })\n : unknownOutcome({ cause: mapBunDriverError({ error }), reason: \"savepoint-outcome-unknown\" });\n scope.state.poisoned = poisoned;\n throw poisoned;\n }\n },\n });\n }\n\n // Reserved connections (and older bun:sql) expose no savepoint helper —\n // drive SAVEPOINT / RELEASE / ROLLBACK TO by hand.\n return runNestedSavepoint({\n scope,\n execute: (statement) => budgetTurn({\n source, budget, cleanup: statement.startsWith(\"ROLLBACK TO SAVEPOINT \"),\n body: () => runMapped(() => transactional.unsafe(statement)),\n }),\n body: (child) => runChild(child, transactional),\n });\n }\n\n /** Top-level transaction on the pool. */\n async function transactionViaPool<T>(\n fn: (txAdapter: DatabaseAdapter) => Promise<T>,\n transactionOptions?: TransactionOptions,\n ): Promise<T> {\n const pool = source as BunInstance;\n\n // Refuse an unsupportable budget before any connection is taken.\n validateTransactionDeadline({\n options: transactionOptions,\n support: BUDGETS.transactionDeadline,\n provider: PROVIDER,\n });\n\n // Fast path: bun:sql drives BEGIN/COMMIT itself. A DEADLINE opts out of\n // it deliberately — the clock must start after the connection is in hand,\n // and only the reserved path below gives that seam.\n if (\n transactionOptions?.isolationLevel === undefined &&\n transactionOptions?.timeout === undefined &&\n transactionOptions?.deadline === undefined\n ) {\n // A budget with no deadline: it still closes the handle at the end, so\n // an escaped transaction client cannot run on a pooled connection.\n const budget = startTransactionBudget({ provider: PROVIDER });\n const txScope = createSavepointScope();\n let callbackFailure: CallbackError | undefined;\n try {\n const result = await pool.begin(async (txSql) => {\n const txAdapter = createAdapter({\n source: txSql,\n parentMode: \"tx\",\n scope: txScope,\n budget,\n });\n try {\n return await runRootScope({ scope: txScope, body: () => fn(txAdapter) });\n } catch (error) {\n callbackFailure = new CallbackError(error);\n throw callbackFailure;\n }\n });\n budget.close({ outcome: \"committed\" });\n return result;\n } catch (error) {\n const knownRollback = callbackFailure !== undefined && error === callbackFailure && txScope.state.poisoned === null;\n budget.close({ outcome: knownRollback ? \"rolled-back\" : \"unknown\" });\n if (callbackFailure !== undefined && error === callbackFailure) throw callbackFailure.inner;\n throw unknownOutcome({ cause: callbackFailure?.inner ?? mapBunDriverError({ error }) });\n }\n }\n\n // Options path: reserve one connection and drive the transaction by hand,\n // because bun:sql's begin() takes no isolation/timeout options.\n const timeoutText =\n transactionOptions.timeout === undefined\n ? undefined\n : statementTimeoutStatement({ timeout: transactionOptions.timeout });\n const reserved = await runMapped(() => pool.reserve());\n // The deadline clock starts HERE: the connection is reserved, so waiting\n // for it is not charged against the caller's transaction budget.\n const budget = startTransactionBudget({ options: transactionOptions, provider: PROVIDER });\n const txScope = createSavepointScope();\n let commitSent = false;\n let discard = false;\n try {\n await runMapped(() =>\n reserved.unsafe(beginStatement({ isolationLevel: transactionOptions.isolationLevel })),\n );\n if (timeoutText !== undefined) await runMapped(() => reserved.unsafe(timeoutText));\n const txAdapter = createAdapter({\n source: reserved,\n parentMode: \"tx\",\n scope: txScope,\n budget,\n });\n const result = await runRootScope({ scope: txScope, body: () => fn(txAdapter) });\n // An expired budget must never commit, however the callback ended.\n await budgetTurn({ source: reserved, budget, stage: \"commit\", body: () => {\n commitSent = true;\n return runMapped(() => reserved.unsafe(\"COMMIT\"));\n } });\n budget.close({ outcome: \"committed\" });\n return result;\n } catch (error) {\n try {\n await reserved.unsafe(\"ROLLBACK\");\n budget.close({ outcome: commitSent || txScope.state.poisoned !== null ? \"unknown\" : \"rolled-back\" });\n } catch {\n // The rollback that should have cleaned up failed: the commit state is\n // genuinely unknown. `SET LOCAL` reverts with the transaction, but\n // this session's transaction state can no longer be asserted.\n discard = true;\n budget.close({ outcome: \"unknown\" });\n if (budget.totalMs !== null && isTransactionDeadlineError(error)) {\n throw transactionOutcomeUnknownError({\n provider: PROVIDER,\n totalMs: budget.totalMs,\n cause: error,\n });\n }\n }\n if (budget.outcome === \"unknown\" && txScope.state.poisoned === null) throw unknownOutcome({ cause: error });\n throw error;\n } finally {\n if (discard) await runMapped(() => reserved.close());\n else reserved.release();\n }\n }\n\n return {\n dialect: DIALECT,\n provider: PROVIDER,\n budgets: BUDGETS,\n get wire(): WireFidelity {\n return activeWire;\n },\n\n async execute(execParams) {\n assertHandle();\n const turn = scopeTurn({ scope });\n if (turn !== undefined) await turn;\n assertHandle();\n const result = runExecute({ source: guardedSource, ...execParams });\n // Inside a transaction a server-reported failure aborts it (postgres):\n // record it so a callback that swallows it cannot commit nothing. The\n // pool-level handle has no transaction to abort.\n return parentMode === \"pool\"\n ? result\n : result.catch((error: unknown) => abortTransactionOnServerFailure({ scope, error }));\n },\n\n async executeUnsafe(execParams) {\n assertHandle();\n const turn = scopeTurn({ scope });\n if (turn !== undefined) await turn;\n assertHandle();\n const result = runExecuteUnsafe({ source: guardedSource, ...execParams });\n return parentMode === \"pool\"\n ? result\n : result.catch((error: unknown) => abortTransactionOnServerFailure({ scope, error }));\n },\n\n async transaction<T>(\n fn: (txAdapter: DatabaseAdapter) => Promise<T>,\n transactionOptions?: TransactionOptions,\n ): Promise<T> {\n return parentMode === \"pool\"\n ? transactionViaPool(fn, transactionOptions)\n : transactionViaSavepoint(fn, transactionOptions);\n },\n\n async connect(): Promise<void> {\n if (parentMode !== \"pool\") return;\n const reserved = await runMapped(() => (source as BunInstance).reserve());\n reserved.release();\n },\n\n async disconnect(): Promise<void> {\n if (parentMode !== \"pool\") return;\n await runMapped(() => (source as BunInstance).close());\n instance = null;\n },\n\n formatArrayParam(values: unknown[]): unknown {\n return toPgArrayLiteral(values);\n },\n };\n }\n\n /** Pool-level facade — the bun:sql client is created on first use. */\n function poolAdapter(): DatabaseAdapter {\n return createAdapter({\n source: getSql(),\n parentMode: \"pool\",\n scope: createSavepointScope(),\n });\n }\n\n return {\n dialect: DIALECT,\n provider: PROVIDER,\n budgets: BUDGETS,\n get wire(): WireFidelity {\n return activeWire;\n },\n\n async withSession({ run }) {\n // Bun 1.3 does not decrement its pool's pending counter when a reserved\n // connection closes or dies. Own a private one-connection driver instance\n // so cleanup cannot hang or force-close unrelated application work.\n const sessionPool = createSqlInstance({ max: SESSION_CONNECTION.max });\n const close = (): Promise<void> => runMapped(() => sessionPool.close({ timeout: SESSION_CONNECTION.closeGraceSeconds }));\n const reserved = await runMapped(() => sessionPool.reserve()).catch(async (cause: unknown) => {\n await close();\n throw cause;\n });\n return runPinnedSession({\n run,\n execute: async (query) => (await runExecuteUnsafe({ source: reserved, ...query })).rows,\n isLost: (error) => error instanceof VibeError && (\n typeof error.meta.sqlstate !== \"string\" || error.meta.sqlstate.startsWith(\"08\") ||\n [\"57P01\", \"57P02\", \"57P03\"].includes(error.meta.sqlstate)\n ),\n release: close,\n });\n },\n\n async execute(params) {\n return poolAdapter().execute(params);\n },\n\n async executeUnsafe(params) {\n const control = classifyRawTransactionControl({ text: params.text });\n if (rawSession !== null) {\n if (control === \"close\") {\n const session = rawSession;\n rawSession = null;\n try {\n return await runExecuteUnsafe({ source: session, ...params });\n } finally {\n session.release();\n }\n }\n // A nested raw BEGIN lands here too — postgres treats it as a warning\n // no-op on the open session, exactly like a single connection would.\n return runExecuteUnsafe({ source: rawSession, ...params });\n }\n if (control === \"open\") {\n const reserved = await runMapped(() => getSql().reserve());\n try {\n const result = await runExecuteUnsafe({ source: reserved, ...params });\n rawSession = reserved;\n return result;\n } catch (error) {\n reserved.release();\n throw error;\n }\n }\n return poolAdapter().executeUnsafe(params);\n },\n\n async transaction<T>(\n fn: (txAdapter: DatabaseAdapter) => Promise<T>,\n transactionOptions?: TransactionOptions,\n ): Promise<T> {\n return poolAdapter().transaction(fn, transactionOptions);\n },\n\n async connect(): Promise<void> {\n return poolAdapter().connect();\n },\n\n async disconnect(): Promise<void> {\n if (rawSession !== null) {\n // An abandoned raw transaction must not leak an in-transaction\n // connection; roll it back best-effort before the pool closes.\n const session = rawSession;\n rawSession = null;\n try {\n await session.unsafe(\"ROLLBACK\");\n } catch {\n /* the pool is closing; the session is going away regardless */\n }\n session.release();\n }\n if (instance === null) return;\n const closing = instance;\n instance = null;\n await runMapped(() => closing.close());\n },\n\n formatArrayParam(values: unknown[]): unknown {\n return toPgArrayLiteral(values);\n },\n };\n}\n\n/**\n * Rows affected by a bun:sql statement: the driver attaches `count` (and, on\n * some versions, `affectedRows`) to the returned array; otherwise the number of\n * returned rows is the best available answer.\n */\nfunction readAffectedRows(params: { rows: BunRows }): number {\n const { rows } = params;\n if (typeof rows.count === \"number\") return rows.count;\n if (typeof rows.affectedRows === \"number\") return rows.affectedRows;\n return rows.length;\n}\n\n/** Bun's simple protocol returns an outer array for scripts; final command wins. */\nfunction finalRows(params: { result: BunResults }): BunRows {\n const { result } = params;\n if (result === null) return [];\n return Array.isArray(result[0]) ? (result as BunRows[]).at(-1) ?? [] : result as BunRows;\n}\n\nfunction unknownOutcome(params: { cause: unknown; reason?: string }): VibeError {\n return new VibeError({\n code: \"VIBE_TRANSACTION\",\n message: \"Bun could not confirm transaction recovery or completion; the outcome is unknown. Nothing is retried automatically.\",\n meta: { reason: params.reason ?? \"transaction-outcome-unknown\", outcome: \"unknown\" },\n cause: params.cause,\n });\n}\n\n// ─── Re-exports (driver-error table, params, helpers) ─────────────\n\nexport {\n BUN_SQLSTATE_ERROR_CODES,\n BUN_SQLSTATE_REASONS,\n bunErrorSqlstate,\n mapBunDriverError,\n} from \"./errors.ts\";\nexport { serializeParams, serializeParamsRaw, toPgArrayLiteral } from \"./params.ts\";\nexport { applyStartupOptions, buildStartupOptions } from \"./connection-url.ts\";\nexport type { PlanCacheMode } from \"./connection-url.ts\";\nexport { createSavepointCounter, nextSavepointName } from \"@vibeorm/runtime/adapter-kit\";\nexport type { SavepointCounter } from \"@vibeorm/runtime/adapter-kit\";\nexport { createTemplateCache, templateChunks } from \"./template-cache.ts\";\nexport type { TemplateCache } from \"./template-cache.ts\";\nexport {\n ISOLATION_LEVEL_SQL,\n beginStatement,\n classifyRawTransactionControl,\n refuseNestedTransactionOptions,\n statementTimeoutStatement,\n} from \"./transaction-sql.ts\";\nexport type { RawTransactionControl } from \"./transaction-sql.ts\";\n// ─── EPIC 6: transaction budgets (shared, @vibeorm/runtime/adapter-kit) ───\nexport {\n DEFAULT_DEADLINE_CLOCK,\n engineStatementBudgetMs,\n isTransactionDeadlineError,\n startTransactionBudget,\n transactionClosedError,\n transactionDeadlineError,\n transactionOutcomeUnknownError,\n validateTransactionDeadline,\n} from \"@vibeorm/runtime/adapter-kit\";\nexport type { BudgetStage, DeadlineClock, TransactionBudget, TransactionOutcome } from \"@vibeorm/runtime/adapter-kit\";\n",
|
|
8
8
|
"/**\n * Connection-URL handling for bun:sql.\n *\n * Per-connection PostgreSQL settings (`plan_cache_mode`, `statement_timeout`)\n * travel in the `options` startup parameter, which the server parses for\n * `-c key=value` pairs — so every connection in bun's internal pool inherits\n * them without a per-query round trip.\n *\n * v1 lesson (LEARNINGS.md): bun:sql forwards *unrecognised* URL parameters to\n * the server as runtime configuration, so a libpq client-side option such as\n * `connect_timeout` must never be put in the URL (PostgreSQL rejects it as an\n * unrecognised configuration parameter). Connection timeouts use bun:sql's\n * `connectionTimeout` constructor option instead.\n */\n\nimport { VibeError } from \"@vibeorm/schema\";\n\n/**\n * PostgreSQL plan-cache behaviour for the implicit prepared statements bun:sql\n * creates. `force_custom_plan` replans with the real parameter values (≈0.1 ms\n * per query) and keeps index selection optimal on range/LIKE/skewed filters —\n * `auto` lets PostgreSQL switch to a generic plan after ~5 executions.\n */\nexport type PlanCacheMode = \"auto\" | \"force_custom_plan\" | \"force_generic_plan\";\n\n/**\n * Build the `options` startup string, or `undefined` when nothing needs setting.\n *\n * @throws VibeError `VIBE_VALIDATION` when `statementTimeout` is not a\n * non-negative integer — the value ends up inside the startup string verbatim.\n */\nexport function buildStartupOptions(params: {\n planCacheMode: PlanCacheMode;\n statementTimeout?: number;\n}): string | undefined {\n const { planCacheMode, statementTimeout } = params;\n const parts: string[] = [];\n if (planCacheMode !== \"auto\") parts.push(`-c plan_cache_mode=${planCacheMode}`);\n if (statementTimeout !== undefined) {\n if (!Number.isInteger(statementTimeout) || statementTimeout < 0) {\n throw new VibeError({\n code: \"VIBE_VALIDATION\",\n message: `statementTimeout must be a non-negative integer of milliseconds, received ${String(statementTimeout)}`,\n meta: { statementTimeout },\n });\n }\n parts.push(`-c statement_timeout=${statementTimeout}`);\n }\n return parts.length === 0 ? undefined : parts.join(\" \");\n}\n\n/** Merge startup settings into one `options` key; adapter settings take precedence. */\nexport function applyStartupOptions(params: { url: string; startupOptions: string }): string {\n if (!URL.canParse(params.url)) {\n throw new VibeError({ code: \"VIBE_VALIDATION\", message: \"invalid PostgreSQL connection URL\" });\n }\n const url = new URL(params.url);\n const merged = [...url.searchParams.getAll(\"options\"), params.startupOptions].filter(Boolean).join(\" \");\n url.searchParams.set(\"options\", merged);\n url.search = url.searchParams.toString().replace(/\\+/g, \"%20\");\n return url.toString();\n}\n",
|
|
9
|
-
"/**\n * Driver-error mapping for `bun:sql`.\n *\n * bun:sql raises `SQL.PostgresError` for server failures and for client-side\n * problems alike. Server failures carry the PostgreSQL SQLSTATE — depending on\n * the Bun version on `code` or on `errno` — while client-side failures use a\n * `ERR_POSTGRES_*` identifier in `code`. Both shapes are read here, so the\n * mapping is stable across Bun versions. Constitution rule 5: only `VibeError`\n * escapes the adapter.\n */\n\nimport { VibeError, type VibeErrorCode } from \"@vibeorm/schema\";\n\n// ─── SQLSTATE table ───────────────────────────────────────────────\n\n/**\n * PostgreSQL SQLSTATE → stable VibeError code. Frozen and mirrored by tests;\n * anything absent from this table (including every `ERR_POSTGRES_*` connection\n * or auth failure) maps to `VIBE_ADAPTER`.\n */\nexport const BUN_SQLSTATE_ERROR_CODES: Readonly<Record<string, VibeErrorCode>> = Object.freeze({\n /** exclusion_violation */\n \"23P01\": \"VIBE_EXCLUSION_VIOLATION\",\n /** unique_violation */\n \"23505\": \"VIBE_UNIQUE_VIOLATION\",\n /** foreign_key_violation */\n \"23503\": \"VIBE_FK_VIOLATION\",\n /** restrict_violation — PostgreSQL 18+ ON DELETE/UPDATE RESTRICT */\n \"23001\": \"VIBE_FK_VIOLATION\",\n /** not_null_violation */\n \"23502\": \"VIBE_VALIDATION\",\n /** check_violation */\n \"23514\": \"VIBE_VALIDATION\",\n /**\n * invalid_text_representation — a value the server cannot parse into the\n * column's type (out-of-range enum value, `\"abc\"` for an integer). Bad input,\n * so the same code sqlite reports for its enum CHECK violation.\n */\n \"22P02\": \"VIBE_VALIDATION\",\n /**\n * insufficient_privilege — a denied table/column privilege, and the SQLSTATE a\n * native row-level-security policy raises when its WITH CHECK refuses a write.\n * Callers identify it by this code, never by message text.\n */\n \"42501\": \"VIBE_PERMISSION_DENIED\",\n /** serialization_failure */\n \"40001\": \"VIBE_TRANSACTION\",\n /** deadlock_detected */\n \"40P01\": \"VIBE_TRANSACTION\",\n /** query_canceled — statement_timeout fired */\n \"57014\": \"VIBE_TRANSACTION\",\n /**\n * lock_not_available — a `nowait` locking read on already-locked rows, or an\n * expired `lock_timeout`. Postgres reports both with this one SQLSTATE.\n */\n \"55P03\": \"VIBE_LOCK_NOT_AVAILABLE\",\n});\n\n/** SQLSTATEs that additionally explain themselves through `meta.reason`. */\nexport const BUN_SQLSTATE_REASONS: Readonly<Record<string, string>> = Object.freeze({\n \"23P01\": \"exclusion-violation\",\n \"57014\": \"timeout\",\n \"55P03\": \"lock-not-available\",\n \"40P01\": \"deadlock\",\n \"40001\": \"serialization-failure\",\n});\n\n// ─── Reading driver errors ────────────────────────────────────────\n\n/** A PostgreSQL SQLSTATE is exactly five digits/uppercase letters (e.g. `40P01`). */\nconst SQLSTATE_PATTERN = /^[0-9A-Z]{5}$/;\n\nfunction readStringField(params: { source: Record<string, unknown>; key: string }): string | undefined {\n const value = params.source[params.key];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\n/**\n * Extract the SQLSTATE from a bun:sql error, accepting it on either `code` or\n * `errno`. `ERR_POSTGRES_*` identifiers are not SQLSTATEs and yield `undefined`.\n */\nexport function bunErrorSqlstate(params: { error: unknown }): string | undefined {\n const { error } = params;\n if (error === null || typeof error !== \"object\") return undefined;\n const source = error as Record<string, unknown>;\n for (const key of [\"code\", \"errno\"]) {\n const value = readStringField({ source, key });\n if (value !== undefined && SQLSTATE_PATTERN.test(value)) return value;\n }\n return undefined;\n}\n\n// ─── Mapping ──────────────────────────────────────────────────────\n\n/**\n * Map any error thrown by bun:sql onto a `VibeError`.\n *\n * A `VibeError` passes through unchanged, so an error raised deeper inside the\n * ORM (or by a nested adapter call) is never re-wrapped.\n */\nexport function mapBunDriverError(params: { error: unknown }): VibeError {\n const { error } = params;\n if (error instanceof VibeError) return error;\n\n const source: Record<string, unknown> =\n error !== null && typeof error === \"object\" ? (error as Record<string, unknown>) : {};\n const sqlstate = bunErrorSqlstate({ error });\n const code: VibeErrorCode =\n (sqlstate === undefined ? undefined : BUN_SQLSTATE_ERROR_CODES[sqlstate]) ?? \"VIBE_ADAPTER\";\n\n const meta: Record<string, unknown> = {};\n if (sqlstate !== undefined) meta.sqlstate = sqlstate;\n const constraint = readStringField({ source, key: \"constraint\" });\n if (constraint !== undefined) meta.constraint = constraint;\n const table = readStringField({ source, key: \"table\" });\n if (table !== undefined) meta.table = table;\n const column = readStringField({ source, key: \"column\" });\n if (column !== undefined) meta.column = column;\n const reason = sqlstate === undefined ? undefined : BUN_SQLSTATE_REASONS[sqlstate];\n if (reason !== undefined) meta.reason = reason;\n // Keep bun's own identifier when it is not a SQLSTATE — it is the only clue\n // a connection/auth/protocol failure carries.\n const driverCode = readStringField({ source, key: \"code\" });\n if (driverCode !== undefined && driverCode !== sqlstate) meta.driverCode = driverCode;\n\n const message =\n readStringField({ source, key: \"message\" }) ??\n (typeof error === \"string\" ? error : \"unknown bun:sql driver error\");\n\n return new VibeError({ code, message, meta, cause: error });\n}\n\n/** Run a driver call, mapping anything it throws onto a `VibeError`. */\nexport async function runMapped<T>(fn: () => Promise<T>): Promise<T> {\n try {\n return await fn();\n } catch (error) {\n throw mapBunDriverError({ error });\n }\n}\n",
|
|
9
|
+
"/**\n * Driver-error mapping for `bun:sql`.\n *\n * bun:sql raises `SQL.PostgresError` for server failures and for client-side\n * problems alike. Server failures carry the PostgreSQL SQLSTATE — depending on\n * the Bun version on `code` or on `errno` — while client-side failures use a\n * `ERR_POSTGRES_*` identifier in `code`. Both shapes are read here, so the\n * mapping is stable across Bun versions. Constitution rule 5: only `VibeError`\n * escapes the adapter.\n */\n\nimport { VibeError, type VibeErrorCode } from \"@vibeorm/schema\";\n\n// ─── SQLSTATE table ───────────────────────────────────────────────\n\n/**\n * PostgreSQL SQLSTATE → stable VibeError code. Frozen and mirrored by tests;\n * anything absent from this table (including every `ERR_POSTGRES_*` connection\n * or auth failure) maps to `VIBE_ADAPTER`.\n */\nexport const BUN_SQLSTATE_ERROR_CODES: Readonly<Record<string, VibeErrorCode>> = Object.freeze({\n /** exclusion_violation */\n \"23P01\": \"VIBE_EXCLUSION_VIOLATION\",\n /** unique_violation */\n \"23505\": \"VIBE_UNIQUE_VIOLATION\",\n /** foreign_key_violation */\n \"23503\": \"VIBE_FK_VIOLATION\",\n /** restrict_violation — PostgreSQL 18+ ON DELETE/UPDATE RESTRICT */\n \"23001\": \"VIBE_FK_VIOLATION\",\n /** not_null_violation */\n \"23502\": \"VIBE_VALIDATION\",\n /** check_violation */\n \"23514\": \"VIBE_VALIDATION\",\n /**\n * invalid_text_representation — a value the server cannot parse into the\n * column's type (out-of-range enum value, `\"abc\"` for an integer). Bad input,\n * so the same code sqlite reports for its enum CHECK violation.\n */\n \"22P02\": \"VIBE_VALIDATION\",\n /** Data exceptions the same bad input raises (mirrors adapter-pg): too long, out of range, bad datetime, datetime overflow. */\n \"22001\": \"VIBE_VALIDATION\",\n \"22003\": \"VIBE_VALIDATION\",\n \"22007\": \"VIBE_VALIDATION\",\n \"22008\": \"VIBE_VALIDATION\",\n /**\n * insufficient_privilege — a denied table/column privilege, and the SQLSTATE a\n * native row-level-security policy raises when its WITH CHECK refuses a write.\n * Callers identify it by this code, never by message text.\n */\n \"42501\": \"VIBE_PERMISSION_DENIED\",\n /** serialization_failure */\n \"40001\": \"VIBE_TRANSACTION\",\n /** deadlock_detected */\n \"40P01\": \"VIBE_TRANSACTION\",\n /** query_canceled — statement_timeout fired */\n \"57014\": \"VIBE_TRANSACTION\",\n /**\n * lock_not_available — a `nowait` locking read on already-locked rows, or an\n * expired `lock_timeout`. Postgres reports both with this one SQLSTATE.\n */\n \"55P03\": \"VIBE_LOCK_NOT_AVAILABLE\",\n});\n\n/** SQLSTATEs that additionally explain themselves through `meta.reason`. */\nexport const BUN_SQLSTATE_REASONS: Readonly<Record<string, string>> = Object.freeze({\n \"23P01\": \"exclusion-violation\",\n \"57014\": \"timeout\",\n \"55P03\": \"lock-not-available\",\n \"40P01\": \"deadlock\",\n \"40001\": \"serialization-failure\",\n});\n\n// ─── Reading driver errors ────────────────────────────────────────\n\n/** A PostgreSQL SQLSTATE is exactly five digits/uppercase letters (e.g. `40P01`). */\nconst SQLSTATE_PATTERN = /^[0-9A-Z]{5}$/;\n\nfunction readStringField(params: { source: Record<string, unknown>; key: string }): string | undefined {\n const value = params.source[params.key];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\n/**\n * Extract the SQLSTATE from a bun:sql error, accepting it on either `code` or\n * `errno`. `ERR_POSTGRES_*` identifiers are not SQLSTATEs and yield `undefined`.\n */\nexport function bunErrorSqlstate(params: { error: unknown }): string | undefined {\n const { error } = params;\n if (error === null || typeof error !== \"object\") return undefined;\n const source = error as Record<string, unknown>;\n for (const key of [\"code\", \"errno\"]) {\n const value = readStringField({ source, key });\n if (value !== undefined && SQLSTATE_PATTERN.test(value)) return value;\n }\n return undefined;\n}\n\n// ─── Mapping ──────────────────────────────────────────────────────\n\n/**\n * Map any error thrown by bun:sql onto a `VibeError`.\n *\n * A `VibeError` passes through unchanged, so an error raised deeper inside the\n * ORM (or by a nested adapter call) is never re-wrapped.\n */\nexport function mapBunDriverError(params: { error: unknown }): VibeError {\n const { error } = params;\n if (error instanceof VibeError) return error;\n\n const source: Record<string, unknown> =\n error !== null && typeof error === \"object\" ? (error as Record<string, unknown>) : {};\n const sqlstate = bunErrorSqlstate({ error });\n const code: VibeErrorCode =\n (sqlstate === undefined ? undefined : BUN_SQLSTATE_ERROR_CODES[sqlstate]) ?? \"VIBE_ADAPTER\";\n\n const meta: Record<string, unknown> = {};\n if (sqlstate !== undefined) meta.sqlstate = sqlstate;\n const constraint = readStringField({ source, key: \"constraint\" });\n if (constraint !== undefined) meta.constraint = constraint;\n const table = readStringField({ source, key: \"table\" });\n if (table !== undefined) meta.table = table;\n const column = readStringField({ source, key: \"column\" });\n if (column !== undefined) meta.column = column;\n const reason = sqlstate === undefined ? undefined : BUN_SQLSTATE_REASONS[sqlstate];\n if (reason !== undefined) meta.reason = reason;\n // Keep bun's own identifier when it is not a SQLSTATE — it is the only clue\n // a connection/auth/protocol failure carries.\n const driverCode = readStringField({ source, key: \"code\" });\n if (driverCode !== undefined && driverCode !== sqlstate) meta.driverCode = driverCode;\n\n const message =\n readStringField({ source, key: \"message\" }) ??\n (typeof error === \"string\" ? error : \"unknown bun:sql driver error\");\n\n return new VibeError({ code, message, meta, cause: error });\n}\n\n/** Run a driver call, mapping anything it throws onto a `VibeError`. */\nexport async function runMapped<T>(fn: () => Promise<T>): Promise<T> {\n try {\n return await fn();\n } catch (error) {\n throw mapBunDriverError({ error });\n }\n}\n",
|
|
10
10
|
"/**\n * Parameter serialization for bun:sql.\n *\n * Verified against Bun 1.3 (re-verified on 1.3.14; `tests/live.test.ts` and\n * the notes below):\n * - a plain object or array bound to a `json`/`jsonb` column is JSON-encoded by\n * bun:sql itself — encoding it here as well double-encodes it and stores a\n * JSON *string* (`jsonb_typeof` = `\"string\"`), so the ORM path must not touch it;\n * - a plain JS array bound to a scalar-list column (`text[]`, `int[]`) is NOT\n * turned into a PostgreSQL array literal by bun:sql — it arrives as `a,b` and\n * the server rejects it with `malformed array literal`. Scalar lists therefore\n * have to be pre-rendered with {@link toPgArrayLiteral}, which is exactly what\n * the adapter's `formatArrayParam` returns.\n *\n * Hence the split (LEARNINGS.md): the ORM path passes values through (scalar\n * lists already arrived as literal strings), while the raw path renders plain JS\n * arrays as array literals so `db.$queryRawUnsafe('… = ANY($1)', [1, 2, 3])`\n * matches rows.\n */\n\nimport { VibeError } from \"@vibeorm/schema\";\n\n// ─── PostgreSQL array literals ────────────────────────────────────\n\n/** Quote and escape one array element: `\"` and `\\` are the special characters. */\nfunction quoteElement(value: string): string {\n return `\"${value.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"')}\"`;\n}\n\n/**\n * Render a JS array as a PostgreSQL array literal string.\n *\n * Element handling:\n * - `null` / `undefined` → unquoted `NULL`\n * - `number` / `bigint` / `boolean` → unquoted primitive\n * - `Date` → quoted ISO-8601 (PostgreSQL cannot parse `String(date)`)\n * - `string` → quoted, with `\"` and `\\` escaped (so commas, braces and quotes\n * inside an element are safe)\n * - any other object, **including a nested array** → quoted `JSON.stringify`,\n * which is what a `Json[]` scalar list needs (PostgreSQL scalar lists are\n * one-dimensional, so a nested array is a JSON value, not a matrix)\n * - binary (`Uint8Array` / `ArrayBuffer`) → unsupported, throws\n *\n * @throws VibeError `VIBE_VALIDATION` for binary elements.\n */\nexport function toPgArrayLiteral(values: readonly unknown[]): string {\n const elements = values.map((value) => {\n if (value === null || value === undefined) return \"NULL\";\n if (typeof value === \"number\" || typeof value === \"bigint\" || typeof value === \"boolean\") {\n return String(value);\n }\n if (value instanceof Date) return quoteElement(value.toISOString());\n if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {\n throw new VibeError({\n code: \"VIBE_VALIDATION\",\n message: \"binary values are not supported inside a postgres array literal\",\n meta: { driver: \"bun:sql\" },\n });\n }\n if (typeof value === \"string\") return quoteElement(value);\n if (typeof value === \"object\") return quoteElement(JSON.stringify(value));\n return quoteElement(String(value));\n });\n return `{${elements.join(\",\")}}`;\n}\n\n// ─── Serialization ────────────────────────────────────────────────\n\n/**\n * `Date` → UTC ISO-8601 text (`2026-03-08T19:38:08.538Z`), the same spelling\n * the array literal above uses.\n *\n * bun:sql serializes a `Date` by the parameter's RESOLVED postgres type\n * (LEARNINGS): fine for `timestamp`/`timestamptz` (UTC text), but a `date`\n * parameter gets `Date#toString()` — `Sun Mar 08 2026 23:30:00 GMT+0000\n * (Coordinated Universal Time)` — which the server rejects in every host TZ\n * (live on Bun 1.4.3: `invalid input syntax for type date` under UTC, `time\n * zone \"gmt-0400\" not recognized` under America/New_York). The ISO text\n * parses for all three, and pins the UTC wall-clock contract the codec table\n * and the other postgres adapters share. Dates the ISO form cannot spell\n * (invalid, BC, beyond year 9999) keep the driver's serializer.\n */\nexport function serializeDate(params: { value: Date }): unknown {\n const { value } = params;\n if (Number.isNaN(value.getTime())) return value;\n const year = value.getUTCFullYear();\n if (year < 1 || year > 9999) return value;\n return value.toISOString();\n}\n\n/**\n * ORM hot path: pass every value straight to bun:sql, except `Date`\n * ({@link serializeDate}).\n *\n * Scalar lists already arrived as array-literal strings from\n * `formatArrayParam`, and bun:sql JSON-encodes objects and arrays for\n * `json`/`jsonb` columns by itself — re-encoding here would store a\n * double-encoded JSON string.\n */\nexport function serializeParams(params: { values: readonly unknown[] }): unknown[] {\n return params.values.map((value) => (value instanceof Date ? serializeDate({ value }) : value));\n}\n\n/**\n * Raw path: render plain JS arrays as PostgreSQL array literals so\n * `db.$queryRawUnsafe('… WHERE \"id\" = ANY($1)', [1, 2, 3])` matches rows;\n * everything else (objects included) goes to bun:sql untouched.\n *\n * Trade-off (v1 lesson): binding a JS array **into** a `jsonb` column from a raw\n * query means calling `JSON.stringify` yourself.\n */\nexport function serializeParamsRaw(params: { values: readonly unknown[] }): unknown[] {\n return params.values.map((value) => {\n if (Array.isArray(value)) return toPgArrayLiteral(value);\n if (value instanceof Date) return serializeDate({ value });\n return value;\n });\n}\n",
|
|
11
11
|
"/**\n * Synthetic tagged-template cache — bun:sql's prepared-statement path.\n *\n * bun:sql only creates a *named* prepared statement (one PostgreSQL keeps a\n * plan for) when the query arrives as a tagged template. Generated SQL is a\n * plain string, so with `preparedStatements: true` the adapter turns each SQL\n * text into a synthetic `TemplateStringsArray` — split at its `$1`, `$2`, …\n * placeholders — and reuses that same object identity for every execution.\n *\n * A tagged template binds its values POSITIONALLY, one per gap, so the split\n * has to keep two things a plain `text.split(/\\$\\d+/)` throws away (F19):\n *\n * - **which** placeholder each gap is. `SELECT $2, $1` has to bind\n * `values[1]` then `values[0]`, and a repeated `$1` needs its value bound at\n * every occurrence — otherwise the statement silently returns other rows, or\n * reaches the server with too few parameters and fails to parse.\n * - **where** a `$n` is not a placeholder at all: inside a string literal, a\n * quoted identifier, a line or block comment, or a dollar-quoted body. A\n * split there tears the literal apart and produces invalid SQL.\n *\n * The cache is LRU-bounded so a long-running process never grows it without\n * limit.\n */\n\nimport { VibeError } from \"@vibeorm/schema\";\n\n/** A SQL text split for bun:sql, with the placeholder index behind each gap. */\nexport type PreparedTemplate = {\n /** The synthetic template; stable by identity so bun:sql can cache its plan. */\n readonly template: TemplateStringsArray;\n /** 1-based `$n` for each gap, in TEXT order (`SELECT $2, $1` → `[2, 1]`). */\n readonly indices: readonly number[];\n};\n\n/** LRU map from SQL text to the synthetic template used to execute it. */\nexport type TemplateCache = {\n /** Template for `text`, creating one on first sight. Stable by identity. */\n getTemplate(params: { text: string }): PreparedTemplate;\n /** Number of texts currently held — diagnostics and tests. */\n size(): number;\n};\n\n// ─── Scanning ─────────────────────────────────────────────────────\n\n/** Is this character part of an unquoted SQL identifier? */\nfunction isIdentChar(char: string | undefined): boolean {\n if (char === undefined) return false;\n return /[A-Za-z0-9_]/.test(char);\n}\n\n/**\n * Index just past a quoted run starting at `start` (`'…'` or `\"…\"`). A doubled\n * quote (`''`, `\"\"`) continues the run — postgres' own escape. A backslash\n * escapes the next character ONLY in an `E'…'` string; with the default\n * `standard_conforming_strings = on` a backslash inside an ordinary literal is\n * just a backslash, and treating it as an escape would run past the literal's\n * real end.\n */\nfunction skipQuoted(text: string, start: number, quote: string): number {\n const escaping =\n quote === \"'\" && (text[start - 1] === \"e\" || text[start - 1] === \"E\") && !isIdentChar(text[start - 2]);\n let index = start + 1;\n while (index < text.length) {\n const char = text[index];\n if (escaping && char === \"\\\\\") {\n index += 2;\n continue;\n }\n if (char === quote) {\n if (text[index + 1] === quote) {\n index += 2;\n continue;\n }\n return index + 1;\n }\n index += 1;\n }\n return text.length; // unterminated — the driver reports it, not this scanner\n}\n\n/** Index just past a block comment, honouring postgres' nesting. */\nfunction skipBlockComment(text: string, start: number): number {\n let depth = 0;\n let index = start;\n while (index < text.length) {\n if (text[index] === \"/\" && text[index + 1] === \"*\") {\n depth += 1;\n index += 2;\n continue;\n }\n if (text[index] === \"*\" && text[index + 1] === \"/\") {\n depth -= 1;\n index += 2;\n if (depth === 0) return index;\n continue;\n }\n index += 1;\n }\n return text.length;\n}\n\n/**\n * Index just past a dollar-quoted body (`$$…$$`, `$tag$…$tag$`) starting at\n * `start`, or `-1` when no dollar quote opens there. `$1` never matches: a tag\n * has to start with a letter or underscore.\n */\nfunction skipDollarQuoted(text: string, start: number): number {\n const opener = /^\\$(?:[A-Za-z_][A-Za-z0-9_]*)?\\$/.exec(text.slice(start));\n if (opener === null) return -1;\n const tag = opener[0];\n const close = text.indexOf(tag, start + tag.length);\n return close === -1 ? text.length : close + tag.length;\n}\n\n/**\n * Split `text` at its real `$n` placeholders. `chunks.length` is always\n * `indices.length + 1`, which is exactly the shape a tagged template needs.\n */\nexport function scanPlaceholders(params: { text: string }): PreparedTemplate {\n const { text } = params;\n const chunks: string[] = [];\n const indices: number[] = [];\n let chunkStart = 0;\n let index = 0;\n\n while (index < text.length) {\n const char = text[index];\n if (char === \"'\" || char === '\"') {\n index = skipQuoted(text, index, char);\n continue;\n }\n if (char === \"-\" && text[index + 1] === \"-\") {\n const newline = text.indexOf(\"\\n\", index);\n index = newline === -1 ? text.length : newline + 1;\n continue;\n }\n if (char === \"/\" && text[index + 1] === \"*\") {\n index = skipBlockComment(text, index);\n continue;\n }\n if (char === \"$\") {\n const dollarEnd = skipDollarQuoted(text, index);\n if (dollarEnd !== -1) {\n index = dollarEnd;\n continue;\n }\n let digits = index + 1;\n while (digits < text.length && text[digits] !== undefined && /[0-9]/.test(text[digits] as string)) digits += 1;\n if (digits > index + 1) {\n chunks.push(text.slice(chunkStart, index));\n indices.push(Number(text.slice(index + 1, digits)));\n chunkStart = digits;\n index = digits;\n continue;\n }\n }\n index += 1;\n }\n\n chunks.push(text.slice(chunkStart));\n const template = Object.assign(chunks, { raw: chunks }) as unknown as TemplateStringsArray;\n return { template, indices };\n}\n\n/**\n * Split a SQL text on `$n` placeholders into the literal chunks around them.\n *\n * Kept for callers that only want the chunks; it is quote-, comment- and\n * dollar-quote-aware through {@link scanPlaceholders}, so `'$1'` inside a\n * string literal is NOT a split point.\n */\nexport function templateChunks(params: { text: string }): string[] {\n return [...scanPlaceholders(params).template];\n}\n\n// ─── Binding ──────────────────────────────────────────────────────\n\n/**\n * The values to hand a synthetic template, in gap order: `$n` picks\n * `values[n - 1]`, a repeated placeholder repeats its value.\n *\n * A `$n` with no matching value is REFUSED (`VIBE_VALIDATION`) rather than\n * bound to `undefined` — misbinding is exactly the failure mode F19 records.\n */\nexport function bindTemplateValues(params: {\n text: string;\n indices: readonly number[];\n values: readonly unknown[];\n}): unknown[] {\n const { text, indices, values } = params;\n return indices.map((placeholder) => {\n if (placeholder < 1 || placeholder > values.length) {\n throw new VibeError({\n code: \"VIBE_VALIDATION\",\n message: `bun:sql prepared statement references $${placeholder} but only ${values.length} parameter(s) were given`,\n meta: { text, placeholder, provided: values.length },\n });\n }\n return values[placeholder - 1];\n });\n}\n\n// ─── Cache ────────────────────────────────────────────────────────\n\n/**\n * Create a template cache holding at most `max` texts (least recently used\n * evicted first).\n */\nexport function createTemplateCache(params: { max: number }): TemplateCache {\n const { max } = params;\n const templates = new Map<string, PreparedTemplate>();\n\n return {\n getTemplate(templateParams: { text: string }): PreparedTemplate {\n const { text } = templateParams;\n const existing = templates.get(text);\n if (existing !== undefined) {\n // Re-insert to mark most-recently-used.\n templates.delete(text);\n templates.set(text, existing);\n return existing;\n }\n const prepared = scanPlaceholders({ text });\n if (templates.size >= max) {\n const oldest = templates.keys().next().value;\n if (oldest !== undefined) templates.delete(oldest);\n }\n templates.set(text, prepared);\n return prepared;\n },\n\n size(): number {\n return templates.size;\n },\n };\n}\n",
|
|
12
12
|
"/**\n * Transaction-control SQL text (postgres dialect, bun:sql flavour).\n *\n * Used by the reserved-connection path, which issues `BEGIN` itself so that\n * isolation level and statement timeout can be applied — bun:sql's\n * `sql.begin(fn)` fast path takes no such options.\n */\n\nimport type { IsolationLevel } from \"@vibeorm/runtime\";\nimport { VibeError } from \"@vibeorm/schema\";\n\n/** VibeORM isolation level → PostgreSQL isolation level keyword. */\nexport const ISOLATION_LEVEL_SQL: Readonly<Record<IsolationLevel, string>> = Object.freeze({\n ReadCommitted: \"READ COMMITTED\",\n RepeatableRead: \"REPEATABLE READ\",\n Serializable: \"SERIALIZABLE\",\n});\n\n/** `BEGIN`, with an `ISOLATION LEVEL` clause when the caller asked for one. */\nexport function beginStatement(params: { isolationLevel?: IsolationLevel }): string {\n const { isolationLevel } = params;\n return isolationLevel === undefined\n ? \"BEGIN\"\n : `BEGIN ISOLATION LEVEL ${ISOLATION_LEVEL_SQL[isolationLevel]}`;\n}\n\n/**\n * `SET LOCAL statement_timeout = <ms>` — transaction-scoped, so PostgreSQL\n * cancels an over-long statement with SQLSTATE 57014 (mapped to\n * `VIBE_TRANSACTION` with `meta.reason = \"timeout\"`).\n *\n * @throws VibeError `VIBE_VALIDATION` when the timeout is not a non-negative\n * integer — the value is interpolated into SQL, so it is never trusted blindly.\n */\nexport function statementTimeoutStatement(params: { timeout: number }): string {\n const { timeout } = params;\n if (!Number.isInteger(timeout) || timeout < 0) {\n throw new VibeError({\n code: \"VIBE_VALIDATION\",\n message: `transaction timeout must be a non-negative integer of milliseconds, received ${String(timeout)}`,\n meta: { timeout },\n });\n }\n return `SET LOCAL statement_timeout = ${timeout}`;\n}\n\n// ─── Raw transaction control (session affinity) ─────────────────\n\n/** How a raw statement steers the adapter's session-affine raw transaction. */\nexport type RawTransactionControl = \"open\" | \"close\" | null;\n\nconst RAW_OPEN_PATTERN: RegExp = /^\\s*(?:begin|start\\s+transaction)\\b[^;]*;?\\s*$/i;\nconst RAW_CLOSE_PATTERN: RegExp = /^\\s*(?:commit|end|rollback|abort)(?:\\s+(?:transaction|work))?\\s*;?\\s*$/i;\n\n/**\n * Classify a raw statement as transaction control.\n *\n * @vibeorm/migrate drives transactional DDL by sending literal `BEGIN` /\n * `COMMIT` / `ROLLBACK` through its stateless `SqlExecutor` — sound only when\n * every statement in between rides the SAME connection. The adapter uses this\n * to pin one connection for the whole raw transaction (\"open\" reserves,\n * \"close\" releases). On a pooled bun:sql instance an unpinned `BEGIN` is\n * refused outright by the driver (`ERR_POSTGRES_UNSAFE_TRANSACTION`); other\n * pool drivers would only work by checkout luck.\n *\n * Deliberately strict: only PURE single-statement control text matches\n * (`BEGIN`, `BEGIN ISOLATION LEVEL …;`, `COMMIT`, `ROLLBACK WORK`, `END`,\n * `ABORT`). Compound scripts, `ROLLBACK TO SAVEPOINT`, two-phase\n * `COMMIT PREPARED` and `COMMIT AND CHAIN` (which keeps a transaction open)\n * never engage the pinning.\n */\nexport function classifyRawTransactionControl(params: { text: string }): RawTransactionControl {\n if (RAW_OPEN_PATTERN.test(params.text)) return \"open\";\n if (RAW_CLOSE_PATTERN.test(params.text)) return \"close\";\n return null;\n}\n\n// ─── Nested transaction options (the cross-adapter contract) ──────\n\n// ONE copy, shared by every adapter through the runtime's adapter-kit;\n// re-exported here so this adapter's public surface is unchanged.\nexport { refuseNestedTransactionOptions } from \"@vibeorm/runtime/adapter-kit\";\n"
|
|
13
13
|
],
|
|
14
|
-
"mappings": ";;AAAA;AAGO,SAAS,YAAY,CAAC,QAAiE;AAAA,EAC5F,OAAO,OAAO,QAAQ,YAAY,IAAI,IAAI,OAAO,OAAO,IAAI,IAAI,IAAI,OAAO,KAAK,OAAO,OAAO;AAAA;;;ACHzF,IAAM,qBAA2E,OAAO,OAAO;AAAA,EACpG,KAAK;AAAA,EAGL,mBAAmB;AACrB,CAAC;;;ACKD;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,sBAAS;;;ACnBT;AAgBO,SAAS,mBAAmB,CAAC,QAGb;AAAA,EACrB,QAAQ,eAAe,qBAAqB;AAAA,EAC5C,MAAM,QAAkB,CAAC;AAAA,EACzB,IAAI,kBAAkB;AAAA,IAAQ,MAAM,KAAK,sBAAsB,eAAe;AAAA,EAC9E,IAAI,qBAAqB,WAAW;AAAA,IAClC,IAAI,CAAC,OAAO,UAAU,gBAAgB,KAAK,mBAAmB,GAAG;AAAA,MAC/D,MAAM,IAAI,UAAU;AAAA,QAClB,MAAM;AAAA,QACN,SAAS,6EAA6E,OAAO,gBAAgB;AAAA,QAC7G,MAAM,EAAE,iBAAiB;AAAA,MAC3B,CAAC;AAAA,IACH;AAAA,IACA,MAAM,KAAK,wBAAwB,kBAAkB;AAAA,EACvD;AAAA,EACA,OAAO,MAAM,WAAW,IAAI,YAAY,MAAM,KAAK,GAAG;AAAA;AAIjD,SAAS,mBAAmB,CAAC,QAAyD;AAAA,EAC3F,IAAI,CAAC,IAAI,SAAS,OAAO,GAAG,GAAG;AAAA,IAC7B,MAAM,IAAI,UAAU,EAAE,MAAM,mBAAmB,SAAS,oCAA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;AAAA,MAClB;AAAA,MACA,IAAI,aAAa;AAAA,QAAM;AAAA,MACvB,MAAM,UAAU;AAAA,MAChB,WAAW;AAAA,MACX,MAAM,UAAU,MAAM,QAAQ,MAAM,CAAC;AAAA;AAAA,IAGvC,gBAAgB,CAAC,QAA4B;AAAA,MAC3C,OAAO,iBAAiB,MAAM;AAAA;AAAA,EAElC;AAAA;AAQF,SAAS,gBAAgB,CAAC,QAAmC;AAAA,EAC3D,QAAQ,SAAS;AAAA,EACjB,IAAI,OAAO,KAAK,UAAU;AAAA,IAAU,OAAO,KAAK;AAAA,EAChD,IAAI,OAAO,KAAK,iBAAiB;AAAA,IAAU,OAAO,KAAK;AAAA,EACvD,OAAO,KAAK;AAAA;AAId,SAAS,SAAS,CAAC,QAAyC;AAAA,EAC1D,QAAQ,WAAW;AAAA,EACnB,IAAI,WAAW;AAAA,IAAM,OAAO,CAAC;AAAA,EAC7B,OAAO,MAAM,QAAQ,OAAO,EAAE,IAAK,OAAqB,GAAG,EAAE,KAAK,CAAC,IAAI;AAAA;AAGzE,SAAS,cAAc,CAAC,QAAwD;AAAA,EAC9E,OAAO,IAAI,WAAU;AAAA,IACnB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM,EAAE,QAAQ,OAAO,UAAU,+BAA+B,SAAS,UAAU;AAAA,IACnF,OAAO,OAAO;AAAA,EAChB,CAAC;AAAA;",
|
|
15
|
+
"debugId": "014C6E379183B00C64756E2164756E21",
|
|
16
16
|
"names": []
|
|
17
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibeorm/adapter-bun",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "bun:sql (Postgres) adapter for VibeORM v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"orm",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"bun": ">=1.2.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@vibeorm/runtime": "2.
|
|
45
|
-
"@vibeorm/schema": "2.
|
|
46
|
-
"@vibeorm/sql": "2.
|
|
44
|
+
"@vibeorm/runtime": "2.4.1",
|
|
45
|
+
"@vibeorm/schema": "2.4.0",
|
|
46
|
+
"@vibeorm/sql": "2.4.0"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|