okmodel 0.8.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 (202) hide show
  1. package/README.md +14 -0
  2. package/dist/dialects/pg/ext/btree-gin.d.ts +26 -0
  3. package/dist/dialects/pg/ext/btree-gin.js +20 -0
  4. package/dist/dialects/pg/ext/btree-gist.d.ts +26 -0
  5. package/dist/dialects/pg/ext/btree-gist.js +20 -0
  6. package/dist/dialects/pg/ext/call.d.ts +53 -0
  7. package/dist/dialects/pg/ext/citext.js +1 -1
  8. package/dist/dialects/pg/ext/feature.d.ts +26 -0
  9. package/dist/dialects/pg/ext/fuzzystrmatch.d.ts +34 -0
  10. package/dist/dialects/pg/ext/fuzzystrmatch.js +33 -0
  11. package/dist/dialects/pg/ext/hstore.d.ts +41 -0
  12. package/dist/dialects/pg/ext/hstore.js +29 -0
  13. package/dist/dialects/pg/ext/index.d.ts +56 -0
  14. package/dist/dialects/pg/ext/index.js +1 -1
  15. package/dist/dialects/pg/ext/ltree.d.ts +41 -0
  16. package/dist/dialects/pg/ext/ltree.js +29 -0
  17. package/dist/dialects/pg/ext/pg-trgm.js +4 -13
  18. package/dist/dialects/pg/ext/pgcrypto.d.ts +33 -0
  19. package/dist/dialects/pg/ext/pgcrypto.js +33 -0
  20. package/dist/dialects/pg/ext/unaccent.d.ts +26 -0
  21. package/dist/dialects/pg/ext/unaccent.js +21 -0
  22. package/dist/dialects/pg/ext/using.d.ts +23 -0
  23. package/dist/dialects/pg/ext/versions.d.ts +36 -0
  24. package/dist/dialects/pg/external.d.ts +19 -0
  25. package/dist/dialects/pg/fn/index.js +4 -4
  26. package/dist/dialects/pg/index.d.ts +1 -0
  27. package/dist/dialects/pg/index.js +16 -11
  28. package/dist/dialects/pg/view/index.js +5 -5
  29. package/dist/dialects/pg/view/scratch.d.ts +4 -1
  30. package/dist/runtime/artifact-file.d.ts +22 -0
  31. package/dist/runtime/client.d.ts +10 -0
  32. package/dist/runtime/drift-detail.d.ts +2 -1
  33. package/dist/runtime/drift.d.ts +3 -10
  34. package/dist/runtime/pg/bun.js +4 -4
  35. package/dist/runtime/pg/neon.js +4 -4
  36. package/dist/runtime/pg/pg.js +4 -4
  37. package/dist/runtime/pg/pglite.js +4 -4
  38. package/dist/runtime/pg/postgresjs.js +4 -4
  39. package/dist/runtime/server-check.d.ts +36 -6
  40. package/dist/runtime/traits/index.js +5 -5
  41. package/dist/runtime/validate/index.js +1 -1
  42. package/dist/shared/{4m6hskg8.js → 0j6qe91y.js} +4 -4
  43. package/dist/shared/{14x60fbf.js → 1mxm04fy.js} +5 -5
  44. package/dist/shared/{b6d6p0zc.js → 2szgv6yj.js} +5 -5
  45. package/dist/shared/{f4jy1j7x.js → 2zdxkt7b.js} +909 -100
  46. package/dist/shared/{mnvjvqyp.js → 3456242y.js} +17 -17
  47. package/dist/shared/3t6kw83m.js +1 -1
  48. package/dist/shared/{6m78c8ss.js → 5kyb3tqx.js} +1 -1
  49. package/dist/shared/61bmrmhr.js +35 -0
  50. package/dist/shared/{zbqbmmrp.js → 62b603gr.js} +8 -8
  51. package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
  52. package/dist/shared/{dpc2r7rb.js → 6nae0spm.js} +150 -89
  53. package/dist/shared/{0wrea3jq.js → 71n0jmhc.js} +1 -1
  54. package/dist/shared/7ba5h6pb.js +17 -0
  55. package/dist/shared/{k86n8vq3.js → 8jesqsrk.js} +1 -1
  56. package/dist/shared/{qd9hhd8f.js → 8n688yjg.js} +1 -1
  57. package/dist/shared/{zgex00fd.js → 8qzkd9f3.js} +5 -5
  58. package/dist/shared/{mkrn359n.js → 90sg0w5a.js} +159 -31
  59. package/dist/shared/{7ghwamrf.js → 99qp9vtg.js} +1 -1
  60. package/dist/shared/{bxas03mq.js → 9dtgn1z2.js} +1 -1
  61. package/dist/shared/{p5nh3r8q.js → aksb89mn.js} +2 -2
  62. package/dist/shared/{wcrheftc.js → bphrgwz9.js} +2 -2
  63. package/dist/shared/{wz2a78mp.js → c3mvnq7a.js} +1 -1
  64. package/dist/shared/{pan0370z.js → ccsmhv9r.js} +24 -6
  65. package/dist/shared/{n0jmpgj1.js → cexb7z6b.js} +1 -1
  66. package/dist/shared/{wvdjznah.js → cf8zdz5p.js} +5 -5
  67. package/dist/shared/{3449rcae.js → ckz05z15.js} +4 -4
  68. package/dist/shared/{35q0n9tz.js → dd5pmnky.js} +7 -7
  69. package/dist/shared/{e8zyaqvj.js → ds229x4r.js} +1 -1
  70. package/dist/{tooling/shared/yw30vnq2.js → shared/e275q7sd.js} +1 -1
  71. package/dist/shared/{mfedzr74.js → ebhz8vh6.js} +4 -4
  72. package/dist/shared/{z581d7ny.js → fdsz3w80.js} +2 -2
  73. package/dist/shared/{sjk86yrx.js → fk9vef30.js} +84 -73
  74. package/dist/shared/{needfe47.js → g89fmz5s.js} +1 -1
  75. package/dist/shared/{m4xff2a6.js → ghqzdp94.js} +2 -2
  76. package/dist/shared/h9811jjm.js +17 -0
  77. package/dist/shared/{kj9d8maq.js → jpybhf98.js} +1 -1
  78. package/dist/shared/kzgrnckd.js +29 -0
  79. package/dist/shared/{agsfb86s.js → mazpbcdj.js} +4 -4
  80. package/dist/shared/{195pzzzz.js → mgaq2sd3.js} +10 -7
  81. package/dist/shared/{5mtf6cj3.js → mvmm3xpb.js} +5 -2
  82. package/dist/shared/{p3xbdcvt.js → myk8fswx.js} +55 -6
  83. package/dist/shared/{njga14v4.js → n306gqkd.js} +8 -8
  84. package/dist/shared/n5whk3mt.js +665 -0
  85. package/dist/shared/{bah9nbg3.js → npdftanb.js} +12 -20
  86. package/dist/shared/{16kvjebh.js → pg4ezgyf.js} +7 -26
  87. package/dist/{tooling/shared/08kemxjd.js → shared/pgsak1yw.js} +1 -1
  88. package/dist/shared/{jp36k7dp.js → qvwwp1mp.js} +61 -40
  89. package/dist/shared/rbxt795q.js +1766 -0
  90. package/dist/shared/{g5yc06ka.js → s7he5e5d.js} +1 -1
  91. package/dist/shared/{hfqmpasr.js → ss2kv2rs.js} +5 -5
  92. package/dist/shared/stfa9xcw.js +450 -0
  93. package/dist/{tooling/shared/rs1jb051.js → shared/tr64w5p0.js} +1 -1
  94. package/dist/shared/{jebgrkeq.js → tw1nvvfj.js} +2 -2
  95. package/dist/shared/{v1wad97q.js → wvtjg5m3.js} +1 -1
  96. package/dist/shared/xqacq37x.js +61 -0
  97. package/dist/shared/{n05z9nwz.js → xtsydxjg.js} +1 -1
  98. package/dist/shared/{jx2m62cs.js → xv8qj97g.js} +5 -5
  99. package/dist/shared/{63f4ksbz.js → xwhdcrm4.js} +1 -1
  100. package/dist/shared/{hm5f8jby.js → yvabyg9k.js} +6 -6
  101. package/dist/shared/yybhre6n.js +136 -0
  102. package/dist/shared/zdqf8k5d.js +8 -0
  103. package/dist/tooling/cli.js +94 -22
  104. package/dist/tooling/driver-run.js +15 -332
  105. package/dist/tooling/github/comment.d.ts +50 -0
  106. package/dist/tooling/github/post-comment.d.ts +17 -0
  107. package/dist/tooling/migrate/commands.d.ts +2 -1
  108. package/dist/tooling/migrate/config.d.ts +13 -0
  109. package/dist/tooling/migrate/export.d.ts +165 -0
  110. package/dist/tooling/migrate/ext-surface.d.ts +80 -0
  111. package/dist/tooling/migrate/ext.d.ts +31 -4
  112. package/dist/tooling/migrate/import-drizzle.d.ts +40 -0
  113. package/dist/tooling/migrate/index.d.ts +3 -0
  114. package/dist/tooling/migrate/index.js +55 -10
  115. package/dist/tooling/migrate/lint-rules.d.ts +18 -1
  116. package/dist/tooling/migrate/lint.d.ts +14 -1
  117. package/dist/tooling/migrate/place.d.ts +18 -0
  118. package/dist/tooling/migrate/plan-json.d.ts +65 -0
  119. package/dist/tooling/migrate/project.d.ts +10 -1
  120. package/dist/tooling/migrate/pull-emit.d.ts +98 -0
  121. package/dist/tooling/migrate/pull-routines.d.ts +126 -0
  122. package/dist/tooling/migrate/pull-verify.d.ts +26 -0
  123. package/dist/tooling/migrate/pull.d.ts +62 -0
  124. package/dist/tooling/migrate/reprint.d.ts +32 -0
  125. package/dist/tooling/migrate/sandbox.d.ts +8 -2
  126. package/dist/tooling/migrate/schema-api.d.ts +43 -0
  127. package/dist/tooling/migrate/sql-lex.d.ts +18 -0
  128. package/dist/tooling/shared/{3m1hkg7z.js → 04svnxxj.js} +4 -4
  129. package/dist/tooling/shared/{ppnnnvj8.js → 0j0jtse1.js} +1 -1
  130. package/dist/tooling/shared/{z8d7ptht.js → 0r05zhyq.js} +5 -5
  131. package/dist/tooling/shared/{a6pp9d12.js → 1800eymw.js} +3 -3
  132. package/dist/tooling/shared/{cmptmb4f.js → 35zemrmf.js} +1 -1
  133. package/dist/tooling/shared/{w7qe8sj1.js → 3rmaz3pq.js} +1 -1
  134. package/dist/{shared/q0cqt2sp.js → tooling/shared/3yn79q5m.js} +1 -1
  135. package/dist/tooling/shared/{2revefqt.js → 57btdkgm.js} +2 -2
  136. package/dist/tooling/shared/{ma2340rx.js → 5bmksndh.js} +2 -2
  137. package/dist/tooling/shared/{9xzm7hjg.js → 5p8km5jb.js} +3 -3
  138. package/dist/tooling/shared/{xhrnjch9.js → 5x3pf400.js} +3 -3
  139. package/dist/tooling/shared/{wwnekq5n.js → 5zrzffnk.js} +1 -1
  140. package/dist/tooling/shared/{p7f08ktn.js → 62fxpc1p.js} +7 -7
  141. package/dist/tooling/shared/{7ae7rjmn.js → 68tf18v4.js} +2 -2
  142. package/dist/tooling/shared/{rf83gr2d.js → 6vk28rjp.js} +7 -3
  143. package/dist/tooling/shared/76pv6qff.js +9 -0
  144. package/dist/tooling/shared/{bz2dqhab.js → 7aews1zg.js} +3 -3
  145. package/dist/tooling/shared/{9kazs5p6.js → 7b3xp9gc.js} +3 -3
  146. package/dist/tooling/shared/{4d2w25vw.js → 7pxncnzs.js} +2 -2
  147. package/dist/tooling/shared/{zvnhh1n0.js → 829fjxyw.js} +2 -2
  148. package/dist/tooling/shared/{dzx85q70.js → 8m5znpdt.js} +1 -1
  149. package/dist/tooling/shared/{g9ad4n80.js → 8yr7ges1.js} +7 -7
  150. package/dist/tooling/shared/{tn8gay14.js → 9qr9rkbh.js} +6 -6
  151. package/dist/tooling/shared/{8sqrsw3s.js → 9sfbtwsk.js} +3 -3
  152. package/dist/{shared/bnby0esn.js → tooling/shared/9wsnsvbf.js} +1 -1
  153. package/dist/tooling/shared/{aftb2mwr.js → a2xe04bm.js} +1 -1
  154. package/dist/tooling/shared/{nf7jmhfa.js → a4pzghha.js} +2 -2
  155. package/dist/tooling/shared/{y5656f0e.js → am04v8na.js} +5 -5
  156. package/dist/tooling/shared/{417zdsk7.js → asgr07mp.js} +5 -5
  157. package/dist/tooling/shared/{pqy21k24.js → c0xevn1h.js} +4 -4
  158. package/dist/tooling/shared/dhatassp.js +134 -0
  159. package/dist/tooling/shared/{spk1jg3r.js → ezqn88nj.js} +8 -8
  160. package/dist/tooling/shared/{6nyfyw70.js → f77nnfqy.js} +2 -2
  161. package/dist/tooling/shared/{wt7j7nf6.js → fh07z1dt.js} +1 -1
  162. package/dist/tooling/shared/{3rrw5w8f.js → gqwevek4.js} +1 -1
  163. package/dist/tooling/shared/{f9mphxej.js → hfq3n3bd.js} +346 -19
  164. package/dist/tooling/shared/{vs0t6qt8.js → j664qjrt.js} +2 -2
  165. package/dist/tooling/shared/{733a1tq3.js → jpgmjsx3.js} +3 -3
  166. package/dist/tooling/shared/{mtrqn2hn.js → jr2nmr81.js} +22 -30
  167. package/dist/{shared/mtw6jz76.js → tooling/shared/jsjjz875.js} +1 -1
  168. package/dist/tooling/shared/{2wtvc7rw.js → kbqnrs1x.js} +2 -2
  169. package/dist/tooling/shared/{gfvtj6d0.js → kz715295.js} +7 -7
  170. package/dist/tooling/shared/{a7q7t4n3.js → m3xt8b1h.js} +2 -2
  171. package/dist/tooling/shared/{dw08f3m8.js → m4hhb8aa.js} +2 -2
  172. package/dist/tooling/shared/{y031jct9.js → mw5npye0.js} +2 -2
  173. package/dist/tooling/shared/{vraj6d74.js → nxq95eb6.js} +3 -3
  174. package/dist/tooling/shared/{fb9k2qwd.js → qartgazh.js} +11 -30
  175. package/dist/tooling/shared/{xjs6zqtc.js → rcywj2w8.js} +9 -9
  176. package/dist/tooling/shared/{dy672fz6.js → s6qha57m.js} +2 -2
  177. package/dist/tooling/shared/{vx86qjv8.js → shjs0379.js} +3 -3
  178. package/dist/tooling/shared/{345tbc2k.js → sjwkt1pg.js} +1 -1
  179. package/dist/tooling/shared/{rq5kk8j6.js → stebqyyd.js} +3 -3
  180. package/dist/tooling/shared/{yk9mp7vb.js → t4xveemq.js} +4 -4
  181. package/dist/tooling/shared/{djydjpqt.js → t6zjeake.js} +5 -5
  182. package/dist/tooling/shared/{zhwnfyb2.js → tcwpjvxe.js} +1 -1
  183. package/dist/tooling/shared/{72fyg4zv.js → tpssp7ac.js} +1 -1
  184. package/dist/tooling/shared/{jne7b93p.js → v6j1ep6w.js} +3 -3
  185. package/dist/tooling/shared/{ec71zqgt.js → vwr2y833.js} +2 -2
  186. package/dist/tooling/shared/{j9t5s12a.js → w17sj05d.js} +2 -2
  187. package/dist/tooling/shared/{3tq8pnb8.js → w5d89rb4.js} +1 -1
  188. package/dist/tooling/shared/{smn6kz1p.js → wbwq1jsa.js} +2 -2
  189. package/dist/tooling/shared/{pwsytxm5.js → wezxf3h8.js} +1 -1
  190. package/dist/tooling/shared/{5bvw2nev.js → yb4kd19s.js} +1 -1
  191. package/dist/tooling/shared/{gmcf9cxf.js → ybdew6j7.js} +2 -2
  192. package/dist/tooling/shared/{ep8zh3bk.js → yfedr1zb.js} +1 -1
  193. package/dist/tooling/shared/{ddjtfgnx.js → yhp829bx.js} +3 -3
  194. package/dist/tooling/shared/{yfr8hzhm.js → ytk1tjs0.js} +1 -1
  195. package/dist/tooling/shared/{03k6res6.js → zs9aymcp.js} +1 -1
  196. package/dist/tooling/shared/zx3v9phv.js +8 -0
  197. package/dist/tooling/testing/index.js +2 -2
  198. package/package.json +38 -9
  199. package/dist/shared/fjpnhqan.js +0 -71
  200. package/dist/shared/n41w4fbz.js +0 -113
  201. package/dist/tooling/shared/pw8fgahx.js +0 -69
  202. /package/dist/shared/{ae4j5f42.js → mfvx6kjx.js} +0 -0
