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
@@ -6,6 +6,50 @@
6
6
  * object for its records.
7
7
  */
8
8
  import type { ExtensionObject } from "../../../contracts/catalog/types.js";
9
+ /** One type the definition says the extension provides. */
10
+ export type ExtensionType = {
11
+ readonly name: string;
12
+ };
13
+ /** One operator the definition says the extension provides. */
14
+ export type ExtensionOperator = {
15
+ readonly name: string;
16
+ readonly left?: string;
17
+ readonly right?: string;
18
+ readonly result: string;
19
+ };
20
+ /** One function the definition says the extension provides. */
21
+ export type ExtensionFunction = {
22
+ readonly name: string;
23
+ readonly args: readonly string[];
24
+ readonly returns: string;
25
+ };
26
+ /** One index method the definition says the extension provides. */
27
+ export type ExtensionIndexMethod = {
28
+ readonly name: string;
29
+ readonly opclass?: string;
30
+ };
31
+ /**
32
+ * Types, operators, functions, and index methods a definition declares.
33
+ *
34
+ * `okm ext test` checks these against the connected server. They are not
35
+ * catalog objects and they do not change the catalog hash.
36
+ */
37
+ export type ExtensionProvides = {
38
+ readonly types?: readonly ExtensionType[];
39
+ readonly operators?: readonly ExtensionOperator[];
40
+ readonly functions?: readonly ExtensionFunction[];
41
+ readonly indexMethods?: readonly ExtensionIndexMethod[];
42
+ };
43
+ /**
44
+ * Version floors for a definition.
45
+ *
46
+ * `postgres` is `>=15`. `version` is an exact pin or a `>=` floor.
47
+ * `okm ext test` checks both against the connected server (OKM1812).
48
+ */
49
+ export type ExtensionRequires = {
50
+ readonly postgres?: string;
51
+ readonly version?: string;
52
+ };
9
53
  /** Options on {@link extension}. */
10
54
  export type ExtensionOptions = {
11
55
  /** Exact pin (`1.6`) or a floor (`>=0.7`). Omitted means unpinned. */
@@ -18,6 +62,14 @@ export type ExtensionOptions = {
18
62
  * The default is `true`. A move of a non-relocatable extension is OKM1814.
19
63
  */
20
64
  readonly relocatable?: boolean;
65
+ /**
66
+ * Floors `okm ext test` checks. Not stored in the catalog record.
67
+ */
68
+ readonly requires?: ExtensionRequires;
69
+ /**
70
+ * Objects `okm ext test` checks. Not stored in the catalog record.
71
+ */
72
+ readonly provides?: ExtensionProvides;
21
73
  };
22
74
  /**
23
75
  * One declared extension.
@@ -30,6 +82,10 @@ export type Extension = {
30
82
  readonly schema: string;
31
83
  readonly relocatable: boolean;
32
84
  readonly version?: string;
85
+ /** Floors from {@link ExtensionOptions.requires}. Absent when omitted. */
86
+ readonly requires?: ExtensionRequires;
87
+ /** Objects from {@link ExtensionOptions.provides}. Absent when omitted. */
88
+ readonly provides?: ExtensionProvides;
33
89
  /**
34
90
  * Catalog records for this declaration.
35
91
  *
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  extension2
3
- } from "../../../shared/jgqj11w4.js";
3
+ } from "../../../shared/6f0z3hzh.js";
4
4
  export {
5
5
  extension2 as extension
6
6
  };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The `ltree` extension. `ancestorOf` is `@>` and `descendantOf` is `<@`. This is not the parent-column walk.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { Fragment } from "../ops/fragment.js";
9
+ import type { IndexCall } from "../table.js";
10
+ import { type Extension, type ExtensionOptions } from "./index.js";
11
+ /** `ltree` plus the methods the naming overlay selected. */
12
+ export type Ltree = Extension & {
13
+ /**
14
+ * `column @> path`. The column is an ancestor of `path`.
15
+ *
16
+ * @param value - Text to compare
17
+ * @returns A where fragment
18
+ */
19
+ ancestorOf(value: string): Fragment;
20
+ /**
21
+ * `column <@ path`. The column is a descendant of `path`.
22
+ *
23
+ * @param value - Text to compare
24
+ * @returns A where fragment
25
+ */
26
+ descendantOf(value: string): Fragment;
27
+ /**
28
+ * A GiST index with `gist_ltree_ops`.
29
+ *
30
+ * @param column - SQL column name
31
+ * @returns An index call whose expression is the `using` tail
32
+ */
33
+ gist(column: string): IndexCall;
34
+ };
35
+ /**
36
+ * Declares `ltree`.
37
+ *
38
+ * @param options - Schema and version pin
39
+ * @returns The extension object and its methods
40
+ */
41
+ export declare function ltree(options?: ExtensionOptions): Ltree;
@@ -0,0 +1,29 @@
1
+ import {
2
+ extension2
3
+ } from "../../../shared/6f0z3hzh.js";
4
+ import {
5
+ opArg
6
+ } from "../../../shared/xqacq37x.js";
7
+ import {
8
+ usingIndex
9
+ } from "../../../shared/h9811jjm.js";
10
+
11
+ // src/dialects/pg/ext/ltree.ts
12
+ function ltree(options = {}) {
13
+ const declared = extension2("ltree", options);
14
+ return {
15
+ ...declared,
16
+ ancestorOf(value) {
17
+ return opArg("@>", value, "ltree");
18
+ },
19
+ descendantOf(value) {
20
+ return opArg("<@", value, "ltree");
21
+ },
22
+ gist(column) {
23
+ return usingIndex(column, "gist", "gist_ltree_ops");
24
+ }
25
+ };
26
+ }
27
+ export {
28
+ ltree
29
+ };
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  extension2
3
- } from "../../../shared/jgqj11w4.js";
3
+ } from "../../../shared/6f0z3hzh.js";
4
+ import {
5
+ usingIndex
6
+ } from "../../../shared/h9811jjm.js";
4
7
  import {
5
8
  tag
6
9
  } from "../../../shared/cn0n68ft.js";
