@luisrodrigues/nestjs-scheduler-dashboard 0.1.3 → 0.1.5

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.
@@ -7,7 +7,7 @@ export declare class JobsService {
7
7
  getJobs(): {
8
8
  cron: {
9
9
  name: string;
10
- cronExpression: any;
10
+ cronExpression: string;
11
11
  running: boolean;
12
12
  nextRun: string;
13
13
  history: import(".").JobExecution[];
@@ -22,7 +22,7 @@ export declare class JobsService {
22
22
  };
23
23
  getJob(name: string): {
24
24
  name: string;
25
- cronExpression: any;
25
+ cronExpression: string;
26
26
  running: boolean;
27
27
  nextRun: string;
28
28
  history: import(".").JobExecution[];
@@ -18,6 +18,31 @@ const schedule_1 = require("@nestjs/schedule");
18
18
  const storage_abstract_1 = require("./storage/storage.abstract");
19
19
  const job_concurrency_1 = require("./decorators/job-concurrency");
20
20
  const scheduler_dash_constants_1 = require("./scheduler-dash.constants");
21
+ function resolveNextRun(job) {
22
+ try {
23
+ const next = job.nextDate?.();
24
+ if (!next)
25
+ return null;
26
+ if (typeof next.toISO === 'function')
27
+ return next.toISO();
28
+ if (next instanceof Date)
29
+ return next.toISOString();
30
+ return null;
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ }
36
+ function resolveCronExpression(cronTime) {
37
+ if (!cronTime || typeof cronTime !== 'object')
38
+ return null;
39
+ const ct = cronTime;
40
+ const src = ct['source'] ?? ct['_source'];
41
+ if (typeof src === 'string')
42
+ return src;
43
+ const str = cronTime.toString?.();
44
+ return str && str !== '[object Object]' ? str : null;
45
+ }
21
46
  let JobsService = class JobsService {
22
47
  constructor(schedulerRegistry, storage) {
23
48
  this.schedulerRegistry = schedulerRegistry;
@@ -26,9 +51,9 @@ let JobsService = class JobsService {
26
51
  getJobs() {
27
52
  const cron = [...this.schedulerRegistry.getCronJobs().entries()].map(([name, job]) => ({
28
53
  name,
29
- cronExpression: job.cronTime.source?.toString() ?? null,
54
+ cronExpression: resolveCronExpression(job.cronTime),
30
55
  running: job.running ?? false,
31
- nextRun: job.nextDate()?.toISO() ?? null,
56
+ nextRun: resolveNextRun(job),
32
57
  history: this.storage.findByJob(name),
33
58
  metrics: this.storage.getMetrics(name),
34
59
  }));
@@ -42,9 +67,9 @@ let JobsService = class JobsService {
42
67
  return null;
43
68
  return {
44
69
  name,
45
- cronExpression: job.cronTime.source?.toString() ?? null,
70
+ cronExpression: resolveCronExpression(job.cronTime),
46
71
  running: job.running ?? false,
47
- nextRun: job.nextDate()?.toISO() ?? null,
72
+ nextRun: resolveNextRun(job),
48
73
  history: this.storage.findByJob(name),
49
74
  metrics: this.storage.getMetrics(name),
50
75
  };
@@ -83,7 +83,7 @@ let SchedulerDashModule = SchedulerDashModule_1 = class SchedulerDashModule {
83
83
  req.originalUrl.replace(new RegExp(`^/${this.escapeRegex(route)}(?=/|$)`), '') || '/';
84
84
  router(req, res, next);
85
85
  })
86
- .forRoutes({ path: `${route}*`, method: common_1.RequestMethod.ALL });
86
+ .forRoutes(route);
87
87
  }
88
88
  static forRoot(options = {}) {
89
89
  const parsed = scheduler_dash_schema_1.SchedulerDashOptionsSchema.safeParse(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luisrodrigues/nestjs-scheduler-dashboard",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Dashboard for @nestjs/schedule — embedded UI, job history, metrics, stop/trigger controls",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,12 +13,12 @@
13
13
  "dev": "tsc -p tsconfig.json --watch"
14
14
  },
15
15
  "peerDependencies": {
16
- "@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0",
17
- "@nestjs/core": "^8.0.0 || ^9.0.0 || ^10.0.0",
18
- "@nestjs/schedule": "^2.0.0 || ^3.0.0 || ^4.0.0",
16
+ "@nestjs/common": "^10.0.0 || ^11.0.0",
17
+ "@nestjs/core": "^10.0.0 || ^11.0.0",
18
+ "@nestjs/schedule": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0",
19
19
  "reflect-metadata": "^0.1.13 || ^0.2.0",
20
20
  "rxjs": "^7.0.0",
21
- "express": "^4.0.0"
21
+ "express": "^4.0.0 || ^5.0.0"
22
22
  },
23
23
  "peerDependenciesMeta": {
24
24
  "reflect-metadata": { "optional": false },