@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.js
CHANGED
|
@@ -3247,11 +3247,31 @@ var Db = class _Db {
|
|
|
3247
3247
|
}
|
|
3248
3248
|
this.queriesLog = [];
|
|
3249
3249
|
this.knexInstance.queriesLog = this.queriesLog;
|
|
3250
|
+
const startsByConnection = /* @__PURE__ */ new Map();
|
|
3251
|
+
const pushStart = (query) => {
|
|
3252
|
+
const uid = query?.__knexUid ?? "";
|
|
3253
|
+
if (!startsByConnection.has(uid)) {
|
|
3254
|
+
startsByConnection.set(uid, []);
|
|
3255
|
+
}
|
|
3256
|
+
startsByConnection.get(uid).push(process.hrtime());
|
|
3257
|
+
};
|
|
3258
|
+
const popStart = (query) => {
|
|
3259
|
+
const uid = query?.__knexUid ?? "";
|
|
3260
|
+
const stack = startsByConnection.get(uid);
|
|
3261
|
+
if (!stack?.length) {
|
|
3262
|
+
return null;
|
|
3263
|
+
}
|
|
3264
|
+
return stack.pop();
|
|
3265
|
+
};
|
|
3250
3266
|
this.knexInstance.on("query", (query) => {
|
|
3251
|
-
query
|
|
3267
|
+
pushStart(query);
|
|
3252
3268
|
});
|
|
3253
3269
|
this.knexInstance.on("query-response", (_response, query) => {
|
|
3254
|
-
const
|
|
3270
|
+
const start = popStart(query);
|
|
3271
|
+
if (!start) {
|
|
3272
|
+
return;
|
|
3273
|
+
}
|
|
3274
|
+
const [seconds, nanoseconds] = process.hrtime(start);
|
|
3255
3275
|
const executionTimeMs = (seconds * 1e3 + nanoseconds / 1e6).toFixed(2);
|
|
3256
3276
|
const logEntry = {
|
|
3257
3277
|
sql: query.sql,
|
|
@@ -3262,6 +3282,7 @@ var Db = class _Db {
|
|
|
3262
3282
|
this.logger.debug?.(`[Db] Query: ${query.sql} | Duration: ${executionTimeMs}ms`);
|
|
3263
3283
|
});
|
|
3264
3284
|
this.knexInstance.on("query-error", (error, query) => {
|
|
3285
|
+
popStart(query);
|
|
3265
3286
|
this.logger.error?.(`[Db] Query failed: ${query.sql}`, error);
|
|
3266
3287
|
});
|
|
3267
3288
|
}
|