turbine-orm 0.28.0 → 0.28.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/cjs/errors.js +15 -1
- package/dist/cjs/powdb.js +1 -1
- package/dist/cjs/powql.js +1 -1
- package/dist/cjs/query/builder.js +75 -294
- package/dist/cjs/query/deferred.js +7 -0
- package/dist/cjs/query/filters.js +251 -0
- package/dist/errors.js +15 -1
- package/dist/powdb.d.ts +1 -1
- package/dist/powdb.js +1 -1
- package/dist/powql.d.ts +1 -1
- package/dist/powql.js +1 -1
- package/dist/query/builder.d.ts +3 -122
- package/dist/query/builder.js +1 -220
- package/dist/query/deferred.d.ts +130 -0
- package/dist/query/deferred.js +6 -0
- package/dist/query/filters.d.ts +120 -0
- package/dist/query/filters.js +232 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Every TS ORM now resolves nested relations in a single `json_agg` query — Pris
|
|
|
14
14
|
|
|
15
15
|
1. **Read-only Studio your DBA will approve.** `npx turbine studio` spins up a loopback-bound web UI with 192-bit auth tokens, `BEGIN READ ONLY` transactions, and — since v0.19 — no raw-SQL surface at all: queries are composed in the ORM's own validated builder. The only TS ORM Studio that physically cannot mutate your database.
|
|
16
16
|
2. **PII-safe error messages.** Turbine errors show WHERE keys, not values. A `UniqueConstraintError` says which column violated the constraint — never the actual user data. Safe to log, safe to surface to monitoring, no scrubbing needed.
|
|
17
|
-
3. **One runtime dependency (`pg`).** No engine binary, no WASM, no adapter packages to keep in lockstep. The main entry
|
|
17
|
+
3. **One runtime dependency (`pg`).** No engine binary, no WASM, no adapter packages to keep in lockstep. The main entry's **import graph** is ~42 kB brotli (edge ~33 kB) with `pg` external — that is the client footprint your bundler sees, not the dual ESM+CJS install size on disk (~3 MB). Prisma 7 dropped its Rust query engine, but its client still ships a TypeScript/WASM query compiler — a ~1.6 MB bundle, down from the ~14 MB Rust-era client.
|
|
18
18
|
4. **SQL-first migrations with drift detection.** Write real SQL. SHA-256 checksums catch modified migration files. `pg_try_advisory_lock()` prevents concurrent runs. Each migration in its own transaction. No shadow database, no magic DSL.
|
|
19
19
|
5. **Edge-native — one import swap.** `turbineHttp(pool, SCHEMA)` — same API on Neon, Vercel Postgres, Cloudflare Hyperdrive, Supabase. No WASM bundle, no adapter package, no separate serverless build.
|
|
20
20
|
6. **Pipeline batching via wire protocol.** Real Parse/Bind/Execute pipeline — not queries wrapped in a transaction. N independent queries in one round-trip.
|
|
@@ -882,7 +882,7 @@ Everything is honest about what ports and what doesn't. Features marked **PG-onl
|
|
|
882
882
|
|
|
883
883
|
**Engine notes:** SQLite uses `RETURNING` (≥ 3.35) just like Postgres. MySQL has no `RETURNING`, so writes re-`SELECT` the affected row and **`createMany` returns `[]`** (the rows ARE inserted — re-query if you need them). SQL Server returns rows via `OUTPUT`/`MERGE`; `DISTINCT ON` is Postgres-only. Only Postgres streams via a true cursor (constant memory); the other engines' `findManyStream` materializes the result then yields it in batches. Optimistic locking throws `OptimisticLockError` on all engines (on MySQL the conflict is detected from the version-checked UPDATE's affected-row count). The `turbine` CLI (`generate`, `migrate`) is currently PostgreSQL-only — point the engine factories at a hand-written or programmatically introspected `SCHEMA`.
|
|
884
884
|
|
|
885
|
-
**PowDB** speaks its own non-SQL query language (PowQL), so it sits outside the SQL matrix above.
|
|
885
|
+
**PowDB** speaks its own non-SQL query language (PowQL), so it sits outside the SQL matrix above. Writes use a trailing **`returning`** keyword (upsert reselects by PK). PKs are server-assigned `auto` ints **or** client UUIDs. Nested relations load client-side (N+1, including many-to-many via the junction — no `json_agg`). Nested writes cover hasMany/hasOne/belongsTo; many-to-many nested writes are not supported. Transactions are single-writer (no nested savepoints). Schema is code-first via `defineSchema` (no wire introspection). Embedded `syncMode: 'normal'` moves fsync off the commit path; the networked transport runs the same data over a socket. Cursor streaming and the Postgres-only trio (pgvector / LISTEN/NOTIFY / RLS session GUCs) throw `UnsupportedFeatureError`. Full details: **[turbineorm.dev/engines#powdb](https://turbineorm.dev/engines#powdb)**.
|
|
886
886
|
|
|
887
887
|
Full setup, signatures, and the complete support matrix: **[turbineorm.dev/engines](https://turbineorm.dev/engines)**.
|
|
888
888
|
|
|
@@ -990,13 +990,13 @@ Turbine is focused and opinionated. Here's what it doesn't do:
|
|
|
990
990
|
|
|
991
991
|
## Requirements
|
|
992
992
|
|
|
993
|
-
- Node.js >=
|
|
993
|
+
- Node.js >= 20.0.0
|
|
994
994
|
- PostgreSQL >= 14
|
|
995
995
|
- Works with both ESM (`import`) and CommonJS (`require`)
|
|
996
996
|
|
|
997
997
|
## Contributing
|
|
998
998
|
|
|
999
|
-
Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, the test strategy, and the PR checklist. The unit suite runs without a database:
|
|
999
|
+
Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, the test strategy, and the PR checklist. Participants agree to the [Code of Conduct](CODE_OF_CONDUCT.md). The unit suite runs without a database:
|
|
1000
1000
|
|
|
1001
1001
|
```bash
|
|
1002
1002
|
npm install
|
package/dist/cjs/errors.js
CHANGED
|
@@ -30,11 +30,25 @@ exports.TurbineErrorCode = {
|
|
|
30
30
|
EXCLUSION_VIOLATION: 'TURBINE_E016',
|
|
31
31
|
UNSUPPORTED_FEATURE: 'TURBINE_E017',
|
|
32
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Prefix a human message with its stable error code so logs are greppable
|
|
35
|
+
* without requiring structured field access. Idempotent if the message already
|
|
36
|
+
* starts with `[TURBINE_E0NN]`.
|
|
37
|
+
*/
|
|
38
|
+
function formatErrorMessage(code, message) {
|
|
39
|
+
const tag = `[${code}]`;
|
|
40
|
+
if (message.startsWith(tag))
|
|
41
|
+
return message;
|
|
42
|
+
// Empty message → just the code (defensive; callers always pass text today).
|
|
43
|
+
if (!message)
|
|
44
|
+
return tag;
|
|
45
|
+
return `${tag} ${message}`;
|
|
46
|
+
}
|
|
33
47
|
/** Base error class for all Turbine errors */
|
|
34
48
|
class TurbineError extends Error {
|
|
35
49
|
code;
|
|
36
50
|
constructor(code, message, options) {
|
|
37
|
-
super(message, options);
|
|
51
|
+
super(formatErrorMessage(code, message), options);
|
|
38
52
|
this.name = 'TurbineError';
|
|
39
53
|
this.code = code;
|
|
40
54
|
}
|
package/dist/cjs/powdb.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* seam. The four SQL engines are untouched.
|
|
11
11
|
*
|
|
12
12
|
* PowDB realities shape the design (all verified firsthand against a live
|
|
13
|
-
* `powdb-server` / the embedded addon, see `docs/strategy/powdb-parity-matrix.md`):
|
|
13
|
+
* `powdb-server` / the embedded addon, see `docs/internal/strategy/powdb-parity-matrix.md`):
|
|
14
14
|
* - **`RETURNING` (since 0.7.0)** — `create/createMany/update/delete` append the
|
|
15
15
|
* trailing `returning` keyword (`RETURNING *`, all columns) and read the
|
|
16
16
|
* affected rows back in one round-trip. `upsert` is the lone exception (its
|
package/dist/cjs/powql.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* it separate also means the four SQL engines are untouched.
|
|
12
12
|
*
|
|
13
13
|
* Behavioural deltas from the SQL path, all driven by PowDB's wire reality (see
|
|
14
|
-
* `docs/strategy/powdb-parity-matrix.md`, every row verified against a live
|
|
14
|
+
* `docs/internal/strategy/powdb-parity-matrix.md`, every row verified against a live
|
|
15
15
|
* server):
|
|
16
16
|
* - `create`/`createMany`/`update`/`delete` use PowDB 0.7.0's trailing
|
|
17
17
|
* `returning` keyword (`RETURNING *`, all columns) to surface affected rows
|