okmodel 0.8.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/README.md +23 -1
  2. package/dist/adapters/pg/bunsql-extra.d.ts +5 -5
  3. package/dist/adapters/pg/bunsql.d.ts +6 -2
  4. package/dist/adapters/pg/nodepostgres.d.ts +16 -1
  5. package/dist/adapters/pg/postgres-extra.d.ts +3 -17
  6. package/dist/adapters/pg/postgresjs.d.ts +2 -1
  7. package/dist/contracts/driver.d.ts +3 -2
  8. package/dist/contracts/error.d.ts +1 -1
  9. package/dist/dialects/pg/errors.d.ts +2 -0
  10. package/dist/dialects/pg/ext/btree-gin.d.ts +26 -0
  11. package/dist/dialects/pg/ext/btree-gin.js +20 -0
  12. package/dist/dialects/pg/ext/btree-gist.d.ts +26 -0
  13. package/dist/dialects/pg/ext/btree-gist.js +20 -0
  14. package/dist/dialects/pg/ext/call.d.ts +53 -0
  15. package/dist/dialects/pg/ext/citext.js +1 -1
  16. package/dist/dialects/pg/ext/feature.d.ts +26 -0
  17. package/dist/dialects/pg/ext/fuzzystrmatch.d.ts +34 -0
  18. package/dist/dialects/pg/ext/fuzzystrmatch.js +33 -0
  19. package/dist/dialects/pg/ext/hstore.d.ts +41 -0
  20. package/dist/dialects/pg/ext/hstore.js +29 -0
  21. package/dist/dialects/pg/ext/index.d.ts +56 -0
  22. package/dist/dialects/pg/ext/index.js +1 -1
  23. package/dist/dialects/pg/ext/ltree.d.ts +41 -0
  24. package/dist/dialects/pg/ext/ltree.js +29 -0
  25. package/dist/dialects/pg/ext/pg-trgm.js +4 -13
  26. package/dist/dialects/pg/ext/pgcrypto.d.ts +33 -0
  27. package/dist/dialects/pg/ext/pgcrypto.js +33 -0
  28. package/dist/dialects/pg/ext/unaccent.d.ts +26 -0
  29. package/dist/dialects/pg/ext/unaccent.js +21 -0
  30. package/dist/dialects/pg/ext/using.d.ts +23 -0
  31. package/dist/dialects/pg/ext/versions.d.ts +36 -0
  32. package/dist/dialects/pg/external.d.ts +19 -0
  33. package/dist/dialects/pg/filters.d.ts +2 -2
  34. package/dist/dialects/pg/fn/index.js +5 -5
  35. package/dist/dialects/pg/index.d.ts +1 -0
  36. package/dist/dialects/pg/index.js +19 -14
  37. package/dist/dialects/pg/introspect.d.ts +12 -0
  38. package/dist/dialects/pg/view/index.js +7 -7
  39. package/dist/dialects/pg/view/scratch.d.ts +4 -1
  40. package/dist/runtime/artifact-file.d.ts +22 -0
  41. package/dist/runtime/client.d.ts +10 -0
  42. package/dist/runtime/drift-detail.d.ts +2 -1
  43. package/dist/runtime/drift.d.ts +3 -10
  44. package/dist/runtime/param-limit.d.ts +20 -0
  45. package/dist/runtime/pg/bun.js +4 -4
  46. package/dist/runtime/pg/neon.js +4 -4
  47. package/dist/runtime/pg/pg.js +4 -4
  48. package/dist/runtime/pg/pglite.js +4 -4
  49. package/dist/runtime/pg/postgresjs.js +11 -11
  50. package/dist/runtime/server-check.d.ts +36 -6
  51. package/dist/runtime/tenancy/index.js +1 -1
  52. package/dist/runtime/traits/index.js +6 -6
  53. package/dist/runtime/validate/index.js +2 -2
  54. package/dist/runtime/write.d.ts +1 -1
  55. package/dist/shared/{4m6hskg8.js → 0j6qe91y.js} +4 -4
  56. package/dist/shared/{6m78c8ss.js → 1h5h1rf5.js} +1 -1
  57. package/dist/shared/{4vbf83xx.js → 2vcnpf0n.js} +1 -1
  58. package/dist/shared/{qd9hhd8f.js → 3ap5hxvj.js} +2 -1
  59. package/dist/shared/{v1wad97q.js → 3d7a80fq.js} +1 -1
  60. package/dist/shared/{wcrheftc.js → 3dr444ny.js} +58 -79
  61. package/dist/shared/{hm5f8jby.js → 3vvpcphd.js} +8 -7
  62. package/dist/shared/{760ppr76.js → 4a3mmhhe.js} +2 -2
  63. package/dist/shared/{mkrn359n.js → 4pkz5nvw.js} +222 -39
  64. package/dist/shared/{agsfb86s.js → 4te76xc5.js} +4 -4
  65. package/dist/shared/{63f4ksbz.js → 60y4ahmw.js} +1 -1
  66. package/dist/shared/61bmrmhr.js +35 -0
  67. package/dist/shared/{bxas03mq.js → 63qjmhnp.js} +100 -17
  68. package/dist/shared/{g5yc06ka.js → 67w3kn71.js} +1 -1
  69. package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
  70. package/dist/shared/{njga14v4.js → 6vfvsdkt.js} +10 -8
  71. package/dist/shared/{kj9d8maq.js → 6xqvesa5.js} +1 -1
  72. package/dist/shared/8gdbty5v.js +665 -0
  73. package/dist/shared/{pan0370z.js → 8ma6drzr.js} +211 -30
  74. package/dist/shared/{mnvjvqyp.js → 8p2bgye0.js} +124 -32
  75. package/dist/shared/{mfedzr74.js → 8qwqrxed.js} +14 -6
  76. package/dist/shared/{hfqmpasr.js → 8v7vzpgt.js} +11 -8
  77. package/dist/shared/{7ghwamrf.js → 99qp9vtg.js} +1 -1
  78. package/dist/shared/{zgex00fd.js → ak61ye1f.js} +5 -5
  79. package/dist/shared/{dpc2r7rb.js → bdekbvmt.js} +218 -95
  80. package/dist/shared/{jebgrkeq.js → bxjq6xqv.js} +2 -2
  81. package/dist/shared/c7dqd3gk.js +1806 -0
  82. package/dist/shared/ddh72ym5.js +20 -0
  83. package/dist/shared/e1c55v04.js +10 -0
  84. package/dist/shared/{mtw6jz76.js → e275q7sd.js} +1 -1
  85. package/dist/shared/{k86n8vq3.js → ekhq3ytz.js} +1 -1
  86. package/dist/shared/esy4dyxe.js +17 -0
  87. package/dist/shared/{gcefca6p.js → f9t9g54z.js} +22 -9
  88. package/dist/shared/{sjk86yrx.js → fk9vef30.js} +84 -73
  89. package/dist/shared/fkjne6gx.js +8 -0
  90. package/dist/shared/{e8zyaqvj.js → fne90dvz.js} +4 -1
  91. package/dist/shared/{needfe47.js → g89fmz5s.js} +1 -1
  92. package/dist/shared/{m4xff2a6.js → ghqzdp94.js} +2 -2
  93. package/dist/shared/{n0jmpgj1.js → gr9sn4za.js} +1 -1
  94. package/dist/shared/{5mtf6cj3.js → gzgfsspx.js} +5 -2
  95. package/dist/shared/h9811jjm.js +17 -0
  96. package/dist/shared/{z581d7ny.js → hgt69zjf.js} +2 -2
  97. package/dist/shared/{35q0n9tz.js → jvxcp1qk.js} +71 -87
  98. package/dist/shared/k73e8n9d.js +136 -0
  99. package/dist/shared/{195pzzzz.js → kzgrcy8s.js} +12 -8
  100. package/dist/shared/kzgrnckd.js +29 -0
  101. package/dist/shared/{p3xbdcvt.js → mz48rs74.js} +68 -8
  102. package/dist/shared/{zbqbmmrp.js → n6je5b28.js} +13 -26
  103. package/dist/shared/{b6d6p0zc.js → ns35jqz0.js} +75 -49
  104. package/dist/shared/{n05z9nwz.js → nstwgzn8.js} +1 -1
  105. package/dist/{tooling/shared/08kemxjd.js → shared/pgsak1yw.js} +1 -1
  106. package/dist/shared/py2zrrm6.js +451 -0
  107. package/dist/shared/{9dr2qnx7.js → qqm3ze6q.js} +1 -1
  108. package/dist/shared/{wvdjznah.js → rcjm0yn7.js} +31 -38
  109. package/dist/shared/rged92v6.js +17 -0
  110. package/dist/shared/{jp36k7dp.js → rw4tpcd0.js} +81 -51
  111. package/dist/shared/{bsek72fg.js → s5qe47a6.js} +3 -0
  112. package/dist/shared/{1d9q9cv2.js → smxzjz60.js} +2 -2
  113. package/dist/shared/{wz2a78mp.js → th5rnaxw.js} +1 -1
  114. package/dist/{tooling/shared/rs1jb051.js → shared/tr64w5p0.js} +1 -1
  115. package/dist/shared/{14x60fbf.js → tyqapcgk.js} +73 -10
  116. package/dist/shared/vsna85qf.js +8 -0
  117. package/dist/shared/{63qtkrca.js → vy47ryqa.js} +55 -5
  118. package/dist/shared/{jx2m62cs.js → wbdh9qbg.js} +7 -5
  119. package/dist/shared/{f4jy1j7x.js → wp7y8q3y.js} +946 -105
  120. package/dist/shared/{16kvjebh.js → xbd9xs6p.js} +7 -26
  121. package/dist/shared/{bah9nbg3.js → xbvz446k.js} +18 -23
  122. package/dist/shared/{p5nh3r8q.js → y6tfjk9q.js} +2 -2
  123. package/dist/shared/{3bb7wsqt.js → ycnft340.js} +1 -1
  124. package/dist/shared/{z7s6fpxv.js → ymenf259.js} +1 -1
  125. package/dist/shared/{0wrea3jq.js → ysdw2fg3.js} +10 -2
  126. package/dist/shared/zecrwdk9.js +61 -0
  127. package/dist/shared/{3t6kw83m.js → zm2rzqba.js} +2 -1
  128. package/dist/tooling/cli.js +200 -50
  129. package/dist/tooling/driver-run.js +109 -343
  130. package/dist/tooling/github/comment.d.ts +56 -0
  131. package/dist/tooling/github/post-comment.d.ts +17 -0
  132. package/dist/tooling/migrate/apply.d.ts +17 -2
  133. package/dist/tooling/migrate/commands.d.ts +2 -1
  134. package/dist/tooling/migrate/config.d.ts +13 -0
  135. package/dist/tooling/migrate/drift.d.ts +12 -0
  136. package/dist/tooling/migrate/driver-url.d.ts +17 -0
  137. package/dist/tooling/migrate/export.d.ts +165 -0
  138. package/dist/tooling/migrate/ext-surface.d.ts +80 -0
  139. package/dist/tooling/migrate/ext.d.ts +31 -4
  140. package/dist/tooling/migrate/import-drizzle.d.ts +40 -0
  141. package/dist/tooling/migrate/index.d.ts +3 -0
  142. package/dist/tooling/migrate/index.js +57 -10
  143. package/dist/tooling/migrate/lint-rules.d.ts +18 -1
  144. package/dist/tooling/migrate/lint.d.ts +14 -1
  145. package/dist/tooling/migrate/place.d.ts +18 -0
  146. package/dist/tooling/migrate/plan-json.d.ts +65 -0
  147. package/dist/tooling/migrate/policy.d.ts +17 -5
  148. package/dist/tooling/migrate/pooler-probe.d.ts +23 -0
  149. package/dist/tooling/migrate/project.d.ts +10 -1
  150. package/dist/tooling/migrate/pull-emit.d.ts +98 -0
  151. package/dist/tooling/migrate/pull-routines.d.ts +126 -0
  152. package/dist/tooling/migrate/pull-verify.d.ts +26 -0
  153. package/dist/tooling/migrate/pull.d.ts +65 -0
  154. package/dist/tooling/migrate/reprint.d.ts +32 -0
  155. package/dist/tooling/migrate/runner.d.ts +24 -1
  156. package/dist/tooling/migrate/sandbox.d.ts +8 -2
  157. package/dist/tooling/migrate/schema-api.d.ts +43 -0
  158. package/dist/tooling/migrate/sql-lex.d.ts +18 -0
  159. package/dist/tooling/shared/{ppnnnvj8.js → 09a6vsys.js} +1 -1
  160. package/dist/tooling/shared/{7ae7rjmn.js → 0v9ptnxp.js} +8 -8
  161. package/dist/tooling/shared/{fb9k2qwd.js → 0wtzps9p.js} +11 -30
  162. package/dist/tooling/shared/{a6pp9d12.js → 0yhf1db4.js} +6 -6
  163. package/dist/tooling/shared/{dy672fz6.js → 19msgrsc.js} +2 -2
  164. package/dist/{shared/q0cqt2sp.js → tooling/shared/1fwfm5m3.js} +1 -1
  165. package/dist/tooling/shared/{f9mphxej.js → 2jdn09e2.js} +401 -24
  166. package/dist/tooling/shared/{jne7b93p.js → 2qrte2ct.js} +5 -5
  167. package/dist/tooling/shared/{5bvw2nev.js → 2v4nwnkb.js} +1 -1
  168. package/dist/tooling/shared/{spk1jg3r.js → 33z39trp.js} +106 -23
  169. package/dist/tooling/shared/{z8d7ptht.js → 353vnw9z.js} +5 -5
  170. package/dist/tooling/shared/{dw08f3m8.js → 390kry9g.js} +2 -2
  171. package/dist/tooling/shared/{xjs6zqtc.js → 3f6etb9z.js} +18 -31
  172. package/dist/{shared/bnby0esn.js → tooling/shared/3t2cqmsx.js} +1 -1
  173. package/dist/tooling/shared/{wwnekq5n.js → 4dzvjtpy.js} +1 -1
  174. package/dist/tooling/shared/{y5656f0e.js → 4ec0nxvw.js} +10 -10
  175. package/dist/tooling/shared/{3m1hkg7z.js → 4tg2bn41.js} +59 -78
  176. package/dist/tooling/shared/{zvnhh1n0.js → 5rah55z0.js} +2 -2
  177. package/dist/tooling/shared/{pqy21k24.js → 804w1t69.js} +4 -4
  178. package/dist/tooling/shared/8g0m0rvd.js +134 -0
  179. package/dist/tooling/shared/8msbtw5s.js +8 -0
  180. package/dist/tooling/shared/{4d2w25vw.js → 8t22h3h7.js} +2 -2
  181. package/dist/tooling/shared/{smn6kz1p.js → 91c59b7b.js} +2 -2
  182. package/dist/tooling/shared/{aftb2mwr.js → adk9k6va.js} +1 -1
  183. package/dist/tooling/shared/{j9t5s12a.js → ajjd5cwz.js} +2 -2
  184. package/dist/tooling/shared/{cmptmb4f.js → angjck01.js} +1 -1
  185. package/dist/tooling/shared/{yw30vnq2.js → asnnc3v5.js} +1 -1
  186. package/dist/tooling/shared/{ma2340rx.js → bj1kyqc8.js} +2 -2
  187. package/dist/tooling/shared/{2wtvc7rw.js → bt3tjemb.js} +11 -3
  188. package/dist/tooling/shared/{ec71zqgt.js → chk2bh4f.js} +2 -2
  189. package/dist/tooling/shared/{gmcf9cxf.js → ckq4z5ax.js} +5 -2
  190. package/dist/tooling/shared/{w7qe8sj1.js → d3rhb24q.js} +1 -1
  191. package/dist/tooling/shared/{y031jct9.js → d8q00vxg.js} +4 -4
  192. package/dist/tooling/shared/{vs0t6qt8.js → dx188rxs.js} +2 -2
  193. package/dist/tooling/shared/{g9ad4n80.js → efq6p9df.js} +35 -42
  194. package/dist/tooling/shared/{ddjtfgnx.js → en6rwzq0.js} +3 -3
  195. package/dist/tooling/shared/{6nyfyw70.js → f2r5g0fs.js} +2 -2
  196. package/dist/tooling/shared/{03k6res6.js → f4gep0nk.js} +1 -1
  197. package/dist/tooling/shared/{gfvtj6d0.js → f8a010fm.js} +13 -11
  198. package/dist/tooling/shared/{3tq8pnb8.js → fdsek6pa.js} +1 -1
  199. package/dist/tooling/shared/fvmrxsd1.js +8 -0
  200. package/dist/tooling/shared/{733a1tq3.js → g3xybeqf.js} +4 -3
  201. package/dist/tooling/shared/{pwsytxm5.js → gefmpwsa.js} +1 -1
  202. package/dist/tooling/shared/{mtrqn2hn.js → gjj71hfh.js} +25 -30
  203. package/dist/tooling/shared/{8sqrsw3s.js → jgzt69pa.js} +5 -5
  204. package/dist/tooling/shared/{nf7jmhfa.js → jm30k2ca.js} +10 -8
  205. package/dist/tooling/shared/{vx86qjv8.js → kayqzpbk.js} +6 -3
  206. package/dist/tooling/shared/{zhwnfyb2.js → kvw1672d.js} +1 -1
  207. package/dist/tooling/shared/{rq5kk8j6.js → mr1kcgpw.js} +3 -3
  208. package/dist/tooling/shared/{72fyg4zv.js → mwbdf409.js} +1 -1
  209. package/dist/tooling/shared/{wt7j7nf6.js → ns9207v3.js} +1 -1
  210. package/dist/tooling/shared/{9xzm7hjg.js → p6tjv97k.js} +3 -3
  211. package/dist/tooling/shared/{yfr8hzhm.js → p73evwf0.js} +1 -1
  212. package/dist/tooling/shared/{dzx85q70.js → phc1nc4g.js} +1 -1
  213. package/dist/tooling/shared/{417zdsk7.js → ppybjw50.js} +79 -16
  214. package/dist/tooling/shared/{yk9mp7vb.js → qdrn8ghn.js} +5 -4
  215. package/dist/tooling/shared/rd8h01ta.js +20 -0
  216. package/dist/tooling/shared/{bz2dqhab.js → rwg8y90m.js} +3 -3
  217. package/dist/tooling/shared/{xhrnjch9.js → ry2f3w8p.js} +3 -3
  218. package/dist/tooling/shared/{a7q7t4n3.js → ryc5sa58.js} +8 -8
  219. package/dist/tooling/shared/{2revefqt.js → ss87qxwv.js} +2 -2
  220. package/dist/tooling/shared/{rf83gr2d.js → vg68k11z.js} +7 -3
  221. package/dist/tooling/shared/{p7f08ktn.js → vms9dta5.js} +73 -89
  222. package/dist/tooling/shared/{3rrw5w8f.js → xchpnbdv.js} +1 -1
  223. package/dist/tooling/shared/{djydjpqt.js → xn6p01fh.js} +5 -5
  224. package/dist/tooling/shared/{9kazs5p6.js → xwr6q618.js} +3 -3
  225. package/dist/tooling/shared/{ep8zh3bk.js → xx3gmq94.js} +1 -1
  226. package/dist/tooling/shared/{tn8gay14.js → y2bd7yfx.js} +21 -13
  227. package/dist/tooling/shared/{vraj6d74.js → y4gq9rbe.js} +11 -11
  228. package/dist/tooling/shared/y4vwft92.js +9 -0
  229. package/dist/tooling/shared/{345tbc2k.js → yz68xcmc.js} +1 -1
  230. package/dist/tooling/testing/factories.d.ts +1 -3
  231. package/dist/tooling/testing/index.js +2 -2
  232. package/package.json +39 -9
  233. package/dist/shared/3449rcae.js +0 -14
  234. package/dist/shared/fjpnhqan.js +0 -71
  235. package/dist/shared/n41w4fbz.js +0 -113
  236. package/dist/tooling/shared/pw8fgahx.js +0 -69
  237. /package/dist/shared/{ae4j5f42.js → mfvx6kjx.js} +0 -0
