okmodel 0.6.0 → 0.8.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 (267) hide show
  1. package/README.md +100 -1131
  2. package/dist/adapters/capabilities.d.ts +35 -0
  3. package/dist/adapters/failure.d.ts +13 -2
  4. package/dist/adapters/lazy-errors.d.ts +22 -0
  5. package/dist/adapters/pg/bun-sql.d.ts +53 -0
  6. package/dist/adapters/pg/bunsql-extra.d.ts +54 -3
  7. package/dist/adapters/pg/bunsql.d.ts +15 -2
  8. package/dist/adapters/pg/cursor.d.ts +17 -0
  9. package/dist/adapters/pg/neon-extra.d.ts +18 -0
  10. package/dist/adapters/pg/neon.d.ts +104 -0
  11. package/dist/adapters/pg/no-inflight-timeout.d.ts +11 -8
  12. package/dist/adapters/pg/nodepostgres-extra.d.ts +22 -1
  13. package/dist/adapters/pg/nodepostgres.d.ts +12 -0
  14. package/dist/adapters/pg/pglite-wire.d.ts +24 -0
  15. package/dist/adapters/pg/pglite.d.ts +10 -0
  16. package/dist/adapters/pg/postgres-extra.d.ts +27 -11
  17. package/dist/adapters/pg/reserved.d.ts +42 -0
  18. package/dist/adapters/pg/session.d.ts +0 -18
  19. package/dist/contracts/connection.d.ts +7 -6
  20. package/dist/contracts/error.d.ts +1 -1
  21. package/dist/dialects/pg/floor.d.ts +68 -0
  22. package/dist/dialects/pg/fn/index.d.ts +39 -1
  23. package/dist/dialects/pg/fn/index.js +118 -26
  24. package/dist/dialects/pg/index.d.ts +8 -1
  25. package/dist/dialects/pg/index.js +435 -170
  26. package/dist/dialects/pg/introspect.d.ts +11 -0
  27. package/dist/dialects/pg/keys.d.ts +11 -8
  28. package/dist/dialects/pg/model.d.ts +40 -0
  29. package/dist/dialects/pg/morph.d.ts +43 -0
  30. package/dist/dialects/pg/operator-fit.d.ts +2 -2
  31. package/dist/dialects/pg/operators.d.ts +14 -7
  32. package/dist/dialects/pg/ops/bucket.d.ts +65 -0
  33. package/dist/dialects/pg/ops/fragment.d.ts +119 -0
  34. package/dist/dialects/pg/ops/inc.d.ts +2 -2
  35. package/dist/dialects/pg/ops/lane.d.ts +49 -0
  36. package/dist/dialects/pg/ops/matches.d.ts +9 -12
  37. package/dist/dialects/pg/ops/relevance.d.ts +13 -0
  38. package/dist/dialects/pg/ops/search-query.d.ts +22 -0
  39. package/dist/dialects/pg/ops/window.d.ts +103 -0
  40. package/dist/dialects/pg/preset.d.ts +1 -1
  41. package/dist/dialects/pg/relations.d.ts +100 -3
  42. package/dist/dialects/pg/schema.d.ts +31 -3
  43. package/dist/dialects/pg/view/client.d.ts +14 -6
  44. package/dist/dialects/pg/view/index.d.ts +73 -1
  45. package/dist/dialects/pg/view/index.js +156 -5
  46. package/dist/dialects/pg/view/scratch.d.ts +8 -5
  47. package/dist/runtime/aggregate.d.ts +8 -2
  48. package/dist/runtime/bucket-group.d.ts +70 -0
  49. package/dist/runtime/conflict.d.ts +22 -4
  50. package/dist/runtime/include.d.ts +0 -8
  51. package/dist/runtime/inflight.d.ts +1 -1
  52. package/dist/runtime/otel.d.ts +105 -0
  53. package/dist/runtime/otel.js +97 -0
  54. package/dist/runtime/page.d.ts +4 -1
  55. package/dist/runtime/pg/bun.js +12 -6
  56. package/dist/runtime/pg/neon.d.ts +38 -0
  57. package/dist/runtime/pg/neon.js +64 -0
  58. package/dist/runtime/pg/pg.js +5 -5
  59. package/dist/runtime/pg/pglite.d.ts +1 -0
  60. package/dist/runtime/pg/pglite.js +9 -9
  61. package/dist/runtime/pg/postgresjs.js +5 -5
  62. package/dist/runtime/plan.d.ts +95 -5
  63. package/dist/runtime/read-stream.d.ts +13 -16
  64. package/dist/runtime/result-name.d.ts +17 -0
  65. package/dist/runtime/server-check.d.ts +3 -3
  66. package/dist/runtime/sort-bind.d.ts +21 -0
  67. package/dist/runtime/sort.d.ts +56 -0
  68. package/dist/runtime/sql-fragment.d.ts +43 -0
  69. package/dist/runtime/sync.d.ts +70 -0
  70. package/dist/runtime/tenancy/index.js +15 -13
  71. package/dist/runtime/text-search.d.ts +20 -0
  72. package/dist/runtime/topology.d.ts +1 -1
  73. package/dist/runtime/traits/index.d.ts +80 -0
  74. package/dist/runtime/traits/index.js +184 -21
  75. package/dist/runtime/tree.d.ts +38 -0
  76. package/dist/runtime/types.d.ts +232 -22
  77. package/dist/runtime/validate/index.js +4 -4
  78. package/dist/runtime/version.d.ts +39 -0
  79. package/dist/runtime/window.d.ts +21 -0
  80. package/dist/runtime/write.d.ts +54 -2
  81. package/dist/shared/{929h19xp.js → 0wrea3jq.js} +141 -13
  82. package/dist/shared/{qq3899ht.js → 12z7aznj.js} +243 -14
  83. package/dist/shared/{1z04fa85.js → 14x60fbf.js} +12 -57
  84. package/dist/shared/{ek2wt2dz.js → 16kvjebh.js} +4 -4
  85. package/dist/shared/{wynzeggs.js → 195pzzzz.js} +8 -8
  86. package/dist/shared/1d9q9cv2.js +312 -0
  87. package/dist/shared/2c13q96h.js +18 -0
  88. package/dist/shared/{b4v57v3x.js → 2d3xq4ps.js} +2 -2
  89. package/dist/shared/{1f0xa3cb.js → 3449rcae.js} +5 -5
  90. package/dist/shared/{wkme6tep.js → 35q0n9tz.js} +8 -16
  91. package/dist/shared/3bb7wsqt.js +99 -0
  92. package/dist/shared/3t6kw83m.js +249 -0
  93. package/dist/shared/{5j36z8dn.js → 4m6hskg8.js} +39 -70
  94. package/dist/shared/{n076ydsc.js → 4vbf83xx.js} +69 -28
  95. package/dist/shared/{vmfkhszw.js → 63f4ksbz.js} +33 -26
  96. package/dist/shared/{c58secgj.js → 63qtkrca.js} +38 -4
  97. package/dist/shared/6m78c8ss.js +6 -0
  98. package/dist/shared/{x3jc53kg.js → 760ppr76.js} +15 -7
  99. package/dist/shared/7ghwamrf.js +40 -0
  100. package/dist/shared/7kms6fvj.js +20 -0
  101. package/dist/shared/7n7ddwt4.js +6 -0
  102. package/dist/shared/9a4ae4p8.js +31 -0
  103. package/dist/shared/{hazqqecq.js → 9dr2qnx7.js} +63 -34
  104. package/dist/shared/{h15jx9bc.js → 9dvh1dr6.js} +1 -1
  105. package/dist/shared/a62rb2da.js +13 -0
  106. package/dist/shared/{cgbamx3e.js → ae4j5f42.js} +23 -4
  107. package/dist/shared/agsfb86s.js +233 -0
  108. package/dist/shared/{8x72s86k.js → b6d6p0zc.js} +13 -7
  109. package/dist/shared/{ag4c7516.js → b76b8d95.js} +2 -2
  110. package/dist/shared/{j60w0dvr.js → bah9nbg3.js} +58 -38
  111. package/dist/shared/bnby0esn.js +10 -0
  112. package/dist/shared/bsek72fg.js +225 -0
  113. package/dist/shared/{2cg3wnxc.js → bxas03mq.js} +608 -141
  114. package/dist/shared/{31vm914h.js → cm3w0ywp.js} +15 -16
  115. package/dist/shared/{gwn6v667.js → cnkky55j.js} +25 -14
  116. package/dist/shared/{dk8v79p3.js → d5nmj7vv.js} +1 -1
  117. package/dist/shared/{ttmg09vd.js → dpc2r7rb.js} +8 -8
  118. package/dist/shared/dzj09cye.js +10 -0
  119. package/dist/shared/{sbdme3vy.js → e8zyaqvj.js} +60 -10
  120. package/dist/shared/{2jd1sn0e.js → ecn8mfdq.js} +6 -6
  121. package/dist/shared/exn3sd90.js +359 -0
  122. package/dist/shared/{t3g0k88x.js → f4jy1j7x.js} +39 -22
  123. package/dist/shared/{y2t3jktd.js → fjpnhqan.js} +20 -13
  124. package/dist/shared/g5yc06ka.js +272 -0
  125. package/dist/shared/ga9j92qj.js +25 -0
  126. package/dist/shared/{3fqwmr09.js → hfqmpasr.js} +6 -6
  127. package/dist/shared/{wt5rzv1h.js → hm5f8jby.js} +7 -7
  128. package/dist/shared/{ys0xzyaj.js → hqpxf4a4.js} +224 -19
  129. package/dist/shared/jebgrkeq.js +179 -0
  130. package/dist/shared/{09p049xa.js → jp36k7dp.js} +44 -16
  131. package/dist/shared/jx2m62cs.js +96 -0
  132. package/dist/shared/{r11n8grd.js → k86n8vq3.js} +7 -4
  133. package/dist/shared/{2z7wv5tj.js → kgwp4jdd.js} +56 -35
  134. package/dist/shared/{knmes2kh.js → kj9d8maq.js} +1 -1
  135. package/dist/shared/{g90m9b0g.js → m4xff2a6.js} +6 -5
  136. package/dist/shared/{r6nwkxnt.js → m7n9h2a5.js} +4 -4
  137. package/dist/shared/mfedzr74.js +145 -0
  138. package/dist/shared/{f0f1n281.js → mkrn359n.js} +60 -11
  139. package/dist/shared/{p248q79y.js → mnvjvqyp.js} +10 -10
  140. package/dist/shared/{672t5vym.js → mss6ctgv.js} +2 -2
  141. package/dist/shared/{4az561fn.js → mtw6jz76.js} +8 -23
  142. package/dist/shared/n05z9nwz.js +313 -0
  143. package/dist/shared/{pjr6xrm5.js → n0jmpgj1.js} +20 -17
  144. package/dist/shared/{p6bjzq9q.js → n41w4fbz.js} +14 -6
  145. package/dist/shared/{b3awxn7h.js → n454kcnw.js} +1 -1
  146. package/dist/shared/n7kg8mmx.js +61 -0
  147. package/dist/shared/nbw1z4yd.js +18 -0
  148. package/dist/shared/needfe47.js +66 -0
  149. package/dist/shared/{1nw1f3vs.js → njga14v4.js} +9 -9
  150. package/dist/shared/{5yv4k6a6.js → nmnsgj7x.js} +145 -3
  151. package/dist/shared/{vjpnzwjz.js → p3xbdcvt.js} +14 -18
  152. package/dist/shared/p5nh3r8q.js +622 -0
  153. package/dist/shared/{nx9hh281.js → pan0370z.js} +13 -12
  154. package/dist/shared/q0cqt2sp.js +12 -0
  155. package/dist/shared/qd9hhd8f.js +37 -0
  156. package/dist/shared/{mb2ycs1p.js → qfw14tna.js} +15 -15
  157. package/dist/shared/{9s0ypp87.js → sjk86yrx.js} +1 -1
  158. package/dist/shared/th3be82n.js +208 -0
  159. package/dist/shared/{ed0b8k4s.js → typ3vy7t.js} +1 -1
  160. package/dist/shared/{5d8t84hg.js → v1wad97q.js} +14 -14
  161. package/dist/shared/{x72jb7ad.js → v8g1vgv8.js} +1 -1
  162. package/dist/shared/{9628a9xt.js → vk7rag46.js} +1 -1
  163. package/dist/shared/{ze4hxsmy.js → w9ejzaqf.js} +1 -1
  164. package/dist/shared/{q3j1tq7a.js → wcrheftc.js} +148 -23
  165. package/dist/shared/wvdjznah.js +213 -0
  166. package/dist/shared/wz2a78mp.js +8 -0
  167. package/dist/shared/xfhe73sb.js +436 -0
  168. package/dist/shared/{r1fdd0f6.js → z581d7ny.js} +5 -2
  169. package/dist/shared/{8etn7d8w.js → z7s6fpxv.js} +1 -1
  170. package/dist/shared/{32cnm7kn.js → zbqbmmrp.js} +76 -40
  171. package/dist/shared/{n7mcc1gk.js → zchaghkf.js} +4 -3
  172. package/dist/shared/{xq0mvhts.js → zgex00fd.js} +6 -6
  173. package/dist/shared/{nsva2a6b.js → znm0bpp5.js} +3 -0
  174. package/dist/shared/zq1he88x.js +155 -0
  175. package/dist/tooling/cli.js +26 -13
  176. package/dist/tooling/driver-run.js +4971 -0
  177. package/dist/tooling/driver-test.d.ts +36 -0
  178. package/dist/tooling/migrate/commands.d.ts +2 -2
  179. package/dist/tooling/migrate/engine.d.ts +3 -2
  180. package/dist/tooling/migrate/index.js +9 -9
  181. package/dist/tooling/migrate/project.d.ts +3 -0
  182. package/dist/tooling/shared/03k6res6.js +210 -0
  183. package/dist/tooling/shared/08kemxjd.js +10 -0
  184. package/dist/tooling/shared/2revefqt.js +209 -0
  185. package/dist/tooling/shared/2wtvc7rw.js +1425 -0
  186. package/dist/tooling/shared/345tbc2k.js +16 -0
  187. package/dist/tooling/shared/3m1hkg7z.js +344 -0
  188. package/dist/tooling/shared/3rrw5w8f.js +81 -0
  189. package/dist/tooling/shared/3tq8pnb8.js +131 -0
  190. package/dist/tooling/shared/417zdsk7.js +194 -0
  191. package/dist/tooling/shared/4d2w25vw.js +40 -0
  192. package/dist/tooling/shared/54tqkxja.js +51 -0
  193. package/dist/tooling/shared/5bvw2nev.js +12 -0
  194. package/dist/tooling/shared/6nyfyw70.js +231 -0
  195. package/dist/tooling/shared/72fyg4zv.js +160 -0
  196. package/dist/tooling/shared/733a1tq3.js +38 -0
  197. package/dist/tooling/shared/7ae7rjmn.js +20 -0
  198. package/dist/tooling/shared/7kms6fvj.js +20 -0
  199. package/dist/tooling/shared/8sqrsw3s.js +49 -0
  200. package/dist/tooling/shared/96ps4g1z.js +32 -0
  201. package/dist/tooling/shared/9kazs5p6.js +195 -0
  202. package/dist/tooling/shared/9xzm7hjg.js +38 -0
  203. package/dist/tooling/shared/a6pp9d12.js +49 -0
  204. package/dist/tooling/shared/a7q7t4n3.js +22 -0
  205. package/dist/tooling/shared/aftb2mwr.js +18 -0
  206. package/dist/tooling/shared/bz2dqhab.js +311 -0
  207. package/dist/tooling/shared/cmptmb4f.js +12 -0
  208. package/dist/tooling/shared/ddjtfgnx.js +177 -0
  209. package/dist/tooling/shared/djydjpqt.js +261 -0
  210. package/dist/tooling/shared/dw08f3m8.js +9 -0
  211. package/dist/tooling/shared/dy672fz6.js +16 -0
  212. package/dist/tooling/shared/dzx85q70.js +66 -0
  213. package/dist/tooling/shared/ec71zqgt.js +270 -0
  214. package/dist/{shared/d5azex6s.js → tooling/shared/ep8zh3bk.js} +1 -1
  215. package/dist/tooling/shared/f9mphxej.js +3789 -0
  216. package/dist/tooling/shared/fb9k2qwd.js +89 -0
  217. package/dist/tooling/shared/g9ad4n80.js +211 -0
  218. package/dist/tooling/shared/gfvtj6d0.js +94 -0
  219. package/dist/tooling/shared/gmcf9cxf.js +294 -0
  220. package/dist/tooling/shared/htnaj77v.js +17 -0
  221. package/dist/tooling/shared/j9t5s12a.js +7 -0
  222. package/dist/tooling/shared/jne7b93p.js +42 -0
  223. package/dist/tooling/shared/ma2340rx.js +118 -0
  224. package/dist/tooling/shared/mtrqn2hn.js +505 -0
  225. package/dist/tooling/shared/n4jqhpqz.js +27 -0
  226. package/dist/tooling/shared/nf7jmhfa.js +20 -0
  227. package/dist/tooling/shared/p7f08ktn.js +332 -0
  228. package/dist/tooling/shared/ppnnnvj8.js +13 -0
  229. package/dist/tooling/shared/pqy21k24.js +312 -0
  230. package/dist/tooling/shared/pw8fgahx.js +69 -0
  231. package/dist/tooling/shared/pwsytxm5.js +17 -0
  232. package/dist/tooling/shared/rf83gr2d.js +94 -0
  233. package/dist/tooling/shared/rq5kk8j6.js +401 -0
  234. package/dist/tooling/shared/rs1jb051.js +12 -0
  235. package/dist/tooling/shared/smn6kz1p.js +157 -0
  236. package/dist/tooling/shared/spk1jg3r.js +1696 -0
  237. package/dist/tooling/shared/tn8gay14.js +143 -0
  238. package/dist/tooling/shared/vraj6d74.js +42 -0
  239. package/dist/tooling/shared/vs0t6qt8.js +64 -0
  240. package/dist/tooling/shared/vx86qjv8.js +150 -0
  241. package/dist/tooling/shared/w7qe8sj1.js +140 -0
  242. package/dist/tooling/shared/wt7j7nf6.js +15 -0
  243. package/dist/tooling/shared/wwnekq5n.js +6 -0
  244. package/dist/tooling/shared/xhrnjch9.js +185 -0
  245. package/dist/tooling/shared/xjs6zqtc.js +190 -0
  246. package/dist/tooling/shared/y031jct9.js +16 -0
  247. package/dist/tooling/shared/y5656f0e.js +233 -0
  248. package/dist/tooling/shared/yfr8hzhm.js +604 -0
  249. package/dist/tooling/shared/yk9mp7vb.js +250 -0
  250. package/dist/tooling/shared/yw30vnq2.js +139 -0
  251. package/dist/tooling/shared/z8d7ptht.js +618 -0
  252. package/dist/tooling/shared/zhwnfyb2.js +9 -0
  253. package/dist/tooling/shared/zvnhh1n0.js +198 -0
  254. package/dist/tooling/testing/index.js +3 -3
  255. package/package.json +17 -3
  256. package/dist/shared/3qnhc7w5.js +0 -38
  257. package/dist/shared/7m88x3e9.js +0 -45
  258. package/dist/shared/8dqhth8c.js +0 -12
  259. package/dist/shared/j3rkk835.js +0 -99
  260. package/dist/shared/k68eedmy.js +0 -85
  261. package/dist/shared/venqrjna.js +0 -216
  262. package/dist/shared/wxr8cwns.js +0 -6
  263. package/dist/shared/y34a8714.js +0 -150
  264. package/dist/shared/zm0mafk4.js +0 -92
  265. package/dist/shared/zy8r7qvz.js +0 -116
  266. package/dist/shared/{ywr8hmey.js → 606g0nbf.js} +3 -3
  267. package/dist/shared/{rpycarcr.js → gcefca6p.js} +4 -4
