okmodel 0.8.0 → 0.9.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 (237) hide show
  1. package/README.md +23 -1
  2. package/dist/adapters/pg/bunsql-extra.d.ts +5 -5
  3. package/dist/adapters/pg/bunsql.d.ts +6 -2
  4. package/dist/adapters/pg/nodepostgres.d.ts +16 -1
  5. package/dist/adapters/pg/postgres-extra.d.ts +3 -17
  6. package/dist/adapters/pg/postgresjs.d.ts +2 -1
  7. package/dist/contracts/driver.d.ts +3 -2
  8. package/dist/contracts/error.d.ts +1 -1
  9. package/dist/dialects/pg/errors.d.ts +2 -0
  10. package/dist/dialects/pg/ext/btree-gin.d.ts +26 -0
  11. package/dist/dialects/pg/ext/btree-gin.js +20 -0
  12. package/dist/dialects/pg/ext/btree-gist.d.ts +26 -0
  13. package/dist/dialects/pg/ext/btree-gist.js +20 -0
  14. package/dist/dialects/pg/ext/call.d.ts +53 -0
  15. package/dist/dialects/pg/ext/citext.js +1 -1
  16. package/dist/dialects/pg/ext/feature.d.ts +26 -0
  17. package/dist/dialects/pg/ext/fuzzystrmatch.d.ts +34 -0
  18. package/dist/dialects/pg/ext/fuzzystrmatch.js +33 -0
  19. package/dist/dialects/pg/ext/hstore.d.ts +41 -0
  20. package/dist/dialects/pg/ext/hstore.js +29 -0
  21. package/dist/dialects/pg/ext/index.d.ts +56 -0
  22. package/dist/dialects/pg/ext/index.js +1 -1
  23. package/dist/dialects/pg/ext/ltree.d.ts +41 -0
  24. package/dist/dialects/pg/ext/ltree.js +29 -0
  25. package/dist/dialects/pg/ext/pg-trgm.js +4 -13
  26. package/dist/dialects/pg/ext/pgcrypto.d.ts +33 -0
  27. package/dist/dialects/pg/ext/pgcrypto.js +33 -0
  28. package/dist/dialects/pg/ext/unaccent.d.ts +26 -0
  29. package/dist/dialects/pg/ext/unaccent.js +21 -0
  30. package/dist/dialects/pg/ext/using.d.ts +23 -0
  31. package/dist/dialects/pg/ext/versions.d.ts +36 -0
  32. package/dist/dialects/pg/external.d.ts +19 -0
  33. package/dist/dialects/pg/filters.d.ts +2 -2
  34. package/dist/dialects/pg/fn/index.js +5 -5
  35. package/dist/dialects/pg/index.d.ts +1 -0
  36. package/dist/dialects/pg/index.js +19 -14
  37. package/dist/dialects/pg/introspect.d.ts +12 -0
  38. package/dist/dialects/pg/view/index.js +7 -7
  39. package/dist/dialects/pg/view/scratch.d.ts +4 -1
  40. package/dist/runtime/artifact-file.d.ts +22 -0
  41. package/dist/runtime/client.d.ts +10 -0
  42. package/dist/runtime/drift-detail.d.ts +2 -1
  43. package/dist/runtime/drift.d.ts +3 -10
  44. package/dist/runtime/param-limit.d.ts +20 -0
  45. package/dist/runtime/pg/bun.js +4 -4
  46. package/dist/runtime/pg/neon.js +4 -4
  47. package/dist/runtime/pg/pg.js +4 -4
  48. package/dist/runtime/pg/pglite.js +4 -4
  49. package/dist/runtime/pg/postgresjs.js +11 -11
  50. package/dist/runtime/server-check.d.ts +36 -6
  51. package/dist/runtime/tenancy/index.js +1 -1
  52. package/dist/runtime/traits/index.js +6 -6
  53. package/dist/runtime/validate/index.js +2 -2
  54. package/dist/runtime/write.d.ts +1 -1
  55. package/dist/shared/{4m6hskg8.js → 0j6qe91y.js} +4 -4
  56. package/dist/shared/{6m78c8ss.js → 1h5h1rf5.js} +1 -1
  57. package/dist/shared/{4vbf83xx.js → 2vcnpf0n.js} +1 -1
  58. package/dist/shared/{qd9hhd8f.js → 3ap5hxvj.js} +2 -1
  59. package/dist/shared/{v1wad97q.js → 3d7a80fq.js} +1 -1
  60. package/dist/shared/{wcrheftc.js → 3dr444ny.js} +58 -79
  61. package/dist/shared/{hm5f8jby.js → 3vvpcphd.js} +8 -7
  62. package/dist/shared/{760ppr76.js → 4a3mmhhe.js} +2 -2
  63. package/dist/shared/{mkrn359n.js → 4pkz5nvw.js} +222 -39
  64. package/dist/shared/{agsfb86s.js → 4te76xc5.js} +4 -4
  65. package/dist/shared/{63f4ksbz.js → 60y4ahmw.js} +1 -1
  66. package/dist/shared/61bmrmhr.js +35 -0
  67. package/dist/shared/{bxas03mq.js → 63qjmhnp.js} +100 -17
  68. package/dist/shared/{g5yc06ka.js → 67w3kn71.js} +1 -1
  69. package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
  70. package/dist/shared/{njga14v4.js → 6vfvsdkt.js} +10 -8
  71. package/dist/shared/{kj9d8maq.js → 6xqvesa5.js} +1 -1
  72. package/dist/shared/8gdbty5v.js +665 -0
  73. package/dist/shared/{pan0370z.js → 8ma6drzr.js} +211 -30
  74. package/dist/shared/{mnvjvqyp.js → 8p2bgye0.js} +124 -32
  75. package/dist/shared/{mfedzr74.js → 8qwqrxed.js} +14 -6
  76. package/dist/shared/{hfqmpasr.js → 8v7vzpgt.js} +11 -8
  77. package/dist/shared/{7ghwamrf.js → 99qp9vtg.js} +1 -1
  78. package/dist/shared/{zgex00fd.js → ak61ye1f.js} +5 -5
  79. package/dist/shared/{dpc2r7rb.js → bdekbvmt.js} +218 -95
  80. package/dist/shared/{jebgrkeq.js → bxjq6xqv.js} +2 -2
  81. package/dist/shared/c7dqd3gk.js +1806 -0
  82. package/dist/shared/ddh72ym5.js +20 -0
  83. package/dist/shared/e1c55v04.js +10 -0
  84. package/dist/shared/{mtw6jz76.js → e275q7sd.js} +1 -1
  85. package/dist/shared/{k86n8vq3.js → ekhq3ytz.js} +1 -1
  86. package/dist/shared/esy4dyxe.js +17 -0
  87. package/dist/shared/{gcefca6p.js → f9t9g54z.js} +22 -9
  88. package/dist/shared/{sjk86yrx.js → fk9vef30.js} +84 -73
  89. package/dist/shared/fkjne6gx.js +8 -0
  90. package/dist/shared/{e8zyaqvj.js → fne90dvz.js} +4 -1
  91. package/dist/shared/{needfe47.js → g89fmz5s.js} +1 -1
  92. package/dist/shared/{m4xff2a6.js → ghqzdp94.js} +2 -2
  93. package/dist/shared/{n0jmpgj1.js → gr9sn4za.js} +1 -1
  94. package/dist/shared/{5mtf6cj3.js → gzgfsspx.js} +5 -2
  95. package/dist/shared/h9811jjm.js +17 -0
  96. package/dist/shared/{z581d7ny.js → hgt69zjf.js} +2 -2
  97. package/dist/shared/{35q0n9tz.js → jvxcp1qk.js} +71 -87
  98. package/dist/shared/k73e8n9d.js +136 -0
  99. package/dist/shared/{195pzzzz.js → kzgrcy8s.js} +12 -8
  100. package/dist/shared/kzgrnckd.js +29 -0
  101. package/dist/shared/{p3xbdcvt.js → mz48rs74.js} +68 -8
  102. package/dist/shared/{zbqbmmrp.js → n6je5b28.js} +13 -26
  103. package/dist/shared/{b6d6p0zc.js → ns35jqz0.js} +75 -49
  104. package/dist/shared/{n05z9nwz.js → nstwgzn8.js} +1 -1
  105. package/dist/{tooling/shared/08kemxjd.js → shared/pgsak1yw.js} +1 -1
  106. package/dist/shared/py2zrrm6.js +451 -0
  107. package/dist/shared/{9dr2qnx7.js → qqm3ze6q.js} +1 -1
  108. package/dist/shared/{wvdjznah.js → rcjm0yn7.js} +31 -38
  109. package/dist/shared/rged92v6.js +17 -0
  110. package/dist/shared/{jp36k7dp.js → rw4tpcd0.js} +81 -51
  111. package/dist/shared/{bsek72fg.js → s5qe47a6.js} +3 -0
  112. package/dist/shared/{1d9q9cv2.js → smxzjz60.js} +2 -2
  113. package/dist/shared/{wz2a78mp.js → th5rnaxw.js} +1 -1
  114. package/dist/{tooling/shared/rs1jb051.js → shared/tr64w5p0.js} +1 -1
  115. package/dist/shared/{14x60fbf.js → tyqapcgk.js} +73 -10
  116. package/dist/shared/vsna85qf.js +8 -0
  117. package/dist/shared/{63qtkrca.js → vy47ryqa.js} +55 -5
  118. package/dist/shared/{jx2m62cs.js → wbdh9qbg.js} +7 -5
  119. package/dist/shared/{f4jy1j7x.js → wp7y8q3y.js} +946 -105
  120. package/dist/shared/{16kvjebh.js → xbd9xs6p.js} +7 -26
  121. package/dist/shared/{bah9nbg3.js → xbvz446k.js} +18 -23
  122. package/dist/shared/{p5nh3r8q.js → y6tfjk9q.js} +2 -2
  123. package/dist/shared/{3bb7wsqt.js → ycnft340.js} +1 -1
  124. package/dist/shared/{z7s6fpxv.js → ymenf259.js} +1 -1
  125. package/dist/shared/{0wrea3jq.js → ysdw2fg3.js} +10 -2
  126. package/dist/shared/zecrwdk9.js +61 -0
  127. package/dist/shared/{3t6kw83m.js → zm2rzqba.js} +2 -1
  128. package/dist/tooling/cli.js +200 -50
  129. package/dist/tooling/driver-run.js +109 -343
  130. package/dist/tooling/github/comment.d.ts +56 -0
  131. package/dist/tooling/github/post-comment.d.ts +17 -0
  132. package/dist/tooling/migrate/apply.d.ts +17 -2
  133. package/dist/tooling/migrate/commands.d.ts +2 -1
  134. package/dist/tooling/migrate/config.d.ts +13 -0
  135. package/dist/tooling/migrate/drift.d.ts +12 -0
  136. package/dist/tooling/migrate/driver-url.d.ts +17 -0
  137. package/dist/tooling/migrate/export.d.ts +165 -0
  138. package/dist/tooling/migrate/ext-surface.d.ts +80 -0
  139. package/dist/tooling/migrate/ext.d.ts +31 -4
  140. package/dist/tooling/migrate/import-drizzle.d.ts +40 -0
  141. package/dist/tooling/migrate/index.d.ts +3 -0
  142. package/dist/tooling/migrate/index.js +57 -10
  143. package/dist/tooling/migrate/lint-rules.d.ts +18 -1
  144. package/dist/tooling/migrate/lint.d.ts +14 -1
  145. package/dist/tooling/migrate/place.d.ts +18 -0
  146. package/dist/tooling/migrate/plan-json.d.ts +65 -0
  147. package/dist/tooling/migrate/policy.d.ts +17 -5
  148. package/dist/tooling/migrate/pooler-probe.d.ts +23 -0
  149. package/dist/tooling/migrate/project.d.ts +10 -1
  150. package/dist/tooling/migrate/pull-emit.d.ts +98 -0
  151. package/dist/tooling/migrate/pull-routines.d.ts +126 -0
  152. package/dist/tooling/migrate/pull-verify.d.ts +26 -0
  153. package/dist/tooling/migrate/pull.d.ts +65 -0
  154. package/dist/tooling/migrate/reprint.d.ts +32 -0
  155. package/dist/tooling/migrate/runner.d.ts +24 -1
  156. package/dist/tooling/migrate/sandbox.d.ts +8 -2
  157. package/dist/tooling/migrate/schema-api.d.ts +43 -0
  158. package/dist/tooling/migrate/sql-lex.d.ts +18 -0
  159. package/dist/tooling/shared/{ppnnnvj8.js → 09a6vsys.js} +1 -1
  160. package/dist/tooling/shared/{7ae7rjmn.js → 0v9ptnxp.js} +8 -8
  161. package/dist/tooling/shared/{fb9k2qwd.js → 0wtzps9p.js} +11 -30
  162. package/dist/tooling/shared/{a6pp9d12.js → 0yhf1db4.js} +6 -6
  163. package/dist/tooling/shared/{dy672fz6.js → 19msgrsc.js} +2 -2
  164. package/dist/{shared/q0cqt2sp.js → tooling/shared/1fwfm5m3.js} +1 -1
  165. package/dist/tooling/shared/{f9mphxej.js → 2jdn09e2.js} +401 -24
  166. package/dist/tooling/shared/{jne7b93p.js → 2qrte2ct.js} +5 -5
  167. package/dist/tooling/shared/{5bvw2nev.js → 2v4nwnkb.js} +1 -1
  168. package/dist/tooling/shared/{spk1jg3r.js → 33z39trp.js} +106 -23
  169. package/dist/tooling/shared/{z8d7ptht.js → 353vnw9z.js} +5 -5
  170. package/dist/tooling/shared/{dw08f3m8.js → 390kry9g.js} +2 -2
  171. package/dist/tooling/shared/{xjs6zqtc.js → 3f6etb9z.js} +18 -31
  172. package/dist/{shared/bnby0esn.js → tooling/shared/3t2cqmsx.js} +1 -1
  173. package/dist/tooling/shared/{wwnekq5n.js → 4dzvjtpy.js} +1 -1
  174. package/dist/tooling/shared/{y5656f0e.js → 4ec0nxvw.js} +10 -10
  175. package/dist/tooling/shared/{3m1hkg7z.js → 4tg2bn41.js} +59 -78
  176. package/dist/tooling/shared/{zvnhh1n0.js → 5rah55z0.js} +2 -2
  177. package/dist/tooling/shared/{pqy21k24.js → 804w1t69.js} +4 -4
  178. package/dist/tooling/shared/8g0m0rvd.js +134 -0
  179. package/dist/tooling/shared/8msbtw5s.js +8 -0
  180. package/dist/tooling/shared/{4d2w25vw.js → 8t22h3h7.js} +2 -2
  181. package/dist/tooling/shared/{smn6kz1p.js → 91c59b7b.js} +2 -2
  182. package/dist/tooling/shared/{aftb2mwr.js → adk9k6va.js} +1 -1
  183. package/dist/tooling/shared/{j9t5s12a.js → ajjd5cwz.js} +2 -2
  184. package/dist/tooling/shared/{cmptmb4f.js → angjck01.js} +1 -1
  185. package/dist/tooling/shared/{yw30vnq2.js → asnnc3v5.js} +1 -1
  186. package/dist/tooling/shared/{ma2340rx.js → bj1kyqc8.js} +2 -2
  187. package/dist/tooling/shared/{2wtvc7rw.js → bt3tjemb.js} +11 -3
  188. package/dist/tooling/shared/{ec71zqgt.js → chk2bh4f.js} +2 -2
  189. package/dist/tooling/shared/{gmcf9cxf.js → ckq4z5ax.js} +5 -2
  190. package/dist/tooling/shared/{w7qe8sj1.js → d3rhb24q.js} +1 -1
  191. package/dist/tooling/shared/{y031jct9.js → d8q00vxg.js} +4 -4
  192. package/dist/tooling/shared/{vs0t6qt8.js → dx188rxs.js} +2 -2
  193. package/dist/tooling/shared/{g9ad4n80.js → efq6p9df.js} +35 -42
  194. package/dist/tooling/shared/{ddjtfgnx.js → en6rwzq0.js} +3 -3
  195. package/dist/tooling/shared/{6nyfyw70.js → f2r5g0fs.js} +2 -2
  196. package/dist/tooling/shared/{03k6res6.js → f4gep0nk.js} +1 -1
  197. package/dist/tooling/shared/{gfvtj6d0.js → f8a010fm.js} +13 -11
  198. package/dist/tooling/shared/{3tq8pnb8.js → fdsek6pa.js} +1 -1
  199. package/dist/tooling/shared/fvmrxsd1.js +8 -0
  200. package/dist/tooling/shared/{733a1tq3.js → g3xybeqf.js} +4 -3
  201. package/dist/tooling/shared/{pwsytxm5.js → gefmpwsa.js} +1 -1
  202. package/dist/tooling/shared/{mtrqn2hn.js → gjj71hfh.js} +25 -30
  203. package/dist/tooling/shared/{8sqrsw3s.js → jgzt69pa.js} +5 -5
  204. package/dist/tooling/shared/{nf7jmhfa.js → jm30k2ca.js} +10 -8
  205. package/dist/tooling/shared/{vx86qjv8.js → kayqzpbk.js} +6 -3
  206. package/dist/tooling/shared/{zhwnfyb2.js → kvw1672d.js} +1 -1
  207. package/dist/tooling/shared/{rq5kk8j6.js → mr1kcgpw.js} +3 -3
  208. package/dist/tooling/shared/{72fyg4zv.js → mwbdf409.js} +1 -1
  209. package/dist/tooling/shared/{wt7j7nf6.js → ns9207v3.js} +1 -1
  210. package/dist/tooling/shared/{9xzm7hjg.js → p6tjv97k.js} +3 -3
  211. package/dist/tooling/shared/{yfr8hzhm.js → p73evwf0.js} +1 -1
  212. package/dist/tooling/shared/{dzx85q70.js → phc1nc4g.js} +1 -1
  213. package/dist/tooling/shared/{417zdsk7.js → ppybjw50.js} +79 -16
  214. package/dist/tooling/shared/{yk9mp7vb.js → qdrn8ghn.js} +5 -4
  215. package/dist/tooling/shared/rd8h01ta.js +20 -0
  216. package/dist/tooling/shared/{bz2dqhab.js → rwg8y90m.js} +3 -3
  217. package/dist/tooling/shared/{xhrnjch9.js → ry2f3w8p.js} +3 -3
  218. package/dist/tooling/shared/{a7q7t4n3.js → ryc5sa58.js} +8 -8
  219. package/dist/tooling/shared/{2revefqt.js → ss87qxwv.js} +2 -2
  220. package/dist/tooling/shared/{rf83gr2d.js → vg68k11z.js} +7 -3
  221. package/dist/tooling/shared/{p7f08ktn.js → vms9dta5.js} +73 -89
  222. package/dist/tooling/shared/{3rrw5w8f.js → xchpnbdv.js} +1 -1
  223. package/dist/tooling/shared/{djydjpqt.js → xn6p01fh.js} +5 -5
  224. package/dist/tooling/shared/{9kazs5p6.js → xwr6q618.js} +3 -3
  225. package/dist/tooling/shared/{ep8zh3bk.js → xx3gmq94.js} +1 -1
  226. package/dist/tooling/shared/{tn8gay14.js → y2bd7yfx.js} +21 -13
  227. package/dist/tooling/shared/{vraj6d74.js → y4gq9rbe.js} +11 -11
  228. package/dist/tooling/shared/y4vwft92.js +9 -0
  229. package/dist/tooling/shared/{345tbc2k.js → yz68xcmc.js} +1 -1
  230. package/dist/tooling/testing/factories.d.ts +1 -3
  231. package/dist/tooling/testing/index.js +2 -2
  232. package/package.json +39 -9
  233. package/dist/shared/3449rcae.js +0 -14
  234. package/dist/shared/fjpnhqan.js +0 -71
  235. package/dist/shared/n41w4fbz.js +0 -113
  236. package/dist/tooling/shared/pw8fgahx.js +0 -69
  237. /package/dist/shared/{ae4j5f42.js → mfvx6kjx.js} +0 -0