package/README.md CHANGED
@@ -135,6 +135,20 @@ export async function removeNote(id: string) {
135
135
 
136
136
  `okm push` is for a database you can recreate. A shared database uses reviewed migrations: `okm generate init`, then `okm migrate apply`.
137
137
 
138
+ ## 0.9
139
+
140
+ This release is the tooling train. `okm pull` writes schema files from a database. `okm import drizzle` writes them from a Drizzle schema. Several catalogs share one database through `external()` and `okm catalog export`. `describe` and `buildCatalog` are on `okmodel/migrate`. Extension packs cover `unaccent`, `hstore`, `ltree`, `btree_gist`, `btree_gin`, `fuzzystrmatch`, and `pgcrypto`. The GitHub Action posts the migration plan on a pull request. A type change that rewrites a table is five migrations, not one `ALTER COLUMN … TYPE`.
141
+
142
+ | Want… | Go to |
143
+ | ----------------------- | ---------------------------------------------------------------------- |
144
+ | Pull a database | [pull](https://okm.omqkhafi.dev/docs/reference/cli#pull) |
145
+ | Import Drizzle | [From Drizzle](https://okm.omqkhafi.dev/docs/start/from-drizzle) |
146
+ | Several catalogs | [Catalogs](https://okm.omqkhafi.dev/docs/define/schema/catalogs) |
147
+ | `describe` | [Schema API](https://okm.omqkhafi.dev/docs/reference/schema-api) |
148
+ | Extension packs | [Extensions](https://okm.omqkhafi.dev/docs/define/schema/extensions) |
149
+ | The GitHub Action | [GitHub Action](https://okm.omqkhafi.dev/docs/reference/github-action) |
150
+ | A rewriting type change | [Type change](https://okm.omqkhafi.dev/docs/reference/type-change) |
151
+
138
152
  ## Next
139
153
 
140
154
  | Want… | Go to |
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The `btree_gin` extension. `gin` stores a GIN operator class for scalar equality.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { IndexCall } from "../table.js";
9
+ import { type Extension, type ExtensionOptions } from "./index.js";
10
+ /** `btree_gin` plus the methods the naming overlay selected. */
11
+ export type BtreeGin = Extension & {
12
+ /**
13
+ * A GIN index with `int4_ops`.
14
+ *
15
+ * @param column - SQL column name
16
+ * @returns An index call whose expression is the `using` tail
17
+ */
18
+ gin(column: string): IndexCall;
19
+ };
20
+ /**
21
+ * Declares `btree_gin`.
22
+ *
23
+ * @param options - Schema and version pin
24
+ * @returns The extension object and its methods
25
+ */
26
+ export declare function btreeGin(options?: ExtensionOptions): BtreeGin;
@@ -0,0 +1,20 @@
1
+ import {
2
+ extension2
3
+ } from "../../../shared/6f0z3hzh.js";
4
+ import {
5
+ usingIndex
6
+ } from "../../../shared/h9811jjm.js";
7
+
8
+ // src/dialects/pg/ext/btree-gin.ts
9
+ function btreeGin(options = {}) {
10
+ const declared = extension2("btree_gin", options);
11
+ return {
12
+ ...declared,
13
+ gin(column) {
14
+ return usingIndex(column, "gin", "int4_ops");
15
+ }
16
+ };
17
+ }
18
+ export {
19
+ btreeGin
20
+ };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The `btree_gist` extension. `gist` stores a GiST operator class so an exclude constraint can use `=`.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { IndexCall } from "../table.js";
9
+ import { type Extension, type ExtensionOptions } from "./index.js";
10
+ /** `btree_gist` plus the methods the naming overlay selected. */
11
+ export type BtreeGist = Extension & {
12
+ /**
13
+ * A GiST index with `gist_int4_ops`.
14
+ *
15
+ * @param column - SQL column name
16
+ * @returns An index call whose expression is the `using` tail
17
+ */
18
+ gist(column: string): IndexCall;
19
+ };
20
+ /**
21
+ * Declares `btree_gist`.
22
+ *
23
+ * @param options - Schema and version pin
24
+ * @returns The extension object and its methods
25
+ */
26
+ export declare function btreeGist(options?: ExtensionOptions): BtreeGist;
@@ -0,0 +1,20 @@
1
+ import {
2
+ extension2
3
+ } from "../../../shared/6f0z3hzh.js";
4
+ import {
5
+ usingIndex
6
+ } from "../../../shared/h9811jjm.js";
7
+
8
+ // src/dialects/pg/ext/btree-gist.ts
9
+ function btreeGist(options = {}) {
10
+ const declared = extension2("btree_gist", options);
11
+ return {
12
+ ...declared,
13
+ gist(column) {
14
+ return usingIndex(column, "gist", "gist_int4_ops");
15
+ }
16
+ };
17
+ }
18
+ export {
19
+ btreeGist
20
+ };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * SQL fragments for an extension function or operator.
3
+ *
4
+ * The fragment is the whole predicate, the same way `fragment` is. Values
5
+ * are parameters. The schema and function names are quoted identifiers the
6
+ * generator wrote.
7
+ */
8
+ import { type Fragment } from "../ops/fragment.js";
9
+ /**
10
+ * `schema.fn(column, …) = schema.fn($1)`.
11
+ *
12
+ * @param schema - Install schema
13
+ * @param name - Function name
14
+ * @param value - Parameter
15
+ * @returns A where fragment
16
+ */
17
+ export declare function fnEqualsArg(schema: string, name: string, value: string): Fragment;
18
+ /**
19
+ * `schema.fn(column, $1) = $2::integer`.
20
+ *
21
+ * @param schema - Install schema
22
+ * @param name - Function name
23
+ * @param value - Text argument
24
+ * @param distance - Integer the function result must equal
25
+ * @returns A where fragment
26
+ */
27
+ export declare function fnDistance(schema: string, name: string, value: string, distance: number): Fragment;
28
+ /**
29
+ * `column <op> $1`, with an optional cast on the parameter.
30
+ *
31
+ * @param op - Operator token the generator wrote
32
+ * @param value - Parameter
33
+ * @param cast - SQL type to cast the parameter to, when the operator needs one
34
+ * @returns A where fragment
35
+ */
36
+ export declare function opArg(op: string, value: string, cast?: string): Fragment;
37
+ /**
38
+ * `schema.fn()` as the whole predicate.
39
+ *
40
+ * @param schema - Install schema
41
+ * @param name - Function name
42
+ * @returns A where fragment
43
+ */
44
+ export declare function bareCall(schema: string, name: string): Fragment;
45
+ /**
46
+ * `encode(schema.digest(column, $1), 'hex') = $2`.
47
+ *
48
+ * @param schema - Install schema
49
+ * @param algorithm - Digest algorithm, a parameter
50
+ * @param hex - Expected hex digest, a parameter
51
+ * @returns A where fragment
52
+ */
53
+ export declare function digestEquals(schema: string, algorithm: string, hex: string): Fragment;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  extension2
3
- } from "../../../shared/jgqj11w4.js";
3
+ } from "../../../shared/6f0z3hzh.js";
4
4
 
5
5
  // src/dialects/pg/ext/citext.ts
6
6
  function citext(options = {}) {
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Version gate for one extension feature (OKM1812).
3
+ *
4
+ * The factory reads the declared extension version. An omitted pin is
5
+ * unpinned: apply checks the server. A pin that still allows a version
6
+ * without the feature fails here, at the call, which is schema build when
7
+ * the schema file calls the method. The message names the feature, the
8
+ * extension version, and `minPostgres`.
9
+ */
10
+ /** What a feature needs. */
11
+ export type FeatureNeed = {
12
+ /** Extension the feature belongs to. */
13
+ readonly name: string;
14
+ /** Minimum extension version (`1.2`). */
15
+ readonly extension: string;
16
+ /** Minimum Postgres major. Named in the message. */
17
+ readonly postgres: number;
18
+ };
19
+ /**
20
+ * Refuses a pin that does not guarantee the feature.
21
+ *
22
+ * @param declared - `version` on the extension, when the caller set one
23
+ * @param feature - Feature name, such as `daitch_mokotoff`
24
+ * @param need - Versions the feature needs
25
+ */
26
+ export declare function assertExtFeature(declared: string | undefined, feature: string, need: FeatureNeed): void;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The `fuzzystrmatch` extension. `levenshtein` compares edit distance. `daitchMokotoff` needs version 1.2 and PostgreSQL 16.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { Fragment } from "../ops/fragment.js";
9
+ import { type Extension, type ExtensionOptions } from "./index.js";
10
+ /** `fuzzystrmatch` plus the methods the naming overlay selected. */
11
+ export type Fuzzystrmatch = Extension & {
12
+ /**
13
+ * `levenshtein(column, value) = distance`.
14
+ *
15
+ * @param value - Text to compare
16
+ * @param distance - Edit distance the function must return
17
+ * @returns A where fragment
18
+ */
19
+ levenshtein(value: string, distance: number): Fragment;
20
+ /**
21
+ * `daitch_mokotoff(column) = daitch_mokotoff(value)`. Needs fuzzystrmatch 1.2 and PostgreSQL 16.
22
+ *
23
+ * @param value - Text to compare
24
+ * @returns A where fragment
25
+ */
26
+ daitchMokotoff(value: string): Fragment;
27
+ };
28
+ /**
29
+ * Declares `fuzzystrmatch`.
30
+ *
31
+ * @param options - Schema and version pin
32
+ * @returns The extension object and its methods
33
+ */
34
+ export declare function fuzzystrmatch(options?: ExtensionOptions): Fuzzystrmatch;
@@ -0,0 +1,33 @@
1
+ import {
2
+ extension2
3
+ } from "../../../shared/6f0z3hzh.js";
4
+ import {
5
+ assertExtFeature
6
+ } from "../../../shared/kzgrnckd.js";
7
+ import {
8
+ fnEqualsArg,
9
+ fnDistance
10
+ } from "../../../shared/xqacq37x.js";
11
+
12
+ // src/dialects/pg/ext/fuzzystrmatch.ts
13
+ function fuzzystrmatch(options = {}) {
14
+ const declared = extension2("fuzzystrmatch", options);
15
+ const schema = declared.schema;
16
+ return {
17
+ ...declared,
18
+ levenshtein(value, distance) {
19
+ return fnDistance(schema, "levenshtein", value, distance);
20
+ },
21
+ daitchMokotoff(value) {
22
+ assertExtFeature(options.version, "daitch_mokotoff", {
23
+ name: "fuzzystrmatch",
24
+ extension: "1.2",
25
+ postgres: 16
26
+ });
27
+ return fnEqualsArg(schema, "daitch_mokotoff", value);
28
+ }
29
+ };
30
+ }
31
+ export {
32
+ fuzzystrmatch
33
+ };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The `hstore` extension. `hasKey` is `?`. `gin` and `gist` index an hstore column.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { Fragment } from "../ops/fragment.js";
9
+ import type { IndexCall } from "../table.js";
10
+ import { type Extension, type ExtensionOptions } from "./index.js";
11
+ /** `hstore` plus the methods the naming overlay selected. */
12
+ export type Hstore = Extension & {
13
+ /**
14
+ * `column ? key`.
15
+ *
16
+ * @param value - Text to compare
17
+ * @returns A where fragment
18
+ */
19
+ hasKey(value: string): Fragment;
20
+ /**
21
+ * A GIN index with `gin_hstore_ops`.
22
+ *
23
+ * @param column - SQL column name
24
+ * @returns An index call whose expression is the `using` tail
25
+ */
26
+ gin(column: string): IndexCall;
27
+ /**
28
+ * A GiST index with `gist_hstore_ops`.
29
+ *
30
+ * @param column - SQL column name
31
+ * @returns An index call whose expression is the `using` tail
32
+ */
33
+ gist(column: string): IndexCall;
34
+ };
35
+ /**
36
+ * Declares `hstore`.
37
+ *
38
+ * @param options - Schema and version pin
39
+ * @returns The extension object and its methods
40
+ */
41
+ export declare function hstore(options?: ExtensionOptions): Hstore;
@@ -0,0 +1,29 @@
1
+ import {
2
+ extension2
3
+ } from "../../../shared/6f0z3hzh.js";
4
+ import {
5
+ opArg
6
+ } from "../../../shared/xqacq37x.js";
7
+ import {
8
+ usingIndex
9
+ } from "../../../shared/h9811jjm.js";
10
+
11
+ // src/dialects/pg/ext/hstore.ts
12
+ function hstore(options = {}) {
13
+ const declared = extension2("hstore", options);
14
+ return {
15
+ ...declared,
16
+ hasKey(value) {
17
+ return opArg("?", value);
18
+ },
19
+ gin(column) {
20
+ return usingIndex(column, "gin", "gin_hstore_ops");
21
+ },
22
+ gist(column) {
23
+ return usingIndex(column, "gist", "gist_hstore_ops");
24
+ }
25
+ };
26
+ }
27
+ export {
28
+ hstore
29
+ };
@@ -6,6 +6,50 @@
6
6
  * object for its records.
7
7
  */
8
8
  import type { ExtensionObject } from "../../../contracts/catalog/types.js";
9
+ /** One type the definition says the extension provides. */
10
+ export type ExtensionType = {
11
+ readonly name: string;
12
+ };
13
+ /** One operator the definition says the extension provides. */
14
+ export type ExtensionOperator = {
15
+ readonly name: string;
16
+ readonly left?: string;
17
+ readonly right?: string;
18
+ readonly result: string;
19
+ };
20
+ /** One function the definition says the extension provides. */
21
+ export type ExtensionFunction = {
22
+ readonly name: string;
23
+ readonly args: readonly string[];
24
+ readonly returns: string;
25
+ };
26
+ /** One index method the definition says the extension provides. */
27
+ export type ExtensionIndexMethod = {
28
+ readonly name: string;
29
+ readonly opclass?: string;
30
+ };
31
+ /**
32
+ * Types, operators, functions, and index methods a definition declares.
33
+ *
34
+ * `okm ext test` checks these against the connected server. They are not
35
+ * catalog objects and they do not change the catalog hash.
36
+ */
37
+ export type ExtensionProvides = {
38
+ readonly types?: readonly ExtensionType[];
39
+ readonly operators?: readonly ExtensionOperator[];
40
+ readonly functions?: readonly ExtensionFunction[];
41
+ readonly indexMethods?: readonly ExtensionIndexMethod[];
42
+ };
43
+ /**
44
+ * Version floors for a definition.
45
+ *
46
+ * `postgres` is `>=15`. `version` is an exact pin or a `>=` floor.
47
+ * `okm ext test` checks both against the connected server (OKM1812).
48
+ */
49
+ export type ExtensionRequires = {
50
+ readonly postgres?: string;
51
+ readonly version?: string;
52
+ };
9
53
  /** Options on {@link extension}. */
10
54
  export type ExtensionOptions = {
11
55
  /** Exact pin (`1.6`) or a floor (`>=0.7`). Omitted means unpinned. */
@@ -18,6 +62,14 @@ export type ExtensionOptions = {
18
62
  * The default is `true`. A move of a non-relocatable extension is OKM1814.
19
63
  */
20
64
  readonly relocatable?: boolean;
65
+ /**
66
+ * Floors `okm ext test` checks. Not stored in the catalog record.
67
+ */
68
+ readonly requires?: ExtensionRequires;
69
+ /**
70
+ * Objects `okm ext test` checks. Not stored in the catalog record.
71
+ */
72
+ readonly provides?: ExtensionProvides;
21
73
  };
22
74
  /**
23
75
  * One declared extension.
@@ -30,6 +82,10 @@ export type Extension = {
30
82
  readonly schema: string;
31
83
  readonly relocatable: boolean;
32
84
  readonly version?: string;
85
+ /** Floors from {@link ExtensionOptions.requires}. Absent when omitted. */
86
+ readonly requires?: ExtensionRequires;
87
+ /** Objects from {@link ExtensionOptions.provides}. Absent when omitted. */
88
+ readonly provides?: ExtensionProvides;
33
89
  /**
34
90
  * Catalog records for this declaration.
35
91
  *
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  extension2
3
- } from "../../../shared/jgqj11w4.js";
3
+ } from "../../../shared/6f0z3hzh.js";
4
4
  export {
5
5
  extension2 as extension
6
6
  };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The `ltree` extension. `ancestorOf` is `@>` and `descendantOf` is `<@`. This is not the parent-column walk.
3
+ *
4
+ * Generated by scripts/ext-generate.ts. Do not edit.
5
+ * `minPostgres` for the base methods is 15. A feature
6
+ * a declared version lacks fails with OKM1812.
7
+ */
8
+ import type { Fragment } from "../ops/fragment.js";
9
+ import type { IndexCall } from "../table.js";
10
+ import { type Extension, type ExtensionOptions } from "./index.js";
11
+ /** `ltree` plus the methods the naming overlay selected. */
12
+ export type Ltree = Extension & {
13
+ /**
14
+ * `column @> path`. The column is an ancestor of `path`.
15
+ *
16
+ * @param value - Text to compare
17
+ * @returns A where fragment
18
+ */
19
+ ancestorOf(value: string): Fragment;
20
+ /**
21
+ * `column <@ path`. The column is a descendant of `path`.
22
+ *
23
+ * @param value - Text to compare
24
+ * @returns A where fragment
25
+ */
26
+ descendantOf(value: string): Fragment;
27
+ /**
28
+ * A GiST index with `gist_ltree_ops`.
29
+ *
30
+ * @param column - SQL column name
31
+ * @returns An index call whose expression is the `using` tail
32
+ */
33
+ gist(column: string): IndexCall;
34
+ };
35
+ /**
36
+ * Declares `ltree`.
37
+ *
38
+ * @param options - Schema and version pin
39
+ * @returns The extension object and its methods
40
+ */
41
+ export declare function ltree(options?: ExtensionOptions): Ltree;
@@ -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;