@@ -11,10 +11,10 @@ import {
11
11
  startupCatalog2,
12
12
  catalogFileText2,
13
13
  parseCatalog2
14
- } from "./qq3899ht.js";
14
+ } from "./12z7aznj.js";
15
15
  import {
16
16
  open2
17
- } from "./wkme6tep.js";
17
+ } from "./35q0n9tz.js";
18
18
  import {
19
19
  sqlStatements,
20
20
  transactionControl,
@@ -35,29 +35,33 @@ import {
35
35
  assertTargetAlias,
36
36
  listTargets,
37
37
  selectTarget
38
- } from "./ttmg09vd.js";
38
+ } from "./dpc2r7rb.js";
39
39
  import {
40
40
  contributedFields
41
41
  } from "./n0dgs0pb.js";
42
42
  import {
43
43
  assertValidation,
44
44
  writeWouldValidate
45
- } from "./ze4hxsmy.js";
45
+ } from "./w9ejzaqf.js";
46
46
  import {
47
47
  tableOwner,
48
48
  stampOwnership
49
49
  } from "./xqve9598.js";
50
50
  import {
51
- catalog,
52
- isDomain
53
- } from "./ywspezzx.js";
51
+ POSTGRES_FLOOR,
52
+ uuidv7NeedsPostgres
53
+ } from "./ga9j92qj.js";
54
54
  import {
55
55
  snakeCase,
56
56
  emittedTypeName
57
- } from "./rpycarcr.js";
57
+ } from "./gcefca6p.js";
58
58
  import {
59
59
  ColumnBuilder2
60
- } from "./ywr8hmey.js";
60
+ } from "./606g0nbf.js";
61
+ import {
62
+ catalog,
63
+ isDomain
64
+ } from "./ywspezzx.js";
61
65
  import {
62
66
  staticNamespace2
63
67
  } from "./358zsv4r.js";
