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.
Files changed (233) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +218 -66
  3. package/dist/adapter-internals-Dc9I8w9Y.mjs +2 -0
  4. package/dist/adapter-internals-Dc9I8w9Y.mjs.map +1 -0
  5. package/dist/adapter-namespace-DEKd5hIN.mjs +2 -0
  6. package/dist/adapter-namespace-DEKd5hIN.mjs.map +1 -0
  7. package/dist/adapters.d.mts +2 -2
  8. package/dist/adapters.mjs +1 -1
  9. package/dist/base-BUN03ArF.mjs +2 -0
  10. package/dist/base-BUN03ArF.mjs.map +1 -0
  11. package/dist/bun-sql.d.mts +1 -2
  12. package/dist/bun-sql.mjs +1 -1
  13. package/dist/bun-sql.mjs.map +1 -1
  14. package/dist/bun-sqlite.d.mts +1 -2
  15. package/dist/bun-sqlite.mjs +1 -1
  16. package/dist/bun-sqlite.mjs.map +1 -1
  17. package/dist/cache/cloudflare-kv.d.mts +1 -2
  18. package/dist/cache/cloudflare-kv.mjs +1 -1
  19. package/dist/cache/cloudflare-kv.mjs.map +1 -1
  20. package/dist/cache/memory.d.mts +1 -2
  21. package/dist/cache/memory.mjs +1 -1
  22. package/dist/cache/memory.mjs.map +1 -1
  23. package/dist/cache.d.mts +2 -4
  24. package/dist/cache.mjs +1 -1
  25. package/dist/cli.mjs +2 -39
  26. package/dist/cli.mjs.map +1 -1
  27. package/dist/client-C0QaN70e.mjs +421 -0
  28. package/dist/client-C0QaN70e.mjs.map +1 -0
  29. package/dist/client-DAwgJteY.mjs +2 -0
  30. package/dist/client-DAwgJteY.mjs.map +1 -0
  31. package/dist/client.d.mts +3 -3
  32. package/dist/client.mjs +1 -1
  33. package/dist/clock-DHSN2GNk.mjs +2 -0
  34. package/dist/clock-DHSN2GNk.mjs.map +1 -0
  35. package/dist/config.d.mts +62 -0
  36. package/dist/config.mjs +1 -0
  37. package/dist/consumable-result-candidate-BgCNshWE.mjs +2 -0
  38. package/dist/consumable-result-candidate-BgCNshWE.mjs.map +1 -0
  39. package/dist/contract-d8tNa7GK.d.mts +34 -0
  40. package/dist/current-ca5_TV29.mjs +2 -0
  41. package/dist/current-ca5_TV29.mjs.map +1 -0
  42. package/dist/d1.d.mts +1 -2
  43. package/dist/d1.mjs +1 -1
  44. package/dist/d1.mjs.map +1 -1
  45. package/dist/datetime-physical-codec-pRp9yrnq.mjs +2 -0
  46. package/dist/datetime-physical-codec-pRp9yrnq.mjs.map +1 -0
  47. package/dist/diagnostics-BpFHhRrD.mjs +2 -0
  48. package/dist/diagnostics-BpFHhRrD.mjs.map +1 -0
  49. package/dist/driver-C2ITQ9lL.mjs +2 -0
  50. package/dist/driver-C2ITQ9lL.mjs.map +1 -0
  51. package/dist/driver-CW-7kaQ2.mjs +2 -0
  52. package/dist/driver-CW-7kaQ2.mjs.map +1 -0
  53. package/dist/driver-options-C9bFmRTQ.mjs +2 -0
  54. package/dist/driver-options-C9bFmRTQ.mjs.map +1 -0
  55. package/dist/driver.d.mts +2 -2
  56. package/dist/driver.mjs +1 -1
  57. package/dist/error-mapping-TxJxI_Il.mjs +2 -0
  58. package/dist/error-mapping-TxJxI_Il.mjs.map +1 -0
  59. package/dist/extension-Dgo4iRy3.mjs +2 -0
  60. package/dist/extension-Dgo4iRy3.mjs.map +1 -0
  61. package/dist/extension-Yd1Lt1V7.mjs +2 -0
  62. package/dist/extension-Yd1Lt1V7.mjs.map +1 -0
  63. package/dist/fs-estate-DsE8tYPI.d.mts +8 -0
  64. package/dist/fs-estate-v7EUeEiD.mjs +2 -0
  65. package/dist/fs-estate-v7EUeEiD.mjs.map +1 -0
  66. package/dist/geo-area-codec-CEekcqFE.mjs +2 -0
  67. package/dist/geo-area-codec-CEekcqFE.mjs.map +1 -0
  68. package/dist/geo-point-codec-BTDzc-ym.mjs +2 -0
  69. package/dist/geo-point-codec-BTDzc-ym.mjs.map +1 -0
  70. package/dist/hydration-C2kb7g6D.mjs +2 -0
  71. package/dist/hydration-C2kb7g6D.mjs.map +1 -0
  72. package/dist/identifiers-O_KYMfe6.mjs +2 -0
  73. package/dist/identifiers-O_KYMfe6.mjs.map +1 -0
  74. package/dist/index-B1Z7NeUy.d.mts +6182 -0
  75. package/dist/index-BQAPotX_.d.mts +468 -0
  76. package/dist/index.d.mts +6 -46
  77. package/dist/index.mjs +1 -1
  78. package/dist/index.mjs.map +1 -1
  79. package/dist/instrumentation.d.mts +2 -2
  80. package/dist/instrumentation.mjs +1 -1
  81. package/dist/libsql.d.mts +1 -2
  82. package/dist/libsql.mjs +1 -1
  83. package/dist/libsql.mjs.map +1 -1
  84. package/dist/migrations/storage/fs.d.mts +2 -0
  85. package/dist/migrations/storage/fs.mjs +1 -0
  86. package/dist/migrations-CRloZBED.mjs +2 -0
  87. package/dist/migrations-CRloZBED.mjs.map +1 -0
  88. package/dist/migrations.d.mts +617 -1243
  89. package/dist/migrations.mjs +1 -10
  90. package/dist/migrations.mjs.map +1 -1
  91. package/dist/mysql-adapter-BkzgEeT0.mjs +2 -0
  92. package/dist/mysql-adapter-BkzgEeT0.mjs.map +1 -0
  93. package/dist/mysql2.d.mts +1 -2
  94. package/dist/mysql2.mjs +1 -1
  95. package/dist/mysql2.mjs.map +1 -1
  96. package/dist/native-types-UAbMZ16d.mjs +2 -0
  97. package/dist/native-types-UAbMZ16d.mjs.map +1 -0
  98. package/dist/neon-http.d.mts +1 -2
  99. package/dist/neon-http.mjs +1 -1
  100. package/dist/neon-http.mjs.map +1 -1
  101. package/dist/normalized-result-DXt6rKPa.mjs +2 -0
  102. package/dist/normalized-result-DXt6rKPa.mjs.map +1 -0
  103. package/dist/pg.d.mts +1 -2
  104. package/dist/pg.mjs +1 -1
  105. package/dist/pg.mjs.map +1 -1
  106. package/dist/pglite.d.mts +1 -2
  107. package/dist/pglite.mjs +1 -1
  108. package/dist/pglite.mjs.map +1 -1
  109. package/dist/physical-CJPPHDgl.mjs +2 -0
  110. package/dist/physical-CJPPHDgl.mjs.map +1 -0
  111. package/dist/planetscale.d.mts +1 -2
  112. package/dist/planetscale.mjs +1 -1
  113. package/dist/planetscale.mjs.map +1 -1
  114. package/dist/postgres-adapter-PPkSyWY3.mjs +2 -0
  115. package/dist/postgres-adapter-PPkSyWY3.mjs.map +1 -0
  116. package/dist/postgres-result-DJS3wvIm.mjs +2 -0
  117. package/dist/postgres-result-DJS3wvIm.mjs.map +1 -0
  118. package/dist/postgres.d.mts +1 -2
  119. package/dist/postgres.mjs +1 -1
  120. package/dist/postgres.mjs.map +1 -1
  121. package/dist/provider-limits-BFNR7ect.mjs +2 -0
  122. package/dist/provider-limits-BFNR7ect.mjs.map +1 -0
  123. package/dist/query-CRk65A10.mjs +2 -0
  124. package/dist/query-CRk65A10.mjs.map +1 -0
  125. package/dist/result-parsing-Cz_70EEo.mjs +2 -0
  126. package/dist/result-parsing-Cz_70EEo.mjs.map +1 -0
  127. package/dist/result-shape-C6DTrvE7.mjs +2 -0
  128. package/dist/result-shape-C6DTrvE7.mjs.map +1 -0
  129. package/dist/scalar-BHqCUxvI.mjs +3 -0
  130. package/dist/scalar-BHqCUxvI.mjs.map +1 -0
  131. package/dist/schema/json.d.mts +402 -0
  132. package/dist/schema/json.mjs +2 -0
  133. package/dist/schema/json.mjs.map +1 -0
  134. package/dist/schema-B5AlBiMF.mjs +2 -0
  135. package/dist/schema-B5AlBiMF.mjs.map +1 -0
  136. package/dist/schema-introspection-CvcX4eiL.mjs +6 -0
  137. package/dist/schema-introspection-CvcX4eiL.mjs.map +1 -0
  138. package/dist/schema-introspection-DX2khdQD.d.mts +28 -0
  139. package/dist/schema.d.mts +5 -293
  140. package/dist/schema.mjs +1 -2
  141. package/dist/sql-CWQw6DuO.d.mts +79 -0
  142. package/dist/sql-m8LT-phW.mjs +2 -0
  143. package/dist/sql-m8LT-phW.mjs.map +1 -0
  144. package/dist/sql-statement-tokens-D-69HPb3.mjs +3 -0
  145. package/dist/sql-statement-tokens-D-69HPb3.mjs.map +1 -0
  146. package/dist/sql.d.mts +2 -0
  147. package/dist/sql.mjs +1 -0
  148. package/dist/sqlite-adapter-5A1l0zRR.mjs +2 -0
  149. package/dist/sqlite-adapter-5A1l0zRR.mjs.map +1 -0
  150. package/dist/sqlite-utils-B-ZXbPld.mjs +2 -0
  151. package/dist/sqlite-utils-B-ZXbPld.mjs.map +1 -0
  152. package/dist/sqlite3.d.mts +1 -2
  153. package/dist/sqlite3.mjs +1 -1
  154. package/dist/sqlite3.mjs.map +1 -1
  155. package/dist/standard-sql-C9_gwkkx.mjs +6 -0
  156. package/dist/standard-sql-C9_gwkkx.mjs.map +1 -0
  157. package/dist/string-CampokWL.d.mts +7359 -0
  158. package/dist/suppressed-failure-BfDwdVMf.mjs +2 -0
  159. package/dist/suppressed-failure-BfDwdVMf.mjs.map +1 -0
  160. package/dist/to-many-DAZulS0R.mjs +2 -0
  161. package/dist/to-many-DAZulS0R.mjs.map +1 -0
  162. package/dist/transaction-D_cuO0Xf.mjs +2 -0
  163. package/dist/transaction-D_cuO0Xf.mjs.map +1 -0
  164. package/dist/transaction-operation-cpNxZs6g.mjs +2 -0
  165. package/dist/transaction-operation-cpNxZs6g.mjs.map +1 -0
  166. package/dist/types-Cf86fj4l.mjs +2 -0
  167. package/dist/types-Cf86fj4l.mjs.map +1 -0
  168. package/dist/utils-CGDt90z6.mjs +33 -0
  169. package/dist/utils-CGDt90z6.mjs.map +1 -0
  170. package/dist/v-DdH9EVw3.mjs +2 -0
  171. package/dist/v-DdH9EVw3.mjs.map +1 -0
  172. package/dist/validation-CCzz_0rK.mjs +2 -0
  173. package/dist/validation-CCzz_0rK.mjs.map +1 -0
  174. package/dist/validation-DTF9uqJ7.mjs +2 -0
  175. package/dist/validation-DTF9uqJ7.mjs.map +1 -0
  176. package/dist/validation.d.mts +2 -2
  177. package/dist/validation.mjs +1 -1
  178. package/dist/validator-uxmHWfxg.mjs +2 -0
  179. package/dist/validator-uxmHWfxg.mjs.map +1 -0
  180. package/dist/value-guards-CSMKqF92.mjs +2 -0
  181. package/dist/value-guards-CSMKqF92.mjs.map +1 -0
  182. package/dist/version-BPl6hw4y.mjs +2 -0
  183. package/dist/version-BPl6hw4y.mjs.map +1 -0
  184. package/package.json +119 -41
  185. package/dist/client-CgdtiDGV.mjs +0 -2
  186. package/dist/client-CgdtiDGV.mjs.map +0 -1
  187. package/dist/cloudflare-kv-DauXhtnT.d.mts +0 -1110
  188. package/dist/d1-http.d.mts +0 -3
  189. package/dist/d1-http.mjs +0 -2
  190. package/dist/d1-http.mjs.map +0 -1
  191. package/dist/driver-B_vBzQ6A.mjs +0 -2
  192. package/dist/driver-B_vBzQ6A.mjs.map +0 -1
  193. package/dist/driver-Cj1EbciY.mjs +0 -2
  194. package/dist/driver-Cj1EbciY.mjs.map +0 -1
  195. package/dist/errors-DvcqIdEo.mjs +0 -2
  196. package/dist/errors-DvcqIdEo.mjs.map +0 -1
  197. package/dist/helper-cDCDjRAD.d.mts +0 -3020
  198. package/dist/helpers-WNr9B-2U.mjs +0 -2
  199. package/dist/helpers-WNr9B-2U.mjs.map +0 -1
  200. package/dist/hydration-CFnwc7j6.mjs +0 -2
  201. package/dist/hydration-CFnwc7j6.mjs.map +0 -1
  202. package/dist/index-3sdVKfeG.d.mts +0 -1447
  203. package/dist/index-BGmpst1h.d.mts +0 -2158
  204. package/dist/mysql-adapter-0catKeCI.mjs +0 -6
  205. package/dist/mysql-adapter-0catKeCI.mjs.map +0 -1
  206. package/dist/mysql-utils-BPw9qhac.mjs +0 -2
  207. package/dist/mysql-utils-BPw9qhac.mjs.map +0 -1
  208. package/dist/native-types-BwICkVjz.mjs +0 -2
  209. package/dist/native-types-BwICkVjz.mjs.map +0 -1
  210. package/dist/pending-operation-CkzYTpi4.mjs +0 -2
  211. package/dist/pending-operation-CkzYTpi4.mjs.map +0 -1
  212. package/dist/postgres-adapter-Blzqj1bl.mjs +0 -6
  213. package/dist/postgres-adapter-Blzqj1bl.mjs.map +0 -1
  214. package/dist/push-qZreXYkb.mjs +0 -252
  215. package/dist/push-qZreXYkb.mjs.map +0 -1
  216. package/dist/result-parsing-FNQbuHvC.mjs +0 -2
  217. package/dist/result-parsing-FNQbuHvC.mjs.map +0 -1
  218. package/dist/schema-DeAJZocc.mjs +0 -2
  219. package/dist/schema-DeAJZocc.mjs.map +0 -1
  220. package/dist/schema.mjs.map +0 -1
  221. package/dist/spans-CJt5UgbJ.mjs +0 -2
  222. package/dist/spans-CJt5UgbJ.mjs.map +0 -1
  223. package/dist/sqlite-adapter-5Em_-oGU.mjs +0 -6
  224. package/dist/sqlite-adapter-5Em_-oGU.mjs.map +0 -1
  225. package/dist/sqlite-utils-BW7elKTz.mjs +0 -2
  226. package/dist/sqlite-utils-BW7elKTz.mjs.map +0 -1
  227. package/dist/tracer-CGzIAsj8.mjs +0 -2
  228. package/dist/tracer-CGzIAsj8.mjs.map +0 -1
  229. package/dist/validation-RtU-wu4N.mjs +0 -2
  230. package/dist/validation-RtU-wu4N.mjs.map +0 -1
  231. package/dist/validator-DpJsJcd7.mjs +0 -3
  232. package/dist/validator-DpJsJcd7.mjs.map +0 -1
  233. 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-like API** | Familiar `findMany`, `create`, `update` operations with `where`, `include`, `select` |
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/drivers/pglite";
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.oneToMany(() => post),
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.manyToOne(() => user).fields("authorId").references("id"),
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.oneToMany(() => post),
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.manyToOne(() => user).fields("authorId").references("id"),
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/drivers/pglite";
84
- import { push } from "viborm/migrations";
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 schema to database (creates tables)
93
- await push(orm, schema);
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 two modes:
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
- // All operations execute in a single transaction
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 includes built-in query caching with TTL and stale-while-revalidate (SWR) support.
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/drivers/pglite";
169
- import { MemoryCache } from "viborm/cache";
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
- schema,
173
- cache: new MemoryCache(),
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/drivers/pglite";
335
+ import { createClient } from "viborm/pglite";
336
+ import { instrumentation } from "viborm/instrumentation";
232
337
 
