@ngn-net/nestjs-telescope 0.2.0 → 0.2.2

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.
@@ -11,5 +11,8 @@ export declare enum EntryType {
11
11
  SCHEDULED_TASK = "scheduled_task",
12
12
  REDIS = "redis",
13
13
  GATE = "gate",
14
+ COMMAND = "command",
15
+ MODEL = "model",
16
+ NOTIFICATION = "notification",
14
17
  DUMP = "dump"
15
18
  }
@@ -16,5 +16,8 @@ var EntryType;
16
16
  EntryType["SCHEDULED_TASK"] = "scheduled_task";
17
17
  EntryType["REDIS"] = "redis";
18
18
  EntryType["GATE"] = "gate";
19
+ EntryType["COMMAND"] = "command";
20
+ EntryType["MODEL"] = "model";
21
+ EntryType["NOTIFICATION"] = "notification";
19
22
  EntryType["DUMP"] = "dump";
20
23
  })(EntryType || (exports.EntryType = EntryType = {}));
package/dist/index.d.ts CHANGED
@@ -8,13 +8,7 @@ export * from './interfaces/entry.interface';
8
8
  export * from './guards/telescope-jwt.guard';
9
9
  export * from './constants';
10
10
  export * from './dashboard.provider';
11
- export * from './watchers/http-request.watcher';
12
- export * from './watchers/query.watcher';
13
- export * from './watchers/cache.watcher';
14
- export * from './watchers/queue.watcher';
15
- export * from './watchers/event.watcher';
16
- export * from './watchers/mail.watcher';
17
- export * from './watchers/log.watcher';
18
- export * from './watchers/exception.watcher';
19
- export * from './watchers/schedule.watcher';
20
- export * from './watchers/redis.watcher';
11
+ export * from './watchers/command.watcher';
12
+ export * from './watchers/model.watcher';
13
+ export * from './watchers/notification.watcher';
14
+ export * from './watchers/gate.watcher';
package/dist/index.js CHANGED
@@ -26,13 +26,7 @@ __exportStar(require("./guards/telescope-jwt.guard"), exports);
26
26
  __exportStar(require("./constants"), exports);
27
27
  __exportStar(require("./dashboard.provider"), exports);
28
28
  // Export all watchers for custom usage/extension
29
- __exportStar(require("./watchers/http-request.watcher"), exports);
30
- __exportStar(require("./watchers/query.watcher"), exports);
31
- __exportStar(require("./watchers/cache.watcher"), exports);
32
- __exportStar(require("./watchers/queue.watcher"), exports);
33
- __exportStar(require("./watchers/event.watcher"), exports);
34
- __exportStar(require("./watchers/mail.watcher"), exports);
35
- __exportStar(require("./watchers/log.watcher"), exports);
36
- __exportStar(require("./watchers/exception.watcher"), exports);
37
- __exportStar(require("./watchers/schedule.watcher"), exports);
38
- __exportStar(require("./watchers/redis.watcher"), exports);
29
+ __exportStar(require("./watchers/command.watcher"), exports);
30
+ __exportStar(require("./watchers/model.watcher"), exports);
31
+ __exportStar(require("./watchers/notification.watcher"), exports);
32
+ __exportStar(require("./watchers/gate.watcher"), exports);
@@ -35,6 +35,9 @@ const exception_watcher_1 = require("./watchers/exception.watcher");
35
35
  const schedule_watcher_1 = require("./watchers/schedule.watcher");
36
36
  const redis_watcher_1 = require("./watchers/redis.watcher");
37
37
  const telescope_jwt_guard_1 = require("./guards/telescope-jwt.guard");
38
+ const command_watcher_1 = require("./watchers/command.watcher");
39
+ const model_watcher_1 = require("./watchers/model.watcher");
40
+ const notification_watcher_1 = require("./watchers/notification.watcher");
38
41
  const constants_1 = require("./constants");
39
42
  const entry_type_enum_1 = require("./enums/entry-type.enum");