@@ -193,8 +197,8 @@ var ERROR_DOCS = [
193
197
  {
194
198
  code: "OKM1110",
195
199
  title: "Engine version",
196
- summary: "The feature needs a newer engine than schema({ requires }) allows.",
197
- fix: "Raise requires, or stop using the feature. The error names both versions."
200
+ summary: "A feature needs a newer PostgreSQL than minPostgres allows. The message names the feature, the version it needs, and this schema's minimum.",
201
+ fix: "Raise minPostgres, or stop using the feature. The error names both versions."
198
202
  },
199
203
  {
200
204
  code: "OKM1111",
@@ -230,7 +234,13 @@ var ERROR_DOCS = [
230
234
  code: "OKM1124",
231
235
  title: "Operator mismatch",
232
236
  summary: "An operator does not apply to the column type.",
233
- fix: "Use an operator the error lists for that column type. Text search needs a tsvector column."
237
+ fix: "Use an operator the error lists for that column type. Search needs a column built for search, not a plain text column."
238
+ },
239
+ {
240
+ code: "OKM1125",
241
+ title: "Bad SQL fragment",
242
+ summary: "A composed fragment is empty, unbalanced, or interpolates a value it cannot bind. A select fragment that is not a number is the same code.",
243
+ fix: "Interpolate a string, number, boolean, null, ident(name), fragment.column, or another fragment. Keep parentheses and quotes balanced. A select fragment is a numeric expression named with as()."
234
244
  },
235
245
  {
236
246
  code: "OKM1130",
@@ -532,6 +542,12 @@ var ERROR_DOCS = [
532
542
  summary: "A typed SQL signature no longer matches the database.",
533
543
  fix: "Regenerate the typed SQL and commit the new signature."
534
544
  },
545
+ {
546
+ code: "OKM1602",
547
+ title: "Bad typed SQL",
548
+ summary: "A raw statement is missing its class, is not one select or one write, or the result class has no column initializers.",
549
+ fix: 'Pass "read" or "write", a fragment`...`, and a class with an initializer on every column. Identifiers are ident(name).'
550
+ },
535
551
  {
536
552
  code: "OKM1701",
537
553
  title: "Tenant context missing",
@@ -541,8 +557,8 @@ var ERROR_DOCS = [
541
557
  {
542
558
  code: "OKM1702",
543
559
  title: "Unverifiable tenant SQL",
544
- summary: "Raw SQL touches a tenant table and the tenant predicate cannot be proved.",
545
- fix: "Use the query builder, or mark the fragment trusted with a reason if it is reviewed."
560
+ summary: "Raw SQL on a tenant table cannot prove the tenant predicate. A raw write is this. A raw read that does not select the primary key with ident is this.",
561
+ fix: 'Use update or delete, or select the primary key with ident(name). unscoped("reason") is the reviewed hatch.'
546
562
  },
547
563
  {
548
564
  code: "OKM1704",
@@ -583,14 +599,14 @@ var ERROR_DOCS = [
583
599
  {
584
600
  code: "OKM1802",
585
601
  title: "Server version",
586
- summary: "The connected server does not satisfy schema({ requires }).",
587
- fix: "Upgrade the server, or lower requires to a version the server meets."
602
+ summary: "The connected server is older than this schema's minPostgres.",
603
+ fix: "Upgrade the server, or lower minPostgres to a major the server meets."
588
604
  },
589
605
  {
590
606
  code: "OKM1803",
591
607
  title: "Postgres floor",
592
- summary: "The connected server is older than PostgreSQL 15, and the schema does not set requires to that older major.",
593
- fix: "Upgrade the server to PostgreSQL 15 or newer, or set schema({ requires }) to the older major on purpose."
608
+ summary: `The connected server is older than PostgreSQL ${String(POSTGRES_FLOOR)}.`,
609
+ fix: `Upgrade the server to PostgreSQL ${String(POSTGRES_FLOOR)} or higher.`
594
610
  },
595
611
  {
596
612
  code: "OKM1810",
@@ -607,8 +623,8 @@ var ERROR_DOCS = [
607
623
  {
608
624
  code: "OKM1812",
609
625
  title: "Feature version",
610
- summary: "A feature needs a newer Postgres or extension version than the one declared or connected.",
611
- fix: 'Raise the declared version, or avoid the feature. uuidv7() below 18 can use t.id({ default: "uuidv4" }), defaults.id set to "uuidv4", or a client generator. Core features are never gated on an extension.'
626
+ summary: "A feature needs a newer PostgreSQL than minPostgres, or an extension version the server does not have. The message names the feature and the version.",
627
+ fix: `Raise minPostgres, or avoid the feature. ${uuidv7NeedsPostgres()} An extension pin names the version to install. Core features are never gated on an extension.`
612
628
  },
613
629
  {
614
630
  code: "OKM1813",
@@ -2382,12 +2398,13 @@ async function checkProject(cwd, flags) {
2382
2398
  const target = selectTarget(opened.config, named);
2383
2399
  assertTargetPolicy(target, "check", flags?.allowProtected ?? false);
2384
2400
  assertTargetPolicy(target, "drift", flags?.allowProtected ?? false);
2385
- const { assertAuthorDrift } = await import("./1f0xa3cb.js");
2401
+ const { assertAuthorDrift } = await import("./3449rcae.js");
2386
2402
  const allowPooler = flags?.allowPooler === true || opened.config.allowPooler === true;
2387
2403
  await assertAuthorDrift(target.url, opened.built.catalog, opened.config.roles, allowPooler);
2388
2404
  return findings;
2389
2405
  }
2390
2406
  function unlistedTableFiles(schemaSource, fileNames) {
2407
+ const folded = schemaSource.toLowerCase();
2391
2408
  const missing = [];
2392
2409
  for (const file of fileNames) {
2393
2410
  if (!file.endsWith(".ts"))
@@ -2395,7 +2412,7 @@ function unlistedTableFiles(schemaSource, fileNames) {
2395
2412
  const stem = basename(file, ".ts");
2396
2413
  if (stem.length === 0 || stem.startsWith("."))
2397
2414
  continue;
2398
- if (!schemaSource.includes(stem))
2415
+ if (!folded.includes(stem.toLowerCase()))
2399
2416
  missing.push(file);
2400
2417
  }
2401
2418
  return missing;
@@ -1,7 +1,13 @@
1
+ import {
2
+ POSTGRES_FLOOR,
3
+ isPostgresMajor,
4
+ parsePostgresFloor,
5
+ serverNeedsPostgres
6
+ } from "./ga9j92qj.js";
1
7
  import {
2
8
  withHttp,
3
9
  attachHttp
4
- } from "./j60w0dvr.js";
10
+ } from "./bah9nbg3.js";
5
11
  import {
6
12
  OkmError2
7
13
  } from "./52szzakm.js";
@@ -11,7 +17,7 @@ var versionQuery = "select current_setting('server_version_num'), version(), (se
11
17
  async function acceptServer(pool, schema, rows, http, requireMeta, options, source) {
12
18
  for (const name in schema.model) {
13
19
  if (schema.model[name]?.presets !== undefined) {
14
- (await import("./r6nwkxnt.js")).checkSchema(schema);
20
+ (await import("./m7n9h2a5.js")).checkSchema(schema);
15
21
  break;
16
22
  }
17
23
  }
@@ -31,7 +37,7 @@ async function acceptServer(pool, schema, rows, http, requireMeta, options, sour
31
37
  }));
32
38
  }
33
39
  } else {
34
- const { assertCompatible } = await import("./ek2wt2dz.js");
40
+ const { assertCompatible } = await import("./16kvjebh.js");
35
41
  try {
36
42
  await assertCompatible(pool, schema, recorded, source, options);
37
43
  } catch (error) {
@@ -41,20 +47,21 @@ async function acceptServer(pool, schema, rows, http, requireMeta, options, sour
41
47
  }
42
48
  }
43
49
  const major = Math.floor(Number(rows[0]?.[0] ?? "0") / 1e4);
44
- const requires = schema.requires?.postgres;
45
- if (requires === undefined) {
46
- if (major < 15) {
47
- throw new OkmError2("OKM1803", `The server is PostgreSQL ${String(major)}. PostgreSQL 15 is the oldest supported.`, withHttp(http, {
48
- fix: { summary: "Upgrade to PostgreSQL 15, or set schema({ requires }) to this major." }
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
+ }
49
57
  }));
50
58
  }
51
59
  return;
52
60
  }
53
- const match = /^>=(\d+)$/.exec(requires.trim());
54
- const need = match?.[1] === undefined ? undefined : Number(match[1]);
55
- if (need === undefined || major < need) {
56
- throw new OkmError2("OKM1802", `The server is PostgreSQL ${String(major)}. schema({ requires }) asks for ${requires}.`, withHttp(http, {
57
- fix: { summary: "Upgrade the server, or lower requires to a version the server meets." }
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." }
58
65
  }));
59
66
  }
60
67
  }
@@ -0,0 +1,272 @@
1
+ import {
2
+ readHandle,
3
+ readCall,
4
+ attachHttp
5
+ } from "./bah9nbg3.js";
6
+ import {
7
+ decodeResult,
8
+ emitWhere,
9
+ emitOrder,
10
+ selectedColumns,
11
+ rejectKeys,
12
+ projectExpr,
13
+ indexes,
14
+ quote,
15
+ list,
16
+ isRecord,
17
+ fail2
18
+ } from "./kgwp4jdd.js";
19
+ import {
20
+ OkmError2,
21
+ throwNamed2
22
+ } from "./52szzakm.js";
23
+
24
+ // src/runtime/tree.ts
25
+ var OPTIONS = [
26
+ "where",
27
+ "select",
28
+ "orderBy",
29
+ "depth",
30
+ "self",
31
+ "relation",
32
+ "route",
33
+ "signal",
34
+ "timeout"
35
+ ];
36
+ function build2(session, table, options, mods, view) {
37
+ try {
38
+ return open(session, table, options, mods, view);
39
+ } catch (error) {
40
+ throw error instanceof OkmError2 ? attachHttp(session.http, error) : error;
41
+ }
42
+ }
43
+ function open(session, table, options, mods, view) {
44
+ const packed = readPacked(options);
45
+ const user = packed.user;
46
+ rejectKeys(user, OPTIONS, packed.walk);
47
+ const indexed = indexes(session.schema).get(table);
48
+ if (indexed === undefined)
49
+ fail2("OKM1120", `Table ${table} is not in the schema.`);
50
+ const edge = pickEdge(indexed, user.relation);
51
+ const identity = identityColumn2(session, indexed);
52
+ const depth = readDepth(user.depth);
53
+ const self = readSelf(user.self);
54
+ const id = userId(identity, packed.id);
55
+ const shared = {
56
+ ...user.where !== undefined ? { where: user.where } : {},
57
+ ...user.select !== undefined ? { select: user.select } : {},
58
+ ...user.orderBy !== undefined ? { orderBy: user.orderBy } : {},
59
+ ...user.signal !== undefined ? { signal: user.signal } : {},
60
+ ...user.timeout !== undefined ? { timeout: user.timeout } : {},
61
+ ...user.route !== undefined ? { route: user.route } : {}
62
+ };
63
+ const base = readCall("find", table, shared, mods.all, session.scope, session.schema.model[table], session.schema, view);
64
+ const spec = { direction: packed.walk, edge, identity, depth, self, id };
65
+ const call = {
66
+ ...base,
67
+ op: packed.walk,
68
+ build: (schema, planned, sink, outputs, source) => {
69
+ emitTree(schema, planned, sink, outputs, source, spec);
70
+ }
71
+ };
72
+ return readHandle(session, table, call, mods, (compiled, rows) => decodeResult(compiled, rows, table));
73
+ }
74
+ function emitTree(schema, table, sink, outputs, call, spec) {
75
+ const { direction, edge, identity, depth, self, id } = spec;
76
+ sink.mark(`walk:${direction}|rel:${edge.name}|self:${self ? "1" : "0"}|depth:${depth === undefined ? "all" : String(depth)}|`);
77
+ const selected = selectedColumns(table, call.select);
78
+ sink.text("with recursive walk as (select ");
79
+ emitKeyList(sink, "s", edge.parent, "k");
80
+ emitKeyList(sink, "s", edge.child, "f");
81
+ sink.text(", 0 as depth, array[s.");
82
+ sink.text(quote(identity.sql));
83
+ sink.text("] as seen from ");
84
+ sink.text(quote(table.model.sql));
85
+ sink.text(" s where s.");
86
+ sink.text(quote(identity.sql));
87
+ sink.text(" = ");
88
+ sink.param(identity.encode(id));
89
+ emitWhere(schema, table, undefined, sink, "s", 0, true);
90
+ sink.text(" union all select ");
91
+ let started = emitBare(sink, "c", edge.parent, false);
92
+ emitBare(sink, "c", edge.child, started);
93
+ sink.text(", w.depth + 1, w.seen || c.");
94
+ sink.text(quote(identity.sql));
95
+ sink.text(" from ");
96
+ sink.text(quote(table.model.sql));
97
+ sink.text(" c join walk w on ");
98
+ if (direction === "descendants")
99
+ emitStep(sink, "c", edge.child, edge.parent, "k");
100
+ else
101
+ emitStep(sink, "c", edge.parent, edge.child, "f");
102
+ sink.text(" where c.");
103
+ sink.text(quote(identity.sql));
104
+ sink.text(" <> all(w.seen)");
105
+ if (depth !== undefined) {
106
+ sink.text(" and w.depth < ");
107
+ sink.text(String(depth));
108
+ }
109
+ emitWhere(schema, table, undefined, sink, "c", 0, true);
110
+ sink.text(") select ");
111
+ let column = 0;
112
+ for (let index = 0;index < selected.length; index += 1) {
113
+ const item = selected[index];
114
+ if (item === undefined)
115
+ continue;
116
+ if (column > 0)
117
+ sink.text(", ");
118
+ sink.text(projectExpr(`t.${quote(item.sql)}`, item.dataType));
119
+ sink.mark(`s:${item.field}`);
120
+ outputs?.fields.push({ key: item.field, at: column, decode: item.decode });
121
+ column += 1;
122
+ }
123
+ if (column === 0)
124
+ sink.text("1");
125
+ sink.text(" from ");
126
+ sink.text(quote(table.model.sql));
127
+ sink.text(" t join walk w on ");
128
+ emitStep(sink, "t", edge.parent, edge.parent, "k");
129
+ if (self)
130
+ emitWhere(schema, table, call.where, sink, "t", 0, false);
131
+ else {
132
+ sink.text(" where w.depth > 0");
133
+ emitWhere(schema, table, call.where, sink, "t", 0, true);
134
+ }
135
+ if (call.orderBy !== undefined) {
136
+ emitOrder(table, call.orderBy, sink, "t");
137
+ return;
138
+ }
139
+ sink.text(" order by w.depth asc");
140
+ sink.mark("order:depth");
141
+ for (const field of table.model.primary) {
142
+ const item = table.columns.get(field);
143
+ if (item === undefined)
144
+ continue;
145
+ sink.text(", t.");
146
+ sink.text(quote(item.sql));
147
+ sink.text(" asc");
148
+ }
149
+ }
150
+ function emitKeyList(sink, alias, columns, prefix) {
151
+ for (let index = 0;index < columns.length; index += 1) {
152
+ const name = columns[index];
153
+ if (name === undefined)
154
+ continue;
155
+ if (index > 0 || prefix === "f")
156
+ sink.text(", ");
157
+ sink.text(alias);
158
+ sink.text(".");
159
+ sink.text(quote(name));
160
+ sink.text(" as ");
161
+ sink.text(prefix);
162
+ sink.text(String(index));
163
+ }
164
+ }
165
+ function emitBare(sink, alias, columns, lead) {
166
+ let started = lead;
167
+ for (const name of columns) {
168
+ if (started)
169
+ sink.text(", ");
170
+ started = true;
171
+ sink.text(alias);
172
+ sink.text(".");
173
+ sink.text(quote(name));
174
+ }
175
+ return started;
176
+ }
177
+ function emitStep(sink, alias, columns, against, prefix) {
178
+ for (let index = 0;index < columns.length; index += 1) {
179
+ const name = columns[index];
180
+ if (name === undefined || against[index] === undefined)
181
+ continue;
182
+ if (index > 0)
183
+ sink.text(" and ");
184
+ sink.text(alias);
185
+ sink.text(".");
186
+ sink.text(quote(name));
187
+ sink.text(" = w.");
188
+ sink.text(prefix);
189
+ sink.text(String(index));
190
+ }
191
+ }
192
+ function readPacked(options) {
193
+ if (!isRecord(options) || options.walk !== "descendants" && options.walk !== "ancestors") {
194
+ fail2("OKM1120", "descendants and ancestors are table methods.");
195
+ }
196
+ const user = options.options;
197
+ if (user === undefined)
198
+ return { id: options.id, walk: options.walk, user: {} };
199
+ if (!isRecord(user))
200
+ fail2("OKM1120", `${options.walk} options must be an object.`);
201
+ return { id: options.id, walk: options.walk, user };
202
+ }
203
+ function pickEdge(table, relation) {
204
+ const edges = selfEdges(table);
205
+ if (edges.length === 0) {
206
+ fail2("OKM1120", `${table.model.name} has no relation to itself.`, `Declare children: many("${table.model.name}") or parent: one("${table.model.name}").`);
207
+ }
208
+ const groups = new Set(edges.map((edge) => edge.child.join("\x00")));
209
+ if (relation === undefined) {
210
+ if (groups.size !== 1) {
211
+ fail2("OKM1120", `${table.model.name} has more than one relation to itself. Pass relation.`, `Accepted names: ${edges.map((edge) => edge.name).join(", ")}.`);
212
+ }
213
+ const only = edges[0];
214
+ if (only === undefined)
215
+ fail2("OKM1120", `${table.model.name} has no relation to itself.`);
216
+ return only;
217
+ }
218
+ if (typeof relation !== "string" || relation.length === 0) {
219
+ fail2("OKM1120", "relation must be a name.");
220
+ }
221
+ const found = edges.find((edge) => edge.name === relation);
222
+ if (found === undefined) {
223
+ throwNamed2("OKM1120", relation, edges.map((edge) => edge.name), `Relation ${relation} is not a self-relation of ${table.model.name}. Accepted names: ${list(edges.map((edge) => edge.name))}.`);
224
+ }
225
+ return found;
226
+ }
227
+ function selfEdges(table) {
228
+ const edges = [];
229
+ for (const relation of table.model.relations) {
230
+ if (relation.table !== table.model.name || relation.through !== undefined)
231
+ continue;
232
+ edges.push(relation.kind === "many" ? { name: relation.name, parent: relation.local, child: relation.remote } : { name: relation.name, parent: relation.remote, child: relation.local });
233
+ }
234
+ return edges;
235
+ }
236
+ function identityColumn2(session, table) {
237
+ const tenancy = session.schema.tenancy;
238
+ const keys = tenancy === undefined ? [] : tenancy.keys ?? [tenancy.key];
239
+ const fields = table.model.primary.filter((field) => !keys.includes(field));
240
+ if (fields.length !== 1) {
241
+ fail2("OKM1120", `${table.model.name} needs one primary key column besides the tenant key.`, "Use a single-column primary key.");
242
+ }
243
+ const field = fields[0];
244
+ const column = field === undefined ? undefined : table.columns.get(field);
245
+ if (column === undefined) {
246
+ fail2("OKM1120", `${table.model.name} needs one primary key column besides the tenant key.`);
247
+ }
248
+ return column;
249
+ }
250
+ function readDepth(value) {
251
+ if (value === undefined)
252
+ return;
253
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
254
+ fail2("OKM1120", "depth must be an integer from 0 up.");
255
+ }
256
+ return value;
257
+ }
258
+ function readSelf(value) {
259
+ if (value === undefined)
260
+ return false;
261
+ if (typeof value !== "boolean")
262
+ fail2("OKM1120", "self must be true or false.");
263
+ return value;
264
+ }
265
+ function userId(column, id) {
266
+ if (id === undefined || id === null) {
267
+ fail2("OKM1121", `${column.field} needs a value.`);
268
+ }
269
+ return id;
270
+ }
271
+
272
+ export { build2, identityColumn2 };
@@ -0,0 +1,25 @@
1
+ // src/dialects/pg/floor.ts
2
+ var POSTGRES_FLOOR = 15;
3
+ var UUIDV7_POSTGRES = 18;
4
+ function isPostgresMajor(value) {
5
+ return typeof value === "number" && (value | 0) === value && value >= 15 && value <= 18;
6
+ }
7
+ var FLOOR_TEXT = /^>=(\d+)$/;
8
+ function parsePostgresFloor(postgres) {
9
+ return Number(FLOOR_TEXT.exec(postgres ?? "")?.[1]);
10
+ }
11
+ function formatPostgresFloor(major) {
12
+ return `>=${major}`;
13
+ }
14
+ function minPostgresDefinition() {
15
+ return "minPostgres: 15-18.";
16
+ }
17
+ function uuidv7NeedsPostgres() {
18
+ const need = UUIDV7_POSTGRES;
19
+ return `uuidv7() needs PostgreSQL ${need} or higher. minPostgres: ${need}.`;
20
+ }
21
+ function serverNeedsPostgres(server, need) {
22
+ return `The server is PostgreSQL ${server}. This schema needs PostgreSQL ${need} or higher (minPostgres: ${need}).`;
23
+ }
24
+
25
+ export { POSTGRES_FLOOR, UUIDV7_POSTGRES, isPostgresMajor, parsePostgresFloor, formatPostgresFloor, minPostgresDefinition, uuidv7NeedsPostgres, serverNeedsPostgres };
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  open2
3
- } from "./wkme6tep.js";
4
- import"./qq3899ht.js";
3
+ } from "./35q0n9tz.js";
4
+ import"./12z7aznj.js";
5
5
  import {
6
6
  createdOf,
7
7
  testing2
8
- } from "./8x72s86k.js";
8
+ } from "./b6d6p0zc.js";
9
9
  import"./n442h54c.js";
10
10
  import {
11
11
  projectPath,
12
12
  loadConfig,
13
13
  loadSchema
14
- } from "./t3g0k88x.js";
14
+ } from "./f4jy1j7x.js";
15
15
  import {
16
16
  sessionFailure,
17
17
  finishQuiet,
@@ -19,8 +19,8 @@ import {
19
19
  assertDirectConnection,
20
20
  assertStableBackend,
21
21
  selectTarget
22
- } from "./ttmg09vd.js";
23
- import"./9s0ypp87.js";
22
+ } from "./dpc2r7rb.js";
23
+ import"./sjk86yrx.js";
24
24
  import {
25
25
  OkmError2
26
26
  } from "./52szzakm.js";
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  open2
3
- } from "./wkme6tep.js";
4
- import"./qq3899ht.js";
3
+ } from "./35q0n9tz.js";
4
+ import"./12z7aznj.js";
5
5
  import"./n442h54c.js";
6
6
  import {
7
7
  assertRoleHealth
8
- } from "./knmes2kh.js";
9
- import"./vjpnzwjz.js";
8
+ } from "./kj9d8maq.js";
9
+ import"./p3xbdcvt.js";
10
10
  import {
11
11
  errorDoc,
12
12
  openProject
13
- } from "./t3g0k88x.js";
13
+ } from "./f4jy1j7x.js";
14
14
  import {
15
15
  omitManagedObjects,
16
16
  sessionFailure,
17
17
  finishQuiet,
18
18
  assertTargetPolicy,
19
19
  selectTarget
20
- } from "./ttmg09vd.js";
21
- import"./9s0ypp87.js";
20
+ } from "./dpc2r7rb.js";
21
+ import"./sjk86yrx.js";
22
22
  import {
23
23
  OkmError2
24
24
  } from "./52szzakm.js";