okmodel 0.7.0 → 0.9.0

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 (258) hide show
  1. package/README.md +14 -0
  2. package/dist/adapters/capabilities.d.ts +32 -0
  3. package/dist/adapters/failure.d.ts +1 -1
  4. package/dist/adapters/pg/bun-sql.d.ts +53 -0
  5. package/dist/adapters/pg/bunsql-extra.d.ts +1 -1
  6. package/dist/adapters/pg/bunsql.d.ts +1 -1
  7. package/dist/adapters/pg/neon-extra.d.ts +18 -0
  8. package/dist/adapters/pg/neon.d.ts +104 -0
  9. package/dist/adapters/pg/no-inflight-timeout.d.ts +1 -1
  10. package/dist/contracts/error.d.ts +1 -1
  11. package/dist/dialects/pg/ext/btree-gin.d.ts +26 -0
  12. package/dist/dialects/pg/ext/btree-gin.js +20 -0
  13. package/dist/dialects/pg/ext/btree-gist.d.ts +26 -0
  14. package/dist/dialects/pg/ext/btree-gist.js +20 -0
  15. package/dist/dialects/pg/ext/call.d.ts +53 -0
  16. package/dist/dialects/pg/ext/citext.js +1 -1
  17. package/dist/dialects/pg/ext/feature.d.ts +26 -0
  18. package/dist/dialects/pg/ext/fuzzystrmatch.d.ts +34 -0
  19. package/dist/dialects/pg/ext/fuzzystrmatch.js +33 -0
  20. package/dist/dialects/pg/ext/hstore.d.ts +41 -0
  21. package/dist/dialects/pg/ext/hstore.js +29 -0
  22. package/dist/dialects/pg/ext/index.d.ts +56 -0
  23. package/dist/dialects/pg/ext/index.js +1 -1
  24. package/dist/dialects/pg/ext/ltree.d.ts +41 -0
  25. package/dist/dialects/pg/ext/ltree.js +29 -0
  26. package/dist/dialects/pg/ext/pg-trgm.js +4 -13
  27. package/dist/dialects/pg/ext/pgcrypto.d.ts +33 -0
  28. package/dist/dialects/pg/ext/pgcrypto.js +33 -0
  29. package/dist/dialects/pg/ext/unaccent.d.ts +26 -0
  30. package/dist/dialects/pg/ext/unaccent.js +21 -0
  31. package/dist/dialects/pg/ext/using.d.ts +23 -0
  32. package/dist/dialects/pg/ext/versions.d.ts +36 -0
  33. package/dist/dialects/pg/external.d.ts +19 -0
  34. package/dist/dialects/pg/fn/index.d.ts +39 -1
  35. package/dist/dialects/pg/fn/index.js +118 -26
  36. package/dist/dialects/pg/index.d.ts +3 -0
  37. package/dist/dialects/pg/index.js +394 -14
  38. package/dist/dialects/pg/introspect.d.ts +11 -0
  39. package/dist/dialects/pg/operators.d.ts +1 -1
  40. package/dist/dialects/pg/ops/fragment.d.ts +119 -0
  41. package/dist/dialects/pg/ops/lane.d.ts +49 -0
  42. package/dist/dialects/pg/view/client.d.ts +14 -6
  43. package/dist/dialects/pg/view/index.d.ts +73 -1
  44. package/dist/dialects/pg/view/index.js +156 -5
  45. package/dist/dialects/pg/view/scratch.d.ts +11 -5
  46. package/dist/runtime/artifact-file.d.ts +22 -0
  47. package/dist/runtime/client.d.ts +10 -0
  48. package/dist/runtime/drift-detail.d.ts +2 -1
  49. package/dist/runtime/drift.d.ts +3 -10
  50. package/dist/runtime/otel.d.ts +105 -0
  51. package/dist/runtime/otel.js +97 -0
  52. package/dist/runtime/pg/bun.js +4 -4
  53. package/dist/runtime/pg/neon.d.ts +38 -0
  54. package/dist/runtime/pg/neon.js +64 -0
  55. package/dist/runtime/pg/pg.js +4 -4
  56. package/dist/runtime/pg/pglite.js +4 -4
  57. package/dist/runtime/pg/postgresjs.js +4 -4
  58. package/dist/runtime/plan.d.ts +1 -1
  59. package/dist/runtime/server-check.d.ts +36 -6
  60. package/dist/runtime/sql-fragment.d.ts +43 -0
  61. package/dist/runtime/tenancy/index.js +10 -10
  62. package/dist/runtime/topology.d.ts +1 -1
  63. package/dist/runtime/traits/index.js +16 -17
  64. package/dist/runtime/types.d.ts +15 -1
  65. package/dist/runtime/validate/index.js +4 -4
  66. package/dist/shared/{81ebdx9p.js → 0j6qe91y.js} +4 -4
  67. package/dist/shared/{qq3899ht.js → 12z7aznj.js} +243 -14
  68. package/dist/shared/{gzaveazc.js → 1d9q9cv2.js} +29 -2
  69. package/dist/shared/{w79hsckn.js → 1mxm04fy.js} +5 -5
  70. package/dist/shared/{7k9grvf6.js → 2szgv6yj.js} +5 -5
  71. package/dist/shared/{gs74dbj5.js → 2zdxkt7b.js} +933 -111
  72. package/dist/shared/{m6p12kbr.js → 3456242y.js} +23 -23
  73. package/dist/shared/3bb7wsqt.js +99 -0
  74. package/dist/shared/{y6njgyda.js → 3t6kw83m.js} +2 -2
  75. package/dist/shared/{xhfsfkgk.js → 4vbf83xx.js} +9 -2
  76. package/dist/shared/{pt94kz7f.js → 5kyb3tqx.js} +1 -1
  77. package/dist/shared/61bmrmhr.js +35 -0
  78. package/dist/shared/{x933k9a3.js → 62b603gr.js} +10 -10
  79. package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
  80. package/dist/shared/{tsvww22q.js → 6nae0spm.js} +156 -95
  81. package/dist/shared/{mtaszv5a.js → 71n0jmhc.js} +102 -4
  82. package/dist/shared/{5e3tf63j.js → 760ppr76.js} +14 -6
  83. package/dist/shared/7ba5h6pb.js +17 -0
  84. package/dist/shared/{sfz1ksn6.js → 8jesqsrk.js} +2 -2
  85. package/dist/shared/{5v3xf80k.js → 8n688yjg.js} +1 -1
  86. package/dist/shared/{rs73fca9.js → 8qzkd9f3.js} +6 -6
  87. package/dist/shared/{ax7qv55k.js → 90sg0w5a.js} +202 -25
  88. package/dist/shared/{zm0ptry0.js → 99qp9vtg.js} +1 -1
  89. package/dist/shared/{xnxsed62.js → 9dr2qnx7.js} +14 -14
  90. package/dist/shared/{1w508jbr.js → 9dtgn1z2.js} +21 -17
  91. package/dist/shared/{h15jx9bc.js → 9dvh1dr6.js} +1 -1
  92. package/dist/shared/{q5c6ngn3.js → a62rb2da.js} +1 -1
  93. package/dist/shared/{te5as7z7.js → aksb89mn.js} +3 -3
  94. package/dist/shared/{bz84tkzm.js → bphrgwz9.js} +2 -2
  95. package/dist/shared/bsek72fg.js +225 -0
  96. package/dist/shared/{7mnme5tn.js → c3mvnq7a.js} +1 -1
  97. package/dist/shared/{p6qc5gcp.js → ccsmhv9r.js} +25 -7
  98. package/dist/shared/{pbp1ss85.js → cexb7z6b.js} +2 -2
  99. package/dist/shared/{ab9gmbwy.js → cf8zdz5p.js} +5 -5
  100. package/dist/shared/{jvd0mqag.js → ckz05z15.js} +5 -5
  101. package/dist/shared/{dk8v79p3.js → d5nmj7vv.js} +1 -1
  102. package/dist/shared/{14vx95q4.js → dd5pmnky.js} +7 -7
  103. package/dist/shared/{vb6qfyve.js → ds229x4r.js} +2 -2
  104. package/dist/shared/{1qa0qajz.js → e275q7sd.js} +1 -1
  105. package/dist/shared/{zp9fmend.js → ebhz8vh6.js} +4 -4
  106. package/dist/shared/{hyh73qk6.js → ecn8mfdq.js} +5 -5
  107. package/dist/shared/{je4axnm8.js → fdsz3w80.js} +2 -2
  108. package/dist/shared/{9s0ypp87.js → fk9vef30.js} +85 -74
  109. package/dist/shared/{g6evj1j3.js → g89fmz5s.js} +1 -1
  110. package/dist/shared/{aytqh5y2.js → ghqzdp94.js} +2 -2
  111. package/dist/shared/h9811jjm.js +17 -0
  112. package/dist/shared/{dkxgzaqd.js → hqpxf4a4.js} +1 -1
  113. package/dist/shared/{8skf0cam.js → jpybhf98.js} +1 -1
  114. package/dist/shared/{67txcrcw.js → kgwp4jdd.js} +4 -4
  115. package/dist/shared/kzgrnckd.js +29 -0
  116. package/dist/shared/mazpbcdj.js +233 -0
  117. package/dist/shared/{kb2sdhfb.js → mfvx6kjx.js} +17 -1
  118. package/dist/shared/{svncdeh5.js → mgaq2sd3.js} +11 -8
  119. package/dist/shared/{5mtf6cj3.js → mvmm3xpb.js} +5 -2
  120. package/dist/shared/{b5pftnn2.js → myk8fswx.js} +66 -21
  121. package/dist/shared/{2shdbn8q.js → n306gqkd.js} +9 -9
  122. package/dist/shared/{n816peh1.js → n454kcnw.js} +1 -1
  123. package/dist/shared/n5whk3mt.js +665 -0
  124. package/dist/shared/n7kg8mmx.js +61 -0
  125. package/dist/shared/{vqrjpcqn.js → nmnsgj7x.js} +1 -1
  126. package/dist/shared/{tbrvgw6z.js → npdftanb.js} +19 -26
  127. package/dist/shared/{ek2wt2dz.js → pg4ezgyf.js} +11 -30
  128. package/dist/shared/{5fe3kbsh.js → pgsak1yw.js} +1 -1
  129. package/dist/shared/{bm22fvzr.js → qfw14tna.js} +2 -2
  130. package/dist/shared/{wa07eas9.js → qvwwp1mp.js} +62 -41
  131. package/dist/shared/rbxt795q.js +1766 -0
  132. package/dist/shared/{xjk7hnn5.js → s7he5e5d.js} +2 -2
  133. package/dist/shared/{w72kgg4q.js → ss2kv2rs.js} +6 -6
  134. package/dist/shared/stfa9xcw.js +450 -0
  135. package/dist/shared/{3v7t1yrv.js → th3be82n.js} +2 -2
  136. package/dist/shared/{79dt02vc.js → tr64w5p0.js} +1 -1
  137. package/dist/shared/{cn957f8d.js → tw1nvvfj.js} +3 -3
  138. package/dist/shared/{ed0b8k4s.js → typ3vy7t.js} +1 -1
  139. package/dist/shared/{9628a9xt.js → vk7rag46.js} +1 -1
  140. package/dist/shared/{ze4hxsmy.js → w9ejzaqf.js} +1 -1
  141. package/dist/shared/{vczs8gd4.js → wvtjg5m3.js} +2 -2
  142. package/dist/shared/{9y3mmmh1.js → xfhe73sb.js} +1 -1
  143. package/dist/shared/xqacq37x.js +61 -0
  144. package/dist/shared/{1est4ezg.js → xtsydxjg.js} +3 -3
  145. package/dist/shared/xv8qj97g.js +96 -0
  146. package/dist/shared/{bg3rym3g.js → xwhdcrm4.js} +2 -2
  147. package/dist/shared/{kr0jzbw2.js → yvabyg9k.js} +7 -7
  148. package/dist/shared/yybhre6n.js +136 -0
  149. package/dist/shared/zdqf8k5d.js +8 -0
  150. package/dist/shared/{jznfax0y.js → zq1he88x.js} +4 -4
  151. package/dist/tooling/cli.js +108 -23
  152. package/dist/tooling/driver-run.js +4654 -0
  153. package/dist/tooling/driver-test.d.ts +36 -0
  154. package/dist/tooling/github/comment.d.ts +50 -0
  155. package/dist/tooling/github/post-comment.d.ts +17 -0
  156. package/dist/tooling/migrate/commands.d.ts +3 -2
  157. package/dist/tooling/migrate/config.d.ts +13 -0
  158. package/dist/tooling/migrate/export.d.ts +165 -0
  159. package/dist/tooling/migrate/ext-surface.d.ts +80 -0
  160. package/dist/tooling/migrate/ext.d.ts +31 -4
  161. package/dist/tooling/migrate/import-drizzle.d.ts +40 -0
  162. package/dist/tooling/migrate/index.d.ts +3 -0
  163. package/dist/tooling/migrate/index.js +55 -10
  164. package/dist/tooling/migrate/lint-rules.d.ts +18 -1
  165. package/dist/tooling/migrate/lint.d.ts +14 -1
  166. package/dist/tooling/migrate/place.d.ts +18 -0
  167. package/dist/tooling/migrate/plan-json.d.ts +65 -0
  168. package/dist/tooling/migrate/project.d.ts +13 -1
  169. package/dist/tooling/migrate/pull-emit.d.ts +98 -0
  170. package/dist/tooling/migrate/pull-routines.d.ts +126 -0
  171. package/dist/tooling/migrate/pull-verify.d.ts +26 -0
  172. package/dist/tooling/migrate/pull.d.ts +62 -0
  173. package/dist/tooling/migrate/reprint.d.ts +32 -0
  174. package/dist/tooling/migrate/sandbox.d.ts +8 -2
  175. package/dist/tooling/migrate/schema-api.d.ts +43 -0
  176. package/dist/tooling/migrate/sql-lex.d.ts +18 -0
  177. package/dist/tooling/shared/04svnxxj.js +344 -0
  178. package/dist/tooling/shared/0j0jtse1.js +13 -0
  179. package/dist/tooling/shared/0r05zhyq.js +618 -0
  180. package/dist/tooling/shared/1800eymw.js +49 -0
  181. package/dist/tooling/shared/35zemrmf.js +12 -0
  182. package/dist/tooling/shared/3rmaz3pq.js +140 -0
  183. package/dist/tooling/shared/3yn79q5m.js +12 -0
  184. package/dist/tooling/shared/54tqkxja.js +51 -0
  185. package/dist/tooling/shared/57btdkgm.js +209 -0
  186. package/dist/tooling/shared/5bmksndh.js +118 -0
  187. package/dist/tooling/shared/5p8km5jb.js +38 -0
  188. package/dist/tooling/shared/5x3pf400.js +185 -0
  189. package/dist/tooling/shared/5zrzffnk.js +6 -0
  190. package/dist/tooling/shared/62fxpc1p.js +332 -0
  191. package/dist/tooling/shared/68tf18v4.js +20 -0
  192. package/dist/tooling/shared/6vk28rjp.js +98 -0
  193. package/dist/tooling/shared/76pv6qff.js +9 -0
  194. package/dist/tooling/shared/7aews1zg.js +311 -0
  195. package/dist/tooling/shared/7b3xp9gc.js +195 -0
  196. package/dist/tooling/shared/7kms6fvj.js +20 -0
  197. package/dist/tooling/shared/7pxncnzs.js +40 -0
  198. package/dist/tooling/shared/829fjxyw.js +198 -0
  199. package/dist/tooling/shared/8m5znpdt.js +66 -0
  200. package/dist/tooling/shared/8yr7ges1.js +211 -0
  201. package/dist/tooling/shared/96ps4g1z.js +32 -0
  202. package/dist/tooling/shared/9qr9rkbh.js +143 -0
  203. package/dist/tooling/shared/9sfbtwsk.js +49 -0
  204. package/dist/tooling/shared/9wsnsvbf.js +10 -0
  205. package/dist/tooling/shared/a2xe04bm.js +18 -0
  206. package/dist/tooling/shared/a4pzghha.js +20 -0
  207. package/dist/tooling/shared/am04v8na.js +233 -0
  208. package/dist/tooling/shared/asgr07mp.js +194 -0
  209. package/dist/tooling/shared/c0xevn1h.js +312 -0
  210. package/dist/tooling/shared/dhatassp.js +134 -0
  211. package/dist/tooling/shared/ezqn88nj.js +1696 -0
  212. package/dist/tooling/shared/f77nnfqy.js +231 -0
  213. package/dist/tooling/shared/fh07z1dt.js +15 -0
  214. package/dist/tooling/shared/gqwevek4.js +81 -0
  215. package/dist/tooling/shared/hfq3n3bd.js +4116 -0
  216. package/dist/tooling/shared/htnaj77v.js +17 -0
  217. package/dist/tooling/shared/j664qjrt.js +64 -0
  218. package/dist/tooling/shared/jpgmjsx3.js +38 -0
  219. package/dist/tooling/shared/jr2nmr81.js +497 -0
  220. package/dist/tooling/shared/jsjjz875.js +139 -0
  221. package/dist/tooling/shared/kbqnrs1x.js +1425 -0
  222. package/dist/tooling/shared/kz715295.js +94 -0
  223. package/dist/tooling/shared/m3xt8b1h.js +22 -0
  224. package/dist/tooling/shared/m4hhb8aa.js +9 -0
  225. package/dist/tooling/shared/mw5npye0.js +16 -0
  226. package/dist/tooling/shared/n4jqhpqz.js +27 -0
  227. package/dist/tooling/shared/nxq95eb6.js +42 -0
  228. package/dist/tooling/shared/qartgazh.js +70 -0
  229. package/dist/tooling/shared/rcywj2w8.js +190 -0
  230. package/dist/tooling/shared/s6qha57m.js +16 -0
  231. package/dist/tooling/shared/shjs0379.js +150 -0
  232. package/dist/tooling/shared/sjwkt1pg.js +16 -0
  233. package/dist/tooling/shared/stebqyyd.js +401 -0
  234. package/dist/tooling/shared/t4xveemq.js +250 -0
  235. package/dist/tooling/shared/t6zjeake.js +261 -0
  236. package/dist/tooling/shared/tcwpjvxe.js +9 -0
  237. package/dist/tooling/shared/tpssp7ac.js +160 -0
  238. package/dist/tooling/shared/v6j1ep6w.js +42 -0
  239. package/dist/tooling/shared/vwr2y833.js +270 -0
  240. package/dist/tooling/shared/w17sj05d.js +7 -0
  241. package/dist/tooling/shared/w5d89rb4.js +131 -0
  242. package/dist/tooling/shared/wbwq1jsa.js +157 -0
  243. package/dist/tooling/shared/wezxf3h8.js +17 -0
  244. package/dist/tooling/shared/yb4kd19s.js +12 -0
  245. package/dist/tooling/shared/ybdew6j7.js +294 -0
  246. package/dist/tooling/shared/yfedr1zb.js +6 -0
  247. package/dist/tooling/shared/yhp829bx.js +177 -0
  248. package/dist/tooling/shared/ytk1tjs0.js +604 -0
  249. package/dist/tooling/shared/zs9aymcp.js +210 -0
  250. package/dist/tooling/shared/zx3v9phv.js +8 -0
  251. package/dist/tooling/testing/index.js +3 -3
  252. package/package.json +50 -9
  253. package/dist/shared/ktz42yez.js +0 -113
  254. package/dist/shared/ttsqgp4p.js +0 -71
  255. package/dist/shared/y34a8714.js +0 -150
  256. package/dist/shared/zy8r7qvz.js +0 -116
  257. package/dist/shared/{ywr8hmey.js → 606g0nbf.js} +3 -3
  258. package/dist/shared/{rpycarcr.js → gcefca6p.js} +4 -4
