@angelitosystems/nest-devtools 1.0.11 → 1.0.13
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/index.cjs +39 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -21
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -923,10 +923,20 @@ var DatabaseInstrumentation = class {
|
|
|
923
923
|
attach() {
|
|
924
924
|
const cleanup = [];
|
|
925
925
|
if (!this.config.capture.database) return () => cleanup.forEach((fn) => fn());
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
926
|
+
let disposed = false;
|
|
927
|
+
queueMicrotask(() => {
|
|
928
|
+
if (disposed) return;
|
|
929
|
+
try {
|
|
930
|
+
if (this.tryAttachTypeOrm()) cleanup.push(this.detachTypeOrm());
|
|
931
|
+
if (this.tryAttachPrisma()) cleanup.push(this.detachPrisma());
|
|
932
|
+
if (this.tryAttachMongoose()) cleanup.push(this.detachMongoose());
|
|
933
|
+
} catch {
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
return () => {
|
|
937
|
+
disposed = true;
|
|
938
|
+
cleanup.splice(0).forEach((fn) => fn());
|
|
939
|
+
};
|
|
930
940
|
}
|
|
931
941
|
tryAttachTypeOrm() {
|
|
932
942
|
try {
|
|
@@ -1019,6 +1029,12 @@ var DatabaseInstrumentation = class {
|
|
|
1019
1029
|
});
|
|
1020
1030
|
return true;
|
|
1021
1031
|
}
|
|
1032
|
+
if (typeof prisma.$on === "function") {
|
|
1033
|
+
prisma.$on("query", (event) => {
|
|
1034
|
+
this.endQuery(event.query ?? "prisma.query", event.params ? [event.params] : [], event.duration ?? 0);
|
|
1035
|
+
});
|
|
1036
|
+
return true;
|
|
1037
|
+
}
|
|
1022
1038
|
const original = prisma.$queryRaw ?? prisma.$executeRaw ?? null;
|
|
1023
1039
|
if (!original) return false;
|
|
1024
1040
|
const wrapped = (query, parameters) => {
|
|
@@ -1162,7 +1178,7 @@ var DatabaseInstrumentation = class {
|
|
|
1162
1178
|
}
|
|
1163
1179
|
resolveTypeOrmDataSource(app) {
|
|
1164
1180
|
try {
|
|
1165
|
-
const dataSource = this.findProvider(app, (value) => typeof value?.query === "function" && typeof value?.manager === "object");
|
|
1181
|
+
const dataSource = this.findProvider(app, /data.?source|typeorm/i, (value) => typeof value?.query === "function" && typeof value?.manager === "object");
|
|
1166
1182
|
if (dataSource) return dataSource;
|
|
1167
1183
|
return null;
|
|
1168
1184
|
} catch {
|
|
@@ -1171,8 +1187,12 @@ var DatabaseInstrumentation = class {
|
|
|
1171
1187
|
}
|
|
1172
1188
|
resolvePrismaClient(app) {
|
|
1173
1189
|
try {
|
|
1174
|
-
const prisma = this.
|
|
1175
|
-
|
|
1190
|
+
const prisma = this.findProvider(
|
|
1191
|
+
app,
|
|
1192
|
+
/prisma/i,
|
|
1193
|
+
(value) => typeof value?.$queryRaw === "function" && typeof value?.$connect === "function" && typeof value?.$disconnect === "function"
|
|
1194
|
+
);
|
|
1195
|
+
if (prisma && typeof prisma.$queryRaw === "function" && typeof prisma.$connect === "function") return prisma;
|
|
1176
1196
|
return null;
|
|
1177
1197
|
} catch {
|
|
1178
1198
|
return null;
|
|
@@ -1180,27 +1200,25 @@ var DatabaseInstrumentation = class {
|
|
|
1180
1200
|
}
|
|
1181
1201
|
resolveMongoose(app) {
|
|
1182
1202
|
try {
|
|
1183
|
-
const mongoose = this.
|
|
1203
|
+
const mongoose = this.findProvider(app, /mongoose/i, (value) => typeof value?.plugin === "function");
|
|
1184
1204
|
if (mongoose && typeof mongoose.plugin === "function") return mongoose;
|
|
1185
1205
|
return null;
|
|
1186
1206
|
} catch {
|
|
1187
1207
|
return null;
|
|
1188
1208
|
}
|
|
1189
1209
|
}
|
|
1190
|
-
|
|
1191
|
-
try {
|
|
1192
|
-
return app?.get?.(token, { strict: false }) ?? null;
|
|
1193
|
-
} catch {
|
|
1194
|
-
return null;
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
findProvider(app, predicate) {
|
|
1210
|
+
findProvider(app, namePattern, predicate) {
|
|
1198
1211
|
try {
|
|
1199
1212
|
const modules = app?.container?.getModules?.() ?? /* @__PURE__ */ new Map();
|
|
1200
1213
|
for (const module of modules.values()) {
|
|
1201
|
-
for (const wrapper of module.providers?.
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1214
|
+
for (const [token, wrapper] of module.providers?.entries?.() ?? []) {
|
|
1215
|
+
const name = String(wrapper?.name ?? wrapper?.metatype?.name ?? token ?? "");
|
|
1216
|
+
if (!namePattern.test(name)) continue;
|
|
1217
|
+
try {
|
|
1218
|
+
const instance = wrapper?.instance;
|
|
1219
|
+
if (instance && predicate(instance)) return instance;
|
|
1220
|
+
} catch {
|
|
1221
|
+
}
|
|
1204
1222
|
}
|
|
1205
1223
|
}
|
|
1206
1224
|
return null;
|
|
@@ -1380,7 +1398,7 @@ function detectNestJsVersion() {
|
|
|
1380
1398
|
}
|
|
1381
1399
|
|
|
1382
1400
|
// src/version.ts
|
|
1383
|
-
var SDK_VERSION = "1.0.
|
|
1401
|
+
var SDK_VERSION = "1.0.13";
|
|
1384
1402
|
|
|
1385
1403
|
// src/banner.ts
|
|
1386
1404
|
var RESET = "\x1B[0m";
|
|
@@ -1565,7 +1583,7 @@ var NestDevTools = class {
|
|
|
1565
1583
|
registerCleanup(new WebsocketInstrumentation({ config, projectInfo }).attach());
|
|
1566
1584
|
}
|
|
1567
1585
|
if (config.capture.database) {
|
|
1568
|
-
registerCleanup(new DatabaseInstrumentation({ config, projectInfo }).attach());
|
|
1586
|
+
registerCleanup(new DatabaseInstrumentation({ config, projectInfo, app }).attach());
|
|
1569
1587
|
}
|
|
1570
1588
|
registerCleanup(new QueueEventInstrumentation({ config, projectInfo }).attach());
|
|
1571
1589
|
printStartupBanner({
|