@cloudnux/local-cloud-provider 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,709 +1,9 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __export = (target, all) => {
11
- for (var name in all)
12
- __defProp(target, name, { get: all[name], enumerable: true });
13
- };
14
- var __copyProps = (to, from, except, desc) => {
15
- if (from && typeof from === "object" || typeof from === "function") {
16
- for (let key of __getOwnPropNames(from))
17
- if (!__hasOwnProp.call(to, key) && key !== except)
18
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
- mod
29
- ));
30
-
31
- // ../../../node_modules/fastify-plugin/lib/getPluginName.js
32
- var require_getPluginName = __commonJS({
33
- "../../../node_modules/fastify-plugin/lib/getPluginName.js"(exports, module) {
34
- "use strict";
35
- var fpStackTracePattern = /at\s{1}(?:.*\.)?plugin\s{1}.*\n\s*(.*)/;
36
- var fileNamePattern = /(\w*(\.\w*)*)\..*/;
37
- module.exports = function getPluginName(fn) {
38
- if (fn.name.length > 0) return fn.name;
39
- const stackTraceLimit = Error.stackTraceLimit;
40
- Error.stackTraceLimit = 10;
41
- try {
42
- throw new Error("anonymous function");
43
- } catch (e) {
44
- Error.stackTraceLimit = stackTraceLimit;
45
- return extractPluginName(e.stack);
46
- }
47
- };
48
- function extractPluginName(stack) {
49
- const m = stack.match(fpStackTracePattern);
50
- return m ? m[1].split(/[/\\]/).slice(-1)[0].match(fileNamePattern)[1] : "anonymous";
51
- }
52
- module.exports.extractPluginName = extractPluginName;
53
- }
54
- });
55
-
56
- // ../../../node_modules/fastify-plugin/lib/toCamelCase.js
57
- var require_toCamelCase = __commonJS({
58
- "../../../node_modules/fastify-plugin/lib/toCamelCase.js"(exports, module) {
59
- "use strict";
60
- module.exports = function toCamelCase(name) {
61
- if (name[0] === "@") {
62
- name = name.slice(1).replace("/", "-");
63
- }
64
- return name.replace(/-(.)/g, function(match, g1) {
65
- return g1.toUpperCase();
66
- });
67
- };
68
- }
69
- });
70
-
71
- // ../../../node_modules/fastify-plugin/plugin.js
72
- var require_plugin = __commonJS({
73
- "../../../node_modules/fastify-plugin/plugin.js"(exports, module) {
74
- "use strict";
75
- var getPluginName = require_getPluginName();
76
- var toCamelCase = require_toCamelCase();
77
- var count = 0;
78
- function plugin(fn, options = {}) {
79
- let autoName = false;
80
- if (fn.default !== void 0) {
81
- fn = fn.default;
82
- }
83
- if (typeof fn !== "function") {
84
- throw new TypeError(
85
- `fastify-plugin expects a function, instead got a '${typeof fn}'`
86
- );
87
- }
88
- if (typeof options === "string") {
89
- options = {
90
- fastify: options
91
- };
92
- }
93
- if (typeof options !== "object" || Array.isArray(options) || options === null) {
94
- throw new TypeError("The options object should be an object");
95
- }
96
- if (options.fastify !== void 0 && typeof options.fastify !== "string") {
97
- throw new TypeError(`fastify-plugin expects a version string, instead got '${typeof options.fastify}'`);
98
- }
99
- if (!options.name) {
100
- autoName = true;
101
- options.name = getPluginName(fn) + "-auto-" + count++;
102
- }
103
- fn[Symbol.for("skip-override")] = options.encapsulate !== true;
104
- fn[Symbol.for("fastify.display-name")] = options.name;
105
- fn[Symbol.for("plugin-meta")] = options;
106
- if (!fn.default) {
107
- fn.default = fn;
108
- }
109
- const camelCase = toCamelCase(options.name);
110
- if (!autoName && !fn[camelCase]) {
111
- fn[camelCase] = fn;
112
- }
113
- return fn;
114
- }
115
- module.exports = plugin;
116
- module.exports.default = plugin;
117
- module.exports.fastifyPlugin = plugin;
118
- }
119
- });
120
-
121
1
  // src/queue-plugin/plugin.ts
