@cloudnux/local-cloud-provider 0.2.1 → 0.3.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.
- package/dist/dev-console-plugin/index.d.ts +177 -0
- package/dist/dev-console-plugin/index.js +3047 -0
- package/dist/dev-console-plugin/index.js.map +1 -0
- package/dist/index.js +79 -53988
- package/dist/index.js.map +1 -1
- package/dist/queue-plugin/index.d.ts +29 -2
- package/dist/queue-plugin/index.js +231 -893
- package/dist/queue-plugin/index.js.map +1 -1
- package/dist/schedule-plugin/index.d.ts +3 -1
- package/dist/schedule-plugin/index.js +129 -8520
- package/dist/schedule-plugin/index.js.map +1 -1
- package/package.json +12 -10
- package/dist/index.d.mts +0 -11
- package/dist/index.mjs +0 -55728
- package/dist/index.mjs.map +0 -1
- package/dist/queue-plugin/index.d.mts +0 -83
- package/dist/queue-plugin/index.mjs +0 -2190
- package/dist/queue-plugin/index.mjs.map +0 -1
- package/dist/schedule-plugin/index.d.mts +0 -111
- package/dist/schedule-plugin/index.mjs +0 -10330
- package/dist/schedule-plugin/index.mjs.map +0 -1
|
@@ -1,718 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
var __export = (target, all) => {
|
|
12
|
-
for (var name in all)
|
|
13
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from))
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
31
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
-
|
|
33
|
-
// ../../../node_modules/fastify-plugin/lib/getPluginName.js
|
|
34
|
-
var require_getPluginName = __commonJS({
|
|
35
|
-
"../../../node_modules/fastify-plugin/lib/getPluginName.js"(exports2, module2) {
|
|
36
|
-
"use strict";
|
|
37
|
-
var fpStackTracePattern = /at\s{1}(?:.*\.)?plugin\s{1}.*\n\s*(.*)/;
|
|
38
|
-
var fileNamePattern = /(\w*(\.\w*)*)\..*/;
|
|
39
|
-
module2.exports = function getPluginName(fn) {
|
|
40
|
-
if (fn.name.length > 0) return fn.name;
|
|
41
|
-
const stackTraceLimit = Error.stackTraceLimit;
|
|
42
|
-
Error.stackTraceLimit = 10;
|
|
43
|
-
try {
|
|
44
|
-
throw new Error("anonymous function");
|
|
45
|
-
} catch (e) {
|
|
46
|
-
Error.stackTraceLimit = stackTraceLimit;
|
|
47
|
-
return extractPluginName(e.stack);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
function extractPluginName(stack) {
|
|
51
|
-
const m = stack.match(fpStackTracePattern);
|
|
52
|
-
return m ? m[1].split(/[/\\]/).slice(-1)[0].match(fileNamePattern)[1] : "anonymous";
|
|
53
|
-
}
|
|
54
|
-
module2.exports.extractPluginName = extractPluginName;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// ../../../node_modules/fastify-plugin/lib/toCamelCase.js
|
|
59
|
-
var require_toCamelCase = __commonJS({
|
|
60
|
-
"../../../node_modules/fastify-plugin/lib/toCamelCase.js"(exports2, module2) {
|
|
61
|
-
"use strict";
|
|
62
|
-
module2.exports = function toCamelCase(name) {
|
|
63
|
-
if (name[0] === "@") {
|
|
64
|
-
name = name.slice(1).replace("/", "-");
|
|
65
|
-
}
|
|
66
|
-
return name.replace(/-(.)/g, function(match, g1) {
|
|
67
|
-
return g1.toUpperCase();
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// ../../../node_modules/fastify-plugin/plugin.js
|
|
74
|
-
var require_plugin = __commonJS({
|
|
75
|
-
"../../../node_modules/fastify-plugin/plugin.js"(exports2, module2) {
|
|
76
|
-
"use strict";
|
|
77
|
-
var getPluginName = require_getPluginName();
|
|
78
|
-
var toCamelCase = require_toCamelCase();
|
|
79
|
-
var count = 0;
|
|
80
|
-
function plugin(fn, options = {}) {
|
|
81
|
-
let autoName = false;
|
|
82
|
-
if (fn.default !== void 0) {
|
|
83
|
-
fn = fn.default;
|
|
84
|
-
}
|
|
85
|
-
if (typeof fn !== "function") {
|
|
86
|
-
throw new TypeError(
|
|
87
|
-
`fastify-plugin expects a function, instead got a '${typeof fn}'`
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
if (typeof options === "string") {
|
|
91
|
-
options = {
|
|
92
|
-
fastify: options
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
if (typeof options !== "object" || Array.isArray(options) || options === null) {
|
|
96
|
-
throw new TypeError("The options object should be an object");
|
|
97
|
-
}
|
|
98
|
-
if (options.fastify !== void 0 && typeof options.fastify !== "string") {
|
|
99
|
-
throw new TypeError(`fastify-plugin expects a version string, instead got '${typeof options.fastify}'`);
|
|
100
|
-
}
|
|
101
|
-
if (!options.name) {
|
|
102
|
-
autoName = true;
|
|
103
|
-
options.name = getPluginName(fn) + "-auto-" + count++;
|
|
104
|
-
}
|
|
105
|
-
fn[Symbol.for("skip-override")] = options.encapsulate !== true;
|
|
106
|
-
fn[Symbol.for("fastify.display-name")] = options.name;
|
|
107
|
-
fn[Symbol.for("plugin-meta")] = options;
|
|
108
|
-
if (!fn.default) {
|
|
109
|
-
fn.default = fn;
|
|
110
|
-
}
|
|
111
|
-
const camelCase = toCamelCase(options.name);
|
|
112
|
-
if (!autoName && !fn[camelCase]) {
|
|
113
|
-
fn[camelCase] = fn;
|
|
114
|
-
}
|
|
115
|
-
return fn;
|
|
116
|
-
}
|
|
117
|
-
module2.exports = plugin;
|
|
118
|
-
module2.exports.default = plugin;
|
|
119
|
-
module2.exports.fastifyPlugin = plugin;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// src/queue-plugin/index.ts
|
|
124
|
-
var index_exports = {};
|
|
125
|
-
__export(index_exports, {
|
|
126
|
-
queuesPlugin: () => queuesPlugin
|
|
127
|
-
});
|
|
128
|
-
module.exports = __toCommonJS(index_exports);
|
|
129
|
-
|
|
130
1
|
// src/queue-plugin/plugin.ts
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// ../../../node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
134
|
-
var ANSI_BACKGROUND_OFFSET = 10;
|
|
135
|
-
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
136
|
-
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
137
|
-
var wrapAnsi16m = (offset = 0) => (red2, green2, blue2) => `\x1B[${38 + offset};2;${red2};${green2};${blue2}m`;
|
|
138
|
-
var styles = {
|
|
139
|
-
modifier: {
|
|
140
|
-
reset: [0, 0],
|
|
141
|
-
// 21 isn't widely supported and 22 does the same thing
|
|
142
|
-
bold: [1, 22],
|
|
143
|
-
dim: [2, 22],
|
|
144
|
-
italic: [3, 23],
|
|
145
|
-
underline: [4, 24],
|
|
146
|
-
overline: [53, 55],
|
|
147
|
-
inverse: [7, 27],
|
|
148
|
-
hidden: [8, 28],
|
|
149
|
-
strikethrough: [9, 29]
|
|
150
|
-
},
|
|
151
|
-
color: {
|
|
152
|
-
black: [30, 39],
|
|
153
|
-
red: [31, 39],
|
|
154
|
-
green: [32, 39],
|
|
155
|
-
yellow: [33, 39],
|
|
156
|
-
blue: [34, 39],
|
|
157
|
-
magenta: [35, 39],
|
|
158
|
-
cyan: [36, 39],
|
|
159
|
-
white: [37, 39],
|
|
160
|
-
// Bright color
|
|
161
|
-
blackBright: [90, 39],
|
|
162
|
-
gray: [90, 39],
|
|
163
|
-
// Alias of `blackBright`
|
|
164
|
-
grey: [90, 39],
|
|
165
|
-
// Alias of `blackBright`
|
|
166
|
-
redBright: [91, 39],
|
|
167
|
-
greenBright: [92, 39],
|
|
168
|
-
yellowBright: [93, 39],
|
|
169
|
-
blueBright: [94, 39],
|
|
170
|
-
magentaBright: [95, 39],
|
|
171
|
-
cyanBright: [96, 39],
|
|
172
|
-
whiteBright: [97, 39]
|
|
173
|
-
},
|
|
174
|
-
bgColor: {
|
|
175
|
-
bgBlack: [40, 49],
|
|
176
|
-
bgRed: [41, 49],
|
|
177
|
-
bgGreen: [42, 49],
|
|
178
|
-
bgYellow: [43, 49],
|
|
179
|
-
bgBlue: [44, 49],
|
|
180
|
-
bgMagenta: [45, 49],
|
|
181
|
-
bgCyan: [46, 49],
|
|
182
|
-
bgWhite: [47, 49],
|
|
183
|
-
// Bright color
|
|
184
|
-
bgBlackBright: [100, 49],
|
|
185
|
-
bgGray: [100, 49],
|
|
186
|
-
// Alias of `bgBlackBright`
|
|
187
|
-
bgGrey: [100, 49],
|
|
188
|
-
// Alias of `bgBlackBright`
|
|
189
|
-
bgRedBright: [101, 49],
|
|
190
|
-
bgGreenBright: [102, 49],
|
|
191
|
-
bgYellowBright: [103, 49],
|
|
192
|
-
bgBlueBright: [104, 49],
|
|
193
|
-
bgMagentaBright: [105, 49],
|
|
194
|
-
bgCyanBright: [106, 49],
|
|
195
|
-
bgWhiteBright: [107, 49]
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
var modifierNames = Object.keys(styles.modifier);
|
|
199
|
-
var foregroundColorNames = Object.keys(styles.color);
|
|
200
|
-
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
201
|
-
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
202
|
-
function assembleStyles() {
|
|
203
|
-
const codes = /* @__PURE__ */ new Map();
|
|
204
|
-
for (const [groupName, group] of Object.entries(styles)) {
|
|
205
|
-
for (const [styleName, style] of Object.entries(group)) {
|
|
206
|
-
styles[styleName] = {
|
|
207
|
-
open: `\x1B[${style[0]}m`,
|
|
208
|
-
close: `\x1B[${style[1]}m`
|
|
209
|
-
};
|
|
210
|
-
group[styleName] = styles[styleName];
|
|
211
|
-
codes.set(style[0], style[1]);
|
|
212
|
-
}
|
|
213
|
-
Object.defineProperty(styles, groupName, {
|
|
214
|
-
value: group,
|
|
215
|
-
enumerable: false
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
Object.defineProperty(styles, "codes", {
|
|
219
|
-
value: codes,
|
|
220
|
-
enumerable: false
|
|
221
|
-
});
|
|
222
|
-
styles.color.close = "\x1B[39m";
|
|
223
|
-
styles.bgColor.close = "\x1B[49m";
|
|
224
|
-
styles.color.ansi = wrapAnsi16();
|
|
225
|
-
styles.color.ansi256 = wrapAnsi256();
|
|
226
|
-
styles.color.ansi16m = wrapAnsi16m();
|
|
227
|
-
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
228
|
-
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
229
|
-
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
230
|
-
Object.defineProperties(styles, {
|
|
231
|
-
rgbToAnsi256: {
|
|
232
|
-
value(red2, green2, blue2) {
|
|
233
|
-
if (red2 === green2 && green2 === blue2) {
|
|
234
|
-
if (red2 < 8) {
|
|
235
|
-
return 16;
|
|
236
|
-
}
|
|
237
|
-
if (red2 > 248) {
|
|
238
|
-
return 231;
|
|
239
|
-
}
|
|
240
|
-
return Math.round((red2 - 8) / 247 * 24) + 232;
|
|
241
|
-
}
|
|
242
|
-
return 16 + 36 * Math.round(red2 / 255 * 5) + 6 * Math.round(green2 / 255 * 5) + Math.round(blue2 / 255 * 5);
|
|
243
|
-
},
|
|
244
|
-
enumerable: false
|
|
245
|
-
},
|
|
246
|
-
hexToRgb: {
|
|
247
|
-
value(hex) {
|
|
248
|
-
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
249
|
-
if (!matches) {
|
|
250
|
-
return [0, 0, 0];
|
|
251
|
-
}
|
|
252
|
-
let [colorString] = matches;
|
|
253
|
-
if (colorString.length === 3) {
|
|
254
|
-
colorString = [...colorString].map((character) => character + character).join("");
|
|
255
|
-
}
|
|
256
|
-
const integer = Number.parseInt(colorString, 16);
|
|
257
|
-
return [
|
|
258
|
-
/* eslint-disable no-bitwise */
|
|
259
|
-
integer >> 16 & 255,
|
|
260
|
-
integer >> 8 & 255,
|
|
261
|
-
integer & 255
|
|
262
|
-
/* eslint-enable no-bitwise */
|
|
263
|
-
];
|
|
264
|
-
},
|
|
265
|
-
enumerable: false
|
|
266
|
-
},
|
|
267
|
-
hexToAnsi256: {
|
|
268
|
-
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
269
|
-
enumerable: false
|
|
270
|
-
},
|
|
271
|
-
ansi256ToAnsi: {
|
|
272
|
-
value(code) {
|
|
273
|
-
if (code < 8) {
|
|
274
|
-
return 30 + code;
|
|
275
|
-
}
|
|
276
|
-
if (code < 16) {
|
|
277
|
-
return 90 + (code - 8);
|
|
278
|
-
}
|
|
279
|
-
let red2;
|
|
280
|
-
let green2;
|
|
281
|
-
let blue2;
|
|
282
|
-
if (code >= 232) {
|
|
283
|
-
red2 = ((code - 232) * 10 + 8) / 255;
|
|
284
|
-
green2 = red2;
|
|
285
|
-
blue2 = red2;
|
|
286
|
-
} else {
|
|
287
|
-
code -= 16;
|
|
288
|
-
const remainder = code % 36;
|
|
289
|
-
red2 = Math.floor(code / 36) / 5;
|
|
290
|
-
green2 = Math.floor(remainder / 6) / 5;
|
|
291
|
-
blue2 = remainder % 6 / 5;
|
|
292
|
-
}
|
|
293
|
-
const value = Math.max(red2, green2, blue2) * 2;
|
|
294
|
-
if (value === 0) {
|
|
295
|
-
return 30;
|
|
296
|
-
}
|
|
297
|
-
let result = 30 + (Math.round(blue2) << 2 | Math.round(green2) << 1 | Math.round(red2));
|
|
298
|
-
if (value === 2) {
|
|
299
|
-
result += 60;
|
|
300
|
-
}
|
|
301
|
-
return result;
|
|
302
|
-
},
|
|
303
|
-
enumerable: false
|
|
304
|
-
},
|
|
305
|
-
rgbToAnsi: {
|
|
306
|
-
value: (red2, green2, blue2) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red2, green2, blue2)),
|
|
307
|
-
enumerable: false
|
|
308
|
-
},
|
|
309
|
-
hexToAnsi: {
|
|
310
|
-
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
311
|
-
enumerable: false
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
return styles;
|
|
315
|
-
}
|
|
316
|
-
var ansiStyles = assembleStyles();
|
|
317
|
-
var ansi_styles_default = ansiStyles;
|
|
318
|
-
|
|
319
|
-
// ../../../node_modules/chalk/source/vendor/supports-color/index.js
|
|
320
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
321
|
-
var import_node_os = __toESM(require("os"), 1);
|
|
322
|
-
var import_node_tty = __toESM(require("tty"), 1);
|
|
323
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
|
324
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
325
|
-
const position = argv.indexOf(prefix + flag);
|
|
326
|
-
const terminatorPosition = argv.indexOf("--");
|
|
327
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
328
|
-
}
|
|
329
|
-
var { env } = import_node_process.default;
|
|
330
|
-
var flagForceColor;
|
|
331
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
332
|
-
flagForceColor = 0;
|
|
333
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
334
|
-
flagForceColor = 1;
|
|
335
|
-
}
|
|
336
|
-
function envForceColor() {
|
|
337
|
-
if ("FORCE_COLOR" in env) {
|
|
338
|
-
if (env.FORCE_COLOR === "true") {
|
|
339
|
-
return 1;
|
|
340
|
-
}
|
|
341
|
-
if (env.FORCE_COLOR === "false") {
|
|
342
|
-
return 0;
|
|
343
|
-
}
|
|
344
|
-
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
function translateLevel(level) {
|
|
348
|
-
if (level === 0) {
|
|
349
|
-
return false;
|
|
350
|
-
}
|
|
351
|
-
return {
|
|
352
|
-
level,
|
|
353
|
-
hasBasic: true,
|
|
354
|
-
has256: level >= 2,
|
|
355
|
-
has16m: level >= 3
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
359
|
-
const noFlagForceColor = envForceColor();
|
|
360
|
-
if (noFlagForceColor !== void 0) {
|
|
361
|
-
flagForceColor = noFlagForceColor;
|
|
362
|
-
}
|
|
363
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
364
|
-
if (forceColor === 0) {
|
|
365
|
-
return 0;
|
|
366
|
-
}
|
|
367
|
-
if (sniffFlags) {
|
|
368
|
-
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
369
|
-
return 3;
|
|
370
|
-
}
|
|
371
|
-
if (hasFlag("color=256")) {
|
|
372
|
-
return 2;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
376
|
-
return 1;
|
|
377
|
-
}
|
|
378
|
-
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
379
|
-
return 0;
|
|
380
|
-
}
|
|
381
|
-
const min = forceColor || 0;
|
|
382
|
-
if (env.TERM === "dumb") {
|
|
383
|
-
return min;
|
|
384
|
-
}
|
|
385
|
-
if (import_node_process.default.platform === "win32") {
|
|
386
|
-
const osRelease = import_node_os.default.release().split(".");
|
|
387
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
388
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
389
|
-
}
|
|
390
|
-
return 1;
|
|
391
|
-
}
|
|
392
|
-
if ("CI" in env) {
|
|
393
|
-
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
|
394
|
-
return 3;
|
|
395
|
-
}
|
|
396
|
-
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
397
|
-
return 1;
|
|
398
|
-
}
|
|
399
|
-
return min;
|
|
400
|
-
}
|
|
401
|
-
if ("TEAMCITY_VERSION" in env) {
|
|
402
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
403
|
-
}
|
|
404
|
-
if (env.COLORTERM === "truecolor") {
|
|
405
|
-
return 3;
|
|
406
|
-
}
|
|
407
|
-
if (env.TERM === "xterm-kitty") {
|
|
408
|
-
return 3;
|
|
409
|
-
}
|
|
410
|
-
if ("TERM_PROGRAM" in env) {
|
|
411
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
412
|
-
switch (env.TERM_PROGRAM) {
|
|
413
|
-
case "iTerm.app": {
|
|
414
|
-
return version >= 3 ? 3 : 2;
|
|
415
|
-
}
|
|
416
|
-
case "Apple_Terminal": {
|
|
417
|
-
return 2;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
422
|
-
return 2;
|
|
423
|
-
}
|
|
424
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
425
|
-
return 1;
|
|
426
|
-
}
|
|
427
|
-
if ("COLORTERM" in env) {
|
|
428
|
-
return 1;
|
|
429
|
-
}
|
|
430
|
-
return min;
|
|
431
|
-
}
|
|
432
|
-
function createSupportsColor(stream, options = {}) {
|
|
433
|
-
const level = _supportsColor(stream, {
|
|
434
|
-
streamIsTTY: stream && stream.isTTY,
|
|
435
|
-
...options
|
|
436
|
-
});
|
|
437
|
-
return translateLevel(level);
|
|
438
|
-
}
|
|
439
|
-
var supportsColor = {
|
|
440
|
-
stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
|
|
441
|
-
stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
|
|
442
|
-
};
|
|
443
|
-
var supports_color_default = supportsColor;
|
|
2
|
+
import fsPlugin from "fastify-plugin";
|
|
444
3
|
|
|
445
|
-
//
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
if (index === -1) {
|
|
449
|
-
return string;
|
|
450
|
-
}
|
|
451
|
-
const substringLength = substring.length;
|
|
452
|
-
let endIndex = 0;
|
|
453
|
-
let returnValue = "";
|
|
454
|
-
do {
|
|
455
|
-
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
456
|
-
endIndex = index + substringLength;
|
|
457
|
-
index = string.indexOf(substring, endIndex);
|
|
458
|
-
} while (index !== -1);
|
|
459
|
-
returnValue += string.slice(endIndex);
|
|
460
|
-
return returnValue;
|
|
461
|
-
}
|
|
462
|
-
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
463
|
-
let endIndex = 0;
|
|
464
|
-
let returnValue = "";
|
|
465
|
-
do {
|
|
466
|
-
const gotCR = string[index - 1] === "\r";
|
|
467
|
-
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
468
|
-
endIndex = index + 1;
|
|
469
|
-
index = string.indexOf("\n", endIndex);
|
|
470
|
-
} while (index !== -1);
|
|
471
|
-
returnValue += string.slice(endIndex);
|
|
472
|
-
return returnValue;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// ../../../node_modules/chalk/source/index.js
|
|
476
|
-
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
477
|
-
var GENERATOR = Symbol("GENERATOR");
|
|
478
|
-
var STYLER = Symbol("STYLER");
|
|
479
|
-
var IS_EMPTY = Symbol("IS_EMPTY");
|
|
480
|
-
var levelMapping = [
|
|
481
|
-
"ansi",
|
|
482
|
-
"ansi",
|
|
483
|
-
"ansi256",
|
|
484
|
-
"ansi16m"
|
|
485
|
-
];
|
|
486
|
-
var styles2 = /* @__PURE__ */ Object.create(null);
|
|
487
|
-
var applyOptions = (object, options = {}) => {
|
|
488
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
489
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
490
|
-
}
|
|
491
|
-
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
492
|
-
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
493
|
-
};
|
|
494
|
-
var chalkFactory = (options) => {
|
|
495
|
-
const chalk2 = (...strings) => strings.join(" ");
|
|
496
|
-
applyOptions(chalk2, options);
|
|
497
|
-
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
498
|
-
return chalk2;
|
|
499
|
-
};
|
|
500
|
-
function createChalk(options) {
|
|
501
|
-
return chalkFactory(options);
|
|
502
|
-
}
|
|
503
|
-
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
504
|
-
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
505
|
-
styles2[styleName] = {
|
|
506
|
-
get() {
|
|
507
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
508
|
-
Object.defineProperty(this, styleName, { value: builder });
|
|
509
|
-
return builder;
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
styles2.visible = {
|
|
514
|
-
get() {
|
|
515
|
-
const builder = createBuilder(this, this[STYLER], true);
|
|
516
|
-
Object.defineProperty(this, "visible", { value: builder });
|
|
517
|
-
return builder;
|
|
518
|
-
}
|
|
519
|
-
};
|
|
520
|
-
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
521
|
-
if (model === "rgb") {
|
|
522
|
-
if (level === "ansi16m") {
|
|
523
|
-
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
524
|
-
}
|
|
525
|
-
if (level === "ansi256") {
|
|
526
|
-
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
527
|
-
}
|
|
528
|
-
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
529
|
-
}
|
|
530
|
-
if (model === "hex") {
|
|
531
|
-
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
532
|
-
}
|
|
533
|
-
return ansi_styles_default[type][model](...arguments_);
|
|
534
|
-
};
|
|
535
|
-
var usedModels = ["rgb", "hex", "ansi256"];
|
|
536
|
-
for (const model of usedModels) {
|
|
537
|
-
styles2[model] = {
|
|
538
|
-
get() {
|
|
539
|
-
const { level } = this;
|
|
540
|
-
return function(...arguments_) {
|
|
541
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
542
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
547
|
-
styles2[bgModel] = {
|
|
548
|
-
get() {
|
|
549
|
-
const { level } = this;
|
|
550
|
-
return function(...arguments_) {
|
|
551
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
552
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
553
|
-
};
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
var proto = Object.defineProperties(() => {
|
|
558
|
-
}, {
|
|
559
|
-
...styles2,
|
|
560
|
-
level: {
|
|
561
|
-
enumerable: true,
|
|
562
|
-
get() {
|
|
563
|
-
return this[GENERATOR].level;
|
|
564
|
-
},
|
|
565
|
-
set(level) {
|
|
566
|
-
this[GENERATOR].level = level;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
});
|
|
570
|
-
var createStyler = (open, close, parent) => {
|
|
571
|
-
let openAll;
|
|
572
|
-
let closeAll;
|
|
573
|
-
if (parent === void 0) {
|
|
574
|
-
openAll = open;
|
|
575
|
-
closeAll = close;
|
|
576
|
-
} else {
|
|
577
|
-
openAll = parent.openAll + open;
|
|
578
|
-
closeAll = close + parent.closeAll;
|
|
579
|
-
}
|
|
580
|
-
return {
|
|
581
|
-
open,
|
|
582
|
-
close,
|
|
583
|
-
openAll,
|
|
584
|
-
closeAll,
|
|
585
|
-
parent
|
|
586
|
-
};
|
|
587
|
-
};
|
|
588
|
-
var createBuilder = (self2, _styler, _isEmpty) => {
|
|
589
|
-
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
590
|
-
Object.setPrototypeOf(builder, proto);
|
|
591
|
-
builder[GENERATOR] = self2;
|
|
592
|
-
builder[STYLER] = _styler;
|
|
593
|
-
builder[IS_EMPTY] = _isEmpty;
|
|
594
|
-
return builder;
|
|
595
|
-
};
|
|
596
|
-
var applyStyle = (self2, string) => {
|
|
597
|
-
if (self2.level <= 0 || !string) {
|
|
598
|
-
return self2[IS_EMPTY] ? "" : string;
|
|
599
|
-
}
|
|
600
|
-
let styler = self2[STYLER];
|
|
601
|
-
if (styler === void 0) {
|
|
602
|
-
return string;
|
|
603
|
-
}
|
|
604
|
-
const { openAll, closeAll } = styler;
|
|
605
|
-
if (string.includes("\x1B")) {
|
|
606
|
-
while (styler !== void 0) {
|
|
607
|
-
string = stringReplaceAll(string, styler.close, styler.open);
|
|
608
|
-
styler = styler.parent;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
const lfIndex = string.indexOf("\n");
|
|
612
|
-
if (lfIndex !== -1) {
|
|
613
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
614
|
-
}
|
|
615
|
-
return openAll + string + closeAll;
|
|
616
|
-
};
|
|
617
|
-
Object.defineProperties(createChalk.prototype, styles2);
|
|
618
|
-
var chalk = createChalk();
|
|
619
|
-
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
620
|
-
var source_default = chalk;
|
|
621
|
-
|
|
622
|
-
// ../../../node_modules/log-symbols/symbols.js
|
|
623
|
-
var symbols_exports = {};
|
|
624
|
-
__export(symbols_exports, {
|
|
625
|
-
error: () => error,
|
|
626
|
-
info: () => info,
|
|
627
|
-
success: () => success,
|
|
628
|
-
warning: () => warning
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
// ../../../node_modules/yoctocolors/base.js
|
|
632
|
-
var import_node_tty2 = __toESM(require("tty"), 1);
|
|
633
|
-
var hasColors = import_node_tty2.default?.WriteStream?.prototype?.hasColors?.() ?? false;
|
|
634
|
-
var format = (open, close) => {
|
|
635
|
-
if (!hasColors) {
|
|
636
|
-
return (input) => input;
|
|
637
|
-
}
|
|
638
|
-
const openCode = `\x1B[${open}m`;
|
|
639
|
-
const closeCode = `\x1B[${close}m`;
|
|
640
|
-
return (input) => {
|
|
641
|
-
const string = input + "";
|
|
642
|
-
let index = string.indexOf(closeCode);
|
|
643
|
-
if (index === -1) {
|
|
644
|
-
return openCode + string + closeCode;
|
|
645
|
-
}
|
|
646
|
-
let result = openCode;
|
|
647
|
-
let lastIndex = 0;
|
|
648
|
-
while (index !== -1) {
|
|
649
|
-
result += string.slice(lastIndex, index) + openCode;
|
|
650
|
-
lastIndex = index + closeCode.length;
|
|
651
|
-
index = string.indexOf(closeCode, lastIndex);
|
|
652
|
-
}
|
|
653
|
-
result += string.slice(lastIndex) + closeCode;
|
|
654
|
-
return result;
|
|
655
|
-
};
|
|
656
|
-
};
|
|
657
|
-
var reset = format(0, 0);
|
|
658
|
-
var bold = format(1, 22);
|
|
659
|
-
var dim = format(2, 22);
|
|
660
|
-
var italic = format(3, 23);
|
|
661
|
-
var underline = format(4, 24);
|
|
662
|
-
var overline = format(53, 55);
|
|
663
|
-
var inverse = format(7, 27);
|
|
664
|
-
var hidden = format(8, 28);
|
|
665
|
-
var strikethrough = format(9, 29);
|
|
666
|
-
var black = format(30, 39);
|
|
667
|
-
var red = format(31, 39);
|
|
668
|
-
var green = format(32, 39);
|
|
669
|
-
var yellow = format(33, 39);
|
|
670
|
-
var blue = format(34, 39);
|
|
671
|
-
var magenta = format(35, 39);
|
|
672
|
-
var cyan = format(36, 39);
|
|
673
|
-
var white = format(37, 39);
|
|
674
|
-
var gray = format(90, 39);
|
|
675
|
-
var bgBlack = format(40, 49);
|
|
676
|
-
var bgRed = format(41, 49);
|
|
677
|
-
var bgGreen = format(42, 49);
|
|
678
|
-
var bgYellow = format(43, 49);
|
|
679
|
-
var bgBlue = format(44, 49);
|
|
680
|
-
var bgMagenta = format(45, 49);
|
|
681
|
-
var bgCyan = format(46, 49);
|
|
682
|
-
var bgWhite = format(47, 49);
|
|
683
|
-
var bgGray = format(100, 49);
|
|
684
|
-
var redBright = format(91, 39);
|
|
685
|
-
var greenBright = format(92, 39);
|
|
686
|
-
var yellowBright = format(93, 39);
|
|
687
|
-
var blueBright = format(94, 39);
|
|
688
|
-
var magentaBright = format(95, 39);
|
|
689
|
-
var cyanBright = format(96, 39);
|
|
690
|
-
var whiteBright = format(97, 39);
|
|
691
|
-
var bgRedBright = format(101, 49);
|
|
692
|
-
var bgGreenBright = format(102, 49);
|
|
693
|
-
var bgYellowBright = format(103, 49);
|
|
694
|
-
var bgBlueBright = format(104, 49);
|
|
695
|
-
var bgMagentaBright = format(105, 49);
|
|
696
|
-
var bgCyanBright = format(106, 49);
|
|
697
|
-
var bgWhiteBright = format(107, 49);
|
|
698
|
-
|
|
699
|
-
// ../../../node_modules/is-unicode-supported/index.js
|
|
700
|
-
var import_node_process2 = __toESM(require("process"), 1);
|
|
701
|
-
function isUnicodeSupported() {
|
|
702
|
-
const { env: env3 } = import_node_process2.default;
|
|
703
|
-
const { TERM, TERM_PROGRAM } = env3;
|
|
704
|
-
if (import_node_process2.default.platform !== "win32") {
|
|
705
|
-
return TERM !== "linux";
|
|
706
|
-
}
|
|
707
|
-
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";
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
// ../../../node_modules/log-symbols/symbols.js
|
|
711
|
-
var _isUnicodeSupported = isUnicodeSupported();
|
|
712
|
-
var info = blue(_isUnicodeSupported ? "\u2139" : "i");
|
|
713
|
-
var success = green(_isUnicodeSupported ? "\u2714" : "\u221A");
|
|
714
|
-
var warning = yellow(_isUnicodeSupported ? "\u26A0" : "\u203C");
|
|
715
|
-
var error = red(_isUnicodeSupported ? "\u2716" : "\xD7");
|
|
4
|
+
// src/queue-plugin/core.ts
|
|
5
|
+
import chalk2 from "chalk";
|
|
6
|
+
import logSymbols from "log-symbols";
|
|
716
7
|
|
|
717
8
|
// ../../../node_modules/lodash-es/_freeGlobal.js
|
|
718
9
|
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
@@ -724,8 +15,8 @@ var root = freeGlobal_default || freeSelf || Function("return this")();
|
|
|
724
15
|
var root_default = root;
|
|
725
16
|
|
|
726
17
|
// ../../../node_modules/lodash-es/_Symbol.js
|
|
727
|
-
var
|
|
728
|
-
var Symbol_default =
|
|
18
|
+
var Symbol = root_default.Symbol;
|
|
19
|
+
var Symbol_default = Symbol;
|
|
729
20
|
|
|
730
21
|
// ../../../node_modules/lodash-es/_getRawTag.js
|
|
731
22
|
var objectProto = Object.prototype;
|
|
@@ -1160,8 +451,8 @@ ListCache.prototype.set = listCacheSet_default;
|
|
|
1160
451
|
var ListCache_default = ListCache;
|
|
1161
452
|
|
|
1162
453
|
// ../../../node_modules/lodash-es/_Map.js
|
|
1163
|
-
var
|
|
1164
|
-
var Map_default =
|
|
454
|
+
var Map = getNative_default(root_default, "Map");
|
|
455
|
+
var Map_default = Map;
|
|
1165
456
|
|
|
1166
457
|
// ../../../node_modules/lodash-es/_mapCacheClear.js
|
|
1167
458
|
function mapCacheClear() {
|
|
@@ -1486,8 +777,8 @@ function json(key, defaultValue) {
|
|
|
1486
777
|
const value = process.env[key] ?? "{}";
|
|
1487
778
|
try {
|
|
1488
779
|
return JSON.parse(value);
|
|
1489
|
-
} catch (
|
|
1490
|
-
throw new Error(`Invalid json environment variable ${key}: ${
|
|
780
|
+
} catch (error) {
|
|
781
|
+
throw new Error(`Invalid json environment variable ${key}: ${error.message}`);
|
|
1491
782
|
}
|
|
1492
783
|
}
|
|
1493
784
|
function array(key, defaultValue) {
|
|
@@ -1530,14 +821,15 @@ var utils = {
|
|
|
1530
821
|
if (defaultValue && !expectedValues.includes(defaultValue)) {
|
|
1531
822
|
throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
|
|
1532
823
|
}
|
|
1533
|
-
const rawValue =
|
|
824
|
+
const rawValue = env(key, defaultValue);
|
|
1534
825
|
return expectedValues.includes(rawValue) ? rawValue : defaultValue ?? "";
|
|
1535
826
|
}
|
|
1536
827
|
};
|
|
1537
|
-
var
|
|
828
|
+
var env = Object.assign(_env, utils);
|
|
1538
829
|
|
|
1539
830
|
// ../../utils/src/logging/index.ts
|
|
1540
|
-
|
|
831
|
+
import chalk from "chalk";
|
|
832
|
+
import { EOL } from "os";
|
|
1541
833
|
|
|
1542
834
|
// ../../utils/src/logging/types.ts
|
|
1543
835
|
var logLevels = {
|
|
@@ -1549,39 +841,39 @@ var logLevels = {
|
|
|
1549
841
|
};
|
|
1550
842
|
|
|
1551
843
|
// ../../utils/src/logging/error-to-string.ts
|
|
1552
|
-
var errorToString = (
|
|
1553
|
-
if (
|
|
1554
|
-
if (
|
|
1555
|
-
if (
|
|
844
|
+
var errorToString = (error) => {
|
|
845
|
+
if (error === null) return "Null error";
|
|
846
|
+
if (error === void 0) return "Undefined error";
|
|
847
|
+
if (error instanceof Error) {
|
|
1556
848
|
return [
|
|
1557
|
-
`Name: ${
|
|
1558
|
-
`Message: ${
|
|
1559
|
-
`Stack: ${
|
|
849
|
+
`Name: ${error.name}`,
|
|
850
|
+
`Message: ${error.message}`,
|
|
851
|
+
`Stack: ${error.stack || "No stack trace available"}`,
|
|
1560
852
|
// Handle additional properties that might exist on custom errors
|
|
1561
|
-
...Object.entries(
|
|
853
|
+
...Object.entries(error).filter(([key]) => !["name", "message", "stack"].includes(key)).map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
|
|
1562
854
|
].join("\n");
|
|
1563
855
|
}
|
|
1564
|
-
if (typeof
|
|
1565
|
-
if (typeof
|
|
856
|
+
if (typeof error === "string") return error;
|
|
857
|
+
if (typeof error === "object") {
|
|
1566
858
|
try {
|
|
1567
|
-
return JSON.stringify(
|
|
859
|
+
return JSON.stringify(error, null, 2);
|
|
1568
860
|
} catch {
|
|
1569
|
-
return `[Object that cannot be stringified: ${Object.prototype.toString.call(
|
|
861
|
+
return `[Object that cannot be stringified: ${Object.prototype.toString.call(error)}]`;
|
|
1570
862
|
}
|
|
1571
863
|
}
|
|
1572
|
-
return String(
|
|
864
|
+
return String(error);
|
|
1573
865
|
};
|
|
1574
866
|
|
|
1575
867
|
// ../../utils/src/logging/index.ts
|
|
1576
|
-
var currentLogLevel =
|
|
868
|
+
var currentLogLevel = logLevels[env("LOG_LEVEL")?.toLowerCase()] ?? logLevels.info;
|
|
1577
869
|
var logger = {
|
|
1578
870
|
fatal: (message, meta) => {
|
|
1579
871
|
if (currentLogLevel >= logLevels.fatal) {
|
|
1580
872
|
console.error(
|
|
1581
873
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1582
|
-
`${
|
|
874
|
+
`${chalk.bgRed.white(" fatal ")}${EOL}`,
|
|
1583
875
|
errorToString(message),
|
|
1584
|
-
meta ? `${
|
|
876
|
+
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1585
877
|
);
|
|
1586
878
|
}
|
|
1587
879
|
},
|
|
@@ -1589,9 +881,9 @@ var logger = {
|
|
|
1589
881
|
if (currentLogLevel >= logLevels.error) {
|
|
1590
882
|
console.error(
|
|
1591
883
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1592
|
-
`${
|
|
884
|
+
`${chalk.bgRed.white(" error ")}${EOL}`,
|
|
1593
885
|
errorToString(message),
|
|
1594
|
-
meta ? `${
|
|
886
|
+
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1595
887
|
);
|
|
1596
888
|
}
|
|
1597
889
|
},
|
|
@@ -1599,9 +891,9 @@ var logger = {
|
|
|
1599
891
|
if (currentLogLevel >= logLevels.warn) {
|
|
1600
892
|
console.warn(
|
|
1601
893
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1602
|
-
`${
|
|
894
|
+
`${chalk.bgYellow.black(" warn ")}${EOL}`,
|
|
1603
895
|
errorToString(message),
|
|
1604
|
-
meta ? `${
|
|
896
|
+
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1605
897
|
);
|
|
1606
898
|
}
|
|
1607
899
|
},
|
|
@@ -1609,9 +901,9 @@ var logger = {
|
|
|
1609
901
|
if (currentLogLevel >= logLevels.info) {
|
|
1610
902
|
console.info(
|
|
1611
903
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1612
|
-
`${
|
|
904
|
+
`${chalk.bgBlue.white(" info ")}${EOL}`,
|
|
1613
905
|
message,
|
|
1614
|
-
meta ? `${
|
|
906
|
+
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1615
907
|
);
|
|
1616
908
|
}
|
|
1617
909
|
},
|
|
@@ -1619,9 +911,9 @@ var logger = {
|
|
|
1619
911
|
if (currentLogLevel >= logLevels.debug) {
|
|
1620
912
|
console.debug(
|
|
1621
913
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1622
|
-
`${
|
|
914
|
+
`${chalk.bgWhite.black(" debug ")}${EOL}`,
|
|
1623
915
|
message,
|
|
1624
|
-
meta ? `${
|
|
916
|
+
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1625
917
|
);
|
|
1626
918
|
}
|
|
1627
919
|
}
|
|
@@ -1651,14 +943,15 @@ var mergeConfig = (defaultConfig, userConfig) => ({
|
|
|
1651
943
|
...userConfig?.persistence || {}
|
|
1652
944
|
}
|
|
1653
945
|
});
|
|
1654
|
-
var createQueueService = (handler) => ({
|
|
946
|
+
var createQueueService = (handler, module) => ({
|
|
1655
947
|
handler,
|
|
1656
948
|
incoming: [],
|
|
1657
949
|
processing: [],
|
|
1658
950
|
dlq: [],
|
|
1659
951
|
timeoutId: null,
|
|
1660
952
|
processingBatch: false,
|
|
1661
|
-
activeProcessing: 0
|
|
953
|
+
activeProcessing: 0,
|
|
954
|
+
module
|
|
1662
955
|
});
|
|
1663
956
|
var createQueueMessage = (body, headers) => {
|
|
1664
957
|
const id = Date.now().toString() + Math.random().toString(36).substring(2, 7);
|
|
@@ -1676,10 +969,10 @@ var moveToProcessing = (queueService, batchSize) => {
|
|
|
1676
969
|
var removeFromProcessing = (queueService, messageId) => {
|
|
1677
970
|
queueService.processing = queueService.processing.filter((msg) => msg.id !== messageId);
|
|
1678
971
|
};
|
|
1679
|
-
var moveToDLQ = (queueService, message,
|
|
972
|
+
var moveToDLQ = (queueService, message, error) => {
|
|
1680
973
|
queueService.dlq.push({
|
|
1681
974
|
...message,
|
|
1682
|
-
error
|
|
975
|
+
error,
|
|
1683
976
|
failedAt: /* @__PURE__ */ new Date()
|
|
1684
977
|
});
|
|
1685
978
|
removeFromProcessing(queueService, message.id);
|
|
@@ -1740,16 +1033,16 @@ var purgeDLQ = (queueService) => {
|
|
|
1740
1033
|
return dlqCount;
|
|
1741
1034
|
};
|
|
1742
1035
|
var logSuccess = (message, messageId, queueName) => {
|
|
1743
|
-
logger.debug(`${
|
|
1036
|
+
logger.debug(`${logSymbols.success} ${chalk2.green(message)} ${chalk2.yellow(messageId)} in queue ${chalk2.magenta(queueName)}`);
|
|
1744
1037
|
};
|
|
1745
|
-
var logError = (message, messageId, queueName,
|
|
1746
|
-
logger.error(`${
|
|
1038
|
+
var logError = (message, messageId, queueName, error) => {
|
|
1039
|
+
logger.error(`${logSymbols.error} ${chalk2.red(message)} ${chalk2.yellow(messageId)} in queue ${chalk2.magenta(queueName)}: ${error}`);
|
|
1747
1040
|
};
|
|
1748
1041
|
var logRetryScheduled = (messageId, delayMs) => {
|
|
1749
|
-
logger.info(`${
|
|
1042
|
+
logger.info(`${chalk2.blue("\u23F1\uFE0F Scheduling retry")} for message ${chalk2.yellow(messageId)} in ${chalk2.cyan(delayMs)}ms`);
|
|
1750
1043
|
};
|
|
1751
1044
|
var logDLQOperation = (operation, count, queueName) => {
|
|
1752
|
-
logger.warn(`${
|
|
1045
|
+
logger.warn(`${logSymbols.warning} ${chalk2.yellow(operation)} ${chalk2.red(count)} messages from DLQ for ${chalk2.green(queueName)}`);
|
|
1753
1046
|
};
|
|
1754
1047
|
|
|
1755
1048
|
// src/queue-plugin/processing.ts
|
|
@@ -1758,14 +1051,14 @@ var createProcessMessageHandler = (config) => async (queueName, message, queueSe
|
|
|
1758
1051
|
await queueService.handler(message);
|
|
1759
1052
|
removeFromProcessing(queueService, message.id);
|
|
1760
1053
|
logSuccess("Successfully processed message", message.id, queueName);
|
|
1761
|
-
} catch (
|
|
1762
|
-
await handleProcessingError(queueName, message, queueService,
|
|
1054
|
+
} catch (error) {
|
|
1055
|
+
await handleProcessingError(queueName, message, queueService, error, config);
|
|
1763
1056
|
}
|
|
1764
1057
|
};
|
|
1765
|
-
var handleProcessingError = async (queueName, message, queueService,
|
|
1766
|
-
logError("Error processing message", message.id, queueName,
|
|
1058
|
+
var handleProcessingError = async (queueName, message, queueService, error, config) => {
|
|
1059
|
+
logError("Error processing message", message.id, queueName, error.message);
|
|
1767
1060
|
if (message.attempts >= config.maxRetries) {
|
|
1768
|
-
moveToDLQ(queueService, message,
|
|
1061
|
+
moveToDLQ(queueService, message, error.message);
|
|
1769
1062
|
return;
|
|
1770
1063
|
}
|
|
1771
1064
|
const updatedMessage = incrementAttempts(queueService, message.id);
|
|
@@ -1823,8 +1116,10 @@ var handleImmediateProcessing = (queueService, config, processBatch, queueName)
|
|
|
1823
1116
|
};
|
|
1824
1117
|
|
|
1825
1118
|
// src/queue-plugin/persistence.ts
|
|
1826
|
-
|
|
1827
|
-
|
|
1119
|
+
import * as fs from "fs/promises";
|
|
1120
|
+
import * as path from "path";
|
|
1121
|
+
import chalk3 from "chalk";
|
|
1122
|
+
import logSymbols2 from "log-symbols";
|
|
1828
1123
|
var createQueueData = (queueService) => ({
|
|
1829
1124
|
incoming: queueService.incoming,
|
|
1830
1125
|
processing: queueService.processing,
|
|
@@ -1856,9 +1151,9 @@ var createPersistenceInitializer = (config, loadAllQueueStates, saveAllQueueStat
|
|
|
1856
1151
|
process.on("SIGINT", shutdownHandler);
|
|
1857
1152
|
process.on("SIGTERM", shutdownHandler);
|
|
1858
1153
|
}
|
|
1859
|
-
logger.debug(`${
|
|
1860
|
-
} catch (
|
|
1861
|
-
logger.error(`${
|
|
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)}`);
|
|
1862
1157
|
}
|
|
1863
1158
|
};
|
|
1864
1159
|
var createQueueStateSaver = (config) => async (queueName, queueService) => {
|
|
@@ -1870,9 +1165,9 @@ var createQueueStateSaver = (config) => async (queueName, queueService) => {
|
|
|
1870
1165
|
const tempFilePath = path.join(config.persistence.directory, `${queueName}.${now}temp.json`);
|
|
1871
1166
|
await fs.writeFile(tempFilePath, JSON.stringify(queueData, null, 2), "utf8");
|
|
1872
1167
|
await fs.rename(tempFilePath, queueFilePath);
|
|
1873
|
-
logger.info(`${
|
|
1874
|
-
} catch (
|
|
1875
|
-
logger.error(`Failed to save queue state for ${queueName}:`,
|
|
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);
|
|
1876
1171
|
}
|
|
1877
1172
|
};
|
|
1878
1173
|
var createAllQueuesStateSaver = (config, saveQueueState) => (queues) => async () => {
|
|
@@ -1880,9 +1175,9 @@ var createAllQueuesStateSaver = (config, saveQueueState) => (queues) => async ()
|
|
|
1880
1175
|
for (const [queueName, queueService] of Object.entries(queues)) {
|
|
1881
1176
|
await saveQueueState(queueName, queueService);
|
|
1882
1177
|
}
|
|
1883
|
-
logger.debug(`${
|
|
1884
|
-
} catch (
|
|
1885
|
-
logger.error(`${
|
|
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)}`);
|
|
1886
1181
|
}
|
|
1887
1182
|
};
|
|
1888
1183
|
var createQueueStateLoader = (config, scheduleProcessing, processMessage) => (queues) => async (queueName) => {
|
|
@@ -1913,15 +1208,15 @@ var createQueueStateLoader = (config, scheduleProcessing, processMessage) => (qu
|
|
|
1913
1208
|
}, 100 * (Math.random() * 10));
|
|
1914
1209
|
}
|
|
1915
1210
|
}
|
|
1916
|
-
} catch (
|
|
1917
|
-
if (
|
|
1211
|
+
} catch (error) {
|
|
1212
|
+
if (error.code === "ENOENT") {
|
|
1918
1213
|
logger.debug(`No saved state found for queue: ${queueName}`);
|
|
1919
1214
|
} else {
|
|
1920
|
-
throw
|
|
1215
|
+
throw error;
|
|
1921
1216
|
}
|
|
1922
1217
|
}
|
|
1923
|
-
} catch (
|
|
1924
|
-
logger.error(`Failed to load queue state for ${queueName}:`,
|
|
1218
|
+
} catch (error) {
|
|
1219
|
+
logger.error(`Failed to load queue state for ${queueName}:`, error);
|
|
1925
1220
|
}
|
|
1926
1221
|
};
|
|
1927
1222
|
var createAllQueuesStateLoader = (config, loadQueueState) => async () => {
|
|
@@ -1933,111 +1228,69 @@ var createAllQueuesStateLoader = (config, loadQueueState) => async () => {
|
|
|
1933
1228
|
await loadQueueState(queueName);
|
|
1934
1229
|
}
|
|
1935
1230
|
logger.debug("All queue states loaded");
|
|
1936
|
-
} catch (
|
|
1937
|
-
logger.error("Failed to load queue states:",
|
|
1231
|
+
} catch (error) {
|
|
1232
|
+
logger.error("Failed to load queue states:", error);
|
|
1938
1233
|
}
|
|
1939
1234
|
};
|
|
1940
1235
|
|
|
1941
1236
|
// src/queue-plugin/routes.ts
|
|
1942
|
-
var
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
if (!queues[queueName]) {
|
|
1949
|
-
return reply.status(404).send({ error: "Queue not found" });
|
|
1950
|
-
}
|
|
1951
|
-
const queue = queues[queueName];
|
|
1952
|
-
const stats = createQueueSummary(queue, config);
|
|
1953
|
-
return reply.status(200).send({
|
|
1954
|
-
stats,
|
|
1955
|
-
messages: {
|
|
1956
|
-
incoming: queue.incoming,
|
|
1957
|
-
processing: queue.processing,
|
|
1958
|
-
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);
|
|
1959
1243
|
}
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
await saveQueueState(queueName, queues[queueName]);
|
|
1973
|
-
}
|
|
1974
|
-
return reply.status(200).send({ id: message.id, queueName });
|
|
1975
|
-
};
|
|
1976
|
-
var createProcessDLQHandler = (queues, scheduleProcessing, saveQueueState) => async (request, reply) => {
|
|
1977
|
-
const queueName = request.params.queue;
|
|
1978
|
-
if (!queues[queueName]) {
|
|
1979
|
-
return reply.status(404).send({ error: "Queue not found" });
|
|
1980
|
-
}
|
|
1981
|
-
const processedCount = moveDLQToIncoming(queues[queueName]);
|
|
1982
|
-
if (processedCount === 0) {
|
|
1983
|
-
return reply.status(200).send({
|
|
1984
|
-
status: "success",
|
|
1985
|
-
message: "No messages in DLQ to process",
|
|
1986
|
-
processed: 0
|
|
1987
|
-
});
|
|
1988
|
-
}
|
|
1989
|
-
logDLQOperation("Moving", processedCount, queueName);
|
|
1990
|
-
scheduleProcessing(queueName, queues[queueName]);
|
|
1991
|
-
if (saveQueueState) {
|
|
1992
|
-
await saveQueueState(queueName, queues[queueName]);
|
|
1993
|
-
}
|
|
1994
|
-
return reply.status(200).send({
|
|
1995
|
-
status: "success",
|
|
1996
|
-
message: `Moved ${processedCount} messages from DLQ to processing queue`,
|
|
1997
|
-
processed: processedCount
|
|
1998
|
-
});
|
|
1999
|
-
};
|
|
2000
|
-
var createPurgeDLQHandler = (queues, saveQueueState) => async (request, reply) => {
|
|
2001
|
-
const queueName = request.params.queue;
|
|
2002
|
-
if (!queues[queueName]) {
|
|
2003
|
-
return reply.status(404).send({ error: "Queue not found" });
|
|
2004
|
-
}
|
|
2005
|
-
const purgedCount = purgeDLQ(queues[queueName]);
|
|
2006
|
-
if (purgedCount === 0) {
|
|
2007
|
-
return reply.status(200).send({
|
|
2008
|
-
status: "success",
|
|
2009
|
-
message: "No messages in DLQ to purge",
|
|
2010
|
-
purged: 0
|
|
2011
|
-
});
|
|
2012
|
-
}
|
|
2013
|
-
logDLQOperation("Purging", purgedCount, queueName);
|
|
2014
|
-
if (saveQueueState) {
|
|
2015
|
-
await saveQueueState(queueName, queues[queueName]);
|
|
2016
|
-
}
|
|
2017
|
-
return reply.status(200).send({
|
|
2018
|
-
status: "success",
|
|
2019
|
-
message: `Purged ${purgedCount} messages from DLQ`,
|
|
2020
|
-
purged: purgedCount
|
|
2021
|
-
});
|
|
2022
|
-
};
|
|
2023
|
-
var registerQueueRoutes = (app, prefix = "", queues, config, scheduleProcessing, processBatch, saveQueueState) => {
|
|
2024
|
-
app.get(`/${prefix}/dashboard`, createDashboardHandler(queues, config));
|
|
2025
|
-
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
|
+
);
|
|
2026
1256
|
app.post(
|
|
2027
1257
|
`/${prefix}/:queue`,
|
|
2028
|
-
|
|
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
|
+
}
|
|
2029
1266
|
);
|
|
2030
1267
|
app.get(
|
|
2031
1268
|
`/${prefix}/:queue/process-dlq`,
|
|
2032
|
-
|
|
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
|
+
}
|
|
2033
1277
|
);
|
|
2034
|
-
app.
|
|
2035
|
-
`/${prefix}/:queue/purge-
|
|
2036
|
-
|
|
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
|
+
}
|
|
2037
1288
|
);
|
|
2038
1289
|
};
|
|
2039
1290
|
|
|
2040
1291
|
// src/queue-plugin/decorator.ts
|
|
1292
|
+
import chalk4 from "chalk";
|
|
1293
|
+
import logSymbols3 from "log-symbols";
|
|
2041
1294
|
var isValidQueueName = (queueName) => {
|
|
2042
1295
|
return typeof queueName === "string" && queueName.length > 0 && /^[a-zA-Z0-9_-]+$/.test(queueName);
|
|
2043
1296
|
};
|
|
@@ -2045,7 +1298,9 @@ var createQueueManager = ({
|
|
|
2045
1298
|
config,
|
|
2046
1299
|
queues,
|
|
2047
1300
|
saveQueueState,
|
|
2048
|
-
loadQueueState
|
|
1301
|
+
loadQueueState,
|
|
1302
|
+
scheduleProcessing,
|
|
1303
|
+
processBatch
|
|
2049
1304
|
}) => {
|
|
2050
1305
|
const validateQueueName = (queueName) => {
|
|
2051
1306
|
if (!queueName || typeof queueName !== "string") {
|
|
@@ -2060,22 +1315,22 @@ var createQueueManager = ({
|
|
|
2060
1315
|
throw new Error("Handler must be a function");
|
|
2061
1316
|
}
|
|
2062
1317
|
};
|
|
2063
|
-
const addQueue = async (queueName, handler) => {
|
|
1318
|
+
const addQueue = async (queueName, handler, module) => {
|
|
2064
1319
|
try {
|
|
2065
1320
|
validateQueueName(queueName);
|
|
2066
1321
|
validateHandler(handler);
|
|
2067
1322
|
if (queues[queueName]) {
|
|
2068
|
-
logger.warn(`${
|
|
1323
|
+
logger.warn(`${logSymbols3.warning} ${chalk4.yellow("Queue already exists:")} ${chalk4.magenta(queueName)}.`);
|
|
2069
1324
|
return;
|
|
2070
1325
|
}
|
|
2071
|
-
queues[queueName] = createQueueService(handler);
|
|
1326
|
+
queues[queueName] = createQueueService(handler, module);
|
|
2072
1327
|
if (config.persistence.enabled && loadQueueState) {
|
|
2073
1328
|
await loadQueueState(queueName);
|
|
2074
1329
|
}
|
|
2075
|
-
logger.info(`${
|
|
2076
|
-
} catch (
|
|
2077
|
-
logger.error(`${
|
|
2078
|
-
throw
|
|
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;
|
|
2079
1334
|
}
|
|
2080
1335
|
};
|
|
2081
1336
|
const removeQueue = async (queueName) => {
|
|
@@ -2087,7 +1342,7 @@ var createQueueManager = ({
|
|
|
2087
1342
|
const queueService = queues[queueName];
|
|
2088
1343
|
const totalMessages = queueService.incoming.length + queueService.processing.length;
|
|
2089
1344
|
if (totalMessages > 0) {
|
|
2090
|
-
logger.warn(`${
|
|
1345
|
+
logger.warn(`${logSymbols3.warning} ${chalk4.yellow("Removing queue with")} ${chalk4.red(totalMessages)} ${chalk4.yellow("pending messages:")} ${chalk4.magenta(queueName)}`);
|
|
2091
1346
|
}
|
|
2092
1347
|
if (queueService.timeoutId) {
|
|
2093
1348
|
clearTimeout(queueService.timeoutId);
|
|
@@ -2096,10 +1351,10 @@ var createQueueManager = ({
|
|
|
2096
1351
|
await saveQueueState(queueName, queueService);
|
|
2097
1352
|
}
|
|
2098
1353
|
delete queues[queueName];
|
|
2099
|
-
logger.info(`${
|
|
2100
|
-
} catch (
|
|
2101
|
-
logger.error(`${
|
|
2102
|
-
throw
|
|
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;
|
|
2103
1358
|
}
|
|
2104
1359
|
};
|
|
2105
1360
|
const hasQueue = (queueName) => {
|
|
@@ -2110,8 +1365,11 @@ var createQueueManager = ({
|
|
|
2110
1365
|
return false;
|
|
2111
1366
|
}
|
|
2112
1367
|
};
|
|
2113
|
-
const listQueues = () => {
|
|
2114
|
-
return Object.keys(queues).
|
|
1368
|
+
const listQueues = (module) => {
|
|
1369
|
+
return Object.keys(queues).filter((queueName) => {
|
|
1370
|
+
const queueService = queues[queueName];
|
|
1371
|
+
return !module || queueService.module === module;
|
|
1372
|
+
}).sort();
|
|
2115
1373
|
};
|
|
2116
1374
|
const getQueueStats = (queueName) => {
|
|
2117
1375
|
try {
|
|
@@ -2124,13 +1382,97 @@ var createQueueManager = ({
|
|
|
2124
1382
|
const getQueuesMap = () => {
|
|
2125
1383
|
return { ...queues };
|
|
2126
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
|
+
};
|
|
2127
1463
|
return {
|
|
2128
1464
|
addQueue,
|
|
2129
1465
|
removeQueue,
|
|
2130
1466
|
hasQueue,
|
|
2131
1467
|
listQueues,
|
|
2132
1468
|
getQueueStats,
|
|
2133
|
-
getQueuesMap
|
|
1469
|
+
getQueuesMap,
|
|
1470
|
+
getConfig,
|
|
1471
|
+
getDashboardSummary,
|
|
1472
|
+
getQueueSummary,
|
|
1473
|
+
enqueueMessage,
|
|
1474
|
+
processDlq,
|
|
1475
|
+
purgeDlq
|
|
2134
1476
|
};
|
|
2135
1477
|
};
|
|
2136
1478
|
var createQueueDecorator = (queueManager) => (app) => {
|
|
@@ -2138,7 +1480,7 @@ var createQueueDecorator = (queueManager) => (app) => {
|
|
|
2138
1480
|
};
|
|
2139
1481
|
|
|
2140
1482
|
// src/queue-plugin/plugin.ts
|
|
2141
|
-
var queuesPlugin = (
|
|
1483
|
+
var queuesPlugin = fsPlugin(async (app, options) => {
|
|
2142
1484
|
const config = mergeConfig(DEFAULT_CONFIG, options.config);
|
|
2143
1485
|
const queues = {};
|
|
2144
1486
|
const processMessage = createProcessMessageHandler(config);
|
|
@@ -2165,25 +1507,21 @@ var queuesPlugin = (0, import_fastify_plugin.default)(async (app, options) => {
|
|
|
2165
1507
|
config,
|
|
2166
1508
|
queues,
|
|
2167
1509
|
saveQueueState: saveQueueState ? (queueName) => saveQueueState(queueName, queues[queueName]) : void 0,
|
|
2168
|
-
loadQueueState
|
|
1510
|
+
loadQueueState,
|
|
1511
|
+
scheduleProcessing,
|
|
1512
|
+
processBatch
|
|
2169
1513
|
});
|
|
2170
1514
|
const decorateQueues = createQueueDecorator(queueManager);
|
|
2171
1515
|
decorateQueues(app);
|
|
2172
1516
|
registerQueueRoutes(
|
|
2173
1517
|
app,
|
|
2174
|
-
options.prefix
|
|
2175
|
-
queues,
|
|
2176
|
-
config,
|
|
2177
|
-
scheduleProcessing,
|
|
2178
|
-
processBatch,
|
|
2179
|
-
saveQueueState ? (queueName) => saveQueueState(queueName, queues[queueName]) : void 0
|
|
1518
|
+
options.prefix
|
|
2180
1519
|
);
|
|
2181
1520
|
await initializePersistence();
|
|
2182
1521
|
});
|
|
2183
|
-
|
|
2184
|
-
0 && (module.exports = {
|
|
1522
|
+
export {
|
|
2185
1523
|
queuesPlugin
|
|
2186
|
-
}
|
|
1524
|
+
};
|
|
2187
1525
|
/*! Bundled license information:
|
|
2188
1526
|
|
|
2189
1527
|
lodash-es/lodash.js:
|