@luisrodrigues/nestjs-scheduler-dashboard 0.1.3 → 0.1.4

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[];
@@ -15,6 +15,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.JobsService = void 0;
16
16
  const common_1 = require("@nestjs/common");
17
17
  const schedule_1 = require("@nestjs/schedule");
18
+ function resolveNextRun(job) {
19
+ try {
20
+ const next = job.nextDate?.();
21
+ if (!next)
22
+ return null;
23
+ if (typeof next.toISO === 'function')
24
+ return next.toISO();
25
+ if (next instanceof Date)
26
+ return next.toISOString();
27
+ return null;
28
+ }
29
+ catch {
30
+ return null;
31
+ }
32
+ }
33
+ function resolveCronExpression(cronTime) {
34
+ if (!cronTime || typeof cronTime !== 'object')
35
+ return null;
36
+ const ct = cronTime;
37
+ const src = ct['source'] ?? ct['_source'];
38
+ if (typeof src === 'string')
39
+ return src;
40
+ if (typeof cronTime.toString === 'function') {
41
+ const str = cronTime.toString();
42
+ if (str !== '[object Object]')
43
+ return str;
44
+ }
45
+ return null;
46
+ }
18
47
  const storage_abstract_1 = require("./storage/storage.abstract");
19
48
  const job_concurrency_1 = require("./decorators/job-concurrency");
20
49
  const scheduler_dash_constants_1 = require("./scheduler-dash.constants");
@@ -26,7 +55,7 @@ let JobsService = class JobsService {
26
55
  getJobs() {
27
56
  const cron = [...this.schedulerRegistry.getCronJobs().entries()].map(([name, job]) => ({
28
57
  name,
29
- cronExpression: job.cronTime.source?.toString() ?? null,
58
+ cronExpression: resolveCronExpression(job.cronTime),
30
59
  running: job.running ?? false,
31
60
  nextRun: job.nextDate()?.toISO() ?? null,
32
61
  history: this.storage.findByJob(name),
@@ -42,7 +71,7 @@ let JobsService = class JobsService {
42
71
  return null;
43
72
  return {
44
73
  name,
45
- cronExpression: job.cronTime.source?.toString() ?? null,
74
+ cronExpression: resolveCronExpression(job.cronTime),
46
75
  running: job.running ?? false,
47
76
  nextRun: job.nextDate()?.toISO() ?? null,
48
77
  history: this.storage.findByJob(name),
@@ -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.4",
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",