@igniter-js/jobs 0.1.13 → 0.1.15
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.
- package/AGENTS.md +119 -243
- package/README.md +352 -158
- package/dist/{adapter-CXZxomI9.d.mts → adapter-DDyMVche.d.mts} +125 -20
- package/dist/{adapter-CXZxomI9.d.ts → adapter-DDyMVche.d.ts} +125 -20
- package/dist/adapters/bun.d.mts +101 -0
- package/dist/adapters/bun.d.ts +101 -0
- package/dist/adapters/bun.js +1048 -0
- package/dist/adapters/bun.js.map +1 -0
- package/dist/adapters/bun.mjs +1046 -0
- package/dist/adapters/bun.mjs.map +1 -0
- package/dist/adapters/{memory.adapter.d.ts → mock.d.mts} +7 -3
- package/dist/adapters/{memory.adapter.d.mts → mock.d.ts} +7 -3
- package/dist/adapters/{memory.adapter.js → mock.js} +122 -25
- package/dist/adapters/mock.js.map +1 -0
- package/dist/adapters/{memory.adapter.mjs → mock.mjs} +122 -25
- package/dist/adapters/mock.mjs.map +1 -0
- package/dist/adapters/{bullmq.adapter.d.mts → node.d.mts} +8 -3
- package/dist/adapters/{bullmq.adapter.d.ts → node.d.ts} +8 -3
- package/dist/adapters/{bullmq.adapter.js → node.js} +194 -40
- package/dist/adapters/node.js.map +1 -0
- package/dist/adapters/{bullmq.adapter.mjs → node.mjs} +194 -40
- package/dist/adapters/node.mjs.map +1 -0
- package/dist/index.d.mts +41 -38
- package/dist/index.d.ts +41 -38
- package/dist/index.js +145 -1856
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +146 -1854
- package/dist/index.mjs.map +1 -1
- package/package.json +29 -41
- package/CHANGELOG.md +0 -13
- package/dist/adapters/bullmq.adapter.js.map +0 -1
- package/dist/adapters/bullmq.adapter.mjs.map +0 -1
- package/dist/adapters/index.d.mts +0 -143
- package/dist/adapters/index.d.ts +0 -143
- package/dist/adapters/index.js +0 -1891
- package/dist/adapters/index.js.map +0 -1
- package/dist/adapters/index.mjs +0 -1887
- package/dist/adapters/index.mjs.map +0 -1
- package/dist/adapters/memory.adapter.js.map +0 -1
- package/dist/adapters/memory.adapter.mjs.map +0 -1
|
@@ -127,6 +127,62 @@ type IgniterJobsInferSchemaOutput<TSchema> = TSchema extends StandardSchemaV1 ?
|
|
|
127
127
|
_output?: infer TOutput;
|
|
128
128
|
} ? TOutput : unknown;
|
|
129
129
|
|
|
130
|
+
type IgniterJobsJobStreamSchemaMap = Record<string, IgniterJobsSchema>;
|
|
131
|
+
interface IgniterJobsJobStreamPersistenceConfig {
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
maxEvents?: number;
|
|
134
|
+
}
|
|
135
|
+
interface IgniterJobsJobStreamDefinition<TEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> {
|
|
136
|
+
persistence?: IgniterJobsJobStreamPersistenceConfig;
|
|
137
|
+
events?: TEvents;
|
|
138
|
+
}
|
|
139
|
+
interface IgniterJobsJobStreamEvent<TType extends string = string, TData = unknown> {
|
|
140
|
+
id: string;
|
|
141
|
+
type: TType;
|
|
142
|
+
data: TData;
|
|
143
|
+
timestamp: Date;
|
|
144
|
+
jobId: string;
|
|
145
|
+
jobName: string;
|
|
146
|
+
queue: string;
|
|
147
|
+
scope?: IgniterJobsScopeEntry;
|
|
148
|
+
}
|
|
149
|
+
interface IgniterJobsJobStreamReadParams {
|
|
150
|
+
after?: string;
|
|
151
|
+
limit?: number;
|
|
152
|
+
}
|
|
153
|
+
type IgniterJobsJobStreamReadResult<TEvent extends IgniterJobsJobStreamEvent = IgniterJobsJobStreamEvent> = {
|
|
154
|
+
items: TEvent[];
|
|
155
|
+
nextCursor?: string;
|
|
156
|
+
hasMore: boolean;
|
|
157
|
+
};
|
|
158
|
+
type IgniterJobsStreamEventsFromDefinition<TDef> = TDef extends {
|
|
159
|
+
stream?: {
|
|
160
|
+
events?: infer TEvents;
|
|
161
|
+
};
|
|
162
|
+
} ? TEvents extends IgniterJobsJobStreamSchemaMap ? TEvents : {} : {};
|
|
163
|
+
type IgniterJobsStreamEventKeys<TDef> = Extract<keyof IgniterJobsStreamEventsFromDefinition<TDef>, string>;
|
|
164
|
+
type IgniterJobsInferStreamType<TDef> = [
|
|
165
|
+
IgniterJobsStreamEventKeys<TDef>
|
|
166
|
+
] extends [never] ? string : IgniterJobsStreamEventKeys<TDef>;
|
|
167
|
+
type IgniterJobsInferStreamEmitData<TDef, TType extends string> = [
|
|
168
|
+
IgniterJobsStreamEventKeys<TDef>
|
|
169
|
+
] extends [never] ? unknown : TType extends IgniterJobsStreamEventKeys<TDef> ? IgniterJobsInferSchemaInput<IgniterJobsStreamEventsFromDefinition<TDef>[TType]> : unknown;
|
|
170
|
+
type IgniterJobsInferStreamReadData<TDef, TType extends string> = [
|
|
171
|
+
IgniterJobsStreamEventKeys<TDef>
|
|
172
|
+
] extends [never] ? unknown : TType extends IgniterJobsStreamEventKeys<TDef> ? IgniterJobsInferSchemaOutput<IgniterJobsStreamEventsFromDefinition<TDef>[TType]> : unknown;
|
|
173
|
+
type IgniterJobsInferJobStreamEvent<TDef> = [
|
|
174
|
+
IgniterJobsStreamEventKeys<TDef>
|
|
175
|
+
] extends [never] ? IgniterJobsJobStreamEvent<string, unknown> : {
|
|
176
|
+
[K in IgniterJobsStreamEventKeys<TDef>]: IgniterJobsJobStreamEvent<K, IgniterJobsInferStreamReadData<TDef, K>>;
|
|
177
|
+
}[IgniterJobsStreamEventKeys<TDef>];
|
|
178
|
+
interface IgniterJobsExecutionStreamEmitter<TDef = unknown, TType extends string = IgniterJobsInferStreamType<TDef>> {
|
|
179
|
+
emit<TEventType extends TType>(type: TEventType, data: IgniterJobsInferStreamEmitData<TDef, TEventType>): Promise<string>;
|
|
180
|
+
}
|
|
181
|
+
interface IgniterJobsJobStreamAccessor<TDef = unknown> {
|
|
182
|
+
subscribe(handler: (event: IgniterJobsInferJobStreamEvent<TDef>) => void | Promise<void>): Promise<() => Promise<void>>;
|
|
183
|
+
read(params?: IgniterJobsJobStreamReadParams): Promise<IgniterJobsJobStreamReadResult<IgniterJobsInferJobStreamEvent<TDef>>>;
|
|
184
|
+
}
|
|
185
|
+
|
|
130
186
|
/**
|
|
131
187
|
* Rate limiter configuration applied to job dispatch or worker level.
|
|
132
188
|
*/
|
|
@@ -152,7 +208,7 @@ interface IgniterJobsInvokeOptions {
|
|
|
152
208
|
/**
|
|
153
209
|
* Runtime execution context passed to handlers.
|
|
154
210
|
*/
|
|
155
|
-
interface IgniterJobsExecutionContext<TContext, TInput extends IgniterJobsSchema | unknown = unknown> {
|
|
211
|
+
interface IgniterJobsExecutionContext<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> {
|
|
156
212
|
input: IgniterJobsInferSchemaInput<TInput>;
|
|
157
213
|
context: TContext;
|
|
158
214
|
job: {
|
|
@@ -167,45 +223,55 @@ interface IgniterJobsExecutionContext<TContext, TInput extends IgniterJobsSchema
|
|
|
167
223
|
*/
|
|
168
224
|
createdAt?: Date;
|
|
169
225
|
metadata?: Record<string, unknown>;
|
|
226
|
+
/**
|
|
227
|
+
* Reports job progress and triggers the public progress hook when supported by the adapter.
|
|
228
|
+
*/
|
|
229
|
+
updateProgress?: (progress: number, message?: string) => Promise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* Emits typed stream events for the current job execution.
|
|
232
|
+
*/
|
|
233
|
+
stream: IgniterJobsExecutionStreamEmitter<IgniterJobDefinition<TContext, TInput, unknown, TStreamEvents>>;
|
|
170
234
|
};
|
|
171
235
|
scope?: IgniterJobsScopeEntry;
|
|
172
236
|
}
|
|
173
237
|
/**
|
|
174
238
|
* Hook context shared by lifecycle handlers.
|
|
175
239
|
*/
|
|
176
|
-
interface IgniterJobsHookContext<TContext, TInput extends IgniterJobsSchema | unknown = unknown> extends IgniterJobsExecutionContext<TContext, TInput> {
|
|
240
|
+
interface IgniterJobsHookContext<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> extends IgniterJobsExecutionContext<TContext, TInput, TStreamEvents> {
|
|
177
241
|
startedAt?: Date;
|
|
178
242
|
duration?: number;
|
|
179
243
|
}
|
|
180
|
-
type IgniterJobsStartHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown> = (context: IgniterJobsHookContext<TContext, TInput>) => void | Promise<void>;
|
|
181
|
-
type IgniterJobsSuccessHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TResult = unknown> = (context: IgniterJobsHookContext<TContext, TInput> & {
|
|
244
|
+
type IgniterJobsStartHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> = (context: IgniterJobsHookContext<TContext, TInput, TStreamEvents>) => void | Promise<void>;
|
|
245
|
+
type IgniterJobsSuccessHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TResult = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> = (context: IgniterJobsHookContext<TContext, TInput, TStreamEvents> & {
|
|
182
246
|
result: TResult;
|
|
183
247
|
}) => void | Promise<void>;
|
|
184
|
-
type IgniterJobsFailureHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown> = (context: IgniterJobsHookContext<TContext, TInput> & {
|
|
248
|
+
type IgniterJobsFailureHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> = (context: IgniterJobsHookContext<TContext, TInput, TStreamEvents> & {
|
|
185
249
|
error: Error;
|
|
186
250
|
isFinalAttempt: boolean;
|
|
187
251
|
}) => void | Promise<void>;
|
|
188
|
-
type IgniterJobsProgressHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown> = (context: IgniterJobsHookContext<TContext, TInput> & {
|
|
252
|
+
type IgniterJobsProgressHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> = (context: IgniterJobsHookContext<TContext, TInput, TStreamEvents> & {
|
|
189
253
|
progress: number;
|
|
190
254
|
message?: string;
|
|
191
255
|
}) => void | Promise<void>;
|
|
192
256
|
/**
|
|
193
257
|
* Definition of a job registered on a queue.
|
|
194
258
|
*/
|
|
195
|
-
interface IgniterJobDefinition<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TResult = unknown> extends IgniterJobsInvokeOptions {
|
|
259
|
+
interface IgniterJobDefinition<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TResult = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> extends IgniterJobsInvokeOptions {
|
|
196
260
|
/** Optional input schema for validation. */
|
|
197
261
|
input?: TInput;
|
|
198
262
|
/** Optional output schema (validation handled externally). */
|
|
199
263
|
output?: IgniterJobsSchema;
|
|
200
264
|
/** Optional queue override (creates child queue in adapters). */
|
|
201
265
|
queue?: string;
|
|
266
|
+
/** Optional stream configuration for live and persisted per-job events. */
|
|
267
|
+
stream?: IgniterJobsJobStreamDefinition<TStreamEvents>;
|
|
202
268
|
/** Job handler implementation. */
|
|
203
|
-
handler: (context: IgniterJobsExecutionContext<TContext, TInput>) => Promise<TResult> | TResult;
|
|
269
|
+
handler: (context: IgniterJobsExecutionContext<TContext, TInput, TStreamEvents>) => Promise<TResult> | TResult;
|
|
204
270
|
/** Lifecycle hooks */
|
|
205
|
-
onStart?: IgniterJobsStartHook<TContext, TInput>;
|
|
206
|
-
onProgress?: IgniterJobsProgressHook<TContext, TInput>;
|
|
207
|
-
onSuccess?: IgniterJobsSuccessHook<TContext, TInput, TResult>;
|
|
208
|
-
onFailure?: IgniterJobsFailureHook<TContext, TInput>;
|
|
271
|
+
onStart?: IgniterJobsStartHook<TContext, TInput, TStreamEvents>;
|
|
272
|
+
onProgress?: IgniterJobsProgressHook<TContext, TInput, TStreamEvents>;
|
|
273
|
+
onSuccess?: IgniterJobsSuccessHook<TContext, TInput, TResult, TStreamEvents>;
|
|
274
|
+
onFailure?: IgniterJobsFailureHook<TContext, TInput, TStreamEvents>;
|
|
209
275
|
}
|
|
210
276
|
/**
|
|
211
277
|
* Definition for cron-style recurring tasks.
|
|
@@ -235,12 +301,12 @@ interface IgniterCronDefinition<TContext, TResult = unknown> {
|
|
|
235
301
|
startDate?: Date;
|
|
236
302
|
/** Optional end date for the schedule (adapter-dependent). */
|
|
237
303
|
endDate?: Date;
|
|
238
|
-
handler: (context: Omit<IgniterJobsExecutionContext<TContext, unknown>,
|
|
304
|
+
handler: (context: Omit<IgniterJobsExecutionContext<TContext, unknown>, "input">) => Promise<TResult> | TResult;
|
|
239
305
|
}
|
|
240
306
|
/**
|
|
241
307
|
* Supported job states for management queries.
|
|
242
308
|
*/
|
|
243
|
-
type IgniterJobStatus =
|
|
309
|
+
type IgniterJobStatus = "waiting" | "active" | "completed" | "failed" | "delayed" | "paused";
|
|
244
310
|
/**
|
|
245
311
|
* Result shape for job inspection calls.
|
|
246
312
|
*/
|
|
@@ -299,11 +365,11 @@ type IgniterJobsScheduleParams<TInput = unknown> = IgniterJobsDispatchParams<TIn
|
|
|
299
365
|
/**
|
|
300
366
|
* Queue configuration produced by `IgniterQueueBuilder`.
|
|
301
367
|
*/
|
|
302
|
-
interface IgniterJobsQueue<TContext, TJobs extends Record<string, IgniterJobDefinition<TContext, any, any>>, TCron extends Record<string, IgniterCronDefinition<TContext, any>>> {
|
|
368
|
+
interface IgniterJobsQueue<TContext, TJobs extends Record<string, IgniterJobDefinition<TContext, any, any, any>>, TCron extends Record<string, IgniterCronDefinition<TContext, any>>> {
|
|
303
369
|
name: string;
|
|
304
370
|
jobs: TJobs;
|
|
305
371
|
crons: TCron;
|
|
306
|
-
defaultJobOptions?: Partial<IgniterJobDefinition<TContext, any, any>>;
|
|
372
|
+
defaultJobOptions?: Partial<IgniterJobDefinition<TContext, any, any, any>>;
|
|
307
373
|
}
|
|
308
374
|
/**
|
|
309
375
|
* Information about a queue used by management APIs.
|
|
@@ -475,7 +541,26 @@ type IgniterJobsAdapterScheduleParams = {
|
|
|
475
541
|
interface IgniterJobsJobLog {
|
|
476
542
|
timestamp: Date;
|
|
477
543
|
message: string;
|
|
478
|
-
level:
|
|
544
|
+
level: "info" | "warn" | "error";
|
|
545
|
+
}
|
|
546
|
+
interface IgniterJobsAdapterJobStreamWriteParams {
|
|
547
|
+
queue: string;
|
|
548
|
+
jobName: string;
|
|
549
|
+
jobId: string;
|
|
550
|
+
scope?: IgniterJobsScopeEntry;
|
|
551
|
+
persistence?: IgniterJobsJobStreamPersistenceConfig;
|
|
552
|
+
event: Omit<IgniterJobsJobStreamEvent<string, unknown>, "id">;
|
|
553
|
+
}
|
|
554
|
+
interface IgniterJobsAdapterJobStreamReadParams {
|
|
555
|
+
queue: string;
|
|
556
|
+
jobId: string;
|
|
557
|
+
after?: string;
|
|
558
|
+
limit?: number;
|
|
559
|
+
}
|
|
560
|
+
interface IgniterJobsAdapterJobStreamSubscribeParams {
|
|
561
|
+
queue: string;
|
|
562
|
+
jobId: string;
|
|
563
|
+
handler: (event: IgniterJobsJobStreamEvent<string, unknown>) => void | Promise<void>;
|
|
479
564
|
}
|
|
480
565
|
/**
|
|
481
566
|
* Adapter contract for jobs backends.
|
|
@@ -506,8 +591,6 @@ interface IgniterJobsAdapter {
|
|
|
506
591
|
force?: boolean;
|
|
507
592
|
}): Promise<void>;
|
|
508
593
|
retryAllInQueue(queue: string): Promise<number>;
|
|
509
|
-
pauseJobType(queue: string, jobName: string): Promise<void>;
|
|
510
|
-
resumeJobType(queue: string, jobName: string): Promise<void>;
|
|
511
594
|
searchJobs(filter: Record<string, unknown>): Promise<IgniterJobSearchResult[]>;
|
|
512
595
|
searchQueues(filter: Record<string, unknown>): Promise<IgniterJobsQueueInfo[]>;
|
|
513
596
|
searchWorkers(filter: Record<string, unknown>): Promise<IgniterJobsWorkerHandle[]>;
|
|
@@ -515,6 +598,9 @@ interface IgniterJobsAdapter {
|
|
|
515
598
|
getWorkers(): Map<string, IgniterJobsWorkerHandle>;
|
|
516
599
|
publishEvent(channel: string, payload: unknown): Promise<void>;
|
|
517
600
|
subscribeEvent(channel: string, handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
|
|
601
|
+
writeJobStreamEvent(params: IgniterJobsAdapterJobStreamWriteParams): Promise<string>;
|
|
602
|
+
readJobStream(params: IgniterJobsAdapterJobStreamReadParams): Promise<IgniterJobsJobStreamReadResult<IgniterJobsJobStreamEvent<string, unknown>>>;
|
|
603
|
+
subscribeJobStream(params: IgniterJobsAdapterJobStreamSubscribeParams): Promise<() => Promise<void>>;
|
|
518
604
|
registerJob(queueName: string, jobName: string, definition: IgniterJobDefinition<any, any, any>): void;
|
|
519
605
|
registerCron(queueName: string, cronName: string, definition: IgniterCronDefinition<any, any>): void;
|
|
520
606
|
shutdown(): Promise<void>;
|
|
@@ -525,5 +611,24 @@ interface IgniterJobsAdapter {
|
|
|
525
611
|
interface IgniterJobsBullMQAdapterOptions {
|
|
526
612
|
redis: Redis;
|
|
527
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* Configuration for the Bun SQLite adapter.
|
|
616
|
+
*/
|
|
617
|
+
interface IgniterJobsBunSQLiteAdapterOptions {
|
|
618
|
+
/** SQLite file path used by the embedded runtime. */
|
|
619
|
+
path: string;
|
|
620
|
+
/** Forces immediate persistence for dispatched jobs. @default false */
|
|
621
|
+
durable?: boolean;
|
|
622
|
+
/** Worker heartbeat interval in milliseconds. @default 10000 */
|
|
623
|
+
heartbeatInterval?: number;
|
|
624
|
+
/** Long-poll timeout while the queue is empty. @default 0 */
|
|
625
|
+
pollTimeout?: number;
|
|
626
|
+
/** Number of jobs pulled per worker batch. @default 10 */
|
|
627
|
+
batchSize?: number;
|
|
628
|
+
/** Lock duration for active jobs in milliseconds. @default 30000 */
|
|
629
|
+
lockDuration?: number;
|
|
630
|
+
/** Maximum stalled detections before a job fails. @default 1 */
|
|
631
|
+
maxStalledCount?: number;
|
|
632
|
+
}
|
|
528
633
|
|
|
529
|
-
export type {
|
|
634
|
+
export type { IgniterJobsSuccessHook as $, IgniterJobsAdapterJobStreamWriteParams as A, IgniterJobsAdapterScheduleParams as B, IgniterJobsBullMQAdapterOptions as C, IgniterJobsBunSQLiteAdapterOptions as D, IgniterJobsEvent as E, IgniterJobsExecutionContext as F, IgniterJobsExecutionStreamEmitter as G, IgniterJobsFailureHook as H, IgniterJobsQueue as I, IgniterJobsHookContext as J, IgniterJobsInferJobStreamEvent as K, IgniterJobsInferSchemaOutput as L, IgniterJobsInferStreamEmitData as M, IgniterJobsInferStreamReadData as N, IgniterJobsInferStreamType as O, IgniterJobsInvokeOptions as P, IgniterJobsJobLog as Q, IgniterJobsJobStreamDefinition as R, IgniterJobsJobStreamEvent as S, IgniterJobsJobStreamPersistenceConfig as T, IgniterJobsJobStreamReadParams as U, IgniterJobsJobStreamReadResult as V, IgniterJobsProgressHook as W, IgniterJobsQueueManager as X, IgniterJobsScheduleOptions as Y, IgniterJobsStartHook as Z, IgniterJobsStreamEventsFromDefinition as _, IgniterJobsAdapter as a, IgniterJobsWorkerMetrics as a0, IgniterJobsScopeDefinition as b, IgniterJobDefinition as c, IgniterJobsWorkerBuilderConfig as d, IgniterJobsTelemetry as e, IgniterJobsEventHandler as f, IgniterJobSearchResult as g, IgniterJobsQueueInfo as h, IgniterJobsWorkerHandle as i, IgniterJobsLimiter as j, IgniterJobsWorkerHandlers as k, IgniterJobsQueueCleanOptions as l, IgniterJobStatus as m, IgniterJobsDispatchParams as n, IgniterJobsInferSchemaInput as o, IgniterJobsScheduleParams as p, IgniterJobsJobStreamAccessor as q, IgniterCronDefinition as r, IgniterJobsScopeEntry as s, IgniterJobsSchema as t, IgniterJobsJobStreamSchemaMap as u, IgniterJobsScopeOptions as v, IgniterJobCounts as w, IgniterJobsAdapterDispatchParams as x, IgniterJobsAdapterJobStreamReadParams as y, IgniterJobsAdapterJobStreamSubscribeParams as z };
|
|
@@ -127,6 +127,62 @@ type IgniterJobsInferSchemaOutput<TSchema> = TSchema extends StandardSchemaV1 ?
|
|
|
127
127
|
_output?: infer TOutput;
|
|
128
128
|
} ? TOutput : unknown;
|
|
129
129
|
|
|
130
|
+
type IgniterJobsJobStreamSchemaMap = Record<string, IgniterJobsSchema>;
|
|
131
|
+
interface IgniterJobsJobStreamPersistenceConfig {
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
maxEvents?: number;
|
|
134
|
+
}
|
|
135
|
+
interface IgniterJobsJobStreamDefinition<TEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> {
|
|
136
|
+
persistence?: IgniterJobsJobStreamPersistenceConfig;
|
|
137
|
+
events?: TEvents;
|
|
138
|
+
}
|
|
139
|
+
interface IgniterJobsJobStreamEvent<TType extends string = string, TData = unknown> {
|
|
140
|
+
id: string;
|
|
141
|
+
type: TType;
|
|
142
|
+
data: TData;
|
|
143
|
+
timestamp: Date;
|
|
144
|
+
jobId: string;
|
|
145
|
+
jobName: string;
|
|
146
|
+
queue: string;
|
|
147
|
+
scope?: IgniterJobsScopeEntry;
|
|
148
|
+
}
|
|
149
|
+
interface IgniterJobsJobStreamReadParams {
|
|
150
|
+
after?: string;
|
|
151
|
+
limit?: number;
|
|
152
|
+
}
|
|
153
|
+
type IgniterJobsJobStreamReadResult<TEvent extends IgniterJobsJobStreamEvent = IgniterJobsJobStreamEvent> = {
|
|
154
|
+
items: TEvent[];
|
|
155
|
+
nextCursor?: string;
|
|
156
|
+
hasMore: boolean;
|
|
157
|
+
};
|
|
158
|
+
type IgniterJobsStreamEventsFromDefinition<TDef> = TDef extends {
|
|
159
|
+
stream?: {
|
|
160
|
+
events?: infer TEvents;
|
|
161
|
+
};
|
|
162
|
+
} ? TEvents extends IgniterJobsJobStreamSchemaMap ? TEvents : {} : {};
|
|
163
|
+
type IgniterJobsStreamEventKeys<TDef> = Extract<keyof IgniterJobsStreamEventsFromDefinition<TDef>, string>;
|
|
164
|
+
type IgniterJobsInferStreamType<TDef> = [
|
|
165
|
+
IgniterJobsStreamEventKeys<TDef>
|
|
166
|
+
] extends [never] ? string : IgniterJobsStreamEventKeys<TDef>;
|
|
167
|
+
type IgniterJobsInferStreamEmitData<TDef, TType extends string> = [
|
|
168
|
+
IgniterJobsStreamEventKeys<TDef>
|
|
169
|
+
] extends [never] ? unknown : TType extends IgniterJobsStreamEventKeys<TDef> ? IgniterJobsInferSchemaInput<IgniterJobsStreamEventsFromDefinition<TDef>[TType]> : unknown;
|
|
170
|
+
type IgniterJobsInferStreamReadData<TDef, TType extends string> = [
|
|
171
|
+
IgniterJobsStreamEventKeys<TDef>
|
|
172
|
+
] extends [never] ? unknown : TType extends IgniterJobsStreamEventKeys<TDef> ? IgniterJobsInferSchemaOutput<IgniterJobsStreamEventsFromDefinition<TDef>[TType]> : unknown;
|
|
173
|
+
type IgniterJobsInferJobStreamEvent<TDef> = [
|
|
174
|
+
IgniterJobsStreamEventKeys<TDef>
|
|
175
|
+
] extends [never] ? IgniterJobsJobStreamEvent<string, unknown> : {
|
|
176
|
+
[K in IgniterJobsStreamEventKeys<TDef>]: IgniterJobsJobStreamEvent<K, IgniterJobsInferStreamReadData<TDef, K>>;
|
|
177
|
+
}[IgniterJobsStreamEventKeys<TDef>];
|
|
178
|
+
interface IgniterJobsExecutionStreamEmitter<TDef = unknown, TType extends string = IgniterJobsInferStreamType<TDef>> {
|
|
179
|
+
emit<TEventType extends TType>(type: TEventType, data: IgniterJobsInferStreamEmitData<TDef, TEventType>): Promise<string>;
|
|
180
|
+
}
|
|
181
|
+
interface IgniterJobsJobStreamAccessor<TDef = unknown> {
|
|
182
|
+
subscribe(handler: (event: IgniterJobsInferJobStreamEvent<TDef>) => void | Promise<void>): Promise<() => Promise<void>>;
|
|
183
|
+
read(params?: IgniterJobsJobStreamReadParams): Promise<IgniterJobsJobStreamReadResult<IgniterJobsInferJobStreamEvent<TDef>>>;
|
|
184
|
+
}
|
|
185
|
+
|
|
130
186
|
/**
|
|
131
187
|
* Rate limiter configuration applied to job dispatch or worker level.
|
|
132
188
|
*/
|
|
@@ -152,7 +208,7 @@ interface IgniterJobsInvokeOptions {
|
|
|
152
208
|
/**
|
|
153
209
|
* Runtime execution context passed to handlers.
|
|
154
210
|
*/
|
|
155
|
-
interface IgniterJobsExecutionContext<TContext, TInput extends IgniterJobsSchema | unknown = unknown> {
|
|
211
|
+
interface IgniterJobsExecutionContext<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> {
|
|
156
212
|
input: IgniterJobsInferSchemaInput<TInput>;
|
|
157
213
|
context: TContext;
|
|
158
214
|
job: {
|
|
@@ -167,45 +223,55 @@ interface IgniterJobsExecutionContext<TContext, TInput extends IgniterJobsSchema
|
|
|
167
223
|
*/
|
|
168
224
|
createdAt?: Date;
|
|
169
225
|
metadata?: Record<string, unknown>;
|
|
226
|
+
/**
|
|
227
|
+
* Reports job progress and triggers the public progress hook when supported by the adapter.
|
|
228
|
+
*/
|
|
229
|
+
updateProgress?: (progress: number, message?: string) => Promise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* Emits typed stream events for the current job execution.
|
|
232
|
+
*/
|
|
233
|
+
stream: IgniterJobsExecutionStreamEmitter<IgniterJobDefinition<TContext, TInput, unknown, TStreamEvents>>;
|
|
170
234
|
};
|
|
171
235
|
scope?: IgniterJobsScopeEntry;
|
|
172
236
|
}
|
|
173
237
|
/**
|
|
174
238
|
* Hook context shared by lifecycle handlers.
|
|
175
239
|
*/
|
|
176
|
-
interface IgniterJobsHookContext<TContext, TInput extends IgniterJobsSchema | unknown = unknown> extends IgniterJobsExecutionContext<TContext, TInput> {
|
|
240
|
+
interface IgniterJobsHookContext<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> extends IgniterJobsExecutionContext<TContext, TInput, TStreamEvents> {
|
|
177
241
|
startedAt?: Date;
|
|
178
242
|
duration?: number;
|
|
179
243
|
}
|
|
180
|
-
type IgniterJobsStartHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown> = (context: IgniterJobsHookContext<TContext, TInput>) => void | Promise<void>;
|
|
181
|
-
type IgniterJobsSuccessHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TResult = unknown> = (context: IgniterJobsHookContext<TContext, TInput> & {
|
|
244
|
+
type IgniterJobsStartHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> = (context: IgniterJobsHookContext<TContext, TInput, TStreamEvents>) => void | Promise<void>;
|
|
245
|
+
type IgniterJobsSuccessHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TResult = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> = (context: IgniterJobsHookContext<TContext, TInput, TStreamEvents> & {
|
|
182
246
|
result: TResult;
|
|
183
247
|
}) => void | Promise<void>;
|
|
184
|
-
type IgniterJobsFailureHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown> = (context: IgniterJobsHookContext<TContext, TInput> & {
|
|
248
|
+
type IgniterJobsFailureHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> = (context: IgniterJobsHookContext<TContext, TInput, TStreamEvents> & {
|
|
185
249
|
error: Error;
|
|
186
250
|
isFinalAttempt: boolean;
|
|
187
251
|
}) => void | Promise<void>;
|
|
188
|
-
type IgniterJobsProgressHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown> = (context: IgniterJobsHookContext<TContext, TInput> & {
|
|
252
|
+
type IgniterJobsProgressHook<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> = (context: IgniterJobsHookContext<TContext, TInput, TStreamEvents> & {
|
|
189
253
|
progress: number;
|
|
190
254
|
message?: string;
|
|
191
255
|
}) => void | Promise<void>;
|
|
192
256
|
/**
|
|
193
257
|
* Definition of a job registered on a queue.
|
|
194
258
|
*/
|
|
195
|
-
interface IgniterJobDefinition<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TResult = unknown> extends IgniterJobsInvokeOptions {
|
|
259
|
+
interface IgniterJobDefinition<TContext, TInput extends IgniterJobsSchema | unknown = unknown, TResult = unknown, TStreamEvents extends IgniterJobsJobStreamSchemaMap | undefined = undefined> extends IgniterJobsInvokeOptions {
|
|
196
260
|
/** Optional input schema for validation. */
|
|
197
261
|
input?: TInput;
|
|
198
262
|
/** Optional output schema (validation handled externally). */
|
|
199
263
|
output?: IgniterJobsSchema;
|
|
200
264
|
/** Optional queue override (creates child queue in adapters). */
|
|
201
265
|
queue?: string;
|
|
266
|
+
/** Optional stream configuration for live and persisted per-job events. */
|
|
267
|
+
stream?: IgniterJobsJobStreamDefinition<TStreamEvents>;
|
|
202
268
|
/** Job handler implementation. */
|
|
203
|
-
handler: (context: IgniterJobsExecutionContext<TContext, TInput>) => Promise<TResult> | TResult;
|
|
269
|
+
handler: (context: IgniterJobsExecutionContext<TContext, TInput, TStreamEvents>) => Promise<TResult> | TResult;
|
|
204
270
|
/** Lifecycle hooks */
|
|
205
|
-
onStart?: IgniterJobsStartHook<TContext, TInput>;
|
|
206
|
-
onProgress?: IgniterJobsProgressHook<TContext, TInput>;
|
|
207
|
-
onSuccess?: IgniterJobsSuccessHook<TContext, TInput, TResult>;
|
|
208
|
-
onFailure?: IgniterJobsFailureHook<TContext, TInput>;
|
|
271
|
+
onStart?: IgniterJobsStartHook<TContext, TInput, TStreamEvents>;
|
|
272
|
+
onProgress?: IgniterJobsProgressHook<TContext, TInput, TStreamEvents>;
|
|
273
|
+
onSuccess?: IgniterJobsSuccessHook<TContext, TInput, TResult, TStreamEvents>;
|
|
274
|
+
onFailure?: IgniterJobsFailureHook<TContext, TInput, TStreamEvents>;
|
|
209
275
|
}
|
|
210
276
|
/**
|
|
211
277
|
* Definition for cron-style recurring tasks.
|
|
@@ -235,12 +301,12 @@ interface IgniterCronDefinition<TContext, TResult = unknown> {
|
|
|
235
301
|
startDate?: Date;
|
|
236
302
|
/** Optional end date for the schedule (adapter-dependent). */
|
|
237
303
|
endDate?: Date;
|
|
238
|
-
handler: (context: Omit<IgniterJobsExecutionContext<TContext, unknown>,
|
|
304
|
+
handler: (context: Omit<IgniterJobsExecutionContext<TContext, unknown>, "input">) => Promise<TResult> | TResult;
|
|
239
305
|
}
|
|
240
306
|
/**
|
|
241
307
|
* Supported job states for management queries.
|
|
242
308
|
*/
|
|
243
|
-
type IgniterJobStatus =
|
|
309
|
+
type IgniterJobStatus = "waiting" | "active" | "completed" | "failed" | "delayed" | "paused";
|
|
244
310
|
/**
|
|
245
311
|
* Result shape for job inspection calls.
|
|
246
312
|
*/
|
|
@@ -299,11 +365,11 @@ type IgniterJobsScheduleParams<TInput = unknown> = IgniterJobsDispatchParams<TIn
|
|
|
299
365
|
/**
|
|
300
366
|
* Queue configuration produced by `IgniterQueueBuilder`.
|
|
301
367
|
*/
|
|
302
|
-
interface IgniterJobsQueue<TContext, TJobs extends Record<string, IgniterJobDefinition<TContext, any, any>>, TCron extends Record<string, IgniterCronDefinition<TContext, any>>> {
|
|
368
|
+
interface IgniterJobsQueue<TContext, TJobs extends Record<string, IgniterJobDefinition<TContext, any, any, any>>, TCron extends Record<string, IgniterCronDefinition<TContext, any>>> {
|
|
303
369
|
name: string;
|
|
304
370
|
jobs: TJobs;
|
|
305
371
|
crons: TCron;
|
|
306
|
-
defaultJobOptions?: Partial<IgniterJobDefinition<TContext, any, any>>;
|
|
372
|
+
defaultJobOptions?: Partial<IgniterJobDefinition<TContext, any, any, any>>;
|
|
307
373
|
}
|
|
308
374
|
/**
|
|
309
375
|
* Information about a queue used by management APIs.
|
|
@@ -475,7 +541,26 @@ type IgniterJobsAdapterScheduleParams = {
|
|
|
475
541
|
interface IgniterJobsJobLog {
|
|
476
542
|
timestamp: Date;
|
|
477
543
|
message: string;
|
|
478
|
-
level:
|
|
544
|
+
level: "info" | "warn" | "error";
|
|
545
|
+
}
|
|
546
|
+
interface IgniterJobsAdapterJobStreamWriteParams {
|
|
547
|
+
queue: string;
|
|
548
|
+
jobName: string;
|
|
549
|
+
jobId: string;
|
|
550
|
+
scope?: IgniterJobsScopeEntry;
|
|
551
|
+
persistence?: IgniterJobsJobStreamPersistenceConfig;
|
|
552
|
+
event: Omit<IgniterJobsJobStreamEvent<string, unknown>, "id">;
|
|
553
|
+
}
|
|
554
|
+
interface IgniterJobsAdapterJobStreamReadParams {
|
|
555
|
+
queue: string;
|
|
556
|
+
jobId: string;
|
|
557
|
+
after?: string;
|
|
558
|
+
limit?: number;
|
|
559
|
+
}
|
|
560
|
+
interface IgniterJobsAdapterJobStreamSubscribeParams {
|
|
561
|
+
queue: string;
|
|
562
|
+
jobId: string;
|
|
563
|
+
handler: (event: IgniterJobsJobStreamEvent<string, unknown>) => void | Promise<void>;
|
|
479
564
|
}
|
|
480
565
|
/**
|
|
481
566
|
* Adapter contract for jobs backends.
|
|
@@ -506,8 +591,6 @@ interface IgniterJobsAdapter {
|
|
|
506
591
|
force?: boolean;
|
|
507
592
|
}): Promise<void>;
|
|
508
593
|
retryAllInQueue(queue: string): Promise<number>;
|
|
509
|
-
pauseJobType(queue: string, jobName: string): Promise<void>;
|
|
510
|
-
resumeJobType(queue: string, jobName: string): Promise<void>;
|
|
511
594
|
searchJobs(filter: Record<string, unknown>): Promise<IgniterJobSearchResult[]>;
|
|
512
595
|
searchQueues(filter: Record<string, unknown>): Promise<IgniterJobsQueueInfo[]>;
|
|
513
596
|
searchWorkers(filter: Record<string, unknown>): Promise<IgniterJobsWorkerHandle[]>;
|
|
@@ -515,6 +598,9 @@ interface IgniterJobsAdapter {
|
|
|
515
598
|
getWorkers(): Map<string, IgniterJobsWorkerHandle>;
|
|
516
599
|
publishEvent(channel: string, payload: unknown): Promise<void>;
|
|
517
600
|
subscribeEvent(channel: string, handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
|
|
601
|
+
writeJobStreamEvent(params: IgniterJobsAdapterJobStreamWriteParams): Promise<string>;
|
|
602
|
+
readJobStream(params: IgniterJobsAdapterJobStreamReadParams): Promise<IgniterJobsJobStreamReadResult<IgniterJobsJobStreamEvent<string, unknown>>>;
|
|
603
|
+
subscribeJobStream(params: IgniterJobsAdapterJobStreamSubscribeParams): Promise<() => Promise<void>>;
|
|
518
604
|
registerJob(queueName: string, jobName: string, definition: IgniterJobDefinition<any, any, any>): void;
|
|
519
605
|
registerCron(queueName: string, cronName: string, definition: IgniterCronDefinition<any, any>): void;
|
|
520
606
|
shutdown(): Promise<void>;
|
|
@@ -525,5 +611,24 @@ interface IgniterJobsAdapter {
|
|
|
525
611
|
interface IgniterJobsBullMQAdapterOptions {
|
|
526
612
|
redis: Redis;
|
|
527
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* Configuration for the Bun SQLite adapter.
|
|
616
|
+
*/
|
|
617
|
+
interface IgniterJobsBunSQLiteAdapterOptions {
|
|
618
|
+
/** SQLite file path used by the embedded runtime. */
|
|
619
|
+
path: string;
|
|
620
|
+
/** Forces immediate persistence for dispatched jobs. @default false */
|
|
621
|
+
durable?: boolean;
|
|
622
|
+
/** Worker heartbeat interval in milliseconds. @default 10000 */
|
|
623
|
+
heartbeatInterval?: number;
|
|
624
|
+
/** Long-poll timeout while the queue is empty. @default 0 */
|
|
625
|
+
pollTimeout?: number;
|
|
626
|
+
/** Number of jobs pulled per worker batch. @default 10 */
|
|
627
|
+
batchSize?: number;
|
|
628
|
+
/** Lock duration for active jobs in milliseconds. @default 30000 */
|
|
629
|
+
lockDuration?: number;
|
|
630
|
+
/** Maximum stalled detections before a job fails. @default 1 */
|
|
631
|
+
maxStalledCount?: number;
|
|
632
|
+
}
|
|
528
633
|
|
|
529
|
-
export type {
|
|
634
|
+
export type { IgniterJobsSuccessHook as $, IgniterJobsAdapterJobStreamWriteParams as A, IgniterJobsAdapterScheduleParams as B, IgniterJobsBullMQAdapterOptions as C, IgniterJobsBunSQLiteAdapterOptions as D, IgniterJobsEvent as E, IgniterJobsExecutionContext as F, IgniterJobsExecutionStreamEmitter as G, IgniterJobsFailureHook as H, IgniterJobsQueue as I, IgniterJobsHookContext as J, IgniterJobsInferJobStreamEvent as K, IgniterJobsInferSchemaOutput as L, IgniterJobsInferStreamEmitData as M, IgniterJobsInferStreamReadData as N, IgniterJobsInferStreamType as O, IgniterJobsInvokeOptions as P, IgniterJobsJobLog as Q, IgniterJobsJobStreamDefinition as R, IgniterJobsJobStreamEvent as S, IgniterJobsJobStreamPersistenceConfig as T, IgniterJobsJobStreamReadParams as U, IgniterJobsJobStreamReadResult as V, IgniterJobsProgressHook as W, IgniterJobsQueueManager as X, IgniterJobsScheduleOptions as Y, IgniterJobsStartHook as Z, IgniterJobsStreamEventsFromDefinition as _, IgniterJobsAdapter as a, IgniterJobsWorkerMetrics as a0, IgniterJobsScopeDefinition as b, IgniterJobDefinition as c, IgniterJobsWorkerBuilderConfig as d, IgniterJobsTelemetry as e, IgniterJobsEventHandler as f, IgniterJobSearchResult as g, IgniterJobsQueueInfo as h, IgniterJobsWorkerHandle as i, IgniterJobsLimiter as j, IgniterJobsWorkerHandlers as k, IgniterJobsQueueCleanOptions as l, IgniterJobStatus as m, IgniterJobsDispatchParams as n, IgniterJobsInferSchemaInput as o, IgniterJobsScheduleParams as p, IgniterJobsJobStreamAccessor as q, IgniterCronDefinition as r, IgniterJobsScopeEntry as s, IgniterJobsSchema as t, IgniterJobsJobStreamSchemaMap as u, IgniterJobsScopeOptions as v, IgniterJobCounts as w, IgniterJobsAdapterDispatchParams as x, IgniterJobsAdapterJobStreamReadParams as y, IgniterJobsAdapterJobStreamSubscribeParams as z };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { a as IgniterJobsAdapter, X as IgniterJobsQueueManager, D as IgniterJobsBunSQLiteAdapterOptions, c as IgniterJobDefinition, r as IgniterCronDefinition, x as IgniterJobsAdapterDispatchParams, B as IgniterJobsAdapterScheduleParams, g as IgniterJobSearchResult, m as IgniterJobStatus, Q as IgniterJobsJobLog, h as IgniterJobsQueueInfo, w as IgniterJobCounts, l as IgniterJobsQueueCleanOptions, i as IgniterJobsWorkerHandle, d as IgniterJobsWorkerBuilderConfig, f as IgniterJobsEventHandler, A as IgniterJobsAdapterJobStreamWriteParams, y as IgniterJobsAdapterJobStreamReadParams, V as IgniterJobsJobStreamReadResult, S as IgniterJobsJobStreamEvent, z as IgniterJobsAdapterJobStreamSubscribeParams } from '../adapter-DDyMVche.mjs';
|
|
2
|
+
import 'ioredis';
|
|
3
|
+
import '@igniter-js/common';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @fileoverview Bun SQLite adapter for @igniter-js/jobs
|
|
7
|
+
* @module @igniter-js/jobs/adapters/bun-sqlite
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Bun-native SQLite adapter for local, embedded, and desktop workloads.
|
|
12
|
+
*/
|
|
13
|
+
declare class IgniterJobsBunSQLiteAdapter implements IgniterJobsAdapter {
|
|
14
|
+
readonly client: {
|
|
15
|
+
type: "bun-sqlite";
|
|
16
|
+
path: string;
|
|
17
|
+
};
|
|
18
|
+
readonly queues: IgniterJobsQueueManager;
|
|
19
|
+
private readonly options;
|
|
20
|
+
private bunqueueModulePromise;
|
|
21
|
+
private readonly queueRuntimes;
|
|
22
|
+
private readonly workers;
|
|
23
|
+
private readonly subscribers;
|
|
24
|
+
private readonly streamSubscribers;
|
|
25
|
+
private readonly registeredJobs;
|
|
26
|
+
private streamDatabasePromise;
|
|
27
|
+
private readonly registeredCrons;
|
|
28
|
+
private constructor();
|
|
29
|
+
static create(options: IgniterJobsBunSQLiteAdapterOptions): IgniterJobsAdapter;
|
|
30
|
+
registerJob(queueName: string, jobName: string, definition: IgniterJobDefinition<any, any, any>): void;
|
|
31
|
+
registerCron(queueName: string, cronName: string, definition: IgniterCronDefinition<any, any>): void;
|
|
32
|
+
dispatch(params: IgniterJobsAdapterDispatchParams): Promise<string>;
|
|
33
|
+
schedule(params: IgniterJobsAdapterScheduleParams): Promise<string>;
|
|
34
|
+
getJob(jobId: string, queue?: string): Promise<IgniterJobSearchResult | null>;
|
|
35
|
+
getJobState(jobId: string, queue?: string): Promise<IgniterJobStatus | null>;
|
|
36
|
+
getJobLogs(jobId: string, queue?: string): Promise<IgniterJobsJobLog[]>;
|
|
37
|
+
getJobProgress(jobId: string, queue?: string): Promise<number>;
|
|
38
|
+
retryJob(jobId: string, queue?: string): Promise<void>;
|
|
39
|
+
removeJob(jobId: string, queue?: string): Promise<void>;
|
|
40
|
+
promoteJob(jobId: string, queue?: string): Promise<void>;
|
|
41
|
+
moveJobToFailed(jobId: string, reason: string, queue?: string): Promise<void>;
|
|
42
|
+
retryManyJobs(jobIds: string[], queue?: string): Promise<void>;
|
|
43
|
+
removeManyJobs(jobIds: string[], queue?: string): Promise<void>;
|
|
44
|
+
getQueueInfo(queue: string): Promise<IgniterJobsQueueInfo | null>;
|
|
45
|
+
getQueueJobCounts(queue: string): Promise<IgniterJobCounts>;
|
|
46
|
+
listQueues(): Promise<IgniterJobsQueueInfo[]>;
|
|
47
|
+
pauseQueue(queue: string): Promise<void>;
|
|
48
|
+
resumeQueue(queue: string): Promise<void>;
|
|
49
|
+
drainQueue(queue: string): Promise<number>;
|
|
50
|
+
cleanQueue(queue: string, options: IgniterJobsQueueCleanOptions): Promise<number>;
|
|
51
|
+
obliterateQueue(queue: string, _options?: {
|
|
52
|
+
force?: boolean;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
retryAllInQueue(queue: string): Promise<number>;
|
|
55
|
+
searchJobs(filter: Record<string, unknown>): Promise<IgniterJobSearchResult[]>;
|
|
56
|
+
searchQueues(filter: Record<string, unknown>): Promise<IgniterJobsQueueInfo[]>;
|
|
57
|
+
searchWorkers(filter: Record<string, unknown>): Promise<IgniterJobsWorkerHandle[]>;
|
|
58
|
+
createWorker(config: IgniterJobsWorkerBuilderConfig): Promise<IgniterJobsWorkerHandle>;
|
|
59
|
+
getWorkers(): Map<string, IgniterJobsWorkerHandle>;
|
|
60
|
+
publishEvent(channel: string, payload: unknown): Promise<void>;
|
|
61
|
+
subscribeEvent(channel: string, handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
|
|
62
|
+
writeJobStreamEvent(params: IgniterJobsAdapterJobStreamWriteParams): Promise<string>;
|
|
63
|
+
readJobStream(params: IgniterJobsAdapterJobStreamReadParams): Promise<IgniterJobsJobStreamReadResult<IgniterJobsJobStreamEvent<string, unknown>>>;
|
|
64
|
+
subscribeJobStream(params: IgniterJobsAdapterJobStreamSubscribeParams): Promise<() => Promise<void>>;
|
|
65
|
+
shutdown(): Promise<void>;
|
|
66
|
+
private loadBunqueue;
|
|
67
|
+
private getStreamDatabase;
|
|
68
|
+
private getQueue;
|
|
69
|
+
private getAllQueueNames;
|
|
70
|
+
private markQueueCronsDirty;
|
|
71
|
+
private syncCronSchedulers;
|
|
72
|
+
private createEnvelope;
|
|
73
|
+
private toJobOptions;
|
|
74
|
+
private processJob;
|
|
75
|
+
private processRegisteredDefinition;
|
|
76
|
+
private processRegisteredCron;
|
|
77
|
+
private createExecutionContext;
|
|
78
|
+
private attachWorkerEvents;
|
|
79
|
+
private toWorkerHandle;
|
|
80
|
+
private buildWorkerMetrics;
|
|
81
|
+
private closeWorkerState;
|
|
82
|
+
private requireJob;
|
|
83
|
+
private findQueueByJobId;
|
|
84
|
+
private getStreamKey;
|
|
85
|
+
private mapStreamRow;
|
|
86
|
+
private mapJob;
|
|
87
|
+
private mapJobSync;
|
|
88
|
+
private normalizeEnvelope;
|
|
89
|
+
private toPublicStatus;
|
|
90
|
+
private toBunqueueStatus;
|
|
91
|
+
private toBunqueueStates;
|
|
92
|
+
private distributeConcurrency;
|
|
93
|
+
private shouldExecuteScheduledJob;
|
|
94
|
+
private parseLogEntry;
|
|
95
|
+
private writeLog;
|
|
96
|
+
private writeQueueLog;
|
|
97
|
+
private invokeHook;
|
|
98
|
+
private invokeHandler;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { IgniterJobsBunSQLiteAdapter, IgniterJobsBunSQLiteAdapterOptions };
|