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
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  emitSqlValue
3
- } from "./gmcf9cxf.js";
3
+ } from "./ckq4z5ax.js";
4
4
  import {
5
5
  assertOperatorFits,
6
6
  sqlType,
@@ -8,7 +8,7 @@ import {
8
8
  assertBoundText,
9
9
  assertRegconfig,
10
10
  textArray
11
- } from "./3tq8pnb8.js";
11
+ } from "./fdsek6pa.js";
12
12
  import {
13
13
  isOperator,
14
14
  operatorName,
@@ -17,7 +17,7 @@ import {
17
17
  quote,
18
18
  isRecord,
19
19
  fail2
20
- } from "./f9mphxej.js";
20
+ } from "./2jdn09e2.js";
21
21
 
22
22
  // src/runtime/operator-sql.ts
23
23
  function emitStructured(table, column, ref, name, value, sink, order) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mapPostgresError2
3
- } from "./f9mphxej.js";
3
+ } from "./2jdn09e2.js";
4
4
  export {
5
5
  mapPostgresError2 as mapPostgresError
6
6
  };
@@ -1,44 +1,47 @@
1
1
  import {
2
2
  DriverError2,
3
3
  isConnectionLost
4
- } from "./f9mphxej.js";
4
+ } from "./2jdn09e2.js";
5
5
  import {
6
6
  armDriverError2,
7
- send3,
8
- connectClient2
9
- } from "./417zdsk7.js";
7
+ logClientError2,
8
+ send4,
9
+ connectClient3
10
+ } from "./ppybjw50.js";
10
11
  import {
11
12
  resetSession2
12
- } from "./4d2w25vw.js";
13
+ } from "./8t22h3h7.js";
13
14
  import {
14
15
  cursorStream
15
16
  } from "./7kms6fvj.js";
16
17
  import {
17
18
  WireSession
18
- } from "./yw30vnq2.js";
19
+ } from "./asnnc3v5.js";
19
20
  import {
20
21
  rejectClosed,
21
22
  runCall
22
- } from "./xhrnjch9.js";
23
+ } from "./ry2f3w8p.js";
23
24
 
24
25
  // src/adapters/pg/nodepostgres-extra.ts
