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.
- package/README.md +23 -1
- package/dist/adapters/pg/bunsql-extra.d.ts +5 -5
- package/dist/adapters/pg/bunsql.d.ts +6 -2
- package/dist/adapters/pg/nodepostgres.d.ts +16 -1
- package/dist/adapters/pg/postgres-extra.d.ts +3 -17
- package/dist/adapters/pg/postgresjs.d.ts +2 -1
- package/dist/contracts/driver.d.ts +3 -2
- package/dist/contracts/error.d.ts +1 -1
- package/dist/dialects/pg/errors.d.ts +2 -0
- 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/filters.d.ts +2 -2
- package/dist/dialects/pg/fn/index.js +5 -5
- package/dist/dialects/pg/index.d.ts +1 -0
- package/dist/dialects/pg/index.js +19 -14
- package/dist/dialects/pg/introspect.d.ts +12 -0
- package/dist/dialects/pg/view/index.js +7 -7
- package/dist/dialects/pg/view/scratch.d.ts +4 -1
- 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/param-limit.d.ts +20 -0
- package/dist/runtime/pg/bun.js +4 -4
- package/dist/runtime/pg/neon.js +4 -4
- package/dist/runtime/pg/pg.js +4 -4
- package/dist/runtime/pg/pglite.js +4 -4
- package/dist/runtime/pg/postgresjs.js +11 -11
- package/dist/runtime/server-check.d.ts +36 -6
- package/dist/runtime/tenancy/index.js +1 -1
- package/dist/runtime/traits/index.js +6 -6
- package/dist/runtime/validate/index.js +2 -2
- package/dist/runtime/write.d.ts +1 -1
- package/dist/shared/{4m6hskg8.js → 0j6qe91y.js} +4 -4
- package/dist/shared/{6m78c8ss.js → 1h5h1rf5.js} +1 -1
- package/dist/shared/{4vbf83xx.js → 2vcnpf0n.js} +1 -1
- package/dist/shared/{qd9hhd8f.js → 3ap5hxvj.js} +2 -1
- package/dist/shared/{v1wad97q.js → 3d7a80fq.js} +1 -1
- package/dist/shared/{wcrheftc.js → 3dr444ny.js} +58 -79
- package/dist/shared/{hm5f8jby.js → 3vvpcphd.js} +8 -7
- package/dist/shared/{760ppr76.js → 4a3mmhhe.js} +2 -2
- package/dist/shared/{mkrn359n.js → 4pkz5nvw.js} +222 -39
- package/dist/shared/{agsfb86s.js → 4te76xc5.js} +4 -4
- package/dist/shared/{63f4ksbz.js → 60y4ahmw.js} +1 -1
- package/dist/shared/61bmrmhr.js +35 -0
- package/dist/shared/{bxas03mq.js → 63qjmhnp.js} +100 -17
- package/dist/shared/{g5yc06ka.js → 67w3kn71.js} +1 -1
- package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
- package/dist/shared/{njga14v4.js → 6vfvsdkt.js} +10 -8
- package/dist/shared/{kj9d8maq.js → 6xqvesa5.js} +1 -1
- package/dist/shared/8gdbty5v.js +665 -0
- package/dist/shared/{pan0370z.js → 8ma6drzr.js} +211 -30
- package/dist/shared/{mnvjvqyp.js → 8p2bgye0.js} +124 -32
- package/dist/shared/{mfedzr74.js → 8qwqrxed.js} +14 -6
- package/dist/shared/{hfqmpasr.js → 8v7vzpgt.js} +11 -8
- package/dist/shared/{7ghwamrf.js → 99qp9vtg.js} +1 -1
- package/dist/shared/{zgex00fd.js → ak61ye1f.js} +5 -5
- package/dist/shared/{dpc2r7rb.js → bdekbvmt.js} +218 -95
- package/dist/shared/{jebgrkeq.js → bxjq6xqv.js} +2 -2
- package/dist/shared/c7dqd3gk.js +1806 -0
- package/dist/shared/ddh72ym5.js +20 -0
- package/dist/shared/e1c55v04.js +10 -0
- package/dist/shared/{mtw6jz76.js → e275q7sd.js} +1 -1
- package/dist/shared/{k86n8vq3.js → ekhq3ytz.js} +1 -1
- package/dist/shared/esy4dyxe.js +17 -0
- package/dist/shared/{gcefca6p.js → f9t9g54z.js} +22 -9
- package/dist/shared/{sjk86yrx.js → fk9vef30.js} +84 -73
- package/dist/shared/fkjne6gx.js +8 -0
- package/dist/shared/{e8zyaqvj.js → fne90dvz.js} +4 -1
- package/dist/shared/{needfe47.js → g89fmz5s.js} +1 -1
- package/dist/shared/{m4xff2a6.js → ghqzdp94.js} +2 -2
- package/dist/shared/{n0jmpgj1.js → gr9sn4za.js} +1 -1
- package/dist/shared/{5mtf6cj3.js → gzgfsspx.js} +5 -2
- package/dist/shared/h9811jjm.js +17 -0
- package/dist/shared/{z581d7ny.js → hgt69zjf.js} +2 -2
- package/dist/shared/{35q0n9tz.js → jvxcp1qk.js} +71 -87
- package/dist/shared/k73e8n9d.js +136 -0
- package/dist/shared/{195pzzzz.js → kzgrcy8s.js} +12 -8
- package/dist/shared/kzgrnckd.js +29 -0
- package/dist/shared/{p3xbdcvt.js → mz48rs74.js} +68 -8
- package/dist/shared/{zbqbmmrp.js → n6je5b28.js} +13 -26
- package/dist/shared/{b6d6p0zc.js → ns35jqz0.js} +75 -49
- package/dist/shared/{n05z9nwz.js → nstwgzn8.js} +1 -1
- package/dist/{tooling/shared/08kemxjd.js → shared/pgsak1yw.js} +1 -1
- package/dist/shared/py2zrrm6.js +451 -0
- package/dist/shared/{9dr2qnx7.js → qqm3ze6q.js} +1 -1
- package/dist/shared/{wvdjznah.js → rcjm0yn7.js} +31 -38
- package/dist/shared/rged92v6.js +17 -0
- package/dist/shared/{jp36k7dp.js → rw4tpcd0.js} +81 -51
- package/dist/shared/{bsek72fg.js → s5qe47a6.js} +3 -0
- package/dist/shared/{1d9q9cv2.js → smxzjz60.js} +2 -2
- package/dist/shared/{wz2a78mp.js → th5rnaxw.js} +1 -1
- package/dist/{tooling/shared/rs1jb051.js → shared/tr64w5p0.js} +1 -1
- package/dist/shared/{14x60fbf.js → tyqapcgk.js} +73 -10
- package/dist/shared/vsna85qf.js +8 -0
- package/dist/shared/{63qtkrca.js → vy47ryqa.js} +55 -5
- package/dist/shared/{jx2m62cs.js → wbdh9qbg.js} +7 -5
- package/dist/shared/{f4jy1j7x.js → wp7y8q3y.js} +946 -105
- package/dist/shared/{16kvjebh.js → xbd9xs6p.js} +7 -26
- package/dist/shared/{bah9nbg3.js → xbvz446k.js} +18 -23
- package/dist/shared/{p5nh3r8q.js → y6tfjk9q.js} +2 -2
- package/dist/shared/{3bb7wsqt.js → ycnft340.js} +1 -1
- package/dist/shared/{z7s6fpxv.js → ymenf259.js} +1 -1
- package/dist/shared/{0wrea3jq.js → ysdw2fg3.js} +10 -2
- package/dist/shared/zecrwdk9.js +61 -0
- package/dist/shared/{3t6kw83m.js → zm2rzqba.js} +2 -1
- package/dist/tooling/cli.js +200 -50
- package/dist/tooling/driver-run.js +109 -343
- package/dist/tooling/github/comment.d.ts +56 -0
- package/dist/tooling/github/post-comment.d.ts +17 -0
- package/dist/tooling/migrate/apply.d.ts +17 -2
- package/dist/tooling/migrate/commands.d.ts +2 -1
- package/dist/tooling/migrate/config.d.ts +13 -0
- package/dist/tooling/migrate/drift.d.ts +12 -0
- package/dist/tooling/migrate/driver-url.d.ts +17 -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 +57 -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/policy.d.ts +17 -5
- package/dist/tooling/migrate/pooler-probe.d.ts +23 -0
- package/dist/tooling/migrate/project.d.ts +10 -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 +65 -0
- package/dist/tooling/migrate/reprint.d.ts +32 -0
- package/dist/tooling/migrate/runner.d.ts +24 -1
- 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/{ppnnnvj8.js → 09a6vsys.js} +1 -1
- package/dist/tooling/shared/{7ae7rjmn.js → 0v9ptnxp.js} +8 -8
- package/dist/tooling/shared/{fb9k2qwd.js → 0wtzps9p.js} +11 -30
- package/dist/tooling/shared/{a6pp9d12.js → 0yhf1db4.js} +6 -6
- package/dist/tooling/shared/{dy672fz6.js → 19msgrsc.js} +2 -2
- package/dist/{shared/q0cqt2sp.js → tooling/shared/1fwfm5m3.js} +1 -1
- package/dist/tooling/shared/{f9mphxej.js → 2jdn09e2.js} +401 -24
- package/dist/tooling/shared/{jne7b93p.js → 2qrte2ct.js} +5 -5
- package/dist/tooling/shared/{5bvw2nev.js → 2v4nwnkb.js} +1 -1
- package/dist/tooling/shared/{spk1jg3r.js → 33z39trp.js} +106 -23
- package/dist/tooling/shared/{z8d7ptht.js → 353vnw9z.js} +5 -5
- package/dist/tooling/shared/{dw08f3m8.js → 390kry9g.js} +2 -2
- package/dist/tooling/shared/{xjs6zqtc.js → 3f6etb9z.js} +18 -31
- package/dist/{shared/bnby0esn.js → tooling/shared/3t2cqmsx.js} +1 -1
- package/dist/tooling/shared/{wwnekq5n.js → 4dzvjtpy.js} +1 -1
- package/dist/tooling/shared/{y5656f0e.js → 4ec0nxvw.js} +10 -10
- package/dist/tooling/shared/{3m1hkg7z.js → 4tg2bn41.js} +59 -78
- package/dist/tooling/shared/{zvnhh1n0.js → 5rah55z0.js} +2 -2
- package/dist/tooling/shared/{pqy21k24.js → 804w1t69.js} +4 -4
- package/dist/tooling/shared/8g0m0rvd.js +134 -0
- package/dist/tooling/shared/8msbtw5s.js +8 -0
- package/dist/tooling/shared/{4d2w25vw.js → 8t22h3h7.js} +2 -2
- package/dist/tooling/shared/{smn6kz1p.js → 91c59b7b.js} +2 -2
- package/dist/tooling/shared/{aftb2mwr.js → adk9k6va.js} +1 -1
- package/dist/tooling/shared/{j9t5s12a.js → ajjd5cwz.js} +2 -2
- package/dist/tooling/shared/{cmptmb4f.js → angjck01.js} +1 -1
- package/dist/tooling/shared/{yw30vnq2.js → asnnc3v5.js} +1 -1
- package/dist/tooling/shared/{ma2340rx.js → bj1kyqc8.js} +2 -2
- package/dist/tooling/shared/{2wtvc7rw.js → bt3tjemb.js} +11 -3
- package/dist/tooling/shared/{ec71zqgt.js → chk2bh4f.js} +2 -2
- package/dist/tooling/shared/{gmcf9cxf.js → ckq4z5ax.js} +5 -2
- package/dist/tooling/shared/{w7qe8sj1.js → d3rhb24q.js} +1 -1
- package/dist/tooling/shared/{y031jct9.js → d8q00vxg.js} +4 -4
- package/dist/tooling/shared/{vs0t6qt8.js → dx188rxs.js} +2 -2
- package/dist/tooling/shared/{g9ad4n80.js → efq6p9df.js} +35 -42
- package/dist/tooling/shared/{ddjtfgnx.js → en6rwzq0.js} +3 -3
- package/dist/tooling/shared/{6nyfyw70.js → f2r5g0fs.js} +2 -2
- package/dist/tooling/shared/{03k6res6.js → f4gep0nk.js} +1 -1
- package/dist/tooling/shared/{gfvtj6d0.js → f8a010fm.js} +13 -11
- package/dist/tooling/shared/{3tq8pnb8.js → fdsek6pa.js} +1 -1
- package/dist/tooling/shared/fvmrxsd1.js +8 -0
- package/dist/tooling/shared/{733a1tq3.js → g3xybeqf.js} +4 -3
- package/dist/tooling/shared/{pwsytxm5.js → gefmpwsa.js} +1 -1
- package/dist/tooling/shared/{mtrqn2hn.js → gjj71hfh.js} +25 -30
- package/dist/tooling/shared/{8sqrsw3s.js → jgzt69pa.js} +5 -5
- package/dist/tooling/shared/{nf7jmhfa.js → jm30k2ca.js} +10 -8
- package/dist/tooling/shared/{vx86qjv8.js → kayqzpbk.js} +6 -3
- package/dist/tooling/shared/{zhwnfyb2.js → kvw1672d.js} +1 -1
- package/dist/tooling/shared/{rq5kk8j6.js → mr1kcgpw.js} +3 -3
- package/dist/tooling/shared/{72fyg4zv.js → mwbdf409.js} +1 -1
- package/dist/tooling/shared/{wt7j7nf6.js → ns9207v3.js} +1 -1
- package/dist/tooling/shared/{9xzm7hjg.js → p6tjv97k.js} +3 -3
- package/dist/tooling/shared/{yfr8hzhm.js → p73evwf0.js} +1 -1
- package/dist/tooling/shared/{dzx85q70.js → phc1nc4g.js} +1 -1
- package/dist/tooling/shared/{417zdsk7.js → ppybjw50.js} +79 -16
- package/dist/tooling/shared/{yk9mp7vb.js → qdrn8ghn.js} +5 -4
- package/dist/tooling/shared/rd8h01ta.js +20 -0
- package/dist/tooling/shared/{bz2dqhab.js → rwg8y90m.js} +3 -3
- package/dist/tooling/shared/{xhrnjch9.js → ry2f3w8p.js} +3 -3
- package/dist/tooling/shared/{a7q7t4n3.js → ryc5sa58.js} +8 -8
- package/dist/tooling/shared/{2revefqt.js → ss87qxwv.js} +2 -2
- package/dist/tooling/shared/{rf83gr2d.js → vg68k11z.js} +7 -3
- package/dist/tooling/shared/{p7f08ktn.js → vms9dta5.js} +73 -89
- package/dist/tooling/shared/{3rrw5w8f.js → xchpnbdv.js} +1 -1
- package/dist/tooling/shared/{djydjpqt.js → xn6p01fh.js} +5 -5
- package/dist/tooling/shared/{9kazs5p6.js → xwr6q618.js} +3 -3
- package/dist/tooling/shared/{ep8zh3bk.js → xx3gmq94.js} +1 -1
- package/dist/tooling/shared/{tn8gay14.js → y2bd7yfx.js} +21 -13
- package/dist/tooling/shared/{vraj6d74.js → y4gq9rbe.js} +11 -11
- package/dist/tooling/shared/y4vwft92.js +9 -0
- package/dist/tooling/shared/{345tbc2k.js → yz68xcmc.js} +1 -1
- package/dist/tooling/testing/factories.d.ts +1 -3
- package/dist/tooling/testing/index.js +2 -2
- package/package.json +39 -9
- package/dist/shared/3449rcae.js +0 -14
- package/dist/shared/fjpnhqan.js +0 -71
- package/dist/shared/n41w4fbz.js +0 -113
- package/dist/tooling/shared/pw8fgahx.js +0 -69
- /package/dist/shared/{ae4j5f42.js → mfvx6kjx.js} +0 -0
package/dist/tooling/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import"../shared/12z7aznj.js";
|
|
2
2
|
import"../shared/n442h54c.js";
|
|
3
|
-
import"../shared/
|
|
3
|
+
import"../shared/fk9vef30.js";
|
|
4
|
+
import"../shared/jvxcp1qk.js";
|
|
4
5
|
import {
|
|
5
6
|
formatFindings,
|
|
6
7
|
hasError,
|
|
@@ -8,12 +9,12 @@ import {
|
|
|
8
9
|
buildProject,
|
|
9
10
|
generateProject,
|
|
10
11
|
planProject,
|
|
11
|
-
checkProject
|
|
12
|
-
|
|
12
|
+
checkProject,
|
|
13
|
+
exportProject
|
|
14
|
+
} from "../shared/wp7y8q3y.js";
|
|
13
15
|
import {
|
|
14
16
|
sessionFailure
|
|
15
|
-
} from "../shared/
|
|
16
|
-
import"../shared/sjk86yrx.js";
|
|
17
|
+
} from "../shared/bdekbvmt.js";
|
|
17
18
|
import {
|
|
18
19
|
OkmError2
|
|
19
20
|
} from "../shared/52szzakm.js";
|
|
@@ -53,8 +54,18 @@ async function run(argv, io) {
|
|
|
53
54
|
`);
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
57
|
+
if (command === "catalog") {
|
|
58
|
+
const sub = rest[0];
|
|
59
|
+
if (sub !== "export") {
|
|
60
|
+
throw new OkmError2("invalid", `Unknown command catalog ${sub ?? ""}.`, {
|
|
61
|
+
fix: { summary: "Use okm catalog export." }
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
stdout(await exportProject(cwd, rest.slice(1)));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
56
67
|
if (command === "check") {
|
|
57
|
-
const findings = await checkProject(cwd, invoke(splitFlags(rest)));
|
|
68
|
+
const findings = await checkProject(cwd, invoke(splitFlags(rest, "check")));
|
|
58
69
|
const warnings = formatFindings(findings);
|
|
59
70
|
if (warnings.length > 0)
|
|
60
71
|
stdout(warnings);
|
|
@@ -63,7 +74,7 @@ async function run(argv, io) {
|
|
|
63
74
|
return;
|
|
64
75
|
}
|
|
65
76
|
if (command === "generate") {
|
|
66
|
-
const parsed = splitFlags(rest);
|
|
77
|
+
const parsed = splitFlags(rest, "generate");
|
|
67
78
|
const written = await generateProject(cwd, parsed.name ?? "migration", parsed.flags);
|
|
68
79
|
stdout(written === undefined ? `no changes
|
|
69
80
|
` : `${written.path}
|
|
@@ -73,60 +84,86 @@ async function run(argv, io) {
|
|
|
73
84
|
return;
|
|
74
85
|
}
|
|
75
86
|
if (command === "dev") {
|
|
76
|
-
const { devProject } = await import("../shared/
|
|
87
|
+
const { devProject } = await import("../shared/ak61ye1f.js");
|
|
77
88
|
stdout(await devProject(cwd));
|
|
78
89
|
return;
|
|
79
90
|
}
|
|
80
91
|
if (command === "push") {
|
|
81
|
-
const { pushProject } = await import("../shared/
|
|
82
|
-
stdout(await pushProject(cwd, invoke(splitFlags(rest))));
|
|
92
|
+
const { pushProject } = await import("../shared/6vfvsdkt.js");
|
|
93
|
+
stdout(await pushProject(cwd, invoke(splitFlags(rest, "push"))));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (command === "pull") {
|
|
97
|
+
const { pullProject } = await import("../shared/esy4dyxe.js");
|
|
98
|
+
stdout((await pullProject(cwd, rest)).text);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (command === "import") {
|
|
102
|
+
const sub = rest[0];
|
|
103
|
+
if (sub !== "drizzle") {
|
|
104
|
+
throw new OkmError2("invalid", `Unknown command import ${sub ?? ""}.`, {
|
|
105
|
+
fix: { summary: "Use okm import drizzle <path>." }
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const { importDrizzle } = await import("../shared/8gdbty5v.js");
|
|
109
|
+
stdout((await importDrizzle(cwd, rest.slice(1))).text);
|
|
83
110
|
return;
|
|
84
111
|
}
|
|
85
112
|
if (command === "migrate") {
|
|
86
113
|
const sub = rest[0];
|
|
87
|
-
const
|
|
114
|
+
const migrateArgs = rest.slice(1);
|
|
115
|
+
const commandKey = sub === "plan" ? "migrate plan" : sub === "apply" ? "migrate apply" : sub === "status" ? "migrate status" : sub === "check" ? "migrate check" : undefined;
|
|
116
|
+
if (commandKey === undefined) {
|
|
117
|
+
throw new OkmError2("invalid", `Unknown command migrate ${sub ?? ""}.`, {
|
|
118
|
+
fix: { summary: "Use okm migrate plan, apply, status, or check." }
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const parsed = splitFlags(sub === "plan" ? migrateArgs.filter((arg) => arg !== "--json") : migrateArgs, commandKey);
|
|
88
122
|
if (sub === "plan") {
|
|
89
123
|
if (parsed.name === undefined) {
|
|
90
124
|
throw new OkmError2("invalid", "okm migrate plan needs a name.");
|
|
91
125
|
}
|
|
92
126
|
const planned = await planProject(cwd, parsed.name, parsed.flags, invoke(parsed));
|
|
93
|
-
|
|
94
|
-
|
|
127
|
+
if (migrateArgs.includes("--json"))
|
|
128
|
+
stdout(planned.json);
|
|
129
|
+
else {
|
|
130
|
+
stdout(planned.text);
|
|
131
|
+
stdout(formatFindings(planned.findings));
|
|
132
|
+
}
|
|
95
133
|
if (hasError(planned.findings))
|
|
96
134
|
throw lintRefusal(planned.findings);
|
|
97
135
|
return;
|
|
98
136
|
}
|
|
99
137
|
if (sub === "apply") {
|
|
100
|
-
const { applyProject } = await import("../shared/
|
|
138
|
+
const { applyProject } = await import("../shared/6vfvsdkt.js");
|
|
101
139
|
stdout(await applyProject(cwd, invoke(parsed), stdout));
|
|
102
140
|
return;
|
|
103
141
|
}
|
|
104
142
|
if (sub === "status") {
|
|
105
|
-
const { statusProject } = await import("../shared/
|
|
143
|
+
const { statusProject } = await import("../shared/kzgrcy8s.js");
|
|
106
144
|
stdout(await statusProject(cwd, invoke(parsed)));
|
|
107
145
|
return;
|
|
108
146
|
}
|
|
109
147
|
if (sub === "check") {
|
|
110
|
-
const { checkMigrations } = await import("../shared/
|
|
111
|
-
|
|
112
|
-
stdout(await checkMigrations(cwd, invoke(parsed), { provision }));
|
|
148
|
+
const { checkMigrations } = await import("../shared/rw4tpcd0.js");
|
|
149
|
+
stdout(await checkMigrations(cwd, invoke(parsed), { provision: parsed.provision }));
|
|
113
150
|
return;
|
|
114
151
|
}
|
|
115
152
|
}
|
|
116
153
|
if (command === "seed") {
|
|
117
|
-
const parsed = splitFlags(rest);
|
|
154
|
+
const parsed = splitFlags(rest, "seed");
|
|
118
155
|
if (parsed.name === undefined) {
|
|
119
156
|
throw new OkmError2("invalid", "okm seed needs a file.", {
|
|
120
157
|
fix: { summary: "Pass okm seed <file>." }
|
|
121
158
|
});
|
|
122
159
|
}
|
|
123
|
-
const { seedProject } = await import("../shared/
|
|
160
|
+
const { seedProject } = await import("../shared/8v7vzpgt.js");
|
|
124
161
|
stdout(await seedProject(cwd, parsed.name, invoke(parsed)));
|
|
125
162
|
return;
|
|
126
163
|
}
|
|
127
164
|
if (command === "doctor") {
|
|
128
|
-
const parsed = splitFlags(rest);
|
|
129
|
-
const { doctorProject } = await import("../shared/
|
|
165
|
+
const parsed = splitFlags(rest, "doctor");
|
|
166
|
+
const { doctorProject } = await import("../shared/3vvpcphd.js");
|
|
130
167
|
stdout(await doctorProject(cwd, parsed.name, invoke(parsed)));
|
|
131
168
|
return;
|
|
132
169
|
}
|
|
@@ -144,22 +181,54 @@ async function run(argv, io) {
|
|
|
144
181
|
}
|
|
145
182
|
if (command === "ext") {
|
|
146
183
|
const sub = rest[0];
|
|
147
|
-
if (sub === "
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
184
|
+
if (sub === "scaffold" || sub === "test") {
|
|
185
|
+
const parsed = extInvocation(rest.slice(1));
|
|
186
|
+
const { extScaffold, extTest } = await import("../shared/py2zrrm6.js");
|
|
187
|
+
const text = sub === "scaffold" ? await extScaffold(cwd, requireName(parsed, "okm ext scaffold <name>"), parsed.flags, parsed.out) : await extTest(cwd, requireName(parsed, "okm ext test <file>"), parsed.flags);
|
|
188
|
+
stdout(text);
|
|
189
|
+
return;
|
|
151
190
|
}
|
|
152
191
|
if (sub === "list" || sub === "check") {
|
|
153
|
-
const { extProject } = await import("../shared/
|
|
154
|
-
stdout(await extProject(cwd, sub, invoke(splitFlags(rest.slice(1)))));
|
|
192
|
+
const { extProject } = await import("../shared/py2zrrm6.js");
|
|
193
|
+
stdout(await extProject(cwd, sub, invoke(splitFlags(rest.slice(1), "ext"))));
|
|
155
194
|
return;
|
|
156
195
|
}
|
|
157
196
|
throw new OkmError2("invalid", `Unknown command ext ${sub ?? ""}.`, {
|
|
158
|
-
fix: { summary: "Use okm ext list or okm ext
|
|
197
|
+
fix: { summary: "Use okm ext list, okm ext check, okm ext scaffold, or okm ext test." }
|
|
159
198
|
});
|
|
160
199
|
}
|
|
161
200
|
throw new OkmError2("invalid", `Unknown command ${command ?? ""}.`);
|
|
162
201
|
}
|
|
202
|
+
function requireName(parsed, usage) {
|
|
203
|
+
if (parsed.name === undefined || parsed.name.length === 0) {
|
|
204
|
+
throw new OkmError2("invalid", `${usage} needs a name.`, {
|
|
205
|
+
fix: { summary: `Pass ${usage}.` }
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return parsed.name;
|
|
209
|
+
}
|
|
210
|
+
function extInvocation(args) {
|
|
211
|
+
const rest = [];
|
|
212
|
+
let out;
|
|
213
|
+
for (let index = 0;index < args.length; index += 1) {
|
|
214
|
+
const arg = args[index] ?? "";
|
|
215
|
+
if (arg === "--out" || arg.startsWith("--out=")) {
|
|
216
|
+
const value = arg === "--out" ? args[index + 1] : arg.slice("--out=".length);
|
|
217
|
+
if (value === undefined || value.length === 0 || value.startsWith("--")) {
|
|
218
|
+
throw new OkmError2("invalid", "--out needs a file.", {
|
|
219
|
+
fix: { summary: "Pass --out <file>. The command never overwrites." }
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
out = value;
|
|
223
|
+
if (arg === "--out")
|
|
224
|
+
index += 1;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
rest.push(arg);
|
|
228
|
+
}
|
|
229
|
+
const parsed = splitFlags(rest, "ext");
|
|
230
|
+
return { name: parsed.name, out, flags: invoke(parsed) };
|
|
231
|
+
}
|
|
163
232
|
function invoke(parsed) {
|
|
164
233
|
return {
|
|
165
234
|
...parsed.target !== undefined ? { target: parsed.target } : {},
|
|
@@ -169,55 +238,90 @@ function invoke(parsed) {
|
|
|
169
238
|
...parsed.statementTimeoutMs !== undefined ? { statementTimeoutMs: parsed.statementTimeoutMs } : {}
|
|
170
239
|
};
|
|
171
240
|
}
|
|
172
|
-
|
|
241
|
+
var COMMAND_FLAGS = {
|
|
242
|
+
check: ["--target", "--allow-pooler", "--lock-timeout", "--statement-timeout"],
|
|
243
|
+
generate: ["--replace"],
|
|
244
|
+
push: ["--target", "--allow-protected", "--allow-pooler"],
|
|
245
|
+
seed: ["--target", "--allow-protected", "--allow-pooler"],
|
|
246
|
+
doctor: ["--target"],
|
|
247
|
+
ext: ["--target", "--allow-pooler", "--out"],
|
|
248
|
+
"migrate plan": ["--target", "--allow-protected", "--replace", "--json"],
|
|
249
|
+
"migrate apply": [
|
|
250
|
+
"--target",
|
|
251
|
+
"--allow-protected",
|
|
252
|
+
"--allow-pooler",
|
|
253
|
+
"--lock-timeout",
|
|
254
|
+
"--statement-timeout"
|
|
255
|
+
],
|
|
256
|
+
"migrate status": ["--target"],
|
|
257
|
+
"migrate check": [
|
|
258
|
+
"--target",
|
|
259
|
+
"--allow-protected",
|
|
260
|
+
"--allow-pooler",
|
|
261
|
+
"--provision",
|
|
262
|
+
"--lock-timeout",
|
|
263
|
+
"--statement-timeout"
|
|
264
|
+
]
|
|
265
|
+
};
|
|
266
|
+
function splitFlags(args, command) {
|
|
267
|
+
const allowed = new Set(COMMAND_FLAGS[command]);
|
|
173
268
|
const flags = [];
|
|
174
269
|
const positionals = [];
|
|
175
270
|
let target;
|
|
176
271
|
let allowProtected = false;
|
|
177
272
|
let allowPooler = false;
|
|
273
|
+
let provision = false;
|
|
178
274
|
let lockTimeoutMs;
|
|
179
275
|
let statementTimeoutMs;
|
|
180
276
|
for (let index = 0;index < args.length; index += 1) {
|
|
181
277
|
const arg = args[index] ?? "";
|
|
182
|
-
if (arg === "--replace") {
|
|
183
|
-
|
|
184
|
-
|
|
278
|
+
if (arg === "--replace" || arg.startsWith("--replace=")) {
|
|
279
|
+
refuseUnknown(command, "--replace", allowed);
|
|
280
|
+
const value = arg === "--replace" ? args[index + 1] : arg.slice("--replace=".length);
|
|
281
|
+
if (value === undefined || value.length === 0 || arg === "--replace" && value.startsWith("--")) {
|
|
185
282
|
throw new OkmError2("OKM1541", "--replace needs table.column.old=new.", {
|
|
186
283
|
fix: { summary: "Pass --replace <table>.<column>.<old>=<new>." }
|
|
187
284
|
});
|
|
188
285
|
}
|
|
189
286
|
flags.push(value);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
if (arg.startsWith("--replace=")) {
|
|
194
|
-
flags.push(arg.slice("--replace=".length));
|
|
287
|
+
if (arg === "--replace")
|
|
288
|
+
index += 1;
|
|
195
289
|
continue;
|
|
196
290
|
}
|
|
197
291
|
if (arg === "--allow-protected") {
|
|
292
|
+
refuseUnknown(command, arg, allowed);
|
|
198
293
|
allowProtected = true;
|
|
199
294
|
continue;
|
|
200
295
|
}
|
|
201
296
|
if (arg === "--allow-pooler") {
|
|
297
|
+
refuseUnknown(command, arg, allowed);
|
|
202
298
|
allowPooler = true;
|
|
203
299
|
continue;
|
|
204
300
|
}
|
|
205
|
-
if (arg === "--
|
|
206
|
-
|
|
207
|
-
|
|
301
|
+
if (arg === "--provision") {
|
|
302
|
+
refuseUnknown(command, arg, allowed);
|
|
303
|
+
provision = true;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (arg === "--json") {
|
|
307
|
+
refuseUnknown(command, arg, allowed);
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (arg === "--target" || arg.startsWith("--target=")) {
|
|
311
|
+
refuseUnknown(command, "--target", allowed);
|
|
312
|
+
const value = arg === "--target" ? args[index + 1] : arg.slice("--target=".length);
|
|
313
|
+
if (value === undefined || value.length === 0 || arg === "--target" && value.startsWith("--")) {
|
|
208
314
|
throw new OkmError2("OKM1853", "--target needs a name.", {
|
|
209
315
|
fix: { summary: "Pass --target <name>." }
|
|
210
316
|
});
|
|
211
317
|
}
|
|
212
318
|
target = value;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
if (arg.startsWith("--target=")) {
|
|
217
|
-
target = arg.slice("--target=".length);
|
|
319
|
+
if (arg === "--target")
|
|
320
|
+
index += 1;
|
|
218
321
|
continue;
|
|
219
322
|
}
|
|
220
323
|
if (arg === "--lock-timeout" || arg === "--statement-timeout") {
|
|
324
|
+
refuseUnknown(command, arg, allowed);
|
|
221
325
|
const value = numberFlag(arg, args[index + 1]);
|
|
222
326
|
if (arg === "--lock-timeout")
|
|
223
327
|
lockTimeoutMs = value;
|
|
@@ -226,6 +330,13 @@ function splitFlags(args) {
|
|
|
226
330
|
index += 1;
|
|
227
331
|
continue;
|
|
228
332
|
}
|
|
333
|
+
if (arg.startsWith("-")) {
|
|
334
|
+
throw new OkmError2("invalid", `Unknown flag ${arg}.`, {
|
|
335
|
+
fix: {
|
|
336
|
+
summary: `Use okm ${command} --help for the flags this command accepts.`
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
229
340
|
positionals.push(arg);
|
|
230
341
|
}
|
|
231
342
|
return {
|
|
@@ -234,24 +345,42 @@ function splitFlags(args) {
|
|
|
234
345
|
target,
|
|
235
346
|
allowProtected,
|
|
236
347
|
allowPooler,
|
|
348
|
+
provision,
|
|
237
349
|
lockTimeoutMs,
|
|
238
350
|
statementTimeoutMs
|
|
239
351
|
};
|
|
240
352
|
}
|
|
353
|
+
function refuseUnknown(command, flag, allowed) {
|
|
354
|
+
if (allowed.has(flag))
|
|
355
|
+
return;
|
|
356
|
+
throw new OkmError2("invalid", `Unknown flag ${flag}.`, {
|
|
357
|
+
fix: {
|
|
358
|
+
summary: `Use okm ${command} --help for the flags this command accepts.`
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
}
|
|
241
362
|
var COMMANDS = [
|
|
242
363
|
["build", "Write the schema build."],
|
|
364
|
+
["catalog export", "Write the catalog snapshot."],
|
|
243
365
|
["check", "Lint the schema and compare it with one target."],
|
|
244
|
-
["dev", "
|
|
366
|
+
["dev", "Open a PGlite database in .okm/dev-db, or name a target called dev."],
|
|
245
367
|
["doctor [code]", "Print a target report, or one error code."],
|
|
246
368
|
["driver test <driver>", "Run conformance against one driver."],
|
|
247
369
|
["ext list", "List extensions the server can install."],
|
|
248
370
|
["ext check", "Compare declared extensions with the server."],
|
|
371
|
+
["ext scaffold <name>", "Print a starting extension() definition."],
|
|
372
|
+
["ext test <file>", "Check an extension() definition against the server."],
|
|
249
373
|
["generate [name]", "Write the next migration."],
|
|
250
|
-
[
|
|
374
|
+
[
|
|
375
|
+
"import drizzle <path>",
|
|
376
|
+
"Import a Drizzle schema. This runs that file. Writes table files and needs no database."
|
|
377
|
+
],
|
|
378
|
+
["migrate plan <name>", "Print the plan and its lock estimates. --json prints a document."],
|
|
251
379
|
["migrate apply", "Apply pending migrations."],
|
|
252
380
|
["migrate status", "Print whether the target is current."],
|
|
253
381
|
["migrate check", "Replay migration history in a scratch schema."],
|
|
254
382
|
["push", "Apply the schema diff to one target."],
|
|
383
|
+
["pull", "Write table files and a schema from one database."],
|
|
255
384
|
["seed <file>", "Run a seed file on one target."]
|
|
256
385
|
];
|
|
257
386
|
function commandsTable() {
|
|
@@ -271,10 +400,31 @@ function commandHelp(argv) {
|
|
|
271
400
|
|
|
272
401
|
${commandsTable()}`;
|
|
273
402
|
}
|
|
274
|
-
|
|
275
|
-
|
|
403
|
+
const flags = flagsForHelp(found[0]);
|
|
404
|
+
const lines = [found[0], found[1]];
|
|
405
|
+
if (flags.length > 0) {
|
|
406
|
+
lines.push("", "Flags:");
|
|
407
|
+
for (const flag of flags)
|
|
408
|
+
lines.push(` ${flag}`);
|
|
409
|
+
}
|
|
410
|
+
return `${lines.join(`
|
|
411
|
+
`)}
|
|
276
412
|
`;
|
|
277
413
|
}
|
|
414
|
+
function flagsForHelp(commandLine) {
|
|
415
|
+
const key = helpCommandKey(commandLine);
|
|
416
|
+
if (key === undefined)
|
|
417
|
+
return [];
|
|
418
|
+
return COMMAND_FLAGS[key];
|
|
419
|
+
}
|
|
420
|
+
function helpCommandKey(commandLine) {
|
|
421
|
+
const name = commandLine.replace(/\s+\[.*?\]/g, "").replace(/\s+<.*?>/g, "").trim();
|
|
422
|
+
if (name in COMMAND_FLAGS)
|
|
423
|
+
return name;
|
|
424
|
+
if (name.startsWith("ext "))
|
|
425
|
+
return "ext";
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
278
428
|
function numberFlag(flag, value) {
|
|
279
429
|
const parsed = value === undefined ? Number.NaN : Number(value);
|
|
280
430
|
if (!Number.isFinite(parsed) || parsed < 0) {
|