okmodel 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/adapters/capabilities.d.ts +32 -0
- package/dist/adapters/failure.d.ts +1 -1
- package/dist/adapters/pg/bun-sql.d.ts +53 -0
- package/dist/adapters/pg/bunsql-extra.d.ts +1 -1
- package/dist/adapters/pg/bunsql.d.ts +1 -1
- package/dist/adapters/pg/neon-extra.d.ts +18 -0
- package/dist/adapters/pg/neon.d.ts +104 -0
- package/dist/adapters/pg/no-inflight-timeout.d.ts +1 -1
- package/dist/contracts/error.d.ts +1 -1
- package/dist/dialects/pg/ext/btree-gin.d.ts +26 -0
- package/dist/dialects/pg/ext/btree-gin.js +20 -0
- package/dist/dialects/pg/ext/btree-gist.d.ts +26 -0
- package/dist/dialects/pg/ext/btree-gist.js +20 -0
- package/dist/dialects/pg/ext/call.d.ts +53 -0
- package/dist/dialects/pg/ext/citext.js +1 -1
- package/dist/dialects/pg/ext/feature.d.ts +26 -0
- package/dist/dialects/pg/ext/fuzzystrmatch.d.ts +34 -0
- package/dist/dialects/pg/ext/fuzzystrmatch.js +33 -0
- package/dist/dialects/pg/ext/hstore.d.ts +41 -0
- package/dist/dialects/pg/ext/hstore.js +29 -0
- package/dist/dialects/pg/ext/index.d.ts +56 -0
- package/dist/dialects/pg/ext/index.js +1 -1
- package/dist/dialects/pg/ext/ltree.d.ts +41 -0
- package/dist/dialects/pg/ext/ltree.js +29 -0
- package/dist/dialects/pg/ext/pg-trgm.js +4 -13
- package/dist/dialects/pg/ext/pgcrypto.d.ts +33 -0
- package/dist/dialects/pg/ext/pgcrypto.js +33 -0
- package/dist/dialects/pg/ext/unaccent.d.ts +26 -0
- package/dist/dialects/pg/ext/unaccent.js +21 -0
- package/dist/dialects/pg/ext/using.d.ts +23 -0
- package/dist/dialects/pg/ext/versions.d.ts +36 -0
- package/dist/dialects/pg/external.d.ts +19 -0
- package/dist/dialects/pg/fn/index.d.ts +39 -1
- package/dist/dialects/pg/fn/index.js +118 -26
- package/dist/dialects/pg/index.d.ts +3 -0
- package/dist/dialects/pg/index.js +394 -14
- package/dist/dialects/pg/introspect.d.ts +11 -0
- package/dist/dialects/pg/operators.d.ts +1 -1
- package/dist/dialects/pg/ops/fragment.d.ts +119 -0
- package/dist/dialects/pg/ops/lane.d.ts +49 -0
- package/dist/dialects/pg/view/client.d.ts +14 -6
- package/dist/dialects/pg/view/index.d.ts +73 -1
- package/dist/dialects/pg/view/index.js +156 -5
- package/dist/dialects/pg/view/scratch.d.ts +11 -5
- package/dist/runtime/artifact-file.d.ts +22 -0
- package/dist/runtime/client.d.ts +10 -0
- package/dist/runtime/drift-detail.d.ts +2 -1
- package/dist/runtime/drift.d.ts +3 -10
- package/dist/runtime/otel.d.ts +105 -0
- package/dist/runtime/otel.js +97 -0
- package/dist/runtime/pg/bun.js +4 -4
- package/dist/runtime/pg/neon.d.ts +38 -0
- package/dist/runtime/pg/neon.js +64 -0
- package/dist/runtime/pg/pg.js +4 -4
- package/dist/runtime/pg/pglite.js +4 -4
- package/dist/runtime/pg/postgresjs.js +4 -4
- package/dist/runtime/plan.d.ts +1 -1
- package/dist/runtime/server-check.d.ts +36 -6
- package/dist/runtime/sql-fragment.d.ts +43 -0
- package/dist/runtime/tenancy/index.js +10 -10
- package/dist/runtime/topology.d.ts +1 -1
- package/dist/runtime/traits/index.js +16 -17
- package/dist/runtime/types.d.ts +15 -1
- package/dist/runtime/validate/index.js +4 -4
- package/dist/shared/{81ebdx9p.js → 0j6qe91y.js} +4 -4
- package/dist/shared/{qq3899ht.js → 12z7aznj.js} +243 -14
- package/dist/shared/{gzaveazc.js → 1d9q9cv2.js} +29 -2
- package/dist/shared/{w79hsckn.js → 1mxm04fy.js} +5 -5
- package/dist/shared/{7k9grvf6.js → 2szgv6yj.js} +5 -5
- package/dist/shared/{gs74dbj5.js → 2zdxkt7b.js} +933 -111
- package/dist/shared/{m6p12kbr.js → 3456242y.js} +23 -23
- package/dist/shared/3bb7wsqt.js +99 -0
- package/dist/shared/{y6njgyda.js → 3t6kw83m.js} +2 -2
- package/dist/shared/{xhfsfkgk.js → 4vbf83xx.js} +9 -2
- package/dist/shared/{pt94kz7f.js → 5kyb3tqx.js} +1 -1
- package/dist/shared/61bmrmhr.js +35 -0
- package/dist/shared/{x933k9a3.js → 62b603gr.js} +10 -10
- package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
- package/dist/shared/{tsvww22q.js → 6nae0spm.js} +156 -95
- package/dist/shared/{mtaszv5a.js → 71n0jmhc.js} +102 -4
- package/dist/shared/{5e3tf63j.js → 760ppr76.js} +14 -6
- package/dist/shared/7ba5h6pb.js +17 -0
- package/dist/shared/{sfz1ksn6.js → 8jesqsrk.js} +2 -2
- package/dist/shared/{5v3xf80k.js → 8n688yjg.js} +1 -1
- package/dist/shared/{rs73fca9.js → 8qzkd9f3.js} +6 -6
- package/dist/shared/{ax7qv55k.js → 90sg0w5a.js} +202 -25
- package/dist/shared/{zm0ptry0.js → 99qp9vtg.js} +1 -1
- package/dist/shared/{xnxsed62.js → 9dr2qnx7.js} +14 -14
- package/dist/shared/{1w508jbr.js → 9dtgn1z2.js} +21 -17
- package/dist/shared/{h15jx9bc.js → 9dvh1dr6.js} +1 -1
- package/dist/shared/{q5c6ngn3.js → a62rb2da.js} +1 -1
- package/dist/shared/{te5as7z7.js → aksb89mn.js} +3 -3
- package/dist/shared/{bz84tkzm.js → bphrgwz9.js} +2 -2
- package/dist/shared/bsek72fg.js +225 -0
- package/dist/shared/{7mnme5tn.js → c3mvnq7a.js} +1 -1
- package/dist/shared/{p6qc5gcp.js → ccsmhv9r.js} +25 -7
- package/dist/shared/{pbp1ss85.js → cexb7z6b.js} +2 -2
- package/dist/shared/{ab9gmbwy.js → cf8zdz5p.js} +5 -5
- package/dist/shared/{jvd0mqag.js → ckz05z15.js} +5 -5
- package/dist/shared/{dk8v79p3.js → d5nmj7vv.js} +1 -1
- package/dist/shared/{14vx95q4.js → dd5pmnky.js} +7 -7
- package/dist/shared/{vb6qfyve.js → ds229x4r.js} +2 -2
- package/dist/shared/{1qa0qajz.js → e275q7sd.js} +1 -1
- package/dist/shared/{zp9fmend.js → ebhz8vh6.js} +4 -4
- package/dist/shared/{hyh73qk6.js → ecn8mfdq.js} +5 -5
- package/dist/shared/{je4axnm8.js → fdsz3w80.js} +2 -2
- package/dist/shared/{9s0ypp87.js → fk9vef30.js} +85 -74
- package/dist/shared/{g6evj1j3.js → g89fmz5s.js} +1 -1
- package/dist/shared/{aytqh5y2.js → ghqzdp94.js} +2 -2
- package/dist/shared/h9811jjm.js +17 -0
- package/dist/shared/{dkxgzaqd.js → hqpxf4a4.js} +1 -1
- package/dist/shared/{8skf0cam.js → jpybhf98.js} +1 -1
- package/dist/shared/{67txcrcw.js → kgwp4jdd.js} +4 -4
- package/dist/shared/kzgrnckd.js +29 -0
- package/dist/shared/mazpbcdj.js +233 -0
- package/dist/shared/{kb2sdhfb.js → mfvx6kjx.js} +17 -1
- package/dist/shared/{svncdeh5.js → mgaq2sd3.js} +11 -8
- package/dist/shared/{5mtf6cj3.js → mvmm3xpb.js} +5 -2
- package/dist/shared/{b5pftnn2.js → myk8fswx.js} +66 -21
- package/dist/shared/{2shdbn8q.js → n306gqkd.js} +9 -9
- package/dist/shared/{n816peh1.js → n454kcnw.js} +1 -1
- package/dist/shared/n5whk3mt.js +665 -0
- package/dist/shared/n7kg8mmx.js +61 -0
- package/dist/shared/{vqrjpcqn.js → nmnsgj7x.js} +1 -1
- package/dist/shared/{tbrvgw6z.js → npdftanb.js} +19 -26
- package/dist/shared/{ek2wt2dz.js → pg4ezgyf.js} +11 -30
- package/dist/shared/{5fe3kbsh.js → pgsak1yw.js} +1 -1
- package/dist/shared/{bm22fvzr.js → qfw14tna.js} +2 -2
- package/dist/shared/{wa07eas9.js → qvwwp1mp.js} +62 -41
- package/dist/shared/rbxt795q.js +1766 -0
- package/dist/shared/{xjk7hnn5.js → s7he5e5d.js} +2 -2
- package/dist/shared/{w72kgg4q.js → ss2kv2rs.js} +6 -6
- package/dist/shared/stfa9xcw.js +450 -0
- package/dist/shared/{3v7t1yrv.js → th3be82n.js} +2 -2
- package/dist/shared/{79dt02vc.js → tr64w5p0.js} +1 -1
- package/dist/shared/{cn957f8d.js → tw1nvvfj.js} +3 -3
- package/dist/shared/{ed0b8k4s.js → typ3vy7t.js} +1 -1
- package/dist/shared/{9628a9xt.js → vk7rag46.js} +1 -1
- package/dist/shared/{ze4hxsmy.js → w9ejzaqf.js} +1 -1
- package/dist/shared/{vczs8gd4.js → wvtjg5m3.js} +2 -2
- package/dist/shared/{9y3mmmh1.js → xfhe73sb.js} +1 -1
- package/dist/shared/xqacq37x.js +61 -0
- package/dist/shared/{1est4ezg.js → xtsydxjg.js} +3 -3
- package/dist/shared/xv8qj97g.js +96 -0
- package/dist/shared/{bg3rym3g.js → xwhdcrm4.js} +2 -2
- package/dist/shared/{kr0jzbw2.js → yvabyg9k.js} +7 -7
- package/dist/shared/yybhre6n.js +136 -0
- package/dist/shared/zdqf8k5d.js +8 -0
- package/dist/shared/{jznfax0y.js → zq1he88x.js} +4 -4
- package/dist/tooling/cli.js +108 -23
- package/dist/tooling/driver-run.js +4654 -0
- package/dist/tooling/driver-test.d.ts +36 -0
- package/dist/tooling/github/comment.d.ts +50 -0
- package/dist/tooling/github/post-comment.d.ts +17 -0
- package/dist/tooling/migrate/commands.d.ts +3 -2
- package/dist/tooling/migrate/config.d.ts +13 -0
- package/dist/tooling/migrate/export.d.ts +165 -0
- package/dist/tooling/migrate/ext-surface.d.ts +80 -0
- package/dist/tooling/migrate/ext.d.ts +31 -4
- package/dist/tooling/migrate/import-drizzle.d.ts +40 -0
- package/dist/tooling/migrate/index.d.ts +3 -0
- package/dist/tooling/migrate/index.js +55 -10
- package/dist/tooling/migrate/lint-rules.d.ts +18 -1
- package/dist/tooling/migrate/lint.d.ts +14 -1
- package/dist/tooling/migrate/place.d.ts +18 -0
- package/dist/tooling/migrate/plan-json.d.ts +65 -0
- package/dist/tooling/migrate/project.d.ts +13 -1
- package/dist/tooling/migrate/pull-emit.d.ts +98 -0
- package/dist/tooling/migrate/pull-routines.d.ts +126 -0
- package/dist/tooling/migrate/pull-verify.d.ts +26 -0
- package/dist/tooling/migrate/pull.d.ts +62 -0
- package/dist/tooling/migrate/reprint.d.ts +32 -0
- package/dist/tooling/migrate/sandbox.d.ts +8 -2
- package/dist/tooling/migrate/schema-api.d.ts +43 -0
- package/dist/tooling/migrate/sql-lex.d.ts +18 -0
- package/dist/tooling/shared/04svnxxj.js +344 -0
- package/dist/tooling/shared/0j0jtse1.js +13 -0
- package/dist/tooling/shared/0r05zhyq.js +618 -0
- package/dist/tooling/shared/1800eymw.js +49 -0
- package/dist/tooling/shared/35zemrmf.js +12 -0
- package/dist/tooling/shared/3rmaz3pq.js +140 -0
- package/dist/tooling/shared/3yn79q5m.js +12 -0
- package/dist/tooling/shared/54tqkxja.js +51 -0
- package/dist/tooling/shared/57btdkgm.js +209 -0
- package/dist/tooling/shared/5bmksndh.js +118 -0
- package/dist/tooling/shared/5p8km5jb.js +38 -0
- package/dist/tooling/shared/5x3pf400.js +185 -0
- package/dist/tooling/shared/5zrzffnk.js +6 -0
- package/dist/tooling/shared/62fxpc1p.js +332 -0
- package/dist/tooling/shared/68tf18v4.js +20 -0
- package/dist/tooling/shared/6vk28rjp.js +98 -0
- package/dist/tooling/shared/76pv6qff.js +9 -0
- package/dist/tooling/shared/7aews1zg.js +311 -0
- package/dist/tooling/shared/7b3xp9gc.js +195 -0
- package/dist/tooling/shared/7kms6fvj.js +20 -0
- package/dist/tooling/shared/7pxncnzs.js +40 -0
- package/dist/tooling/shared/829fjxyw.js +198 -0
- package/dist/tooling/shared/8m5znpdt.js +66 -0
- package/dist/tooling/shared/8yr7ges1.js +211 -0
- package/dist/tooling/shared/96ps4g1z.js +32 -0
- package/dist/tooling/shared/9qr9rkbh.js +143 -0
- package/dist/tooling/shared/9sfbtwsk.js +49 -0
- package/dist/tooling/shared/9wsnsvbf.js +10 -0
- package/dist/tooling/shared/a2xe04bm.js +18 -0
- package/dist/tooling/shared/a4pzghha.js +20 -0
- package/dist/tooling/shared/am04v8na.js +233 -0
- package/dist/tooling/shared/asgr07mp.js +194 -0
- package/dist/tooling/shared/c0xevn1h.js +312 -0
- package/dist/tooling/shared/dhatassp.js +134 -0
- package/dist/tooling/shared/ezqn88nj.js +1696 -0
- package/dist/tooling/shared/f77nnfqy.js +231 -0
- package/dist/tooling/shared/fh07z1dt.js +15 -0
- package/dist/tooling/shared/gqwevek4.js +81 -0
- package/dist/tooling/shared/hfq3n3bd.js +4116 -0
- package/dist/tooling/shared/htnaj77v.js +17 -0
- package/dist/tooling/shared/j664qjrt.js +64 -0
- package/dist/tooling/shared/jpgmjsx3.js +38 -0
- package/dist/tooling/shared/jr2nmr81.js +497 -0
- package/dist/tooling/shared/jsjjz875.js +139 -0
- package/dist/tooling/shared/kbqnrs1x.js +1425 -0
- package/dist/tooling/shared/kz715295.js +94 -0
- package/dist/tooling/shared/m3xt8b1h.js +22 -0
- package/dist/tooling/shared/m4hhb8aa.js +9 -0
- package/dist/tooling/shared/mw5npye0.js +16 -0
- package/dist/tooling/shared/n4jqhpqz.js +27 -0
- package/dist/tooling/shared/nxq95eb6.js +42 -0
- package/dist/tooling/shared/qartgazh.js +70 -0
- package/dist/tooling/shared/rcywj2w8.js +190 -0
- package/dist/tooling/shared/s6qha57m.js +16 -0
- package/dist/tooling/shared/shjs0379.js +150 -0
- package/dist/tooling/shared/sjwkt1pg.js +16 -0
- package/dist/tooling/shared/stebqyyd.js +401 -0
- package/dist/tooling/shared/t4xveemq.js +250 -0
- package/dist/tooling/shared/t6zjeake.js +261 -0
- package/dist/tooling/shared/tcwpjvxe.js +9 -0
- package/dist/tooling/shared/tpssp7ac.js +160 -0
- package/dist/tooling/shared/v6j1ep6w.js +42 -0
- package/dist/tooling/shared/vwr2y833.js +270 -0
- package/dist/tooling/shared/w17sj05d.js +7 -0
- package/dist/tooling/shared/w5d89rb4.js +131 -0
- package/dist/tooling/shared/wbwq1jsa.js +157 -0
- package/dist/tooling/shared/wezxf3h8.js +17 -0
- package/dist/tooling/shared/yb4kd19s.js +12 -0
- package/dist/tooling/shared/ybdew6j7.js +294 -0
- package/dist/tooling/shared/yfedr1zb.js +6 -0
- package/dist/tooling/shared/yhp829bx.js +177 -0
- package/dist/tooling/shared/ytk1tjs0.js +604 -0
- package/dist/tooling/shared/zs9aymcp.js +210 -0
- package/dist/tooling/shared/zx3v9phv.js +8 -0
- package/dist/tooling/testing/index.js +3 -3
- package/package.json +50 -9
- package/dist/shared/ktz42yez.js +0 -113
- package/dist/shared/ttsqgp4p.js +0 -71
- package/dist/shared/y34a8714.js +0 -150
- package/dist/shared/zy8r7qvz.js +0 -116
- package/dist/shared/{ywr8hmey.js → 606g0nbf.js} +3 -3
- package/dist/shared/{rpycarcr.js → gcefca6p.js} +4 -4
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OkmError2
|
|
3
|
+
} from "./52szzakm.js";
|
|
4
|
+
|
|
5
|
+
// src/tooling/driver-test.ts
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
import { existsSync } from "node:fs";
|
|
8
|
+
import { dirname, join } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
async function driverTest(args, stdout) {
|
|
11
|
+
const runner = driverRunnerPath(dirname(fileURLToPath(import.meta.url)));
|
|
12
|
+
if (!existsSync(runner)) {
|
|
13
|
+
throw new OkmError2("invalid", "okm driver test cannot find its runner.", {
|
|
14
|
+
fix: { summary: "Run bun run build, then retry." }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const command = runner.endsWith(".ts") ? "bun" : process.execPath;
|
|
18
|
+
const result = await runProcess(command, [runner, ...args]);
|
|
19
|
+
if (result.stdout.length > 0)
|
|
20
|
+
stdout(result.stdout);
|
|
21
|
+
if (result.code !== 0) {
|
|
22
|
+
const detail = result.stderr.trim();
|
|
23
|
+
throw new OkmError2("invalid", detail === "" ? "okm driver test failed." : detail, {
|
|
24
|
+
fix: { summary: "The report lists each failed case." }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function driverRunnerPath(here) {
|
|
29
|
+
const source = join(here, "..", "..", "packages", "harness", "src", "driver-run.ts");
|
|
30
|
+
if (existsSync(source))
|
|
31
|
+
return source;
|
|
32
|
+
const beside = join(here, "driver-run.js");
|
|
33
|
+
if (existsSync(beside))
|
|
34
|
+
return beside;
|
|
35
|
+
return join(here, "..", "tooling", "driver-run.js");
|
|
36
|
+
}
|
|
37
|
+
function runProcess(command, args) {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
const child = spawn(command, [...args], { stdio: ["ignore", "pipe", "pipe"] });
|
|
40
|
+
const out = [];
|
|
41
|
+
const err = [];
|
|
42
|
+
child.stdout.on("data", (chunk) => {
|
|
43
|
+
out.push(chunk);
|
|
44
|
+
});
|
|
45
|
+
child.stderr.on("data", (chunk) => {
|
|
46
|
+
err.push(chunk);
|
|
47
|
+
});
|
|
48
|
+
const proc = child;
|
|
49
|
+
proc.on("error", reject);
|
|
50
|
+
proc.on("close", (code) => {
|
|
51
|
+
resolve({
|
|
52
|
+
code: code ?? 1,
|
|
53
|
+
stdout: Buffer.concat(out).toString("utf8"),
|
|
54
|
+
stderr: Buffer.concat(err).toString("utf8")
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
driverTest
|
|
61
|
+
};
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
logicalIntent,
|
|
9
9
|
appliedRules,
|
|
10
10
|
rejectKeys
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./kgwp4jdd.js";
|
|
12
12
|
import {
|
|
13
13
|
OkmError2,
|
|
14
14
|
safe2,
|
|
@@ -86,7 +86,7 @@ function openClient(session) {
|
|
|
86
86
|
},
|
|
87
87
|
close,
|
|
88
88
|
connected: session.connected,
|
|
89
|
-
tx: (...args) => import("./
|
|
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("./
|
|
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("./
|
|
138
|
+
return lazyRead(session, () => import("./5kyb3tqx.js"), table, options, base, view);
|
|
139
139
|
},
|
|
140
140
|
aggregate(options = {}) {
|
|
141
|
-
return lazyRead(session, () => import("./
|
|
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("./
|
|
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("./
|
|
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) {
|
|
@@ -169,16 +169,17 @@ function tableApi(session, table, view, uses) {
|
|
|
169
169
|
for (const name in session.schema.model[table]?.presets) {
|
|
170
170
|
api[name] = (...args) => tableApi(session, table, view, [uses, name, args]);
|
|
171
171
|
}
|
|
172
|
+
api[Symbol.for("okm.lane")] = [session, table, mapError];
|
|
172
173
|
return api;
|
|
173
174
|
}
|
|
174
175
|
function batchHandle(session, ops, options, replica) {
|
|
175
|
-
return queryHandle(() => import("./
|
|
176
|
+
return queryHandle(() => import("./ds229x4r.js").then((mod) => mod.batch(session, ops, options, replica)), {
|
|
176
177
|
replica: () => batchHandle(session, ops, options, true)
|
|
177
178
|
});
|
|
178
179
|
}
|
|
179
180
|
var writers;
|
|
180
181
|
function loadWrite() {
|
|
181
|
-
writers ??= import("./
|
|
182
|
+
writers ??= import("./8n688yjg.js");
|
|
182
183
|
return writers;
|
|
183
184
|
}
|
|
184
185
|
function queryHandle(run, extra) {
|
|
@@ -288,7 +289,7 @@ function lazyRead(session, load, table, options, mods, view, sync) {
|
|
|
288
289
|
return queryHandle(() => read().then((box) => box.it), extra);
|
|
289
290
|
}
|
|
290
291
|
async function decodeRows(plan, rows, table) {
|
|
291
|
-
return plan.outputs.includes.length === 0 ? decodeResult(plan, rows, table) : (await import("./
|
|
292
|
+
return plan.outputs.includes.length === 0 ? decodeResult(plan, rows, table) : (await import("./hqpxf4a4.js")).decodeIncluded(plan, rows, table);
|
|
292
293
|
}
|
|
293
294
|
function readHandle(session, table, call, mods, decode, extra) {
|
|
294
295
|
let prepared;
|
|
@@ -301,14 +302,14 @@ function readHandle(session, table, call, mods, decode, extra) {
|
|
|
301
302
|
call = (await import("./m7n9h2a5.js")).refine(session.schema, origin, mods.uses);
|
|
302
303
|
}
|
|
303
304
|
if (searched) {
|
|
304
|
-
call = (await import("./
|
|
305
|
+
call = (await import("./zq1he88x.js")).applyTextSearch(session.schema, call);
|
|
305
306
|
}
|
|
306
307
|
const hooks = await hooksFor(call);
|
|
307
308
|
if (readNeedsOperatorSql(session.schema, call) || hooks?.needsOperator(session.schema, call)) {
|
|
308
309
|
await loadOperatorSql();
|
|
309
310
|
}
|
|
310
311
|
if (call.build === undefined && selectHasWindow(call.select)) {
|
|
311
|
-
call = (await import("./
|
|
312
|
+
call = (await import("./1d9q9cv2.js")).attach(session.schema, call);
|
|
312
313
|
}
|
|
313
314
|
const bound = bindCall(session.schema, call, hooks);
|
|
314
315
|
let plan = session.cache.get(bound.key);
|
|
@@ -371,7 +372,7 @@ function readHandle(session, table, call, mods, decode, extra) {
|
|
|
371
372
|
}
|
|
372
373
|
function streamLazy(session, call, mods, view, batch) {
|
|
373
374
|
return async function* () {
|
|
374
|
-
const { streamRows } = await import("./
|
|
375
|
+
const { streamRows } = await import("./tw1nvvfj.js");
|
|
375
376
|
yield* streamRows(session, call, mods, view, batch, (error) => logged(session, error));
|
|
376
377
|
}();
|
|
377
378
|
}
|
|
@@ -404,16 +405,8 @@ function readCall(op, table, options, all, scope, model, schema, view) {
|
|
|
404
405
|
};
|
|
405
406
|
}
|
|
406
407
|
async function checkServer(pool, schema, http, requireMeta, options, source) {
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
try {
|
|
410
|
-
const result = await pool.execute(server.versionQuery, undefined, options);
|
|
411
|
-
rows = result.rows;
|
|
412
|
-
} catch (error) {
|
|
413
|
-
const { mapPostgresError } = await import("./63qtkrca.js");
|
|
414
|
-
throw mapPostgresError(error, mapOptions(http, false, schema));
|
|
415
|
-
}
|
|
416
|
-
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);
|
|
417
410
|
}
|
|
418
411
|
async function mapError(session, error) {
|
|
419
412
|
if (error instanceof OkmError2) {
|
|
@@ -433,7 +426,7 @@ function errorFields(error) {
|
|
|
433
426
|
var includeHooks;
|
|
434
427
|
var operatorSql;
|
|
435
428
|
function loadOperatorSql() {
|
|
436
|
-
operatorSql ??= import("./
|
|
429
|
+
operatorSql ??= import("./4vbf83xx.js").then(() => {
|
|
437
430
|
return;
|
|
438
431
|
});
|
|
439
432
|
return operatorSql;
|
|
@@ -444,7 +437,7 @@ function selectHasWindow(select) {
|
|
|
444
437
|
function hooksFor(call) {
|
|
445
438
|
if (call.include === undefined)
|
|
446
439
|
return Promise.resolve(undefined);
|
|
447
|
-
includeHooks ??= import("./
|
|
440
|
+
includeHooks ??= import("./hqpxf4a4.js").then((mod) => mod.includeHooks);
|
|
448
441
|
return includeHooks;
|
|
449
442
|
}
|
|
450
443
|
function bindNow(schema, call) {
|
|
@@ -503,4 +496,4 @@ function logged(session, error) {
|
|
|
503
496
|
return error;
|
|
504
497
|
}
|
|
505
498
|
|
|
506
|
-
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
|
-
} from "./
|
|
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;
|
|
@@ -14,7 +18,7 @@ async function assertCompatible(pool, schema, recordedHash, source, options) {
|
|
|
14
18
|
if (code.artifact !== undefined) {
|
|
15
19
|
const artifact = code.artifact;
|
|
16
20
|
await loadOnce(`text\x00${artifact.hash}`, async () => {
|
|
17
|
-
const { loadTrustedCatalog } = await import("./
|
|
21
|
+
const { loadTrustedCatalog } = await import("./d5nmj7vv.js");
|
|
18
22
|
loadTrustedCatalog(artifact.text, artifact.hash);
|
|
19
23
|
});
|
|
20
24
|
} else if (code.fromFile) {
|
|
@@ -28,12 +32,12 @@ async function assertCompatible(pool, schema, recordedHash, source, options) {
|
|
|
28
32
|
}
|
|
29
33
|
});
|
|
30
34
|
}
|
|
31
|
-
const { loadTrustedCatalog } = await import("./
|
|
35
|
+
const { loadTrustedCatalog } = await import("./d5nmj7vv.js");
|
|
32
36
|
loadTrustedCatalog(text, code.hash);
|
|
33
37
|
});
|
|
34
38
|
}
|
|
35
|
-
const { assertDrift } = await import("./
|
|
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) {
|
|
@@ -42,7 +46,7 @@ async function codeHash(schema, source) {
|
|
|
42
46
|
const listed = await readHashFile(source.catalogDir);
|
|
43
47
|
if (listed !== undefined)
|
|
44
48
|
return { hash: listed, fromFile: true };
|
|
45
|
-
const { catalogHash } = await import("./
|
|
49
|
+
const { catalogHash } = await import("./d5nmj7vv.js");
|
|
46
50
|
return { hash: catalogHash(schemaCatalog(schema)), fromFile: false };
|
|
47
51
|
}
|
|
48
52
|
function schemaCatalog(schema) {
|
|
@@ -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
|
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./mss6ctgv.js";
|
|
4
4
|
import {
|
|
5
5
|
effectivePredicate
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./n454kcnw.js";
|
|
7
7
|
import {
|
|
8
8
|
runWrite
|
|
9
9
|
} from "./n4jqhpqz.js";
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
isRecord,
|
|
18
18
|
registerFailFix,
|
|
19
19
|
fail2
|
|
20
|
-
} from "./
|
|
20
|
+
} from "./kgwp4jdd.js";
|
|
21
21
|
import {
|
|
22
22
|
safetyInstalled,
|
|
23
23
|
runSafety
|
|
@@ -1,42 +1,50 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseCatalog2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./12z7aznj.js";
|
|
4
|
+
import {
|
|
5
|
+
quoteIdent2
|
|
6
|
+
} from "./fk9vef30.js";
|
|
4
7
|
import"./n442h54c.js";
|
|
5
8
|
import"./cm3w0ywp.js";
|
|
6
|
-
import"./
|
|
9
|
+
import"./dd5pmnky.js";
|
|
7
10
|
import {
|
|
8
11
|
watchReserved2
|
|
9
|
-
} from "./
|
|
12
|
+
} from "./bphrgwz9.js";
|
|
10
13
|
import {
|
|
11
14
|
ensureMigrationTables2
|
|
12
|
-
} from "./
|
|
15
|
+
} from "./ccsmhv9r.js";
|
|
13
16
|
import {
|
|
14
17
|
sealViews,
|
|
15
18
|
catalogQuery2,
|
|
16
19
|
managedRoleOptions2
|
|
17
|
-
} from "./
|
|
20
|
+
} from "./90sg0w5a.js";
|
|
18
21
|
import {
|
|
19
22
|
assumeRole,
|
|
20
23
|
grantSchema,
|
|
21
24
|
assertSchemaUsageLanded,
|
|
22
25
|
catalogsEqual,
|
|
23
26
|
snapshotDifference
|
|
24
|
-
} from "./
|
|
27
|
+
} from "./3456242y.js";
|
|
25
28
|
import {
|
|
26
29
|
roleExists
|
|
27
|
-
} from "./
|
|
30
|
+
} from "./jpybhf98.js";
|
|
28
31
|
import {
|
|
29
32
|
introspectSchema
|
|
30
|
-
} from "./
|
|
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 "./
|
|
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 "./
|
|
62
|
+
} from "./6nae0spm.js";
|
|
55
63
|
import {
|
|
56
64
|
isConnectionLost
|
|
57
65
|
} from "./cnkky55j.js";
|
|
58
|
-
import {
|
|
59
|
-
quoteIdent
|
|
60
|
-
} from "./9s0ypp87.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 = `${
|
|
136
|
-
const to = `${
|
|
137
|
-
const fromDefaults = `in schema ${
|
|
138
|
-
const toDefaults = `in schema ${
|
|
139
|
-
const fromSchema = `on schema ${
|
|
140
|
-
const toSchema = `on 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 ${
|
|
185
|
+
await reserved.unsafe(`create schema ${quoteIdent2(scratch)}`);
|
|
177
186
|
created = true;
|
|
178
|
-
await reserved.unsafe(`set local search_path to ${
|
|
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 ${
|
|
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 ${
|
|
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 ${
|
|
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
|
-
|
|
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
|
-
|
|
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";
|