okmodel 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -1116
- package/dist/adapters/capabilities.d.ts +3 -0
- package/dist/adapters/failure.d.ts +13 -2
- package/dist/adapters/lazy-errors.d.ts +22 -0
- package/dist/adapters/pg/bunsql-extra.d.ts +54 -3
- package/dist/adapters/pg/bunsql.d.ts +14 -1
- package/dist/adapters/pg/cursor.d.ts +17 -0
- package/dist/adapters/pg/no-inflight-timeout.d.ts +20 -0
- package/dist/adapters/pg/nodepostgres-extra.d.ts +22 -1
- package/dist/adapters/pg/nodepostgres.d.ts +12 -0
- package/dist/adapters/pg/pglite-wire.d.ts +24 -0
- package/dist/adapters/pg/pglite.d.ts +10 -0
- package/dist/adapters/pg/postgres-extra.d.ts +41 -3
- package/dist/adapters/pg/reserved.d.ts +42 -0
- package/dist/adapters/pg/session.d.ts +0 -18
- package/dist/contracts/catalog/document.d.ts +19 -5
- package/dist/contracts/catalog/object.d.ts +2 -1
- package/dist/contracts/catalog/policy.d.ts +48 -0
- package/dist/contracts/catalog/types.d.ts +25 -1
- package/dist/contracts/catalog/view.d.ts +2 -0
- package/dist/contracts/connection.d.ts +7 -6
- package/dist/contracts/internal.js +1 -1
- package/dist/contracts/location.d.ts +10 -0
- package/dist/dialects/pg/column.d.ts +13 -2
- package/dist/dialects/pg/ddl.d.ts +37 -1
- package/dist/dialects/pg/emit.d.ts +19 -1
- package/dist/dialects/pg/errors.d.ts +32 -1
- package/dist/dialects/pg/ext/citext.js +1 -1
- package/dist/dialects/pg/ext/index.js +1 -1
- package/dist/dialects/pg/ext/pg-trgm.js +1 -1
- package/dist/dialects/pg/filter-parse.d.ts +5 -4
- package/dist/dialects/pg/floor.d.ts +68 -0
- package/dist/dialects/pg/fn/index.js +2 -2
- package/dist/dialects/pg/index.d.ts +8 -2
- package/dist/dialects/pg/index.js +67 -171
- package/dist/dialects/pg/introspect.d.ts +7 -0
- package/dist/dialects/pg/keys.d.ts +11 -8
- package/dist/dialects/pg/model.d.ts +47 -2
- package/dist/dialects/pg/morph.d.ts +43 -0
- package/dist/dialects/pg/operator-fit.d.ts +2 -2
- package/dist/dialects/pg/operators.d.ts +14 -7
- package/dist/dialects/pg/ops/bucket.d.ts +65 -0
- package/dist/dialects/pg/ops/inc.d.ts +2 -2
- package/dist/dialects/pg/ops/matches.d.ts +9 -12
- package/dist/dialects/pg/ops/relevance.d.ts +13 -0
- package/dist/dialects/pg/ops/search-query.d.ts +22 -0
- package/dist/dialects/pg/ops/window.d.ts +103 -0
- package/dist/dialects/pg/owner.d.ts +42 -0
- package/dist/dialects/pg/path-endpoint.d.ts +20 -0
- package/dist/dialects/pg/preset.d.ts +1 -1
- package/dist/dialects/pg/relations.d.ts +100 -3
- package/dist/dialects/pg/role/check.d.ts +3 -0
- package/dist/dialects/pg/role/index.d.ts +71 -6
- package/dist/dialects/pg/role/sql.d.ts +11 -0
- package/dist/dialects/pg/schema.d.ts +33 -3
- package/dist/dialects/pg/table.d.ts +25 -3
- package/dist/dialects/pg/tenancy.d.ts +45 -3
- package/dist/dialects/pg/view/client.d.ts +19 -1
- package/dist/dialects/pg/view/index.d.ts +4 -0
- package/dist/dialects/pg/view/index.js +21 -178
- package/dist/dialects/pg/view/refresh.d.ts +24 -0
- package/dist/runtime/aggregate.d.ts +8 -2
- package/dist/runtime/batch.d.ts +1 -1
- package/dist/runtime/bucket-group.d.ts +70 -0
- package/dist/runtime/conflict.d.ts +24 -6
- package/dist/runtime/drift.d.ts +9 -0
- package/dist/runtime/include.d.ts +0 -8
- package/dist/runtime/inflight.d.ts +14 -0
- package/dist/runtime/page.d.ts +4 -1
- package/dist/runtime/pg/bun.js +12 -5
- package/dist/runtime/pg/pg.js +5 -5
- package/dist/runtime/pg/pglite.d.ts +1 -0
- package/dist/runtime/pg/pglite.js +9 -8
- package/dist/runtime/pg/postgresjs.js +5 -5
- package/dist/runtime/plan.d.ts +113 -15
- package/dist/runtime/predicate.d.ts +19 -0
- package/dist/runtime/read-stream.d.ts +13 -16
- package/dist/runtime/result-name.d.ts +17 -0
- package/dist/runtime/safety/index.js +1 -1
- package/dist/runtime/server-check.d.ts +3 -3
- package/dist/runtime/sort-bind.d.ts +21 -0
- package/dist/runtime/sort.d.ts +56 -0
- package/dist/runtime/sync.d.ts +70 -0
- package/dist/runtime/tenancy/composite.d.ts +26 -0
- package/dist/runtime/tenancy/context.d.ts +16 -0
- package/dist/runtime/tenancy/index.d.ts +9 -5
- package/dist/runtime/tenancy/index.js +1511 -38
- package/dist/runtime/tenancy/path.d.ts +87 -0
- package/dist/runtime/tenancy/rls.d.ts +67 -0
- package/dist/runtime/tenancy/via.d.ts +22 -0
- package/dist/runtime/text-search.d.ts +20 -0
- package/dist/runtime/traits/index.d.ts +80 -0
- package/dist/runtime/traits/index.js +187 -17
- package/dist/runtime/tree.d.ts +38 -0
- package/dist/runtime/types.d.ts +231 -23
- package/dist/runtime/validate/index.js +4 -4
- package/dist/runtime/version.d.ts +39 -0
- package/dist/runtime/window.d.ts +21 -0
- package/dist/runtime/write.d.ts +55 -3
- package/dist/shared/{krxx77g0.js → 14vx95q4.js} +12 -18
- package/dist/shared/1est4ezg.js +313 -0
- package/dist/shared/{4az561fn.js → 1qa0qajz.js} +8 -23
- package/dist/shared/1w508jbr.js +1611 -0
- package/dist/shared/2c13q96h.js +18 -0
- package/dist/shared/2d3xq4ps.js +9 -0
- package/dist/shared/2shdbn8q.js +23 -0
- package/dist/shared/{t4tbsy9h.js → 358zsv4r.js} +1 -1
- package/dist/shared/3v7t1yrv.js +208 -0
- package/dist/shared/5e3tf63j.js +220 -0
- package/dist/shared/5fe3kbsh.js +10 -0
- package/dist/shared/5v3xf80k.js +37 -0
- package/dist/shared/{51mvgj8w.js → 63qtkrca.js} +130 -3
- package/dist/shared/{gbtcc2d7.js → 67txcrcw.js} +62 -66
- package/dist/shared/79dt02vc.js +12 -0
- package/dist/shared/{v36c5g6p.js → 7k9grvf6.js} +407 -14
- package/dist/shared/7kms6fvj.js +20 -0
- package/dist/shared/7mnme5tn.js +8 -0
- package/dist/shared/7n7ddwt4.js +6 -0
- package/dist/shared/{87jvvhnt.js → 81ebdx9p.js} +48 -68
- package/dist/shared/{szm0cksa.js → 8skf0cam.js} +34 -6
- package/dist/shared/{gjthds9j.js → 9628a9xt.js} +1 -1
- package/dist/shared/9a4ae4p8.js +31 -0
- package/dist/shared/{8xsbagad.js → 9s0ypp87.js} +88 -7
- package/dist/shared/9y3mmmh1.js +436 -0
- package/dist/shared/ab9gmbwy.js +213 -0
- package/dist/shared/{sycnx8gt.js → ax7qv55k.js} +18 -8
- package/dist/shared/{f5cw5q5r.js → aytqh5y2.js} +6 -4
- package/dist/shared/{fancm5pt.js → b5pftnn2.js} +138 -15
- package/dist/shared/{efmy2gcg.js → b76b8d95.js} +2 -2
- package/dist/shared/bdk4sty6.js +58 -0
- package/dist/shared/{32zqc1dw.js → bg3rym3g.js} +63 -32
- package/dist/shared/{0t22wwh1.js → bm22fvzr.js} +16 -14
- package/dist/shared/bz84tkzm.js +342 -0
- package/dist/shared/{31vm914h.js → cm3w0ywp.js} +15 -16
- package/dist/shared/cn957f8d.js +179 -0
- package/dist/shared/{pf0d8f77.js → cnkky55j.js} +25 -14
- package/dist/shared/{5fqx9yh4.js → dk8v79p3.js} +3 -1
- package/dist/shared/{nkaxvt9q.js → dkxgzaqd.js} +224 -19
- package/dist/shared/dzj09cye.js +10 -0
- package/dist/shared/{4m9fn52z.js → ed0b8k4s.js} +1 -1
- package/dist/shared/{z2rnngj4.js → ek2wt2dz.js} +8 -5
- package/dist/shared/exn3sd90.js +359 -0
- package/dist/shared/g6evj1j3.js +66 -0
- package/dist/shared/ga9j92qj.js +25 -0
- package/dist/shared/{qv2ydck9.js → gs74dbj5.js} +651 -76
- package/dist/shared/gzaveazc.js +285 -0
- package/dist/shared/{8rsy3hxz.js → h15jx9bc.js} +1 -1
- package/dist/shared/{dyj86cmj.js → hyh73qk6.js} +3 -3
- package/dist/shared/je4axnm8.js +22 -0
- package/dist/shared/{ycatkxmq.js → jgqj11w4.js} +1 -1
- package/dist/shared/{6qd27mx0.js → jvd0mqag.js} +5 -5
- package/dist/shared/jznfax0y.js +155 -0
- package/dist/shared/{cgbamx3e.js → kb2sdhfb.js} +7 -4
- package/dist/shared/{ps7a6h14.js → kr0jzbw2.js} +12 -8
- package/dist/shared/{janx09m5.js → ktz42yez.js} +20 -8
- package/dist/shared/{gde73es6.js → m6p12kbr.js} +56 -55
- package/dist/shared/{r6nwkxnt.js → m7n9h2a5.js} +4 -4
- package/dist/shared/{672t5vym.js → mss6ctgv.js} +2 -2
- package/dist/shared/{nxdp2ze3.js → mtaszv5a.js} +144 -12
- package/dist/shared/n816peh1.js +45 -0
- package/dist/shared/nbw1z4yd.js +18 -0
- package/dist/shared/{cctw17hj.js → p6qc5gcp.js} +38 -34
- package/dist/shared/{6rk2gen5.js → pbp1ss85.js} +20 -17
- package/dist/shared/pt94kz7f.js +6 -0
- package/dist/shared/{wq9n6pwr.js → pz6rj8ay.js} +82 -9
- package/dist/shared/q5c6ngn3.js +13 -0
- package/dist/shared/{8bwbwy8h.js → qq3899ht.js} +128 -18
- package/dist/shared/{8ktwd3rh.js → r3j8s5y0.js} +1 -1
- package/dist/shared/rhs3xe4k.js +7 -0
- package/dist/shared/{ntneex2a.js → rpycarcr.js} +6 -6
- package/dist/shared/{sdc7r2ww.js → rs73fca9.js} +8 -8
- package/dist/shared/{tm5ab8we.js → sfz1ksn6.js} +7 -4
- package/dist/shared/{6mnp99hx.js → svncdeh5.js} +16 -12
- package/dist/shared/{hf22e0wt.js → tbrvgw6z.js} +62 -42
- package/dist/shared/te5as7z7.js +622 -0
- package/dist/shared/{ga3sfy93.js → tsvww22q.js} +535 -200
- package/dist/shared/{47x8x9ze.js → ttsqgp4p.js} +20 -13
- package/dist/shared/{x72jb7ad.js → v8g1vgv8.js} +1 -1
- package/dist/shared/vb6qfyve.js +152 -0
- package/dist/shared/{r2sp8hrc.js → vczs8gd4.js} +22 -13
- package/dist/shared/{1g0drakv.js → vqrjpcqn.js} +145 -3
- package/dist/shared/{2pqx26h8.js → w72kgg4q.js} +31 -22
- package/dist/shared/{96qcj21c.js → w79hsckn.js} +16 -51
- package/dist/shared/wa07eas9.js +730 -0
- package/dist/shared/{k8v5v5wj.js → x933k9a3.js} +75 -34
- package/dist/shared/{cr74e96e.js → xhfsfkgk.js} +62 -28
- package/dist/shared/xjk7hnn5.js +272 -0
- package/dist/shared/{5enne4ma.js → xnxsed62.js} +66 -113
- package/dist/shared/xqve9598.js +53 -0
- package/dist/shared/{9x25fxhc.js → y34a8714.js} +1 -1
- package/dist/shared/{k7dwkhvq.js → y6jdds7g.js} +4 -1
- package/dist/shared/y6njgyda.js +249 -0
- package/dist/shared/{c9z5g0fm.js → ywr8hmey.js} +5 -2
- package/dist/shared/{g7ez901n.js → ywspezzx.js} +1 -1
- package/dist/shared/z7s6fpxv.js +62 -0
- package/dist/shared/{n7mcc1gk.js → zchaghkf.js} +4 -3
- package/dist/shared/{9m80mkac.js → ze4hxsmy.js} +1 -1
- package/dist/shared/zm0ptry0.js +40 -0
- package/dist/shared/{nsva2a6b.js → znm0bpp5.js} +3 -0
- package/dist/shared/zp9fmend.js +145 -0
- package/dist/shared/{y005b761.js → zy8r7qvz.js} +6 -2
- package/dist/tooling/cli.js +41 -15
- package/dist/tooling/migrate/apply.d.ts +14 -0
- package/dist/tooling/migrate/check.d.ts +3 -4
- package/dist/tooling/migrate/classify.d.ts +4 -0
- package/dist/tooling/migrate/config.d.ts +3 -2
- package/dist/tooling/migrate/engine.d.ts +3 -2
- package/dist/tooling/migrate/files.d.ts +11 -1
- package/dist/tooling/migrate/index.js +14 -14
- package/dist/tooling/migrate/lint.d.ts +1 -1
- package/dist/tooling/migrate/lost.d.ts +28 -0
- package/dist/tooling/migrate/paths.d.ts +14 -0
- package/dist/tooling/migrate/plan.d.ts +6 -3
- package/dist/tooling/migrate/runner.d.ts +25 -0
- package/dist/tooling/migrate/sandbox.d.ts +57 -0
- package/dist/tooling/migrate/sql-lex.d.ts +20 -3
- package/dist/tooling/migrate/text.d.ts +42 -0
- package/dist/tooling/node-version.d.ts +21 -0
- package/dist/tooling/testing/facts.d.ts +33 -5
- package/dist/tooling/testing/index.d.ts +1 -1
- package/dist/tooling/testing/index.js +3 -3
- package/dist/tooling/testing/isolation.d.ts +11 -5
- package/package.json +8 -3
- package/dist/shared/7m88x3e9.js +0 -45
- package/dist/shared/7zwwyh0v.js +0 -448
- package/dist/shared/aj2qxyhj.js +0 -90
- package/dist/shared/caw8b9d8.js +0 -204
- package/dist/shared/jwtxdj06.js +0 -76
- package/dist/shared/kfjp0gck.js +0 -212
- package/dist/shared/q58y17hy.js +0 -21
- package/dist/shared/qm7cdtvr.js +0 -912
- package/dist/shared/r8x5qhd7.js +0 -86
- package/dist/shared/zqrnhwsq.js +0 -31
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* OKM11xx for a driver that lacks a flag: OKM1110 is the engine-version gate,
|
|
6
6
|
* and OKM1801 is a dialect mismatch. This module does not invent a code and
|
|
7
7
|
* does not throw for a missing flag.
|
|
8
|
+
*
|
|
9
|
+
* `stream` means the driver can open a server cursor. `.stream()` does not
|
|
10
|
+
* read it. That method walks keyset batches on every driver.
|
|
8
11
|
*/
|
|
9
12
|
import type { DriverCapabilities } from "../contracts/driver.js";
|
|
10
13
|
/** Capability names a caller can read. */
|
|
@@ -13,10 +13,21 @@ export declare function driverErrors(): Promise<ErrorModule>;
|
|
|
13
13
|
/**
|
|
14
14
|
* Rejects with a closed-pool {@link import("./error.js").DriverError}.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
16
|
+
* The text and SQLSTATE `08006` load with the lazy error module. Classification
|
|
17
|
+
* reads the SQLSTATE. The message is "The pool is closed."
|
|
18
|
+
*
|
|
19
|
+
* @returns A rejected promise
|
|
20
|
+
*/
|
|
21
|
+
export declare function rejectClosed(): Promise<never>;
|
|
22
|
+
/**
|
|
23
|
+
* Rejects with OKM1120 when a driver cannot cancel a positive timeout.
|
|
24
|
+
*
|
|
25
|
+
* The message stays `timeout`. Kind stays `invalid`. Bun.sql and PGlite call
|
|
26
|
+
* this. Other drivers do not, so their connect graphs omit it.
|
|
27
|
+
*
|
|
17
28
|
* @returns A rejected promise
|
|
18
29
|
*/
|
|
19
|
-
export declare function
|
|
30
|
+
export declare function rejectUncancellable(): Promise<never>;
|
|
20
31
|
/**
|
|
21
32
|
* Rejects with kind `cancelled`.
|
|
22
33
|
*
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error text a connect entry does not need until a call fails.
|
|
3
|
+
*
|
|
4
|
+
* Loaded on the first closed pool or on a positive `timeout` for a driver
|
|
5
|
+
* that cannot cancel. A successful execute does not import this module.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* OKM1120 for a positive `timeout` on Bun.sql or PGlite.
|
|
9
|
+
*
|
|
10
|
+
* Kind stays `invalid`. The message stays `timeout` (D224, D239).
|
|
11
|
+
*
|
|
12
|
+
* @returns A rejected promise
|
|
13
|
+
*/
|
|
14
|
+
export declare function refused(): Promise<never>;
|
|
15
|
+
/**
|
|
16
|
+
* A pool that has already been closed.
|
|
17
|
+
*
|
|
18
|
+
* The message is for people. Classification reads SQLSTATE `08006`.
|
|
19
|
+
*
|
|
20
|
+
* @returns A rejected promise
|
|
21
|
+
*/
|
|
22
|
+
export declare function closed(): Promise<never>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Reserved connections for Bun.sql.
|
|
3
3
|
*
|
|
4
|
-
* Loaded on the first reserve, batch, or
|
|
4
|
+
* Loaded on the first reserve, batch, stream, or dead connection. A read that
|
|
5
|
+
* succeeds does not use it.
|
|
5
6
|
*/
|
|
6
|
-
import type {
|
|
7
|
+
import type { ReservedSQL, SQL } from "bun";
|
|
8
|
+
import type { DriverConnection, WireValue } from "../../contracts/driver.js";
|
|
7
9
|
import { type HeldPool } from "./bunsql.js";
|
|
8
10
|
/**
|
|
9
11
|
* Checks out one connection and clears it on release.
|
|
@@ -14,4 +16,53 @@ import { type HeldPool } from "./bunsql.js";
|
|
|
14
16
|
* @param held - The pool and its counters
|
|
15
17
|
* @returns A connection the caller must release
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Drops a dead pooled socket, then runs `again` once when that is safe.
|
|
21
|
+
*
|
|
22
|
+
* A `57P01` or a socket Bun has already closed is evicted before another
|
|
23
|
+
* statement can take it. A client read is tried once more when `depth` is 0.
|
|
24
|
+
* A raw pool retries only when the socket had already closed, or Bun rejected
|
|
25
|
+
* the statement before the server saw it, so a query killed while it was
|
|
26
|
+
* running is not started again. `again` does not pass through `recover`.
|
|
27
|
+
*
|
|
28
|
+
* @param sql - The pool
|
|
29
|
+
* @param error - The failure from the first attempt
|
|
30
|
+
* @param text - Statement text, used to decide the retry
|
|
31
|
+
* @param depth - Open transaction depth. Above zero, an earlier command was sent
|
|
32
|
+
* @param clientRead - The pool was opened for a client, which retries a read once
|
|
33
|
+
* @param closedDuring - `onclose` ran after this statement was sent
|
|
34
|
+
* @param again - The same statement, on whatever connection the pool hands out next
|
|
35
|
+
* @returns The retried result, or a rejection of `error`
|
|
36
|
+
*/
|
|
37
|
+
export declare function recover<T>(sql: SQL, error: unknown, text: string, depth: number, clientRead: boolean, closedDuring: boolean, again: () => Promise<T>): Promise<T>;
|
|
38
|
+
/**
|
|
39
|
+
* Spends a closed socket before the caller's statement is sent.
|
|
40
|
+
*
|
|
41
|
+
* @param sql - The pool
|
|
42
|
+
*/
|
|
43
|
+
export declare function drainClosed(sql: SQL): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Subscribes on one pooled connection.
|
|
46
|
+
*
|
|
47
|
+
* @param sql - The pool
|
|
48
|
+
* @param parked - Reserved handles to put back first
|
|
49
|
+
* @param closed - The pool is closed
|
|
50
|
+
* @param channel - Notify channel
|
|
51
|
+
* @param onNotify - Payload callback
|
|
52
|
+
* @returns Stops the subscription
|
|
53
|
+
*/
|
|
54
|
+
export declare function listen(sql: SQL, parked: ReservedSQL[], closed: boolean, channel: string, onNotify: (payload: string) => void): Promise<() => Promise<void>>;
|
|
55
|
+
export declare function checkout(held: HeldPool): Promise<DriverConnection & {
|
|
56
|
+
evict(): void;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Yields cursor chunks from one checked-out Bun.sql connection.
|
|
60
|
+
*
|
|
61
|
+
* @param checkout - Reserves the connection
|
|
62
|
+
* @param text - Query to stream
|
|
63
|
+
* @param params - Wire parameters
|
|
64
|
+
* @returns Chunks of wire rows
|
|
65
|
+
*/
|
|
66
|
+
export declare function streamRows(checkout: () => Promise<DriverConnection & {
|
|
67
|
+
evict?: () => void;
|
|
68
|
+
}>, text: string, params: readonly WireValue[] | undefined): AsyncIterable<readonly (readonly WireValue[])[]>;
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { SQL, type ReservedSQL } from "bun";
|
|
13
13
|
import type { DriverPool, DriverPoolConfig, WireValue } from "../../contracts/driver.js";
|
|
14
|
+
import { DriverError } from "../error.js";
|
|
14
15
|
import { noticeBuffer, type WireQuery } from "./session.js";
|
|
15
16
|
export { BUNSQL_CAPABILITIES as capabilities, hasCapability, readCapability, } from "../capabilities.js";
|
|
16
|
-
export { DriverError }
|
|
17
|
+
export { DriverError };
|
|
17
18
|
/** TLS values Bun.sql accepts that this adapter forwards. */
|
|
18
19
|
export type BunSqlTls = boolean | "disable" | "allow" | "prefer" | "require" | "verify-ca" | "verify-full";
|
|
19
20
|
/** Options for {@link open}. */
|
|
@@ -40,7 +41,19 @@ export type HeldPool = {
|
|
|
40
41
|
readonly counters: Counters;
|
|
41
42
|
readonly notices: ReturnType<typeof noticeBuffer>;
|
|
42
43
|
readonly isClosed: () => boolean;
|
|
44
|
+
/** Sockets this pool has closed. The count never returns to zero. */
|
|
45
|
+
readonly closures: () => number;
|
|
43
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Marks a pool opened for a client.
|
|
49
|
+
*
|
|
50
|
+
* A client read that finds a dead socket is tried once. A pool from raw
|
|
51
|
+
* {@link open} is not marked, so a statement the server killed while it was
|
|
52
|
+
* running is not started again.
|
|
53
|
+
*
|
|
54
|
+
* @param pool - The pool `connect` just opened
|
|
55
|
+
*/
|
|
56
|
+
export declare function markClientPool(pool: DriverPool): void;
|
|
44
57
|
/** Pool occupancy. */
|
|
45
58
|
export type Counters = {
|
|
46
59
|
reserved: number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side cursor for drivers that stream through a checked-out connection.
|
|
3
|
+
*
|
|
4
|
+
* Loaded with the stream chunk. A read does not import this.
|
|
5
|
+
*/
|
|
6
|
+
import type { ExecuteResult, WireValue } from "../../contracts/driver.js";
|
|
7
|
+
/**
|
|
8
|
+
* Yields cursor chunks from one connection that is already checked out.
|
|
9
|
+
*
|
|
10
|
+
* The cursor is session-local. `ROLLBACK` in the end drops it.
|
|
11
|
+
*
|
|
12
|
+
* @param run - Executes on the checked-out connection
|
|
13
|
+
* @param text - Query to stream
|
|
14
|
+
* @param params - Wire parameters
|
|
15
|
+
* @returns Chunks of wire rows
|
|
16
|
+
*/
|
|
17
|
+
export declare function cursorStream(run: (text: string, params?: readonly WireValue[]) => Promise<ExecuteResult>, text: string, params: readonly WireValue[] | undefined): AsyncIterable<readonly (readonly WireValue[])[]>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refusal for a driver that cannot cancel an in-flight statement (D224).
|
|
3
|
+
*
|
|
4
|
+
* Bun.sql and PGlite refuse a positive `timeout`. The OKM1120 text loads with
|
|
5
|
+
* the lazy error module, so a connect entry does not carry it. Kind is
|
|
6
|
+
* `invalid`, which separates it from kind `timeout`. `timeout: 0` still fails
|
|
7
|
+
* immediately as kind `timeout`. `signal` is unchanged. postgres.js and
|
|
8
|
+
* node-postgres do not import this.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Returns a rejected OKM1120 when `timeout` is a positive number.
|
|
12
|
+
*
|
|
13
|
+
* Absent, and a non-positive timeout, return `undefined` so the caller runs.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Per-call options
|
|
16
|
+
* @returns A rejected promise, or `undefined` when the call may run
|
|
17
|
+
*/
|
|
18
|
+
export declare function noTimeout(options: {
|
|
19
|
+
readonly timeout?: number;
|
|
20
|
+
} | undefined): Promise<never> | undefined;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Loaded on the first reserve, batch, or stream. A read does not use it.
|
|
5
5
|
*/
|
|
6
|
-
import type { DriverConnection } from "../../contracts/driver.js";
|
|
6
|
+
import type { DriverConnection, WireValue } from "../../contracts/driver.js";
|
|
7
7
|
import { type HeldPool } from "./nodepostgres.js";
|
|
8
8
|
/**
|
|
9
9
|
* Checks out one client and clears it on release.
|
|
@@ -16,3 +16,24 @@ import { type HeldPool } from "./nodepostgres.js";
|
|
|
16
16
|
* @returns A connection the caller must release
|
|
17
17
|
*/
|
|
18
18
|
export declare function checkout(held: HeldPool): Promise<DriverConnection>;
|
|
19
|
+
/**
|
|
20
|
+
* Listens on one checked-out client.
|
|
21
|
+
*
|
|
22
|
+
* The client has no pool error listener. One is set here so a dropped socket
|
|
23
|
+
* is not an uncaught `error` event.
|
|
24
|
+
*
|
|
25
|
+
* @param held - The pool and its counters
|
|
26
|
+
* @param channel - Notification channel
|
|
27
|
+
* @param onNotify - Called with each payload
|
|
28
|
+
* @returns Stops the listener
|
|
29
|
+
*/
|
|
30
|
+
export declare function listen(held: HeldPool, channel: string, onNotify: (payload: string) => void): Promise<() => Promise<void>>;
|
|
31
|
+
/**
|
|
32
|
+
* Yields cursor chunks from one checked-out client.
|
|
33
|
+
*
|
|
34
|
+
* @param checkout - Reserves the connection
|
|
35
|
+
* @param text - Query to stream
|
|
36
|
+
* @param params - Wire parameters
|
|
37
|
+
* @returns Chunks of wire rows
|
|
38
|
+
*/
|
|
39
|
+
export declare function streamRows(checkout: () => Promise<DriverConnection>, text: string, params: readonly WireValue[] | undefined): AsyncIterable<readonly (readonly WireValue[])[]>;
|
|
@@ -44,6 +44,18 @@ export type Counters = {
|
|
|
44
44
|
reservedBusy: number;
|
|
45
45
|
waiting: number;
|
|
46
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Attaches the one error listener a pool or a checked-out client can use.
|
|
49
|
+
*
|
|
50
|
+
* node-postgres types list `connect` and `notification` only. An idle pool
|
|
51
|
+
* client and a `LISTEN` client both emit `error` with no listener, and that
|
|
52
|
+
* is an uncaught exception. The default handler ignores it. The pool has
|
|
53
|
+
* already removed an idle client.
|
|
54
|
+
*
|
|
55
|
+
* @param source - Pool or client
|
|
56
|
+
* @param handle - What to do with the error
|
|
57
|
+
*/
|
|
58
|
+
export declare function armDriverError(source: object, handle?: () => void): void;
|
|
47
59
|
/**
|
|
48
60
|
* Opens a node-postgres pool for one endpoint.
|
|
49
61
|
*
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PGlite wire codecs, loaded from {@link import("./pglite.ts").open}.
|
|
3
|
+
*
|
|
4
|
+
* A JS number, bigint, or boolean is sent as wire text. An `08P01` from a
|
|
5
|
+
* bad parameter is a driver error. A lost connection stays `unavailable`.
|
|
6
|
+
*/
|
|
7
|
+
declare const parsers: Record<number, (value: string) => string>;
|
|
8
|
+
declare const serializers: Record<number, (value: unknown) => string>;
|
|
9
|
+
/** Identity parsers. The dialect owns parsing. */
|
|
10
|
+
export { parsers };
|
|
11
|
+
/** Wire-text serializers. Number, bigint, and boolean are text. */
|
|
12
|
+
export { serializers };
|
|
13
|
+
/**
|
|
14
|
+
* Maps a PGlite failure.
|
|
15
|
+
*
|
|
16
|
+
* `08P01` means the parameter did not fit the protocol message. The
|
|
17
|
+
* replacement carries the message and neither a SQLSTATE nor a cause, so the
|
|
18
|
+
* kind is `driver`. Any other failure, including a closed connection, is
|
|
19
|
+
* mapped unchanged.
|
|
20
|
+
*
|
|
21
|
+
* @param error - Caught value
|
|
22
|
+
* @returns A normalised driver error
|
|
23
|
+
*/
|
|
24
|
+
export declare function fail(error: unknown): Promise<unknown>;
|
|
@@ -19,3 +19,13 @@ export type PgliteConfig = DriverPoolConfig & {
|
|
|
19
19
|
* @returns The pool
|
|
20
20
|
*/
|
|
21
21
|
export declare function open(config?: PgliteConfig): Promise<DriverPool>;
|
|
22
|
+
/**
|
|
23
|
+
* A pool whose `close` marks this client only.
|
|
24
|
+
*
|
|
25
|
+
* The inner pool stays open. A later call fails as unavailable.
|
|
26
|
+
* The body stays this small: the PGlite incremental figure is 11,510, 500 under its gate.
|
|
27
|
+
*
|
|
28
|
+
* @param pool - The caller's pool
|
|
29
|
+
* @returns A pool the client owns
|
|
30
|
+
*/
|
|
31
|
+
export declare function seal(pool: DriverPool): DriverPool;
|
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
* Loaded on the first reserve, batch, describe, or stream.
|
|
5
5
|
*/
|
|
6
6
|
import type { Sql } from "postgres";
|
|
7
|
-
import type { DescribeResult, DriverConnection, ExecuteResult, WireValue } from "../../contracts/driver.js";
|
|
7
|
+
import type { DescribeResult, DriverConnection, ExecuteOptions, ExecuteResult, Statement, WireValue } from "../../contracts/driver.js";
|
|
8
8
|
import { type Watch } from "./call.js";
|
|
9
9
|
import { type Canceller, type Counters, type NoticeBuffer } from "./postgresjs.js";
|
|
10
|
+
type Lost = {
|
|
11
|
+
on: boolean;
|
|
12
|
+
/** Rejects the reset or drain that is using this reserved connection. */
|
|
13
|
+
stop: () => void;
|
|
14
|
+
};
|
|
10
15
|
/** State `open` shares with a checkout. */
|
|
11
16
|
export type HeldPool = {
|
|
12
17
|
readonly sql: Sql;
|
|
@@ -23,7 +28,7 @@ export type HeldPool = {
|
|
|
23
28
|
* @param pool - The open pool
|
|
24
29
|
* @returns A connection the caller must release
|
|
25
30
|
*/
|
|
26
|
-
export declare function checkout(pool: HeldPool): Promise<DriverConnection>;
|
|
31
|
+
export declare function checkout(pool: HeldPool, timeoutMs?: number): Promise<DriverConnection>;
|
|
27
32
|
/**
|
|
28
33
|
* Describes a statement.
|
|
29
34
|
*
|
|
@@ -42,7 +47,40 @@ export declare function describe(sql: Sql, text: string, params?: readonly WireV
|
|
|
42
47
|
* @returns Chunks of wire rows
|
|
43
48
|
*/
|
|
44
49
|
export declare function stream(sql: Sql, text: string, params?: readonly WireValue[]): AsyncIterable<readonly (readonly WireValue[])[]>;
|
|
45
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Settles `run` when `ms` elapses, the reserved connection closes, or every
|
|
52
|
+
* slot in the pool has closed.
|
|
53
|
+
*
|
|
54
|
+
* A positive `ms` rejects with `timeout` and does not use the pool close hook.
|
|
55
|
+
* `link` is the reserved connection's lost flag, or the pool client.
|
|
56
|
+
*
|
|
57
|
+
* @param ms - Deadline in milliseconds. `0` waits for a close
|
|
58
|
+
* @param run - Driver operation
|
|
59
|
+
* @param link - Connection flag, or the pool client when the wait has no connection
|
|
60
|
+
* @returns The operation's value
|
|
61
|
+
*/
|
|
62
|
+
export declare function deadline<T>(ms: number, run: () => Promise<T>, link?: Lost | Sql): Promise<T>;
|
|
63
|
+
/**
|
|
64
|
+
* Checks out one connection, runs one batch, and releases it.
|
|
65
|
+
*
|
|
66
|
+
* The call timeout covers acquiring the connection and clearing it on release.
|
|
67
|
+
*
|
|
68
|
+
* @param pool - The open pool
|
|
69
|
+
* @param statements - Statements in order
|
|
70
|
+
* @param options - Call timeout and signal
|
|
71
|
+
* @returns One result per statement
|
|
72
|
+
*/
|
|
73
|
+
export declare function runBatch(pool: HeldPool, statements: readonly Statement[], options: ExecuteOptions | undefined): Promise<readonly ExecuteResult[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Sets `lost` when the reserved socket closes.
|
|
76
|
+
*
|
|
77
|
+
* The first statement installs `onclose`. Later statements see the flag
|
|
78
|
+
* before they write.
|
|
79
|
+
*
|
|
80
|
+
* @param sql - Reserved connection
|
|
81
|
+
* @param lost - Set when that socket closes
|
|
82
|
+
*/
|
|
83
|
+
export declare function watchReserved(sql: Sql, lost: Lost): void;
|
|
46
84
|
type Gate = {
|
|
47
85
|
enter(): void;
|
|
48
86
|
leave(): void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared reset and lost-connection guard for a reserved connection.
|
|
3
|
+
*
|
|
4
|
+
* node-postgres, Bun.sql, and PGlite load this with the first reserve.
|
|
5
|
+
* postgres.js keeps its own copy: a second module in that adapter bundle
|
|
6
|
+
* crosses the incremental size gate.
|
|
7
|
+
*/
|
|
8
|
+
/** Set when the reserved socket is gone. */
|
|
9
|
+
export type Lost = {
|
|
10
|
+
on: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Clears session state on a reserved connection.
|
|
14
|
+
*
|
|
15
|
+
* A failed reset rolls back and tries once more. The caller supplies `run`.
|
|
16
|
+
*
|
|
17
|
+
* @param depth - Open transaction depth. Above zero, roll back first
|
|
18
|
+
* @param run - Executes one statement on the reserved connection
|
|
19
|
+
*/
|
|
20
|
+
export declare function resetSession(depth: number, run: (text: string) => Promise<unknown>): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Clears a PGlite session the same way {@link resetSession} clears the others.
|
|
23
|
+
*
|
|
24
|
+
* Rollback goes through the session so its depth is cleared on failure too.
|
|
25
|
+
*
|
|
26
|
+
* @param session - The single PGlite connection
|
|
27
|
+
*/
|
|
28
|
+
export declare function resetQueried(session: {
|
|
29
|
+
inTransaction(): boolean;
|
|
30
|
+
rollback(): Promise<void>;
|
|
31
|
+
query(text: string, params: undefined, watch: undefined): Promise<unknown>;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Refuses the next statement after the reserved connection is gone.
|
|
35
|
+
*
|
|
36
|
+
* The first lost-connection error sets the flag.
|
|
37
|
+
*
|
|
38
|
+
* @param lost - Set when the socket is gone
|
|
39
|
+
* @param run - The statement
|
|
40
|
+
* @returns The statement, or a closed-pool rejection
|
|
41
|
+
*/
|
|
42
|
+
export declare function refuseWhenLost<T>(lost: Lost, run: () => Promise<T>): Promise<T>;
|
|
@@ -23,13 +23,6 @@ export type NoticeBuffer = {
|
|
|
23
23
|
readonly code?: string | undefined;
|
|
24
24
|
}): void;
|
|
25
25
|
};
|
|
26
|
-
/**
|
|
27
|
-
* Quotes one identifier.
|
|
28
|
-
*
|
|
29
|
-
* @param name - Channel or cursor name
|
|
30
|
-
* @returns A double-quoted identifier
|
|
31
|
-
*/
|
|
32
|
-
export declare function quoteIdent(name: string): string;
|
|
33
26
|
/**
|
|
34
27
|
* An empty notice buffer the pool fills as the server sends notices.
|
|
35
28
|
*
|
|
@@ -81,14 +74,3 @@ export declare class WireSession implements BatchSession {
|
|
|
81
74
|
private watched;
|
|
82
75
|
private finishWatched;
|
|
83
76
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Yields cursor chunks from one connection that is already checked out.
|
|
86
|
-
*
|
|
87
|
-
* The cursor is session-local. `ROLLBACK` in the end drops it.
|
|
88
|
-
*
|
|
89
|
-
* @param run - Executes on the checked-out connection
|
|
90
|
-
* @param text - Query to stream
|
|
91
|
-
* @param params - Wire parameters
|
|
92
|
-
* @returns Chunks of wire rows
|
|
93
|
-
*/
|
|
94
|
-
export declare function cursorStream(run: (text: string, params?: readonly WireValue[]) => Promise<ExecuteResult>, text: string, params: readonly WireValue[] | undefined): AsyncIterable<readonly (readonly WireValue[])[]>;
|
|
@@ -67,11 +67,13 @@ export declare function catalogHash(source: Catalog): string;
|
|
|
67
67
|
*
|
|
68
68
|
* Roles, grants, and default privileges come from the migration config, not
|
|
69
69
|
* the schema, so they are left out. A `schema()` catalog never has them, so
|
|
70
|
-
* `connect()` hashes it unchanged. `okm check` still verifies them.
|
|
71
|
-
*
|
|
70
|
+
* `connect()` hashes it unchanged. `okm check` still verifies them. An
|
|
71
|
+
* `external` or `ignored` owner is planning state. The startup copy writes
|
|
72
|
+
* it back to `managed`, which is what `schema()` stored. A catalog with
|
|
73
|
+
* neither privileges nor those owners is returned as is.
|
|
72
74
|
*
|
|
73
75
|
* @param source - Catalog document
|
|
74
|
-
* @returns The catalog
|
|
76
|
+
* @returns The catalog `connect()` hashes
|
|
75
77
|
*/
|
|
76
78
|
export declare function startupCatalog(source: Catalog): Catalog;
|
|
77
79
|
/**
|
|
@@ -89,11 +91,23 @@ export declare function startupHash(source: Catalog): string;
|
|
|
89
91
|
* stored hash and the version, then trusts the objects (D133). `okm check`
|
|
90
92
|
* and dev keep {@link parseCatalog}.
|
|
91
93
|
*
|
|
92
|
-
* @param text -
|
|
93
|
-
* @param hash - SHA-256 of
|
|
94
|
+
* @param text - Catalog JSON. A BOM is stripped and `\r` is removed before the hash check
|
|
95
|
+
* @param hash - SHA-256 of that normalized text, stored beside the artifact
|
|
94
96
|
* @returns The catalog document
|
|
95
97
|
*/
|
|
96
98
|
export declare function loadTrustedCatalog(text: string, hash: string): Catalog;
|
|
99
|
+
/**
|
|
100
|
+
* Catalog file bytes the hash covers.
|
|
101
|
+
*
|
|
102
|
+
* A leading UTF-8 BOM is dropped. Carriage returns are removed, so a CRLF
|
|
103
|
+
* checkout hashes like the LF file the writer stored. An LF file is unchanged.
|
|
104
|
+
* UTF-16 is OKM1027.
|
|
105
|
+
*
|
|
106
|
+
* @param text - Raw catalog JSON or hash file
|
|
107
|
+
* @param label - Name used when the text is UTF-16
|
|
108
|
+
* @returns Text to hash and parse
|
|
109
|
+
*/
|
|
110
|
+
export declare function catalogFileText(text: string, label?: string): string;
|
|
97
111
|
/**
|
|
98
112
|
* Reads canonical catalog JSON.
|
|
99
113
|
*
|
|
@@ -106,7 +106,8 @@ export declare function index(input: IndexInput): IndexObject;
|
|
|
106
106
|
* Builds a constraint object.
|
|
107
107
|
*
|
|
108
108
|
* Primary key names are `{parent}_pkey` and do not include column names.
|
|
109
|
-
*
|
|
109
|
+
* Unique and foreign-key names use every SQL column. Checks use `nameKey`,
|
|
110
|
+
* which stays fixed when a field is renamed. `nameKey` is always stored.
|
|
110
111
|
*
|
|
111
112
|
* @param input - Parent, kind, columns, and the stable name key
|
|
112
113
|
* @returns A constraint envelope
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Row-level security policy catalog objects.
|
|
3
|
+
*
|
|
4
|
+
* The factory stores the record. It does not plan SQL. Postgres DDL stays in
|
|
5
|
+
* the dialect. A schema that never imports `rlsTenancy` does not load this.
|
|
6
|
+
*/
|
|
7
|
+
import type { ObjectIdentity, ObjectRef, Owner, PolicyCommand, PolicyObject, Provenance } from "./types.js";
|
|
8
|
+
/** Input for {@link policyObject}. */
|
|
9
|
+
export type PolicyInput = {
|
|
10
|
+
readonly parent: ObjectRef;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly command: PolicyCommand;
|
|
13
|
+
readonly expression: string;
|
|
14
|
+
/** True when the table is `FORCE ROW LEVEL SECURITY`. */
|
|
15
|
+
readonly force: boolean;
|
|
16
|
+
readonly owner?: Owner;
|
|
17
|
+
readonly provenance: Provenance;
|
|
18
|
+
/** Extra edges. The parent table is always included. */
|
|
19
|
+
readonly dependencies?: readonly ObjectIdentity[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Predicate stored for `{table}_tenant`.
|
|
23
|
+
*
|
|
24
|
+
* The text is what `pg_get_expr` prints, so a replayed catalog matches.
|
|
25
|
+
* An unset `app.tenant` becomes null and the comparison matches no row.
|
|
26
|
+
*
|
|
27
|
+
* @param column - SQL name of the tenant column
|
|
28
|
+
* @param dataType - Postgres type of that column
|
|
29
|
+
* @returns The `USING` and `WITH CHECK` expression
|
|
30
|
+
*/
|
|
31
|
+
export declare function tenantPolicyExpression(column: string, dataType: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Predicate stored for `{table}_unscoped_select`.
|
|
34
|
+
*
|
|
35
|
+
* `SELECT` only. Writes stay on the tenant policy.
|
|
36
|
+
*
|
|
37
|
+
* @returns The `USING` expression
|
|
38
|
+
*/
|
|
39
|
+
export declare function unscopedPolicyExpression(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Builds a policy record.
|
|
42
|
+
*
|
|
43
|
+
* Identity is `(parent, name)`. A name past the dialect limit is fitted.
|
|
44
|
+
*
|
|
45
|
+
* @param input - Parent table, command, and expression
|
|
46
|
+
* @returns The catalog object
|
|
47
|
+
*/
|
|
48
|
+
export declare function policyObject(input: PolicyInput): PolicyObject;
|
|
@@ -393,6 +393,13 @@ export type ViewColumn = {
|
|
|
393
393
|
export type ViewDefinition = {
|
|
394
394
|
readonly columns: readonly ViewColumn[];
|
|
395
395
|
readonly query: string;
|
|
396
|
+
/**
|
|
397
|
+
* `WITH (security_invoker = true)`.
|
|
398
|
+
*
|
|
399
|
+
* Set only for a view over tenant tables under `rlsTenancy`. Omitted
|
|
400
|
+
* otherwise, so a view under another strategy keeps the same catalog bytes.
|
|
401
|
+
*/
|
|
402
|
+
readonly securityInvoker?: true;
|
|
396
403
|
};
|
|
397
404
|
/**
|
|
398
405
|
* Materialized view definition.
|
|
@@ -440,10 +447,27 @@ export type RoleObject = CatalogEnvelope<"role", RoleIdentity, RoleDefinition>;
|
|
|
440
447
|
export type GrantObject = CatalogEnvelope<"grant", GrantIdentity, GrantDefinition>;
|
|
441
448
|
/** A default privilege. Identity is `(forRole, namespace, objectKind, grantee, privilege)`. */
|
|
442
449
|
export type DefaultPrivilegeObject = CatalogEnvelope<"defaultPrivilege", DefaultPrivilegeIdentity, DefaultPrivilegeDefinition>;
|
|
450
|
+
/** Which statements a policy covers. `all` is every command. `select` is reads. */
|
|
451
|
+
export type PolicyCommand = "all" | "select";
|
|
452
|
+
/**
|
|
453
|
+
* One row-level security policy.
|
|
454
|
+
*
|
|
455
|
+
* `expression` is the `USING` text, and the `WITH CHECK` text when `command`
|
|
456
|
+
* is `all`. `force` is true when the table is `FORCE ROW LEVEL SECURITY`.
|
|
457
|
+
*/
|
|
458
|
+
export type PolicyDefinition = {
|
|
459
|
+
readonly command: PolicyCommand;
|
|
460
|
+
readonly expression: string;
|
|
461
|
+
readonly force: boolean;
|
|
462
|
+
};
|
|
463
|
+
/** A policy. Identity is `(parent, name)`. */
|
|
464
|
+
export type PolicyObject = CatalogEnvelope<"policy", AnchoredIdentity & {
|
|
465
|
+
readonly kind: "policy";
|
|
466
|
+
}, PolicyDefinition>;
|
|
443
467
|
/**
|
|
444
468
|
* One built catalog object.
|
|
445
469
|
*/
|
|
446
|
-
export type CatalogObject = TableObject | ColumnObject | IndexObject | ConstraintObject | SequenceObject | TypeObject | ExtensionObject | FunctionObject | TriggerObject | ViewObject | MaterializedViewObject | RoleObject | GrantObject | DefaultPrivilegeObject;
|
|
470
|
+
export type CatalogObject = TableObject | ColumnObject | IndexObject | ConstraintObject | SequenceObject | TypeObject | ExtensionObject | FunctionObject | TriggerObject | ViewObject | MaterializedViewObject | RoleObject | GrantObject | DefaultPrivilegeObject | PolicyObject;
|
|
447
471
|
/** Format version stored in the serialized catalog. */
|
|
448
472
|
export declare const CATALOG_VERSION = 1;
|
|
449
473
|
/** A catalog document. Object order is identity-key order. */
|
|
@@ -11,6 +11,8 @@ export type ViewInput = {
|
|
|
11
11
|
readonly name: string;
|
|
12
12
|
readonly columns: readonly ViewColumn[];
|
|
13
13
|
readonly query: string;
|
|
14
|
+
/** `WITH (security_invoker = true)`. Omitted from the record when unset. */
|
|
15
|
+
readonly securityInvoker?: true;
|
|
14
16
|
readonly owner?: Owner;
|
|
15
17
|
readonly provenance: Provenance;
|
|
16
18
|
readonly dependencies?: readonly ObjectIdentity[];
|
|
@@ -24,8 +24,10 @@ export declare function isConnectionErrno(code: string): boolean;
|
|
|
24
24
|
/**
|
|
25
25
|
* Reports whether `error` is a dropped or refused connection.
|
|
26
26
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
27
|
+
* The decision is a driver `code` ({@link isConnectionErrno}, including
|
|
28
|
+
* `CONNECT_TIMEOUT`, or `ERR_POSTGRES_CONNECTION_CLOSED`) or a SQLSTATE in
|
|
29
|
+
* class `08` or `57P01`–`57P03`. A server SQLSTATE outside that set is never
|
|
30
|
+
* a lost connection. Message text is not read.
|
|
29
31
|
*
|
|
30
32
|
* @param error - Caught value
|
|
31
33
|
* @returns `true` when no session remains
|
|
@@ -35,10 +37,9 @@ export declare function isConnectionFailure(error: unknown): boolean;
|
|
|
35
37
|
* Reports whether the connection is gone after `error`, or the outcome of a
|
|
36
38
|
* statement on it is unknown (`outcome_unknown`).
|
|
37
39
|
*
|
|
38
|
-
* It reads what {@link isConnectionFailure} reads,
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* not a rollback, not a reset. Loaded with the code that reserves a connection.
|
|
40
|
+
* It reads what {@link isConnectionFailure} reads, and the error's `cause`.
|
|
41
|
+
* Nothing more should be sent to such a connection: not a rollback, not a
|
|
42
|
+
* reset. Loaded with the code that reserves a connection.
|
|
42
43
|
*
|
|
43
44
|
* @param error - Caught value
|
|
44
45
|
* @returns `true` when the session cannot be used again
|
|
@@ -14,6 +14,16 @@
|
|
|
14
14
|
* @returns `file.ts:line`, or `undefined` when the runtime has no stack
|
|
15
15
|
*/
|
|
16
16
|
export declare function callerLocation(skip: number): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* File and line from stack lines, skipping `location.ts` frames.
|
|
19
|
+
*
|
|
20
|
+
* A frame may use `/` or `\`.
|
|
21
|
+
*
|
|
22
|
+
* @param lines - `Error.stack` split on `\n`
|
|
23
|
+
* @param skip - Callers to pass before the frame that is recorded
|
|
24
|
+
* @returns `file.ts:line`, or `undefined` when no frame remains
|
|
25
|
+
*/
|
|
26
|
+
export declare function locationFromLines(lines: readonly string[], skip: number): string | undefined;
|
|
17
27
|
/**
|
|
18
28
|
* Appends a source location to an error message.
|
|
19
29
|
*
|