okmodel 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -1
- package/dist/adapters/pg/bunsql-extra.d.ts +5 -5
- package/dist/adapters/pg/bunsql.d.ts +6 -2
- package/dist/adapters/pg/nodepostgres.d.ts +16 -1
- package/dist/adapters/pg/postgres-extra.d.ts +3 -17
- package/dist/adapters/pg/postgresjs.d.ts +2 -1
- package/dist/contracts/driver.d.ts +3 -2
- package/dist/contracts/error.d.ts +1 -1
- package/dist/dialects/pg/errors.d.ts +2 -0
- package/dist/dialects/pg/ext/btree-gin.d.ts +26 -0
- package/dist/dialects/pg/ext/btree-gin.js +20 -0
- package/dist/dialects/pg/ext/btree-gist.d.ts +26 -0
- package/dist/dialects/pg/ext/btree-gist.js +20 -0
- package/dist/dialects/pg/ext/call.d.ts +53 -0
- package/dist/dialects/pg/ext/citext.js +1 -1
- package/dist/dialects/pg/ext/feature.d.ts +26 -0
- package/dist/dialects/pg/ext/fuzzystrmatch.d.ts +34 -0
- package/dist/dialects/pg/ext/fuzzystrmatch.js +33 -0
- package/dist/dialects/pg/ext/hstore.d.ts +41 -0
- package/dist/dialects/pg/ext/hstore.js +29 -0
- package/dist/dialects/pg/ext/index.d.ts +56 -0
- package/dist/dialects/pg/ext/index.js +1 -1
- package/dist/dialects/pg/ext/ltree.d.ts +41 -0
- package/dist/dialects/pg/ext/ltree.js +29 -0
- package/dist/dialects/pg/ext/pg-trgm.js +4 -13
- package/dist/dialects/pg/ext/pgcrypto.d.ts +33 -0
- package/dist/dialects/pg/ext/pgcrypto.js +33 -0
- package/dist/dialects/pg/ext/unaccent.d.ts +26 -0
- package/dist/dialects/pg/ext/unaccent.js +21 -0
- package/dist/dialects/pg/ext/using.d.ts +23 -0
- package/dist/dialects/pg/ext/versions.d.ts +36 -0
- package/dist/dialects/pg/external.d.ts +19 -0
- package/dist/dialects/pg/filters.d.ts +2 -2
- package/dist/dialects/pg/fn/index.js +5 -5
- package/dist/dialects/pg/index.d.ts +1 -0
- package/dist/dialects/pg/index.js +19 -14
- package/dist/dialects/pg/introspect.d.ts +12 -0
- package/dist/dialects/pg/view/index.js +7 -7
- package/dist/dialects/pg/view/scratch.d.ts +4 -1
- package/dist/runtime/artifact-file.d.ts +22 -0
- package/dist/runtime/client.d.ts +10 -0
- package/dist/runtime/drift-detail.d.ts +2 -1
- package/dist/runtime/drift.d.ts +3 -10
- package/dist/runtime/param-limit.d.ts +20 -0
- package/dist/runtime/pg/bun.js +4 -4
- package/dist/runtime/pg/neon.js +4 -4
- package/dist/runtime/pg/pg.js +4 -4
- package/dist/runtime/pg/pglite.js +4 -4
- package/dist/runtime/pg/postgresjs.js +11 -11
- package/dist/runtime/server-check.d.ts +36 -6
- package/dist/runtime/tenancy/index.js +1 -1
- package/dist/runtime/traits/index.js +6 -6
- package/dist/runtime/validate/index.js +2 -2
- package/dist/runtime/write.d.ts +1 -1
- package/dist/shared/{4m6hskg8.js → 0j6qe91y.js} +4 -4
- package/dist/shared/{6m78c8ss.js → 1h5h1rf5.js} +1 -1
- package/dist/shared/{4vbf83xx.js → 2vcnpf0n.js} +1 -1
- package/dist/shared/{qd9hhd8f.js → 3ap5hxvj.js} +2 -1
- package/dist/shared/{v1wad97q.js → 3d7a80fq.js} +1 -1
- package/dist/shared/{wcrheftc.js → 3dr444ny.js} +58 -79
- package/dist/shared/{hm5f8jby.js → 3vvpcphd.js} +8 -7
- package/dist/shared/{760ppr76.js → 4a3mmhhe.js} +2 -2
- package/dist/shared/{mkrn359n.js → 4pkz5nvw.js} +222 -39
- package/dist/shared/{agsfb86s.js → 4te76xc5.js} +4 -4
- package/dist/shared/{63f4ksbz.js → 60y4ahmw.js} +1 -1
- package/dist/shared/61bmrmhr.js +35 -0
- package/dist/shared/{bxas03mq.js → 63qjmhnp.js} +100 -17
- package/dist/shared/{g5yc06ka.js → 67w3kn71.js} +1 -1
- package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
- package/dist/shared/{njga14v4.js → 6vfvsdkt.js} +10 -8
- package/dist/shared/{kj9d8maq.js → 6xqvesa5.js} +1 -1
- package/dist/shared/8gdbty5v.js +665 -0
- package/dist/shared/{pan0370z.js → 8ma6drzr.js} +211 -30
- package/dist/shared/{mnvjvqyp.js → 8p2bgye0.js} +124 -32
- package/dist/shared/{mfedzr74.js → 8qwqrxed.js} +14 -6
- package/dist/shared/{hfqmpasr.js → 8v7vzpgt.js} +11 -8
- package/dist/shared/{7ghwamrf.js → 99qp9vtg.js} +1 -1
- package/dist/shared/{zgex00fd.js → ak61ye1f.js} +5 -5
- package/dist/shared/{dpc2r7rb.js → bdekbvmt.js} +218 -95
- package/dist/shared/{jebgrkeq.js → bxjq6xqv.js} +2 -2
- package/dist/shared/c7dqd3gk.js +1806 -0
- package/dist/shared/ddh72ym5.js +20 -0
- package/dist/shared/e1c55v04.js +10 -0
- package/dist/shared/{mtw6jz76.js → e275q7sd.js} +1 -1
- package/dist/shared/{k86n8vq3.js → ekhq3ytz.js} +1 -1
- package/dist/shared/esy4dyxe.js +17 -0
- package/dist/shared/{gcefca6p.js → f9t9g54z.js} +22 -9
- package/dist/shared/{sjk86yrx.js → fk9vef30.js} +84 -73
- package/dist/shared/fkjne6gx.js +8 -0
- package/dist/shared/{e8zyaqvj.js → fne90dvz.js} +4 -1
- package/dist/shared/{needfe47.js → g89fmz5s.js} +1 -1
- package/dist/shared/{m4xff2a6.js → ghqzdp94.js} +2 -2
- package/dist/shared/{n0jmpgj1.js → gr9sn4za.js} +1 -1
- package/dist/shared/{5mtf6cj3.js → gzgfsspx.js} +5 -2
- package/dist/shared/h9811jjm.js +17 -0
- package/dist/shared/{z581d7ny.js → hgt69zjf.js} +2 -2
- package/dist/shared/{35q0n9tz.js → jvxcp1qk.js} +71 -87
- package/dist/shared/k73e8n9d.js +136 -0
- package/dist/shared/{195pzzzz.js → kzgrcy8s.js} +12 -8
- package/dist/shared/kzgrnckd.js +29 -0
- package/dist/shared/{p3xbdcvt.js → mz48rs74.js} +68 -8
- package/dist/shared/{zbqbmmrp.js → n6je5b28.js} +13 -26
- package/dist/shared/{b6d6p0zc.js → ns35jqz0.js} +75 -49
- package/dist/shared/{n05z9nwz.js → nstwgzn8.js} +1 -1
- package/dist/{tooling/shared/08kemxjd.js → shared/pgsak1yw.js} +1 -1
- package/dist/shared/py2zrrm6.js +451 -0
- package/dist/shared/{9dr2qnx7.js → qqm3ze6q.js} +1 -1
- package/dist/shared/{wvdjznah.js → rcjm0yn7.js} +31 -38
- package/dist/shared/rged92v6.js +17 -0
- package/dist/shared/{jp36k7dp.js → rw4tpcd0.js} +81 -51
- package/dist/shared/{bsek72fg.js → s5qe47a6.js} +3 -0
- package/dist/shared/{1d9q9cv2.js → smxzjz60.js} +2 -2
- package/dist/shared/{wz2a78mp.js → th5rnaxw.js} +1 -1
- package/dist/{tooling/shared/rs1jb051.js → shared/tr64w5p0.js} +1 -1
- package/dist/shared/{14x60fbf.js → tyqapcgk.js} +73 -10
- package/dist/shared/vsna85qf.js +8 -0
- package/dist/shared/{63qtkrca.js → vy47ryqa.js} +55 -5
- package/dist/shared/{jx2m62cs.js → wbdh9qbg.js} +7 -5
- package/dist/shared/{f4jy1j7x.js → wp7y8q3y.js} +946 -105
- package/dist/shared/{16kvjebh.js → xbd9xs6p.js} +7 -26
- package/dist/shared/{bah9nbg3.js → xbvz446k.js} +18 -23
- package/dist/shared/{p5nh3r8q.js → y6tfjk9q.js} +2 -2
- package/dist/shared/{3bb7wsqt.js → ycnft340.js} +1 -1
- package/dist/shared/{z7s6fpxv.js → ymenf259.js} +1 -1
- package/dist/shared/{0wrea3jq.js → ysdw2fg3.js} +10 -2
- package/dist/shared/zecrwdk9.js +61 -0
- package/dist/shared/{3t6kw83m.js → zm2rzqba.js} +2 -1
- package/dist/tooling/cli.js +200 -50
- package/dist/tooling/driver-run.js +109 -343
- package/dist/tooling/github/comment.d.ts +56 -0
- package/dist/tooling/github/post-comment.d.ts +17 -0
- package/dist/tooling/migrate/apply.d.ts +17 -2
- package/dist/tooling/migrate/commands.d.ts +2 -1
- package/dist/tooling/migrate/config.d.ts +13 -0
- package/dist/tooling/migrate/drift.d.ts +12 -0
- package/dist/tooling/migrate/driver-url.d.ts +17 -0
- package/dist/tooling/migrate/export.d.ts +165 -0
- package/dist/tooling/migrate/ext-surface.d.ts +80 -0
- package/dist/tooling/migrate/ext.d.ts +31 -4
- package/dist/tooling/migrate/import-drizzle.d.ts +40 -0
- package/dist/tooling/migrate/index.d.ts +3 -0
- package/dist/tooling/migrate/index.js +57 -10
- package/dist/tooling/migrate/lint-rules.d.ts +18 -1
- package/dist/tooling/migrate/lint.d.ts +14 -1
- package/dist/tooling/migrate/place.d.ts +18 -0
- package/dist/tooling/migrate/plan-json.d.ts +65 -0
- package/dist/tooling/migrate/policy.d.ts +17 -5
- package/dist/tooling/migrate/pooler-probe.d.ts +23 -0
- package/dist/tooling/migrate/project.d.ts +10 -1
- package/dist/tooling/migrate/pull-emit.d.ts +98 -0
- package/dist/tooling/migrate/pull-routines.d.ts +126 -0
- package/dist/tooling/migrate/pull-verify.d.ts +26 -0
- package/dist/tooling/migrate/pull.d.ts +65 -0
- package/dist/tooling/migrate/reprint.d.ts +32 -0
- package/dist/tooling/migrate/runner.d.ts +24 -1
- package/dist/tooling/migrate/sandbox.d.ts +8 -2
- package/dist/tooling/migrate/schema-api.d.ts +43 -0
- package/dist/tooling/migrate/sql-lex.d.ts +18 -0
- package/dist/tooling/shared/{ppnnnvj8.js → 09a6vsys.js} +1 -1
- package/dist/tooling/shared/{7ae7rjmn.js → 0v9ptnxp.js} +8 -8
- package/dist/tooling/shared/{fb9k2qwd.js → 0wtzps9p.js} +11 -30
- package/dist/tooling/shared/{a6pp9d12.js → 0yhf1db4.js} +6 -6
- package/dist/tooling/shared/{dy672fz6.js → 19msgrsc.js} +2 -2
- package/dist/{shared/q0cqt2sp.js → tooling/shared/1fwfm5m3.js} +1 -1
- package/dist/tooling/shared/{f9mphxej.js → 2jdn09e2.js} +401 -24
- package/dist/tooling/shared/{jne7b93p.js → 2qrte2ct.js} +5 -5
- package/dist/tooling/shared/{5bvw2nev.js → 2v4nwnkb.js} +1 -1
- package/dist/tooling/shared/{spk1jg3r.js → 33z39trp.js} +106 -23
- package/dist/tooling/shared/{z8d7ptht.js → 353vnw9z.js} +5 -5
- package/dist/tooling/shared/{dw08f3m8.js → 390kry9g.js} +2 -2
- package/dist/tooling/shared/{xjs6zqtc.js → 3f6etb9z.js} +18 -31
- package/dist/{shared/bnby0esn.js → tooling/shared/3t2cqmsx.js} +1 -1
- package/dist/tooling/shared/{wwnekq5n.js → 4dzvjtpy.js} +1 -1
- package/dist/tooling/shared/{y5656f0e.js → 4ec0nxvw.js} +10 -10
- package/dist/tooling/shared/{3m1hkg7z.js → 4tg2bn41.js} +59 -78
- package/dist/tooling/shared/{zvnhh1n0.js → 5rah55z0.js} +2 -2
- package/dist/tooling/shared/{pqy21k24.js → 804w1t69.js} +4 -4
- package/dist/tooling/shared/8g0m0rvd.js +134 -0
- package/dist/tooling/shared/8msbtw5s.js +8 -0
- package/dist/tooling/shared/{4d2w25vw.js → 8t22h3h7.js} +2 -2
- package/dist/tooling/shared/{smn6kz1p.js → 91c59b7b.js} +2 -2
- package/dist/tooling/shared/{aftb2mwr.js → adk9k6va.js} +1 -1
- package/dist/tooling/shared/{j9t5s12a.js → ajjd5cwz.js} +2 -2
- package/dist/tooling/shared/{cmptmb4f.js → angjck01.js} +1 -1
- package/dist/tooling/shared/{yw30vnq2.js → asnnc3v5.js} +1 -1
- package/dist/tooling/shared/{ma2340rx.js → bj1kyqc8.js} +2 -2
- package/dist/tooling/shared/{2wtvc7rw.js → bt3tjemb.js} +11 -3
- package/dist/tooling/shared/{ec71zqgt.js → chk2bh4f.js} +2 -2
- package/dist/tooling/shared/{gmcf9cxf.js → ckq4z5ax.js} +5 -2
- package/dist/tooling/shared/{w7qe8sj1.js → d3rhb24q.js} +1 -1
- package/dist/tooling/shared/{y031jct9.js → d8q00vxg.js} +4 -4
- package/dist/tooling/shared/{vs0t6qt8.js → dx188rxs.js} +2 -2
- package/dist/tooling/shared/{g9ad4n80.js → efq6p9df.js} +35 -42
- package/dist/tooling/shared/{ddjtfgnx.js → en6rwzq0.js} +3 -3
- package/dist/tooling/shared/{6nyfyw70.js → f2r5g0fs.js} +2 -2
- package/dist/tooling/shared/{03k6res6.js → f4gep0nk.js} +1 -1
- package/dist/tooling/shared/{gfvtj6d0.js → f8a010fm.js} +13 -11
- package/dist/tooling/shared/{3tq8pnb8.js → fdsek6pa.js} +1 -1
- package/dist/tooling/shared/fvmrxsd1.js +8 -0
- package/dist/tooling/shared/{733a1tq3.js → g3xybeqf.js} +4 -3
- package/dist/tooling/shared/{pwsytxm5.js → gefmpwsa.js} +1 -1
- package/dist/tooling/shared/{mtrqn2hn.js → gjj71hfh.js} +25 -30
- package/dist/tooling/shared/{8sqrsw3s.js → jgzt69pa.js} +5 -5
- package/dist/tooling/shared/{nf7jmhfa.js → jm30k2ca.js} +10 -8
- package/dist/tooling/shared/{vx86qjv8.js → kayqzpbk.js} +6 -3
- package/dist/tooling/shared/{zhwnfyb2.js → kvw1672d.js} +1 -1
- package/dist/tooling/shared/{rq5kk8j6.js → mr1kcgpw.js} +3 -3
- package/dist/tooling/shared/{72fyg4zv.js → mwbdf409.js} +1 -1
- package/dist/tooling/shared/{wt7j7nf6.js → ns9207v3.js} +1 -1
- package/dist/tooling/shared/{9xzm7hjg.js → p6tjv97k.js} +3 -3
- package/dist/tooling/shared/{yfr8hzhm.js → p73evwf0.js} +1 -1
- package/dist/tooling/shared/{dzx85q70.js → phc1nc4g.js} +1 -1
- package/dist/tooling/shared/{417zdsk7.js → ppybjw50.js} +79 -16
- package/dist/tooling/shared/{yk9mp7vb.js → qdrn8ghn.js} +5 -4
- package/dist/tooling/shared/rd8h01ta.js +20 -0
- package/dist/tooling/shared/{bz2dqhab.js → rwg8y90m.js} +3 -3
- package/dist/tooling/shared/{xhrnjch9.js → ry2f3w8p.js} +3 -3
- package/dist/tooling/shared/{a7q7t4n3.js → ryc5sa58.js} +8 -8
- package/dist/tooling/shared/{2revefqt.js → ss87qxwv.js} +2 -2
- package/dist/tooling/shared/{rf83gr2d.js → vg68k11z.js} +7 -3
- package/dist/tooling/shared/{p7f08ktn.js → vms9dta5.js} +73 -89
- package/dist/tooling/shared/{3rrw5w8f.js → xchpnbdv.js} +1 -1
- package/dist/tooling/shared/{djydjpqt.js → xn6p01fh.js} +5 -5
- package/dist/tooling/shared/{9kazs5p6.js → xwr6q618.js} +3 -3
- package/dist/tooling/shared/{ep8zh3bk.js → xx3gmq94.js} +1 -1
- package/dist/tooling/shared/{tn8gay14.js → y2bd7yfx.js} +21 -13
- package/dist/tooling/shared/{vraj6d74.js → y4gq9rbe.js} +11 -11
- package/dist/tooling/shared/y4vwft92.js +9 -0
- package/dist/tooling/shared/{345tbc2k.js → yz68xcmc.js} +1 -1
- package/dist/tooling/testing/factories.d.ts +1 -3
- package/dist/tooling/testing/index.js +2 -2
- package/package.json +39 -9
- package/dist/shared/3449rcae.js +0 -14
- package/dist/shared/fjpnhqan.js +0 -71
- package/dist/shared/n41w4fbz.js +0 -113
- package/dist/tooling/shared/pw8fgahx.js +0 -69
- /package/dist/shared/{ae4j5f42.js → mfvx6kjx.js} +0 -0
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
DriverError2,
|
|
3
3
|
timedOut2,
|
|
4
4
|
isConnectionLost
|
|
5
|
-
} from "./
|
|
5
|
+
} from "./2jdn09e2.js";
|
|
6
6
|
import {
|
|
7
7
|
PgSession2
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./vms9dta5.js";
|
|
9
9
|
import {
|
|
10
10
|
driverErrors,
|
|
11
11
|
rejectClosed,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
runCall,
|
|
14
14
|
rowsFrom,
|
|
15
15
|
resultFrom
|
|
16
|
-
} from "./
|
|
16
|
+
} from "./ry2f3w8p.js";
|
|
17
17
|
|
|
18
18
|
// src/adapters/pg/postgres-extra.ts
|
|
19
19
|
var RESET_ALL = "RESET ALL";
|
|
@@ -48,7 +48,7 @@ async function checkout(pool, timeoutMs) {
|
|
|
48
48
|
batch: (statements, options) => {
|
|
49
49
|
remember(options?.timeout);
|
|
50
50
|
return guard(() => runCall(pool.isClosed(), options, async (watch) => {
|
|
51
|
-
const { runAtomicBatch } = await import("./
|
|
51
|
+
const { runAtomicBatch } = await import("./xchpnbdv.js");
|
|
52
52
|
return runAtomicBatch(session, statements, watch);
|
|
53
53
|
}));
|
|
54
54
|
},
|
|
@@ -78,18 +78,12 @@ async function checkout(pool, timeoutMs) {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
async function describe(sql, text, params) {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
columns: described.columns.map((column) => column.name),
|
|
85
|
-
parameterCount: described.types.length
|
|
86
|
-
};
|
|
81
|
+
const d = await sql.unsafe(text, asParams(params), { prepare: true }).describe();
|
|
82
|
+
return { columns: d.columns.map((c) => c.name), parameterCount: d.types.length };
|
|
87
83
|
}
|
|
88
84
|
async function* stream(sql, text, params) {
|
|
89
|
-
const
|
|
90
|
-
for await (const chunk of pending.cursor(64)) {
|
|
85
|
+
for await (const chunk of sql.unsafe(text, asParams(params)).cursor(64))
|
|
91
86
|
yield rowsFrom(chunk);
|
|
92
|
-
}
|
|
93
87
|
}
|
|
94
88
|
function poolWaits(sql) {
|
|
95
89
|
const options = sql.options;
|
|
@@ -103,14 +97,14 @@ function poolWaits(sql) {
|
|
|
103
97
|
n.add(id);
|
|
104
98
|
if (n.size < options.max) {
|
|
105
99
|
queueMicrotask(() => {
|
|
106
|
-
for (const
|
|
107
|
-
|
|
100
|
+
for (const w of q)
|
|
101
|
+
w.a();
|
|
108
102
|
});
|
|
109
103
|
return;
|
|
110
104
|
}
|
|
111
105
|
n.clear();
|
|
112
|
-
for (const
|
|
113
|
-
|
|
106
|
+
for (const w of q)
|
|
107
|
+
w.s();
|
|
114
108
|
q.clear();
|
|
115
109
|
};
|
|
116
110
|
return options;
|
|
@@ -192,41 +186,40 @@ function reserveConnection(sql, acquireMs, counters, callMs) {
|
|
|
192
186
|
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
193
187
|
};
|
|
194
188
|
return new Promise((resolve, reject) => {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
timer = setTimeout(() => {
|
|
198
|
-
if (settled)
|
|
199
|
-
return;
|
|
200
|
-
settled = true;
|
|
201
|
-
finish();
|
|
202
|
-
driverErrors().then((errors) => {
|
|
203
|
-
reject(errors.acquireTimeout());
|
|
204
|
-
});
|
|
205
|
-
}, acquireMs);
|
|
206
|
-
}
|
|
207
|
-
const ms = callMs !== undefined && callMs > 0 ? callMs : 0;
|
|
208
|
-
deadline(ms, () => sql.reserve(), sql).then((connection) => {
|
|
209
|
-
if (settled) {
|
|
210
|
-
resetConnection(connection, 0).catch(() => {
|
|
211
|
-
return;
|
|
212
|
-
}).finally(() => {
|
|
213
|
-
connection.release();
|
|
214
|
-
});
|
|
189
|
+
const timer = acquireMs === undefined ? undefined : setTimeout(() => {
|
|
190
|
+
if (settled)
|
|
215
191
|
return;
|
|
216
|
-
}
|
|
217
192
|
settled = true;
|
|
218
|
-
if (timer !== undefined)
|
|
219
|
-
clearTimeout(timer);
|
|
220
193
|
finish();
|
|
221
|
-
|
|
222
|
-
|
|
194
|
+
driverErrors().then((errors) => {
|
|
195
|
+
reject(errors.acquireTimeout());
|
|
196
|
+
});
|
|
197
|
+
}, acquireMs);
|
|
198
|
+
const done = (fn) => {
|
|
223
199
|
if (settled)
|
|
224
200
|
return;
|
|
225
201
|
settled = true;
|
|
226
202
|
if (timer !== undefined)
|
|
227
203
|
clearTimeout(timer);
|
|
228
204
|
finish();
|
|
229
|
-
|
|
205
|
+
fn();
|
|
206
|
+
};
|
|
207
|
+
deadline(callMs !== undefined && callMs > 0 ? callMs : 0, () => sql.reserve(), sql).then((connection) => {
|
|
208
|
+
if (settled) {
|
|
209
|
+
resetConnection(connection, 0).catch(() => {
|
|
210
|
+
return;
|
|
211
|
+
}).finally(() => {
|
|
212
|
+
connection.release();
|
|
213
|
+
});
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
done(() => {
|
|
217
|
+
resolve(connection);
|
|
218
|
+
});
|
|
219
|
+
}, (error) => {
|
|
220
|
+
done(() => {
|
|
221
|
+
mapFailure(error).then(reject);
|
|
222
|
+
});
|
|
230
223
|
});
|
|
231
224
|
});
|
|
232
225
|
}
|
|
@@ -235,22 +228,20 @@ async function resetConnection(sql, depth) {
|
|
|
235
228
|
await sql.unsafe("ROLLBACK").catch(() => {
|
|
236
229
|
return;
|
|
237
230
|
});
|
|
238
|
-
|
|
231
|
+
const clear = async () => {
|
|
239
232
|
await sql.unsafe(RESET_ALL);
|
|
240
233
|
await sql.unsafe(UNLOCK);
|
|
234
|
+
};
|
|
235
|
+
try {
|
|
236
|
+
await clear();
|
|
241
237
|
} catch {
|
|
242
238
|
await sql.unsafe("ROLLBACK").catch(() => {
|
|
243
239
|
return;
|
|
244
240
|
});
|
|
245
|
-
await
|
|
246
|
-
await sql.unsafe(UNLOCK);
|
|
241
|
+
await clear();
|
|
247
242
|
}
|
|
248
243
|
}
|
|
249
|
-
|
|
250
|
-
if (params === undefined)
|
|
251
|
-
return [];
|
|
252
|
-
return params;
|
|
253
|
-
}
|
|
244
|
+
var asParams = (params) => params ?? [];
|
|
254
245
|
function arm(sql, lost) {
|
|
255
246
|
const unsafe = sql.unsafe.bind(sql);
|
|
256
247
|
sql.unsafe = (text, params, options) => unsafe(text, params, {
|
|
@@ -268,14 +259,7 @@ async function holdCheckout(gate, checkout) {
|
|
|
268
259
|
const connection = await checkout();
|
|
269
260
|
let released = false;
|
|
270
261
|
const release = connection.release.bind(connection);
|
|
271
|
-
connection.release = () =>
|
|
272
|
-
if (released)
|
|
273
|
-
return Promise.resolve();
|
|
274
|
-
released = true;
|
|
275
|
-
return release().finally(() => {
|
|
276
|
-
gate.leave();
|
|
277
|
-
});
|
|
278
|
-
};
|
|
262
|
+
connection.release = () => released ? Promise.resolve() : (released = true, release().finally(() => gate.leave()));
|
|
279
263
|
return connection;
|
|
280
264
|
} catch (error) {
|
|
281
265
|
gate.leave();
|
|
@@ -290,11 +274,9 @@ async function holdListener(gate, start) {
|
|
|
290
274
|
if (stopped)
|
|
291
275
|
return;
|
|
292
276
|
stopped = true;
|
|
293
|
-
|
|
294
|
-
await stop();
|
|
295
|
-
} finally {
|
|
277
|
+
await stop().finally(() => {
|
|
296
278
|
gate.leave();
|
|
297
|
-
}
|
|
279
|
+
});
|
|
298
280
|
};
|
|
299
281
|
} catch (error) {
|
|
300
282
|
gate.leave();
|
|
@@ -302,36 +284,35 @@ async function holdListener(gate, start) {
|
|
|
302
284
|
}
|
|
303
285
|
}
|
|
304
286
|
function watchQuery(pending, watch, onAbort, ctx) {
|
|
287
|
+
const done = () => {
|
|
288
|
+
ctx.leave();
|
|
289
|
+
ctx.untrack(pending);
|
|
290
|
+
watch.signal.removeEventListener("abort", onAbort);
|
|
291
|
+
};
|
|
305
292
|
return pending.then((value) => {
|
|
306
|
-
|
|
293
|
+
done();
|
|
307
294
|
const why = watch.reason();
|
|
308
295
|
if (why === "timeout" || why === "cancelled")
|
|
309
296
|
return classify(why, watch);
|
|
310
297
|
ctx.note(ctx.text);
|
|
311
298
|
return resultFrom(value, ctx.notices.since(ctx.start));
|
|
312
299
|
}, (error) => {
|
|
313
|
-
|
|
300
|
+
done();
|
|
314
301
|
return classify(error, watch);
|
|
315
302
|
});
|
|
316
303
|
}
|
|
317
|
-
function finishWatch(pending, watch, onAbort, ctx) {
|
|
318
|
-
ctx.leave();
|
|
319
|
-
ctx.untrack(pending);
|
|
320
|
-
watch.signal.removeEventListener("abort", onAbort);
|
|
321
|
-
}
|
|
322
304
|
async function classify(error, watch) {
|
|
323
305
|
const errors = await driverErrors();
|
|
324
306
|
if (error instanceof errors.DriverError)
|
|
325
|
-
|
|
307
|
+
throw error;
|
|
326
308
|
const why = typeof error === "string" ? error : watch.reason();
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return Promise.reject(errors.cancelled(typeof error === "string" ? undefined : error));
|
|
309
|
+
const cause = typeof error === "string" ? undefined : error;
|
|
310
|
+
if (why === "timeout")
|
|
311
|
+
throw errors.timedOut(cause);
|
|
312
|
+
if (why === "cancelled" || errors.errorField(error, "code") === "57014") {
|
|
313
|
+
throw errors.cancelled(cause);
|
|
333
314
|
}
|
|
334
|
-
|
|
315
|
+
throw errors.mapDriverError(error);
|
|
335
316
|
}
|
|
336
317
|
export {
|
|
337
318
|
checkout,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
readHandle,
|
|
4
4
|
readCall,
|
|
5
5
|
attachHttp
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./gjj71hfh.js";
|
|
7
7
|
import {
|
|
8
8
|
OkmError,
|
|
9
9
|
throwNamed,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
isRecord,
|
|
18
18
|
registerFailFix,
|
|
19
19
|
fail2
|
|
20
|
-
} from "./
|
|
20
|
+
} from "./2jdn09e2.js";
|
|
21
21
|
|
|
22
22
|
// src/runtime/page.ts
|
|
23
23
|
registerFailFix("OKM1130", "Request the next page with the same orderBy and the exact next value the previous page returned. The cursor encodes that order.");
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
readSelectFragment,
|
|
3
3
|
emitSqlSelect,
|
|
4
4
|
decodeSqlNumber
|
|
5
|
-
} from "./
|
|
6
|
-
import"./
|
|
5
|
+
} from "./ckq4z5ax.js";
|
|
6
|
+
import"./fdsek6pa.js";
|
|
7
7
|
import {
|
|
8
8
|
refusePrototypeKey
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./09a6vsys.js";
|
|
10
10
|
import {
|
|
11
11
|
throwNamed,
|
|
12
12
|
emitWhere,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
list,
|
|
21
21
|
isRecord,
|
|
22
22
|
fail2
|
|
23
|
-
} from "./
|
|
23
|
+
} from "./2jdn09e2.js";
|
|
24
24
|
|
|
25
25
|
// src/dialects/pg/ops/window.ts
|
|
26
26
|
var RUNTIME = Symbol.for("okmodel.window");
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {
|
|
2
|
+
withHttp,
|
|
3
|
+
attachHttp,
|
|
4
|
+
mapOptions
|
|
5
|
+
} from "./gjj71hfh.js";
|
|
6
|
+
import {
|
|
7
|
+
OkmError,
|
|
8
|
+
POSTGRES_FLOOR,
|
|
9
|
+
isPostgresMajor,
|
|
10
|
+
parsePostgresFloor,
|
|
11
|
+
serverNeedsPostgres
|
|
12
|
+
} from "./2jdn09e2.js";
|
|
13
|
+
|
|
14
|
+
// src/runtime/artifact-file.ts
|
|
15
|
+
function artifactDir(catalogDir) {
|
|
16
|
+
if (catalogDir !== undefined)
|
|
17
|
+
return catalogDir.replace(/[/\\]+$/, "");
|
|
18
|
+
const cwd = globalThis.process?.cwd?.() ?? ".";
|
|
19
|
+
return `${cwd}/.okm`;
|
|
20
|
+
}
|
|
21
|
+
async function readText(path) {
|
|
22
|
+
const bun = globalThis.Bun;
|
|
23
|
+
if (bun !== undefined) {
|
|
24
|
+
const file = bun.file(path);
|
|
25
|
+
if (!await file.exists())
|
|
26
|
+
return;
|
|
27
|
+
return file.text();
|
|
28
|
+
}
|
|
29
|
+
const loader = globalThis.process?.getBuiltinModule;
|
|
30
|
+
if (loader === undefined)
|
|
31
|
+
return;
|
|
32
|
+
try {
|
|
33
|
+
return await loader("node:fs/promises").readFile(path, "utf8");
|
|
34
|
+
} catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/runtime/server-check.ts
|
|
40
|
+
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)";
|
|
41
|
+
var historyQuery = "select migration_id, class, catalog_hash from okm_history order by migration_id, step_index";
|
|
42
|
+
async function versionSql(namespace) {
|
|
43
|
+
if (namespace === "public")
|
|
44
|
+
return versionQuery;
|
|
45
|
+
const relation = await qualified("okm_meta", namespace);
|
|
46
|
+
const literal = relation.replaceAll("'", "''");
|
|
47
|
+
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)`;
|
|
48
|
+
}
|
|
49
|
+
async function historySql2(namespace) {
|
|
50
|
+
if (namespace === "public")
|
|
51
|
+
return historyQuery;
|
|
52
|
+
return `select migration_id, class, catalog_hash from ${await qualified("okm_history", namespace)} order by migration_id, step_index`;
|
|
53
|
+
}
|
|
54
|
+
async function recordedNamespace(catalogDir) {
|
|
55
|
+
const text = await readText(`${artifactDir(catalogDir)}/namespace`);
|
|
56
|
+
if (text === undefined)
|
|
57
|
+
return "public";
|
|
58
|
+
const line = text.trim();
|
|
59
|
+
if (line === "" || line === "public")
|
|
60
|
+
return "public";
|
|
61
|
+
if (line.includes("\x00") || line.includes(`
|
|
62
|
+
`) || line.includes("\r")) {
|
|
63
|
+
throw new OkmError("OKM1122", "The catalog namespace file is not one identifier.", {
|
|
64
|
+
fix: { summary: "Run okm build so .okm/namespace is the schema from defineConfig." }
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return line;
|
|
68
|
+
}
|
|
69
|
+
async function acceptServer2(pool, schema, http, requireMeta, options, source) {
|
|
70
|
+
const namespace = await recordedNamespace(source.catalogDir);
|
|
71
|
+
let rows;
|
|
72
|
+
try {
|
|
73
|
+
const result = await pool.execute(await versionSql(namespace), undefined, options);
|
|
74
|
+
rows = result.rows;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
const { mapPostgresError } = await import("./xx3gmq94.js");
|
|
77
|
+
throw mapPostgresError(error, mapOptions(http, false, schema));
|
|
78
|
+
}
|
|
79
|
+
for (const name in schema.model) {
|
|
80
|
+
if (schema.model[name]?.presets !== undefined) {
|
|
81
|
+
(await import("./bj1kyqc8.js")).checkSchema(schema);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const version = rows[0]?.[1];
|
|
86
|
+
if (version === null || version === undefined || !version.startsWith("PostgreSQL")) {
|
|
87
|
+
throw new OkmError("OKM1801", "The server is not PostgreSQL. The schema dialect is postgres.", withHttp(http, {
|
|
88
|
+
fix: { summary: "Open the schema with the Postgres driver that matches it." }
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
const recorded = rows[0]?.[2];
|
|
92
|
+
if (recorded === null || recorded === undefined || recorded.length === 0) {
|
|
93
|
+
if (requireMeta) {
|
|
94
|
+
throw new OkmError("OKM1520", "okm_meta has no catalog hash.", withHttp(http, {
|
|
95
|
+
fix: {
|
|
96
|
+
summary: "Apply migrations so okm_meta records the catalog, or omit requireMeta to adopt this database."
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
const { assertCompatible } = await import("./0wtzps9p.js");
|
|
102
|
+
try {
|
|
103
|
+
await assertCompatible(pool, schema, recorded, source, options, namespace);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (error instanceof OkmError)
|
|
106
|
+
throw attachHttp(http, error);
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const major = Math.floor(Number(rows[0]?.[0] ?? "0") / 1e4);
|
|
111
|
+
const raw = schema.requires?.postgres;
|
|
112
|
+
if (raw === undefined) {
|
|
113
|
+
if (major < POSTGRES_FLOOR) {
|
|
114
|
+
throw new OkmError("OKM1803", serverNeedsPostgres(major, POSTGRES_FLOOR), withHttp(http, {
|
|
115
|
+
fix: {
|
|
116
|
+
summary: `Upgrade to PostgreSQL ${String(POSTGRES_FLOOR)} or higher.`
|
|
117
|
+
}
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const need = parsePostgresFloor(raw);
|
|
123
|
+
if (!isPostgresMajor(need) || major < need) {
|
|
124
|
+
throw new OkmError("OKM1802", serverNeedsPostgres(major, isPostgresMajor(need) ? need : POSTGRES_FLOOR), withHttp(http, {
|
|
125
|
+
fix: { summary: "Upgrade the server, or lower minPostgres to a major the server meets." }
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function qualified(table, namespace) {
|
|
130
|
+
const { quoteIdent } = await import("./8msbtw5s.js");
|
|
131
|
+
return `${quoteIdent(namespace)}.${table}`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { artifactDir, readText, historySql2, acceptServer2 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertNoControl
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fdsek6pa.js";
|
|
4
4
|
import {
|
|
5
5
|
throwNamed,
|
|
6
6
|
isOperator,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
list,
|
|
13
13
|
isRecord,
|
|
14
14
|
fail2
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./2jdn09e2.js";
|
|
16
16
|
|
|
17
17
|
// src/dialects/pg/ops/search-query.ts
|
|
18
18
|
function searchValue(query, options) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createClient
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./gjj71hfh.js";
|
|
4
4
|
import {
|
|
5
5
|
OkmError,
|
|
6
6
|
isConnectionSqlstate,
|
|
7
7
|
isConnectionErrno
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./2jdn09e2.js";
|
|
9
9
|
|
|
10
10
|
// src/runtime/topology.ts
|
|
11
11
|
var CIRCUIT_AT = 2;
|
|
@@ -1166,7 +1166,15 @@ function fromSelect(handle, select, candidates) {
|
|
|
1166
1166
|
lag: byteLagNumber(handle, endpoint)
|
|
1167
1167
|
});
|
|
1168
1168
|
}
|
|
1169
|
-
|
|
1169
|
+
let returned;
|
|
1170
|
+
try {
|
|
1171
|
+
returned = select(offered, { op: "read" });
|
|
1172
|
+
} catch (error) {
|
|
1173
|
+
if (error instanceof OkmError)
|
|
1174
|
+
throw error;
|
|
1175
|
+
const message = error instanceof Error ? error.message : "routing.select threw.";
|
|
1176
|
+
throw new OkmError("invalid", message, { kind: "invalid", cause: error });
|
|
1177
|
+
}
|
|
1170
1178
|
if (typeof returned === "string") {
|
|
1171
1179
|
const endpoint = endpoints.find((item) => item.name === returned);
|
|
1172
1180
|
if (endpoint !== undefined)
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
readHandle,
|
|
3
3
|
readCall,
|
|
4
4
|
attachHttp
|
|
5
|
-
} from "./
|
|
5
|
+
} from "./gjj71hfh.js";
|
|
6
6
|
import {
|
|
7
7
|
OkmError,
|
|
8
8
|
throwNamed,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
list,
|
|
18
18
|
isRecord,
|
|
19
19
|
fail2
|
|
20
|
-
} from "./
|
|
20
|
+
} from "./2jdn09e2.js";
|
|
21
21
|
|
|
22
22
|
// src/runtime/tree.ts
|
|
23
23
|
var OPTIONS = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertNoControl
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fdsek6pa.js";
|
|
4
4
|
import {
|
|
5
5
|
OkmError,
|
|
6
6
|
throwNamed,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
quote,
|
|
13
13
|
list,
|
|
14
14
|
fail2
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./2jdn09e2.js";
|
|
16
16
|
|
|
17
17
|
// src/dialects/pg/ops/fragment.ts
|
|
18
18
|
var IDENT = Symbol("okmodel.sql.ident");
|
|
@@ -57,6 +57,9 @@ function scanLiteral(literal, state) {
|
|
|
57
57
|
for (let index = 0;index < literal.length; index += 1) {
|
|
58
58
|
const char = literal[index] ?? "";
|
|
59
59
|
const code = literal.charCodeAt(index);
|
|
60
|
+
if (char === "\\") {
|
|
61
|
+
fragmentError("A fragment cannot include a backslash.", "Pass the value as an interpolation.");
|
|
62
|
+
}
|
|
60
63
|
if (state.quote !== undefined) {
|
|
61
64
|
if (char !== state.quote)
|
|
62
65
|
continue;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
open4,
|
|
3
3
|
PgSession2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./vms9dta5.js";
|
|
5
5
|
import {
|
|
6
6
|
POSTGRESJS_CAPABILITIES,
|
|
7
7
|
readCapability2,
|
|
8
8
|
hasCapability2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./ry2f3w8p.js";
|
|
10
10
|
export {
|
|
11
11
|
PgSession2 as PgSession,
|
|
12
12
|
POSTGRESJS_CAPABILITIES as capabilities,
|
|
13
13
|
hasCapability2 as hasCapability,
|
|
14
|
-
|
|
14
|
+
open4 as open,
|
|
15
15
|
readCapability2 as readCapability
|
|
16
16
|
};
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
readHandle,
|
|
4
4
|
readCall,
|
|
5
5
|
attachHttp
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./gjj71hfh.js";
|
|
7
7
|
import {
|
|
8
8
|
OkmError,
|
|
9
9
|
throwNamed,
|
|
10
10
|
fail2
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./2jdn09e2.js";
|
|
12
12
|
|
|
13
13
|
// src/runtime/lock.ts
|
|
14
14
|
var LOCKS = ["update", "share"];
|