@orion-js/dogs 4.0.0-next.0 → 4.0.0-next.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.
@@ -0,0 +1,222 @@
1
+ import { Blackbox } from '@orion-js/schema';
2
+ import { OrionLogger } from '@orion-js/logger';
3
+ import * as _orion_js_mongodb from '@orion-js/mongodb';
4
+ import { ModelToDocumentTypeWithoutId } from '@orion-js/mongodb';
5
+
6
+ interface ScheduleJobOptionsBase {
7
+ name: string;
8
+ params?: Blackbox;
9
+ priority?: number;
10
+ uniqueIdentifier?: string;
11
+ }
12
+ type ScheduleJobOptionsRunIn = ScheduleJobOptionsBase & {
13
+ runIn: number;
14
+ };
15
+ type ScheduleJobOptionsRunAt = ScheduleJobOptionsBase & {
16
+ runAt: Date;
17
+ };
18
+ type ScheduleJobOptions = ScheduleJobOptionsRunIn | ScheduleJobOptionsRunAt | ScheduleJobOptionsBase;
19
+ interface ScheduleJobRecordOptions {
20
+ name: string;
21
+ params: Blackbox;
22
+ nextRunAt: Date;
23
+ priority: number;
24
+ uniqueIdentifier?: string;
25
+ }
26
+
27
+ declare class HistoryRecord {
28
+ _id: string;
29
+ jobId: string;
30
+ executionId: string;
31
+ jobName: string;
32
+ type: 'recurrent' | 'event';
33
+ priority: number;
34
+ tries: number;
35
+ uniqueIdentifier?: string;
36
+ startedAt: Date;
37
+ endedAt: Date;
38
+ duration: number;
39
+ expiresAt?: Date;
40
+ status: 'success' | 'error' | 'stale';
41
+ errorMessage?: string;
42
+ params?: Blackbox;
43
+ result?: Blackbox;
44
+ }
45
+
46
+ declare class JobRecord {
47
+ _id: string;
48
+ jobName: string;
49
+ type: 'recurrent' | 'event';
50
+ priority: number;
51
+ uniqueIdentifier?: string;
52
+ nextRunAt: Date;
53
+ lastRunAt?: Date;
54
+ lockedUntil?: Date;
55
+ tries?: number;
56
+ params?: any;
57
+ }
58
+
59
+ interface JobToRun {
60
+ jobId: string;
61
+ executionId: string;
62
+ name: string;
63
+ type: 'event' | 'recurrent';
64
+ params: Blackbox;
65
+ tries: number;
66
+ lockTime: number;
67
+ priority: number;
68
+ uniqueIdentifier?: string;
69
+ }
70
+ interface ExecutionContext {
71
+ record: JobToRun;
72
+ definition: JobDefinition;
73
+ tries: number;
74
+ logger: OrionLogger;
75
+ extendLockTime: (extraTime: number) => Promise<void>;
76
+ clearStaleTimeout: () => void;
77
+ }
78
+ interface WorkerInstance {
79
+ running: boolean;
80
+ workerIndex: number;
81
+ stop: () => Promise<void>;
82
+ respawn: () => Promise<void>;
83
+ promise?: Promise<any>;
84
+ }
85
+ interface WorkersInstance {
86
+ running: boolean;
87
+ workersCount: number;
88
+ workers: WorkerInstance[];
89
+ /**
90
+ * Stop all workers and wait for them to finish
91
+ */
92
+ stop: () => Promise<void>;
93
+ }
94
+
95
+ interface JobRetryResultBase {
96
+ action: 'retry' | 'dismiss';
97
+ }
98
+ type JobRetryResultRunIn = JobRetryResultBase & {
99
+ runIn: number;
100
+ };
101
+ type JobRetryResultRunAt = JobRetryResultBase & {
102
+ runAt: Date;
103
+ };
104
+ type JobRetryResult = JobRetryResultRunIn | JobRetryResultRunAt | JobRetryResultBase;
105
+ interface BaseJobDefinition {
106
+ /**
107
+ * The function to execute when the job is executed.
108
+ */
109
+ resolve: (params: Blackbox, context: ExecutionContext) => Promise<Blackbox | void>;
110
+ /**
111
+ * Called if the job fails.
112
+ */
113
+ onError?: (error: Error, params: Blackbox, context: ExecutionContext) => Promise<JobRetryResult>;
114
+ /**
115
+ * Called if the job locktime is expired. The job will be executed again.
116
+ */
117
+ onStale?: (params: Blackbox, context: ExecutionContext) => Promise<void>;
118
+ /**
119
+ * Save the executions of the job time in milliseconds. Default is 1 week. Set to 0 to disable.
120
+ */
121
+ saveExecutionsFor?: number;
122
+ }
123
+ interface RecurrentJobDefinition extends BaseJobDefinition {
124
+ /**
125
+ * Type of the job.
126
+ */
127
+ type: 'recurrent';
128
+ /**
129
+ * A function executed after each execution that returns the date of the next run.
130
+ */
131
+ getNextRun?: () => Date;
132
+ /**
133
+ * Run every x milliseconds. This will be ignored if getNextRun is defined.
134
+ */
135
+ runEvery?: number;
136
+ /**
137
+ * The priority of the job. Higher is more priority. Default is 100.
138
+ */
139
+ priority?: number;
140
+ }
141
+ interface EventJobDefinition extends BaseJobDefinition {
142
+ /**
143
+ * Type of the job.
144
+ */
145
+ type: 'event';
146
+ }
147
+ type JobDefinition = RecurrentJobDefinition | EventJobDefinition;
148
+ type JobDefinitionWithName = JobDefinition & {
149
+ name: string;
150
+ };
151
+ interface JobsDefinition {
152
+ [jobName: string]: JobDefinition;
153
+ }
154
+
155
+ type LogLevels = 'debug' | 'info' | 'warn' | 'error' | 'none';
156
+ interface StartWorkersConfig {
157
+ /**
158
+ * Object map of the jobs that this workers will execute
159
+ */
160
+ jobs: JobsDefinition;
161
+ /**
162
+ * Time in milliseconds to wait between each look without results for a job
163
+ * to run at the database. Default is 3000.
164
+ */
165
+ pollInterval: number;
166
+ /**
167
+ * Time in milliseconds to wait too look for a job after a job execution. Default is 100.
168
+ */
169
+ cooldownPeriod: number;
170
+ /**
171
+ * Number of workers to start. Default is 1.
172
+ */
173
+ workersCount: number;
174
+ /**
175
+ * Time in milliseconds to lock a job for execution. Default is 30000 (30 seconds).
176
+ * If a job is locked for longer than this time, it will be considered as failed.
177
+ * This is to prevent a job from being executed multiple times at the same time.
178
+ * You can extend this time inside a job by calling extendLockTime from context.
179
+ */
180
+ lockTime: number;
181
+ }
182
+
183
+ declare const defineJob: (options: JobDefinition) => JobDefinition;
184
+
185
+ declare class JobsHistoryRepo {
186
+ history: () => _orion_js_mongodb.Collection<HistoryRecord>;
187
+ saveExecution(record: ModelToDocumentTypeWithoutId<HistoryRecord>): Promise<void>;
188
+ getExecutions(jobName: string, limit?: number, skip?: number): Promise<HistoryRecord[]>;
189
+ }
190
+
191
+ declare class JobsRepo {
192
+ jobs: () => _orion_js_mongodb.Collection<JobRecord>;
193
+ getJobAndLock(jobNames: string[], lockTime: number): Promise<JobToRun>;
194
+ setJobRecordPriority(jobId: string, priority: number): Promise<void>;
195
+ scheduleNextRun(options: {
196
+ jobId: string;
197
+ nextRunAt: Date;
198
+ addTries: boolean;
199
+ priority: number;
200
+ }): Promise<void>;
201
+ deleteEventJob(jobId: string): Promise<void>;
202
+ extendLockTime(jobId: string, extraTime: number): Promise<void>;
203
+ ensureJobRecord(job: JobDefinitionWithName): Promise<void>;
204
+ scheduleJob(options: ScheduleJobRecordOptions): Promise<void>;
205
+ }
206
+
207
+ declare function Jobs(): ClassDecorator;
208
+ interface JobsPropertyDescriptor extends Omit<PropertyDecorator, 'value'> {
209
+ value?: JobDefinition['resolve'];
210
+ }
211
+ declare function RecurrentJob(options: Omit<RecurrentJobDefinition, 'resolve' | 'type'>): (target: any, propertyKey: string, descriptor: JobsPropertyDescriptor) => void;
212
+ declare function EventJob(options?: Omit<EventJobDefinition, 'resolve' | 'type'>): (target: any, propertyKey: string, descriptor: JobsPropertyDescriptor) => void;
213
+ declare function getServiceJobs(target: any): {
214
+ [key: string]: JobDefinition;
215
+ };
216
+
217
+ declare const jobsHistoryRepo: JobsHistoryRepo;
218
+ declare const jobsRepo: JobsRepo;
219
+ declare const startWorkers: (config: Partial<StartWorkersConfig>) => WorkersInstance;
220
+ declare const scheduleJob: (options: ScheduleJobOptions) => Promise<void>;
221
+
222
+ export { type BaseJobDefinition, EventJob, type EventJobDefinition, type ExecutionContext, HistoryRecord, type JobDefinition, type JobDefinitionWithName, JobRecord, type JobRetryResult, type JobRetryResultBase, type JobRetryResultRunAt, type JobRetryResultRunIn, type JobToRun, Jobs, type JobsDefinition, type JobsPropertyDescriptor, type LogLevels, RecurrentJob, type RecurrentJobDefinition, type ScheduleJobOptions, type ScheduleJobOptionsBase, type ScheduleJobOptionsRunAt, type ScheduleJobOptionsRunIn, type ScheduleJobRecordOptions, type StartWorkersConfig, type WorkerInstance, type WorkersInstance, defineJob, getServiceJobs, jobsHistoryRepo, jobsRepo, scheduleJob, startWorkers };
package/dist/index.d.ts CHANGED
@@ -1,215 +1,222 @@
1
- // Generated by dts-bundle-generator v9.5.1
2
-
1
+ import { Blackbox } from '@orion-js/schema';
3
2
  import { OrionLogger } from '@orion-js/logger';