@@ -25,18 +28,6 @@ function pgTrgm(options = {}) {
25
28
  }
26
29
  };
27
30
  }
28
- function usingIndex(column, method, opclass) {
29
- const quoted = `"${column.replaceAll('"', '""')}"`;
30
- const call = {
31
- columns: [column],
32
- isUnique: false,
33
- expression: `using ${method} (${quoted} ${opclass})`,
34
- unique() {
35
- return call;
36
- }
37
- };
38
- return call;
39
- }
40
31
  export {
41
32
  pgTrgm
42
33
  };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The `pgcrypto` extension. `digest` compares a hex digest. `fipsMode` needs version 1.4 and PostgreSQL 18.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { Fragment } from "../ops/fragment.js";
9
+ import { type Extension, type ExtensionOptions } from "./index.js";
10
+ /** `pgcrypto` plus the methods the naming overlay selected. */
11
+ export type Pgcrypto = Extension & {
12
+ /**
13
+ * `encode(digest(column, algorithm), 'hex') = hex`.
14
+ *
15
+ * @param algorithm - Digest algorithm, such as `sha256`
16
+ * @param hex - Expected hex digest
17
+ * @returns A where fragment
18
+ */
19
+ digest(algorithm: string, hex: string): Fragment;
20
+ /**
21
+ * `fips_mode()` is true or false on the column's row. Needs pgcrypto 1.4 and PostgreSQL 18.
22
+ *
23
+ * @returns A where fragment
24
+ */
25
+ fipsMode(): Fragment;
26
+ };
27
+ /**
28
+ * Declares `pgcrypto`.
29
+ *
30
+ * @param options - Schema and version pin
31
+ * @returns The extension object and its methods
32
+ */
33
+ export declare function pgcrypto(options?: ExtensionOptions): Pgcrypto;
@@ -0,0 +1,33 @@
1
+ import {
2
+ extension2
3
+ } from "../../../shared/6f0z3hzh.js";
4
+ import {
5
+ assertExtFeature
6
+ } from "../../../shared/kzgrnckd.js";
7
+ import {
8
+ bareCall,
9
+ digestEquals
10
+ } from "../../../shared/xqacq37x.js";
11
+
12
+ // src/dialects/pg/ext/pgcrypto.ts
13
+ function pgcrypto(options = {}) {
14
+ const declared = extension2("pgcrypto", options);
15
+ const schema = declared.schema;
16
+ return {
17
+ ...declared,
18
+ digest(algorithm, hex) {
19
+ return digestEquals(schema, algorithm, hex);
20
+ },
21
+ fipsMode() {
22
+ assertExtFeature(options.version, "fips_mode", {
23
+ name: "pgcrypto",
24
+ extension: "1.4",
25
+ postgres: 18
26
+ });
27
+ return bareCall(schema, "fips_mode");
28
+ }
29
+ };
30
+ }
31
+ export {
32
+ pgcrypto
33
+ };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The `unaccent` extension. `unaccent` folds accents on a text column.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { Fragment } from "../ops/fragment.js";
9
+ import { type Extension, type ExtensionOptions } from "./index.js";
10
+ /** `unaccent` plus the methods the naming overlay selected. */
11
+ export type Unaccent = Extension & {
12
+ /**
13
+ * `unaccent(column) = unaccent(value)`.
14
+ *
15
+ * @param value - Text to compare
16
+ * @returns A where fragment
17
+ */
18
+ unaccent(value: string): Fragment;
19
+ };
20
+ /**
21
+ * Declares `unaccent`.
22
+ *
23
+ * @param options - Schema and version pin
24
+ * @returns The extension object and its methods
25
+ */
26
+ export declare function unaccent(options?: ExtensionOptions): Unaccent;
@@ -0,0 +1,21 @@
1
+ import {
2
+ extension2
3
+ } from "../../../shared/6f0z3hzh.js";
4
+ import {
5
+ fnEqualsArg
6
+ } from "../../../shared/xqacq37x.js";
7
+
8
+ // src/dialects/pg/ext/unaccent.ts
9
+ function unaccent(options = {}) {
10
+ const declared = extension2("unaccent", options);
11
+ const schema = declared.schema;
12
+ return {
13
+ ...declared,
14
+ unaccent(value) {
15
+ return fnEqualsArg(schema, "unaccent", value);
16
+ }
17
+ };
18
+ }
19
+ export {
20
+ unaccent
21
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Index tails for extension operator classes.
3
+ *
4
+ * The catalog index stores `using …`. The core index factory does not grow a
5
+ * `using` field. `pg_trgm` and the generated packs share this helper.
6
+ */
7
+ import type { IndexCall } from "../table.js";
8
+ /**
9
+ * Quotes one identifier the extension wrote, not a caller string from SQL.
10
+ *
11
+ * @param name - Identifier
12
+ * @returns A double-quoted identifier
13
+ */
14
+ export declare function quotedIdent(name: string): string;
15
+ /**
16
+ * An index call whose expression is a `using` tail.
17
+ *
18
+ * @param column - SQL column name
19
+ * @param method - Index method, such as `gin` or `gist`
20
+ * @param opclass - Operator class, such as `gin_trgm_ops`
21
+ * @returns The index call
22
+ */
23
+ export declare function usingIndex(column: string, method: string, opclass: string): IndexCall;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Default versions and drift signatures for the generated packs.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * Versions are the control-file default on each supported major.
6
+ */
7
+ /** One object the drift check requires on the connected server. */
8
+ export type ExtSignature = {
9
+ readonly kind: "function";
10
+ readonly name: string;
11
+ readonly args: string;
12
+ } | {
13
+ readonly kind: "operator";
14
+ readonly name: string;
15
+ readonly left: string;
16
+ readonly right: string;
17
+ } | {
18
+ readonly kind: "opclass";
19
+ readonly name: string;
20
+ readonly method: string;
21
+ };
22
+ /** One generated pack's versions and the objects the drift check names. */
23
+ export type ExtPackRecord = {
24
+ readonly name: string;
25
+ readonly versions: {
26
+ readonly 15: string;
27
+ readonly 16: string;
28
+ readonly 17: string;
29
+ readonly 18: string;
30
+ };
31
+ /** Oldest major the base methods exist on. */
32
+ readonly minPostgres: 15;
33
+ readonly signatures: readonly ExtSignature[];
34
+ };
35
+ /** Packs this version generates. `vector` is not in the list (D281). */
36
+ export declare const EXT_PACKS: readonly ExtPackRecord[];
@@ -0,0 +1,19 @@
1
+ /**
2
+ * A table owned by another catalog.
3
+ *
4
+ * The mark is the same one `withOwner(..., "external")` stores. `schema()`
5
+ * does not read it. Tooling stamps the catalog and, when `defineConfig`
6
+ * names a snapshot, keeps this table's namespace and name from that file.
7
+ */
8
+ import type { AnyTable } from "./table.js";
9
+ /**
10
+ * Turns a table exported by another catalog into an external definition.
11
+ *
12
+ * The table object is the same value: its name and columns stay. SQL for a
13
+ * managed foreign key is schema-qualified. A plan never creates, alters, or
14
+ * drops this table. `okm check` verifies it against the snapshot.
15
+ *
16
+ * @param table - A `table()` value declared by the owning catalog
17
+ * @returns The same table, marked external
18
+ */
19
+ export declare function external<T extends AnyTable>(table: T): T;
@@ -5,12 +5,46 @@
5
5
  * records. `schema()` only asks each declared object for those records.
6
6
  */
7
7
  import type { CatalogObject, FunctionLanguage, FunctionSecurity, FunctionVolatility, TriggerEvent, TriggerLevel, TriggerTiming } from "../../../contracts/catalog/types.js";
8
+ import { type FragmentIdent } from "../ops/fragment.js";
9
+ import { type Eq } from "../operators.js";
10
+ import type { Window } from "../ops/window.js";
8
11
  import type { AnyTable, SqlText } from "../table.js";
9
12
  /** One argument of {@link fn}. */
10
13
  export type FunctionArgumentInput = {
11
14
  readonly name: string;
12
15
  readonly type: string;
13
16
  };
17
+ /** Postgres types that bind as a number. Anything else binds as text. */
18
+ type NumericReturn = "smallint" | "integer" | "bigint" | "int2" | "int4" | "int8" | "real" | "double precision" | "float4" | "float8" | "numeric";
19
+ /** A select name for {@link FnCall.as}. Numeric returns are numbers. Text stays text. */
20
+ type CallAs<R extends string, A extends string> = R extends NumericReturn | `numeric${string}` ? Window<A, number> : Window<A, string>;
21
+ /**
22
+ * A typed call.
23
+ *
24
+ * It is a `sql` fragment, so `where` accepts it as {@link Eq}. `.as(name)` is
25
+ * the `select` form. `orderBy` does not: adding the call to that union is one
26
+ * composite type over the ceiling.
27
+ *
28
+ * @typeParam R - Declared return type
29
+ */
30
+ export type FnCall<R extends string = string> = Eq<never> & {
31
+ /**
32
+ * Names the select result.
33
+ *
34
+ * @typeParam A - Result key
35
+ * @param name - Result key. Not a column name
36
+ * @returns A select entry
37
+ */
38
+ as<const A extends string>(name: A): CallAs<R, A>;
39
+ };
40
+ /** One argument value. `ident` names a field. Null is SQL null. */
41
+ type CallValue<T extends string> = T extends "boolean" | "bool" ? boolean | FragmentIdent | null : T extends NumericReturn | `numeric${string}` ? number | FragmentIdent | null : string | FragmentIdent | null;
42
+ /** Argument list of a call, in declaration order. */
43
+ type CallArgs<A extends readonly FunctionArgumentInput[]> = {
44
+ [I in keyof A]: A[I] extends FunctionArgumentInput ? CallValue<A[I]["type"]> : never;
45
+ };
46
+ /** `fn.slugify(col)`. The value is {@link FnCall}. */
47
+ type FnCaller<A extends readonly FunctionArgumentInput[], R extends string> = (...args: CallArgs<A>) => FnCall<R>;
14
48
  /**
15
49
  * A table, or one column of a table.
16
50
  *
@@ -96,7 +130,10 @@ export type TriggerDeclaration = {
96
130
  * @param options - Signature, language, body, and dependencies
97
131
  * @returns The definition object `schema({ functions })` stores
98
132
  */
99
- export declare function fn(name: string, options: FunctionOptions): Routine;
133
+ export declare function fn<const A extends readonly FunctionArgumentInput[] = readonly [], const R extends string = string>(name: string, options: FunctionOptions & {
134
+ readonly arguments?: A;
135
+ readonly returns: R;
136
+ }): Routine & FnCaller<A, R>;
100
137
  /**
101
138
  * Declares a trigger.
102
139
  *
@@ -105,3 +142,4 @@ export declare function fn(name: string, options: FunctionOptions): Routine;
105
142
  * @returns The definition object `schema({ triggers })` stores
106
143
  */
107
144
  export declare function trigger(name: string, options: TriggerOptions): TriggerDeclaration;
145
+ export {};
@@ -1,10 +1,23 @@
1
1
  import {
2
2
  functionObject,
3
3
  triggerObject
4
- } from "../../../shared/y34a8714.js";
4
+ } from "../../../shared/12z7aznj.js";
5
+ import {
6
+ quoteIdent2
7
+ } from "../../../shared/fk9vef30.js";
8
+ import {
9
+ isFragmentParts,
10
+ sqlExpression,
11
+ identName
12
+ } from "../../../shared/bsek72fg.js";
5
13
  import {
6
14
  staticNamespace2
7
15
  } from "../../../shared/358zsv4r.js";