@@ -0,0 +1,233 @@
1
+ import {
2
+ outcomeUnknown2
3
+ } from "./cm3w0ywp.js";
4
+ import {
5
+ noTimeout
6
+ } from "./tr64w5p0.js";
7
+ import {
8
+ noticeBuffer,
9
+ WireSession
10
+ } from "./e275q7sd.js";
11
+ import {
12
+ NEON_WEBSOCKET_CAPABILITIES,
13
+ NEON_HTTP_CAPABILITIES,
14
+ driverErrors,
15
+ rejectClosed,
16
+ mapFailure,
17
+ runCall,
18
+ EMPTY_NOTICES,
19
+ resultFrom
20
+ } from "./mfvx6kjx.js";
21
+
22
+ // src/adapters/pg/neon.ts
23
+ import {
24
+ Pool,
25
+ neon,
26
+ neonConfig
27
+ } from "@neondatabase/serverless";
28
+ var CONNECT_MS = 30000;
29
+ var WIRE = {
30
+ getTypeParser() {
31
+ return (value) => value;
32
+ }
33
+ };
34
+ var names = new Map;
35
+ async function open6(config) {
36
+ if (config.mode === "http")
37
+ return openHttp(config);
38
+ return openWebSocket(config);
39
+ }
40
+ function connectClient2(pool, acquireMs, counters) {
41
+ counters.waiting += 1;
42
+ let settled = false;
43
+ return new Promise((resolve, reject) => {
44
+ let timer;
45
+ if (acquireMs !== undefined) {
46
+ timer = setTimeout(() => {
47
+ settled = true;
48
+ counters.waiting = Math.max(0, counters.waiting - 1);
49
+ driverErrors().then((errors) => {
50
+ reject(errors.acquireTimeout());
51
+ });
52
+ }, acquireMs);
53
+ }
54
+ take(pool).then((client) => {
55
+ if (settled) {
56
+ client.release();
57
+ return;
58
+ }
59
+ if (timer !== undefined)
60
+ clearTimeout(timer);
61
+ counters.waiting = Math.max(0, counters.waiting - 1);
62
+ resolve(client);
63
+ }, (error) => {
64
+ if (settled)
65
+ return;
66
+ if (timer !== undefined)
67
+ clearTimeout(timer);
68
+ counters.waiting = Math.max(0, counters.waiting - 1);
69
+ mapFailure(error).then(reject);
70
+ });
71
+ });
72
+ }
73
+ function send3(runner, text, params, named) {
74
+ const query = {
75
+ text,
76
+ rowMode: "array",
77
+ types: WIRE,
78
+ ...params !== undefined && params.length > 0 ? { values: params } : {},
79
+ ...named ? { name: statementName(text) } : {}
80
+ };
81
+ return runner.query(query);
82
+ }
83
+ async function openWebSocket(config) {
84
+ ensureWebSocket();
85
+ const max = config.max ?? 10;
86
+ const acquireMs = config.timeouts?.acquire;
87
+ const counters = { reserved: 0, busy: 0, reservedBusy: 0, waiting: 0 };
88
+ const notices = noticeBuffer();
89
+ let closed = false;
90
+ const isClosed = () => closed;
91
+ const named = config.prepared === "named";
92
+ const pool = new Pool({
93
+ connectionString: config.url,
94
+ max,
95
+ idleTimeoutMillis: 0,
96
+ allowExitOnIdle: true,
97
+ connectionTimeoutMillis: CONNECT_MS,
98
+ application_name: "okmodel",
99
+ types: WIRE,
100
+ ...config.searchPath !== undefined ? { options: `-c search_path=${config.searchPath}` } : {}
101
+ });
102
+ pool.on("error", () => {
103
+ return;
104
+ });
105
+ try {
106
+ const warmed = await take(pool);
107
+ warmed.release();
108
+ } catch (error) {
109
+ await pool.end().catch(() => {
110
+ return;
111
+ });
112
+ throw await mapFailure(error);
113
+ }
114
+ const root = new WireSession((text, params) => send3(pool, text, params, named), notices, isClosed, false, () => {
115
+ counters.busy += 1;
116
+ }, () => {
117
+ counters.busy = Math.max(0, counters.busy - 1);
118
+ });
119
+ const held = { pool, acquireMs, counters, notices, named, isClosed };
120
+ const checkout = () => closed ? rejectClosed() : import("./xv8qj97g.js").then((mod) => mod.checkout(held));
121
+ return {
122
+ capabilities: NEON_WEBSOCKET_CAPABILITIES,
123
+ execute(text, params, options) {
124
+ const refused = noTimeout(options);
125
+ if (refused !== undefined)
126
+ return refused;
127
+ return runCall(closed, options, (watch) => root.query(text, params, watch));
128
+ },
129
+ async batch(statements, options) {
130
+ const refused = noTimeout(options);
131
+ if (refused !== undefined)
132
+ return refused;
133
+ const connection = await checkout();
134
+ try {
135
+ return await connection.batch(statements, options);
136
+ } finally {
137
+ await connection.release();
138
+ }
139
+ },
140
+ reserve: () => checkout(),
141
+ stats: () => statsOf(counters, max),
142
+ async close() {
143
+ closed = true;
144
+ await pool.end();
145
+ }
146
+ };
147
+ }
148
+ function openHttp(config) {
149
+ const max = config.max ?? 10;
150
+ const counters = { reserved: 0, busy: 0, reservedBusy: 0, waiting: 0 };
151
+ let closed = false;
152
+ const sql = neon(config.url, { arrayMode: true, fullResults: true });
153
+ const run = async (text, params) => {
154
+ counters.busy += 1;
155
+ try {
156
+ const result = await sql.query(text, params === undefined ? [] : [...params]);
157
+ return resultFrom(result, EMPTY_NOTICES);
158
+ } finally {
159
+ counters.busy = Math.max(0, counters.busy - 1);
160
+ }
161
+ };
162
+ return {
163
+ capabilities: NEON_HTTP_CAPABILITIES,
164
+ execute(text, params, options) {
165
+ const refused = noTimeout(options);
166
+ if (refused !== undefined)
167
+ return refused;
168
+ if (closed)
169
+ return rejectClosed();
170
+ return runCall(closed, options, () => run(text, params).catch((error) => mapFailure(error).then((mapped) => Promise.reject(mapped))));
171
+ },
172
+ async batch(statements, options) {
173
+ const refused = noTimeout(options);
174
+ if (refused !== undefined)
175
+ return refused;
176
+ if (closed)
177
+ return rejectClosed();
178
+ counters.busy += 1;
179
+ try {
180
+ const queries = statements.map((statement) => sql.query(statement.text, statement.params === undefined ? [] : [...statement.params]));
181
+ const results = await sql.transaction(queries, httpOptions());
182
+ return results.map((result) => resultFrom(result, EMPTY_NOTICES));
183
+ } catch (error) {
184
+ if (!isDatabaseError(error))
185
+ throw outcomeUnknown2(error);
186
+ throw await mapFailure(error);
187
+ } finally {
188
+ counters.busy = Math.max(0, counters.busy - 1);
189
+ }
190
+ },
191
+ stats: () => statsOf(counters, max),
192
+ close() {
193
+ closed = true;
194
+ return Promise.resolve();
195
+ }
196
+ };
197
+ }
198
+ function httpOptions() {
199
+ return { arrayMode: true, fullResults: true };
200
+ }
201
+ function isDatabaseError(error) {
202
+ if (typeof error !== "object" || error === null)
203
+ return false;
204
+ const code = Reflect.get(error, "code");
205
+ return typeof code === "string" && /^[0-9A-Z]{5}$/.test(code);
206
+ }
207
+ function take(pool) {
208
+ const connect = pool.connect.bind(pool);
209
+ return connect();
210
+ }
211
+ function ensureWebSocket() {
212
+ if (neonConfig.webSocketConstructor === undefined && typeof WebSocket === "function") {
213
+ neonConfig.webSocketConstructor = WebSocket;
214
+ }
215
+ }
216
+ function statementName(text) {
217
+ const existing = names.get(text);
218
+ if (existing !== undefined)
219
+ return existing;
220
+ const name = `okm_${String(names.size)}`;
221
+ names.set(text, name);
222
+ return name;
223
+ }
224
+ function statsOf(counters, size) {
225
+ return {
226
+ size,
227
+ idle: Math.max(0, size - counters.reserved - counters.busy),
228
+ inflight: counters.busy + counters.reservedBusy,
229
+ waiting: counters.waiting
230
+ };
231
+ }
232
+
233
+ export { open6, connectClient2, send3 };
@@ -31,6 +31,22 @@ var BUNSQL_CAPABILITIES = {
31
31
  prepared: "unnamed",
32
32
  describe: false
33
33
  };
