okmodel 0.1.1 → 0.3.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 +727 -37
- package/dist/adapters/capabilities.d.ts +34 -0
- package/dist/adapters/pg/bunsql-extra.d.ts +17 -0
- package/dist/adapters/pg/bunsql.d.ts +60 -0
- package/dist/adapters/pg/call.d.ts +2 -12
- package/dist/adapters/pg/nodepostgres-extra.d.ts +18 -0
- package/dist/adapters/pg/nodepostgres.d.ts +57 -0
- package/dist/adapters/pg/postgres-extra.d.ts +50 -1
- package/dist/adapters/pg/postgresjs.d.ts +0 -4
- package/dist/adapters/pg/session.d.ts +94 -0
- package/dist/adapters/pg/watch.d.ts +18 -0
- package/dist/contracts/catalog/enum.d.ts +31 -4
- package/dist/contracts/catalog/extension.d.ts +61 -0
- package/dist/contracts/catalog/object.d.ts +1 -0
- package/dist/contracts/catalog/privilege.d.ts +64 -0
- package/dist/contracts/catalog/routine.d.ts +56 -0
- package/dist/contracts/catalog/types.d.ts +179 -18
- package/dist/contracts/catalog/view.d.ts +73 -0
- package/dist/contracts/connection.d.ts +13 -0
- package/dist/contracts/driver.d.ts +18 -5
- package/dist/contracts/error.d.ts +17 -1
- package/dist/contracts/generator.d.ts +63 -0
- package/dist/contracts/index.d.ts +2 -2
- package/dist/contracts/index.js +1 -1
- package/dist/contracts/internal.js +11 -9
- package/dist/contracts/location.d.ts +24 -0
- package/dist/contracts/rows.d.ts +15 -0
- package/dist/dialects/pg/archive-bind.d.ts +22 -0
- package/dist/dialects/pg/column.d.ts +129 -10
- package/dist/dialects/pg/compile.d.ts +1 -0
- package/dist/dialects/pg/custom.d.ts +6 -0
- package/dist/dialects/pg/ddl.d.ts +65 -1
- package/dist/dialects/pg/enum.d.ts +10 -8
- package/dist/dialects/pg/ext/citext.d.ts +14 -0
- package/dist/dialects/pg/ext/citext.js +11 -0
- package/dist/dialects/pg/ext/index.d.ts +52 -0
- package/dist/dialects/pg/ext/index.js +6 -0
- package/dist/dialects/pg/ext/pg-trgm.d.ts +53 -0
- package/dist/dialects/pg/ext/pg-trgm.js +42 -0
- package/dist/dialects/pg/filter-parse.d.ts +19 -0
- package/dist/dialects/pg/filters.d.ts +19 -0
- package/dist/dialects/pg/fn/index.d.ts +107 -0
- package/dist/dialects/pg/fn/index.js +175 -0
- package/dist/dialects/pg/fn/touch.d.ts +14 -0
- package/dist/dialects/pg/index.d.ts +11 -2
- package/dist/dialects/pg/index.js +243 -1062
- package/dist/dialects/pg/introspect.d.ts +10 -1
- package/dist/dialects/pg/keys.d.ts +19 -3
- package/dist/dialects/pg/model.d.ts +223 -2
- package/dist/dialects/pg/operator-fit.d.ts +86 -0
- package/dist/dialects/pg/operators.d.ts +46 -1
- package/dist/dialects/pg/ops/arr-append.d.ts +9 -0
- package/dist/dialects/pg/ops/arr-ns.d.ts +7 -0
- package/dist/dialects/pg/ops/arr-remove.d.ts +9 -0
- package/dist/dialects/pg/ops/containedBy.d.ts +9 -0
- package/dist/dialects/pg/ops/contains.d.ts +8 -4
- package/dist/dialects/pg/ops/hasAnyKey.d.ts +8 -0
- package/dist/dialects/pg/ops/hasKey.d.ts +8 -0
- package/dist/dialects/pg/ops/json-ns.d.ts +6 -0
- package/dist/dialects/pg/ops/json-set.d.ts +12 -0
- package/dist/dialects/pg/ops/matches.d.ts +16 -0
- package/dist/dialects/pg/ops/overlaps.d.ts +9 -0
- package/dist/dialects/pg/ops/path.d.ts +13 -0
- package/dist/dialects/pg/preset.d.ts +76 -0
- package/dist/dialects/pg/relations.d.ts +59 -2
- package/dist/dialects/pg/role/check.d.ts +45 -0
- package/dist/dialects/pg/role/index.d.ts +50 -0
- package/dist/dialects/pg/role/sql.d.ts +44 -0
- package/dist/dialects/pg/schema.d.ts +109 -5
- package/dist/dialects/pg/table.d.ts +137 -11
- package/dist/dialects/pg/temporal.d.ts +9 -7
- package/dist/dialects/pg/tenancy.d.ts +103 -0
- package/dist/dialects/pg/through.d.ts +21 -0
- package/dist/dialects/pg/trait.d.ts +141 -0
- package/dist/dialects/pg/view/client.d.ts +30 -0
- package/dist/dialects/pg/view/depend.d.ts +35 -0
- package/dist/dialects/pg/view/index.d.ts +114 -0
- package/dist/dialects/pg/view/index.js +289 -0
- package/dist/dialects/pg/view/scratch.d.ts +21 -0
- package/dist/dialects/pg/where.d.ts +37 -0
- package/dist/runtime/aggregate.d.ts +25 -0
- package/dist/runtime/archive-handle.d.ts +18 -0
- package/dist/runtime/archive-rules.d.ts +12 -0
- package/dist/runtime/archive.d.ts +73 -0
- package/dist/runtime/batch.d.ts +20 -0
- package/dist/runtime/client.d.ts +114 -5
- package/dist/runtime/conflict.d.ts +2 -1
- package/dist/runtime/exposure.d.ts +27 -0
- package/dist/runtime/hookm.d.ts +39 -0
- package/dist/runtime/ids/index.d.ts +11 -0
- package/dist/runtime/ids/index.js +193 -0
- package/dist/runtime/ids/okid-extended.d.ts +19 -0
- package/dist/runtime/ids/okid-generator.d.ts +21 -0
- package/dist/runtime/ids/okid-shared.d.ts +89 -0
- package/dist/runtime/ids/okid.d.ts +24 -0
- package/dist/runtime/ids/uuid.d.ts +21 -0
- package/dist/runtime/lock.d.ts +22 -0
- package/dist/runtime/operator-sql.d.ts +8 -0
- package/dist/runtime/page.d.ts +25 -0
- package/dist/runtime/pg/bun.d.ts +30 -0
- package/dist/runtime/pg/bun.js +52 -0
- package/dist/runtime/pg/pg.d.ts +29 -0
- package/dist/runtime/pg/pg.js +52 -0
- package/dist/runtime/pg/pglite.js +16 -17
- package/dist/runtime/pg/postgresjs.js +14 -24
- package/dist/runtime/plan.d.ts +146 -7
- package/dist/runtime/preset-stack.d.ts +17 -0
- package/dist/runtime/presets.d.ts +48 -0
- package/dist/runtime/read-stream.d.ts +26 -0
- package/dist/runtime/safety/index.d.ts +159 -0
- package/dist/runtime/safety/index.js +294 -0
- package/dist/runtime/safety-hook.d.ts +42 -0
- package/dist/runtime/server-check.d.ts +34 -0
- package/dist/runtime/tenancy/index.d.ts +37 -0
- package/dist/runtime/tenancy/index.js +368 -0
- package/dist/runtime/trait-read.d.ts +30 -0
- package/dist/runtime/traits/index.d.ts +133 -0
- package/dist/runtime/traits/index.js +646 -0
- package/dist/runtime/transaction.d.ts +19 -0
- package/dist/runtime/tx.d.ts +22 -7
- package/dist/runtime/types.d.ts +376 -27
- package/dist/runtime/validate/bind.d.ts +11 -0
- package/dist/runtime/validate/closed.d.ts +16 -0
- package/dist/runtime/validate/engine.d.ts +41 -0
- package/dist/runtime/validate/hook.d.ts +17 -0
- package/dist/runtime/validate/index.d.ts +21 -0
- package/dist/runtime/validate/index.js +175 -0
- package/dist/runtime/validate/load.d.ts +13 -0
- package/dist/runtime/validate/places.d.ts +41 -0
- package/dist/runtime/validate/rules.d.ts +108 -0
- package/dist/runtime/validate/surface.d.ts +102 -0
- package/dist/runtime/write.d.ts +30 -5
- package/dist/shared/01yr20s5.js +149 -0
- package/dist/shared/0jc3ffzf.js +154 -0
- package/dist/shared/0v1g424p.js +26 -0
- package/dist/shared/1g0drakv.js +225 -0
- package/dist/shared/{kprcwaha.js → 1tfdfvhh.js} +5 -3
- package/dist/shared/{05w44d8g.js → 2ssqrv66.js} +767 -715
- package/dist/shared/3ekj9x92.js +210 -0
- package/dist/shared/49ypnfwt.js +1122 -0
- package/dist/shared/4e4c6vq2.js +62 -0
- package/dist/shared/4m9fn52z.js +70 -0
- package/dist/shared/{ycwz42az.js → 52szzakm.js} +6 -26
- package/dist/shared/5nmdenb6.js +1229 -0
- package/dist/shared/672t5vym.js +12 -0
- package/dist/shared/6bazvqwm.js +86 -0
- package/dist/shared/6w5j844a.js +201 -0
- package/dist/shared/{fgqgsb5z.js → 75xkjv0t.js} +2 -2
- package/dist/shared/7fvtrkwr.js +84 -0
- package/dist/shared/7m88x3e9.js +45 -0
- package/dist/shared/{mtkwv8wx.js → 7p2wbz7f.js} +1 -1
- package/dist/shared/83eaefwr.js +10 -0
- package/dist/shared/94ez8kzh.js +19 -0
- package/dist/shared/96ps4g1z.js +32 -0
- package/dist/shared/{xqbhg6cn.js → 999ade2q.js} +95 -10
- package/dist/shared/9m80mkac.js +158 -0
- package/dist/shared/9x25fxhc.js +150 -0
- package/dist/shared/a5sxz52y.js +13 -0
- package/dist/shared/axhk06q1.js +156 -0
- package/dist/shared/{dynq16vb.js → b066g80h.js} +8 -6
- package/dist/shared/bqha5cg6.js +229 -0
- package/dist/shared/bryqk9k9.js +31 -0
- package/dist/shared/c8aghh05.js +442 -0
- package/dist/shared/c9z5g0fm.js +309 -0
- package/dist/shared/{m3ypagh5.js → dbjej1tw.js} +124 -15
- package/dist/shared/dyj86cmj.js +69 -0
- package/dist/shared/e6wg00wd.js +164 -0
- package/dist/shared/{hadrfb9h.js → edwqqryd.js} +17 -14
- package/dist/shared/{qk3hxfja.js → fptpmvxp.js} +5 -5
- package/dist/shared/fs0ex00p.js +76 -0
- package/dist/shared/{jjb7yht9.js → g4f5kcx9.js} +3 -3
- package/dist/shared/gjthds9j.js +48 -0
- package/dist/shared/hcmdtwgh.js +102 -0
- package/dist/shared/{g5fhqmwe.js → jkc6ws1p.js} +6 -56
- package/dist/shared/{yd1kzwn2.js → jns2wx4t.js} +55 -12
- package/dist/shared/k34e0xf2.js +450 -0
- package/dist/shared/k3ted12y.js +33 -0
- package/dist/shared/k7dwkhvq.js +31 -0
- package/dist/shared/{8b04d28c.js → kgnc8grt.js} +2 -2
- package/dist/shared/{hd293j9g.js → kyxb62mc.js} +14 -2
- package/dist/shared/m78s7898.js +376 -0
- package/dist/shared/m9tv7xn7.js +404 -0
- package/dist/shared/meck53jv.js +99 -0
- package/dist/shared/mt5wswjz.js +90 -0
- package/dist/shared/n0dgs0pb.js +75 -0
- package/dist/shared/n442h54c.js +14 -0
- package/dist/shared/n4jqhpqz.js +27 -0
- package/dist/shared/n7mcc1gk.js +132 -0
- package/dist/shared/ne02ng5c.js +68 -0
- package/dist/shared/{mkjmqjv4.js → nfzc5z0w.js} +2 -104
- package/dist/shared/nsva2a6b.js +42 -0
- package/dist/shared/p24x2334.js +195 -0
- package/dist/shared/qbxzvwwc.js +88 -0
- package/dist/shared/{w8samvk1.js → qybh48nd.js} +1 -1
- package/dist/shared/r6nwkxnt.js +86 -0
- package/dist/shared/{xy79j5hq.js → rrstp3kb.js} +25 -36
- package/dist/shared/rwmrejjz.js +26 -0
- package/dist/shared/{zhc5vmgf.js → s6gqfn5j.js} +2 -2
- package/dist/shared/{523ft3e8.js → scwxrpx2.js} +7 -5
- package/dist/shared/{j5cn2963.js → t4tbsy9h.js} +13 -64
- package/dist/shared/{y9m15dfv.js → t616ynfn.js} +544 -32
- package/dist/shared/{ngk8gj61.js → tbszx8mz.js} +15 -1
- package/dist/shared/th14ygv2.js +69 -0
- package/dist/shared/tmbdywx0.js +178 -0
- package/dist/shared/ty3v3hfk.js +64 -0
- package/dist/shared/wekze34d.js +246 -0
- package/dist/shared/x6wysh83.js +1132 -0
- package/dist/shared/{rgs0st28.js → xrfnq5k8.js} +237 -434
- package/dist/shared/{x5x59srr.js → xva8v7qk.js} +416 -83
- package/dist/shared/{dkn3y60a.js → xw1d69vd.js} +76 -112
- package/dist/shared/y005b761.js +112 -0
- package/dist/shared/ydaz1sv3.js +55 -0
- package/dist/shared/{p0cbr3g2.js → zwmqxb0g.js} +1 -1
- package/dist/tooling/cli.js +40 -12
- package/dist/tooling/migrate/apply.d.ts +16 -0
- package/dist/tooling/migrate/commands.d.ts +12 -1
- package/dist/tooling/migrate/config.d.ts +8 -0
- package/dist/tooling/migrate/doctor.d.ts +25 -0
- package/dist/tooling/migrate/drift.d.ts +19 -0
- package/dist/tooling/migrate/engine.d.ts +36 -0
- package/dist/tooling/migrate/ext.d.ts +17 -0
- package/dist/tooling/migrate/extensions.d.ts +51 -0
- package/dist/tooling/migrate/managed.d.ts +17 -0
- package/dist/tooling/migrate/plan.d.ts +14 -1
- package/dist/tooling/migrate/project.d.ts +25 -1
- package/dist/tooling/migrate/type-name.d.ts +19 -0
- package/package.json +61 -4
- package/dist/shared/gk7cs7sp.js +0 -566
|
@@ -41,6 +41,40 @@ export declare const PGLITE_CAPABILITIES: {
|
|
|
41
41
|
readonly prepared: "unnamed";
|
|
42
42
|
readonly describe: true;
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* node-postgres execution flags.
|
|
46
|
+
*
|
|
47
|
+
* Interactive transactions, cursor streaming, listen, and cancel are set
|
|
48
|
+
* because the conformance suite passes them. Describe is false: `pg` cannot
|
|
49
|
+
* describe a statement without running it, and that case is skipped.
|
|
50
|
+
* Parameterized queries use the unnamed extended protocol.
|
|
51
|
+
*/
|
|
52
|
+
export declare const NODE_POSTGRES_CAPABILITIES: {
|
|
53
|
+
readonly transactions: "interactive";
|
|
54
|
+
readonly stream: true;
|
|
55
|
+
readonly listen: true;
|
|
56
|
+
readonly cancel: true;
|
|
57
|
+
readonly prepared: "unnamed";
|
|
58
|
+
readonly describe: false;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Bun.sql execution flags.
|
|
62
|
+
*
|
|
63
|
+
* Interactive transactions, cursor streaming, and listen pass the conformance
|
|
64
|
+
* suite. `cancel` is false: `Query.cancel()` does not abort the backend
|
|
65
|
+
* (Bun 1.4), so the cancel and in-flight timeout cases are skipped.
|
|
66
|
+
* `describe` is false: Bun.sql has no describe API. RAISE NOTICE is not
|
|
67
|
+
* surfaced, so the notice case is skipped. `prepare` is off, so a
|
|
68
|
+
* parameterized query does not leave a named statement.
|
|
69
|
+
*/
|
|
70
|
+
export declare const BUNSQL_CAPABILITIES: {
|
|
71
|
+
readonly transactions: "interactive";
|
|
72
|
+
readonly stream: true;
|
|
73
|
+
readonly listen: true;
|
|
74
|
+
readonly cancel: false;
|
|
75
|
+
readonly prepared: "unnamed";
|
|
76
|
+
readonly describe: false;
|
|
77
|
+
};
|
|
44
78
|
/**
|
|
45
79
|
* Reads one capability flag.
|
|
46
80
|
*
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reserved connections for Bun.sql.
|
|
3
|
+
*
|
|
4
|
+
* Loaded on the first reserve, batch, or stream. A read does not use it.
|
|
5
|
+
*/
|
|
6
|
+
import type { DriverConnection } from "../../contracts/driver.js";
|
|
7
|
+
import { type HeldPool } from "./bunsql.js";
|
|
8
|
+
/**
|
|
9
|
+
* Checks out one connection and clears it on release.
|
|
10
|
+
*
|
|
11
|
+
* A connection that is gone is neither reset nor parked: Bun.sql has already
|
|
12
|
+
* dropped it, and parking it would hand a dead session to the next caller.
|
|
13
|
+
*
|
|
14
|
+
* @param held - The pool and its counters
|
|
15
|
+
* @returns A connection the caller must release
|
|
16
|
+
*/
|
|
17
|
+
export declare function checkout(held: HeldPool): Promise<DriverConnection>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun.sql adapter (`okmodel/pg/bun`).
|
|
3
|
+
*
|
|
4
|
+
* Bun's built-in client. There is no package to install. This module is the
|
|
5
|
+
* only place that imports `bun`. It runs on Bun; another runtime cannot load
|
|
6
|
+
* that import.
|
|
7
|
+
*
|
|
8
|
+
* `idleTimeout` stays 0, which is Bun's default: no idle timer, and a
|
|
9
|
+
* finished script exits without `close()`. `Query.cancel()` does not abort
|
|
10
|
+
* the backend, so `cancel` is false. Server notices are not surfaced.
|
|
11
|
+
*/
|
|
12
|
+
import { SQL, type ReservedSQL } from "bun";
|
|
13
|
+
import type { DriverPool, DriverPoolConfig, WireValue } from "../../contracts/driver.js";
|
|
14
|
+
import { noticeBuffer, type WireQuery } from "./session.js";
|
|
15
|
+
export { BUNSQL_CAPABILITIES as capabilities, hasCapability, readCapability, } from "../capabilities.js";
|
|
16
|
+
export { DriverError } from "../error.js";
|
|
17
|
+
/** TLS values Bun.sql accepts that this adapter forwards. */
|
|
18
|
+
export type BunSqlTls = boolean | "disable" | "allow" | "prefer" | "require" | "verify-ca" | "verify-full";
|
|
19
|
+
/** Options for {@link open}. */
|
|
20
|
+
export type BunSqlConfig = DriverPoolConfig & {
|
|
21
|
+
/** Connection URL for this endpoint. */
|
|
22
|
+
readonly url: string;
|
|
23
|
+
/**
|
|
24
|
+
* Named prepared statements, or the unnamed protocol.
|
|
25
|
+
*
|
|
26
|
+
* Unnamed is the default (`prepare: false`). `prepared: "named"` is not
|
|
27
|
+
* for transaction-mode poolers.
|
|
28
|
+
*/
|
|
29
|
+
readonly prepared?: "named" | "unnamed";
|
|
30
|
+
/** Session search path for every connection in the pool. */
|
|
31
|
+
readonly searchPath?: string;
|
|
32
|
+
/** TLS mode passed to Bun.sql. */
|
|
33
|
+
readonly ssl?: BunSqlTls;
|
|
34
|
+
};
|
|
35
|
+
/** What a checkout needs from the pool that opened it. */
|
|
36
|
+
export type HeldPool = {
|
|
37
|
+
readonly sql: SQL;
|
|
38
|
+
readonly parked: ReservedSQL[];
|
|
39
|
+
readonly acquireMs: number | undefined;
|
|
40
|
+
readonly counters: Counters;
|
|
41
|
+
readonly notices: ReturnType<typeof noticeBuffer>;
|
|
42
|
+
readonly isClosed: () => boolean;
|
|
43
|
+
};
|
|
44
|
+
/** Pool occupancy. */
|
|
45
|
+
export type Counters = {
|
|
46
|
+
reserved: number;
|
|
47
|
+
busy: number;
|
|
48
|
+
reservedBusy: number;
|
|
49
|
+
waiting: number;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Opens a Bun.sql pool for one endpoint.
|
|
53
|
+
*
|
|
54
|
+
* @param config - URL, pool size, and acquire timeout
|
|
55
|
+
* @returns The pool
|
|
56
|
+
*/
|
|
57
|
+
export declare function open(config: BunSqlConfig): DriverPool;
|
|
58
|
+
export declare function send(sql: SQL, text: string, params: readonly WireValue[] | undefined): WireQuery;
|
|
59
|
+
export declare function reserve(sql: SQL, acquireMs: number | undefined, counters: Counters): Promise<ReservedSQL>;
|
|
60
|
+
export declare function park(parked: ReservedSQL[], reserved: ReservedSQL): Promise<void>;
|
|
@@ -28,24 +28,14 @@ export declare function needsWatch(options: ExecuteOptions | undefined): boolean
|
|
|
28
28
|
/**
|
|
29
29
|
* Next transaction depth after one statement.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
* transaction. Kept here so a read does not load the batch runner.
|
|
31
|
+
* `BEGIN` may carry modes (`begin isolation level serializable`). `ROLLBACK TO
|
|
32
|
+
* SAVEPOINT` stays inside the transaction. Kept here so a read does not load the batch runner.
|
|
33
33
|
*
|
|
34
34
|
* @param depth - Depth before the statement
|
|
35
35
|
* @param text - Statement text
|
|
36
36
|
* @returns Depth after a successful statement
|
|
37
37
|
*/
|
|
38
38
|
export declare function nextTransactionDepth(depth: number, text: string): number;
|
|
39
|
-
/**
|
|
40
|
-
* Opens a watch for one call.
|
|
41
|
-
*
|
|
42
|
-
* The caller has already rejected a pre-aborted signal and a non-positive
|
|
43
|
-
* timeout.
|
|
44
|
-
*
|
|
45
|
-
* @param options - Options that include a signal or a timeout
|
|
46
|
-
* @returns The watch. The caller must {@link Watch.finish} it
|
|
47
|
-
*/
|
|
48
|
-
export declare function openWatch(options: ExecuteOptions): Watch;
|
|
49
39
|
/**
|
|
50
40
|
* Runs `fn` with a watch when the caller set a signal or a timeout.
|
|
51
41
|
*
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reserved connections for node-postgres.
|
|
3
|
+
*
|
|
4
|
+
* Loaded on the first reserve, batch, or stream. A read does not use it.
|
|
5
|
+
*/
|
|
6
|
+
import type { DriverConnection } from "../../contracts/driver.js";
|
|
7
|
+
import { type HeldPool } from "./nodepostgres.js";
|
|
8
|
+
/**
|
|
9
|
+
* Checks out one client and clears it on release.
|
|
10
|
+
*
|
|
11
|
+
* A client whose connection is gone is destroyed on release, and nothing more is
|
|
12
|
+
* sent to it. A checked-out client has no pool error listener, so one is set here:
|
|
13
|
+
* without it a dropped socket is an uncaught `error` event.
|
|
14
|
+
*
|
|
15
|
+
* @param held - The pool and its counters
|
|
16
|
+
* @returns A connection the caller must release
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkout(held: HeldPool): Promise<DriverConnection>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* node-postgres adapter (`okmodel/pg/pg`).
|
|
3
|
+
*
|
|
4
|
+
* One pool per `open` call. `pg` is an optional peer of this entry.
|
|
5
|
+
* Idle clients are unref'd (`allowExitOnIdle`) and are not closed on a timer
|
|
6
|
+
* (`idleTimeoutMillis: 0`), so a finished script exits and a live process
|
|
7
|
+
* keeps its connection. Cancel sends a Postgres CancelRequest on a side
|
|
8
|
+
* socket. That socket is unref'd.
|
|
9
|
+
*/
|
|
10
|
+
import pg, { type PoolClient, type QueryConfig, type QueryResult } from "pg";
|
|
11
|
+
import type { DriverPool, DriverPoolConfig, WireValue } from "../../contracts/driver.js";
|
|
12
|
+
import { noticeBuffer, type WireQuery } from "./session.js";
|
|
13
|
+
export { hasCapability, NODE_POSTGRES_CAPABILITIES as capabilities, readCapability, } from "../capabilities.js";
|
|
14
|
+
export { DriverError } from "../error.js";
|
|
15
|
+
/** Options for {@link open}. */
|
|
16
|
+
export type NodePostgresConfig = DriverPoolConfig & {
|
|
17
|
+
/** Connection URL for this endpoint. */
|
|
18
|
+
readonly url: string;
|
|
19
|
+
/**
|
|
20
|
+
* Named prepared statements, or the unnamed protocol.
|
|
21
|
+
*
|
|
22
|
+
* Unnamed is the default. It stays valid behind a pooler in transaction mode.
|
|
23
|
+
* `prepared: "named"` is not for transaction-mode poolers.
|
|
24
|
+
*/
|
|
25
|
+
readonly prepared?: "named" | "unnamed";
|
|
26
|
+
/** Session search path for every connection in the pool. */
|
|
27
|
+
readonly searchPath?: string;
|
|
28
|
+
/** TLS mode passed to node-postgres. */
|
|
29
|
+
readonly ssl?: boolean | "require" | "allow" | "prefer" | "verify-full" | object;
|
|
30
|
+
};
|
|
31
|
+
/** What a checkout needs from the pool that opened it. */
|
|
32
|
+
export type HeldPool = {
|
|
33
|
+
readonly pool: InstanceType<typeof pg.Pool>;
|
|
34
|
+
readonly acquireMs: number | undefined;
|
|
35
|
+
readonly counters: Counters;
|
|
36
|
+
readonly notices: ReturnType<typeof noticeBuffer>;
|
|
37
|
+
readonly named: boolean;
|
|
38
|
+
readonly isClosed: () => boolean;
|
|
39
|
+
};
|
|
40
|
+
/** Pool occupancy. */
|
|
41
|
+
export type Counters = {
|
|
42
|
+
reserved: number;
|
|
43
|
+
busy: number;
|
|
44
|
+
reservedBusy: number;
|
|
45
|
+
waiting: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Opens a node-postgres pool for one endpoint.
|
|
49
|
+
*
|
|
50
|
+
* @param config - URL, pool size, and acquire timeout
|
|
51
|
+
* @returns The pool
|
|
52
|
+
*/
|
|
53
|
+
export declare function open(config: NodePostgresConfig): DriverPool;
|
|
54
|
+
export declare function send(runner: {
|
|
55
|
+
query(config: QueryConfig): Promise<QueryResult>;
|
|
56
|
+
}, text: string, params: readonly WireValue[] | undefined, named: boolean, client: PoolClient | undefined): WireQuery;
|
|
57
|
+
export declare function connectClient(pool: InstanceType<typeof pg.Pool>, acquireMs: number | undefined, counters: Counters): Promise<PoolClient>;
|
|
@@ -4,7 +4,8 @@
|
|
|
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, WireValue } from "../../contracts/driver.js";
|
|
7
|
+
import type { DescribeResult, DriverConnection, ExecuteResult, WireValue } from "../../contracts/driver.js";
|
|
8
|
+
import { type Watch } from "./call.js";
|
|
8
9
|
import { type Canceller, type Counters, type NoticeBuffer } from "./postgresjs.js";
|
|
9
10
|
/** State `open` shares with a checkout. */
|
|
10
11
|
export type HeldPool = {
|
|
@@ -41,3 +42,51 @@ export declare function describe(sql: Sql, text: string, params?: readonly WireV
|
|
|
41
42
|
* @returns Chunks of wire rows
|
|
42
43
|
*/
|
|
43
44
|
export declare function stream(sql: Sql, text: string, params?: readonly WireValue[]): AsyncIterable<readonly (readonly WireValue[])[]>;
|
|
45
|
+
/** Refcount a checkout or a listener borrows from the pool. */
|
|
46
|
+
type Gate = {
|
|
47
|
+
enter(): void;
|
|
48
|
+
leave(): void;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Keeps sockets referenced until `release` finishes.
|
|
52
|
+
*
|
|
53
|
+
* The caller has already entered `gate`. A second `release` does not change
|
|
54
|
+
* the count. Checkout failure leaves the gate.
|
|
55
|
+
*
|
|
56
|
+
* @param gate - Refcount already entered for this checkout
|
|
57
|
+
* @param checkout - Reserves the connection
|
|
58
|
+
* @returns The connection, with release counted once
|
|
59
|
+
*/
|
|
60
|
+
export declare function holdCheckout<T extends {
|
|
61
|
+
release(): Promise<void>;
|
|
62
|
+
}>(gate: Gate, checkout: () => Promise<T>): Promise<T>;
|
|
63
|
+
/**
|
|
64
|
+
* Keeps sockets referenced for as long as the listener is active.
|
|
65
|
+
*
|
|
66
|
+
* The caller has already entered `gate`.
|
|
67
|
+
*
|
|
68
|
+
* @param gate - Listener refcount already entered
|
|
69
|
+
* @param start - Subscribes and returns the stop function
|
|
70
|
+
* @returns A stop function that can be called again
|
|
71
|
+
*/
|
|
72
|
+
export declare function holdListener(gate: Gate, start: () => Promise<() => Promise<void>>): Promise<() => Promise<void>>;
|
|
73
|
+
/**
|
|
74
|
+
* Finishes a query that can be aborted by a signal or a timeout.
|
|
75
|
+
*
|
|
76
|
+
* The caller has already tracked `pending` and attached `onAbort`.
|
|
77
|
+
*
|
|
78
|
+
* @param pending - The in-flight statement
|
|
79
|
+
* @param watch - Abort signal and the reason it fired
|
|
80
|
+
* @param onAbort - Listener the caller attached
|
|
81
|
+
* @param ctx - Notice slice and the session counters the plain path also uses
|
|
82
|
+
* @returns The wire result, or a rejected driver error
|
|
83
|
+
*/
|
|
84
|
+
export declare function watchQuery(pending: Canceller & Promise<unknown>, watch: Watch, onAbort: () => void, ctx: {
|
|
85
|
+
readonly start: number;
|
|
86
|
+
readonly text: string;
|
|
87
|
+
readonly notices: NoticeBuffer;
|
|
88
|
+
leave(): void;
|
|
89
|
+
note(text: string): void;
|
|
90
|
+
untrack(pending: Canceller): void;
|
|
91
|
+
}): Promise<ExecuteResult>;
|
|
92
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared interactive session for drivers that speak wire text.
|
|
3
|
+
*
|
|
4
|
+
* The postgres.js adapter keeps its own session. node-postgres and Bun.sql
|
|
5
|
+
* share this one: transaction depth, notices, and a watched cancel.
|
|
6
|
+
*/
|
|
7
|
+
import type { ExecuteResult, Notice, WireValue } from "../../contracts/driver.js";
|
|
8
|
+
import type { BatchSession } from "./batch.js";
|
|
9
|
+
import type { Watch } from "./call.js";
|
|
10
|
+
/** A query the session can abort when the driver supports it. */
|
|
11
|
+
export type WireQuery = Promise<unknown> & {
|
|
12
|
+
cancel?(): void;
|
|
13
|
+
};
|
|
14
|
+
/** Sends one statement and returns the driver's own result. */
|
|
15
|
+
export type WireSender = (text: string, params: readonly WireValue[] | undefined) => WireQuery;
|
|
16
|
+
/** Notice slice shared by a pool. */
|
|
17
|
+
export type NoticeBuffer = {
|
|
18
|
+
start(): number;
|
|
19
|
+
since(start: number): readonly Notice[];
|
|
20
|
+
push(notice: {
|
|
21
|
+
readonly severity?: string | undefined;
|
|
22
|
+
readonly message?: string | undefined;
|
|
23
|
+
readonly code?: string | undefined;
|
|
24
|
+
}): void;
|
|
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
|
+
/**
|
|
34
|
+
* An empty notice buffer the pool fills as the server sends notices.
|
|
35
|
+
*
|
|
36
|
+
* @returns The buffer
|
|
37
|
+
*/
|
|
38
|
+
export declare function noticeBuffer(): NoticeBuffer;
|
|
39
|
+
/**
|
|
40
|
+
* One connection's statement runner.
|
|
41
|
+
*
|
|
42
|
+
* `send` is the driver. This class owns depth, notices, and cancel tracking.
|
|
43
|
+
*/
|
|
44
|
+
export declare class WireSession implements BatchSession {
|
|
45
|
+
readonly canCancel: boolean;
|
|
46
|
+
private transactionDepth;
|
|
47
|
+
private readonly local;
|
|
48
|
+
private readonly send;
|
|
49
|
+
private readonly notices;
|
|
50
|
+
private readonly isClosed;
|
|
51
|
+
private readonly onEnter;
|
|
52
|
+
private readonly onLeave;
|
|
53
|
+
private readonly shared;
|
|
54
|
+
/**
|
|
55
|
+
* @param send - Runs one statement on this connection
|
|
56
|
+
* @param notices - Pool notice buffer
|
|
57
|
+
* @param isClosed - Pool closed flag
|
|
58
|
+
* @param canCancel - The driver aborts an in-flight statement
|
|
59
|
+
* @param onEnter - Marks one statement in flight
|
|
60
|
+
* @param onLeave - Marks that statement finished
|
|
61
|
+
* @param shared - Pool-wide in-flight set, when this connection is reserved
|
|
62
|
+
*/
|
|
63
|
+
constructor(send: WireSender, notices: NoticeBuffer, isClosed: () => boolean, canCancel: boolean, onEnter: () => void, onLeave: () => void, shared?: Set<WireQuery>);
|
|
64
|
+
/** @inheritdoc */
|
|
65
|
+
query(text: string, params: readonly WireValue[] | undefined, watch: Watch | undefined): Promise<ExecuteResult>;
|
|
66
|
+
/** @inheritdoc */
|
|
67
|
+
inTransaction(): boolean;
|
|
68
|
+
/** @inheritdoc */
|
|
69
|
+
abandon(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Open transaction depth.
|
|
72
|
+
*
|
|
73
|
+
* @returns The depth. Zero means no transaction
|
|
74
|
+
*/
|
|
75
|
+
depth(): number;
|
|
76
|
+
/** Aborts in-flight statements on this connection. */
|
|
77
|
+
cancel(): void;
|
|
78
|
+
private note;
|
|
79
|
+
private track;
|
|
80
|
+
private untrack;
|
|
81
|
+
private watched;
|
|
82
|
+
private finishWatched;
|
|
83
|
+
}
|
|
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[])[]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deadline and abort signal for one call.
|
|
3
|
+
*
|
|
4
|
+
* Loaded the first time a call passes `signal` or `timeout`. A plain execute
|
|
5
|
+
* does not load it.
|
|
6
|
+
*/
|
|
7
|
+
import type { ExecuteOptions } from "../../contracts/driver.js";
|
|
8
|
+
import type { Watch } from "./call.js";
|
|
9
|
+
/**
|
|
10
|
+
* Opens a watch for one call.
|
|
11
|
+
*
|
|
12
|
+
* The caller has already rejected a pre-aborted signal and a non-positive
|
|
13
|
+
* timeout.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Options that include a signal or a timeout
|
|
16
|
+
* @returns The watch. The caller must {@link Watch.finish} it
|
|
17
|
+
*/
|
|
18
|
+
export declare function openWatch(options: ExecuteOptions): Watch;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Enum catalog objects.
|
|
2
|
+
* Enum and domain catalog objects.
|
|
3
3
|
*
|
|
4
|
-
* Kind `type`, identity `(namespace, name)`.
|
|
5
|
-
* label list
|
|
4
|
+
* Kind `type`, identity `(namespace, name)`. An enum definition is the ordered
|
|
5
|
+
* label list. A domain definition is the base type and the check.
|
|
6
6
|
*/
|
|
7
|
-
import type { Namespace, ObjectIdentity, Owner, Provenance, TypeObject } from "./types.js";
|
|
7
|
+
import type { DomainDefinition, Namespace, ObjectIdentity, Owner, Provenance, TypeDefinition, TypeObject } from "./types.js";
|
|
8
8
|
/** Input for {@link enumType}. */
|
|
9
9
|
export type EnumTypeInput = {
|
|
10
10
|
readonly namespace: Namespace;
|
|
@@ -25,6 +25,33 @@ export type EnumTypeInput = {
|
|
|
25
25
|
* @returns A type envelope
|
|
26
26
|
*/
|
|
27
27
|
export declare function enumType(input: EnumTypeInput): TypeObject;
|
|
28
|
+
/** Input for {@link domainType}. */
|
|
29
|
+
export type DomainTypeInput = {
|
|
30
|
+
readonly namespace: Namespace;
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly base: string;
|
|
33
|
+
readonly check: string;
|
|
34
|
+
readonly owner?: Owner;
|
|
35
|
+
readonly provenance: Provenance;
|
|
36
|
+
readonly dependencies?: readonly ObjectIdentity[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Builds a domain type object.
|
|
40
|
+
*
|
|
41
|
+
* The definition is the base type and the check. An empty base or an empty
|
|
42
|
+
* check is OKM1020.
|
|
43
|
+
*
|
|
44
|
+
* @param input - Namespace, name, base type, and check
|
|
45
|
+
* @returns A type envelope
|
|
46
|
+
*/
|
|
47
|
+
export declare function domainType(input: DomainTypeInput): TypeObject;
|
|
48
|
+
/**
|
|
49
|
+
* Reports whether a type definition is a domain.
|
|
50
|
+
*
|
|
51
|
+
* @param definition - Enum labels or a domain base and check
|
|
52
|
+
* @returns `true` when the definition has a base type
|
|
53
|
+
*/
|
|
54
|
+
export declare function isDomain(definition: TypeDefinition): definition is DomainDefinition;
|
|
28
55
|
/**
|
|
29
56
|
* Reports whether two label lists are the same text in the same order.
|
|
30
57
|
*
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension catalog objects.
|
|
3
|
+
*
|
|
4
|
+
* The factory stores the record. It does not parse a document and it does
|
|
5
|
+
* not plan SQL. Those stay in the document chunk and in tooling.
|
|
6
|
+
*/
|
|
7
|
+
import type { Catalog, ExtensionObject, ObjectIdentity, Owner, Provenance } from "./types.js";
|
|
8
|
+
/** Input for {@link extensionObject}. */
|
|
9
|
+
export type ExtensionInput = {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly schema: string;
|
|
12
|
+
readonly relocatable?: boolean;
|
|
13
|
+
readonly version?: string;
|
|
14
|
+
readonly owner?: Owner;
|
|
15
|
+
readonly provenance: Provenance;
|
|
16
|
+
readonly dependencies?: readonly ObjectIdentity[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Builds an extension record.
|
|
20
|
+
*
|
|
21
|
+
* @param input - Name, install schema, and optional version pin
|
|
22
|
+
* @returns The catalog object
|
|
23
|
+
*/
|
|
24
|
+
export declare function extensionObject(input: ExtensionInput): ExtensionObject;
|
|
25
|
+
/**
|
|
26
|
+
* Reports whether a version is an exact pin (`1.6`), not a floor or an omission.
|
|
27
|
+
*
|
|
28
|
+
* @param version - Declared or installed version
|
|
29
|
+
* @returns `true` when every component is a decimal integer
|
|
30
|
+
*/
|
|
31
|
+
export declare function isExactVersion(version: string | undefined): version is string;
|
|
32
|
+
/**
|
|
33
|
+
* Compares two exact versions. A shorter tail is zero.
|
|
34
|
+
*
|
|
35
|
+
* @param left - Exact version
|
|
36
|
+
* @param right - Exact version
|
|
37
|
+
* @returns Negative when `left` is older, positive when it is newer
|
|
38
|
+
*/
|
|
39
|
+
export declare function compareExtensionVersions(left: string, right: string): number;
|
|
40
|
+
/**
|
|
41
|
+
* Reports whether two extension records are the same migration.
|
|
42
|
+
*
|
|
43
|
+
* An unpinned or floor declaration matches any installed version. Schema and
|
|
44
|
+
* `relocatable` still have to match.
|
|
45
|
+
*
|
|
46
|
+
* @param before - Previous record
|
|
47
|
+
* @param after - Declared record
|
|
48
|
+
* @returns `true` when no `ALTER EXTENSION` is required
|
|
49
|
+
*/
|
|
50
|
+
export declare function sameExtensionDefinition(before: ExtensionObject, after: ExtensionObject): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Drops a version when the other side of a diff does not pin an exact one.
|
|
53
|
+
*
|
|
54
|
+
* Serialization then compares the rest of the record. Exact pins on both
|
|
55
|
+
* sides are left as written.
|
|
56
|
+
*
|
|
57
|
+
* @param source - Catalog being compared
|
|
58
|
+
* @param other - The other catalog
|
|
59
|
+
* @returns `source`, or a copy with those versions removed
|
|
60
|
+
*/
|
|
61
|
+
export declare function alignExtensionVersions(source: Catalog, other: Catalog): Catalog;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Role, grant, and default-privilege records.
|
|
3
|
+
*
|
|
4
|
+
* The factories store the envelope. SQL, introspection, and the doctor
|
|
5
|
+
* checks live in the dialect and in tooling.
|
|
6
|
+
*/
|
|
7
|
+
import type { DefaultPrivilegeObject, GrantObject, GrantObjectRef, Namespace, ObjectIdentity, Owner, Provenance, RoleObject } from "./types.js";
|
|
8
|
+
/** Input for {@link roleObject}. */
|
|
9
|
+
export type RoleInput = {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly login?: boolean;
|
|
12
|
+
readonly inherit?: boolean;
|
|
13
|
+
readonly owner?: Owner;
|
|
14
|
+
readonly provenance: Provenance;
|
|
15
|
+
readonly dependencies?: readonly ObjectIdentity[];
|
|
16
|
+
};
|
|
17
|
+
/** Input for {@link grantObject}. */
|
|
18
|
+
export type GrantInput = {
|
|
19
|
+
readonly role: string;
|
|
20
|
+
readonly object: GrantObjectRef;
|
|
21
|
+
readonly privilege: string;
|
|
22
|
+
readonly owner?: Owner;
|
|
23
|
+
readonly provenance: Provenance;
|
|
24
|
+
readonly dependencies?: readonly ObjectIdentity[];
|
|
25
|
+
};
|
|
26
|
+
/** Input for {@link defaultPrivilegeObject}. */
|
|
27
|
+
export type DefaultPrivilegeInput = {
|
|
28
|
+
readonly forRole: string;
|
|
29
|
+
readonly namespace: Namespace;
|
|
30
|
+
readonly objectKind: string;
|
|
31
|
+
readonly grantee: string;
|
|
32
|
+
readonly privilege: string;
|
|
33
|
+
readonly owner?: Owner;
|
|
34
|
+
readonly provenance: Provenance;
|
|
35
|
+
readonly dependencies?: readonly ObjectIdentity[];
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Builds a role record.
|
|
39
|
+
*
|
|
40
|
+
* The name is an identifier. The grant key is not.
|
|
41
|
+
*
|
|
42
|
+
* @param input - Name, login, and inherit
|
|
43
|
+
* @returns The catalog object
|
|
44
|
+
*/
|
|
45
|
+
export declare function roleObject(input: RoleInput): RoleObject;
|
|
46
|
+
/**
|
|
47
|
+
* Builds a grant record.
|
|
48
|
+
*
|
|
49
|
+
* Identity is `(role, object, privilege)`. It is not checked against the
|
|
50
|
+
* 63-byte identifier limit (D119).
|
|
51
|
+
*
|
|
52
|
+
* @param input - Grantee, object, and one privilege
|
|
53
|
+
* @returns The catalog object
|
|
54
|
+
*/
|
|
55
|
+
export declare function grantObject(input: GrantInput): GrantObject;
|
|
56
|
+
/**
|
|
57
|
+
* Builds a default-privilege record.
|
|
58
|
+
*
|
|
59
|
+
* Identity is `(forRole, namespace, objectKind, grantee, privilege)`.
|
|
60
|
+
*
|
|
61
|
+
* @param input - Creating role, schema, object kind, grantee, and privilege
|
|
62
|
+
* @returns The catalog object
|
|
63
|
+
*/
|
|
64
|
+
export declare function defaultPrivilegeObject(input: DefaultPrivilegeInput): DefaultPrivilegeObject;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function and trigger catalog objects.
|
|
3
|
+
*
|
|
4
|
+
* The factories store the record. They do not plan SQL. DDL stays in the
|
|
5
|
+
* dialect, and `fn()` / `trigger()` stay on `okmodel/fn`.
|
|
6
|
+
*/
|
|
7
|
+
import type { FunctionArgument, FunctionLanguage, FunctionObject, FunctionSecurity, FunctionVolatility, Namespace, ObjectIdentity, ObjectRef, Owner, Provenance, TriggerCall, TriggerEvent, TriggerLevel, TriggerObject, TriggerTiming } from "./types.js";
|
|
8
|
+
/** Input for {@link functionObject}. */
|
|
9
|
+
export type FunctionInput = {
|
|
10
|
+
readonly namespace?: Namespace;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly arguments?: readonly FunctionArgument[];
|
|
13
|
+
readonly returns: string;
|
|
14
|
+
readonly language: FunctionLanguage;
|
|
15
|
+
readonly volatility?: FunctionVolatility;
|
|
16
|
+
readonly security?: FunctionSecurity;
|
|
17
|
+
readonly searchPath?: string;
|
|
18
|
+
readonly body: string;
|
|
19
|
+
readonly atomic?: boolean;
|
|
20
|
+
readonly owner?: Owner;
|
|
21
|
+
readonly provenance: Provenance;
|
|
22
|
+
readonly dependencies?: readonly ObjectIdentity[];
|
|
23
|
+
};
|
|
24
|
+
/** Input for {@link triggerObject}. */
|
|
25
|
+
export type TriggerInput = {
|
|
26
|
+
readonly parent: ObjectRef;
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly timing: TriggerTiming;
|
|
29
|
+
readonly events: readonly TriggerEvent[];
|
|
30
|
+
readonly level: TriggerLevel;
|
|
31
|
+
readonly calls: TriggerCall;
|
|
32
|
+
readonly updateOf?: readonly string[];
|
|
33
|
+
readonly when?: string;
|
|
34
|
+
readonly owner?: Owner;
|
|
35
|
+
readonly provenance: Provenance;
|
|
36
|
+
readonly dependencies?: readonly ObjectIdentity[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Builds a function record.
|
|
40
|
+
*
|
|
41
|
+
* Argument types are the identity. Names live only in the definition.
|
|
42
|
+
*
|
|
43
|
+
* @param input - Signature, language, and body
|
|
44
|
+
* @returns The catalog object
|
|
45
|
+
*/
|
|
46
|
+
export declare function functionObject(input: FunctionInput): FunctionObject;
|
|
47
|
+
/**
|
|
48
|
+
* Builds a trigger record.
|
|
49
|
+
*
|
|
50
|
+
* Dependencies are the table, the function, and each `UPDATE OF` column.
|
|
51
|
+
* Events are stored in a fixed order.
|
|
52
|
+
*
|
|
53
|
+
* @param input - Timing, events, and the function it calls
|
|
54
|
+
* @returns The catalog object
|
|
55
|
+
*/
|
|
56
|
+
export declare function triggerObject(input: TriggerInput): TriggerObject;
|