122
- var import_fastify_plugin = __toESM(require_plugin());
123
-
124
- // ../../../node_modules/chalk/source/vendor/ansi-styles/index.js
125
- var ANSI_BACKGROUND_OFFSET = 10;
126
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
127
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
128
- var wrapAnsi16m = (offset = 0) => (red2, green2, blue2) => `\x1B[${38 + offset};2;${red2};${green2};${blue2}m`;
129
- var styles = {
130
- modifier: {
131
- reset: [0, 0],
132
- // 21 isn't widely supported and 22 does the same thing
133
- bold: [1, 22],
134
- dim: [2, 22],
135
- italic: [3, 23],
136
- underline: [4, 24],
137
- overline: [53, 55],
138
- inverse: [7, 27],
139
- hidden: [8, 28],
140
- strikethrough: [9, 29]
141
- },
142
- color: {
143
- black: [30, 39],
144
- red: [31, 39],
145
- green: [32, 39],
146
- yellow: [33, 39],
147
- blue: [34, 39],
148
- magenta: [35, 39],
149
- cyan: [36, 39],
150
- white: [37, 39],
151
- // Bright color
152
- blackBright: [90, 39],
153
- gray: [90, 39],
154
- // Alias of `blackBright`
155
- grey: [90, 39],
156
- // Alias of `blackBright`
157
- redBright: [91, 39],
158
- greenBright: [92, 39],
159
- yellowBright: [93, 39],
160
- blueBright: [94, 39],
161
- magentaBright: [95, 39],
162
- cyanBright: [96, 39],
163
- whiteBright: [97, 39]
164
- },
165
- bgColor: {
166
- bgBlack: [40, 49],
167
- bgRed: [41, 49],
168
- bgGreen: [42, 49],
169
- bgYellow: [43, 49],
170
- bgBlue: [44, 49],
171
- bgMagenta: [45, 49],
172
- bgCyan: [46, 49],
173
- bgWhite: [47, 49],
174
- // Bright color
175
- bgBlackBright: [100, 49],
176
- bgGray: [100, 49],
177
- // Alias of `bgBlackBright`
178
- bgGrey: [100, 49],
179
- // Alias of `bgBlackBright`
180
- bgRedBright: [101, 49],
181
- bgGreenBright: [102, 49],
182
- bgYellowBright: [103, 49],
183
- bgBlueBright: [104, 49],
184
- bgMagentaBright: [105, 49],
185
- bgCyanBright: [106, 49],
186
- bgWhiteBright: [107, 49]
187
- }
188
- };
189
- var modifierNames = Object.keys(styles.modifier);
190
- var foregroundColorNames = Object.keys(styles.color);
191
- var backgroundColorNames = Object.keys(styles.bgColor);
192
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
193
- function assembleStyles() {
194
- const codes = /* @__PURE__ */ new Map();
195
- for (const [groupName, group] of Object.entries(styles)) {
196
- for (const [styleName, style] of Object.entries(group)) {
197
- styles[styleName] = {
198
- open: `\x1B[${style[0]}m`,
199
- close: `\x1B[${style[1]}m`
200
- };
201
- group[styleName] = styles[styleName];
202
- codes.set(style[0], style[1]);
203
- }
204
- Object.defineProperty(styles, groupName, {
205
- value: group,
206
- enumerable: false
207
- });
208
- }
209
- Object.defineProperty(styles, "codes", {
210
- value: codes,
211
- enumerable: false
212
- });
213
- styles.color.close = "\x1B[39m";
214
- styles.bgColor.close = "\x1B[49m";
215
- styles.color.ansi = wrapAnsi16();
216
- styles.color.ansi256 = wrapAnsi256();
217
- styles.color.ansi16m = wrapAnsi16m();
218
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
219
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
220
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
221
- Object.defineProperties(styles, {
222
- rgbToAnsi256: {
223
- value(red2, green2, blue2) {
224
- if (red2 === green2 && green2 === blue2) {
225
- if (red2 < 8) {
226
- return 16;
227
- }
228
- if (red2 > 248) {
229
- return 231;
230
- }
231
- return Math.round((red2 - 8) / 247 * 24) + 232;
232
- }
233
- return 16 + 36 * Math.round(red2 / 255 * 5) + 6 * Math.round(green2 / 255 * 5) + Math.round(blue2 / 255 * 5);
234
- },
235
- enumerable: false
236
- },
237
- hexToRgb: {
238
- value(hex) {
239
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
240
- if (!matches) {
241
- return [0, 0, 0];
242
- }
243
- let [colorString] = matches;
244
- if (colorString.length === 3) {
245
- colorString = [...colorString].map((character) => character + character).join("");
246
- }
247
- const integer = Number.parseInt(colorString, 16);
248
- return [
249
- /* eslint-disable no-bitwise */
250
- integer >> 16 & 255,
251
- integer >> 8 & 255,
252
- integer & 255
253
- /* eslint-enable no-bitwise */
254
- ];
255
- },
256
- enumerable: false
257
- },
258
- hexToAnsi256: {
259
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
260
- enumerable: false
261
- },
262
- ansi256ToAnsi: {
263
- value(code) {
264
- if (code < 8) {
265
- return 30 + code;
266
- }
267
- if (code < 16) {
268
- return 90 + (code - 8);
269
- }
270
- let red2;
271
- let green2;
272
- let blue2;
273
- if (code >= 232) {
274
- red2 = ((code - 232) * 10 + 8) / 255;
275
- green2 = red2;
276
- blue2 = red2;
277
- } else {
278
- code -= 16;
279
- const remainder = code % 36;
280
- red2 = Math.floor(code / 36) / 5;
281
- green2 = Math.floor(remainder / 6) / 5;
282
- blue2 = remainder % 6 / 5;
283
- }
284
- const value = Math.max(red2, green2, blue2) * 2;
285
- if (value === 0) {
286
- return 30;
287
- }
288
- let result = 30 + (Math.round(blue2) << 2 | Math.round(green2) << 1 | Math.round(red2));
289
- if (value === 2) {
290
- result += 60;
291
- }
292
- return result;
293
- },
294
- enumerable: false
295
- },
296
- rgbToAnsi: {
297
- value: (red2, green2, blue2) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red2, green2, blue2)),
298
- enumerable: false
299
- },
300
- hexToAnsi: {
301
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
302
- enumerable: false
303
- }
304
- });
305
- return styles;
306
- }
307
- var ansiStyles = assembleStyles();
308
- var ansi_styles_default = ansiStyles;
309
-
310
- // ../../../node_modules/chalk/source/vendor/supports-color/index.js
311
- import process2 from "process";
312
- import os from "os";
313
- import tty from "tty";
314
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
315
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
316
- const position = argv.indexOf(prefix + flag);
317
- const terminatorPosition = argv.indexOf("--");
318
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
319
- }
320
- var { env } = process2;
321
- var flagForceColor;
322
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
323
- flagForceColor = 0;
324
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
325
- flagForceColor = 1;
326
- }
327
- function envForceColor() {
328
- if ("FORCE_COLOR" in env) {
329
- if (env.FORCE_COLOR === "true") {
330
- return 1;
331
- }
332
- if (env.FORCE_COLOR === "false") {
333
- return 0;
334
- }
335
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
336
- }
337
- }
338
- function translateLevel(level) {
339
- if (level === 0) {
340
- return false;
341
- }
342
- return {
343
- level,
344
- hasBasic: true,
345
- has256: level >= 2,
346
- has16m: level >= 3
347
- };
348
- }
349
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
350
- const noFlagForceColor = envForceColor();
351
- if (noFlagForceColor !== void 0) {
352
- flagForceColor = noFlagForceColor;
353
- }
354
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
355
- if (forceColor === 0) {
356
- return 0;
357
- }
358
- if (sniffFlags) {
359
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
360
- return 3;
361
- }
362
- if (hasFlag("color=256")) {
363
- return 2;
364
- }
365
- }
366
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
367
- return 1;
368
- }
369
- if (haveStream && !streamIsTTY && forceColor === void 0) {
370
- return 0;
371
- }
372
- const min = forceColor || 0;
373
- if (env.TERM === "dumb") {
374
- return min;
375
- }
376
- if (process2.platform === "win32") {
377
- const osRelease = os.release().split(".");
378
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
379
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
380
- }
381
- return 1;
382
- }
383
- if ("CI" in env) {
384
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
385
- return 3;
386
- }
387
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
388
- return 1;
389
- }
390
- return min;
391
- }
392
- if ("TEAMCITY_VERSION" in env) {
393
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
394
- }
395
- if (env.COLORTERM === "truecolor") {
396
- return 3;
397
- }
398
- if (env.TERM === "xterm-kitty") {
399
- return 3;
400
- }
401
- if ("TERM_PROGRAM" in env) {
402
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
403
- switch (env.TERM_PROGRAM) {
404
- case "iTerm.app": {
405
- return version >= 3 ? 3 : 2;
406
- }
407
- case "Apple_Terminal": {
408
- return 2;
409
- }
410
- }
411
- }
412
- if (/-256(color)?$/i.test(env.TERM)) {
413
- return 2;
414
- }
415
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
416
- return 1;
417
- }
418
- if ("COLORTERM" in env) {
419
- return 1;
420
- }
421
- return min;
422
- }
423
- function createSupportsColor(stream, options = {}) {
424
- const level = _supportsColor(stream, {
425
- streamIsTTY: stream && stream.isTTY,
426
- ...options
427
- });
428
- return translateLevel(level);
429
- }
430
- var supportsColor = {
431
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
432
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
433
- };
434
- var supports_color_default = supportsColor;
2
+ import fsPlugin from "fastify-plugin";
435
3
 