34
+ var NEON_WEBSOCKET_CAPABILITIES = {
35
+ transactions: "interactive",
36
+ stream: false,
37
+ listen: false,
38
+ cancel: false,
39
+ prepared: "unnamed",
40
+ describe: false
41
+ };
42
+ var NEON_HTTP_CAPABILITIES = {
43
+ transactions: "batch",
44
+ stream: false,
45
+ listen: false,
46
+ cancel: false,
47
+ prepared: "none",
48
+ describe: false
49
+ };
34
50
  function readCapability2(flags, name) {
35
51
  return flags[name];
36
52
  }
@@ -166,4 +182,4 @@ function countFrom(value, rows) {
166
182
  return rows;
167
183
  }
168
184
 
169
- export { POSTGRESJS_CAPABILITIES, PGLITE_CAPABILITIES, NODE_POSTGRES_CAPABILITIES, BUNSQL_CAPABILITIES, readCapability2, hasCapability2, driverErrors, rejectClosed, rejectUncancellable, rejectCancelled, rejectTimedOut, mapFailure, nextTransactionDepth, runCall, EMPTY_NOTICES, rowsFrom, resultFrom };
185
+ export { POSTGRESJS_CAPABILITIES, PGLITE_CAPABILITIES, NODE_POSTGRES_CAPABILITIES, BUNSQL_CAPABILITIES, NEON_WEBSOCKET_CAPABILITIES, NEON_HTTP_CAPABILITIES, readCapability2, hasCapability2, driverErrors, rejectClosed, rejectUncancellable, rejectCancelled, rejectTimedOut, mapFailure, nextTransactionDepth, runCall, EMPTY_NOTICES, rowsFrom, resultFrom };
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  open2
3
- } from "./14vx95q4.js";
4
- import"./qq3899ht.js";
3
+ } from "./dd5pmnky.js";
4
+ import"./12z7aznj.js";
5
+ import"./fk9vef30.js";
5
6
  import"./n442h54c.js";
