duckdb-tinyorm 2.0.4 → 3.0.1
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 +8 -4
- package/dist/helpers/bulk-insert.helper.d.ts +2 -1
- package/dist/helpers/bulk-insert.helper.js +9 -13
- package/dist/helpers/bulk-insert.helper.js.map +1 -1
- package/dist/helpers/db.helper.d.ts +11 -11
- package/dist/helpers/db.helper.js +109 -118
- package/dist/helpers/db.helper.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/migration/migration.d.ts +2 -2
- package/dist/migration/migration.js +28 -36
- package/dist/migration/migration.js.map +1 -1
- package/dist/repositories/duckdb.repository.d.ts +10 -3
- package/dist/repositories/duckdb.repository.js +117 -19
- package/dist/repositories/duckdb.repository.js.map +1 -1
- package/dist/repositories/transaction.d.ts +2 -3
- package/dist/repositories/transaction.js +3 -15
- package/dist/repositories/transaction.js.map +1 -1
- package/dist/test.js +119 -83
- package/dist/test.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -37,12 +37,12 @@ npm install duckdb-tinyorm
|
|
|
37
37
|
yarn add duckdb-tinyorm
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
DuckDB TinyORM requires `reflect-metadata` for decorator support:
|
|
40
|
+
DuckDB TinyORM requires `reflect-metadata` and the DuckDB Node-API for decorator support:
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
npm install reflect-metadata
|
|
43
|
+
npm install reflect-metadata @duckdb/node-api
|
|
44
44
|
# or
|
|
45
|
-
yarn add reflect-metadata
|
|
45
|
+
yarn add reflect-metadata @duckdb/node-api
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
Make sure to import `reflect-metadata` at the beginning of your application:
|
|
@@ -134,6 +134,7 @@ main();
|
|
|
134
134
|
- 🔍 **Query Builder**: Fluent API for building complex queries
|
|
135
135
|
- 📊 **Data Export**: Export data to CSV, JSON, and Parquet formats
|
|
136
136
|
- 📄 **Pagination**: Built-in support for paginating large datasets
|
|
137
|
+
- 🔄 **Promise-based API**: Uses the new native Promise support in DuckDB Node-API
|
|
137
138
|
|
|
138
139
|
## 🏗️ Entity Definition
|
|
139
140
|
|
|
@@ -376,7 +377,10 @@ const inMemoryDb = DuckDbRepository.getInstances({
|
|
|
376
377
|
const fileDb = DuckDbRepository.getInstances({
|
|
377
378
|
name: 'production',
|
|
378
379
|
location: DuckDbLocation.File,
|
|
379
|
-
filename: './data/mydb.db'
|
|
380
|
+
filename: './data/mydb.db',
|
|
381
|
+
options: {
|
|
382
|
+
threads: '4'
|
|
383
|
+
}
|
|
380
384
|
});
|
|
381
385
|
```
|
|
382
386
|
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { DuckDBConnection } from '@duckdb/node-api';
|
|
2
|
+
export declare function bulkInsert(connection: DuckDBConnection, query: string): Promise<void>;
|
|
@@ -2,18 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bulkInsert = bulkInsert;
|
|
4
4
|
async function bulkInsert(connection, query) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
connection.run(query
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
resolve();
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
5
|
+
// Add logging to see the exact query being executed
|
|
6
|
+
console.log("Executing bulk insert query:", query);
|
|
7
|
+
try {
|
|
8
|
+
await connection.run(query);
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
console.error("Error bulk inserting!", err);
|
|
12
|
+
throw err;
|
|
13
|
+
}
|
|
18
14
|
}
|
|
19
15
|
//# sourceMappingURL=bulk-insert.helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk-insert.helper.js","sourceRoot":"","sources":["../../src/helpers/bulk-insert.helper.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"bulk-insert.helper.js","sourceRoot":"","sources":["../../src/helpers/bulk-insert.helper.ts"],"names":[],"mappings":";;AAEA,gCAUC;AAVM,KAAK,UAAU,UAAU,CAAC,UAA4B,EAAE,KAAa;IACxE,oDAAoD;IACpD,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;IAEnD,IAAI,CAAC;QACD,MAAM,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;QAC5C,MAAM,GAAG,CAAC;IACd,CAAC;AACL,CAAC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function executeDuckDbQuery(connection?:
|
|
3
|
-
export declare function bulkInsert(connection?:
|
|
4
|
-
export declare function dropTable(connection?:
|
|
5
|
-
export declare function saveToParquet(connection?:
|
|
6
|
-
export declare function deleteTableData(connection?:
|
|
7
|
-
export declare function executeQuery(connection?:
|
|
8
|
-
export declare function saveQueryToParquet(connection?:
|
|
9
|
-
export declare function exportToCSV(connection:
|
|
1
|
+
import { DuckDBConnection } from '@duckdb/node-api';
|
|
2
|
+
export declare function executeDuckDbQuery(connection?: DuckDBConnection, query?: string): Promise<void>;
|
|
3
|
+
export declare function bulkInsert(connection?: DuckDBConnection, query?: string): Promise<void>;
|
|
4
|
+
export declare function dropTable(connection?: DuckDBConnection, tableName?: string): Promise<void>;
|
|
5
|
+
export declare function saveToParquet(connection?: DuckDBConnection, fileName?: string, tableName?: string, folder?: string): Promise<void>;
|
|
6
|
+
export declare function deleteTableData(connection?: DuckDBConnection, tableName?: string): Promise<any[]>;
|
|
7
|
+
export declare function executeQuery(connection?: DuckDBConnection, query?: string): Promise<any[]>;
|
|
8
|
+
export declare function saveQueryToParquet(connection?: DuckDBConnection, fileName?: string, query?: string, folder?: string): Promise<void>;
|
|
9
|
+
export declare function exportToCSV(connection: DuckDBConnection, source: string, fileName: string, options?: {
|
|
10
10
|
header?: boolean;
|
|
11
11
|
delimiter?: string;
|
|
12
12
|
}): Promise<void>;
|
|
13
|
-
export declare function exportToJSON(connection:
|
|
13
|
+
export declare function exportToJSON(connection: DuckDBConnection, source: string, fileName: string, options?: {
|
|
14
14
|
pretty?: boolean;
|
|
15
15
|
}): Promise<void>;
|
|
16
|
-
export declare function exportToParquet(connection:
|
|
16
|
+
export declare function exportToParquet(connection: DuckDBConnection, source: string, fileName: string, options?: {
|
|
17
17
|
compression?: string;
|
|
18
18
|
}): Promise<void>;
|
|
@@ -11,154 +11,145 @@ exports.exportToCSV = exportToCSV;
|
|
|
11
11
|
exports.exportToJSON = exportToJSON;
|
|
12
12
|
exports.exportToParquet = exportToParquet;
|
|
13
13
|
async function executeDuckDbQuery(connection, query) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
return resolve(response);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
14
|
+
if (!connection || !query) {
|
|
15
|
+
throw new Error("Connection or query is missing");
|
|
16
|
+
}
|
|
17
|
+
await connection.run(query);
|
|
22
18
|
}
|
|
23
19
|
async function bulkInsert(connection, query) {
|
|
20
|
+
if (!connection) {
|
|
21
|
+
throw new Error("Connection is not established. Make sure you've connected to DuckDB before inserting data.");
|
|
22
|
+
}
|
|
23
|
+
if (!query || query.trim() === '') {
|
|
24
|
+
throw new Error("Query is empty or undefined");
|
|
25
|
+
}
|
|
26
|
+
// Add logging to see the exact query being executed
|
|
27
|
+
console.log("Executing bulk insert query:", query);
|
|
24
28
|
try {
|
|
25
|
-
await
|
|
29
|
+
await connection.run(query);
|
|
26
30
|
}
|
|
27
31
|
catch (err) {
|
|
28
|
-
console.error(
|
|
32
|
+
console.error("Error bulk inserting!", err);
|
|
33
|
+
throw err;
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
36
|
async function dropTable(connection, tableName) {
|
|
37
|
+
if (!connection || !tableName) {
|
|
38
|
+
throw new Error("Connection or table name is missing");
|
|
39
|
+
}
|
|
32
40
|
const query = `DROP TABLE IF EXISTS ${tableName}`;
|
|
33
41
|
try {
|
|
34
|
-
await
|
|
42
|
+
await connection.run(query);
|
|
35
43
|
}
|
|
36
44
|
catch (err) {
|
|
37
45
|
console.error(`Error dropping table "${tableName}":`, err);
|
|
46
|
+
throw err;
|
|
38
47
|
}
|
|
39
48
|
}
|
|
40
49
|
async function saveToParquet(connection, fileName, tableName, folder) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
console.log('Error uploading Parquet file to Azure Blob Storage:', err);
|
|
55
|
-
return Promise.reject(err);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
});
|
|
50
|
+
if (!connection || !fileName || !tableName) {
|
|
51
|
+
throw new Error("Connection, file name, or table name is missing");
|
|
52
|
+
}
|
|
53
|
+
const folderPath = folder ? `${folder}/${fileName}` : fileName;
|
|
54
|
+
const query = `COPY ${tableName} TO '${folderPath}' (FORMAT PARQUET, COMPRESSION ZSTD)`;
|
|
55
|
+
try {
|
|
56
|
+
await connection.run(query);
|
|
57
|
+
console.log(`Dumped table ${tableName} into ${folderPath}`);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
console.error(`Error saving to Parquet:`, err);
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
|
-
async function deleteTableData(connection,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
async function deleteTableData(connection, tableName) {
|
|
65
|
+
if (!connection || !tableName) {
|
|
66
|
+
throw new Error("Connection or table name is missing");
|
|
67
|
+
}
|
|
68
|
+
const query = `DELETE FROM ${tableName}`;
|
|
69
|
+
try {
|
|
70
|
+
const reader = await connection.runAndReadAll(query);
|
|
71
|
+
return reader.getRowObjects();
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
console.error(`Error deleting table data from "${tableName}":`, err);
|
|
75
|
+
throw err;
|
|
76
|
+
}
|
|
72
77
|
}
|
|
73
78
|
async function executeQuery(connection, query) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
79
|
+
if (!connection) {
|
|
80
|
+
throw new Error("Connection is not established. Make sure you've connected to DuckDB before executing queries.");
|
|
81
|
+
}
|
|
82
|
+
if (!query || query.trim() === '') {
|
|
83
|
+
throw new Error("Query is empty or undefined");
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const reader = await connection.runAndReadAll(query);
|
|
87
|
+
return reader.getRowObjects();
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
console.error(`Error executing query: ${query}`, err);
|
|
91
|
+
throw err;
|
|
92
|
+
}
|
|
84
93
|
}
|
|
85
94
|
async function saveQueryToParquet(connection, fileName, query, folder) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return Promise.reject(err);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
95
|
+
if (!connection || !fileName || !query) {
|
|
96
|
+
throw new Error("Connection, file name, or query is missing");
|
|
97
|
+
}
|
|
98
|
+
const folderPath = folder ? `${folder}/${fileName}` : fileName;
|
|
99
|
+
const copyQuery = `COPY (${query}) TO '${folderPath}' (FORMAT PARQUET, COMPRESSION ZSTD)`;
|
|
100
|
+
try {
|
|
101
|
+
await connection.run(copyQuery);
|
|
102
|
+
console.log(`Saved query results to ${folderPath}`);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
console.error(`Error saving query to Parquet:`, err);
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
104
108
|
}
|
|
105
|
-
// Add these export helper functions
|
|
106
109
|
async function exportToCSV(connection, source, fileName, options) {
|
|
107
110
|
const header = options?.header !== false ? 'HEADER' : 'NO_HEADER';
|
|
108
111
|
const delimiter = options?.delimiter ?? ',';
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
connection
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
resolve();
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
});
|
|
112
|
+
const isQuery = source.trim().toUpperCase().startsWith('SELECT');
|
|
113
|
+
const copyCommand = isQuery
|
|
114
|
+
? `COPY (${source}) TO '${fileName}' (FORMAT CSV, ${header}, DELIMITER '${delimiter}')`
|
|
115
|
+
: `COPY ${source} TO '${fileName}' (FORMAT CSV, ${header}, DELIMITER '${delimiter}')`;
|
|
116
|
+
try {
|
|
117
|
+
await connection.run(copyCommand);
|
|
118
|
+
console.log(`Exported to CSV: ${fileName}`);
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
console.error('CSV export failed:', err);
|
|
122
|
+
throw err;
|
|
123
|
+
}
|
|
125
124
|
}
|
|
126
125
|
async function exportToJSON(connection, source, fileName, options) {
|
|
127
126
|
const formatOption = options?.pretty ? 'FORMAT JSON, ARRAY TRUE' : 'FORMAT JSON';
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
connection
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
resolve();
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
});
|
|
127
|
+
const isQuery = source.trim().toUpperCase().startsWith('SELECT');
|
|
128
|
+
const copyCommand = isQuery
|
|
129
|
+
? `COPY (${source}) TO '${fileName}' (${formatOption})`
|
|
130
|
+
: `COPY ${source} TO '${fileName}' (${formatOption})`;
|
|
131
|
+
try {
|
|
132
|
+
await connection.run(copyCommand);
|
|
133
|
+
console.log(`Exported to JSON: ${fileName}`);
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
console.error('JSON export failed:', err);
|
|
137
|
+
throw err;
|
|
138
|
+
}
|
|
144
139
|
}
|
|
145
140
|
async function exportToParquet(connection, source, fileName, options) {
|
|
146
141
|
const compression = options?.compression ?? 'ZSTD'; // Default to ZSTD compression
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
connection
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
resolve();
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
});
|
|
142
|
+
const isQuery = source.trim().toUpperCase().startsWith('SELECT');
|
|
143
|
+
const copyCommand = isQuery
|
|
144
|
+
? `COPY (${source}) TO '${fileName}' (FORMAT PARQUET, COMPRESSION ${compression})`
|
|
145
|
+
: `COPY ${source} TO '${fileName}' (FORMAT PARQUET, COMPRESSION ${compression})`;
|
|
146
|
+
try {
|
|
147
|
+
await connection.run(copyCommand);
|
|
148
|
+
console.log(`Exported to Parquet: ${fileName}`);
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
console.error('Parquet export failed:', err);
|
|
152
|
+
throw err;
|
|
153
|
+
}
|
|
163
154
|
}
|
|
164
155
|
//# sourceMappingURL=db.helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.helper.js","sourceRoot":"","sources":["../../src/helpers/db.helper.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"db.helper.js","sourceRoot":"","sources":["../../src/helpers/db.helper.ts"],"names":[],"mappings":";;AAGA,gDAKC;AAED,gCAkBC;AAED,8BAWC;AAED,sCAeC;AAED,0CAaC;AAED,oCAgBC;AAED,gDAeC;AAED,kCAgBC;AAED,oCAeC;AAED,0CAeC;AA7JM,KAAK,UAAU,kBAAkB,CAAC,UAA6B,EAAE,KAAc;IAClF,IAAI,CAAC,UAAU,IAAI,CAAC,KAAK,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAEM,KAAK,UAAU,UAAU,CAAC,UAA6B,EAAE,KAAc;IAC1E,IAAI,CAAC,UAAU,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAC;IAClH,CAAC;IAED,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACnD,CAAC;IAED,oDAAoD;IACpD,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;IAEnD,IAAI,CAAC;QACD,MAAM,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;QAC5C,MAAM,GAAG,CAAC;IACd,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,SAAS,CAAC,UAA6B,EAA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,CAAC,wBAAwB,QAAQ,EAAE,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;QAC7C,MAAM,GAAG,CAAC;IACd,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,5 @@ import { QueryBuilder } from './query/query-builder';
|
|
|
8
8
|
import { Transaction } from './repositories/transaction';
|
|
9
9
|
import { Page, Pageable } from './pagination/pagination';
|
|
10
10
|
import { Migration, MigrationRunner, MigrationOptions } from './migration/migration';
|
|
11
|
-
import { ConnectionError } from './errors/orm-errors';
|
|
12
|
-
import { OrmBaseError, EntityNotFoundError, PrimaryKeyError, TableCreationError, QueryExecutionError, TransactionError, ValidationError, MigrationError } from './errors/orm-errors';
|
|
11
|
+
import { OrmBaseError, EntityNotFoundError, PrimaryKeyError, TableCreationError, QueryExecutionError, TransactionError, ValidationError, MigrationError, ConnectionError } from './errors/orm-errors';
|
|
13
12
|
export { DataTypeDecorator, Id, Unique, BaseRepository, Entity, Repository, DuckDbRepository, IRepository, DuckDbConfig, DuckDbLocation, getClassName, getTableName, getPrimaryId, generateCreateTableStatement, generateInsertIntoStatement, QueryBuilder, Transaction, Page, Pageable, Migration, MigrationRunner, MigrationOptions, Column, ColumnOptions, NotNull, Default, Check, AutoIncrement, TableOptions, OrmBaseError, ConnectionError, EntityNotFoundError, PrimaryKeyError, TableCreationError, QueryExecutionError, TransactionError, ValidationError, MigrationError, ExportOptions };
|
package/dist/index.js
CHANGED
|
@@ -32,14 +32,13 @@ const migration_1 = require("./migration/migration");
|
|
|
32
32
|
Object.defineProperty(exports, "Migration", { enumerable: true, get: function () { return migration_1.Migration; } });
|
|
33
33
|
Object.defineProperty(exports, "MigrationRunner", { enumerable: true, get: function () { return migration_1.MigrationRunner; } });
|
|
34
34
|
const orm_errors_1 = require("./errors/orm-errors");
|
|
35
|
+
Object.defineProperty(exports, "OrmBaseError", { enumerable: true, get: function () { return orm_errors_1.OrmBaseError; } });
|
|
36
|
+
Object.defineProperty(exports, "EntityNotFoundError", { enumerable: true, get: function () { return orm_errors_1.EntityNotFoundError; } });
|
|
37
|
+
Object.defineProperty(exports, "PrimaryKeyError", { enumerable: true, get: function () { return orm_errors_1.PrimaryKeyError; } });
|
|
38
|
+
Object.defineProperty(exports, "TableCreationError", { enumerable: true, get: function () { return orm_errors_1.TableCreationError; } });
|
|
39
|
+
Object.defineProperty(exports, "QueryExecutionError", { enumerable: true, get: function () { return orm_errors_1.QueryExecutionError; } });
|
|
40
|
+
Object.defineProperty(exports, "TransactionError", { enumerable: true, get: function () { return orm_errors_1.TransactionError; } });
|
|
41
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return orm_errors_1.ValidationError; } });
|
|
42
|
+
Object.defineProperty(exports, "MigrationError", { enumerable: true, get: function () { return orm_errors_1.MigrationError; } });
|
|
35
43
|
Object.defineProperty(exports, "ConnectionError", { enumerable: true, get: function () { return orm_errors_1.ConnectionError; } });
|
|
36
|
-
const orm_errors_2 = require("./errors/orm-errors");
|
|
37
|
-
Object.defineProperty(exports, "OrmBaseError", { enumerable: true, get: function () { return orm_errors_2.OrmBaseError; } });
|
|
38
|
-
Object.defineProperty(exports, "EntityNotFoundError", { enumerable: true, get: function () { return orm_errors_2.EntityNotFoundError; } });
|
|
39
|
-
Object.defineProperty(exports, "PrimaryKeyError", { enumerable: true, get: function () { return orm_errors_2.PrimaryKeyError; } });
|
|
40
|
-
Object.defineProperty(exports, "TableCreationError", { enumerable: true, get: function () { return orm_errors_2.TableCreationError; } });
|
|
41
|
-
Object.defineProperty(exports, "QueryExecutionError", { enumerable: true, get: function () { return orm_errors_2.QueryExecutionError; } });
|
|
42
|
-
Object.defineProperty(exports, "TransactionError", { enumerable: true, get: function () { return orm_errors_2.TransactionError; } });
|
|
43
|
-
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return orm_errors_2.ValidationError; } });
|
|
44
|
-
Object.defineProperty(exports, "MigrationError", { enumerable: true, get: function () { return orm_errors_2.MigrationError; } });
|
|
45
44
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAC1B,yEAGyC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAC1B,yEAGyC;AAgBrC,kGAlBA,uCAAiB,OAkBA;AAIjB,uFAtBmB,4BAAM,OAsBnB;AAHN,mFAnB2B,wBAAE,OAmB3B;AAIF,2FAvB+B,gCAAU,OAuB/B;AAHV,uFApB2C,4BAAM,OAoB3C;AAsBN,uFAzCA,4BAAM,OAyCA;AAEN,wFA3CuB,6BAAO,OA2CvB;AACP,wFA5CgC,6BAAO,OA4ChC;AACP,sFA7CyC,2BAAK,OA6CzC;AACL,8FA9CgD,mCAAa,OA8ChD;AA5CjB,oEAAgE;AAkB5D,+FAlBK,gCAAc,OAkBL;AAjBlB,wEAAiH;AAoB7G,iGApBK,oCAAgB,OAoBL;AAGhB,+FAvBqC,kCAAc,OAuBrC;AArBlB,mEAAkJ;AAsB9I,6FAtBK,gCAAY,OAsBL;AACZ,6FAvBmB,gCAAY,OAuBnB;AACZ,6FAxBiC,gCAAY,OAwBjC;AACZ,6GAzB+C,gDAA4B,OAyB/C;AAC5B,4GA1B6E,+CAA2B,OA0B7E;AAzB/B,yDAAqD;AA0BjD,6FA1BK,4BAAY,OA0BL;AAzBhB,4DAAyD;AA0BrD,4FA1BK,yBAAW,OA0BL;AAxBf,qDAAqF;AA2BjF,0FA3BK,qBAAS,OA2BL;AACT,gGA5BgB,2BAAe,OA4BhB;AA3BnB,oDAG6B;AAqCzB,6FAvCA,yBAAY,OAuCA;AAEZ,oGAzCc,gCAAmB,OAyCd;AACnB,gGA1CmC,4BAAe,OA0CnC;AACf,mGA3CoD,+BAAkB,OA2CpD;AAClB,oGA3CA,gCAAmB,OA2CA;AACnB,iGA5CqB,6BAAgB,OA4CrB;AAChB,gGA7CuC,4BAAe,OA6CvC;AACf,+FA9CwD,2BAAc,OA8CxD;AAPd,gGAvCwE,4BAAe,OAuCxE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DuckDBConnection } from '@duckdb/node-api';
|
|
2
2
|
export interface MigrationOptions {
|
|
3
3
|
tableName?: string;
|
|
4
4
|
}
|
|
@@ -10,7 +10,7 @@ export declare abstract class Migration {
|
|
|
10
10
|
export declare class MigrationRunner {
|
|
11
11
|
private readonly connection;
|
|
12
12
|
private readonly migrationTableName;
|
|
13
|
-
constructor(connection:
|
|
13
|
+
constructor(connection: DuckDBConnection, options?: MigrationOptions);
|
|
14
14
|
initialize(): Promise<void>;
|
|
15
15
|
private createMigrationTableIfNotExists;
|
|
16
16
|
applyMigrations(migrations: Migration[]): Promise<void>;
|
|
@@ -22,16 +22,13 @@ class MigrationRunner {
|
|
|
22
22
|
applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
23
23
|
)
|
|
24
24
|
`;
|
|
25
|
-
|
|
26
|
-
this.connection.run(query
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
25
|
+
try {
|
|
26
|
+
await this.connection.run(query);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error('Failed to create migration table:', error);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
35
32
|
}
|
|
36
33
|
async applyMigrations(migrations) {
|
|
37
34
|
await this.initialize();
|
|
@@ -67,22 +64,20 @@ class MigrationRunner {
|
|
|
67
64
|
}
|
|
68
65
|
async getAppliedMigrations() {
|
|
69
66
|
const query = `SELECT * FROM ${this.migrationTableName} ORDER BY id ASC`;
|
|
70
|
-
|
|
71
|
-
this.connection.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
});
|
|
67
|
+
try {
|
|
68
|
+
const reader = await this.connection.runAndReadAll(query);
|
|
69
|
+
const rows = reader.getRowObjects();
|
|
70
|
+
// Cast the result to the expected type
|
|
71
|
+
return rows.map((row) => ({
|
|
72
|
+
id: typeof row.id === 'number' ? row.id : Number(row.id),
|
|
73
|
+
version: String(row.version),
|
|
74
|
+
applied_at: String(row.applied_at)
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
console.error('Failed to get applied migrations:', error);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
86
81
|
}
|
|
87
82
|
async applyMigration(migration) {
|
|
88
83
|
const upQuery = migration.up();
|
|
@@ -127,16 +122,13 @@ class MigrationRunner {
|
|
|
127
122
|
}
|
|
128
123
|
}
|
|
129
124
|
async executeQuery(query) {
|
|
130
|
-
|
|
131
|
-
this.connection.run(query
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
});
|
|
125
|
+
try {
|
|
126
|
+
return await this.connection.run(query);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
console.error(`Failed to execute query: ${query}`, error);
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
140
132
|
}
|
|
141
133
|
}
|
|
142
134
|
exports.MigrationRunner = MigrationRunner;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.js","sourceRoot":"","sources":["../../src/migration/migration.ts"],"names":[],"mappings":";;;AASA,MAAsB,SAAS;CAI9B;AAJD,8BAIC;AAED,MAAa,eAA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AAC;CACJ;AAtJD,0CAsJC"}
|
|
@@ -8,16 +8,22 @@ export interface DuckDbConfig {
|
|
|
8
8
|
name: string;
|
|
9
9
|
location: DuckDbLocation;
|
|
10
10
|
filename?: string;
|
|
11
|
+
options?: Record<string, string>;
|
|
11
12
|
}
|
|
12
13
|
export declare class DuckDbRepository {
|
|
13
|
-
private
|
|
14
|
+
private instance?;
|
|
14
15
|
private connection?;
|
|
15
16
|
private tables;
|
|
16
17
|
private isClosed;
|
|
18
|
+
private connectionPromise;
|
|
19
|
+
private initialized;
|
|
17
20
|
private static instance;
|
|
21
|
+
static getInstance(duckdbConfig?: DuckDbConfig): Promise<DuckDbRepository>;
|
|
18
22
|
static getInstances(duckdbConfig?: DuckDbConfig): DuckDbRepository;
|
|
19
|
-
protected constructor(location?: string);
|
|
20
|
-
|
|
23
|
+
protected constructor(location?: string, options?: Record<string, string>);
|
|
24
|
+
private initSync;
|
|
25
|
+
connect(): Promise<void>;
|
|
26
|
+
private ensureConnected;
|
|
21
27
|
createTableIfNotExists<T>(tableName: string, classType: new () => T): Promise<void>;
|
|
22
28
|
getDuckDbExtension(extension_name: string): Promise<any[]>;
|
|
23
29
|
executeQuery(query: string): Promise<any[]>;
|
|
@@ -41,6 +47,7 @@ export declare class DuckDbRepository {
|
|
|
41
47
|
private buildS3SecretQuery;
|
|
42
48
|
private buildAzureSecretQuery;
|
|
43
49
|
secretExists(secretName: string): Promise<boolean>;
|
|
50
|
+
close(): Promise<void>;
|
|
44
51
|
}
|
|
45
52
|
export interface ExportOptions {
|
|
46
53
|
format: 'csv' | 'json' | 'parquet';
|