16
+ import {
17
+ isOperator,
18
+ operatorName,
19
+ operatorValue
20
+ } from "../../../shared/cn0n68ft.js";
8
21
  import {
9
22
  assertIdentifier2
10
23
  } from "../../../shared/nfzc5z0w.js";
@@ -36,32 +49,111 @@ function fn(name, options) {
36
49
  }
37
50
  const argTypes = (options.arguments ?? []).map((argument) => argument.type);
38
51
  const schema = options.schema ?? "public";
39
- return {
40
- name,
41
- schema,
42
- argTypes,
43
- contribute(peers, built) {
44
- assertPeers(peers, "functions");
45
- const namespace = staticNamespace2(schema);
46
- const provenance = { origin: "file", name };
47
- return [
48
- functionObject({
49
- namespace,
50
- name,
51
- ...options.arguments !== undefined ? { arguments: options.arguments } : {},
52
- returns: options.returns,
53
- language,
54
- ...options.volatility !== undefined ? { volatility: options.volatility } : {},
55
- ...options.security !== undefined ? { security: options.security } : {},
56
- ...options.searchPath !== undefined ? { searchPath: options.searchPath } : {},
57
- body,
58
- ...atomic ? { atomic: true } : {},
59
- provenance,
60
- dependencies: dependencyEdges(options.dependsOn, built)
61
- })
62
- ];
63
- }
52
+ const declared = options.arguments ?? [];
53
+ const contribute = (peers, built) => {
54
+ assertPeers(peers, "functions");
55
+ const namespace = staticNamespace2(schema);
56
+ const provenance = { origin: "file", name };
57
+ return [
58
+ functionObject({
59
+ namespace,
60
+ name,
61
+ ...options.arguments !== undefined ? { arguments: options.arguments } : {},
62
+ returns: options.returns,
63
+ language,
64
+ ...options.volatility !== undefined ? { volatility: options.volatility } : {},
65
+ ...options.security !== undefined ? { security: options.security } : {},
66
+ ...options.searchPath !== undefined ? { searchPath: options.searchPath } : {},
67
+ body,
68
+ ...atomic ? { atomic: true } : {},
69
+ provenance,
70
+ dependencies: dependencyEdges(options.dependsOn, built)
71
+ })
72
+ ];
64
73
  };
74
+ const call = (...args) => invoke(schema, name, declared, options.returns, args);
75
+ define(call, "name", name);
76
+ define(call, "schema", schema);
77
+ define(call, "argTypes", argTypes);
78
+ define(call, "contribute", contribute);
79
+ return call;
80
+ }
81
+ function define(target, key, value) {
82
+ Object.defineProperty(target, key, {
83
+ value,
84
+ enumerable: true,
85
+ writable: true,
86
+ configurable: true
87
+ });
88
+ }
89
+ var NUMERIC_RETURNS = new Set([
90
+ "smallint",
91
+ "integer",
92
+ "bigint",
93
+ "int2",
94
+ "int4",
95
+ "int8",
96
+ "real",
97
+ "double precision",
98
+ "float4",
99
+ "float8",
100
+ "numeric"
101
+ ]);
102
+ function invoke(schemaName, name, declared, returns, args) {
103
+ if (args.length !== declared.length) {
104
+ throw new OkmError2("OKM1120", `Function ${name} expects ${String(declared.length)} arguments.`, { fix: { summary: "Pass one value for each declared argument, in order." } });
105
+ }
106
+ const parts = [{ k: "t", s: `${quoteIdent2(schemaName)}.${quoteIdent2(name)}(` }];
107
+ for (let index = 0;index < args.length; index += 1) {
108
+ if (index > 0)
109
+ parts.push({ k: "t", s: ", " });
110
+ appendArg(parts, args[index], name);
111
+ }
112
+ parts.push({ k: "t", s: ")" });
113
+ const textual = !(NUMERIC_RETURNS.has(returns) || returns.startsWith("numeric("));
114
+ return sqlExpression(parts, textual);
115
+ }
116
+ function appendArg(parts, value, name) {
117
+ if (value === null) {
118
+ parts.push({ k: "n" });
119
+ return;
120
+ }
121
+ if (typeof value === "string" || typeof value === "boolean") {
122
+ parts.push({ k: "p", v: String(value) });
123
+ return;
124
+ }
125
+ if (typeof value === "number") {
126
+ if (!Number.isFinite(value)) {
127
+ throw new OkmError2("OKM1120", `Function ${name} needs a finite number.`, {
128
+ fix: { summary: "Pass a finite number, or leave it out." }
129
+ });
130
+ }
131
+ parts.push({ k: "p", v: String(value) });
132
+ return;
133
+ }
134
+ const field = identName(value);
135
+ if (field !== undefined) {
136
+ parts.push({ k: "i", n: field });
137
+ return;
138
+ }
139
+ if (isOperator(value) && operatorName(value) === "sql") {
140
+ const stored = operatorValue(value);
141
+ if (isFragmentParts(stored)) {
142
+ parts.push({ k: "f", parts: stored });
143
+ return;
144
+ }
145
+ }
146
+ if (isHandle(value)) {
147
+ assertIdentifier2(value.name, `function ${name}`);
148
+ parts.push({ k: "i", n: value.name });
149
+ return;
150
+ }
151
+ throw new OkmError2("OKM1121", `Function ${name} received a value it cannot bind.`, {
152
+ fix: { summary: "Pass a string, number, boolean, null, or ident(field)." }
153
+ });
154
+ }
155
+ function isHandle(value) {
156
+ return typeof value === "object" && value !== null && "name" in value && typeof value.name === "string" && value.name.length > 0 && !isOperator(value);
65
157
  }