6
7
  import {
7
8
  CURRENT,
@@ -14,21 +15,21 @@ import {
14
15
  import {
15
16
  expandProvisioned,
16
17
  provisionHistoryIsKnown
17
- } from "./m6p12kbr.js";
18
- import"./8skf0cam.js";
19
- import"./b5pftnn2.js";
18
+ } from "./3456242y.js";
19
+ import"./jpybhf98.js";
20
+ import"./myk8fswx.js";
20
21
  import {
21
22
  projectPath,
23
+ catalogNamespace,
22
24
  loadMigrations,
23
25
  loadConfig
24
- } from "./gs74dbj5.js";
26
+ } from "./2zdxkt7b.js";
25
27
  import {
26
28
  sessionFailure,
27
29
  finishQuiet,
28
30
  assertTargetPolicy,
29
31
  listTargets
30
- } from "./tsvww22q.js";
31
- import"./9s0ypp87.js";
32
+ } from "./6nae0spm.js";
32
33
  import {
33
34
  OkmError2
34
35
  } from "./52szzakm.js";
@@ -109,6 +110,7 @@ async function readTargetStatus(input) {
109
110
  }
110
111
  async function statusProject(cwd, flags) {
111
112
  const config = await loadConfig(cwd);
113
+ const namespace = catalogNamespace(config);
112
114
  const targets = chosen(listTargets(config), flags.target);
113
115
  const migrations = loadMigrations(projectPath(cwd, config.migrations ?? "migrations"));
114
116
  const rows = [];
@@ -117,6 +119,7 @@ async function statusProject(cwd, flags) {
117
119
  url: target.url,
118
120
  target: target.name,
119
121
  protected: target.protected,
122
+ ...namespace === "public" ? {} : { searchPath: namespace },
120
123
  migrations
121
124
  }));
