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
|
@@ -19,6 +19,18 @@ import type { RolesInput } from "../../dialects/pg/role/index.js";
|
|
|
19
19
|
* @param roles - `defineConfig({ roles })`, when set
|
|
20
20
|
*/
|
|
21
21
|
export declare function assertAuthorDrift(url: string, author: Catalog, roles?: RolesInput, allowPooler?: boolean): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Reprints each domain check the way this server stores it.
|
|
24
|
+
*
|
|
25
|
+
* Author spellings such as `VALUE > 0` become `((VALUE > 0))`, so a plan
|
|
26
|
+
* against a live catalog does not treat the reprint as a permanent change.
|
|
27
|
+
* The catalog hash still uses the author text (B-37).
|
|
28
|
+
*
|
|
29
|
+
* @param runner - Database connection
|
|
30
|
+
* @param source - Catalog whose domain checks may still be author SQL
|
|
31
|
+
* @returns A catalog whose domain checks carry the server reprint
|
|
32
|
+
*/
|
|
33
|
+
export declare function sealDomainChecks(runner: CatalogQuery, source: Catalog): Promise<Catalog>;
|
|
22
34
|
/**
|
|
23
35
|
* Turns a postgres.js handle into the query shape introspection uses.
|
|
24
36
|
*
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection URL helpers for migrate commands.
|
|
3
|
+
*
|
|
4
|
+
* Pooler client hints in the query string are not Postgres startup parameters.
|
|
5
|
+
* Every migrate path that opens a driver must strip those hints first. The
|
|
6
|
+
* URL guard still reads `pgbouncer=true` on the original URL before this runs.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Removes the `pgbouncer` query parameter before a driver opens a connection.
|
|
10
|
+
*
|
|
11
|
+
* Other pooler hints in the URL are left alone: this version does not
|
|
12
|
+
* interpret them.
|
|
13
|
+
*
|
|
14
|
+
* @param url - A `postgres://` or `postgresql://` URL
|
|
15
|
+
* @returns The same URL without `pgbouncer` in the query string
|
|
16
|
+
*/
|
|
17
|
+
export declare function driverUrl(url: string): string;
|
|
@@ -3,17 +3,19 @@ import {
|
|
|
3
3
|
parseCatalog2
|
|
4
4
|
} from "../../shared/12z7aznj.js";
|
|
5
5
|
import"../../shared/fk9vef30.js";
|
|
6
|
-
import"../../shared/
|
|
6
|
+
import"../../shared/jvxcp1qk.js";
|
|
7
7
|
import"../../shared/n442h54c.js";
|
|
8
|
+
import"../../shared/4pkz5nvw.js";
|
|
8
9
|
import {
|
|
9
10
|
applyTarget2,
|
|
10
11
|
backfillTiming2
|
|
11
|
-
} from "../../shared/
|
|
12
|
+
} from "../../shared/8ma6drzr.js";
|
|
12
13
|
import {
|
|
13
14
|
readReference
|
|
14
|
-
} from "../../shared/
|
|
15
|
-
import"../../shared/
|
|
16
|
-
import"../../shared/
|
|
15
|
+
} from "../../shared/8p2bgye0.js";
|
|
16
|
+
import"../../shared/6xqvesa5.js";
|
|
17
|
+
import"../../shared/e1c55v04.js";
|
|
18
|
+
import"../../shared/mz48rs74.js";
|
|
17
19
|
import {
|
|
18
20
|
projectPath,
|
|
19
21
|
LOGICAL_FORMAT,
|
|
@@ -21,11 +23,11 @@ import {
|
|
|
21
23
|
loadHeadSnapshot,
|
|
22
24
|
loadBuiltSchema,
|
|
23
25
|
loadConfig
|
|
24
|
-
} from "../../shared/
|
|
26
|
+
} from "../../shared/wp7y8q3y.js";
|
|
25
27
|
import {
|
|
26
28
|
assertTargetPolicy,
|
|
27
29
|
selectTarget
|
|
28
|
-
} from "../../shared/
|
|
30
|
+
} from "../../shared/bdekbvmt.js";
|
|
29
31
|
import {
|
|
30
32
|
canonicalJson
|
|
31
33
|
} from "../../shared/358zsv4r.js";
|
|
@@ -56,17 +56,29 @@ export declare function assertTargetAlias(targets: readonly TargetRecord[]): voi
|
|
|
56
56
|
* @param allowPooler - The invocation opted in
|
|
57
57
|
*/
|
|
58
58
|
export declare function assertDirectConnection(url: string, allowPooler: boolean): void;
|
|
59
|
+
/** Options for {@link assertStableBackend}. */
|
|
60
|
+
export type StableBackendOptions = {
|
|
61
|
+
/**
|
|
62
|
+
* Holds another backend between pid reads so a LIFO transaction-mode
|
|
63
|
+
* pooler cannot hand the next read the same server. Resolves to a release
|
|
64
|
+
* function that ends the hold.
|
|
65
|
+
*/
|
|
66
|
+
readonly holdBackend?: () => Promise<() => Promise<void>>;
|
|
67
|
+
};
|
|
59
68
|
/**
|
|
60
|
-
* Refuses a session whose backend pid changes
|
|
69
|
+
* Refuses a session whose backend pid changes across eight statements.
|
|
61
70
|
*
|
|
62
|
-
* The
|
|
63
|
-
*
|
|
64
|
-
*
|
|
71
|
+
* The reads are separate round trips and are not wrapped in a transaction.
|
|
72
|
+
* A transaction-mode pooler can hand back a different backend. Two reads
|
|
73
|
+
* miss a default PgBouncer with `server_round_robin=0` (LIFO); eight reads
|
|
74
|
+
* plus an optional hold between them catch that case. A direct session
|
|
75
|
+
* keeps one pid. `--allow-pooler` skips the probe.
|
|
65
76
|
*
|
|
66
77
|
* @param readPid - Reads `pg_backend_pid()` on the session under test
|
|
67
78
|
* @param allowPooler - The invocation opted in
|
|
79
|
+
* @param options - Optional hold used by the migrate warm-and-hold probe
|
|
68
80
|
*/
|
|
69
|
-
export declare function assertStableBackend(readPid: () => Promise<string>, allowPooler: boolean): Promise<void>;
|
|
81
|
+
export declare function assertStableBackend(readPid: () => Promise<string>, allowPooler: boolean, options?: StableBackendOptions): Promise<void>;
|
|
70
82
|
/**
|
|
71
83
|
* Lists configured targets.
|
|
72
84
|
*
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pid probe for transaction-mode poolers (B-41).
|
|
3
|
+
*
|
|
4
|
+
* Eight separate `pg_backend_pid()` reads on the caller's session. Two or
|
|
5
|
+
* more distinct pids mean a pooler handed out a new backend. A direct
|
|
6
|
+
* session keeps one pid.
|
|
7
|
+
*
|
|
8
|
+
* Warm-and-hold for LIFO PgBouncer (`server_round_robin=0`) needs extra
|
|
9
|
+
* connections and deadlocks a single-connection target (PGlite wire) when
|
|
10
|
+
* apply/seed already hold `max: 1`. That path stays in the PgBouncer test
|
|
11
|
+
* via {@link holdBackendBetweenReads}; production keeps URL heuristics plus
|
|
12
|
+
* these eight reads.
|
|
13
|
+
*/
|
|
14
|
+
import { type StableBackendOptions } from "./policy.js";
|
|
15
|
+
/**
|
|
16
|
+
* Refuses a session whose backend pid changes across eight reads.
|
|
17
|
+
*
|
|
18
|
+
* @param _url - Target URL (unused; kept for call-site stability)
|
|
19
|
+
* @param readPid - Reads `pg_backend_pid()` on the session under test
|
|
20
|
+
* @param allowPooler - The invocation opted in
|
|
21
|
+
* @param options - Optional hold between reads (PgBouncer tests)
|
|
22
|
+
*/
|
|
23
|
+
export declare function probeStableBackend(_url: string, readPid: () => Promise<string>, allowPooler: boolean, options?: StableBackendOptions): Promise<void>;
|
|
@@ -56,6 +56,9 @@ export declare function pullLayout(cwd: string, schema: string, tables: string |
|
|
|
56
56
|
/**
|
|
57
57
|
* Refuses an existing file, writes the rest, and formats them.
|
|
58
58
|
*
|
|
59
|
+
* When `oxfmt` is missing or fails, the files stay as written and a notice is
|
|
60
|
+
* printed on stderr. The pull or import report still returns.
|
|
61
|
+
*
|
|
59
62
|
* @param files - Files from {@link emitPull}
|
|
60
63
|
* @param verb - `Pull` or `Import`, named in OKM1855
|
|
61
64
|
*/
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* `okm_backfill` after each commit.
|
|
8
8
|
*/
|
|
9
9
|
import type { DriverConnection } from "../../contracts/driver.js";
|
|
10
|
+
import { OkmError } from "../../contracts/error.js";
|
|
10
11
|
import type { PlanStep } from "./plan.js";
|
|
11
12
|
/** One step with its index in the migration file. */
|
|
12
13
|
export type RunnableStep = {
|
|
@@ -79,7 +80,9 @@ export declare function runTarget(connection: DriverConnection, run: TargetRun,
|
|
|
79
80
|
/**
|
|
80
81
|
* Assumes `role` for the rest of this connection.
|
|
81
82
|
*
|
|
82
|
-
* A second call with the same role does nothing.
|
|
83
|
+
* A second call with the same role does nothing. A non-superuser that created
|
|
84
|
+
* the role with `CREATEROLE` is granted membership first: Postgres 15 creates
|
|
85
|
+
* no membership row, and Postgres 16+ grants `ADMIN` without `SET`.
|
|
83
86
|
*
|
|
84
87
|
* @param connection - Reserved connection
|
|
85
88
|
* @param role - Migration role
|
|
@@ -88,6 +91,15 @@ export declare function runTarget(connection: DriverConnection, run: TargetRun,
|
|
|
88
91
|
export declare function assumeRole(connection: DriverConnection, role: string, session: {
|
|
89
92
|
setRole?: string;
|
|
90
93
|
}): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Maps a Postgres role-privilege refusal to a clear `OkmError`.
|
|
96
|
+
*
|
|
97
|
+
* @param error - Driver failure
|
|
98
|
+
* @param role - Role named in the step, when known
|
|
99
|
+
* @returns A forbidden error that names CREATEROLE or the SET option, or
|
|
100
|
+
* `undefined` when the failure is something else
|
|
101
|
+
*/
|
|
102
|
+
export declare function rolePrivilegeError(error: unknown, role?: string): OkmError | undefined;
|
|
91
103
|
/**
|
|
92
104
|
* Lets a new migration role create objects in `schema`.
|
|
93
105
|
*
|
|
@@ -110,6 +122,17 @@ export declare function grantAppMeta(connection: DriverConnection, role: string
|
|
|
110
122
|
setRole?: string;
|
|
111
123
|
}): Promise<void>;
|
|
112
124
|
export declare function grantSchema(connection: DriverConnection, schema: string, role: string): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Makes `role` the owner of `schema` when the connecting role can.
|
|
127
|
+
*
|
|
128
|
+
* Grants on the schema to reporting and other roles need the migration role
|
|
129
|
+
* to own it. A connecting role that is not the owner leaves the schema as is.
|
|
130
|
+
*
|
|
131
|
+
* @param connection - Reserved connection, before `SET ROLE`
|
|
132
|
+
* @param schema - Schema the migration writes
|
|
133
|
+
* @param role - Migration role that was just created
|
|
134
|
+
*/
|
|
135
|
+
export declare function ownSchema(connection: DriverConnection, schema: string, role: string): Promise<void>;
|
|
113
136
|
/**
|
|
114
137
|
* Fails when `GRANT USAGE ON SCHEMA` did not add the role.
|
|
115
138
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fail2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./2jdn09e2.js";
|
|
4
4
|
|
|
5
5
|
// src/runtime/result-name.ts
|
|
6
6
|
var PROTOTYPE_KEYS = ",__proto__,constructor,toString,hasOwnProperty,valueOf,isPrototypeOf,propertyIsEnumerable,toLocaleString,__defineGetter__,__defineSetter__,__lookupGetter__,__lookupSetter__,then,";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./
|
|
2
|
+
open2,
|
|
3
|
+
connectClient2,
|
|
4
|
+
send2
|
|
5
|
+
} from "./4ec0nxvw.js";
|
|
6
6
|
import {
|
|
7
7
|
NEON_WEBSOCKET_CAPABILITIES,
|
|
8
8
|
NEON_HTTP_CAPABILITIES,
|
|
9
9
|
readCapability2,
|
|
10
10
|
hasCapability2
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./ry2f3w8p.js";
|
|
12
12
|
export {
|
|
13
13
|
NEON_WEBSOCKET_CAPABILITIES as capabilities,
|
|
14
|
-
|
|
14
|
+
connectClient2 as connectClient,
|
|
15
15
|
hasCapability2 as hasCapability,
|
|
16
16
|
NEON_HTTP_CAPABILITIES as httpCapabilities,
|
|
17
|
-
|
|
17
|
+
open2 as open,
|
|
18
18
|
readCapability2 as readCapability,
|
|
19
|
-
|
|
19
|
+
send2 as send
|
|
20
20
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OkmError,
|
|
3
3
|
catalogFileText2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./2jdn09e2.js";
|
|
5
5
|
import {
|
|
6
6
|
artifactDir,
|
|
7
7
|
readText
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./8g0m0rvd.js";
|
|
9
9
|
|
|
10
10
|
// src/runtime/drift.ts
|
|
11
11
|
async function assertCompatible(pool, schema, recordedHash, source, options, namespace = "public") {
|
|
@@ -16,7 +16,7 @@ async function assertCompatible(pool, schema, recordedHash, source, options, nam
|
|
|
16
16
|
if (code.artifact !== undefined) {
|
|
17
17
|
const artifact = code.artifact;
|
|
18
18
|
await loadOnce(`text\x00${artifact.hash}`, async () => {
|
|
19
|
-
const { loadTrustedCatalog } = await import("./
|
|
19
|
+
const { loadTrustedCatalog } = await import("./2v4nwnkb.js");
|
|
20
20
|
loadTrustedCatalog(artifact.text, artifact.hash);
|
|
21
21
|
});
|
|
22
22
|
} else if (code.fromFile) {
|
|
@@ -30,11 +30,11 @@ async function assertCompatible(pool, schema, recordedHash, source, options, nam
|
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
const { loadTrustedCatalog } = await import("./
|
|
33
|
+
const { loadTrustedCatalog } = await import("./2v4nwnkb.js");
|
|
34
34
|
loadTrustedCatalog(text, code.hash);
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
const { assertDrift } = await import("./
|
|
37
|
+
const { assertDrift } = await import("./vg68k11z.js");
|
|
38
38
|
await assertDrift(pool, code.hash, recordedHash, options, namespace);
|
|
39
39
|
}
|
|
40
40
|
async function codeHash(schema, source) {
|
|
@@ -44,7 +44,7 @@ async function codeHash(schema, source) {
|
|
|
44
44
|
const listed = await readHashFile(source.catalogDir);
|
|
45
45
|
if (listed !== undefined)
|
|
46
46
|
return { hash: listed, fromFile: true };
|
|
47
|
-
const { catalogHash } = await import("./
|
|
47
|
+
const { catalogHash } = await import("./2v4nwnkb.js");
|
|
48
48
|
return { hash: catalogHash(schemaCatalog(schema)), fromFile: false };
|
|
49
49
|
}
|
|
50
50
|
function schemaCatalog(schema) {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
markClientPool2,
|
|
3
|
-
|
|
4
|
-
} from "./
|
|
3
|
+
open3
|
|
4
|
+
} from "./3f6etb9z.js";
|
|
5
5
|
import {
|
|
6
6
|
createClient
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./gjj71hfh.js";
|
|
8
8
|
|
|
9
9
|
// src/runtime/pg/bun.ts
|
|
10
10
|
function connect(target, options) {
|
|
11
11
|
if (typeof target === "object" && !isPool(target)) {
|
|
12
|
-
return import("./
|
|
13
|
-
const pool =
|
|
12
|
+
return import("./bt3tjemb.js").then((mod) => mod.default(target, options, (config) => {
|
|
13
|
+
const pool = open3(config);
|
|
14
14
|
markClientPool2(pool);
|
|
15
15
|
return pool;
|
|
16
16
|
}));
|
|
17
17
|
}
|
|
18
18
|
const owned = !isPool(target);
|
|
19
|
-
const pool = isPool(target) ? target :
|
|
19
|
+
const pool = isPool(target) ? target : open3({
|
|
20
20
|
url: target,
|
|
21
21
|
...options.max !== undefined ? { max: options.max } : {},
|
|
22
22
|
...options.timeouts !== undefined ? { timeouts: options.timeouts } : {},
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
open6,
|
|
3
3
|
seal2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./xn6p01fh.js";
|
|
5
5
|
import {
|
|
6
6
|
PGLITE_CAPABILITIES,
|
|
7
7
|
readCapability2,
|
|
8
8
|
hasCapability2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./ry2f3w8p.js";
|
|
10
10
|
export {
|
|
11
11
|
PGLITE_CAPABILITIES as capabilities,
|
|
12
12
|
hasCapability2 as hasCapability,
|
|
@@ -531,7 +531,7 @@ function mapPostgresError2(error, options) {
|
|
|
531
531
|
return error;
|
|
532
532
|
if (!isDriverError2(error))
|
|
533
533
|
return OkmError.from(error);
|
|
534
|
-
const search = searchInputError(error);
|
|
534
|
+
const search = searchInputError(error, options);
|
|
535
535
|
if (search !== undefined)
|
|
536
536
|
return search;
|
|
537
537
|
const kind = kindOf(error);
|
|
@@ -540,6 +540,7 @@ function mapPostgresError2(error, options) {
|
|
|
540
540
|
const fieldReason = hint?.reason ?? (kind === "not_null" ? "not_null" : reasonOf(kind, error.table, error.constraint, columns, options?.schema));
|
|
541
541
|
const values = options?.includeValues === true ? valuesOf(error.detail, columns) : undefined;
|
|
542
542
|
const code = kind === "outcome_unknown" ? "OKM1401" : kind;
|
|
543
|
+
const redactCause = options?.includeValues !== true && needsSafeCause(options?.schema, error.table, columns);
|
|
543
544
|
return new OkmError(code, summaryOf(kind, error, columns, fieldReason), {
|
|
544
545
|
kind,
|
|
545
546
|
fieldReason,
|
|
@@ -549,11 +550,59 @@ function mapPostgresError2(error, options) {
|
|
|
549
550
|
...error.constraint !== undefined ? { constraint: error.constraint } : {},
|
|
550
551
|
...error.sqlstate !== undefined ? { sqlstate: error.sqlstate } : {},
|
|
551
552
|
batchIndex: error.batchIndex,
|
|
552
|
-
cause: error.cause ?? error,
|
|
553
|
+
cause: redactCause ? safeCause(error) : error.cause ?? error,
|
|
553
554
|
...options?.includeValues === true && values !== undefined ? { includeValues: true, values } : {},
|
|
554
555
|
...options?.http !== undefined ? { http: options.http } : {}
|
|
555
556
|
});
|
|
556
557
|
}
|
|
558
|
+
function needsSafeCause(schema, table, columns) {
|
|
559
|
+
if (schema === undefined)
|
|
560
|
+
return false;
|
|
561
|
+
const model = modelForTable(schema, table);
|
|
562
|
+
if (model !== undefined && model.columns.some((column) => column.sensitive === true)) {
|
|
563
|
+
return true;
|
|
564
|
+
}
|
|
565
|
+
if (columns.length === 0)
|
|
566
|
+
return false;
|
|
567
|
+
for (const item of Object.values(schema.model)) {
|
|
568
|
+
for (const column of item.columns) {
|
|
569
|
+
if (column.sensitive !== true)
|
|
570
|
+
continue;
|
|
571
|
+
for (const name of columns) {
|
|
572
|
+
if (column.sql === name || column.field === name)
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
579
|
+
function safeCause(error) {
|
|
580
|
+
const out = { name: "DriverError" };
|
|
581
|
+
if (error.sqlstate !== undefined)
|
|
582
|
+
out.sqlstate = error.sqlstate;
|
|
583
|
+
if (error.constraint !== undefined)
|
|
584
|
+
out.constraint = error.constraint;
|
|
585
|
+
if (error.table !== undefined)
|
|
586
|
+
out.table = error.table;
|
|
587
|
+
if (error.column !== undefined)
|
|
588
|
+
out.column = error.column;
|
|
589
|
+
const nested = error.cause;
|
|
590
|
+
if (typeof nested === "object" && nested !== null) {
|
|
591
|
+
const code = Reflect.get(nested, "code");
|
|
592
|
+
if (typeof code === "string" && code.length > 0 && code.length <= 64)
|
|
593
|
+
out.code = code;
|
|
594
|
+
}
|
|
595
|
+
return out;
|
|
596
|
+
}
|
|
597
|
+
function modelForTable(schema, table) {
|
|
598
|
+
if (table === undefined)
|
|
599
|
+
return;
|
|
600
|
+
for (const item of Object.values(schema.model)) {
|
|
601
|
+
if (item.sql === table)
|
|
602
|
+
return item;
|
|
603
|
+
}
|
|
604
|
+
return schema.model[table];
|
|
605
|
+
}
|
|
557
606
|
var TLS_CODE = /^(ERR_TLS_|ERR_POSTGRES_TLS_|SELF_SIGNED_CERT_|DEPTH_ZERO_SELF_SIGNED_CERT$|UNABLE_TO_VERIFY_LEAF_SIGNATURE$)/;
|
|
558
607
|
function isTlsFailure(error) {
|
|
559
608
|
const cause = error.cause;
|
|
@@ -572,14 +621,15 @@ function searchQuery(error) {
|
|
|
572
621
|
const query = Reflect.get(cause, "query");
|
|
573
622
|
return typeof query === "string" && query.includes("to_tsquery");
|
|
574
623
|
}
|
|
575
|
-
function searchInputError(error) {
|
|
624
|
+
function searchInputError(error, options) {
|
|
576
625
|
const sqlstate = error.sqlstate;
|
|
577
626
|
const message = error.message;
|
|
627
|
+
const cause = options?.includeValues !== true && needsSafeCause(options?.schema, error.table, columnsOf(error)) ? safeCause(error) : error.cause ?? error;
|
|
578
628
|
if (sqlstate === "42601" && (message.includes("tsquery") || searchQuery(error))) {
|
|
579
629
|
return new OkmError("OKM1120", `Search input is not valid. ${stripRowValues(message)}`, {
|
|
580
630
|
kind: "invalid",
|
|
581
631
|
sqlstate,
|
|
582
|
-
cause
|
|
632
|
+
cause,
|
|
583
633
|
fix: { summary: "Fix the advanced search text, or use natural, all-words, or phrase." }
|
|
584
634
|
});
|
|
585
635
|
}
|
|
@@ -587,7 +637,7 @@ function searchInputError(error) {
|
|
|
587
637
|
return new OkmError("OKM1122", stripRowValues(message), {
|
|
588
638
|
kind: "invalid",
|
|
589
639
|
sqlstate,
|
|
590
|
-
cause
|
|
640
|
+
cause,
|
|
591
641
|
fix: {
|
|
592
642
|
summary: "Use a text search configuration that exists, such as english, or omit language."
|
|
593
643
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./
|
|
2
|
+
open5
|
|
3
|
+
} from "./ppybjw50.js";
|
|
4
4
|
import {
|
|
5
5
|
createClient
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./gjj71hfh.js";
|
|
7
7
|
|
|
8
8
|
// src/runtime/pg/pg.ts
|
|
9
9
|
function connect(target, options) {
|
|
10
10
|
if (typeof target === "object" && !isPool(target)) {
|
|
11
|
-
return import("./
|
|
11
|
+
return import("./bt3tjemb.js").then((mod) => mod.default(target, options, open5));
|
|
12
12
|
}
|
|
13
13
|
const owned = !isPool(target);
|
|
14
|
-
const pool = isPool(target) ? target :
|
|
14
|
+
const pool = isPool(target) ? target : open5({
|
|
15
15
|
url: target,
|
|
16
16
|
...options.max !== undefined ? { max: options.max } : {},
|
|
17
17
|
...options.timeouts !== undefined ? { timeouts: options.timeouts } : {},
|