66
158
  function trigger(name, options) {
67
159
  return {
@@ -7,6 +7,7 @@
7
7
  export { type PostgresMajor } from "./floor.js";
8
8
  export { schema, type BuiltSchema, type SchemaCodecs, type SchemaInput, type SchemaRequires, } from "./schema.js";
9
9
  export { withOwner, type DeclaredOwner } from "./owner.js";
10
+ export { external } from "./external.js";
10
11
  export { index, sql, table, type AnyTable, type ColumnHandle, type IndexCall, type SqlText, type SqlValue, type FilterOperator, type Table, type TableOptions, } from "./table.js";
11
12
  export type { PresetQuery } from "./preset.js";
12
13
  export { custom } from "./custom.js";
@@ -57,4 +58,6 @@ export { or } from "./ops/or.js";
57
58
  export { overlaps } from "./ops/overlaps.js";
58
59
  export { path } from "./ops/path.js";
59
60
  export { startsWith } from "./ops/startsWith.js";
61
+ export { fragment, ident, type Fragment } from "./ops/fragment.js";
62
+ export { explain, raw, type ExplainResult } from "./ops/lane.js";
60
63
  export { many, manyThrough, morph, morphMany, morphTo, one, type ManyRelation, type ManyThroughRelation, type MorphManyRelation, type MorphRelation, type OneRelation, type RelationCall, } from "./relations.js";