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
|
@@ -1,63 +1,73 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseCatalog2
|
|
3
3
|
} from "./12z7aznj.js";
|
|
4
|
+
import {
|
|
5
|
+
quoteIdent2
|
|
6
|
+
} from "./fk9vef30.js";
|
|
4
7
|
import"./n442h54c.js";
|
|
5
8
|
import"./cm3w0ywp.js";
|
|
6
|
-
import"./
|
|
9
|
+
import"./jvxcp1qk.js";
|
|
7
10
|
import {
|
|
8
11
|
watchReserved2
|
|
9
|
-
} from "./
|
|
10
|
-
import {
|
|
11
|
-
ensureMigrationTables2
|
|
12
|
-
} from "./pan0370z.js";
|
|
12
|
+
} from "./3dr444ny.js";
|
|
13
13
|
import {
|
|
14
14
|
sealViews,
|
|
15
15
|
catalogQuery2,
|
|
16
16
|
managedRoleOptions2
|
|
17
|
-
} from "./
|
|
17
|
+
} from "./4pkz5nvw.js";
|
|
18
|
+
import {
|
|
19
|
+
ensureMigrationTables2
|
|
20
|
+
} from "./8ma6drzr.js";
|
|
18
21
|
import {
|
|
19
22
|
assumeRole,
|
|
20
23
|
grantSchema,
|
|
24
|
+
ownSchema,
|
|
21
25
|
assertSchemaUsageLanded,
|
|
22
26
|
catalogsEqual,
|
|
23
27
|
snapshotDifference
|
|
24
|
-
} from "./
|
|
28
|
+
} from "./8p2bgye0.js";
|
|
25
29
|
import {
|
|
26
30
|
roleExists
|
|
27
|
-
} from "./
|
|
31
|
+
} from "./6xqvesa5.js";
|
|
32
|
+
import {
|
|
33
|
+
probeStableBackend
|
|
34
|
+
} from "./e1c55v04.js";
|
|
28
35
|
import {
|
|
29
36
|
introspectSchema
|
|
30
|
-
} from "./
|
|
37
|
+
} from "./mz48rs74.js";
|
|
31
38
|
import {
|
|
32
39
|
projectPath,
|
|
40
|
+
loadSnapshots,
|
|
41
|
+
assertSnapshots,
|
|
42
|
+
assertLiveExternal,
|
|
33
43
|
loadMigrations,
|
|
34
44
|
readMigrationPlan,
|
|
45
|
+
lintReprints,
|
|
35
46
|
lintMigrationDirectory,
|
|
47
|
+
formatFindings,
|
|
36
48
|
hasError,
|
|
37
49
|
lintRefusal,
|
|
38
50
|
openProject
|
|
39
|
-
} from "./
|
|
51
|
+
} from "./wp7y8q3y.js";
|
|
40
52
|
import {
|
|
53
|
+
driverUrl,
|
|
41
54
|
sqlStatements,
|
|
42
55
|
transactionControl,
|
|
43
56
|
canonicalTypeName,
|
|
44
57
|
createdRoleName,
|
|
45
58
|
createRoleOnce,
|
|
59
|
+
changesRole,
|
|
46
60
|
classOf,
|
|
47
61
|
strictestClass,
|
|
48
62
|
planMigration,
|
|
49
63
|
sessionFailure,
|
|
50
64
|
finishQuiet,
|
|
51
65
|
assertDirectConnection,
|
|
52
|
-
assertStableBackend,
|
|
53
66
|
selectTarget
|
|
54
|
-
} from "./
|
|
67
|
+
} from "./bdekbvmt.js";
|
|
55
68
|
import {
|
|
56
69
|
isConnectionLost
|
|
57
70
|
} from "./cnkky55j.js";
|
|
58
|
-
import {
|
|
59
|
-
quoteIdent
|
|
60
|
-
} from "./sjk86yrx.js";
|
|
61
71
|
import {
|
|
62
72
|
catalog,
|
|
63
73
|
isDomain
|
|
@@ -77,6 +87,7 @@ import { join } from "node:path";
|
|
|
77
87
|
import postgres from "postgres";
|
|
78
88
|
async function replayCheckHistory(url, scratch, config, allowPooler, history) {
|
|
79
89
|
const skips = [];
|
|
90
|
+
const reprints = [];
|
|
80
91
|
let stop;
|
|
81
92
|
await inCheckTransaction(url, scratch, config, allowPooler, async (sql) => {
|
|
82
93
|
const connection = driverOf(sql);
|
|
@@ -88,7 +99,10 @@ async function replayCheckHistory(url, scratch, config, allowPooler, history) {
|
|
|
88
99
|
await replayMigration(sql, connection, scratch, config, migration, session, skips);
|
|
89
100
|
await restoreSession(sql, session);
|
|
90
101
|
const runner = catalogQuery2(sql);
|
|
91
|
-
const live = await introspectSchema(runner, scratch, "public", managedRoleOptions2(config.roles));
|
|
102
|
+
const live = await introspectSchema(runner, scratch, config.namespace ?? "public", managedRoleOptions2(config.roles));
|
|
103
|
+
for (const item of lintReprints(migration.catalog, live, migration.steps)) {
|
|
104
|
+
reprints.push({ ...item, place: `${migration.id} ${item.place}` });
|
|
105
|
+
}
|
|
92
106
|
const sealed = await sealViews(runner, migration.catalog);
|
|
93
107
|
const back = planMigration({ before: live, after: sealed, name: migration.id });
|
|
94
108
|
if (back.steps.length === 0)
|
|
@@ -97,7 +111,7 @@ async function replayCheckHistory(url, scratch, config, allowPooler, history) {
|
|
|
97
111
|
return;
|
|
98
112
|
}
|
|
99
113
|
});
|
|
100
|
-
return stop === undefined ? { skips } : { skips, stop };
|
|
114
|
+
return stop === undefined ? { skips, reprints } : { skips, reprints, stop };
|
|
101
115
|
}
|
|
102
116
|
async function proveCheckSnapshot(url, provided, replayed, config, allowPooler, history) {
|
|
103
117
|
const head = history.at(-1);
|
|
@@ -115,10 +129,10 @@ async function proveCheckSnapshot(url, provided, replayed, config, allowPooler,
|
|
|
115
129
|
await runSteps(sql, connection, provided, config.roles?.migration, {
|
|
116
130
|
id: "snapshot",
|
|
117
131
|
catalog: head.catalog,
|
|
118
|
-
steps: retargetSteps(planned.steps, provided)
|
|
132
|
+
steps: retargetSteps(planned.steps, provided, config.namespace ?? "public")
|
|
119
133
|
}, session, []);
|
|
120
134
|
await restoreSession(sql, session);
|
|
121
|
-
return introspectSchema(catalogQuery2(sql), provided, "public", managedRoleOptions2(config.roles));
|
|
135
|
+
return introspectSchema(catalogQuery2(sql), provided, config.namespace ?? "public", managedRoleOptions2(config.roles));
|
|
122
136
|
});
|
|
123
137
|
const again = await inCheckTransaction(url, replayed, config, allowPooler, async (sql) => {
|
|
124
138
|
const connection = driverOf(sql);
|
|
@@ -127,17 +141,17 @@ async function proveCheckSnapshot(url, provided, replayed, config, allowPooler,
|
|
|
127
141
|
await replayMigration(sql, connection, replayed, config, migration, session, []);
|
|
128
142
|
}
|
|
129
143
|
await restoreSession(sql, session);
|
|
130
|
-
return introspectSchema(catalogQuery2(sql), replayed, "public", managedRoleOptions2(config.roles));
|
|
144
|
+
return introspectSchema(catalogQuery2(sql), replayed, config.namespace ?? "public", managedRoleOptions2(config.roles));
|
|
131
145
|
});
|
|
132
146
|
return snapshotDifference(installed, again);
|
|
133
147
|
}
|
|
134
|
-
function retargetSteps(steps, schema) {
|
|
135
|
-
const from = `${
|
|
136
|
-
const to = `${
|
|
137
|
-
const fromDefaults = `in schema ${
|
|
138
|
-
const toDefaults = `in schema ${
|
|
139
|
-
const fromSchema = `on schema ${
|
|
140
|
-
const toSchema = `on schema ${
|
|
148
|
+
function retargetSteps(steps, schema, source = "public") {
|
|
149
|
+
const from = `${quoteIdent2(source)}.`;
|
|
150
|
+
const to = `${quoteIdent2(schema)}.`;
|
|
151
|
+
const fromDefaults = `in schema ${quoteIdent2(source)} `;
|
|
152
|
+
const toDefaults = `in schema ${quoteIdent2(schema)} `;
|
|
153
|
+
const fromSchema = `on schema ${quoteIdent2(source)}`;
|
|
154
|
+
const toSchema = `on schema ${quoteIdent2(schema)}`;
|
|
141
155
|
return steps.map((step) => ({
|
|
142
156
|
...step,
|
|
143
157
|
sql: step.sql.replaceAll(from, to).replaceAll(fromDefaults, toDefaults).replaceAll(fromSchema, toSchema),
|
|
@@ -145,7 +159,7 @@ function retargetSteps(steps, schema) {
|
|
|
145
159
|
}));
|
|
146
160
|
}
|
|
147
161
|
async function inCheckTransaction(url, scratch, config, allowPooler, run) {
|
|
148
|
-
const sql = postgres(url, {
|
|
162
|
+
const sql = postgres(driverUrl(url), {
|
|
149
163
|
max: 1,
|
|
150
164
|
connect_timeout: 5,
|
|
151
165
|
idle_timeout: 1,
|
|
@@ -165,7 +179,7 @@ async function inCheckTransaction(url, scratch, config, allowPooler, run) {
|
|
|
165
179
|
let rolledBack = false;
|
|
166
180
|
let xid = "";
|
|
167
181
|
try {
|
|
168
|
-
await
|
|
182
|
+
await probeStableBackend(url, async () => {
|
|
169
183
|
const rows = await reserved.unsafe("select pg_backend_pid()::text as pid");
|
|
170
184
|
const pid = cell(rows[0], "pid");
|
|
171
185
|
return pid ?? "";
|
|
@@ -173,9 +187,9 @@ async function inCheckTransaction(url, scratch, config, allowPooler, run) {
|
|
|
173
187
|
await reserved.unsafe("begin");
|
|
174
188
|
open = true;
|
|
175
189
|
xid = await readXid(reserved);
|
|
176
|
-
await reserved.unsafe(`create schema ${
|
|
190
|
+
await reserved.unsafe(`create schema ${quoteIdent2(scratch)}`);
|
|
177
191
|
created = true;
|
|
178
|
-
await reserved.unsafe(`set local search_path to ${
|
|
192
|
+
await reserved.unsafe(`set local search_path to ${quoteIdent2(scratch)}`);
|
|
179
193
|
await setLocalTimeout(reserved, "lock_timeout", config.timeouts?.lock);
|
|
180
194
|
await setLocalTimeout(reserved, "statement_timeout", config.timeouts?.statement);
|
|
181
195
|
await ownScratch(reserved, scratch, config.roles?.migration);
|
|
@@ -264,14 +278,14 @@ function closedError() {
|
|
|
264
278
|
return Object.assign(new Error("CONNECTION_CLOSED"), { code: "CONNECTION_CLOSED" });
|
|
265
279
|
}
|
|
266
280
|
async function dropScratch(url, scratch) {
|
|
267
|
-
const sql = postgres(url, {
|
|
281
|
+
const sql = postgres(driverUrl(url), {
|
|
268
282
|
max: 1,
|
|
269
283
|
connect_timeout: 5,
|
|
270
284
|
idle_timeout: 1,
|
|
271
285
|
onnotice: () => {}
|
|
272
286
|
});
|
|
273
287
|
try {
|
|
274
|
-
await sql.unsafe(`drop schema if exists ${
|
|
288
|
+
await sql.unsafe(`drop schema if exists ${quoteIdent2(scratch)} cascade`);
|
|
275
289
|
const rows = await sql`
|
|
276
290
|
select nspname from pg_namespace where nspname = ${scratch}
|
|
277
291
|
`;
|
|
@@ -299,7 +313,7 @@ async function restoreSession(sql, session) {
|
|
|
299
313
|
delete session.setRole;
|
|
300
314
|
}
|
|
301
315
|
async function replayMigration(sql, connection, scratch, config, migration, session, skips) {
|
|
302
|
-
await runSteps(sql, connection, scratch, config.roles?.migration, { ...migration, steps: retargetSteps(migration.steps, scratch) }, session, skips);
|
|
316
|
+
await runSteps(sql, connection, scratch, config.roles?.migration, { ...migration, steps: retargetSteps(migration.steps, scratch, config.namespace ?? "public") }, session, skips);
|
|
303
317
|
}
|
|
304
318
|
async function runSteps(sql, connection, scratch, migrationRole, migration, session, skips) {
|
|
305
319
|
for (let index = 0;index < migration.steps.length; index += 1) {
|
|
@@ -313,6 +327,9 @@ async function runSteps(sql, connection, scratch, migrationRole, migration, sess
|
|
|
313
327
|
if (prepared.sql.length === 0)
|
|
314
328
|
continue;
|
|
315
329
|
try {
|
|
330
|
+
if (migrationRole !== undefined && !changesRole(step.sql) && session.setRole !== migrationRole && await roleExists(connection, migrationRole)) {
|
|
331
|
+
await assumeRole(connection, migrationRole, session);
|
|
332
|
+
}
|
|
316
333
|
const created = createdRoleName(step.sql);
|
|
317
334
|
const existed = created !== undefined && await roleExists(connection, created);
|
|
318
335
|
if (step.backfill !== undefined) {
|
|
@@ -323,17 +340,18 @@ async function runSteps(sql, connection, scratch, migrationRole, migration, sess
|
|
|
323
340
|
} else if (!existed) {
|
|
324
341
|
await sql.unsafe(createRoleOnce(prepared.sql.replace(/;\s*$/, "")));
|
|
325
342
|
}
|
|
326
|
-
if (created !== undefined && created === migrationRole) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
await assumeRole(connection, created, session);
|
|
343
|
+
if (created !== undefined && created === migrationRole && !existed) {
|
|
344
|
+
await grantSchema(connection, scratch, created);
|
|
345
|
+
await ownSchema(connection, scratch, created);
|
|
346
|
+
await connection.execute(`grant select, insert, update on okm_meta, okm_history, okm_backfill to ${quoteIdent2(created)}`);
|
|
332
347
|
}
|
|
333
348
|
} catch (error) {
|
|
334
349
|
throw failStep(migration.id, index, error);
|
|
335
350
|
}
|
|
336
351
|
}
|
|
352
|
+
if (migrationRole !== undefined && session.setRole !== migrationRole && await roleExists(connection, migrationRole)) {
|
|
353
|
+
await assumeRole(connection, migrationRole, session);
|
|
354
|
+
}
|
|
337
355
|
}
|
|
338
356
|
function prepareCheckSql(sql) {
|
|
339
357
|
const parts = sqlStatements(sql);
|
|
@@ -378,7 +396,7 @@ async function ownScratch(sql, scratch, role) {
|
|
|
378
396
|
const exists = await sql.unsafe("select exists (select 1 from pg_roles where rolname = $1) as ok", [role]);
|
|
379
397
|
const present = cell(exists[0], "ok");
|
|
380
398
|
if (present === "t" || present === "true") {
|
|
381
|
-
await sql.unsafe(`alter schema ${
|
|
399
|
+
await sql.unsafe(`alter schema ${quoteIdent2(scratch)} owner to ${quoteIdent2(role)}`);
|
|
382
400
|
}
|
|
383
401
|
}
|
|
384
402
|
async function setLocalTimeout(sql, name, ms) {
|
|
@@ -476,6 +494,8 @@ async function checkMigrations(cwd, flags, options) {
|
|
|
476
494
|
}
|
|
477
495
|
});
|
|
478
496
|
}
|
|
497
|
+
assertSnapshots(cwd, opened.config, opened.built.catalog);
|
|
498
|
+
await assertLiveExternal(target.url, opened.built.catalog, loadSnapshots(cwd, opened.config));
|
|
479
499
|
const directory = projectPath(cwd, opened.config.migrations ?? "migrations");
|
|
480
500
|
const history = readHistory(directory);
|
|
481
501
|
const previous = previousFailures(history);
|
|
@@ -490,16 +510,21 @@ async function checkMigrations(cwd, flags, options) {
|
|
|
490
510
|
throwFailure([equivalence]);
|
|
491
511
|
}
|
|
492
512
|
const replayed = await replayHistory(opened.config, target.url, flags, history);
|
|
513
|
+
const reprintErrors = replayed.reprints.filter((item) => item.severity === "error");
|
|
514
|
+
const reprintWarnings = replayed.reprints.filter((item) => item.severity === "warning");
|
|
493
515
|
const failures = [...replayed.failures, ...previous, ...stale, ...lint];
|
|
516
|
+
if (reprintErrors.length > 0) {
|
|
517
|
+
const refusal = lintRefusal(reprintErrors);
|
|
518
|
+
failures.push({ code: refusal.code, message: refusal.message, fix: refusal.fix.summary });
|
|
519
|
+
}
|
|
494
520
|
if (failures.length > 0)
|
|
495
|
-
throwFailure(failures);
|
|
521
|
+
throwFailure(failures, reprintWarnings);
|
|
496
522
|
const summary = `ok ${String(history.length)} migrations
|
|
497
523
|
`;
|
|
498
|
-
|
|
499
|
-
return summary;
|
|
500
|
-
return `${summary}${replayed.skips.join(`
|
|
524
|
+
const skipped = replayed.skips.length === 0 ? "" : `${replayed.skips.join(`
|
|
501
525
|
`)}
|
|
502
526
|
`;
|
|
527
|
+
return `${summary}${skipped}${formatFindings(reprintWarnings)}`;
|
|
503
528
|
}
|
|
504
529
|
function previousCatalogGaps(before, after) {
|
|
505
530
|
const afterBy = new Map(after.objects.map((object) => [identityKey2(object.identity), object]));
|
|
@@ -597,14 +622,16 @@ ${difference}`,
|
|
|
597
622
|
}
|
|
598
623
|
async function replayHistory(config, url, flags, history) {
|
|
599
624
|
if (history.length === 0)
|
|
600
|
-
return { failures: [], skips: [] };
|
|
625
|
+
return { failures: [], skips: [], reprints: [] };
|
|
601
626
|
const scratch = `${CHECK_SCHEMA_PREFIX}${crypto.randomUUID().replaceAll("-", "")}`;
|
|
602
627
|
const outcome = await replayCheckHistory(url, scratch, config, flags.allowPooler || config.allowPooler === true, history);
|
|
603
|
-
if (outcome.stop === undefined)
|
|
604
|
-
return { failures: [], skips: outcome.skips };
|
|
628
|
+
if (outcome.stop === undefined) {
|
|
629
|
+
return { failures: [], skips: outcome.skips, reprints: outcome.reprints };
|
|
630
|
+
}
|
|
605
631
|
return {
|
|
606
632
|
failures: [historyFailure(history, outcome.stop.index, outcome.stop.back)],
|
|
607
|
-
skips: outcome.skips
|
|
633
|
+
skips: outcome.skips,
|
|
634
|
+
reprints: outcome.reprints
|
|
608
635
|
};
|
|
609
636
|
}
|
|
610
637
|
function refuseTransactionControl(history) {
|
|
@@ -676,13 +703,16 @@ function readHistory(directory) {
|
|
|
676
703
|
catalog: parseCatalog2(readFileSync(join(directory, `${migration.id}.catalog.json`), "utf8"))
|
|
677
704
|
}));
|
|
678
705
|
}
|
|
679
|
-
function throwFailure(failures) {
|
|
706
|
+
function throwFailure(failures, warnings = []) {
|
|
680
707
|
const first = failures[0];
|
|
681
708
|
if (first === undefined)
|
|
682
709
|
throw new Error("okm migrate check has no failure to report.");
|
|
683
710
|
const message = failures.length === 1 ? first.message : failures.map((failure) => `${failure.code} ${failure.message}`).join(`
|
|
684
711
|
`);
|
|
685
|
-
|
|
712
|
+
const notes = formatFindings(warnings).trim();
|
|
713
|
+
const text = notes.length === 0 ? message : `${message}
|
|
714
|
+
${notes}`;
|
|
715
|
+
throw new OkmError2(first.code, text, { fix: { summary: first.fix } });
|
|
686
716
|
}
|
|
687
717
|
function checkedKind(kind) {
|
|
688
718
|
return kind === "table" || kind === "column" || kind === "constraint" || kind === "type";
|
|
@@ -54,6 +54,9 @@ function scanLiteral(literal, state) {
|
|
|
54
54
|
for (let index = 0;index < literal.length; index += 1) {
|
|
55
55
|
const char = literal[index] ?? "";
|
|
56
56
|
const code = literal.charCodeAt(index);
|
|
57
|
+
if (char === "\\") {
|
|
58
|
+
fragmentError("A fragment cannot include a backslash.", "Pass the value as an interpolation.");
|
|
59
|
+
}
|
|
57
60
|
if (state.quote !== undefined) {
|
|
58
61
|
if (char !== state.quote)
|
|
59
62
|
continue;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
emitSqlSelect,
|
|
3
3
|
decodeSqlNumber
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./ycnft340.js";
|
|
5
5
|
import {
|
|
6
6
|
refusePrototypeKey
|
|
7
7
|
} from "./a62rb2da.js";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./9a4ae4p8.js";
|
|
11
11
|
import {
|
|
12
12
|
readSelectFragment
|
|
13
|
-
} from "./
|
|
13
|
+
} from "./s5qe47a6.js";
|
|
14
14
|
import {
|
|
15
15
|
emitWhere,
|
|
16
16
|
emitOrder,
|
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
2
|
noticeBuffer,
|
|
3
3
|
WireSession
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./e275q7sd.js";
|
|
5
5
|
import {
|
|
6
6
|
NODE_POSTGRES_CAPABILITIES,
|
|
7
7
|
driverErrors,
|
|
8
8
|
rejectClosed,
|
|
9
|
+
rejectCancelled,
|
|
10
|
+
rejectTimedOut,
|
|
9
11
|
mapFailure,
|
|
10
12
|
runCall
|
|
11
|
-
} from "./
|
|
13
|
+
} from "./mfvx6kjx.js";
|
|
12
14
|
|
|
13
15
|
// src/adapters/pg/nodepostgres.ts
|
|
14
16
|
import net from "node:net";
|
|
15
17
|
import pg from "pg";
|
|
16
18
|
var CANCEL_CODE = 80877102;
|
|
19
|
+
var ABORT_GRACE_MS = 250;
|
|
17
20
|
var identity = (value) => value;
|
|
18
21
|
function armDriverError(source, handle = () => {}) {
|
|
19
22
|
source.on("error", handle);
|
|
20
23
|
}
|
|
24
|
+
function logClientError(notices, error) {
|
|
25
|
+
const message = error instanceof Error ? error.message : typeof error === "string" ? error : "client error";
|
|
26
|
+
const code = typeof error === "object" && error !== null && "code" in error ? Reflect.get(error, "code") : undefined;
|
|
27
|
+
notices.push({
|
|
28
|
+
severity: "ERROR",
|
|
29
|
+
message,
|
|
30
|
+
...typeof code === "string" && code.length > 0 ? { code } : {}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
21
33
|
var WIRE = {
|
|
22
34
|
getTypeParser() {
|
|
23
35
|
return identity;
|
|
@@ -25,7 +37,7 @@ var WIRE = {
|
|
|
25
37
|
};
|
|
26
38
|
function open4(config) {
|
|
27
39
|
const max = config.max ?? 10;
|
|
28
|
-
const acquireMs = config.timeouts?.acquire;
|
|
40
|
+
const acquireMs = config.timeouts?.acquire ?? 1e4;
|
|
29
41
|
const counters = { reserved: 0, busy: 0, reservedBusy: 0, waiting: 0 };
|
|
30
42
|
const inflight = new Set;
|
|
31
43
|
const notices = noticeBuffer();
|
|
@@ -43,11 +55,16 @@ function open4(config) {
|
|
|
43
55
|
...config.ssl !== undefined ? { ssl: config.ssl } : {},
|
|
44
56
|
...config.searchPath !== undefined ? { options: `-c search_path=${config.searchPath}` } : {}
|
|
45
57
|
});
|
|
46
|
-
armDriverError(pool)
|
|
58
|
+
armDriverError(pool, (error) => {
|
|
59
|
+
logClientError(notices, error);
|
|
60
|
+
});
|
|
47
61
|
pool.on("connect", (client) => {
|
|
48
62
|
client.on("notice", (notice) => {
|
|
49
63
|
notices.push(notice);
|
|
50
64
|
});
|
|
65
|
+
armDriverError(client, (error) => {
|
|
66
|
+
logClientError(notices, error);
|
|
67
|
+
});
|
|
51
68
|
});
|
|
52
69
|
const root = new WireSession((text, params) => send(pool, text, params, named, undefined), notices, isClosed, true, () => {
|
|
53
70
|
counters.busy += 1;
|
|
@@ -55,7 +72,7 @@ function open4(config) {
|
|
|
55
72
|
counters.busy = Math.max(0, counters.busy - 1);
|
|
56
73
|
}, inflight);
|
|
57
74
|
const held = { pool, acquireMs, counters, notices, named, isClosed };
|
|
58
|
-
const checkout = () => closed ? rejectClosed() : import("./
|
|
75
|
+
const checkout = () => closed ? rejectClosed() : import("./8qwqrxed.js").then((mod) => mod.checkout(held));
|
|
59
76
|
return {
|
|
60
77
|
capabilities: NODE_POSTGRES_CAPABILITIES,
|
|
61
78
|
execute(text, params, options) {
|
|
@@ -63,17 +80,31 @@ function open4(config) {
|
|
|
63
80
|
if (watch === undefined)
|
|
64
81
|
return root.query(text, params, undefined);
|
|
65
82
|
const client = await connectClient(pool, acquireMs, counters);
|
|
83
|
+
if (watch.signal.aborted) {
|
|
84
|
+
client.release();
|
|
85
|
+
return watch.reason() === "cancelled" ? rejectCancelled() : rejectTimedOut();
|
|
86
|
+
}
|
|
66
87
|
counters.busy += 1;
|
|
88
|
+
const slot = trackCheckout(client, () => {
|
|
89
|
+
counters.busy = Math.max(0, counters.busy - 1);
|
|
90
|
+
});
|
|
67
91
|
const session = new WireSession((statement, values) => send(client, statement, values, named, client), notices, isClosed, true, () => {
|
|
68
92
|
return;
|
|
69
93
|
}, () => {
|
|
70
94
|
return;
|
|
71
95
|
}, inflight);
|
|
96
|
+
const onAbort = () => {
|
|
97
|
+
slot.abandon();
|
|
98
|
+
};
|
|
99
|
+
if (watch.signal.aborted)
|
|
100
|
+
onAbort();
|
|
101
|
+
else
|
|
102
|
+
watch.signal.addEventListener("abort", onAbort, { once: true });
|
|
72
103
|
try {
|
|
73
104
|
return await session.query(text, params, watch);
|
|
74
105
|
} finally {
|
|
75
|
-
|
|
76
|
-
|
|
106
|
+
watch.signal.removeEventListener("abort", onAbort);
|
|
107
|
+
slot.release();
|
|
77
108
|
}
|
|
78
109
|
});
|
|
79
110
|
},
|
|
@@ -88,14 +119,14 @@ function open4(config) {
|
|
|
88
119
|
reserve: () => checkout(),
|
|
89
120
|
stream(text, params) {
|
|
90
121
|
return async function* () {
|
|
91
|
-
const { streamRows } = await import("./
|
|
122
|
+
const { streamRows } = await import("./8qwqrxed.js");
|
|
92
123
|
yield* streamRows(checkout, text, params);
|
|
93
124
|
}();
|
|
94
125
|
},
|
|
95
126
|
listen(channel, onNotify) {
|
|
96
127
|
if (closed)
|
|
97
128
|
return rejectClosed();
|
|
98
|
-
return import("./
|
|
129
|
+
return import("./8qwqrxed.js").then((mod) => mod.listen(held, channel, onNotify));
|
|
99
130
|
},
|
|
100
131
|
cancel() {
|
|
101
132
|
for (const pending of inflight)
|
|
@@ -149,6 +180,38 @@ function cancelBackend(client) {
|
|
|
149
180
|
socket.end(bytes);
|
|
150
181
|
});
|
|
151
182
|
}
|
|
183
|
+
function trackCheckout(client, done) {
|
|
184
|
+
let dead = false;
|
|
185
|
+
let released = false;
|
|
186
|
+
let grace;
|
|
187
|
+
const onError = () => {
|
|
188
|
+
dead = true;
|
|
189
|
+
};
|
|
190
|
+
const events = client;
|
|
191
|
+
events.on("error", onError);
|
|
192
|
+
const release = () => {
|
|
193
|
+
if (released)
|
|
194
|
+
return;
|
|
195
|
+
released = true;
|
|
196
|
+
if (grace !== undefined)
|
|
197
|
+
clearTimeout(grace);
|
|
198
|
+
events.removeListener("error", onError);
|
|
199
|
+
done();
|
|
200
|
+
client.release(dead ? true : undefined);
|
|
201
|
+
};
|
|
202
|
+
return {
|
|
203
|
+
abandon() {
|
|
204
|
+
if (released || grace !== undefined)
|
|
205
|
+
return;
|
|
206
|
+
grace = setTimeout(() => {
|
|
207
|
+
dead = true;
|
|
208
|
+
release();
|
|
209
|
+
}, ABORT_GRACE_MS);
|
|
210
|
+
grace.unref();
|
|
211
|
+
},
|
|
212
|
+
release
|
|
213
|
+
};
|
|
214
|
+
}
|
|
152
215
|
function connectClient(pool, acquireMs, counters) {
|
|
153
216
|
counters.waiting += 1;
|
|
154
217
|
let settled = false;
|
|
@@ -191,4 +254,4 @@ function statsOf(counters, size) {
|
|
|
191
254
|
};
|
|
192
255
|
}
|
|
193
256
|
|
|
194
|
-
export { armDriverError, open4, send, connectClient };
|
|
257
|
+
export { armDriverError, logClientError, open4, send, connectClient };
|
|
@@ -14,7 +14,7 @@ function mapPostgresError(error, options) {
|
|
|
14
14
|
return error;
|
|
15
15
|
if (!isDriverError(error))
|
|
16
16
|
return OkmError2.from(error);
|
|
17
|
-
const search = searchInputError(error);
|
|
17
|
+
const search = searchInputError(error, options);
|
|
18
18
|
if (search !== undefined)
|
|
19
19
|
return search;
|
|
20
20
|
const kind = kindOf(error);
|
|
@@ -23,6 +23,7 @@ function mapPostgresError(error, options) {
|
|
|
23
23
|
const fieldReason = hint?.reason ?? (kind === "not_null" ? "not_null" : reasonOf(kind, error.table, error.constraint, columns, options?.schema));
|
|
24
24
|
const values = options?.includeValues === true ? valuesOf(error.detail, columns) : undefined;
|
|
25
25
|
const code = kind === "outcome_unknown" ? "OKM1401" : kind;
|
|
26
|
+
const redactCause = options?.includeValues !== true && needsSafeCause(options?.schema, error.table, columns);
|
|
26
27
|
return new OkmError2(code, summaryOf(kind, error, columns, fieldReason), {
|
|
27
28
|
kind,
|
|
28
29
|
fieldReason,
|
|
@@ -32,11 +33,59 @@ function mapPostgresError(error, options) {
|
|
|
32
33
|
...error.constraint !== undefined ? { constraint: error.constraint } : {},
|
|
33
34
|
...error.sqlstate !== undefined ? { sqlstate: error.sqlstate } : {},
|
|
34
35
|
batchIndex: error.batchIndex,
|
|
35
|
-
cause: error.cause ?? error,
|
|
36
|
+
cause: redactCause ? safeCause(error) : error.cause ?? error,
|
|
36
37
|
...options?.includeValues === true && values !== undefined ? { includeValues: true, values } : {},
|
|
37
38
|
...options?.http !== undefined ? { http: options.http } : {}
|
|
38
39
|
});
|
|
39
40
|
}
|
|
41
|
+
function needsSafeCause(schema, table, columns) {
|
|
42
|
+
if (schema === undefined)
|
|
43
|
+
return false;
|
|
44
|
+
const model = modelForTable(schema, table);
|
|
45
|
+
if (model !== undefined && model.columns.some((column) => column.sensitive === true)) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
if (columns.length === 0)
|
|
49
|
+
return false;
|
|
50
|
+
for (const item of Object.values(schema.model)) {
|
|
51
|
+
for (const column of item.columns) {
|
|
52
|
+
if (column.sensitive !== true)
|
|
53
|
+
continue;
|
|
54
|
+
for (const name of columns) {
|
|
55
|
+
if (column.sql === name || column.field === name)
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
function safeCause(error) {
|
|
63
|
+
const out = { name: "DriverError" };
|
|
64
|
+
if (error.sqlstate !== undefined)
|
|
65
|
+
out.sqlstate = error.sqlstate;
|
|
66
|
+
if (error.constraint !== undefined)
|
|
67
|
+
out.constraint = error.constraint;
|
|
68
|
+
if (error.table !== undefined)
|
|
69
|
+
out.table = error.table;
|
|
70
|
+
if (error.column !== undefined)
|
|
71
|
+
out.column = error.column;
|
|
72
|
+
const nested = error.cause;
|
|
73
|
+
if (typeof nested === "object" && nested !== null) {
|
|
74
|
+
const code = Reflect.get(nested, "code");
|
|
75
|
+
if (typeof code === "string" && code.length > 0 && code.length <= 64)
|
|
76
|
+
out.code = code;
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
function modelForTable(schema, table) {
|
|
81
|
+
if (table === undefined)
|
|
82
|
+
return;
|
|
83
|
+
for (const item of Object.values(schema.model)) {
|
|
84
|
+
if (item.sql === table)
|
|
85
|
+
return item;
|
|
86
|
+
}
|
|
87
|
+
return schema.model[table];
|
|
88
|
+
}
|
|
40
89
|
var TLS_CODE = /^(ERR_TLS_|ERR_POSTGRES_TLS_|SELF_SIGNED_CERT_|DEPTH_ZERO_SELF_SIGNED_CERT$|UNABLE_TO_VERIFY_LEAF_SIGNATURE$)/;
|
|
41
90
|
function isTlsFailure(error) {
|
|
42
91
|
const cause = error.cause;
|
|
@@ -55,14 +104,15 @@ function searchQuery(error) {
|
|
|
55
104
|
const query = Reflect.get(cause, "query");
|
|
56
105
|
return typeof query === "string" && query.includes("to_tsquery");
|
|
57
106
|
}
|
|
58
|
-
function searchInputError(error) {
|
|
107
|
+
function searchInputError(error, options) {
|
|
59
108
|
const sqlstate = error.sqlstate;
|
|
60
109
|
const message = error.message;
|
|
110
|
+
const cause = options?.includeValues !== true && needsSafeCause(options?.schema, error.table, columnsOf(error)) ? safeCause(error) : error.cause ?? error;
|
|
61
111
|
if (sqlstate === "42601" && (message.includes("tsquery") || searchQuery(error))) {
|
|
62
112
|
return new OkmError2("OKM1120", `Search input is not valid. ${stripRowValues(message)}`, {
|
|
63
113
|
kind: "invalid",
|
|
64
114
|
sqlstate,
|
|
65
|
-
cause
|
|
115
|
+
cause,
|
|
66
116
|
fix: { summary: "Fix the advanced search text, or use natural, all-words, or phrase." }
|
|
67
117
|
});
|
|
68
118
|
}
|
|
@@ -70,7 +120,7 @@ function searchInputError(error) {
|
|
|
70
120
|
return new OkmError2("OKM1122", stripRowValues(message), {
|
|
71
121
|
kind: "invalid",
|
|
72
122
|
sqlstate,
|
|
73
|
-
cause
|
|
123
|
+
cause,
|
|
74
124
|
fix: {
|
|
75
125
|
summary: "Use a text search configuration that exists, such as english, or omit language."
|
|
76
126
|
}
|