@nmakarov/cli-toolkit 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/args.cjs +1 -4
- package/dist/args.cjs.map +1 -1
- package/dist/args.js +1 -1
- package/dist/args.js.map +1 -1
- package/dist/cli-runner.cjs +1252 -604
- package/dist/cli-runner.cjs.map +1 -1
- package/dist/cli-runner.js +1299 -650
- package/dist/cli-runner.js.map +1 -1
- package/dist/db.cjs +85 -157
- package/dist/db.cjs.map +1 -1
- package/dist/db.js +84 -150
- package/dist/db.js.map +1 -1
- package/dist/errors.cjs +2 -2
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js +2 -1
- package/dist/errors.js.map +1 -1
- package/dist/filedatabase.cjs +19 -19
- package/dist/filedatabase.cjs.map +1 -1
- package/dist/filedatabase.js +19 -16
- package/dist/filedatabase.js.map +1 -1
- package/dist/http-client.cjs +9 -11
- package/dist/http-client.cjs.map +1 -1
- package/dist/http-client.js +10 -9
- package/dist/http-client.js.map +1 -1
- package/dist/http-client2.cjs +34 -37
- package/dist/http-client2.cjs.map +1 -1
- package/dist/http-client2.js +34 -34
- package/dist/http-client2.js.map +1 -1
- package/dist/index.cjs +1739 -720
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1746 -721
- package/dist/index.js.map +1 -1
- package/dist/init.cjs +81 -68
- package/dist/init.cjs.map +1 -1
- package/dist/init.js +96 -82
- package/dist/init.js.map +1 -1
- package/dist/logger.cjs +5 -5
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.js +5 -4
- package/dist/logger.js.map +1 -1
- package/dist/mock-server.cjs +21 -33
- package/dist/mock-server.cjs.map +1 -1
- package/dist/mock-server.js +21 -28
- package/dist/mock-server.js.map +1 -1
- package/dist/params.cjs +6 -9
- package/dist/params.cjs.map +1 -1
- package/dist/params.js +6 -6
- package/dist/params.js.map +1 -1
- package/dist/s3.cjs +286 -0
- package/dist/s3.cjs.map +1 -0
- package/dist/s3.js +273 -0
- package/dist/s3.js.map +1 -0
- package/dist/screen.cjs +34 -39
- package/dist/screen.cjs.map +1 -1
- package/dist/screen.js +48 -46
- package/dist/screen.js.map +1 -1
- package/dist/tasks.cjs +1354 -501
- package/dist/tasks.cjs.map +1 -1
- package/dist/tasks.js +1369 -527
- package/dist/tasks.js.map +1 -1
- package/dist/utils.cjs +7 -8
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +6 -6
- package/dist/utils.js.map +1 -1
- package/package.json +32 -47
- package/scripts/ssm/{parse-cli.ts → parse-cli.js} +4 -4
- package/scripts/ssm/{ssm-admin.ts → ssm-admin.js} +12 -12
- package/scripts/ssm/{ssm-pull.ts → ssm-pull.js} +10 -13
package/dist/db.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// src/db/index.
|
|
1
|
+
// src/db/index.js
|
|
2
2
|
import knex from "knex";
|
|
3
3
|
|
|
4
|
-
// src/errors.
|
|
4
|
+
// src/errors.js
|
|
5
5
|
var FrameworkError = class extends Error {
|
|
6
6
|
constructor(message) {
|
|
7
7
|
super(message);
|
|
@@ -15,21 +15,56 @@ var ParamError = class extends FrameworkError {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
// src/db/index.
|
|
18
|
+
// src/db/index.js
|
|
19
|
+
var KNEX_DEFAULTS = {
|
|
20
|
+
testConnection: true,
|
|
21
|
+
pool: { min: 2, max: 10 },
|
|
22
|
+
acquireConnectionTimeout: 1e4,
|
|
23
|
+
ssl: { rejectUnauthorized: false }
|
|
24
|
+
};
|
|
19
25
|
var Db = class {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
static async init(context, options = {}) {
|
|
27
|
+
const defs = {
|
|
28
|
+
dbName: "string",
|
|
29
|
+
dbConnectionString: "string",
|
|
30
|
+
dbProfile: "boolean default false"
|
|
31
|
+
};
|
|
32
|
+
const discovered = context?.params?.getAllForModule?.("db", defs) ?? {};
|
|
33
|
+
const merged = { ...discovered, ...options };
|
|
34
|
+
let { dbName, dbConnectionString } = merged;
|
|
35
|
+
const { dbProfile } = merged;
|
|
36
|
+
if (!dbName && !dbConnectionString) {
|
|
37
|
+
dbName = "local";
|
|
38
|
+
}
|
|
39
|
+
if (dbName && /^(postgresql|mysql):\/\//.test(dbName)) {
|
|
40
|
+
dbConnectionString = dbName;
|
|
41
|
+
dbName = void 0;
|
|
42
|
+
}
|
|
43
|
+
if (dbName && !dbConnectionString) {
|
|
44
|
+
const paramName = `dbConnectionString${capitalizeFirstLetter(dbName)}`;
|
|
45
|
+
dbConnectionString = await context.params.get(paramName, "string");
|
|
46
|
+
if (!dbConnectionString) {
|
|
47
|
+
throw new ParamError(
|
|
48
|
+
`Db: cannot find dbConnectionString for dbName="${dbName}" (looked for param "${paramName}")`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const config = {
|
|
53
|
+
...KNEX_DEFAULTS,
|
|
54
|
+
connectionString: dbConnectionString,
|
|
55
|
+
name: dbName || merged.name || "default",
|
|
56
|
+
profile: !!dbProfile,
|
|
57
|
+
logger: context.logger
|
|
58
|
+
};
|
|
59
|
+
return dbConnect(context, config);
|
|
60
|
+
}
|
|
29
61
|
constructor(config) {
|
|
30
|
-
if (!config.connectionString) {
|
|
62
|
+
if (!config || !config.connectionString) {
|
|
31
63
|
throw new ParamError("Db: connectionString is required");
|
|
32
64
|
}
|
|
65
|
+
this.knexInstance = null;
|
|
66
|
+
this.isConnected = false;
|
|
67
|
+
this.queriesLog = [];
|
|
33
68
|
this.config = {
|
|
34
69
|
testConnection: true,
|
|
35
70
|
profile: false,
|
|
@@ -42,25 +77,23 @@ var Db = class {
|
|
|
42
77
|
};
|
|
43
78
|
this.logger = this.config.logger;
|
|
44
79
|
const instance = this;
|
|
45
|
-
const callableWrapper = function(
|
|
80
|
+
const callableWrapper = function() {
|
|
46
81
|
throw new Error("This should never be called directly");
|
|
47
82
|
};
|
|
48
83
|
callableWrapper._instance = instance;
|
|
49
84
|
return new Proxy(callableWrapper, {
|
|
50
|
-
|
|
51
|
-
apply: (target, thisArg, argumentsList) => {
|
|
85
|
+
apply: (target, _thisArg, argumentsList) => {
|
|
52
86
|
const inst = target._instance;
|
|
53
87
|
if (!inst.knexInstance) {
|
|
54
88
|
throw new Error("Db: Not connected. Call connect() first.");
|
|
55
89
|
}
|
|
56
90
|
return inst.knexInstance(...argumentsList);
|
|
57
91
|
},
|
|
58
|
-
// Intercept property access: db.schema, db.raw, etc.
|
|
59
92
|
get: (target, prop) => {
|
|
60
93
|
if (prop === "_instance") {
|
|
61
94
|
return target._instance;
|
|
62
95
|
}
|
|
63
|
-
const
|
|
96
|
+
const inst = target._instance;
|
|
64
97
|
const ownMethods = [
|
|
65
98
|
"connect",
|
|
66
99
|
"disconnect",
|
|
@@ -73,26 +106,26 @@ var Db = class {
|
|
|
73
106
|
"detectClient",
|
|
74
107
|
"attachProfiler"
|
|
75
108
|
];
|
|
76
|
-
if (prop in
|
|
77
|
-
const value =
|
|
109
|
+
if (prop in inst) {
|
|
110
|
+
const value = inst[prop];
|
|
78
111
|
if (typeof value === "function" && ownMethods.includes(prop)) {
|
|
79
|
-
return value.bind(
|
|
112
|
+
return value.bind(inst);
|
|
80
113
|
}
|
|
81
114
|
if (typeof value !== "function") {
|
|
82
115
|
return value;
|
|
83
116
|
}
|
|
84
117
|
}
|
|
85
|
-
if (
|
|
86
|
-
const knexProp =
|
|
118
|
+
if (inst.knexInstance) {
|
|
119
|
+
const knexProp = inst.knexInstance[prop];
|
|
87
120
|
if (typeof knexProp === "function") {
|
|
88
|
-
return knexProp.bind(
|
|
121
|
+
return knexProp.bind(inst.knexInstance);
|
|
89
122
|
}
|
|
90
123
|
return knexProp;
|
|
91
124
|
}
|
|
92
|
-
if (prop in
|
|
93
|
-
const method =
|
|
125
|
+
if (prop in inst) {
|
|
126
|
+
const method = inst[prop];
|
|
94
127
|
if (typeof method === "function") {
|
|
95
|
-
return method.bind(
|
|
128
|
+
return method.bind(inst);
|
|
96
129
|
}
|
|
97
130
|
return method;
|
|
98
131
|
}
|
|
@@ -100,9 +133,6 @@ var Db = class {
|
|
|
100
133
|
}
|
|
101
134
|
});
|
|
102
135
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Detect database client type from connection string
|
|
105
|
-
*/
|
|
106
136
|
detectClient(connectionString) {
|
|
107
137
|
if (connectionString.match(/^postgresql/)) {
|
|
108
138
|
return "pg";
|
|
@@ -112,9 +142,6 @@ var Db = class {
|
|
|
112
142
|
}
|
|
113
143
|
return null;
|
|
114
144
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Connect to the database
|
|
117
|
-
*/
|
|
118
145
|
async connect() {
|
|
119
146
|
if (this.isConnected && this.knexInstance) {
|
|
120
147
|
this.logger.warn?.("[Db] Already connected");
|
|
@@ -123,14 +150,13 @@ var Db = class {
|
|
|
123
150
|
const client = this.detectClient(this.config.connectionString);
|
|
124
151
|
if (!client) {
|
|
125
152
|
throw new ParamError(
|
|
126
|
-
|
|
153
|
+
"Db: Cannot determine client type from connection string. Expected postgresql:// or mysql://"
|
|
127
154
|
);
|
|
128
155
|
}
|
|
129
156
|
try {
|
|
130
157
|
const connectionConfig = {
|
|
131
158
|
connectionString: this.config.connectionString,
|
|
132
159
|
family: 4
|
|
133
|
-
// Force IPv4 only (disable IPv6)
|
|
134
160
|
};
|
|
135
161
|
this.knexInstance = knex({
|
|
136
162
|
client,
|
|
@@ -146,7 +172,9 @@ var Db = class {
|
|
|
146
172
|
await this.testConnection();
|
|
147
173
|
}
|
|
148
174
|
this.isConnected = true;
|
|
149
|
-
this.logger.debug?.(
|
|
175
|
+
this.logger.debug?.(
|
|
176
|
+
`[Db] Connected to database "${this.config.name || this.config.connectionString}"`
|
|
177
|
+
);
|
|
150
178
|
} catch (error) {
|
|
151
179
|
if (error instanceof ParamError) {
|
|
152
180
|
throw error;
|
|
@@ -155,9 +183,6 @@ var Db = class {
|
|
|
155
183
|
throw new ParamError(`Db: Connection failed - ${errorMsg}`);
|
|
156
184
|
}
|
|
157
185
|
}
|
|
158
|
-
/**
|
|
159
|
-
* Disconnect from the database
|
|
160
|
-
*/
|
|
161
186
|
async disconnect() {
|
|
162
187
|
if (!this.knexInstance) {
|
|
163
188
|
return;
|
|
@@ -167,16 +192,15 @@ var Db = class {
|
|
|
167
192
|
this.knexInstance = null;
|
|
168
193
|
this.isConnected = false;
|
|
169
194
|
this.queriesLog = [];
|
|
170
|
-
this.logger.debug?.(
|
|
195
|
+
this.logger.debug?.(
|
|
196
|
+
`[Db] Disconnected from database "${this.config.name || this.config.connectionString}"`
|
|
197
|
+
);
|
|
171
198
|
} catch (error) {
|
|
172
199
|
const errorMsg = this.getErrorMessage(error);
|
|
173
200
|
this.logger.error?.(`[Db] Error disconnecting: ${errorMsg}`);
|
|
174
201
|
throw error;
|
|
175
202
|
}
|
|
176
203
|
}
|
|
177
|
-
/**
|
|
178
|
-
* Extract error message from various error types
|
|
179
|
-
*/
|
|
180
204
|
getErrorMessage(error) {
|
|
181
205
|
if (error instanceof AggregateError) {
|
|
182
206
|
const errors = error.errors || [];
|
|
@@ -201,9 +225,11 @@ var Db = class {
|
|
|
201
225
|
return `${code} (tried: ${addresses.join(", ")})`;
|
|
202
226
|
}
|
|
203
227
|
}
|
|
204
|
-
const uniqueMessages = [
|
|
205
|
-
|
|
206
|
-
|
|
228
|
+
const uniqueMessages = [
|
|
229
|
+
...new Set(
|
|
230
|
+
errors.map((e) => e instanceof Error ? e.message : String(e))
|
|
231
|
+
)
|
|
232
|
+
];
|
|
207
233
|
if (uniqueMessages.length === 1) {
|
|
208
234
|
return uniqueMessages[0];
|
|
209
235
|
}
|
|
@@ -212,28 +238,25 @@ var Db = class {
|
|
|
212
238
|
return error.message || "Multiple errors occurred";
|
|
213
239
|
}
|
|
214
240
|
if (error instanceof Error) {
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
217
|
-
return `${
|
|
241
|
+
const code = error.code;
|
|
242
|
+
if (code) {
|
|
243
|
+
return `${code}: ${error.message || String(error)}`;
|
|
218
244
|
}
|
|
219
245
|
return error.message || String(error);
|
|
220
246
|
}
|
|
221
247
|
if (typeof error === "string") {
|
|
222
248
|
return error;
|
|
223
249
|
}
|
|
224
|
-
if (error
|
|
250
|
+
if (error && typeof error === "object" && "message" in error) {
|
|
225
251
|
const msg = String(error.message);
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
228
|
-
return `${
|
|
252
|
+
const code = error.code;
|
|
253
|
+
if (code) {
|
|
254
|
+
return `${code}: ${msg}`;
|
|
229
255
|
}
|
|
230
256
|
return msg;
|
|
231
257
|
}
|
|
232
258
|
return String(error) || "Unknown error";
|
|
233
259
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Test database connection
|
|
236
|
-
*/
|
|
237
260
|
async testConnection() {
|
|
238
261
|
if (!this.knexInstance) {
|
|
239
262
|
throw new Error("Db: Not connected. Call connect() first.");
|
|
@@ -249,9 +272,6 @@ var Db = class {
|
|
|
249
272
|
throw new ParamError(`Db: Connection test failed - ${errorMsg}`);
|
|
250
273
|
}
|
|
251
274
|
}
|
|
252
|
-
/**
|
|
253
|
-
* Attach query profiler to log all queries
|
|
254
|
-
*/
|
|
255
275
|
attachProfiler() {
|
|
256
276
|
if (!this.knexInstance) {
|
|
257
277
|
return;
|
|
@@ -261,7 +281,7 @@ var Db = class {
|
|
|
261
281
|
this.knexInstance.on("query", (query) => {
|
|
262
282
|
query.__startTime = process.hrtime();
|
|
263
283
|
});
|
|
264
|
-
this.knexInstance.on("query-response", (
|
|
284
|
+
this.knexInstance.on("query-response", (_response, query) => {
|
|
265
285
|
const [seconds, nanoseconds] = process.hrtime(query.__startTime);
|
|
266
286
|
const executionTimeMs = (seconds * 1e3 + nanoseconds / 1e6).toFixed(2);
|
|
267
287
|
const logEntry = {
|
|
@@ -276,15 +296,9 @@ var Db = class {
|
|
|
276
296
|
this.logger.error?.(`[Db] Query failed: ${query.sql}`, error);
|
|
277
297
|
});
|
|
278
298
|
}
|
|
279
|
-
/**
|
|
280
|
-
* Get query log (only available if profiling is enabled)
|
|
281
|
-
*/
|
|
282
299
|
getQueryLog() {
|
|
283
300
|
return [...this.queriesLog];
|
|
284
301
|
}
|
|
285
|
-
/**
|
|
286
|
-
* Check if a table exists
|
|
287
|
-
*/
|
|
288
302
|
async tableExists(tableName) {
|
|
289
303
|
if (!this.knexInstance) {
|
|
290
304
|
throw new Error("Db: Not connected. Call connect() first.");
|
|
@@ -296,65 +310,28 @@ var Db = class {
|
|
|
296
310
|
throw error;
|
|
297
311
|
}
|
|
298
312
|
}
|
|
299
|
-
/**
|
|
300
|
-
* Get the underlying Knex instance (for advanced usage)
|
|
301
|
-
*/
|
|
302
313
|
getKnex() {
|
|
303
314
|
if (!this.knexInstance) {
|
|
304
315
|
throw new Error("Db: Not connected. Call connect() first.");
|
|
305
316
|
}
|
|
306
317
|
return this.knexInstance;
|
|
307
318
|
}
|
|
308
|
-
/**
|
|
309
|
-
* Get connection status
|
|
310
|
-
*/
|
|
311
319
|
isConnectedToDb() {
|
|
312
320
|
return this.isConnected && this.knexInstance !== null;
|
|
313
321
|
}
|
|
314
|
-
/**
|
|
315
|
-
* Initialize Db with context (connects and registers disconnect cleanup).
|
|
316
|
-
* Params are read via getAllForModule("db", defs). Same as dbInit(context, dbNameOrConnectionString).
|
|
317
|
-
*/
|
|
318
|
-
static async init(context, dbNameOrConnectionString) {
|
|
319
|
-
return dbFindAndConnect(context, dbNameOrConnectionString);
|
|
320
|
-
}
|
|
321
322
|
};
|
|
322
323
|
function capitalizeFirstLetter(str) {
|
|
323
324
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
324
325
|
}
|
|
325
|
-
async function dbConnect(context,
|
|
326
|
-
const defs = {
|
|
327
|
-
testDbConnection: "boolean default true",
|
|
328
|
-
name: "string",
|
|
329
|
-
poolMin: "number default 2",
|
|
330
|
-
poolMax: "number default 10",
|
|
331
|
-
acquireConnectionTimeout: "number default 10000",
|
|
332
|
-
sslRejectUnauthorized: "boolean default false"
|
|
333
|
-
};
|
|
334
|
-
const paramsConfig = context.params.getAllForModule(defs);
|
|
335
|
-
const config = {
|
|
336
|
-
connectionString,
|
|
337
|
-
name: paramsConfig.name || name || "default",
|
|
338
|
-
testConnection: paramsConfig.testDbConnection,
|
|
339
|
-
profile: dbProfile ?? false,
|
|
340
|
-
pool: {
|
|
341
|
-
min: paramsConfig.poolMin,
|
|
342
|
-
max: paramsConfig.poolMax
|
|
343
|
-
},
|
|
344
|
-
acquireConnectionTimeout: paramsConfig.acquireConnectionTimeout,
|
|
345
|
-
ssl: {
|
|
346
|
-
rejectUnauthorized: paramsConfig.sslRejectUnauthorized
|
|
347
|
-
},
|
|
348
|
-
logger: context.logger
|
|
349
|
-
};
|
|
326
|
+
async function dbConnect(context, config) {
|
|
350
327
|
try {
|
|
351
328
|
const db = new Db(config);
|
|
352
329
|
context.registerCleanup(async () => {
|
|
353
330
|
await db.disconnect();
|
|
354
|
-
context.logger.debug(`[Db] instance "${name
|
|
331
|
+
context.logger.debug?.(`[Db] instance "${config.name}" disconnected`);
|
|
355
332
|
});
|
|
356
333
|
await db.connect();
|
|
357
|
-
context.logger.debug(`[Db] instance "${name
|
|
334
|
+
context.logger.debug?.(`[Db] instance "${config.name}" initialized`);
|
|
358
335
|
return db;
|
|
359
336
|
} catch (error) {
|
|
360
337
|
if (error instanceof ParamError) {
|
|
@@ -364,50 +341,7 @@ async function dbConnect(context, connectionString, name, dbProfile) {
|
|
|
364
341
|
throw new ParamError(`[Db] connect error: ${errorMsg}`);
|
|
365
342
|
}
|
|
366
343
|
}
|
|
367
|
-
async function dbFindAndConnect(context, dbNameOrConnectionString) {
|
|
368
|
-
let dbName;
|
|
369
|
-
let dbConnectionString;
|
|
370
|
-
let dbProfile;
|
|
371
|
-
if (dbNameOrConnectionString) {
|
|
372
|
-
if (dbNameOrConnectionString.match(/^(postgresql|mysql):\/\/[^\s]+:[^\s]+@[^\s]+:\d+\/[^\s]+$/)) {
|
|
373
|
-
dbName = void 0;
|
|
374
|
-
dbConnectionString = dbNameOrConnectionString;
|
|
375
|
-
} else {
|
|
376
|
-
dbName = dbNameOrConnectionString;
|
|
377
|
-
}
|
|
378
|
-
} else {
|
|
379
|
-
const defs = {
|
|
380
|
-
dbName: "string",
|
|
381
|
-
dbConnectionString: "string",
|
|
382
|
-
dbProfile: "boolean default false"
|
|
383
|
-
};
|
|
384
|
-
const paramsConfig = context.params.getAll(defs);
|
|
385
|
-
dbName = paramsConfig.dbName;
|
|
386
|
-
dbConnectionString = paramsConfig.dbConnectionString;
|
|
387
|
-
dbProfile = paramsConfig.dbProfile;
|
|
388
|
-
}
|
|
389
|
-
if (!dbName && !dbConnectionString) {
|
|
390
|
-
throw new ParamError("Db: either dbName or dbConnectionString must be specified");
|
|
391
|
-
}
|
|
392
|
-
if (dbName) {
|
|
393
|
-
const paramName = `dbConnectionString${capitalizeFirstLetter(dbName)}`;
|
|
394
|
-
dbConnectionString = await context.params.get(paramName, "string");
|
|
395
|
-
if (!dbConnectionString) {
|
|
396
|
-
throw new ParamError(
|
|
397
|
-
`Db: cannot find dbConnectionString for dbName="${dbName}" (looked for param "${paramName}")`
|
|
398
|
-
);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
const db = await dbConnect(context, dbConnectionString, dbName, dbProfile);
|
|
402
|
-
return db;
|
|
403
|
-
}
|
|
404
|
-
async function dbInit(context, dbNameOrConnectionString) {
|
|
405
|
-
return await dbFindAndConnect(context, dbNameOrConnectionString);
|
|
406
|
-
}
|
|
407
344
|
export {
|
|
408
|
-
Db
|
|
409
|
-
dbConnect,
|
|
410
|
-
dbFindAndConnect,
|
|
411
|
-
dbInit
|
|
345
|
+
Db
|
|
412
346
|
};
|
|
413
347
|
//# sourceMappingURL=db.js.map
|
package/dist/db.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/db/index.ts","../src/errors.ts"],"sourcesContent":["/**\n * Database Client - Low-level SQL database operations\n *\n * Wraps Knex.js with connection management, profiling, and utility functions.\n * The instance can be used directly like a Knex instance: db('table').select()\n */\n\nimport knex, { Knex } from 'knex';\nimport { ParamError } from '../errors.js';\nimport type { Context } from '../init/types.js';\nimport type { DbConfig, DbOptions, DatabaseClient, QueryLogEntry, DbInstance } from './types.js';\n\n/**\n * Database client wrapper around Knex\n * \n * Usage:\n * ```typescript\n * const db = new Db({\n * connectionString: 'postgresql://user:pass@host:5432/dbname',\n * testConnection: true,\n * profile: false\n * });\n * await db.connect();\n * \n * // Use like Knex:\n * const users = await db('users').select('*');\n * await db('posts').insert({ title: 'Hello' });\n * ```\n */\nexport class Db {\n private knexInstance: Knex | null = null;\n private config: Required<DbConfig>;\n private logger: any;\n private queriesLog: QueryLogEntry[] = [];\n private isConnected: boolean = false;\n\n /**\n * Constructor - accepts config object\n * Use dbInit() function to initialize with Context\n */\n constructor(config: DbConfig) {\n if (!config.connectionString) {\n throw new ParamError('Db: connectionString is required');\n }\n\n this.config = {\n testConnection: true,\n profile: false,\n pool: { min: 2, max: 10 },\n acquireConnectionTimeout: 10000,\n ssl: { rejectUnauthorized: false },\n logger: console,\n name: 'default',\n ...config,\n };\n\n this.logger = this.config.logger;\n\n // Create a callable function wrapper that forwards to the instance\n // This allows db('table') to work like Knex\n const instance = this;\n const callableWrapper = function(...args: any[]) {\n // This function body is never executed - the Proxy apply trap handles calls\n // But we need a function to make the Proxy apply trap work\n throw new Error('This should never be called directly');\n };\n \n // Store instance reference on the wrapper for Proxy access\n (callableWrapper as any)._instance = instance;\n\n // Create a Proxy that makes the wrapper callable and forwards property access\n return new Proxy(callableWrapper, {\n // Intercept function calls: db('table')\n apply: (target, thisArg, argumentsList) => {\n const inst = (target as any)._instance;\n if (!inst.knexInstance) {\n throw new Error('Db: Not connected. Call connect() first.');\n }\n // Forward the call to the Knex instance (Knex instances are callable)\n return (inst.knexInstance as any)(...argumentsList);\n },\n // Intercept property access: db.schema, db.raw, etc.\n get: (target, prop) => {\n // Allow access to _instance for internal use\n if (prop === '_instance') {\n return (target as any)._instance;\n }\n \n const instance = (target as any)._instance;\n \n // List of our own methods that should NOT be forwarded to Knex\n const ownMethods = [\n 'connect',\n 'disconnect',\n 'testConnection',\n 'tableExists',\n 'getQueryLog',\n 'getKnex',\n 'isConnectedToDb',\n 'getErrorMessage',\n 'detectClient',\n 'attachProfiler',\n ];\n \n // Always return our own methods first (before checking Knex)\n if (prop in instance) {\n const value = (instance as any)[prop];\n // If it's one of our own methods, return it bound to instance\n if (typeof value === 'function' && ownMethods.includes(prop as string)) {\n return value.bind(instance);\n }\n // If it's a non-function property, return it\n if (typeof value !== 'function') {\n return value;\n }\n }\n \n // If we have a Knex instance, forward to it for everything else\n if (instance.knexInstance) {\n const knexProp = (instance.knexInstance as any)[prop];\n if (typeof knexProp === 'function') {\n // Bind methods to the Knex instance\n return knexProp.bind(instance.knexInstance);\n }\n return knexProp;\n }\n \n // Return our own methods that aren't in the ownMethods list (shouldn't happen, but fallback)\n if (prop in instance) {\n const method = (instance as any)[prop];\n if (typeof method === 'function') {\n return method.bind(instance);\n }\n return method;\n }\n \n // Property doesn't exist\n return undefined;\n },\n }) as any;\n }\n\n /**\n * Detect database client type from connection string\n */\n private detectClient(connectionString: string): DatabaseClient | null {\n if (connectionString.match(/^postgresql/)) {\n return 'pg';\n }\n if (connectionString.match(/^mysql/)) {\n return 'mysql2';\n }\n return null;\n }\n\n /**\n * Connect to the database\n */\n async connect(): Promise<void> {\n if (this.isConnected && this.knexInstance) {\n this.logger.warn?.('[Db] Already connected');\n return;\n }\n\n const client = this.detectClient(this.config.connectionString);\n if (!client) {\n throw new ParamError(\n `Db: Cannot determine client type from connection string. Expected postgresql:// or mysql://`\n );\n }\n\n try {\n // Force IPv4 only (disable IPv6) by setting family: 4 in connection config\n // Knex accepts connection as string or object; we wrap string to add family option\n const connectionConfig = {\n connectionString: this.config.connectionString,\n family: 4, // Force IPv4 only (disable IPv6)\n };\n\n this.knexInstance = knex({\n client,\n connection: connectionConfig,\n pool: this.config.pool,\n acquireConnectionTimeout: this.config.acquireConnectionTimeout,\n ...(this.config.ssl && { ssl: this.config.ssl }),\n } as any);\n\n // Attach profiler if enabled\n if (this.config.profile) {\n this.attachProfiler();\n }\n\n // Test connection if requested\n if (this.config.testConnection) {\n await this.testConnection();\n }\n\n this.isConnected = true;\n this.logger.debug?.(`[Db] Connected to database \"${this.config.name || this.config.connectionString}\"`);\n } catch (error: any) {\n // If testConnection already threw a ParamError, preserve its message\n if (error instanceof ParamError) {\n throw error;\n }\n const errorMsg = this.getErrorMessage(error);\n throw new ParamError(`Db: Connection failed - ${errorMsg}`);\n }\n }\n\n /**\n * Disconnect from the database\n */\n async disconnect(): Promise<void> {\n if (!this.knexInstance) {\n return;\n }\n\n try {\n await this.knexInstance.destroy();\n this.knexInstance = null;\n this.isConnected = false;\n this.queriesLog = [];\n this.logger.debug?.(`[Db] Disconnected from database \"${this.config.name || this.config.connectionString}\"`);\n } catch (error: any) {\n const errorMsg = this.getErrorMessage(error);\n this.logger.error?.(`[Db] Error disconnecting: ${errorMsg}`);\n throw error;\n }\n }\n\n /**\n * Extract error message from various error types\n */\n private getErrorMessage(error: any): string {\n // Handle AggregateError (can contain multiple errors)\n if (error instanceof AggregateError) {\n const errors = error.errors || [];\n \n // If all errors are the same type (e.g., ECONNREFUSED for different IPs), show a consolidated message\n if (errors.length > 0) {\n const firstError = errors[0];\n const firstErrorMsg = firstError instanceof Error ? firstError.message : String(firstError);\n \n // Check if all errors are similar (same error code/type, different addresses)\n const allSimilar = errors.every((e: any) => {\n const msg = e instanceof Error ? e.message : String(e);\n // Extract error code (e.g., \"ECONNREFUSED\") from message\n const codeMatch = msg.match(/^(\\w+)\\s/);\n const firstCodeMatch = firstErrorMsg.match(/^(\\w+)\\s/);\n return codeMatch && firstCodeMatch && codeMatch[1] === firstCodeMatch[1];\n });\n \n if (allSimilar && errors.length > 1) {\n // Extract addresses/IPs from error messages\n const addresses = errors.map((e: any) => {\n const msg = e instanceof Error ? e.message : String(e);\n // Try to extract address (e.g., \"::1:5432\" or \"127.0.0.1:5432\")\n const addrMatch = msg.match(/([:\\d.]+:\\d+)/);\n return addrMatch ? addrMatch[1] : null;\n }).filter(Boolean);\n \n if (addresses.length > 0) {\n // Show consolidated message with all addresses\n const codeMatch = firstErrorMsg.match(/^(\\w+)\\s/);\n const code = codeMatch ? codeMatch[1] : 'Connection error';\n return `${code} (tried: ${addresses.join(', ')})`;\n }\n }\n \n // Fallback: show all errors but deduplicate identical messages\n const uniqueMessages = [...new Set(errors.map((e: any) => {\n return e instanceof Error ? e.message : String(e);\n }))];\n \n if (uniqueMessages.length === 1) {\n return uniqueMessages[0];\n }\n \n return uniqueMessages.join('; ');\n }\n \n return error.message || 'Multiple errors occurred';\n }\n \n // Handle standard Error objects\n if (error instanceof Error) {\n // Check for common database error properties (code is often present on Node.js errors)\n const errorWithCode = error as Error & { code?: string };\n if (errorWithCode.code) {\n return `${errorWithCode.code}: ${error.message || String(error)}`;\n }\n return error.message || String(error);\n }\n \n // Handle string errors\n if (typeof error === 'string') {\n return error;\n }\n \n // Handle objects with message property\n if (error?.message) {\n const msg = String(error.message);\n const errorWithCode = error as { code?: string };\n if (errorWithCode.code) {\n return `${errorWithCode.code}: ${msg}`;\n }\n return msg;\n }\n \n // Fallback: try to stringify the error\n return String(error) || 'Unknown error';\n }\n\n /**\n * Test database connection\n */\n async testConnection(): Promise<boolean> {\n if (!this.knexInstance) {\n throw new Error('Db: Not connected. Call connect() first.');\n }\n\n try {\n const result = await this.knexInstance.raw('SELECT 2+3 AS result');\n const isOk = result.rows?.[0]?.result === 5 || result[0]?.[0]?.result === 5;\n this.logger.debug?.(`[Db] Connection test: ${isOk ? 'OK' : 'FAILED'}`);\n return isOk;\n } catch (error: any) {\n const errorMsg = this.getErrorMessage(error);\n this.logger.error?.(`[Db] Connection test failed: ${errorMsg}`);\n throw new ParamError(`Db: Connection test failed - ${errorMsg}`);\n }\n }\n\n /**\n * Attach query profiler to log all queries\n */\n attachProfiler(): void {\n if (!this.knexInstance) {\n return;\n }\n\n this.queriesLog = [];\n (this.knexInstance as any).queriesLog = this.queriesLog;\n\n this.knexInstance.on('query', (query: any) => {\n query.__startTime = process.hrtime();\n });\n\n this.knexInstance.on('query-response', (response: any, query: any) => {\n const [seconds, nanoseconds] = process.hrtime(query.__startTime);\n const executionTimeMs = ((seconds * 1000) + (nanoseconds / 1e6)).toFixed(2);\n\n const logEntry: QueryLogEntry = {\n sql: query.sql,\n bindings: query.bindings || [],\n executionTimeMs,\n };\n\n this.queriesLog.push(logEntry);\n this.logger.debug?.(`[Db] Query: ${query.sql} | Duration: ${executionTimeMs}ms`);\n });\n\n this.knexInstance.on('query-error', (error: Error, query: any) => {\n this.logger.error?.(`[Db] Query failed: ${query.sql}`, error);\n });\n }\n\n /**\n * Get query log (only available if profiling is enabled)\n */\n getQueryLog(): QueryLogEntry[] {\n return [...this.queriesLog];\n }\n\n /**\n * Check if a table exists\n */\n async tableExists(tableName: string): Promise<boolean> {\n if (!this.knexInstance) {\n throw new Error('Db: Not connected. Call connect() first.');\n }\n\n try {\n return await this.knexInstance.schema.hasTable(tableName);\n } catch (error: any) {\n this.logger.error?.(`[Db] Error checking table existence: ${error.message}`);\n throw error;\n }\n }\n\n /**\n * Get the underlying Knex instance (for advanced usage)\n */\n getKnex(): Knex {\n if (!this.knexInstance) {\n throw new Error('Db: Not connected. Call connect() first.');\n }\n return this.knexInstance;\n }\n\n /**\n * Get connection status\n */\n isConnectedToDb(): boolean {\n return this.isConnected && this.knexInstance !== null;\n }\n\n /**\n * Initialize Db with context (connects and registers disconnect cleanup).\n * Params are read via getAllForModule(\"db\", defs). Same as dbInit(context, dbNameOrConnectionString).\n */\n static async init(context: Context, dbNameOrConnectionString?: string): Promise<Db> {\n return dbFindAndConnect(context, dbNameOrConnectionString);\n }\n}\n\n/**\n * Helper function to capitalize first letter of a string\n */\nfunction capitalizeFirstLetter(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n/**\n * Connect to database - creates Db instance, connects, registers cleanup, attaches profiler\n * \n * This is a dedicated connect function that handles:\n * - Creating Db instance with proper configuration\n * - Connecting to database\n * - Registering cleanup function\n * - Attaching profiler if needed\n * - Better error handling\n */\nexport async function dbConnect(\n context: Context,\n connectionString: string,\n name?: string,\n dbProfile?: boolean\n): Promise<Db> {\n // Get configuration from params\n const defs = {\n testDbConnection: 'boolean default true',\n name: 'string',\n poolMin: 'number default 2',\n poolMax: 'number default 10',\n acquireConnectionTimeout: 'number default 10000',\n sslRejectUnauthorized: 'boolean default false',\n };\n \n const paramsConfig = context.params.getAllForModule(defs);\n\n // Create config\n const config: DbConfig = {\n connectionString,\n name: paramsConfig.name || name || 'default',\n testConnection: paramsConfig.testDbConnection,\n profile: dbProfile ?? false,\n pool: {\n min: paramsConfig.poolMin,\n max: paramsConfig.poolMax,\n },\n acquireConnectionTimeout: paramsConfig.acquireConnectionTimeout,\n ssl: {\n rejectUnauthorized: paramsConfig.sslRejectUnauthorized,\n },\n logger: context.logger,\n };\n \n try {\n // Create Db instance\n const db = new Db(config);\n \n // Register cleanup function\n context.registerCleanup(async () => {\n await db.disconnect();\n context.logger.debug(`[Db] instance \"${name || connectionString}\" destroyed`);\n });\n \n // Connect to database (profiler is attached automatically if config.profile is true)\n await db.connect();\n \n context.logger.debug(`[Db] instance \"${name || connectionString}\" initialized`);\n \n return db;\n } catch (error: any) {\n // Better error handling\n if (error instanceof ParamError) {\n throw error;\n }\n const errorMsg = error instanceof Error ? error.message : String(error);\n throw new ParamError(`[Db] connect error: ${errorMsg}`);\n }\n}\n\n/**\n * Find and connect to database - resolves database name or connection string\n * \n * This function handles:\n * - Direct connection string (postgresql://... or mysql://...)\n * - Database name/label that gets resolved to dbConnectionString${CapitalizedName}\n * - Reading from params if no second parameter provided\n */\nexport async function dbFindAndConnect(\n context: Context,\n dbNameOrConnectionString?: string\n): Promise<Db> {\n let dbName: string | undefined;\n let dbConnectionString: string | undefined;\n let dbProfile: boolean | undefined;\n \n // If second parameter is provided\n if (dbNameOrConnectionString) {\n // Check if it looks like a connection string (postgresql:// or mysql://)\n if (dbNameOrConnectionString.match(/^(postgresql|mysql):\\/\\/[^\\s]+:[^\\s]+@[^\\s]+:\\d+\\/[^\\s]+$/)) {\n dbName = undefined;\n dbConnectionString = dbNameOrConnectionString;\n } else {\n // Treat it as a database name/label\n dbName = dbNameOrConnectionString;\n }\n } else {\n // No second parameter - read from params\n const defs = {\n dbName: 'string',\n dbConnectionString: 'string',\n dbProfile: 'boolean default false',\n };\n \n const paramsConfig = context.params.getAll(defs);\n dbName = paramsConfig.dbName;\n dbConnectionString = paramsConfig.dbConnectionString;\n dbProfile = paramsConfig.dbProfile;\n }\n \n // Validate that we have either dbName or dbConnectionString\n if (!dbName && !dbConnectionString) {\n throw new ParamError('Db: either dbName or dbConnectionString must be specified');\n }\n \n // If dbName is provided, resolve it to connection string\n if (dbName) {\n const paramName = `dbConnectionString${capitalizeFirstLetter(dbName)}`;\n dbConnectionString = await context.params.get(paramName, 'string');\n if (!dbConnectionString) {\n throw new ParamError(\n `Db: cannot find dbConnectionString for dbName=\"${dbName}\" (looked for param \"${paramName}\")`\n );\n }\n }\n \n // Connect using dedicated connect function\n // context.logger.notice(`[Db] connecting to database \"${dbConnectionString}\"`);\n // TODO: figure out the output of \"--showUsedParams\" in the case of the DB - stuff gets to \"script\" section that doesn't belong there.\n const db = await dbConnect(context, dbConnectionString!, dbName, dbProfile);\n \n // Test connection (connect() already tests if testConnection is true, but we can test explicitly here too)\n // The test is already done in db.connect() if config.testConnection is true\n \n return db;\n}\n\n/**\n * Initialize Db instance with context (auto-connects)\n * \n * This is the standard \"init\" function that auto-initializes the DB component.\n * It calls dbFindAndConnect, optionally passing a second parameter.\n * \n * Usage:\n * ```typescript\n * // Auto-initialize from params:\n * const db = await dbInit(context);\n * \n * // Or with database name/label:\n * const db = await dbInit(context, 'local');\n * \n * // Or with direct connection string:\n * const db = await dbInit(context, 'postgresql://user:pass@host:5432/dbname');\n * ```\n */\nexport async function dbInit(\n context: Context,\n dbNameOrConnectionString?: string\n): Promise<Db> {\n return await dbFindAndConnect(context, dbNameOrConnectionString);\n}\n\n","/**\n * Error classes for the CLI toolkit\n */\n\nexport class FrameworkError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"FrameworkError\";\n }\n}\n\nexport class ParamError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"ParamError\";\n }\n}\n\nexport class InitError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"InitError\";\n }\n}\n\nexport class CriticalRequestError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"CriticalRequestError\";\n }\n}\n\nexport class ControlFlowError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ControlFlowError\";\n }\n}\n\nexport class HttpClientError extends FrameworkError {\n constructor(message: string, public readonly cause?: Error) {\n super(message);\n this.name = \"HttpClientError\";\n }\n}\n\nexport class FileDatabaseError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"FileDatabaseError\";\n }\n}\n\n"],"mappings":";AAOA,OAAO,UAAoB;;;ACHpB,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACtC,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,aAAN,cAAyB,eAAe;AAAA,EAC3C,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;;;ADaO,IAAM,KAAN,MAAS;AAAA,EACJ,eAA4B;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,aAA8B,CAAC;AAAA,EAC/B,cAAuB;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,YAAY,QAAkB;AAC1B,QAAI,CAAC,OAAO,kBAAkB;AAC1B,YAAM,IAAI,WAAW,kCAAk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MAAM,wBAAwB,SAAS;AAAA,MAC7F;AAAA,IACJ;AAAA,EACJ;AAKA,QAAM,KAAK,MAAM,UAAU,SAAS,oBAAqB,QAAQ,SAAS;AAK1E,SAAO;AACX;AAoBA,eAAsB,OAClB,SACA,0BACW;AACX,SAAO,MAAM,iBAAiB,SAAS,wBAAwB;AACnE;","names":["instance"]}
|
|
1
|
+
{"version":3,"sources":["../src/db/index.js","../src/errors.js"],"sourcesContent":["import knex from \"knex\";\nimport { ParamError } from \"../errors.js\";\n\nconst KNEX_DEFAULTS = {\n testConnection: true,\n pool: { min: 2, max: 10 },\n acquireConnectionTimeout: 10000,\n ssl: { rejectUnauthorized: false },\n};\n\nexport class Db {\n static async init(context, options = {}) {\n const defs = {\n dbName: \"string\",\n dbConnectionString: \"string\",\n dbProfile: \"boolean default false\",\n };\n const discovered = context?.params?.getAllForModule?.(\"db\", defs) ?? {};\n const merged = { ...discovered, ...options };\n\n let { dbName, dbConnectionString } = merged;\n const { dbProfile } = merged;\n\n if (!dbName && !dbConnectionString) {\n dbName = \"local\";\n }\n\n if (dbName && /^(postgresql|mysql):\\/\\//.test(dbName)) {\n dbConnectionString = dbName;\n dbName = undefined;\n }\n\n if (dbName && !dbConnectionString) {\n const paramName = `dbConnectionString${capitalizeFirstLetter(dbName)}`;\n dbConnectionString = await context.params.get(paramName, \"string\");\n if (!dbConnectionString) {\n throw new ParamError(\n `Db: cannot find dbConnectionString for dbName=\"${dbName}\" (looked for param \"${paramName}\")`\n );\n }\n }\n\n const config = {\n ...KNEX_DEFAULTS,\n connectionString: dbConnectionString,\n name: dbName || merged.name || \"default\",\n profile: !!dbProfile,\n logger: context.logger,\n };\n\n return dbConnect(context, config);\n }\n\n constructor(config) {\n if (!config || !config.connectionString) {\n throw new ParamError(\"Db: connectionString is required\");\n }\n\n this.knexInstance = null;\n this.isConnected = false;\n this.queriesLog = [];\n\n this.config = {\n testConnection: true,\n profile: false,\n pool: { min: 2, max: 10 },\n acquireConnectionTimeout: 10000,\n ssl: { rejectUnauthorized: false },\n logger: console,\n name: \"default\",\n ...config,\n };\n\n this.logger = this.config.logger;\n\n const instance = this;\n const callableWrapper = function () {\n throw new Error(\"This should never be called directly\");\n };\n callableWrapper._instance = instance;\n\n return new Proxy(callableWrapper, {\n apply: (target, _thisArg, argumentsList) => {\n const inst = target._instance;\n if (!inst.knexInstance) {\n throw new Error(\"Db: Not connected. Call connect() first.\");\n }\n return inst.knexInstance(...argumentsList);\n },\n get: (target, prop) => {\n if (prop === \"_instance\") {\n return target._instance;\n }\n\n const inst = target._instance;\n\n const ownMethods = [\n \"connect\",\n \"disconnect\",\n \"testConnection\",\n \"tableExists\",\n \"getQueryLog\",\n \"getKnex\",\n \"isConnectedToDb\",\n \"getErrorMessage\",\n \"detectClient\",\n \"attachProfiler\",\n ];\n\n if (prop in inst) {\n const value = inst[prop];\n if (typeof value === \"function\" && ownMethods.includes(prop)) {\n return value.bind(inst);\n }\n if (typeof value !== \"function\") {\n return value;\n }\n }\n\n if (inst.knexInstance) {\n const knexProp = inst.knexInstance[prop];\n if (typeof knexProp === \"function\") {\n return knexProp.bind(inst.knexInstance);\n }\n return knexProp;\n }\n\n if (prop in inst) {\n const method = inst[prop];\n if (typeof method === \"function\") {\n return method.bind(inst);\n }\n return method;\n }\n\n return undefined;\n },\n });\n }\n\n detectClient(connectionString) {\n if (connectionString.match(/^postgresql/)) {\n return \"pg\";\n }\n if (connectionString.match(/^mysql/)) {\n return \"mysql2\";\n }\n return null;\n }\n\n async connect() {\n if (this.isConnected && this.knexInstance) {\n this.logger.warn?.(\"[Db] Already connected\");\n return;\n }\n\n const client = this.detectClient(this.config.connectionString);\n if (!client) {\n throw new ParamError(\n \"Db: Cannot determine client type from connection string. Expected postgresql:// or mysql://\"\n );\n }\n\n try {\n const connectionConfig = {\n connectionString: this.config.connectionString,\n family: 4,\n };\n\n this.knexInstance = knex({\n client,\n connection: connectionConfig,\n pool: this.config.pool,\n acquireConnectionTimeout: this.config.acquireConnectionTimeout,\n ...(this.config.ssl && { ssl: this.config.ssl }),\n });\n\n if (this.config.profile) {\n this.attachProfiler();\n }\n\n if (this.config.testConnection) {\n await this.testConnection();\n }\n\n this.isConnected = true;\n this.logger.debug?.(\n `[Db] Connected to database \"${this.config.name || this.config.connectionString}\"`\n );\n } catch (error) {\n if (error instanceof ParamError) {\n throw error;\n }\n const errorMsg = this.getErrorMessage(error);\n throw new ParamError(`Db: Connection failed - ${errorMsg}`);\n }\n }\n\n async disconnect() {\n if (!this.knexInstance) {\n return;\n }\n\n try {\n await this.knexInstance.destroy();\n this.knexInstance = null;\n this.isConnected = false;\n this.queriesLog = [];\n this.logger.debug?.(\n `[Db] Disconnected from database \"${this.config.name || this.config.connectionString}\"`\n );\n } catch (error) {\n const errorMsg = this.getErrorMessage(error);\n this.logger.error?.(`[Db] Error disconnecting: ${errorMsg}`);\n throw error;\n }\n }\n\n getErrorMessage(error) {\n if (error instanceof AggregateError) {\n const errors = error.errors || [];\n\n if (errors.length > 0) {\n const firstError = errors[0];\n const firstErrorMsg =\n firstError instanceof Error ? firstError.message : String(firstError);\n\n const allSimilar = errors.every((e) => {\n const msg = e instanceof Error ? e.message : String(e);\n const codeMatch = msg.match(/^(\\w+)\\s/);\n const firstCodeMatch = firstErrorMsg.match(/^(\\w+)\\s/);\n return codeMatch && firstCodeMatch && codeMatch[1] === firstCodeMatch[1];\n });\n\n if (allSimilar && errors.length > 1) {\n const addresses = errors\n .map((e) => {\n const msg = e instanceof Error ? e.message : String(e);\n const addrMatch = msg.match(/([:\\d.]+:\\d+)/);\n return addrMatch ? addrMatch[1] : null;\n })\n .filter(Boolean);\n\n if (addresses.length > 0) {\n const codeMatch = firstErrorMsg.match(/^(\\w+)\\s/);\n const code = codeMatch ? codeMatch[1] : \"Connection error\";\n return `${code} (tried: ${addresses.join(\", \")})`;\n }\n }\n\n const uniqueMessages = [\n ...new Set(\n errors.map((e) => (e instanceof Error ? e.message : String(e)))\n ),\n ];\n\n if (uniqueMessages.length === 1) {\n return uniqueMessages[0];\n }\n\n return uniqueMessages.join(\"; \");\n }\n\n return error.message || \"Multiple errors occurred\";\n }\n\n if (error instanceof Error) {\n const code = error.code;\n if (code) {\n return `${code}: ${error.message || String(error)}`;\n }\n return error.message || String(error);\n }\n\n if (typeof error === \"string\") {\n return error;\n }\n\n if (error && typeof error === \"object\" && \"message\" in error) {\n const msg = String(error.message);\n const code = error.code;\n if (code) {\n return `${code}: ${msg}`;\n }\n return msg;\n }\n\n return String(error) || \"Unknown error\";\n }\n\n async testConnection() {\n if (!this.knexInstance) {\n throw new Error(\"Db: Not connected. Call connect() first.\");\n }\n\n try {\n const result = await this.knexInstance.raw(\"SELECT 2+3 AS result\");\n const isOk = result.rows?.[0]?.result === 5 || result[0]?.[0]?.result === 5;\n this.logger.debug?.(`[Db] Connection test: ${isOk ? \"OK\" : \"FAILED\"}`);\n return isOk;\n } catch (error) {\n const errorMsg = this.getErrorMessage(error);\n this.logger.error?.(`[Db] Connection test failed: ${errorMsg}`);\n throw new ParamError(`Db: Connection test failed - ${errorMsg}`);\n }\n }\n\n attachProfiler() {\n if (!this.knexInstance) {\n return;\n }\n\n this.queriesLog = [];\n this.knexInstance.queriesLog = this.queriesLog;\n\n this.knexInstance.on(\"query\", (query) => {\n query.__startTime = process.hrtime();\n });\n\n this.knexInstance.on(\"query-response\", (_response, query) => {\n const [seconds, nanoseconds] = process.hrtime(query.__startTime);\n const executionTimeMs = (seconds * 1000 + nanoseconds / 1e6).toFixed(2);\n\n const logEntry = {\n sql: query.sql,\n bindings: query.bindings || [],\n executionTimeMs,\n };\n\n this.queriesLog.push(logEntry);\n this.logger.debug?.(`[Db] Query: ${query.sql} | Duration: ${executionTimeMs}ms`);\n });\n\n this.knexInstance.on(\"query-error\", (error, query) => {\n this.logger.error?.(`[Db] Query failed: ${query.sql}`, error);\n });\n }\n\n getQueryLog() {\n return [...this.queriesLog];\n }\n\n async tableExists(tableName) {\n if (!this.knexInstance) {\n throw new Error(\"Db: Not connected. Call connect() first.\");\n }\n\n try {\n return await this.knexInstance.schema.hasTable(tableName);\n } catch (error) {\n this.logger.error?.(`[Db] Error checking table existence: ${error.message}`);\n throw error;\n }\n }\n\n getKnex() {\n if (!this.knexInstance) {\n throw new Error(\"Db: Not connected. Call connect() first.\");\n }\n return this.knexInstance;\n }\n\n isConnectedToDb() {\n return this.isConnected && this.knexInstance !== null;\n }\n}\n\nfunction capitalizeFirstLetter(str) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nasync function dbConnect(context, config) {\n try {\n const db = new Db(config);\n\n context.registerCleanup(async () => {\n await db.disconnect();\n context.logger.debug?.(`[Db] instance \"${config.name}\" disconnected`);\n });\n\n await db.connect();\n\n context.logger.debug?.(`[Db] instance \"${config.name}\" initialized`);\n\n return db;\n } catch (error) {\n if (error instanceof ParamError) {\n throw error;\n }\n const errorMsg = error instanceof Error ? error.message : String(error);\n throw new ParamError(`[Db] connect error: ${errorMsg}`);\n }\n}\n","/**\n * Error classes for the CLI toolkit\n */\n\nexport class FrameworkError extends Error {\n constructor(message) {\n super(message);\n this.name = \"FrameworkError\";\n }\n}\n\nexport class ParamError extends FrameworkError {\n constructor(message) {\n super(message);\n this.name = \"ParamError\";\n }\n}\n\nexport class InitError extends FrameworkError {\n constructor(message) {\n super(message);\n this.name = \"InitError\";\n }\n}\n\nexport class CriticalRequestError extends FrameworkError {\n constructor(message) {\n super(message);\n this.name = \"CriticalRequestError\";\n }\n}\n\nexport class ControlFlowError extends Error {\n constructor(message) {\n super(message);\n this.name = \"ControlFlowError\";\n }\n}\n\nexport class HttpClientError extends FrameworkError {\n constructor(message, cause) {\n super(message);this.cause = cause;;\n this.name = \"HttpClientError\";\n }\n}\n\nexport class FileDatabaseError extends FrameworkError {\n constructor(message) {\n super(message);\n this.name = \"FileDatabaseError\";\n }\n}\n\n"],"mappings":";AAAA,OAAO,UAAU;;;ACIV,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACtC,YAAY,SAAS;AACjB,UAAM,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__getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -17,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
16
|
};
|
|
18
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
18
|
|
|
20
|
-
// src/errors.
|
|
19
|
+
// src/errors.js
|
|
21
20
|
var errors_exports = {};
|
|
22
21
|
__export(errors_exports, {
|
|
23
22
|
ControlFlowError: () => ControlFlowError,
|
|
@@ -63,6 +62,7 @@ var HttpClientError = class extends FrameworkError {
|
|
|
63
62
|
constructor(message, cause) {
|
|
64
63
|
super(message);
|
|
65
64
|
this.cause = cause;
|
|
65
|
+
;
|
|
66
66
|
this.name = "HttpClientError";
|
|
67
67
|
}
|
|
68
68
|
};
|
package/dist/errors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.
|
|
1
|
+
{"version":3,"sources":["../src/errors.js"],"sourcesContent":["/**\n * Error classes for the CLI toolkit\n */\n\nexport class FrameworkError extends Error {\n constructor(message) {\n super(message);\n this.name = \"FrameworkError\";\n }\n}\n\nexport class ParamError extends FrameworkError {\n constructor(message) {\n super(message);\n this.name = \"ParamError\";\n }\n}\n\nexport class InitError extends FrameworkError {\n constructor(message) {\n super(message);\n this.name = \"InitError\";\n }\n}\n\nexport class CriticalRequestError extends FrameworkError {\n constructor(message) {\n super(message);\n this.name = \"CriticalRequestError\";\n }\n}\n\nexport class ControlFlowError extends Error {\n constructor(message) {\n super(message);\n this.name = \"ControlFlowError\";\n }\n}\n\nexport class HttpClientError extends FrameworkError {\n constructor(message, cause) {\n super(message);this.cause = cause;;\n this.name = \"HttpClientError\";\n }\n}\n\nexport class FileDatabaseError extends FrameworkError {\n constructor(message) {\n super(message);\n this.name = \"FileDatabaseError\";\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACtC,YAAY,SAAS;AACjB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,aAAN,cAAyB,eAAe;AAAA,EAC3C,YAAY,SAAS;AACjB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,YAAN,cAAwB,eAAe;AAAA,EAC1C,YAAY,SAAS;AACjB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,uBAAN,cAAmC,eAAe;AAAA,EACrD,YAAY,SAAS;AACjB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EACxC,YAAY,SAAS;AACjB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,kBAAN,cAA8B,eAAe;AAAA,EAChD,YAAY,SAAW,OAAO;AAC1B,UAAM,OAAO;AAAE,SAAK,QAAQ;AAAM;AAClC,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,oBAAN,cAAgC,eAAe;AAAA,EAClD,YAAY,SAAS;AACjB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;","names":[]}
|
package/dist/errors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/errors.
|
|
1
|
+
// src/errors.js
|
|
2
2
|
var FrameworkError = class extends Error {
|
|
3
3
|
constructor(message) {
|
|
4
4
|
super(message);
|
|
@@ -33,6 +33,7 @@ var HttpClientError = class extends FrameworkError {
|
|
|
33
33
|
constructor(message, cause) {
|
|
34
34
|
super(message);
|
|
35
35
|
this.cause = cause;
|
|
36
|
+
;
|
|
36
37
|
this.name = "HttpClientError";
|
|
37
38
|
}
|
|
38
39
|
};
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.
|
|
1
|
+
{"version":3,"sources":["../src/errors.js"],"sourcesContent":["/**\n * Error classes for the CLI toolkit\n */\n\nexport class FrameworkError extends Error {\n constructor(message) {\n super(message);\n this.name = \"FrameworkError\";\n }\n}\n\nexport class ParamError extends FrameworkError {\n constructor(message) {\n super(message);\n this.name = \"ParamError\";\n }\n}\n\nexport class InitError extends FrameworkError {\n constructor(message) {\n super(message);\n this.name = \"InitError\";\n }\n}\n\nexport class CriticalRequestError extends FrameworkError {\n constructor(message) {\n super(message);\n this.name = \"CriticalRequestError\";\n }\n}\n\nexport class ControlFlowError extends Error {\n constructor(message) {\n super(message);\n this.name = \"ControlFlowError\";\n }\n}\n\nexport class HttpClientError extends FrameworkError {\n constructor(message, cause) {\n super(message);this.cause = cause;;\n this.name = \"HttpClientError\";\n }\n}\n\nexport class FileDatabaseError extends FrameworkError {\n constructor(message) {\n super(message);\n this.name = \"FileDatabaseError\";\n }\n}\n\n"],"mappings":";AAIO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACtC,YAAY,SAAS;AACjB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,aAAN,cAAyB,eAAe;AAAA,EAC3C,YAAY,SAAS;AACjB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,YAAN,cAAwB,eAAe;AAAA,EAC1C,YAAY,SAAS;AACjB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,uBAAN,cAAmC,eAAe;AAAA,EACrD,YAAY,SAAS;AACjB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EACxC,YAAY,SAAS;AACjB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,kBAAN,cAA8B,eAAe;AAAA,EAChD,YAAY,SAAW,OAAO;AAC1B,UAAM,OAAO;AAAE,SAAK,QAAQ;AAAM;AAClC,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,oBAAN,cAAgC,eAAe;AAAA,EAClD,YAAY,SAAS;AACjB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;","names":[]}
|