viborm 0.1.0 → 1.0.0-rc.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/LICENSE +21 -0
- package/README.md +220 -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-C6g-wpU_.mjs +2 -0
- package/dist/client-C6g-wpU_.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-jAZ95pZ5.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-B7rrn6zq.mjs +2 -0
- package/dist/driver-B7rrn6zq.mjs.map +1 -0
- package/dist/driver-Cpluw-nE.mjs +2 -0
- package/dist/driver-Cpluw-nE.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 +3 -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-B1Daewmr.mjs +2 -0
- package/dist/extension-B1Daewmr.mjs.map +1 -0
- package/dist/extension-k9VoiK58.mjs +2 -0
- package/dist/extension-k9VoiK58.mjs.map +1 -0
- package/dist/fs-estate-B4hLZOp1.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-ChhK6Q53.d.mts +5797 -0
- package/dist/index-RtRFAdIS.d.mts +521 -0
- package/dist/index.d.mts +7 -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 +670 -1241
- package/dist/migrations.mjs +1 -10
- package/dist/migrations.mjs.map +1 -1
- package/dist/mysql-adapter-DfAF6Hd0.mjs +2 -0
- package/dist/mysql-adapter-DfAF6Hd0.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-DDvmW2rG.mjs +2 -0
- package/dist/postgres-adapter-DDvmW2rG.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-CoFkQif_.mjs +2 -0
- package/dist/result-shape-CoFkQif_.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-Chr4x7p3.mjs +6 -0
- package/dist/schema-introspection-Chr4x7p3.mjs.map +1 -0
- package/dist/schema-introspection-DPKy4QnW.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-3v4Bg8iy.mjs +2 -0
- package/dist/sqlite-adapter-3v4Bg8iy.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-DTN5ytg3.mjs +6 -0
- package/dist/standard-sql-DTN5ytg3.mjs.map +1 -0
- package/dist/string-CBx6pS96.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-07XaHy-w.d.mts +283 -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-Bg5wI5xl.mjs +2 -0
- package/dist/version-Bg5wI5xl.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,93 @@
|
|
|
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.2`; it does not mean that candidate is published.
|
|
8
|
+
The preceding `1.0.0-rc.1` is published. Install an exact published candidate
|
|
9
|
+
for reproducible evaluation; `next` follows the latest published RC.
|
|
10
|
+
V1 includes breaking changes. Read the [upgrade guide](docs/content/docs/getting-started/upgrading-to-v1.mdx)
|
|
11
|
+
and [changelog](CHANGELOG.md) before migrating. Node.js 22 or newer and
|
|
12
|
+
TypeScript 5.8 or newer are the supported Node/TypeScript floors. The docs site
|
|
13
|
+
has its own Node.js requirement.
|
|
14
|
+
|
|
15
|
+
The [driver guide](docs/content/docs/drivers/index.mdx) distinguishes local
|
|
16
|
+
qualification from hosted preview limits. Publication follows [RELEASING.md](RELEASING.md);
|
|
17
|
+
stable V1 is not released by this preparation step.
|
|
18
|
+
|
|
5
19
|
## Key Features
|
|
6
20
|
|
|
7
21
|
| Feature | Description |
|
|
8
22
|
|---------|-------------|
|
|
9
23
|
| **Zero Codegen** | Types flow from schema → query → result via TypeScript inference |
|
|
10
24
|
| **Standard Schema V1** | Interoperable with Zod, Valibot, ArkType for validation |
|
|
11
|
-
| **Prisma-
|
|
25
|
+
| **Prisma-inspired API** | Familiar `findMany`, `create`, `update` operations with `where`, `include`, `select` |
|
|
12
26
|
| **Multi-Database** | PostgreSQL, MySQL, SQLite from one codebase via adapter pattern |
|
|
13
27
|
| **Chainable Schema** | `s.string().nullable().unique()` with immutable state tracking |
|
|
14
28
|
|
|
29
|
+
## Prisma Compatibility Snapshot
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
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).
|
|
34
|
+
|
|
35
|
+
Status legend:
|
|
36
|
+
|
|
37
|
+
| Status | Meaning |
|
|
38
|
+
|--------|---------|
|
|
39
|
+
| `Supported` | Same core shape as Prisma for the documented relational SQL surface |
|
|
40
|
+
| `Subset` | Prisma supports more shapes; VibORM supports a smaller fail-closed subset |
|
|
41
|
+
| `Different` | Intentional VibORM API decision |
|
|
42
|
+
| `Unsupported` | Not part of the current public contract |
|
|
43
|
+
|
|
44
|
+
### Basic CRUD
|
|
45
|
+
|
|
46
|
+
| Area | Prisma Client | VibORM | Status |
|
|
47
|
+
|------|---------------|--------|--------|
|
|
48
|
+
| 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` |
|
|
49
|
+
| 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` |
|
|
50
|
+
| 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` |
|
|
51
|
+
| 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` |
|
|
52
|
+
| 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` |
|
|
53
|
+
| 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` |
|
|
54
|
+
| Upsert | `upsert` with unique `where`, `create`, `update`; returns row | Same core shape; supported nested writes are allowed in covered branches | `Supported` |
|
|
55
|
+
| 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` |
|
|
56
|
+
|
|
57
|
+
### Advanced Queries
|
|
58
|
+
|
|
59
|
+
| Area | Prisma Client | VibORM | Status |
|
|
60
|
+
|------|---------------|--------|--------|
|
|
61
|
+
| 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` |
|
|
62
|
+
| Relation filters | To-one `is`/`isNot`; to-many `some`/`every`/`none` | Same documented relation filter surface, including nested relation filters where covered | `Supported` |
|
|
63
|
+
| Projection | `select`, `include`, nested selection, relation `_count` | Supports `select`, `include`, nested selection, and relation `_count`; top-level `select` + `include` rejects | `Supported` |
|
|
64
|
+
| 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` |
|
|
65
|
+
| Pagination | `cursor`, `skip`, `take`, negative `take` on list reads | Supports cursor pagination, `skip`, `take`, negative `take`; cursor uses `whereUnique` | `Supported` |
|
|
66
|
+
| `distinct` | `findMany({ distinct })` with Prisma's in-memory distinct semantics | Supports scalar-field `distinct`; relation fields reject; SQL strategy is adapter-owned | `Subset` |
|
|
67
|
+
| `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` |
|
|
68
|
+
| `aggregate` | `_count`, `_avg`, `_sum`, `_min`, `_max` with `where`, order, pagination | Same documented aggregate selectors and input-window pagination; invalid/empty aggregate selection rejects | `Supported` |
|
|
69
|
+
| `groupBy` | `by`, aggregates, `having`, `orderBy`, `skip`, `take`; no `select` | Supports scalar `by`, aggregate selections, `having`, order, `skip`, `take`; invalid group/having shapes reject | `Supported` |
|
|
70
|
+
| 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` |
|
|
71
|
+
| Transactions | Callback and array `$transaction` | Callback transactions on transactional drivers; batch mode on transactional or atomic-batch drivers | `Supported` |
|
|
72
|
+
| `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` |
|
|
73
|
+
| 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` |
|
|
74
|
+
| Existence check | Emulated with `count`/`findFirst` in Prisma | `exist({ where })` is a VibORM extension returning `boolean`; no `exists` alias | `Different` |
|
|
75
|
+
|
|
15
76
|
```typescript
|
|
16
77
|
import { s } from "viborm";
|
|
17
|
-
import { createClient } from "viborm/
|
|
78
|
+
import { createClient } from "viborm/pglite";
|
|
18
79
|
|
|
19
80
|
// Schema carries type information
|
|
20
81
|
const user = s.model({
|
|
21
82
|
id: s.string().id().ulid(),
|
|
22
83
|
email: s.string().unique(),
|
|
23
|
-
posts: s.
|
|
84
|
+
posts: s.toMany(() => post),
|
|
24
85
|
});
|
|
25
86
|
|
|
26
87
|
const post = s.model({
|
|
27
88
|
id: s.string().id().ulid(),
|
|
28
89
|
title: s.string(),
|
|
29
90
|
authorId: s.string(),
|
|
30
|
-
author: s.
|
|
91
|
+
author: s.toOne(() => user).fields("authorId").references("id"),
|
|
31
92
|
});
|
|
32
93
|
|
|
33
94
|
// Fully typed queries - no codegen!
|
|
@@ -62,7 +123,7 @@ export const user = s.model({
|
|
|
62
123
|
name: s.string(),
|
|
63
124
|
email: s.string().unique(),
|
|
64
125
|
createdAt: s.dateTime().now(),
|
|
65
|
-
posts: s.
|
|
126
|
+
posts: s.toMany(() => post),
|
|
66
127
|
});
|
|
67
128
|
|
|
68
129
|
export const post = s.model({
|
|
@@ -70,7 +131,7 @@ export const post = s.model({
|
|
|
70
131
|
title: s.string(),
|
|
71
132
|
content: s.string().nullable(),
|
|
72
133
|
authorId: s.string(),
|
|
73
|
-
author: s.
|
|
134
|
+
author: s.toOne(() => user).fields("authorId").references("id"),
|
|
74
135
|
});
|
|
75
136
|
|
|
76
137
|
export const schema = { user, post };
|
|
@@ -80,8 +141,8 @@ export const schema = { user, post };
|
|
|
80
141
|
|
|
81
142
|
```typescript
|
|
82
143
|
// db.ts
|
|
83
|
-
import { createClient } from "viborm/
|
|
84
|
-
import {
|
|
144
|
+
import { createClient } from "viborm/pglite";
|
|
145
|
+
import { createMigrationClient } from "viborm/migrations";
|
|
85
146
|
import { schema } from "./schema";
|
|
86
147
|
|
|
87
148
|
export const orm = createClient({
|
|
@@ -89,8 +150,9 @@ export const orm = createClient({
|
|
|
89
150
|
dataDir: ".pglite", // Persists to filesystem (omit for in-memory)
|
|
90
151
|
});
|
|
91
152
|
|
|
92
|
-
// Push
|
|
93
|
-
|
|
153
|
+
// History-free live sync. Push never writes estate storage or the marker.
|
|
154
|
+
const migrations = createMigrationClient(orm);
|
|
155
|
+
await migrations.push();
|
|
94
156
|
```
|
|
95
157
|
|
|
96
158
|
### 4. Query
|
|
@@ -127,7 +189,7 @@ await orm.user.delete({
|
|
|
127
189
|
|
|
128
190
|
## Transactions
|
|
129
191
|
|
|
130
|
-
VibORM supports transactions with
|
|
192
|
+
VibORM supports callback transactions on drivers with real transaction support, and batch mode on drivers with transactions or native atomic batch support.
|
|
131
193
|
|
|
132
194
|
### Callback Mode (Dynamic)
|
|
133
195
|
|
|
@@ -136,11 +198,11 @@ const result = await orm.$transaction(async (tx) => {
|
|
|
136
198
|
const user = await tx.user.create({
|
|
137
199
|
data: { name: "Alice", email: "alice@example.com" }
|
|
138
200
|
});
|
|
139
|
-
|
|
201
|
+
|
|
140
202
|
await tx.post.create({
|
|
141
203
|
data: { title: "First Post", authorId: user.id }
|
|
142
204
|
});
|
|
143
|
-
|
|
205
|
+
|
|
144
206
|
return user;
|
|
145
207
|
});
|
|
146
208
|
// If any operation fails, all changes are rolled back
|
|
@@ -153,25 +215,58 @@ const [user, post] = await orm.$transaction([
|
|
|
153
215
|
orm.user.create({ data: { name: "Bob", email: "bob@example.com" } }),
|
|
154
216
|
orm.post.create({ data: { title: "Hello", authorId: "user-id" } })
|
|
155
217
|
]);
|
|
156
|
-
//
|
|
218
|
+
// Executes atomically when the driver supports transactions or native batch
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Client Extensions
|
|
224
|
+
|
|
225
|
+
`$extends()` returns an immutable derived client. Extensions have six distinct
|
|
226
|
+
capabilities: `request`, `query`, `statement`, `observe`, `client`, and `model`.
|
|
227
|
+
See the [extension guide](docs/content/docs/extensions/index.mdx) for their
|
|
228
|
+
authority and exact lifecycle.
|
|
229
|
+
|
|
230
|
+
Internally, `src/extensions/` is the single generic definition, chain,
|
|
231
|
+
method-binding, admission, and capability-runner boundary. The official
|
|
232
|
+
implementations remain with their domains in `src/cache/extension.ts`,
|
|
233
|
+
`src/instrumentation/extension.ts`, and
|
|
234
|
+
`src/client/default-omit-extension.ts`; client, query-engine, and drivers only
|
|
235
|
+
retain the lifecycle trigger points whose facts they create.
|
|
236
|
+
|
|
237
|
+
Client default projection is also an extension:
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
import { defaultOmit } from "viborm/client";
|
|
241
|
+
|
|
242
|
+
const publicOrm = orm.$extends(
|
|
243
|
+
defaultOmit<typeof schema>()({
|
|
244
|
+
user: { passwordHash: true },
|
|
245
|
+
})
|
|
246
|
+
);
|
|
157
247
|
```
|
|
158
248
|
|
|
249
|
+
`defaultOmit()` is a presentation default, not authorization. VibORM does not
|
|
250
|
+
currently ship an RBAC helper; complete policy must account for the full query
|
|
251
|
+
and mutation graph.
|
|
252
|
+
|
|
159
253
|
---
|
|
160
254
|
|
|
161
255
|
## Caching
|
|
162
256
|
|
|
163
|
-
VibORM
|
|
257
|
+
VibORM provides query caching as an official client extension, with TTL and
|
|
258
|
+
stale-while-revalidate (SWR) support.
|
|
164
259
|
|
|
165
260
|
### Setup
|
|
166
261
|
|
|
167
262
|
```typescript
|
|
168
|
-
import { createClient } from "viborm/
|
|
169
|
-
import {
|
|
263
|
+
import { createClient } from "viborm/pglite";
|
|
264
|
+
import { cache } from "viborm/cache";
|
|
265
|
+
import { MemoryCache } from "viborm/cache/memory";
|
|
170
266
|
|
|
171
|
-
const orm = createClient({
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
});
|
|
267
|
+
const orm = createClient({ schema }).$extends(
|
|
268
|
+
cache({ driver: new MemoryCache() })
|
|
269
|
+
);
|
|
175
270
|
```
|
|
176
271
|
|
|
177
272
|
### Basic Caching
|
|
@@ -185,6 +280,11 @@ const posts = await orm.$withCache({ ttl: "1 hour" }).post.findMany();
|
|
|
185
280
|
|
|
186
281
|
// TTL in milliseconds
|
|
187
282
|
const recent = await orm.$withCache({ ttl: 30000 }).user.findMany();
|
|
283
|
+
|
|
284
|
+
// A custom key is a suffix of the canonical model/operation/argument key.
|
|
285
|
+
const active = await orm
|
|
286
|
+
.$withCache({ key: "active-users" })
|
|
287
|
+
.user.findMany({ where: { active: true } });
|
|
188
288
|
```
|
|
189
289
|
|
|
190
290
|
### Stale-While-Revalidate (SWR)
|
|
@@ -212,6 +312,12 @@ await orm.user.create({
|
|
|
212
312
|
await orm.$invalidate("user:*", "post:findMany:*");
|
|
213
313
|
```
|
|
214
314
|
|
|
315
|
+
Cached values are portable snapshots. Every hit materializes a fresh detached
|
|
316
|
+
result graph, so one caller cannot mutate a later caller's value. Official
|
|
317
|
+
cache reads bypass caching inside callback transactions, array transactions,
|
|
318
|
+
raw operations, and clients with statement transforms. Mutation invalidation
|
|
319
|
+
still follows the transaction's write-outcome boundary.
|
|
320
|
+
|
|
215
321
|
### Cache Drivers
|
|
216
322
|
|
|
217
323
|
| Driver | Use Case |
|
|
@@ -228,13 +334,12 @@ VibORM supports OpenTelemetry tracing and structured logging.
|
|
|
228
334
|
### Setup
|
|
229
335
|
|
|
230
336
|
```typescript
|
|
231
|
-
import { createClient } from "viborm/
|
|
337
|
+
import { createClient } from "viborm/pglite";
|
|
338
|
+
import { instrumentation } from "viborm/instrumentation";
|
|
232
339
|
|
|
233
|
-
const orm = createClient({
|
|
234
|
-
|
|
235
|
-
instrumentation: {
|
|
340
|
+
const orm = createClient({ schema }).$extends(
|
|
341
|
+
instrumentation({
|
|
236
342
|
tracing: {
|
|
237
|
-
enabled: true,
|
|
238
343
|
// Optional: customize tracer
|
|
239
344
|
},
|
|
240
345
|
logging: {
|
|
@@ -242,23 +347,26 @@ const orm = createClient({
|
|
|
242
347
|
cache: true, // Log cache hits/misses
|
|
243
348
|
warning: true, // Log warnings
|
|
244
349
|
error: true, // Log errors
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
350
|
+
},
|
|
351
|
+
})
|
|
352
|
+
);
|
|
248
353
|
```
|
|
249
354
|
|
|
250
355
|
### Serverless Support
|
|
251
356
|
|
|
252
|
-
For serverless
|
|
357
|
+
For serverless caching, provide `waitUntil` to the cache extension so the
|
|
358
|
+
request lifetime owns background revalidation:
|
|
253
359
|
|
|
254
360
|
```typescript
|
|
255
361
|
// Cloudflare Workers
|
|
256
362
|
export default {
|
|
257
363
|
async fetch(request, env, ctx) {
|
|
258
|
-
const orm = createClient({
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
364
|
+
const orm = createClient({ schema }).$extends(
|
|
365
|
+
cache({
|
|
366
|
+
driver: new CloudflareKVCache(env.CACHE),
|
|
367
|
+
waitUntil: ctx.waitUntil.bind(ctx),
|
|
368
|
+
})
|
|
369
|
+
);
|
|
262
370
|
// ...
|
|
263
371
|
}
|
|
264
372
|
};
|
|
@@ -266,14 +374,14 @@ export default {
|
|
|
266
374
|
|
|
267
375
|
---
|
|
268
376
|
|
|
269
|
-
##
|
|
377
|
+
## Scalar Types
|
|
270
378
|
|
|
271
379
|
| Type | Description | Example |
|
|
272
380
|
|------|-------------|---------|
|
|
273
|
-
| `string()` | Text
|
|
381
|
+
| `string()` | Text scalars | `s.string().unique()` |
|
|
274
382
|
| `int()` | 32-bit integers | `s.int().default(0)` |
|
|
275
|
-
| `
|
|
276
|
-
| `decimal()` |
|
|
383
|
+
| `number()` | Approximate number | `s.number()` |
|
|
384
|
+
| `decimal({ precision, scale })` | Exact fixed decimals (`Decimal` results) | `s.decimal({ precision: 10, scale: 2 })` |
|
|
277
385
|
| `bigInt()` | 64-bit integers | `s.bigInt()` |
|
|
278
386
|
| `boolean()` | Boolean values | `s.boolean().default(false)` |
|
|
279
387
|
| `dateTime()` | Date and time | `s.dateTime().now()` |
|
|
@@ -283,20 +391,58 @@ export default {
|
|
|
283
391
|
| `enum()` | Enumerated values | `s.enum(["ADMIN", "USER"])` |
|
|
284
392
|
| `blob()` | Binary data (Uint8Array) | `s.blob()` |
|
|
285
393
|
| `vector()` | Vector embeddings (pgvector) | `s.vector(1536)` |
|
|
286
|
-
| `point()` | PostGIS point type | `
|
|
394
|
+
| `point()` | PostGIS point type | `import { point } from "viborm"` (not exposed on `s`) |
|
|
287
395
|
|
|
288
396
|
### Auto-generation
|
|
289
397
|
|
|
290
398
|
```typescript
|
|
291
399
|
s.string().id().uuid() // UUID v4
|
|
400
|
+
s.string().id().uuidv7() // UUID v7 (time-sortable)
|
|
292
401
|
s.string().id().ulid() // ULID
|
|
402
|
+
s.string().id().ksuid() // KSUID (time-sortable)
|
|
293
403
|
s.string().id().nanoid() // NanoID
|
|
294
|
-
s.string().id().cuid() //
|
|
404
|
+
s.string().id().cuid() // CUID2
|
|
295
405
|
s.int().id().increment() // Auto-increment
|
|
296
406
|
s.dateTime().now() // Current timestamp on create
|
|
297
407
|
s.dateTime().updatedAt() // Update timestamp on every update
|
|
298
408
|
```
|
|
299
409
|
|
|
410
|
+
Every one of those is generated by VibORM itself, from `crypto.getRandomValues`.
|
|
411
|
+
Naming a format is also a promise about the field's values: it is validated, and
|
|
412
|
+
`uuid`, `uuidv7`, `ulid` and `ksuid` are stored as the identifier rather than as
|
|
413
|
+
its text. See [String scalars](https://viborm.dev/docs/schema/scalars/string)
|
|
414
|
+
and, for a table that already holds text,
|
|
415
|
+
[Converting identifier columns](https://viborm.dev/docs/migration/identifiers).
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## Runtime Dependencies
|
|
420
|
+
|
|
421
|
+
VibORM installs one runtime dependency for the core package, and one CLI-only
|
|
422
|
+
pair. No entry the client bundle reaches imports any of them; the CLI pair is
|
|
423
|
+
imported by `dist/cli.mjs` and by nothing else:
|
|
424
|
+
|
|
425
|
+
| Package | Why it is a dependency |
|
|
426
|
+
|---|---|
|
|
427
|
+
| `@standard-schema/spec` | Types only — the interface every validator here speaks |
|
|
428
|
+
| `@clack/prompts`, `commander` | The CLI only, imported by `dist/cli.mjs` |
|
|
429
|
+
|
|
430
|
+
There is no value-type dependency and no hash dependency: the exact decimal and
|
|
431
|
+
SHA3-512 are VibORM's own, and the `v.*` validation primitives always were.
|
|
432
|
+
|
|
433
|
+
What left the graph, and what replaced it:
|
|
434
|
+
|
|
435
|
+
| Removed | Replaced by |
|
|
436
|
+
|---|---|
|
|
437
|
+
| `decimal.js` | VibORM's own `Decimal` over a `BigInt` coefficient — a deliberate API change, documented in the changelog |
|
|
438
|
+
| `@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) |
|
|
439
|
+
| `nanoid` | VibORM's own NanoID |
|
|
440
|
+
| `ulidx` | VibORM's own ULID, with unbiased randomness and the same monotonicity |
|
|
441
|
+
| `@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) |
|
|
442
|
+
|
|
443
|
+
Database drivers (`pg`, `mysql2`, `better-sqlite3`, …) are never dependencies:
|
|
444
|
+
you install the one you use.
|
|
445
|
+
|
|
300
446
|
---
|
|
301
447
|
|
|
302
448
|
## Supported Drivers
|
|
@@ -324,14 +470,13 @@ s.dateTime().updatedAt() // Update timestamp on every update
|
|
|
324
470
|
| `sqlite3` | `better-sqlite3` | Node.js (synchronous) |
|
|
325
471
|
| `libsql` | `@libsql/client` | Turso / LibSQL |
|
|
326
472
|
| `d1` | Cloudflare binding | Cloudflare D1 (Workers) |
|
|
327
|
-
| `d1-http` | Cloudflare API | Cloudflare D1 (HTTP) |
|
|
328
473
|
| `bun-sqlite` | Built-in | Bun runtime |
|
|
329
474
|
|
|
330
475
|
---
|
|
331
476
|
|
|
332
477
|
## Repository Structure
|
|
333
478
|
|
|
334
|
-
VibORM uses a **
|
|
479
|
+
VibORM uses a **12-layer architecture**. Each layer has an `AGENTS.md` with detailed documentation.
|
|
335
480
|
|
|
336
481
|
```
|
|
337
482
|
src/
|
|
@@ -339,9 +484,9 @@ src/
|
|
|
339
484
|
│ Branded types, set-theory optimization
|
|
340
485
|
│
|
|
341
486
|
├── schema/ L2-L5 Schema definition
|
|
342
|
-
│ ├──
|
|
487
|
+
│ ├── scalars/ Scalar types with State generic pattern
|
|
343
488
|
│ ├── model/ Model composition, query schemas
|
|
344
|
-
│ ├── relation/
|
|
489
|
+
│ ├── relation/ The two relation factories and their state
|
|
345
490
|
│ └── validation/ Definition-time schema validation
|
|
346
491
|
│
|
|
347
492
|
├── query-engine/ L6 Database-agnostic query building
|
|
@@ -351,13 +496,20 @@ src/
|
|
|
351
496
|
│ PostgreSQL, MySQL, SQLite dialect implementations
|
|
352
497
|
│
|
|
353
498
|
├── drivers/ L8 Connection management, query execution
|
|
354
|
-
│
|
|
355
|
-
│ mysql2, planetscale, sqlite3, libsql, d1,
|
|
499
|
+
│ 11 drivers: pglite, pg, postgres, neon-http, bun-sql,
|
|
500
|
+
│ mysql2, planetscale, sqlite3, libsql, d1, bun-sqlite
|
|
501
|
+
│
|
|
502
|
+
├── extensions/ Cross-cutting six-capability contracts, immutable chain,
|
|
503
|
+
│ method binding, runners, and array-admission latch
|
|
356
504
|
│
|
|
357
505
|
├── client/ L9 Type inference, ORM interface
|
|
358
506
|
│ Recursive proxy pattern, result types
|
|
359
507
|
│
|
|
360
|
-
|
|
508
|
+
├── cache/ L10 Query caching, invalidation, stale-while-revalidate
|
|
509
|
+
│
|
|
510
|
+
├── instrumentation/ L11 Tracing, structured logging, diagnostics
|
|
511
|
+
│
|
|
512
|
+
└── migrations/ L12 Authenticated estate, history-free push, DDL
|
|
361
513
|
```
|
|
362
514
|
|
|
363
515
|
### Key Architecture Rules
|
|
@@ -366,7 +518,7 @@ src/
|
|
|
366
518
|
|
|
367
519
|
2. **Natural Type Inference**: Never use type assertions (`as`). Types flow from schema → validation → client.
|
|
368
520
|
|
|
369
|
-
3. **Immutable State**: Every
|
|
521
|
+
3. **Immutable State**: Every scalar modifier returns a NEW instance. `s.string().nullable()` returns a new scalar, doesn't mutate.
|
|
370
522
|
|
|
371
523
|
4. **Lazy Evaluation**: Schemas are built on first access (`??=` pattern) and cached.
|
|
372
524
|
|
|
@@ -411,7 +563,7 @@ pnpm package:build # Build distributable with tsdown
|
|
|
411
563
|
import { ... } from "@schema"; // src/schema/
|
|
412
564
|
import { ... } from "@client"; // src/client/
|
|
413
565
|
import { ... } from "@validation"; // src/validation/
|
|
414
|
-
import { ... } from "@query-engine";
|
|
566
|
+
import { ... } from "@query-engine/*"; // direct src/query-engine/ owner
|
|
415
567
|
import { ... } from "@adapters"; // src/adapters/
|
|
416
568
|
import { ... } from "@drivers"; // src/drivers/
|
|
417
569
|
import { ... } from "@sql"; // src/sql/
|
|
@@ -439,7 +591,7 @@ When working with an AI assistant, point it to these files first.
|
|
|
439
591
|
|
|
440
592
|
| I want to... | Start here |
|
|
441
593
|
|--------------|------------|
|
|
442
|
-
| Add new
|
|
594
|
+
| Add new scalar type | `src/schema/scalars/AGENTS.md` |
|
|
443
595
|
| Add query operator | `src/query-engine/AGENTS.md` + `src/adapters/AGENTS.md` |
|
|
444
596
|
| Fix type inference bug | `src/client/AGENTS.md` → check upstream schemas |
|
|
445
597
|
| Add migration operation | `src/migrations/AGENTS.md` |
|
|
@@ -455,7 +607,7 @@ Tests mirror the `src/` structure:
|
|
|
455
607
|
```
|
|
456
608
|
tests/
|
|
457
609
|
├── validation/ 28 tests for v.* primitives
|
|
458
|
-
├──
|
|
610
|
+
├── scalars/ Schema generation per scalar type
|
|
459
611
|
├── model/ Query schemas (where, create, update, args)
|
|
460
612
|
│ ├── filter/ WHERE clause generation
|
|
461
613
|
│ ├── create/ CREATE input schemas
|
|
@@ -478,7 +630,7 @@ Most tests run against PGlite (in-memory PostgreSQL). Driver tests in `tests/dri
|
|
|
478
630
|
|---------|---------------|-----|
|
|
479
631
|
| Hardcoded SQL in query-engine | Breaks MySQL/SQLite | Use `ctx.adapter.*` methods |
|
|
480
632
|
| Type assertions (`as`) | Hides type mismatches | Let types flow naturally |
|
|
481
|
-
| Forgot
|
|
633
|
+
| Forgot Scalar union update | New scalar type invisible | Update `src/schema/scalars/base.ts` |
|
|
482
634
|
| Direct model reference in relation | ReferenceError at runtime | Use thunk `() => model` |
|
|
483
635
|
| Eager schema building | Performance (rebuilds every access) | Use `??=` lazy pattern |
|
|
484
636
|
| Mutation instead of new instance | Type/runtime desync | Return new instance from modifiers |
|
|
@@ -489,21 +641,23 @@ Most tests run against PGlite (in-memory PostgreSQL). Driver tests in `tests/dri
|
|
|
489
641
|
|
|
490
642
|
**Core features working:**
|
|
491
643
|
- All CRUD operations (create, read, update, delete, upsert)
|
|
492
|
-
- Relations (
|
|
493
|
-
-
|
|
644
|
+
- 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
|
|
645
|
+
- Supported nested writes (`create`, `createMany`, `connect`, `connectOrCreate`, `disconnect`, `delete`, `set`, `update`, `updateMany`, `upsert`, `deleteMany`) across callback-transaction and atomic-batch paths
|
|
494
646
|
- Select/include with typed results
|
|
495
|
-
-
|
|
496
|
-
-
|
|
647
|
+
- 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`)
|
|
648
|
+
- All scalar types (string, int, number, boolean, dateTime, json, enum, etc.)
|
|
649
|
+
- PostgreSQL, MySQL, and SQLite adapters, including authenticated estate migrations and history-free `push` where the provider lock/CAS is proven
|
|
497
650
|
- Query caching with TTL and SWR
|
|
498
|
-
- Transactions (callback and batch modes)
|
|
651
|
+
- Transactions (callback and batch modes), with Prisma's `{ isolationLevel, timeout, maxWait }` options honored or refused per driver — never ignored
|
|
499
652
|
- OpenTelemetry instrumentation
|
|
500
653
|
|
|
501
654
|
**Known limitations:**
|
|
502
|
-
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
-
|
|
506
|
-
-
|
|
655
|
+
- Full Prisma parity is not complete; VibORM is Prisma-inspired.
|
|
656
|
+
- Parent `create` and the create branch of parent `upsert` intentionally exclude update/delete-like nested operations.
|
|
657
|
+
- Impossible or unsafe primary-key dataflow shapes reject before mutation instead of partially applying nested writes.
|
|
658
|
+
- 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([...])`.
|
|
659
|
+
- 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.
|
|
660
|
+
- 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
661
|
|
|
508
662
|
See `PENDING_WORK.md` for detailed tracking.
|
|
509
663
|
|
|
@@ -514,10 +668,10 @@ See `PENDING_WORK.md` for detailed tracking.
|
|
|
514
668
|
All internal state is accessed via `["~"]`:
|
|
515
669
|
|
|
516
670
|
```typescript
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
relation["~"].
|
|
671
|
+
scalar["~"].state // ScalarState - configuration object
|
|
672
|
+
scalar["~"].state.base // Base scalar schema
|
|
673
|
+
schemaRegistry.proxy.user.core.where // Operation schema for this model
|
|
674
|
+
relation["~"].state.getter // Thunk to target model
|
|
521
675
|
```
|
|
522
676
|
|
|
523
677
|
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-ChhK6Q53.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-DDvmW2rG.mjs";import{n,t as r}from"./mysql-adapter-DfAF6Hd0.mjs";import{n as i,t as a}from"./sqlite-adapter-3v4Bg8iy.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
|