@starbemtech/star-db-query-builder 1.3.0 → 1.4.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/.claude/skills/star-db-query-builder/SKILL.md +104 -0
- package/CHANGELOG.md +81 -46
- package/LICENSE +21 -0
- package/README.md +194 -94
- package/bin/install-skill.js +53 -0
- package/dist/src/core/repository.d.ts +92 -9
- package/dist/src/core/repository.js +275 -27
- package/dist/src/core/repository.js.map +1 -1
- package/dist/src/core/types.d.ts +17 -2
- package/dist/src/core/utils.d.ts +102 -0
- package/dist/src/core/utils.js +287 -70
- package/dist/src/core/utils.js.map +1 -1
- package/dist/src/db/initDb.d.ts +60 -50
- package/dist/src/db/initDb.js +96 -64
- package/dist/src/db/initDb.js.map +1 -1
- package/dist/src/db/mysqlClient.d.ts +3 -8
- package/dist/src/db/mysqlClient.js +9 -11
- package/dist/src/db/mysqlClient.js.map +1 -1
- package/dist/src/db/pgClient.js +0 -2
- package/dist/src/db/pgClient.js.map +1 -1
- package/dist/src/monitor/monitor.js +7 -0
- package/dist/src/monitor/monitor.js.map +1 -1
- package/package.json +28 -20
- package/.github/workflows/publish.yml +0 -118
- package/.prettierignore +0 -3
- package/.prettierrc +0 -5
- package/ARCHITECTURE.md +0 -313
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -131
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -131
- package/coverage/lcov-report/mysqlClient.ts.html +0 -685
- package/coverage/lcov-report/pgClient.ts.html +0 -823
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov.info +0 -533
- package/coverage/mysqlClient.ts.html +0 -685
- package/coverage/pgClient.ts.html +0 -823
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/dist/src/setupTests.d.ts +0 -26
- package/dist/src/setupTests.js +0 -43
- package/dist/src/setupTests.js.map +0 -1
- package/docs/INDEX.md +0 -145
- package/docs/methods/findFirst.md +0 -394
- package/docs/methods/findMany.md +0 -587
- package/docs/methods/insert.md +0 -536
- package/docs/methods/insertMany.md +0 -627
- package/docs/methods/joins.md +0 -781
- package/docs/methods/rawQuery.md +0 -284
- package/docs/methods/transactions.md +0 -737
- package/eslint.config.mjs +0 -77
- package/index.ts +0 -16
- package/jest.config.ts +0 -194
- package/scripts/release.sh +0 -123
- package/src/core/repository.ts +0 -865
- package/src/core/types.ts +0 -97
- package/src/core/utils.ts +0 -357
- package/src/db/IDatabaseClient.ts +0 -16
- package/src/db/__tests__/mysqlClient.test.ts +0 -262
- package/src/db/__tests__/pgClient.test.ts +0 -260
- package/src/db/initDb.ts +0 -181
- package/src/db/mysqlClient.ts +0 -200
- package/src/db/pgClient.ts +0 -246
- package/src/monitor/monitor.ts +0 -16
- package/src/setupTests.ts +0 -45
- package/tsconfig.test.json +0 -21
package/dist/src/db/initDb.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { DBClients, RetryOptions } from '../core/types';
|
|
|
10
10
|
* @param config.options - Connection options specific to the database type
|
|
11
11
|
* @param config.retryOptions - Optional retry configuration for failed queries
|
|
12
12
|
* @param config.installUnaccentExtension - Optional flag to install unaccent extension (PostgreSQL only)
|
|
13
|
+
* @param config.queryTimeout - Optional query timeout in milliseconds, applied to every query run through this client. For PostgreSQL this maps onto the pool's `query_timeout` (an explicit `query_timeout` in `options` takes precedence). For MySQL, since mysql2 has no pool-wide query timeout, it is passed as the `timeout` option on every individual query.
|
|
13
14
|
* @returns Promise<void> - Resolves when the database client is successfully initialized
|
|
14
15
|
*
|
|
15
16
|
* @throws {Error} When type is not provided or is invalid
|
|
@@ -29,7 +30,8 @@ import { DBClients, RetryOptions } from '../core/types';
|
|
|
29
30
|
* password: 'password'
|
|
30
31
|
* },
|
|
31
32
|
* retryOptions: { maxRetries: 3, delay: 1000 },
|
|
32
|
-
* installUnaccentExtension: true
|
|
33
|
+
* installUnaccentExtension: true,
|
|
34
|
+
* queryTimeout: 5000
|
|
33
35
|
* });
|
|
34
36
|
*
|
|
35
37
|
* @example
|
|
@@ -44,7 +46,8 @@ import { DBClients, RetryOptions } from '../core/types';
|
|
|
44
46
|
* user: 'user',
|
|
45
47
|
* password: 'password'
|
|
46
48
|
* },
|
|
47
|
-
* retryOptions: { maxRetries: 3, delay: 1000 }
|
|
49
|
+
* retryOptions: { maxRetries: 3, delay: 1000 },
|
|
50
|
+
* queryTimeout: 5000
|
|
48
51
|
* });
|
|
49
52
|
*/
|
|
50
53
|
export declare const initDb: <T>(config: {
|
|
@@ -53,55 +56,8 @@ export declare const initDb: <T>(config: {
|
|
|
53
56
|
options: T;
|
|
54
57
|
retryOptions?: RetryOptions;
|
|
55
58
|
installUnaccentExtension?: boolean;
|
|
59
|
+
queryTimeout?: number;
|
|
56
60
|
}) => Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* Initialize a database client with the specified configuration
|
|
59
|
-
*
|
|
60
|
-
* @template T - The type of connection options (PoolConfig for PostgreSQL or PoolOptions for MySQL)
|
|
61
|
-
* @param config - Configuration object for database initialization
|
|
62
|
-
* @param config.name - Optional name for the database client (defaults to 'default')
|
|
63
|
-
* @param config.type - Database type ('pg' for PostgreSQL or 'mysql' for MySQL)
|
|
64
|
-
* @param config.options - Connection options specific to the database type
|
|
65
|
-
* @param config.retryOptions - Optional retry configuration for failed queries
|
|
66
|
-
* @param config.installUnaccentExtension - Optional flag to install unaccent extension (PostgreSQL only)
|
|
67
|
-
* @returns Promise<void> - Resolves when the database client is successfully initialized
|
|
68
|
-
*
|
|
69
|
-
* @throws {Error} When database type is not provided or is invalid
|
|
70
|
-
* @throws {Error} When connection options are not provided
|
|
71
|
-
* @throws {Error} When an unsupported database type is specified
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* // Initialize PostgreSQL client
|
|
75
|
-
* await initDb({
|
|
76
|
-
* name: 'myPostgresDb',
|
|
77
|
-
* type: 'pg',
|
|
78
|
-
* options: {
|
|
79
|
-
* host: 'localhost',
|
|
80
|
-
* port: 5432,
|
|
81
|
-
* database: 'mydb',
|
|
82
|
-
* user: 'user',
|
|
83
|
-
* password: 'password'
|
|
84
|
-
* },
|
|
85
|
-
* retryOptions: { maxRetries: 3, delay: 1000 },
|
|
86
|
-
* installUnaccentExtension: true
|
|
87
|
-
* });
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* // Initialize MySQL client
|
|
91
|
-
* await initDb({
|
|
92
|
-
* name: 'myMysqlDb',
|
|
93
|
-
* type: 'mysql',
|
|
94
|
-
* options: {
|
|
95
|
-
* host: 'localhost',
|
|
96
|
-
* port: 3306,
|
|
97
|
-
* database: 'mydb',
|
|
98
|
-
* user: 'user',
|
|
99
|
-
* password: 'password'
|
|
100
|
-
* },
|
|
101
|
-
* retryOptions: { maxRetries: 3, delay: 1000 }
|
|
102
|
-
* });
|
|
103
|
-
*/
|
|
104
|
-
export declare const getDbClient: (name?: string) => IDatabaseClient;
|
|
105
61
|
/**
|
|
106
62
|
* Retrieves a specific database client by name
|
|
107
63
|
*
|
|
@@ -127,4 +83,58 @@ export declare const getDbClient: (name?: string) => IDatabaseClient;
|
|
|
127
83
|
* console.error('Database client not found:', error.message);
|
|
128
84
|
* }
|
|
129
85
|
*/
|
|
86
|
+
export declare const getDbClient: (name?: string) => IDatabaseClient;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves every registered database client, keyed by name
|
|
89
|
+
*
|
|
90
|
+
* @returns Record<string, IDatabaseClient> - A map of all initialized database clients, keyed by the name they were registered under (including 'default')
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* const clients = getAllDbClients();
|
|
94
|
+
* const names = Object.keys(clients); // ['default', 'myPostgresDb', 'myMysqlDb']
|
|
95
|
+
*/
|
|
130
96
|
export declare const getAllDbClients: () => Record<string, IDatabaseClient>;
|
|
97
|
+
/**
|
|
98
|
+
* Closes a database client's connection pool and removes it from the registry
|
|
99
|
+
*
|
|
100
|
+
* Use this to release connections gracefully on application shutdown or
|
|
101
|
+
* between tests, since `initDb` has no other way to release the pools it
|
|
102
|
+
* creates.
|
|
103
|
+
*
|
|
104
|
+
* @param name - Optional name of the database client to close. If not provided, closes the default client
|
|
105
|
+
* @returns Promise<void> - Resolves when the pool has been closed
|
|
106
|
+
*
|
|
107
|
+
* @throws {Error} When the specified database client name is not found or not initialized
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* await closeDb() // closes the default client
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* await closeDb('myPostgresDb')
|
|
114
|
+
*/
|
|
115
|
+
export declare const closeDb: (name?: string) => Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Closes every registered database client's connection pool
|
|
118
|
+
*
|
|
119
|
+
* @returns Promise<void> - Resolves when all pools have been closed
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* await closeAllDbClients()
|
|
123
|
+
*/
|
|
124
|
+
export declare const closeAllDbClients: () => Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Clears the in-memory client/pool registry without closing any connection
|
|
127
|
+
*
|
|
128
|
+
* This is a synchronous escape hatch for test suites and hot-reload tooling
|
|
129
|
+
* that need a clean registry between runs (e.g. calling `initDb` again with
|
|
130
|
+
* the same name without first awaiting a real `closeDb`). It does NOT call
|
|
131
|
+
* `pool.end()`, so any real (non-mocked) connection pool that was registered
|
|
132
|
+
* is orphaned — leaked, not released. Production code that wants to release
|
|
133
|
+
* connections should use `closeDb`/`closeAllDbClients` instead.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* afterEach(() => {
|
|
137
|
+
* resetDbClients() // test isolation only — pools here are mocked
|
|
138
|
+
* })
|
|
139
|
+
*/
|
|
140
|
+
export declare const resetDbClients: () => void;
|
package/dist/src/db/initDb.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAllDbClients = exports.getDbClient = exports.initDb = void 0;
|
|
3
|
+
exports.resetDbClients = exports.closeAllDbClients = exports.closeDb = exports.getAllDbClients = exports.getDbClient = exports.initDb = void 0;
|
|
4
4
|
const pg_1 = require("pg");
|
|
5
5
|
const promise_1 = require("mysql2/promise");
|
|
6
6
|
const pgClient_1 = require("./pgClient");
|
|
7
7
|
const mysqlClient_1 = require("./mysqlClient");
|
|
8
8
|
const dbClients = {};
|
|
9
|
+
const dbPools = {};
|
|
9
10
|
const defaultName = 'default';
|
|
10
11
|
/**
|
|
11
12
|
* Initialize a database client with the specified configuration
|
|
@@ -17,6 +18,7 @@ const defaultName = 'default';
|
|
|
17
18
|
* @param config.options - Connection options specific to the database type
|
|
18
19
|
* @param config.retryOptions - Optional retry configuration for failed queries
|
|
19
20
|
* @param config.installUnaccentExtension - Optional flag to install unaccent extension (PostgreSQL only)
|
|
21
|
+
* @param config.queryTimeout - Optional query timeout in milliseconds, applied to every query run through this client. For PostgreSQL this maps onto the pool's `query_timeout` (an explicit `query_timeout` in `options` takes precedence). For MySQL, since mysql2 has no pool-wide query timeout, it is passed as the `timeout` option on every individual query.
|
|
20
22
|
* @returns Promise<void> - Resolves when the database client is successfully initialized
|
|
21
23
|
*
|
|
22
24
|
* @throws {Error} When type is not provided or is invalid
|
|
@@ -36,7 +38,8 @@ const defaultName = 'default';
|
|
|
36
38
|
* password: 'password'
|
|
37
39
|
* },
|
|
38
40
|
* retryOptions: { maxRetries: 3, delay: 1000 },
|
|
39
|
-
* installUnaccentExtension: true
|
|
41
|
+
* installUnaccentExtension: true,
|
|
42
|
+
* queryTimeout: 5000
|
|
40
43
|
* });
|
|
41
44
|
*
|
|
42
45
|
* @example
|
|
@@ -51,7 +54,8 @@ const defaultName = 'default';
|
|
|
51
54
|
* user: 'user',
|
|
52
55
|
* password: 'password'
|
|
53
56
|
* },
|
|
54
|
-
* retryOptions: { maxRetries: 3, delay: 1000 }
|
|
57
|
+
* retryOptions: { maxRetries: 3, delay: 1000 },
|
|
58
|
+
* queryTimeout: 5000
|
|
55
59
|
* });
|
|
56
60
|
*/
|
|
57
61
|
const initDb = async (config) => {
|
|
@@ -59,77 +63,26 @@ const initDb = async (config) => {
|
|
|
59
63
|
throw new Error('Type is required. Accept values: pg | mysql');
|
|
60
64
|
if (!config.options)
|
|
61
65
|
throw new Error('Connection options is required');
|
|
66
|
+
const key = config.name || defaultName;
|
|
62
67
|
if (config.type === 'pg') {
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
const options = config.options;
|
|
69
|
+
const poolConfig = config.queryTimeout && options.query_timeout === undefined
|
|
70
|
+
? { ...options, query_timeout: config.queryTimeout }
|
|
71
|
+
: options;
|
|
72
|
+
const pool = new pg_1.Pool(poolConfig);
|
|
73
|
+
dbClients[key] = await (0, pgClient_1.createPgClient)(pool, config.retryOptions, poolConfig, config.installUnaccentExtension);
|
|
74
|
+
dbPools[key] = pool;
|
|
67
75
|
}
|
|
68
76
|
else if (config.type === 'mysql') {
|
|
69
77
|
const pool = (0, promise_1.createPool)(config.options);
|
|
70
|
-
dbClients[
|
|
71
|
-
|
|
78
|
+
dbClients[key] = (0, mysqlClient_1.createMysqlClient)(pool, config.retryOptions, config.queryTimeout);
|
|
79
|
+
dbPools[key] = pool;
|
|
72
80
|
}
|
|
73
81
|
else {
|
|
74
82
|
throw new Error('Unsupported database type');
|
|
75
83
|
}
|
|
76
84
|
};
|
|
77
85
|
exports.initDb = initDb;
|
|
78
|
-
/**
|
|
79
|
-
* Initialize a database client with the specified configuration
|
|
80
|
-
*
|
|
81
|
-
* @template T - The type of connection options (PoolConfig for PostgreSQL or PoolOptions for MySQL)
|
|
82
|
-
* @param config - Configuration object for database initialization
|
|
83
|
-
* @param config.name - Optional name for the database client (defaults to 'default')
|
|
84
|
-
* @param config.type - Database type ('pg' for PostgreSQL or 'mysql' for MySQL)
|
|
85
|
-
* @param config.options - Connection options specific to the database type
|
|
86
|
-
* @param config.retryOptions - Optional retry configuration for failed queries
|
|
87
|
-
* @param config.installUnaccentExtension - Optional flag to install unaccent extension (PostgreSQL only)
|
|
88
|
-
* @returns Promise<void> - Resolves when the database client is successfully initialized
|
|
89
|
-
*
|
|
90
|
-
* @throws {Error} When database type is not provided or is invalid
|
|
91
|
-
* @throws {Error} When connection options are not provided
|
|
92
|
-
* @throws {Error} When an unsupported database type is specified
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* // Initialize PostgreSQL client
|
|
96
|
-
* await initDb({
|
|
97
|
-
* name: 'myPostgresDb',
|
|
98
|
-
* type: 'pg',
|
|
99
|
-
* options: {
|
|
100
|
-
* host: 'localhost',
|
|
101
|
-
* port: 5432,
|
|
102
|
-
* database: 'mydb',
|
|
103
|
-
* user: 'user',
|
|
104
|
-
* password: 'password'
|
|
105
|
-
* },
|
|
106
|
-
* retryOptions: { maxRetries: 3, delay: 1000 },
|
|
107
|
-
* installUnaccentExtension: true
|
|
108
|
-
* });
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* // Initialize MySQL client
|
|
112
|
-
* await initDb({
|
|
113
|
-
* name: 'myMysqlDb',
|
|
114
|
-
* type: 'mysql',
|
|
115
|
-
* options: {
|
|
116
|
-
* host: 'localhost',
|
|
117
|
-
* port: 3306,
|
|
118
|
-
* database: 'mydb',
|
|
119
|
-
* user: 'user',
|
|
120
|
-
* password: 'password'
|
|
121
|
-
* },
|
|
122
|
-
* retryOptions: { maxRetries: 3, delay: 1000 }
|
|
123
|
-
* });
|
|
124
|
-
*/
|
|
125
|
-
const getDbClient = (name) => {
|
|
126
|
-
const client = dbClients[name || defaultName];
|
|
127
|
-
if (!client) {
|
|
128
|
-
throw new Error(`Database client "${name}" is not initialized`);
|
|
129
|
-
}
|
|
130
|
-
return client;
|
|
131
|
-
};
|
|
132
|
-
exports.getDbClient = getDbClient;
|
|
133
86
|
/**
|
|
134
87
|
* Retrieves a specific database client by name
|
|
135
88
|
*
|
|
@@ -155,8 +108,87 @@ exports.getDbClient = getDbClient;
|
|
|
155
108
|
* console.error('Database client not found:', error.message);
|
|
156
109
|
* }
|
|
157
110
|
*/
|
|
111
|
+
const getDbClient = (name) => {
|
|
112
|
+
const key = name || defaultName;
|
|
113
|
+
const client = dbClients[key];
|
|
114
|
+
if (!client) {
|
|
115
|
+
throw new Error(`Database client "${key}" is not initialized`);
|
|
116
|
+
}
|
|
117
|
+
return client;
|
|
118
|
+
};
|
|
119
|
+
exports.getDbClient = getDbClient;
|
|
120
|
+
/**
|
|
121
|
+
* Retrieves every registered database client, keyed by name
|
|
122
|
+
*
|
|
123
|
+
* @returns Record<string, IDatabaseClient> - A map of all initialized database clients, keyed by the name they were registered under (including 'default')
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* const clients = getAllDbClients();
|
|
127
|
+
* const names = Object.keys(clients); // ['default', 'myPostgresDb', 'myMysqlDb']
|
|
128
|
+
*/
|
|
158
129
|
const getAllDbClients = () => {
|
|
159
130
|
return dbClients;
|
|
160
131
|
};
|
|
161
132
|
exports.getAllDbClients = getAllDbClients;
|
|
133
|
+
/**
|
|
134
|
+
* Closes a database client's connection pool and removes it from the registry
|
|
135
|
+
*
|
|
136
|
+
* Use this to release connections gracefully on application shutdown or
|
|
137
|
+
* between tests, since `initDb` has no other way to release the pools it
|
|
138
|
+
* creates.
|
|
139
|
+
*
|
|
140
|
+
* @param name - Optional name of the database client to close. If not provided, closes the default client
|
|
141
|
+
* @returns Promise<void> - Resolves when the pool has been closed
|
|
142
|
+
*
|
|
143
|
+
* @throws {Error} When the specified database client name is not found or not initialized
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* await closeDb() // closes the default client
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* await closeDb('myPostgresDb')
|
|
150
|
+
*/
|
|
151
|
+
const closeDb = async (name) => {
|
|
152
|
+
const key = name || defaultName;
|
|
153
|
+
const pool = dbPools[key];
|
|
154
|
+
if (!pool) {
|
|
155
|
+
throw new Error(`Database client "${key}" is not initialized`);
|
|
156
|
+
}
|
|
157
|
+
await pool.end();
|
|
158
|
+
delete dbPools[key];
|
|
159
|
+
delete dbClients[key];
|
|
160
|
+
};
|
|
161
|
+
exports.closeDb = closeDb;
|
|
162
|
+
/**
|
|
163
|
+
* Closes every registered database client's connection pool
|
|
164
|
+
*
|
|
165
|
+
* @returns Promise<void> - Resolves when all pools have been closed
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* await closeAllDbClients()
|
|
169
|
+
*/
|
|
170
|
+
const closeAllDbClients = async () => {
|
|
171
|
+
await Promise.all(Object.keys(dbPools).map((key) => (0, exports.closeDb)(key)));
|
|
172
|
+
};
|
|
173
|
+
exports.closeAllDbClients = closeAllDbClients;
|
|
174
|
+
/**
|
|
175
|
+
* Clears the in-memory client/pool registry without closing any connection
|
|
176
|
+
*
|
|
177
|
+
* This is a synchronous escape hatch for test suites and hot-reload tooling
|
|
178
|
+
* that need a clean registry between runs (e.g. calling `initDb` again with
|
|
179
|
+
* the same name without first awaiting a real `closeDb`). It does NOT call
|
|
180
|
+
* `pool.end()`, so any real (non-mocked) connection pool that was registered
|
|
181
|
+
* is orphaned — leaked, not released. Production code that wants to release
|
|
182
|
+
* connections should use `closeDb`/`closeAllDbClients` instead.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* afterEach(() => {
|
|
186
|
+
* resetDbClients() // test isolation only — pools here are mocked
|
|
187
|
+
* })
|
|
188
|
+
*/
|
|
189
|
+
const resetDbClients = () => {
|
|
190
|
+
Object.keys(dbClients).forEach((key) => delete dbClients[key]);
|
|
191
|
+
Object.keys(dbPools).forEach((key) => delete dbPools[key]);
|
|
192
|
+
};
|
|
193
|
+
exports.resetDbClients = resetDbClients;
|
|
162
194
|
//# sourceMappingURL=initDb.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initDb.js","sourceRoot":"","sources":["../../../src/db/initDb.ts"],"names":[],"mappings":";;;AAAA,2BAAqC;AACrC,4CAA8D;AAC9D,yCAA2C;AAC3C,+CAAiD;
|
|
1
|
+
{"version":3,"file":"initDb.js","sourceRoot":"","sources":["../../../src/db/initDb.ts"],"names":[],"mappings":";;;AAAA,2BAAqC;AACrC,4CAA8D;AAC9D,yCAA2C;AAC3C,+CAAiD;AAQjD,MAAM,SAAS,GAAoC,EAAE,CAAA;AACrD,MAAM,OAAO,GAAiC,EAAE,CAAA;AAChD,MAAM,WAAW,GAAG,SAAS,CAAA;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACI,MAAM,MAAM,GAAG,KAAK,EAAK,MAO/B,EAAiB,EAAE;IAClB,IAAI,CAAC,MAAM,CAAC,IAAI;QACd,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAEhE,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IAEtE,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,IAAI,WAAW,CAAA;IAEtC,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAgC,CAAA;QACvD,MAAM,UAAU,GACd,MAAM,CAAC,YAAY,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS;YACxD,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,YAAY,EAAE;YACpD,CAAC,CAAC,OAAO,CAAA;QACb,MAAM,IAAI,GA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a,EAAiB,EAAE;IAC5D,MAAM,GAAG,GAAG,IAAI,IAAI,WAAW,CAAA;IAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;IAEzB,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,sBAAsB,CAAC,CAAA;IAChE,CAAC;IAED,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;IAChB,OAAO,OAAO,CAAC,GAAG,CAAC,CAAA;IACnB,OAAO,SAAS,CAAC,GAAG,CAAC,CAAA;AACvB,CAAC,CAAA;AAXY,QAAA,OAAO,WAWnB;AAED;;;;;;;GAOG;AACI,MAAM,iBAAiB,GAAG,KAAK,IAAmB,EAAE;IACzD,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,eAAO,EAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AACpE,CAAC,CAAA;AAFY,QAAA,iBAAiB,qBAE7B;AAED;;;;;;;;;;;;;;GAcG;AACI,MAAM,cAAc,GAAG,GAAS,EAAE;IACvC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;IAC9D,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;AAC5D,CAAC,CAAA;AAHY,QAAA,cAAc,kBAG1B"}
|
|
@@ -9,18 +9,13 @@ import { RetryOptions } from '../core/types';
|
|
|
9
9
|
*
|
|
10
10
|
* @param pool - The MySQL pool instance
|
|
11
11
|
* @param retryOptions - Optional retry options for failed queries
|
|
12
|
+
* @param queryTimeout - Optional query timeout in milliseconds, applied to every query since mysql2 has no pool-wide timeout option (only a per-query one)
|
|
12
13
|
* @returns IDatabaseClient - The MySQL database client instance
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
16
|
* const mysqlClient = createMysqlClient(pool, { retries: 3, factor: 2, minTimeout: 1000 });
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
|
-
* const mysqlClient = createMysqlClient(pool,
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const mysqlClient = createMysqlClient(pool, { retries: 3, factor: 2, minTimeout: 1000 });
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* const mysqlClient = createMysqlClient(pool, { retries: 3, factor: 2, minTimeout: 1000 });
|
|
19
|
+
* const mysqlClient = createMysqlClient(pool, undefined, 5000); // 5s query timeout
|
|
25
20
|
*/
|
|
26
|
-
export declare const createMysqlClient: (pool: Pool, retryOptions?: RetryOptions) => IDatabaseClient;
|
|
21
|
+
export declare const createMysqlClient: (pool: Pool, retryOptions?: RetryOptions, queryTimeout?: number) => IDatabaseClient;
|
|
@@ -46,21 +46,16 @@ function isTransientError(error) {
|
|
|
46
46
|
*
|
|
47
47
|
* @param pool - The MySQL pool instance
|
|
48
48
|
* @param retryOptions - Optional retry options for failed queries
|
|
49
|
+
* @param queryTimeout - Optional query timeout in milliseconds, applied to every query since mysql2 has no pool-wide timeout option (only a per-query one)
|
|
49
50
|
* @returns IDatabaseClient - The MySQL database client instance
|
|
50
51
|
*
|
|
51
52
|
* @example
|
|
52
53
|
* const mysqlClient = createMysqlClient(pool, { retries: 3, factor: 2, minTimeout: 1000 });
|
|
53
54
|
*
|
|
54
55
|
* @example
|
|
55
|
-
* const mysqlClient = createMysqlClient(pool,
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* const mysqlClient = createMysqlClient(pool, { retries: 3, factor: 2, minTimeout: 1000 });
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* const mysqlClient = createMysqlClient(pool, { retries: 3, factor: 2, minTimeout: 1000 });
|
|
56
|
+
* const mysqlClient = createMysqlClient(pool, undefined, 5000); // 5s query timeout
|
|
62
57
|
*/
|
|
63
|
-
const createMysqlClient = (pool, retryOptions) => {
|
|
58
|
+
const createMysqlClient = (pool, retryOptions, queryTimeout) => {
|
|
64
59
|
monitor_1.monitor.emit(monitor_1.MonitorEvents.CONNECTION_CREATED, {
|
|
65
60
|
clientType: 'mysql',
|
|
66
61
|
poolOptions: pool.config,
|
|
@@ -77,7 +72,9 @@ const createMysqlClient = (pool, retryOptions) => {
|
|
|
77
72
|
params,
|
|
78
73
|
attempt,
|
|
79
74
|
});
|
|
80
|
-
const [rows] =
|
|
75
|
+
const [rows] = queryTimeout
|
|
76
|
+
? await pool.execute({ sql, timeout: queryTimeout }, params)
|
|
77
|
+
: await pool.execute(sql, params);
|
|
81
78
|
const elapsedTime = Date.now() - startTime;
|
|
82
79
|
monitor_1.monitor.emit(monitor_1.MonitorEvents.QUERY_END, {
|
|
83
80
|
clientType: 'mysql',
|
|
@@ -99,7 +96,6 @@ const createMysqlClient = (pool, retryOptions) => {
|
|
|
99
96
|
error,
|
|
100
97
|
});
|
|
101
98
|
if (isTransientError(error)) {
|
|
102
|
-
console.warn(`MySQL query attempt ${attempt} failed, retrying...`, error);
|
|
103
99
|
monitor_1.monitor.emit(monitor_1.MonitorEvents.RETRY_ATTEMPT, {
|
|
104
100
|
clientType: 'mysql',
|
|
105
101
|
sql,
|
|
@@ -128,7 +124,9 @@ const createMysqlClient = (pool, retryOptions) => {
|
|
|
128
124
|
attempt: 1,
|
|
129
125
|
inTransaction: true,
|
|
130
126
|
});
|
|
131
|
-
const [rows] =
|
|
127
|
+
const [rows] = queryTimeout
|
|
128
|
+
? await connection.execute({ sql, timeout: queryTimeout }, params)
|
|
129
|
+
: await connection.execute(sql, params);
|
|
132
130
|
const elapsedTime = Date.now() - startTime;
|
|
133
131
|
monitor_1.monitor.emit(monitor_1.MonitorEvents.QUERY_END, {
|
|
134
132
|
clientType: 'mysql',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mysqlClient.js","sourceRoot":"","sources":["../../../src/db/mysqlClient.ts"],"names":[],"mappings":";;;;;;AACA,kEAAwC;AAGxC,gDAA2D;AAE3D,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,YAAY;IACZ,WAAW;IACX,0BAA0B;IAC1B,cAAc;CACf,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAS,gBAAgB,CAAC,KAAU;IAClC,OAAO,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AACnE,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"mysqlClient.js","sourceRoot":"","sources":["../../../src/db/mysqlClient.ts"],"names":[],"mappings":";;;;;;AACA,kEAAwC;AAGxC,gDAA2D;AAE3D,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,YAAY;IACZ,WAAW;IACX,0BAA0B;IAC1B,cAAc;CACf,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAS,gBAAgB,CAAC,KAAU;IAClC,OAAO,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AACnE,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,iBAAiB,GAAG,CAC/B,IAAU,EACV,YAA2B,EAC3B,YAAqB,EACJ,EAAE;IACnB,iBAAO,CAAC,IAAI,CAAC,uBAAa,CAAC,kBAAkB,EAAE;QAC7C,UAAU,EAAE,OAAO;QACnB,WAAW,EAAE,IAAI,CAAC,MAAM;KACzB,CAAC,CAAA;IAEF,OAAO;QACL,UAAU,EAAE,OAAO;QACnB,KAAK,EAAE,KAAK,EAAK,GAAW,EAAE,MAAc,EAAc,EAAE;YAC1D,OAAO,IA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G,EAAE,GAAG,SAAS,CAAA;4BAC1C,iBAAO,CAAC,IAAI,CAAC,uBAAa,CAAC,WAAW,EAAE;gCACtC,UAAU,EAAE,OAAO;gCACnB,GAAG;gCACH,MAAM;gCACN,OAAO,EAAE,CAAC;gCACV,WAAW;gCACX,KAAK;gCACL,aAAa,EAAE,IAAI;6BACpB,CAAC,CAAA;4BACF,MAAM,KAAK,CAAA;wBACb,CAAC;oBACH,CAAC;oBACD,MAAM,EAAE,KAAK,IAAmB,EAAE;wBAChC,IAAI,CAAC;4BACH,MAAM,UAAU,CAAC,MAAM,EAAE,CAAA;4BACzB,iBAAO,CAAC,IAAI,CAAC,uBAAa,CAAC,kBAAkB,EAAE;gCAC7C,UAAU,EAAE,OAAO;6BACpB,CAAC,CAAA;wBACJ,CAAC;gCAAS,CAAC;4BACT,UAAU,CAAC,OAAO,EAAE,CAAA;wBACtB,CAAC;oBACH,CAAC;oBACD,QAAQ,EAAE,KAAK,IAAmB,EAAE;wBAClC,IAAI,CAAC;4BACH,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAA;4BAC3B,iBAAO,CAAC,IAAI,CAAC,uBAAa,CAAC,oBAAoB,EAAE;gCAC/C,UAAU,EAAE,OAAO;6BACpB,CAAC,CAAA;wBACJ,CAAC;gCAAS,CAAC;4BACT,UAAU,CAAC,OAAO,EAAE,CAAA;wBACtB,CAAC;oBACH,CAAC;iBACF,CAAA;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,UAAU,CAAC,OAAO,EAAE,CAAA;gBACpB,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AA7IY,QAAA,iBAAiB,qBA6I7B"}
|
package/dist/src/db/pgClient.js
CHANGED
|
@@ -58,7 +58,6 @@ async function ensureUnaccentExtension(pool) {
|
|
|
58
58
|
extension: 'unaccent',
|
|
59
59
|
status: 'installed',
|
|
60
60
|
});
|
|
61
|
-
console.info('@starbemtech/star-db-query-builder: Extensão unaccent instalada com sucesso.');
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
catch (error) {
|
|
@@ -134,7 +133,6 @@ const createPgClient = async (pool, retryOptions, poolConfig, installUnaccentExt
|
|
|
134
133
|
error,
|
|
135
134
|
});
|
|
136
135
|
if (isTransientError(error)) {
|
|
137
|
-
console.warn(`Postgres query attempt ${attempt} failed, retrying...`, error);
|
|
138
136
|
monitor_1.monitor.emit(monitor_1.MonitorEvents.RETRY_ATTEMPT, {
|
|
139
137
|
clientType: 'pg',
|
|
140
138
|
sql,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pgClient.js","sourceRoot":"","sources":["../../../src/db/pgClient.ts"],"names":[],"mappings":";;;;;;AACA,kEAAwC;AAGxC,gDAA2D;AAE3D,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,CAAA;AAEhF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAS,gBAAgB,CAAC,KAAU;IAClC,OAAO,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AACnE,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,KAAK,UAAU,uBAAuB,CAAC,IAAU;IAC/C,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC;;KAEpC,CAAC,CAAA;QAEF,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAA;YAE3D,iBAAO,CAAC,IAAI,CAAC,uBAAa,CAAC,kBAAkB,EAAE;gBAC7C,UAAU,EAAE,IAAI;gBAChB,SAAS,EAAE,UAAU;gBACrB,MAAM,EAAE,WAAW;aACpB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file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MonitorEvents || (exports.MonitorEvents = MonitorEvents = {}));
|
|
18
18
|
exports.monitor = new stream_1.EventEmitter();
|
|
19
|
+
// This is a shared singleton: an app using multiple named db clients
|
|
20
|
+
// (see initDb's `name` option) can easily attach more than the default 10
|
|
21
|
+
// listeners per event (e.g. one logger/metrics/tracing consumer per client),
|
|
22
|
+
// without that being a real leak. Raise the cap instead of letting Node warn
|
|
23
|
+
// on a legitimate multi-client setup; still bounded (not 0/Infinity) so an
|
|
24
|
+
// actual listener leak keeps surfacing a warning.
|
|
25
|
+
exports.monitor.setMaxListeners(20);
|
|
19
26
|
//# sourceMappingURL=monitor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../../src/monitor/monitor.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAErC;;GAEG;AACH,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,0DAAyC,CAAA;IACzC,4CAA2B,CAAA;IAC3B,wCAAuB,CAAA;IACvB,4CAA2B,CAAA;IAC3B,gDAA+B,CAAA;IAC/B,0DAAyC,CAAA;IACzC,8DAA6C,CAAA;AAC/C,CAAC,EARW,aAAa,6BAAb,aAAa,QAQxB;AAEY,QAAA,OAAO,GAAG,IAAI,qBAAY,EAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../../src/monitor/monitor.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAErC;;GAEG;AACH,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,0DAAyC,CAAA;IACzC,4CAA2B,CAAA;IAC3B,wCAAuB,CAAA;IACvB,4CAA2B,CAAA;IAC3B,gDAA+B,CAAA;IAC/B,0DAAyC,CAAA;IACzC,8DAA6C,CAAA;AAC/C,CAAC,EARW,aAAa,6BAAb,aAAa,QAQxB;AAEY,QAAA,OAAO,GAAG,IAAI,qBAAY,EAAE,CAAA;AAEzC,qEAAqE;AACrE,0EAA0E;AAC1E,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,kDAAkD;AAClD,eAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starbemtech/star-db-query-builder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "A query builder to be used with mysql or postgres",
|
|
5
5
|
"author": "Julio Sousa <julio.sousa@starbem.app>",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"star-db-query-builder-install-skill": "./bin/install-skill.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"bin",
|
|
14
|
+
".claude",
|
|
15
|
+
"CHANGELOG.md"
|
|
16
|
+
],
|
|
8
17
|
"license": "MIT",
|
|
9
18
|
"engines": {
|
|
10
19
|
"node": ">=18"
|
|
11
20
|
},
|
|
12
21
|
"repository": {
|
|
13
22
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/
|
|
23
|
+
"url": "git+https://github.com/Starbem/star-db-query-builder.git"
|
|
15
24
|
},
|
|
16
25
|
"bugs": {
|
|
17
|
-
"url": "https://github.com/
|
|
26
|
+
"url": "https://github.com/Starbem/star-db-query-builder/issues"
|
|
18
27
|
},
|
|
19
28
|
"keywords": [
|
|
20
29
|
"javascript",
|
|
@@ -36,6 +45,7 @@
|
|
|
36
45
|
"lint": "eslint src/**/*.ts",
|
|
37
46
|
"lint:fix": "eslint src/**/*.ts --fix",
|
|
38
47
|
"format": "prettier --write src/**/*.ts",
|
|
48
|
+
"format:check": "prettier --check src/**/*.ts",
|
|
39
49
|
"type:check": "tsc --noEmit",
|
|
40
50
|
"clean": "rm -rf dist coverage",
|
|
41
51
|
"prebuild": "npm run clean",
|
|
@@ -49,34 +59,32 @@
|
|
|
49
59
|
"prepublishOnly": "npm run clean && npm run build && npm run test:ci"
|
|
50
60
|
},
|
|
51
61
|
"dependencies": {
|
|
52
|
-
"mysql2": "^3.
|
|
53
|
-
"pg": "^8.
|
|
62
|
+
"mysql2": "^3.24.3",
|
|
63
|
+
"pg": "^8.23.0",
|
|
54
64
|
"promise-retry": "^2.0.1",
|
|
55
|
-
"uuid": "^11.1.
|
|
65
|
+
"uuid": "^11.1.1"
|
|
56
66
|
},
|
|
57
67
|
"devDependencies": {
|
|
58
|
-
"@eslint/js": "^9.
|
|
68
|
+
"@eslint/js": "^9.39.5",
|
|
59
69
|
"@types/jest": "^29.5.14",
|
|
60
70
|
"@types/mysql": "^2.15.27",
|
|
61
|
-
"@types/node": "^24.3
|
|
62
|
-
"@types/pg": "^8.
|
|
71
|
+
"@types/node": "^24.13.3",
|
|
72
|
+
"@types/pg": "^8.23.1",
|
|
63
73
|
"@types/promise-retry": "^1.1.6",
|
|
64
74
|
"@types/uuid": "^10.0.0",
|
|
65
|
-
"
|
|
66
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
67
|
-
"eslint": "^9.35.0",
|
|
75
|
+
"eslint": "^9.39.5",
|
|
68
76
|
"eslint-config-prettier": "^10.1.8",
|
|
69
77
|
"eslint-plugin-jest": "^28.14.0",
|
|
70
|
-
"eslint-plugin-prettier": "^5.5.
|
|
71
|
-
"globals": "^16.
|
|
78
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
79
|
+
"globals": "^16.5.0",
|
|
72
80
|
"husky": "^9.1.7",
|
|
73
81
|
"jest": "^29.7.0",
|
|
74
|
-
"lint-staged": "^16.
|
|
75
|
-
"prettier": "^3.6
|
|
76
|
-
"ts-jest": "^29.4.
|
|
82
|
+
"lint-staged": "^16.4.0",
|
|
83
|
+
"prettier": "^3.9.6",
|
|
84
|
+
"ts-jest": "^29.4.12",
|
|
77
85
|
"ts-node": "^10.9.2",
|
|
78
|
-
"typescript": "^5.9.
|
|
79
|
-
"typescript-eslint": "^8.
|
|
86
|
+
"typescript": "^5.9.3",
|
|
87
|
+
"typescript-eslint": "^8.69.0"
|
|
80
88
|
},
|
|
81
89
|
"lint-staged": {
|
|
82
90
|
"*.{ts}": [
|
|
@@ -90,4 +98,4 @@
|
|
|
90
98
|
}
|
|
91
99
|
},
|
|
92
100
|
"packageManager": "pnpm@8.6.2"
|
|
93
|
-
}
|
|
101
|
+
}
|