436
- // ../../../node_modules/chalk/source/utilities.js
437
- function stringReplaceAll(string, substring, replacer) {
438
- let index = string.indexOf(substring);
439
- if (index === -1) {
440
- return string;
441
- }
442
- const substringLength = substring.length;
443
- let endIndex = 0;
444
- let returnValue = "";
445
- do {
446
- returnValue += string.slice(endIndex, index) + substring + replacer;
447
- endIndex = index + substringLength;
448
- index = string.indexOf(substring, endIndex);
449
- } while (index !== -1);
450
- returnValue += string.slice(endIndex);
451
- return returnValue;
452
- }
453
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
454
- let endIndex = 0;
455
- let returnValue = "";
456
- do {
457
- const gotCR = string[index - 1] === "\r";
458
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
459
- endIndex = index + 1;
460
- index = string.indexOf("\n", endIndex);
461
- } while (index !== -1);
462
- returnValue += string.slice(endIndex);
463
- return returnValue;
464
- }
465
-
466
- // ../../../node_modules/chalk/source/index.js
467
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
468
- var GENERATOR = Symbol("GENERATOR");
469
- var STYLER = Symbol("STYLER");
470
- var IS_EMPTY = Symbol("IS_EMPTY");
471
- var levelMapping = [
472
- "ansi",
473
- "ansi",
474
- "ansi256",
475
- "ansi16m"
476
- ];
477
- var styles2 = /* @__PURE__ */ Object.create(null);
478
- var applyOptions = (object, options = {}) => {
479
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
480
- throw new Error("The `level` option should be an integer from 0 to 3");
481
- }
482
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
483
- object.level = options.level === void 0 ? colorLevel : options.level;
484
- };
485
- var chalkFactory = (options) => {
486
- const chalk2 = (...strings) => strings.join(" ");
487
- applyOptions(chalk2, options);
488
- Object.setPrototypeOf(chalk2, createChalk.prototype);
489
- return chalk2;
490
- };
491
- function createChalk(options) {
492
- return chalkFactory(options);
493
- }
494
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
495
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
496
- styles2[styleName] = {
497
- get() {
498
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
499
- Object.defineProperty(this, styleName, { value: builder });
500
- return builder;
501
- }
502
- };
503
- }
504
- styles2.visible = {
505
- get() {
506
- const builder = createBuilder(this, this[STYLER], true);
507
- Object.defineProperty(this, "visible", { value: builder });
508
- return builder;
509
- }
510
- };
511
- var getModelAnsi = (model, level, type, ...arguments_) => {
512
- if (model === "rgb") {
513
- if (level === "ansi16m") {
514
- return ansi_styles_default[type].ansi16m(...arguments_);
515
- }
516
- if (level === "ansi256") {
517
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
518
- }
519
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
520
- }
521
- if (model === "hex") {
522
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
523
- }
524
- return ansi_styles_default[type][model](...arguments_);
525
- };
526
- var usedModels = ["rgb", "hex", "ansi256"];
527
- for (const model of usedModels) {
528
- styles2[model] = {
529
- get() {
530
- const { level } = this;
531
- return function(...arguments_) {
532
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
533
- return createBuilder(this, styler, this[IS_EMPTY]);
534
- };
535
- }
536
- };
537
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
538
- styles2[bgModel] = {
539
- get() {
540
- const { level } = this;
541
- return function(...arguments_) {
542
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
543
- return createBuilder(this, styler, this[IS_EMPTY]);
544
- };
545
- }
546
- };
547
- }
548
- var proto = Object.defineProperties(() => {
549
- }, {
550
- ...styles2,
551
- level: {
552
- enumerable: true,
553
- get() {
554
- return this[GENERATOR].level;
555
- },
556
- set(level) {
557
- this[GENERATOR].level = level;
558
- }
559
- }
560
- });
561
- var createStyler = (open, close, parent) => {
562
- let openAll;
563
- let closeAll;
564
- if (parent === void 0) {
565
- openAll = open;
566
- closeAll = close;
567
- } else {
568
- openAll = parent.openAll + open;
569
- closeAll = close + parent.closeAll;
570
- }
571
- return {
572
- open,
573
- close,
574
- openAll,
575
- closeAll,
576
- parent
577
- };
578
- };
579
- var createBuilder = (self2, _styler, _isEmpty) => {
580
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
581
- Object.setPrototypeOf(builder, proto);
582
- builder[GENERATOR] = self2;
583
- builder[STYLER] = _styler;
584
- builder[IS_EMPTY] = _isEmpty;
585
- return builder;
586
- };
587
- var applyStyle = (self2, string) => {
588
- if (self2.level <= 0 || !string) {
589
- return self2[IS_EMPTY] ? "" : string;
590
- }
591
- let styler = self2[STYLER];
592
- if (styler === void 0) {
593
- return string;
594
- }
595
- const { openAll, closeAll } = styler;
596
- if (string.includes("\x1B")) {
597
- while (styler !== void 0) {
598
- string = stringReplaceAll(string, styler.close, styler.open);
599
- styler = styler.parent;
600
- }
601
- }
602
- const lfIndex = string.indexOf("\n");
603
- if (lfIndex !== -1) {
604
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
605
- }
606
- return openAll + string + closeAll;
607
- };
608
- Object.defineProperties(createChalk.prototype, styles2);
609
- var chalk = createChalk();
610
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
611
- var source_default = chalk;
612
-
613
- // ../../../node_modules/log-symbols/symbols.js
614
- var symbols_exports = {};
615
- __export(symbols_exports, {
616
- error: () => error,
617
- info: () => info,
618
- success: () => success,
619
- warning: () => warning
620
- });
621
-
622
- // ../../../node_modules/yoctocolors/base.js
623
- import tty2 from "tty";
624
- var hasColors = tty2?.WriteStream?.prototype?.hasColors?.() ?? false;
625
- var format = (open, close) => {
626
- if (!hasColors) {
627
- return (input) => input;
628
- }
629
- const openCode = `\x1B[${open}m`;
630
- const closeCode = `\x1B[${close}m`;
631
- return (input) => {
632
- const string = input + "";
633
- let index = string.indexOf(closeCode);
634
- if (index === -1) {
635
- return openCode + string + closeCode;
636
- }
637
- let result = openCode;
638
- let lastIndex = 0;
639
- while (index !== -1) {
640
- result += string.slice(lastIndex, index) + openCode;
641
- lastIndex = index + closeCode.length;
642
- index = string.indexOf(closeCode, lastIndex);
643
- }
644
- result += string.slice(lastIndex) + closeCode;
645
- return result;
646
- };
647
- };
648
- var reset = format(0, 0);
649
- var bold = format(1, 22);
650
- var dim = format(2, 22);
651
- var italic = format(3, 23);
652
- var underline = format(4, 24);
653
- var overline = format(53, 55);
654
- var inverse = format(7, 27);
655
- var hidden = format(8, 28);
656
- var strikethrough = format(9, 29);
657
- var black = format(30, 39);
658
- var red = format(31, 39);
659
- var green = format(32, 39);
660
- var yellow = format(33, 39);
661
- var blue = format(34, 39);
662
- var magenta = format(35, 39);
663
- var cyan = format(36, 39);
664
- var white = format(37, 39);
665
- var gray = format(90, 39);
666
- var bgBlack = format(40, 49);
667
- var bgRed = format(41, 49);
668
- var bgGreen = format(42, 49);
669
- var bgYellow = format(43, 49);
670
- var bgBlue = format(44, 49);
671
- var bgMagenta = format(45, 49);
672
- var bgCyan = format(46, 49);
673
- var bgWhite = format(47, 49);
674
- var bgGray = format(100, 49);
675
- var redBright = format(91, 39);
676
- var greenBright = format(92, 39);
677
- var yellowBright = format(93, 39);
678
- var blueBright = format(94, 39);
679
- var magentaBright = format(95, 39);
680
- var cyanBright = format(96, 39);
681
- var whiteBright = format(97, 39);
682
- var bgRedBright = format(101, 49);
683
- var bgGreenBright = format(102, 49);
684
- var bgYellowBright = format(103, 49);
685
- var bgBlueBright = format(104, 49);
686
- var bgMagentaBright = format(105, 49);
687
- var bgCyanBright = format(106, 49);
688
- var bgWhiteBright = format(107, 49);
689
-
690
- // ../../../node_modules/is-unicode-supported/index.js
691
- import process3 from "process";
692
- function isUnicodeSupported() {
693
- const { env: env3 } = process3;
694
- const { TERM, TERM_PROGRAM } = env3;
695
- if (process3.platform !== "win32") {
696
- return TERM !== "linux";
697
- }
698
- return Boolean(env3.WT_SESSION) || Boolean(env3.TERMINUS_SUBLIME) || env3.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env3.TERMINAL_EMULATOR === "JetBrains-JediTerm";
699
- }
700
-
701
- // ../../../node_modules/log-symbols/symbols.js
702
- var _isUnicodeSupported = isUnicodeSupported();
703
- var info = blue(_isUnicodeSupported ? "\u2139" : "i");
704
- var success = green(_isUnicodeSupported ? "\u2714" : "\u221A");
705
- var warning = yellow(_isUnicodeSupported ? "\u26A0" : "\u203C");
706
- var error = red(_isUnicodeSupported ? "\u2716" : "\xD7");
4
+ // src/queue-plugin/core.ts
5
+ import chalk2 from "chalk";
6
+ import logSymbols from "log-symbols";
707
7
 