3
+ import * as _orion_js_mongodb from '@orion-js/mongodb';
4
4
  import { ModelToDocumentTypeWithoutId } from '@orion-js/mongodb';
5
5
 
6
- export type Blackbox = {
7
- [name: string]: any;
8
- };
9
- export interface JobToRun {
10
- jobId: string;
11
- executionId: string;
12
- name: string;
13
- type: "event" | "recurrent";
14
- params: Blackbox;
15
- tries: number;
16
- lockTime: number;
17
- priority: number;
18
- uniqueIdentifier?: string;
19
- }
20
- export interface ExecutionContext {
21
- record: JobToRun;
22
- definition: JobDefinition;
23
- tries: number;
24
- logger: OrionLogger;
25
- extendLockTime: (extraTime: number) => Promise<void>;
26
- clearStaleTimeout: () => void;
27
- }
28
- export interface WorkerInstance {
29
- running: boolean;
30
- workerIndex: number;
31
- stop: () => Promise<void>;
32
- respawn: () => Promise<void>;
33
- promise?: Promise<any>;
34
- }
35
- export interface WorkersInstance {
36
- running: boolean;
37
- workersCount: number;
38
- workers: WorkerInstance[];
39
- /**
40
- * Stop all workers and wait for them to finish
41
- */
42
- stop: () => Promise<void>;
43
- }
44
- export interface JobRetryResultBase {
45
- action: "retry" | "dismiss";
46
- }
47
- export type JobRetryResultRunIn = JobRetryResultBase & {
48
- runIn: number;
6
+ interface ScheduleJobOptionsBase {
7
+ name: string;
8
+ params?: Blackbox;
9
+ priority?: number;
10
+ uniqueIdentifier?: string;
11
+ }
12
+ type ScheduleJobOptionsRunIn = ScheduleJobOptionsBase & {
13
+ runIn: number;
49
14
  };
50
- export type JobRetryResultRunAt = JobRetryResultBase & {
51
- runAt: Date;
15
+ type ScheduleJobOptionsRunAt = ScheduleJobOptionsBase & {
16
+ runAt: Date;
52
17
  };
53
- export type JobRetryResult = JobRetryResultRunIn | JobRetryResultRunAt | JobRetryResultBase;
54
- export interface BaseJobDefinition {
55
- /**
56
- * The function to execute when the job is executed.
57
- */
58
- resolve: (params: Blackbox, context: ExecutionContext) => Promise<Blackbox | void>;
59
- /**
60
- * Called if the job fails.
61
- */
62
- onError?: (error: Error, params: Blackbox, context: ExecutionContext) => Promise<JobRetryResult>;
63
- /**
64
- * Called if the job locktime is expired. The job will be executed again.
65
- */
66
- onStale?: (params: Blackbox, context: ExecutionContext) => Promise<void>;
67
- /**
68
- * Save the executions of the job time in milliseconds. Default is 1 week. Set to 0 to disable.
69
- */
70
- saveExecutionsFor?: number;
71
- }
72
- export interface RecurrentJobDefinition extends BaseJobDefinition {
73
- /**
74
- * Type of the job.
75
- */
76
- type: "recurrent";
77
- /**
78
- * A function executed after each execution that returns the date of the next run.
79
- */
80
- getNextRun?: () => Date;
81
- /**
82
- * Run every x milliseconds. This will be ignored if getNextRun is defined.
83
- */
84
- runEvery?: number;
85
- /**
86
- * The priority of the job. Higher is more priority. Default is 100.
87
- */
88
- priority?: number;
89
- }
90
- export interface EventJobDefinition extends BaseJobDefinition {
91
- /**
92
- * Type of the job.
93
- */
94
- type: "event";
95
- }
96
- export type JobDefinition = RecurrentJobDefinition | EventJobDefinition;
97
- export type JobDefinitionWithName = JobDefinition & {
98
- name: string;
18
+ type ScheduleJobOptions = ScheduleJobOptionsRunIn | ScheduleJobOptionsRunAt | ScheduleJobOptionsBase;
19
+ interface ScheduleJobRecordOptions {
20
+ name: string;
21
+ params: Blackbox;
22
+ nextRunAt: Date;
23
+ priority: number;
24
+ uniqueIdentifier?: string;
25
+ }
26
+
27
+ declare class HistoryRecord {
28
+ _id: string;
29
+ jobId: string;
30
+ executionId: string;
31
+ jobName: string;
32
+ type: 'recurrent' | 'event';
33
+ priority: number;
34
+ tries: number;
35
+ uniqueIdentifier?: string;
36
+ startedAt: Date;
37
+ endedAt: Date;
38
+ duration: number;
39
+ expiresAt?: Date;
40
+ status: 'success' | 'error' | 'stale';
41
+ errorMessage?: string;
42
+ params?: Blackbox;
43
+ result?: Blackbox;
44
+ }
45
+
46
+ declare class JobRecord {
47
+ _id: string;
48
+ jobName: string;
49
+ type: 'recurrent' | 'event';
50
+ priority: number;
51
+ uniqueIdentifier?: string;
52
+ nextRunAt: Date;
53
+ lastRunAt?: Date;
54
+ lockedUntil?: Date;
55
+ tries?: number;
56
+ params?: any;
57
+ }
58
+
59
+ interface JobToRun {
60
+ jobId: string;
61
+ executionId: string;
62
+ name: string;
63
+ type: 'event' | 'recurrent';
64
+ params: Blackbox;
65
+ tries: number;
66
+ lockTime: number;
67
+ priority: number;
68
+ uniqueIdentifier?: string;
69
+ }
70
+ interface ExecutionContext {
71
+ record: JobToRun;
72
+ definition: JobDefinition;
73
+ tries: number;
74
+ logger: OrionLogger;
75
+ extendLockTime: (extraTime: number) => Promise<void>;
76
+ clearStaleTimeout: () => void;
77
+ }
78
+ interface WorkerInstance {
79
+ running: boolean;
80
+ workerIndex: number;
81
+ stop: () => Promise<void>;
82
+ respawn: () => Promise<void>;
83
+ promise?: Promise<any>;
84
+ }
85
+ interface WorkersInstance {
86
+ running: boolean;
87
+ workersCount: number;
88
+ workers: WorkerInstance[];
89
+ /**
90
+ * Stop all workers and wait for them to finish
91
+ */
92
+ stop: () => Promise<void>;
93
+ }
94
+
95
+ interface JobRetryResultBase {
96
+ action: 'retry' | 'dismiss';
97
+ }
98
+ type JobRetryResultRunIn = JobRetryResultBase & {
99
+ runIn: number;
99
100
  };
100
- export interface JobsDefinition {
101
- [jobName: string]: JobDefinition;
102
- }
103
- export declare const defineJob: (options: JobDefinition) => JobDefinition;
104
- export type LogLevels = "debug" | "info" | "warn" | "error" | "none";
105
- export interface StartWorkersConfig {
106
- /**
107
- * Object map of the jobs that this workers will execute
108
- */
109
- jobs: JobsDefinition;
110
- /**
111
- * Time in milliseconds to wait between each look without results for a job
112
- * to run at the database. Default is 3000.
113
- */
114
- pollInterval: number;
115
- /**
116
- * Time in milliseconds to wait too look for a job after a job execution. Default is 100.
117
- */
118
- cooldownPeriod: number;
119
- /**
120
- * Number of workers to start. Default is 1.
121
- */
122
- workersCount: number;
123
- /**
124
- * Time in milliseconds to lock a job for execution. Default is 30000 (30 seconds).
125
- * If a job is locked for longer than this time, it will be considered as failed.
126
- * This is to prevent a job from being executed multiple times at the same time.
127
- * You can extend this time inside a job by calling extendLockTime from context.
128
- */
129
- lockTime: number;
130
- }
131
- export interface ScheduleJobOptionsBase {
132
- name: string;
133
- params?: Blackbox;
134
- priority?: number;
135
- uniqueIdentifier?: string;
136
- }
137
- export type ScheduleJobOptionsRunIn = ScheduleJobOptionsBase & {
138
- runIn: number;
101
+ type JobRetryResultRunAt = JobRetryResultBase & {
102
+ runAt: Date;
139
103
  };
140
- export type ScheduleJobOptionsRunAt = ScheduleJobOptionsBase & {
141
- runAt: Date;
104
+ type JobRetryResult = JobRetryResultRunIn | JobRetryResultRunAt | JobRetryResultBase;
105
+ interface BaseJobDefinition {
106
+ /**
107
+ * The function to execute when the job is executed.
108
+ */
109
+ resolve: (params: Blackbox, context: ExecutionContext) => Promise<Blackbox | void>;
110
+ /**
111
+ * Called if the job fails.
112
+ */
113
+ onError?: (error: Error, params: Blackbox, context: ExecutionContext) => Promise<JobRetryResult>;
114
+ /**
115
+ * Called if the job locktime is expired. The job will be executed again.
116
+ */
117
+ onStale?: (params: Blackbox, context: ExecutionContext) => Promise<void>;
118
+ /**
119
+ * Save the executions of the job time in milliseconds. Default is 1 week. Set to 0 to disable.
120
+ */
121
+ saveExecutionsFor?: number;
122
+ }
123
+ interface RecurrentJobDefinition extends BaseJobDefinition {
124
+ /**
125
+ * Type of the job.
126
+ */
127
+ type: 'recurrent';
128
+ /**
129
+ * A function executed after each execution that returns the date of the next run.
130
+ */
131
+ getNextRun?: () => Date;
132
+ /**
133
+ * Run every x milliseconds. This will be ignored if getNextRun is defined.
134
+ */
135
+ runEvery?: number;
136
+ /**
137
+ * The priority of the job. Higher is more priority. Default is 100.
138
+ */
139
+ priority?: number;
140
+ }
141
+ interface EventJobDefinition extends BaseJobDefinition {
142
+ /**
143
+ * Type of the job.
144
+ */
145
+ type: 'event';
146
+ }
147
+ type JobDefinition = RecurrentJobDefinition | EventJobDefinition;
148
+ type JobDefinitionWithName = JobDefinition & {
149
+ name: string;
142
150
  };
143
- export type ScheduleJobOptions = ScheduleJobOptionsRunIn | ScheduleJobOptionsRunAt | ScheduleJobOptionsBase;
144
- export interface ScheduleJobRecordOptions {
145
- name: string;
146
- params: Blackbox;
147
- nextRunAt: Date;
148
- priority: number;
149
- uniqueIdentifier?: string;
150
- }
151
- export declare class HistoryRecord {
152
- _id: string;
153
- jobId: string;
154
- executionId: string;
155
- jobName: string;
156
- type: "recurrent" | "event";
157
- priority: number;
158
- tries: number;
159
- uniqueIdentifier?: string;
160
- startedAt: Date;
161
- endedAt: Date;
162
- duration: number;
163
- expiresAt?: Date;
164
- status: "success" | "error" | "stale";
165
- errorMessage?: string;
166
- params?: Blackbox;
167
- result?: Blackbox;
151
+ interface JobsDefinition {
152
+ [jobName: string]: JobDefinition;
153
+ }
154
+
155
+ type LogLevels = 'debug' | 'info' | 'warn' | 'error' | 'none';
156
+ interface StartWorkersConfig {
157
+ /**
158
+ * Object map of the jobs that this workers will execute
159
+ */
160
+ jobs: JobsDefinition;
161
+ /**
162
+ * Time in milliseconds to wait between each look without results for a job
163
+ * to run at the database. Default is 3000.
164
+ */
165
+ pollInterval: number;
166
+ /**
167
+ * Time in milliseconds to wait too look for a job after a job execution. Default is 100.
168
+ */
169
+ cooldownPeriod: number;
170
+ /**
171
+ * Number of workers to start. Default is 1.
172
+ */
173
+ workersCount: number;
174
+ /**
175
+ * Time in milliseconds to lock a job for execution. Default is 30000 (30 seconds).
176
+ * If a job is locked for longer than this time, it will be considered as failed.
177
+ * This is to prevent a job from being executed multiple times at the same time.
178
+ * You can extend this time inside a job by calling extendLockTime from context.
179
+ */
180
+ lockTime: number;
168
181
  }
182
+
183
+ declare const defineJob: (options: JobDefinition) => JobDefinition;
184
+
169
185
  declare class JobsHistoryRepo {
170
- history: () => import("@orion-js/mongodb").Collection<HistoryRecord>;
171
- saveExecution(record: ModelToDocumentTypeWithoutId<HistoryRecord>): Promise<void>;
172
- getExecutions(jobName: string, limit?: number, skip?: number): Promise<HistoryRecord[]>;
173
- }
174
- export declare class JobRecord {
175
- _id: string;
176
- jobName: string;
177
- type: "recurrent" | "event";
178
- priority: number;
179
- uniqueIdentifier?: string;
180
- nextRunAt: Date;
181
- lastRunAt?: Date;
182
- lockedUntil?: Date;
183
- tries?: number;
184
- params?: any;
186
+ history: () => _orion_js_mongodb.Collection<HistoryRecord>;
187
+ saveExecution(record: ModelToDocumentTypeWithoutId<HistoryRecord>): Promise<void>;
188
+ getExecutions(jobName: string, limit?: number, skip?: number): Promise<HistoryRecord[]>;
185
189
  }
190
+
186
191
  declare class JobsRepo {
187
- jobs: () => import("@orion-js/mongodb").Collection<JobRecord>;
188
- getJobAndLock(jobNames: string[], lockTime: number): Promise<JobToRun>;
189
- setJobRecordPriority(jobId: string, priority: number): Promise<void>;
190
- scheduleNextRun(options: {
191
- jobId: string;
192
- nextRunAt: Date;
193
- addTries: boolean;
194
- priority: number;
195
- }): Promise<void>;
196
- deleteEventJob(jobId: string): Promise<void>;
197
- extendLockTime(jobId: string, extraTime: number): Promise<void>;
198
- ensureJobRecord(job: JobDefinitionWithName): Promise<void>;
199
- scheduleJob(options: ScheduleJobRecordOptions): Promise<void>;
200
- }
201
- export declare function Jobs(): ClassDecorator;
202
- export interface JobsPropertyDescriptor extends Omit<PropertyDecorator, "value"> {
203
- value?: JobDefinition["resolve"];
204
- }
205
- export declare function RecurrentJob(options: Omit<RecurrentJobDefinition, "resolve" | "type">): (target: any, propertyKey: string, descriptor: JobsPropertyDescriptor) => void;
206
- export declare function EventJob(options?: Omit<EventJobDefinition, "resolve" | "type">): (target: any, propertyKey: string, descriptor: JobsPropertyDescriptor) => void;
207
- export declare function getServiceJobs(target: any): {
208
- [key: string]: JobDefinition;
192
+ jobs: () => _orion_js_mongodb.Collection<JobRecord>;
193
+ getJobAndLock(jobNames: string[], lockTime: number): Promise<JobToRun>;
194
+ setJobRecordPriority(jobId: string, priority: number): Promise<void>;
195
+ scheduleNextRun(options: {
196
+ jobId: string;
197
+ nextRunAt: Date;
198
+ addTries: boolean;
199
+ priority: number;
200
+ }): Promise<void>;
201
+ deleteEventJob(jobId: string): Promise<void>;
202
+ extendLockTime(jobId: string, extraTime: number): Promise<void>;
203
+ ensureJobRecord(job: JobDefinitionWithName): Promise<void>;
204
+ scheduleJob(options: ScheduleJobRecordOptions): Promise<void>;
205
+ }
206
+
207
+ declare function Jobs(): ClassDecorator;
208
+ interface JobsPropertyDescriptor extends Omit<PropertyDecorator, 'value'> {
209
+ value?: JobDefinition['resolve'];
210
+ }
211
+ declare function RecurrentJob(options: Omit<RecurrentJobDefinition, 'resolve' | 'type'>): (target: any, propertyKey: string, descriptor: JobsPropertyDescriptor) => void;
212
+ declare function EventJob(options?: Omit<EventJobDefinition, 'resolve' | 'type'>): (target: any, propertyKey: string, descriptor: JobsPropertyDescriptor) => void;
213
+ declare function getServiceJobs(target: any): {
214
+ [key: string]: JobDefinition;
209
215
  };
210
- export declare const jobsHistoryRepo: JobsHistoryRepo;
211
- export declare const jobsRepo: JobsRepo;
212
- export declare const startWorkers: (config: Partial<StartWorkersConfig>) => WorkersInstance;
213
- export declare const scheduleJob: (options: ScheduleJobOptions) => Promise<void>;
214
216
 
215
- export {};
217
+ declare const jobsHistoryRepo: JobsHistoryRepo;
218
+ declare const jobsRepo: JobsRepo;
219
+ declare const startWorkers: (config: Partial<StartWorkersConfig>) => WorkersInstance;
220
+ declare const scheduleJob: (options: ScheduleJobOptions) => Promise<void>;
221
+
222
+ export { type BaseJobDefinition, EventJob, type EventJobDefinition, type ExecutionContext, HistoryRecord, type JobDefinition, type JobDefinitionWithName, JobRecord, type JobRetryResult, type JobRetryResultBase, type JobRetryResultRunAt, type JobRetryResultRunIn, type JobToRun, Jobs, type JobsDefinition, type JobsPropertyDescriptor, type LogLevels, RecurrentJob, type RecurrentJobDefinition, type ScheduleJobOptions, type ScheduleJobOptionsBase, type ScheduleJobOptionsRunAt, type ScheduleJobOptionsRunIn, type ScheduleJobRecordOptions, type StartWorkersConfig, type WorkerInstance, type WorkersInstance, defineJob, getServiceJobs, jobsHistoryRepo, jobsRepo, scheduleJob, startWorkers };