@nmakarov/cli-toolkit 0.37.0 → 0.39.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/cli-runner.cjs +23 -2
- package/dist/cli-runner.cjs.map +1 -1
- package/dist/cli-runner.js +23 -2
- package/dist/cli-runner.js.map +1 -1
- package/dist/db.cjs +23 -2
- package/dist/db.cjs.map +1 -1
- package/dist/db.js +23 -2
- package/dist/db.js.map +1 -1
- package/dist/index.cjs +23 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli-runner.cjs
CHANGED
|
@@ -3263,11 +3263,31 @@ var Db = class _Db {
|
|
|
3263
3263
|
}
|
|
3264
3264
|
this.queriesLog = [];
|
|
3265
3265
|
this.knexInstance.queriesLog = this.queriesLog;
|
|
3266
|
+
const startsByConnection = /* @__PURE__ */ new Map();
|
|
3267
|
+
const pushStart = (query) => {
|
|
3268
|
+
const uid = query?.__knexUid ?? "";
|
|
3269
|
+
if (!startsByConnection.has(uid)) {
|
|
3270
|
+
startsByConnection.set(uid, []);
|
|
3271
|
+
}
|
|
3272
|
+
startsByConnection.get(uid).push(process.hrtime());
|
|
3273
|
+
};
|
|
3274
|
+
const popStart = (query) => {
|
|
3275
|
+
const uid = query?.__knexUid ?? "";
|
|
3276
|
+
const stack = startsByConnection.get(uid);
|
|
3277
|
+
if (!stack?.length) {
|
|
3278
|
+
return null;
|
|
3279
|
+
}
|
|
3280
|
+
return stack.pop();
|
|
3281
|
+
};
|
|
3266
3282
|
this.knexInstance.on("query", (query) => {
|
|
3267
|
-
query
|
|
3283
|
+
pushStart(query);
|
|
3268
3284
|
});
|
|
3269
3285
|
this.knexInstance.on("query-response", (_response, query) => {
|
|
3270
|
-
const
|
|
3286
|
+
const start = popStart(query);
|
|
3287
|
+
if (!start) {
|
|
3288
|
+
return;
|
|
3289
|
+
}
|
|
3290
|
+
const [seconds, nanoseconds] = process.hrtime(start);
|
|
3271
3291
|
const executionTimeMs = (seconds * 1e3 + nanoseconds / 1e6).toFixed(2);
|
|
3272
3292
|
const logEntry = {
|
|
3273
3293
|
sql: query.sql,
|
|
@@ -3278,6 +3298,7 @@ var Db = class _Db {
|
|
|
3278
3298
|
this.logger.debug?.(`[Db] Query: ${query.sql} | Duration: ${executionTimeMs}ms`);
|
|
3279
3299
|
});
|
|
3280
3300
|
this.knexInstance.on("query-error", (error, query) => {
|
|
3301
|
+
popStart(query);
|
|
3281
3302
|
this.logger.error?.(`[Db] Query failed: ${query.sql}`, error);
|
|
3282
3303
|
});
|
|
3283
3304
|
}
|