233
- const orm = createClient({
234
- schema,
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 environments, provide a `waitUntil` function to ensure background operations complete:
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
- schema,
260
- waitUntil: ctx.waitUntil.bind(ctx),
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
- ## Field Types
375
+ ## Scalar Types
270
376
 
271
377
  | Type | Description | Example |
272
378
  |------|-------------|---------|
273
- | `string()` | Text fields | `s.string().unique()` |
379
+ | `string()` | Text scalars | `s.string().unique()` |
274
380
  | `int()` | 32-bit integers | `s.int().default(0)` |
275
- | `float()` | Floating-point | `s.float()` |
276
- | `decimal()` | High-precision decimals | `s.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 | `s.point()` |
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() // 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 **10-layer architecture**. Each layer has an `AGENTS.md` with detailed documentation.
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
- │ ├── fields/ Field types with State generic pattern
485
+ │ ├── scalars/ Scalar types with State generic pattern
343
486
  │ ├── model/ Model composition, query schemas
344
- │ ├── relation/ Relation types (oneToMany, manyToOne, etc.)
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
- │ 12 drivers: pglite, pg, postgres, neon-http, bun-sql,
355
- │ mysql2, planetscale, sqlite3, libsql, d1, d1-http, bun-sqlite
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
- └── migrations/ L10 Schema diffing, push
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 field modifier returns a NEW instance. `s.string().nullable()` returns a new field, doesn't mutate.
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"; // src/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 field type | `src/schema/fields/AGENTS.md` |
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
- ├── fields/ Schema generation per field type
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 Field union update | New field type invisible | Update `src/schema/fields/base.ts` |
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 (oneToOne, oneToMany, manyToOne, manyToMany)
493
- - Nested writes (connect, disconnect, create, update, delete)
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
- - All field types (string, int, float, boolean, dateTime, json, enum, etc.)
496
- - PostgreSQL, MySQL, and SQLite adapters
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
- - MySQL migrations not yet implemented
503
-
504
- **Future features** (documented in `features-docs/`):
505
- - Polymorphic relations
506
- - Recursive queries (WITH RECURSIVE)
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
- field["~"].state // FieldState - configuration object
518
- field["~"].schemas // {base, filter, create, update} - lazy built
519
- model["~"].schemas.where // Where schema for this model
520
- relation["~"].targetModel // Thunk to target model
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,2 @@
1
+ import{c as e}from"./native-types-UAbMZ16d.mjs";function t(t,n,r){Object.defineProperty(t,`namespace`,{value:n===void 0?void 0:e(n,r),writable:!1,enumerable:!0,configurable:!1})}export{t};
2
+ //# sourceMappingURL=adapter-namespace-DEKd5hIN.mjs.map
@@ -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"}
@@ -1,2 +1,2 @@
1
- import { _ as InsertParts, a as SchemaError, c as SQLiteAdapter, d as postgresAdapter, f as MySQLAdapter, g as DeleteParts, h as DatabaseAdapter, i as QueryError, l as sqliteAdapter, m as CastType, n as AdapterError, o as ValidationError, p as mysqlAdapter, r as ConnectionError, s as ValidationRule, t as ASTError, u as PostgresAdapter, v as QueryParts, y as UpdateParts } from "./index-BGmpst1h.mjs";
2
- export { ASTError, AdapterError, CastType, ConnectionError, DatabaseAdapter, DeleteParts, InsertParts, MySQLAdapter, PostgresAdapter, QueryError, QueryParts, SQLiteAdapter, SchemaError, UpdateParts, ValidationError, ValidationRule, mysqlAdapter, postgresAdapter, sqliteAdapter };
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-Blzqj1bl.mjs";import{n,t as r}from"./mysql-adapter-0catKeCI.mjs";import{n as i,t as a}from"./sqlite-adapter-5Em_-oGU.mjs";export{r as MySQLAdapter,t as PostgresAdapter,a as SQLiteAdapter,n as mysqlAdapter,e as postgresAdapter,i as sqliteAdapter};
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