1
1
import {
2
2
InMemorySQLiteDatabase ,
3
+ sqliteClientProvider ,
3
4
sqliteConnection ,
4
5
type SQLiteClient ,
5
6
type SQLiteClientConnection ,
6
7
type SQLiteConnectorType ,
7
8
type SQLitePoolClientConnection ,
8
9
} from '..' ;
9
- import { sqliteClientProvider } from '../..' ;
10
10
import {
11
11
createConnectionPool ,
12
12
JSONSerializer ,
13
13
type ConnectionPool ,
14
14
} from '../../../../core' ;
15
15
16
- export type SQLiteAmbientClientPool = ConnectionPool < SQLiteClientConnection > ;
16
+ export type SQLiteAmbientClientPool <
17
+ ConnectorType extends SQLiteConnectorType = SQLiteConnectorType ,
18
+ > = ConnectionPool < SQLiteClientConnection < ConnectorType > > ;
17
19
18
- export type SQLiteAmbientConnectionPool = ConnectionPool <
19
- SQLitePoolClientConnection | SQLiteClientConnection
20
+ export type SQLiteAmbientConnectionPool <
21
+ ConnectorType extends SQLiteConnectorType = SQLiteConnectorType ,
22
+ > = ConnectionPool <
23
+ | SQLitePoolClientConnection < ConnectorType >
24
+ | SQLiteClientConnection < ConnectorType >
20
25
> ;
21
26
22
- export type SQLitePool = SQLiteAmbientClientPool | SQLiteAmbientConnectionPool ;
27
+ export type SQLitePool <
28
+ ConnectorType extends SQLiteConnectorType = SQLiteConnectorType ,
29
+ > =
30
+ | SQLiteAmbientClientPool < ConnectorType >
31
+ | SQLiteAmbientConnectionPool < ConnectorType > ;
23
32
24
33
// TODO: Add connection pool handling
25
34
@@ -30,7 +39,7 @@ export const sqliteAmbientConnectionPool = <
30
39
connection :
31
40
| SQLitePoolClientConnection < ConnectorType >
32
41
| SQLiteClientConnection < ConnectorType > ;
33
- } ) : SQLiteAmbientConnectionPool => {
42
+ } ) : SQLiteAmbientConnectionPool < ConnectorType > => {
34
43
const { connection, connector : connectorType } = options ;
35
44
36
45
return createConnectionPool ( {
@@ -48,7 +57,7 @@ export const sqliteSingletonClientPool = <
48
57
connector : ConnectorType ;
49
58
fileName : string ;
50
59
database ?: string | undefined ;
51
- } ) : SQLiteAmbientClientPool => {
60
+ } ) : SQLiteAmbientClientPool < ConnectorType > => {
52
61
const { connector, fileName } = options ;
53
62
let connection : SQLiteClientConnection | undefined = undefined ;
54
63
@@ -86,7 +95,7 @@ export const sqliteAlwaysNewClientPool = <
86
95
connector : ConnectorType ;
87
96
fileName : string ;
88
97
database ?: string | undefined ;
89
- } ) : SQLiteAmbientClientPool => {
98
+ } ) : SQLiteAmbientClientPool < ConnectorType > => {
90
99
const { connector, fileName } = options ;
91
100
92
101
return createConnectionPool ( {
@@ -111,7 +120,7 @@ export const sqliteAmbientClientPool = <
111
120
> ( options : {
112
121
connector : ConnectorType ;
113
122
client : SQLiteClient ;
114
- } ) : SQLiteAmbientClientPool => {
123
+ } ) : SQLiteAmbientClientPool < ConnectorType > => {
115
124
const { client, connector } = options ;
116
125
117
126
const getConnection = ( ) => {
@@ -182,12 +191,16 @@ export type SQLitePoolOptions<
182
191
183
192
export function sqlitePool <
184
193
ConnectorType extends SQLiteConnectorType = SQLiteConnectorType ,
185
- > ( options : SQLitePoolNotPooledOptions < ConnectorType > ) : SQLiteAmbientClientPool ;
194
+ > (
195
+ options : SQLitePoolNotPooledOptions < ConnectorType > ,
196
+ ) : SQLiteAmbientClientPool < ConnectorType > ;
186
197
export function sqlitePool <
187
198
ConnectorType extends SQLiteConnectorType = SQLiteConnectorType ,
188
199
> (
189
200
options : SQLitePoolOptions < ConnectorType > ,
190
- ) : SQLiteAmbientClientPool | SQLiteAmbientConnectionPool {
201
+ ) :
202
+ | SQLiteAmbientClientPool < ConnectorType >
203
+ | SQLiteAmbientConnectionPool < ConnectorType > {
191
204
const { fileName, connector } = options ;
192
205
193
206
// TODO: Handle dates and bigints
0 commit comments