@@ -20,12 +20,11 @@ import {
20
20
  compareText,
21
21
  enumType,
22
22
  domainType,
23
- isDomain,
24
23
  sameEnumLabels,
25
24
  indexObjects,
26
25
  orderIndexed,
27
- creationOrder2,
28
26
  quoteLiteral,
27
+ renderCatalog2,
29
28
  clientGenerator,
30
29
  readClientGenerator,
31
30
  definition,
@@ -46,7 +45,7 @@ import {
46
45
  jsonb,
47
46
  quote,
48
47
  primaryUrl
49
- } from "./shared/f9mphxej.js";
48
+ } from "./shared/2jdn09e2.js";
50
49
  import { createRequire } from "node:module";
51
50
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
52
51
 
@@ -353,8 +352,7 @@ function registerDriverSuite(suite) {
353
352
  try {
354
353
  const setting = await scalar(second, "SELECT current_setting('okm.p13', true)");
355
354
  expect(setting).not.toBe("yes");
356
- expect(await scalar(second, "SELECT pg_backend_pid()::text")).toBe(pid);
357
- expect(await scalar(second, "SELECT count(*)::text FROM pg_locks WHERE locktype = 'advisory' AND pid = pg_backend_pid()")).toBe("0");
355
+ expect(await scalar(second, `SELECT count(*)::text FROM pg_locks WHERE locktype = 'advisory' AND pid = ${pid}`)).toBe("0");
358
356
  } finally {
359
357
  await second.release();
360
358
  }
@@ -445,9 +443,28 @@ async function using(open, fn) {
445
443
  try {
446
444
  await fn(pool);
447
445
  } finally {
446
+ await dropOkmTables(pool);
448
447
  await pool.close();
449
448
  }
450
449
  }
450
+ async function dropOkmTables(pool) {
451
+ try {
452
+ await pool.execute(`
453
+ do $$
454
+ declare
455
+ r record;
456
+ begin
457
+ for r in
458
+ select tablename
459
+ from pg_tables
460
+ where schemaname = current_schema()
461
+ and tablename like 'okm\\_%' escape '\\'
462
+ loop
463
+ execute format('drop table if exists %I cascade', r.tablename);
464
+ end loop;
465
+ end $$`);
466
+ } catch {}
467
+ }
451
468
  function tableName() {
452
469
  return `okm_${Math.random().toString(36).slice(2, 10)}`;
453
470
  }
@@ -615,9 +632,28 @@ async function using2(open, fn) {
615
632
  try {
616
633
  await fn(pool);
617
634
  } finally {
635
+ await dropOkmTables2(pool);
618
636
  await pool.close();
619
637
  }
620
638
  }
639
+ async function dropOkmTables2(pool) {
640
+ try {
641
+ await pool.execute(`
642
+ do $$
643
+ declare
644
+ r record;
645
+ begin
646
+ for r in
647
+ select tablename
648
+ from pg_tables
649
+ where schemaname = current_schema()
650
+ and tablename like 'okm\\_%' escape '\\'
651
+ loop
652
+ execute format('drop table if exists %I cascade', r.tablename);
653
+ end loop;
654
+ end $$`);
655
+ } catch {}
656
+ }
621
657
  async function mapped(pending) {
622
658
  try {
623
659
  await pending;
@@ -693,322 +729,6 @@ function assertForeignKeys(objects, keys) {
693
729
  }
694
730
  }
695
731
 
696
- // src/dialects/pg/ddl.ts
697
- function quoteIdent(name) {
698
- return `"${name.replaceAll('"', '""')}"`;
699
- }
700
- function renderCatalog(source, schema) {
701
- const folded = foldedKeys(source);
702
- const statements = [];
703
- const ordered = creationOrder2(source);
704
- const created = uniqueBeforeForeignKey(ordered);
705
- for (const object of ordered) {
706
- if (object.kind !== "type" || object.owner === "ignored")
707
- continue;
708
- const sql = createObjectSql(object, schema);
709
- if (sql !== undefined)
710
- statements.push(sql);
711
- }
712
- for (const object of created) {
713
- if (object.kind === "type" || object.kind === "function" || object.kind === "trigger" || object.kind === "view" || object.kind === "materializedView" || object.kind === "policy" || ownedByView(object)) {
714
- continue;
715
- }
716
- if (object.owner === "ignored")
717
- continue;
718
- const key = identityKey(object.identity);
719
- if (object.kind === "table") {
720
- statements.push(createTableSql(object, source, schema));
721
- continue;
722
- }
723
- if (folded.has(key))
724
- continue;
725
- const sql = createObjectSql(object, schema);
726
- if (sql !== undefined)
727
- statements.push(sql);
728
- }
729
- for (const object of created) {
730
- if (object.kind !== "policy" || object.owner === "ignored")
731
- continue;
732
- for (const step of policyCreatePlan(object, schema))
733
- statements.push(step.sql);
734
- }
735
- for (const kind of ["function", "trigger"]) {
736
- for (const object of ordered) {
737
- if (object.kind !== kind || object.owner === "ignored")
738
- continue;
739
- const sql = createObjectSql(object, schema);
740
- if (sql !== undefined)
741
- statements.push(sql);
742
- }
743
- }
744
- for (const kind of ["view", "materializedView"]) {
745
- for (const object of ordered) {
746
- if (object.kind !== kind || object.owner === "ignored")
747
- continue;
748
- const sql = createObjectSql(object, schema);
749
- if (sql !== undefined)
750
- statements.push(sql);
751
- }
752
- }
753
- for (const object of ordered) {
754
- if (!ownedByView(object) || object.owner === "ignored")
755
- continue;
756
- const sql = createObjectSql(object, schema);
757
- if (sql !== undefined)
758
- statements.push(sql);
759
- }
760
- return statements;
761
- }
762
- function uniqueBeforeForeignKey(objects) {
763
- const uniques = objects.filter((object) => object.kind === "constraint" && object.definition.constraintKind === "unique");
764
- if (uniques.length === 0)
765
- return objects;
766
- const emitted = new Set;
767
- const result = [];
768
- for (const object of objects) {
769
- if (emitted.has(object))
770
- continue;
771
- if (object.kind === "constraint" && object.definition.constraintKind === "foreignKey") {
772
- const target = object.definition.references;
773
- if (target !== undefined && !coveredByPrimary(objects, target.parent, target.columns)) {
774
- const columns = target.columns.join("\x00");
775
- for (const unique of uniques) {
776
- if (emitted.has(unique))
777
- continue;
778
- if (!sameRef(unique.identity.parent, target.parent))
779
- continue;
780
- if (unique.definition.columns.join("\x00") !== columns)
781
- continue;
782
- result.push(unique);
783
- emitted.add(unique);
784
- }
785
- }
786
- }
787
- result.push(object);
788
- emitted.add(object);
789
- }
790
- return result;
791
- }
792
- function coveredByPrimary(objects, parent, columns) {
793
- const key = columns.join("\x00");
794
- return objects.some((object) => object.kind === "constraint" && object.definition.constraintKind === "primaryKey" && sameRef(object.identity.parent, parent) && object.definition.columns.join("\x00") === key);
795
- }
796
- function sameRef(left, right) {
797
- if (left.name !== right.name || left.namespace.form !== right.namespace.form)
798
- return false;
799
- if (left.namespace.form === "static" && right.namespace.form === "static") {
800
- return left.namespace.name === right.namespace.name;
801
- }
802
- return left.namespace.form === "template" && right.namespace.form === "template" ? left.namespace.pattern === right.namespace.pattern : false;
803
- }
804
- function ownedByView(object) {
805
- if (object.kind !== "index")
806
- return false;
807
- return object.dependencies.some((edge) => edge.target.kind === "view" || edge.target.kind === "materializedView");
808
- }
809
- function createObjectSql(object, schema) {
810
- switch (object.kind) {
811
- case "column":
812
- return `alter table ${qualify(schema, object.identity.parent.name)} add column ${columnSql(object)}`;
813
- case "index":
814
- return createIndexSql(object, schema);
815
- case "constraint":
816
- return `alter table ${qualify(schema, object.identity.parent.name)} add constraint ${quoteIdent(object.identity.name)} ${constraintBody(object, schema)}`;
817
- case "sequence":
818
- return createSequenceSql(object, schema);
819
- case "type":
820
- return createTypeSql(object, schema);
821
- case "extension":
822
- return createExtensionSql(object);
823
- case "function":
824
- return functionSql(object, schema, false);
825
- case "trigger":
826
- return triggerSql(object, schema);
827
- case "view":
828
- return viewSql(object, schema, false);
829
- case "materializedView":
830
- return materializedViewSql(object, schema);
831
- case "table":
832
- return;
833
- default:
834
- return;
835
- }
836
- }
837
- function functionSql(object, schema, replace) {
838
- const definition = object.definition;
839
- const args = definition.arguments.map((argument) => `${quoteIdent(argument.name)} ${argument.type}`).join(", ");
840
- const head = `${replace ? "create or replace" : "create"} function ${qualify(schema, object.identity.name)}(${args})`;
841
- const security = ` security ${definition.security}`;
842
- const path = definition.searchPath === undefined ? "" : ` set search_path to ${definition.searchPath}`;
843
- const tail = `returns ${definition.returns} language ${definition.language} ${definition.volatility}${security}${path}`;
844
- if (definition.atomic)
845
- return `${head} ${tail} ${definition.body}`;
846
- return `${head} ${tail} as ${dollarQuote(definition.body)}`;
847
- }
848
- function viewSql(object, schema, replace) {
849
- const verb = replace ? "create or replace view" : "create view";
850
- const invoker = object.definition.securityInvoker === true ? " with (security_invoker = true)" : "";
851
- return `${verb} ${qualify(schema, object.identity.name)}${invoker} as ${object.definition.query}`;
852
- }
853
- function policyCreatePlan(object, schema) {
854
- const table = qualify(schema, object.identity.parent.name);
855
- const name = quoteIdent(object.identity.name);
856
- const command = object.definition.command === "all" ? "all" : "select";
857
- const check = object.definition.command === "all" ? ` with check ${object.definition.expression}` : "";
858
- const create = {
859
- sql: `create policy ${name} on ${table} as permissive for ${command} using ${object.definition.expression}${check}`,
860
- kind: "create-policy"
861
- };
862
- if (object.definition.command !== "all")
863
- return [create];
864
- return [
865
- { sql: `alter table ${table} enable row level security`, kind: "enable-rls" },
866
- { sql: `alter table ${table} force row level security`, kind: "enable-rls" },
867
- create
868
- ];
869
- }
870
- function materializedViewSql(object, schema) {
871
- return `create materialized view ${qualify(schema, object.identity.name)} as ${object.definition.query} with no data`;
872
- }
873
- function triggerSql(object, schema) {
874
- const definition = object.definition;
875
- const timing = definition.timing === "instead" ? "instead of" : definition.timing;
876
- const events = definition.events.map((event) => {
877
- if (event !== "update" || definition.updateOf === undefined)
878
- return event;
879
- return `update of ${definition.updateOf.map((column) => quoteIdent(column)).join(", ")}`;
880
- }).join(" or ");
881
- const when = definition.when === undefined ? "" : ` when (${definition.when})`;
882
- const args = definition.calls.argTypes.join(", ");
883
- const fn = `${qualify(schema, definition.calls.name)}(${args})`;
884
- return `create trigger ${quoteIdent(object.identity.name)} ${timing} ${events} on ${qualify(schema, object.identity.parent.name)} for each ${definition.level}${when} execute function ${fn}`;
885
- }
886
- function dollarQuote(body) {
887
- let tag = "okm";
888
- while (body.includes(`$${tag}$`))
889
- tag = `${tag}_`;
890
- return `$${tag}$${body}$${tag}$`;
891
- }
892
- function identitySequence(sequence, source) {
893
- const key = identityKey(sequence.identity);
894
- return source.objects.some((object) => {
895
- if (object.kind !== "column" || object.definition.identity === undefined)
896
- return false;
897
- return object.dependencies.some((edge) => identityKey(edge.target) === key);
898
- });
899
- }
900
- function foldedKeys(source) {
901
- const keys = new Set;
902
- for (const object of source.objects) {
903
- if (object.kind === "column")
904
- keys.add(identityKey(object.identity));
905
- if (object.kind === "constraint" && object.definition.constraintKind === "primaryKey") {
906
- keys.add(identityKey(object.identity));
907
- }
908
- if (object.kind === "sequence" && identitySequence(object, source)) {
909
- keys.add(identityKey(object.identity));
910
- }
911
- }
912
- return keys;
913
- }
914
- function createTableSql(tableObject, source, schema) {
915
- const parent = tableObject.identity.name;
916
- const columns = source.objects.filter((object) => object.kind === "column" && object.identity.parent.name === parent);
917
- const primary = source.objects.find((object) => object.kind === "constraint" && object.definition.constraintKind === "primaryKey" && object.identity.parent.name === parent);
918
- const lines = columns.map((column) => columnSql(column));
919
- if (primary !== undefined) {
920
- const cols = primary.definition.columns.map((name) => quoteIdent(name)).join(", ");
921
- lines.push(`constraint ${quoteIdent(primary.identity.name)} primary key (${cols})`);
922
- }
923
- const partition = tableObject.definition.partition;
924
- const tail = partition === undefined ? "" : ` partition by ${partition.method} (${partition.columns.map((name) => quoteIdent(name)).join(", ")})`;
925
- return `create table ${qualify(schema, parent)} (
926
- ${lines.join(`,
927
- `)}
928
- )${tail}`;
929
- }
930
- function collateSql(collation) {
931
- if (collation === undefined)
932
- return "";
933
- return ` collate ${quoteIdent(collation)}`;
934
- }
935
- function createTypeSql(object, schema) {
936
- if (isDomain(object.definition)) {
937
- const name = object.identity.name;
938
- const constraint = quoteIdent(fitIdentifier(`${name}_check`));
939
- return `create domain ${qualify(schema, name)} as ${object.definition.base} constraint ${constraint} check (${object.definition.check})`;
940
- }
941
- const labels = object.definition.labels.map((label) => quoteLiteral(label)).join(", ");
942
- return `create type ${qualify(schema, object.identity.name)} as enum (${labels})`;
943
- }
944
- function columnSql(column) {
945
- const definition = column.definition;
946
- let sql = `${quoteIdent(column.identity.name)} ${definition.dataType}${collateSql(definition.collation)}`;
947
- if (definition.identity !== undefined) {
948
- sql += definition.identity.always ? " generated always as identity" : " generated by default as identity";
949
- } else if (definition.generated !== undefined) {
950
- sql += ` generated always as (${definition.generated.expression}) stored`;
951
- }
952
- if (!definition.nullable)
953
- sql += " not null";
954
- if (definition.defaultExpression !== undefined)
955
- sql += ` default ${definition.defaultExpression}`;
956
- return sql;
957
- }
958
- function createIndexSql(object, schema) {
959
- const unique = object.definition.unique ? "unique " : "";
960
- const where = object.definition.predicate === undefined ? "" : ` where ${object.definition.predicate}`;
961
- const expression = object.definition.expression;
962
- const name = quoteIdent(object.identity.name);
963
- const on = qualify(schema, object.identity.parent.name);
964
- if (expression !== undefined && expression.startsWith("using ")) {
965
- return `create ${unique}index ${name} on ${on} ${expression}${where}`;
966
- }
967
- const target = expression !== undefined ? `(${expression})` : object.definition.columns.map((column) => quoteIdent(column)).join(", ");
968
- return `create ${unique}index ${name} on ${on} (${target})${where}`;
969
- }
970
- function createExtensionSql(object) {
971
- const version = object.definition.version;
972
- const pinned = version !== undefined && /^\d+(?:\.\d+)*$/.test(version) ? ` version ${quoteLiteral(version)}` : "";
973
- return `create extension ${quoteIdent(object.identity.name)} schema ${quoteIdent(object.definition.schema)}${pinned}`;
974
- }
975
- function createSequenceSql(object, schema) {
976
- const definition = object.definition;
977
- const cycle = definition.cycle ? " cycle" : "";
978
- return `create sequence ${qualify(schema, object.identity.name)} as ${definition.dataType} start ${definition.start} increment ${definition.increment}${cycle}`;
979
- }
980
- function constraintBody(object, schema) {
981
- const definition = object.definition;
982
- const columns = definition.columns.map((name) => quoteIdent(name)).join(", ");
983
- switch (definition.constraintKind) {
984
- case "primaryKey":
985
- return `primary key (${columns})`;
986
- case "unique": {
987
- const nulls = definition.nullsNotDistinct ? " nulls not distinct" : "";
988
- return `unique${nulls} (${columns})${deferClause(definition)}`;
989
- }
990
- case "check":
991
- return `check (${definition.expression ?? "true"})${deferClause(definition)}`;
992
- case "foreignKey": {
993
- const references = definition.references;
994
- const target = references === undefined ? "" : ` references ${qualify(schema, references.parent.name)} (${references.columns.map((name) => quoteIdent(name)).join(", ")})`;
995
- const onDelete = references?.onDelete === undefined ? "" : ` on delete ${references.onDelete}`;
996
- const onUpdate = references?.onUpdate === undefined ? "" : ` on update ${references.onUpdate}`;
997
- return `foreign key (${columns})${target}${onDelete}${onUpdate}${deferClause(definition)}`;
998
- }
999
- default:
1000
- return definition.constraintKind;
1001
- }
1002
- }
1003
- function deferClause(definition) {
1004
- if (!definition.deferrable)
1005
- return "";
1006
- return ` deferrable initially ${definition.initially}`;
1007
- }
1008
- function qualify(schema, name) {
1009
- return `${quoteIdent(schema)}.${quoteIdent(name)}`;
1010
- }
1011
-
1012
732
  // src/contracts/location.ts
1013
733
  function callerLocation(skip) {
1014
734
  const lines = new Error().stack?.split(`
@@ -1204,29 +924,29 @@ function readTenancy(value) {
1204
924
  }
1205
925
 
1206
926
  // src/dialects/pg/filters.ts
1207
- function openFilters(table, relations, spec, hiddenFields) {
927
+ function openFilters(table, relations, spec, isHidden) {
1208
928
  const allow = spec.allow ?? {};
1209
929
  const sort = spec.sort ?? [];
1210
930
  for (const field of Object.keys(allow))
1211
- deny(hiddenFields, table, field);
931
+ deny(isHidden, table, field);
1212
932
  for (const field of sort)
1213
- deny(hiddenFields, table, field);
933
+ deny(isHidden, table, field);
1214
934
  const nested = spec.relations;
1215
935
  if (nested !== undefined) {
1216
936
  for (const name of Object.keys(nested)) {
1217
937
  const target = relationTable(relations, name);
1218
938
  for (const field of nested[name] ?? [])
1219
- deny(hiddenFields, target, field);
939
+ deny(isHidden, target, field);
1220
940
  }
1221
941
  }
1222
942
  return {
1223
943
  parse(query) {
1224
- return import("./shared/03k6res6.js").then((mod) => mod.parseQuery(allow, sort, query, nested));
944
+ return import("./shared/f4gep0nk.js").then((mod) => mod.parseQuery(allow, sort, query, nested));
1225
945
  }
1226
946
  };
1227
947
  }
1228
- function deny(hiddenFields, table, field) {
1229
- if (!hiddenFields.has(`${table}.${field}`))
948
+ function deny(isHidden, table, field) {
949
+ if (!isHidden(table, field))
1230
950
  return;
1231
951
  throw new OkmError("OKM1123", `Field ${table}.${field} is hidden.`, {
1232
952
  fix: {
@@ -1279,7 +999,8 @@ function table2(name, columns, options) {
1279
999
  name,
1280
1000
  columns,
1281
1001
  filters(spec) {
1282
- return openFilters(name, options?.relations, spec, hiddenFields);
1002
+ const ownHidden = hiddenColumnFields(columns);
1003
+ return openFilters(name, options?.relations, spec, (tableName, field) => tableName === name ? ownHidden.has(field) : hiddenFields.has(`${tableName}.${field}`));
1283
1004
  },
1284
1005
  ...options !== undefined ? { options } : {},
1285
1006
  ...source !== undefined ? { source } : {}
@@ -1343,11 +1064,23 @@ function rejectLater(options, known, later, where) {
1343
1064
  }
1344
1065
  }
1345
1066
  var hiddenFields = new Set;
1346
- function remember(name, columns) {
1067
+ function hiddenColumnFields(columns) {
1068
+ const fields = new Set;
1347
1069
  for (const field of Object.keys(columns)) {
1348
1070
  const column = columns[field];
1349
1071
  if (column?.state?.hidden === true)
1350
- hiddenFields.add(`${name}.${field}`);
1072
+ fields.add(field);
1073
+ }
1074
+ return fields;
1075
+ }
1076
+ function remember(name, columns) {
1077
+ const prefix = `${name}.`;
1078
+ for (const key of hiddenFields) {
1079
+ if (key.startsWith(prefix))
1080
+ hiddenFields.delete(key);
1081
+ }
1082
+ for (const field of hiddenColumnFields(columns)) {
1083
+ hiddenFields.add(`${name}.${field}`);
1351
1084
  }
1352
1085
  }
1353
1086
 
@@ -3777,7 +3510,7 @@ function registerTxSuite(suite) {
3777
3510
  max: options.max ?? 4,
3778
3511
  ...options.url ? { url: options.url } : {}
3779
3512
  });
3780
- const ddl = [...renderCatalog(built.catalog, schemaName), ...options.sql ?? []];
3513
+ const ddl = [...renderCatalog2(built.catalog, schemaName), ...options.sql ?? []];
3781
3514
  for (const statement of ddl)
3782
3515
  await (setup ?? pool).execute(statement);
3783
3516
  const db = await suite.connect(pool, {
@@ -4622,7 +4355,7 @@ function skipped(test, reason) {
4622
4355
  return skipFor(test, reason, (name) => `${name} (${reason})`);
4623
4356
  }
4624
4357
  async function openSuiteAdmin(url) {
4625
- const { openPostgres } = await import("./shared/pwsytxm5.js");
4358
+ const { openPostgres } = await import("./shared/gefmpwsa.js");
4626
4359
  return openPostgres(url);
4627
4360
  }
4628
4361
  async function failure2(promise) {
@@ -4655,14 +4388,45 @@ function barrier(parties) {
4655
4388
  }
4656
4389
 
4657
4390
  // packages/harness/src/driver-run.ts
4391
+ var MIN_BUN = "1.4.0";
4658
4392
  async function executeDriverTest(argv) {
4659
4393
  process.env.TZ = "UTC";
4394
+ refuseOldBun();
4660
4395
  const parsed = parseArgs(argv);
4661
4396
  const target = await loadTarget(parsed.driver, parsed.url);
4662
4397
  const rows = await runTarget(target);
4663
4398
  const failed = rows.filter((row) => row.result === "fail").length;
4664
4399
  return { text: render(target.name, rows), failed };
4665
4400
  }
4401
+ function refuseOldBun() {
4402
+ if (typeof Bun === "undefined")
4403
+ return;
4404
+ const version = typeof Bun.version === "string" ? Bun.version : "";
4405
+ if (bunAtLeast(version, MIN_BUN))
4406
+ return;
4407
+ throw new Error(`okm driver test needs Bun >=${MIN_BUN} (package.json engines.bun). This process is ${version === "" ? "Bun (unknown version)" : `Bun ${version}`}.`);
4408
+ }
4409
+ function bunAtLeast(version, minimum) {
4410
+ const left = parseSemver(version);
4411
+ const right = parseSemver(minimum);
4412
+ if (left === undefined || right === undefined)
4413
+ return false;
4414
+ for (let index = 0;index < 3; index += 1) {
4415
+ const a = left[index] ?? 0;
4416
+ const b = right[index] ?? 0;
4417
+ if (a > b)
4418
+ return true;
4419
+ if (a < b)
4420
+ return false;
4421
+ }
4422
+ return true;
4423
+ }
4424
+ function parseSemver(value) {
4425
+ const match = /^(\d+)\.(\d+)\.(\d+)/.exec(value.trim());
4426
+ if (match === null)
4427
+ return;
4428
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
4429
+ }
4666
4430
  if (__require.main == __require.module) {
4667
4431
  executeDriverTest(process.argv.slice(2)).then((report) => {
4668
4432
  process.stdout.write(report.text);
@@ -4720,8 +4484,8 @@ async function loadTarget(driver, url) {
4720
4484
  }
4721
4485
  async function firstParty(driver, url) {
4722
4486
  if (driver === "pglite") {
4723
- const adapter = await import("./shared/dy672fz6.js");
4724
- const runtime = await import("./shared/9xzm7hjg.js");
4487
+ const adapter = await import("./shared/19msgrsc.js");
4488
+ const runtime = await import("./shared/p6tjv97k.js");
4725
4489
  return {
4726
4490
  name: "pglite",
4727
4491
  capabilities: adapter.capabilities,
@@ -4736,8 +4500,8 @@ async function firstParty(driver, url) {
4736
4500
  if (url === undefined)
4737
4501
  throw new Error(`okm driver test ${driver} needs --url or DATABASE_URL.`);
4738
4502
  if (driver === "postgresjs") {
4739
- const adapter = await import("./shared/y031jct9.js");
4740
- const runtime = await import("./shared/vraj6d74.js");
4503
+ const adapter = await import("./shared/d8q00vxg.js");
4504
+ const runtime = await import("./shared/y4gq9rbe.js");
4741
4505
  return networked("postgres.js", adapter.capabilities, true, url, (config) => adapter.open({
4742
4506
  url: config.url ?? url,
4743
4507
  max: config.max,
@@ -4746,8 +4510,8 @@ async function firstParty(driver, url) {
4746
4510
  }), (pool, options) => runtime.connect(pool, options));
4747
4511
  }
4748
4512
  if (driver === "pg") {
4749
- const adapter = await import("./shared/nf7jmhfa.js");
4750
- const runtime = await import("./shared/jne7b93p.js");
4513
+ const adapter = await import("./shared/jm30k2ca.js");
4514
+ const runtime = await import("./shared/2qrte2ct.js");
4751
4515
  return networked("node-postgres", adapter.capabilities, true, url, (config) => adapter.open({
4752
4516
  url: config.url ?? url,
4753
4517
  max: config.max,
@@ -4756,8 +4520,8 @@ async function firstParty(driver, url) {
4756
4520
  }), (pool, options) => runtime.connect(pool, options));
4757
4521
  }
4758
4522
  if (driver === "neon") {
4759
- const adapter = await import("./shared/7ae7rjmn.js");
4760
- const runtime = await import("./shared/8sqrsw3s.js");
4523
+ const adapter = await import("./shared/0v9ptnxp.js");
4524
+ const runtime = await import("./shared/jgzt69pa.js");
4761
4525
  return networked("neon", adapter.capabilities, false, url, (config) => adapter.open({
4762
4526
  url: config.url ?? url,
4763
4527
  max: config.max,
@@ -4768,8 +4532,8 @@ async function firstParty(driver, url) {
4768
4532
  if (typeof Bun === "undefined" || typeof Bun.SQL !== "function") {
4769
4533
  throw new Error("bun runs only under Bun.");
4770
4534
  }
4771
- const adapter = await import("./shared/a7q7t4n3.js");
4772
- const runtime = await import("./shared/a6pp9d12.js");
4535
+ const adapter = await import("./shared/ryc5sa58.js");
4536
+ const runtime = await import("./shared/0yhf1db4.js");
4773
4537
  return networked("bun.sql", adapter.capabilities, false, url, (config) => adapter.open({
4774
4538
  url: config.url ?? url,
4775
4539
  max: config.max,
@@ -4967,5 +4731,7 @@ function render(driver, rows) {
4967
4731
  `;
4968
4732
  }
4969
4733
  export {
4734
+ MIN_BUN,
4735
+ bunAtLeast,
4970
4736
  executeDriverTest
4971
4737
  };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Pull-request comment for `okm migrate plan --json` (D279).
3
+ *
4
+ * The text comes from the plan document. It does not read the human plan.
5
+ */
6
+ import { type PlanDocument } from "../migrate/plan-json.js";
7
+ /**
8
+ * Hidden marker that identifies the sticky comment.
9
+ *
10
+ * A later push updates the comment whose body contains this marker.
11
+ */
12
+ export declare const PLAN_COMMENT_MARKER = "<!-- okmodel-migrate-plan -->";
13
+ /** Default login that posts the Action comment with `GITHUB_TOKEN`. */
14
+ export declare const PLAN_COMMENT_BOT = "github-actions[bot]";
15
+ /** A comment the sticky update may replace. */
16
+ export type StickyComment = {
17
+ readonly id: number;
18
+ readonly body: string;
19
+ /** GitHub login of the comment author. */
20
+ readonly author: string;
21
+ };
22
+ /**
23
+ * Renders the plan comment.
24
+ *
25
+ * The first heading is the strictest class. Each step is one table row
26
+ * with its class and lock. The lock is the plan's lock line, including a
27
+ * row estimate when the plan printed one. Lint findings keep their codes.
28
+ *
29
+ * @param plan - Document from `okm migrate plan --json`
30
+ * @returns Markdown, including {@link PLAN_COMMENT_MARKER}
31
+ */
32
+ export declare function renderPlanComment(plan: PlanDocument): string;
33
+ /**
34
+ * Comment body for a plan file, or a status line when the file is not a document.
35
+ *
36
+ * The status line records exit codes only. It does not include command text.
37
+ *
38
+ * @param text - Stdout of `okm migrate plan --json`, when the file exists
39
+ * @param checkStatus - Exit code of `okm migrate check`
40
+ * @param planStatus - Exit code of `okm migrate plan --json`
41
+ * @returns The comment body
42
+ */
43
+ export declare function planCommentBody(text: string | undefined, checkStatus: string, planStatus: string): string;
44
+ /**
45
+ * The comment to update, when one already carries the marker and an allowed author.
46
+ *
47
+ * The first match wins. A missing match means the caller creates a comment.
48
+ * A marker on another author's comment is ignored so the Action never edits it.
49
+ *
50
+ * @param comments - Comments already on the pull request
51
+ * @param authors - Logins allowed to own the sticky comment. Default is the Actions bot
52
+ * @returns The id to update, or `undefined` to create one
53
+ */
54
+ export declare function stickyCommentTarget(comments: readonly StickyComment[], authors?: readonly string[]): {
55
+ readonly updateId: number;
56
+ } | undefined;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Creates or updates the sticky plan comment (D279).
3
+ *
4
+ * Uses `GITHUB_TOKEN` only. The workflow needs `pull-requests: write`.
5
+ * The token is not written to stdout or stderr.
6
+ */
7
+ /**
8
+ * Posts the plan comment for one pull request.
9
+ *
10
+ * An existing comment that contains the marker is updated. Otherwise a
11
+ * comment is created. The body comes from {@link planCommentBody}.
12
+ *
13
+ * @param planPath - File written by `okm migrate plan --json`
14
+ * @param checkStatus - Exit code of `okm migrate check`
15
+ * @param planStatus - Exit code of `okm migrate plan --json`
16
+ */
17
+ export declare function postPlanComment(planPath: string, checkStatus: string, planStatus: string): Promise<void>;