@portqueue/cli 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -2
  3. package/dist/args.d.ts +25 -0
  4. package/dist/args.test.d.ts +1 -0
  5. package/dist/basic-auth.d.ts +12 -0
  6. package/dist/basic-auth.test.d.ts +1 -0
  7. package/dist/cli.d.ts +1 -0
  8. package/dist/cli.mjs +8 -0
  9. package/dist/cli.mjs.map +1 -0
  10. package/dist/commands/add.d.ts +3 -0
  11. package/dist/commands/add.test.d.ts +1 -0
  12. package/dist/commands/cancel.d.ts +3 -0
  13. package/dist/commands/cancel.test.d.ts +1 -0
  14. package/dist/commands/dashboard.d.ts +3 -0
  15. package/dist/commands/doctor.d.ts +3 -0
  16. package/dist/commands/doctor.test.d.ts +1 -0
  17. package/dist/commands/helpers.d.ts +30 -0
  18. package/dist/commands/helpers.test.d.ts +1 -0
  19. package/dist/commands/index.d.ts +8 -0
  20. package/dist/commands/instances.d.ts +5 -0
  21. package/dist/commands/instances.test.d.ts +1 -0
  22. package/dist/commands/jobs.d.ts +5 -0
  23. package/dist/commands/jobs.test.d.ts +1 -0
  24. package/dist/commands/listen.d.ts +3 -0
  25. package/dist/commands/migrate.d.ts +3 -0
  26. package/dist/commands/migrate.test.d.ts +1 -0
  27. package/dist/commands/pause.d.ts +5 -0
  28. package/dist/commands/pause.test.d.ts +1 -0
  29. package/dist/commands/purge.d.ts +3 -0
  30. package/dist/commands/purge.test.d.ts +1 -0
  31. package/dist/commands/queues.d.ts +3 -0
  32. package/dist/commands/queues.test.d.ts +1 -0
  33. package/dist/commands/registry.test.d.ts +1 -0
  34. package/dist/commands/remove-instance.d.ts +3 -0
  35. package/dist/commands/remove-queue.d.ts +3 -0
  36. package/dist/commands/remove.d.ts +3 -0
  37. package/dist/commands/remove.test.d.ts +1 -0
  38. package/dist/commands/retry.d.ts +3 -0
  39. package/dist/commands/retry.test.d.ts +1 -0
  40. package/dist/commands/schedules.d.ts +3 -0
  41. package/dist/commands/schedules.test.d.ts +1 -0
  42. package/dist/commands/stats.d.ts +3 -0
  43. package/dist/commands/stats.test.d.ts +1 -0
  44. package/dist/commands/types.d.ts +40 -0
  45. package/dist/driver.d.ts +34 -0
  46. package/dist/driver.test.d.ts +1 -0
  47. package/dist/errors.d.ts +3 -0
  48. package/dist/help.d.ts +2 -0
  49. package/dist/help.test.d.ts +1 -0
  50. package/dist/index.d.ts +4 -0
  51. package/dist/index.mjs +8 -0
  52. package/dist/index.mjs.map +1 -0
  53. package/dist/output.d.ts +33 -0
  54. package/dist/output.test.d.ts +1 -0
  55. package/dist/run-gA8fFpEb.js +1053 -0
  56. package/dist/run-gA8fFpEb.js.map +1 -0
  57. package/dist/run.d.ts +1 -0
  58. package/dist/run.test.d.ts +1 -0
  59. package/dist/test-support/capture.d.ts +5 -0
  60. package/dist/test-support/fake-pq.d.ts +41 -0
  61. package/dist/test-support/run-command.d.ts +20 -0
  62. package/package.json +60 -4
@@ -0,0 +1,1053 @@
1
+ import { JobStatus, msToSeconds, CancelOutcome, PortQueueEvent, PauseMode, secondsToMs, PortQueue, MigrationMode } from "@portqueue/core";
2
+ import { createServer } from "node:http";
3
+ import { timingSafeEqual } from "node:crypto";
4
+ import require$$0 from "buffer";
5
+ const BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
6
+ "json",
7
+ "watch",
8
+ "yes",
9
+ "no-color",
10
+ "help"
11
+ ]);
12
+ function parseArgs(argv) {
13
+ const command = [];
14
+ const flags = {};
15
+ const positionals = [];
16
+ let sawCommand = false;
17
+ for (let i = 0; i < argv.length; i += 1) {
18
+ const token = argv[i];
19
+ if (token.startsWith("--")) {
20
+ const eq = token.indexOf("=");
21
+ if (eq !== -1) {
22
+ flags[token.slice(2, eq)] = token.slice(eq + 1);
23
+ } else {
24
+ const key = token.slice(2);
25
+ const next = argv[i + 1];
26
+ if (!BOOLEAN_FLAGS.has(key) && next !== void 0 && !next.startsWith("--")) {
27
+ flags[key] = next;
28
+ i += 1;
29
+ } else {
30
+ flags[key] = true;
31
+ }
32
+ }
33
+ } else if (!sawCommand) {
34
+ command.push(token);
35
+ sawCommand = true;
36
+ } else {
37
+ positionals.push(token);
38
+ }
39
+ }
40
+ return { command, flags, positionals };
41
+ }
42
+ function flagString(flags, name) {
43
+ const v = flags[name];
44
+ return typeof v === "string" ? v : void 0;
45
+ }
46
+ function flagNumber(flags, name) {
47
+ const v = flagString(flags, name);
48
+ return v === void 0 ? void 0 : Number(v);
49
+ }
50
+ function flagBool(flags, name) {
51
+ return flags[name] === true || flags[name] === "true";
52
+ }
53
+ class CliError extends Error {
54
+ }
55
+ const NO_COLOR = Boolean(process.env.NO_COLOR) || !process.stdout.isTTY;
56
+ const CODES = {
57
+ reset: "\x1B[0m",
58
+ dim: "\x1B[2m",
59
+ bold: "\x1B[1m",
60
+ red: "\x1B[31m",
61
+ green: "\x1B[32m",
62
+ yellow: "\x1B[33m",
63
+ blue: "\x1B[34m",
64
+ magenta: "\x1B[35m",
65
+ cyan: "\x1B[36m",
66
+ gray: "\x1B[90m"
67
+ };
68
+ let colorEnabled = !NO_COLOR;
69
+ function setColorEnabled(enabled) {
70
+ colorEnabled = enabled;
71
+ }
72
+ function color(text, ...styles) {
73
+ if (!colorEnabled) return text;
74
+ return styles.map((s) => CODES[s]).join("") + text + CODES.reset;
75
+ }
76
+ function colorStatus(status) {
77
+ switch (status) {
78
+ case JobStatus.ACTIVE:
79
+ return color(status, "cyan");
80
+ case JobStatus.COMPLETED:
81
+ return color(status, "green");
82
+ case JobStatus.FAILED:
83
+ return color(status, "red");
84
+ case JobStatus.RETRY:
85
+ return color(status, "yellow");
86
+ case JobStatus.PENDING:
87
+ return color(status, "dim");
88
+ default:
89
+ return color(status, "gray");
90
+ }
91
+ }
92
+ const symbols = {
93
+ ok: () => color("✔", "green"),
94
+ warn: () => color("⚠", "yellow"),
95
+ err: () => color("✖", "red")
96
+ };
97
+ function success(message) {
98
+ process.stdout.write(`${symbols.ok()} ${message}
99
+ `);
100
+ }
101
+ function warn(message) {
102
+ process.stdout.write(`${symbols.warn()} ${color(message, "yellow")}
103
+ `);
104
+ }
105
+ function fail(message) {
106
+ process.stderr.write(`${symbols.err()} ${color(message, "red")}
107
+ `);
108
+ }
109
+ function heading(text) {
110
+ process.stdout.write(`
111
+ ${color(text, "bold")}
112
+ `);
113
+ }
114
+ function table(headers, rows) {
115
+ const widths = headers.map(
116
+ (h, i) => Math.max(h.length, ...rows.map((r) => (r[i] ?? "").replace(ANSI_RE, "").length))
117
+ );
118
+ const line = (cells) => cells.map((c, i) => {
119
+ const visibleLen = c.replace(ANSI_RE, "").length;
120
+ return c + " ".repeat(Math.max(0, widths[i] - visibleLen));
121
+ }).join(" ");
122
+ process.stdout.write(color(line(headers), "dim") + "\n");
123
+ for (const row of rows) process.stdout.write(line(row) + "\n");
124
+ }
125
+ const ANSI_RE = /\x1b\[[0-9;]*m/g;
126
+ function relativeTime(date, now = Date.now()) {
127
+ if (!date) return color("—", "gray");
128
+ const diff = date.getTime() - now;
129
+ const abs = Math.abs(diff);
130
+ const s = Math.round(msToSeconds(abs));
131
+ const unit = s < 60 ? `${s}s` : s < 3600 ? `${Math.round(s / 60)}m` : s < 86400 ? `${Math.round(s / 3600)}h` : `${Math.round(s / 86400)}d`;
132
+ return diff >= 0 ? `in ${unit}` : `${unit} ago`;
133
+ }
134
+ function printJson(value) {
135
+ process.stdout.write(JSON.stringify(value, null, 2) + "\n");
136
+ }
137
+ function requireFlag(flags, name) {
138
+ const value = flagString(flags, name);
139
+ if (!value) throw new CliError(`Missing required --${name}.`);
140
+ return value;
141
+ }
142
+ function parseStatus(value) {
143
+ if (!value) return void 0;
144
+ const upper = value.toUpperCase();
145
+ if (Object.values(JobStatus).includes(upper)) return upper;
146
+ throw new CliError(`Unknown status '${value}'. Valid: ${Object.values(JobStatus).join(", ")}.`);
147
+ }
148
+ function pageFlags(flags) {
149
+ const limit = flagNumber(flags, "limit");
150
+ const offset = flagNumber(flags, "offset");
151
+ if (limit !== void 0 && (!Number.isInteger(limit) || limit < 1)) {
152
+ throw new CliError(`--limit must be a whole number of at least 1 (got '${String(limit)}').`);
153
+ }
154
+ if (offset !== void 0 && (!Number.isInteger(offset) || offset < 0)) {
155
+ throw new CliError(`--offset must be a whole number of at least 0 (got '${String(offset)}').`);
156
+ }
157
+ return {
158
+ ...limit !== void 0 ? { limit } : {},
159
+ ...offset !== void 0 ? { offset } : {}
160
+ };
161
+ }
162
+ function printMoreHint(page, offset = 0) {
163
+ const next = offset + page.items.length;
164
+ if (next < page.total) {
165
+ process.stdout.write(color(`
166
+ … more — use --offset ${next}
167
+ `, "dim"));
168
+ }
169
+ }
170
+ const PAGE_USAGE = "[--limit <n> --offset <n>]";
171
+ var CommandGroup = /* @__PURE__ */ ((CommandGroup2) => {
172
+ CommandGroup2["Monitoring"] = "Monitoring";
173
+ CommandGroup2["Actions"] = "Actions";
174
+ CommandGroup2["Operational"] = "Operational";
175
+ return CommandGroup2;
176
+ })(CommandGroup || {});
177
+ async function parseData(raw) {
178
+ if (raw.startsWith("@")) {
179
+ const { readFileSync } = await import("node:fs");
180
+ return JSON.parse(readFileSync(raw.slice(1), "utf8"));
181
+ }
182
+ return JSON.parse(raw);
183
+ }
184
+ const addCommand = {
185
+ name: "add",
186
+ group: CommandGroup.Actions,
187
+ summary: "Enqueue a job or create a recurring schedule",
188
+ usage: '--queue <name> --data <json|@file> [--priority --start-after <seconds>\n --idempotency-key <k> | --cron "<expr>" --timezone <tz> | --every <seconds>]',
189
+ async run({ pq, flags }) {
190
+ const queue = requireFlag(flags, "queue");
191
+ const data = await parseData(requireFlag(flags, "data"));
192
+ const options = { data };
193
+ const schedule = {};
194
+ if (flagNumber(flags, "priority") !== void 0)
195
+ options.priority = flagNumber(flags, "priority");
196
+ const startAfter = flagString(flags, "start-after");
197
+ if (startAfter !== void 0) {
198
+ if (!/^\d+$/.test(startAfter)) {
199
+ throw new CliError(
200
+ `--start-after '${startAfter}' is not a whole number of seconds (e.g. --start-after 30).`
201
+ );
202
+ }
203
+ schedule.startAfterSeconds = Number(startAfter);
204
+ }
205
+ if (flagNumber(flags, "retry-max-attempts") !== void 0) {
206
+ options.retry = { maxAttempts: flagNumber(flags, "retry-max-attempts") };
207
+ }
208
+ if (flagString(flags, "idempotency-key")) {
209
+ options.idempotencyKey = flagString(flags, "idempotency-key");
210
+ }
211
+ const cron = flagString(flags, "cron");
212
+ const timezone = flagString(flags, "timezone");
213
+ const every = flagNumber(flags, "every");
214
+ if (cron) schedule.cron = timezone ? { pattern: cron, tz: timezone } : cron;
215
+ else if (every !== void 0) schedule.startEverySeconds = every;
216
+ if (Object.keys(schedule).length > 0) options.schedule = schedule;
217
+ const result = await pq.addJob({ queue, ...options });
218
+ if (flagBool(flags, "json")) return printJson(result);
219
+ if (result.scheduleId) {
220
+ success(
221
+ `Schedule ${result.scheduleId} created (next run ${relativeTime(result.nextRunAt ?? null)}).`
222
+ );
223
+ } else {
224
+ success(`Job ${result.jobId} added${result.deduplicated ? " (deduplicated)" : ""}.`);
225
+ }
226
+ }
227
+ };
228
+ const cancelCommand = {
229
+ name: "cancel",
230
+ group: CommandGroup.Actions,
231
+ summary: "Cancel a pending job, or ask a running one to stop",
232
+ usage: "--id <jobId>",
233
+ async run({ pq, flags }) {
234
+ const jobId = requireFlag(flags, "id");
235
+ switch (await pq.cancelJob({ jobId })) {
236
+ case CancelOutcome.CANCELLED:
237
+ success(`Cancelled job ${jobId}.`);
238
+ break;
239
+ case CancelOutcome.SIGNALLED:
240
+ warn(
241
+ `Job ${jobId} is running in this process and was asked to stop. It only stops if its handler observes job.signal — check the job to see what it became.`
242
+ );
243
+ break;
244
+ default:
245
+ warn(`Job ${jobId} could not be cancelled (already finished, or running elsewhere).`);
246
+ }
247
+ }
248
+ };
249
+ function getDefaultExportFromCjs(x) {
250
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
251
+ }
252
+ var basicAuth = { exports: {} };
253
+ var safeBuffer = { exports: {} };
254
+ var hasRequiredSafeBuffer;
255
+ function requireSafeBuffer() {
256
+ if (hasRequiredSafeBuffer) return safeBuffer.exports;
257
+ hasRequiredSafeBuffer = 1;
258
+ (function(module, exports) {
259
+ var buffer = require$$0;
260
+ var Buffer2 = buffer.Buffer;
261
+ function copyProps(src, dst) {
262
+ for (var key in src) {
263
+ dst[key] = src[key];
264
+ }
265
+ }
266
+ if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
267
+ module.exports = buffer;
268
+ } else {
269
+ copyProps(buffer, exports);
270
+ exports.Buffer = SafeBuffer;
271
+ }
272
+ function SafeBuffer(arg, encodingOrOffset, length) {
273
+ return Buffer2(arg, encodingOrOffset, length);
274
+ }
275
+ copyProps(Buffer2, SafeBuffer);
276
+ SafeBuffer.from = function(arg, encodingOrOffset, length) {
277
+ if (typeof arg === "number") {
278
+ throw new TypeError("Argument must not be a number");
279
+ }
280
+ return Buffer2(arg, encodingOrOffset, length);
281
+ };
282
+ SafeBuffer.alloc = function(size, fill, encoding) {
283
+ if (typeof size !== "number") {
284
+ throw new TypeError("Argument must be a number");
285
+ }
286
+ var buf = Buffer2(size);
287
+ if (fill !== void 0) {
288
+ if (typeof encoding === "string") {
289
+ buf.fill(fill, encoding);
290
+ } else {
291
+ buf.fill(fill);
292
+ }
293
+ } else {
294
+ buf.fill(0);
295
+ }
296
+ return buf;
297
+ };
298
+ SafeBuffer.allocUnsafe = function(size) {
299
+ if (typeof size !== "number") {
300
+ throw new TypeError("Argument must be a number");
301
+ }
302
+ return Buffer2(size);
303
+ };
304
+ SafeBuffer.allocUnsafeSlow = function(size) {
305
+ if (typeof size !== "number") {
306
+ throw new TypeError("Argument must be a number");
307
+ }
308
+ return buffer.SlowBuffer(size);
309
+ };
310
+ })(safeBuffer, safeBuffer.exports);
311
+ return safeBuffer.exports;
312
+ }
313
+ /*!
314
+ * basic-auth
315
+ * Copyright(c) 2013 TJ Holowaychuk
316
+ * Copyright(c) 2014 Jonathan Ong
317
+ * Copyright(c) 2015-2016 Douglas Christopher Wilson
318
+ * MIT Licensed
319
+ */
320
+ var hasRequiredBasicAuth;
321
+ function requireBasicAuth() {
322
+ if (hasRequiredBasicAuth) return basicAuth.exports;
323
+ hasRequiredBasicAuth = 1;
324
+ var Buffer2 = requireSafeBuffer().Buffer;
325
+ basicAuth.exports = auth2;
326
+ basicAuth.exports.parse = parse;
327
+ var CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/;
328
+ var USER_PASS_REGEXP = /^([^:]*):(.*)$/;
329
+ function auth2(req) {
330
+ if (!req) {
331
+ throw new TypeError("argument req is required");
332
+ }
333
+ if (typeof req !== "object") {
334
+ throw new TypeError("argument req is required to be an object");
335
+ }
336
+ var header = getAuthorization(req);
337
+ return parse(header);
338
+ }
339
+ function decodeBase64(str) {
340
+ return Buffer2.from(str, "base64").toString();
341
+ }
342
+ function getAuthorization(req) {
343
+ if (!req.headers || typeof req.headers !== "object") {
344
+ throw new TypeError("argument req is required to have headers property");
345
+ }
346
+ return req.headers.authorization;
347
+ }
348
+ function parse(string) {
349
+ if (typeof string !== "string") {
350
+ return void 0;
351
+ }
352
+ var match = CREDENTIALS_REGEXP.exec(string);
353
+ if (!match) {
354
+ return void 0;
355
+ }
356
+ var userPass = USER_PASS_REGEXP.exec(decodeBase64(match[1]));
357
+ if (!userPass) {
358
+ return void 0;
359
+ }
360
+ return new Credentials(userPass[1], userPass[2]);
361
+ }
362
+ function Credentials(name, pass) {
363
+ this.name = name;
364
+ this.pass = pass;
365
+ }
366
+ return basicAuth.exports;
367
+ }
368
+ var basicAuthExports = requireBasicAuth();
369
+ const auth = /* @__PURE__ */ getDefaultExportFromCjs(basicAuthExports);
370
+ function safeEqual(a, b) {
371
+ const ab = Buffer.from(a, "utf8");
372
+ const bb = Buffer.from(b, "utf8");
373
+ const len = Math.max(ab.length, bb.length, 1);
374
+ const pa = Buffer.alloc(len);
375
+ const pb = Buffer.alloc(len);
376
+ ab.copy(pa);
377
+ bb.copy(pb);
378
+ return timingSafeEqual(pa, pb) && ab.length === bb.length;
379
+ }
380
+ function createBasicAuthGuard(options) {
381
+ const realm = options.realm ?? "PortQueue Dashboard";
382
+ return (req, res) => {
383
+ const credentials = auth(req);
384
+ const ok = credentials !== void 0 && safeEqual(credentials.name, options.username) && safeEqual(credentials.pass, options.password);
385
+ if (ok) return true;
386
+ res.writeHead(401, {
387
+ "www-authenticate": `Basic realm="${realm}", charset="UTF-8"`,
388
+ "content-type": "text/plain; charset=utf-8"
389
+ });
390
+ res.end("Unauthorized");
391
+ return false;
392
+ };
393
+ }
394
+ const DEFAULT_PORT = 4321;
395
+ const DEFAULT_HOST = "127.0.0.1";
396
+ const DEFAULT_BASE_PATH = "/portqueue";
397
+ const dashboardCommand = {
398
+ name: "dashboard",
399
+ group: CommandGroup.Operational,
400
+ summary: "Serve the web dashboard",
401
+ usage: "--port <n> --root-user <u> --root-password <p> [--host <h> --base-path <p>]",
402
+ persistent: true,
403
+ async run({ pq, flags, onExit }) {
404
+ const port = flagNumber(flags, "port") ?? DEFAULT_PORT;
405
+ const user = flagString(flags, "root-user") ?? process.env.PORTQUEUE_ROOT_USER;
406
+ const password = flagString(flags, "root-password") ?? process.env.PORTQUEUE_ROOT_PASSWORD;
407
+ if (!user || !password) {
408
+ throw new CliError(
409
+ "The served dashboard requires credentials. Pass --root-user and --root-password (or set PORTQUEUE_ROOT_USER / PORTQUEUE_ROOT_PASSWORD)."
410
+ );
411
+ }
412
+ const basePath = flagString(flags, "base-path");
413
+ const { createDashboard } = await import("@portqueue/dashboard");
414
+ const dashboard = createDashboard({
415
+ driver: pq._cli.driver,
416
+ ...basePath ? { basePath } : {}
417
+ });
418
+ onExit(() => dashboard.close());
419
+ const guard = createBasicAuthGuard({ username: user, password });
420
+ const handler = dashboard.node();
421
+ const server = createServer((req, res) => {
422
+ if (!guard(req, res)) return;
423
+ if (!handler(req, res)) {
424
+ res.statusCode = 404;
425
+ res.end("Not found");
426
+ }
427
+ });
428
+ onExit(
429
+ () => new Promise((resolve) => {
430
+ server.close(() => resolve());
431
+ server.closeIdleConnections?.();
432
+ })
433
+ );
434
+ const host = flagString(flags, "host") ?? DEFAULT_HOST;
435
+ await new Promise((resolve) => server.listen(port, host, resolve));
436
+ success(
437
+ `Dashboard serving at http://${host}:${port}${basePath ?? DEFAULT_BASE_PATH} (basic auth).`
438
+ );
439
+ await new Promise(() => {
440
+ });
441
+ }
442
+ };
443
+ const doctorCommand = {
444
+ name: "doctor",
445
+ group: CommandGroup.Operational,
446
+ summary: "Check connectivity and schema health",
447
+ usage: "[--json]",
448
+ async run({ pq, flags }) {
449
+ const report = await pq._cli.doctor();
450
+ if (flagBool(flags, "json")) return printJson(report);
451
+ heading("PortQueue doctor");
452
+ table(
453
+ ["Check", "Result"],
454
+ [
455
+ ["Engine", report.engine],
456
+ ["Server version", report.serverVersion],
457
+ ["Capabilities", report.verifiedCapabilities.join(", ") || color("none", "dim")],
458
+ [
459
+ "Schema version",
460
+ report.schemaVersion === null ? "not migrated" : String(report.schemaVersion)
461
+ ],
462
+ ["Latest migration", String(report.latestVersion)],
463
+ ["Queues", String(report.queueCount)],
464
+ ["Instances", String(report.instanceCount)]
465
+ ]
466
+ );
467
+ if (report.schemaVersion === null) {
468
+ warn("The schema has never been migrated. Run `portqueue migrate`.");
469
+ } else if (report.schemaVersion < report.latestVersion) {
470
+ warn(
471
+ `Schema is at v${report.schemaVersion} but this driver ships v${report.latestVersion}. Run \`portqueue migrate\`.`
472
+ );
473
+ } else {
474
+ success("Connected, and the schema is current.");
475
+ }
476
+ }
477
+ };
478
+ const METRIC_WARN_PERCENT = 75;
479
+ const METRIC_DANGER_PERCENT = 85;
480
+ function percent(value) {
481
+ if (value === null) return "—";
482
+ const text = `${value.toFixed(1)}%`;
483
+ if (value >= METRIC_DANGER_PERCENT) return color(text, "red");
484
+ if (value >= METRIC_WARN_PERCENT) return color(text, "yellow");
485
+ return text;
486
+ }
487
+ function processed(instance) {
488
+ return Object.values(instance.counts).reduce((sum, n) => sum + n, 0);
489
+ }
490
+ const instancesCommand = {
491
+ name: "instances",
492
+ group: CommandGroup.Monitoring,
493
+ summary: "List instances with liveness, process health and jobs processed",
494
+ usage: PAGE_USAGE,
495
+ async run({ pq, flags }) {
496
+ const page = await pq.getInstances({ ...pageFlags(flags) });
497
+ if (flagBool(flags, "json")) return printJson(page);
498
+ heading("Instances");
499
+ table(
500
+ // The two health columns say whose numbers they are in the header, since a bare "CPU" in a
501
+ // terminal reads as the box's load.
502
+ ["Instance", "Live", "Paused", "CPU (proc)", "Mem (proc)", "Processed", "Last Seen"],
503
+ page.items.map((i) => [
504
+ i.instanceKey,
505
+ i.alive ? "yes" : color("no", "dim"),
506
+ i.processingPaused ? "yes" : color("no", "dim"),
507
+ percent(i.cpuPercent),
508
+ percent(i.memoryPercent),
509
+ String(processed(i)),
510
+ relativeTime(i.lastSeenAt)
511
+ ])
512
+ );
513
+ printMoreHint(page, pageFlags(flags).offset);
514
+ }
515
+ };
516
+ const instanceCommand = {
517
+ name: "instance",
518
+ group: CommandGroup.Monitoring,
519
+ summary: "One instance: process health at its last heartbeat + jobs by status",
520
+ usage: "--key <instanceKey>",
521
+ async run({ pq, flags }) {
522
+ const instanceKey = flagString(flags, "key");
523
+ if (!instanceKey) throw new CliError("Missing required --key.");
524
+ const instance = await pq.getInstance({ instanceKey });
525
+ if (!instance) throw new CliError(`Instance '${instanceKey}' not found.`);
526
+ if (flagBool(flags, "json")) return printJson(instance);
527
+ heading(`Instance ${instance.instanceKey}`);
528
+ table(
529
+ ["Property", "Value"],
530
+ [
531
+ ["Live", instance.alive ? "yes" : color("no", "dim")],
532
+ ["Paused", instance.processingPaused ? "yes" : color("no", "dim")],
533
+ // Spelled out here, where there is room: a share of the cores available, and a share of
534
+ // V8's heap limit — neither is the machine's.
535
+ ["CPU (process, % of all cores)", percent(instance.cpuPercent)],
536
+ ["Memory (process, % of heap limit)", percent(instance.memoryPercent)],
537
+ ["Last seen", relativeTime(instance.lastSeenAt)],
538
+ ["First seen", relativeTime(instance.createdAt)]
539
+ ]
540
+ );
541
+ heading("Jobs processed");
542
+ const counts = Object.entries(instance.counts).filter(([, n]) => n > 0);
543
+ table(
544
+ ["Status", "Count"],
545
+ counts.length ? [
546
+ ...counts.map(([status, n]) => [status, String(n)]),
547
+ ["TOTAL", String(processed(instance))]
548
+ ] : [["—", "0"]]
549
+ );
550
+ }
551
+ };
552
+ const jobsCommand = {
553
+ name: "jobs",
554
+ group: CommandGroup.Monitoring,
555
+ summary: "Paged job list",
556
+ usage: `--queue <name> [--status <s>] [--schedule-id <id>] ${PAGE_USAGE}`,
557
+ async run({ pq, flags }) {
558
+ const status = parseStatus(flagString(flags, "status"));
559
+ const page = await pq.getJobs({
560
+ ...flagString(flags, "queue") ? { queue: flagString(flags, "queue") } : {},
561
+ ...status ? { statuses: [status] } : {},
562
+ ...flagString(flags, "schedule-id") ? { scheduleId: flagString(flags, "schedule-id") } : {},
563
+ ...pageFlags(flags)
564
+ });
565
+ if (flagBool(flags, "json")) return printJson(page);
566
+ heading("Jobs");
567
+ table(
568
+ ["ID", "Status", "Attempt", "Created"],
569
+ page.items.map((j) => [
570
+ j.id.slice(0, 12),
571
+ colorStatus(j.status),
572
+ `${j.retryAttempt}/${j.retryMaxAttempts}`,
573
+ relativeTime(j.createdAt)
574
+ ])
575
+ );
576
+ printMoreHint(page, pageFlags(flags).offset);
577
+ }
578
+ };
579
+ const jobCommand = {
580
+ name: "job",
581
+ group: CommandGroup.Monitoring,
582
+ summary: "Full job detail",
583
+ usage: "--id <jobId>",
584
+ async run({ pq, flags }) {
585
+ const snap = await pq.getJob({ jobId: requireFlag(flags, "id") });
586
+ if (!snap) throw new CliError(`Job '${flagString(flags, "id")}' not found.`);
587
+ if (flagBool(flags, "json")) return printJson(snap);
588
+ heading(`Job ${snap.id}`);
589
+ printJson(snap);
590
+ }
591
+ };
592
+ const listenCommand = {
593
+ name: "listen",
594
+ group: CommandGroup.Operational,
595
+ summary: "Stream events infinitely",
596
+ usage: "[--queue <name>]",
597
+ persistent: true,
598
+ async run({ pq, flags, onExit }) {
599
+ const queue = flagString(flags, "queue");
600
+ const json = flagBool(flags, "json");
601
+ heading(`Listening${queue ? ` — ${queue}` : ""} (Ctrl+C to stop)`);
602
+ const unsubscribes = Object.values(PortQueueEvent).map(
603
+ (event) => pq.on(
604
+ event,
605
+ (payload) => {
606
+ if (json) return printJson({ event, ...payload });
607
+ const q = payload.queue ?? "";
608
+ process.stdout.write(
609
+ `${color((/* @__PURE__ */ new Date()).toISOString(), "dim")} ${color(event, "cyan")} ${q}
610
+ `
611
+ );
612
+ },
613
+ queue ? { queue } : void 0
614
+ )
615
+ );
616
+ onExit(() => {
617
+ for (const unsubscribe of unsubscribes) unsubscribe();
618
+ });
619
+ await new Promise(() => {
620
+ });
621
+ }
622
+ };
623
+ const migrateCommand = {
624
+ name: "migrate",
625
+ group: CommandGroup.Operational,
626
+ summary: "Apply pending schema migrations",
627
+ usage: "[--mode auto|validate-only]",
628
+ async run({ pq }) {
629
+ await pq.migrate();
630
+ success("Migrations applied (or already up to date).");
631
+ }
632
+ };
633
+ const pauseCommand = {
634
+ name: "pause",
635
+ group: CommandGroup.Actions,
636
+ summary: "Pause a queue",
637
+ usage: "--queue <name> [--mode processing|all]",
638
+ async run({ pq, flags }) {
639
+ const queue = requireFlag(flags, "queue");
640
+ const mode = flagString(flags, "mode") === "all" ? PauseMode.ALL : PauseMode.PROCESSING;
641
+ await pq.pauseQueue({ queue, mode });
642
+ success(`Paused '${queue}' (${mode}).`);
643
+ }
644
+ };
645
+ const resumeCommand = {
646
+ name: "resume",
647
+ group: CommandGroup.Actions,
648
+ summary: "Resume a paused queue",
649
+ usage: "--queue <name>",
650
+ async run({ pq, flags }) {
651
+ const queue = requireFlag(flags, "queue");
652
+ await pq.resumeQueue({ queue });
653
+ success(`Resumed '${queue}'.`);
654
+ }
655
+ };
656
+ const purgeCommand = {
657
+ name: "purge",
658
+ group: CommandGroup.Actions,
659
+ summary: "Delete jobs in a state (destructive — needs --yes)",
660
+ usage: "--queue <name> --status <status> --yes",
661
+ async run({ pq, flags }) {
662
+ const queue = requireFlag(flags, "queue");
663
+ const status = parseStatus(requireFlag(flags, "status"));
664
+ if (!flagBool(flags, "yes")) {
665
+ throw new CliError("purge is destructive — pass --yes to confirm.");
666
+ }
667
+ const n = await pq._cli.purge({ queue, statuses: [status] });
668
+ success(`Purged ${n} ${status} job(s) from '${queue}'.`);
669
+ }
670
+ };
671
+ const queuesCommand = {
672
+ name: "queues",
673
+ group: CommandGroup.Monitoring,
674
+ summary: "List queues with counts + paused state",
675
+ usage: PAGE_USAGE,
676
+ async run({ pq, flags }) {
677
+ const page = await pq.getQueues({ ...pageFlags(flags) });
678
+ if (flagBool(flags, "json")) return printJson(page);
679
+ heading("Queues");
680
+ table(
681
+ ["Name", "Pending", "Active", "Completed", "Failed", "Paused"],
682
+ page.items.map((q) => [
683
+ q.name,
684
+ String(q.counts.PENDING),
685
+ String(q.counts.ACTIVE),
686
+ String(q.counts.COMPLETED),
687
+ String(q.counts.FAILED),
688
+ q.acceptingPaused ? "ALL" : q.processingPaused ? "PROCESSING" : color("no", "dim")
689
+ ])
690
+ );
691
+ printMoreHint(page, pageFlags(flags).offset);
692
+ }
693
+ };
694
+ const removeCommand = {
695
+ name: "remove",
696
+ group: CommandGroup.Actions,
697
+ summary: "Remove a job or a schedule",
698
+ usage: "(--id <jobId> | --schedule-id <id>)",
699
+ async run({ pq, flags }) {
700
+ const id = flagString(flags, "id");
701
+ const scheduleId = flagString(flags, "schedule-id");
702
+ if (id && scheduleId || !id && !scheduleId) {
703
+ throw new CliError(
704
+ "remove requires exactly one of --id (a job) or --schedule-id (a schedule)."
705
+ );
706
+ }
707
+ if (id) {
708
+ if (await pq.removeJob({ jobId: id })) {
709
+ success(`Removed job ${id}.`);
710
+ return;
711
+ }
712
+ const snap = await pq.getJob({ jobId: id });
713
+ if (!snap) throw new CliError(`Job '${id}' not found.`);
714
+ warn(`Job ${id} is ${snap.status} and was not removed (cancel it first).`);
715
+ } else {
716
+ const ok = await pq.removeSchedule({ scheduleId });
717
+ if (ok) success(`Removed schedule ${scheduleId}.`);
718
+ else warn(`Schedule ${scheduleId} not found.`);
719
+ }
720
+ }
721
+ };
722
+ const removeInstanceCommand = {
723
+ name: "remove-instance",
724
+ group: CommandGroup.Actions,
725
+ summary: "Remove a long-inactive instance from monitoring",
726
+ usage: "--instance-key <key>",
727
+ async run({ pq, flags }) {
728
+ const instanceKey = requireFlag(flags, "instance-key");
729
+ const ok = await pq.removeInstance({ instanceKey });
730
+ if (ok) success(`Removed instance '${instanceKey}'.`);
731
+ else warn(`Instance '${instanceKey}' not found.`);
732
+ }
733
+ };
734
+ const removeQueueCommand = {
735
+ name: "remove-queue",
736
+ group: CommandGroup.Actions,
737
+ summary: "Remove a queue no longer used by any running code",
738
+ usage: "--queue <name>",
739
+ async run({ pq, flags }) {
740
+ const queue = requireFlag(flags, "queue");
741
+ const ok = await pq.removeQueue({ name: queue });
742
+ if (ok) success(`Removed queue '${queue}'.`);
743
+ else warn(`Queue '${queue}' not found.`);
744
+ }
745
+ };
746
+ const retryCommand = {
747
+ name: "retry",
748
+ group: CommandGroup.Actions,
749
+ summary: "Requeue a failed job",
750
+ usage: "--id <jobId>",
751
+ async run({ pq, flags }) {
752
+ const jobId = requireFlag(flags, "id");
753
+ const res = await pq.retryJob({ jobId });
754
+ if (res) {
755
+ success(`Requeued job ${res.jobId} on queue ${res.queue}.`);
756
+ return;
757
+ }
758
+ const snap = await pq.getJob({ jobId });
759
+ if (!snap) throw new CliError(`Job '${jobId}' not found.`);
760
+ throw new CliError(
761
+ `Job ${jobId} is ${snap.status} and cannot be requeued. Cancel it first, then retry once it has settled.`
762
+ );
763
+ }
764
+ };
765
+ const schedulesCommand = {
766
+ name: "schedules",
767
+ group: CommandGroup.Monitoring,
768
+ summary: "List recurring definitions",
769
+ usage: `[--queue <name>] ${PAGE_USAGE}`,
770
+ async run({ pq, flags }) {
771
+ const queue = flagString(flags, "queue");
772
+ const window = pageFlags(flags);
773
+ const page = await pq._cli.getSchedules({ ...queue ? { queue } : {}, ...window });
774
+ if (flagBool(flags, "json")) return printJson(page);
775
+ heading(
776
+ `Schedules${queue ? ` — ${queue}` : " (all queues)"} — showing ${page.items.length} of ${page.total}`
777
+ );
778
+ table(
779
+ ["Schedule ID", "Queue", "Cron/Every", "Next Run", "Enabled"],
780
+ page.items.map((s) => [
781
+ s.scheduleId,
782
+ s.queue,
783
+ s.cron ?? `every ${s.everySeconds}s`,
784
+ relativeTime(s.nextRunAt ?? null),
785
+ s.enabled ? "yes" : "no"
786
+ ])
787
+ );
788
+ printMoreHint(page, window.offset);
789
+ }
790
+ };
791
+ const WATCH_INTERVAL_SECONDS = 2;
792
+ const statsCommand = {
793
+ name: "stats",
794
+ group: CommandGroup.Monitoring,
795
+ summary: "Job counts by state",
796
+ usage: "[--queue <name>] [--watch]",
797
+ async run({ pq, flags, onExit }) {
798
+ const queue = flagString(flags, "queue");
799
+ const render = async () => {
800
+ const stats = await pq.getQueueStats(queue ? { queue } : {});
801
+ if (flagBool(flags, "json")) return printJson(stats);
802
+ heading(`Stats${queue ? ` — ${queue}` : " (all queues)"}`);
803
+ const rows = Object.entries(stats.counts).map(([status, count]) => [
804
+ colorStatus(status),
805
+ String(count)
806
+ ]);
807
+ table(["State", "Count"], rows);
808
+ };
809
+ await render();
810
+ if (flagBool(flags, "watch")) {
811
+ warn("Watching — press Ctrl+C to stop.");
812
+ const timer = setInterval(
813
+ () => void render(),
814
+ secondsToMs(WATCH_INTERVAL_SECONDS, "--watch interval")
815
+ );
816
+ onExit(() => clearInterval(timer));
817
+ await new Promise(() => {
818
+ });
819
+ }
820
+ }
821
+ };
822
+ const COMMANDS = [
823
+ // Monitoring
824
+ statsCommand,
825
+ queuesCommand,
826
+ jobsCommand,
827
+ jobCommand,
828
+ schedulesCommand,
829
+ instancesCommand,
830
+ instanceCommand,
831
+ // Actions
832
+ addCommand,
833
+ retryCommand,
834
+ cancelCommand,
835
+ removeCommand,
836
+ removeQueueCommand,
837
+ removeInstanceCommand,
838
+ purgeCommand,
839
+ pauseCommand,
840
+ resumeCommand,
841
+ // Operational
842
+ migrateCommand,
843
+ doctorCommand,
844
+ listenCommand,
845
+ dashboardCommand
846
+ ];
847
+ const COMMANDS_BY_NAME = new Map(
848
+ COMMANDS.map((command) => [command.name, command])
849
+ );
850
+ var CliEngine = /* @__PURE__ */ ((CliEngine2) => {
851
+ CliEngine2["POSTGRES"] = "postgres";
852
+ CliEngine2["PGLITE"] = "pglite";
853
+ CliEngine2["SQLITE"] = "sqlite";
854
+ CliEngine2["MYSQL"] = "mysql";
855
+ CliEngine2["ORACLE"] = "oracle";
856
+ return CliEngine2;
857
+ })(CliEngine || {});
858
+ const SCHEME_TO_ENGINE = {
859
+ postgres: "postgres",
860
+ postgresql: "postgres",
861
+ mysql: "mysql",
862
+ oracle: "oracle",
863
+ sqlite: "sqlite",
864
+ file: "sqlite"
865
+ /* SQLITE */
866
+ };
867
+ const KNOWN_ENGINES = new Set(Object.values(CliEngine));
868
+ async function buildPortQueue(flags) {
869
+ const driver = await buildDriver(flags);
870
+ return new PortQueue({ driver, _headless: true, migration: MigrationMode.AUTO });
871
+ }
872
+ async function buildDriver(flags) {
873
+ const connectionString = flags.connectionString ?? process.env.DATABASE_URL;
874
+ const engine = resolveEngine(flags.driver, connectionString);
875
+ return createDriver(engine, connectionString, flags);
876
+ }
877
+ function resolveEngine(driver, connectionString) {
878
+ if (driver) {
879
+ const normalized = driver.toLowerCase();
880
+ if (!KNOWN_ENGINES.has(normalized)) {
881
+ throw new CliError(
882
+ `Unknown --driver '${driver}'. Expected one of: ${Object.values(CliEngine).join(", ")}.`
883
+ );
884
+ }
885
+ return normalized;
886
+ }
887
+ const scheme = connectionString ? schemeOf(connectionString) : void 0;
888
+ if (scheme && SCHEME_TO_ENGINE[scheme]) return SCHEME_TO_ENGINE[scheme];
889
+ throw new CliError(
890
+ `Cannot determine the database engine. Pass --driver <${Object.values(CliEngine).join("|")}>, or supply a connection string whose scheme names the engine (postgres://, postgresql://, mysql://, oracle://, sqlite://, file://). sqlite and pglite have no URL scheme, so they always need --driver.`
891
+ );
892
+ }
893
+ function schemeOf(connectionString) {
894
+ const match = /^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(connectionString.trim());
895
+ return match ? match[1].toLowerCase() : void 0;
896
+ }
897
+ function storageOptions(flags) {
898
+ return {
899
+ ...flags.schema !== void 0 ? { schema: flags.schema } : {},
900
+ ...flags.tablePrefix !== void 0 ? { tablePrefix: flags.tablePrefix } : {},
901
+ ...flags.namespace !== void 0 ? { namespace: flags.namespace } : {}
902
+ };
903
+ }
904
+ function requireConnectionString(engine, connectionString) {
905
+ if (!connectionString) {
906
+ throw new CliError(
907
+ `The ${engine} driver needs a connection string. Pass --connection-string <url> or set DATABASE_URL.`
908
+ );
909
+ }
910
+ return connectionString;
911
+ }
912
+ async function createDriver(engine, connectionString, flags) {
913
+ const storage = storageOptions(flags);
914
+ switch (engine) {
915
+ case "postgres": {
916
+ const { PostgresDriver } = await import("@portqueue/core/drivers/postgres");
917
+ return new PostgresDriver({
918
+ connectionString: requireConnectionString(engine, connectionString),
919
+ ...storage
920
+ });
921
+ }
922
+ case "mysql": {
923
+ const { MysqlDriver } = await import("@portqueue/core/drivers/mysql");
924
+ return new MysqlDriver({
925
+ connectionString: requireConnectionString(engine, connectionString),
926
+ ...storage
927
+ });
928
+ }
929
+ case "oracle": {
930
+ const { OracleDriver } = await import("@portqueue/core/drivers/oracle");
931
+ return new OracleDriver({
932
+ connectString: requireConnectionString(engine, connectionString),
933
+ ...storage
934
+ });
935
+ }
936
+ case "sqlite": {
937
+ const { SqliteDriver } = await import("@portqueue/core/drivers/sqlite");
938
+ return new SqliteDriver({
939
+ ...connectionString !== void 0 ? { path: connectionString } : {},
940
+ ...storage.tablePrefix !== void 0 ? { tablePrefix: storage.tablePrefix } : {},
941
+ ...storage.namespace !== void 0 ? { namespace: storage.namespace } : {}
942
+ });
943
+ }
944
+ case "pglite": {
945
+ const { PgliteDriver } = await import("@portqueue/core/drivers/pglite");
946
+ return new PgliteDriver({
947
+ ...connectionString !== void 0 ? { dataDir: connectionString } : {},
948
+ ...storage
949
+ });
950
+ }
951
+ }
952
+ }
953
+ const INTRO = `
954
+ portqueue — operate and monitor a PortQueue instance.
955
+
956
+ Usage: portqueue <command> [--flags]
957
+ `;
958
+ const GLOBAL_FLAGS = `
959
+ Global flags:
960
+ --driver <engine> postgres | pglite | sqlite | mysql | oracle
961
+ --connection-string <s> DB connection string (also via DATABASE_URL)
962
+ --schema <name> Optional storage schema
963
+ --table-prefix <name> Optional table prefix (default pq_)
964
+ --namespace <name> Optional pub/sub namespace
965
+ --json Machine-readable output
966
+ --no-color Disable ANSI color
967
+ `;
968
+ function renderHelp() {
969
+ const sections = Object.values(CommandGroup).map((group) => {
970
+ const commands = COMMANDS.filter((command) => command.group === group);
971
+ if (commands.length === 0) return "";
972
+ const lines = commands.map((command) => {
973
+ const signature = command.usage ? `${command.name} ${command.usage}` : command.name;
974
+ return ` ${signature}
975
+ ${command.summary}`;
976
+ });
977
+ return `${group}:
978
+ ${lines.join("\n")}`;
979
+ }).filter(Boolean);
980
+ return `${INTRO}
981
+ ${sections.join("\n\n")}
982
+ ${GLOBAL_FLAGS}`;
983
+ }
984
+ const WATCH_FLAG = "watch";
985
+ const STOP_SIGNALS = ["SIGINT", "SIGTERM"];
986
+ const EXIT_ON_SIGINT = 130;
987
+ const EXIT_ON_SIGTERM = 143;
988
+ async function run(argv) {
989
+ const parsed = parseArgs(argv);
990
+ const commandName = parsed.command[0];
991
+ if (!commandName || commandName === "help" || flagBool(parsed.flags, "help")) {
992
+ process.stdout.write(renderHelp());
993
+ return 0;
994
+ }
995
+ if (flagBool(parsed.flags, "no-color")) setColorEnabled(false);
996
+ const command = COMMANDS_BY_NAME.get(commandName);
997
+ if (!command) {
998
+ fail(`Unknown command '${commandName}'. Run \`portqueue help\`.`);
999
+ return 1;
1000
+ }
1001
+ let pq;
1002
+ const teardowns = [];
1003
+ const onExit = (fn) => void teardowns.unshift(fn);
1004
+ const closeAll = async () => {
1005
+ const client = pq;
1006
+ pq = void 0;
1007
+ for (const teardown of teardowns.splice(0)) {
1008
+ await Promise.resolve().then(teardown).catch(() => void 0);
1009
+ }
1010
+ if (client) await client.shutdown().catch(() => void 0);
1011
+ };
1012
+ try {
1013
+ pq = await buildPortQueue({
1014
+ driver: flagString(parsed.flags, "driver"),
1015
+ connectionString: flagString(parsed.flags, "connection-string"),
1016
+ schema: flagString(parsed.flags, "schema"),
1017
+ tablePrefix: flagString(parsed.flags, "table-prefix"),
1018
+ namespace: flagString(parsed.flags, "namespace")
1019
+ });
1020
+ if (!pq.isRunning) await pq.init();
1021
+ const persistent = command.persistent === true || flagBool(parsed.flags, WATCH_FLAG);
1022
+ if (persistent) installStopHandlers(closeAll);
1023
+ await command.run({ pq, flags: parsed.flags, onExit });
1024
+ if (!persistent) await closeAll();
1025
+ return 0;
1026
+ } catch (err) {
1027
+ if (err instanceof CliError) {
1028
+ fail(err.message);
1029
+ } else {
1030
+ const debug = flagString(parsed.flags, "log-level") === "debug";
1031
+ fail(`${err.message}${debug ? `
1032
+ ${err.stack}` : ""}`);
1033
+ }
1034
+ await closeAll();
1035
+ return 1;
1036
+ }
1037
+ }
1038
+ function installStopHandlers(closeAll) {
1039
+ for (const signal of STOP_SIGNALS) {
1040
+ process.once(signal, () => {
1041
+ void closeAll().then(() => {
1042
+ process.exit(signal === "SIGINT" ? EXIT_ON_SIGINT : EXIT_ON_SIGTERM);
1043
+ });
1044
+ });
1045
+ }
1046
+ }
1047
+ export {
1048
+ CliEngine as C,
1049
+ buildPortQueue as b,
1050
+ parseArgs as p,
1051
+ run as r
1052
+ };
1053
+ //# sourceMappingURL=run-gA8fFpEb.js.map