@ngn-net/nestjs-telescope 0.1.6 → 0.1.8
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/README.md +42 -34
- package/dist/constants.d.ts +12 -3
- package/dist/constants.js +14 -5
- package/dist/controllers/telescope.controller.d.ts +5 -2
- package/dist/controllers/telescope.controller.js +41 -13
- package/dist/index.d.ts +11 -0
- package/dist/index.js +12 -0
- package/dist/interfaces/telescope-options.interface.d.ts +9 -3
- package/dist/storage/entities/telescope-entry.entity.js +34 -7
- package/dist/storage/telescope-repository.service.d.ts +17 -7
- package/dist/storage/telescope-repository.service.js +42 -17
- package/dist/telescope.module.d.ts +6 -2
- package/dist/telescope.module.js +148 -44
- package/dist/telescope.service.d.ts +21 -1
- package/dist/telescope.service.js +72 -22
- package/dist/ui/index.html +1635 -0
- package/dist/watchers/cache.watcher.d.ts +5 -4
- package/dist/watchers/cache.watcher.js +50 -34
- package/dist/watchers/event.watcher.d.ts +7 -3
- package/dist/watchers/event.watcher.js +22 -6
- package/dist/watchers/exception.watcher.js +7 -1
- package/dist/watchers/http-request.watcher.d.ts +3 -1
- package/dist/watchers/http-request.watcher.js +25 -8
- package/dist/watchers/log.watcher.d.ts +1 -0
- package/dist/watchers/log.watcher.js +22 -17
- package/dist/watchers/mail.watcher.d.ts +1 -1
- package/dist/watchers/mail.watcher.js +28 -56
- package/dist/watchers/query.watcher.d.ts +6 -3
- package/dist/watchers/query.watcher.js +36 -8
- package/dist/watchers/queue.watcher.d.ts +2 -4
- package/dist/watchers/queue.watcher.js +38 -32
- package/dist/watchers/redis.watcher.d.ts +3 -1
- package/dist/watchers/redis.watcher.js +16 -4
- package/dist/watchers/schedule.watcher.d.ts +8 -3
- package/dist/watchers/schedule.watcher.js +25 -11
- package/package.json +51 -19
- package/ui/index.html +602 -235
|
@@ -15,52 +15,58 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.QueueWatcher = void 0;
|
|
16
16
|
// src/watchers/queue.watcher.ts
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
|
-
const bullmq_1 = require("@nestjs/bullmq");
|
|
19
|
-
const bullmq_2 = require("bullmq");
|
|
20
18
|
const telescope_service_1 = require("../telescope.service");
|
|
21
19
|
const entry_type_enum_1 = require("../enums/entry-type.enum");
|
|
22
20
|
let QueueWatcher = class QueueWatcher {
|
|
23
|
-
queue;
|
|
24
21
|
telescope;
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
this.queue = queue;
|
|
22
|
+
queue;
|
|
23
|
+
constructor(telescope, queue) {
|
|
28
24
|
this.telescope = telescope;
|
|
25
|
+
this.queue = queue;
|
|
29
26
|
}
|
|
30
27
|
onModuleInit() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
// Skip if no queue is available (BullMQ not configured)
|
|
29
|
+
if (!this.queue)
|
|
30
|
+
return;
|
|
31
|
+
try {
|
|
32
|
+
const QueueEvents = require('bullmq').QueueEvents;
|
|
33
|
+
const queueEvents = new QueueEvents(this.queue.name, {
|
|
34
|
+
connection: this.queue.opts?.connection,
|
|
35
|
+
});
|
|
36
|
+
queueEvents.on('completed', ({ jobId, returnvalue }) => {
|
|
37
|
+
this.telescope.record({
|
|
38
|
+
type: entry_type_enum_1.EntryType.JOB,
|
|
39
|
+
content: { jobId, status: 'completed', returnvalue },
|
|
40
|
+
});
|
|
38
41
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
queueEvents.on('failed', ({ jobId, failedReason }) => {
|
|
43
|
+
this.telescope.record({
|
|
44
|
+
type: entry_type_enum_1.EntryType.JOB,
|
|
45
|
+
content: { jobId, status: 'failed', failedReason },
|
|
46
|
+
});
|
|
44
47
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
queueEvents.on('active', ({ jobId, prev }) => {
|
|
49
|
+
this.telescope.record({
|
|
50
|
+
type: entry_type_enum_1.EntryType.JOB,
|
|
51
|
+
content: { jobId, status: 'active', prev },
|
|
52
|
+
});
|
|
50
53
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
queueEvents.on('stalled', ({ jobId }) => {
|
|
55
|
+
this.telescope.record({
|
|
56
|
+
type: entry_type_enum_1.EntryType.JOB,
|
|
57
|
+
content: { jobId, status: 'stalled' },
|
|
58
|
+
});
|
|
56
59
|
});
|
|
57
|
-
}
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// bullmq not available or queue setup failed — skip silently
|
|
63
|
+
}
|
|
58
64
|
}
|
|
59
65
|
};
|
|
60
66
|
exports.QueueWatcher = QueueWatcher;
|
|
61
67
|
exports.QueueWatcher = QueueWatcher = __decorate([
|
|
62
68
|
(0, common_1.Injectable)(),
|
|
63
|
-
__param(
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
__param(1, (0, common_1.Optional)()),
|
|
70
|
+
__param(1, (0, common_1.Inject)('BullQueue_telescope-queue')),
|
|
71
|
+
__metadata("design:paramtypes", [telescope_service_1.TelescopeService, Object])
|
|
66
72
|
], QueueWatcher);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { OnModuleInit } from '@nestjs/common';
|
|
2
2
|
import { TelescopeService } from '../telescope.service';
|
|
3
|
+
import { TelescopeOptions } from '../interfaces/telescope-options.interface';
|
|
3
4
|
export declare class RedisWatcher implements OnModuleInit {
|
|
4
5
|
private readonly telescope;
|
|
5
|
-
|
|
6
|
+
private readonly options?;
|
|
7
|
+
constructor(telescope: TelescopeService, options?: TelescopeOptions | undefined);
|
|
6
8
|
onModuleInit(): void;
|
|
7
9
|
}
|
|
@@ -8,16 +8,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.RedisWatcher = void 0;
|
|
13
16
|
// src/watchers/redis.watcher.ts
|
|
14
17
|
const common_1 = require("@nestjs/common");
|
|
15
18
|
const telescope_service_1 = require("../telescope.service");
|
|
16
19
|
const entry_type_enum_1 = require("../enums/entry-type.enum");
|
|
20
|
+
const constants_1 = require("../constants");
|
|
17
21
|
let RedisWatcher = class RedisWatcher {
|
|
18
22
|
telescope;
|
|
19
|
-
|
|
23
|
+
options;
|
|
24
|
+
constructor(telescope, options) {
|
|
20
25
|
this.telescope = telescope;
|
|
26
|
+
this.options = options;
|
|
21
27
|
}
|
|
22
28
|
onModuleInit() {
|
|
23
29
|
try {
|
|
@@ -31,9 +37,13 @@ let RedisWatcher = class RedisWatcher {
|
|
|
31
37
|
const start = Date.now();
|
|
32
38
|
const name = command?.name || 'unknown';
|
|
33
39
|
const commandArgs = command?.args || [];
|
|
40
|
+
// Skip ignored commands
|
|
41
|
+
if (self.telescope.shouldIgnoreCommand(name)) {
|
|
42
|
+
return originalSendCommand.call(this, command, ...args);
|
|
43
|
+
}
|
|
34
44
|
const result = originalSendCommand.call(this, command, ...args);
|
|
35
45
|
if (result && typeof result.then === 'function') {
|
|
36
|
-
result.then((
|
|
46
|
+
result.then(() => {
|
|
37
47
|
const duration = Date.now() - start;
|
|
38
48
|
self.telescope.record({
|
|
39
49
|
type: entry_type_enum_1.EntryType.REDIS,
|
|
@@ -62,7 +72,7 @@ let RedisWatcher = class RedisWatcher {
|
|
|
62
72
|
};
|
|
63
73
|
}
|
|
64
74
|
}
|
|
65
|
-
catch
|
|
75
|
+
catch {
|
|
66
76
|
// ioredis is not loaded or available, skip hooking
|
|
67
77
|
}
|
|
68
78
|
}
|
|
@@ -70,5 +80,7 @@ let RedisWatcher = class RedisWatcher {
|
|
|
70
80
|
exports.RedisWatcher = RedisWatcher;
|
|
71
81
|
exports.RedisWatcher = RedisWatcher = __decorate([
|
|
72
82
|
(0, common_1.Injectable)(),
|
|
73
|
-
|
|
83
|
+
__param(1, (0, common_1.Inject)(constants_1.TELESCOPE_OPTIONS)),
|
|
84
|
+
__param(1, (0, common_1.Optional)()),
|
|
85
|
+
__metadata("design:paramtypes", [telescope_service_1.TelescopeService, Object])
|
|
74
86
|
], RedisWatcher);
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { OnApplicationBootstrap } from '@nestjs/common';
|
|
2
|
-
import { SchedulerRegistry } from '@nestjs/schedule';
|
|
3
2
|
import { TelescopeService } from '../telescope.service';
|
|
4
3
|
export declare class ScheduleWatcher implements OnApplicationBootstrap {
|
|
5
4
|
private readonly telescope;
|
|
6
|
-
private
|
|
7
|
-
constructor(telescope: TelescopeService
|
|
5
|
+
private schedulerRegistry;
|
|
6
|
+
constructor(telescope: TelescopeService);
|
|
8
7
|
onApplicationBootstrap(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Set the scheduler registry reference. Called from the module setup
|
|
10
|
+
* when @nestjs/schedule is available.
|
|
11
|
+
*/
|
|
12
|
+
setSchedulerRegistry(registry: any): void;
|
|
13
|
+
private hookIntoCronJobs;
|
|
9
14
|
}
|
|
@@ -8,30 +8,46 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.ScheduleWatcher = void 0;
|
|
16
13
|
// src/watchers/schedule.watcher.ts
|
|
17
14
|
const common_1 = require("@nestjs/common");
|
|
18
|
-
const schedule_1 = require("@nestjs/schedule");
|
|
19
15
|
const telescope_service_1 = require("../telescope.service");
|
|
20
16
|
const entry_type_enum_1 = require("../enums/entry-type.enum");
|
|
21
17
|
let ScheduleWatcher = class ScheduleWatcher {
|
|
22
18
|
telescope;
|
|
23
19
|
schedulerRegistry;
|
|
24
|
-
constructor(telescope
|
|
20
|
+
constructor(telescope) {
|
|
25
21
|
this.telescope = telescope;
|
|
26
|
-
this.schedulerRegistry = schedulerRegistry;
|
|
27
22
|
}
|
|
28
23
|
onApplicationBootstrap() {
|
|
24
|
+
// Dynamically resolve SchedulerRegistry to avoid hard dependency
|
|
25
|
+
try {
|
|
26
|
+
const schedule = require('@nestjs/schedule');
|
|
27
|
+
// SchedulerRegistry is a provider, we can't inject it here
|
|
28
|
+
// This watcher works when setSchedulerRegistry() is called from the module
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// @nestjs/schedule not installed
|
|
32
|
+
}
|
|
33
|
+
if (this.schedulerRegistry) {
|
|
34
|
+
this.hookIntoCronJobs();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Set the scheduler registry reference. Called from the module setup
|
|
39
|
+
* when @nestjs/schedule is available.
|
|
40
|
+
*/
|
|
41
|
+
setSchedulerRegistry(registry) {
|
|
42
|
+
this.schedulerRegistry = registry;
|
|
43
|
+
this.hookIntoCronJobs();
|
|
44
|
+
}
|
|
45
|
+
hookIntoCronJobs() {
|
|
29
46
|
if (!this.schedulerRegistry)
|
|
30
47
|
return;
|
|
31
48
|
try {
|
|
32
49
|
const cronJobs = this.schedulerRegistry.getCronJobs();
|
|
33
50
|
cronJobs.forEach((job, name) => {
|
|
34
|
-
// Intercept cron job execution callbacks
|
|
35
51
|
const originalCallbacks = job.callbacks || [];
|
|
36
52
|
if (originalCallbacks.length > 0) {
|
|
37
53
|
job.callbacks = originalCallbacks.map((cb) => {
|
|
@@ -78,7 +94,7 @@ let ScheduleWatcher = class ScheduleWatcher {
|
|
|
78
94
|
}
|
|
79
95
|
});
|
|
80
96
|
}
|
|
81
|
-
catch
|
|
97
|
+
catch {
|
|
82
98
|
// Ignore if schedule registry lookup fails
|
|
83
99
|
}
|
|
84
100
|
}
|
|
@@ -86,7 +102,5 @@ let ScheduleWatcher = class ScheduleWatcher {
|
|
|
86
102
|
exports.ScheduleWatcher = ScheduleWatcher;
|
|
87
103
|
exports.ScheduleWatcher = ScheduleWatcher = __decorate([
|
|
88
104
|
(0, common_1.Injectable)(),
|
|
89
|
-
|
|
90
|
-
__metadata("design:paramtypes", [telescope_service_1.TelescopeService,
|
|
91
|
-
schedule_1.SchedulerRegistry])
|
|
105
|
+
__metadata("design:paramtypes", [telescope_service_1.TelescopeService])
|
|
92
106
|
], ScheduleWatcher);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngn-net/nestjs-telescope",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -9,47 +9,79 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"main": "dist/index.js",
|
|
11
11
|
"types": "dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"ui"
|
|
15
|
+
],
|
|
12
16
|
"scripts": {
|
|
13
|
-
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
14
17
|
"clean": "rimraf dist",
|
|
18
|
+
"copy-ui": "node scripts/copy-ui.js",
|
|
19
|
+
"build": "npm run clean && tsc -p tsconfig.build.json && npm run copy-ui",
|
|
15
20
|
"test": "jest",
|
|
16
21
|
"prepare": "npm run build"
|
|
17
22
|
},
|
|
18
|
-
|
|
19
|
-
"@nestjs/common": "^11",
|
|
20
|
-
"@nestjs/core": "^11",
|
|
21
|
-
"@nestjs/typeorm": "^11",
|
|
22
|
-
"@nestjs/bullmq": "^11",
|
|
23
|
-
"@nestjs/config": "^3",
|
|
24
|
-
"@nestjs/jwt": "^11",
|
|
25
|
-
"@nestjs/passport": "^11",
|
|
26
|
-
"@nestjs/cache-manager": "^3",
|
|
27
|
-
"@nestjs/event-emitter": "^2",
|
|
28
|
-
"@nestjs/schedule": "^4",
|
|
29
|
-
"typeorm": "^0.3",
|
|
30
|
-
"bullmq": "^5",
|
|
31
|
-
"nodemailer": "^6",
|
|
32
|
-
"cache-manager": "^5",
|
|
23
|
+
"dependencies": {
|
|
33
24
|
"class-transformer": "^0.5",
|
|
34
25
|
"class-validator": "^0.14",
|
|
35
26
|
"reflect-metadata": "^0.2",
|
|
36
27
|
"passport-jwt": "^4"
|
|
37
28
|
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@nestjs/common": "^11",
|
|
31
|
+
"@nestjs/core": "^11",
|
|
32
|
+
"@nestjs/typeorm": "^11",
|
|
33
|
+
"typeorm": "^0.3",
|
|
34
|
+
"@nestjs/jwt": "^11",
|
|
35
|
+
"@nestjs/passport": "^11",
|
|
36
|
+
"@nestjs/bullmq": "^11",
|
|
37
|
+
"bullmq": "^5",
|
|
38
|
+
"@nestjs/cache-manager": "^3",
|
|
39
|
+
"cache-manager": "^5",
|
|
40
|
+
"@nestjs/event-emitter": "^2",
|
|
41
|
+
"@nestjs/schedule": "^4",
|
|
42
|
+
"nodemailer": "^6"
|
|
43
|
+
},
|
|
44
|
+
"peerDependenciesMeta": {
|
|
45
|
+
"@nestjs/bullmq": {
|
|
46
|
+
"optional": true
|
|
47
|
+
},
|
|
48
|
+
"bullmq": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
51
|
+
"@nestjs/cache-manager": {
|
|
52
|
+
"optional": true
|
|
53
|
+
},
|
|
54
|
+
"cache-manager": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"@nestjs/event-emitter": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
60
|
+
"@nestjs/schedule": {
|
|
61
|
+
"optional": true
|
|
62
|
+
},
|
|
63
|
+
"nodemailer": {
|
|
64
|
+
"optional": true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
38
67
|
"devDependencies": {
|
|
39
68
|
"@nestjs/common": "^11",
|
|
40
69
|
"@nestjs/core": "^11",
|
|
41
70
|
"@nestjs/typeorm": "^11",
|
|
42
71
|
"@nestjs/bullmq": "^11",
|
|
43
|
-
"@nestjs/config": "^3",
|
|
44
72
|
"@nestjs/jwt": "^11",
|
|
45
73
|
"@nestjs/passport": "^11",
|
|
46
74
|
"@nestjs/event-emitter": "^2",
|
|
47
75
|
"@nestjs/schedule": "^4",
|
|
48
|
-
"@nestjs/cache-manager": "^
|
|
76
|
+
"@nestjs/cache-manager": "^3",
|
|
49
77
|
"ts-node": "^10",
|
|
50
78
|
"rimraf": "^5",
|
|
51
79
|
"jest": "^29",
|
|
52
80
|
"ts-jest": "^29",
|
|
81
|
+
"typescript": "^5",
|
|
82
|
+
"rxjs": "^7",
|
|
83
|
+
"typeorm": "^0.3",
|
|
84
|
+
"nodemailer": "^6",
|
|
53
85
|
"@types/jest": "^29",
|
|
54
86
|
"@types/node": "^20",
|
|
55
87
|
"@types/express": "^4.17.21",
|