@navios/schedule 0.4.0 → 0.7.0

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +7 -0
  3. package/README.md +221 -317
  4. package/dist/src/cron.constants.d.mts +25 -0
  5. package/dist/src/cron.constants.d.mts.map +1 -1
  6. package/dist/src/decorators/cron.decorator.d.mts +48 -0
  7. package/dist/src/decorators/cron.decorator.d.mts.map +1 -1
  8. package/dist/src/decorators/schedulable.decorator.d.mts +25 -0
  9. package/dist/src/decorators/schedulable.decorator.d.mts.map +1 -1
  10. package/dist/src/scheduler.service.d.mts +102 -0
  11. package/dist/src/scheduler.service.d.mts.map +1 -1
  12. package/dist/tsconfig.tsbuildinfo +1 -1
  13. package/lib/index.cjs +626 -0
  14. package/lib/index.cjs.map +1 -0
  15. package/lib/index.d.cts +264 -0
  16. package/lib/index.d.cts.map +1 -0
  17. package/lib/index.d.mts +264 -14
  18. package/lib/index.d.mts.map +1 -0
  19. package/lib/index.mjs +592 -209
  20. package/lib/index.mjs.map +1 -1
  21. package/package.json +6 -6
  22. package/project.json +2 -2
  23. package/src/__tests__/schedule.spec.mts +5 -3
  24. package/src/cron.constants.mts +25 -0
  25. package/src/decorators/cron.decorator.mts +48 -1
  26. package/src/decorators/schedulable.decorator.mts +25 -0
  27. package/src/scheduler.service.mts +105 -10
  28. package/tsdown.config.mts +33 -0
  29. package/dist/tsdown.config.d.mts +0 -3
  30. package/dist/tsdown.config.d.mts.map +0 -1
  31. package/dist/tsup.config.d.mts +0 -3
  32. package/dist/tsup.config.d.mts.map +0 -1
  33. package/dist/vitest.config.d.mts +0 -3
  34. package/dist/vitest.config.d.mts.map +0 -1
  35. package/lib/_tsup-dts-rollup.d.mts +0 -105
  36. package/lib/_tsup-dts-rollup.d.ts +0 -105
  37. package/lib/index.d.ts +0 -14
  38. package/lib/index.js +0 -240
  39. package/lib/index.js.map +0 -1
  40. package/tsup.config.mts +0 -12