25
26
  async function checkout(held) {
26
27
  const { pool, counters, named, isClosed } = held;
27
28
  if (isClosed())
28
29
  return rejectClosed();
29
- const client = await connectClient2(pool, held.acquireMs, counters);
30
+ const client = await connectClient3(pool, held.acquireMs, counters);
30
31
  counters.reserved += 1;
31
32
  let lost = false;
32
- const onError = () => {
33
+ const onError = (error) => {
33
34
  lost = true;
35
+ if (error !== undefined)
36
+ logClientError2(held.notices, error);
34
37
  };
35
38
  const events = client;
36
39
  events.on("error", onError);
37
40
  const local = new Set;
38
41
  const session = new WireSession((text, params) => {
39
- const pending = send3(client, text, params, named, client);
42
+ const pending = send4(client, text, params, named, client);
40
43
  const guarded = pending.catch((error) => {
41
- if (isConnectionLost(error) || lost) {
44
+ if (isConnectionLost(error) || lost || pgClosed(error)) {
42
45
  lost = true;
43
46
  if (isConnectionLost(error))
44
47
  throw error;
@@ -62,7 +65,7 @@ async function checkout(held) {
62
65
  return {
63
66
  execute: (text, params, options) => guard(() => runCall(isClosed(), options, (watch) => session.query(text, params, watch))),
64
67
  batch: (statements, options) => guard(() => runCall(isClosed(), options, async (watch) => {
65
- const { runAtomicBatch } = await import("./3rrw5w8f.js");
68
+ const { runAtomicBatch } = await import("./xchpnbdv.js");
66
69
  return runAtomicBatch(session, statements, watch);
67
70
  })),
68
71
  cancel() {
@@ -75,6 +78,8 @@ async function checkout(held) {
75
78
  try {
76
79
  if (!lost)
77
80
  await reset(session, client);
81
+ } catch {
82
+ lost = true;
78
83
  } finally {
79
84
  counters.reserved = Math.max(0, counters.reserved - 1);
80
85
  events.removeListener("error", onError);
@@ -83,12 +88,15 @@ async function checkout(held) {
83
88
  }
84
89
  };
85
90
  }
91
+ function pgClosed(error) {
92
+ return error instanceof Error && error.message === "Client has encountered a connection error and is not queryable";
93
+ }
86
94
  async function reset(session, client) {
87
95
  await resetSession2(session.depth(), (text) => client.query(text));
88
96
  }
89
97
  async function listen(held, channel, onNotify) {
90
98
  const { pool, counters } = held;
91
- const client = await connectClient2(pool, held.acquireMs, counters);
99
+ const client = await connectClient3(pool, held.acquireMs, counters);
92
100
  counters.reserved += 1;
93
101
  const quoted = quoteIdent(channel);
94
102
  const onNotification = (message) => {
@@ -1,24 +1,24 @@
1
1
  import {
2
- open3
3
- } from "./p7f08ktn.js";
2
+ open4
3
+ } from "./vms9dta5.js";
4
4
  import {
5
5
  createClient
6
- } from "./mtrqn2hn.js";
6
+ } from "./gjj71hfh.js";
7
7
 
8
8
  // src/runtime/pg/postgresjs.ts
9
9
  function connect(target, options) {
10
10
  if (typeof target === "object" && !isPool(target)) {
11
- return import("./2wtvc7rw.js").then((mod) => mod.default(target, options, open3));
11
+ return import("./bt3tjemb.js").then((mod) => mod.default(target, options, open4));
12
12
  }
13
13
  const owned = !isPool(target);
14
- const pool = isPool(target) ? target : open3({
14
+ const pool = owned ? open4({
15
15
  url: target,
16
- ...options.max !== undefined ? { max: options.max } : {},
17
- ...options.timeouts !== undefined ? { timeouts: options.timeouts } : {},
18
- ...options.prepared !== undefined ? { prepared: options.prepared } : {},
19
- ...options.searchPath !== undefined ? { searchPath: options.searchPath } : {},
20
- ...options.ssl !== undefined ? { ssl: options.ssl } : {}
21
- });
16
+ max: options.max,
17
+ timeouts: options.timeouts,
18
+ prepared: options.prepared,
19
+ searchPath: options.searchPath,
20
+ ssl: options.ssl
21
+ }) : target;
22
22
  return createClient(options.schema, pool, {
23
23
  ownsPool: owned,
24
24
  http: options.errors?.http,
@@ -0,0 +1,9 @@
1
+ import {
2
+ historySql2,
3
+ acceptServer2
4
+ } from "./8g0m0rvd.js";
5
+ import"./gjj71hfh.js";
6
+ export {
7
+ acceptServer2 as acceptServer,
8
+ historySql2 as historySql
9
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  OkmError,
3
3
  DriverError2
4
- } from "./f9mphxej.js";
4
+ } from "./2jdn09e2.js";
5
5
 
6
6
  // src/adapters/lazy-errors.ts
7
7
  function refused() {
@@ -90,8 +90,6 @@ export type FactoryHost = {
90
90
  readonly rng: Rng;
91
91
  /** Latest row of a table in one tenant. Isolation uses its own map. */
92
92
  cache: Map<string, Record<string, unknown>>;
93
- /** Tables currently being inserted. A repeat is a factory cycle. */
94
- readonly creating: Set<string>;
95
93
  readonly created: Map<string, number>;
96
94
  readonly definitions: Map<string, (context: FactoryContext) => Readonly<Record<string, unknown>>>;
97
95
  };
@@ -113,7 +111,7 @@ export declare function bindFactories(host: FactoryHost, definitions: Readonly<R
113
111
  * @param inherited - Tenant from the parent row, when this row is a child
114
112
  * @returns The inserted row
115
113
  */
116
- export declare function insertRow(host: FactoryHost, table: string, overrides: Readonly<Record<string, unknown>> | undefined, children: Readonly<Record<string, number>> | undefined, inherited: string | undefined): Promise<Record<string, unknown>>;
114
+ export declare function insertRow(host: FactoryHost, table: string, overrides: Readonly<Record<string, unknown>> | undefined, children: Readonly<Record<string, number>> | undefined, inherited: string | undefined, creating?: Set<string>): Promise<Record<string, unknown>>;
117
115
  /**
118
116
  * Drops a cached factory row.
119
117
  *
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  testing2
3
- } from "../../shared/b6d6p0zc.js";
4
- import"../../shared/sjk86yrx.js";
3
+ } from "../../shared/ns35jqz0.js";
4
+ import"../../shared/fk9vef30.js";
5
5
  import"../../shared/12z7aznj.js";
6
6
  export {
7
7
  testing2 as testing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "okmodel",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "okmodel is a catalog-first TypeScript ORM, PostgreSQL first.",
5
5
  "keywords": [
6
6
  "migrations",
@@ -114,10 +114,38 @@
114
114
  "./pg/pg_trgm": {
115
115
  "types": "./dist/dialects/pg/ext/pg-trgm.d.ts",
116
116
  "import": "./dist/dialects/pg/ext/pg-trgm.js"
117
+ },
118
+ "./pg/unaccent": {
119
+ "types": "./dist/dialects/pg/ext/unaccent.d.ts",
120
+ "import": "./dist/dialects/pg/ext/unaccent.js"
121
+ },
122
+ "./pg/hstore": {
123
+ "types": "./dist/dialects/pg/ext/hstore.d.ts",
124
+ "import": "./dist/dialects/pg/ext/hstore.js"
125
+ },
126
+ "./pg/ltree": {
127
+ "types": "./dist/dialects/pg/ext/ltree.d.ts",
128
+ "import": "./dist/dialects/pg/ext/ltree.js"
129
+ },
130
+ "./pg/btree_gist": {
131
+ "types": "./dist/dialects/pg/ext/btree-gist.d.ts",
132
+ "import": "./dist/dialects/pg/ext/btree-gist.js"
133
+ },
134
+ "./pg/btree_gin": {
135
+ "types": "./dist/dialects/pg/ext/btree-gin.d.ts",
136
+ "import": "./dist/dialects/pg/ext/btree-gin.js"
137
+ },
138
+ "./pg/fuzzystrmatch": {
139
+ "types": "./dist/dialects/pg/ext/fuzzystrmatch.d.ts",
140
+ "import": "./dist/dialects/pg/ext/fuzzystrmatch.js"
141
+ },
142
+ "./pg/pgcrypto": {
143
+ "types": "./dist/dialects/pg/ext/pgcrypto.d.ts",
144
+ "import": "./dist/dialects/pg/ext/pgcrypto.js"
117
145
  }
118
146
  },
119
147
  "scripts": {
120
- "build": "rm -rf dist && bun build ./src/contracts/index.ts ./src/contracts/internal.ts ./src/dialects/pg/index.ts ./src/runtime/pg/postgresjs.ts ./src/runtime/pg/pglite.ts ./src/runtime/pg/pg.ts ./src/runtime/pg/bun.ts ./src/runtime/pg/neon.ts ./src/runtime/ids/index.ts ./src/runtime/safety/index.ts ./src/runtime/traits/index.ts ./src/runtime/tenancy/index.ts ./src/runtime/validate/index.ts ./src/runtime/otel.ts ./src/dialects/pg/ext/index.ts ./src/dialects/pg/fn/index.ts ./src/dialects/pg/view/index.ts ./src/dialects/pg/ext/citext.ts ./src/dialects/pg/ext/pg-trgm.ts ./src/tooling/migrate/index.ts ./src/tooling/testing/index.ts ./src/tooling/cli.ts --outdir ./dist --root ./src --format esm --target node --splitting --chunk-naming=shared/[hash].js --external postgres --external @electric-sql/pglite --external pg --external bun --external @neondatabase/serverless && bunx tsc -p tsconfig.build.json && rm -f ./dist/dialects/pg/temporal.local.d.ts && bun build ./packages/harness/src/driver-run.ts --outdir ./dist/tooling --format esm --target node --splitting --chunk-naming=shared/[hash].js --external postgres --external @electric-sql/pglite --external pg --external bun --external @neondatabase/serverless && bun ./scripts/write-bin-wrappers.ts",
148
+ "build": "rm -rf dist && bun build ./src/contracts/index.ts ./src/contracts/internal.ts ./src/dialects/pg/index.ts ./src/runtime/pg/postgresjs.ts ./src/runtime/pg/pglite.ts ./src/runtime/pg/pg.ts ./src/runtime/pg/bun.ts ./src/runtime/pg/neon.ts ./src/runtime/ids/index.ts ./src/runtime/safety/index.ts ./src/runtime/traits/index.ts ./src/runtime/tenancy/index.ts ./src/runtime/validate/index.ts ./src/runtime/otel.ts ./src/dialects/pg/ext/index.ts ./src/dialects/pg/fn/index.ts ./src/dialects/pg/view/index.ts ./src/dialects/pg/ext/citext.ts ./src/dialects/pg/ext/pg-trgm.ts ./src/dialects/pg/ext/unaccent.ts ./src/dialects/pg/ext/hstore.ts ./src/dialects/pg/ext/ltree.ts ./src/dialects/pg/ext/btree-gist.ts ./src/dialects/pg/ext/btree-gin.ts ./src/dialects/pg/ext/fuzzystrmatch.ts ./src/dialects/pg/ext/pgcrypto.ts ./src/tooling/migrate/index.ts ./src/tooling/testing/index.ts ./src/tooling/cli.ts --outdir ./dist --root ./src --format esm --target node --splitting --chunk-naming=shared/[hash].js --external postgres --external @electric-sql/pglite --external pg --external bun --external @neondatabase/serverless && bunx tsc -p tsconfig.build.json && rm -f ./dist/dialects/pg/temporal.local.d.ts && bun build ./packages/harness/src/driver-run.ts --outdir ./dist/tooling --format esm --target node --splitting --chunk-naming=shared/[hash].js --external postgres --external @electric-sql/pglite --external pg --external bun --external @neondatabase/serverless && bun ./scripts/write-bin-wrappers.ts",
121
149
  "driver-bench": "bun ./scripts/driver-bench.ts",
122
150
  "typecheck": "bunx tsc --noEmit -p tsconfig.json",
123
151
  "editor-check": "bun ./scripts/editor-check.ts",
@@ -161,15 +189,16 @@
161
189
  "devDependencies": {
162
190
  "@arethetypeswrong/cli": "^0.18.5",
163
191
  "@electric-sql/pglite-socket": "^0.2.11",
164
- "@types/bun": "^1.4.2",
192
+ "@types/bun": "^1.4.3",
193
+ "drizzle-orm": "0.45.4",
165
194
  "expect-type": "^1.4.0",
166
195
  "fast-check": "^4.10.2",
167
- "oxc-parser": "^0.152.0",
168
- "oxfmt": "0.71.0",
169
- "oxlint": "^1.86.0",
170
- "oxlint-tsgolint": "^7.0.2003",
171
- "publint": "^0.3.24",
172
- "temporal-polyfill": "^1.0.5",
196
+ "oxc-parser": "0.154.0",
197
+ "oxfmt": "0.73.0",
198
+ "oxlint": "^1.88.0",
199
+ "oxlint-tsgolint": "^7.0.2004",
200
+ "publint": "^0.3.25",
201
+ "temporal-polyfill": "^1.0.6",
173
202
  "temporal-spec": "^1.0.1",
174
203
  "typescript": "7",
175
204
  "typescript-editor": "npm:typescript@6.0.3"
@@ -195,6 +224,7 @@
195
224
  }
196
225
  },
197
226
  "engines": {
227
+ "bun": ">=1.4.0",
198
228
  "node": ">=22.18"
199
229
  }
200
230
  }
@@ -1,14 +0,0 @@
1
- import {
2
- assertAuthorDrift2,
3
- catalogQuery2,
4
- managedRoleOptions2
5
- } from "./mkrn359n.js";
6
- import"./p3xbdcvt.js";
7
- import"./dpc2r7rb.js";
8
- import"./sjk86yrx.js";
9
- import"./12z7aznj.js";
10
- export {
11
- assertAuthorDrift2 as assertAuthorDrift,
12
- catalogQuery2 as catalogQuery,
13
- managedRoleOptions2 as managedRoleOptions
14
- };
@@ -1,71 +0,0 @@
1
- import {
2
- POSTGRES_FLOOR,
3
- isPostgresMajor,
4
- parsePostgresFloor,
5
- serverNeedsPostgres
6
- } from "./ga9j92qj.js";
7
- import {
8
- withHttp,
9
- attachHttp
10
- } from "./bah9nbg3.js";
11
- import {
12
- OkmError2
13
- } from "./52szzakm.js";
14
-
15
- // src/runtime/server-check.ts
16
- var versionQuery = "select current_setting('server_version_num'), version(), (select (xpath('//catalog_hash/text()', query_to_xml('select catalog_hash from okm_meta where id = ''head''', true, false, '')))[1]::text where to_regclass('okm_meta') is not null)";
17
- async function acceptServer(pool, schema, rows, http, requireMeta, options, source) {
18
- for (const name in schema.model) {
19
- if (schema.model[name]?.presets !== undefined) {
20
- (await import("./m7n9h2a5.js")).checkSchema(schema);
21
- break;
22
- }
23
- }
24
- const version = rows[0]?.[1];
25
- if (version === null || version === undefined || !version.startsWith("PostgreSQL")) {
26
- throw new OkmError2("OKM1801", "The server is not PostgreSQL. The schema dialect is postgres.", withHttp(http, {
27
- fix: { summary: "Open the schema with the Postgres driver that matches it." }
28
- }));
29
- }
30
- const recorded = rows[0]?.[2];
31
- if (recorded === null || recorded === undefined || recorded.length === 0) {
32
- if (requireMeta) {
33
- throw new OkmError2("OKM1520", "okm_meta has no catalog hash.", withHttp(http, {
34
- fix: {
35
- summary: "Apply migrations so okm_meta records the catalog, or omit requireMeta to adopt this database."
36
- }
37
- }));
38
- }
39
- } else {
40
- const { assertCompatible } = await import("./16kvjebh.js");
41
- try {
42
- await assertCompatible(pool, schema, recorded, source, options);
43
- } catch (error) {
44
- if (error instanceof OkmError2)
45
- throw attachHttp(http, error);
46
- throw error;
47
- }
48
- }
49
- const major = Math.floor(Number(rows[0]?.[0] ?? "0") / 1e4);
50
- const raw = schema.requires?.postgres;
51
- if (raw === undefined) {
52
- if (major < POSTGRES_FLOOR) {
53
- throw new OkmError2("OKM1803", serverNeedsPostgres(major, POSTGRES_FLOOR), withHttp(http, {
54
- fix: {
55
- summary: `Upgrade to PostgreSQL ${String(POSTGRES_FLOOR)} or higher.`
56
- }
57
- }));
58
- }
59
- return;
60
- }
61
- const need = parsePostgresFloor(raw);
62
- if (!isPostgresMajor(need) || major < need) {
63
- throw new OkmError2("OKM1802", serverNeedsPostgres(major, isPostgresMajor(need) ? need : POSTGRES_FLOOR), withHttp(http, {
64
- fix: { summary: "Upgrade the server, or lower minPostgres to a major the server meets." }
65
- }));
66
- }
67
- }
68
- export {
69
- acceptServer,
70
- versionQuery
71
- };
@@ -1,113 +0,0 @@
1
- import {
2
- open2
3
- } from "./35q0n9tz.js";
4
- import"./12z7aznj.js";
5
- import"./n442h54c.js";
6
- import {
7
- openProject
8
- } from "./f4jy1j7x.js";
9
- import {
10
- sessionFailure,
11
- finishQuiet,
12
- assertTargetPolicy,
13
- selectTarget
14
- } from "./dpc2r7rb.js";
15
- import"./sjk86yrx.js";
16
- import {
17
- isExactVersion,
18
- compareExtensionVersions
19
- } from "./r3j8s5y0.js";
20
- import {
21
- OkmError2
22
- } from "./52szzakm.js";
23
-
24
- // src/tooling/migrate/ext.ts
25
- async function extProject(cwd, command, flags) {
26
- const opened = await openProject(cwd);
27
- const target = selectTarget(opened.config, flags.target);
28
- assertTargetPolicy(target, "check", flags.allowProtected);
29
- const pool = open2({ url: target.url, max: 1 });
30
- try {
31
- if (command === "list")
32
- return formatList(await readExtensions(pool));
33
- return formatCheck(opened.built.catalog.objects, await readExtensions(pool));
34
- } catch (error) {
35
- throw sessionFailure(error) ?? error;
36
- } finally {
37
- await finishQuiet(() => pool.close());
38
- }
39
- }
40
- var LIST_SQL = `
41
- select a.name, a.default_version, e.extversion, n.nspname
42
- from pg_available_extensions a
43
- left join pg_extension e on e.extname = a.name
44
- left join pg_namespace n on n.oid = e.extnamespace
45
- order by a.name
46
- `;
47
- async function readExtensions(pool) {
48
- const result = await pool.execute(LIST_SQL);
49
- return result.rows.map((row) => ({
50
- name: cell(row[0]),
51
- defaultVersion: cell(row[1]),
52
- installedVersion: cell(row[2]),
53
- schema: cell(row[3])
54
- }));
55
- }
56
- function cell(value) {
57
- return typeof value === "string" ? value : "";
58
- }
59
- function formatList(rows) {
60
- const lines = ["name\tdefault\tinstalled\tschema"];
61
- for (const row of rows) {
62
- lines.push([row.name, row.defaultVersion, row.installedVersion, row.schema].join("\t"));
63
- }
64
- return `${lines.join(`
65
- `)}
66
- `;
67
- }
68
- function formatCheck(objects, server) {
69
- const declared = objects.filter((object) => object.kind === "extension");
70
- if (declared.length === 0)
71
- return `no extensions
72
- `;
73
- const installed = new Map(server.map((row) => [row.name, row.installedVersion]));
74
- const lines = ["name\tdeclared\tinstalled"];
75
- for (const object of [...declared].sort((left, right) => left.identity.name < right.identity.name ? -1 : 1)) {
76
- const name = object.identity.name;
77
- const have = installed.get(name) ?? "";
78
- if (have.length === 0) {
79
- throw new OkmError2("OKM1811", `Extension ${name} is not installed on the server.`, {
80
- fix: { summary: "Install the extension, or remove the declaration." }
81
- });
82
- }
83
- const want = object.definition.version;
84
- if (!versionAccepted(want, have)) {
85
- throw new OkmError2("OKM1812", extensionNeeds(name, want ?? "", have), {
86
- fix: { summary: "Install a version the declaration accepts, or change the pin." }
87
- });
88
- }
89
- lines.push([name, want ?? "-", have].join("\t"));
90
- }
91
- return `${lines.join(`
92
- `)}
93
- `;
94
- }
95
- function extensionNeeds(name, want, have) {
96
- const floor = /^>=(\d+(?:\.\d+)*)$/.exec(want);
97
- const need = floor?.[1] ?? want;
98
- const higher = floor === null ? "" : " or higher";
99
- return `Extension ${name} needs ${need}${higher}. The server has ${have}. Install a version the declaration accepts, or change the pin.`;
100
- }
101
- function versionAccepted(declared, installed) {
102
- if (declared === undefined)
103
- return true;
104
- const floor = /^>=(\d+(?:\.\d+)*)$/.exec(declared);
105
- const minimum = floor?.[1];
106
- if (minimum !== undefined) {
107
- return isExactVersion(installed) && compareExtensionVersions(installed, minimum) >= 0;
108
- }
109
- return declared === installed;
110
- }
111
- export {
112
- extProject
113
- };
@@ -1,69 +0,0 @@
1
- import {
2
- withHttp,
3
- attachHttp
4
- } from "./mtrqn2hn.js";
5
- import {
6
- OkmError,
7
- POSTGRES_FLOOR,
8
- isPostgresMajor,
9
- parsePostgresFloor,
10
- serverNeedsPostgres
11
- } from "./f9mphxej.js";
12
-
13
- // src/runtime/server-check.ts
14
- var versionQuery = "select current_setting('server_version_num'), version(), (select (xpath('//catalog_hash/text()', query_to_xml('select catalog_hash from okm_meta where id = ''head''', true, false, '')))[1]::text where to_regclass('okm_meta') is not null)";
15
- async function acceptServer(pool, schema, rows, http, requireMeta, options, source) {
16
- for (const name in schema.model) {
17
- if (schema.model[name]?.presets !== undefined) {
18
- (await import("./ma2340rx.js")).checkSchema(schema);
19
- break;
20
- }
21
- }
22
- const version = rows[0]?.[1];
23
- if (version === null || version === undefined || !version.startsWith("PostgreSQL")) {
24
- throw new OkmError("OKM1801", "The server is not PostgreSQL. The schema dialect is postgres.", withHttp(http, {
25
- fix: { summary: "Open the schema with the Postgres driver that matches it." }
26
- }));
27
- }
28
- const recorded = rows[0]?.[2];
29
- if (recorded === null || recorded === undefined || recorded.length === 0) {
30
- if (requireMeta) {
31
- throw new OkmError("OKM1520", "okm_meta has no catalog hash.", withHttp(http, {
32
- fix: {
33
- summary: "Apply migrations so okm_meta records the catalog, or omit requireMeta to adopt this database."
34
- }
35
- }));
36
- }
37
- } else {
38
- const { assertCompatible } = await import("./fb9k2qwd.js");
39
- try {
40
- await assertCompatible(pool, schema, recorded, source, options);
41
- } catch (error) {
42
- if (error instanceof OkmError)
43
- throw attachHttp(http, error);
44
- throw error;
45
- }
46
- }
47
- const major = Math.floor(Number(rows[0]?.[0] ?? "0") / 1e4);
48
- const raw = schema.requires?.postgres;
49
- if (raw === undefined) {
50
- if (major < POSTGRES_FLOOR) {
51
- throw new OkmError("OKM1803", serverNeedsPostgres(major, POSTGRES_FLOOR), withHttp(http, {
52
- fix: {
53
- summary: `Upgrade to PostgreSQL ${String(POSTGRES_FLOOR)} or higher.`
54
- }
55
- }));
56
- }
57
- return;
58
- }
59
- const need = parsePostgresFloor(raw);
60
- if (!isPostgresMajor(need) || major < need) {
61
- throw new OkmError("OKM1802", serverNeedsPostgres(major, isPostgresMajor(need) ? need : POSTGRES_FLOOR), withHttp(http, {
62
- fix: { summary: "Upgrade the server, or lower minPostgres to a major the server meets." }
63
- }));
64
- }
65
- }
66
- export {
67
- acceptServer,
68
- versionQuery
69
- };
File without changes