122
125
  }
@@ -1,3 +1,6 @@
1
+ import {
2
+ historySql2
3
+ } from "./yybhre6n.js";
1
4
  import {
2
5
  BEHIND_EXPAND,
3
6
  BEHIND_CONTRACT,
@@ -37,10 +40,10 @@ function driftVerdict(codeHash, recordedHash, migrations) {
37
40
  const last = migrations.at(-1);
38
41
  return { state: "behind", migrationId: last?.id ?? "" };
39
42
  }
40
- async function assertDrift(pool, codeHash, recordedHash, options) {
43
+ async function assertDrift(pool, codeHash, recordedHash, options, namespace = "public") {
41
44
  let rows;
42
45
  try {
43
- const result = await pool.execute("select migration_id, class, catalog_hash from okm_history order by migration_id, step_index", undefined, options);
46
+ const result = await pool.execute(await historySql2(namespace), undefined, options);
44
47
  rows = result.rows;
45
48
  } catch (error) {
46
49
  throw gapError({ state: "behind", migrationId: "" }, error);
@@ -1,35 +1,31 @@
1
1
  import {
2
2
  roleObject,
3
3
  grantObject,
4
- defaultPrivilegeObject
5
- } from "./qq3899ht.js";
6
- import {
7
- columnPrivilege
8
- } from "./tsvww22q.js";
9
- import {
10
- quoteIdent
11
- } from "./9s0ypp87.js";
12
- import {
13
- policyObject
14
- } from "./bdk4sty6.js";
15
- import {
4
+ defaultPrivilegeObject,
16
5
  functionObject,
17
- triggerObject
18
- } from "./y34a8714.js";
19
- import {
6
+ triggerObject,
20
7
  normaliseViewQuery,
21
8
  viewObject,
22
9
  materializedViewObject,
23
10
  materializedViewIndex
24
- } from "./zy8r7qvz.js";
11
+ } from "./12z7aznj.js";
25
12
  import {
26
- extensionObject
27
- } from "./r3j8s5y0.js";
13
+ quoteIdent2
14
+ } from "./fk9vef30.js";
15
+ import {
16
+ columnPrivilege
17
+ } from "./6nae0spm.js";
18
+ import {
19
+ policyObject
20
+ } from "./bdk4sty6.js";
28
21
  import {
29
22
  catalog,
30
23
  enumType,
31
24
  domainType
32
25
  } from "./ywspezzx.js";
26
+ import {
27
+ extensionObject
28
+ } from "./r3j8s5y0.js";
33
29
  import {
34
30
  staticNamespace2,
35
31
  identityKey2,
@@ -269,7 +265,10 @@ async function introspectSchema(runner, concrete, logical = "public", options) {
269
265
  ...expression.length > 0 ? { expression } : {},
270
266
  ...refTable.length > 0 ? {
271
267
  references: {
272
- parent: { namespace, name: refTable },
268
+ parent: {
269
+ namespace: referencedNamespace(text(row, "ref_schema"), concrete, namespace),
270
+ name: refTable
271
+ },
273
272
  columns: refColumns,
274
273
  ...onDelete !== undefined ? { onDelete } : {},
275
274
  ...onUpdate !== undefined ? { onUpdate } : {}
@@ -450,8 +449,38 @@ async function introspectSchema(runner, concrete, logical = "public", options) {
450
449
  if (options?.managedRoles !== undefined) {
451
450
  objects.push(...await readPrivileges(runner, concrete, logical, namespace, provenance, objects, options.managedRoles, options.reportingRole));
452
451
  }
452
+ await includeOutsideReferences(runner, logical, provenance, objects);
453
453
  return catalog(objects);
454
454
  }
455
+ async function includeOutsideReferences(runner, logical, provenance, objects) {
456
+ const wanted = new Map;
457
+ for (const object of objects) {
458
+ if (object.kind !== "constraint" || object.definition.references === undefined)
459
+ continue;
460
+ const parent = object.definition.references.parent;
461
+ if (parent.namespace.form !== "static" || parent.namespace.name === logical)
462
+ continue;
463
+ wanted.set(`${parent.namespace.name}.${parent.name}`, {
464
+ schema: parent.namespace.name,
465
+ name: parent.name
466
+ });
467
+ }
468
+ for (const target of wanted.values()) {
469
+ const namespace = staticNamespace2(target.schema);
470
+ const parent = { namespace, name: target.name };
471
+ objects.push(table3({ namespace, name: target.name, provenance }));
472
+ const rows = await runner.query(OUTSIDE_COLUMNS, [target.schema, target.name]);
473
+ for (const row of rows) {
474
+ objects.push(column2({
475
+ parent,
476
+ name: text(row, "name"),
477
+ dataType: text(row, "type"),
478
+ nullable: !flag(row, "not_null"),
479
+ provenance
480
+ }));
481
+ }
482
+ }
483
+ }
455
484
  var EMITTED = new Set(["SELECT", "INSERT", "UPDATE", "DELETE", "EXECUTE", "USAGE"]);
456
485
  var ROLES = `select rolname, rolcanlogin, rolinherit from pg_roles where rolname !~ '^pg_'`;
457
486
  var RELATION_GRANTS = `select c.relname as name,
@@ -708,7 +737,7 @@ function indexExpression(row, columns) {
708
737
  const opclasses = list(text(row, "opc"));
709
738
  const body = columns.map((name, index) => {
710
739
  const opclass = opclasses[index];
711
- return opclass === undefined ? quoteIdent(name) : `${quoteIdent(name)} ${opclass}`;
740
+ return opclass === undefined ? quoteIdent2(name) : `${quoteIdent2(name)} ${opclass}`;
712
741
  }).join(", ");
713
742
  return `using ${method} (${body.length > 0 ? body : stored})`;
714
743
  }
@@ -765,6 +794,20 @@ var COLUMNS = `
765
794
  and ${CHILD}
766
795
  and ${member("c.oid", "pg_class")}
767
796
  `;
797
+ function referencedNamespace(refSchema, concrete, logical) {
798
+ if (refSchema.length > 0 && refSchema !== concrete)
799
+ return staticNamespace2(refSchema);
800
+ return logical;
801
+ }
802
+ var OUTSIDE_COLUMNS = `
803
+ select a.attname as name, format_type(a.atttypid, a.atttypmod) as type, a.attnotnull as not_null
804
+ from pg_attribute a
805
+ join pg_class c on c.oid = a.attrelid
806
+ join pg_namespace n on n.oid = c.relnamespace
807
+ where n.nspname = $1 and c.relname = $2
808
+ and a.attnum > 0 and not a.attisdropped
809
+ order by a.attnum
810
+ `;
768
811
  var CONSTRAINTS = `
769
812
  select rel.relname as parent, con.conname as name, con.contype as contype,
770
813
  con.condeferrable as deferrable, con.condeferred as deferred,
@@ -775,6 +818,7 @@ var CONSTRAINTS = `
775
818
  join pg_attribute a on a.attrelid = con.conrelid and a.attnum = cols.attnum
776
819
  ) as columns,
777
820
  ref.relname as ref_table,
821
+ refn.nspname as ref_schema,
778
822
  (
779
823
  select coalesce(string_agg(a.attname, ',' order by cols.ord), '')
780
824
  from unnest(con.confkey) with ordinality as cols(attnum, ord)
@@ -784,6 +828,7 @@ var CONSTRAINTS = `
784
828
  join pg_class rel on rel.oid = con.conrelid
785
829
  join pg_namespace n on n.oid = rel.relnamespace
786
830
  left join pg_class ref on ref.oid = con.confrelid
831
+ left join pg_namespace refn on refn.oid = ref.relnamespace
787
832
  where n.nspname = $1
788
833
  and con.contype in ('p', 'u', 'f', 'c')
789
834
  and not exists (select 1 from pg_inherits i where i.inhrelid = rel.oid)
@@ -1037,4 +1082,4 @@ function flag(row, key) {
1037
1082
  return value === true || value === "true" || value === "t";
1038
1083
  }
1039
1084
 
1040
- export { cellText, VIEW_DEPENDENCIES, viewDependencyEdges, PUBLIC, introspectSchema, FUNCTION_ARG_TYPES };
1085
+ export { cellText, VIEW_DEPENDENCIES, viewDependencyEdges, PUBLIC, introspectSchema, FUNCTION_ARG_TYPES, atomicBody };
@@ -4,16 +4,16 @@ import {
4
4
  applyProject2,
5
5
  pushProject2,
6
6
  backfillTiming2
7
- } from "./p6qc5gcp.js";
8
- import"./m6p12kbr.js";
9
- import"./8skf0cam.js";
10
- import"./b5pftnn2.js";
11
- import"./gs74dbj5.js";
12
- import"./tsvww22q.js";
7
+ } from "./ccsmhv9r.js";
8
+ import"./3456242y.js";
9
+ import"./jpybhf98.js";
10
+ import"./myk8fswx.js";
11
+ import"./2zdxkt7b.js";
12
+ import"./6nae0spm.js";
13
13
  import"./n442h54c.js";
14
- import"./9s0ypp87.js";
15
- import"./qq3899ht.js";
16
- import"./14vx95q4.js";
14
+ import"./fk9vef30.js";
15
+ import"./12z7aznj.js";
16
+ import"./dd5pmnky.js";
17
17
  export {
18
18
  applyProject2 as applyProject,
19
19
  applyTarget2 as applyTarget,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isRecord,
3
3
  orFail
4
- } from "./67txcrcw.js";
4
+ } from "./kgwp4jdd.js";
5
5
  import {
6
6
  isOperator,
7
7
  operatorName,