@zyno-io/ts-server-foundation 26.927.2216 → 26.930.146
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/dist/src/database/drivers/postgres.d.ts +8 -1
- package/dist/src/database/drivers/postgres.d.ts.map +1 -1
- package/dist/src/database/drivers/postgres.js +34 -5
- package/dist/src/database/drivers/postgres.js.map +1 -1
- package/dist/src/di/container.js +1 -1
- package/dist/src/http/request.js +1 -1
- package/docs/content/database.md +19 -0
- package/package.json +2 -2
|
@@ -3,20 +3,27 @@ import type { DatabaseDriver, DriverConnection } from '../driver';
|
|
|
3
3
|
export interface PgPoolLike {
|
|
4
4
|
connect(): Promise<PgClientLike>;
|
|
5
5
|
end(): Promise<void>;
|
|
6
|
+
on?(event: 'error', listener: (error: Error) => void): unknown;
|
|
7
|
+
on?(event: 'connect', listener: (client: PgClientLike) => void): unknown;
|
|
6
8
|
}
|
|
7
9
|
export interface PgClientLike {
|
|
8
10
|
query<T = Record<string, unknown>>(text: string, values?: unknown[]): Promise<{
|
|
9
11
|
rows: T[];
|
|
10
12
|
rowCount: number | null;
|
|
11
13
|
}>;
|
|
12
|
-
release(): void;
|
|
14
|
+
release(error?: Error | boolean): void;
|
|
15
|
+
on?(event: 'error', listener: (error: Error) => void): unknown;
|
|
13
16
|
}
|
|
14
17
|
export declare class PostgresDriver implements DatabaseDriver {
|
|
15
18
|
readonly dialect: 'postgres';
|
|
16
19
|
private pool;
|
|
20
|
+
private logger;
|
|
21
|
+
private clientErrors;
|
|
17
22
|
constructor(configOrPool: PoolConfig | PgPoolLike);
|
|
18
23
|
connect(): Promise<void>;
|
|
19
24
|
close(): Promise<void>;
|
|
20
25
|
acquire(): Promise<DriverConnection>;
|
|
26
|
+
private watchClient;
|
|
27
|
+
private logConnectionError;
|
|
21
28
|
}
|
|
22
29
|
//# sourceMappingURL=postgres.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../../src/database/drivers/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../../src/database/drivers/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,IAAI,CAAC;AAItC,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAA8B,MAAM,WAAW,CAAC;AAG9F,MAAM,WAAW,UAAU;IACvB,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IACjC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC;IAC/D,EAAE,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC;CAC5E;AAED,MAAM,WAAW,YAAY;IACzB,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IACtH,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC;IACvC,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC;CAClE;AAED,qBAAa,cAAe,YAAW,cAAc;IACjD,QAAQ,CAAC,OAAO,EAAG,UAAU,CAAU;IACvC,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,YAAY,CAAkD;IAEtE,YAAY,YAAY,EAAE,UAAU,GAAG,UAAU,EAOhD;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAG7B;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAEK,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAGzC;IAED,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,kBAAkB;CAI7B"}
|
|
@@ -4,13 +4,21 @@ exports.__tsfTypeAliases = exports.PostgresDriver = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const _a = tslib_1.__importStar(require("@zyno-io/ts-reflection/type-metadata-runtime"));
|
|
6
6
|
const pg_1 = require("pg");
|
|
7
|
+
const logger_1 = require("../../services/logger");
|
|
7
8
|
const __tsf_metadata_type = _a.createCompactMetadataRegistryV2("[2,[{\"kind\":10,\"literal\":\"postgres\"},{\"kind\":22,\"type\":{\"kind\":3}},{\"kind\":22,\"type\":{\"kind\":18,\"typeName\":\"DriverConnection\",\"types\":[]}},{\"kind\":18,\"typeName\":\"RenderedSql\",\"types\":[{\"kind\":20,\"name\":\"sql\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"bindings\",\"type\":{\"kind\":14,\"type\":{\"kind\":2}},\"optional\":false}]},{\"kind\":22,\"type\":{\"kind\":18,\"typeName\":\"QueryResult\",\"types\":[{\"kind\":20,\"name\":\"rows\",\"type\":{\"kind\":14,\"type\":{\"kind\":2,\"typeName\":\"T\"}},\"optional\":false},{\"kind\":20,\"name\":\"executeResult\",\"type\":{\"kind\":12,\"types\":[{\"$tsfNode\":0},{\"kind\":4}]},\"optional\":true}]}},{\"kind\":22,\"type\":{\"$tsfNode\":0}},{\"kind\":6},{\"kind\":18,\"typeName\":\"PgClientLike\",\"types\":[]}],[{\"kind\":18,\"typeName\":\"ExecuteResult\",\"types\":{\"$tsfNode\":1}},[{\"$tsfNode\":2},{\"$tsfNode\":3},{\"$tsfNode\":4},{\"$tsfNode\":5}],{\"kind\":20,\"name\":\"affectedRows\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"insertId\",\"type\":{\"$tsfNode\":6},\"optional\":true},{\"kind\":20,\"name\":\"warningStatus\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"rowCount\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":6}]},{\"kind\":4}]}]]", []);
|
|
8
9
|
let _PostgresDriverMetadata_1;
|
|
9
10
|
class PostgresDriver {
|
|
10
11
|
dialect = 'postgres';
|
|
11
12
|
pool;
|
|
13
|
+
logger = (0, logger_1.createLogger)('PostgresDriver');
|
|
14
|
+
clientErrors = new WeakMap();
|
|
12
15
|
constructor(configOrPool) {
|
|
13
|
-
this.pool = isPgPoolLike(configOrPool)
|
|
16
|
+
this.pool = isPgPoolLike(configOrPool)
|
|
17
|
+
? configOrPool
|
|
18
|
+
: new pg_1.Pool({ ...configOrPool, connectionTimeoutMillis: configOrPool.connectionTimeoutMillis ?? 5000 });
|
|
19
|
+
// pg-pool removes failed idle clients before forwarding their errors.
|
|
20
|
+
this.pool.on?.('error', error => this.logConnectionError('pool', error));
|
|
21
|
+
this.pool.on?.('connect', client => this.watchClient(client));
|
|
14
22
|
}
|
|
15
23
|
async connect() {
|
|
16
24
|
const connection = await this.acquire();
|
|
@@ -20,7 +28,26 @@ class PostgresDriver {
|
|
|
20
28
|
await this.pool.end();
|
|
21
29
|
}
|
|
22
30
|
async acquire() {
|
|
23
|
-
|
|
31
|
+
const client = await this.pool.connect();
|
|
32
|
+
return new PostgresConnection(client, this.watchClient(client));
|
|
33
|
+
}
|
|
34
|
+
watchClient(client) {
|
|
35
|
+
let state = this.clientErrors.get(client);
|
|
36
|
+
if (!state) {
|
|
37
|
+
state = {};
|
|
38
|
+
this.clientErrors.set(client, state);
|
|
39
|
+
const clientState = state;
|
|
40
|
+
// Keep this listener while idle and between transaction queries.
|
|
41
|
+
client.on?.('error', error => {
|
|
42
|
+
clientState.error = error;
|
|
43
|
+
this.logConnectionError('client', error);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return state;
|
|
47
|
+
}
|
|
48
|
+
logConnectionError(source, error) {
|
|
49
|
+
// Pool errors can contain a client with credentials and query bindings.
|
|
50
|
+
this.logger.error('PostgreSQL connection error', { source, message: error.message });
|
|
24
51
|
}
|
|
25
52
|
static __tsfType = _PostgresDriverMetadata_1 = _a.decodeCompactMetadataV2("[2,{\"kind\":16,\"name\":\"PostgresDriver\",\"typeName\":\"PostgresDriver\",\"classType\":{\"$tsf\":0},\"properties\":[{\"name\":\"dialect\",\"type\":{\"$tsfType\":0},\"optional\":false}],\"methods\":[{\"name\":\"connect\",\"parameters\":[],\"returnType\":{\"$tsfType\":1}},{\"name\":\"close\",\"parameters\":[],\"returnType\":{\"$tsfType\":1}},{\"name\":\"acquire\",\"parameters\":[],\"returnType\":{\"$tsfType\":2}}],\"hasConstructor\":true,\"constructorParameters\":[{\"name\":\"configOrPool\",\"type\":{\"kind\":12,\"types\":[{\"$tsfAlias\":[1,\"pg\",\"PoolConfig\",\"PoolConfig\"]},{\"kind\":18,\"typeName\":\"PgPoolLike\",\"types\":[]}]},\"optional\":false,\"default\":false}]},[]]", [() => PostgresDriver, require], __tsf_metadata_type);
|
|
26
53
|
}
|
|
@@ -30,8 +57,10 @@ PostgresDriver.__tsfType = _PostgresDriverMetadata_1;
|
|
|
30
57
|
let _PostgresConnectionMetadata_1;
|
|
31
58
|
class PostgresConnection {
|
|
32
59
|
client;
|
|
33
|
-
|
|
60
|
+
state;
|
|
61
|
+
constructor(client, state) {
|
|
34
62
|
this.client = client;
|
|
63
|
+
this.state = state;
|
|
35
64
|
}
|
|
36
65
|
async query(query) {
|
|
37
66
|
const result = await this.client.query(query.sql, query.bindings);
|
|
@@ -60,9 +89,9 @@ class PostgresConnection {
|
|
|
60
89
|
await this.client.query(`ROLLBACK TO SAVEPOINT ${quoteSavepoint(name)}`);
|
|
61
90
|
}
|
|
62
91
|
async release() {
|
|
63
|
-
this.client.release();
|
|
92
|
+
this.client.release(this.state.error);
|
|
64
93
|
}
|
|
65
|
-
static __tsfType = _PostgresConnectionMetadata_1 = _a.decodeCompactMetadataV2("[2,{\"kind\":16,\"name\":\"PostgresConnection\",\"typeName\":\"PostgresConnection\",\"classType\":{\"$tsf\":0},\"properties\":[],\"methods\":[{\"name\":\"query\",\"parameters\":{\"$tsfNode\":0},\"returnType\":{\"$tsfType\":4}},{\"name\":\"execute\",\"parameters\":{\"$tsfNode\":0},\"returnType\":{\"$tsfType\":5}},{\"name\":\"begin\",\"parameters\":[],\"returnType\":{\"$tsfType\":1}},{\"name\":\"commit\",\"parameters\":[],\"returnType\":{\"$tsfType\":1}},{\"name\":\"rollback\",\"parameters\":[],\"returnType\":{\"$tsfType\":1}},{\"name\":\"savepoint\",\"parameters\":{\"$tsfNode\":1},\"returnType\":{\"$tsfType\":1}},{\"name\":\"rollbackToSavepoint\",\"parameters\":{\"$tsfNode\":1},\"returnType\":{\"$tsfType\":1}},{\"name\":\"release\",\"parameters\":[],\"returnType\":{\"$tsfType\":1}}],\"hasConstructor\":true,\"constructorParameters\":[{\"name\":\"client\",\"type\":{\"$tsfType\":7},\"optional\":false,\"default\":false}]},[[{\"$tsfNode\":2}],[{\"$tsfNode\":3}],{\"name\":\"query\",\"type\":{\"$tsfType\":3},\"optional\":false,\"default\":false},{\"name\":\"name\",\"type\":{\"$tsfType\":6},\"optional\":false,\"default\":false}]]", [() => PostgresConnection], __tsf_metadata_type);
|
|
94
|
+
static __tsfType = _PostgresConnectionMetadata_1 = _a.decodeCompactMetadataV2("[2,{\"kind\":16,\"name\":\"PostgresConnection\",\"typeName\":\"PostgresConnection\",\"classType\":{\"$tsf\":0},\"properties\":[],\"methods\":[{\"name\":\"query\",\"parameters\":{\"$tsfNode\":0},\"returnType\":{\"$tsfType\":4}},{\"name\":\"execute\",\"parameters\":{\"$tsfNode\":0},\"returnType\":{\"$tsfType\":5}},{\"name\":\"begin\",\"parameters\":[],\"returnType\":{\"$tsfType\":1}},{\"name\":\"commit\",\"parameters\":[],\"returnType\":{\"$tsfType\":1}},{\"name\":\"rollback\",\"parameters\":[],\"returnType\":{\"$tsfType\":1}},{\"name\":\"savepoint\",\"parameters\":{\"$tsfNode\":1},\"returnType\":{\"$tsfType\":1}},{\"name\":\"rollbackToSavepoint\",\"parameters\":{\"$tsfNode\":1},\"returnType\":{\"$tsfType\":1}},{\"name\":\"release\",\"parameters\":[],\"returnType\":{\"$tsfType\":1}}],\"hasConstructor\":true,\"constructorParameters\":[{\"name\":\"client\",\"type\":{\"$tsfType\":7},\"optional\":false,\"default\":false},{\"name\":\"state\",\"type\":{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"error\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"Error\",\"classType\":{\"$tsf\":1}},{\"kind\":4}]},\"optional\":true}]},\"optional\":false,\"default\":false}]},[[{\"$tsfNode\":2}],[{\"$tsfNode\":3}],{\"name\":\"query\",\"type\":{\"$tsfType\":3},\"optional\":false,\"default\":false},{\"name\":\"name\",\"type\":{\"$tsfType\":6},\"optional\":false,\"default\":false}]]", [() => PostgresConnection, () => (typeof Error !== "undefined" ? Error : (typeof exports !== "undefined" ? exports.Error : undefined))], __tsf_metadata_type);
|
|
66
95
|
}
|
|
67
96
|
_PostgresConnectionMetadata_1.classType = PostgresConnection;
|
|
68
97
|
PostgresConnection.__tsfType = _PostgresConnectionMetadata_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres.js","sourceRoot":"","sources":["../../../../src/database/drivers/postgres.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"postgres.js","sourceRoot":"","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,MAAM,CAAC,QAAQ,IAAI,CAAC;YAClC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,CAAC;SACjC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,KAAK;QACP,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,MAAM;QACR,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,QAAQ;QACV,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAY;QACxB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,IAAY;QAClC,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,OAAO;QACT,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;;CACJ;;;AAED,SAAS,YAAY,CAAC,KAA8B;IAChD,OAAO,OAAQ,KAAoB,CAAC,OAAO,KAAK,UAAU,IAAI,OAAQ,KAAoB,CAAC,GAAG,KAAK,UAAU,CAAC;AAClH,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAChC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;AAC3C,CAAC"}
|
package/dist/src/di/container.js
CHANGED
|
@@ -9,7 +9,7 @@ const types_1 = require("../types");
|
|
|
9
9
|
const errors_1 = require("./errors");
|
|
10
10
|
const provider_1 = require("./provider");
|
|
11
11
|
const module_1 = require("./module");
|
|
12
|
-
const __tsf_metadata_type = _a.createCompactMetadataRegistryV2("[2,[{\"kind\":2,\"typeName\":\"Token\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"T\"}]},{\"kind\":2,\"typeName\":\"T\"},{\"kind\":2,\"typeName\":\"Token\"},{\"kind\":7},{\"kind\":8},{\"kind\":14,\"type\":{\"kind\":2,\"typeName\":\"Token\"}},{\"kind\":2},{\"kind\":2,\"typeName\":\"ClassType\"},{\"kind\":14,\"type\":{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"token\",\"type\":{\"kind\":2,\"typeName\":\"Token\"},\"optional\":false},{\"kind\":20,\"name\":\"provider\",\"type\":{\"kind\":2,\"typeName\":\"Provider\"},\"optional\":false},{\"kind\":20,\"name\":\"moduleId\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"exported\",\"type\":{\"kind\":8},\"optional\":false}]}},{\"kind\":18,\"typeName\":\"ModuleDefinition\",\"types\":[{\"kind\":20,\"name\":\"
|
|
12
|
+
const __tsf_metadata_type = _a.createCompactMetadataRegistryV2("[2,[{\"kind\":2,\"typeName\":\"Token\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"T\"}]},{\"kind\":2,\"typeName\":\"T\"},{\"kind\":2,\"typeName\":\"Token\"},{\"kind\":7},{\"kind\":8},{\"kind\":14,\"type\":{\"kind\":2,\"typeName\":\"Token\"}},{\"kind\":2},{\"kind\":2,\"typeName\":\"ClassType\"},{\"kind\":14,\"type\":{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"token\",\"type\":{\"kind\":2,\"typeName\":\"Token\"},\"optional\":false},{\"kind\":20,\"name\":\"provider\",\"type\":{\"kind\":2,\"typeName\":\"Provider\"},\"optional\":false},{\"kind\":20,\"name\":\"moduleId\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"exported\",\"type\":{\"kind\":8},\"optional\":false}]}},{\"kind\":18,\"typeName\":\"ModuleDefinition\",\"types\":[{\"$tsfNode\":0},{\"$tsfNode\":1},{\"kind\":20,\"name\":\"imports\",\"type\":{\"kind\":12,\"types\":[{\"kind\":14,\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"ModuleDefinition\",\"types\":[{\"$tsfNode\":0},{\"$tsfNode\":1},{\"kind\":20,\"name\":\"imports\",\"type\":{\"kind\":12,\"types\":[{\"kind\":14,\"type\":{\"kind\":12,\"types\":[{\"kind\":2,\"typeName\":\"ModuleDefinition\"},{\"kind\":2,\"typeName\":\"ClassType\"},{\"kind\":18,\"typeName\":\"ModuleInstance\",\"types\":[{\"kind\":20,\"name\":\"definition\",\"type\":{\"kind\":2,\"typeName\":\"ModuleDefinition\"},\"optional\":false}]}],\"typeName\":\"ModuleLike\"}},{\"kind\":4}]},\"optional\":true},{\"$tsfNode\":2},{\"$tsfNode\":3},{\"$tsfNode\":4},{\"$tsfNode\":5},{\"$tsfNode\":6}],\"typeParameters\":[\"C\"]},{\"kind\":2,\"typeName\":\"ClassType\"},{\"kind\":18,\"typeName\":\"ModuleInstance\",\"types\":[{\"kind\":20,\"name\":\"definition\",\"type\":{\"kind\":18,\"typeName\":\"ModuleDefinition\",\"types\":[{\"$tsfNode\":0},{\"$tsfNode\":1},{\"kind\":20,\"name\":\"imports\",\"type\":{\"kind\":12,\"types\":[{\"kind\":14,\"type\":{\"kind\":12,\"types\":[{\"kind\":2,\"typeName\":\"ModuleDefinition\"},{\"kind\":2,\"typeName\":\"ClassType\"},{\"kind\":2,\"typeName\":\"ModuleInstance\"}],\"typeName\":\"ModuleLike\"}},{\"kind\":4}]},\"optional\":true},{\"$tsfNode\":2},{\"$tsfNode\":3},{\"$tsfNode\":4},{\"$tsfNode\":5},{\"$tsfNode\":6}],\"typeParameters\":[\"C\"]},\"optional\":false}]}],\"typeName\":\"ModuleLike\"}},{\"kind\":4}]},\"optional\":true},{\"$tsfNode\":2},{\"$tsfNode\":3},{\"$tsfNode\":4},{\"$tsfNode\":5},{\"$tsfNode\":6}],\"typeParameters\":[\"C\"]}],[{\"kind\":20,\"name\":\"config\",\"type\":{\"$tsfNode\":7},\"optional\":true},{\"kind\":20,\"name\":\"defaultConfig\",\"type\":{\"$tsfNode\":8},\"optional\":true},{\"kind\":20,\"name\":\"exports\",\"type\":{\"$tsfNode\":9},\"optional\":true},{\"kind\":20,\"name\":\"providers\",\"type\":{\"$tsfNode\":10},\"optional\":true},{\"kind\":20,\"name\":\"controllers\",\"type\":{\"$tsfNode\":11},\"optional\":true},{\"kind\":20,\"name\":\"listeners\",\"type\":{\"$tsfNode\":11},\"optional\":true},{\"kind\":20,\"name\":\"commands\",\"type\":{\"$tsfNode\":11},\"optional\":true},{\"kind\":12,\"types\":{\"$tsfNode\":12}},{\"kind\":12,\"types\":{\"$tsfNode\":13}},{\"kind\":12,\"types\":{\"$tsfNode\":14}},{\"kind\":12,\"types\":{\"$tsfNode\":15}},{\"kind\":12,\"types\":{\"$tsfNode\":16}},[{\"$tsfNode\":17},{\"kind\":4}],[{\"$tsfNode\":18},{\"kind\":4}],[{\"kind\":14,\"type\":{\"kind\":2,\"typeName\":\"Token\"}},{\"kind\":4}],[{\"kind\":14,\"type\":{\"kind\":2,\"typeName\":\"Provider\"}},{\"kind\":4}],[{\"kind\":14,\"type\":{\"kind\":2,\"typeName\":\"ClassType\"}},{\"kind\":4}],{\"kind\":2,\"typeName\":\"ClassType\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"C\"}]},{\"kind\":18,\"typeName\":\"Partial\",\"utilityType\":\"Partial\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"C\"}],\"utilityKeys\":[],\"types\":[]}]]", []);
|
|
13
13
|
let _ContainerMetadata_1;
|
|
14
14
|
class Container {
|
|
15
15
|
modules = [];
|
package/dist/src/http/request.js
CHANGED
|
@@ -8,7 +8,7 @@ const node_zlib_1 = require("node:zlib");
|
|
|
8
8
|
const errors_1 = require("./errors");
|
|
9
9
|
const form_body_1 = require("./form-body");
|
|
10
10
|
const headers_1 = require("./headers");
|
|
11
|
-
const __tsf_metadata_type = _a.createCompactMetadataRegistryV2("[2,[{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":2,\"typeName\":\"symbol\"}]},{\"kind\":2}],\"index\":{\"kind\":2},\"types\":[]},{\"$tsfNode\":0},{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":6},{\"$tsfNode\":1}],\"index\":{\"$tsfNode\":1},\"types\":[]},{\"kind\":6},{\"kind\":13,\"types\":[{\"$tsfNode\":0},{\"kind\":2,\"typeName\":\"(headers: HttpHeaderInput) =\\u003e HttpRequest\"}],\"typeName\":\"HttpRequestHeaders\"},{\"kind\":2},{\"kind\":8},{\"$tsfNode\":2},{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":8}]},{\"kind\":17},{\"kind\":22,\"type\":{\"kind\":6}},{\"kind\":18,\"typeName\":\"Partial\",\"utilityType\":\"Partial\",\"typeArguments\":[{\"$tsfNode\":2}],\"utilityKeys\":[],\"types\":[{\"kind\":20,\"name\":\"maxFormFields\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxFormFieldNameLength\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxFormDepth\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxFormArrayIndex\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxBodyBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxCompressedBodyBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true}]},{\"kind\":3},{\"kind\":7},{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"GET\"},{\"kind\":10,\"literal\":\"POST\"},{\"kind\":10,\"literal\":\"PUT\"},{\"kind\":10,\"literal\":\"PATCH\"},{\"kind\":10,\"literal\":\"DELETE\"},{\"kind\":10,\"literal\":\"OPTIONS\"},{\"kind\":10,\"literal\":\"HEAD\"}],\"typeName\":\"KnownHttpMethod\"},{\"kind\":13,\"types\":[{\"kind\":6},{\"kind\":18,\"types\":[]}]}],\"typeName\":\"HttpMethod\"},{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":6},{\"$tsfNode\":3}],\"index\":{\"$tsfNode\":3},\"types\":[],\"typeName\":\"HttpHeaderInput\"},{\"kind\":2,\"typeName\":\"(error?: Error | null, data?: Buffer) =\\u003e void\"},{\"kind\":2,\"typeName\":\"(chunk: Buffer) =\\u003e void\"}],[{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":6},{\"kind\":6}],\"index\":{\"kind\":6},\"types\":[]},{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":14,\"type\":{\"kind\":6}}]},{\"kind\":18,\"typeName\":\"HttpRequestBodyLimits\",\"types\":{\"$tsfNode\":4}},{\"kind\":12,\"types\":{\"$tsfNode\":5}},[{\"$tsfNode\":6},{\"$tsfNode\":7},{\"$tsfNode\":8},{\"$tsfNode\":9},{\"$tsfNode\":10},{\"$tsfNode\":11}],[{\"kind\":6},{\"kind\":
|
|
11
|
+
const __tsf_metadata_type = _a.createCompactMetadataRegistryV2("[2,[{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":2,\"typeName\":\"symbol\"}]},{\"kind\":2}],\"index\":{\"kind\":2},\"types\":[]},{\"$tsfNode\":0},{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":6},{\"$tsfNode\":1}],\"index\":{\"$tsfNode\":1},\"types\":[]},{\"kind\":6},{\"kind\":13,\"types\":[{\"$tsfNode\":0},{\"kind\":2,\"typeName\":\"(headers: HttpHeaderInput) =\\u003e HttpRequest\"}],\"typeName\":\"HttpRequestHeaders\"},{\"kind\":2},{\"kind\":8},{\"$tsfNode\":2},{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":8}]},{\"kind\":17},{\"kind\":22,\"type\":{\"kind\":6}},{\"kind\":18,\"typeName\":\"Partial\",\"utilityType\":\"Partial\",\"typeArguments\":[{\"$tsfNode\":2}],\"utilityKeys\":[],\"types\":[{\"kind\":20,\"name\":\"maxFormFields\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxFormFieldNameLength\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxFormDepth\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxFormArrayIndex\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxBodyBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxCompressedBodyBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true}]},{\"kind\":3},{\"kind\":7},{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"GET\"},{\"kind\":10,\"literal\":\"POST\"},{\"kind\":10,\"literal\":\"PUT\"},{\"kind\":10,\"literal\":\"PATCH\"},{\"kind\":10,\"literal\":\"DELETE\"},{\"kind\":10,\"literal\":\"OPTIONS\"},{\"kind\":10,\"literal\":\"HEAD\"}],\"typeName\":\"KnownHttpMethod\"},{\"kind\":13,\"types\":[{\"kind\":6},{\"kind\":18,\"types\":[]}]}],\"typeName\":\"HttpMethod\"},{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":6},{\"$tsfNode\":3}],\"index\":{\"$tsfNode\":3},\"types\":[],\"typeName\":\"HttpHeaderInput\"},{\"kind\":2,\"typeName\":\"(error?: Error | null, data?: Buffer) =\\u003e void\"},{\"kind\":2,\"typeName\":\"(chunk: Buffer) =\\u003e void\"}],[{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":6},{\"kind\":6}],\"index\":{\"kind\":6},\"types\":[]},{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":14,\"type\":{\"kind\":6}}]},{\"kind\":18,\"typeName\":\"HttpRequestBodyLimits\",\"types\":{\"$tsfNode\":4}},{\"kind\":12,\"types\":{\"$tsfNode\":5}},[{\"$tsfNode\":6},{\"$tsfNode\":7},{\"$tsfNode\":8},{\"$tsfNode\":9},{\"$tsfNode\":10},{\"$tsfNode\":11}],[{\"kind\":6},{\"kind\":7},{\"kind\":8},{\"kind\":14,\"type\":{\"kind\":6}},{\"kind\":4}],{\"kind\":20,\"name\":\"maxFormFields\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"maxFormFieldNameLength\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"maxFormDepth\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"maxFormArrayIndex\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"maxBodyBytes\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"maxCompressedBodyBytes\",\"type\":{\"kind\":7},\"optional\":false}]]", []);
|
|
12
12
|
exports.defaultHttpRequestBodyLimits = {
|
|
13
13
|
maxBodyBytes: 100 * 1024 * 1024,
|
|
14
14
|
maxCompressedBodyBytes: 25 * 1024 * 1024,
|
package/docs/content/database.md
CHANGED
|
@@ -546,3 +546,22 @@ const stop = registerDatabaseQueryObserver(entry => {
|
|
|
546
546
|
```
|
|
547
547
|
|
|
548
548
|
Observers receive start/finish events with SQL, bindings, dialect, operation, timing, and errors.
|
|
549
|
+
|
|
550
|
+
## PostgreSQL connection recovery
|
|
551
|
+
|
|
552
|
+
PostgreSQL pools created by the driver default `connectionTimeoutMillis` to 5000
|
|
553
|
+
(5 seconds). Set this standard pg option in `createPostgresDatabase` or
|
|
554
|
+
`PostgresDriver` configuration to override it; explicit `0` disables the timeout.
|
|
555
|
+
Injected pools retain their own timeout configuration.
|
|
556
|
+
|
|
557
|
+
The driver logs pool and client connection errors through the `PostgresDriver`
|
|
558
|
+
logger, including only the source and error message. Failed idle clients are
|
|
559
|
+
evicted by pg-pool; failed checked-out clients are destroyed when released.
|
|
560
|
+
Always release acquired connections, including after query or transaction errors.
|
|
561
|
+
Later acquisitions open fresh connections. Failed queries and transactions reject
|
|
562
|
+
and are never automatically replayed, because a disconnected write may already
|
|
563
|
+
have committed.
|
|
564
|
+
|
|
565
|
+
Custom `PgPoolLike` and `PgClientLike` implementations remain supported without
|
|
566
|
+
event methods. To support disconnect recovery they should provide the optional
|
|
567
|
+
`on` methods and honor `client.release(error)` by destroying failed clients.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyno-io/ts-server-foundation",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.930.146",
|
|
4
4
|
"description": "TypeScript server foundation with reflected type metadata",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@ttsc/graph": "^0.30.1",
|
|
93
93
|
"@types/ws": "^8.18.1",
|
|
94
94
|
"@zyno-io/config": "^1.14.0",
|
|
95
|
-
"@zyno-io/ts-reflection": "26.
|
|
95
|
+
"@zyno-io/ts-reflection": "26.930.146",
|
|
96
96
|
"bcrypt": "^6.0.0",
|
|
97
97
|
"bullmq": "^6.3.4",
|
|
98
98
|
"busboy": "^1.6.0",
|