bunqueue 1.0.7 → 1.0.8
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/README.md +65 -0
- package/dist/cli/client.d.ts +14 -0
- package/dist/cli/client.d.ts.map +1 -0
- package/dist/cli/client.js +170 -0
- package/dist/cli/client.js.map +1 -0
- package/dist/cli/commands/core.d.ts +7 -0
- package/dist/cli/commands/core.d.ts.map +1 -0
- package/dist/cli/commands/core.js +150 -0
- package/dist/cli/commands/core.js.map +1 -0
- package/dist/cli/commands/cron.d.ts +7 -0
- package/dist/cli/commands/cron.d.ts.map +1 -0
- package/dist/cli/commands/cron.js +69 -0
- package/dist/cli/commands/cron.js.map +1 -0
- package/dist/cli/commands/dlq.d.ts +7 -0
- package/dist/cli/commands/dlq.d.ts.map +1 -0
- package/dist/cli/commands/dlq.js +63 -0
- package/dist/cli/commands/dlq.js.map +1 -0
- package/dist/cli/commands/job.d.ts +7 -0
- package/dist/cli/commands/job.d.ts.map +1 -0
- package/dist/cli/commands/job.js +155 -0
- package/dist/cli/commands/job.js.map +1 -0
- package/dist/cli/commands/monitor.d.ts +7 -0
- package/dist/cli/commands/monitor.d.ts.map +1 -0
- package/dist/cli/commands/monitor.js +19 -0
- package/dist/cli/commands/monitor.js.map +1 -0
- package/dist/cli/commands/queue.d.ts +7 -0
- package/dist/cli/commands/queue.d.ts.map +1 -0
- package/dist/cli/commands/queue.js +122 -0
- package/dist/cli/commands/queue.js.map +1 -0
- package/dist/cli/commands/rateLimit.d.ts +7 -0
- package/dist/cli/commands/rateLimit.d.ts.map +1 -0
- package/dist/cli/commands/rateLimit.js +64 -0
- package/dist/cli/commands/rateLimit.js.map +1 -0
- package/dist/cli/commands/server.d.ts +7 -0
- package/dist/cli/commands/server.d.ts.map +1 -0
- package/dist/cli/commands/server.js +97 -0
- package/dist/cli/commands/server.js.map +1 -0
- package/dist/cli/commands/types.d.ts +17 -0
- package/dist/cli/commands/types.d.ts.map +1 -0
- package/dist/cli/commands/types.js +47 -0
- package/dist/cli/commands/types.js.map +1 -0
- package/dist/cli/commands/webhook.d.ts +7 -0
- package/dist/cli/commands/webhook.d.ts.map +1 -0
- package/dist/cli/commands/webhook.js +78 -0
- package/dist/cli/commands/webhook.js.map +1 -0
- package/dist/cli/commands/worker.d.ts +7 -0
- package/dist/cli/commands/worker.d.ts.map +1 -0
- package/dist/cli/commands/worker.js +49 -0
- package/dist/cli/commands/worker.js.map +1 -0
- package/dist/cli/help.d.ts +14 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +176 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +109 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/output.d.ts +9 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +260 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/domain/queue/priorityQueue.d.ts.map +1 -1
- package/dist/domain/queue/priorityQueue.js +10 -8
- package/dist/domain/queue/priorityQueue.js.map +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.js +33 -11
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook Command Builders
|
|
3
|
+
* Webhook management operations
|
|
4
|
+
*/
|
|
5
|
+
import { parseArgs } from 'node:util';
|
|
6
|
+
import { CommandError, requireArg } from './types';
|
|
7
|
+
/** Valid webhook events */
|
|
8
|
+
const VALID_EVENTS = [
|
|
9
|
+
'job.completed',
|
|
10
|
+
'job.failed',
|
|
11
|
+
'job.progress',
|
|
12
|
+
'job.active',
|
|
13
|
+
'job.waiting',
|
|
14
|
+
'job.delayed',
|
|
15
|
+
];
|
|
16
|
+
/** Build a webhook subcommand */
|
|
17
|
+
export function buildWebhookCommand(args) {
|
|
18
|
+
const subcommand = args[0];
|
|
19
|
+
const subArgs = args.slice(1);
|
|
20
|
+
switch (subcommand) {
|
|
21
|
+
case 'list':
|
|
22
|
+
return { cmd: 'ListWebhooks' };
|
|
23
|
+
case 'add':
|
|
24
|
+
return buildAddWebhook(subArgs);
|
|
25
|
+
case 'remove':
|
|
26
|
+
return buildRemoveWebhook(subArgs);
|
|
27
|
+
default:
|
|
28
|
+
throw new CommandError(`Unknown webhook subcommand: ${subcommand}. Use: list, add, remove`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function buildAddWebhook(args) {
|
|
32
|
+
const { values, positionals } = parseArgs({
|
|
33
|
+
args,
|
|
34
|
+
options: {
|
|
35
|
+
events: { type: 'string', short: 'e' },
|
|
36
|
+
queue: { type: 'string', short: 'q' },
|
|
37
|
+
secret: { type: 'string', short: 's' },
|
|
38
|
+
},
|
|
39
|
+
allowPositionals: true,
|
|
40
|
+
strict: false,
|
|
41
|
+
});
|
|
42
|
+
const url = requireArg(positionals, 0, 'url');
|
|
43
|
+
if (!values.events) {
|
|
44
|
+
throw new CommandError(`--events (-e) is required (comma-separated). Valid events: ${VALID_EVENTS.join(', ')}`);
|
|
45
|
+
}
|
|
46
|
+
const events = values.events.split(',').filter(Boolean);
|
|
47
|
+
if (events.length === 0) {
|
|
48
|
+
throw new CommandError('At least one event must be specified');
|
|
49
|
+
}
|
|
50
|
+
// Validate events
|
|
51
|
+
for (const event of events) {
|
|
52
|
+
if (!VALID_EVENTS.includes(event)) {
|
|
53
|
+
throw new CommandError(`Invalid event: ${event}. Valid events: ${VALID_EVENTS.join(', ')}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Validate URL
|
|
57
|
+
try {
|
|
58
|
+
new URL(url);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
throw new CommandError(`Invalid URL: ${url}`);
|
|
62
|
+
}
|
|
63
|
+
const cmd = {
|
|
64
|
+
cmd: 'AddWebhook',
|
|
65
|
+
url,
|
|
66
|
+
events,
|
|
67
|
+
};
|
|
68
|
+
if (values.queue)
|
|
69
|
+
cmd.queue = values.queue;
|
|
70
|
+
if (values.secret)
|
|
71
|
+
cmd.secret = values.secret;
|
|
72
|
+
return cmd;
|
|
73
|
+
}
|
|
74
|
+
function buildRemoveWebhook(args) {
|
|
75
|
+
const webhookId = requireArg(args, 0, 'webhookId');
|
|
76
|
+
return { cmd: 'RemoveWebhook', webhookId };
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=webhook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../../src/cli/commands/webhook.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEnD,2BAA2B;AAC3B,MAAM,YAAY,GAAG;IACnB,eAAe;IACf,YAAY;IACZ,cAAc;IACd,YAAY;IACZ,aAAa;IACb,aAAa;CACd,CAAC;AAEF,iCAAiC;AACjC,MAAM,UAAU,mBAAmB,CAAC,IAAc;IAChD,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE9B,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,MAAM;YACT,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC;QACjC,KAAK,KAAK;YACR,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;QAClC,KAAK,QAAQ;YACX,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACrC;YACE,MAAM,IAAI,YAAY,CAAC,+BAA+B,UAAU,0BAA0B,CAAC,CAAC;IAChG,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,IAAc;IACrC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;QACxC,IAAI;QACJ,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E,YAAY;QACjB,GAAG;QACH,MAAM;KACP,CAAC;IAEF,IAAI,MAAM,CAAC,KAAK;QAAE,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC3C,IAAI,MAAM,CAAC,MAAM;QAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAE9C,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAc;IACxC,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;IACnD,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/worker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,gCAAgC;AAChC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgB1E"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Command Builders
|
|
3
|
+
* Worker management operations
|
|
4
|
+
*/
|
|
5
|
+
import { parseArgs } from 'node:util';
|
|
6
|
+
import { CommandError, requireArg } from './types';
|
|
7
|
+
/** Build a worker subcommand */
|
|
8
|
+
export function buildWorkerCommand(args) {
|
|
9
|
+
const subcommand = args[0];
|
|
10
|
+
const subArgs = args.slice(1);
|
|
11
|
+
switch (subcommand) {
|
|
12
|
+
case 'list':
|
|
13
|
+
return { cmd: 'ListWorkers' };
|
|
14
|
+
case 'register':
|
|
15
|
+
return buildRegisterWorker(subArgs);
|
|
16
|
+
case 'unregister':
|
|
17
|
+
return buildUnregisterWorker(subArgs);
|
|
18
|
+
default:
|
|
19
|
+
throw new CommandError(`Unknown worker subcommand: ${subcommand}. Use: list, register, unregister`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function buildRegisterWorker(args) {
|
|
23
|
+
const { values, positionals } = parseArgs({
|
|
24
|
+
args,
|
|
25
|
+
options: {
|
|
26
|
+
queues: { type: 'string', short: 'q' },
|
|
27
|
+
},
|
|
28
|
+
allowPositionals: true,
|
|
29
|
+
strict: false,
|
|
30
|
+
});
|
|
31
|
+
const name = requireArg(positionals, 0, 'name');
|
|
32
|
+
if (!values.queues) {
|
|
33
|
+
throw new CommandError('--queues (-q) is required (comma-separated queue names)');
|
|
34
|
+
}
|
|
35
|
+
const queues = values.queues.split(',').filter(Boolean);
|
|
36
|
+
if (queues.length === 0) {
|
|
37
|
+
throw new CommandError('At least one queue must be specified');
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
cmd: 'RegisterWorker',
|
|
41
|
+
name,
|
|
42
|
+
queues,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function buildUnregisterWorker(args) {
|
|
46
|
+
const workerId = requireArg(args, 0, 'workerId');
|
|
47
|
+
return { cmd: 'UnregisterWorker', workerId };
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/cli/commands/worker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEnD,gCAAgC;AAChC,MAAM,UAAU,kBAAkB,CAAC,IAAc;IAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE9B,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,MAAM;YACT,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;QAChC,KAAK,UAAU;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
*/
|
|
4
|
+
/** Print version information */
|
|
5
|
+
export declare function printVersion(version: string): void;
|
|
6
|
+
/** Print main help */
|
|
7
|
+
export declare function printHelp(): void;
|
|
8
|
+
/** Print server help */
|
|
9
|
+
export declare function printServerHelp(): void;
|
|
10
|
+
/** Print push command help */
|
|
11
|
+
export declare function printPushHelp(): void;
|
|
12
|
+
/** Print cron add help */
|
|
13
|
+
export declare function printCronAddHelp(): void;
|
|
14
|
+
//# sourceMappingURL=help.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,gCAAgC;AAChC,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAElD;AAED,sBAAsB;AACtB,wBAAgB,SAAS,IAAI,IAAI,CAyFhC;AAED,wBAAwB;AACxB,wBAAgB,eAAe,IAAI,IAAI,CAmBtC;AAED,8BAA8B;AAC9B,wBAAgB,aAAa,IAAI,IAAI,CA+BpC;AAED,0BAA0B;AAC1B,wBAAgB,gBAAgB,IAAI,IAAI,CAqBvC"}
|
package/dist/cli/help.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Help Text Generator
|
|
3
|
+
*/
|
|
4
|
+
/** Print version information */
|
|
5
|
+
export function printVersion(version) {
|
|
6
|
+
console.log(`bunqueue v${version}`);
|
|
7
|
+
}
|
|
8
|
+
/** Print main help */
|
|
9
|
+
export function printHelp() {
|
|
10
|
+
console.log(`
|
|
11
|
+
bunqueue - High-performance job queue server for Bun
|
|
12
|
+
|
|
13
|
+
USAGE:
|
|
14
|
+
bunqueue [command] [options]
|
|
15
|
+
|
|
16
|
+
SERVER MODE:
|
|
17
|
+
bunqueue Start server with default settings
|
|
18
|
+
bunqueue start [options] Start server with options
|
|
19
|
+
|
|
20
|
+
CORE COMMANDS:
|
|
21
|
+
push <queue> <data> [opts] Push a job to a queue
|
|
22
|
+
pull <queue> [--timeout ms] Pull the next job from a queue
|
|
23
|
+
ack <id> [--result json] Acknowledge job completion
|
|
24
|
+
fail <id> [--error message] Mark job as failed
|
|
25
|
+
|
|
26
|
+
JOB COMMANDS:
|
|
27
|
+
job get <id> Get job details
|
|
28
|
+
job state <id> Get job state
|
|
29
|
+
job result <id> Get job result
|
|
30
|
+
job cancel <id> Cancel a job
|
|
31
|
+
job progress <id> <n> [--msg] Update job progress (0-100)
|
|
32
|
+
job update <id> <data> Update job data
|
|
33
|
+
job priority <id> <n> Change job priority
|
|
34
|
+
job promote <id> Promote delayed job to waiting
|
|
35
|
+
job delay <id> <ms> Move active job to delayed
|
|
36
|
+
job discard <id> Discard job to DLQ
|
|
37
|
+
job logs <id> Get job logs
|
|
38
|
+
job log <id> <message> Add log entry to job
|
|
39
|
+
|
|
40
|
+
QUEUE COMMANDS:
|
|
41
|
+
queue list List all queues
|
|
42
|
+
queue pause <queue> Pause queue processing
|
|
43
|
+
queue resume <queue> Resume queue processing
|
|
44
|
+
queue drain <queue> Remove all waiting jobs
|
|
45
|
+
queue obliterate <queue> Remove all queue data
|
|
46
|
+
queue clean <q> --grace <ms> Clean old jobs
|
|
47
|
+
queue count <queue> Count jobs in queue
|
|
48
|
+
queue jobs <queue> [--state s] List jobs in queue
|
|
49
|
+
|
|
50
|
+
RATE LIMITING:
|
|
51
|
+
rate-limit set <queue> <n> Set rate limit (jobs/second)
|
|
52
|
+
rate-limit clear <queue> Clear rate limit
|
|
53
|
+
concurrency set <queue> <n> Set concurrency limit
|
|
54
|
+
concurrency clear <queue> Clear concurrency limit
|
|
55
|
+
|
|
56
|
+
DLQ COMMANDS:
|
|
57
|
+
dlq list <queue> [--count n] List DLQ jobs
|
|
58
|
+
dlq retry <queue> [--id jobId] Retry DLQ jobs
|
|
59
|
+
dlq purge <queue> Purge DLQ
|
|
60
|
+
|
|
61
|
+
CRON COMMANDS:
|
|
62
|
+
cron list List cron jobs
|
|
63
|
+
cron add <name> [options] Add cron job
|
|
64
|
+
cron delete <name> Delete cron job
|
|
65
|
+
|
|
66
|
+
WORKER COMMANDS:
|
|
67
|
+
worker list List registered workers
|
|
68
|
+
worker register <name> -q q1,q2 Register a worker
|
|
69
|
+
worker unregister <id> Unregister a worker
|
|
70
|
+
|
|
71
|
+
WEBHOOK COMMANDS:
|
|
72
|
+
webhook list List webhooks
|
|
73
|
+
webhook add <url> [options] Add webhook
|
|
74
|
+
webhook remove <id> Remove webhook
|
|
75
|
+
|
|
76
|
+
MONITORING:
|
|
77
|
+
stats Show server statistics
|
|
78
|
+
metrics Show Prometheus metrics
|
|
79
|
+
health Health check
|
|
80
|
+
|
|
81
|
+
GLOBAL OPTIONS:
|
|
82
|
+
-H, --host <host> Server host (default: localhost)
|
|
83
|
+
-p, --port <port> TCP port (default: 6789)
|
|
84
|
+
-t, --token <token> Authentication token
|
|
85
|
+
--json Output as JSON
|
|
86
|
+
--help Show help
|
|
87
|
+
--version Show version
|
|
88
|
+
|
|
89
|
+
EXAMPLES:
|
|
90
|
+
bunqueue start --tcp-port 6789
|
|
91
|
+
bunqueue push emails '{"to":"user@test.com"}'
|
|
92
|
+
bunqueue push emails '{"id":1}' --priority 10 --delay 5000
|
|
93
|
+
bunqueue pull emails --timeout 5000
|
|
94
|
+
bunqueue job get 12345
|
|
95
|
+
bunqueue queue list
|
|
96
|
+
bunqueue stats --json
|
|
97
|
+
`);
|
|
98
|
+
}
|
|
99
|
+
/** Print server help */
|
|
100
|
+
export function printServerHelp() {
|
|
101
|
+
console.log(`
|
|
102
|
+
Usage: bunqueue start [options]
|
|
103
|
+
|
|
104
|
+
Start the bunQ server.
|
|
105
|
+
|
|
106
|
+
Options:
|
|
107
|
+
--tcp-port <port> TCP server port (default: 6789, env: TCP_PORT)
|
|
108
|
+
--http-port <port> HTTP server port (default: 6790, env: HTTP_PORT)
|
|
109
|
+
--host <host> Bind address (default: 0.0.0.0, env: HOST)
|
|
110
|
+
--data-path <path> SQLite database path (env: DATA_PATH)
|
|
111
|
+
--auth-tokens <list> Comma-separated auth tokens (env: AUTH_TOKENS)
|
|
112
|
+
--help Show this help
|
|
113
|
+
|
|
114
|
+
Examples:
|
|
115
|
+
bunqueue start
|
|
116
|
+
bunqueue start --tcp-port 7000 --http-port 7001
|
|
117
|
+
bunqueue start --data-path ./data/queue.db
|
|
118
|
+
`);
|
|
119
|
+
}
|
|
120
|
+
/** Print push command help */
|
|
121
|
+
export function printPushHelp() {
|
|
122
|
+
console.log(`
|
|
123
|
+
Usage: bunqueue push <queue> <data> [options]
|
|
124
|
+
|
|
125
|
+
Push a job to a queue.
|
|
126
|
+
|
|
127
|
+
Arguments:
|
|
128
|
+
queue Queue name
|
|
129
|
+
data Job data as JSON string
|
|
130
|
+
|
|
131
|
+
Options:
|
|
132
|
+
-P, --priority <n> Job priority (higher = processed first)
|
|
133
|
+
-d, --delay <ms> Delay before processing
|
|
134
|
+
--max-attempts <n> Maximum retry attempts (default: 3)
|
|
135
|
+
--backoff <ms> Backoff between retries (default: 1000)
|
|
136
|
+
--ttl <ms> Time to live
|
|
137
|
+
--timeout <ms> Processing timeout
|
|
138
|
+
-u, --unique-key <k> Unique key for deduplication
|
|
139
|
+
--job-id <id> Custom job ID
|
|
140
|
+
--depends-on <ids> Comma-separated dependency job IDs
|
|
141
|
+
--tags <tags> Comma-separated tags
|
|
142
|
+
-g, --group-id <id> Group ID
|
|
143
|
+
--lifo Last-in-first-out ordering
|
|
144
|
+
--remove-on-complete Remove job after completion
|
|
145
|
+
--remove-on-fail Remove job after final failure
|
|
146
|
+
|
|
147
|
+
Examples:
|
|
148
|
+
bunqueue push emails '{"to":"user@test.com"}'
|
|
149
|
+
bunqueue push tasks '{"action":"sync"}' --priority 10
|
|
150
|
+
bunqueue push jobs '{"id":1}' --delay 60000 --max-attempts 5
|
|
151
|
+
`);
|
|
152
|
+
}
|
|
153
|
+
/** Print cron add help */
|
|
154
|
+
export function printCronAddHelp() {
|
|
155
|
+
console.log(`
|
|
156
|
+
Usage: bunqueue cron add <name> [options]
|
|
157
|
+
|
|
158
|
+
Add a cron job.
|
|
159
|
+
|
|
160
|
+
Arguments:
|
|
161
|
+
name Cron job name (unique identifier)
|
|
162
|
+
|
|
163
|
+
Options:
|
|
164
|
+
-q, --queue <queue> Target queue (required)
|
|
165
|
+
-d, --data <json> Job data as JSON (required)
|
|
166
|
+
-s, --schedule <exp> Cron expression (e.g., "0 * * * *")
|
|
167
|
+
-e, --every <ms> Repeat interval in milliseconds
|
|
168
|
+
-P, --priority <n> Job priority
|
|
169
|
+
--max-limit <n> Maximum executions (0 = unlimited)
|
|
170
|
+
|
|
171
|
+
Examples:
|
|
172
|
+
bunqueue cron add hourly-cleanup -q maintenance -d '{"task":"cleanup"}' -s "0 * * * *"
|
|
173
|
+
bunqueue cron add health-check -q monitoring -d '{}' -e 60000
|
|
174
|
+
`);
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,gCAAgC;AAChC,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,OAAO,CAAC,GAAG,CAAC,aAAa,OAAO,EAAE,CAAC,CAAC;AACtC,CAAC;AAED,sBAAsB;AACtB,MAAM,UAAU,SAAS;IACvB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuFb,CAAC,CAAC;AACH,CAAC;AAED,wBAAwB;AACxB,MAAM,UAAU,eAAe;IAC7B,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;CAiBb,CAAC,CAAC;AACH,CAAC;AAED,8BAA8B;AAC9B,MAAM,UAAU,aAAa;IAC3B,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Bb,CAAC,CAAC;AACH,CAAC;AAED,0BAA0B;AAC1B,MAAM,UAAU,gBAAgB;IAC9B,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;CAmBb,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAoEH,qBAAqB;AACrB,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CA2C1C"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* bunqueue CLI Entry Point
|
|
4
|
+
* Routes to server or client mode based on arguments
|
|
5
|
+
*/
|
|
6
|
+
import { runServer } from './commands/server';
|
|
7
|
+
import { executeCommand } from './client';
|
|
8
|
+
import { printHelp, printVersion } from './help';
|
|
9
|
+
/** Version from package.json */
|
|
10
|
+
const VERSION = '1.0.7';
|
|
11
|
+
/** Parse global options from process.argv */
|
|
12
|
+
function parseGlobalOptions() {
|
|
13
|
+
const allArgs = process.argv.slice(2);
|
|
14
|
+
// Extract global options manually to preserve subcommand flags
|
|
15
|
+
let host = 'localhost';
|
|
16
|
+
let port = 6789;
|
|
17
|
+
let token;
|
|
18
|
+
let json = false;
|
|
19
|
+
let help = false;
|
|
20
|
+
let version = false;
|
|
21
|
+
const commandArgs = [];
|
|
22
|
+
let i = 0;
|
|
23
|
+
while (i < allArgs.length) {
|
|
24
|
+
const arg = allArgs[i];
|
|
25
|
+
if (arg === '--host' || arg === '-H') {
|
|
26
|
+
host = allArgs[++i] ?? 'localhost';
|
|
27
|
+
}
|
|
28
|
+
else if (arg === '--port' || arg === '-p') {
|
|
29
|
+
port = parseInt(allArgs[++i] ?? '6789', 10);
|
|
30
|
+
}
|
|
31
|
+
else if (arg === '--token' || arg === '-t') {
|
|
32
|
+
token = allArgs[++i];
|
|
33
|
+
}
|
|
34
|
+
else if (arg === '--json') {
|
|
35
|
+
json = true;
|
|
36
|
+
}
|
|
37
|
+
else if (arg === '--help') {
|
|
38
|
+
help = true;
|
|
39
|
+
}
|
|
40
|
+
else if (arg === '--version') {
|
|
41
|
+
version = true;
|
|
42
|
+
}
|
|
43
|
+
else if (arg.startsWith('--host=')) {
|
|
44
|
+
host = arg.slice(7);
|
|
45
|
+
}
|
|
46
|
+
else if (arg.startsWith('--port=')) {
|
|
47
|
+
port = parseInt(arg.slice(7), 10);
|
|
48
|
+
}
|
|
49
|
+
else if (arg.startsWith('--token=')) {
|
|
50
|
+
token = arg.slice(8);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// Not a global option, pass to command
|
|
54
|
+
commandArgs.push(arg);
|
|
55
|
+
}
|
|
56
|
+
i++;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
options: { host, port, token, json, help, version },
|
|
60
|
+
commandArgs,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Main CLI entry */
|
|
64
|
+
export async function main() {
|
|
65
|
+
const { options, commandArgs } = parseGlobalOptions();
|
|
66
|
+
// Handle --version
|
|
67
|
+
if (options.version) {
|
|
68
|
+
printVersion(VERSION);
|
|
69
|
+
process.exit(0);
|
|
70
|
+
}
|
|
71
|
+
// Handle --help with no command
|
|
72
|
+
if (options.help && commandArgs.length === 0) {
|
|
73
|
+
printHelp();
|
|
74
|
+
process.exit(0);
|
|
75
|
+
}
|
|
76
|
+
// Get the command (first positional argument)
|
|
77
|
+
const command = commandArgs[0];
|
|
78
|
+
// No command or 'start' = server mode
|
|
79
|
+
if (!command || command === 'start') {
|
|
80
|
+
const serverArgs = command === 'start' ? commandArgs.slice(1) : commandArgs;
|
|
81
|
+
await runServer(serverArgs, options.help);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Help for specific command
|
|
85
|
+
if (options.help) {
|
|
86
|
+
// Could add command-specific help here
|
|
87
|
+
printHelp();
|
|
88
|
+
process.exit(0);
|
|
89
|
+
}
|
|
90
|
+
// Client mode - execute command against server
|
|
91
|
+
try {
|
|
92
|
+
await executeCommand(command, commandArgs.slice(1), options);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
if (err instanceof Error) {
|
|
96
|
+
console.error(`Error: ${err.message}`);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
console.error('Unknown error occurred');
|
|
100
|
+
}
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Run if this is the main module
|
|
105
|
+
main().catch((err) => {
|
|
106
|
+
console.error('Fatal error:', err);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
});
|
|
109
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEjD,gCAAgC;AAChC,MAAM,OAAO,GAAG,OAAO,CAAC;AAYxB,6CAA6C;AAC7C,SAAS,kBAAkB;IACzB,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEtC,+DAA+D;IAC/D,IAAI,IAAI,GAAG,WAAW,CAAC;IACvB,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,IAAI,KAAyB,CAAC;IAC9B,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,IAAI,CAAC,GAAG,CAAC,C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AC,CAAC;IAClB,CAAC;IAED,+CAA+C;IAC/C,IAAI,CAAC;QACH,MAAM,cAAc,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,iCAAiC;AACjC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Output Formatting
|
|
3
|
+
* Formats command responses for terminal display
|
|
4
|
+
*/
|
|
5
|
+
/** Main output formatter */
|
|
6
|
+
export declare function formatOutput(response: Record<string, unknown>, command: string, asJson: boolean): string;
|
|
7
|
+
/** Format error message */
|
|
8
|
+
export declare function formatError(message: string, asJson: boolean): string;
|
|
9
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAySH,4BAA4B;AAC5B,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,GACd,MAAM,CAUR;AAED,2BAA2B;AAC3B,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAKpE"}
|