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,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DriverError2
|
|
3
|
+
} from "./cm3w0ywp.js";
|
|
4
|
+
import {
|
|
5
|
+
connectClient2,
|
|
6
|
+
send3
|
|
7
|
+
} from "./mazpbcdj.js";
|
|
8
|
+
import {
|
|
9
|
+
resetSession2
|
|
10
|
+
} from "./99qp9vtg.js";
|
|
11
|
+
import {
|
|
12
|
+
isConnectionLost
|
|
13
|
+
} from "./cnkky55j.js";
|
|
14
|
+
import {
|
|
15
|
+
noTimeout
|
|
16
|
+
} from "./tr64w5p0.js";
|
|
17
|
+
import {
|
|
18
|
+
WireSession
|
|
19
|
+
} from "./e275q7sd.js";
|
|
20
|
+
import {
|
|
21
|
+
rejectClosed,
|
|
22
|
+
runCall
|
|
23
|
+
} from "./mfvx6kjx.js";
|
|
24
|
+
|
|
25
|
+
// src/adapters/pg/neon-extra.ts
|
|
26
|
+
async function checkout(held) {
|
|
27
|
+
const { pool, counters, named, isClosed } = held;
|
|
28
|
+
if (isClosed())
|
|
29
|
+
return rejectClosed();
|
|
30
|
+
const client = await connectClient2(pool, held.acquireMs, counters);
|
|
31
|
+
counters.reserved += 1;
|
|
32
|
+
let lost = false;
|
|
33
|
+
const onError = () => {
|
|
34
|
+
lost = true;
|
|
35
|
+
};
|
|
36
|
+
const events = client;
|
|
37
|
+
events.on("error", onError);
|
|
38
|
+
const local = new Set;
|
|
39
|
+
const session = new WireSession((text, params) => {
|
|
40
|
+
const pending = send3(client, text, params, named);
|
|
41
|
+
const guarded = pending.catch((error) => {
|
|
42
|
+
if (isConnectionLost(error) || lost) {
|
|
43
|
+
lost = true;
|
|
44
|
+
if (isConnectionLost(error))
|
|
45
|
+
throw error;
|
|
46
|
+
throw Object.assign(new DriverError2("CONNECTION_CLOSED", { cause: error }), {
|
|
47
|
+
code: "CONNECTION_CLOSED"
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
throw error;
|
|
51
|
+
});
|
|
52
|
+
return guarded;
|
|
53
|
+
}, held.notices, isClosed, false, () => {
|
|
54
|
+
counters.reservedBusy += 1;
|
|
55
|
+
}, () => {
|
|
56
|
+
counters.reservedBusy = Math.max(0, counters.reservedBusy - 1);
|
|
57
|
+
}, local);
|
|
58
|
+
const guard = (run) => lost ? rejectClosed() : run();
|
|
59
|
+
let released = false;
|
|
60
|
+
return {
|
|
61
|
+
execute: (text, params, options) => {
|
|
62
|
+
const refused = noTimeout(options);
|
|
63
|
+
if (refused !== undefined)
|
|
64
|
+
return refused;
|
|
65
|
+
return guard(() => runCall(isClosed(), options, (watch) => session.query(text, params, watch)));
|
|
66
|
+
},
|
|
67
|
+
batch: (statements, options) => {
|
|
68
|
+
const refused = noTimeout(options);
|
|
69
|
+
if (refused !== undefined)
|
|
70
|
+
return refused;
|
|
71
|
+
return guard(() => runCall(isClosed(), options, async (watch) => {
|
|
72
|
+
const { runAtomicBatch } = await import("./b76b8d95.js");
|
|
73
|
+
return runAtomicBatch(session, statements, watch);
|
|
74
|
+
}));
|
|
75
|
+
},
|
|
76
|
+
async release() {
|
|
77
|
+
if (released)
|
|
78
|
+
return;
|
|
79
|
+
released = true;
|
|
80
|
+
try {
|
|
81
|
+
if (!lost)
|
|
82
|
+
await reset(session, client);
|
|
83
|
+
} finally {
|
|
84
|
+
counters.reserved = Math.max(0, counters.reserved - 1);
|
|
85
|
+
events.removeListener("error", onError);
|
|
86
|
+
client.release(lost);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
async function reset(session, client) {
|
|
92
|
+
await resetSession2(session.depth(), (text) => client.query(text));
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
checkout
|
|
96
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
touchFields,
|
|
3
3
|
fieldSealed
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./9dtgn1z2.js";
|
|
5
5
|
import {
|
|
6
6
|
projectExpr,
|
|
7
7
|
quote,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
isRecord,
|
|
10
10
|
registerFailFix,
|
|
11
11
|
fail2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./kgwp4jdd.js";
|
|
13
13
|
import {
|
|
14
14
|
throwNamed2
|
|
15
15
|
} from "./52szzakm.js";
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
open2
|
|
3
|
-
} from "./
|
|
4
|
-
import"./
|
|
3
|
+
} from "./dd5pmnky.js";
|
|
4
|
+
import"./12z7aznj.js";
|
|
5
|
+
import"./fk9vef30.js";
|
|
5
6
|
import"./n442h54c.js";
|
|
6
7
|
import {
|
|
7
8
|
assertRoleHealth
|
|
8
|
-
} from "./
|
|
9
|
-
import"./
|
|
9
|
+
} from "./jpybhf98.js";
|
|
10
|
+
import"./myk8fswx.js";
|
|
10
11
|
import {
|
|
11
12
|
errorDoc,
|
|
12
13
|
openProject
|
|
13
|
-
} from "./
|
|
14
|
+
} from "./2zdxkt7b.js";
|
|
14
15
|
import {
|
|
15
16
|
omitManagedObjects,
|
|
16
17
|
sessionFailure,
|
|
17
18
|
finishQuiet,
|
|
18
19
|
assertTargetPolicy,
|
|
19
20
|
selectTarget
|
|
20
|
-
} from "./
|
|
21
|
-
import"./9s0ypp87.js";
|
|
21
|
+
} from "./6nae0spm.js";
|
|
22
22
|
import {
|
|
23
23
|
OkmError2
|
|
24
24
|
} from "./52szzakm.js";
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {
|
|
2
|
+
POSTGRES_FLOOR,
|
|
3
|
+
isPostgresMajor,
|
|
4
|
+
parsePostgresFloor,
|
|
5
|
+
serverNeedsPostgres
|
|
6
|
+
} from "./ga9j92qj.js";
|
|
7
|
+
import {
|
|
8
|
+
withHttp,
|
|
9
|
+
attachHttp,
|
|
10
|
+
mapOptions
|
|
11
|
+
} from "./npdftanb.js";
|
|
12
|
+
import {
|
|
13
|
+
OkmError2
|
|
14
|
+
} from "./52szzakm.js";
|
|
15
|
+
|
|
16
|
+
// src/runtime/artifact-file.ts
|
|
17
|
+
function artifactDir(catalogDir) {
|
|
18
|
+
if (catalogDir !== undefined)
|
|
19
|
+
return catalogDir.replace(/[/\\]+$/, "");
|
|
20
|
+
const cwd = globalThis.process?.cwd?.() ?? ".";
|
|
21
|
+
return `${cwd}/.okm`;
|
|
22
|
+
}
|
|
23
|
+
async function readText(path) {
|
|
24
|
+
const bun = globalThis.Bun;
|
|
25
|
+
if (bun !== undefined) {
|
|
26
|
+
const file = bun.file(path);
|
|
27
|
+
if (!await file.exists())
|
|
28
|
+
return;
|
|
29
|
+
return file.text();
|
|
30
|
+
}
|
|
31
|
+
const loader = globalThis.process?.getBuiltinModule;
|
|
32
|
+
if (loader === undefined)
|
|
33
|
+
return;
|
|
34
|
+
try {
|
|
35
|
+
return await loader("node:fs/promises").readFile(path, "utf8");
|
|
36
|
+
} catch {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/runtime/server-check.ts
|
|
42
|
+
var versionQuery = "select current_setting('server_version_num'), version(), (select (xpath('//catalog_hash/text()', query_to_xml('select catalog_hash from okm_meta where id = ''head''', true, false, '')))[1]::text where to_regclass('okm_meta') is not null)";
|
|
43
|
+
var historyQuery = "select migration_id, class, catalog_hash from okm_history order by migration_id, step_index";
|
|
44
|
+
async function versionSql(namespace) {
|
|
45
|
+
if (namespace === "public")
|
|
46
|
+
return versionQuery;
|
|
47
|
+
const relation = await qualified("okm_meta", namespace);
|
|
48
|
+
const literal = relation.replaceAll("'", "''");
|
|
49
|
+
return `select current_setting('server_version_num'), version(), (select (xpath('//catalog_hash/text()', query_to_xml('select catalog_hash from ${literal} where id = ''head''', true, false, '')))[1]::text where to_regclass('${literal}') is not null)`;
|
|
50
|
+
}
|
|
51
|
+
async function historySql2(namespace) {
|
|
52
|
+
if (namespace === "public")
|
|
53
|
+
return historyQuery;
|
|
54
|
+
return `select migration_id, class, catalog_hash from ${await qualified("okm_history", namespace)} order by migration_id, step_index`;
|
|
55
|
+
}
|
|
56
|
+
async function recordedNamespace(catalogDir) {
|
|
57
|
+
const text = await readText(`${artifactDir(catalogDir)}/namespace`);
|
|
58
|
+
if (text === undefined)
|
|
59
|
+
return "public";
|
|
60
|
+
const line = text.trim();
|
|
61
|
+
if (line === "" || line === "public")
|
|
62
|
+
return "public";
|
|
63
|
+
if (line.includes("\x00") || line.includes(`
|
|
64
|
+
`) || line.includes("\r")) {
|
|
65
|
+
throw new OkmError2("OKM1122", "The catalog namespace file is not one identifier.", {
|
|
66
|
+
fix: { summary: "Run okm build so .okm/namespace is the schema from defineConfig." }
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return line;
|
|
70
|
+
}
|
|
71
|
+
async function acceptServer2(pool, schema, http, requireMeta, options, source) {
|
|
72
|
+
const namespace = await recordedNamespace(source.catalogDir);
|
|
73
|
+
let rows;
|
|
74
|
+
try {
|
|
75
|
+
const result = await pool.execute(await versionSql(namespace), undefined, options);
|
|
76
|
+
rows = result.rows;
|
|
77
|
+
} catch (error) {
|
|
78
|
+
const { mapPostgresError } = await import("./63qtkrca.js");
|
|
79
|
+
throw mapPostgresError(error, mapOptions(http, false, schema));
|
|
80
|
+
}
|
|
81
|
+
for (const name in schema.model) {
|
|
82
|
+
if (schema.model[name]?.presets !== undefined) {
|
|
83
|
+
(await import("./m7n9h2a5.js")).checkSchema(schema);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const version = rows[0]?.[1];
|
|
88
|
+
if (version === null || version === undefined || !version.startsWith("PostgreSQL")) {
|
|
89
|
+
throw new OkmError2("OKM1801", "The server is not PostgreSQL. The schema dialect is postgres.", withHttp(http, {
|
|
90
|
+
fix: { summary: "Open the schema with the Postgres driver that matches it." }
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
const recorded = rows[0]?.[2];
|
|
94
|
+
if (recorded === null || recorded === undefined || recorded.length === 0) {
|
|
95
|
+
if (requireMeta) {
|
|
96
|
+
throw new OkmError2("OKM1520", "okm_meta has no catalog hash.", withHttp(http, {
|
|
97
|
+
fix: {
|
|
98
|
+
summary: "Apply migrations so okm_meta records the catalog, or omit requireMeta to adopt this database."
|
|
99
|
+
}
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
const { assertCompatible } = await import("./pg4ezgyf.js");
|
|
104
|
+
try {
|
|
105
|
+
await assertCompatible(pool, schema, recorded, source, options, namespace);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (error instanceof OkmError2)
|
|
108
|
+
throw attachHttp(http, error);
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const major = Math.floor(Number(rows[0]?.[0] ?? "0") / 1e4);
|
|
113
|
+
const raw = schema.requires?.postgres;
|
|
114
|
+
if (raw === undefined) {
|
|
115
|
+
if (major < POSTGRES_FLOOR) {
|
|
116
|
+
throw new OkmError2("OKM1803", serverNeedsPostgres(major, POSTGRES_FLOOR), withHttp(http, {
|
|
117
|
+
fix: {
|
|
118
|
+
summary: `Upgrade to PostgreSQL ${String(POSTGRES_FLOOR)} or higher.`
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const need = parsePostgresFloor(raw);
|
|
125
|
+
if (!isPostgresMajor(need) || major < need) {
|
|
126
|
+
throw new OkmError2("OKM1802", serverNeedsPostgres(major, isPostgresMajor(need) ? need : POSTGRES_FLOOR), withHttp(http, {
|
|
127
|
+
fix: { summary: "Upgrade the server, or lower minPostgres to a major the server meets." }
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async function qualified(table, namespace) {
|
|
132
|
+
const { quoteIdent } = await import("./61bmrmhr.js");
|
|
133
|
+
return `${quoteIdent(namespace)}.${table}`;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export { artifactDir, readText, historySql2, acceptServer2 };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
assertNoControl
|
|
3
|
-
} from "./zchaghkf.js";
|
|
4
1
|
import {
|
|
5
2
|
searchValue
|
|
6
3
|
} from "./dzj09cye.js";
|
|
4
|
+
import {
|
|
5
|
+
assertNoControl
|
|
6
|
+
} from "./zchaghkf.js";
|
|
7
7
|
import {
|
|
8
8
|
refuseHidden,
|
|
9
9
|
indexes,
|
|
10
10
|
list,
|
|
11
11
|
isRecord,
|
|
12
12
|
fail2
|
|
13
|
-
} from "./
|
|
13
|
+
} from "./kgwp4jdd.js";
|
|
14
14
|
import {
|
|
15
15
|
isOperator,
|
|
16
16
|
operatorName,
|
package/dist/tooling/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import"../shared/
|
|
1
|
+
import"../shared/12z7aznj.js";
|
|
2
2
|
import"../shared/n442h54c.js";
|
|
3
|
-
import"../shared/
|
|
3
|
+
import"../shared/fk9vef30.js";
|
|
4
|
+
import"../shared/dd5pmnky.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/2zdxkt7b.js";
|
|
13
15
|
import {
|
|
14
16
|
sessionFailure
|
|
15
|
-
} from "../shared/
|
|
16
|
-
import"../shared/9s0ypp87.js";
|
|
17
|
+
} from "../shared/6nae0spm.js";
|
|
17
18
|
import {
|
|
18
19
|
OkmError2
|
|
19
20
|
} from "../shared/52szzakm.js";
|
|
@@ -53,6 +54,16 @@ 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
68
|
const findings = await checkProject(cwd, invoke(splitFlags(rest)));
|
|
58
69
|
const warnings = formatFindings(findings);
|
|
@@ -73,41 +84,62 @@ 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/8qzkd9f3.js");
|
|
77
88
|
stdout(await devProject(cwd));
|
|
78
89
|
return;
|
|
79
90
|
}
|
|
80
91
|
if (command === "push") {
|
|
81
|
-
const { pushProject } = await import("../shared/
|
|
92
|
+
const { pushProject } = await import("../shared/n306gqkd.js");
|
|
82
93
|
stdout(await pushProject(cwd, invoke(splitFlags(rest))));
|
|
83
94
|
return;
|
|
84
95
|
}
|
|
96
|
+
if (command === "pull") {
|
|
97
|
+
const { pullProject } = await import("../shared/7ba5h6pb.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/n5whk3mt.js");
|
|
109
|
+
stdout((await importDrizzle(cwd, rest.slice(1))).text);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
85
112
|
if (command === "migrate") {
|
|
86
113
|
const sub = rest[0];
|
|
87
|
-
const
|
|
114
|
+
const migrateArgs = rest.slice(1);
|
|
115
|
+
const parsed = splitFlags(sub === "plan" ? migrateArgs.filter((arg) => arg !== "--json") : migrateArgs);
|
|
88
116
|
if (sub === "plan") {
|
|
89
117
|
if (parsed.name === undefined) {
|
|
90
118
|
throw new OkmError2("invalid", "okm migrate plan needs a name.");
|
|
91
119
|
}
|
|
92
120
|
const planned = await planProject(cwd, parsed.name, parsed.flags, invoke(parsed));
|
|
93
|
-
|
|
94
|
-
|
|
121
|
+
if (migrateArgs.includes("--json"))
|
|
122
|
+
stdout(planned.json);
|
|
123
|
+
else {
|
|
124
|
+
stdout(planned.text);
|
|
125
|
+
stdout(formatFindings(planned.findings));
|
|
126
|
+
}
|
|
95
127
|
if (hasError(planned.findings))
|
|
96
128
|
throw lintRefusal(planned.findings);
|
|
97
129
|
return;
|
|
98
130
|
}
|
|
99
131
|
if (sub === "apply") {
|
|
100
|
-
const { applyProject } = await import("../shared/
|
|
132
|
+
const { applyProject } = await import("../shared/n306gqkd.js");
|
|
101
133
|
stdout(await applyProject(cwd, invoke(parsed), stdout));
|
|
102
134
|
return;
|
|
103
135
|
}
|
|
104
136
|
if (sub === "status") {
|
|
105
|
-
const { statusProject } = await import("../shared/
|
|
137
|
+
const { statusProject } = await import("../shared/mgaq2sd3.js");
|
|
106
138
|
stdout(await statusProject(cwd, invoke(parsed)));
|
|
107
139
|
return;
|
|
108
140
|
}
|
|
109
141
|
if (sub === "check") {
|
|
110
|
-
const { checkMigrations } = await import("../shared/
|
|
142
|
+
const { checkMigrations } = await import("../shared/qvwwp1mp.js");
|
|
111
143
|
const provision = parsed.flags.includes("--provision") || rest.slice(1).includes("--provision");
|
|
112
144
|
stdout(await checkMigrations(cwd, invoke(parsed), { provision }));
|
|
113
145
|
return;
|
|
@@ -120,34 +152,78 @@ async function run(argv, io) {
|
|
|
120
152
|
fix: { summary: "Pass okm seed <file>." }
|
|
121
153
|
});
|
|
122
154
|
}
|
|
123
|
-
const { seedProject } = await import("../shared/
|
|
155
|
+
const { seedProject } = await import("../shared/ss2kv2rs.js");
|
|
124
156
|
stdout(await seedProject(cwd, parsed.name, invoke(parsed)));
|
|
125
157
|
return;
|
|
126
158
|
}
|
|
127
159
|
if (command === "doctor") {
|
|
128
160
|
const parsed = splitFlags(rest);
|
|
129
|
-
const { doctorProject } = await import("../shared/
|
|
161
|
+
const { doctorProject } = await import("../shared/yvabyg9k.js");
|
|
130
162
|
stdout(await doctorProject(cwd, parsed.name, invoke(parsed)));
|
|
131
163
|
return;
|
|
132
164
|
}
|
|
133
|
-
if (command === "
|
|
165
|
+
if (command === "driver") {
|
|
134
166
|
const sub = rest[0];
|
|
135
|
-
if (sub
|
|
136
|
-
|
|
137
|
-
|
|
167
|
+
if (sub !== "test") {
|
|
168
|
+
const message = sub === undefined ? "Unknown command driver." : `Unknown command driver ${sub}.`;
|
|
169
|
+
throw new OkmError2("invalid", message, {
|
|
170
|
+
fix: { summary: "Use okm driver test <driver>." }
|
|
138
171
|
});
|
|
139
172
|
}
|
|
173
|
+
const { driverTest } = await import("../shared/n7kg8mmx.js");
|
|
174
|
+
await driverTest(rest.slice(1), stdout);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (command === "ext") {
|
|
178
|
+
const sub = rest[0];
|
|
179
|
+
if (sub === "scaffold" || sub === "test") {
|
|
180
|
+
const parsed = extInvocation(rest.slice(1));
|
|
181
|
+
const { extScaffold, extTest } = await import("../shared/stfa9xcw.js");
|
|
182
|
+
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);
|
|
183
|
+
stdout(text);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
140
186
|
if (sub === "list" || sub === "check") {
|
|
141
|
-
const { extProject } = await import("../shared/
|
|
187
|
+
const { extProject } = await import("../shared/stfa9xcw.js");
|
|
142
188
|
stdout(await extProject(cwd, sub, invoke(splitFlags(rest.slice(1)))));
|
|
143
189
|
return;
|
|
144
190
|
}
|
|
145
191
|
throw new OkmError2("invalid", `Unknown command ext ${sub ?? ""}.`, {
|
|
146
|
-
fix: { summary: "Use okm ext list or okm ext
|
|
192
|
+
fix: { summary: "Use okm ext list, okm ext check, okm ext scaffold, or okm ext test." }
|
|
147
193
|
});
|
|
148
194
|
}
|
|
149
195
|
throw new OkmError2("invalid", `Unknown command ${command ?? ""}.`);
|
|
150
196
|
}
|
|
197
|
+
function requireName(parsed, usage) {
|
|
198
|
+
if (parsed.name === undefined || parsed.name.length === 0) {
|
|
199
|
+
throw new OkmError2("invalid", `${usage} needs a name.`, {
|
|
200
|
+
fix: { summary: `Pass ${usage}.` }
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return parsed.name;
|
|
204
|
+
}
|
|
205
|
+
function extInvocation(args) {
|
|
206
|
+
const rest = [];
|
|
207
|
+
let out;
|
|
208
|
+
for (let index = 0;index < args.length; index += 1) {
|
|
209
|
+
const arg = args[index] ?? "";
|
|
210
|
+
if (arg === "--out" || arg.startsWith("--out=")) {
|
|
211
|
+
const value = arg === "--out" ? args[index + 1] : arg.slice("--out=".length);
|
|
212
|
+
if (value === undefined || value.length === 0 || value.startsWith("--")) {
|
|
213
|
+
throw new OkmError2("invalid", "--out needs a file.", {
|
|
214
|
+
fix: { summary: "Pass --out <file>. The command never overwrites." }
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
out = value;
|
|
218
|
+
if (arg === "--out")
|
|
219
|
+
index += 1;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
rest.push(arg);
|
|
223
|
+
}
|
|
224
|
+
const parsed = splitFlags(rest);
|
|
225
|
+
return { name: parsed.name, out, flags: invoke(parsed) };
|
|
226
|
+
}
|
|
151
227
|
function invoke(parsed) {
|
|
152
228
|
return {
|
|
153
229
|
...parsed.target !== undefined ? { target: parsed.target } : {},
|
|
@@ -228,17 +304,26 @@ function splitFlags(args) {
|
|
|
228
304
|
}
|
|
229
305
|
var COMMANDS = [
|
|
230
306
|
["build", "Write the schema build."],
|
|
307
|
+
["catalog export", "Write the catalog snapshot."],
|
|
231
308
|
["check", "Lint the schema and compare it with one target."],
|
|
232
309
|
["dev", "Watch the schema and reload."],
|
|
233
310
|
["doctor [code]", "Print a target report, or one error code."],
|
|
311
|
+
["driver test <driver>", "Run conformance against one driver."],
|
|
234
312
|
["ext list", "List extensions the server can install."],
|
|
235
313
|
["ext check", "Compare declared extensions with the server."],
|
|
314
|
+
["ext scaffold <name>", "Print a starting extension() definition."],
|
|
315
|
+
["ext test <file>", "Check an extension() definition against the server."],
|
|
236
316
|
["generate [name]", "Write the next migration."],
|
|
237
|
-
[
|
|
317
|
+
[
|
|
318
|
+
"import drizzle <path>",
|
|
319
|
+
"Import a Drizzle schema. This runs that file. Writes table files and needs no database."
|
|
320
|
+
],
|
|
321
|
+
["migrate plan <name>", "Print the plan and its lock estimates. --json prints a document."],
|
|
238
322
|
["migrate apply", "Apply pending migrations."],
|
|
239
323
|
["migrate status", "Print whether the target is current."],
|
|
240
324
|
["migrate check", "Replay migration history in a scratch schema."],
|
|
241
325
|
["push", "Apply the schema diff to one target."],
|
|
326
|
+
["pull", "Write table files and a schema from one database."],
|
|
242
327
|
["seed <file>", "Run a seed file on one target."]
|
|
243
328
|
];
|
|
244
329
|
function commandsTable() {
|