@event-driven-io/dumbo 0.12.1 → 0.13.0-alpha.2

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.
Files changed (101) hide show
  1. package/dist/chunk-2FKOO7MT.js +1 -0
  2. package/dist/chunk-2FKOO7MT.js.map +1 -0
  3. package/dist/chunk-3AZXA4Q4.cjs +1 -0
  4. package/dist/chunk-3AZXA4Q4.cjs.map +1 -0
  5. package/dist/chunk-55X4XXTZ.cjs +40 -0
  6. package/dist/chunk-55X4XXTZ.cjs.map +1 -0
  7. package/dist/chunk-72RN47FR.cjs +36 -0
  8. package/dist/chunk-72RN47FR.cjs.map +1 -0
  9. package/dist/chunk-DY2FMM5O.cjs +1 -0
  10. package/dist/chunk-DY2FMM5O.cjs.map +1 -0
  11. package/dist/chunk-DYX7V3LM.cjs +1409 -0
  12. package/dist/chunk-DYX7V3LM.cjs.map +1 -0
  13. package/dist/chunk-IIFZU7RA.js +1409 -0
  14. package/dist/chunk-IIFZU7RA.js.map +1 -0
  15. package/dist/chunk-KIWDFZ4Q.js +69 -0
  16. package/dist/chunk-KIWDFZ4Q.js.map +1 -0
  17. package/dist/chunk-L52DDJVT.js +1 -0
  18. package/dist/chunk-L52DDJVT.js.map +1 -0
  19. package/dist/chunk-LKLJL6B2.cjs +1 -0
  20. package/dist/chunk-LKLJL6B2.cjs.map +1 -0
  21. package/dist/chunk-ML7B25UO.js +40 -0
  22. package/dist/chunk-ML7B25UO.js.map +1 -0
  23. package/dist/chunk-PXIJTLLG.cjs +34 -0
  24. package/dist/chunk-PXIJTLLG.cjs.map +1 -0
  25. package/dist/chunk-QD3XOIUK.js +34 -0
  26. package/dist/chunk-QD3XOIUK.js.map +1 -0
  27. package/dist/chunk-SYFQT5SJ.js +1 -0
  28. package/dist/chunk-SYFQT5SJ.js.map +1 -0
  29. package/dist/chunk-TXXOMO2S.cjs +69 -0
  30. package/dist/chunk-TXXOMO2S.cjs.map +1 -0
  31. package/dist/chunk-VWPQS5RN.js +147 -0
  32. package/dist/chunk-VWPQS5RN.js.map +1 -0
  33. package/dist/chunk-Y7ETN53Q.cjs +147 -0
  34. package/dist/chunk-Y7ETN53Q.cjs.map +1 -0
  35. package/dist/chunk-YJF6HCJO.js +36 -0
  36. package/dist/chunk-YJF6HCJO.js.map +1 -0
  37. package/dist/connection-OKCNNQLA.cjs +17 -0
  38. package/dist/connection-OKCNNQLA.cjs.map +1 -0
  39. package/dist/connection-QSWKG7CD.js +17 -0
  40. package/dist/connection-QSWKG7CD.js.map +1 -0
  41. package/dist/connection.int.spec-4JZ5IO52.js +279 -0
  42. package/dist/connection.int.spec-4JZ5IO52.js.map +1 -0
  43. package/dist/connection.int.spec-WSLCBNOR.cjs +279 -0
  44. package/dist/connection.int.spec-WSLCBNOR.cjs.map +1 -0
  45. package/dist/connections-3374TYPY.js +20 -0
  46. package/dist/connections-3374TYPY.js.map +1 -0
  47. package/dist/connections-DM3XBOND.js +18 -0
  48. package/dist/connections-DM3XBOND.js.map +1 -0
  49. package/dist/connections-KNAIUBC5.cjs +18 -0
  50. package/dist/connections-KNAIUBC5.cjs.map +1 -0
  51. package/dist/connections-ROCX4PBC.cjs +20 -0
  52. package/dist/connections-ROCX4PBC.cjs.map +1 -0
  53. package/dist/core-FB34A5DC.js +38 -0
  54. package/dist/core-FB34A5DC.js.map +1 -0
  55. package/dist/core-ROYOQ2PP.cjs +38 -0
  56. package/dist/core-ROYOQ2PP.cjs.map +1 -0
  57. package/dist/execute-DVHVB627.cjs +10 -0
  58. package/dist/execute-DVHVB627.cjs.map +1 -0
  59. package/dist/execute-HCURO5PS.cjs +11 -0
  60. package/dist/execute-HCURO5PS.cjs.map +1 -0
  61. package/dist/execute-NABA4WBO.js +10 -0
  62. package/dist/execute-NABA4WBO.js.map +1 -0
  63. package/dist/execute-TDYAV2AC.js +11 -0
  64. package/dist/execute-TDYAV2AC.js.map +1 -0
  65. package/dist/index-C0xy8dwZ.d.cts +183 -0
  66. package/dist/index-C0xy8dwZ.d.ts +183 -0
  67. package/dist/index.cjs +91 -1294
  68. package/dist/index.cjs.map +1 -1
  69. package/dist/index.d.cts +14 -169
  70. package/dist/index.d.ts +14 -169
  71. package/dist/index.js +92 -1295
  72. package/dist/index.js.map +1 -1
  73. package/dist/pg.cjs +79 -0
  74. package/dist/pg.cjs.map +1 -0
  75. package/dist/pg.d.cts +3 -0
  76. package/dist/pg.d.ts +3 -0
  77. package/dist/pg.js +79 -0
  78. package/dist/pg.js.map +1 -0
  79. package/dist/pool-4C3RXVW5.cjs +20 -0
  80. package/dist/pool-4C3RXVW5.cjs.map +1 -0
  81. package/dist/pool-72E2RZLT.js +20 -0
  82. package/dist/pool-72E2RZLT.js.map +1 -0
  83. package/dist/sqlite-6TQBKUQW.js +8 -0
  84. package/dist/sqlite-6TQBKUQW.js.map +1 -0
  85. package/dist/sqlite-V3G6SXM3.cjs +8 -0
  86. package/dist/sqlite-V3G6SXM3.cjs.map +1 -0
  87. package/dist/sqlite3-MGFULTOS.cjs +20 -0
  88. package/dist/sqlite3-MGFULTOS.cjs.map +1 -0
  89. package/dist/sqlite3-YRIOHH6U.js +20 -0
  90. package/dist/sqlite3-YRIOHH6U.js.map +1 -0
  91. package/dist/sqlite3.cjs +49 -0
  92. package/dist/sqlite3.cjs.map +1 -0
  93. package/dist/sqlite3.d.cts +125 -0
  94. package/dist/sqlite3.d.ts +125 -0
  95. package/dist/sqlite3.js +49 -0
  96. package/dist/sqlite3.js.map +1 -0
  97. package/dist/transactions-7RPMRDZJ.cjs +10 -0
  98. package/dist/transactions-7RPMRDZJ.cjs.map +1 -0
  99. package/dist/transactions-KIOZ2TLT.js +10 -0
  100. package/dist/transactions-KIOZ2TLT.js.map +1 -0
  101. package/package.json +43 -8
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,18 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-LKLJL6B2.cjs');
2
+
3
+
4
+
5
+
6
+ var _chunkTXXOMO2Scjs = require('./chunk-TXXOMO2S.cjs');
7
+ require('./chunk-Y7ETN53Q.cjs');
8
+ require('./chunk-72RN47FR.cjs');
9
+ require('./chunk-PXIJTLLG.cjs');
10
+ require('./chunk-3AZXA4Q4.cjs');
11
+ require('./chunk-55X4XXTZ.cjs');
12
+ require('./chunk-DYX7V3LM.cjs');
13
+
14
+
15
+
16
+
17
+ exports.SQLite3ConnectorType = _chunkTXXOMO2Scjs.SQLite3ConnectorType; exports.checkConnection = _chunkTXXOMO2Scjs.checkConnection; exports.sqlite3Client = _chunkTXXOMO2Scjs.sqlite3Client;
18
+ //# sourceMappingURL=connections-KNAIUBC5.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/connections-KNAIUBC5.cjs"],"names":[],"mappings":"AAAA,yGAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACF,4LAAC","file":"/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/connections-KNAIUBC5.cjs"}
@@ -0,0 +1,20 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+ var _chunkY7ETN53Qcjs = require('./chunk-Y7ETN53Q.cjs');
8
+ require('./chunk-72RN47FR.cjs');
9
+ require('./chunk-PXIJTLLG.cjs');
10
+ require('./chunk-3AZXA4Q4.cjs');
11
+ require('./chunk-55X4XXTZ.cjs');
12
+ require('./chunk-DYX7V3LM.cjs');
13
+
14
+
15
+
16
+
17
+
18
+
19
+ exports.InMemorySQLiteDatabase = _chunkY7ETN53Qcjs.InMemorySQLiteDatabase; exports.isSQLiteError = _chunkY7ETN53Qcjs.isSQLiteError; exports.sqliteClientConnection = _chunkY7ETN53Qcjs.sqliteClientConnection; exports.sqliteConnection = _chunkY7ETN53Qcjs.sqliteConnection; exports.sqlitePoolClientConnection = _chunkY7ETN53Qcjs.sqlitePoolClientConnection;
20
+ //# sourceMappingURL=connections-ROCX4PBC.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/connections-ROCX4PBC.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,gWAAC","file":"/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/connections-ROCX4PBC.cjs"}
@@ -0,0 +1,38 @@
1
+ import {
2
+ InMemorySQLiteDatabase,
3
+ isSQLiteError,
4
+ sqliteAlwaysNewClientPool,
5
+ sqliteAmbientClientPool,
6
+ sqliteAmbientConnectionPool,
7
+ sqliteClientConnection,
8
+ sqliteConnection,
9
+ sqlitePool,
10
+ sqlitePoolClientConnection,
11
+ sqliteSingletonClientPool
12
+ } from "./chunk-VWPQS5RN.js";
13
+ import "./chunk-YJF6HCJO.js";
14
+ import {
15
+ sqliteTransaction
16
+ } from "./chunk-QD3XOIUK.js";
17
+ import "./chunk-2FKOO7MT.js";
18
+ import {
19
+ sqliteExecute,
20
+ sqliteSQLExecutor
21
+ } from "./chunk-ML7B25UO.js";
22
+ import "./chunk-IIFZU7RA.js";
23
+ export {
24
+ InMemorySQLiteDatabase,
25
+ isSQLiteError,
26
+ sqliteAlwaysNewClientPool,
27
+ sqliteAmbientClientPool,
28
+ sqliteAmbientConnectionPool,
29
+ sqliteClientConnection,
30
+ sqliteConnection,
31
+ sqliteExecute,
32
+ sqlitePool,
33
+ sqlitePoolClientConnection,
34
+ sqliteSQLExecutor,
35
+ sqliteSingletonClientPool,
36
+ sqliteTransaction
37
+ };
38
+ //# sourceMappingURL=core-FB34A5DC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,38 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ var _chunkY7ETN53Qcjs = require('./chunk-Y7ETN53Q.cjs');
13
+ require('./chunk-72RN47FR.cjs');
14
+
15
+
16
+ var _chunkPXIJTLLGcjs = require('./chunk-PXIJTLLG.cjs');
17
+ require('./chunk-3AZXA4Q4.cjs');
18
+
19
+
20
+
21
+ var _chunk55X4XXTZcjs = require('./chunk-55X4XXTZ.cjs');
22
+ require('./chunk-DYX7V3LM.cjs');
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+ exports.InMemorySQLiteDatabase = _chunkY7ETN53Qcjs.InMemorySQLiteDatabase; exports.isSQLiteError = _chunkY7ETN53Qcjs.isSQLiteError; exports.sqliteAlwaysNewClientPool = _chunkY7ETN53Qcjs.sqliteAlwaysNewClientPool; exports.sqliteAmbientClientPool = _chunkY7ETN53Qcjs.sqliteAmbientClientPool; exports.sqliteAmbientConnectionPool = _chunkY7ETN53Qcjs.sqliteAmbientConnectionPool; exports.sqliteClientConnection = _chunkY7ETN53Qcjs.sqliteClientConnection; exports.sqliteConnection = _chunkY7ETN53Qcjs.sqliteConnection; exports.sqliteExecute = _chunk55X4XXTZcjs.sqliteExecute; exports.sqlitePool = _chunkY7ETN53Qcjs.sqlitePool; exports.sqlitePoolClientConnection = _chunkY7ETN53Qcjs.sqlitePoolClientConnection; exports.sqliteSQLExecutor = _chunk55X4XXTZcjs.sqliteSQLExecutor; exports.sqliteSingletonClientPool = _chunkY7ETN53Qcjs.sqliteSingletonClientPool; exports.sqliteTransaction = _chunkPXIJTLLGcjs.sqliteTransaction;
38
+ //# sourceMappingURL=core-ROYOQ2PP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/core-ROYOQ2PP.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,k5BAAC","file":"/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/core-ROYOQ2PP.cjs"}
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunk55X4XXTZcjs = require('./chunk-55X4XXTZ.cjs');
5
+ require('./chunk-DYX7V3LM.cjs');
6
+
7
+
8
+
9
+ exports.sqliteExecute = _chunk55X4XXTZcjs.sqliteExecute; exports.sqliteSQLExecutor = _chunk55X4XXTZcjs.sqliteSQLExecutor;
10
+ //# sourceMappingURL=execute-DVHVB627.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/execute-DVHVB627.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,yHAAC","file":"/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/execute-DVHVB627.cjs"}
@@ -0,0 +1,11 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-3AZXA4Q4.cjs');
2
+
3
+
4
+
5
+ var _chunk55X4XXTZcjs = require('./chunk-55X4XXTZ.cjs');
6
+ require('./chunk-DYX7V3LM.cjs');
7
+
8
+
9
+
10
+ exports.sqliteExecute = _chunk55X4XXTZcjs.sqliteExecute; exports.sqliteSQLExecutor = _chunk55X4XXTZcjs.sqliteSQLExecutor;
11
+ //# sourceMappingURL=execute-HCURO5PS.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/execute-HCURO5PS.cjs"],"names":[],"mappings":"AAAA,yGAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,yHAAC","file":"/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/execute-HCURO5PS.cjs"}
@@ -0,0 +1,10 @@
1
+ import {
2
+ sqliteExecute,
3
+ sqliteSQLExecutor
4
+ } from "./chunk-ML7B25UO.js";
5
+ import "./chunk-IIFZU7RA.js";
6
+ export {
7
+ sqliteExecute,
8
+ sqliteSQLExecutor
9
+ };
10
+ //# sourceMappingURL=execute-NABA4WBO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,11 @@
1
+ import "./chunk-2FKOO7MT.js";
2
+ import {
3
+ sqliteExecute,
4
+ sqliteSQLExecutor
5
+ } from "./chunk-ML7B25UO.js";
6
+ import "./chunk-IIFZU7RA.js";
7
+ export {
8
+ sqliteExecute,
9
+ sqliteSQLExecutor
10
+ };
11
+ //# sourceMappingURL=execute-TDYAV2AC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,183 @@
1
+ interface QueryResultRow {
2
+ [column: string]: any;
3
+ }
4
+ type QueryResult<Result extends QueryResultRow = QueryResultRow> = {
5
+ rowCount: number | null;
6
+ rows: Result[];
7
+ };
8
+
9
+ declare const sql: (sqlQuery: string, ...params: unknown[]) => SQL;
10
+ declare const rawSql: (sqlQuery: string) => SQL;
11
+ declare const isSQL: (literal: unknown) => literal is SQL;
12
+ declare const literal: (value: unknown) => {
13
+ type: string;
14
+ value: unknown;
15
+ };
16
+ declare const identifier: (value: string) => {
17
+ type: string;
18
+ value: string;
19
+ };
20
+ declare const plainString: (value: string) => {
21
+ type: string;
22
+ value: string;
23
+ };
24
+ type SQL = string & {
25
+ __brand: 'sql';
26
+ };
27
+ declare function SQL(strings: TemplateStringsArray, ...values: unknown[]): SQL;
28
+
29
+ type SQLQueryOptions = {
30
+ timeoutMs?: number;
31
+ };
32
+ type SQLCommandOptions = {
33
+ timeoutMs?: number;
34
+ };
35
+ interface DbSQLExecutor<ConnectorType extends string = string, DbClient = unknown> {
36
+ type: ConnectorType;
37
+ query<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sql: SQL, options?: SQLQueryOptions): Promise<QueryResult<Result>>;
38
+ batchQuery<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sqls: SQL[], options?: SQLQueryOptions): Promise<QueryResult<Result>[]>;
39
+ command<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sql: SQL, options?: SQLCommandOptions): Promise<QueryResult<Result>>;
40
+ batchCommand<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sqls: SQL[], options?: SQLCommandOptions): Promise<QueryResult<Result>[]>;
41
+ }
42
+ interface SQLExecutor {
43
+ query<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: SQLQueryOptions): Promise<QueryResult<Result>>;
44
+ batchQuery<Result extends QueryResultRow = QueryResultRow>(sqls: SQL[], options?: SQLQueryOptions): Promise<QueryResult<Result>[]>;
45
+ command<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: SQLCommandOptions): Promise<QueryResult<Result>>;
46
+ batchCommand<Result extends QueryResultRow = QueryResultRow>(sqls: SQL[], options?: SQLCommandOptions): Promise<QueryResult<Result>[]>;
47
+ }
48
+ interface WithSQLExecutor {
49
+ execute: SQLExecutor;
50
+ }
51
+ declare const sqlExecutor: <DbClient = unknown, DbExecutor extends DbSQLExecutor = DbSQLExecutor>(sqlExecutor: DbExecutor, options: {
52
+ connect: () => Promise<DbClient>;
53
+ close?: (client: DbClient, error?: unknown) => Promise<void>;
54
+ }) => SQLExecutor;
55
+ declare const sqlExecutorInNewConnection: <ConnectionType extends Connection>(options: {
56
+ connection: () => Promise<ConnectionType>;
57
+ }) => SQLExecutor;
58
+ declare const executeInNewDbClient: <DbClient = unknown, Result = unknown>(handle: (client: DbClient) => Promise<Result>, options: {
59
+ connect: () => Promise<DbClient>;
60
+ close?: (client: DbClient, error?: unknown) => Promise<void>;
61
+ }) => Promise<Result>;
62
+ declare const executeInNewConnection: <ConnectionType extends Connection, Result>(handle: (connection: ConnectionType) => Promise<Result>, options: {
63
+ connection: () => Promise<ConnectionType>;
64
+ }) => Promise<Result>;
65
+
66
+ interface DatabaseTransaction<ConnectorType extends string = string, DbClient = unknown> extends WithSQLExecutor {
67
+ type: ConnectorType;
68
+ connection: Connection<ConnectorType, DbClient>;
69
+ begin: () => Promise<void>;
70
+ commit: () => Promise<void>;
71
+ rollback: (error?: unknown) => Promise<void>;
72
+ }
73
+ interface DatabaseTransactionFactory<ConnectorType extends string = string, DbClient = unknown> {
74
+ transaction: () => DatabaseTransaction<ConnectorType, DbClient>;
75
+ withTransaction: <Result = never>(handle: (transaction: DatabaseTransaction<ConnectorType, DbClient>) => Promise<TransactionResult<Result> | Result>) => Promise<Result>;
76
+ }
77
+ type TransactionResult<Result> = {
78
+ success: boolean;
79
+ result: Result;
80
+ };
81
+ declare const executeInTransaction: <ConnectorType extends string = string, DbClient = unknown, Result = void>(transaction: DatabaseTransaction<ConnectorType, DbClient>, handle: (transaction: DatabaseTransaction<ConnectorType, DbClient>) => Promise<TransactionResult<Result> | Result>) => Promise<Result>;
82
+ declare const transactionFactoryWithDbClient: <ConnectorType extends string = string, DbClient = unknown>(connect: () => Promise<DbClient>, initTransaction: (client: Promise<DbClient>) => DatabaseTransaction<ConnectorType, DbClient>) => DatabaseTransactionFactory<ConnectorType, DbClient>;
83
+ declare const transactionFactoryWithNewConnection: <ConnectionType extends Connection = Connection>(connect: () => ConnectionType) => DatabaseTransactionFactory<ConnectionType["type"]>;
84
+
85
+ interface Connection<ConnectorType extends string = string, DbClient = unknown> extends WithSQLExecutor, DatabaseTransactionFactory<ConnectorType> {
86
+ type: ConnectorType;
87
+ open: () => Promise<DbClient>;
88
+ close: () => Promise<void>;
89
+ }
90
+ interface ConnectionFactory<ConnectionType extends Connection = Connection> {
91
+ connection: () => Promise<ConnectionType>;
92
+ withConnection: <Result = unknown>(handle: (connection: ConnectionType) => Promise<Result>) => Promise<Result>;
93
+ }
94
+ type CreateConnectionOptions<ConnectorType extends string = string, DbClient = unknown, ConnectionType extends Connection<ConnectorType, DbClient> = Connection<ConnectorType, DbClient>, Executor extends DbSQLExecutor = DbSQLExecutor> = {
95
+ type: ConnectorType;
96
+ connect: Promise<DbClient>;
97
+ close: (client: DbClient) => Promise<void>;
98
+ initTransaction: (connection: () => ConnectionType) => (client: Promise<DbClient>) => DatabaseTransaction<ConnectorType, DbClient>;
99
+ executor: () => Executor;
100
+ };
101
+ declare const createConnection: <ConnectorType extends string = string, DbClient = unknown, ConnectionType extends Connection<ConnectorType, DbClient> = Connection<ConnectorType, DbClient>, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateConnectionOptions<ConnectorType, DbClient, ConnectionType, Executor>) => ConnectionType;
102
+
103
+ interface ConnectionPool<ConnectionType extends Connection = Connection> extends WithSQLExecutor, ConnectionFactory<ConnectionType>, DatabaseTransactionFactory<ConnectionType['type']> {
104
+ type: ConnectionType['type'];
105
+ close: () => Promise<void>;
106
+ }
107
+ type ConnectionPoolFactory<ConnectionPoolType extends ConnectionPool = ConnectionPool, ConnectionPoolOptions = unknown> = (options: ConnectionPoolOptions) => ConnectionPoolType;
108
+ declare const createConnectionPool: <ConnectionType extends Connection, ConnectionPoolType extends ConnectionPool<ConnectionType>>(pool: Pick<ConnectionPool<ConnectionType>, "type"> & Partial<ConnectionPool<ConnectionType>> & {
109
+ getConnection: () => ConnectionType;
110
+ }) => ConnectionPoolType;
111
+
112
+ type DatabaseType = string;
113
+ type DatabaseDriverName = string;
114
+ type ConnectorTypeName<DatabaseTypeName extends DatabaseType = DatabaseType, DriverName extends DatabaseDriverName = DatabaseDriverName> = `${DatabaseTypeName}:${DriverName}`;
115
+ type ConnectorTypeParts<T extends DatabaseType = DatabaseType> = {
116
+ databaseType: T;
117
+ driverName: string;
118
+ };
119
+ /**
120
+ * Accepts a `databaseType` (e.g. PostgreSQL, SQLite) and a `driverName`
121
+ * (the library name, e.g. pg, sqlite3) and combines them to a singular
122
+ * `connectorType` which can be used in database handling.
123
+ */
124
+ declare function toConnectorType<T extends DatabaseType>(databaseType: T, driverName: string): ConnectorTypeName<T>;
125
+ /**
126
+ * Accepts a fully formatted `connectorType` and returns the broken down
127
+ * `databaseType` and `driverName`.
128
+ */
129
+ declare function fromConnectorType<T extends DatabaseType>(connectorType: ConnectorTypeName<T>): ConnectorTypeParts<T>;
130
+ /**
131
+ * Accepts a fully formatted `connectorType` and returns the `driverName`.
132
+ */
133
+ declare function getDriverName<T extends DatabaseType>(connectorType: ConnectorTypeName<T>): DatabaseDriverName;
134
+
135
+ type JSONSerializerOptions = {
136
+ disableBigIntSerialization?: boolean;
137
+ };
138
+ type JSONSerializeOptions = {
139
+ replacer?: JSONReplacer;
140
+ } & JSONSerializerOptions;
141
+ type JSONDeserializeOptions = {
142
+ reviver?: JSONReviver;
143
+ } & JSONSerializerOptions;
144
+ type JSONObjectCodecOptions<SerializeOptions = JSONSerializeOptions, DeserializeOptions = JSONDeserializeOptions> = {
145
+ serializer?: JSONSerializer<SerializeOptions, DeserializeOptions>;
146
+ } | {
147
+ serializerOptions?: JSONSerializerOptions;
148
+ };
149
+ declare const composeJSONReplacers: (...replacers: JSONReplacer[]) => JSONReplacer;
150
+ declare const composeJSONRevivers: (...revivers: JSONReviver[]) => JSONReviver;
151
+ type JSONReplacer = (this: any, key: string, value: any) => any;
152
+ declare const JSONReplacer: (opts?: JSONSerializeOptions) => JSONReplacer | undefined;
153
+ type JSONReviver = (this: any, key: string, value: any) => any;
154
+ declare const JSONReviver: (opts?: JSONDeserializeOptions) => JSONReviver | undefined;
155
+ declare const JSONReplacers: {
156
+ bigInt: JSONReplacer;
157
+ };
158
+ declare const JSONRevivers: {
159
+ bigInt: JSONReviver;
160
+ };
161
+ declare const jsonSerializer: (options?: JSONSerializerOptions) => JSONSerializer;
162
+ interface JSONSerializer<SerializeOptions = JSONSerializeOptions, DeserializeOptions = JSONDeserializeOptions> extends Serializer<string, SerializeOptions, DeserializeOptions> {
163
+ serialize<T>(object: T, options?: SerializeOptions): string;
164
+ deserialize<T>(payload: string, options?: DeserializeOptions): T;
165
+ }
166
+ declare const JSONSerializer: JSONSerializer<JSONSerializeOptions, JSONDeserializeOptions>;
167
+ declare const RawJSONSerializer: JSONSerializer<JSONSerializeOptions, JSONDeserializeOptions>;
168
+ interface JSONObjectCodec<T, SerializeOptions = JSONSerializeOptions, DeserializeOptions = JSONDeserializeOptions> extends ObjectCodec<T, string> {
169
+ encode(object: T, options?: SerializeOptions): string;
170
+ decode(payload: string, options?: DeserializeOptions): T;
171
+ }
172
+ declare const JSONObjectCodec: <T, SerializeOptions = JSONSerializeOptions, DeserializeOptions = JSONDeserializeOptions>(options: JSONObjectCodecOptions<SerializeOptions, DeserializeOptions>) => JSONObjectCodec<T, SerializeOptions, DeserializeOptions>;
173
+
174
+ interface Serializer<Payload, SerializeOptions = never, DeserializeOptions = SerializeOptions> {
175
+ serialize<T>(object: T, options?: SerializeOptions): Payload;
176
+ deserialize<T>(payload: Payload, options?: DeserializeOptions): T;
177
+ }
178
+ interface ObjectCodec<T, Payload> {
179
+ encode(object: T): Payload;
180
+ decode(payload: Payload): T;
181
+ }
182
+
183
+ export { type Serializer as A, composeJSONReplacers as B, type Connection as C, type DbSQLExecutor as D, composeJSONRevivers as E, JSONReplacer as F, JSONReplacers as G, JSONReviver as H, JSONRevivers as I, JSONSerializer as J, jsonSerializer as K, JSONObjectCodec as L, type JSONObjectCodecOptions as M, identifier as N, type ObjectCodec as O, isSQL as P, type QueryResultRow as Q, RawJSONSerializer as R, type SQLExecutor as S, type TransactionResult as T, literal as U, plainString as V, type WithSQLExecutor as W, rawSql as X, sql as Y, type ConnectionPool as a, type DatabaseTransaction as b, type ConnectorTypeName as c, type QueryResult as d, SQL as e, type ConnectionFactory as f, type CreateConnectionOptions as g, createConnection as h, type ConnectionPoolFactory as i, createConnectionPool as j, type DatabaseTransactionFactory as k, executeInTransaction as l, transactionFactoryWithNewConnection as m, type DatabaseType as n, type DatabaseDriverName as o, type ConnectorTypeParts as p, toConnectorType as q, fromConnectorType as r, getDriverName as s, transactionFactoryWithDbClient as t, type SQLQueryOptions as u, type SQLCommandOptions as v, sqlExecutor as w, sqlExecutorInNewConnection as x, executeInNewDbClient as y, executeInNewConnection as z };
@@ -0,0 +1,183 @@
1
+ interface QueryResultRow {
2
+ [column: string]: any;
3
+ }
4
+ type QueryResult<Result extends QueryResultRow = QueryResultRow> = {
5
+ rowCount: number | null;
6
+ rows: Result[];
7
+ };
8
+
9
+ declare const sql: (sqlQuery: string, ...params: unknown[]) => SQL;
10
+ declare const rawSql: (sqlQuery: string) => SQL;
11
+ declare const isSQL: (literal: unknown) => literal is SQL;
12
+ declare const literal: (value: unknown) => {
13
+ type: string;
14
+ value: unknown;
15
+ };
16
+ declare const identifier: (value: string) => {
17
+ type: string;
18
+ value: string;
19
+ };
20
+ declare const plainString: (value: string) => {
21
+ type: string;
22
+ value: string;
23
+ };
24
+ type SQL = string & {
25
+ __brand: 'sql';
26
+ };
27
+ declare function SQL(strings: TemplateStringsArray, ...values: unknown[]): SQL;
28
+
29
+ type SQLQueryOptions = {
30
+ timeoutMs?: number;
31
+ };
32
+ type SQLCommandOptions = {
33
+ timeoutMs?: number;
34
+ };
35
+ interface DbSQLExecutor<ConnectorType extends string = string, DbClient = unknown> {
36
+ type: ConnectorType;
37
+ query<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sql: SQL, options?: SQLQueryOptions): Promise<QueryResult<Result>>;
38
+ batchQuery<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sqls: SQL[], options?: SQLQueryOptions): Promise<QueryResult<Result>[]>;
39
+ command<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sql: SQL, options?: SQLCommandOptions): Promise<QueryResult<Result>>;
40
+ batchCommand<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sqls: SQL[], options?: SQLCommandOptions): Promise<QueryResult<Result>[]>;
41
+ }
42
+ interface SQLExecutor {
43
+ query<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: SQLQueryOptions): Promise<QueryResult<Result>>;
44
+ batchQuery<Result extends QueryResultRow = QueryResultRow>(sqls: SQL[], options?: SQLQueryOptions): Promise<QueryResult<Result>[]>;
45
+ command<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: SQLCommandOptions): Promise<QueryResult<Result>>;
46
+ batchCommand<Result extends QueryResultRow = QueryResultRow>(sqls: SQL[], options?: SQLCommandOptions): Promise<QueryResult<Result>[]>;
47
+ }
48
+ interface WithSQLExecutor {
49
+ execute: SQLExecutor;
50
+ }
51
+ declare const sqlExecutor: <DbClient = unknown, DbExecutor extends DbSQLExecutor = DbSQLExecutor>(sqlExecutor: DbExecutor, options: {
52
+ connect: () => Promise<DbClient>;
53
+ close?: (client: DbClient, error?: unknown) => Promise<void>;
54
+ }) => SQLExecutor;
55
+ declare const sqlExecutorInNewConnection: <ConnectionType extends Connection>(options: {
56
+ connection: () => Promise<ConnectionType>;
57
+ }) => SQLExecutor;
58
+ declare const executeInNewDbClient: <DbClient = unknown, Result = unknown>(handle: (client: DbClient) => Promise<Result>, options: {
59
+ connect: () => Promise<DbClient>;
60
+ close?: (client: DbClient, error?: unknown) => Promise<void>;
61
+ }) => Promise<Result>;
62
+ declare const executeInNewConnection: <ConnectionType extends Connection, Result>(handle: (connection: ConnectionType) => Promise<Result>, options: {
63
+ connection: () => Promise<ConnectionType>;
64
+ }) => Promise<Result>;
65
+
66
+ interface DatabaseTransaction<ConnectorType extends string = string, DbClient = unknown> extends WithSQLExecutor {
67
+ type: ConnectorType;
68
+ connection: Connection<ConnectorType, DbClient>;
69
+ begin: () => Promise<void>;
70
+ commit: () => Promise<void>;
71
+ rollback: (error?: unknown) => Promise<void>;
72
+ }
73
+ interface DatabaseTransactionFactory<ConnectorType extends string = string, DbClient = unknown> {
74
+ transaction: () => DatabaseTransaction<ConnectorType, DbClient>;
75
+ withTransaction: <Result = never>(handle: (transaction: DatabaseTransaction<ConnectorType, DbClient>) => Promise<TransactionResult<Result> | Result>) => Promise<Result>;
76
+ }
77
+ type TransactionResult<Result> = {
78
+ success: boolean;
79
+ result: Result;
80
+ };
81
+ declare const executeInTransaction: <ConnectorType extends string = string, DbClient = unknown, Result = void>(transaction: DatabaseTransaction<ConnectorType, DbClient>, handle: (transaction: DatabaseTransaction<ConnectorType, DbClient>) => Promise<TransactionResult<Result> | Result>) => Promise<Result>;
82
+ declare const transactionFactoryWithDbClient: <ConnectorType extends string = string, DbClient = unknown>(connect: () => Promise<DbClient>, initTransaction: (client: Promise<DbClient>) => DatabaseTransaction<ConnectorType, DbClient>) => DatabaseTransactionFactory<ConnectorType, DbClient>;
83
+ declare const transactionFactoryWithNewConnection: <ConnectionType extends Connection = Connection>(connect: () => ConnectionType) => DatabaseTransactionFactory<ConnectionType["type"]>;
84
+
85
+ interface Connection<ConnectorType extends string = string, DbClient = unknown> extends WithSQLExecutor, DatabaseTransactionFactory<ConnectorType> {
86
+ type: ConnectorType;
87
+ open: () => Promise<DbClient>;
88
+ close: () => Promise<void>;
89
+ }
90
+ interface ConnectionFactory<ConnectionType extends Connection = Connection> {
91
+ connection: () => Promise<ConnectionType>;
92
+ withConnection: <Result = unknown>(handle: (connection: ConnectionType) => Promise<Result>) => Promise<Result>;
93
+ }
94
+ type CreateConnectionOptions<ConnectorType extends string = string, DbClient = unknown, ConnectionType extends Connection<ConnectorType, DbClient> = Connection<ConnectorType, DbClient>, Executor extends DbSQLExecutor = DbSQLExecutor> = {
95
+ type: ConnectorType;
96
+ connect: Promise<DbClient>;
97
+ close: (client: DbClient) => Promise<void>;
98
+ initTransaction: (connection: () => ConnectionType) => (client: Promise<DbClient>) => DatabaseTransaction<ConnectorType, DbClient>;
99
+ executor: () => Executor;
100
+ };
101
+ declare const createConnection: <ConnectorType extends string = string, DbClient = unknown, ConnectionType extends Connection<ConnectorType, DbClient> = Connection<ConnectorType, DbClient>, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateConnectionOptions<ConnectorType, DbClient, ConnectionType, Executor>) => ConnectionType;
102
+
103
+ interface ConnectionPool<ConnectionType extends Connection = Connection> extends WithSQLExecutor, ConnectionFactory<ConnectionType>, DatabaseTransactionFactory<ConnectionType['type']> {
104
+ type: ConnectionType['type'];
105
+ close: () => Promise<void>;
106
+ }
107
+ type ConnectionPoolFactory<ConnectionPoolType extends ConnectionPool = ConnectionPool, ConnectionPoolOptions = unknown> = (options: ConnectionPoolOptions) => ConnectionPoolType;
108
+ declare const createConnectionPool: <ConnectionType extends Connection, ConnectionPoolType extends ConnectionPool<ConnectionType>>(pool: Pick<ConnectionPool<ConnectionType>, "type"> & Partial<ConnectionPool<ConnectionType>> & {
109
+ getConnection: () => ConnectionType;
110
+ }) => ConnectionPoolType;
111
+
112
+ type DatabaseType = string;
113
+ type DatabaseDriverName = string;
114
+ type ConnectorTypeName<DatabaseTypeName extends DatabaseType = DatabaseType, DriverName extends DatabaseDriverName = DatabaseDriverName> = `${DatabaseTypeName}:${DriverName}`;
115
+ type ConnectorTypeParts<T extends DatabaseType = DatabaseType> = {
116
+ databaseType: T;
117
+ driverName: string;
118
+ };
119
+ /**
120
+ * Accepts a `databaseType` (e.g. PostgreSQL, SQLite) and a `driverName`
121
+ * (the library name, e.g. pg, sqlite3) and combines them to a singular
122
+ * `connectorType` which can be used in database handling.
123
+ */
124
+ declare function toConnectorType<T extends DatabaseType>(databaseType: T, driverName: string): ConnectorTypeName<T>;
125
+ /**
126
+ * Accepts a fully formatted `connectorType` and returns the broken down
127
+ * `databaseType` and `driverName`.
128
+ */
129
+ declare function fromConnectorType<T extends DatabaseType>(connectorType: ConnectorTypeName<T>): ConnectorTypeParts<T>;
130
+ /**
131
+ * Accepts a fully formatted `connectorType` and returns the `driverName`.
132
+ */
133
+ declare function getDriverName<T extends DatabaseType>(connectorType: ConnectorTypeName<T>): DatabaseDriverName;
134
+
135
+ type JSONSerializerOptions = {
136
+ disableBigIntSerialization?: boolean;
137
+ };
138
+ type JSONSerializeOptions = {
139
+ replacer?: JSONReplacer;
140
+ } & JSONSerializerOptions;
141
+ type JSONDeserializeOptions = {
142
+ reviver?: JSONReviver;
143
+ } & JSONSerializerOptions;
144
+ type JSONObjectCodecOptions<SerializeOptions = JSONSerializeOptions, DeserializeOptions = JSONDeserializeOptions> = {
145
+ serializer?: JSONSerializer<SerializeOptions, DeserializeOptions>;
146
+ } | {
147
+ serializerOptions?: JSONSerializerOptions;
148
+ };
149
+ declare const composeJSONReplacers: (...replacers: JSONReplacer[]) => JSONReplacer;
150
+ declare const composeJSONRevivers: (...revivers: JSONReviver[]) => JSONReviver;
151
+ type JSONReplacer = (this: any, key: string, value: any) => any;
152
+ declare const JSONReplacer: (opts?: JSONSerializeOptions) => JSONReplacer | undefined;
153
+ type JSONReviver = (this: any, key: string, value: any) => any;
154
+ declare const JSONReviver: (opts?: JSONDeserializeOptions) => JSONReviver | undefined;
155
+ declare const JSONReplacers: {
156
+ bigInt: JSONReplacer;
157
+ };
158
+ declare const JSONRevivers: {
159
+ bigInt: JSONReviver;
160
+ };
161
+ declare const jsonSerializer: (options?: JSONSerializerOptions) => JSONSerializer;
162
+ interface JSONSerializer<SerializeOptions = JSONSerializeOptions, DeserializeOptions = JSONDeserializeOptions> extends Serializer<string, SerializeOptions, DeserializeOptions> {
163
+ serialize<T>(object: T, options?: SerializeOptions): string;
164
+ deserialize<T>(payload: string, options?: DeserializeOptions): T;
165
+ }
166
+ declare const JSONSerializer: JSONSerializer<JSONSerializeOptions, JSONDeserializeOptions>;
167
+ declare const RawJSONSerializer: JSONSerializer<JSONSerializeOptions, JSONDeserializeOptions>;
168
+ interface JSONObjectCodec<T, SerializeOptions = JSONSerializeOptions, DeserializeOptions = JSONDeserializeOptions> extends ObjectCodec<T, string> {
169
+ encode(object: T, options?: SerializeOptions): string;
170
+ decode(payload: string, options?: DeserializeOptions): T;
171
+ }
172
+ declare const JSONObjectCodec: <T, SerializeOptions = JSONSerializeOptions, DeserializeOptions = JSONDeserializeOptions>(options: JSONObjectCodecOptions<SerializeOptions, DeserializeOptions>) => JSONObjectCodec<T, SerializeOptions, DeserializeOptions>;
173
+
174
+ interface Serializer<Payload, SerializeOptions = never, DeserializeOptions = SerializeOptions> {
175
+ serialize<T>(object: T, options?: SerializeOptions): Payload;
176
+ deserialize<T>(payload: Payload, options?: DeserializeOptions): T;
177
+ }
178
+ interface ObjectCodec<T, Payload> {
179
+ encode(object: T): Payload;
180
+ decode(payload: Payload): T;
181
+ }
182
+
183
+ export { type Serializer as A, composeJSONReplacers as B, type Connection as C, type DbSQLExecutor as D, composeJSONRevivers as E, JSONReplacer as F, JSONReplacers as G, JSONReviver as H, JSONRevivers as I, JSONSerializer as J, jsonSerializer as K, JSONObjectCodec as L, type JSONObjectCodecOptions as M, identifier as N, type ObjectCodec as O, isSQL as P, type QueryResultRow as Q, RawJSONSerializer as R, type SQLExecutor as S, type TransactionResult as T, literal as U, plainString as V, type WithSQLExecutor as W, rawSql as X, sql as Y, type ConnectionPool as a, type DatabaseTransaction as b, type ConnectorTypeName as c, type QueryResult as d, SQL as e, type ConnectionFactory as f, type CreateConnectionOptions as g, createConnection as h, type ConnectionPoolFactory as i, createConnectionPool as j, type DatabaseTransactionFactory as k, executeInTransaction as l, transactionFactoryWithNewConnection as m, type DatabaseType as n, type DatabaseDriverName as o, type ConnectorTypeParts as p, toConnectorType as q, fromConnectorType as r, getDriverName as s, transactionFactoryWithDbClient as t, type SQLQueryOptions as u, type SQLCommandOptions as v, sqlExecutor as w, sqlExecutorInNewConnection as x, executeInNewDbClient as y, executeInNewConnection as z };