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,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DriverError2,
|
|
3
|
+
cancelled2,
|
|
4
|
+
timedOut2,
|
|
5
|
+
outcomeUnknown2,
|
|
6
|
+
acquireTimeout2,
|
|
7
|
+
errorField2,
|
|
8
|
+
mapDriverError2
|
|
9
|
+
} from "./hfq3n3bd.js";
|
|
10
|
+
export {
|
|
11
|
+
DriverError2 as DriverError,
|
|
12
|
+
acquireTimeout2 as acquireTimeout,
|
|
13
|
+
cancelled2 as cancelled,
|
|
14
|
+
errorField2 as errorField,
|
|
15
|
+
mapDriverError2 as mapDriverError,
|
|
16
|
+
outcomeUnknown2 as outcomeUnknown,
|
|
17
|
+
timedOut2 as timedOut
|
|
18
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
armDriverError2,
|
|
3
|
+
open4,
|
|
4
|
+
send3,
|
|
5
|
+
connectClient2
|
|
6
|
+
} from "./asgr07mp.js";
|
|
7
|
+
import {
|
|
8
|
+
NODE_POSTGRES_CAPABILITIES,
|
|
9
|
+
readCapability2,
|
|
10
|
+
hasCapability2
|
|
11
|
+
} from "./5x3pf400.js";
|
|
12
|
+
export {
|
|
13
|
+
armDriverError2 as armDriverError,
|
|
14
|
+
NODE_POSTGRES_CAPABILITIES as capabilities,
|
|
15
|
+
connectClient2 as connectClient,
|
|
16
|
+
hasCapability2 as hasCapability,
|
|
17
|
+
open4 as open,
|
|
18
|
+
readCapability2 as readCapability,
|
|
19
|
+
send3 as send
|
|
20
|
+
};
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import {
|
|
2
|
+
outcomeUnknown2
|
|
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
|
+
NEON_WEBSOCKET_CAPABILITIES,
|
|
13
|
+
NEON_HTTP_CAPABILITIES,
|
|
14
|
+
driverErrors,
|
|
15
|
+
rejectClosed,
|
|
16
|
+
mapFailure,
|
|
17
|
+
runCall,
|
|
18
|
+
EMPTY_NOTICES,
|
|
19
|
+
resultFrom
|
|
20
|
+
} from "./5x3pf400.js";
|
|
21
|
+
|
|
22
|
+
// src/adapters/pg/neon.ts
|
|
23
|
+
import {
|
|
24
|
+
Pool,
|
|
25
|
+
neon,
|
|
26
|
+
neonConfig
|
|
27
|
+
} from "@neondatabase/serverless";
|
|
28
|
+
var CONNECT_MS = 30000;
|
|
29
|
+
var WIRE = {
|
|
30
|
+
getTypeParser() {
|
|
31
|
+
return (value) => value;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var names = new Map;
|
|
35
|
+
async function open5(config) {
|
|
36
|
+
if (config.mode === "http")
|
|
37
|
+
return openHttp(config);
|
|
38
|
+
return openWebSocket(config);
|
|
39
|
+
}
|
|
40
|
+
function connectClient3(pool, acquireMs, counters) {
|
|
41
|
+
counters.waiting += 1;
|
|
42
|
+
let settled = false;
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
let timer;
|
|
45
|
+
if (acquireMs !== undefined) {
|
|
46
|
+
timer = setTimeout(() => {
|
|
47
|
+
settled = true;
|
|
48
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
49
|
+
driverErrors().then((errors) => {
|
|
50
|
+
reject(errors.acquireTimeout());
|
|
51
|
+
});
|
|
52
|
+
}, acquireMs);
|
|
53
|
+
}
|
|
54
|
+
take(pool).then((client) => {
|
|
55
|
+
if (settled) {
|
|
56
|
+
client.release();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (timer !== undefined)
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
62
|
+
resolve(client);
|
|
63
|
+
}, (error) => {
|
|
64
|
+
if (settled)
|
|
65
|
+
return;
|
|
66
|
+
if (timer !== undefined)
|
|
67
|
+
clearTimeout(timer);
|
|
68
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
69
|
+
mapFailure(error).then(reject);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function send4(runner, text, params, named) {
|
|
74
|
+
const query = {
|
|
75
|
+
text,
|
|
76
|
+
rowMode: "array",
|
|
77
|
+
types: WIRE,
|
|
78
|
+
...params !== undefined && params.length > 0 ? { values: params } : {},
|
|
79
|
+
...named ? { name: statementName(text) } : {}
|
|
80
|
+
};
|
|
81
|
+
return runner.query(query);
|
|
82
|
+
}
|
|
83
|
+
async function openWebSocket(config) {
|
|
84
|
+
ensureWebSocket();
|
|
85
|
+
const max = config.max ?? 10;
|
|
86
|
+
const acquireMs = config.timeouts?.acquire;
|
|
87
|
+
const counters = { reserved: 0, busy: 0, reservedBusy: 0, waiting: 0 };
|
|
88
|
+
const notices = noticeBuffer();
|
|
89
|
+
let closed = false;
|
|
90
|
+
const isClosed = () => closed;
|
|
91
|
+
const named = config.prepared === "named";
|
|
92
|
+
const pool = new Pool({
|
|
93
|
+
connectionString: config.url,
|
|
94
|
+
max,
|
|
95
|
+
idleTimeoutMillis: 0,
|
|
96
|
+
allowExitOnIdle: true,
|
|
97
|
+
connectionTimeoutMillis: CONNECT_MS,
|
|
98
|
+
application_name: "okmodel",
|
|
99
|
+
types: WIRE,
|
|
100
|
+
...config.searchPath !== undefined ? { options: `-c search_path=${config.searchPath}` } : {}
|
|
101
|
+
});
|
|
102
|
+
pool.on("error", () => {
|
|
103
|
+
return;
|
|
104
|
+
});
|
|
105
|
+
try {
|
|
106
|
+
const warmed = await take(pool);
|
|
107
|
+
warmed.release();
|
|
108
|
+
} catch (error) {
|
|
109
|
+
await pool.end().catch(() => {
|
|
110
|
+
return;
|
|
111
|
+
});
|
|
112
|
+
throw await mapFailure(error);
|
|
113
|
+
}
|
|
114
|
+
const root = new WireSession((text, params) => send4(pool, text, params, named), notices, isClosed, false, () => {
|
|
115
|
+
counters.busy += 1;
|
|
116
|
+
}, () => {
|
|
117
|
+
counters.busy = Math.max(0, counters.busy - 1);
|
|
118
|
+
});
|
|
119
|
+
const held = { pool, acquireMs, counters, notices, named, isClosed };
|
|
120
|
+
const checkout = () => closed ? rejectClosed() : import("./kz715295.js").then((mod) => mod.checkout(held));
|
|
121
|
+
return {
|
|
122
|
+
capabilities: NEON_WEBSOCKET_CAPABILITIES,
|
|
123
|
+
execute(text, params, options) {
|
|
124
|
+
const refused = noTimeout(options);
|
|
125
|
+
if (refused !== undefined)
|
|
126
|
+
return refused;
|
|
127
|
+
return runCall(closed, options, (watch) => root.query(text, params, watch));
|
|
128
|
+
},
|
|
129
|
+
async batch(statements, options) {
|
|
130
|
+
const refused = noTimeout(options);
|
|
131
|
+
if (refused !== undefined)
|
|
132
|
+
return refused;
|
|
133
|
+
const connection = await checkout();
|
|
134
|
+
try {
|
|
135
|
+
return await connection.batch(statements, options);
|
|
136
|
+
} finally {
|
|
137
|
+
await connection.release();
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
reserve: () => checkout(),
|
|
141
|
+
stats: () => statsOf(counters, max),
|
|
142
|
+
async close() {
|
|
143
|
+
closed = true;
|
|
144
|
+
await pool.end();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function openHttp(config) {
|
|
149
|
+
const max = config.max ?? 10;
|
|
150
|
+
const counters = { reserved: 0, busy: 0, reservedBusy: 0, waiting: 0 };
|
|
151
|
+
let closed = false;
|
|
152
|
+
const sql = neon(config.url, { arrayMode: true, fullResults: true });
|
|
153
|
+
const run = async (text, params) => {
|
|
154
|
+
counters.busy += 1;
|
|
155
|
+
try {
|
|
156
|
+
const result = await sql.query(text, params === undefined ? [] : [...params]);
|
|
157
|
+
return resultFrom(result, EMPTY_NOTICES);
|
|
158
|
+
} finally {
|
|
159
|
+
counters.busy = Math.max(0, counters.busy - 1);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
capabilities: NEON_HTTP_CAPABILITIES,
|
|
164
|
+
execute(text, params, options) {
|
|
165
|
+
const refused = noTimeout(options);
|
|
166
|
+
if (refused !== undefined)
|
|
167
|
+
return refused;
|
|
168
|
+
if (closed)
|
|
169
|
+
return rejectClosed();
|
|
170
|
+
return runCall(closed, options, () => run(text, params).catch((error) => mapFailure(error).then((mapped) => Promise.reject(mapped))));
|
|
171
|
+
},
|
|
172
|
+
async batch(statements, options) {
|
|
173
|
+
const refused = noTimeout(options);
|
|
174
|
+
if (refused !== undefined)
|
|
175
|
+
return refused;
|
|
176
|
+
if (closed)
|
|
177
|
+
return rejectClosed();
|
|
178
|
+
counters.busy += 1;
|
|
179
|
+
try {
|
|
180
|
+
const queries = statements.map((statement) => sql.query(statement.text, statement.params === undefined ? [] : [...statement.params]));
|
|
181
|
+
const results = await sql.transaction(queries, httpOptions());
|
|
182
|
+
return results.map((result) => resultFrom(result, EMPTY_NOTICES));
|
|
183
|
+
} catch (error) {
|
|
184
|
+
if (!isDatabaseError(error))
|
|
185
|
+
throw outcomeUnknown2(error);
|
|
186
|
+
throw await mapFailure(error);
|
|
187
|
+
} finally {
|
|
188
|
+
counters.busy = Math.max(0, counters.busy - 1);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
stats: () => statsOf(counters, max),
|
|
192
|
+
close() {
|
|
193
|
+
closed = true;
|
|
194
|
+
return Promise.resolve();
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function httpOptions() {
|
|
199
|
+
return { arrayMode: true, fullResults: true };
|
|
200
|
+
}
|
|
201
|
+
function isDatabaseError(error) {
|
|
202
|
+
if (typeof error !== "object" || error === null)
|
|
203
|
+
return false;
|
|
204
|
+
const code = Reflect.get(error, "code");
|
|
205
|
+
return typeof code === "string" && /^[0-9A-Z]{5}$/.test(code);
|
|
206
|
+
}
|
|
207
|
+
function take(pool) {
|
|
208
|
+
const connect = pool.connect.bind(pool);
|
|
209
|
+
return connect();
|
|
210
|
+
}
|
|
211
|
+
function ensureWebSocket() {
|
|
212
|
+
if (neonConfig.webSocketConstructor === undefined && typeof WebSocket === "function") {
|
|
213
|
+
neonConfig.webSocketConstructor = WebSocket;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function statementName(text) {
|
|
217
|
+
const existing = names.get(text);
|
|
218
|
+
if (existing !== undefined)
|
|
219
|
+
return existing;
|
|
220
|
+
const name = `okm_${String(names.size)}`;
|
|
221
|
+
names.set(text, name);
|
|
222
|
+
return name;
|
|
223
|
+
}
|
|
224
|
+
function statsOf(counters, size) {
|
|
225
|
+
return {
|
|
226
|
+
size,
|
|
227
|
+
idle: Math.max(0, size - counters.reserved - counters.busy),
|
|
228
|
+
inflight: counters.busy + counters.reservedBusy,
|
|
229
|
+
waiting: counters.waiting
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export { open5, connectClient3, send4 };
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import {
|
|
2
|
+
noticeBuffer,
|
|
3
|
+
WireSession
|
|
4
|
+
} from "./jsjjz875.js";
|
|
5
|
+
import {
|
|
6
|
+
NODE_POSTGRES_CAPABILITIES,
|
|
7
|
+
driverErrors,
|
|
8
|
+
rejectClosed,
|
|
9
|
+
mapFailure,
|
|
10
|
+
runCall
|
|
11
|
+
} from "./5x3pf400.js";
|
|
12
|
+
|
|
13
|
+
// src/adapters/pg/nodepostgres.ts
|
|
14
|
+
import net from "node:net";
|
|
15
|
+
import pg from "pg";
|
|
16
|
+
var CANCEL_CODE = 80877102;
|
|
17
|
+
var identity = (value) => value;
|
|
18
|
+
function armDriverError2(source, handle = () => {}) {
|
|
19
|
+
source.on("error", handle);
|
|
20
|
+
}
|
|
21
|
+
var WIRE = {
|
|
22
|
+
getTypeParser() {
|
|
23
|
+
return identity;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
function open4(config) {
|
|
27
|
+
const max = config.max ?? 10;
|
|
28
|
+
const acquireMs = config.timeouts?.acquire;
|
|
29
|
+
const counters = { reserved: 0, busy: 0, reservedBusy: 0, waiting: 0 };
|
|
30
|
+
const inflight = new Set;
|
|
31
|
+
const notices = noticeBuffer();
|
|
32
|
+
let closed = false;
|
|
33
|
+
const isClosed = () => closed;
|
|
34
|
+
const named = config.prepared === "named";
|
|
35
|
+
const pool = new pg.Pool({
|
|
36
|
+
connectionString: config.url,
|
|
37
|
+
max,
|
|
38
|
+
idleTimeoutMillis: 0,
|
|
39
|
+
allowExitOnIdle: true,
|
|
40
|
+
connectionTimeoutMillis: 5000,
|
|
41
|
+
application_name: "okmodel",
|
|
42
|
+
types: WIRE,
|
|
43
|
+
...config.ssl !== undefined ? { ssl: config.ssl } : {},
|
|
44
|
+
...config.searchPath !== undefined ? { options: `-c search_path=${config.searchPath}` } : {}
|
|
45
|
+
});
|
|
46
|
+
armDriverError2(pool);
|
|
47
|
+
pool.on("connect", (client) => {
|
|
48
|
+
client.on("notice", (notice) => {
|
|
49
|
+
notices.push(notice);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
const root = new WireSession((text, params) => send3(pool, text, params, named, undefined), notices, isClosed, true, () => {
|
|
53
|
+
counters.busy += 1;
|
|
54
|
+
}, () => {
|
|
55
|
+
counters.busy = Math.max(0, counters.busy - 1);
|
|
56
|
+
}, inflight);
|
|
57
|
+
const held = { pool, acquireMs, counters, notices, named, isClosed };
|
|
58
|
+
const checkout = () => closed ? rejectClosed() : import("./9qr9rkbh.js").then((mod) => mod.checkout(held));
|
|
59
|
+
return {
|
|
60
|
+
capabilities: NODE_POSTGRES_CAPABILITIES,
|
|
61
|
+
execute(text, params, options) {
|
|
62
|
+
return runCall(closed, options, async (watch) => {
|
|
63
|
+
if (watch === undefined)
|
|
64
|
+
return root.query(text, params, undefined);
|
|
65
|
+
const client = await connectClient2(pool, acquireMs, counters);
|
|
66
|
+
counters.busy += 1;
|
|
67
|
+
const session = new WireSession((statement, values) => send3(client, statement, values, named, client), notices, isClosed, true, () => {
|
|
68
|
+
return;
|
|
69
|
+
}, () => {
|
|
70
|
+
return;
|
|
71
|
+
}, inflight);
|
|
72
|
+
try {
|
|
73
|
+
return await session.query(text, params, watch);
|
|
74
|
+
} finally {
|
|
75
|
+
counters.busy = Math.max(0, counters.busy - 1);
|
|
76
|
+
client.release();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
async batch(statements, options) {
|
|
81
|
+
const connection = await checkout();
|
|
82
|
+
try {
|
|
83
|
+
return await connection.batch(statements, options);
|
|
84
|
+
} finally {
|
|
85
|
+
await connection.release();
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
reserve: () => checkout(),
|
|
89
|
+
stream(text, params) {
|
|
90
|
+
return async function* () {
|
|
91
|
+
const { streamRows } = await import("./9qr9rkbh.js");
|
|
92
|
+
yield* streamRows(checkout, text, params);
|
|
93
|
+
}();
|
|
94
|
+
},
|
|
95
|
+
listen(channel, onNotify) {
|
|
96
|
+
if (closed)
|
|
97
|
+
return rejectClosed();
|
|
98
|
+
return import("./9qr9rkbh.js").then((mod) => mod.listen(held, channel, onNotify));
|
|
99
|
+
},
|
|
100
|
+
cancel() {
|
|
101
|
+
for (const pending of inflight)
|
|
102
|
+
pending.cancel?.();
|
|
103
|
+
},
|
|
104
|
+
stats: () => statsOf(counters, max),
|
|
105
|
+
async close() {
|
|
106
|
+
closed = true;
|
|
107
|
+
await pool.end();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function send3(runner, text, params, named, client) {
|
|
112
|
+
const query = {
|
|
113
|
+
text,
|
|
114
|
+
rowMode: "array",
|
|
115
|
+
types: WIRE,
|
|
116
|
+
...params !== undefined && params.length > 0 ? { values: params } : {},
|
|
117
|
+
...named ? { name: statementName(text) } : {}
|
|
118
|
+
};
|
|
119
|
+
const pending = runner.query(query);
|
|
120
|
+
if (client !== undefined)
|
|
121
|
+
pending.cancel = () => cancelBackend(client);
|
|
122
|
+
return pending;
|
|
123
|
+
}
|
|
124
|
+
var names = new Map;
|
|
125
|
+
function statementName(text) {
|
|
126
|
+
const existing = names.get(text);
|
|
127
|
+
if (existing !== undefined)
|
|
128
|
+
return existing;
|
|
129
|
+
const name = `okm_${String(names.size)}`;
|
|
130
|
+
names.set(text, name);
|
|
131
|
+
return name;
|
|
132
|
+
}
|
|
133
|
+
function cancelBackend(client) {
|
|
134
|
+
const pid = client.processID;
|
|
135
|
+
const secret = client.secretKey;
|
|
136
|
+
if (typeof pid !== "number" || typeof secret !== "number")
|
|
137
|
+
return;
|
|
138
|
+
const socket = client.host.startsWith("/") === true ? net.connect(client.host) : net.connect(client.port, client.host);
|
|
139
|
+
socket.unref();
|
|
140
|
+
socket.once("error", () => {
|
|
141
|
+
socket.destroy();
|
|
142
|
+
});
|
|
143
|
+
socket.once("connect", () => {
|
|
144
|
+
const bytes = Buffer.alloc(16);
|
|
145
|
+
bytes.writeInt32BE(16, 0);
|
|
146
|
+
bytes.writeInt32BE(CANCEL_CODE, 4);
|
|
147
|
+
bytes.writeInt32BE(pid, 8);
|
|
148
|
+
bytes.writeInt32BE(secret, 12);
|
|
149
|
+
socket.end(bytes);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function connectClient2(pool, acquireMs, counters) {
|
|
153
|
+
counters.waiting += 1;
|
|
154
|
+
let settled = false;
|
|
155
|
+
return new Promise((resolve, reject) => {
|
|
156
|
+
let timer;
|
|
157
|
+
if (acquireMs !== undefined) {
|
|
158
|
+
timer = setTimeout(() => {
|
|
159
|
+
settled = true;
|
|
160
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
161
|
+
driverErrors().then((errors) => {
|
|
162
|
+
reject(errors.acquireTimeout());
|
|
163
|
+
});
|
|
164
|
+
}, acquireMs);
|
|
165
|
+
}
|
|
166
|
+
pool.connect().then((client) => {
|
|
167
|
+
if (settled) {
|
|
168
|
+
client.release();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (timer !== undefined)
|
|
172
|
+
clearTimeout(timer);
|
|
173
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
174
|
+
resolve(client);
|
|
175
|
+
}, (error) => {
|
|
176
|
+
if (settled)
|
|
177
|
+
return;
|
|
178
|
+
if (timer !== undefined)
|
|
179
|
+
clearTimeout(timer);
|
|
180
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
181
|
+
mapFailure(error).then(reject);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function statsOf(counters, size) {
|
|
186
|
+
return {
|
|
187
|
+
size,
|
|
188
|
+
idle: Math.max(0, size - counters.reserved - counters.busy),
|
|
189
|
+
inflight: counters.busy + counters.reservedBusy,
|
|
190
|
+
waiting: counters.waiting
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export { armDriverError2, open4, send3, connectClient2 };
|