40
43
  let TelescopeModule = TelescopeModule_1 = class TelescopeModule {
@@ -48,6 +51,7 @@ let TelescopeModule = TelescopeModule_1 = class TelescopeModule {
48
51
  }
49
52
  onModuleInit() {
50
53
  // Dynamic peer dependency validation at bootstrap
54
+ const warnedTypes = new Set();
51
55
  const hasDependency = (type, packageName) => {
52
56
  try {
53
57
  require(packageName);
@@ -55,19 +59,17 @@ let TelescopeModule = TelescopeModule_1 = class TelescopeModule {
55
59
  }
56
60
  catch (e) {
57
61
  if (this.options.enabledEntryTypes && this.options.enabledEntryTypes.includes(type)) {
58
- throw new Error(`NestJS Telescope Error: EntryType '${type}' was explicitly enabled in config, but the required peer dependency '${packageName}' is not installed.`);
62
+ if (!warnedTypes.has(type)) {
63
+ warnedTypes.add(type);
64
+ common_1.Logger.warn(`EntryType '${type}' was explicitly enabled in config, but the required peer dependency '${packageName}' is not installed. The '${type}' watcher has been disabled.`, 'TelescopeModule');
65
+ }
59
66
  }
60
67
  return false;
61
68
  }
62
69
  };
63
70
  hasDependency(entry_type_enum_1.EntryType.CACHE, '@nestjs/cache-manager');
64
- const hasBull = hasDependency(entry_type_enum_1.EntryType.JOB, '@nestjs/bullmq');
65
- const hasBullmq = hasDependency(entry_type_enum_1.EntryType.JOB, 'bullmq');
66
- if (this.options.enabledEntryTypes && this.options.enabledEntryTypes.includes(entry_type_enum_1.EntryType.JOB)) {
67
- if (!hasBull || !hasBullmq) {
68
- throw new Error(`NestJS Telescope Error: EntryType 'JOB' was explicitly enabled in config, but the required peer dependencies '@nestjs/bullmq' and 'bullmq' are not installed.`);
69
- }
70
- }
71
+ hasDependency(entry_type_enum_1.EntryType.JOB, '@nestjs/bullmq');
72
+ hasDependency(entry_type_enum_1.EntryType.JOB, 'bullmq');
71
73
  hasDependency(entry_type_enum_1.EntryType.EVENT, '@nestjs/event-emitter');
72
74
  hasDependency(entry_type_enum_1.EntryType.SCHEDULED_TASK, '@nestjs/schedule');
73
75
  hasDependency(entry_type_enum_1.EntryType.MAIL, 'nodemailer');
@@ -216,6 +218,10 @@ let TelescopeModule = TelescopeModule_1 = class TelescopeModule {
216
218
  { type: entry_type_enum_1.EntryType.LOG, watcher: log_watcher_1.LogWatcher },
217
219
  { type: entry_type_enum_1.EntryType.EXCEPTION, watcher: exception_watcher_1.ExceptionWatcher, isInterceptor: true },
218
220
  { type: entry_type_enum_1.EntryType.REDIS, watcher: redis_watcher_1.RedisWatcher },
221
+ // New watchers for parity with Laravel Telescope
222
+ { type: entry_type_enum_1.EntryType.COMMAND, watcher: command_watcher_1.CommandWatcher },
223
+ { type: entry_type_enum_1.EntryType.MODEL, watcher: model_watcher_1.ModelWatcher },
224
+ { type: entry_type_enum_1.EntryType.NOTIFICATION, watcher: notification_watcher_1.NotificationWatcher },
219
225
  ];
220
226
  for (const item of coreWatchers) {
221
227
  if (!options.enabledEntryTypes || options.enabledEntryTypes.includes(item.type)) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ngn-net/nestjs-telescope",
3
- "version": "0.2.0",
4
- "builtAt": "2026-06-08T11:00:55.375Z"
3
+ "version": "0.2.2",
4
+ "builtAt": "2026-06-08T11:45:21.433Z"
5
5
  }
@@ -0,0 +1,13 @@
1
+ import { OnModuleInit } from '@nestjs/common';
2
+ import { TelescopeService } from '../telescope.service';
3
+ /**
4
+ * Placeholder watcher for command execution monitoring.
5
+ * In a real implementation you would integrate with a command runner
6
+ * such as `nest-commander` or capture process events.
7
+ */
8
+ export declare class CommandWatcher implements OnModuleInit {
9
+ private readonly telescope;
10
+ private readonly logger;
11
+ constructor(telescope: TelescopeService);
12
+ onModuleInit(): void;
13
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var CommandWatcher_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.CommandWatcher = void 0;
14
+ // src/watchers/command.watcher.ts
15
+ const common_1 = require("@nestjs/common");
16
+ const telescope_service_1 = require("../telescope.service");
17
+ const entry_type_enum_1 = require("../enums/entry-type.enum");
18
+ /**
19
+ * Placeholder watcher for command execution monitoring.
20
+ * In a real implementation you would integrate with a command runner
21
+ * such as `nest-commander` or capture process events.
22
+ */
23
+ let CommandWatcher = CommandWatcher_1 = class CommandWatcher {
24
+ telescope;
25
+ logger = new common_1.Logger(CommandWatcher_1.name);
26
+ constructor(telescope) {
27
+ this.telescope = telescope;
28
+ }
29
+ onModuleInit() {
30
+ // Example: record a dummy command entry when the module initializes.
31
+ this.telescope
32
+ .record({
33
+ type: entry_type_enum_1.EntryType.COMMAND,
34
+ content: {
35
+ command: 'module:init',
36
+ args: process.argv.slice(2),
37
+ timestamp: new Date().toISOString(),
38
+ },
39
+ })
40
+ .catch(() => { });
41
+ this.logger.debug('CommandWatcher initialized – dummy entry recorded');
42
+ }
43
+ };
44
+ exports.CommandWatcher = CommandWatcher;
45
+ exports.CommandWatcher = CommandWatcher = CommandWatcher_1 = __decorate([
46
+ (0, common_1.Injectable)(),
47
+ __metadata("design:paramtypes", [telescope_service_1.TelescopeService])
48
+ ], CommandWatcher);
@@ -0,0 +1,13 @@
1
+ import { OnModuleInit } from '@nestjs/common';
2
+ import { TelescopeService } from '../telescope.service';
3
+ /**
4
+ * Placeholder watcher for authorization gate checks.
5
+ * In a full implementation you would hook into NestJS guards (CanActivate)
6
+ * and record the decision, user, policy, etc.
7
+ */
8
+ export declare class GateWatcher implements OnModuleInit {
9
+ private readonly telescope;
10
+ private readonly logger;
11
+ constructor(telescope: TelescopeService);
12
+ onModuleInit(): void;
13
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var GateWatcher_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.GateWatcher = void 0;
14
+ // src/watchers/gate.watcher.ts
15
+ const common_1 = require("@nestjs/common");
16
+ const telescope_service_1 = require("../telescope.service");
17
+ const entry_type_enum_1 = require("../enums/entry-type.enum");
18
+ /**
19
+ * Placeholder watcher for authorization gate checks.
20
+ * In a full implementation you would hook into NestJS guards (CanActivate)
21
+ * and record the decision, user, policy, etc.
22
+ */
23
+ let GateWatcher = GateWatcher_1 = class GateWatcher {
24
+ telescope;
25
+ logger = new common_1.Logger(GateWatcher_1.name);
26
+ constructor(telescope) {
27
+ this.telescope = telescope;
28
+ }
29
+ onModuleInit() {
30
+ // Record a dummy gate entry on init for demonstration.
31
+ this.telescope
32
+ .record({
33
+ type: entry_type_enum_1.EntryType.GATE,
34
+ content: {
35
+ gate: 'module:init',
36
+ allowed: true,
37
+ timestamp: new Date().toISOString(),
38
+ },
39
+ })
40
+ .catch(() => { });
41
+ this.logger.debug('GateWatcher initialized – dummy entry recorded');
42
+ }
43
+ };
44
+ exports.GateWatcher = GateWatcher;
45
+ exports.GateWatcher = GateWatcher = GateWatcher_1 = __decorate([
46
+ (0, common_1.Injectable)(),
47
+ __metadata("design:paramtypes", [telescope_service_1.TelescopeService])
48
+ ], GateWatcher);
@@ -0,0 +1,12 @@
1
+ import { OnModuleInit } from '@nestjs/common';
2
+ import { TelescopeService } from '../telescope.service';
3
+ /**
4
+ * Placeholder watcher for ORM model events (e.g., TypeORM, Mongoose, Sequelize).
5
+ * Real implementation would subscribe to lifecycle hooks and record create/update/delete.
6
+ */
7
+ export declare class ModelWatcher implements OnModuleInit {
8
+ private readonly telescope;
9
+ private readonly logger;
10
+ constructor(telescope: TelescopeService);
11
+ onModuleInit(): void;
12
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var ModelWatcher_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.ModelWatcher = void 0;
14
+ // src/watchers/model.watcher.ts
15
+ const common_1 = require("@nestjs/common");
16
+ const telescope_service_1 = require("../telescope.service");
17
+ const entry_type_enum_1 = require("../enums/entry-type.enum");
18
+ /**
19
+ * Placeholder watcher for ORM model events (e.g., TypeORM, Mongoose, Sequelize).
20
+ * Real implementation would subscribe to lifecycle hooks and record create/update/delete.
21
+ */
22
+ let ModelWatcher = ModelWatcher_1 = class ModelWatcher {
23
+ telescope;
24
+ logger = new common_1.Logger(ModelWatcher_1.name);
25
+ constructor(telescope) {
26
+ this.telescope = telescope;
27
+ }
28
+ onModuleInit() {
29
+ // Dummy entry to prove watcher registration.
30
+ this.telescope
31
+ .record({
32
+ type: entry_type_enum_1.EntryType.MODEL,
33
+ content: {
34
+ model: 'module:init',
35
+ action: 'init',
36
+ timestamp: new Date().toISOString(),
37
+ },
38
+ })
39
+ .catch(() => { });
40
+ this.logger.debug('ModelWatcher initialized – dummy entry recorded');
41
+ }
42
+ };
43
+ exports.ModelWatcher = ModelWatcher;
44
+ exports.ModelWatcher = ModelWatcher = ModelWatcher_1 = __decorate([
45
+ (0, common_1.Injectable)(),
46
+ __metadata("design:paramtypes", [telescope_service_1.TelescopeService])
47
+ ], ModelWatcher);
@@ -0,0 +1,13 @@
1
+ import { OnModuleInit } from '@nestjs/common';
2
+ import { TelescopeService } from '../telescope.service';
3
+ /**
4
+ * Placeholder watcher for notification events.
5
+ * In a full implementation you would hook into NestJS's EventEmitter2 or any
6
+ * custom notification system and log the payload.
7
+ */
8
+ export declare class NotificationWatcher implements OnModuleInit {
9
+ private readonly telescope;
10
+ private readonly logger;
11
+ constructor(telescope: TelescopeService);
12
+ onModuleInit(): void;
13
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var NotificationWatcher_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.NotificationWatcher = void 0;
14
+ // src/watchers/notification.watcher.ts
15
+ const common_1 = require("@nestjs/common");
16
+ const telescope_service_1 = require("../telescope.service");
17
+ const entry_type_enum_1 = require("../enums/entry-type.enum");
18
+ /**
19
+ * Placeholder watcher for notification events.
20
+ * In a full implementation you would hook into NestJS's EventEmitter2 or any
21
+ * custom notification system and log the payload.
22
+ */
23
+ let NotificationWatcher = NotificationWatcher_1 = class NotificationWatcher {
24
+ telescope;
25
+ logger = new common_1.Logger(NotificationWatcher_1.name);
26
+ constructor(telescope) {
27
+ this.telescope = telescope;
28
+ }
29
+ onModuleInit() {
30
+ // Record a dummy notification on module init.
31
+ this.telescope
32
+ .record({
33
+ type: entry_type_enum_1.EntryType.NOTIFICATION,
34
+ content: {
35
+ notification: 'module:init',
36
+ payload: {},
37
+ timestamp: new Date().toISOString(),
38
+ },
39
+ })
40
+ .catch(() => { });
41
+ this.logger.debug('NotificationWatcher initialized – dummy entry recorded');
42
+ }
43
+ };
44
+ exports.NotificationWatcher = NotificationWatcher;
45
+ exports.NotificationWatcher = NotificationWatcher = NotificationWatcher_1 = __decorate([
46
+ (0, common_1.Injectable)(),
47
+ __metadata("design:paramtypes", [telescope_service_1.TelescopeService])
48
+ ], NotificationWatcher);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngn-net/nestjs-telescope",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },