@igniter-js/jobs 0.1.1 → 0.1.12
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 +1118 -96
- package/CHANGELOG.md +8 -0
- package/README.md +2146 -93
- package/dist/{adapter-PiDCQWQd.d.mts → adapter-CXZxomI9.d.mts} +2 -2
- package/dist/{adapter-PiDCQWQd.d.ts → adapter-CXZxomI9.d.ts} +2 -2
- package/dist/adapters/bullmq.adapter.d.mts +2 -2
- package/dist/adapters/bullmq.adapter.d.ts +2 -2
- package/dist/adapters/bullmq.adapter.js +2 -2
- package/dist/adapters/bullmq.adapter.js.map +1 -1
- package/dist/adapters/bullmq.adapter.mjs +1 -1
- package/dist/adapters/bullmq.adapter.mjs.map +1 -1
- package/dist/adapters/index.d.mts +140 -2
- package/dist/adapters/index.d.ts +140 -2
- package/dist/adapters/index.js +864 -31
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +863 -31
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/adapters/memory.adapter.d.mts +2 -2
- package/dist/adapters/memory.adapter.d.ts +2 -2
- package/dist/adapters/memory.adapter.js +122 -30
- package/dist/adapters/memory.adapter.js.map +1 -1
- package/dist/adapters/memory.adapter.mjs +121 -29
- package/dist/adapters/memory.adapter.mjs.map +1 -1
- package/dist/index.d.mts +452 -342
- package/dist/index.d.ts +452 -342
- package/dist/index.js +1923 -1002
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1921 -1001
- package/dist/index.mjs.map +1 -1
- package/dist/shim.d.mts +36 -0
- package/dist/shim.d.ts +36 -0
- package/dist/shim.js +75 -0
- package/dist/shim.js.map +1 -0
- package/dist/shim.mjs +67 -0
- package/dist/shim.mjs.map +1 -0
- package/dist/telemetry/index.d.mts +281 -0
- package/dist/telemetry/index.d.ts +281 -0
- package/dist/telemetry/index.js +97 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/index.mjs +95 -0
- package/dist/telemetry/index.mjs.map +1 -0
- package/package.json +44 -11
|
@@ -1,5 +1,143 @@
|
|
|
1
1
|
export { IgniterJobsBullMQAdapter } from './bullmq.adapter.mjs';
|
|
2
2
|
export { IgniterJobsMemoryAdapter } from './memory.adapter.mjs';
|
|
3
|
-
import '../adapter-
|
|
3
|
+
import { I as IgniterJobsAdapter, a as IgniterJobsQueueManager, c as IgniterJobDefinition, d as IgniterCronDefinition, e as IgniterJobsAdapterDispatchParams, f as IgniterJobsAdapterScheduleParams, g as IgniterJobSearchResult, h as IgniterJobStatus, i as IgniterJobsJobLog, j as IgniterJobsQueueInfo, o as IgniterJobCounts, k as IgniterJobsQueueCleanOptions, l as IgniterJobsWorkerHandle, m as IgniterJobsWorkerBuilderConfig, n as IgniterJobsEventHandler } from '../adapter-CXZxomI9.mjs';
|
|
4
4
|
import 'ioredis';
|
|
5
|
-
import '@igniter-js/
|
|
5
|
+
import '@igniter-js/common';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @fileoverview SQLite adapter for @igniter-js/jobs (local/desktop/CLI environments)
|
|
9
|
+
* @module @igniter-js/jobs/adapters/sqlite
|
|
10
|
+
*
|
|
11
|
+
* This adapter provides persistent job queue storage using SQLite, ideal for:
|
|
12
|
+
* - Desktop applications (Tauri, Electron)
|
|
13
|
+
* - CLI tools
|
|
14
|
+
* - MCP Servers
|
|
15
|
+
* - Local development
|
|
16
|
+
* - Edge/embedded environments
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Configuration options for the SQLite adapter.
|
|
21
|
+
*/
|
|
22
|
+
interface IgniterJobsSQLiteAdapterOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Path to the SQLite database file.
|
|
25
|
+
* Use `:memory:` for an in-memory database (useful for testing).
|
|
26
|
+
* @example './data/jobs.sqlite'
|
|
27
|
+
* @example ':memory:'
|
|
28
|
+
*/
|
|
29
|
+
path: string;
|
|
30
|
+
/**
|
|
31
|
+
* Interval in milliseconds for the worker polling loop.
|
|
32
|
+
* Lower values mean faster job pickup but higher CPU usage.
|
|
33
|
+
* @default 500
|
|
34
|
+
*/
|
|
35
|
+
pollingInterval?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to enable WAL mode for better concurrent read/write performance.
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
enableWAL?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* SQLite-based adapter for local/desktop/CLI job queue persistence.
|
|
44
|
+
*
|
|
45
|
+
* Features:
|
|
46
|
+
* - Full persistence across process restarts
|
|
47
|
+
* - Zero external dependencies (SQLite is embedded)
|
|
48
|
+
* - WAL mode for concurrent access
|
|
49
|
+
* - Automatic schema migrations
|
|
50
|
+
* - Compatible with Tauri, Electron, Node.js CLIs
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const adapter = IgniterJobsSQLiteAdapter.create({
|
|
55
|
+
* path: './data/jobs.sqlite'
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* const jobs = IgniterJobs.create()
|
|
59
|
+
* .withAdapter(adapter)
|
|
60
|
+
* .build();
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
declare class IgniterJobsSQLiteAdapter implements IgniterJobsAdapter {
|
|
64
|
+
readonly client: {
|
|
65
|
+
type: "sqlite";
|
|
66
|
+
path: string;
|
|
67
|
+
};
|
|
68
|
+
private db;
|
|
69
|
+
private readonly options;
|
|
70
|
+
private readonly registeredJobs;
|
|
71
|
+
private readonly registeredCrons;
|
|
72
|
+
private readonly workers;
|
|
73
|
+
private readonly subscribers;
|
|
74
|
+
private readonly pausedQueues;
|
|
75
|
+
readonly queues: IgniterJobsQueueManager;
|
|
76
|
+
private constructor();
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new SQLite adapter instance.
|
|
79
|
+
*
|
|
80
|
+
* @param options - Configuration options
|
|
81
|
+
* @returns A new adapter instance
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* // File-based database (persistent)
|
|
86
|
+
* const adapter = IgniterJobsSQLiteAdapter.create({
|
|
87
|
+
* path: './data/jobs.sqlite'
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* // In-memory database (for testing)
|
|
91
|
+
* const testAdapter = IgniterJobsSQLiteAdapter.create({
|
|
92
|
+
* path: ':memory:'
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
static create(options: IgniterJobsSQLiteAdapterOptions): IgniterJobsAdapter;
|
|
97
|
+
private initializeSchema;
|
|
98
|
+
registerJob(queueName: string, jobName: string, definition: IgniterJobDefinition<any, any, any>): void;
|
|
99
|
+
registerCron(queueName: string, cronName: string, definition: IgniterCronDefinition<any, any>): void;
|
|
100
|
+
dispatch(params: IgniterJobsAdapterDispatchParams): Promise<string>;
|
|
101
|
+
private promoteDelayedJob;
|
|
102
|
+
schedule(params: IgniterJobsAdapterScheduleParams): Promise<string>;
|
|
103
|
+
getJob(jobId: string, queue?: string): Promise<IgniterJobSearchResult | null>;
|
|
104
|
+
getJobState(jobId: string, queue?: string): Promise<IgniterJobStatus | null>;
|
|
105
|
+
getJobLogs(jobId: string, queue?: string): Promise<IgniterJobsJobLog[]>;
|
|
106
|
+
getJobProgress(jobId: string, queue?: string): Promise<number>;
|
|
107
|
+
retryJob(jobId: string, queue?: string): Promise<void>;
|
|
108
|
+
removeJob(jobId: string, queue?: string): Promise<void>;
|
|
109
|
+
promoteJob(jobId: string, queue?: string): Promise<void>;
|
|
110
|
+
moveJobToFailed(jobId: string, reason: string, queue?: string): Promise<void>;
|
|
111
|
+
retryManyJobs(jobIds: string[], queue?: string): Promise<void>;
|
|
112
|
+
removeManyJobs(jobIds: string[], queue?: string): Promise<void>;
|
|
113
|
+
getQueueInfo(queue: string): Promise<IgniterJobsQueueInfo | null>;
|
|
114
|
+
getQueueJobCounts(queue: string): Promise<IgniterJobCounts>;
|
|
115
|
+
listQueues(): Promise<IgniterJobsQueueInfo[]>;
|
|
116
|
+
pauseQueue(queue: string): Promise<void>;
|
|
117
|
+
resumeQueue(queue: string): Promise<void>;
|
|
118
|
+
drainQueue(queue: string): Promise<number>;
|
|
119
|
+
cleanQueue(queue: string, options: IgniterJobsQueueCleanOptions): Promise<number>;
|
|
120
|
+
obliterateQueue(queue: string, _options?: {
|
|
121
|
+
force?: boolean;
|
|
122
|
+
}): Promise<void>;
|
|
123
|
+
retryAllInQueue(queue: string): Promise<number>;
|
|
124
|
+
pauseJobType(queue: string, jobName: string): Promise<void>;
|
|
125
|
+
resumeJobType(queue: string, jobName: string): Promise<void>;
|
|
126
|
+
searchJobs(filter: any): Promise<IgniterJobSearchResult[]>;
|
|
127
|
+
searchQueues(filter: any): Promise<IgniterJobsQueueInfo[]>;
|
|
128
|
+
searchWorkers(filter: any): Promise<IgniterJobsWorkerHandle[]>;
|
|
129
|
+
createWorker(config: IgniterJobsWorkerBuilderConfig): Promise<IgniterJobsWorkerHandle>;
|
|
130
|
+
getWorkers(): Map<string, IgniterJobsWorkerHandle>;
|
|
131
|
+
publishEvent(channel: string, payload: unknown): Promise<void>;
|
|
132
|
+
subscribeEvent(channel: string, handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
|
|
133
|
+
shutdown(): Promise<void>;
|
|
134
|
+
private rowToSearchResult;
|
|
135
|
+
private toWorkerHandle;
|
|
136
|
+
private toWorkerMetrics;
|
|
137
|
+
private startPollingLoop;
|
|
138
|
+
private processNextJobs;
|
|
139
|
+
private processJob;
|
|
140
|
+
private addJobLog;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { IgniterJobsSQLiteAdapter, type IgniterJobsSQLiteAdapterOptions };
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,5 +1,143 @@
|
|
|
1
1
|
export { IgniterJobsBullMQAdapter } from './bullmq.adapter.js';
|
|
2
2
|
export { IgniterJobsMemoryAdapter } from './memory.adapter.js';
|
|
3
|
-
import '../adapter-
|
|
3
|
+
import { I as IgniterJobsAdapter, a as IgniterJobsQueueManager, c as IgniterJobDefinition, d as IgniterCronDefinition, e as IgniterJobsAdapterDispatchParams, f as IgniterJobsAdapterScheduleParams, g as IgniterJobSearchResult, h as IgniterJobStatus, i as IgniterJobsJobLog, j as IgniterJobsQueueInfo, o as IgniterJobCounts, k as IgniterJobsQueueCleanOptions, l as IgniterJobsWorkerHandle, m as IgniterJobsWorkerBuilderConfig, n as IgniterJobsEventHandler } from '../adapter-CXZxomI9.js';
|
|
4
4
|
import 'ioredis';
|
|
5
|
-
import '@igniter-js/
|
|
5
|
+
import '@igniter-js/common';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @fileoverview SQLite adapter for @igniter-js/jobs (local/desktop/CLI environments)
|
|
9
|
+
* @module @igniter-js/jobs/adapters/sqlite
|
|
10
|
+
*
|
|
11
|
+
* This adapter provides persistent job queue storage using SQLite, ideal for:
|
|
12
|
+
* - Desktop applications (Tauri, Electron)
|
|
13
|
+
* - CLI tools
|
|
14
|
+
* - MCP Servers
|
|
15
|
+
* - Local development
|
|
16
|
+
* - Edge/embedded environments
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Configuration options for the SQLite adapter.
|
|
21
|
+
*/
|
|
22
|
+
interface IgniterJobsSQLiteAdapterOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Path to the SQLite database file.
|
|
25
|
+
* Use `:memory:` for an in-memory database (useful for testing).
|
|
26
|
+
* @example './data/jobs.sqlite'
|
|
27
|
+
* @example ':memory:'
|
|
28
|
+
*/
|
|
29
|
+
path: string;
|
|
30
|
+
/**
|
|
31
|
+
* Interval in milliseconds for the worker polling loop.
|
|
32
|
+
* Lower values mean faster job pickup but higher CPU usage.
|
|
33
|
+
* @default 500
|
|
34
|
+
*/
|
|
35
|
+
pollingInterval?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to enable WAL mode for better concurrent read/write performance.
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
enableWAL?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* SQLite-based adapter for local/desktop/CLI job queue persistence.
|
|
44
|
+
*
|
|
45
|
+
* Features:
|
|
46
|
+
* - Full persistence across process restarts
|
|
47
|
+
* - Zero external dependencies (SQLite is embedded)
|
|
48
|
+
* - WAL mode for concurrent access
|
|
49
|
+
* - Automatic schema migrations
|
|
50
|
+
* - Compatible with Tauri, Electron, Node.js CLIs
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const adapter = IgniterJobsSQLiteAdapter.create({
|
|
55
|
+
* path: './data/jobs.sqlite'
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* const jobs = IgniterJobs.create()
|
|
59
|
+
* .withAdapter(adapter)
|
|
60
|
+
* .build();
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
declare class IgniterJobsSQLiteAdapter implements IgniterJobsAdapter {
|
|
64
|
+
readonly client: {
|
|
65
|
+
type: "sqlite";
|
|
66
|
+
path: string;
|
|
67
|
+
};
|
|
68
|
+
private db;
|
|
69
|
+
private readonly options;
|
|
70
|
+
private readonly registeredJobs;
|
|
71
|
+
private readonly registeredCrons;
|
|
72
|
+
private readonly workers;
|
|
73
|
+
private readonly subscribers;
|
|
74
|
+
private readonly pausedQueues;
|
|
75
|
+
readonly queues: IgniterJobsQueueManager;
|
|
76
|
+
private constructor();
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new SQLite adapter instance.
|
|
79
|
+
*
|
|
80
|
+
* @param options - Configuration options
|
|
81
|
+
* @returns A new adapter instance
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* // File-based database (persistent)
|
|
86
|
+
* const adapter = IgniterJobsSQLiteAdapter.create({
|
|
87
|
+
* path: './data/jobs.sqlite'
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* // In-memory database (for testing)
|
|
91
|
+
* const testAdapter = IgniterJobsSQLiteAdapter.create({
|
|
92
|
+
* path: ':memory:'
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
static create(options: IgniterJobsSQLiteAdapterOptions): IgniterJobsAdapter;
|
|
97
|
+
private initializeSchema;
|
|
98
|
+
registerJob(queueName: string, jobName: string, definition: IgniterJobDefinition<any, any, any>): void;
|
|
99
|
+
registerCron(queueName: string, cronName: string, definition: IgniterCronDefinition<any, any>): void;
|
|
100
|
+
dispatch(params: IgniterJobsAdapterDispatchParams): Promise<string>;
|
|
101
|
+
private promoteDelayedJob;
|
|
102
|
+
schedule(params: IgniterJobsAdapterScheduleParams): Promise<string>;
|
|
103
|
+
getJob(jobId: string, queue?: string): Promise<IgniterJobSearchResult | null>;
|
|
104
|
+
getJobState(jobId: string, queue?: string): Promise<IgniterJobStatus | null>;
|
|
105
|
+
getJobLogs(jobId: string, queue?: string): Promise<IgniterJobsJobLog[]>;
|
|
106
|
+
getJobProgress(jobId: string, queue?: string): Promise<number>;
|
|
107
|
+
retryJob(jobId: string, queue?: string): Promise<void>;
|
|
108
|
+
removeJob(jobId: string, queue?: string): Promise<void>;
|
|
109
|
+
promoteJob(jobId: string, queue?: string): Promise<void>;
|
|
110
|
+
moveJobToFailed(jobId: string, reason: string, queue?: string): Promise<void>;
|
|
111
|
+
retryManyJobs(jobIds: string[], queue?: string): Promise<void>;
|
|
112
|
+
removeManyJobs(jobIds: string[], queue?: string): Promise<void>;
|
|
113
|
+
getQueueInfo(queue: string): Promise<IgniterJobsQueueInfo | null>;
|
|
114
|
+
getQueueJobCounts(queue: string): Promise<IgniterJobCounts>;
|
|
115
|
+
listQueues(): Promise<IgniterJobsQueueInfo[]>;
|
|
116
|
+
pauseQueue(queue: string): Promise<void>;
|
|
117
|
+
resumeQueue(queue: string): Promise<void>;
|
|
118
|
+
drainQueue(queue: string): Promise<number>;
|
|
119
|
+
cleanQueue(queue: string, options: IgniterJobsQueueCleanOptions): Promise<number>;
|
|
120
|
+
obliterateQueue(queue: string, _options?: {
|
|
121
|
+
force?: boolean;
|
|
122
|
+
}): Promise<void>;
|
|
123
|
+
retryAllInQueue(queue: string): Promise<number>;
|
|
124
|
+
pauseJobType(queue: string, jobName: string): Promise<void>;
|
|
125
|
+
resumeJobType(queue: string, jobName: string): Promise<void>;
|
|
126
|
+
searchJobs(filter: any): Promise<IgniterJobSearchResult[]>;
|
|
127
|
+
searchQueues(filter: any): Promise<IgniterJobsQueueInfo[]>;
|
|
128
|
+
searchWorkers(filter: any): Promise<IgniterJobsWorkerHandle[]>;
|
|
129
|
+
createWorker(config: IgniterJobsWorkerBuilderConfig): Promise<IgniterJobsWorkerHandle>;
|
|
130
|
+
getWorkers(): Map<string, IgniterJobsWorkerHandle>;
|
|
131
|
+
publishEvent(channel: string, payload: unknown): Promise<void>;
|
|
132
|
+
subscribeEvent(channel: string, handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
|
|
133
|
+
shutdown(): Promise<void>;
|
|
134
|
+
private rowToSearchResult;
|
|
135
|
+
private toWorkerHandle;
|
|
136
|
+
private toWorkerMetrics;
|
|
137
|
+
private startPollingLoop;
|
|
138
|
+
private processNextJobs;
|
|
139
|
+
private processJob;
|
|
140
|
+
private addJobLog;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { IgniterJobsSQLiteAdapter, type IgniterJobsSQLiteAdapterOptions };
|