@@ -0,0 +1,264 @@
1
+ import { CronJob, CronJobParams } from "cron";
2
+ import { ClassType } from "@navios/core";
3
+
4
+ //#region src/decorators/cron.decorator.d.mts
5
+
6
+ /**
7
+ * Options for configuring a cron job.
8
+ *
9
+ * @public
10
+ */
11
+ interface CronOptions {
12
+ /**
13
+ * Whether the job should be disabled by default.
14
+ * Disabled jobs won't start automatically but can be manually started later.
15
+ *
16
+ * @default false
17
+ */
18
+ disabled?: boolean;
19
+ }
20
+ /**
21
+ * Decorator that marks a method to run on a cron schedule.
22
+ *
23
+ * The method must be in a class decorated with `@Schedulable()`.
24
+ * The method will be automatically executed according to the provided cron expression.
25
+ *
26
+ * @param cronTime - Cron expression (5 or 6 fields) or a pre-defined Schedule constant
27
+ * @param options - Optional configuration for the cron job
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * @Schedulable()
32
+ * class TaskService {
33
+ * // Run daily at midnight
34
+ * @Cron('0 0 * * *')
35
+ * async dailyTask() {
36
+ * console.log('Running daily task')
37
+ * }
38
+ *
39
+ * // Use pre-defined schedule
40
+ * @Cron(Schedule.EveryFiveMinutes)
41
+ * async frequentTask() {
42
+ * console.log('Running every 5 minutes')
43
+ * }
44
+ *
45
+ * // Disabled job (won't start automatically)
46
+ * @Cron('0 2 * * *', { disabled: true })
47
+ * async maintenanceTask() {
48
+ * console.log('Maintenance task')
49
+ * }
50
+ * }
51
+ * ```
52
+ *
53
+ * @throws {Error} If applied to something other than a method
54
+ *
55
+ * @public
56
+ */
57
+ declare function Cron(cronTime: CronJobParams['cronTime'], options?: CronOptions): (target: () => Promise<void>, context: ClassMethodDecoratorContext) => () => Promise<void>;
58
+ //#endregion
59
+ //#region src/decorators/schedulable.decorator.d.mts
60
+ /**
61
+ * Decorator that marks a class as schedulable and makes it injectable.
62
+ *
63
+ * Classes decorated with `@Schedulable()` can contain methods decorated with `@Cron()`
64
+ * that will be automatically scheduled and executed. This decorator also applies
65
+ * the `@Injectable()` decorator, making the class available for dependency injection.
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * @Schedulable()
70
+ * class TaskService {
71
+ * @Cron('0 0 * * *')
72
+ * async dailyTask() {
73
+ * // This will run daily at midnight
74
+ * }
75
+ * }
76
+ *
77
+ * // Register the service
78
+ * schedulerService.register(TaskService)
79
+ * ```
80
+ *
81
+ * @throws {Error} If applied to something other than a class
82
+ *
83
+ * @public
84
+ */
85
+ declare function Schedulable(): (target: ClassType, context: ClassDecoratorContext) => ClassType;
86
+ //#endregion
87
+ //#region src/metadata/cron.metadata.d.mts
88
+ declare const CronMetadataKey: unique symbol;
89
+ interface CronMetadata {
90
+ classMethod: string;
91
+ cronTime: CronJobParams['cronTime'] | null;
92
+ disabled: boolean;
93
+ }
94
+ declare function getAllCronMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<CronMetadata>;
95
+ declare function getCronMetadata(target: Function, context: ClassMethodDecoratorContext): CronMetadata;
96
+ //#endregion
97
+ //#region src/metadata/schedule.metadata.d.mts
98
+ declare const ScheduleMetadataKey: unique symbol;
99
+ interface ScheduleMetadata {
100
+ name: string;
101
+ jobs: Set<CronMetadata>;
102
+ }
103
+ declare function getScheduleMetadata(target: ClassType, context: ClassDecoratorContext): ScheduleMetadata;
104
+ declare function extractScheduleMetadata(target: ClassType): ScheduleMetadata;
105
+ declare function hasScheduleMetadata(target: ClassType): boolean;
106
+ //#endregion
107
+ //#region src/cron.constants.d.mts
108
+ /**
109
+ * Pre-defined cron schedule constants for common scheduling patterns.
110
+ *
111
+ * These constants provide convenient shortcuts for frequently used cron expressions,
112
+ * making it easier to schedule jobs without manually writing cron expressions.
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * import { Schedule } from '@navios/schedule'
117
+ *
118
+ * @Schedulable()
119
+ * class TaskService {
120
+ * @Cron(Schedule.EveryMinute)
121
+ * async everyMinute() {}
122
+ *
123
+ * @Cron(Schedule.EveryHour)
124
+ * async hourly() {}
125
+ *
126
+ * @Cron(Schedule.EveryDay)
127
+ * async daily() {}
128
+ * }
129
+ * ```
130
+ *
131
+ * @public
132
+ */
133
+ declare enum Schedule {
134
+ EveryMinute = "*/1 * * * *",
135
+ EveryFiveMinutes = "*/5 * * * *",
136
+ EveryTenMinutes = "*/10 * * * *",
137
+ EveryFifteenMinutes = "*/15 * * * *",
138
+ EveryThirtyMinutes = "*/30 * * * *",
139
+ EveryHour = "0 * * * *",
140
+ EveryTwoHours = "0 */2 * * *",
141
+ EveryThreeHours = "0 */3 * * *",
142
+ EveryFourHours = "0 */4 * * *",
143
+ EverySixHours = "0 */6 * * *",
144
+ EveryTwelveHours = "0 */12 * * *",
145
+ EveryDay = "0 0 * * *",
146
+ EveryWeek = "0 0 * * 0",
147
+ EveryMonth = "0 0 1 * *",
148
+ }
149
+ //#endregion
150
+ //#region src/scheduler.service.d.mts
151
+ /**
152
+ * Service responsible for managing and executing scheduled cron jobs.
153
+ *
154
+ * The SchedulerService registers schedulable services decorated with `@Schedulable()`
155
+ * and automatically starts their cron jobs based on the `@Cron()` decorator configuration.
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * import { inject, Injectable } from '@navios/core'
160
+ * import { SchedulerService } from '@navios/schedule'
161
+ *
162
+ * @Injectable()
163
+ * class AppModule {
164
+ * private readonly scheduler = inject(SchedulerService)
165
+ *
166
+ * async onModuleInit() {
167
+ * this.scheduler.register(MySchedulableService)
168
+ * }
169
+ * }
170
+ * ```
171
+ *
172
+ * @public
173
+ */
174
+ declare class SchedulerService {
175
+ private readonly logger;
176
+ private readonly container;
177
+ private readonly jobs;
178
+ /**
179
+ * Registers a schedulable service and starts all its cron jobs.
180
+ *
181
+ * The service must be decorated with `@Schedulable()` and contain methods
182
+ * decorated with `@Cron()` to be registered successfully.
183
+ *
184
+ * @param service - The schedulable service class to register
185
+ * @throws {Error} If the service is not decorated with `@Schedulable()`
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * @Schedulable()
190
+ * class TaskService {
191
+ * @Cron('0 0 * * *')
192
+ * async dailyTask() {
193
+ * // Runs daily at midnight
194
+ * }
195
+ * }
196
+ *
197
+ * schedulerService.register(TaskService)
198
+ * ```
199
+ *
200
+ * @public
201
+ */
202
+ register(service: ClassType): void;
203
+ /**
204
+ * Retrieves a specific cron job instance for a method in a schedulable service.
205
+ *
206
+ * @param service - The schedulable service class
207
+ * @param method - The name of the method decorated with `@Cron()`
208
+ * @returns The CronJob instance if found, undefined otherwise
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * const job = schedulerService.getJob(TaskService, 'dailyTask')
213
+ * if (job) {
214
+ * console.log('Job is active:', job.isActive)
215
+ * job.start() // Manually start the job
216
+ * job.stop() // Manually stop the job
217
+ * }
218
+ * ```
219
+ *
220
+ * @public
221
+ */
222
+ getJob<T extends ClassType>(service: T, method: keyof InstanceType<T>): CronJob | undefined;
223
+ private registerJobs;
224
+ /**
225
+ * Starts all registered cron jobs that are currently inactive.
226
+ *
227
+ * Only jobs that are not already active will be started. This method
228
+ * is useful for resuming all jobs after calling `stopAll()`.
229
+ *
230
+ * @example
231
+ * ```typescript
232
+ * // Stop all jobs
233
+ * schedulerService.stopAll()
234
+ *
235
+ * // Later, resume all jobs
236
+ * schedulerService.startAll()
237
+ * ```
238
+ *
239
+ * @public
240
+ */
241
+ startAll(): void;
242
+ /**
243
+ * Stops all registered cron jobs that are currently active.
244
+ *
245
+ * Only jobs that are currently active will be stopped. This method
246
+ * is useful for pausing all scheduled tasks, for example during
247
+ * application shutdown or maintenance.
248
+ *
249
+ * @example
250
+ * ```typescript
251
+ * // Pause all scheduled jobs
252
+ * schedulerService.stopAll()
253
+ *
254
+ * // Jobs can be resumed later with startAll()
255
+ * schedulerService.startAll()
256
+ * ```
257
+ *
258
+ * @public
259
+ */
260
+ stopAll(): void;
261
+ }
262
+ //#endregion
263
+ export { Cron, CronMetadata, CronMetadataKey, CronOptions, Schedulable, Schedule, ScheduleMetadata, ScheduleMetadataKey, SchedulerService, extractScheduleMetadata, getAllCronMetadata, getCronMetadata, getScheduleMetadata, hasScheduleMetadata };
264
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/decorators/cron.decorator.mts","../src/decorators/schedulable.decorator.mts","../src/metadata/cron.metadata.mts","../src/metadata/schedule.metadata.mts","../src/cron.constants.mts","../src/scheduler.service.mts"],"sourcesContent":[],"mappings":";;;;;;;;AASA;AA+CA;AACY,UAhDK,WAAA,CAgDL;EACA;;;;;;;;AC3BZ;;;;;;;;AC7BA;AAEA;AAMA;;;;;;AAiBA;;;;;;;;ACrBA;AAEA;AAKA;;;;;AAyBA;AAWA;;;;ACxBA;iBJ+BgB,IAAA,WACJ,qCACA,6BAGM,wBACL,sCADK;;;;;;AApDlB;AA+CA;;;;;;;;;;ACzBA;;;;;;;;AC7BA;AAEA;AAMA;AACW,iBDoBK,WAAA,CAAA,CCpBL,EAAA,CAAA,MAAA,EDqBO,SCrBP,EAAA,OAAA,EDqB2B,qBCrB3B,EAAA,GDqBgD,SCrBhD;;;cATE;UAEI,YAAA;;EFKA,QAAA,EEHL,aFGgB,CAAA,UAAA,CAAA,GAAA,IAAA;EA+CZ,QAAI,EAAA,OAAA;;AAER,iBEhDI,kBAAA,CFgDJ,OAAA,EE/CD,2BF+CC,GE/C6B,qBF+C7B,CAAA,EE9CT,GF8CS,CE9CL,YF8CK,CAAA;AAGM,iBElCF,eAAA,CFkCE,MAAA,EEjCR,QFiCQ,EAAA,OAAA,EEhCP,2BFgCO,CAAA,EE/Bf,YF+Be;;;cGvDL;UAEI,gBAAA;EHCA,IAAA,EAAA,MAAA;EA+CD,IAAA,EG9CR,GH8CY,CG9CR,YH8CQ,CAAA;;AAER,iBG7CI,mBAAA,CH6CJ,MAAA,EG5CF,SH4CE,EAAA,OAAA,EG3CD,qBH2CC,CAAA,EG1CT,gBH0CS;AAGM,iBGvBF,uBAAA,CHuBE,MAAA,EGvB8B,SHuB9B,CAAA,EGvB0C,gBHuB1C;AACL,iBGbG,mBAAA,CHaH,MAAA,EGb+B,SHa/B,CAAA,EAAA,OAAA;;;;;;;AArDb;AA+CA;;;;;;;;;;ACzBA;;;;;;;;AC7BA;AAEA;AAMgB,aEeJ,QAAA;EFdD,WAAA,GAAA,aAAA;EAA8B,gBAAA,GAAA,aAAA;EAClC,eAAA,GAAA,cAAA;EAAJ,mBAAA,GAAA,cAAA;EAAG,kBAAA,GAAA,cAAA;EAeU,SAAA,GAAA,WAAe;EACrB,aAAA,GAAA,aAAA;EACC,eAAA,GAAA,aAAA;EACR,cAAA,GAAA,aAAA;EAAY,aAAA,GAAA,aAAA;;;;ECxBF,UAAA,GAAA,WAAqD;AAElE;;;;;AHCA;AA+CA;;;;;;;;;;ACzBA;;;;;;;;AC7BA;AAEA;AAMgB,cG2BH,gBAAA,CH3BqB;EACvB,iBAAA,MAAA;EAA8B,iBAAA,SAAA;EAClC,iBAAA,IAAA;EAAJ;;AAeH;;;;;;;;ACrBA;AAEA;AAKA;;;;;AAyBA;AAWA;;;;ACxBA;;oBC2CoB;;AAhCpB;;;;;;;;;;;;;;;;;;mBA8DmB,oBACN,iBACK,aAAa,KAC1B"}
package/lib/index.d.mts CHANGED
@@ -1,14 +1,264 @@
1
- export { Cron } from './_tsup-dts-rollup.mjs';
2
- export { CronOptions } from './_tsup-dts-rollup.mjs';
3
- export { Schedulable } from './_tsup-dts-rollup.mjs';
4
- export { getAllCronMetadata } from './_tsup-dts-rollup.mjs';
5
- export { getCronMetadata } from './_tsup-dts-rollup.mjs';
6
- export { CronMetadataKey } from './_tsup-dts-rollup.mjs';
7
- export { CronMetadata } from './_tsup-dts-rollup.mjs';
8
- export { getScheduleMetadata } from './_tsup-dts-rollup.mjs';
9
- export { extractScheduleMetadata } from './_tsup-dts-rollup.mjs';
10
- export { hasScheduleMetadata } from './_tsup-dts-rollup.mjs';
11
- export { ScheduleMetadataKey } from './_tsup-dts-rollup.mjs';
12
- export { ScheduleMetadata } from './_tsup-dts-rollup.mjs';
13
- export { Schedule_alias_1 as Schedule } from './_tsup-dts-rollup.mjs';
14
- export { SchedulerService } from './_tsup-dts-rollup.mjs';
1
+ import { ClassType } from "@navios/core";
2
+ import { CronJob, CronJobParams } from "cron";
3
+
4
+ //#region src/decorators/cron.decorator.d.mts
5
+
6
+ /**
7
+ * Options for configuring a cron job.
8
+ *
9
+ * @public
10
+ */
11
+ interface CronOptions {
12
+ /**
13
+ * Whether the job should be disabled by default.
14
+ * Disabled jobs won't start automatically but can be manually started later.
15
+ *
16
+ * @default false
17
+ */
18
+ disabled?: boolean;
19
+ }
20
+ /**
21
+ * Decorator that marks a method to run on a cron schedule.
22
+ *
23
+ * The method must be in a class decorated with `@Schedulable()`.
24
+ * The method will be automatically executed according to the provided cron expression.
25
+ *
26
+ * @param cronTime - Cron expression (5 or 6 fields) or a pre-defined Schedule constant
27
+ * @param options - Optional configuration for the cron job
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * @Schedulable()
32
+ * class TaskService {
33
+ * // Run daily at midnight
34
+ * @Cron('0 0 * * *')
35
+ * async dailyTask() {
36
+ * console.log('Running daily task')
37
+ * }
38
+ *
39
+ * // Use pre-defined schedule
40
+ * @Cron(Schedule.EveryFiveMinutes)
41
+ * async frequentTask() {
42
+ * console.log('Running every 5 minutes')
43
+ * }
44
+ *
45
+ * // Disabled job (won't start automatically)
46
+ * @Cron('0 2 * * *', { disabled: true })
47
+ * async maintenanceTask() {
48
+ * console.log('Maintenance task')
49
+ * }
50
+ * }
51
+ * ```
52
+ *
53
+ * @throws {Error} If applied to something other than a method
54
+ *
55
+ * @public
56
+ */
57
+ declare function Cron(cronTime: CronJobParams['cronTime'], options?: CronOptions): (target: () => Promise<void>, context: ClassMethodDecoratorContext) => () => Promise<void>;
58
+ //#endregion
59
+ //#region src/decorators/schedulable.decorator.d.mts
60
+ /**
61
+ * Decorator that marks a class as schedulable and makes it injectable.
62
+ *
63
+ * Classes decorated with `@Schedulable()` can contain methods decorated with `@Cron()`
64
+ * that will be automatically scheduled and executed. This decorator also applies
65
+ * the `@Injectable()` decorator, making the class available for dependency injection.
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * @Schedulable()
70
+ * class TaskService {
71
+ * @Cron('0 0 * * *')
72
+ * async dailyTask() {
73
+ * // This will run daily at midnight
74
+ * }
75
+ * }
76
+ *
77
+ * // Register the service
78
+ * schedulerService.register(TaskService)
79
+ * ```
80
+ *
81
+ * @throws {Error} If applied to something other than a class
82
+ *
83
+ * @public
84
+ */
85
+ declare function Schedulable(): (target: ClassType, context: ClassDecoratorContext) => ClassType;
86
+ //#endregion
87
+ //#region src/metadata/cron.metadata.d.mts
88
+ declare const CronMetadataKey: unique symbol;
89
+ interface CronMetadata {
90
+ classMethod: string;
91
+ cronTime: CronJobParams['cronTime'] | null;
92
+ disabled: boolean;
93
+ }
94
+ declare function getAllCronMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<CronMetadata>;
95
+ declare function getCronMetadata(target: Function, context: ClassMethodDecoratorContext): CronMetadata;
96
+ //#endregion
97
+ //#region src/metadata/schedule.metadata.d.mts
98
+ declare const ScheduleMetadataKey: unique symbol;
99
+ interface ScheduleMetadata {
100
+ name: string;
101
+ jobs: Set<CronMetadata>;
102
+ }
103
+ declare function getScheduleMetadata(target: ClassType, context: ClassDecoratorContext): ScheduleMetadata;
104
+ declare function extractScheduleMetadata(target: ClassType): ScheduleMetadata;
105
+ declare function hasScheduleMetadata(target: ClassType): boolean;
106
+ //#endregion
107
+ //#region src/cron.constants.d.mts
108
+ /**
109
+ * Pre-defined cron schedule constants for common scheduling patterns.
110
+ *
111
+ * These constants provide convenient shortcuts for frequently used cron expressions,
112
+ * making it easier to schedule jobs without manually writing cron expressions.
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * import { Schedule } from '@navios/schedule'
117
+ *
118
+ * @Schedulable()
119
+ * class TaskService {
120
+ * @Cron(Schedule.EveryMinute)
121
+ * async everyMinute() {}
122
+ *
123
+ * @Cron(Schedule.EveryHour)
124
+ * async hourly() {}
125
+ *
126
+ * @Cron(Schedule.EveryDay)
127
+ * async daily() {}
128
+ * }
129
+ * ```
130
+ *
131
+ * @public
132
+ */
133
+ declare enum Schedule {
134
+ EveryMinute = "*/1 * * * *",
135
+ EveryFiveMinutes = "*/5 * * * *",
136
+ EveryTenMinutes = "*/10 * * * *",
137
+ EveryFifteenMinutes = "*/15 * * * *",
138
+ EveryThirtyMinutes = "*/30 * * * *",
139
+ EveryHour = "0 * * * *",
140
+ EveryTwoHours = "0 */2 * * *",
141
+ EveryThreeHours = "0 */3 * * *",
142
+ EveryFourHours = "0 */4 * * *",
143
+ EverySixHours = "0 */6 * * *",
144
+ EveryTwelveHours = "0 */12 * * *",
145
+ EveryDay = "0 0 * * *",
146
+ EveryWeek = "0 0 * * 0",
147
+ EveryMonth = "0 0 1 * *",
148
+ }
149
+ //#endregion
150
+ //#region src/scheduler.service.d.mts
151
+ /**
152
+ * Service responsible for managing and executing scheduled cron jobs.
153
+ *
154
+ * The SchedulerService registers schedulable services decorated with `@Schedulable()`
155
+ * and automatically starts their cron jobs based on the `@Cron()` decorator configuration.
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * import { inject, Injectable } from '@navios/core'
160
+ * import { SchedulerService } from '@navios/schedule'
161
+ *
162
+ * @Injectable()
163
+ * class AppModule {
164
+ * private readonly scheduler = inject(SchedulerService)
165
+ *
166
+ * async onModuleInit() {
167
+ * this.scheduler.register(MySchedulableService)
168
+ * }
169
+ * }
170
+ * ```
171
+ *
172
+ * @public
173
+ */
174
+ declare class SchedulerService {
175
+ private readonly logger;
176
+ private readonly container;
177
+ private readonly jobs;
178
+ /**
179
+ * Registers a schedulable service and starts all its cron jobs.
180
+ *
181
+ * The service must be decorated with `@Schedulable()` and contain methods
182
+ * decorated with `@Cron()` to be registered successfully.
183
+ *
184
+ * @param service - The schedulable service class to register
185
+ * @throws {Error} If the service is not decorated with `@Schedulable()`
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * @Schedulable()
190
+ * class TaskService {
191
+ * @Cron('0 0 * * *')
192
+ * async dailyTask() {
193
+ * // Runs daily at midnight
194
+ * }
195
+ * }
196
+ *
197
+ * schedulerService.register(TaskService)
198
+ * ```
199
+ *
200
+ * @public
201
+ */
202
+ register(service: ClassType): void;
203
+ /**
204
+ * Retrieves a specific cron job instance for a method in a schedulable service.
205
+ *
206
+ * @param service - The schedulable service class
207
+ * @param method - The name of the method decorated with `@Cron()`
208
+ * @returns The CronJob instance if found, undefined otherwise
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * const job = schedulerService.getJob(TaskService, 'dailyTask')
213
+ * if (job) {
214
+ * console.log('Job is active:', job.isActive)
215
+ * job.start() // Manually start the job
216
+ * job.stop() // Manually stop the job
217
+ * }
218
+ * ```
219
+ *
220
+ * @public
221
+ */
222
+ getJob<T extends ClassType>(service: T, method: keyof InstanceType<T>): CronJob | undefined;
223
+ private registerJobs;
224
+ /**
225
+ * Starts all registered cron jobs that are currently inactive.
226
+ *
227
+ * Only jobs that are not already active will be started. This method
228
+ * is useful for resuming all jobs after calling `stopAll()`.
229
+ *
230
+ * @example
231
+ * ```typescript
232
+ * // Stop all jobs
233
+ * schedulerService.stopAll()
234
+ *
235
+ * // Later, resume all jobs
236
+ * schedulerService.startAll()
237
+ * ```
238
+ *
239
+ * @public
240
+ */
241
+ startAll(): void;
242
+ /**
243
+ * Stops all registered cron jobs that are currently active.
244
+ *
245
+ * Only jobs that are currently active will be stopped. This method
246
+ * is useful for pausing all scheduled tasks, for example during
247
+ * application shutdown or maintenance.
248
+ *
249
+ * @example
250
+ * ```typescript
251
+ * // Pause all scheduled jobs
252
+ * schedulerService.stopAll()
253
+ *
254
+ * // Jobs can be resumed later with startAll()
255
+ * schedulerService.startAll()
256
+ * ```
257
+ *
258
+ * @public
259
+ */
260
+ stopAll(): void;
261
+ }
262
+ //#endregion
263
+ export { Cron, CronMetadata, CronMetadataKey, CronOptions, Schedulable, Schedule, ScheduleMetadata, ScheduleMetadataKey, SchedulerService, extractScheduleMetadata, getAllCronMetadata, getCronMetadata, getScheduleMetadata, hasScheduleMetadata };
264
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/decorators/cron.decorator.mts","../src/decorators/schedulable.decorator.mts","../src/metadata/cron.metadata.mts","../src/metadata/schedule.metadata.mts","../src/cron.constants.mts","../src/scheduler.service.mts"],"sourcesContent":[],"mappings":";;;;;;;;AASA;AA+CA;AACY,UAhDK,WAAA,CAgDL;EACA;;;;;;;;AC3BZ;;;;;;;;AC7BA;AAEA;AAMA;;;;;;AAiBA;;;;;;;;ACrBA;AAEA;AAKA;;;;;AAyBA;AAWA;;;;ACxBA;iBJ+BgB,IAAA,WACJ,qCACA,6BAGM,wBACL,sCADK;;;;;;AApDlB;AA+CA;;;;;;;;;;ACzBA;;;;;;;;AC7BA;AAEA;AAMA;AACW,iBDoBK,WAAA,CAAA,CCpBL,EAAA,CAAA,MAAA,EDqBO,SCrBP,EAAA,OAAA,EDqB2B,qBCrB3B,EAAA,GDqBgD,SCrBhD;;;cATE;UAEI,YAAA;;EFKA,QAAA,EEHL,aFGgB,CAAA,UAAA,CAAA,GAAA,IAAA;EA+CZ,QAAI,EAAA,OAAA;;AAER,iBEhDI,kBAAA,CFgDJ,OAAA,EE/CD,2BF+CC,GE/C6B,qBF+C7B,CAAA,EE9CT,GF8CS,CE9CL,YF8CK,CAAA;AAGM,iBElCF,eAAA,CFkCE,MAAA,EEjCR,QFiCQ,EAAA,OAAA,EEhCP,2BFgCO,CAAA,EE/Bf,YF+Be;;;cGvDL;UAEI,gBAAA;EHCA,IAAA,EAAA,MAAA;EA+CD,IAAA,EG9CR,GH8CY,CG9CR,YH8CQ,CAAA;;AAER,iBG7CI,mBAAA,CH6CJ,MAAA,EG5CF,SH4CE,EAAA,OAAA,EG3CD,qBH2CC,CAAA,EG1CT,gBH0CS;AAGM,iBGvBF,uBAAA,CHuBE,MAAA,EGvB8B,SHuB9B,CAAA,EGvB0C,gBHuB1C;AACL,iBGbG,mBAAA,CHaH,MAAA,EGb+B,SHa/B,CAAA,EAAA,OAAA;;;;;;;AArDb;AA+CA;;;;;;;;;;ACzBA;;;;;;;;AC7BA;AAEA;AAMgB,aEeJ,QAAA;EFdD,WAAA,GAAA,aAAA;EAA8B,gBAAA,GAAA,aAAA;EAClC,eAAA,GAAA,cAAA;EAAJ,mBAAA,GAAA,cAAA;EAAG,kBAAA,GAAA,cAAA;EAeU,SAAA,GAAA,WAAe;EACrB,aAAA,GAAA,aAAA;EACC,eAAA,GAAA,aAAA;EACR,cAAA,GAAA,aAAA;EAAY,aAAA,GAAA,aAAA;;;;ECxBF,UAAA,GAAA,WAAqD;AAElE;;;;;AHCA;AA+CA;;;;;;;;;;ACzBA;;;;;;;;AC7BA;AAEA;AAMgB,cG2BH,gBAAA,CH3BqB;EACvB,iBAAA,MAAA;EAA8B,iBAAA,SAAA;EAClC,iBAAA,IAAA;EAAJ;;AAeH;;;;;;;;ACrBA;AAEA;AAKA;;;;;AAyBA;AAWA;;;;ACxBA;;oBC2CoB;;AAhCpB;;;;;;;;;;;;;;;;;;mBA8DmB,oBACN,iBACK,aAAa,KAC1B"}