708
8
  // ../../../node_modules/lodash-es/_freeGlobal.js
709
9
  var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
@@ -715,8 +15,8 @@ var root = freeGlobal_default || freeSelf || Function("return this")();
715
15
  var root_default = root;
716
16
 
717
17
  // ../../../node_modules/lodash-es/_Symbol.js
718
- var Symbol2 = root_default.Symbol;
719
- var Symbol_default = Symbol2;
18
+ var Symbol = root_default.Symbol;
19
+ var Symbol_default = Symbol;
720
20
 
721
21
  // ../../../node_modules/lodash-es/_getRawTag.js
722
22
  var objectProto = Object.prototype;
@@ -1151,8 +451,8 @@ ListCache.prototype.set = listCacheSet_default;
1151
451
  var ListCache_default = ListCache;
1152
452
 
1153
453
  // ../../../node_modules/lodash-es/_Map.js
1154
- var Map2 = getNative_default(root_default, "Map");
1155
- var Map_default = Map2;
454
+ var Map = getNative_default(root_default, "Map");
455
+ var Map_default = Map;
1156
456
 
1157
457
  // ../../../node_modules/lodash-es/_mapCacheClear.js
1158
458
  function mapCacheClear() {
@@ -1477,8 +777,8 @@ function json(key, defaultValue) {
1477
777
  const value = process.env[key] ?? "{}";
1478
778
  try {
1479
779
  return JSON.parse(value);
1480
- } catch (error2) {
1481
- throw new Error(`Invalid json environment variable ${key}: ${error2.message}`);
780
+ } catch (error) {
781
+ throw new Error(`Invalid json environment variable ${key}: ${error.message}`);
1482
782
  }
1483
783
  }
1484
784
  function array(key, defaultValue) {
@@ -1521,13 +821,14 @@ var utils = {
1521
821
  if (defaultValue && !expectedValues.includes(defaultValue)) {
1522
822
  throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
1523
823
  }
1524
- const rawValue = env2(key, defaultValue);
824
+ const rawValue = env(key, defaultValue);
1525
825
  return expectedValues.includes(rawValue) ? rawValue : defaultValue ?? "";
1526
826
  }
1527
827
  };
1528
- var env2 = Object.assign(_env, utils);
828
+ var env = Object.assign(_env, utils);
1529
829
 
1530
830
  // ../../utils/src/logging/index.ts
831
+ import chalk from "chalk";
1531
832
  import { EOL } from "os";
1532
833
 
1533
834
  // ../../utils/src/logging/types.ts
@@ -1540,37 +841,37 @@ var logLevels = {
1540
841
  };
1541
842
 
1542
843
  // ../../utils/src/logging/error-to-string.ts
1543
- var errorToString = (error2) => {
1544
- if (error2 === null) return "Null error";
1545
- if (error2 === void 0) return "Undefined error";
1546
- if (error2 instanceof Error) {
844
+ var errorToString = (error) => {
845
+ if (error === null) return "Null error";
846
+ if (error === void 0) return "Undefined error";
847
+ if (error instanceof Error) {
1547
848
  return [
1548
- `Name: ${error2.name}`,
1549
- `Message: ${error2.message}`,
1550
- `Stack: ${error2.stack || "No stack trace available"}`,
849
+ `Name: ${error.name}`,
850
+ `Message: ${error.message}`,
851
+ `Stack: ${error.stack || "No stack trace available"}`,
1551
852
  // Handle additional properties that might exist on custom errors
1552
- ...Object.entries(error2).filter(([key]) => !["name", "message", "stack"].includes(key)).map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
853
+ ...Object.entries(error).filter(([key]) => !["name", "message", "stack"].includes(key)).map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
1553
854
  ].join("\n");
1554
855
  }
1555
- if (typeof error2 === "string") return error2;
1556
- if (typeof error2 === "object") {
856
+ if (typeof error === "string") return error;
857
+ if (typeof error === "object") {
1557
858
  try {
1558
- return JSON.stringify(error2, null, 2);
859
+ return JSON.stringify(error, null, 2);
1559
860
  } catch {
1560
- return `[Object that cannot be stringified: ${Object.prototype.toString.call(error2)}]`;
861
+ return `[Object that cannot be stringified: ${Object.prototype.toString.call(error)}]`;
1561
862
  }
1562
863
  }
1563
- return String(error2);
864
+ return String(error);
1564
865
  };
1565
866
 
1566
867
  // ../../utils/src/logging/index.ts
1567
- var currentLogLevel = env2.int("LOG_LEVEL", logLevels.info);
868
+ var currentLogLevel = logLevels[env("LOG_LEVEL")?.toLowerCase()] ?? logLevels.info;
1568
869
  var logger = {
1569
870
  fatal: (message, meta) => {
1570
871
  if (currentLogLevel >= logLevels.fatal) {
1571
872
  console.error(
1572
873
  `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1573
- `${source_default.bgRed.white(" fatal ")}${EOL}`,
874
+ `${chalk.bgRed.white(" fatal ")}${EOL}`,
1574
875
  errorToString(message),
1575
876
  meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1576
877
  );
@@ -1580,7 +881,7 @@ var logger = {
1580
881
  if (currentLogLevel >= logLevels.error) {
1581
882
  console.error(
1582
883
  `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1583
- `${source_default.bgRed.white(" error ")}${EOL}`,
884
+ `${chalk.bgRed.white(" error ")}${EOL}`,
1584
885
  errorToString(message),
1585
886
  meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1586
887
  );
@@ -1590,7 +891,7 @@ var logger = {
1590
891
  if (currentLogLevel >= logLevels.warn) {
1591
892
  console.warn(
1592
893
  `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1593
- `${source_default.bgYellow.black(" warn ")}${EOL}`,
894
+ `${chalk.bgYellow.black(" warn ")}${EOL}`,
1594
895
  errorToString(message),
1595
896
  meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1596
897
  );
@@ -1600,7 +901,7 @@ var logger = {
1600
901
  if (currentLogLevel >= logLevels.info) {
1601
902
  console.info(
1602
903
  `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1603
- `${source_default.bgBlue.white(" info ")}${EOL}`,
904
+ `${chalk.bgBlue.white(" info ")}${EOL}`,
1604
905
  message,
1605
906
  meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1606
907
  );
@@ -1610,7 +911,7 @@ var logger = {
1610
911
  if (currentLogLevel >= logLevels.debug) {
1611
912
  console.debug(
1612
913
  `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1613
- `${source_default.bgWhite.black(" debug ")}${EOL}`,
914
+ `${chalk.bgWhite.black(" debug ")}${EOL}`,
1614
915
  message,
1615
916
  meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1616
917
  );
@@ -1642,14 +943,15 @@ var mergeConfig = (defaultConfig, userConfig) => ({
1642
943
  ...userConfig?.persistence || {}
1643
944
  }
1644
945
  });
1645
- var createQueueService = (handler) => ({
946
+ var createQueueService = (handler, module) => ({
1646
947
  handler,
1647
948
  incoming: [],
1648
949
  processing: [],
1649
950
  dlq: [],
1650
951
  timeoutId: null,
1651
952
  processingBatch: false,
1652
- activeProcessing: 0
953
+ activeProcessing: 0,
954
+ module
1653
955
  });
1654
956
  var createQueueMessage = (body, headers) => {
1655
957
  const id = Date.now().toString() + Math.random().toString(36).substring(2, 7);
@@ -1667,10 +969,10 @@ var moveToProcessing = (queueService, batchSize) => {
1667
969
  var removeFromProcessing = (queueService, messageId) => {
1668
970
  queueService.processing = queueService.processing.filter((msg) => msg.id !== messageId);
1669
971
  };
1670
- var moveToDLQ = (queueService, message, error2) => {
972
+ var moveToDLQ = (queueService, message, error) => {
1671
973
  queueService.dlq.push({
1672
974
  ...message,
1673
- error: error2,
975
+ error,
1674
976
  failedAt: /* @__PURE__ */ new Date()
1675
977
  });
1676
978
  removeFromProcessing(queueService, message.id);
@@ -1731,16 +1033,16 @@ var purgeDLQ = (queueService) => {
1731
1033
  return dlqCount;
1732
1034
  };
1733
1035
  var logSuccess = (message, messageId, queueName) => {
1734
- logger.debug(`${symbols_exports.success} ${source_default.green(message)} ${source_default.yellow(messageId)} in queue ${source_default.magenta(queueName)}`);
1036
+ logger.debug(`${logSymbols.success} ${chalk2.green(message)} ${chalk2.yellow(messageId)} in queue ${chalk2.magenta(queueName)}`);
1735
1037
  };
1736
- var logError = (message, messageId, queueName, error2) => {
1737
- logger.error(`${symbols_exports.error} ${source_default.red(message)} ${source_default.yellow(messageId)} in queue ${source_default.magenta(queueName)}: ${error2}`);
1038
+ var logError = (message, messageId, queueName, error) => {
1039
+ logger.error(`${logSymbols.error} ${chalk2.red(message)} ${chalk2.yellow(messageId)} in queue ${chalk2.magenta(queueName)}: ${error}`);
1738
1040
  };
1739
1041
  var logRetryScheduled = (messageId, delayMs) => {
1740
- logger.info(`${source_default.blue("\u23F1\uFE0F Scheduling retry")} for message ${source_default.yellow(messageId)} in ${source_default.cyan(delayMs)}ms`);
1042
+ logger.info(`${chalk2.blue("\u23F1\uFE0F Scheduling retry")} for message ${chalk2.yellow(messageId)} in ${chalk2.cyan(delayMs)}ms`);
1741
1043
  };
1742
1044
  var logDLQOperation = (operation, count, queueName) => {
1743
- logger.warn(`${symbols_exports.warning} ${source_default.yellow(operation)} ${source_default.red(count)} messages from DLQ for ${source_default.green(queueName)}`);
1045
+ logger.warn(`${logSymbols.warning} ${chalk2.yellow(operation)} ${chalk2.red(count)} messages from DLQ for ${chalk2.green(queueName)}`);
1744
1046
  };
1745
1047
 
1746
1048
  // src/queue-plugin/processing.ts
@@ -1749,14 +1051,14 @@ var createProcessMessageHandler = (config) => async (queueName, message, queueSe
1749
1051
  await queueService.handler(message);
1750
1052
  removeFromProcessing(queueService, message.id);
1751
1053
  logSuccess("Successfully processed message", message.id, queueName);
1752
- } catch (error2) {
1753
- await handleProcessingError(queueName, message, queueService, error2, config);
1054
+ } catch (error) {
1055
+ await handleProcessingError(queueName, message, queueService, error, config);
1754
1056
  }
1755
1057
  };
1756
- var handleProcessingError = async (queueName, message, queueService, error2, config) => {
1757
- logError("Error processing message", message.id, queueName, error2.message);
1058
+ var handleProcessingError = async (queueName, message, queueService, error, config) => {
1059
+ logError("Error processing message", message.id, queueName, error.message);
1758
1060
  if (message.attempts >= config.maxRetries) {
1759
- moveToDLQ(queueService, message, error2.message);
1061
+ moveToDLQ(queueService, message, error.message);
1760
1062
  return;
1761
1063
  }
1762
1064
  const updatedMessage = incrementAttempts(queueService, message.id);
@@ -1816,6 +1118,8 @@ var handleImmediateProcessing = (queueService, config, processBatch, queueName)
1816
1118
  // src/queue-plugin/persistence.ts
1817
1119
  import * as fs from "fs/promises";
1818
1120
  import * as path from "path";
1121
+ import chalk3 from "chalk";
1122
+ import logSymbols2 from "log-symbols";
1819
1123
  var createQueueData = (queueService) => ({
1820
1124
  incoming: queueService.incoming,
1821
1125
  processing: queueService.processing,
@@ -1847,9 +1151,9 @@ var createPersistenceInitializer = (config, loadAllQueueStates, saveAllQueueStat
1847
1151
  process.on("SIGINT", shutdownHandler);
1848
1152
  process.on("SIGTERM", shutdownHandler);
1849
1153
  }
1850
- logger.debug(`${symbols_exports.success} ${source_default.green("Queue persistence initialized:")} ${source_default.yellow(config.persistence.directory)}`);
1851
- } catch (error2) {
1852
- logger.error(`${symbols_exports.error} ${source_default.red("Failed to initialize queue persistence:")} ${source_default.yellow(error2.message)}`);
1154
+ logger.debug(`${logSymbols2.success} ${chalk3.green("Queue persistence initialized:")} ${chalk3.yellow(config.persistence.directory)}`);
1155
+ } catch (error) {
1156
+ logger.error(`${logSymbols2.error} ${chalk3.red("Failed to initialize queue persistence:")} ${chalk3.yellow(error.message)}`);
1853
1157
  }
1854
1158
  };
1855
1159
  var createQueueStateSaver = (config) => async (queueName, queueService) => {
@@ -1861,9 +1165,9 @@ var createQueueStateSaver = (config) => async (queueName, queueService) => {
1861
1165
  const tempFilePath = path.join(config.persistence.directory, `${queueName}.${now}temp.json`);
1862
1166
  await fs.writeFile(tempFilePath, JSON.stringify(queueData, null, 2), "utf8");
1863
1167
  await fs.rename(tempFilePath, queueFilePath);
1864
- logger.info(`${symbols_exports.info} ${source_default.blue("Queue state saved:")} ${source_default.green(queueName)}`);
1865
- } catch (error2) {
1866
- logger.error(`Failed to save queue state for ${queueName}:`, error2);
1168
+ logger.info(`${logSymbols2.info} ${chalk3.blue("Queue state saved:")} ${chalk3.green(queueName)}`);
1169
+ } catch (error) {
1170
+ logger.error(`Failed to save queue state for ${queueName}:`, error);
1867
1171
  }
1868
1172
  };
1869
1173
  var createAllQueuesStateSaver = (config, saveQueueState) => (queues) => async () => {
@@ -1871,9 +1175,9 @@ var createAllQueuesStateSaver = (config, saveQueueState) => (queues) => async ()
1871
1175
  for (const [queueName, queueService] of Object.entries(queues)) {
1872
1176
  await saveQueueState(queueName, queueService);
1873
1177
  }
1874
- logger.debug(`${symbols_exports.success} ${source_default.green("All queue states saved to")} ${source_default.yellow(config.persistence.directory)}`);
1875
- } catch (error2) {
1876
- logger.error(`${symbols_exports.error} ${source_default.red("Failed to save all queue states:")} ${source_default.yellow(error2.message)}`);
1178
+ logger.debug(`${logSymbols2.success} ${chalk3.green("All queue states saved to")} ${chalk3.yellow(config.persistence.directory)}`);
1179
+ } catch (error) {
1180
+ logger.error(`${logSymbols2.error} ${chalk3.red("Failed to save all queue states:")} ${chalk3.yellow(error.message)}`);
1877
1181
  }
1878
1182
  };
1879
1183
  var createQueueStateLoader = (config, scheduleProcessing, processMessage) => (queues) => async (queueName) => {
@@ -1904,15 +1208,15 @@ var createQueueStateLoader = (config, scheduleProcessing, processMessage) => (qu
1904
1208
  }, 100 * (Math.random() * 10));
1905
1209
  }
1906
1210
  }
1907
- } catch (error2) {
1908
- if (error2.code === "ENOENT") {
1211
+ } catch (error) {
1212
+ if (error.code === "ENOENT") {
1909
1213
  logger.debug(`No saved state found for queue: ${queueName}`);
1910
1214
  } else {
1911
- throw error2;
1215
+ throw error;
1912
1216
  }
1913
1217
  }
1914
- } catch (error2) {
1915
- logger.error(`Failed to load queue state for ${queueName}:`, error2);
1218
+ } catch (error) {
1219
+ logger.error(`Failed to load queue state for ${queueName}:`, error);
1916
1220
  }
1917
1221
  };
1918
1222
  var createAllQueuesStateLoader = (config, loadQueueState) => async () => {
@@ -1924,111 +1228,69 @@ var createAllQueuesStateLoader = (config, loadQueueState) => async () => {
1924
1228
  await loadQueueState(queueName);
1925
1229
  }
1926
1230
  logger.debug("All queue states loaded");
1927
- } catch (error2) {
1928
- logger.error("Failed to load queue states:", error2);
1231
+ } catch (error) {
1232
+ logger.error("Failed to load queue states:", error);
1929
1233
  }
1930
1234
  };
1931
1235
 
1932
1236
  // src/queue-plugin/routes.ts
1933
- var createDashboardHandler = (queues, config) => async (_, reply) => {
1934
- const summary = createDashboardSummary(queues, config);
1935
- return reply.status(200).send(summary);
1936
- };
1937
- var createQueueDetailsHandler = (queues, config) => async (request, reply) => {
1938
- const queueName = request.params.queue;
1939
- if (!queues[queueName]) {
1940
- return reply.status(404).send({ error: "Queue not found" });
1941
- }
1942
- const queue = queues[queueName];
1943
- const stats = createQueueSummary(queue, config);
1944
- return reply.status(200).send({
1945
- stats,
1946
- messages: {
1947
- incoming: queue.incoming,
1948
- processing: queue.processing,
1949
- dlq: queue.dlq
1237
+ var registerQueueRoutes = (app, prefix = "") => {
1238
+ app.get(
1239
+ `/${prefix}/dashboard`,
1240
+ async (_, reply) => {
1241
+ const summary = app.queues.getDashboardSummary();
1242
+ return reply.status(200).send(summary);
1950
1243
  }
1951
- });
1952
- };
1953
- var createEnqueueMessageHandler = (queues, config, scheduleProcessing, processBatch, saveQueueState) => async (request, reply) => {
1954
- const queueName = request.params.queue;
1955
- if (!queues[queueName]) {
1956
- return reply.status(404).send({ error: "Queue not found" });
1957
- }
1958
- const message = createQueueMessage(request.body, request.headers);
1959
- queues[queueName].incoming.push(message);
1960
- scheduleProcessing(queueName, queues[queueName]);
1961
- handleImmediateProcessing(queues[queueName], config, processBatch, queueName);
1962
- if (config.persistence.enabled && saveQueueState) {
1963
- await saveQueueState(queueName, queues[queueName]);
1964
- }
1965
- return reply.status(200).send({ id: message.id, queueName });
1966
- };
1967
- var createProcessDLQHandler = (queues, scheduleProcessing, saveQueueState) => async (request, reply) => {
1968
- const queueName = request.params.queue;
1969
- if (!queues[queueName]) {
1970
- return reply.status(404).send({ error: "Queue not found" });
1971
- }
1972
- const processedCount = moveDLQToIncoming(queues[queueName]);
1973
- if (processedCount === 0) {
1974
- return reply.status(200).send({
1975
- status: "success",
1976
- message: "No messages in DLQ to process",
1977
- processed: 0
1978
- });
1979
- }
1980
- logDLQOperation("Moving", processedCount, queueName);
1981
- scheduleProcessing(queueName, queues[queueName]);
1982
- if (saveQueueState) {
1983
- await saveQueueState(queueName, queues[queueName]);
1984
- }
1985
- return reply.status(200).send({
1986
- status: "success",
1987
- message: `Moved ${processedCount} messages from DLQ to processing queue`,
1988
- processed: processedCount
1989
- });
1990
- };
1991
- var createPurgeDLQHandler = (queues, saveQueueState) => async (request, reply) => {
1992
- const queueName = request.params.queue;
1993
- if (!queues[queueName]) {
1994
- return reply.status(404).send({ error: "Queue not found" });
1995
- }
1996
- const purgedCount = purgeDLQ(queues[queueName]);
1997
- if (purgedCount === 0) {
1998
- return reply.status(200).send({
1999
- status: "success",
2000
- message: "No messages in DLQ to purge",
2001
- purged: 0
2002
- });
2003
- }
2004
- logDLQOperation("Purging", purgedCount, queueName);
2005
- if (saveQueueState) {
2006
- await saveQueueState(queueName, queues[queueName]);
2007
- }
2008
- return reply.status(200).send({
2009
- status: "success",
2010
- message: `Purged ${purgedCount} messages from DLQ`,
2011
- purged: purgedCount
2012
- });
2013
- };
2014
- var registerQueueRoutes = (app, prefix = "", queues, config, scheduleProcessing, processBatch, saveQueueState) => {
2015
- app.get(`/${prefix}/dashboard`, createDashboardHandler(queues, config));
2016
- app.get(`/${prefix}/:queue`, createQueueDetailsHandler(queues, config));
1244
+ );
1245
+ app.get(
1246
+ `/${prefix}/:queue`,
1247
+ async (request, reply) => {
1248
+ const queueName = request.params.queue;
1249
+ const summary = app.queues.getQueueSummary(queueName);
1250
+ if (summary === null) {
1251
+ return reply.status(404).send({ error: "Queue not found" });
1252
+ }
1253
+ return reply.status(200).send(summary);
1254
+ }
1255
+ );
2017
1256
  app.post(
2018
1257
  `/${prefix}/:queue`,
2019
- createEnqueueMessageHandler(queues, config, scheduleProcessing, processBatch, saveQueueState)
1258
+ async (request, reply) => {
1259
+ const queueName = request.params.queue;
1260
+ const result = await app.queues.enqueueMessage(queueName, request.body, request.headers);
1261
+ if (result === null) {
1262
+ return reply.status(404).send({ error: "Queue not found" });
1263
+ }
1264
+ return reply.status(200).send(result);
1265
+ }
2020
1266
  );
2021
1267
  app.get(
2022
1268
  `/${prefix}/:queue/process-dlq`,
2023
- createProcessDLQHandler(queues, scheduleProcessing, saveQueueState)
1269
+ async (request, reply) => {
1270
+ const queueName = request.params.queue;
1271
+ const result = await app.queues.processDlq(queueName);
1272
+ if (result === null) {
1273
+ return reply.status(404).send(result);
1274
+ }
1275
+ return reply.status(200).send(result);
1276
+ }
2024
1277
  );
2025
- app.get(
2026
- `/${prefix}/:queue/purge-dlg`,
2027
- createPurgeDLQHandler(queues, saveQueueState)
1278
+ app.post(
1279
+ `/${prefix}/:queue/purge-dlq`,
1280
+ async (request, reply) => {
1281
+ const queueName = request.params.queue;
1282
+ const result = await app.queues.purgeDlq(queueName);
1283
+ if (result === null) {
1284
+ return reply.status(404).send({ error: "Queue not found" });
1285
+ }
1286
+ return reply.status(200).send(result);
1287
+ }
2028
1288
  );
2029
1289
  };
2030
1290
 
2031
1291
  // src/queue-plugin/decorator.ts
1292
+ import chalk4 from "chalk";
1293
+ import logSymbols3 from "log-symbols";
2032
1294
  var isValidQueueName = (queueName) => {
2033
1295
  return typeof queueName === "string" && queueName.length > 0 && /^[a-zA-Z0-9_-]+$/.test(queueName);
2034
1296
  };
@@ -2036,7 +1298,9 @@ var createQueueManager = ({
2036
1298
  config,
2037
1299
  queues,
2038
1300
  saveQueueState,
2039
- loadQueueState
1301
+ loadQueueState,
1302
+ scheduleProcessing,
1303
+ processBatch
2040
1304
  }) => {
2041
1305
  const validateQueueName = (queueName) => {
2042
1306
  if (!queueName || typeof queueName !== "string") {
@@ -2051,22 +1315,22 @@ var createQueueManager = ({
2051
1315
  throw new Error("Handler must be a function");
2052
1316
  }
2053
1317
  };
2054
- const addQueue = async (queueName, handler) => {
1318
+ const addQueue = async (queueName, handler, module) => {
2055
1319
  try {
2056
1320
  validateQueueName(queueName);
2057
1321
  validateHandler(handler);
2058
1322
  if (queues[queueName]) {
2059
- logger.warn(`${symbols_exports.warning} ${source_default.yellow("Queue already exists:")} ${source_default.magenta(queueName)}.`);
1323
+ logger.warn(`${logSymbols3.warning} ${chalk4.yellow("Queue already exists:")} ${chalk4.magenta(queueName)}.`);
2060
1324
  return;
2061
1325
  }
2062
- queues[queueName] = createQueueService(handler);
1326
+ queues[queueName] = createQueueService(handler, module);
2063
1327
  if (config.persistence.enabled && loadQueueState) {
2064
1328
  await loadQueueState(queueName);
2065
1329
  }
2066
- logger.info(`${symbols_exports.success} ${source_default.green("Queue added:")} ${source_default.magenta(queueName)}`);
2067
- } catch (error2) {
2068
- logger.error(`${symbols_exports.error} ${source_default.red("Failed to add queue")} ${source_default.magenta(queueName)}: ${error2.message}`);
2069
- throw error2;
1330
+ logger.info(`${logSymbols3.success} ${chalk4.green("Queue added:")} ${chalk4.magenta(queueName)}`);
1331
+ } catch (error) {
1332
+ logger.error(`${logSymbols3.error} ${chalk4.red("Failed to add queue")} ${chalk4.magenta(queueName)}: ${error.message}`);
1333
+ throw error;
2070
1334
  }
2071
1335
  };
2072
1336
  const removeQueue = async (queueName) => {
@@ -2078,7 +1342,7 @@ var createQueueManager = ({
2078
1342
  const queueService = queues[queueName];
2079
1343
  const totalMessages = queueService.incoming.length + queueService.processing.length;
2080
1344
  if (totalMessages > 0) {
2081
- logger.warn(`${symbols_exports.warning} ${source_default.yellow("Removing queue with")} ${source_default.red(totalMessages)} ${source_default.yellow("pending messages:")} ${source_default.magenta(queueName)}`);
1345
+ logger.warn(`${logSymbols3.warning} ${chalk4.yellow("Removing queue with")} ${chalk4.red(totalMessages)} ${chalk4.yellow("pending messages:")} ${chalk4.magenta(queueName)}`);
2082
1346
  }
2083
1347
  if (queueService.timeoutId) {
2084
1348
  clearTimeout(queueService.timeoutId);
@@ -2087,10 +1351,10 @@ var createQueueManager = ({
2087
1351
  await saveQueueState(queueName, queueService);
2088
1352
  }
2089
1353
  delete queues[queueName];
2090
- logger.info(`${symbols_exports.success} ${source_default.green("Queue removed:")} ${source_default.magenta(queueName)}`);
2091
- } catch (error2) {
2092
- logger.error(`${symbols_exports.error} ${source_default.red("Failed to remove queue")} ${source_default.magenta(queueName)}: ${error2.message}`);
2093
- throw error2;
1354
+ logger.info(`${logSymbols3.success} ${chalk4.green("Queue removed:")} ${chalk4.magenta(queueName)}`);
1355
+ } catch (error) {
1356
+ logger.error(`${logSymbols3.error} ${chalk4.red("Failed to remove queue")} ${chalk4.magenta(queueName)}: ${error.message}`);
1357
+ throw error;
2094
1358
  }
2095
1359
  };
2096
1360
  const hasQueue = (queueName) => {
@@ -2101,8 +1365,11 @@ var createQueueManager = ({
2101
1365
  return false;
2102
1366
  }
2103
1367
  };
2104
- const listQueues = () => {
2105
- return Object.keys(queues).sort();
1368
+ const listQueues = (module) => {
1369
+ return Object.keys(queues).filter((queueName) => {
1370
+ const queueService = queues[queueName];
1371
+ return !module || queueService.module === module;
1372
+ }).sort();
2106
1373
  };
2107
1374
  const getQueueStats = (queueName) => {
2108
1375
  try {
@@ -2115,13 +1382,97 @@ var createQueueManager = ({
2115
1382
  const getQueuesMap = () => {
2116
1383
  return { ...queues };
2117
1384
  };
1385
+ const getConfig = () => config;
1386
+ const getDashboardSummary = () => createDashboardSummary(queues, config);
1387
+ const getQueueSummary = (queueName) => {
1388
+ if (!queues[queueName]) {
1389
+ return null;
1390
+ }
1391
+ const queue = queues[queueName];
1392
+ const stats = createQueueSummary(queue, config);
1393
+ return {
1394
+ stats,
1395
+ messages: {
1396
+ incoming: queue.incoming,
1397
+ processing: queue.processing,
1398
+ dlq: queue.dlq
1399
+ }
1400
+ };
1401
+ };
1402
+ const enqueueMessage = async (queueName, body, attributes) => {
1403
+ if (!queues[queueName]) {
1404
+ return null;
1405
+ }
1406
+ const message = createQueueMessage(body, attributes);
1407
+ queues[queueName].incoming.push(message);
1408
+ scheduleProcessing(queueName, queues[queueName]);
1409
+ handleImmediateProcessing(queues[queueName], config, processBatch, queueName);
1410
+ if (config.persistence.enabled && saveQueueState) {
1411
+ await saveQueueState(queueName, queues[queueName]);
1412
+ }
1413
+ return {
1414
+ id: message.id,
1415
+ queueName
1416
+ };
1417
+ };
1418
+ const processDlq = async (queueName) => {
1419
+ if (!queues[queueName]) {
1420
+ return null;
1421
+ }
1422
+ const processedCount = moveDLQToIncoming(queues[queueName]);
1423
+ if (processedCount === 0) {
1424
+ return {
1425
+ status: "success",
1426
+ message: "No messages in DLQ to process",
1427
+ processed: 0
1428
+ };
1429
+ }
1430
+ logDLQOperation("Moving", processedCount, queueName);
1431
+ scheduleProcessing(queueName, queues[queueName]);
1432
+ if (saveQueueState) {
1433
+ await saveQueueState(queueName, queues[queueName]);
1434
+ }
1435
+ return {
1436
+ status: "success",
1437
+ message: `Moved ${processedCount} messages from DLQ to processing queue`,
1438
+ processed: processedCount
1439
+ };
1440
+ };
1441
+ const purgeDlq = async (queueName) => {
1442
+ if (!queues[queueName]) {
1443
+ return null;
1444
+ }
1445
+ const purgedCount = purgeDLQ(queues[queueName]);
1446
+ if (purgedCount === 0) {
1447
+ return {
1448
+ status: "success",
1449
+ message: "No messages in DLQ to purge",
1450
+ purged: 0
1451
+ };
1452
+ }
1453
+ logDLQOperation("Purging", purgedCount, queueName);
1454
+ if (saveQueueState) {
1455
+ await saveQueueState(queueName, queues[queueName]);
1456
+ }
1457
+ return {
1458
+ status: "success",
1459
+ message: `Purged ${purgedCount} messages from DLQ`,
1460
+ purged: purgedCount
1461
+ };
1462
+ };
2118
1463
  return {
2119
1464
  addQueue,
2120
1465
  removeQueue,
2121
1466
  hasQueue,
2122
1467
  listQueues,
2123
1468
  getQueueStats,
2124
- getQueuesMap
1469
+ getQueuesMap,
1470
+ getConfig,
1471
+ getDashboardSummary,
1472
+ getQueueSummary,
1473
+ enqueueMessage,
1474
+ processDlq,
1475
+ purgeDlq
2125
1476
  };
2126
1477
  };
2127
1478
  var createQueueDecorator = (queueManager) => (app) => {
@@ -2129,7 +1480,7 @@ var createQueueDecorator = (queueManager) => (app) => {
2129
1480
  };
2130
1481
 
2131
1482
  // src/queue-plugin/plugin.ts
2132
- var queuesPlugin = (0, import_fastify_plugin.default)(async (app, options) => {
1483
+ var queuesPlugin = fsPlugin(async (app, options) => {
2133
1484
  const config = mergeConfig(DEFAULT_CONFIG, options.config);
2134
1485
  const queues = {};
2135
1486
  const processMessage = createProcessMessageHandler(config);
@@ -2156,18 +1507,15 @@ var queuesPlugin = (0, import_fastify_plugin.default)(async (app, options) => {
2156
1507
  config,
2157
1508
  queues,
2158
1509
  saveQueueState: saveQueueState ? (queueName) => saveQueueState(queueName, queues[queueName]) : void 0,
2159
- loadQueueState
1510
+ loadQueueState,
1511
+ scheduleProcessing,
1512
+ processBatch
2160
1513
  });
2161
1514
  const decorateQueues = createQueueDecorator(queueManager);
2162
1515
  decorateQueues(app);
2163
1516
  registerQueueRoutes(
2164
1517
  app,
2165
- options.prefix,
2166
- queues,
2167
- config,
2168
- scheduleProcessing,
2169
- processBatch,
2170
- saveQueueState ? (queueName) => saveQueueState(queueName, queues[queueName]) : void 0
1518
+ options.prefix
2171
1519
  );
2172
1520
  await initializePersistence();
2173
1521
  });