package/README.md CHANGED
@@ -50,7 +50,15 @@ bun add okmodel @electric-sql/pglite
50
50
  bun add okmodel
51
51
  ```
52
52
 
53
- postgres.js is the default on Node and Bun. node-postgres is for a project that already has `pg`. PGlite runs Postgres in the process. The last line is Bun.sql, built into Bun, and it runs only there.
53
+ postgres.js is the default on Node and Bun. node-postgres is for a project that already has `pg`. PGlite runs Postgres in the process. The last line is Bun.sql, built into Bun 1.4+, and it runs only there.
54
+
55
+ Date and time columns need a `Temporal` global. Bun and Node 26 have it. On Node 22 and 24 assign a polyfill before those columns run (OKM1210 when it is missing). Example with `temporal-polyfill` (not part of the quickstart script):
56
+
57
+ ```typescript
58
+ import { Temporal } from "temporal-polyfill";
59
+
60
+ globalThis.Temporal = Temporal;
61
+ ```
54
62
 
55
63
  ## Quick start
56
64
 
@@ -135,6 +143,20 @@ export async function removeNote(id: string) {
135
143
 
136
144
  `okm push` is for a database you can recreate. A shared database uses reviewed migrations: `okm generate init`, then `okm migrate apply`.
137
145
 
146
+ ## 0.9
147
+
148
+ This release is the tooling train. `okm pull` writes schema files from a database. `okm import drizzle` writes them from a Drizzle schema. Several catalogs share one database through `external()` and `okm catalog export`. `describe` and `buildCatalog` are on `okmodel/migrate`. Extension packs cover `unaccent`, `hstore`, `ltree`, `btree_gist`, `btree_gin`, `fuzzystrmatch`, and `pgcrypto`. The GitHub Action posts the migration plan on a pull request. A type change that rewrites a table is five migrations, not one `ALTER COLUMN … TYPE`.
149
+
150
+ | Want… | Go to |
151
+ | ----------------------- | ---------------------------------------------------------------------- |
152
+ | Pull a database | [pull](https://okm.omqkhafi.dev/docs/reference/cli#pull) |
153
+ | Import Drizzle | [From Drizzle](https://okm.omqkhafi.dev/docs/start/from-drizzle) |
154
+ | Several catalogs | [Catalogs](https://okm.omqkhafi.dev/docs/define/schema/catalogs) |
155
+ | `describe` | [Schema API](https://okm.omqkhafi.dev/docs/reference/schema-api) |
156
+ | Extension packs | [Extensions](https://okm.omqkhafi.dev/docs/define/schema/extensions) |
157
+ | The GitHub Action | [GitHub Action](https://okm.omqkhafi.dev/docs/reference/github-action) |
158
+ | A rewriting type change | [Type change](https://okm.omqkhafi.dev/docs/reference/type-change) |
159
+
138
160
  ## Next
139
161
 
140
162
  | Want… | Go to |
@@ -4,14 +4,15 @@
4
4
  * Loaded on the first reserve, batch, stream, or dead connection. A read that
5
5
  * succeeds does not use it.
6
6
  */
7
- import type { ReservedSQL, SQL } from "./bun-sql.js";
7
+ import type { SQL } from "./bun-sql.js";
8
8
  import type { DriverConnection, WireValue } from "../../contracts/driver.js";
9
9
  import { type HeldPool } from "./bunsql.js";
10
10
  /**
11
11
  * Checks out one connection and clears it on release.
12
12
  *
13
- * A connection that is gone is neither reset nor parked: Bun.sql has already
14
- * dropped it, and parking it would hand a dead session to the next caller.
13
+ * A connection that is gone is neither reset nor returned to the pool: Bun.sql
14
+ * has already dropped it. A reset or release failure after the caller's work
15
+ * finished destroys the handle and does not fail the call.
15
16
  *
16
17
  * @param held - The pool and its counters
17
18
  * @returns A connection the caller must release
@@ -45,13 +46,12 @@ export declare function drainClosed(sql: SQL): Promise<void>;
45
46
  * Subscribes on one pooled connection.
46
47
  *
47
48
  * @param sql - The pool
48
- * @param parked - Reserved handles to put back first
49
49
  * @param closed - The pool is closed
50
50
  * @param channel - Notify channel
51
51
  * @param onNotify - Payload callback
52
52
  * @returns Stops the subscription
53
53
  */
54
- export declare function listen(sql: SQL, parked: ReservedSQL[], closed: boolean, channel: string, onNotify: (payload: string) => void): Promise<() => Promise<void>>;
54
+ export declare function listen(sql: SQL, closed: boolean, channel: string, onNotify: (payload: string) => void): Promise<() => Promise<void>>;
55
55
  export declare function checkout(held: HeldPool): Promise<DriverConnection & {
56
56
  evict(): void;
57
57
  }>;
@@ -36,7 +36,6 @@ export type BunSqlConfig = DriverPoolConfig & {
36
36
  /** What a checkout needs from the pool that opened it. */
37
37
  export type HeldPool = {
38
38
  readonly sql: SQL;
39
- readonly parked: ReservedSQL[];
40
39
  readonly acquireMs: number | undefined;
41
40
  readonly counters: Counters;
42
41
  readonly notices: ReturnType<typeof noticeBuffer>;
@@ -70,4 +69,9 @@ export type Counters = {
70
69
  export declare function open(config: BunSqlConfig): DriverPool;
71
70
  export declare function send(sql: SQL, text: string, params: readonly WireValue[] | undefined): WireQuery;
72
71
  export declare function reserve(sql: SQL, acquireMs: number | undefined, counters: Counters): Promise<ReservedSQL>;
73
- export declare function park(parked: ReservedSQL[], reserved: ReservedSQL): Promise<void>;
72
+ /**
73
+ * Returns a reserved handle to Bun's pool.
74
+ *
75
+ * @param reserved - The handle to release
76
+ */
77
+ export declare function releaseReserved(reserved: ReservedSQL): Promise<void>;
@@ -55,7 +55,22 @@ export type Counters = {
55
55
  * @param source - Pool or client
56
56
  * @param handle - What to do with the error
57
57
  */
58
- export declare function armDriverError(source: object, handle?: () => void): void;
58
+ export declare function armDriverError(source: object, handle?: (error?: unknown) => void): void;
59
+ /**
60
+ * Records an idle or checked-out client error on the notice path (B-44).
61
+ *
62
+ * Does not throw. The pool has already dropped a dead idle client.
63
+ *
64
+ * @param notices - Pool notice buffer
65
+ * @param error - The `error` event value
66
+ */
67
+ export declare function logClientError(notices: {
68
+ push(notice: {
69
+ severity: string;
70
+ message: string;
71
+ code?: string;
72
+ }): void;
73
+ }, error: unknown): void;
59
74
  /**
60
75
  * Opens a node-postgres pool for one endpoint.
61
76
  *
@@ -29,23 +29,7 @@ export type HeldPool = {
29
29
  * @returns A connection the caller must release
30
30
  */
31
31
  export declare function checkout(pool: HeldPool, timeoutMs?: number): Promise<DriverConnection>;
32
- /**
33
- * Describes a statement.
34
- *
35
- * @param sql - Pool client
36
- * @param text - SQL
37
- * @param params - Wire parameters
38
- * @returns Column names and the parameter count
39
- */
40
32
  export declare function describe(sql: Sql, text: string, params?: readonly WireValue[]): Promise<DescribeResult>;
41
- /**
42
- * Yields cursor chunks.
43
- *
44
- * @param sql - Pool client
45
- * @param text - SQL
46
- * @param params - Wire parameters
47
- * @returns Chunks of wire rows
48
- */
49
33
  export declare function stream(sql: Sql, text: string, params?: readonly WireValue[]): AsyncIterable<readonly (readonly WireValue[])[]>;
50
34
  /**
51
35
  * Settles `run` when `ms` elapses, the reserved connection closes, or every
@@ -80,7 +64,9 @@ export declare function runBatch(pool: HeldPool, statements: readonly Statement[
80
64
  * @param sql - Reserved connection
81
65
  * @param lost - Set when that socket closes
82
66
  */
83
- export declare function watchReserved(sql: Sql, lost: Lost): void;
67
+ declare function arm(sql: Sql, lost: Lost): void;
68
+ /** @inheritdoc */
69
+ export declare const watchReserved: typeof arm;
84
70
  type Gate = {
85
71
  enter(): void;
86
72
  leave(): void;
@@ -53,7 +53,8 @@ export declare function open(config: PostgresJsConfig): DriverPool;
53
53
  export declare class PgSession implements BatchSession {
54
54
  readonly canCancel = true;
55
55
  private transactionDepth;
56
- private readonly sql;
56
+ /** Current client. A storm rebuild assigns a new pool client here. */
57
+ sql: Sql;
57
58
  private readonly counters;
58
59
  private readonly scope;
59
60
  private readonly local;
@@ -162,8 +162,9 @@ export type DriverPoolConfig = {
162
162
  readonly max?: number;
163
163
  /**
164
164
  * Ceilings in milliseconds. An adapter reads `acquire`: it waits for a
165
- * connection up to that long, then fails with OKM1846. Omitted means wait
166
- * without a deadline. The other keys belong to the runtime.
165
+ * connection up to that long, then fails with OKM1846. Omitted means the
166
+ * adapter default (10 s on postgres.js and node-postgres). The other keys
167
+ * belong to the runtime.
167
168
  */
168
169
  readonly timeouts?: DriverTimeouts;
169
170
  };
@@ -31,7 +31,7 @@ export type ColumnCode = (typeof COLUMN_CODES)[number];
31
31
  * These are spec §21 codes. They are a type only, so the runtime entry does
32
32
  * not gain a second registry.
33
33
  */
34
- export type QueryCode = "OKM1101" | "OKM1102" | "OKM1104" | "OKM1105" | "OKM1111" | "OKM1120" | "OKM1121" | "OKM1124" | "OKM1125" | "OKM1130" | "OKM1190" | "OKM1701" | "OKM1704" | "OKM1801" | "OKM1802" | "OKM1803" | "OKM1843";
34
+ export type QueryCode = "OKM1101" | "OKM1102" | "OKM1104" | "OKM1105" | "OKM1111" | "OKM1120" | "OKM1121" | "OKM1124" | "OKM1125" | "OKM1126" | "OKM1130" | "OKM1190" | "OKM1701" | "OKM1704" | "OKM1801" | "OKM1802" | "OKM1803" | "OKM1843";
35
35
  /** Kinds from spec §14, in category order. */
36
36
  export declare const ERROR_KINDS: readonly ["invalid", "not_null", "check", "foreign_key", "unique", "exclusion", "conflict", "not_found", "not_unique", "forbidden", "serialization", "deadlock", "lock_timeout", "timeout", "cancelled", "unavailable", "schema_drift", "driver", "read_only", "outcome_unknown"];
37
37
  /** One spec §14 kind. */
@@ -25,6 +25,8 @@ export type MapPostgresErrorSchema = {
25
25
  type SqlField = {
26
26
  readonly field: string;
27
27
  readonly sql: string;
28
+ /** When true, mapped errors for this table keep values out of `cause` (B-33). */
29
+ readonly sensitive?: boolean;
28
30
  };
29
31
  /** Options for {@link mapPostgresError}. */
30
32
  export type MapPostgresErrorOptions = {
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The `btree_gin` extension. `gin` stores a GIN operator class for scalar equality.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { IndexCall } from "../table.js";
9
+ import { type Extension, type ExtensionOptions } from "./index.js";
10
+ /** `btree_gin` plus the methods the naming overlay selected. */
11
+ export type BtreeGin = Extension & {
12
+ /**
13
+ * A GIN index with `int4_ops`.
14
+ *
15
+ * @param column - SQL column name
16
+ * @returns An index call whose expression is the `using` tail
17
+ */
18
+ gin(column: string): IndexCall;
19
+ };
20
+ /**
21
+ * Declares `btree_gin`.
22
+ *
23
+ * @param options - Schema and version pin
24
+ * @returns The extension object and its methods
25
+ */
26
+ export declare function btreeGin(options?: ExtensionOptions): BtreeGin;
@@ -0,0 +1,20 @@
1
+ import {
2
+ extension2
3
+ } from "../../../shared/6f0z3hzh.js";
4
+ import {
5
+ usingIndex
6
+ } from "../../../shared/h9811jjm.js";
7
+
8
+ // src/dialects/pg/ext/btree-gin.ts
9
+ function btreeGin(options = {}) {
10
+ const declared = extension2("btree_gin", options);
11
+ return {
12
+ ...declared,
13
+ gin(column) {
14
+ return usingIndex(column, "gin", "int4_ops");
15
+ }
16
+ };
17
+ }
18
+ export {
19
+ btreeGin
20
+ };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The `btree_gist` extension. `gist` stores a GiST operator class so an exclude constraint can use `=`.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { IndexCall } from "../table.js";
9
+ import { type Extension, type ExtensionOptions } from "./index.js";
10
+ /** `btree_gist` plus the methods the naming overlay selected. */
11
+ export type BtreeGist = Extension & {
12
+ /**
13
+ * A GiST index with `gist_int4_ops`.
14
+ *
15
+ * @param column - SQL column name
16
+ * @returns An index call whose expression is the `using` tail
17
+ */
18
+ gist(column: string): IndexCall;
19
+ };
20
+ /**
21
+ * Declares `btree_gist`.
22
+ *
23
+ * @param options - Schema and version pin
24
+ * @returns The extension object and its methods
25
+ */
26
+ export declare function btreeGist(options?: ExtensionOptions): BtreeGist;
@@ -0,0 +1,20 @@
1
+ import {
2
+ extension2
3
+ } from "../../../shared/6f0z3hzh.js";
4
+ import {
5
+ usingIndex
6
+ } from "../../../shared/h9811jjm.js";
7
+
8
+ // src/dialects/pg/ext/btree-gist.ts
9
+ function btreeGist(options = {}) {
10
+ const declared = extension2("btree_gist", options);
11
+ return {
12
+ ...declared,
13
+ gist(column) {
14
+ return usingIndex(column, "gist", "gist_int4_ops");
15
+ }
16
+ };
17
+ }
18
+ export {
19
+ btreeGist
20
+ };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * SQL fragments for an extension function or operator.
3
+ *
4
+ * The fragment is the whole predicate, the same way `fragment` is. Values
5
+ * are parameters. The schema and function names are quoted identifiers the
6
+ * generator wrote.
7
+ */
8
+ import { type Fragment } from "../ops/fragment.js";
9
+ /**
10
+ * `schema.fn(column, …) = schema.fn($1)`.
11
+ *
12
+ * @param schema - Install schema
13
+ * @param name - Function name
14
+ * @param value - Parameter
15
+ * @returns A where fragment
16
+ */
17
+ export declare function fnEqualsArg(schema: string, name: string, value: string): Fragment;
18
+ /**
19
+ * `schema.fn(column, $1) = $2::integer`.
20
+ *
21
+ * @param schema - Install schema
22
+ * @param name - Function name
23
+ * @param value - Text argument
24
+ * @param distance - Integer the function result must equal
25
+ * @returns A where fragment
26
+ */
27
+ export declare function fnDistance(schema: string, name: string, value: string, distance: number): Fragment;
28
+ /**
29
+ * `column <op> $1`, with an optional cast on the parameter.
30
+ *
31
+ * @param op - Operator token the generator wrote
32
+ * @param value - Parameter
33
+ * @param cast - SQL type to cast the parameter to, when the operator needs one
34
+ * @returns A where fragment
35
+ */
36
+ export declare function opArg(op: string, value: string, cast?: string): Fragment;
37
+ /**
38
+ * `schema.fn()` as the whole predicate.
39
+ *
40
+ * @param schema - Install schema
41
+ * @param name - Function name
42
+ * @returns A where fragment
43
+ */
44
+ export declare function bareCall(schema: string, name: string): Fragment;
45
+ /**
46
+ * `encode(schema.digest(column, $1), 'hex') = $2`.
47
+ *
48
+ * @param schema - Install schema
49
+ * @param algorithm - Digest algorithm, a parameter
50
+ * @param hex - Expected hex digest, a parameter
51
+ * @returns A where fragment
52
+ */
53
+ export declare function digestEquals(schema: string, algorithm: string, hex: string): Fragment;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  extension2
3
- } from "../../../shared/jgqj11w4.js";
3
+ } from "../../../shared/6f0z3hzh.js";
4
4
 
5
5
  // src/dialects/pg/ext/citext.ts
6
6
  function citext(options = {}) {
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Version gate for one extension feature (OKM1812).
3
+ *
4
+ * The factory reads the declared extension version. An omitted pin is
5
+ * unpinned: apply checks the server. A pin that still allows a version
6
+ * without the feature fails here, at the call, which is schema build when
7
+ * the schema file calls the method. The message names the feature, the
8
+ * extension version, and `minPostgres`.
9
+ */
10
+ /** What a feature needs. */
11
+ export type FeatureNeed = {
12
+ /** Extension the feature belongs to. */
13
+ readonly name: string;
14
+ /** Minimum extension version (`1.2`). */
15
+ readonly extension: string;
16
+ /** Minimum Postgres major. Named in the message. */
17
+ readonly postgres: number;
18
+ };
19
+ /**
20
+ * Refuses a pin that does not guarantee the feature.
21
+ *
22
+ * @param declared - `version` on the extension, when the caller set one
23
+ * @param feature - Feature name, such as `daitch_mokotoff`
24
+ * @param need - Versions the feature needs
25
+ */
26
+ export declare function assertExtFeature(declared: string | undefined, feature: string, need: FeatureNeed): void;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The `fuzzystrmatch` extension. `levenshtein` compares edit distance. `daitchMokotoff` needs version 1.2 and PostgreSQL 16.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { Fragment } from "../ops/fragment.js";
9
+ import { type Extension, type ExtensionOptions } from "./index.js";
10
+ /** `fuzzystrmatch` plus the methods the naming overlay selected. */
11
+ export type Fuzzystrmatch = Extension & {
12
+ /**
13
+ * `levenshtein(column, value) = distance`.
14
+ *
15
+ * @param value - Text to compare
16
+ * @param distance - Edit distance the function must return
17
+ * @returns A where fragment
18
+ */
19
+ levenshtein(value: string, distance: number): Fragment;
20
+ /**
21
+ * `daitch_mokotoff(column) = daitch_mokotoff(value)`. Needs fuzzystrmatch 1.2 and PostgreSQL 16.
22
+ *
23
+ * @param value - Text to compare
24
+ * @returns A where fragment
25
+ */
26
+ daitchMokotoff(value: string): Fragment;
27
+ };
28
+ /**
29
+ * Declares `fuzzystrmatch`.
30
+ *
31
+ * @param options - Schema and version pin
32
+ * @returns The extension object and its methods
33
+ */
34
+ export declare function fuzzystrmatch(options?: ExtensionOptions): Fuzzystrmatch;
@@ -0,0 +1,33 @@
1
+ import {
2
+ extension2
3
+ } from "../../../shared/6f0z3hzh.js";
4
+ import {
5
+ assertExtFeature
6
+ } from "../../../shared/kzgrnckd.js";
7
+ import {
8
+ fnEqualsArg,
9
+ fnDistance
10
+ } from "../../../shared/zecrwdk9.js";
11
+
12
+ // src/dialects/pg/ext/fuzzystrmatch.ts
13
+ function fuzzystrmatch(options = {}) {
14
+ const declared = extension2("fuzzystrmatch", options);
15
+ const schema = declared.schema;
16
+ return {
17
+ ...declared,
18
+ levenshtein(value, distance) {
19
+ return fnDistance(schema, "levenshtein", value, distance);
20
+ },
21
+ daitchMokotoff(value) {
22
+ assertExtFeature(options.version, "daitch_mokotoff", {
23
+ name: "fuzzystrmatch",
24
+ extension: "1.2",
25
+ postgres: 16
26
+ });
27
+ return fnEqualsArg(schema, "daitch_mokotoff", value);
28
+ }
29
+ };
30
+ }
31
+ export {
32
+ fuzzystrmatch
33
+ };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The `hstore` extension. `hasKey` is `?`. `gin` and `gist` index an hstore column.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { Fragment } from "../ops/fragment.js";
9
+ import type { IndexCall } from "../table.js";
10
+ import { type Extension, type ExtensionOptions } from "./index.js";
11
+ /** `hstore` plus the methods the naming overlay selected. */
12
+ export type Hstore = Extension & {
13
+ /**
14
+ * `column ? key`.
15
+ *
16
+ * @param value - Text to compare
17
+ * @returns A where fragment
18
+ */
19
+ hasKey(value: string): Fragment;
20
+ /**
21
+ * A GIN index with `gin_hstore_ops`.
22
+ *
23
+ * @param column - SQL column name
24
+ * @returns An index call whose expression is the `using` tail
25
+ */
26
+ gin(column: string): IndexCall;
27
+ /**
28
+ * A GiST index with `gist_hstore_ops`.
29
+ *
30
+ * @param column - SQL column name
31
+ * @returns An index call whose expression is the `using` tail
32
+ */
33
+ gist(column: string): IndexCall;
34
+ };
35
+ /**
36
+ * Declares `hstore`.
37
+ *
38
+ * @param options - Schema and version pin
39
+ * @returns The extension object and its methods
40
+ */
41
+ export declare function hstore(options?: ExtensionOptions): Hstore;
@@ -0,0 +1,29 @@
1
+ import {
2
+ extension2
3
+ } from "../../../shared/6f0z3hzh.js";
4
+ import {
5
+ opArg
6
+ } from "../../../shared/zecrwdk9.js";
7
+ import {
8
+ usingIndex
9
+ } from "../../../shared/h9811jjm.js";
10
+
11
+ // src/dialects/pg/ext/hstore.ts
12
+ function hstore(options = {}) {
13
+ const declared = extension2("hstore", options);
14
+ return {
15
+ ...declared,
16
+ hasKey(value) {
17
+ return opArg("?", value);
18
+ },
19
+ gin(column) {
20
+ return usingIndex(column, "gin", "gin_hstore_ops");
21
+ },
22
+ gist(column) {
23
+ return usingIndex(column, "gist", "gist_hstore_ops");
24
+ }
25
+ };
26
+ }
27
+ export {
28
+ hstore
29
+ };
@@ -6,6 +6,50 @@
6
6
  * object for its records.
7
7
  */
8
8
  import type { ExtensionObject } from "../../../contracts/catalog/types.js";
9
+ /** One type the definition says the extension provides. */
10
+ export type ExtensionType = {
11
+ readonly name: string;
12
+ };
13
+ /** One operator the definition says the extension provides. */
14
+ export type ExtensionOperator = {
15
+ readonly name: string;
16
+ readonly left?: string;
17
+ readonly right?: string;
18
+ readonly result: string;
19
+ };
20
+ /** One function the definition says the extension provides. */
21
+ export type ExtensionFunction = {
22
+ readonly name: string;
23
+ readonly args: readonly string[];
24
+ readonly returns: string;
25
+ };
26
+ /** One index method the definition says the extension provides. */
27
+ export type ExtensionIndexMethod = {
28
+ readonly name: string;
29
+ readonly opclass?: string;
30
+ };
31
+ /**
32
+ * Types, operators, functions, and index methods a definition declares.
33
+ *
34
+ * `okm ext test` checks these against the connected server. They are not
35
+ * catalog objects and they do not change the catalog hash.
36
+ */
37
+ export type ExtensionProvides = {
38
+ readonly types?: readonly ExtensionType[];
39
+ readonly operators?: readonly ExtensionOperator[];
40
+ readonly functions?: readonly ExtensionFunction[];
41
+ readonly indexMethods?: readonly ExtensionIndexMethod[];
42
+ };
43
+ /**
44
+ * Version floors for a definition.
45
+ *
46
+ * `postgres` is `>=15`. `version` is an exact pin or a `>=` floor.
47
+ * `okm ext test` checks both against the connected server (OKM1812).
48
+ */
49
+ export type ExtensionRequires = {
50
+ readonly postgres?: string;
51
+ readonly version?: string;
52
+ };
9
53
  /** Options on {@link extension}. */
10
54
  export type ExtensionOptions = {
11
55
  /** Exact pin (`1.6`) or a floor (`>=0.7`). Omitted means unpinned. */
@@ -18,6 +62,14 @@ export type ExtensionOptions = {
18
62
  * The default is `true`. A move of a non-relocatable extension is OKM1814.
19
63
  */
20
64
  readonly relocatable?: boolean;
65
+ /**
66
+ * Floors `okm ext test` checks. Not stored in the catalog record.
67
+ */
68
+ readonly requires?: ExtensionRequires;
69
+ /**
70
+ * Objects `okm ext test` checks. Not stored in the catalog record.
71
+ */
72
+ readonly provides?: ExtensionProvides;
21
73
  };
22
74
  /**
23
75
  * One declared extension.
@@ -30,6 +82,10 @@ export type Extension = {
30
82
  readonly schema: string;
31
83
  readonly relocatable: boolean;
32
84
  readonly version?: string;
85
+ /** Floors from {@link ExtensionOptions.requires}. Absent when omitted. */
86
+ readonly requires?: ExtensionRequires;
87
+ /** Objects from {@link ExtensionOptions.provides}. Absent when omitted. */
88
+ readonly provides?: ExtensionProvides;
33
89
  /**
34
90
  * Catalog records for this declaration.
35
91
  *
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  extension2
3
- } from "../../../shared/jgqj11w4.js";
3
+ } from "../../../shared/6f0z3hzh.js";
4
4
  export {
5
5
  extension2 as extension
6
6
  };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The `ltree` extension. `ancestorOf` is `@>` and `descendantOf` is `<@`. This is not the parent-column walk.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { Fragment } from "../ops/fragment.js";
9
+ import type { IndexCall } from "../table.js";
10
+ import { type Extension, type ExtensionOptions } from "./index.js";
11
+ /** `ltree` plus the methods the naming overlay selected. */
12
+ export type Ltree = Extension & {
13
+ /**
14
+ * `column @> path`. The column is an ancestor of `path`.
15
+ *
16
+ * @param value - Text to compare
17
+ * @returns A where fragment
18
+ */
19
+ ancestorOf(value: string): Fragment;
20
+ /**
21
+ * `column <@ path`. The column is a descendant of `path`.
22
+ *
23
+ * @param value - Text to compare
24
+ * @returns A where fragment
25
+ */
26
+ descendantOf(value: string): Fragment;
27
+ /**
28
+ * A GiST index with `gist_ltree_ops`.
29
+ *
30
+ * @param column - SQL column name
31
+ * @returns An index call whose expression is the `using` tail
32
+ */
33
+ gist(column: string): IndexCall;
34
+ };
35
+ /**
36
+ * Declares `ltree`.
37
+ *
38
+ * @param options - Schema and version pin
39
+ * @returns The extension object and its methods
40
+ */
41
+ export declare function ltree(options?: ExtensionOptions): Ltree;