viborm 0.1.0 → 1.0.0-rc.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/LICENSE +21 -0
- package/README.md +218 -66
- package/dist/adapter-internals-Dc9I8w9Y.mjs +2 -0
- package/dist/adapter-internals-Dc9I8w9Y.mjs.map +1 -0
- package/dist/adapter-namespace-DEKd5hIN.mjs +2 -0
- package/dist/adapter-namespace-DEKd5hIN.mjs.map +1 -0
- package/dist/adapters.d.mts +2 -2
- package/dist/adapters.mjs +1 -1
- package/dist/base-BUN03ArF.mjs +2 -0
- package/dist/base-BUN03ArF.mjs.map +1 -0
- package/dist/bun-sql.d.mts +1 -2
- package/dist/bun-sql.mjs +1 -1
- package/dist/bun-sql.mjs.map +1 -1
- package/dist/bun-sqlite.d.mts +1 -2
- package/dist/bun-sqlite.mjs +1 -1
- package/dist/bun-sqlite.mjs.map +1 -1
- package/dist/cache/cloudflare-kv.d.mts +1 -2
- package/dist/cache/cloudflare-kv.mjs +1 -1
- package/dist/cache/cloudflare-kv.mjs.map +1 -1
- package/dist/cache/memory.d.mts +1 -2
- package/dist/cache/memory.mjs +1 -1
- package/dist/cache/memory.mjs.map +1 -1
- package/dist/cache.d.mts +2 -4
- package/dist/cache.mjs +1 -1
- package/dist/cli.mjs +2 -39
- package/dist/cli.mjs.map +1 -1
- package/dist/client-C0QaN70e.mjs +421 -0
- package/dist/client-C0QaN70e.mjs.map +1 -0
- package/dist/client-DAwgJteY.mjs +2 -0
- package/dist/client-DAwgJteY.mjs.map +1 -0
- package/dist/client.d.mts +3 -3
- package/dist/client.mjs +1 -1
- package/dist/clock-DHSN2GNk.mjs +2 -0
- package/dist/clock-DHSN2GNk.mjs.map +1 -0
- package/dist/config.d.mts +62 -0
- package/dist/config.mjs +1 -0
- package/dist/consumable-result-candidate-BgCNshWE.mjs +2 -0
- package/dist/consumable-result-candidate-BgCNshWE.mjs.map +1 -0
- package/dist/contract-d8tNa7GK.d.mts +34 -0
- package/dist/current-ca5_TV29.mjs +2 -0
- package/dist/current-ca5_TV29.mjs.map +1 -0
- package/dist/d1.d.mts +1 -2
- package/dist/d1.mjs +1 -1
- package/dist/d1.mjs.map +1 -1
- package/dist/datetime-physical-codec-pRp9yrnq.mjs +2 -0
- package/dist/datetime-physical-codec-pRp9yrnq.mjs.map +1 -0
- package/dist/diagnostics-BpFHhRrD.mjs +2 -0
- package/dist/diagnostics-BpFHhRrD.mjs.map +1 -0
- package/dist/driver-C2ITQ9lL.mjs +2 -0
- package/dist/driver-C2ITQ9lL.mjs.map +1 -0
- package/dist/driver-CW-7kaQ2.mjs +2 -0
- package/dist/driver-CW-7kaQ2.mjs.map +1 -0
- package/dist/driver-options-C9bFmRTQ.mjs +2 -0
- package/dist/driver-options-C9bFmRTQ.mjs.map +1 -0
- package/dist/driver.d.mts +2 -2
- package/dist/driver.mjs +1 -1
- package/dist/error-mapping-TxJxI_Il.mjs +2 -0
- package/dist/error-mapping-TxJxI_Il.mjs.map +1 -0
- package/dist/extension-Dgo4iRy3.mjs +2 -0
- package/dist/extension-Dgo4iRy3.mjs.map +1 -0
- package/dist/extension-Yd1Lt1V7.mjs +2 -0
- package/dist/extension-Yd1Lt1V7.mjs.map +1 -0
- package/dist/fs-estate-DsE8tYPI.d.mts +8 -0
- package/dist/fs-estate-v7EUeEiD.mjs +2 -0
- package/dist/fs-estate-v7EUeEiD.mjs.map +1 -0
- package/dist/geo-area-codec-CEekcqFE.mjs +2 -0
- package/dist/geo-area-codec-CEekcqFE.mjs.map +1 -0
- package/dist/geo-point-codec-BTDzc-ym.mjs +2 -0
- package/dist/geo-point-codec-BTDzc-ym.mjs.map +1 -0
- package/dist/hydration-C2kb7g6D.mjs +2 -0
- package/dist/hydration-C2kb7g6D.mjs.map +1 -0
- package/dist/identifiers-O_KYMfe6.mjs +2 -0
- package/dist/identifiers-O_KYMfe6.mjs.map +1 -0
- package/dist/index-B1Z7NeUy.d.mts +6182 -0
- package/dist/index-BQAPotX_.d.mts +468 -0
- package/dist/index.d.mts +6 -46
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/instrumentation.d.mts +2 -2
- package/dist/instrumentation.mjs +1 -1
- package/dist/libsql.d.mts +1 -2
- package/dist/libsql.mjs +1 -1
- package/dist/libsql.mjs.map +1 -1
- package/dist/migrations/storage/fs.d.mts +2 -0
- package/dist/migrations/storage/fs.mjs +1 -0
- package/dist/migrations-CRloZBED.mjs +2 -0
- package/dist/migrations-CRloZBED.mjs.map +1 -0
- package/dist/migrations.d.mts +617 -1243
- package/dist/migrations.mjs +1 -10
- package/dist/migrations.mjs.map +1 -1
- package/dist/mysql-adapter-BkzgEeT0.mjs +2 -0
- package/dist/mysql-adapter-BkzgEeT0.mjs.map +1 -0
- package/dist/mysql2.d.mts +1 -2
- package/dist/mysql2.mjs +1 -1
- package/dist/mysql2.mjs.map +1 -1
- package/dist/native-types-UAbMZ16d.mjs +2 -0
- package/dist/native-types-UAbMZ16d.mjs.map +1 -0
- package/dist/neon-http.d.mts +1 -2
- package/dist/neon-http.mjs +1 -1
- package/dist/neon-http.mjs.map +1 -1
- package/dist/normalized-result-DXt6rKPa.mjs +2 -0
- package/dist/normalized-result-DXt6rKPa.mjs.map +1 -0
- package/dist/pg.d.mts +1 -2
- package/dist/pg.mjs +1 -1
- package/dist/pg.mjs.map +1 -1
- package/dist/pglite.d.mts +1 -2
- package/dist/pglite.mjs +1 -1
- package/dist/pglite.mjs.map +1 -1
- package/dist/physical-CJPPHDgl.mjs +2 -0
- package/dist/physical-CJPPHDgl.mjs.map +1 -0
- package/dist/planetscale.d.mts +1 -2
- package/dist/planetscale.mjs +1 -1
- package/dist/planetscale.mjs.map +1 -1
- package/dist/postgres-adapter-PPkSyWY3.mjs +2 -0
- package/dist/postgres-adapter-PPkSyWY3.mjs.map +1 -0
- package/dist/postgres-result-DJS3wvIm.mjs +2 -0
- package/dist/postgres-result-DJS3wvIm.mjs.map +1 -0
- package/dist/postgres.d.mts +1 -2
- package/dist/postgres.mjs +1 -1
- package/dist/postgres.mjs.map +1 -1
- package/dist/provider-limits-BFNR7ect.mjs +2 -0
- package/dist/provider-limits-BFNR7ect.mjs.map +1 -0
- package/dist/query-CRk65A10.mjs +2 -0
- package/dist/query-CRk65A10.mjs.map +1 -0
- package/dist/result-parsing-Cz_70EEo.mjs +2 -0
- package/dist/result-parsing-Cz_70EEo.mjs.map +1 -0
- package/dist/result-shape-C6DTrvE7.mjs +2 -0
- package/dist/result-shape-C6DTrvE7.mjs.map +1 -0
- package/dist/scalar-BHqCUxvI.mjs +3 -0
- package/dist/scalar-BHqCUxvI.mjs.map +1 -0
- package/dist/schema/json.d.mts +402 -0
- package/dist/schema/json.mjs +2 -0
- package/dist/schema/json.mjs.map +1 -0
- package/dist/schema-B5AlBiMF.mjs +2 -0
- package/dist/schema-B5AlBiMF.mjs.map +1 -0
- package/dist/schema-introspection-CvcX4eiL.mjs +6 -0
- package/dist/schema-introspection-CvcX4eiL.mjs.map +1 -0
- package/dist/schema-introspection-DX2khdQD.d.mts +28 -0
- package/dist/schema.d.mts +5 -293
- package/dist/schema.mjs +1 -2
- package/dist/sql-CWQw6DuO.d.mts +79 -0
- package/dist/sql-m8LT-phW.mjs +2 -0
- package/dist/sql-m8LT-phW.mjs.map +1 -0
- package/dist/sql-statement-tokens-D-69HPb3.mjs +3 -0
- package/dist/sql-statement-tokens-D-69HPb3.mjs.map +1 -0
- package/dist/sql.d.mts +2 -0
- package/dist/sql.mjs +1 -0
- package/dist/sqlite-adapter-5A1l0zRR.mjs +2 -0
- package/dist/sqlite-adapter-5A1l0zRR.mjs.map +1 -0
- package/dist/sqlite-utils-B-ZXbPld.mjs +2 -0
- package/dist/sqlite-utils-B-ZXbPld.mjs.map +1 -0
- package/dist/sqlite3.d.mts +1 -2
- package/dist/sqlite3.mjs +1 -1
- package/dist/sqlite3.mjs.map +1 -1
- package/dist/standard-sql-C9_gwkkx.mjs +6 -0
- package/dist/standard-sql-C9_gwkkx.mjs.map +1 -0
- package/dist/string-CampokWL.d.mts +7359 -0
- package/dist/suppressed-failure-BfDwdVMf.mjs +2 -0
- package/dist/suppressed-failure-BfDwdVMf.mjs.map +1 -0
- package/dist/to-many-DAZulS0R.mjs +2 -0
- package/dist/to-many-DAZulS0R.mjs.map +1 -0
- package/dist/transaction-D_cuO0Xf.mjs +2 -0
- package/dist/transaction-D_cuO0Xf.mjs.map +1 -0
- package/dist/transaction-operation-cpNxZs6g.mjs +2 -0
- package/dist/transaction-operation-cpNxZs6g.mjs.map +1 -0
- package/dist/types-Cf86fj4l.mjs +2 -0
- package/dist/types-Cf86fj4l.mjs.map +1 -0
- package/dist/utils-CGDt90z6.mjs +33 -0
- package/dist/utils-CGDt90z6.mjs.map +1 -0
- package/dist/v-DdH9EVw3.mjs +2 -0
- package/dist/v-DdH9EVw3.mjs.map +1 -0
- package/dist/validation-CCzz_0rK.mjs +2 -0
- package/dist/validation-CCzz_0rK.mjs.map +1 -0
- package/dist/validation-DTF9uqJ7.mjs +2 -0
- package/dist/validation-DTF9uqJ7.mjs.map +1 -0
- package/dist/validation.d.mts +2 -2
- package/dist/validation.mjs +1 -1
- package/dist/validator-uxmHWfxg.mjs +2 -0
- package/dist/validator-uxmHWfxg.mjs.map +1 -0
- package/dist/value-guards-CSMKqF92.mjs +2 -0
- package/dist/value-guards-CSMKqF92.mjs.map +1 -0
- package/dist/version-BPl6hw4y.mjs +2 -0
- package/dist/version-BPl6hw4y.mjs.map +1 -0
- package/package.json +119 -41
- package/dist/client-CgdtiDGV.mjs +0 -2
- package/dist/client-CgdtiDGV.mjs.map +0 -1
- package/dist/cloudflare-kv-DauXhtnT.d.mts +0 -1110
- package/dist/d1-http.d.mts +0 -3
- package/dist/d1-http.mjs +0 -2
- package/dist/d1-http.mjs.map +0 -1
- package/dist/driver-B_vBzQ6A.mjs +0 -2
- package/dist/driver-B_vBzQ6A.mjs.map +0 -1
- package/dist/driver-Cj1EbciY.mjs +0 -2
- package/dist/driver-Cj1EbciY.mjs.map +0 -1
- package/dist/errors-DvcqIdEo.mjs +0 -2
- package/dist/errors-DvcqIdEo.mjs.map +0 -1
- package/dist/helper-cDCDjRAD.d.mts +0 -3020
- package/dist/helpers-WNr9B-2U.mjs +0 -2
- package/dist/helpers-WNr9B-2U.mjs.map +0 -1
- package/dist/hydration-CFnwc7j6.mjs +0 -2
- package/dist/hydration-CFnwc7j6.mjs.map +0 -1
- package/dist/index-3sdVKfeG.d.mts +0 -1447
- package/dist/index-BGmpst1h.d.mts +0 -2158
- package/dist/mysql-adapter-0catKeCI.mjs +0 -6
- package/dist/mysql-adapter-0catKeCI.mjs.map +0 -1
- package/dist/mysql-utils-BPw9qhac.mjs +0 -2
- package/dist/mysql-utils-BPw9qhac.mjs.map +0 -1
- package/dist/native-types-BwICkVjz.mjs +0 -2
- package/dist/native-types-BwICkVjz.mjs.map +0 -1
- package/dist/pending-operation-CkzYTpi4.mjs +0 -2
- package/dist/pending-operation-CkzYTpi4.mjs.map +0 -1
- package/dist/postgres-adapter-Blzqj1bl.mjs +0 -6
- package/dist/postgres-adapter-Blzqj1bl.mjs.map +0 -1
- package/dist/push-qZreXYkb.mjs +0 -252
- package/dist/push-qZreXYkb.mjs.map +0 -1
- package/dist/result-parsing-FNQbuHvC.mjs +0 -2
- package/dist/result-parsing-FNQbuHvC.mjs.map +0 -1
- package/dist/schema-DeAJZocc.mjs +0 -2
- package/dist/schema-DeAJZocc.mjs.map +0 -1
- package/dist/schema.mjs.map +0 -1
- package/dist/spans-CJt5UgbJ.mjs +0 -2
- package/dist/spans-CJt5UgbJ.mjs.map +0 -1
- package/dist/sqlite-adapter-5Em_-oGU.mjs +0 -6
- package/dist/sqlite-adapter-5Em_-oGU.mjs.map +0 -1
- package/dist/sqlite-utils-BW7elKTz.mjs +0 -2
- package/dist/sqlite-utils-BW7elKTz.mjs.map +0 -1
- package/dist/tracer-CGzIAsj8.mjs +0 -2
- package/dist/tracer-CGzIAsj8.mjs.map +0 -1
- package/dist/validation-RtU-wu4N.mjs +0 -2
- package/dist/validation-RtU-wu4N.mjs.map +0 -1
- package/dist/validator-DpJsJcd7.mjs +0 -3
- package/dist/validator-DpJsJcd7.mjs.map +0 -1
- package/readme/README.md +0 -69
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Arnaud
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,32 +2,91 @@
|
|
|
2
2
|
|
|
3
3
|
Type-safe TypeScript ORM with **zero code generation**. Types are inferred from schema definitions at compile time—no `prisma generate` needed.
|
|
4
4
|
|
|
5
|
+
## V1 release candidate
|
|
6
|
+
|
|
7
|
+
This source prepares `1.0.0-rc.1`; it does not mean the candidate is published.
|
|
8
|
+
V1 includes breaking changes. Read the [upgrade guide](docs/content/docs/getting-started/upgrading-to-v1.mdx)
|
|
9
|
+
and [changelog](CHANGELOG.md) before migrating. Node.js 22 or newer and
|
|
10
|
+
TypeScript 5.8 or newer are the supported Node/TypeScript floors. The docs site
|
|
11
|
+
has its own Node.js requirement.
|
|
12
|
+
|
|
13
|
+
The [driver guide](docs/content/docs/drivers/index.mdx) distinguishes local
|
|
14
|
+
qualification from hosted preview limits. Publication follows [RELEASING.md](RELEASING.md);
|
|
15
|
+
stable V1 is not released by this preparation step.
|
|
16
|
+
|
|
5
17
|
## Key Features
|
|
6
18
|
|
|
7
19
|
| Feature | Description |
|
|
8
20
|
|---------|-------------|
|
|
9
21
|
| **Zero Codegen** | Types flow from schema → query → result via TypeScript inference |
|
|
10
22
|
| **Standard Schema V1** | Interoperable with Zod, Valibot, ArkType for validation |
|
|
11
|
-
| **Prisma-
|
|
23
|
+
| **Prisma-inspired API** | Familiar `findMany`, `create`, `update` operations with `where`, `include`, `select` |
|
|
12
24
|
| **Multi-Database** | PostgreSQL, MySQL, SQLite from one codebase via adapter pattern |
|
|
13
25
|
| **Chainable Schema** | `s.string().nullable().unique()` with immutable state tracking |
|
|
14
26
|
|
|
27
|
+
## Prisma Compatibility Snapshot
|
|
28
|
+
|
|
29
|
+
VibORM is Prisma-inspired, not a full Prisma clone. The matrix below compares the normal Prisma Client relational CRUD/query surface with VibORM's current documented contract. `Supported` means the input works for the documented surface or rejects before query generation; it does not mean every Prisma preview, provider-specific, or unsafe API exists.
|
|
30
|
+
|
|
31
|
+
Detailed contract: [client compatibility](docs/content/docs/client/compatibility.mdx) and [Prisma parity contract](docs/architecture/prisma-parity-contract.md). Prisma baseline: [CRUD](https://www.prisma.io/docs/orm/prisma-client/queries/crud) and [aggregation/grouping](https://www.prisma.io/docs/orm/prisma-client/queries/aggregation-grouping-summarizing).
|
|
32
|
+
|
|
33
|
+
Status legend:
|
|
34
|
+
|
|
35
|
+
| Status | Meaning |
|
|
36
|
+
|--------|---------|
|
|
37
|
+
| `Supported` | Same core shape as Prisma for the documented relational SQL surface |
|
|
38
|
+
| `Subset` | Prisma supports more shapes; VibORM supports a smaller fail-closed subset |
|
|
39
|
+
| `Different` | Intentional VibORM API decision |
|
|
40
|
+
| `Unsupported` | Not part of the current public contract |
|
|
41
|
+
|
|
42
|
+
### Basic CRUD
|
|
43
|
+
|
|
44
|
+
| Area | Prisma Client | VibORM | Status |
|
|
45
|
+
|------|---------------|--------|--------|
|
|
46
|
+
| Single-record reads | `findUnique`, `findUniqueOrThrow`, `findFirst`, `findFirstOrThrow` with `where`, `orderBy`, `select`, `include` | Same core operations; unique reads require a real unique discriminator (which may be narrowed by non-unique scalar filters and `AND`/`OR`/`NOT`, Prisma ≥4.5) and or-throw variants throw `NotFoundError` | `Supported` |
|
|
47
|
+
| Multi-record reads | `findMany` with filters, ordering, pagination, `distinct`, `select`, `include` | Supports scalar/relation filters, scalar and supported relation ordering, cursor/offset pagination, negative `take`, `distinct`, `select`, `include` | `Supported` |
|
|
48
|
+
| Create one | `create` with scalar data, nested writes, `select`, `include` | Supports scalar data and documented nested writes; unsupported nested write keys reject before parent mutation | `Supported` |
|
|
49
|
+
| Create many | `createMany` returns `{ count }`; `createManyAndReturn` is a separate provider-specific method | `createMany` returns `{ count }`, or the inserted rows when the call carries a `select` (implicit returning — there is no `createManyAndReturn` method); `skipDuplicates` skips duplicate-key conflicts only, and combining it with `select` needs a `RETURNING` dialect | `Different` |
|
|
50
|
+
| Update one | `update` by unique selector; returns updated row; supports atomic numeric ops and nested writes | Requires unique `where`; throws on missing row; supports scalar updates, atomic numeric ops, and documented nested writes | `Supported` |
|
|
51
|
+
| Update many | `updateMany` returns `{ count }`; `updateManyAndReturn` is a separate provider-specific method | `updateMany` returns `{ count }`, or the updated rows when the call carries a `select` (implicit returning — there is no `updateManyAndReturn` method) | `Different` |
|
|
52
|
+
| Upsert | `upsert` with unique `where`, `create`, `update`; returns row | Same core shape; supported nested writes are allowed in covered branches | `Supported` |
|
|
53
|
+
| Delete | `delete` by unique selector returns deleted row; `deleteMany` returns `{ count }` | Same core shape; `delete` throws on missing row and non-returning dialects fetch before delete where safe. `deleteMany` additionally returns the deleted rows when the call carries a `select` — a superset Prisma has no form of | `Different` |
|
|
54
|
+
|
|
55
|
+
### Advanced Queries
|
|
56
|
+
|
|
57
|
+
| Area | Prisma Client | VibORM | Status |
|
|
58
|
+
|------|---------------|--------|--------|
|
|
59
|
+
| Scalar filters | `where` with scalar operators and `AND`/`OR`/`NOT` | Supports documented scalar operators and logical filters; unknown/unsupported operators reject before SQL generation | `Supported` |
|
|
60
|
+
| Relation filters | To-one `is`/`isNot`; to-many `some`/`every`/`none` | Same documented relation filter surface, including nested relation filters where covered | `Supported` |
|
|
61
|
+
| Projection | `select`, `include`, nested selection, relation `_count` | Supports `select`, `include`, nested selection, and relation `_count`; top-level `select` + `include` rejects | `Supported` |
|
|
62
|
+
| Sorting | Scalar-field `orderBy`, to-one relation order by scalar fields, to-many relation `_count` order, aggregate/group ordering, provider-specific relevance ordering | Supports scalar-field order, to-one relation order by scalar fields, to-many relation `_count`, and documented aggregate/group ordering; unsupported to-many scalar-field order and `_relevance` reject | `Subset` |
|
|
63
|
+
| Pagination | `cursor`, `skip`, `take`, negative `take` on list reads | Supports cursor pagination, `skip`, `take`, negative `take`; cursor uses `whereUnique` | `Supported` |
|
|
64
|
+
| `distinct` | `findMany({ distinct })` with Prisma's in-memory distinct semantics | Supports scalar-field `distinct`; relation fields reject; SQL strategy is adapter-owned | `Subset` |
|
|
65
|
+
| `count` | Count records and selected non-null fields; supports filters and pagination-style args | Supports `where`, selected count fields, and `orderBy`/`cursor`/`take`/`skip` input-window pagination | `Supported` |
|
|
66
|
+
| `aggregate` | `_count`, `_avg`, `_sum`, `_min`, `_max` with `where`, order, pagination | Same documented aggregate selectors and input-window pagination; invalid/empty aggregate selection rejects | `Supported` |
|
|
67
|
+
| `groupBy` | `by`, aggregates, `having`, `orderBy`, `skip`, `take`; no `select` | Supports scalar `by`, aggregate selections, `having`, order, `skip`, `take`; invalid group/having shapes reject | `Supported` |
|
|
68
|
+
| Nested writes | Broad nested create/connect/update/delete/upsert matrix | Supports `create`, `createMany`, `connect`, `connectOrCreate`, nullable/correlated `disconnect`, `delete`, `set`, `update`, to-many `updateMany`, `upsert`, and to-many `deleteMany`; callback-transaction and atomic-batch paths propagate generated and updated primary keys where the shape is safe; create-branch update/delete-like shapes are excluded | `Subset` |
|
|
69
|
+
| Transactions | Callback and array `$transaction` | Callback transactions on transactional drivers; batch mode on transactional or atomic-batch drivers | `Supported` |
|
|
70
|
+
| `omit` | Prisma supports per-query and client-level `omit` | Supports per-query `omit` plus the official `defaultOmit()` client extension, and lets query-level `omit` subtract from `select`; the local `{ field: false }` override of that default also works. VibORM additionally has a schema-level `.omit()` that is a hard exclusion no query can undo | `Different` |
|
|
71
|
+
| Raw SQL | Prisma tagged `$queryRaw`/`$executeRaw` plus unsafe variants | Tagged `$queryRaw` (returns `T[]`) / `$executeRaw` (returns the affected count) plus `$queryRawUnsafe`/`$executeRawUnsafe`; lazy raw operations mix with model operations in array transactions and also run on the interactive transaction client. `sql`/`join`/`empty`/`raw` are exported from the package root | `Supported` |
|
|
72
|
+
| Existence check | Emulated with `count`/`findFirst` in Prisma | `exist({ where })` is a VibORM extension returning `boolean`; no `exists` alias | `Different` |
|
|
73
|
+
|
|
15
74
|
```typescript
|
|
16
75
|
import { s } from "viborm";
|
|
17
|
-
import { createClient } from "viborm/
|
|
76
|
+
import { createClient } from "viborm/pglite";
|
|
18
77
|
|
|
19
78
|
// Schema carries type information
|
|
20
79
|
const user = s.model({
|
|
21
80
|
id: s.string().id().ulid(),
|
|
22
81
|
email: s.string().unique(),
|
|
23
|
-
posts: s.
|
|
82
|
+
posts: s.toMany(() => post),
|
|
24
83
|
});
|
|
25
84
|
|
|
26
85
|
const post = s.model({
|
|
27
86
|
id: s.string().id().ulid(),
|
|
28
87
|
title: s.string(),
|
|
29
88
|
authorId: s.string(),
|
|
30
|
-
author: s.
|
|
89
|
+
author: s.toOne(() => user).fields("authorId").references("id"),
|
|
31
90
|
});
|
|
32
91
|
|
|
33
92
|
// Fully typed queries - no codegen!
|
|
@@ -62,7 +121,7 @@ export const user = s.model({
|
|
|
62
121
|
name: s.string(),
|
|
63
122
|
email: s.string().unique(),
|
|
64
123
|
createdAt: s.dateTime().now(),
|
|
65
|
-
posts: s.
|
|
124
|
+
posts: s.toMany(() => post),
|
|
66
125
|
});
|
|
67
126
|
|
|
68
127
|
export const post = s.model({
|
|
@@ -70,7 +129,7 @@ export const post = s.model({
|
|
|
70
129
|
title: s.string(),
|
|
71
130
|
content: s.string().nullable(),
|
|
72
131
|
authorId: s.string(),
|
|
73
|
-
author: s.
|
|
132
|
+
author: s.toOne(() => user).fields("authorId").references("id"),
|
|
74
133
|
});
|
|
75
134
|
|
|
76
135
|
export const schema = { user, post };
|
|
@@ -80,8 +139,8 @@ export const schema = { user, post };
|
|
|
80
139
|
|
|
81
140
|
```typescript
|
|
82
141
|
// db.ts
|
|
83
|
-
import { createClient } from "viborm/
|
|
84
|
-
import {
|
|
142
|
+
import { createClient } from "viborm/pglite";
|
|
143
|
+
import { createMigrationClient } from "viborm/migrations";
|
|
85
144
|
import { schema } from "./schema";
|
|
86
145
|
|
|
87
146
|
export const orm = createClient({
|
|
@@ -89,8 +148,9 @@ export const orm = createClient({
|
|
|
89
148
|
dataDir: ".pglite", // Persists to filesystem (omit for in-memory)
|
|
90
149
|
});
|
|
91
150
|
|
|
92
|
-
// Push
|
|
93
|
-
|
|
151
|
+
// History-free live sync. Push never writes estate storage or the marker.
|
|
152
|
+
const migrations = createMigrationClient(orm);
|
|
153
|
+
await migrations.push();
|
|
94
154
|
```
|
|
95
155
|
|
|
96
156
|
### 4. Query
|
|
@@ -127,7 +187,7 @@ await orm.user.delete({
|
|
|
127
187
|
|
|
128
188
|
## Transactions
|
|
129
189
|
|
|
130
|
-
VibORM supports transactions with
|
|
190
|
+
VibORM supports callback transactions on drivers with real transaction support, and batch mode on drivers with transactions or native atomic batch support.
|
|
131
191
|
|
|
132
192
|
### Callback Mode (Dynamic)
|
|
133
193
|
|
|
@@ -136,11 +196,11 @@ const result = await orm.$transaction(async (tx) => {
|
|
|
136
196
|
const user = await tx.user.create({
|
|
137
197
|
data: { name: "Alice", email: "alice@example.com" }
|
|
138
198
|
});
|
|
139
|
-
|
|
199
|
+
|
|
140
200
|
await tx.post.create({
|
|
141
201
|
data: { title: "First Post", authorId: user.id }
|
|
142
202
|
});
|
|
143
|
-
|
|
203
|
+
|
|
144
204
|
return user;
|
|
145
205
|
});
|
|
146
206
|
// If any operation fails, all changes are rolled back
|
|
@@ -153,25 +213,58 @@ const [user, post] = await orm.$transaction([
|
|
|
153
213
|
orm.user.create({ data: { name: "Bob", email: "bob@example.com" } }),
|
|
154
214
|
orm.post.create({ data: { title: "Hello", authorId: "user-id" } })
|
|
155
215
|
]);
|
|
156
|
-
//
|
|
216
|
+
// Executes atomically when the driver supports transactions or native batch
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Client Extensions
|
|
222
|
+
|
|
223
|
+
`$extends()` returns an immutable derived client. Extensions have six distinct
|
|
224
|
+
capabilities: `request`, `query`, `statement`, `observe`, `client`, and `model`.
|
|
225
|
+
See the [extension guide](docs/content/docs/extensions/index.mdx) for their
|
|
226
|
+
authority and exact lifecycle.
|
|
227
|
+
|
|
228
|
+
Internally, `src/extensions/` is the single generic definition, chain,
|
|
229
|
+
method-binding, admission, and capability-runner boundary. The official
|
|
230
|
+
implementations remain with their domains in `src/cache/extension.ts`,
|
|
231
|
+
`src/instrumentation/extension.ts`, and
|
|
232
|
+
`src/client/default-omit-extension.ts`; client, query-engine, and drivers only
|
|
233
|
+
retain the lifecycle trigger points whose facts they create.
|
|
234
|
+
|
|
235
|
+
Client default projection is also an extension:
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
import { defaultOmit } from "viborm/client";
|
|
239
|
+
|
|
240
|
+
const publicOrm = orm.$extends(
|
|
241
|
+
defaultOmit<typeof schema>()({
|
|
242
|
+
user: { passwordHash: true },
|
|
243
|
+
})
|
|
244
|
+
);
|
|
157
245
|
```
|
|
158
246
|
|
|
247
|
+
`defaultOmit()` is a presentation default, not authorization. VibORM does not
|
|
248
|
+
currently ship an RBAC helper; complete policy must account for the full query
|
|
249
|
+
and mutation graph.
|
|
250
|
+
|
|
159
251
|
---
|
|
160
252
|
|
|
161
253
|
## Caching
|
|
162
254
|
|
|
163
|
-
VibORM
|
|
255
|
+
VibORM provides query caching as an official client extension, with TTL and
|
|
256
|
+
stale-while-revalidate (SWR) support.
|
|
164
257
|
|
|
165
258
|
### Setup
|
|
166
259
|
|
|
167
260
|
```typescript
|
|
168
|
-
import { createClient } from "viborm/
|
|
169
|
-
import {
|
|
261
|
+
import { createClient } from "viborm/pglite";
|
|
262
|
+
import { cache } from "viborm/cache";
|
|
263
|
+
import { MemoryCache } from "viborm/cache/memory";
|
|
170
264
|
|
|
171
|
-
const orm = createClient({
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
});
|
|
265
|
+
const orm = createClient({ schema }).$extends(
|
|
266
|
+
cache({ driver: new MemoryCache() })
|
|
267
|
+
);
|
|
175
268
|
```
|
|
176
269
|
|
|
177
270
|
### Basic Caching
|
|
@@ -185,6 +278,11 @@ const posts = await orm.$withCache({ ttl: "1 hour" }).post.findMany();
|
|
|
185
278
|
|
|
186
279
|
// TTL in milliseconds
|
|
187
280
|
const recent = await orm.$withCache({ ttl: 30000 }).user.findMany();
|
|
281
|
+
|
|
282
|
+
// A custom key is a suffix of the canonical model/operation/argument key.
|
|
283
|
+
const active = await orm
|
|
284
|
+
.$withCache({ key: "active-users" })
|
|
285
|
+
.user.findMany({ where: { active: true } });
|
|
188
286
|
```
|
|
189
287
|
|
|
190
288
|
### Stale-While-Revalidate (SWR)
|
|
@@ -212,6 +310,12 @@ await orm.user.create({
|
|
|
212
310
|
await orm.$invalidate("user:*", "post:findMany:*");
|
|
213
311
|
```
|
|
214
312
|
|
|
313
|
+
Cached values are portable snapshots. Every hit materializes a fresh detached
|
|
314
|
+
result graph, so one caller cannot mutate a later caller's value. Official
|
|
315
|
+
cache reads bypass caching inside callback transactions, array transactions,
|
|
316
|
+
raw operations, and clients with statement transforms. Mutation invalidation
|
|
317
|
+
still follows the transaction's write-outcome boundary.
|
|
318
|
+
|
|
215
319
|
### Cache Drivers
|
|
216
320
|
|
|
217
321
|
| Driver | Use Case |
|
|
@@ -228,13 +332,12 @@ VibORM supports OpenTelemetry tracing and structured logging.
|
|
|
228
332
|
### Setup
|
|
229
333
|
|
|
230
334
|
```typescript
|
|
231
|
-
import { createClient } from "viborm/
|
|
335
|
+
import { createClient } from "viborm/pglite";
|
|
336
|
+
import { instrumentation } from "viborm/instrumentation";
|
|
232
337
|
|
|
233
|
-
const orm = createClient({
|
|
234
|
-
|
|
235
|
-
instrumentation: {
|
|
338
|
+
const orm = createClient({ schema }).$extends(
|
|
339
|
+
instrumentation({
|
|
236
340
|
tracing: {
|
|
237
|
-
enabled: true,
|
|
238
341
|
// Optional: customize tracer
|
|
239
342
|
},
|
|
240
343
|
logging: {
|
|
@@ -242,23 +345,26 @@ const orm = createClient({
|
|
|
242
345
|
cache: true, // Log cache hits/misses
|
|
243
346
|
warning: true, // Log warnings
|
|
244
347
|
error: true, // Log errors
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
348
|
+
},
|
|
349
|
+
})
|
|
350
|
+
);
|
|
248
351
|
```
|
|
249
352
|
|
|
250
353
|
### Serverless Support
|
|
251
354
|
|
|
252
|
-
For serverless
|
|
355
|
+
For serverless caching, provide `waitUntil` to the cache extension so the
|
|
356
|
+
request lifetime owns background revalidation:
|
|
253
357
|
|
|
254
358
|
```typescript
|
|
255
359
|
// Cloudflare Workers
|
|
256
360
|
export default {
|
|
257
361
|
async fetch(request, env, ctx) {
|
|
258
|
-
const orm = createClient({
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
362
|
+
const orm = createClient({ schema }).$extends(
|
|
363
|
+
cache({
|
|
364
|
+
driver: new CloudflareKVCache(env.CACHE),
|
|
365
|
+
waitUntil: ctx.waitUntil.bind(ctx),
|
|
366
|
+
})
|
|
367
|
+
);
|
|
262
368
|
// ...
|
|
263
369
|
}
|
|
264
370
|
};
|
|
@@ -266,14 +372,14 @@ export default {
|
|
|
266
372
|
|
|
267
373
|
---
|
|
268
374
|
|
|
269
|
-
##
|
|
375
|
+
## Scalar Types
|
|
270
376
|
|
|
271
377
|
| Type | Description | Example |
|
|
272
378
|
|------|-------------|---------|
|
|
273
|
-
| `string()` | Text
|
|
379
|
+
| `string()` | Text scalars | `s.string().unique()` |
|
|
274
380
|
| `int()` | 32-bit integers | `s.int().default(0)` |
|
|
275
|
-
| `
|
|
276
|
-
| `decimal()` |
|
|
381
|
+
| `number()` | Approximate number | `s.number()` |
|
|
382
|
+
| `decimal({ precision, scale })` | Exact fixed decimals (`Decimal` results) | `s.decimal({ precision: 10, scale: 2 })` |
|
|
277
383
|
| `bigInt()` | 64-bit integers | `s.bigInt()` |
|
|
278
384
|
| `boolean()` | Boolean values | `s.boolean().default(false)` |
|
|
279
385
|
| `dateTime()` | Date and time | `s.dateTime().now()` |
|
|
@@ -283,20 +389,58 @@ export default {
|
|
|
283
389
|
| `enum()` | Enumerated values | `s.enum(["ADMIN", "USER"])` |
|
|
284
390
|
| `blob()` | Binary data (Uint8Array) | `s.blob()` |
|
|
285
391
|
| `vector()` | Vector embeddings (pgvector) | `s.vector(1536)` |
|
|
286
|
-
| `point()` | PostGIS point type | `
|
|
392
|
+
| `point()` | PostGIS point type | `import { point } from "viborm"` (not exposed on `s`) |
|
|
287
393
|
|
|
288
394
|
### Auto-generation
|
|
289
395
|
|
|
290
396
|
```typescript
|
|
291
397
|
s.string().id().uuid() // UUID v4
|
|
398
|
+
s.string().id().uuidv7() // UUID v7 (time-sortable)
|
|
292
399
|
s.string().id().ulid() // ULID
|
|
400
|
+
s.string().id().ksuid() // KSUID (time-sortable)
|
|
293
401
|
s.string().id().nanoid() // NanoID
|
|
294
|
-
s.string().id().cuid() //
|
|
402
|
+
s.string().id().cuid() // CUID2
|
|
295
403
|
s.int().id().increment() // Auto-increment
|
|
296
404
|
s.dateTime().now() // Current timestamp on create
|
|
297
405
|
s.dateTime().updatedAt() // Update timestamp on every update
|
|
298
406
|
```
|
|
299
407
|
|
|
408
|
+
Every one of those is generated by VibORM itself, from `crypto.getRandomValues`.
|
|
409
|
+
Naming a format is also a promise about the field's values: it is validated, and
|
|
410
|
+
`uuid`, `uuidv7`, `ulid` and `ksuid` are stored as the identifier rather than as
|
|
411
|
+
its text. See [String scalars](https://viborm.dev/docs/schema/scalars/string)
|
|
412
|
+
and, for a table that already holds text,
|
|
413
|
+
[Converting identifier columns](https://viborm.dev/docs/migration/identifiers).
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## Runtime Dependencies
|
|
418
|
+
|
|
419
|
+
VibORM installs one runtime dependency for the core package, and one CLI-only
|
|
420
|
+
pair. No entry the client bundle reaches imports any of them; the CLI pair is
|
|
421
|
+
imported by `dist/cli.mjs` and by nothing else:
|
|
422
|
+
|
|
423
|
+
| Package | Why it is a dependency |
|
|
424
|
+
|---|---|
|
|
425
|
+
| `@standard-schema/spec` | Types only — the interface every validator here speaks |
|
|
426
|
+
| `@clack/prompts`, `commander` | The CLI only, imported by `dist/cli.mjs` |
|
|
427
|
+
|
|
428
|
+
There is no value-type dependency and no hash dependency: the exact decimal and
|
|
429
|
+
SHA3-512 are VibORM's own, and the `v.*` validation primitives always were.
|
|
430
|
+
|
|
431
|
+
What left the graph, and what replaced it:
|
|
432
|
+
|
|
433
|
+
| Removed | Replaced by |
|
|
434
|
+
|---|---|
|
|
435
|
+
| `decimal.js` | VibORM's own `Decimal` over a `BigInt` coefficient — a deliberate API change, documented in the changelog |
|
|
436
|
+
| `@paralleldrive/cuid2` | VibORM's own CUID2, byte-identical to it (proven by a differential test against the pinned package, which remains a devDependency for exactly that test) |
|
|
437
|
+
| `nanoid` | VibORM's own NanoID |
|
|
438
|
+
| `ulidx` | VibORM's own ULID, with unbiased randomness and the same monotonicity |
|
|
439
|
+
| `@noble/hashes` | VibORM's own SHA3-512, proven byte-identical to it over the NIST known-answer vectors and 10,000 random messages (the package remains a devDependency for exactly that test) |
|
|
440
|
+
|
|
441
|
+
Database drivers (`pg`, `mysql2`, `better-sqlite3`, …) are never dependencies:
|
|
442
|
+
you install the one you use.
|
|
443
|
+
|
|
300
444
|
---
|
|
301
445
|
|
|
302
446
|
## Supported Drivers
|
|
@@ -324,14 +468,13 @@ s.dateTime().updatedAt() // Update timestamp on every update
|
|
|
324
468
|
| `sqlite3` | `better-sqlite3` | Node.js (synchronous) |
|
|
325
469
|
| `libsql` | `@libsql/client` | Turso / LibSQL |
|
|
326
470
|
| `d1` | Cloudflare binding | Cloudflare D1 (Workers) |
|
|
327
|
-
| `d1-http` | Cloudflare API | Cloudflare D1 (HTTP) |
|
|
328
471
|
| `bun-sqlite` | Built-in | Bun runtime |
|
|
329
472
|
|
|
330
473
|
---
|
|
331
474
|
|
|
332
475
|
## Repository Structure
|
|
333
476
|
|
|
334
|
-
VibORM uses a **
|
|
477
|
+
VibORM uses a **12-layer architecture**. Each layer has an `AGENTS.md` with detailed documentation.
|
|
335
478
|
|
|
336
479
|
```
|
|
337
480
|
src/
|
|
@@ -339,9 +482,9 @@ src/
|
|
|
339
482
|
│ Branded types, set-theory optimization
|
|
340
483
|
│
|
|
341
484
|
├── schema/ L2-L5 Schema definition
|
|
342
|
-
│ ├──
|
|
485
|
+
│ ├── scalars/ Scalar types with State generic pattern
|
|
343
486
|
│ ├── model/ Model composition, query schemas
|
|
344
|
-
│ ├── relation/
|
|
487
|
+
│ ├── relation/ The two relation factories and their state
|
|
345
488
|
│ └── validation/ Definition-time schema validation
|
|
346
489
|
│
|
|
347
490
|
├── query-engine/ L6 Database-agnostic query building
|
|
@@ -351,13 +494,20 @@ src/
|
|
|
351
494
|
│ PostgreSQL, MySQL, SQLite dialect implementations
|
|
352
495
|
│
|
|
353
496
|
├── drivers/ L8 Connection management, query execution
|
|
354
|
-
│
|
|
355
|
-
│ mysql2, planetscale, sqlite3, libsql, d1,
|
|
497
|
+
│ 11 drivers: pglite, pg, postgres, neon-http, bun-sql,
|
|
498
|
+
│ mysql2, planetscale, sqlite3, libsql, d1, bun-sqlite
|
|
499
|
+
│
|
|
500
|
+
├── extensions/ Cross-cutting six-capability contracts, immutable chain,
|
|
501
|
+
│ method binding, runners, and array-admission latch
|
|
356
502
|
│
|
|
357
503
|
├── client/ L9 Type inference, ORM interface
|
|
358
504
|
│ Recursive proxy pattern, result types
|
|
359
505
|
│
|
|
360
|
-
|
|
506
|
+
├── cache/ L10 Query caching, invalidation, stale-while-revalidate
|
|
507
|
+
│
|
|
508
|
+
├── instrumentation/ L11 Tracing, structured logging, diagnostics
|
|
509
|
+
│
|
|
510
|
+
└── migrations/ L12 Authenticated estate, history-free push, DDL
|
|
361
511
|
```
|
|
362
512
|
|
|
363
513
|
### Key Architecture Rules
|
|
@@ -366,7 +516,7 @@ src/
|
|
|
366
516
|
|
|
367
517
|
2. **Natural Type Inference**: Never use type assertions (`as`). Types flow from schema → validation → client.
|
|
368
518
|
|
|
369
|
-
3. **Immutable State**: Every
|
|
519
|
+
3. **Immutable State**: Every scalar modifier returns a NEW instance. `s.string().nullable()` returns a new scalar, doesn't mutate.
|
|
370
520
|
|
|
371
521
|
4. **Lazy Evaluation**: Schemas are built on first access (`??=` pattern) and cached.
|
|
372
522
|
|
|
@@ -411,7 +561,7 @@ pnpm package:build # Build distributable with tsdown
|
|
|
411
561
|
import { ... } from "@schema"; // src/schema/
|
|
412
562
|
import { ... } from "@client"; // src/client/
|
|
413
563
|
import { ... } from "@validation"; // src/validation/
|
|
414
|
-
import { ... } from "@query-engine";
|
|
564
|
+
import { ... } from "@query-engine/*"; // direct src/query-engine/ owner
|
|
415
565
|
import { ... } from "@adapters"; // src/adapters/
|
|
416
566
|
import { ... } from "@drivers"; // src/drivers/
|
|
417
567
|
import { ... } from "@sql"; // src/sql/
|
|
@@ -439,7 +589,7 @@ When working with an AI assistant, point it to these files first.
|
|
|
439
589
|
|
|
440
590
|
| I want to... | Start here |
|
|
441
591
|
|--------------|------------|
|
|
442
|
-
| Add new
|
|
592
|
+
| Add new scalar type | `src/schema/scalars/AGENTS.md` |
|
|
443
593
|
| Add query operator | `src/query-engine/AGENTS.md` + `src/adapters/AGENTS.md` |
|
|
444
594
|
| Fix type inference bug | `src/client/AGENTS.md` → check upstream schemas |
|
|
445
595
|
| Add migration operation | `src/migrations/AGENTS.md` |
|
|
@@ -455,7 +605,7 @@ Tests mirror the `src/` structure:
|
|
|
455
605
|
```
|
|
456
606
|
tests/
|
|
457
607
|
├── validation/ 28 tests for v.* primitives
|
|
458
|
-
├──
|
|
608
|
+
├── scalars/ Schema generation per scalar type
|
|
459
609
|
├── model/ Query schemas (where, create, update, args)
|
|
460
610
|
│ ├── filter/ WHERE clause generation
|
|
461
611
|
│ ├── create/ CREATE input schemas
|
|
@@ -478,7 +628,7 @@ Most tests run against PGlite (in-memory PostgreSQL). Driver tests in `tests/dri
|
|
|
478
628
|
|---------|---------------|-----|
|
|
479
629
|
| Hardcoded SQL in query-engine | Breaks MySQL/SQLite | Use `ctx.adapter.*` methods |
|
|
480
630
|
| Type assertions (`as`) | Hides type mismatches | Let types flow naturally |
|
|
481
|
-
| Forgot
|
|
631
|
+
| Forgot Scalar union update | New scalar type invisible | Update `src/schema/scalars/base.ts` |
|
|
482
632
|
| Direct model reference in relation | ReferenceError at runtime | Use thunk `() => model` |
|
|
483
633
|
| Eager schema building | Performance (rebuilds every access) | Use `??=` lazy pattern |
|
|
484
634
|
| Mutation instead of new instance | Type/runtime desync | Return new instance from modifiers |
|
|
@@ -489,21 +639,23 @@ Most tests run against PGlite (in-memory PostgreSQL). Driver tests in `tests/dri
|
|
|
489
639
|
|
|
490
640
|
**Core features working:**
|
|
491
641
|
- All CRUD operations (create, read, update, delete, upsert)
|
|
492
|
-
- Relations (
|
|
493
|
-
-
|
|
642
|
+
- Relations: two factories, `s.toOne` and `s.toMany`, over one model or a map of named variants. Every ordinary cardinality cell (one-to-one, one-to-many, many-to-many) and both variant cardinalities are derived from the declared pair, each with direct and inverse read/write surfaces
|
|
643
|
+
- Supported nested writes (`create`, `createMany`, `connect`, `connectOrCreate`, `disconnect`, `delete`, `set`, `update`, `updateMany`, `upsert`, `deleteMany`) across callback-transaction and atomic-batch paths
|
|
494
644
|
- Select/include with typed results
|
|
495
|
-
-
|
|
496
|
-
-
|
|
645
|
+
- Recursive relation projections (`recurse` on a self-relation in `select`/`include`, `WITH RECURSIVE` underneath): implemented through the ordinary projection, executed locally on SQLite, PGlite, PostgreSQL and MySQL; hosted providers not yet qualified (`features-docs/recursive-query.md`)
|
|
646
|
+
- All scalar types (string, int, number, boolean, dateTime, json, enum, etc.)
|
|
647
|
+
- PostgreSQL, MySQL, and SQLite adapters, including authenticated estate migrations and history-free `push` where the provider lock/CAS is proven
|
|
497
648
|
- Query caching with TTL and SWR
|
|
498
|
-
- Transactions (callback and batch modes)
|
|
649
|
+
- Transactions (callback and batch modes), with Prisma's `{ isolationLevel, timeout, maxWait }` options honored or refused per driver — never ignored
|
|
499
650
|
- OpenTelemetry instrumentation
|
|
500
651
|
|
|
501
652
|
**Known limitations:**
|
|
502
|
-
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
-
|
|
506
|
-
-
|
|
653
|
+
- Full Prisma parity is not complete; VibORM is Prisma-inspired.
|
|
654
|
+
- Parent `create` and the create branch of parent `upsert` intentionally exclude update/delete-like nested operations.
|
|
655
|
+
- Impossible or unsafe primary-key dataflow shapes reject before mutation instead of partially applying nested writes.
|
|
656
|
+
- Raw queries are Prisma-shaped tagged templates; the pre-1.0 `$queryRaw(string, params?)` form still runs for one release behind a deprecation notice. Raw calls are lazy, promise-compatible operations that can mix with model operations in `$transaction([...])`.
|
|
657
|
+
- Transaction options are honored where the driver can honor them and refused with a typed `UnsupportedOperationError` (naming the option and the reason) where it cannot; see the per-driver table in the Transactions docs.
|
|
658
|
+
- Local nested-write conformance is proven on PGlite/Postgres-style and SQLite-family paths; hosted D1 binding and Neon HTTP need external runs before claiming hosted verification.
|
|
507
659
|
|
|
508
660
|
See `PENDING_WORK.md` for detailed tracking.
|
|
509
661
|
|
|
@@ -514,10 +666,10 @@ See `PENDING_WORK.md` for detailed tracking.
|
|
|
514
666
|
All internal state is accessed via `["~"]`:
|
|
515
667
|
|
|
516
668
|
```typescript
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
relation["~"].
|
|
669
|
+
scalar["~"].state // ScalarState - configuration object
|
|
670
|
+
scalar["~"].state.base // Base scalar schema
|
|
671
|
+
schemaRegistry.proxy.user.core.where // Operation schema for this model
|
|
672
|
+
relation["~"].state.getter // Thunk to target model
|
|
521
673
|
```
|
|
522
674
|
|
|
523
675
|
This keeps the public API clean and signals "internal" to developers.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=Symbol(`viborm.adapterInternals`);function t(t){return e in t}function n(t,n){Object.defineProperty(t,e,{configurable:!1,enumerable:!1,value:Object.freeze(n),writable:!1})}function r(n){if(!t(n))throw TypeError(`The database adapter must extend a VibORM dialect adapter.`);return n[e]}function i(e,t){return r(e).select(t)}export{r as n,n as r,i as t};
|
|
2
|
+
//# sourceMappingURL=adapter-internals-Dc9I8w9Y.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-internals-Dc9I8w9Y.mjs","names":[],"sources":["../src/adapters/adapter-internals.ts"],"sourcesContent":["import type { Sql } from \"@sql\";\nimport type { BatchReferenceSqlAdapter } from \"./adapter-core-types\";\nimport type { QueryParts } from \"./adapter-query-parts\";\nimport type { ConstraintIdentities } from \"./constraint-identity\";\nimport type { DatabaseAdapter } from \"./database-adapter\";\n\nexport type { QueryParts } from \"./adapter-query-parts\";\n\nconst ADAPTER_INTERNALS: unique symbol = Symbol(\"viborm.adapterInternals\");\n\ninterface AdapterInternals {\n readonly select: (parts: QueryParts) => Sql;\n readonly batchRefs: BatchReferenceSqlAdapter;\n readonly constraints: ConstraintIdentities;\n}\n\ninterface AdapterWithInternals extends DatabaseAdapter {\n readonly [ADAPTER_INTERNALS]: AdapterInternals;\n}\n\nfunction hasAdapterInternals(\n adapter: DatabaseAdapter\n): adapter is AdapterWithInternals {\n return ADAPTER_INTERNALS in adapter;\n}\n\n/** Install the one query-engine-only dialect seam on a concrete adapter. */\nexport function installAdapterInternals(\n adapter: DatabaseAdapter,\n internals: AdapterInternals\n): void {\n Object.defineProperty(adapter, ADAPTER_INTERNALS, {\n configurable: false,\n enumerable: false,\n value: Object.freeze(internals),\n writable: false,\n });\n}\n\n/** Read the internal seam installed by a stock dialect adapter. */\nexport function getAdapterInternals(\n adapter: DatabaseAdapter\n): AdapterInternals {\n if (!hasAdapterInternals(adapter)) {\n throw new TypeError(\n \"The database adapter must extend a VibORM dialect adapter.\"\n );\n }\n return adapter[ADAPTER_INTERNALS];\n}\n\n/** Assemble one query-engine SELECT without exposing its parts publicly. */\nexport function assembleAdapterSelect(\n adapter: DatabaseAdapter,\n parts: QueryParts\n): Sql {\n return getAdapterInternals(adapter).select(parts);\n}\n"],"mappings":"AAQA,MAAM,EAAmC,OAAO,0BAA0B,CAY1E,SAAS,EACP,EACiC,CACjC,OAAO,KAAqB,EAI9B,SAAgB,EACd,EACA,EACM,CACN,OAAO,eAAe,EAAS,EAAmB,CAChD,aAAc,GACd,WAAY,GACZ,MAAO,OAAO,OAAO,EAAU,CAC/B,SAAU,GACX,CAAC,CAIJ,SAAgB,EACd,EACkB,CAClB,GAAI,CAAC,EAAoB,EAAQ,CAC/B,MAAU,UACR,6DACD,CAEH,OAAO,EAAQ,GAIjB,SAAgB,EACd,EACA,EACK,CACL,OAAO,EAAoB,EAAQ,CAAC,OAAO,EAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-namespace-DEKd5hIN.mjs","names":[],"sources":["../src/adapters/adapter-namespace.ts"],"sourcesContent":["// The adapter's namespace fact, installed once.\n//\n// `readonly` is a compile-time claim, and query rendering, migrations, cache\n// scope and instrumentation all read this one object at execution time. The\n// property is therefore installed as an own, non-writable, non-configurable\n// value: hostile JavaScript that binds a cache scope and then rewrites the\n// qualifier before the statement runs fails at the assignment instead.\n//\n// The whole adapter is deliberately NOT frozen — the existing vector test seam\n// remains mutable. GeoPoint is installed separately as another immutable fact.\n\nimport { type NamespaceDialect, normalizeNamespace } from \"@schema/identifier\";\n\n/**\n * Validate one constructor argument and install it. `undefined` installs an\n * immutable absence, which is what an unbound MySQL adapter means.\n */\nexport function installAdapterNamespace(\n adapter: object,\n namespace: unknown,\n dialect: NamespaceDialect\n): void {\n Object.defineProperty(adapter, \"namespace\", {\n value:\n namespace === undefined\n ? undefined\n : normalizeNamespace(namespace, dialect),\n writable: false,\n enumerable: true,\n configurable: false,\n });\n}\n"],"mappings":"gDAiBA,SAAgB,EACd,EACA,EACA,EACM,CACN,OAAO,eAAe,EAAS,YAAa,CAC1C,MACE,IAAc,IAAA,GACV,IAAA,GACA,EAAmB,EAAW,EAAQ,CAC5C,SAAU,GACV,WAAY,GACZ,aAAc,GACf,CAAC"}
|
package/dist/adapters.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { a as MySQLAdapter, i as postgresAdapter, n as sqliteAdapter, o as mysqlAdapter, r as PostgresAdapter, s as DatabaseAdapter, t as SQLiteAdapter } from "./index-B1Z7NeUy.mjs";
|
|
2
|
+
export { DatabaseAdapter, MySQLAdapter, PostgresAdapter, SQLiteAdapter, mysqlAdapter, postgresAdapter, sqliteAdapter };
|
package/dist/adapters.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./postgres-adapter-
|
|
1
|
+
import"./geo-point-codec-BTDzc-ym.mjs";import"./geo-area-codec-CEekcqFE.mjs";import{n as e,t}from"./postgres-adapter-PPkSyWY3.mjs";import{n,t as r}from"./mysql-adapter-BkzgEeT0.mjs";import{n as i,t as a}from"./sqlite-adapter-5A1l0zRR.mjs";export{r as MySQLAdapter,t as PostgresAdapter,a as SQLiteAdapter,n as mysqlAdapter,e as postgresAdapter,i as sqliteAdapter};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as e,f as t,l as n,r,s as i}from"./diagnostics-BpFHhRrD.mjs";let a=function(e){return e.CONNECTION_FAILED=`V1001`,e.CONNECTION_TIMEOUT=`V1002`,e.CONNECTION_CLOSED=`V1003`,e.CLIENT_INITIALIZATION=`V1004`,e.QUERY_FAILED=`V2001`,e.QUERY_TIMEOUT=`V2002`,e.QUERY_SYNTAX=`V2003`,e.UNIQUE_CONSTRAINT=`V3001`,e.FOREIGN_KEY_CONSTRAINT=`V3002`,e.NOT_NULL_CONSTRAINT=`V3003`,e.CHECK_CONSTRAINT=`V3004`,e.VALUE_TOO_LONG=`V3005`,e.VALIDATION_FAILED=`V4001`,e.INVALID_INPUT=`V4002`,e.MISSING_REQUIRED=`V4003`,e.TRANSACTION_FAILED=`V5001`,e.TRANSACTION_TIMEOUT=`V5002`,e.DEADLOCK=`V5003`,e.SERIALIZATION_FAILURE=`V5004`,e.INVALID_TRANSACTION_INPUT=`V5005`,e.RECORD_NOT_FOUND=`V6001`,e.MODEL_NOT_FOUND=`V6002`,e.RELATION_NOT_FOUND=`V6003`,e.NESTED_WRITE_FAILED=`V7001`,e.NESTED_CREATE_FAILED=`V7002`,e.NESTED_UPDATE_FAILED=`V7003`,e.NESTED_DELETE_FAILED=`V7004`,e.NESTED_CONNECT_FAILED=`V7005`,e.NESTED_WRITE_ASSERTION_FAILED=`V7006`,e.FEATURE_NOT_SUPPORTED=`V8001`,e.DRIVER_NOT_SUPPORTED=`V8002`,e.UNSUPPORTED_OPERATION=`V8003`,e.CACHE_INVALID_TTL=`V10001`,e.CACHE_INVALID_KEY=`V10002`,e.CACHE_OPERATION_NOT_CACHEABLE=`V10003`,e.CACHE_CONFIGURATION=`V10004`,e.MIGRATION_FAILED=`V11001`,e.MIGRATION_NOT_FOUND=`V11002`,e.MIGRATION_CHECKSUM_MISMATCH=`V11003`,e.MIGRATION_DIALECT_MISMATCH=`V11004`,e.MIGRATION_LOCK_FAILED=`V11005`,e.MIGRATION_ALREADY_APPLIED=`V11006`,e.MIGRATION_OUT_OF_ORDER=`V11007`,e.MIGRATION_FILE_NOT_FOUND=`V11008`,e.MIGRATION_INVALID_STATE=`V11009`,e.MIGRATION_DESTRUCTIVE_REJECTED=`V11010`,e.MIGRATION_STORAGE_REQUIRED=`V11011`,e.MIGRATION_INVALID_ESTATE=`V11012`,e.MIGRATION_PATH_REQUIRED=`V11013`,e.MIGRATION_DRIFT=`V11014`,e.MIGRATION_MARKER_CONFLICT=`V11015`,e.MIGRATION_UNFINISHED_ATTEMPT=`V11016`,e.MIGRATION_CONSENT_REQUIRED=`V11017`,e.MIGRATION_CONSENT_MISMATCH=`V11018`,e.MIGRATION_PARTIAL_EFFECT=`V11019`,e.MIGRATION_AMBIGUOUS_COMMIT=`V11020`,e.MIGRATION_UNSUPPORTED_PROVIDER=`V11021`,e.MIGRATION_CORRUPTION=`V11022`,e.OPERATION_ALREADY_EXECUTED=`V12001`,e.OPERATION_EXECUTION_CONFLICT=`V12002`,e.OPERATION_CLIENT_MISMATCH=`V12003`,e.OPERATION_SCOPE_MISMATCH=`V12004`,e.INTERNAL_ERROR=`V9001`,e.SCHEMA_ERROR=`V9002`,e}({});const o=new Map([[a.CONNECTION_FAILED,`P1001`],[a.CONNECTION_TIMEOUT,`P1002`],[a.CONNECTION_CLOSED,`P1017`],[a.CLIENT_INITIALIZATION,`P1012`],[a.UNIQUE_CONSTRAINT,`P2002`],[a.FOREIGN_KEY_CONSTRAINT,`P2003`],[a.NOT_NULL_CONSTRAINT,`P2011`],[a.CHECK_CONSTRAINT,`P2004`],[a.VALUE_TOO_LONG,`P2000`],[a.VALIDATION_FAILED,`P2009`],[a.RECORD_NOT_FOUND,`P2025`]]);function s(e){return o.get(e)}var c=class extends Error{static diagnosticName=`VibORMError`;code;originalCause;meta;timestamp;constructor(e,t,a){super(e);let o=l(new.target);this.name=o,this.code=t,this.originalCause=a?.cause?i(a.cause):void 0,this.meta=n(a?.meta??{},a?.diagnostics),this.timestamp=new Date,r(this,{cause:this.originalCause,code:t,disclosure:a?.diagnostics,message:e,meta:this.meta,name:o,prismaCode:s(t),timestamp:this.timestamp}),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}get prismaCode(){return s(this.code)}isRetryable(){return m(this.code).retryable}toJSON(){return t(this)??{name:`VibORMError`,message:`VibORM operation failed`,code:a.INTERNAL_ERROR,meta:{},timestamp:`Invalid Date`}}};function l(t){let n=t;for(let t=0;t<16&&typeof n==`function`;t+=1){let t=e(n,`diagnosticName`);if(t&&`value`in t&&typeof t.value==`string`&&t.value.length>0)return t.value;try{n=Object.getPrototypeOf(n)}catch{return`VibORMError`}}return`VibORMError`}function u(e){return e instanceof c}const d={expected:!0,retryable:!1},f={expected:!0,retryable:!0},p={expected:!1,retryable:!1};function m(e){switch(e){case a.CONNECTION_TIMEOUT:return f;case a.CONNECTION_FAILED:case a.CONNECTION_CLOSED:case a.CLIENT_INITIALIZATION:return d;case a.QUERY_TIMEOUT:return f;case a.QUERY_FAILED:case a.QUERY_SYNTAX:return d;case a.UNIQUE_CONSTRAINT:case a.FOREIGN_KEY_CONSTRAINT:case a.NOT_NULL_CONSTRAINT:case a.CHECK_CONSTRAINT:case a.VALUE_TOO_LONG:return d;case a.VALIDATION_FAILED:case a.INVALID_INPUT:case a.MISSING_REQUIRED:return d;case a.DEADLOCK:case a.SERIALIZATION_FAILURE:return f;case a.TRANSACTION_FAILED:case a.TRANSACTION_TIMEOUT:case a.INVALID_TRANSACTION_INPUT:return d;case a.RECORD_NOT_FOUND:case a.MODEL_NOT_FOUND:case a.RELATION_NOT_FOUND:return d;case a.NESTED_WRITE_FAILED:case a.NESTED_CREATE_FAILED:case a.NESTED_UPDATE_FAILED:case a.NESTED_DELETE_FAILED:case a.NESTED_CONNECT_FAILED:case a.NESTED_WRITE_ASSERTION_FAILED:return d;case a.FEATURE_NOT_SUPPORTED:case a.DRIVER_NOT_SUPPORTED:case a.UNSUPPORTED_OPERATION:return d;case a.CACHE_INVALID_TTL:case a.CACHE_INVALID_KEY:case a.CACHE_OPERATION_NOT_CACHEABLE:case a.CACHE_CONFIGURATION:return d;case a.MIGRATION_FAILED:case a.MIGRATION_NOT_FOUND:case a.MIGRATION_CHECKSUM_MISMATCH:case a.MIGRATION_DIALECT_MISMATCH:case a.MIGRATION_LOCK_FAILED:case a.MIGRATION_ALREADY_APPLIED:case a.MIGRATION_OUT_OF_ORDER:case a.MIGRATION_FILE_NOT_FOUND:case a.MIGRATION_INVALID_STATE:case a.MIGRATION_DESTRUCTIVE_REJECTED:case a.MIGRATION_STORAGE_REQUIRED:case a.MIGRATION_INVALID_ESTATE:case a.MIGRATION_PATH_REQUIRED:case a.MIGRATION_DRIFT:case a.MIGRATION_MARKER_CONFLICT:case a.MIGRATION_UNFINISHED_ATTEMPT:case a.MIGRATION_CONSENT_REQUIRED:case a.MIGRATION_CONSENT_MISMATCH:case a.MIGRATION_PARTIAL_EFFECT:case a.MIGRATION_AMBIGUOUS_COMMIT:case a.MIGRATION_UNSUPPORTED_PROVIDER:case a.MIGRATION_CORRUPTION:return d;case a.OPERATION_ALREADY_EXECUTED:case a.OPERATION_EXECUTION_CONFLICT:case a.OPERATION_CLIENT_MISMATCH:case a.OPERATION_SCOPE_MISMATCH:return d;case a.INTERNAL_ERROR:case a.SCHEMA_ERROR:return p}}function h(e){if(u(e))return e.isRetryable();if(e instanceof Error&&`code`in e){let t=[`40001`,`40P01`,`SQLITE_BUSY`],n=e.code;return typeof n==`string`&&t.includes(n)}return!1}function g(e,t=a.INTERNAL_ERROR,n){return u(e)?e:new c(`VibORM operation failed`,t,{cause:e instanceof Error?e:Error(String(e)),meta:n})}export{s as a,u as i,a as n,g as o,h as r,c as t};
|
|
2
|
+
//# sourceMappingURL=base-BUN03ArF.mjs.map
|