okmodel 0.9.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 +9 -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/fuzzystrmatch.js +1 -1
- package/dist/dialects/pg/ext/hstore.js +1 -1
- package/dist/dialects/pg/ext/ltree.js +1 -1
- package/dist/dialects/pg/ext/pgcrypto.js +1 -1
- package/dist/dialects/pg/ext/unaccent.js +1 -1
- package/dist/dialects/pg/filters.d.ts +2 -2
- package/dist/dialects/pg/fn/index.js +1 -1
- package/dist/dialects/pg/index.js +3 -3
- package/dist/dialects/pg/introspect.d.ts +12 -0
- package/dist/dialects/pg/view/index.js +2 -2
- package/dist/runtime/param-limit.d.ts +20 -0
- package/dist/runtime/pg/bun.js +3 -3
- package/dist/runtime/pg/neon.js +3 -3
- package/dist/runtime/pg/pg.js +3 -3
- package/dist/runtime/pg/pglite.js +2 -2
- package/dist/runtime/pg/postgresjs.js +10 -10
- package/dist/runtime/tenancy/index.js +1 -1
- package/dist/runtime/traits/index.js +2 -2
- package/dist/runtime/validate/index.js +2 -2
- package/dist/runtime/write.d.ts +1 -1
- package/dist/shared/{5kyb3tqx.js → 1h5h1rf5.js} +1 -1
- package/dist/shared/{4vbf83xx.js → 2vcnpf0n.js} +1 -1
- package/dist/shared/{8n688yjg.js → 3ap5hxvj.js} +2 -1
- package/dist/shared/{wvtjg5m3.js → 3d7a80fq.js} +1 -1
- package/dist/shared/{bphrgwz9.js → 3dr444ny.js} +57 -78
- package/dist/shared/{yvabyg9k.js → 3vvpcphd.js} +7 -6
- package/dist/shared/{760ppr76.js → 4a3mmhhe.js} +2 -2
- package/dist/shared/{90sg0w5a.js → 4pkz5nvw.js} +65 -10
- package/dist/shared/{mazpbcdj.js → 4te76xc5.js} +1 -1
- package/dist/shared/{xwhdcrm4.js → 60y4ahmw.js} +1 -1
- package/dist/shared/{9dtgn1z2.js → 63qjmhnp.js} +100 -17
- package/dist/shared/{s7he5e5d.js → 67w3kn71.js} +1 -1
- package/dist/shared/{n306gqkd.js → 6vfvsdkt.js} +9 -7
- package/dist/shared/{jpybhf98.js → 6xqvesa5.js} +1 -1
- package/dist/shared/{n5whk3mt.js → 8gdbty5v.js} +8 -8
- package/dist/shared/{ccsmhv9r.js → 8ma6drzr.js} +194 -31
- package/dist/shared/{3456242y.js → 8p2bgye0.js} +110 -18
- package/dist/shared/{ebhz8vh6.js → 8qwqrxed.js} +11 -3
- package/dist/shared/{ss2kv2rs.js → 8v7vzpgt.js} +10 -7
- package/dist/shared/{8qzkd9f3.js → ak61ye1f.js} +3 -3
- package/dist/shared/{6nae0spm.js → bdekbvmt.js} +69 -7
- package/dist/shared/{tw1nvvfj.js → bxjq6xqv.js} +2 -2
- package/dist/shared/{rbxt795q.js → c7dqd3gk.js} +81 -41
- package/dist/shared/ddh72ym5.js +20 -0
- package/dist/shared/e1c55v04.js +10 -0
- package/dist/shared/{8jesqsrk.js → ekhq3ytz.js} +1 -1
- package/dist/shared/{7ba5h6pb.js → esy4dyxe.js} +5 -5
- package/dist/shared/{gcefca6p.js → f9t9g54z.js} +22 -9
- package/dist/shared/fkjne6gx.js +8 -0
- package/dist/shared/{ds229x4r.js → fne90dvz.js} +4 -1
- package/dist/shared/{cexb7z6b.js → gr9sn4za.js} +1 -1
- package/dist/shared/{mvmm3xpb.js → gzgfsspx.js} +1 -1
- package/dist/shared/{fdsz3w80.js → hgt69zjf.js} +2 -2
- package/dist/shared/{dd5pmnky.js → jvxcp1qk.js} +70 -86
- package/dist/shared/{yybhre6n.js → k73e8n9d.js} +3 -3
- package/dist/shared/{mgaq2sd3.js → kzgrcy8s.js} +8 -7
- package/dist/shared/{myk8fswx.js → mz48rs74.js} +14 -3
- package/dist/shared/{62b603gr.js → n6je5b28.js} +10 -23
- package/dist/shared/{2szgv6yj.js → ns35jqz0.js} +71 -45
- package/dist/shared/{xtsydxjg.js → nstwgzn8.js} +1 -1
- package/dist/shared/{stfa9xcw.js → py2zrrm6.js} +7 -6
- package/dist/shared/{9dr2qnx7.js → qqm3ze6q.js} +1 -1
- package/dist/shared/{cf8zdz5p.js → rcjm0yn7.js} +27 -34
- package/dist/shared/{ckz05z15.js → rged92v6.js} +7 -4
- package/dist/shared/{qvwwp1mp.js → rw4tpcd0.js} +30 -21
- package/dist/shared/{bsek72fg.js → s5qe47a6.js} +3 -0
- package/dist/shared/{1d9q9cv2.js → smxzjz60.js} +2 -2
- package/dist/shared/{c3mvnq7a.js → th5rnaxw.js} +1 -1
- package/dist/shared/{1mxm04fy.js → tyqapcgk.js} +71 -8
- package/dist/shared/{zdqf8k5d.js → vsna85qf.js} +1 -1
- package/dist/shared/{63qtkrca.js → vy47ryqa.js} +55 -5
- package/dist/shared/{xv8qj97g.js → wbdh9qbg.js} +3 -1
- package/dist/shared/{2zdxkt7b.js → wp7y8q3y.js} +41 -9
- package/dist/shared/{pg4ezgyf.js → xbd9xs6p.js} +2 -2
- package/dist/shared/{npdftanb.js → xbvz446k.js} +16 -13
- package/dist/shared/{aksb89mn.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/{71n0jmhc.js → ysdw2fg3.js} +10 -2
- package/dist/shared/{xqacq37x.js → zecrwdk9.js} +1 -1
- package/dist/shared/{3t6kw83m.js → zm2rzqba.js} +2 -1
- package/dist/tooling/cli.js +122 -44
- package/dist/tooling/driver-run.js +107 -24
- package/dist/tooling/github/comment.d.ts +8 -2
- package/dist/tooling/migrate/apply.d.ts +17 -2
- package/dist/tooling/migrate/drift.d.ts +12 -0
- package/dist/tooling/migrate/driver-url.d.ts +17 -0
- package/dist/tooling/migrate/index.js +9 -7
- package/dist/tooling/migrate/policy.d.ts +17 -5
- package/dist/tooling/migrate/pooler-probe.d.ts +23 -0
- package/dist/tooling/migrate/pull.d.ts +3 -0
- package/dist/tooling/migrate/runner.d.ts +24 -1
- package/dist/tooling/shared/{0j0jtse1.js → 09a6vsys.js} +1 -1
- package/dist/tooling/shared/{68tf18v4.js → 0v9ptnxp.js} +8 -8
- package/dist/tooling/shared/{qartgazh.js → 0wtzps9p.js} +6 -6
- package/dist/tooling/shared/{1800eymw.js → 0yhf1db4.js} +6 -6
- package/dist/tooling/shared/{s6qha57m.js → 19msgrsc.js} +2 -2
- package/dist/tooling/shared/{3yn79q5m.js → 1fwfm5m3.js} +1 -1
- package/dist/tooling/shared/{hfq3n3bd.js → 2jdn09e2.js} +55 -5
- package/dist/tooling/shared/{v6j1ep6w.js → 2qrte2ct.js} +5 -5
- package/dist/tooling/shared/{yb4kd19s.js → 2v4nwnkb.js} +1 -1
- package/dist/tooling/shared/{ezqn88nj.js → 33z39trp.js} +106 -23
- package/dist/tooling/shared/{0r05zhyq.js → 353vnw9z.js} +5 -5
- package/dist/tooling/shared/{m4hhb8aa.js → 390kry9g.js} +2 -2
- package/dist/tooling/shared/{rcywj2w8.js → 3f6etb9z.js} +18 -31
- package/dist/tooling/shared/{9wsnsvbf.js → 3t2cqmsx.js} +1 -1
- package/dist/tooling/shared/{5zrzffnk.js → 4dzvjtpy.js} +1 -1
- package/dist/tooling/shared/{am04v8na.js → 4ec0nxvw.js} +10 -10
- package/dist/tooling/shared/{04svnxxj.js → 4tg2bn41.js} +59 -78
- package/dist/tooling/shared/{829fjxyw.js → 5rah55z0.js} +2 -2
- package/dist/tooling/shared/{c0xevn1h.js → 804w1t69.js} +4 -4
- package/dist/tooling/shared/{dhatassp.js → 8g0m0rvd.js} +6 -6
- package/dist/tooling/shared/{zx3v9phv.js → 8msbtw5s.js} +1 -1
- package/dist/tooling/shared/{7pxncnzs.js → 8t22h3h7.js} +2 -2
- package/dist/tooling/shared/{wbwq1jsa.js → 91c59b7b.js} +2 -2
- package/dist/tooling/shared/{a2xe04bm.js → adk9k6va.js} +1 -1
- package/dist/tooling/shared/{w17sj05d.js → ajjd5cwz.js} +2 -2
- package/dist/tooling/shared/{35zemrmf.js → angjck01.js} +1 -1
- package/dist/tooling/shared/{jsjjz875.js → asnnc3v5.js} +1 -1
- package/dist/tooling/shared/{5bmksndh.js → bj1kyqc8.js} +2 -2
- package/dist/tooling/shared/{kbqnrs1x.js → bt3tjemb.js} +11 -3
- package/dist/tooling/shared/{vwr2y833.js → chk2bh4f.js} +2 -2
- package/dist/tooling/shared/{ybdew6j7.js → ckq4z5ax.js} +5 -2
- package/dist/tooling/shared/{3rmaz3pq.js → d3rhb24q.js} +1 -1
- package/dist/tooling/shared/{mw5npye0.js → d8q00vxg.js} +4 -4
- package/dist/tooling/shared/{j664qjrt.js → dx188rxs.js} +2 -2
- package/dist/tooling/shared/{8yr7ges1.js → efq6p9df.js} +35 -42
- package/dist/tooling/shared/{yhp829bx.js → en6rwzq0.js} +3 -3
- package/dist/tooling/shared/{f77nnfqy.js → f2r5g0fs.js} +2 -2
- package/dist/tooling/shared/{zs9aymcp.js → f4gep0nk.js} +1 -1
- package/dist/tooling/shared/{kz715295.js → f8a010fm.js} +13 -11
- package/dist/tooling/shared/{w5d89rb4.js → fdsek6pa.js} +1 -1
- package/dist/tooling/shared/fvmrxsd1.js +8 -0
- package/dist/tooling/shared/{jpgmjsx3.js → g3xybeqf.js} +4 -3
- package/dist/tooling/shared/{wezxf3h8.js → gefmpwsa.js} +1 -1
- package/dist/tooling/shared/{jr2nmr81.js → gjj71hfh.js} +23 -20
- package/dist/tooling/shared/{9sfbtwsk.js → jgzt69pa.js} +5 -5
- package/dist/tooling/shared/{a4pzghha.js → jm30k2ca.js} +10 -8
- package/dist/tooling/shared/{shjs0379.js → kayqzpbk.js} +6 -3
- package/dist/tooling/shared/{tcwpjvxe.js → kvw1672d.js} +1 -1
- package/dist/tooling/shared/{stebqyyd.js → mr1kcgpw.js} +3 -3
- package/dist/tooling/shared/{tpssp7ac.js → mwbdf409.js} +1 -1
- package/dist/tooling/shared/{fh07z1dt.js → ns9207v3.js} +1 -1
- package/dist/tooling/shared/{5p8km5jb.js → p6tjv97k.js} +3 -3
- package/dist/tooling/shared/{ytk1tjs0.js → p73evwf0.js} +1 -1
- package/dist/tooling/shared/{8m5znpdt.js → phc1nc4g.js} +1 -1
- package/dist/tooling/shared/{asgr07mp.js → ppybjw50.js} +79 -16
- package/dist/tooling/shared/{t4xveemq.js → qdrn8ghn.js} +5 -4
- package/dist/tooling/shared/rd8h01ta.js +20 -0
- package/dist/tooling/shared/{7aews1zg.js → rwg8y90m.js} +3 -3
- package/dist/tooling/shared/{5x3pf400.js → ry2f3w8p.js} +3 -3
- package/dist/tooling/shared/{m3xt8b1h.js → ryc5sa58.js} +8 -8
- package/dist/tooling/shared/{57btdkgm.js → ss87qxwv.js} +2 -2
- package/dist/tooling/shared/{6vk28rjp.js → vg68k11z.js} +3 -3
- package/dist/tooling/shared/{62fxpc1p.js → vms9dta5.js} +73 -89
- package/dist/tooling/shared/{gqwevek4.js → xchpnbdv.js} +1 -1
- package/dist/tooling/shared/{t6zjeake.js → xn6p01fh.js} +5 -5
- package/dist/tooling/shared/{7b3xp9gc.js → xwr6q618.js} +3 -3
- package/dist/tooling/shared/{yfedr1zb.js → xx3gmq94.js} +1 -1
- package/dist/tooling/shared/{9qr9rkbh.js → y2bd7yfx.js} +21 -13
- package/dist/tooling/shared/{nxq95eb6.js → y4gq9rbe.js} +11 -11
- package/dist/tooling/shared/{76pv6qff.js → y4vwft92.js} +2 -2
- package/dist/tooling/shared/{sjwkt1pg.js → yz68xcmc.js} +1 -1
- package/dist/tooling/testing/factories.d.ts +1 -3
- package/dist/tooling/testing/index.js +1 -1
- package/package.json +2 -1
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./cm3w0ywp.js";
|
|
5
5
|
import {
|
|
6
6
|
PgSession
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./jvxcp1qk.js";
|
|
8
8
|
import {
|
|
9
9
|
isConnectionLost
|
|
10
10
|
} from "./cnkky55j.js";
|
|
@@ -80,18 +80,12 @@ async function checkout2(pool, timeoutMs) {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
async function describe2(sql, text, params) {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
columns: described.columns.map((column) => column.name),
|
|
87
|
-
parameterCount: described.types.length
|
|
88
|
-
};
|
|
83
|
+
const d = await sql.unsafe(text, asParams(params), { prepare: true }).describe();
|
|
84
|
+
return { columns: d.columns.map((c) => c.name), parameterCount: d.types.length };
|
|
89
85
|
}
|
|
90
86
|
async function* stream2(sql, text, params) {
|
|
91
|
-
const
|
|
92
|
-
for await (const chunk of pending.cursor(64)) {
|
|
87
|
+
for await (const chunk of sql.unsafe(text, asParams(params)).cursor(64))
|
|
93
88
|
yield rowsFrom(chunk);
|
|
94
|
-
}
|
|
95
89
|
}
|
|
96
90
|
function poolWaits(sql) {
|
|
97
91
|
const options = sql.options;
|
|
@@ -105,14 +99,14 @@ function poolWaits(sql) {
|
|
|
105
99
|
n.add(id);
|
|
106
100
|
if (n.size < options.max) {
|
|
107
101
|
queueMicrotask(() => {
|
|
108
|
-
for (const
|
|
109
|
-
|
|
102
|
+
for (const w of q)
|
|
103
|
+
w.a();
|
|
110
104
|
});
|
|
111
105
|
return;
|
|
112
106
|
}
|
|
113
107
|
n.clear();
|
|
114
|
-
for (const
|
|
115
|
-
|
|
108
|
+
for (const w of q)
|
|
109
|
+
w.s();
|
|
116
110
|
q.clear();
|
|
117
111
|
};
|
|
118
112
|
return options;
|
|
@@ -194,41 +188,40 @@ function reserveConnection(sql, acquireMs, counters, callMs) {
|
|
|
194
188
|
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
195
189
|
};
|
|
196
190
|
return new Promise((resolve, reject) => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
timer = setTimeout(() => {
|
|
200
|
-
if (settled)
|
|
201
|
-
return;
|
|
202
|
-
settled = true;
|
|
203
|
-
finish();
|
|
204
|
-
driverErrors().then((errors) => {
|
|
205
|
-
reject(errors.acquireTimeout());
|
|
206
|
-
});
|
|
207
|
-
}, acquireMs);
|
|
208
|
-
}
|
|
209
|
-
const ms = callMs !== undefined && callMs > 0 ? callMs : 0;
|
|
210
|
-
deadline(ms, () => sql.reserve(), sql).then((connection) => {
|
|
211
|
-
if (settled) {
|
|
212
|
-
resetConnection(connection, 0).catch(() => {
|
|
213
|
-
return;
|
|
214
|
-
}).finally(() => {
|
|
215
|
-
connection.release();
|
|
216
|
-
});
|
|
191
|
+
const timer = acquireMs === undefined ? undefined : setTimeout(() => {
|
|
192
|
+
if (settled)
|
|
217
193
|
return;
|
|
218
|
-
}
|
|
219
194
|
settled = true;
|
|
220
|
-
if (timer !== undefined)
|
|
221
|
-
clearTimeout(timer);
|
|
222
195
|
finish();
|
|
223
|
-
|
|
224
|
-
|
|
196
|
+
driverErrors().then((errors) => {
|
|
197
|
+
reject(errors.acquireTimeout());
|
|
198
|
+
});
|
|
199
|
+
}, acquireMs);
|
|
200
|
+
const done = (fn) => {
|
|
225
201
|
if (settled)
|
|
226
202
|
return;
|
|
227
203
|
settled = true;
|
|
228
204
|
if (timer !== undefined)
|
|
229
205
|
clearTimeout(timer);
|
|
230
206
|
finish();
|
|
231
|
-
|
|
207
|
+
fn();
|
|
208
|
+
};
|
|
209
|
+
deadline(callMs !== undefined && callMs > 0 ? callMs : 0, () => sql.reserve(), sql).then((connection) => {
|
|
210
|
+
if (settled) {
|
|
211
|
+
resetConnection(connection, 0).catch(() => {
|
|
212
|
+
return;
|
|
213
|
+
}).finally(() => {
|
|
214
|
+
connection.release();
|
|
215
|
+
});
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
done(() => {
|
|
219
|
+
resolve(connection);
|
|
220
|
+
});
|
|
221
|
+
}, (error) => {
|
|
222
|
+
done(() => {
|
|
223
|
+
mapFailure(error).then(reject);
|
|
224
|
+
});
|
|
232
225
|
});
|
|
233
226
|
});
|
|
234
227
|
}
|
|
@@ -237,25 +230,20 @@ async function resetConnection(sql, depth) {
|
|
|
237
230
|
await sql.unsafe("ROLLBACK").catch(() => {
|
|
238
231
|
return;
|
|
239
232
|
});
|
|
240
|
-
|
|
233
|
+
const clear = async () => {
|
|
241
234
|
await sql.unsafe(RESET_ALL);
|
|
242
235
|
await sql.unsafe(UNLOCK);
|
|
236
|
+
};
|
|
237
|
+
try {
|
|
238
|
+
await clear();
|
|
243
239
|
} catch {
|
|
244
240
|
await sql.unsafe("ROLLBACK").catch(() => {
|
|
245
241
|
return;
|
|
246
242
|
});
|
|
247
|
-
await
|
|
248
|
-
await sql.unsafe(UNLOCK);
|
|
243
|
+
await clear();
|
|
249
244
|
}
|
|
250
245
|
}
|
|
251
|
-
|
|
252
|
-
if (params === undefined)
|
|
253
|
-
return [];
|
|
254
|
-
return params;
|
|
255
|
-
}
|
|
256
|
-
function watchReserved2(sql, lost) {
|
|
257
|
-
arm(sql, lost);
|
|
258
|
-
}
|
|
246
|
+
var asParams = (params) => params ?? [];
|
|
259
247
|
function arm(sql, lost) {
|
|
260
248
|
const unsafe = sql.unsafe.bind(sql);
|
|
261
249
|
sql.unsafe = (text, params, options) => unsafe(text, params, {
|
|
@@ -268,19 +256,13 @@ function arm(sql, lost) {
|
|
|
268
256
|
}
|
|
269
257
|
});
|
|
270
258
|
}
|
|
259
|
+
var watchReserved2 = arm;
|
|
271
260
|
async function holdCheckout2(gate, checkout) {
|
|
272
261
|
try {
|
|
273
262
|
const connection = await checkout();
|
|
274
263
|
let released = false;
|
|
275
264
|
const release = connection.release.bind(connection);
|
|
276
|
-
connection.release = () =>
|
|
277
|
-
if (released)
|
|
278
|
-
return Promise.resolve();
|
|
279
|
-
released = true;
|
|
280
|
-
return release().finally(() => {
|
|
281
|
-
gate.leave();
|
|
282
|
-
});
|
|
283
|
-
};
|
|
265
|
+
connection.release = () => released ? Promise.resolve() : (released = true, release().finally(() => gate.leave()));
|
|
284
266
|
return connection;
|
|
285
267
|
} catch (error) {
|
|
286
268
|
gate.leave();
|
|
@@ -295,11 +277,9 @@ async function holdListener2(gate, start) {
|
|
|
295
277
|
if (stopped)
|
|
296
278
|
return;
|
|
297
279
|
stopped = true;
|
|
298
|
-
|
|
299
|
-
await stop();
|
|
300
|
-
} finally {
|
|
280
|
+
await stop().finally(() => {
|
|
301
281
|
gate.leave();
|
|
302
|
-
}
|
|
282
|
+
});
|
|
303
283
|
};
|
|
304
284
|
} catch (error) {
|
|
305
285
|
gate.leave();
|
|
@@ -307,36 +287,35 @@ async function holdListener2(gate, start) {
|
|
|
307
287
|
}
|
|
308
288
|
}
|
|
309
289
|
function watchQuery2(pending, watch, onAbort, ctx) {
|
|
290
|
+
const done = () => {
|
|
291
|
+
ctx.leave();
|
|
292
|
+
ctx.untrack(pending);
|
|
293
|
+
watch.signal.removeEventListener("abort", onAbort);
|
|
294
|
+
};
|
|
310
295
|
return pending.then((value) => {
|
|
311
|
-
|
|
296
|
+
done();
|
|
312
297
|
const why = watch.reason();
|
|
313
298
|
if (why === "timeout" || why === "cancelled")
|
|
314
299
|
return classify(why, watch);
|
|
315
300
|
ctx.note(ctx.text);
|
|
316
301
|
return resultFrom(value, ctx.notices.since(ctx.start));
|
|
317
302
|
}, (error) => {
|
|
318
|
-
|
|
303
|
+
done();
|
|
319
304
|
return classify(error, watch);
|
|
320
305
|
});
|
|
321
306
|
}
|
|
322
|
-
function finishWatch(pending, watch, onAbort, ctx) {
|
|
323
|
-
ctx.leave();
|
|
324
|
-
ctx.untrack(pending);
|
|
325
|
-
watch.signal.removeEventListener("abort", onAbort);
|
|
326
|
-
}
|
|
327
307
|
async function classify(error, watch) {
|
|
328
308
|
const errors = await driverErrors();
|
|
329
309
|
if (error instanceof errors.DriverError)
|
|
330
|
-
|
|
310
|
+
throw error;
|
|
331
311
|
const why = typeof error === "string" ? error : watch.reason();
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
return Promise.reject(errors.cancelled(typeof error === "string" ? undefined : error));
|
|
312
|
+
const cause = typeof error === "string" ? undefined : error;
|
|
313
|
+
if (why === "timeout")
|
|
314
|
+
throw errors.timedOut(cause);
|
|
315
|
+
if (why === "cancelled" || errors.errorField(error, "code") === "57014") {
|
|
316
|
+
throw errors.cancelled(cause);
|
|
338
317
|
}
|
|
339
|
-
|
|
318
|
+
throw errors.mapDriverError(error);
|
|
340
319
|
}
|
|
341
320
|
|
|
342
321
|
export { checkout2, describe2, stream2, runBatch2, watchReserved2, holdCheckout2, holdListener2, watchQuery2 };
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
open2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./jvxcp1qk.js";
|
|
4
4
|
import"./12z7aznj.js";
|
|
5
5
|
import"./fk9vef30.js";
|
|
6
6
|
import"./n442h54c.js";
|
|
7
7
|
import {
|
|
8
8
|
assertRoleHealth
|
|
9
|
-
} from "./
|
|
10
|
-
import"./
|
|
9
|
+
} from "./6xqvesa5.js";
|
|
10
|
+
import"./mz48rs74.js";
|
|
11
11
|
import {
|
|
12
12
|
errorDoc,
|
|
13
13
|
openProject
|
|
14
|
-
} from "./
|
|
14
|
+
} from "./wp7y8q3y.js";
|
|
15
15
|
import {
|
|
16
|
+
driverUrl,
|
|
16
17
|
omitManagedObjects,
|
|
17
18
|
sessionFailure,
|
|
18
19
|
finishQuiet,
|
|
19
20
|
assertTargetPolicy,
|
|
20
21
|
selectTarget
|
|
21
|
-
} from "./
|
|
22
|
+
} from "./bdekbvmt.js";
|
|
22
23
|
import {
|
|
23
24
|
OkmError2
|
|
24
25
|
} from "./52szzakm.js";
|
|
@@ -42,7 +43,7 @@ ${doc.fix}
|
|
|
42
43
|
if (opened.config.roles !== undefined) {
|
|
43
44
|
const target = selectTarget(opened.config, flags?.target);
|
|
44
45
|
assertTargetPolicy(target, "check", flags?.allowProtected ?? false);
|
|
45
|
-
const pool = open2({ url: target.url, max: 1 });
|
|
46
|
+
const pool = open2({ url: driverUrl(target.url), max: 1 });
|
|
46
47
|
try {
|
|
47
48
|
await assertRoleHealth(pool, opened.config.roles, objects);
|
|
48
49
|
} catch (error) {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./typ3vy7t.js";
|
|
9
9
|
import {
|
|
10
10
|
snakeCase
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./f9t9g54z.js";
|
|
12
12
|
import {
|
|
13
13
|
OkmError2
|
|
14
14
|
} from "./52szzakm.js";
|
|
@@ -85,7 +85,7 @@ function viewClient(name, columns, query, tenancy, refresh = "plain") {
|
|
|
85
85
|
}
|
|
86
86
|
function refreshHandle(session, name, mode) {
|
|
87
87
|
const concurrently = mode === "concurrently";
|
|
88
|
-
return () => lazyRefresh(() => import("./
|
|
88
|
+
return () => lazyRefresh(() => import("./ymenf259.js").then((mod) => mod.refreshView(session, name, concurrently)));
|
|
89
89
|
}
|
|
90
90
|
function lazyRefresh(run) {
|
|
91
91
|
let pending;
|
|
@@ -7,23 +7,28 @@ import {
|
|
|
7
7
|
quoteIdent2,
|
|
8
8
|
createObjectSql2
|
|
9
9
|
} from "./fk9vef30.js";
|
|
10
|
+
import {
|
|
11
|
+
probeStableBackend
|
|
12
|
+
} from "./e1c55v04.js";
|
|
10
13
|
import {
|
|
11
14
|
cellText,
|
|
12
15
|
VIEW_DEPENDENCIES,
|
|
13
16
|
viewDependencyEdges,
|
|
14
17
|
PUBLIC,
|
|
15
18
|
introspectSchema,
|
|
16
|
-
atomicBody
|
|
17
|
-
|
|
19
|
+
atomicBody,
|
|
20
|
+
reprintDomainCheck
|
|
21
|
+
} from "./mz48rs74.js";
|
|
18
22
|
import {
|
|
23
|
+
driverUrl,
|
|
19
24
|
planMigration,
|
|
20
25
|
sessionFailure,
|
|
21
26
|
finishQuiet,
|
|
22
|
-
assertDirectConnection
|
|
23
|
-
|
|
24
|
-
} from "./6nae0spm.js";
|
|
27
|
+
assertDirectConnection
|
|
28
|
+
} from "./bdekbvmt.js";
|
|
25
29
|
import {
|
|
26
|
-
catalog
|
|
30
|
+
catalog,
|
|
31
|
+
isDomain
|
|
27
32
|
} from "./ywspezzx.js";
|
|
28
33
|
import {
|
|
29
34
|
OkmError2
|
|
@@ -58,8 +63,10 @@ async function sealViews(runner, source) {
|
|
|
58
63
|
const previous = await runner.query(`select current_setting('search_path') as path`);
|
|
59
64
|
const saved = cellText(previous[0]?.path);
|
|
60
65
|
const path = await scratchSearchPath(runner, source);
|
|
66
|
+
let installed = [];
|
|
61
67
|
try {
|
|
62
68
|
await runner.query(`select set_config('search_path', $1, false)`, [path]);
|
|
69
|
+
installed = await createExtensions(runner, source);
|
|
63
70
|
await createObjects(runner, source, "type");
|
|
64
71
|
for (const object of source.objects) {
|
|
65
72
|
if (object.kind !== "table")
|
|
@@ -116,6 +123,7 @@ async function sealViews(runner, source) {
|
|
|
116
123
|
return;
|
|
117
124
|
});
|
|
118
125
|
await dropScratch(runner);
|
|
126
|
+
await dropInstalledExtensions(runner, installed);
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
129
|
async function scratchSearchPath(runner, source) {
|
|
@@ -152,6 +160,32 @@ async function createObjects(runner, source, kind) {
|
|
|
152
160
|
await runner.query(statement);
|
|
153
161
|
}
|
|
154
162
|
}
|
|
163
|
+
async function createExtensions(runner, source) {
|
|
164
|
+
const installed = [];
|
|
165
|
+
for (const object of source.objects) {
|
|
166
|
+
if (object.kind !== "extension")
|
|
167
|
+
continue;
|
|
168
|
+
const name = object.identity.name;
|
|
169
|
+
const present = await runner.query(`select 1 as ok from pg_extension where extname = $1`, [
|
|
170
|
+
name
|
|
171
|
+
]);
|
|
172
|
+
if (present.length > 0)
|
|
173
|
+
continue;
|
|
174
|
+
const statement = createObjectSql2(object, SCRATCH);
|
|
175
|
+
if (statement === undefined)
|
|
176
|
+
continue;
|
|
177
|
+
await runner.query(statement);
|
|
178
|
+
installed.push(name);
|
|
179
|
+
}
|
|
180
|
+
return installed;
|
|
181
|
+
}
|
|
182
|
+
async function dropInstalledExtensions(runner, names) {
|
|
183
|
+
for (const name of names) {
|
|
184
|
+
await runner.query(`drop extension if exists ${quoteIdent2(name)}`).catch(() => {
|
|
185
|
+
return;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
155
189
|
var FUNCTION_DEFS = `
|
|
156
190
|
select p.proname as name,
|
|
157
191
|
pg_get_function_identity_arguments(p.oid) as args,
|
|
@@ -393,14 +427,14 @@ async function dropScratch(runner) {
|
|
|
393
427
|
// src/tooling/migrate/drift.ts
|
|
394
428
|
async function assertAuthorDrift2(url, author, roles, allowPooler = false) {
|
|
395
429
|
assertDirectConnection(url, allowPooler);
|
|
396
|
-
const sql = postgres(url, {
|
|
430
|
+
const sql = postgres(driverUrl(url), {
|
|
397
431
|
max: 1,
|
|
398
432
|
connect_timeout: 5,
|
|
399
433
|
idle_timeout: 1,
|
|
400
434
|
onnotice: () => {}
|
|
401
435
|
});
|
|
402
436
|
try {
|
|
403
|
-
await
|
|
437
|
+
await probeStableBackend(url, async () => {
|
|
404
438
|
const rows = await sql`select pg_backend_pid()::text as pid`;
|
|
405
439
|
return rows[0]?.pid ?? "";
|
|
406
440
|
}, allowPooler);
|
|
@@ -411,7 +445,7 @@ async function assertAuthorDrift2(url, author, roles, allowPooler = false) {
|
|
|
411
445
|
if (present[0]?.reg == null)
|
|
412
446
|
return;
|
|
413
447
|
const runner = catalogQuery2(sql);
|
|
414
|
-
const authorOnServer = await sealViews(runner, author);
|
|
448
|
+
const authorOnServer = await sealDomainChecks2(runner, await sealViews(runner, author));
|
|
415
449
|
const live = await introspectSchema(runner, schema, schema, managedRoleOptions2(roles));
|
|
416
450
|
const plan = planMigration({ before: live, after: authorOnServer, name: "check" });
|
|
417
451
|
if (plan.steps.length === 0)
|
|
@@ -429,6 +463,27 @@ ${plan.steps.map((step) => step.sql).join(`
|
|
|
429
463
|
await finishQuiet(() => sql.end({ timeout: 5 }));
|
|
430
464
|
}
|
|
431
465
|
}
|
|
466
|
+
async function sealDomainChecks2(runner, source) {
|
|
467
|
+
const objects = [];
|
|
468
|
+
let changed = false;
|
|
469
|
+
for (const object of source.objects) {
|
|
470
|
+
if (object.kind !== "type" || !isDomain(object.definition)) {
|
|
471
|
+
objects.push(object);
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
const reprinted = await reprintDomainCheck(runner, object.definition.base, object.definition.check);
|
|
475
|
+
if (reprinted === object.definition.check) {
|
|
476
|
+
objects.push(object);
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
changed = true;
|
|
480
|
+
objects.push({
|
|
481
|
+
...object,
|
|
482
|
+
definition: { ...object.definition, check: reprinted }
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
return changed ? { version: source.version, objects } : source;
|
|
486
|
+
}
|
|
432
487
|
function catalogQuery2(sql) {
|
|
433
488
|
return {
|
|
434
489
|
async query(text, params) {
|
|
@@ -473,4 +528,4 @@ function managedRoleNames(roles) {
|
|
|
473
528
|
return [...names];
|
|
474
529
|
}
|
|
475
530
|
|
|
476
|
-
export { sealViews, assertAuthorDrift2, catalogQuery2, managedRoleOptions2 };
|
|
531
|
+
export { sealViews, assertAuthorDrift2, sealDomainChecks2, catalogQuery2, managedRoleOptions2 };
|
|
@@ -117,7 +117,7 @@ async function openWebSocket(config) {
|
|
|
117
117
|
counters.busy = Math.max(0, counters.busy - 1);
|
|
118
118
|
});
|
|
119
119
|
const held = { pool, acquireMs, counters, notices, named, isClosed };
|
|
120
|
-
const checkout = () => closed ? rejectClosed() : import("./
|
|
120
|
+
const checkout = () => closed ? rejectClosed() : import("./wbdh9qbg.js").then((mod) => mod.checkout(held));
|
|
121
121
|
return {
|
|
122
122
|
capabilities: NEON_WEBSOCKET_CAPABILITIES,
|
|
123
123
|
execute(text, params, options) {
|