@ontemper/sdk 0.7.0-postgresql.3 → 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 +7 -33
- package/dist/Contract/RuntimeApi.d.ts +0 -19
- package/dist/Contract/RuntimeApi.d.ts.map +1 -1
- package/dist/Contract/RuntimeApi.js +1 -1
- package/dist/Contract/RuntimeApi.js.map +1 -1
- package/dist/Edi.d.ts +13 -2
- package/dist/Edi.d.ts.map +1 -1
- package/dist/Edi.js +40 -15
- package/dist/Edi.js.map +1 -1
- package/dist/EdiModel.d.ts +55 -0
- package/dist/EdiModel.d.ts.map +1 -1
- package/dist/HttpApiResource.d.ts +0 -12
- package/dist/HttpApiResource.d.ts.map +1 -1
- package/dist/HttpApiResource.js +1 -1
- package/dist/HttpApiResource.js.map +1 -1
- package/dist/Manifest.d.ts +1 -1
- package/dist/Manifest.d.ts.map +1 -1
- package/dist/Manifest.js +1 -1
- package/dist/Manifest.js.map +1 -1
- package/dist/RuntimeResources.d.ts +1 -13
- package/dist/RuntimeResources.d.ts.map +1 -1
- package/dist/RuntimeResources.js +3 -18
- package/dist/RuntimeResources.js.map +1 -1
- package/package.json +4 -25
- package/dist/PostgreSql.d.ts +0 -24
- package/dist/PostgreSql.d.ts.map +0 -1
- package/dist/PostgreSql.js +0 -64
- package/dist/PostgreSql.js.map +0 -1
- package/dist/PostgreSqlPool.d.ts +0 -70
- package/dist/PostgreSqlPool.d.ts.map +0 -1
- package/dist/PostgreSqlPool.js +0 -131
- package/dist/PostgreSqlPool.js.map +0 -1
- package/dist/PostgreSqlTimeouts.d.ts +0 -4
- package/dist/PostgreSqlTimeouts.d.ts.map +0 -1
- package/dist/PostgreSqlTimeouts.js +0 -16
- package/dist/PostgreSqlTimeouts.js.map +0 -1
- package/dist/PostgreSqlTunnel.d.ts +0 -25
- package/dist/PostgreSqlTunnel.d.ts.map +0 -1
- package/dist/PostgreSqlTunnel.js +0 -114
- package/dist/PostgreSqlTunnel.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeResources.d.ts","sourceRoot":"","sources":["../src/RuntimeResources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,OAAO,EAAY,MAAM,EAAQ,KAAK,EAAU,QAAQ,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAErH,OAAO,EAAE,UAAU,EAA2C,MAAM,aAAa,CAAC;AAElF,OAAO,EAQL,KAAK,
|
|
1
|
+
{"version":3,"file":"RuntimeResources.d.ts","sourceRoot":"","sources":["../src/RuntimeResources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,OAAO,EAAY,MAAM,EAAQ,KAAK,EAAU,QAAQ,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAErH,OAAO,EAAE,UAAU,EAA2C,MAAM,aAAa,CAAC;AAElF,OAAO,EAQL,KAAK,gCAAgC,EACtC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,sBAAsB,CAAC;AAY9B,qGAAqG;AACrG,MAAM,MAAM,gBAAgB,GAAG,OAAO,gCAAgC,CAAC,IAAI,CAAC;AAE5E,MAAM,MAAM,SAAS,GAAG,qBAAqB,GAAG,0BAA0B,GAAG,yBAAyB,CAAC;AA2KvG,yGAAyG;AACzG,MAAM,WAAW,cAAc;IAC7B,wGAAwG;IACxG,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;IACxF,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,oBAAoB,CAAC,CAAC;IAChG,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,CACf,QAAQ,EAAE,gBAAgB,KACvB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,0BAA0B,GAAG,oBAAoB,CAAC,CAAC;CAC3F;;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,qBAErC;IAEC,MAAM,CAAC,QAAQ,CAAC,KAAK,8DAAiD;CACvE"}
|
package/dist/RuntimeResources.js
CHANGED
|
@@ -26,8 +26,7 @@ const statusOfRuntimeError = {
|
|
|
26
26
|
RuntimeResourcesConflictError: 409,
|
|
27
27
|
RuntimeResourcesUnavailableError: 503,
|
|
28
28
|
};
|
|
29
|
-
|
|
30
|
-
const makeRuntimeCaller = Effect.gen(function* () {
|
|
29
|
+
const ResourcesMake = Effect.gen(function* () {
|
|
31
30
|
const tokens = yield* makeRuntimeTokens;
|
|
32
31
|
// Each attempt's scope owns its request: leaving the scope aborts it, so no response outlives its attempt.
|
|
33
32
|
const platform = HttpClient.withScope(yield* HttpClient.HttpClient).pipe(HttpClient.mapRequestEffect((request) => Config.NonEmptyString('UNNBOUND_API_URL').pipe(Effect.map((apiUrl) => HttpClientRequest.prependUrl(request, apiUrl)), Effect.mapError(() => new ApiUrlMissing()))));
|
|
@@ -79,22 +78,6 @@ const makeRuntimeCaller = Effect.gen(function* () {
|
|
|
79
78
|
return yield* attempt(client.resourcesRuntime, yield* tokens.replacing(token));
|
|
80
79
|
}).pipe(Effect.catchIf((error) => error._tag !== 'ResourcesUnauthorizedError' && error._tag !== 'ResourcesUnavailableError', (error) => Effect.fail(toReadError(error))));
|
|
81
80
|
};
|
|
82
|
-
return { tokens, call };
|
|
83
|
-
});
|
|
84
|
-
// Registers the answer's secrets in the caller's context, so a cached read masks them like a fresh one.
|
|
85
|
-
const unwrap = (read) => read.pipe(Effect.tap(({ redactionMasks }) => registerSecrets(redactionMasks ?? [])), Effect.map(({ value }) => value));
|
|
86
|
-
/** Uncached runtime reads for the PostgreSQL subpath: a record, its metadata, and the current runtime token. */
|
|
87
|
-
export const makeRuntimeResourceClient = Effect.map(makeRuntimeCaller, ({ tokens, call }) => ({
|
|
88
|
-
/**
|
|
89
|
-
* The token for one database tunnel; re-read on every call, never cached by the caller. The tunnel re-checks it
|
|
90
|
-
* every 2 s, so a token in its 30 s refresh window would end the connection when it expires.
|
|
91
|
-
*/
|
|
92
|
-
tunnelToken: tokens.current,
|
|
93
|
-
resolve: (key) => unwrap(call('resolveResource', `key ${key}`, (api, authorization) => api.resolveResource({ headers: { authorization }, payload: { key } }), (status, message) => (status === 409 ? new InvalidResourceError({ target: `key ${key}`, message }) : undefined))),
|
|
94
|
-
inspect: (key) => unwrap(call('inspectResource', `key ${key}`, (api, authorization) => api.inspectResource({ headers: { authorization }, payload: { key } }))),
|
|
95
|
-
}));
|
|
96
|
-
const ResourcesMake = Effect.gen(function* () {
|
|
97
|
-
const { call } = yield* makeRuntimeCaller;
|
|
98
81
|
const cache = (lookup) => Cache.makeWith(lookup, {
|
|
99
82
|
capacity: CACHE_CAPACITY,
|
|
100
83
|
// A failure is not kept: the next read asks the resolver again.
|
|
@@ -111,6 +94,8 @@ const ResourcesMake = Effect.gen(function* () {
|
|
|
111
94
|
? new InvalidResourceError({ target, message })
|
|
112
95
|
: undefined);
|
|
113
96
|
});
|
|
97
|
+
// Registers the answer's secrets in the caller's context, so a cached read masks them like a fresh one.
|
|
98
|
+
const unwrap = (read) => read.pipe(Effect.tap(({ redactionMasks }) => registerSecrets(redactionMasks ?? [])), Effect.map(({ value }) => value));
|
|
114
99
|
return RuntimeResources.of({
|
|
115
100
|
variable: (key) => Effect.map(unwrap(Cache.get(variables, key)), Redacted.make),
|
|
116
101
|
// Each caller gets its own copy: the cached value is shared across requests for 30 s.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeResources.js","sourceRoot":"","sources":["../src/RuntimeResources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,M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
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontemper/sdk",
|
|
3
|
-
"version": "0.7.0
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Effect workflow SDK for Temper.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,10 +42,6 @@
|
|
|
42
42
|
"./as2/testing": {
|
|
43
43
|
"types": "./dist/As2Testing.d.ts",
|
|
44
44
|
"default": "./dist/As2Testing.js"
|
|
45
|
-
},
|
|
46
|
-
"./postgresql": {
|
|
47
|
-
"types": "./dist/PostgreSql.d.ts",
|
|
48
|
-
"default": "./dist/PostgreSql.js"
|
|
49
45
|
}
|
|
50
46
|
},
|
|
51
47
|
"bin": {
|
|
@@ -63,41 +59,24 @@
|
|
|
63
59
|
"ssh2": "1.17.0"
|
|
64
60
|
},
|
|
65
61
|
"peerDependencies": {
|
|
66
|
-
"effect": "4.0.6"
|
|
67
|
-
"pg": "^8.16.0",
|
|
68
|
-
"ws": "^8.18.0"
|
|
69
|
-
},
|
|
70
|
-
"peerDependenciesMeta": {
|
|
71
|
-
"pg": {
|
|
72
|
-
"optional": true
|
|
73
|
-
},
|
|
74
|
-
"ws": {
|
|
75
|
-
"optional": true
|
|
76
|
-
}
|
|
62
|
+
"effect": "4.0.6"
|
|
77
63
|
},
|
|
78
64
|
"devDependencies": {
|
|
79
|
-
"@temper/shared": "1.0.0",
|
|
80
|
-
"@testcontainers/postgresql": "^11.14.0",
|
|
81
65
|
"@types/bun": "1.4.1",
|
|
82
66
|
"@types/node": "26.4.1",
|
|
83
|
-
"@types/pg": "^8.20.0",
|
|
84
67
|
"@types/ssh2": "1.15.5",
|
|
85
|
-
"@types/ws": "^8.18.1",
|
|
86
68
|
"effect": "4.0.6",
|
|
87
|
-
"
|
|
88
|
-
"vitest": "^4.0.15",
|
|
89
|
-
"ws": "^8.21.3"
|
|
69
|
+
"vitest": "^4.0.15"
|
|
90
70
|
},
|
|
91
71
|
"publishConfig": {
|
|
92
72
|
"access": "public"
|
|
93
73
|
},
|
|
94
74
|
"license": "MIT",
|
|
95
75
|
"sideEffects": false,
|
|
96
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "9a27b5d87f016d6ccdf1a887af9409f25e2b852e",
|
|
97
77
|
"scripts": {
|
|
98
78
|
"build": "tsc -p tsconfig.json",
|
|
99
79
|
"test": "vitest run",
|
|
100
|
-
"test:unit": "vitest run --exclude '**/*.integration.test.ts'",
|
|
101
80
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
102
81
|
}
|
|
103
82
|
}
|
package/dist/PostgreSql.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PostgreSQL Resource pools: `import { createPostgresqlPool } from '@temper/workflow/postgresql'`. Needs the `pg`
|
|
3
|
-
* and `ws` packages, which only this subpath loads.
|
|
4
|
-
*/
|
|
5
|
-
import { Effect, type Scope } from 'effect';
|
|
6
|
-
import type pg from 'pg';
|
|
7
|
-
import type { InvalidResourceError } from './ResourcesErrors.js';
|
|
8
|
-
import { type ReadError } from './RuntimeResources.js';
|
|
9
|
-
export { PostgresqlResource } from './PostgreSqlPool.js';
|
|
10
|
-
/** What opening a pool can fail with; a rejected tunnel fails each connection instead, never the open. */
|
|
11
|
-
export type PostgresqlPoolError = ReadError | InvalidResourceError;
|
|
12
|
-
/**
|
|
13
|
-
* The pool for the PostgreSQL Resource `key`, ended when the scope closes; a client still checked out after 15 s
|
|
14
|
-
* is left open and logged. Native TCP, except in a builder (`TEMPER_DATABASE_TUNNEL=websocket`) for a
|
|
15
|
-
* Temper-managed database, which goes through the Resources tunnel.
|
|
16
|
-
*/
|
|
17
|
-
export declare const makePostgresqlPool: (key: string) => Effect.Effect<pg.Pool, PostgresqlPoolError, Scope.Scope>;
|
|
18
|
-
/**
|
|
19
|
-
* Resolves a PostgreSQL Resource and selects its runtime transport without opening a connection; the caller ends
|
|
20
|
-
* the pool. Rejects with the SDK's Resource errors: `ResourceNotFoundError` only when no record answers the key,
|
|
21
|
-
* and `InvalidResourceError` for a found record that cannot serve, such as one whose password Variable is missing.
|
|
22
|
-
*/
|
|
23
|
-
export declare function createPostgresqlPool(key: string): Promise<pg.Pool>;
|
|
24
|
-
//# sourceMappingURL=PostgreSql.d.ts.map
|
package/dist/PostgreSql.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSql.d.ts","sourceRoot":"","sources":["../src/PostgreSql.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAA2C,MAAM,EAAuB,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE1G,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,0GAA0G;AAC1G,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,oBAAoB,CAAC;AAiDnE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAS,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,EAAE,KAAK,CAAC,KAAK,CAC7C,CAAC;AAS5D;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAIxE"}
|
package/dist/PostgreSql.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PostgreSQL Resource pools: `import { createPostgresqlPool } from '@temper/workflow/postgresql'`. Needs the `pg`
|
|
3
|
-
* and `ws` packages, which only this subpath loads.
|
|
4
|
-
*/
|
|
5
|
-
import { Cause, Config, ConfigProvider, Duration, Effect, Exit, Layer, Option } from 'effect';
|
|
6
|
-
import { FetchHttpClient, HttpClient } from 'effect/http';
|
|
7
|
-
import { loggerLayer, writeStdoutLine } from './Logger.js';
|
|
8
|
-
import { endPool, makeResourcePool, tunnelEnabled } from './PostgreSqlPool.js';
|
|
9
|
-
import { makeRuntimeResourceClient } from './RuntimeResources.js';
|
|
10
|
-
export { PostgresqlResource } from './PostgreSqlPool.js';
|
|
11
|
-
// A token in its refresh window waits for the provider's next publish. pg's connect timeout is 10 s, so the wait
|
|
12
|
-
// ends with the connection attempt instead of holding the process open.
|
|
13
|
-
const TUNNEL_AUTHORIZATION_TIMEOUT = Duration.seconds(10);
|
|
14
|
-
// The tunnel path keeps literal dots out of the router's file-extension handling, as @ontemper/resources did.
|
|
15
|
-
const tunnelAuthorization = (key) => Effect.gen(function* () {
|
|
16
|
-
const apiUrl = yield* Config.NonEmptyString('UNNBOUND_API_URL');
|
|
17
|
-
const endpoint = new URL(`/api/runtime/databases/${encodeURIComponent(key.replaceAll('.', '%2E'))}/tunnel`, apiUrl);
|
|
18
|
-
if (endpoint.protocol !== 'https:' && endpoint.protocol !== 'http:') {
|
|
19
|
-
return yield* Effect.fail(new Error('Temper API URL must use HTTP or HTTPS.'));
|
|
20
|
-
}
|
|
21
|
-
endpoint.protocol = endpoint.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
22
|
-
return endpoint.href;
|
|
23
|
-
});
|
|
24
|
-
const open = (rawKey) => Effect.gen(function* () {
|
|
25
|
-
const key = rawKey.trim();
|
|
26
|
-
// A workflow's own HttpClient when there is one; resolver calls disable its tracing either way.
|
|
27
|
-
const httpClient = yield* Effect.serviceOption(HttpClient.HttpClient);
|
|
28
|
-
const client = yield* makeRuntimeResourceClient.pipe(Option.isSome(httpClient)
|
|
29
|
-
? Effect.provideService(HttpClient.HttpClient, httpClient.value)
|
|
30
|
-
: Effect.provide(FetchHttpClient.layer));
|
|
31
|
-
const tunnel = tunnelEnabled(yield* Config.option(Config.String('TEMPER_DATABASE_TUNNEL')).pipe(Effect.orElseSucceed(() => Option.none())));
|
|
32
|
-
const context = yield* Effect.context();
|
|
33
|
-
return yield* makeResourcePool(key, {
|
|
34
|
-
resolve: client.resolve,
|
|
35
|
-
inspect: client.inspect,
|
|
36
|
-
authorizeTunnel: tunnel
|
|
37
|
-
? (tunnelKey) => Effect.runPromiseWith(context)(Effect.all({ url: tunnelAuthorization(tunnelKey), token: client.tunnelToken }).pipe(Effect.timeoutOrElse({
|
|
38
|
-
duration: TUNNEL_AUTHORIZATION_TIMEOUT,
|
|
39
|
-
orElse: () => Effect.fail(new Error('No runtime token for the database tunnel within 10 s.')),
|
|
40
|
-
})))
|
|
41
|
-
: undefined,
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
/**
|
|
45
|
-
* The pool for the PostgreSQL Resource `key`, ended when the scope closes; a client still checked out after 15 s
|
|
46
|
-
* is left open and logged. Native TCP, except in a builder (`TEMPER_DATABASE_TUNNEL=websocket`) for a
|
|
47
|
-
* Temper-managed database, which goes through the Resources tunnel.
|
|
48
|
-
*/
|
|
49
|
-
export const makePostgresqlPool = (key) => Effect.acquireRelease(open(key), (pool) => endPool(pool));
|
|
50
|
-
// Outside a workflow the pool logs through the SDK line logger on stdout and reads the live environment, as
|
|
51
|
-
// `workflow()` does; Effect's default provider keeps a copy taken on first use.
|
|
52
|
-
const standalone = loggerLayer(writeStdoutLine).pipe(Layer.orDie, Layer.provideMerge(ConfigProvider.layer(ConfigProvider.fromEnvRecord(process.env, { preserveEmptyStrings: true }))));
|
|
53
|
-
/**
|
|
54
|
-
* Resolves a PostgreSQL Resource and selects its runtime transport without opening a connection; the caller ends
|
|
55
|
-
* the pool. Rejects with the SDK's Resource errors: `ResourceNotFoundError` only when no record answers the key,
|
|
56
|
-
* and `InvalidResourceError` for a found record that cannot serve, such as one whose password Variable is missing.
|
|
57
|
-
*/
|
|
58
|
-
export async function createPostgresqlPool(key) {
|
|
59
|
-
const exit = await Effect.runPromiseExit(open(key).pipe(Effect.provide(standalone)));
|
|
60
|
-
if (Exit.isSuccess(exit))
|
|
61
|
-
return exit.value;
|
|
62
|
-
throw Cause.squash(exit.cause);
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=PostgreSql.js.map
|
package/dist/PostgreSql.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSql.js","sourceRoot":"","sources":["../src/PostgreSql.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,yBAAyB,EAAkB,MAAM,uBAAuB,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAKzD,iHAAiH;AACjH,wEAAwE;AACxE,MAAM,4BAA4B,GAAG,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAE1D,8GAA8G;AAC9G,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAE,EAAE,CAC1C,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,0BAA0B,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACpH,IAAI,QAAQ,CAAC,QAAQ,KAAK,QAAQ,IAAI,QAAQ,C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,CAAC,CAAC,CAAC;IACrF,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC;IAC5C,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC"}
|
package/dist/PostgreSqlPool.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { type Duration, Effect, Option, Schema } from 'effect';
|
|
2
|
-
import pg from 'pg';
|
|
3
|
-
import { InvalidResourceError } from './ResourcesErrors.js';
|
|
4
|
-
import type { InspectedResource, ReadError } from './RuntimeResources.js';
|
|
5
|
-
/** A `postgresql` record as `@ontemper/resources` reads it; `sslmode` carries libpq semantics, and `tls` the CA and client certificate. */
|
|
6
|
-
export declare const PostgresqlResource: Schema.Struct<{
|
|
7
|
-
readonly host: Schema.String;
|
|
8
|
-
readonly port: Schema.withDecodingDefaultKey<Schema.Int, never>;
|
|
9
|
-
readonly dbname: Schema.String;
|
|
10
|
-
readonly user: Schema.String;
|
|
11
|
-
readonly auth: Schema.Union<readonly [Schema.Struct<{
|
|
12
|
-
readonly type: Schema.Literal<"password">;
|
|
13
|
-
readonly password: Schema.RedactedFromValue<Schema.String>;
|
|
14
|
-
}>, Schema.Struct<{
|
|
15
|
-
readonly type: Schema.Literal<"rds_iam">;
|
|
16
|
-
readonly region: Schema.String;
|
|
17
|
-
readonly awsAuth: Schema.Union<readonly [Schema.Struct<{
|
|
18
|
-
readonly type: Schema.Literal<"access_key">;
|
|
19
|
-
readonly accessKeyId: Schema.String;
|
|
20
|
-
readonly secretAccessKey: Schema.RedactedFromValue<Schema.String>;
|
|
21
|
-
readonly sessionToken: Schema.optionalKey<Schema.RedactedFromValue<Schema.String>>;
|
|
22
|
-
}>, Schema.Struct<{
|
|
23
|
-
readonly type: Schema.Literal<"assume_role">;
|
|
24
|
-
readonly roleArn: Schema.String;
|
|
25
|
-
readonly externalId: Schema.optionalKey<Schema.String>;
|
|
26
|
-
}>, Schema.Struct<{
|
|
27
|
-
readonly type: Schema.Literal<"ambient">;
|
|
28
|
-
}>]>;
|
|
29
|
-
}>, Schema.Struct<{
|
|
30
|
-
readonly type: Schema.Literal<"none">;
|
|
31
|
-
}>]>;
|
|
32
|
-
readonly sslmode: Schema.withDecodingDefaultKey<Schema.Literals<readonly ["disable", "require", "verify-ca", "verify-full"]>, never>;
|
|
33
|
-
readonly tls: Schema.optionalKey<Schema.Struct<{
|
|
34
|
-
readonly caCertificate: Schema.optionalKey<Schema.String>;
|
|
35
|
-
readonly clientCertificate: Schema.optionalKey<Schema.String>;
|
|
36
|
-
readonly clientKey: Schema.optionalKey<Schema.RedactedFromValue<Schema.String>>;
|
|
37
|
-
readonly clientKeyPassphrase: Schema.optionalKey<Schema.RedactedFromValue<Schema.String>>;
|
|
38
|
-
readonly serverName: Schema.optionalKey<Schema.String>;
|
|
39
|
-
}>>;
|
|
40
|
-
readonly sshTunnel: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
|
|
41
|
-
readonly options: Schema.optionalKey<Schema.String>;
|
|
42
|
-
}>;
|
|
43
|
-
export type PostgresqlResource = typeof PostgresqlResource.Type;
|
|
44
|
-
/** Where a pool reads its Resource: the runtime API in a workflow, fixed answers in tests. */
|
|
45
|
-
export interface ResourceSource {
|
|
46
|
-
readonly resolve: (key: string) => Effect.Effect<Schema.Json, ReadError | InvalidResourceError>;
|
|
47
|
-
/** The only read whose 404 means that no record answers the key. */
|
|
48
|
-
readonly inspect: (key: string) => Effect.Effect<Pick<InspectedResource, 'metadata'>, ReadError>;
|
|
49
|
-
/** Set only in builders (`TEMPER_DATABASE_TUNNEL=websocket`); never cache what it returns. */
|
|
50
|
-
readonly authorizeTunnel?: ((key: string) => Promise<{
|
|
51
|
-
readonly url: string;
|
|
52
|
-
readonly token: string;
|
|
53
|
-
}>) | undefined;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Inspects, then resolves the Resource and builds an unconnected pool. `ResourceNotFoundError` means only that no
|
|
57
|
-
* record answers the key. Warnings go through the caller's logger and secret masks, as do the password's masks.
|
|
58
|
-
*/
|
|
59
|
-
export declare const makeResourcePool: (key: string, source: ResourceSource) => Effect.Effect<pg.Pool, ReadError | InvalidResourceError>;
|
|
60
|
-
export declare const tunnelEnabled: (value: Option.Option<string>) => boolean;
|
|
61
|
-
/** Outlasts the pool's 10 s statement timeout, so a query in flight when the scope closes can still finish. */
|
|
62
|
-
export declare const POOL_END_TIMEOUT: Duration.Input;
|
|
63
|
-
/**
|
|
64
|
-
* Ends the pool, waiting at most `timeout`. pg-pool's `end()` waits for every checked-out client, so a leaked
|
|
65
|
-
* `pool.connect()` would otherwise hold its scope open; past the bound the release logs a warning and returns.
|
|
66
|
-
*/
|
|
67
|
-
export declare const endPool: (pool: {
|
|
68
|
-
readonly end: () => Promise<void>;
|
|
69
|
-
}, timeout?: Duration.Input) => Effect.Effect<void>;
|
|
70
|
-
//# sourceMappingURL=PostgreSqlPool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSqlPool.d.ts","sourceRoot":"","sources":["../src/PostgreSqlPool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAuB,MAAM,EAAE,MAAM,QAAQ,CAAC;AACpF,OAAO,EAAE,MAAM,IAAI,CAAC;AAKpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAK1E,2IAA2I;AAC3I,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqB7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAC;AAEhE,8FAA8F;AAC9F,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,oBAAoB,CAAC,CAAC;IAChG,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC;IACjG,8FAA8F;IAC9F,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,GAAG,SAAS,CAAC;CACrH;AAsED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QACtB,MAAM,UACH,cAAc,KACrB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,oBAAoB,CAqCtD,CAAC;AAEL,eAAO,MAAM,aAAa,UAAW,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,YAAwC,CAAC;AAEnG,+GAA+G;AAC/G,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,KAAoB,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,OAAO,SACZ;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,YAClC,QAAQ,CAAC,KAAK,KACtB,MAAM,CAAC,MAAM,CAAC,IAAI,CAUlB,CAAC"}
|
package/dist/PostgreSqlPool.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { Effect, Option, Predicate, Redacted, Schema } from 'effect';
|
|
2
|
-
import pg from 'pg';
|
|
3
|
-
import { AwsAuth, TlsSettings } from './HttpApiResource.js';
|
|
4
|
-
import { observePostgreSqlTimeouts } from './PostgreSqlTimeouts.js';
|
|
5
|
-
import { PostgreSqlTunnelStream } from './PostgreSqlTunnel.js';
|
|
6
|
-
import { registerSecrets } from './Redaction.js';
|
|
7
|
-
import { InvalidResourceError } from './ResourcesErrors.js';
|
|
8
|
-
const NonEmptyString = Schema.String.check(Schema.isMinLength(1));
|
|
9
|
-
const Secret = Schema.RedactedFromValue(Schema.String);
|
|
10
|
-
/** A `postgresql` record as `@ontemper/resources` reads it; `sslmode` carries libpq semantics, and `tls` the CA and client certificate. */
|
|
11
|
-
export const PostgresqlResource = Schema.Struct({
|
|
12
|
-
host: NonEmptyString,
|
|
13
|
-
port: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65_535 })).pipe(Schema.withDecodingDefaultKey(Effect.succeed(5432))),
|
|
14
|
-
dbname: NonEmptyString,
|
|
15
|
-
user: NonEmptyString,
|
|
16
|
-
// Closed: the type decides how the client signs in.
|
|
17
|
-
auth: Schema.Union([
|
|
18
|
-
Schema.Struct({ type: Schema.Literal('password'), password: Secret }),
|
|
19
|
-
Schema.Struct({ type: Schema.Literal('rds_iam'), region: NonEmptyString, awsAuth: AwsAuth }),
|
|
20
|
-
Schema.Struct({ type: Schema.Literal('none') }),
|
|
21
|
-
]),
|
|
22
|
-
// Closed: libpq's weaker `allow` and `prefer` would map to no TLS at all.
|
|
23
|
-
sslmode: Schema.Literals(['disable', 'require', 'verify-ca', 'verify-full']).pipe(Schema.withDecodingDefaultKey(Effect.succeed('verify-full'))),
|
|
24
|
-
tls: Schema.optionalKey(TlsSettings),
|
|
25
|
-
// Only its presence matters: this pool refuses a bastion tunnel.
|
|
26
|
-
sshTunnel: Schema.optionalKey(Schema.Record(Schema.String, Schema.Json)),
|
|
27
|
-
options: Schema.optionalKey(Schema.String),
|
|
28
|
-
});
|
|
29
|
-
const validate = Schema.toStandardSchemaV1(PostgresqlResource)['~standard'].validate;
|
|
30
|
-
// Names only the failing paths: a schema message can quote the value, which may be a secret.
|
|
31
|
-
const decode = (key, value) => Effect.suspend(() => {
|
|
32
|
-
const result = validate(value);
|
|
33
|
-
if (result instanceof Promise)
|
|
34
|
-
return Effect.die(new Error('PostgresqlResource decodes synchronously'));
|
|
35
|
-
if (result.issues === undefined)
|
|
36
|
-
return Effect.succeed(result.value);
|
|
37
|
-
const paths = result.issues.map((issue) => (issue.path ?? []).map((part) => String(Predicate.isObject(part) ? part.key : part)).join('.') || '(root)');
|
|
38
|
-
return Effect.fail(new InvalidResourceError({
|
|
39
|
-
target: `key ${key}`,
|
|
40
|
-
message: `Resource ${key} does not match the expected schema: invalid ${[...new Set(paths)].join(', ')}`,
|
|
41
|
-
}));
|
|
42
|
-
});
|
|
43
|
-
function sslConfig(resource) {
|
|
44
|
-
const { tls } = resource;
|
|
45
|
-
const clientCertificate = tls?.clientCertificate
|
|
46
|
-
? {
|
|
47
|
-
cert: tls.clientCertificate,
|
|
48
|
-
key: tls.clientKey === undefined ? undefined : Redacted.value(tls.clientKey),
|
|
49
|
-
passphrase: tls.clientKeyPassphrase === undefined ? undefined : Redacted.value(tls.clientKeyPassphrase),
|
|
50
|
-
}
|
|
51
|
-
: {};
|
|
52
|
-
switch (resource.sslmode) {
|
|
53
|
-
case 'disable':
|
|
54
|
-
return false;
|
|
55
|
-
case 'require':
|
|
56
|
-
return { rejectUnauthorized: false, ...clientCertificate };
|
|
57
|
-
case 'verify-ca':
|
|
58
|
-
return {
|
|
59
|
-
rejectUnauthorized: true,
|
|
60
|
-
ca: tls?.caCertificate,
|
|
61
|
-
...clientCertificate,
|
|
62
|
-
checkServerIdentity: () => undefined,
|
|
63
|
-
};
|
|
64
|
-
case 'verify-full':
|
|
65
|
-
return { rejectUnauthorized: true, ca: tls?.caCertificate, ...clientCertificate, servername: tls?.serverName };
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// RDS IAM needs a token signer and an SSH tunnel needs a bastion client; neither runs inside this pool.
|
|
69
|
-
const resourcePassword = (key, resource) => {
|
|
70
|
-
const refuse = (message) => Effect.fail(new InvalidResourceError({ target: `key ${key}`, message }));
|
|
71
|
-
if (resource.sshTunnel)
|
|
72
|
-
return refuse(`PostgreSQL Resource ${key} needs an SSH tunnel, which this SDK does not open.`);
|
|
73
|
-
if (resource.auth.type === 'rds_iam') {
|
|
74
|
-
return refuse(`PostgreSQL Resource ${key} uses RDS IAM authentication, which this SDK does not support.`);
|
|
75
|
-
}
|
|
76
|
-
return Effect.succeed(resource.auth.type === 'password' ? Redacted.value(resource.auth.password) : '');
|
|
77
|
-
};
|
|
78
|
-
const ManagedPlacement = Schema.Struct({ managedDatabasePlacementId: Schema.String });
|
|
79
|
-
const isManaged = Schema.is(ManagedPlacement);
|
|
80
|
-
// The runtime API answers a missing Variable reference with the same 404 as a missing record, so after a found
|
|
81
|
-
// `inspect` a resolve 404 names a broken record, never an absent one.
|
|
82
|
-
const brokenReference = (key) => new InvalidResourceError({
|
|
83
|
-
target: `key ${key}`,
|
|
84
|
-
message: `Resource ${key} exists, but a value it references, such as its password Variable, does not resolve in this environment.`,
|
|
85
|
-
});
|
|
86
|
-
/**
|
|
87
|
-
* Inspects, then resolves the Resource and builds an unconnected pool. `ResourceNotFoundError` means only that no
|
|
88
|
-
* record answers the key. Warnings go through the caller's logger and secret masks, as do the password's masks.
|
|
89
|
-
*/
|
|
90
|
-
export const makeResourcePool = (key, source) => Effect.gen(function* () {
|
|
91
|
-
const record = yield* source.inspect(key);
|
|
92
|
-
const resource = yield* source.resolve(key).pipe(Effect.catchTag('ResourceNotFoundError', () => Effect.fail(brokenReference(key))), Effect.flatMap((value) => decode(key, value)));
|
|
93
|
-
const password = yield* resourcePassword(key, resource);
|
|
94
|
-
yield* registerSecrets([password]);
|
|
95
|
-
const authorize = source.authorizeTunnel;
|
|
96
|
-
const managed = isManaged(record.metadata);
|
|
97
|
-
const context = yield* Effect.context();
|
|
98
|
-
const warn = (event, message, fields = {}) => {
|
|
99
|
-
Effect.runForkWith(context)(Effect.logWarning(message).pipe(Effect.annotateLogs({ event, ...fields })));
|
|
100
|
-
};
|
|
101
|
-
// Each physical connection reads current runtime authorization, including connections opened after token renewal.
|
|
102
|
-
const stream = managed && authorize ? () => new PostgreSqlTunnelStream(() => authorize(key)) : undefined;
|
|
103
|
-
// A callback prevents pg from substituting ambient PGPASSWORD/pgpass for an empty Resource password.
|
|
104
|
-
const pool = observePostgreSqlTimeouts(new pg.Pool({
|
|
105
|
-
stream,
|
|
106
|
-
host: resource.host,
|
|
107
|
-
port: resource.port,
|
|
108
|
-
user: resource.user,
|
|
109
|
-
password: () => password,
|
|
110
|
-
database: resource.dbname,
|
|
111
|
-
ssl: sslConfig(resource),
|
|
112
|
-
max: 5,
|
|
113
|
-
connectionTimeoutMillis: 10_000,
|
|
114
|
-
idleTimeoutMillis: 30_000,
|
|
115
|
-
statement_timeout: 10_000,
|
|
116
|
-
}), () => warn('temper.database.query.timeout', 'PostgreSQL statement timed out.', { code: '57014' }));
|
|
117
|
-
// The error and its attached client stay out of the line: both can carry server text and login details.
|
|
118
|
-
pool.on('error', () => warn('temper.database.connection.error', 'An idle PostgreSQL connection closed.'));
|
|
119
|
-
return pool;
|
|
120
|
-
});
|
|
121
|
-
export const tunnelEnabled = (value) => Option.contains(value, 'websocket');
|
|
122
|
-
/** Outlasts the pool's 10 s statement timeout, so a query in flight when the scope closes can still finish. */
|
|
123
|
-
export const POOL_END_TIMEOUT = '15 seconds';
|
|
124
|
-
/**
|
|
125
|
-
* Ends the pool, waiting at most `timeout`. pg-pool's `end()` waits for every checked-out client, so a leaked
|
|
126
|
-
* `pool.connect()` would otherwise hold its scope open; past the bound the release logs a warning and returns.
|
|
127
|
-
*/
|
|
128
|
-
export const endPool = (pool, timeout = POOL_END_TIMEOUT) => Effect.promise(() => pool.end().catch(() => undefined)).pipe(Effect.timeoutOption(timeout), Effect.flatMap((ended) => Option.isSome(ended)
|
|
129
|
-
? Effect.void
|
|
130
|
-
: Effect.logWarning('A PostgreSQL pool did not end in time: a client was not released.').pipe(Effect.annotateLogs({ event: 'temper.database.pool.end.timeout' }))));
|
|
131
|
-
//# sourceMappingURL=PostgreSqlPool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSqlPool.js","sourceRoot":"","sources":["../src/PostgreSqlPool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACpF,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAG5D,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,MAAM,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAEvD,2IAA2I;AAC3I,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAC5E,MAAM,CAAC,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CACpD;IACD,MAAM,EAAE,cAAc;IACtB,IAAI,EAAE,cAAc;IACpB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC;QACjB,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CAAC;AACd,CAAC,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAA4B,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAEnG,+GAA+G;AAC/G,MAAM,CAAC,MAAM,gBAAgB,GAAmB,YAAY,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,IAA2C,EAC3C,OAAO,GAAmB,gBAAgB,EACrB,EAAE,CACvB,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAC1D,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,EAC7B,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CACvB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;IAClB,CAAC,CAAC,MAAM,CAAC,IAAI;IACb,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,mEAAmE,CAAC,CAAC,IAAI,CACzF,MAAM,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,kCAAkC,EAAE,CAAC,CACnE,CACN,CACF,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import pg from 'pg';
|
|
2
|
-
/** Calls `report` once per statement timeout on any connection of the pool, without changing query results. */
|
|
3
|
-
export declare const observePostgreSqlTimeouts: (pool: pg.Pool, report: () => void) => pg.Pool;
|
|
4
|
-
//# sourceMappingURL=PostgreSqlTimeouts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSqlTimeouts.d.ts","sourceRoot":"","sources":["../src/PostgreSqlTimeouts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,+GAA+G;AAC/G,eAAO,MAAM,yBAAyB,SAAU,EAAE,CAAC,IAAI,UAAU,MAAM,IAAI,KAAG,EAAE,CAAC,IAWhF,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import pg from 'pg';
|
|
2
|
-
/** Calls `report` once per statement timeout on any connection of the pool, without changing query results. */
|
|
3
|
-
export const observePostgreSqlTimeouts = (pool, report) => {
|
|
4
|
-
pool.on('connect', (client) => {
|
|
5
|
-
if (!(client instanceof pg.Client) || !client.connection)
|
|
6
|
-
return;
|
|
7
|
-
// Wire errors cover pool, checked-out client, and callback queries without changing their return values.
|
|
8
|
-
client.connection.on('errorMessage', (error) => {
|
|
9
|
-
if (error instanceof pg.DatabaseError && error.code === '57014' && error.message.includes('statement timeout')) {
|
|
10
|
-
report();
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
return pool;
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=PostgreSqlTimeouts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSqlTimeouts.js","sourceRoot":"","sources":["../src/PostgreSqlTimeouts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,+GAA+G;AAC/G,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,IAAa,EAAE,MAAkB,EAAW,EAAE;IACtF,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE;QAC5B,IAAI,CAAC,CAAC,MAAM,YAAY,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU;YAAE,OAAO;QACjE,yGAAyG;QACzG,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,KAAY,EAAE,EAAE;YACpD,IAAI,KAAK,YAAY,EAAE,CAAC,aAAa,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;gBAC/G,MAAM,EAAE,CAAC;YACX,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Duplex } from 'node:stream';
|
|
2
|
-
/** Reads current runtime authorization; called once per physical connection, so a renewed token is used at once. */
|
|
3
|
-
export type TunnelAuthorization = () => Promise<{
|
|
4
|
-
readonly url: string;
|
|
5
|
-
readonly token: string;
|
|
6
|
-
}>;
|
|
7
|
-
/** A pg socket over the Resources-authenticated WebSocket tunnel; any failure ends the connection, never falls back to TCP. */
|
|
8
|
-
export declare class PostgreSqlTunnelStream extends Duplex {
|
|
9
|
-
private readonly authorize;
|
|
10
|
-
private transport;
|
|
11
|
-
private socket;
|
|
12
|
-
private referenced;
|
|
13
|
-
private closingCleanly;
|
|
14
|
-
constructor(authorize: TunnelAuthorization);
|
|
15
|
-
setNoDelay(): this;
|
|
16
|
-
setKeepAlive(): this;
|
|
17
|
-
ref(): this;
|
|
18
|
-
unref(): this;
|
|
19
|
-
connect(): this;
|
|
20
|
-
_read(): void;
|
|
21
|
-
_write(chunk: Buffer, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
22
|
-
_final(callback: (error?: Error | null) => void): void;
|
|
23
|
-
_destroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=PostgreSqlTunnel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSqlTunnel.d.ts","sourceRoot":"","sources":["../src/PostgreSqlTunnel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,oHAAoH;AACpH,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAIlG,+HAA+H;AAC/H,qBAAa,sBAAuB,SAAQ,MAAM;IAKpC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAJtC,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,cAAc,CAAS;IAC/B,YAA6B,SAAS,EAAE,mBAAmB,EAE1D;IACD,UAAU,SAET;IACD,YAAY,SAEX;IACD,GAAG,SAIF;IACD,KAAK,SAIJ;IACD,OAAO,SA6CN;IACQ,KAAK,SAEb;IACQ,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,QAYjG;IACQ,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,QAIvD;IACQ,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,QAG9E;CACF"}
|