@truvity/cnpg-client 0.0.0 → 2.50.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 +79 -2
- package/dist/esm/config.d.ts +70 -0
- package/dist/esm/config.js +166 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/pool.d.ts +58 -0
- package/dist/esm/pool.js +207 -0
- package/dist/esm/retry.d.ts +24 -0
- package/dist/esm/retry.js +117 -0
- package/package.json +50 -2
package/README.md
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
-
# @truvity/cnpg-client
|
|
1
|
+
# @truvity/cnpg-client (TypeScript)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The TypeScript adapter of the [client contract](../README.md), on
|
|
4
|
+
`pg` (node-postgres). ESM; on Node 22.12 or later `require()` works too.
|
|
5
|
+
Published to GitHub Packages.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
GitHub Packages answers 401 to anonymous installs even for a public package,
|
|
10
|
+
so a token with `read:packages` is always needed. In `.npmrc`:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
@truvity:registry=https://npm.pkg.github.com
|
|
14
|
+
//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_TOKEN}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
npm install @truvity/cnpg-client
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Locally the token can be `$(gh auth token)` (after
|
|
22
|
+
`gh auth refresh -s read:packages`); in GitHub Actions use
|
|
23
|
+
`${{ github.token }}` with `packages: read`. Yarn 4: set
|
|
24
|
+
`npmScopes.truvity.npmRegistryServer` to `https://npm.pkg.github.com` and
|
|
25
|
+
`npmAuthToken` in `.yarnrc.yml`.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { CnpgPool, configFromEnv } from "@truvity/cnpg-client";
|
|
29
|
+
|
|
30
|
+
const pool = await CnpgPool.create(configFromEnv()); // PGHOST, PGSSLROOTCERT, ... ; retries the first connection
|
|
31
|
+
const { rows } = await pool.query("select $1::int as n", [1]);
|
|
32
|
+
|
|
33
|
+
await pool.do(async () => { // idempotent unit of work, retried on connection-class errors
|
|
34
|
+
await pool.query("update ...");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
app.get("/readyz", async (_req, res) => {
|
|
38
|
+
await pool.health().then(() => res.sendStatus(200), () => res.sendStatus(503));
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## What it does
|
|
43
|
+
|
|
44
|
+
- Always `verify-full`: `ssl` is built with `rejectUnauthorized: true`, the
|
|
45
|
+
given CA as the only trust root and `servername` set to the host. A
|
|
46
|
+
missing CA, a `sslMode` other than `verify-full`, or a half client
|
|
47
|
+
certificate is a `ConfigError` that lists every problem.
|
|
48
|
+
- The CA, certificate, key and `passwordFile` are read again for every new
|
|
49
|
+
connection: `pgPoolConfig()` returns a `pg.PoolConfig` whose `Client` class
|
|
50
|
+
loads them in its constructor, which is the one hook node-postgres gives
|
|
51
|
+
for per-connection TLS material. `maxConnLifetimeMs` (30m) recycles
|
|
52
|
+
connections, so a renewed certificate is used without a restart. (No
|
|
53
|
+
per-connection jitter: node-postgres has a single pool-wide lifetime.)
|
|
54
|
+
- An error on an idle pooled connection is handled (`onError`), never thrown:
|
|
55
|
+
a `pg.Pool` without an `error` listener takes the process down when the
|
|
56
|
+
primary goes away.
|
|
57
|
+
- `pool.health()`, `pool.do(fn)`, `retry(policy, fn)`, `isRetryable(err)`.
|
|
58
|
+
- `toJSON()` and `redactConfig()` carry no password or key material.
|
|
59
|
+
|
|
60
|
+
For TypeORM or another library that owns the pool, pass the options through:
|
|
61
|
+
`extra: pgPoolConfig(config)`.
|
|
62
|
+
|
|
63
|
+
## Tracing
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { trace } from "@opentelemetry/api";
|
|
67
|
+
const pool = await CnpgPool.create(config, { tracer: trace.getTracer("my-service") });
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`@opentelemetry/api` is an optional peer dependency. `pool.query` is traced
|
|
71
|
+
(statement with placeholders, never arguments); statements on a client from
|
|
72
|
+
`pool.connect()` are not.
|
|
73
|
+
|
|
74
|
+
## Develop
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
cd clients/ts
|
|
78
|
+
npm ci && npm run lint && npm run typecheck && npm test && npm run build
|
|
79
|
+
just clients-ts-conformance # from the repository root; needs docker
|
|
80
|
+
```
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Bounds the retry of connection-class failures. */
|
|
2
|
+
export interface RetryPolicy {
|
|
3
|
+
/** Total tries, including the first; 0 = no cap, `budgetMs` alone bounds the retry. */
|
|
4
|
+
attempts: number;
|
|
5
|
+
/** Ceiling of the first sleep, ms. */
|
|
6
|
+
initialDelayMs: number;
|
|
7
|
+
/** Ceiling of any sleep, ms. */
|
|
8
|
+
maxDelayMs: number;
|
|
9
|
+
/** Total time that may be spent waiting, ms. */
|
|
10
|
+
budgetMs: number;
|
|
11
|
+
/**
|
|
12
|
+
* Called before each sleep, after a retryable failure: `attempt` is the try
|
|
13
|
+
* that failed (1-based), `delayMs` the coming sleep. For logging.
|
|
14
|
+
*/
|
|
15
|
+
onRetry?: (attempt: number, err: Error, delayMs: number) => void;
|
|
16
|
+
}
|
|
17
|
+
export interface CnpgConfig {
|
|
18
|
+
host: string;
|
|
19
|
+
port: number;
|
|
20
|
+
database: string;
|
|
21
|
+
user: string;
|
|
22
|
+
/** For a scram role. `passwordFile` wins and is read again for every new connection. */
|
|
23
|
+
password?: string;
|
|
24
|
+
passwordFile?: string;
|
|
25
|
+
/** Server CA file. Required: this file is the only trust root. */
|
|
26
|
+
sslRootCert: string;
|
|
27
|
+
/** Client certificate and key of a certificate role; both or neither. */
|
|
28
|
+
sslCert?: string;
|
|
29
|
+
sslKey?: string;
|
|
30
|
+
/** Exists to be refused: undefined or "verify-full". */
|
|
31
|
+
sslMode?: string;
|
|
32
|
+
applicationName: string;
|
|
33
|
+
connectTimeoutMs: number;
|
|
34
|
+
/** 0 disables. */
|
|
35
|
+
statementTimeoutMs: number;
|
|
36
|
+
/** 0 disables. */
|
|
37
|
+
idleInTxTimeoutMs: number;
|
|
38
|
+
poolMax: number;
|
|
39
|
+
poolMin: number;
|
|
40
|
+
/** Keep below the client certificate's life. */
|
|
41
|
+
maxConnLifetimeMs: number;
|
|
42
|
+
maxConnIdleMs: number;
|
|
43
|
+
retry: RetryPolicy;
|
|
44
|
+
/** Called for errors on idle pooled connections (never thrown: an unhandled pool error would kill the process). */
|
|
45
|
+
onError?: (err: Error) => void;
|
|
46
|
+
}
|
|
47
|
+
export declare class ConfigError extends Error {
|
|
48
|
+
readonly problems: string[];
|
|
49
|
+
constructor(problems: string[]);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* No attempt cap: retry for up to 45s, backing off from 200ms to a 2s ceiling.
|
|
53
|
+
* A CloudNativePG failover leaves the primary unreachable for 10 to 30s, so
|
|
54
|
+
* time, not a try count, is the binding limit.
|
|
55
|
+
*/
|
|
56
|
+
export declare const defaultRetryPolicy: () => RetryPolicy;
|
|
57
|
+
/** The contract's defaults; fill host, database, user and sslRootCert. */
|
|
58
|
+
export declare function defaultConfig(): Pick<CnpgConfig, "port" | "applicationName" | "connectTimeoutMs" | "statementTimeoutMs" | "idleInTxTimeoutMs" | "poolMax" | "poolMin" | "maxConnLifetimeMs" | "maxConnIdleMs" | "retry">;
|
|
59
|
+
/** Reports every problem, not just the first. */
|
|
60
|
+
export declare function validateConfig(c: CnpgConfig): void;
|
|
61
|
+
/** "500ms", "30s", "5m", "1h" (a "0" is accepted too). */
|
|
62
|
+
export declare function parseDuration(text: string): number;
|
|
63
|
+
/**
|
|
64
|
+
* Builds a configuration from the contract's environment: the libpq names the
|
|
65
|
+
* cnpg-client Helm library chart exports, plus the CNPG_CLIENT_* tuning
|
|
66
|
+
* variables. The result is validated.
|
|
67
|
+
*/
|
|
68
|
+
export declare function configFromEnv(env?: Record<string, string | undefined>): CnpgConfig;
|
|
69
|
+
/** A copy that is safe to log or serialise: no password, no key material. */
|
|
70
|
+
export declare function redactConfig(c: CnpgConfig): Record<string, unknown>;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
export class ConfigError extends Error {
|
|
3
|
+
problems;
|
|
4
|
+
constructor(problems) {
|
|
5
|
+
super(`cnpg-client: invalid configuration:\n - ${problems.join("\n - ")}`);
|
|
6
|
+
this.problems = problems;
|
|
7
|
+
this.name = "ConfigError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* No attempt cap: retry for up to 45s, backing off from 200ms to a 2s ceiling.
|
|
12
|
+
* A CloudNativePG failover leaves the primary unreachable for 10 to 30s, so
|
|
13
|
+
* time, not a try count, is the binding limit.
|
|
14
|
+
*/
|
|
15
|
+
export const defaultRetryPolicy = () => ({
|
|
16
|
+
attempts: 0,
|
|
17
|
+
initialDelayMs: 200,
|
|
18
|
+
maxDelayMs: 2_000,
|
|
19
|
+
budgetMs: 45_000,
|
|
20
|
+
});
|
|
21
|
+
/** The contract's defaults; fill host, database, user and sslRootCert. */
|
|
22
|
+
export function defaultConfig() {
|
|
23
|
+
return {
|
|
24
|
+
port: 5432,
|
|
25
|
+
applicationName: programName(),
|
|
26
|
+
connectTimeoutMs: 5_000,
|
|
27
|
+
statementTimeoutMs: 30_000,
|
|
28
|
+
idleInTxTimeoutMs: 60_000,
|
|
29
|
+
poolMax: 10,
|
|
30
|
+
poolMin: 0,
|
|
31
|
+
maxConnLifetimeMs: 30 * 60_000,
|
|
32
|
+
maxConnIdleMs: 5 * 60_000,
|
|
33
|
+
retry: defaultRetryPolicy(),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function programName() {
|
|
37
|
+
const name = basename(process.argv[1] ?? "node");
|
|
38
|
+
return name.slice(0, 63); // NAMEDATALEN-1
|
|
39
|
+
}
|
|
40
|
+
/** Reports every problem, not just the first. */
|
|
41
|
+
export function validateConfig(c) {
|
|
42
|
+
const p = [];
|
|
43
|
+
if (c.sslMode !== undefined && c.sslMode !== "" && c.sslMode !== "verify-full") {
|
|
44
|
+
p.push(`sslmode "${c.sslMode}" is refused; only verify-full is accepted`);
|
|
45
|
+
}
|
|
46
|
+
if (!c.host)
|
|
47
|
+
p.push("host is required");
|
|
48
|
+
if (/[, ]/.test(c.host ?? ""))
|
|
49
|
+
p.push(`host "${c.host}": exactly one host name is accepted (the cluster's rw Service)`);
|
|
50
|
+
if (!Number.isInteger(c.port) || c.port < 1 || c.port > 65535)
|
|
51
|
+
p.push("port must be 1-65535");
|
|
52
|
+
if (!c.database)
|
|
53
|
+
p.push("database is required");
|
|
54
|
+
if (!c.user)
|
|
55
|
+
p.push("user is required");
|
|
56
|
+
if (!c.sslRootCert) {
|
|
57
|
+
p.push("the server CA file is required (PGSSLROOTCERT): verify-full has nothing to verify against without it");
|
|
58
|
+
}
|
|
59
|
+
if (Boolean(c.sslCert) !== Boolean(c.sslKey))
|
|
60
|
+
p.push("client certificate and key go together");
|
|
61
|
+
if (!(c.poolMax >= 1))
|
|
62
|
+
p.push("poolMax must be at least 1");
|
|
63
|
+
if (!(c.poolMin >= 0 && c.poolMin <= c.poolMax))
|
|
64
|
+
p.push("poolMin must be between 0 and poolMax");
|
|
65
|
+
if (!(c.connectTimeoutMs > 0))
|
|
66
|
+
p.push("connectTimeoutMs must be positive");
|
|
67
|
+
if (c.statementTimeoutMs < 0 || c.idleInTxTimeoutMs < 0)
|
|
68
|
+
p.push("timeouts must not be negative");
|
|
69
|
+
if (!(c.maxConnLifetimeMs > 0 && c.maxConnIdleMs > 0))
|
|
70
|
+
p.push("maxConnLifetimeMs and maxConnIdleMs must be positive");
|
|
71
|
+
const r = c.retry;
|
|
72
|
+
if (!(r.attempts >= 0 && r.initialDelayMs > 0 && r.maxDelayMs >= r.initialDelayMs && r.budgetMs > 0)) {
|
|
73
|
+
p.push("retry: attempts>=0 (0 = no cap), 0<initialDelayMs<=maxDelayMs, budgetMs>0");
|
|
74
|
+
}
|
|
75
|
+
if (p.length > 0)
|
|
76
|
+
throw new ConfigError(p);
|
|
77
|
+
}
|
|
78
|
+
const DURATION = /^(\d+(?:\.\d+)?)(ms|s|m|h)$/;
|
|
79
|
+
const UNIT_MS = { ms: 1, s: 1_000, m: 60_000, h: 3_600_000 };
|
|
80
|
+
/** "500ms", "30s", "5m", "1h" (a "0" is accepted too). */
|
|
81
|
+
export function parseDuration(text) {
|
|
82
|
+
if (text === "0")
|
|
83
|
+
return 0;
|
|
84
|
+
const m = DURATION.exec(text);
|
|
85
|
+
if (!m)
|
|
86
|
+
throw new Error(`"${text}" is not a duration (use 500ms, 30s, 5m, 1h)`);
|
|
87
|
+
return Math.round(Number(m[1]) * UNIT_MS[m[2]]);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Builds a configuration from the contract's environment: the libpq names the
|
|
91
|
+
* cnpg-client Helm library chart exports, plus the CNPG_CLIENT_* tuning
|
|
92
|
+
* variables. The result is validated.
|
|
93
|
+
*/
|
|
94
|
+
export function configFromEnv(env = process.env) {
|
|
95
|
+
const problems = [];
|
|
96
|
+
const get = (k) => (env[k] === "" ? undefined : env[k]);
|
|
97
|
+
const num = (k, into, parse) => {
|
|
98
|
+
const v = get(k);
|
|
99
|
+
if (v === undefined)
|
|
100
|
+
return;
|
|
101
|
+
try {
|
|
102
|
+
const n = parse(v);
|
|
103
|
+
if (!Number.isFinite(n))
|
|
104
|
+
throw new Error("not a number");
|
|
105
|
+
into(n);
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
problems.push(`${k}="${v}": ${e.message}`);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const int = (s) => {
|
|
112
|
+
if (!/^\d+$/.test(s))
|
|
113
|
+
throw new Error("not a whole number");
|
|
114
|
+
return Number(s);
|
|
115
|
+
};
|
|
116
|
+
const c = {
|
|
117
|
+
...defaultConfig(),
|
|
118
|
+
host: get("PGHOST") ?? "",
|
|
119
|
+
database: get("PGDATABASE") ?? "",
|
|
120
|
+
user: get("PGUSER") ?? "",
|
|
121
|
+
sslRootCert: get("PGSSLROOTCERT") ?? "",
|
|
122
|
+
sslCert: get("PGSSLCERT"),
|
|
123
|
+
sslKey: get("PGSSLKEY"),
|
|
124
|
+
sslMode: get("PGSSLMODE"),
|
|
125
|
+
password: get("PGPASSWORD"),
|
|
126
|
+
passwordFile: get("CNPG_CLIENT_PASSWORD_FILE"),
|
|
127
|
+
};
|
|
128
|
+
const app = get("PGAPPNAME");
|
|
129
|
+
if (app)
|
|
130
|
+
c.applicationName = app;
|
|
131
|
+
num("PGPORT", (n) => (c.port = n), int);
|
|
132
|
+
num("PGCONNECT_TIMEOUT", (n) => (c.connectTimeoutMs = n * 1000), (s) => {
|
|
133
|
+
const n = int(s);
|
|
134
|
+
if (n <= 0)
|
|
135
|
+
throw new Error("must be positive seconds");
|
|
136
|
+
return n;
|
|
137
|
+
});
|
|
138
|
+
num("CNPG_CLIENT_STATEMENT_TIMEOUT", (n) => (c.statementTimeoutMs = n), parseDuration);
|
|
139
|
+
num("CNPG_CLIENT_IDLE_TX_TIMEOUT", (n) => (c.idleInTxTimeoutMs = n), parseDuration);
|
|
140
|
+
num("CNPG_CLIENT_POOL_MAX", (n) => (c.poolMax = n), int);
|
|
141
|
+
num("CNPG_CLIENT_POOL_MIN", (n) => (c.poolMin = n), int);
|
|
142
|
+
num("CNPG_CLIENT_CONN_MAX_LIFETIME", (n) => (c.maxConnLifetimeMs = n), parseDuration);
|
|
143
|
+
num("CNPG_CLIENT_CONN_MAX_IDLE", (n) => (c.maxConnIdleMs = n), parseDuration);
|
|
144
|
+
num("CNPG_CLIENT_RETRY_ATTEMPTS", (n) => (c.retry.attempts = n), int);
|
|
145
|
+
num("CNPG_CLIENT_RETRY_MAX_DELAY", (n) => (c.retry.maxDelayMs = n), parseDuration);
|
|
146
|
+
num("CNPG_CLIENT_RETRY_BUDGET", (n) => (c.retry.budgetMs = n), parseDuration);
|
|
147
|
+
if (problems.length > 0)
|
|
148
|
+
throw new ConfigError(problems);
|
|
149
|
+
validateConfig(c);
|
|
150
|
+
return c;
|
|
151
|
+
}
|
|
152
|
+
/** A copy that is safe to log or serialise: no password, no key material. */
|
|
153
|
+
export function redactConfig(c) {
|
|
154
|
+
return {
|
|
155
|
+
host: c.host,
|
|
156
|
+
port: c.port,
|
|
157
|
+
database: c.database,
|
|
158
|
+
user: c.user,
|
|
159
|
+
password: c.password || c.passwordFile ? "<redacted>" : "<none>",
|
|
160
|
+
sslmode: "verify-full",
|
|
161
|
+
sslRootCert: c.sslRootCert,
|
|
162
|
+
sslCert: c.sslCert,
|
|
163
|
+
sslKey: c.sslKey,
|
|
164
|
+
applicationName: c.applicationName,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { type CnpgConfig, ConfigError, configFromEnv, defaultConfig, defaultRetryPolicy, parseDuration, type RetryPolicy, redactConfig, validateConfig, } from "./config.js";
|
|
2
|
+
export { CnpgPool, type CnpgPoolOptions, HEALTH_TIMEOUT_MS, type PoolStats, pgPoolConfig, STARTUP_ATTEMPT_TIMEOUT_MS, } from "./pool.js";
|
|
3
|
+
export { AttemptTimeoutError, backoffMs, isRetryable, retry } from "./retry.js";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ConfigError, configFromEnv, defaultConfig, defaultRetryPolicy, parseDuration, redactConfig, validateConfig, } from "./config.js";
|
|
2
|
+
export { CnpgPool, HEALTH_TIMEOUT_MS, pgPoolConfig, STARTUP_ATTEMPT_TIMEOUT_MS, } from "./pool.js";
|
|
3
|
+
export { AttemptTimeoutError, backoffMs, isRetryable, retry } from "./retry.js";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Tracer } from "@opentelemetry/api";
|
|
2
|
+
import pg from "pg";
|
|
3
|
+
import { type CnpgConfig } from "./config.js";
|
|
4
|
+
/** Bounds {@link CnpgPool.health}. */
|
|
5
|
+
export declare const HEALTH_TIMEOUT_MS = 2000;
|
|
6
|
+
/** Bounds one try of the first connection in {@link CnpgPool.create}: cold DNS, TLS and authentication. */
|
|
7
|
+
export declare const STARTUP_ATTEMPT_TIMEOUT_MS = 5000;
|
|
8
|
+
/** Open, idle and waiting connections, for a metrics exporter. */
|
|
9
|
+
export interface PoolStats {
|
|
10
|
+
total: number;
|
|
11
|
+
idle: number;
|
|
12
|
+
waiting: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `pg.PoolConfig` for the contract. The `Client` it carries re-reads the
|
|
16
|
+
* certificate, key, CA and password files for every new physical connection,
|
|
17
|
+
* so a renewed Secret reaches the next connection without a restart. Pass it
|
|
18
|
+
* as TypeORM's `extra`, or to `new pg.Pool(...)`; prefer {@link CnpgPool}.
|
|
19
|
+
*/
|
|
20
|
+
export declare function pgPoolConfig(config: CnpgConfig): pg.PoolConfig;
|
|
21
|
+
export interface CnpgPoolOptions {
|
|
22
|
+
/** OpenTelemetry tracer; spans only for {@link CnpgPool.query}. */
|
|
23
|
+
tracer?: Tracer;
|
|
24
|
+
/** Abandons the first connection (and its retries) when aborted; an abort is never retried. */
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A node-postgres pool with the contract's behaviour: verify-full against the
|
|
29
|
+
* given CA, certificate/key/password reload per connection, bounded
|
|
30
|
+
* connection lifetime, failover-aware retry and a health check.
|
|
31
|
+
*/
|
|
32
|
+
export declare class CnpgPool {
|
|
33
|
+
readonly config: CnpgConfig;
|
|
34
|
+
private readonly tracer?;
|
|
35
|
+
readonly pool: pg.Pool;
|
|
36
|
+
private constructor();
|
|
37
|
+
/** Validates, builds the pool and proves the first connection under the retry policy. */
|
|
38
|
+
static create(config: CnpgConfig, options?: CnpgPoolOptions): Promise<CnpgPool>;
|
|
39
|
+
/** One try of the first connection: a raw `select 1` bounded by {@link STARTUP_ATTEMPT_TIMEOUT_MS}. */
|
|
40
|
+
private startupProbe;
|
|
41
|
+
/** Runs one statement; traced when a tracer was given. */
|
|
42
|
+
query<R extends pg.QueryResultRow = pg.QueryResultRow>(text: string, values?: unknown[]): Promise<pg.QueryResult<R>>;
|
|
43
|
+
/** A pooled client for transactions; statements on it are not traced. Release it. */
|
|
44
|
+
connect(): Promise<pg.PoolClient>;
|
|
45
|
+
/** Runs `fn` under the retry policy; see {@link retry}. */
|
|
46
|
+
do<T>(fn: () => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
47
|
+
/**
|
|
48
|
+
* SELECT 1 on a pooled connection, bounded by {@link HEALTH_TIMEOUT_MS}. It
|
|
49
|
+
* exercises the real path (Service, TLS, authentication), so it suits a
|
|
50
|
+
* readiness probe. Rejects when unhealthy.
|
|
51
|
+
*/
|
|
52
|
+
health(): Promise<void>;
|
|
53
|
+
stats(): PoolStats;
|
|
54
|
+
/** Closes every connection. */
|
|
55
|
+
end(): Promise<void>;
|
|
56
|
+
/** Safe to log: no password, no key material. */
|
|
57
|
+
toJSON(): Record<string, unknown>;
|
|
58
|
+
}
|
package/dist/esm/pool.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { isIP } from "node:net";
|
|
3
|
+
import pg from "pg";
|
|
4
|
+
import { redactConfig, validateConfig } from "./config.js";
|
|
5
|
+
import { AttemptTimeoutError, retry } from "./retry.js";
|
|
6
|
+
/** Bounds {@link CnpgPool.health}. */
|
|
7
|
+
export const HEALTH_TIMEOUT_MS = 2_000;
|
|
8
|
+
/** Bounds one try of the first connection in {@link CnpgPool.create}: cold DNS, TLS and authentication. */
|
|
9
|
+
export const STARTUP_ATTEMPT_TIMEOUT_MS = 5_000;
|
|
10
|
+
function readPassword(c) {
|
|
11
|
+
if (c.passwordFile)
|
|
12
|
+
return readFileSync(c.passwordFile, "utf8").replace(/[\r\n]+$/, "");
|
|
13
|
+
return c.password;
|
|
14
|
+
}
|
|
15
|
+
/** Read NOW, for one connection: the CA, the client certificate and key. */
|
|
16
|
+
function readSsl(c) {
|
|
17
|
+
return {
|
|
18
|
+
ca: readFileSync(c.sslRootCert),
|
|
19
|
+
...(c.sslCert && c.sslKey ? { cert: readFileSync(c.sslCert), key: readFileSync(c.sslKey) } : {}),
|
|
20
|
+
rejectUnauthorized: true,
|
|
21
|
+
minVersion: "TLSv1.2",
|
|
22
|
+
// verify-full: the certificate must name the host that was dialled.
|
|
23
|
+
...(isIP(c.host) ? {} : { servername: c.host }),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* `pg.PoolConfig` for the contract. The `Client` it carries re-reads the
|
|
28
|
+
* certificate, key, CA and password files for every new physical connection,
|
|
29
|
+
* so a renewed Secret reaches the next connection without a restart. Pass it
|
|
30
|
+
* as TypeORM's `extra`, or to `new pg.Pool(...)`; prefer {@link CnpgPool}.
|
|
31
|
+
*/
|
|
32
|
+
export function pgPoolConfig(config) {
|
|
33
|
+
validateConfig(config);
|
|
34
|
+
const c = { ...config };
|
|
35
|
+
class ReloadingClient extends pg.Client {
|
|
36
|
+
#loadError;
|
|
37
|
+
constructor(options) {
|
|
38
|
+
let fresh = {};
|
|
39
|
+
let loadError;
|
|
40
|
+
try {
|
|
41
|
+
fresh = { ssl: readSsl(c), password: readPassword(c) };
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
// pg-pool builds clients where a throw would be an uncaught exception;
|
|
45
|
+
// fail this connection's connect() instead.
|
|
46
|
+
loadError = new Error(`cnpg-client: reading TLS or password files: ${e.message}`);
|
|
47
|
+
}
|
|
48
|
+
super({ ...options, ...fresh });
|
|
49
|
+
this.#loadError = loadError;
|
|
50
|
+
}
|
|
51
|
+
// biome-ignore lint/suspicious/noExplicitAny: pg's connect has promise and callback overloads
|
|
52
|
+
connect(cb) {
|
|
53
|
+
if (this.#loadError) {
|
|
54
|
+
const err = this.#loadError;
|
|
55
|
+
if (cb) {
|
|
56
|
+
process.nextTick(cb, err);
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return Promise.reject(err);
|
|
60
|
+
}
|
|
61
|
+
return super.connect(cb);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
host: c.host,
|
|
66
|
+
port: c.port,
|
|
67
|
+
database: c.database,
|
|
68
|
+
user: c.user,
|
|
69
|
+
application_name: c.applicationName,
|
|
70
|
+
connectionTimeoutMillis: c.connectTimeoutMs,
|
|
71
|
+
statement_timeout: c.statementTimeoutMs,
|
|
72
|
+
idle_in_transaction_session_timeout: c.idleInTxTimeoutMs,
|
|
73
|
+
max: c.poolMax,
|
|
74
|
+
min: c.poolMin,
|
|
75
|
+
idleTimeoutMillis: c.maxConnIdleMs,
|
|
76
|
+
maxLifetimeSeconds: c.maxConnLifetimeMs / 1000,
|
|
77
|
+
allowExitOnIdle: false,
|
|
78
|
+
Client: ReloadingClient,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function operation(text) {
|
|
82
|
+
const m = /^[\s(]*([A-Za-z]{1,16})\b/.exec(text);
|
|
83
|
+
return m ? m[1].toUpperCase() : "QUERY";
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A node-postgres pool with the contract's behaviour: verify-full against the
|
|
87
|
+
* given CA, certificate/key/password reload per connection, bounded
|
|
88
|
+
* connection lifetime, failover-aware retry and a health check.
|
|
89
|
+
*/
|
|
90
|
+
export class CnpgPool {
|
|
91
|
+
config;
|
|
92
|
+
tracer;
|
|
93
|
+
pool;
|
|
94
|
+
constructor(config, tracer) {
|
|
95
|
+
this.config = config;
|
|
96
|
+
this.tracer = tracer;
|
|
97
|
+
this.pool = new pg.Pool(pgPoolConfig(config));
|
|
98
|
+
// An error on an IDLE pooled client (the primary went away) is emitted on
|
|
99
|
+
// the pool; with no listener it is thrown and takes the process down.
|
|
100
|
+
this.pool.on("error", (err) => config.onError?.(err));
|
|
101
|
+
}
|
|
102
|
+
/** Validates, builds the pool and proves the first connection under the retry policy. */
|
|
103
|
+
static async create(config, options = {}) {
|
|
104
|
+
validateConfig(config);
|
|
105
|
+
const p = new CnpgPool(config, options.tracer);
|
|
106
|
+
try {
|
|
107
|
+
await retry(config.retry, () => p.startupProbe(), options.signal);
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
await p.end().catch(() => undefined);
|
|
111
|
+
throw new Error(`cnpg-client: first connection to ${config.host}:${config.port}: ${e.message}`, {
|
|
112
|
+
cause: e,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return p;
|
|
116
|
+
}
|
|
117
|
+
/** One try of the first connection: a raw `select 1` bounded by {@link STARTUP_ATTEMPT_TIMEOUT_MS}. */
|
|
118
|
+
async startupProbe() {
|
|
119
|
+
let timer;
|
|
120
|
+
const deadline = new Promise((_, reject) => {
|
|
121
|
+
timer = setTimeout(() => reject(new AttemptTimeoutError("first connection", STARTUP_ATTEMPT_TIMEOUT_MS)), STARTUP_ATTEMPT_TIMEOUT_MS);
|
|
122
|
+
});
|
|
123
|
+
try {
|
|
124
|
+
await Promise.race([
|
|
125
|
+
this.pool.query({ text: "select 1", query_timeout: STARTUP_ATTEMPT_TIMEOUT_MS }),
|
|
126
|
+
deadline,
|
|
127
|
+
]);
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
clearTimeout(timer);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** Runs one statement; traced when a tracer was given. */
|
|
134
|
+
async query(text, values) {
|
|
135
|
+
const tracer = this.tracer;
|
|
136
|
+
if (!tracer)
|
|
137
|
+
return this.pool.query(text, values);
|
|
138
|
+
const op = operation(text);
|
|
139
|
+
return tracer.startActiveSpan(`${op} ${this.config.database}`, {
|
|
140
|
+
kind: 2, // SpanKind.CLIENT, without a runtime import of the optional API
|
|
141
|
+
attributes: {
|
|
142
|
+
"db.system.name": "postgresql",
|
|
143
|
+
"db.namespace": this.config.database,
|
|
144
|
+
"db.operation.name": op,
|
|
145
|
+
"db.query.text": text, // placeholders only; the arguments are user data
|
|
146
|
+
"server.address": this.config.host,
|
|
147
|
+
"server.port": this.config.port,
|
|
148
|
+
},
|
|
149
|
+
}, async (span) => {
|
|
150
|
+
try {
|
|
151
|
+
const res = await this.pool.query(text, values);
|
|
152
|
+
span.setAttribute("db.response.returned_rows", res.rowCount ?? 0);
|
|
153
|
+
return res;
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
span.recordException(e);
|
|
157
|
+
span.setStatus({ code: 2, message: "query failed" }); // SpanStatusCode.ERROR
|
|
158
|
+
throw e;
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
span.end();
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/** A pooled client for transactions; statements on it are not traced. Release it. */
|
|
166
|
+
connect() {
|
|
167
|
+
return this.pool.connect();
|
|
168
|
+
}
|
|
169
|
+
/** Runs `fn` under the retry policy; see {@link retry}. */
|
|
170
|
+
do(fn, signal) {
|
|
171
|
+
return retry(this.config.retry, fn, signal);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* SELECT 1 on a pooled connection, bounded by {@link HEALTH_TIMEOUT_MS}. It
|
|
175
|
+
* exercises the real path (Service, TLS, authentication), so it suits a
|
|
176
|
+
* readiness probe. Rejects when unhealthy.
|
|
177
|
+
*/
|
|
178
|
+
async health() {
|
|
179
|
+
let timer;
|
|
180
|
+
const deadline = new Promise((_, reject) => {
|
|
181
|
+
timer = setTimeout(() => reject(new Error("cnpg-client: health: timed out")), HEALTH_TIMEOUT_MS);
|
|
182
|
+
});
|
|
183
|
+
try {
|
|
184
|
+
await Promise.race([
|
|
185
|
+
this.pool.query({ text: "select 1", query_timeout: HEALTH_TIMEOUT_MS }),
|
|
186
|
+
deadline,
|
|
187
|
+
]);
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
190
|
+
throw new Error(`cnpg-client: health: ${e.message}`, { cause: e });
|
|
191
|
+
}
|
|
192
|
+
finally {
|
|
193
|
+
clearTimeout(timer);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
stats() {
|
|
197
|
+
return { total: this.pool.totalCount, idle: this.pool.idleCount, waiting: this.pool.waitingCount };
|
|
198
|
+
}
|
|
199
|
+
/** Closes every connection. */
|
|
200
|
+
end() {
|
|
201
|
+
return this.pool.end();
|
|
202
|
+
}
|
|
203
|
+
/** Safe to log: no password, no key material. */
|
|
204
|
+
toJSON() {
|
|
205
|
+
return redactConfig(this.config);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RetryPolicy } from "./config.js";
|
|
2
|
+
/** Exponential backoff with full jitter. `attempt` is 1 for the first retry. */
|
|
3
|
+
export declare function backoffMs(p: RetryPolicy, attempt: number): number;
|
|
4
|
+
/**
|
|
5
|
+
* Runs `fn`, repeating it while it fails with a retryable error (see
|
|
6
|
+
* {@link isRetryable}). `fn` must be safe to run again: a statement that may
|
|
7
|
+
* have committed before the connection broke is the caller's to reason about,
|
|
8
|
+
* which is why the unit of retry is the caller's whole function.
|
|
9
|
+
*/
|
|
10
|
+
export declare function retry<T>(policy: RetryPolicy, fn: () => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Reports whether `err` means the connection (not the statement) failed: the
|
|
13
|
+
* server went away, was demoted, or is not accepting yet. Those are what a
|
|
14
|
+
* CloudNativePG switchover or crash looks like to a client.
|
|
15
|
+
*
|
|
16
|
+
* Never retryable: authentication and permission errors, constraint and syntax
|
|
17
|
+
* errors, a statement timeout (57014), a serialization failure (40001, 40P01:
|
|
18
|
+
* the caller retries its transaction) and certificate verification failures.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isRetryable(err: unknown): boolean;
|
|
21
|
+
/** One try of the first connection ran past its own bound; the caller's signal is separate. */
|
|
22
|
+
export declare class AttemptTimeoutError extends Error {
|
|
23
|
+
constructor(what: string, ms: number);
|
|
24
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const sleep = (ms, signal) => new Promise((resolve) => {
|
|
2
|
+
const t = setTimeout(done, ms);
|
|
3
|
+
signal?.addEventListener("abort", done, { once: true });
|
|
4
|
+
function done() {
|
|
5
|
+
clearTimeout(t);
|
|
6
|
+
signal?.removeEventListener("abort", done);
|
|
7
|
+
resolve();
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
/** Exponential backoff with full jitter. `attempt` is 1 for the first retry. */
|
|
11
|
+
export function backoffMs(p, attempt) {
|
|
12
|
+
const ceil = Math.min(p.maxDelayMs, p.initialDelayMs * 2 ** (attempt - 1));
|
|
13
|
+
return Math.floor(Math.random() * (ceil + 1));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Runs `fn`, repeating it while it fails with a retryable error (see
|
|
17
|
+
* {@link isRetryable}). `fn` must be safe to run again: a statement that may
|
|
18
|
+
* have committed before the connection broke is the caller's to reason about,
|
|
19
|
+
* which is why the unit of retry is the caller's whole function.
|
|
20
|
+
*/
|
|
21
|
+
export async function retry(policy, fn, signal) {
|
|
22
|
+
const start = Date.now();
|
|
23
|
+
for (let attempt = 1;; attempt++) {
|
|
24
|
+
try {
|
|
25
|
+
return await fn();
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
if (signal?.aborted || !isRetryable(err) || (policy.attempts > 0 && attempt >= policy.attempts))
|
|
29
|
+
throw err;
|
|
30
|
+
const delay = backoffMs(policy, attempt);
|
|
31
|
+
if (Date.now() - start + delay > policy.budgetMs)
|
|
32
|
+
throw err;
|
|
33
|
+
policy.onRetry?.(attempt, err, delay);
|
|
34
|
+
await sleep(delay, signal);
|
|
35
|
+
if (signal?.aborted)
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const NEVER_CODES = new Set([
|
|
41
|
+
// certificate verification and TLS handshake rejection: a second try cannot fix them
|
|
42
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
43
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
44
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
45
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
46
|
+
"CERT_HAS_EXPIRED",
|
|
47
|
+
"CERT_NOT_YET_VALID",
|
|
48
|
+
"ERR_TLS_CERT_ALTNAME_INVALID",
|
|
49
|
+
"ERR_TLS_INVALID_PROTOCOL_VERSION",
|
|
50
|
+
]);
|
|
51
|
+
const NETWORK_CODES = new Set([
|
|
52
|
+
"ECONNRESET",
|
|
53
|
+
"ECONNREFUSED",
|
|
54
|
+
"EPIPE",
|
|
55
|
+
"ETIMEDOUT",
|
|
56
|
+
"EAI_AGAIN",
|
|
57
|
+
"ECONNABORTED",
|
|
58
|
+
"EHOSTUNREACH",
|
|
59
|
+
]);
|
|
60
|
+
const MESSAGES = [
|
|
61
|
+
"Connection terminated",
|
|
62
|
+
"timeout exceeded when trying to connect",
|
|
63
|
+
"Client has encountered a connection error",
|
|
64
|
+
"Client was closed and is not queryable",
|
|
65
|
+
"the database system is starting up",
|
|
66
|
+
"the database system is shutting down",
|
|
67
|
+
];
|
|
68
|
+
/**
|
|
69
|
+
* Reports whether `err` means the connection (not the statement) failed: the
|
|
70
|
+
* server went away, was demoted, or is not accepting yet. Those are what a
|
|
71
|
+
* CloudNativePG switchover or crash looks like to a client.
|
|
72
|
+
*
|
|
73
|
+
* Never retryable: authentication and permission errors, constraint and syntax
|
|
74
|
+
* errors, a statement timeout (57014), a serialization failure (40001, 40P01:
|
|
75
|
+
* the caller retries its transaction) and certificate verification failures.
|
|
76
|
+
*/
|
|
77
|
+
export function isRetryable(err) {
|
|
78
|
+
if (!(err instanceof Error))
|
|
79
|
+
return false;
|
|
80
|
+
// The cause chain: a wrapper (such as the health check's) hides the pg error's code.
|
|
81
|
+
const chain = [];
|
|
82
|
+
for (let e = err; e instanceof Error && chain.length < 8; e = e.cause)
|
|
83
|
+
chain.push(e);
|
|
84
|
+
if (chain.some(neverRetryable))
|
|
85
|
+
return false;
|
|
86
|
+
return chain.some(retryableOne);
|
|
87
|
+
}
|
|
88
|
+
/** One try of the first connection ran past its own bound; the caller's signal is separate. */
|
|
89
|
+
export class AttemptTimeoutError extends Error {
|
|
90
|
+
constructor(what, ms) {
|
|
91
|
+
super(`cnpg-client: ${what}: attempt timed out after ${ms}ms`);
|
|
92
|
+
this.name = "AttemptTimeoutError";
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function neverRetryable(err) {
|
|
96
|
+
const code = err.code;
|
|
97
|
+
return typeof code === "string" && (NEVER_CODES.has(code) || code.startsWith("ERR_SSL_"));
|
|
98
|
+
}
|
|
99
|
+
function retryableOne(err) {
|
|
100
|
+
if (err instanceof AttemptTimeoutError)
|
|
101
|
+
return true;
|
|
102
|
+
const code = err.code;
|
|
103
|
+
if (typeof code === "string") {
|
|
104
|
+
if (NETWORK_CODES.has(code))
|
|
105
|
+
return true;
|
|
106
|
+
if (/^[0-9A-Z]{5}$/.test(code))
|
|
107
|
+
return retryableSqlState(code);
|
|
108
|
+
}
|
|
109
|
+
return MESSAGES.some((m) => err.message.includes(m));
|
|
110
|
+
}
|
|
111
|
+
function retryableSqlState(code) {
|
|
112
|
+
if (code.startsWith("08"))
|
|
113
|
+
return true; // connection exception
|
|
114
|
+
// admin shutdown, crash shutdown, cannot connect now; read_only_sql_transaction
|
|
115
|
+
// (a demoted primary still answering); too_many_connections (a new primary filling)
|
|
116
|
+
return ["57P01", "57P02", "57P03", "25006", "53300"].includes(code);
|
|
117
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truvity/cnpg-client",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.50.0",
|
|
4
|
+
"description": "PostgreSQL client adapter for CloudNativePG clusters: verify-full, per-connection certificate reload, failover-aware retry.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/truvity/cnpg.git",
|
|
9
9
|
"directory": "clients/ts"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/esm/index.js",
|
|
13
|
+
"module": "./dist/esm/index.js",
|
|
14
|
+
"types": "./dist/esm/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/esm/index.d.ts",
|
|
18
|
+
"default": "./dist/esm/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"registry": "https://registry.npmjs.org",
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=20"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
34
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
35
|
+
"lint": "biome check .",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:conformance": "vitest run test/conformance.test.ts"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"pg": "^8.23.1"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@opentelemetry/api": "^1.9.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"@opentelemetry/api": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@biomejs/biome": "^2.5.15",
|
|
52
|
+
"@opentelemetry/api": "^1.9.1",
|
|
53
|
+
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
|
54
|
+
"@types/node": "^22.0.0",
|
|
55
|
+
"@types/pg": "^8.15.0",
|
|
56
|
+
"typescript": "^7.0.2",
|
|
57
|
+
"vitest": "^5.0.3"
|
|
10
58
|
}
|
|
11
59
|
}
|