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
@@ -86,7 +86,7 @@ function openClient(session) {
86
86
  },
87
87
  close,
88
88
  connected: session.connected,
89
- tx: (...args) => import("./v1wad97q.js").then((mod) => mod.tx(session, args)),
89
+ tx: (...args) => import("./wvtjg5m3.js").then((mod) => mod.tx(session, args)),
90
90
  batch: (ops, options) => batchHandle(session, ops, options),
91
91
  ...session.tx?.extras
92
92
  };
@@ -121,7 +121,7 @@ function tableApi(session, table, view, uses) {
121
121
  const api = {
122
122
  find(options = {}) {
123
123
  if ("lock" in options) {
124
- return lazyRead(session, () => import("./k86n8vq3.js"), table, options, base, view);
124
+ return lazyRead(session, () => import("./8jesqsrk.js"), table, options, base, view);
125
125
  }
126
126
  return start(session, "find", table, options, base, view);
127
127
  },
@@ -135,10 +135,10 @@ function tableApi(session, table, view, uses) {
135
135
  return start(session, "exists", table, options, base, view);
136
136
  },
137
137
  page(options) {
138
- return lazyRead(session, () => import("./6m78c8ss.js"), table, options, base, view);
138
+ return lazyRead(session, () => import("./5kyb3tqx.js"), table, options, base, view);
139
139
  },
140
140
  aggregate(options = {}) {
141
- return lazyRead(session, () => import("./n05z9nwz.js"), table, options, base, view);
141
+ return lazyRead(session, () => import("./xtsydxjg.js"), table, options, base, view);
142
142
  },
143
143
  insert(data, options = {}) {
144
144
  return writeHandle(session, "insert", table, data, options, mods);
@@ -151,9 +151,9 @@ function tableApi(session, table, view, uses) {
151
151
  }
152
152
  };
153
153
  for (const walk of ["descendants", "ancestors"]) {
154
- api[walk] = (id, options) => lazyRead(session, () => import("./wz2a78mp.js"), table, { id, walk, options }, base, view);
154
+ api[walk] = (id, options) => lazyRead(session, () => import("./c3mvnq7a.js"), table, { id, walk, options }, base, view);
155
155
  }
156
- api.sync = (id, relation, ids, options) => lazyRead(session, () => import("./p5nh3r8q.js"), table, { id, relation, ids, options }, base, view, true);
156
+ api.sync = (id, relation, ids, options) => lazyRead(session, () => import("./aksb89mn.js"), table, { id, relation, ids, options }, base, view, true);
157
157
  const hooks = session.schema.hooks;
158
158
  if (hooks !== undefined) {
159
159
  for (const hook of hooks) {
@@ -173,13 +173,13 @@ function tableApi(session, table, view, uses) {
173
173
  return api;
174
174
  }
175
175
  function batchHandle(session, ops, options, replica) {
176
- return queryHandle(() => import("./e8zyaqvj.js").then((mod) => mod.batch(session, ops, options, replica)), {
176
+ return queryHandle(() => import("./ds229x4r.js").then((mod) => mod.batch(session, ops, options, replica)), {
177
177
  replica: () => batchHandle(session, ops, options, true)
178
178
  });
179
179
  }
180
180
  var writers;
181
181
  function loadWrite() {
182
- writers ??= import("./qd9hhd8f.js");
182
+ writers ??= import("./8n688yjg.js");
183
183
  return writers;
184
184
  }
185
185
  function queryHandle(run, extra) {
@@ -372,7 +372,7 @@ function readHandle(session, table, call, mods, decode, extra) {
372
372
  }
373
373
  function streamLazy(session, call, mods, view, batch) {
374
374
  return async function* () {
375
- const { streamRows } = await import("./jebgrkeq.js");
375
+ const { streamRows } = await import("./tw1nvvfj.js");
376
376
  yield* streamRows(session, call, mods, view, batch, (error) => logged(session, error));
377
377
  }();
378
378
  }
@@ -405,16 +405,8 @@ function readCall(op, table, options, all, scope, model, schema, view) {
405
405
  };
406
406
  }
407
407
  async function checkServer(pool, schema, http, requireMeta, options, source) {
408
- const server = await import("./fjpnhqan.js");
409
- let rows;
410
- try {
411
- const result = await pool.execute(server.versionQuery, undefined, options);
412
- rows = result.rows;
413
- } catch (error) {
414
- const { mapPostgresError } = await import("./63qtkrca.js");
415
- throw mapPostgresError(error, mapOptions(http, false, schema));
416
- }
417
- await server.acceptServer(pool, schema, rows, http, requireMeta, options, source);
408
+ const { acceptServer } = await import("./zdqf8k5d.js");
409
+ await acceptServer(pool, schema, http, requireMeta, options, source);
418
410
  }
419
411
  async function mapError(session, error) {
420
412
  if (error instanceof OkmError2) {
@@ -504,4 +496,4 @@ function logged(session, error) {
504
496
  return error;
505
497
  }
506
498
 
507
- export { createClient, openClient, queryHandle, decodeRows, readHandle, readCall, withHttp, attachHttp, settleCall };
499
+ export { createClient, openClient, queryHandle, decodeRows, readHandle, readCall, withHttp, attachHttp, mapOptions, settleCall };
@@ -1,12 +1,16 @@
1
1
  import {
2
2
  catalogFileText2
3
3
  } from "./12z7aznj.js";
4
+ import {
5
+ artifactDir,
6
+ readText
7
+ } from "./yybhre6n.js";
4
8
  import {
5
9
  OkmError2
6
10
  } from "./52szzakm.js";
7
11
 
8
12
  // src/runtime/drift.ts
9
- async function assertCompatible(pool, schema, recordedHash, source, options) {
13
+ async function assertCompatible(pool, schema, recordedHash, source, options, namespace = "public") {
10
14
  const code = await codeHash(schema, source);
11
15
  if (code.hash === recordedHash)
12
16
  return;
@@ -32,8 +36,8 @@ async function assertCompatible(pool, schema, recordedHash, source, options) {
32
36
  loadTrustedCatalog(text, code.hash);
33
37
  });
34
38
  }
35
- const { assertDrift } = await import("./5mtf6cj3.js");
36
- await assertDrift(pool, code.hash, recordedHash, options);
39
+ const { assertDrift } = await import("./mvmm3xpb.js");
40
+ await assertDrift(pool, code.hash, recordedHash, options, namespace);
37
41
  }
38
42
  async function codeHash(schema, source) {
39
43
  if (source.catalog !== undefined) {
@@ -63,29 +67,6 @@ async function readHashFile(catalogDir) {
63
67
  const hash = catalogFileText2(text, "catalog.hash").trim();
64
68
  return hash.length === 0 ? undefined : hash;
65
69
  }
66
- function artifactDir(catalogDir) {
67
- if (catalogDir !== undefined)
68
- return catalogDir.replace(/[/\\]+$/, "");
69
- const cwd = globalThis.process?.cwd?.() ?? ".";
70
- return `${cwd}/.okm`;
71
- }
72
- async function readText(path) {
73
- const bun = globalThis.Bun;
74
- if (bun !== undefined) {
75
- const file = bun.file(path);
76
- if (!await file.exists())
77
- return;
78
- return file.text();
79
- }
80
- const loader = globalThis.process?.getBuiltinModule;
81
- if (loader === undefined)
82
- return;
83
- try {
84
- return await loader("node:fs/promises").readFile(path, "utf8");
85
- } catch {
86
- return;
87
- }
88
- }
89
70
  export {
90
71
  assertCompatible
91
72
  };
@@ -2,7 +2,7 @@ import {
2
2
  resetSession2,
3
3
  resetQueried2,
4
4
  refuseWhenLost2
5
- } from "./4d2w25vw.js";
5
+ } from "./99qp9vtg.js";
6
6
  export {
7
7
  refuseWhenLost2 as refuseWhenLost,
8
8
  resetQueried2 as resetQueried,
@@ -1,42 +1,50 @@
1
1
  import {
2
2
  parseCatalog2
3
3
  } from "./12z7aznj.js";
4
+ import {
5
+ quoteIdent2
6
+ } from "./fk9vef30.js";
4
7
  import"./n442h54c.js";
5
8
  import"./cm3w0ywp.js";
6
- import"./35q0n9tz.js";
9
+ import"./dd5pmnky.js";
7
10
  import {
8
11
  watchReserved2
9
- } from "./wcrheftc.js";
12
+ } from "./bphrgwz9.js";
10
13
  import {
11
14
  ensureMigrationTables2
12
- } from "./pan0370z.js";
15
+ } from "./ccsmhv9r.js";
13
16
  import {
14
17
  sealViews,
15
18
  catalogQuery2,
16
19
  managedRoleOptions2
17
- } from "./mkrn359n.js";
20
+ } from "./90sg0w5a.js";
18
21
  import {
19
22
  assumeRole,
20
23
  grantSchema,
21
24
  assertSchemaUsageLanded,
22
25
  catalogsEqual,
23
26
  snapshotDifference
24
- } from "./mnvjvqyp.js";
27
+ } from "./3456242y.js";
25
28
  import {
26
29
  roleExists
27
- } from "./kj9d8maq.js";
30
+ } from "./jpybhf98.js";
28
31
  import {
29
32
  introspectSchema
30
- } from "./p3xbdcvt.js";
33
+ } from "./myk8fswx.js";
31
34
  import {
32
35
  projectPath,
36
+ loadSnapshots,
37
+ assertSnapshots,
38
+ assertLiveExternal,
33
39
  loadMigrations,
34
40
  readMigrationPlan,
41
+ lintReprints,
35
42
  lintMigrationDirectory,
43
+ formatFindings,
36
44
  hasError,
37
45
  lintRefusal,
38
46
  openProject
39
- } from "./f4jy1j7x.js";
47
+ } from "./2zdxkt7b.js";
40
48
  import {
41
49
  sqlStatements,
42
50
  transactionControl,
@@ -51,13 +59,10 @@ import {
51
59
  assertDirectConnection,
52
60
  assertStableBackend,
53
61
  selectTarget
54
- } from "./dpc2r7rb.js";
62
+ } from "./6nae0spm.js";
55
63
  import {
56
64
  isConnectionLost
57
65
  } from "./cnkky55j.js";
58
- import {
59
- quoteIdent
60
- } from "./sjk86yrx.js";
61
66
  import {
62
67
  catalog,
63
68
  isDomain
@@ -77,6 +82,7 @@ import { join } from "node:path";
77
82
  import postgres from "postgres";
78
83
  async function replayCheckHistory(url, scratch, config, allowPooler, history) {
79
84
  const skips = [];
85
+ const reprints = [];
80
86
  let stop;
81
87
  await inCheckTransaction(url, scratch, config, allowPooler, async (sql) => {
82
88
  const connection = driverOf(sql);
@@ -88,7 +94,10 @@ async function replayCheckHistory(url, scratch, config, allowPooler, history) {
88
94
  await replayMigration(sql, connection, scratch, config, migration, session, skips);
89
95
  await restoreSession(sql, session);
90
96
  const runner = catalogQuery2(sql);
91
- const live = await introspectSchema(runner, scratch, "public", managedRoleOptions2(config.roles));
97
+ const live = await introspectSchema(runner, scratch, config.namespace ?? "public", managedRoleOptions2(config.roles));
98
+ for (const item of lintReprints(migration.catalog, live, migration.steps)) {
99
+ reprints.push({ ...item, place: `${migration.id} ${item.place}` });
100
+ }
92
101
  const sealed = await sealViews(runner, migration.catalog);
93
102
  const back = planMigration({ before: live, after: sealed, name: migration.id });
94
103
  if (back.steps.length === 0)
@@ -97,7 +106,7 @@ async function replayCheckHistory(url, scratch, config, allowPooler, history) {
97
106
  return;
98
107
  }
99
108
  });
100
- return stop === undefined ? { skips } : { skips, stop };
109
+ return stop === undefined ? { skips, reprints } : { skips, reprints, stop };
101
110
  }
102
111
  async function proveCheckSnapshot(url, provided, replayed, config, allowPooler, history) {
103
112
  const head = history.at(-1);
@@ -115,10 +124,10 @@ async function proveCheckSnapshot(url, provided, replayed, config, allowPooler,
115
124
  await runSteps(sql, connection, provided, config.roles?.migration, {
116
125
  id: "snapshot",
117
126
  catalog: head.catalog,
118
- steps: retargetSteps(planned.steps, provided)
127
+ steps: retargetSteps(planned.steps, provided, config.namespace ?? "public")
119
128
  }, session, []);
120
129
  await restoreSession(sql, session);
121
- return introspectSchema(catalogQuery2(sql), provided, "public", managedRoleOptions2(config.roles));
130
+ return introspectSchema(catalogQuery2(sql), provided, config.namespace ?? "public", managedRoleOptions2(config.roles));
122
131
  });
123
132
  const again = await inCheckTransaction(url, replayed, config, allowPooler, async (sql) => {
124
133
  const connection = driverOf(sql);
@@ -127,17 +136,17 @@ async function proveCheckSnapshot(url, provided, replayed, config, allowPooler,
127
136
  await replayMigration(sql, connection, replayed, config, migration, session, []);
128
137
  }
129
138
  await restoreSession(sql, session);
130
- return introspectSchema(catalogQuery2(sql), replayed, "public", managedRoleOptions2(config.roles));
139
+ return introspectSchema(catalogQuery2(sql), replayed, config.namespace ?? "public", managedRoleOptions2(config.roles));
131
140
  });
132
141
  return snapshotDifference(installed, again);
133
142
  }
134
- function retargetSteps(steps, schema) {
135
- const from = `${quoteIdent("public")}.`;
136
- const to = `${quoteIdent(schema)}.`;
137
- const fromDefaults = `in schema ${quoteIdent("public")} `;
138
- const toDefaults = `in schema ${quoteIdent(schema)} `;
139
- const fromSchema = `on schema ${quoteIdent("public")}`;
140
- const toSchema = `on schema ${quoteIdent(schema)}`;
143
+ function retargetSteps(steps, schema, source = "public") {
144
+ const from = `${quoteIdent2(source)}.`;
145
+ const to = `${quoteIdent2(schema)}.`;
146
+ const fromDefaults = `in schema ${quoteIdent2(source)} `;
147
+ const toDefaults = `in schema ${quoteIdent2(schema)} `;
148
+ const fromSchema = `on schema ${quoteIdent2(source)}`;
149
+ const toSchema = `on schema ${quoteIdent2(schema)}`;
141
150
  return steps.map((step) => ({
142
151
  ...step,
143
152
  sql: step.sql.replaceAll(from, to).replaceAll(fromDefaults, toDefaults).replaceAll(fromSchema, toSchema),
@@ -173,9 +182,9 @@ async function inCheckTransaction(url, scratch, config, allowPooler, run) {
173
182
  await reserved.unsafe("begin");
174
183
  open = true;
175
184
  xid = await readXid(reserved);
176
- await reserved.unsafe(`create schema ${quoteIdent(scratch)}`);
185
+ await reserved.unsafe(`create schema ${quoteIdent2(scratch)}`);
177
186
  created = true;
178
- await reserved.unsafe(`set local search_path to ${quoteIdent(scratch)}`);
187
+ await reserved.unsafe(`set local search_path to ${quoteIdent2(scratch)}`);
179
188
  await setLocalTimeout(reserved, "lock_timeout", config.timeouts?.lock);
180
189
  await setLocalTimeout(reserved, "statement_timeout", config.timeouts?.statement);
181
190
  await ownScratch(reserved, scratch, config.roles?.migration);
@@ -271,7 +280,7 @@ async function dropScratch(url, scratch) {
271
280
  onnotice: () => {}
272
281
  });
273
282
  try {
274
- await sql.unsafe(`drop schema if exists ${quoteIdent(scratch)} cascade`);
283
+ await sql.unsafe(`drop schema if exists ${quoteIdent2(scratch)} cascade`);
275
284
  const rows = await sql`
276
285
  select nspname from pg_namespace where nspname = ${scratch}
277
286
  `;
@@ -299,7 +308,7 @@ async function restoreSession(sql, session) {
299
308
  delete session.setRole;
300
309
  }
301
310
  async function replayMigration(sql, connection, scratch, config, migration, session, skips) {
302
- await runSteps(sql, connection, scratch, config.roles?.migration, { ...migration, steps: retargetSteps(migration.steps, scratch) }, session, skips);
311
+ await runSteps(sql, connection, scratch, config.roles?.migration, { ...migration, steps: retargetSteps(migration.steps, scratch, config.namespace ?? "public") }, session, skips);
303
312
  }
304
313
  async function runSteps(sql, connection, scratch, migrationRole, migration, session, skips) {
305
314
  for (let index = 0;index < migration.steps.length; index += 1) {
@@ -326,7 +335,7 @@ async function runSteps(sql, connection, scratch, migrationRole, migration, sess
326
335
  if (created !== undefined && created === migrationRole) {
327
336
  if (!existed) {
328
337
  await grantSchema(connection, scratch, created);
329
- await connection.execute(`grant select, insert, update on okm_meta, okm_history, okm_backfill to ${quoteIdent(created)}`);
338
+ await connection.execute(`grant select, insert, update on okm_meta, okm_history, okm_backfill to ${quoteIdent2(created)}`);
330
339
  }
331
340
  await assumeRole(connection, created, session);
332
341
  }
@@ -378,7 +387,7 @@ async function ownScratch(sql, scratch, role) {
378
387
  const exists = await sql.unsafe("select exists (select 1 from pg_roles where rolname = $1) as ok", [role]);
379
388
  const present = cell(exists[0], "ok");
380
389
  if (present === "t" || present === "true") {
381
- await sql.unsafe(`alter schema ${quoteIdent(scratch)} owner to ${quoteIdent(role)}`);
390
+ await sql.unsafe(`alter schema ${quoteIdent2(scratch)} owner to ${quoteIdent2(role)}`);
382
391
  }
383
392
  }
384
393
  async function setLocalTimeout(sql, name, ms) {
@@ -476,6 +485,8 @@ async function checkMigrations(cwd, flags, options) {
476
485
  }
477
486
  });
478
487
  }
488
+ assertSnapshots(cwd, opened.config, opened.built.catalog);
489
+ await assertLiveExternal(target.url, opened.built.catalog, loadSnapshots(cwd, opened.config));
479
490
  const directory = projectPath(cwd, opened.config.migrations ?? "migrations");
480
491
  const history = readHistory(directory);
481
492
  const previous = previousFailures(history);
@@ -490,16 +501,21 @@ async function checkMigrations(cwd, flags, options) {
490
501
  throwFailure([equivalence]);
491
502
  }
492
503
  const replayed = await replayHistory(opened.config, target.url, flags, history);
504
+ const reprintErrors = replayed.reprints.filter((item) => item.severity === "error");
505
+ const reprintWarnings = replayed.reprints.filter((item) => item.severity === "warning");
493
506
  const failures = [...replayed.failures, ...previous, ...stale, ...lint];
507
+ if (reprintErrors.length > 0) {
508
+ const refusal = lintRefusal(reprintErrors);
509
+ failures.push({ code: refusal.code, message: refusal.message, fix: refusal.fix.summary });
510
+ }
494
511
  if (failures.length > 0)
495
- throwFailure(failures);
512
+ throwFailure(failures, reprintWarnings);
496
513
  const summary = `ok ${String(history.length)} migrations
497
514
  `;
498
- if (replayed.skips.length === 0)
499
- return summary;
500
- return `${summary}${replayed.skips.join(`
515
+ const skipped = replayed.skips.length === 0 ? "" : `${replayed.skips.join(`
501
516
  `)}
502
517
  `;
518
+ return `${summary}${skipped}${formatFindings(reprintWarnings)}`;
503
519
  }
504
520
  function previousCatalogGaps(before, after) {
505
521
  const afterBy = new Map(after.objects.map((object) => [identityKey2(object.identity), object]));
@@ -597,14 +613,16 @@ ${difference}`,
597
613
  }
598
614
  async function replayHistory(config, url, flags, history) {
599
615
  if (history.length === 0)
600
- return { failures: [], skips: [] };
616
+ return { failures: [], skips: [], reprints: [] };
601
617
  const scratch = `${CHECK_SCHEMA_PREFIX}${crypto.randomUUID().replaceAll("-", "")}`;
602
618
  const outcome = await replayCheckHistory(url, scratch, config, flags.allowPooler || config.allowPooler === true, history);
603
- if (outcome.stop === undefined)
604
- return { failures: [], skips: outcome.skips };
619
+ if (outcome.stop === undefined) {
620
+ return { failures: [], skips: outcome.skips, reprints: outcome.reprints };
621
+ }
605
622
  return {
606
623
  failures: [historyFailure(history, outcome.stop.index, outcome.stop.back)],
607
- skips: outcome.skips
624
+ skips: outcome.skips,
625
+ reprints: outcome.reprints
608
626
  };
609
627
  }
610
628
  function refuseTransactionControl(history) {
@@ -676,13 +694,16 @@ function readHistory(directory) {
676
694
  catalog: parseCatalog2(readFileSync(join(directory, `${migration.id}.catalog.json`), "utf8"))
677
695
  }));
678
696
  }
679
- function throwFailure(failures) {
697
+ function throwFailure(failures, warnings = []) {
680
698
  const first = failures[0];
681
699
  if (first === undefined)
682
700
  throw new Error("okm migrate check has no failure to report.");
683
701
  const message = failures.length === 1 ? first.message : failures.map((failure) => `${failure.code} ${failure.message}`).join(`
684
702
  `);
685
- throw new OkmError2(first.code, message, { fix: { summary: first.fix } });
703
+ const notes = formatFindings(warnings).trim();
704
+ const text = notes.length === 0 ? message : `${message}
705
+ ${notes}`;
706
+ throw new OkmError2(first.code, text, { fix: { summary: first.fix } });
686
707
  }
687
708
  function checkedKind(kind) {
688
709
  return kind === "table" || kind === "column" || kind === "constraint" || kind === "type";