@slonik/driver 46.1.0 → 46.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/factories/createDriverFactory.d.ts +53 -53
- package/dist/factories/createDriverFactory.d.ts.map +1 -1
- package/dist/factories/createDriverFactory.js +2 -3
- package/dist/factories/createDriverFactory.js.map +1 -1
- package/package.json +8 -8
- package/src/factories/createDriverFactory.ts +75 -75
|
@@ -3,52 +3,9 @@ import EventEmitter from 'node:events';
|
|
|
3
3
|
import { type Readable } from 'node:stream';
|
|
4
4
|
import { type ConnectionOptions as TlsConnectionOptions } from 'node:tls';
|
|
5
5
|
import { type StrictEventEmitter } from 'strict-event-emitter-types';
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
fields: readonly Field[];
|
|
9
|
-
};
|
|
10
|
-
export interface DriverStream<T> extends Readable {
|
|
11
|
-
on(event: 'data', listener: (chunk: StreamDataEvent<T>) => void): this;
|
|
12
|
-
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
13
|
-
[Symbol.asyncIterator]: () => AsyncIterableIterator<StreamDataEvent<T>>;
|
|
14
|
-
}
|
|
15
|
-
type BasicConnection = {
|
|
16
|
-
readonly query: (query: string) => Promise<void>;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* @property name Value of "pg_type"."typname" (e.g. "int8", "timestamp", "timestamptz").
|
|
20
|
-
*/
|
|
21
|
-
export type DriverTypeParser<T = unknown> = {
|
|
22
|
-
readonly name: string;
|
|
23
|
-
readonly parse: (value: string) => T;
|
|
24
|
-
};
|
|
25
|
-
export type DriverConfiguration = {
|
|
26
|
-
readonly connectionTimeout: number | 'DISABLE_TIMEOUT';
|
|
27
|
-
readonly connectionUri: string;
|
|
28
|
-
readonly gracefulTerminationTimeout?: number;
|
|
29
|
-
readonly idleInTransactionSessionTimeout: number | 'DISABLE_TIMEOUT';
|
|
30
|
-
readonly idleTimeout?: number | 'DISABLE_TIMEOUT';
|
|
31
|
-
readonly maximumPoolSize?: number;
|
|
32
|
-
readonly minimumPoolSize?: number;
|
|
33
|
-
readonly resetConnection?: (connection: BasicConnection) => Promise<void>;
|
|
34
|
-
readonly ssl?: TlsConnectionOptions;
|
|
35
|
-
readonly statementTimeout: number | 'DISABLE_TIMEOUT';
|
|
36
|
-
readonly typeParsers: readonly DriverTypeParser[];
|
|
37
|
-
};
|
|
38
|
-
export type DriverNotice = {
|
|
39
|
-
message: string;
|
|
6
|
+
export type Driver = {
|
|
7
|
+
createClient: () => Promise<DriverClient>;
|
|
40
8
|
};
|
|
41
|
-
export type DriverEventEmitter = StrictEventEmitter<EventEmitter, {
|
|
42
|
-
error: (error: Error) => void;
|
|
43
|
-
}>;
|
|
44
|
-
export type DriverClientEventEmitter = StrictEventEmitter<EventEmitter, {
|
|
45
|
-
acquire: () => void;
|
|
46
|
-
destroy: () => void;
|
|
47
|
-
error: (error: Error) => void;
|
|
48
|
-
notice: (event: DriverNotice) => void;
|
|
49
|
-
release: () => void;
|
|
50
|
-
}>;
|
|
51
|
-
export type DriverClientState = 'ACQUIRED' | 'DESTROYED' | 'IDLE' | 'PENDING_DESTROY' | 'PENDING_RELEASE';
|
|
52
9
|
export type DriverClient = {
|
|
53
10
|
acquire: () => void;
|
|
54
11
|
destroy: () => Promise<void>;
|
|
@@ -61,28 +18,67 @@ export type DriverClient = {
|
|
|
61
18
|
state: () => DriverClientState;
|
|
62
19
|
stream: (query: string, values?: unknown[]) => DriverStream<DriverStreamResult>;
|
|
63
20
|
};
|
|
64
|
-
export type
|
|
65
|
-
|
|
21
|
+
export type DriverClientEventEmitter = StrictEventEmitter<EventEmitter, {
|
|
22
|
+
acquire: () => void;
|
|
23
|
+
destroy: () => void;
|
|
24
|
+
error: (error: Error) => void;
|
|
25
|
+
notice: (event: DriverNotice) => void;
|
|
26
|
+
release: () => void;
|
|
27
|
+
}>;
|
|
28
|
+
export type DriverClientState = 'ACQUIRED' | 'DESTROYED' | 'IDLE' | 'PENDING_DESTROY' | 'PENDING_RELEASE';
|
|
29
|
+
export type DriverCommand = 'COPY' | 'DELETE' | 'INSERT' | 'SELECT' | 'UPDATE';
|
|
30
|
+
export type DriverConfiguration = {
|
|
31
|
+
readonly connectionTimeout: 'DISABLE_TIMEOUT' | number;
|
|
32
|
+
readonly connectionUri: string;
|
|
33
|
+
readonly gracefulTerminationTimeout?: number;
|
|
34
|
+
readonly idleInTransactionSessionTimeout: 'DISABLE_TIMEOUT' | number;
|
|
35
|
+
readonly idleTimeout?: 'DISABLE_TIMEOUT' | number;
|
|
36
|
+
readonly maximumPoolSize?: number;
|
|
37
|
+
readonly minimumPoolSize?: number;
|
|
38
|
+
readonly resetConnection?: (connection: BasicConnection) => Promise<void>;
|
|
39
|
+
readonly ssl?: TlsConnectionOptions;
|
|
40
|
+
readonly statementTimeout: 'DISABLE_TIMEOUT' | number;
|
|
41
|
+
readonly typeParsers: readonly DriverTypeParser[];
|
|
66
42
|
};
|
|
43
|
+
export type DriverEventEmitter = StrictEventEmitter<EventEmitter, {
|
|
44
|
+
error: (error: Error) => void;
|
|
45
|
+
}>;
|
|
67
46
|
export type DriverFactory = ({ driverConfiguration, }: {
|
|
68
47
|
driverConfiguration: DriverConfiguration;
|
|
69
48
|
}) => Promise<Driver>;
|
|
70
|
-
type
|
|
71
|
-
|
|
72
|
-
name: string;
|
|
49
|
+
export type DriverNotice = {
|
|
50
|
+
message: string;
|
|
73
51
|
};
|
|
74
|
-
export type DriverCommand = 'COPY' | 'DELETE' | 'INSERT' | 'SELECT' | 'UPDATE';
|
|
75
52
|
export type DriverQueryResult = {
|
|
76
53
|
readonly command: DriverCommand;
|
|
77
54
|
readonly fields: DriverField[];
|
|
78
|
-
readonly rowCount:
|
|
55
|
+
readonly rowCount: null | number;
|
|
79
56
|
readonly rows: Array<Record<string, unknown>>;
|
|
80
57
|
};
|
|
58
|
+
export interface DriverStream<T> extends Readable {
|
|
59
|
+
[Symbol.asyncIterator]: () => AsyncIterableIterator<StreamDataEvent<T>>;
|
|
60
|
+
on(event: 'data', listener: (chunk: StreamDataEvent<T>) => void): this;
|
|
61
|
+
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
62
|
+
}
|
|
81
63
|
export type DriverStreamResult = {
|
|
82
64
|
readonly fields: DriverField[];
|
|
83
65
|
readonly row: Record<string, unknown>;
|
|
84
66
|
};
|
|
85
|
-
|
|
67
|
+
/**
|
|
68
|
+
* @property name Value of "pg_type"."typname" (e.g. "int8", "timestamp", "timestamptz").
|
|
69
|
+
*/
|
|
70
|
+
export type DriverTypeParser<T = unknown> = {
|
|
71
|
+
readonly name: string;
|
|
72
|
+
readonly parse: (value: string) => T;
|
|
73
|
+
};
|
|
74
|
+
type BasicConnection = {
|
|
75
|
+
readonly query: (query: string) => Promise<void>;
|
|
76
|
+
};
|
|
77
|
+
type DriverField = {
|
|
78
|
+
dataTypeId: number;
|
|
79
|
+
name: string;
|
|
80
|
+
};
|
|
81
|
+
type DriverSetup = ({ driverConfiguration, driverEventEmitter, }: {
|
|
86
82
|
driverConfiguration: DriverConfiguration;
|
|
87
83
|
driverEventEmitter: DriverEventEmitter;
|
|
88
84
|
}) => Promise<InternalPoolClientFactory>;
|
|
@@ -102,6 +98,10 @@ type InternalPoolClientFactory = {
|
|
|
102
98
|
clientEventEmitter: DriverClientEventEmitter;
|
|
103
99
|
}) => Promise<InternalPoolClient>;
|
|
104
100
|
};
|
|
101
|
+
type StreamDataEvent<T> = {
|
|
102
|
+
data: T;
|
|
103
|
+
fields: readonly Field[];
|
|
104
|
+
};
|
|
105
105
|
export declare const createDriverFactory: (setup: DriverSetup) => DriverFactory;
|
|
106
106
|
export {};
|
|
107
107
|
//# sourceMappingURL=createDriverFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDriverFactory.d.ts","sourceRoot":"","sources":["../../src/factories/createDriverFactory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createDriverFactory.d.ts","sourceRoot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type-definitions */
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
5
|
};
|
|
@@ -36,7 +37,7 @@ const createDriverFactory = (setup) => {
|
|
|
36
37
|
}, 'unhandled driver client error');
|
|
37
38
|
};
|
|
38
39
|
clientEventEmitter.on('error', onError);
|
|
39
|
-
const {
|
|
40
|
+
const { connect, end, query, stream } = await createPoolClient({
|
|
40
41
|
clientEventEmitter,
|
|
41
42
|
});
|
|
42
43
|
let isAcquired = false;
|
|
@@ -125,7 +126,6 @@ const createDriverFactory = (setup) => {
|
|
|
125
126
|
idleTimeout = null;
|
|
126
127
|
}, driverConfiguration.idleTimeout).unref();
|
|
127
128
|
}
|
|
128
|
-
// eslint-disable-next-line require-atomic-updates
|
|
129
129
|
isAcquired = false;
|
|
130
130
|
releasePromise = null;
|
|
131
131
|
clientEventEmitter.emit('release');
|
|
@@ -190,7 +190,6 @@ const createDriverFactory = (setup) => {
|
|
|
190
190
|
return result;
|
|
191
191
|
}
|
|
192
192
|
finally {
|
|
193
|
-
// eslint-disable-next-line require-atomic-updates
|
|
194
193
|
activeQueryPromise = null;
|
|
195
194
|
}
|
|
196
195
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDriverFactory.js","sourceRoot":"","sources":["../../src/factories/createDriverFactory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createDriverFactory.js","sourceRoot":"","sources":["../../src/factories/createDriverFactory.ts"],"names":[],"mappings":";AAAA,mEAAmE;;;;;;AAEnE,sCAAmC;AAEnC,iDAAgD;AAChD,8DAAuC;AAEvC,mDAA2D;AAE3D,qDAAiD;AAkJ1C,MAAM,mBAAmB,GAAG,CAAC,KAAkB,EAAiB,EAAE;IACvE,OAAO,KAAK,EAAE,EAAE,mBAAmB,EAAE,EAAmB,EAAE;QACxD,MAAM,EAAE,eAAe,EAAE,GAAG,mBAAmB,CAAC;QAEh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,EAAE,CAAC;wBAE7B,IAAI,YAAY,KAAK,iBAAiB,EAAE,CAAC;4BACvC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;wBAChD,CAAC;wBAED,IAAI,YAAY,KAAK,iBAAiB,EAAE,CAAC;4BACvC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;wBAChD,CAAC;wBAED,IAAI,YAAY,KAAK,WAAW,EAAE,CAAC;4BACjC,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;wBAC1C,CAAC;wBAED,IAAI,YAAY,KAAK,UAAU,EAAE,CAAC;4BAChC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;wBAC7C,CAAC;wBAED,kGAAkG;wBAElG,OAAO,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;oBAC7B,CAAC;iBACF,CAAC;gBAEF,MAAM,OAAO,EAAE,CAAC;gBAEhB,OAAO,MAAM,CAAC;YAChB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AA5RW,QAAA,mBAAmB,uBA4R9B"}
|
package/package.json
CHANGED
|
@@ -16,22 +16,22 @@
|
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@slonik/types": "^46.
|
|
20
|
-
"@slonik/utilities": "^46.
|
|
19
|
+
"@slonik/types": "^46.3.0",
|
|
20
|
+
"@slonik/utilities": "^46.3.0",
|
|
21
21
|
"roarr": "^7.21.1",
|
|
22
22
|
"serialize-error": "^8.0.0",
|
|
23
23
|
"strict-event-emitter-types": "^2.0.0"
|
|
24
24
|
},
|
|
25
25
|
"description": "A Node.js PostgreSQL client with strict types, detailed logging and assertions.",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@types/node": "^
|
|
27
|
+
"@types/node": "^22.9.0",
|
|
28
28
|
"ava": "^6.1.3",
|
|
29
|
-
"cspell": "^8.
|
|
30
|
-
"eslint": "^
|
|
31
|
-
"eslint-config-canonical": "^42.8.1",
|
|
29
|
+
"cspell": "^8.16.0",
|
|
30
|
+
"eslint": "^9.16.0",
|
|
32
31
|
"nyc": "^15.1.0",
|
|
33
32
|
"ts-node": "^10.9.1",
|
|
34
|
-
"typescript": "^5.
|
|
33
|
+
"typescript": "^5.6.3",
|
|
34
|
+
"@slonik/eslint-config": "^46.3.0"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=18"
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"url": "https://github.com/gajus/slonik"
|
|
75
75
|
},
|
|
76
76
|
"types": "./dist/index.d.ts",
|
|
77
|
-
"version": "46.
|
|
77
|
+
"version": "46.3.0",
|
|
78
78
|
"scripts": {
|
|
79
79
|
"build": "rm -fr ./dist && tsc --project ./tsconfig.json",
|
|
80
80
|
"lint": "npm run lint:cspell && npm run lint:eslint && npm run lint:tsc",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/consistent-type-definitions */
|
|
2
|
+
|
|
1
3
|
import { Logger } from '../Logger';
|
|
2
4
|
import { type Field } from '@slonik/types';
|
|
3
5
|
import { generateUid } from '@slonik/utilities';
|
|
@@ -8,55 +10,26 @@ import { type ConnectionOptions as TlsConnectionOptions } from 'node:tls';
|
|
|
8
10
|
import { serializeError } from 'serialize-error';
|
|
9
11
|
import { type StrictEventEmitter } from 'strict-event-emitter-types';
|
|
10
12
|
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
14
|
-
export interface DriverStream<T> extends Readable {
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/method-signature-style
|
|
16
|
-
on(event: 'data', listener: (chunk: StreamDataEvent<T>) => void): this;
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/method-signature-style
|
|
18
|
-
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
19
|
-
|
|
20
|
-
[Symbol.asyncIterator]: () => AsyncIterableIterator<StreamDataEvent<T>>;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
type BasicConnection = {
|
|
24
|
-
readonly query: (query: string) => Promise<void>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @property name Value of "pg_type"."typname" (e.g. "int8", "timestamp", "timestamptz").
|
|
29
|
-
*/
|
|
30
|
-
export type DriverTypeParser<T = unknown> = {
|
|
31
|
-
readonly name: string;
|
|
32
|
-
readonly parse: (value: string) => T;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type DriverConfiguration = {
|
|
36
|
-
readonly connectionTimeout: number | 'DISABLE_TIMEOUT';
|
|
37
|
-
readonly connectionUri: string;
|
|
38
|
-
readonly gracefulTerminationTimeout?: number;
|
|
39
|
-
readonly idleInTransactionSessionTimeout: number | 'DISABLE_TIMEOUT';
|
|
40
|
-
readonly idleTimeout?: number | 'DISABLE_TIMEOUT';
|
|
41
|
-
readonly maximumPoolSize?: number;
|
|
42
|
-
readonly minimumPoolSize?: number;
|
|
43
|
-
readonly resetConnection?: (connection: BasicConnection) => Promise<void>;
|
|
44
|
-
readonly ssl?: TlsConnectionOptions;
|
|
45
|
-
readonly statementTimeout: number | 'DISABLE_TIMEOUT';
|
|
46
|
-
readonly typeParsers: readonly DriverTypeParser[];
|
|
13
|
+
export type Driver = {
|
|
14
|
+
createClient: () => Promise<DriverClient>;
|
|
47
15
|
};
|
|
48
16
|
|
|
49
|
-
export type
|
|
50
|
-
|
|
17
|
+
export type DriverClient = {
|
|
18
|
+
acquire: () => void;
|
|
19
|
+
destroy: () => Promise<void>;
|
|
20
|
+
id: () => string;
|
|
21
|
+
off: DriverClientEventEmitter['off'];
|
|
22
|
+
on: DriverClientEventEmitter['on'];
|
|
23
|
+
query: (query: string, values?: unknown[]) => Promise<DriverQueryResult>;
|
|
24
|
+
release: () => Promise<void>;
|
|
25
|
+
removeListener: DriverClientEventEmitter['removeListener'];
|
|
26
|
+
state: () => DriverClientState;
|
|
27
|
+
stream: (
|
|
28
|
+
query: string,
|
|
29
|
+
values?: unknown[],
|
|
30
|
+
) => DriverStream<DriverStreamResult>;
|
|
51
31
|
};
|
|
52
32
|
|
|
53
|
-
export type DriverEventEmitter = StrictEventEmitter<
|
|
54
|
-
EventEmitter,
|
|
55
|
-
{
|
|
56
|
-
error: (error: Error) => void;
|
|
57
|
-
}
|
|
58
|
-
>;
|
|
59
|
-
|
|
60
33
|
export type DriverClientEventEmitter = StrictEventEmitter<
|
|
61
34
|
EventEmitter,
|
|
62
35
|
{
|
|
@@ -75,54 +48,81 @@ export type DriverClientState =
|
|
|
75
48
|
| 'PENDING_DESTROY'
|
|
76
49
|
| 'PENDING_RELEASE';
|
|
77
50
|
|
|
78
|
-
export type
|
|
79
|
-
acquire: () => void;
|
|
80
|
-
destroy: () => Promise<void>;
|
|
81
|
-
id: () => string;
|
|
82
|
-
off: DriverClientEventEmitter['off'];
|
|
83
|
-
on: DriverClientEventEmitter['on'];
|
|
84
|
-
query: (query: string, values?: unknown[]) => Promise<DriverQueryResult>;
|
|
85
|
-
release: () => Promise<void>;
|
|
86
|
-
removeListener: DriverClientEventEmitter['removeListener'];
|
|
87
|
-
state: () => DriverClientState;
|
|
88
|
-
stream: (
|
|
89
|
-
query: string,
|
|
90
|
-
values?: unknown[],
|
|
91
|
-
) => DriverStream<DriverStreamResult>;
|
|
92
|
-
};
|
|
51
|
+
export type DriverCommand = 'COPY' | 'DELETE' | 'INSERT' | 'SELECT' | 'UPDATE';
|
|
93
52
|
|
|
94
|
-
export type
|
|
95
|
-
|
|
53
|
+
export type DriverConfiguration = {
|
|
54
|
+
readonly connectionTimeout: 'DISABLE_TIMEOUT' | number;
|
|
55
|
+
readonly connectionUri: string;
|
|
56
|
+
readonly gracefulTerminationTimeout?: number;
|
|
57
|
+
readonly idleInTransactionSessionTimeout: 'DISABLE_TIMEOUT' | number;
|
|
58
|
+
readonly idleTimeout?: 'DISABLE_TIMEOUT' | number;
|
|
59
|
+
readonly maximumPoolSize?: number;
|
|
60
|
+
readonly minimumPoolSize?: number;
|
|
61
|
+
readonly resetConnection?: (connection: BasicConnection) => Promise<void>;
|
|
62
|
+
readonly ssl?: TlsConnectionOptions;
|
|
63
|
+
readonly statementTimeout: 'DISABLE_TIMEOUT' | number;
|
|
64
|
+
readonly typeParsers: readonly DriverTypeParser[];
|
|
96
65
|
};
|
|
97
66
|
|
|
67
|
+
export type DriverEventEmitter = StrictEventEmitter<
|
|
68
|
+
EventEmitter,
|
|
69
|
+
{
|
|
70
|
+
error: (error: Error) => void;
|
|
71
|
+
}
|
|
72
|
+
>;
|
|
73
|
+
|
|
98
74
|
export type DriverFactory = ({
|
|
99
75
|
driverConfiguration,
|
|
100
76
|
}: {
|
|
101
77
|
driverConfiguration: DriverConfiguration;
|
|
102
78
|
}) => Promise<Driver>;
|
|
103
79
|
|
|
104
|
-
type
|
|
105
|
-
|
|
106
|
-
name: string;
|
|
80
|
+
export type DriverNotice = {
|
|
81
|
+
message: string;
|
|
107
82
|
};
|
|
108
83
|
|
|
109
|
-
export type DriverCommand = 'COPY' | 'DELETE' | 'INSERT' | 'SELECT' | 'UPDATE';
|
|
110
|
-
|
|
111
84
|
export type DriverQueryResult = {
|
|
112
85
|
readonly command: DriverCommand;
|
|
113
86
|
readonly fields: DriverField[];
|
|
114
|
-
readonly rowCount:
|
|
87
|
+
readonly rowCount: null | number;
|
|
115
88
|
readonly rows: Array<Record<string, unknown>>;
|
|
116
89
|
};
|
|
117
90
|
|
|
91
|
+
// @ts-expect-error - TODO figure out how to fix this
|
|
92
|
+
export interface DriverStream<T> extends Readable {
|
|
93
|
+
[Symbol.asyncIterator]: () => AsyncIterableIterator<StreamDataEvent<T>>;
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/method-signature-style
|
|
95
|
+
on(event: 'data', listener: (chunk: StreamDataEvent<T>) => void): this;
|
|
96
|
+
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/method-signature-style
|
|
98
|
+
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
99
|
+
}
|
|
100
|
+
|
|
118
101
|
export type DriverStreamResult = {
|
|
119
102
|
readonly fields: DriverField[];
|
|
120
103
|
readonly row: Record<string, unknown>;
|
|
121
104
|
};
|
|
122
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @property name Value of "pg_type"."typname" (e.g. "int8", "timestamp", "timestamptz").
|
|
108
|
+
*/
|
|
109
|
+
export type DriverTypeParser<T = unknown> = {
|
|
110
|
+
readonly name: string;
|
|
111
|
+
readonly parse: (value: string) => T;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
type BasicConnection = {
|
|
115
|
+
readonly query: (query: string) => Promise<void>;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
type DriverField = {
|
|
119
|
+
dataTypeId: number;
|
|
120
|
+
name: string;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
123
|
type DriverSetup = ({
|
|
124
|
-
driverEventEmitter,
|
|
125
124
|
driverConfiguration,
|
|
125
|
+
driverEventEmitter,
|
|
126
126
|
}: {
|
|
127
127
|
driverConfiguration: DriverConfiguration;
|
|
128
128
|
driverEventEmitter: DriverEventEmitter;
|
|
@@ -151,6 +151,8 @@ type InternalPoolClientFactory = {
|
|
|
151
151
|
}) => Promise<InternalPoolClient>;
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
+
type StreamDataEvent<T> = { data: T; fields: readonly Field[] };
|
|
155
|
+
|
|
154
156
|
export const createDriverFactory = (setup: DriverSetup): DriverFactory => {
|
|
155
157
|
return async ({ driverConfiguration }): Promise<Driver> => {
|
|
156
158
|
const { resetConnection } = driverConfiguration;
|
|
@@ -189,7 +191,7 @@ export const createDriverFactory = (setup: DriverSetup): DriverFactory => {
|
|
|
189
191
|
|
|
190
192
|
clientEventEmitter.on('error', onError);
|
|
191
193
|
|
|
192
|
-
const {
|
|
194
|
+
const { connect, end, query, stream } = await createPoolClient({
|
|
193
195
|
clientEventEmitter,
|
|
194
196
|
});
|
|
195
197
|
|
|
@@ -197,9 +199,9 @@ export const createDriverFactory = (setup: DriverSetup): DriverFactory => {
|
|
|
197
199
|
let isDestroyed = false;
|
|
198
200
|
let idleTimeout: NodeJS.Timeout | null = null;
|
|
199
201
|
|
|
200
|
-
let activeQueryPromise: Promise<DriverQueryResult>
|
|
201
|
-
let destroyPromise: Promise<void>
|
|
202
|
-
let releasePromise: Promise<void>
|
|
202
|
+
let activeQueryPromise: null | Promise<DriverQueryResult> = null;
|
|
203
|
+
let destroyPromise: null | Promise<void> = null;
|
|
204
|
+
let releasePromise: null | Promise<void> = null;
|
|
203
205
|
|
|
204
206
|
const id = generateUid();
|
|
205
207
|
|
|
@@ -311,7 +313,6 @@ export const createDriverFactory = (setup: DriverSetup): DriverFactory => {
|
|
|
311
313
|
}, driverConfiguration.idleTimeout).unref();
|
|
312
314
|
}
|
|
313
315
|
|
|
314
|
-
// eslint-disable-next-line require-atomic-updates
|
|
315
316
|
isAcquired = false;
|
|
316
317
|
|
|
317
318
|
releasePromise = null;
|
|
@@ -397,7 +398,6 @@ export const createDriverFactory = (setup: DriverSetup): DriverFactory => {
|
|
|
397
398
|
|
|
398
399
|
return result;
|
|
399
400
|
} finally {
|
|
400
|
-
// eslint-disable-next-line require-atomic-updates
|
|
401
401
|
activeQueryPromise = null;
|
|
402
402
|
}
|
|
403
403
|
},
|