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,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DriverError2,
|
|
3
|
+
isConnectionLost
|
|
4
|
+
} from "./hfq3n3bd.js";
|
|
5
|
+
import {
|
|
6
|
+
connectClient3,
|
|
7
|
+
send4
|
|
8
|
+
} from "./am04v8na.js";
|
|
9
|
+
import {
|
|
10
|
+
resetSession2
|
|
11
|
+
} from "./7pxncnzs.js";
|
|
12
|
+
import {
|
|
13
|
+
WireSession
|
|
14
|
+
} from "./jsjjz875.js";
|
|
15
|
+
import {
|
|
16
|
+
noTimeout
|
|
17
|
+
} from "./3yn79q5m.js";
|
|
18
|
+
import {
|
|
19
|
+
rejectClosed,
|
|
20
|
+
runCall
|
|
21
|
+
} from "./5x3pf400.js";
|
|
22
|
+
|
|
23
|
+
// src/adapters/pg/neon-extra.ts
|
|
24
|
+
async function checkout(held) {
|
|
25
|
+
const { pool, counters, named, isClosed } = held;
|
|
26
|
+
if (isClosed())
|
|
27
|
+
return rejectClosed();
|
|
28
|
+
const client = await connectClient3(pool, held.acquireMs, counters);
|
|
29
|
+
counters.reserved += 1;
|
|
30
|
+
let lost = false;
|
|
31
|
+
const onError = () => {
|
|
32
|
+
lost = true;
|
|
33
|
+
};
|
|
34
|
+
const events = client;
|
|
35
|
+
events.on("error", onError);
|
|
36
|
+
const local = new Set;
|
|
37
|
+
const session = new WireSession((text, params) => {
|
|
38
|
+
const pending = send4(client, text, params, named);
|
|
39
|
+
const guarded = pending.catch((error) => {
|
|
40
|
+
if (isConnectionLost(error) || lost) {
|
|
41
|
+
lost = true;
|
|
42
|
+
if (isConnectionLost(error))
|
|
43
|
+
throw error;
|
|
44
|
+
throw Object.assign(new DriverError2("CONNECTION_CLOSED", { cause: error }), {
|
|
45
|
+
code: "CONNECTION_CLOSED"
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
throw error;
|
|
49
|
+
});
|
|
50
|
+
return guarded;
|
|
51
|
+
}, held.notices, isClosed, false, () => {
|
|
52
|
+
counters.reservedBusy += 1;
|
|
53
|
+
}, () => {
|
|
54
|
+
counters.reservedBusy = Math.max(0, counters.reservedBusy - 1);
|
|
55
|
+
}, local);
|
|
56
|
+
const guard = (run) => lost ? rejectClosed() : run();
|
|
57
|
+
let released = false;
|
|
58
|
+
return {
|
|
59
|
+
execute: (text, params, options) => {
|
|
60
|
+
const refused = noTimeout(options);
|
|
61
|
+
if (refused !== undefined)
|
|
62
|
+
return refused;
|
|
63
|
+
return guard(() => runCall(isClosed(), options, (watch) => session.query(text, params, watch)));
|
|
64
|
+
},
|
|
65
|
+
batch: (statements, options) => {
|
|
66
|
+
const refused = noTimeout(options);
|
|
67
|
+
if (refused !== undefined)
|
|
68
|
+
return refused;
|
|
69
|
+
return guard(() => runCall(isClosed(), options, async (watch) => {
|
|
70
|
+
const { runAtomicBatch } = await import("./gqwevek4.js");
|
|
71
|
+
return runAtomicBatch(session, statements, watch);
|
|
72
|
+
}));
|
|
73
|
+
},
|
|
74
|
+
async release() {
|
|
75
|
+
if (released)
|
|
76
|
+
return;
|
|
77
|
+
released = true;
|
|
78
|
+
try {
|
|
79
|
+
if (!lost)
|
|
80
|
+
await reset(session, client);
|
|
81
|
+
} finally {
|
|
82
|
+
counters.reserved = Math.max(0, counters.reserved - 1);
|
|
83
|
+
events.removeListener("error", onError);
|
|
84
|
+
client.release(lost);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async function reset(session, client) {
|
|
90
|
+
await resetSession2(session.depth(), (text) => client.query(text));
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
checkout
|
|
94
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
markClientPool2,
|
|
3
|
+
open2,
|
|
4
|
+
send2,
|
|
5
|
+
reserve2,
|
|
6
|
+
park2
|
|
7
|
+
} from "./rcywj2w8.js";
|
|
8
|
+
import {
|
|
9
|
+
BUNSQL_CAPABILITIES,
|
|
10
|
+
readCapability2,
|
|
11
|
+
hasCapability2
|
|
12
|
+
} from "./5x3pf400.js";
|
|
13
|
+
export {
|
|
14
|
+
BUNSQL_CAPABILITIES as capabilities,
|
|
15
|
+
hasCapability2 as hasCapability,
|
|
16
|
+
markClientPool2 as markClientPool,
|
|
17
|
+
open2 as open,
|
|
18
|
+
park2 as park,
|
|
19
|
+
readCapability2 as readCapability,
|
|
20
|
+
reserve2 as reserve,
|
|
21
|
+
send2 as send
|
|
22
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
open3,
|
|
3
|
+
PgSession2
|
|
4
|
+
} from "./62fxpc1p.js";
|
|
5
|
+
import {
|
|
6
|
+
POSTGRESJS_CAPABILITIES,
|
|
7
|
+
readCapability2,
|
|
8
|
+
hasCapability2
|
|
9
|
+
} from "./5x3pf400.js";
|
|
10
|
+
export {
|
|
11
|
+
PgSession2 as PgSession,
|
|
12
|
+
POSTGRESJS_CAPABILITIES as capabilities,
|
|
13
|
+
hasCapability2 as hasCapability,
|
|
14
|
+
open3 as open,
|
|
15
|
+
readCapability2 as readCapability
|
|
16
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/runtime/tx.ts
|
|
2
|
+
async function runWrite(host, statements, options, atomic) {
|
|
3
|
+
if (statements.length === 0)
|
|
4
|
+
return [];
|
|
5
|
+
const first = statements[0];
|
|
6
|
+
const limit = options?.timeout ?? host.timeouts?.statement;
|
|
7
|
+
const call = limit === undefined || limit === options?.timeout ? options : { ...options, timeout: limit };
|
|
8
|
+
const single = statements.length === 1 && first !== undefined && atomic === undefined;
|
|
9
|
+
const watched = host.hookm !== undefined && !single && host.tx === undefined ? await import("./96ps4g1z.js") : undefined;
|
|
10
|
+
watched?.phase(host.hookm, "start", 0);
|
|
11
|
+
let results;
|
|
12
|
+
try {
|
|
13
|
+
results = single ? [await host.pool.execute(first.text, first.params, call)] : await host.pool.batch(statements, call);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
watched?.phase(host.hookm, "rollback", 0);
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
watched?.phase(host.hookm, "commit", 0);
|
|
19
|
+
if (host.hookm !== undefined) {
|
|
20
|
+
const heard = results.flatMap((result) => result.notices);
|
|
21
|
+
if (heard.length > 0)
|
|
22
|
+
(await import("./96ps4g1z.js")).notices(host.hookm, heard);
|
|
23
|
+
}
|
|
24
|
+
return results;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { runWrite };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
open3
|
|
3
|
+
} from "./62fxpc1p.js";
|
|
4
|
+
import {
|
|
5
|
+
createClient
|
|
6
|
+
} from "./jr2nmr81.js";
|
|
7
|
+
|
|
8
|
+
// src/runtime/pg/postgresjs.ts
|
|
9
|
+
function connect(target, options) {
|
|
10
|
+
if (typeof target === "object" && !isPool(target)) {
|
|
11
|
+
return import("./kbqnrs1x.js").then((mod) => mod.default(target, options, open3));
|
|
12
|
+
}
|
|
13
|
+
const owned = !isPool(target);
|
|
14
|
+
const pool = isPool(target) ? target : open3({
|
|
15
|
+
url: target,
|
|
16
|
+
...options.max !== undefined ? { max: options.max } : {},
|
|
17
|
+
...options.timeouts !== undefined ? { timeouts: options.timeouts } : {},
|
|
18
|
+
...options.prepared !== undefined ? { prepared: options.prepared } : {},
|
|
19
|
+
...options.searchPath !== undefined ? { searchPath: options.searchPath } : {},
|
|
20
|
+
...options.ssl !== undefined ? { ssl: options.ssl } : {}
|
|
21
|
+
});
|
|
22
|
+
return createClient(options.schema, pool, {
|
|
23
|
+
ownsPool: owned,
|
|
24
|
+
http: options.errors?.http,
|
|
25
|
+
includeValues: options.errors?.includeValues,
|
|
26
|
+
logger: options.logger,
|
|
27
|
+
signal: options.signal,
|
|
28
|
+
timeout: options.timeout,
|
|
29
|
+
timeouts: options.timeouts,
|
|
30
|
+
hookm: options.hookm,
|
|
31
|
+
catalog: options.catalog,
|
|
32
|
+
catalogDir: options.catalogDir,
|
|
33
|
+
requireMeta: options.requireMeta,
|
|
34
|
+
generators: options.generators
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function isPool(target) {
|
|
38
|
+
return typeof target === "object" && "execute" in target && "capabilities" in target;
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
connect
|
|
42
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OkmError,
|
|
3
|
+
catalogFileText2
|
|
4
|
+
} from "./hfq3n3bd.js";
|
|
5
|
+
import {
|
|
6
|
+
artifactDir,
|
|
7
|
+
readText
|
|
8
|
+
} from "./dhatassp.js";
|
|
9
|
+
|
|
10
|
+
// src/runtime/drift.ts
|
|
11
|
+
async function assertCompatible(pool, schema, recordedHash, source, options, namespace = "public") {
|
|
12
|
+
const code = await codeHash(schema, source);
|
|
13
|
+
if (code.hash === recordedHash)
|
|
14
|
+
return;
|
|
15
|
+
const { loadOnce } = await import("./htnaj77v.js");
|
|
16
|
+
if (code.artifact !== undefined) {
|
|
17
|
+
const artifact = code.artifact;
|
|
18
|
+
await loadOnce(`text\x00${artifact.hash}`, async () => {
|
|
19
|
+
const { loadTrustedCatalog } = await import("./yb4kd19s.js");
|
|
20
|
+
loadTrustedCatalog(artifact.text, artifact.hash);
|
|
21
|
+
});
|
|
22
|
+
} else if (code.fromFile) {
|
|
23
|
+
const dir = artifactDir(source.catalogDir);
|
|
24
|
+
await loadOnce(`file\x00${dir}\x00${code.hash}`, async () => {
|
|
25
|
+
const text = await readText(`${dir}/catalog.json`);
|
|
26
|
+
if (text === undefined) {
|
|
27
|
+
throw new OkmError("OKM1027", `${dir}/catalog.json is missing.`, {
|
|
28
|
+
fix: {
|
|
29
|
+
summary: "Run okm build so catalog.json matches catalog.hash. connect does not rebuild the catalog from the schema."
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const { loadTrustedCatalog } = await import("./yb4kd19s.js");
|
|
34
|
+
loadTrustedCatalog(text, code.hash);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const { assertDrift } = await import("./6vk28rjp.js");
|
|
38
|
+
await assertDrift(pool, code.hash, recordedHash, options, namespace);
|
|
39
|
+
}
|
|
40
|
+
async function codeHash(schema, source) {
|
|
41
|
+
if (source.catalog !== undefined) {
|
|
42
|
+
return { hash: source.catalog.hash, artifact: source.catalog, fromFile: false };
|
|
43
|
+
}
|
|
44
|
+
const listed = await readHashFile(source.catalogDir);
|
|
45
|
+
if (listed !== undefined)
|
|
46
|
+
return { hash: listed, fromFile: true };
|
|
47
|
+
const { catalogHash } = await import("./yb4kd19s.js");
|
|
48
|
+
return { hash: catalogHash(schemaCatalog(schema)), fromFile: false };
|
|
49
|
+
}
|
|
50
|
+
function schemaCatalog(schema) {
|
|
51
|
+
const value = Reflect.get(schema, "catalog");
|
|
52
|
+
if (typeof value !== "object" || value === null || !("objects" in value)) {
|
|
53
|
+
throw new OkmError("OKM1520", "The schema has no catalog to compare.", {
|
|
54
|
+
fix: {
|
|
55
|
+
summary: "Pass the schema() result to connect, or a catalog artifact from okm build."
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
async function readHashFile(catalogDir) {
|
|
62
|
+
const text = await readText(`${artifactDir(catalogDir)}/catalog.hash`);
|
|
63
|
+
if (text === undefined)
|
|
64
|
+
return;
|
|
65
|
+
const hash = catalogFileText2(text, "catalog.hash").trim();
|
|
66
|
+
return hash.length === 0 ? undefined : hash;
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
assertCompatible
|
|
70
|
+
};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DriverError2
|
|
3
|
+
} from "./hfq3n3bd.js";
|
|
4
|
+
import {
|
|
5
|
+
noticeBuffer,
|
|
6
|
+
WireSession
|
|
7
|
+
} from "./jsjjz875.js";
|
|
8
|
+
import {
|
|
9
|
+
noTimeout
|
|
10
|
+
} from "./3yn79q5m.js";
|
|
11
|
+
import {
|
|
12
|
+
BUNSQL_CAPABILITIES,
|
|
13
|
+
driverErrors,
|
|
14
|
+
rejectClosed,
|
|
15
|
+
mapFailure,
|
|
16
|
+
runCall
|
|
17
|
+
} from "./5x3pf400.js";
|
|
18
|
+
|
|
19
|
+
// src/adapters/pg/bunsql.ts
|
|
20
|
+
import { SQL as BunSQL } from "bun";
|
|
21
|
+
var clientPools = new WeakSet;
|
|
22
|
+
function markClientPool2(pool) {
|
|
23
|
+
clientPools.add(pool);
|
|
24
|
+
}
|
|
25
|
+
function open2(config) {
|
|
26
|
+
const max = config.max ?? 10;
|
|
27
|
+
const acquireMs = config.timeouts?.acquire;
|
|
28
|
+
const counters = { reserved: 0, busy: 0, reservedBusy: 0, waiting: 0 };
|
|
29
|
+
const notices = noticeBuffer();
|
|
30
|
+
let closed = false;
|
|
31
|
+
const isClosed = () => closed;
|
|
32
|
+
const named = config.prepared === "named";
|
|
33
|
+
const parked = [];
|
|
34
|
+
let dropped = 0;
|
|
35
|
+
let closures = 0;
|
|
36
|
+
const sql = new BunSQL(config.url, {
|
|
37
|
+
max,
|
|
38
|
+
idleTimeout: 0,
|
|
39
|
+
maxLifetime: 0,
|
|
40
|
+
prepare: named,
|
|
41
|
+
bigint: false,
|
|
42
|
+
connectionTimeout: 5,
|
|
43
|
+
connection: {
|
|
44
|
+
application_name: "okmodel",
|
|
45
|
+
...config.searchPath !== undefined ? { search_path: config.searchPath } : {}
|
|
46
|
+
},
|
|
47
|
+
...config.ssl !== undefined ? { tls: config.ssl } : {},
|
|
48
|
+
onclose() {
|
|
49
|
+
dropped += 1;
|
|
50
|
+
closures += 1;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const root = new WireSession((text, params) => send2(sql, text, params), notices, isClosed, false, () => {
|
|
54
|
+
counters.busy += 1;
|
|
55
|
+
}, () => {
|
|
56
|
+
counters.busy = Math.max(0, counters.busy - 1);
|
|
57
|
+
});
|
|
58
|
+
const held = {
|
|
59
|
+
sql,
|
|
60
|
+
parked,
|
|
61
|
+
acquireMs,
|
|
62
|
+
counters,
|
|
63
|
+
notices,
|
|
64
|
+
isClosed,
|
|
65
|
+
closures: () => closures
|
|
66
|
+
};
|
|
67
|
+
const run = (text, params, watch) => {
|
|
68
|
+
const sent = dropped;
|
|
69
|
+
return root.query(text, params, watch).catch((error) => import("./8yr7ges1.js").then((mod) => mod.recover(sql, error, text, root.depth(), clientPools.has(pool), dropped > sent, () => root.query(text, params, watch))));
|
|
70
|
+
};
|
|
71
|
+
const afterDrop = (text, params, watch) => {
|
|
72
|
+
if (dropped === 0)
|
|
73
|
+
return run(text, params, watch);
|
|
74
|
+
const seen = dropped;
|
|
75
|
+
return import("./8yr7ges1.js").then((mod) => mod.drainClosed(sql).then(() => {
|
|
76
|
+
if (dropped === seen)
|
|
77
|
+
dropped = 0;
|
|
78
|
+
return run(text, params, watch);
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
const checkout = () => closed ? rejectClosed() : import("./8yr7ges1.js").then((mod) => mod.checkout(held));
|
|
82
|
+
const pool = {
|
|
83
|
+
capabilities: BUNSQL_CAPABILITIES,
|
|
84
|
+
execute(text, params, options) {
|
|
85
|
+
const refused = noTimeout(options);
|
|
86
|
+
if (refused !== undefined)
|
|
87
|
+
return refused;
|
|
88
|
+
return runCall(closed, options, (watch) => releaseParked(parked).then(() => afterDrop(text, params, watch)));
|
|
89
|
+
},
|
|
90
|
+
async batch(statements, options) {
|
|
91
|
+
const refused = noTimeout(options);
|
|
92
|
+
if (refused !== undefined)
|
|
93
|
+
return refused;
|
|
94
|
+
const connection = await checkout();
|
|
95
|
+
try {
|
|
96
|
+
return await connection.batch(statements, options);
|
|
97
|
+
} finally {
|
|
98
|
+
await connection.release();
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
reserve: () => checkout(),
|
|
102
|
+
stream(text, params) {
|
|
103
|
+
return async function* () {
|
|
104
|
+
const { streamRows } = await import("./8yr7ges1.js");
|
|
105
|
+
yield* streamRows(checkout, text, params);
|
|
106
|
+
}();
|
|
107
|
+
},
|
|
108
|
+
listen(channel, onNotify) {
|
|
109
|
+
return import("./8yr7ges1.js").then((mod) => mod.listen(sql, parked, closed, channel, onNotify));
|
|
110
|
+
},
|
|
111
|
+
stats: () => statsOf(counters, max),
|
|
112
|
+
async close() {
|
|
113
|
+
closed = true;
|
|
114
|
+
await releaseParked(parked);
|
|
115
|
+
await sql.close();
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return pool;
|
|
119
|
+
}
|
|
120
|
+
function send2(sql, text, params) {
|
|
121
|
+
const refused = refuseInt8(params);
|
|
122
|
+
if (refused !== undefined)
|
|
123
|
+
return refused;
|
|
124
|
+
if (params === undefined || params.length === 0)
|
|
125
|
+
return sql.unsafe(text).raw();
|
|
126
|
+
return sql.unsafe(text, [...params]).raw();
|
|
127
|
+
}
|
|
128
|
+
function refuseInt8(params) {
|
|
129
|
+
if (params === undefined)
|
|
130
|
+
return;
|
|
131
|
+
for (const value of params) {
|
|
132
|
+
if (value === null || value.length < 19 || !/^-?(?:0|[1-9]\d*)$/.test(value))
|
|
133
|
+
continue;
|
|
134
|
+
const parsed = BigInt(value);
|
|
135
|
+
if (parsed > 9223372036854775807n || parsed < -9223372036854775808n) {
|
|
136
|
+
return Promise.reject(new DriverError2("bigint out of range", { sqlstate: "22003" }));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
async function reserve2(sql, acquireMs, counters) {
|
|
142
|
+
counters.waiting += 1;
|
|
143
|
+
try {
|
|
144
|
+
if (acquireMs === undefined)
|
|
145
|
+
return await sql.reserve();
|
|
146
|
+
return await sql.reserve({ signal: AbortSignal.timeout(acquireMs) });
|
|
147
|
+
} catch (error) {
|
|
148
|
+
if (isAbort(error)) {
|
|
149
|
+
const errors = await driverErrors();
|
|
150
|
+
throw errors.acquireTimeout();
|
|
151
|
+
}
|
|
152
|
+
throw await mapFailure(error);
|
|
153
|
+
} finally {
|
|
154
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async function park2(parked, reserved) {
|
|
158
|
+
parked.push(reserved);
|
|
159
|
+
while (parked.length > 1) {
|
|
160
|
+
const extra = parked.shift();
|
|
161
|
+
if (extra !== undefined)
|
|
162
|
+
await releaseReserved(extra);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async function releaseParked(parked) {
|
|
166
|
+
const pending = parked.splice(0);
|
|
167
|
+
for (const reserved of pending)
|
|
168
|
+
await releaseReserved(reserved);
|
|
169
|
+
}
|
|
170
|
+
function releaseReserved(reserved) {
|
|
171
|
+
const done = reserved.release();
|
|
172
|
+
return done instanceof Promise ? done.then(() => {
|
|
173
|
+
return;
|
|
174
|
+
}) : Promise.resolve();
|
|
175
|
+
}
|
|
176
|
+
function isAbort(error) {
|
|
177
|
+
if (!(error instanceof Error))
|
|
178
|
+
return false;
|
|
179
|
+
return error.name === "AbortError" || error.name === "TimeoutError";
|
|
180
|
+
}
|
|
181
|
+
function statsOf(counters, size) {
|
|
182
|
+
return {
|
|
183
|
+
size,
|
|
184
|
+
idle: Math.max(0, size - counters.reserved - counters.busy),
|
|
185
|
+
inflight: counters.busy + counters.reservedBusy,
|
|
186
|
+
waiting: counters.waiting
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export { markClientPool2, open2, send2, reserve2, park2 };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
open6,
|
|
3
|
+
seal2
|
|
4
|
+
} from "./t6zjeake.js";
|
|
5
|
+
import {
|
|
6
|
+
PGLITE_CAPABILITIES,
|
|
7
|
+
readCapability2,
|
|
8
|
+
hasCapability2
|
|
9
|
+
} from "./5x3pf400.js";
|
|
10
|
+
export {
|
|
11
|
+
PGLITE_CAPABILITIES as capabilities,
|
|
12
|
+
hasCapability2 as hasCapability,
|
|
13
|
+
open6 as open,
|
|
14
|
+
readCapability2 as readCapability,
|
|
15
|
+
seal2 as seal
|
|
16
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runWrite
|
|
3
|
+
} from "./n4jqhpqz.js";
|
|
4
|
+
import {
|
|
5
|
+
refuseUncancellableTimeout
|
|
6
|
+
} from "./tcwpjvxe.js";
|
|
7
|
+
import {
|
|
8
|
+
withHttp,
|
|
9
|
+
settleCall
|
|
10
|
+
} from "./jr2nmr81.js";
|
|
11
|
+
import {
|
|
12
|
+
OkmError,
|
|
13
|
+
rejectKeys,
|
|
14
|
+
isRecord,
|
|
15
|
+
fail2
|
|
16
|
+
} from "./hfq3n3bd.js";
|
|
17
|
+
|
|
18
|
+
// src/runtime/batch.ts
|
|
19
|
+
async function batch(session, ops, options, replica) {
|
|
20
|
+
try {
|
|
21
|
+
if (replica !== undefined) {
|
|
22
|
+
throw new OkmError("OKM1840", "batch() needs the primary. .replica() is not allowed on a batch.", withHttp(session.http, {
|
|
23
|
+
fix: { summary: "Remove .replica(). A batch always runs on the primary." }
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
if (!Array.isArray(ops))
|
|
27
|
+
fail2("OKM1121", "batch expects a list of write operations.");
|
|
28
|
+
const record = options ?? {};
|
|
29
|
+
if (!isRecord(record))
|
|
30
|
+
fail2("OKM1121", "batch options must be an object.");
|
|
31
|
+
rejectKeys(record, ["signal", "timeout"], "batch");
|
|
32
|
+
await refuseUncancellableTimeout(session.pool, typeof record["timeout"] === "number" ? record["timeout"] : undefined);
|
|
33
|
+
for (const op of ops) {
|
|
34
|
+
if (typeof op === "object" && op !== null && op["~refresh"] === true) {
|
|
35
|
+
fail2("OKM1121", "batch does not take refresh(). Await refresh() on its own. It is one statement and cannot share the batch.");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const prepared = [];
|
|
39
|
+
for (const op of ops) {
|
|
40
|
+
const plan = typeof op === "object" && op !== null ? op["~plan"] : undefined;
|
|
41
|
+
if (plan === undefined) {
|
|
42
|
+
fail2("OKM1121", "batch takes write operations: insert, update, delete, and archive. Pass them without awaiting.");
|
|
43
|
+
}
|
|
44
|
+
const item = await plan();
|
|
45
|
+
if (item.checked === "parent") {
|
|
46
|
+
throw new OkmError("OKM1705", "batch does not take an update that sets a path column. The parent is checked in the statement, and a batch cannot report that after it commits. Use update({ where, set }) inside tx().", { fix: { summary: "Use update({ where, set }) inside tx()." } });
|
|
47
|
+
}
|
|
48
|
+
if (item.checked !== undefined) {
|
|
49
|
+
fail2("OKM1121", item.checked === "restore" ? "batch does not take restore: it is refused while its parent is archived, and a batch cannot report that after it commits. Use tx()." : "batch does not take a write with expect: the count is checked after the statement ran, and a batch cannot report that after it commits. Use tx().");
|
|
50
|
+
}
|
|
51
|
+
prepared.push(item);
|
|
52
|
+
}
|
|
53
|
+
return await run(session, prepared, record);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return settleCall(session, error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function run(session, prepared, options) {
|
|
59
|
+
await session.connected;
|
|
60
|
+
const statements = [];
|
|
61
|
+
const starts = [];
|
|
62
|
+
for (const item of prepared) {
|
|
63
|
+
starts.push(statements.length);
|
|
64
|
+
statements.push(...item.statements);
|
|
65
|
+
}
|
|
66
|
+
if (statements.length === 0)
|
|
67
|
+
return prepared.map((item) => item.finish([]));
|
|
68
|
+
let results;
|
|
69
|
+
try {
|
|
70
|
+
results = await runWrite(session, statements, call(options), true);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
throw at(error, starts);
|
|
73
|
+
}
|
|
74
|
+
const extra = await recover(session, prepared, results, starts, options);
|
|
75
|
+
return prepared.map((item, index) => {
|
|
76
|
+
const from = starts[index] ?? 0;
|
|
77
|
+
const slice = results.slice(from, from + item.statements.length);
|
|
78
|
+
const more = extra.get(index);
|
|
79
|
+
return item.finish(more === undefined ? slice : slice.concat(more));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async function recover(session, prepared, results, starts, options) {
|
|
83
|
+
const pending = [];
|
|
84
|
+
for (let index = 0;index < prepared.length; index += 1) {
|
|
85
|
+
const item = prepared[index];
|
|
86
|
+
if (item?.follow === undefined)
|
|
87
|
+
continue;
|
|
88
|
+
const from = starts[index] ?? 0;
|
|
89
|
+
const more = item.follow(results.slice(from, from + item.statements.length));
|
|
90
|
+
if (more.length === 0)
|
|
91
|
+
continue;
|
|
92
|
+
pending.push({ index, statements: more });
|
|
93
|
+
}
|
|
94
|
+
const found = new Map;
|
|
95
|
+
if (pending.length === 0)
|
|
96
|
+
return found;
|
|
97
|
+
const flat = [];
|
|
98
|
+
const extraStarts = [];
|
|
99
|
+
for (const item of pending) {
|
|
100
|
+
extraStarts.push(flat.length);
|
|
101
|
+
flat.push(...item.statements);
|
|
102
|
+
}
|
|
103
|
+
let ran;
|
|
104
|
+
try {
|
|
105
|
+
ran = await runWrite(session, flat, call(options), true);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
throw mapExtra(error, pending, extraStarts);
|
|
108
|
+
}
|
|
109
|
+
for (let index = 0;index < pending.length; index += 1) {
|
|
110
|
+
const item = pending[index];
|
|
111
|
+
if (item === undefined)
|
|
112
|
+
continue;
|
|
113
|
+
const from = extraStarts[index] ?? 0;
|
|
114
|
+
found.set(item.index, ran.slice(from, extraStarts[index + 1] ?? ran.length));
|
|
115
|
+
}
|
|
116
|
+
return found;
|
|
117
|
+
}
|
|
118
|
+
function mapExtra(error, pending, extraStarts) {
|
|
119
|
+
const failed = error?.batchIndex;
|
|
120
|
+
const move = error?.at;
|
|
121
|
+
if (typeof failed !== "number" || typeof move !== "function")
|
|
122
|
+
return error;
|
|
123
|
+
let slot = 0;
|
|
124
|
+
while (slot + 1 < extraStarts.length && (extraStarts[slot + 1] ?? Infinity) <= failed)
|
|
125
|
+
slot += 1;
|
|
126
|
+
const op = pending[slot]?.index ?? slot;
|
|
127
|
+
return op === failed ? error : move.call(error, op);
|
|
128
|
+
}
|
|
129
|
+
function call(options) {
|
|
130
|
+
const { signal, timeout } = options;
|
|
131
|
+
if (signal === undefined && timeout === undefined)
|
|
132
|
+
return;
|
|
133
|
+
return {
|
|
134
|
+
...signal !== undefined ? { signal } : {},
|
|
135
|
+
...typeof timeout === "number" ? { timeout } : {}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function at(error, starts) {
|
|
139
|
+
const failed = error?.batchIndex;
|
|
140
|
+
const move = error?.at;
|
|
141
|
+
if (typeof failed !== "number" || typeof move !== "function")
|
|
142
|
+
return error;
|
|
143
|
+
let index = 0;
|
|
144
|
+
while (index + 1 < starts.length && (starts[index + 1] ?? Infinity) <= failed)
|
|
145
|
+
index += 1;
|
|
146
|
+
return index === failed ? error : move.call(error, index);
|
|
147
|
+
}
|
|
148
|
+
export {
|
|
149
|
+
batch
|
|
150
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OkmError,
|
|
3
|
+
DriverError2
|
|
4
|
+
} from "./hfq3n3bd.js";
|
|
5
|
+
|
|
6
|
+
// src/adapters/lazy-errors.ts
|
|
7
|
+
function refused() {
|
|
8
|
+
return Promise.reject(new OkmError("OKM1120", "timeout"));
|
|
9
|
+
}
|
|
10
|
+
function closed() {
|
|
11
|
+
return Promise.reject(new DriverError2("The pool is closed.", { sqlstate: "08006" }));
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
closed,
|
|
15
|
+
refused
|
|
16
|
+
};
|