@cloudnux/local-cloud-provider 0.18.0 → 0.20.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 +76 -6
- package/dist/dev-console-plugin/index.js +994 -2037
- package/dist/dev-console-plugin/index.js.map +1 -1
- package/dist/index.d.ts +19 -4
- package/dist/index.js +162 -197
- package/dist/index.js.map +1 -1
- package/dist/queue-plugin/index.d.ts +36 -13
- package/dist/queue-plugin/index.js +342 -1431
- package/dist/queue-plugin/index.js.map +1 -1
- package/dist/schedule-plugin/index.d.ts +49 -21
- package/dist/schedule-plugin/index.js +529 -1590
- package/dist/schedule-plugin/index.js.map +1 -1
- package/dist/websocket-plugin/index.d.ts +18 -0
- package/dist/websocket-plugin/index.js +18 -1029
- package/dist/websocket-plugin/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/logging/pretty-writer.ts","../../../../../node_modules/lodash-es/_freeGlobal.js","../../../../../node_modules/lodash-es/_root.js","../../../../../node_modules/lodash-es/_Symbol.js","../../../../../node_modules/lodash-es/_getRawTag.js","../../../../../node_modules/lodash-es/_objectToString.js","../../../../../node_modules/lodash-es/_baseGetTag.js","../../../../../node_modules/lodash-es/isObjectLike.js","../../../../../node_modules/lodash-es/isSymbol.js","../../../../../node_modules/lodash-es/_arrayMap.js","../../../../../node_modules/lodash-es/isArray.js","../../../../../node_modules/lodash-es/_baseToString.js","../../../../../node_modules/lodash-es/_trimmedEndIndex.js","../../../../../node_modules/lodash-es/_baseTrim.js","../../../../../node_modules/lodash-es/isObject.js","../../../../../node_modules/lodash-es/isFunction.js","../../../../../node_modules/lodash-es/_coreJsData.js","../../../../../node_modules/lodash-es/_isMasked.js","../../../../../node_modules/lodash-es/_toSource.js","../../../../../node_modules/lodash-es/_baseIsNative.js","../../../../../node_modules/lodash-es/_getValue.js","../../../../../node_modules/lodash-es/_getNative.js","../../../../../node_modules/lodash-es/_baseFindIndex.js","../../../../../node_modules/lodash-es/_baseIsNaN.js","../../../../../node_modules/lodash-es/_strictIndexOf.js","../../../../../node_modules/lodash-es/_baseIndexOf.js","../../../../../node_modules/lodash-es/_isIndex.js","../../../../../node_modules/lodash-es/eq.js","../../../../../node_modules/lodash-es/isLength.js","../../../../../node_modules/lodash-es/_baseIsArguments.js","../../../../../node_modules/lodash-es/isArguments.js","../../../../../node_modules/lodash-es/_isKey.js","../../../../../node_modules/lodash-es/_nativeCreate.js","../../../../../node_modules/lodash-es/_hashClear.js","../../../../../node_modules/lodash-es/_hashDelete.js","../../../../../node_modules/lodash-es/_hashGet.js","../../../../../node_modules/lodash-es/_hashHas.js","../../../../../node_modules/lodash-es/_hashSet.js","../../../../../node_modules/lodash-es/_Hash.js","../../../../../node_modules/lodash-es/_listCacheClear.js","../../../../../node_modules/lodash-es/_assocIndexOf.js","../../../../../node_modules/lodash-es/_listCacheDelete.js","../../../../../node_modules/lodash-es/_listCacheGet.js","../../../../../node_modules/lodash-es/_listCacheHas.js","../../../../../node_modules/lodash-es/_listCacheSet.js","../../../../../node_modules/lodash-es/_ListCache.js","../../../../../node_modules/lodash-es/_Map.js","../../../../../node_modules/lodash-es/_mapCacheClear.js","../../../../../node_modules/lodash-es/_isKeyable.js","../../../../../node_modules/lodash-es/_getMapData.js","../../../../../node_modules/lodash-es/_mapCacheDelete.js","../../../../../node_modules/lodash-es/_mapCacheGet.js","../../../../../node_modules/lodash-es/_mapCacheHas.js","../../../../../node_modules/lodash-es/_mapCacheSet.js","../../../../../node_modules/lodash-es/_MapCache.js","../../../../../node_modules/lodash-es/memoize.js","../../../../../node_modules/lodash-es/_memoizeCapped.js","../../../../../node_modules/lodash-es/_stringToPath.js","../../../../../node_modules/lodash-es/toString.js","../../../../../node_modules/lodash-es/_castPath.js","../../../../../node_modules/lodash-es/_toKey.js","../../../../../node_modules/lodash-es/_baseSlice.js","../../../../../node_modules/lodash-es/_castSlice.js","../../../../../node_modules/lodash-es/_hasUnicode.js","../../../../../node_modules/lodash-es/_asciiToArray.js","../../../../../node_modules/lodash-es/_unicodeToArray.js","../../../../../node_modules/lodash-es/_stringToArray.js","../../../../../node_modules/lodash-es/_hasPath.js","../../../../../node_modules/lodash-es/_baseHas.js","../../../../../node_modules/lodash-es/has.js","../../../../../node_modules/lodash-es/_charsEndIndex.js","../../../../../node_modules/lodash-es/_charsStartIndex.js","../../../../../node_modules/lodash-es/trim.js","../../../../utils/src/config/env.ts","../../../../utils/src/logging/types.ts","../../../../utils/src/logging/error-to-string.ts","../../../../utils/src/logging/writer.ts","../../../../utils/src/logging/index.ts","../../src/dev-console-plugin/plugin.ts","../../src/queue-plugin/plugin.ts","../../src/queue-plugin/core.ts","../../src/queue-plugin/processing.ts","../../src/queue-plugin/persistence.ts","../../src/queue-plugin/routes.ts","../../src/queue-plugin/decorator.ts","../../src/schedule-plugin/plugin.ts","../../src/schedule-plugin/core.ts","../../src/schedule-plugin/cron-utils.ts","../../src/schedule-plugin/utils.ts","../../src/schedule-plugin/execution.ts","../../src/schedule-plugin/persistence.ts","../../src/schedule-plugin/cleanup.ts","../../src/schedule-plugin/jobs.ts","../../src/schedule-plugin/routes.ts","../../src/schedule-plugin/decorator.ts","../../src/websocket-plugin/plugin.ts","../../src/dev-console-plugin/route-registry.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { EOL } from \"os\";\nimport { setWriter } from \"@cloudnux/utils\";\nimport type { LogWriter, LogEntry } from \"@cloudnux/utils\";\n\nconst levelColor: Record<string, (s: string) => string> = {\n fatal: chalk.bgRed.white,\n error: chalk.red,\n warn: chalk.yellow,\n info: chalk.cyan,\n debug: chalk.gray,\n trace: chalk.white,\n};\n\nfunction formatTime(ms: number): string {\n return new Date(ms).toTimeString().slice(0, 8);\n}\n\nfunction formatMeta(meta: Record<string, unknown>): string {\n const { req, res, ...rest } = meta as any;\n const lines: string[] = [];\n\n if (req) {\n const reqParts = [`${req.method} ${req.url}`];\n if (req.remoteAddress) reqParts.push(`from ${req.remoteAddress}:${req.remotePort ?? \"\"}`);\n if (req.headers) reqParts.push(`headers=${JSON.stringify(req.headers, null, 2)}`);\n if (req.body !== undefined) reqParts.push(`body=${typeof req.body === \"string\" ? req.body : JSON.stringify(req.body, null, 2)}`);\n lines.push(chalk.dim(\" req: \" + reqParts.join(\" \")));\n }\n if (res) {\n const resParts = [`${res.statusCode}`];\n if (res.headers) resParts.push(`headers=${JSON.stringify(res.headers, null, 2)}`);\n if (res.body !== undefined) resParts.push(`body=${typeof res.body === \"string\" ? res.body : JSON.stringify(res.body, null, 2)}`);\n lines.push(chalk.dim(\" res: \" + resParts.join(\" \")));\n }\n if (Object.keys(rest).length) {\n lines.push(chalk.dim(\" \" + JSON.stringify(rest, null, 2)));\n }\n\n return lines.length ? EOL + lines.join(EOL) : \"\";\n}\n\nconst prettyWriter: LogWriter = (entry: LogEntry) => {\n const color = levelColor[entry.levelName] ?? chalk.white;\n const time = chalk.dim(formatTime(entry.time));\n const level = color(entry.levelName.toUpperCase().padEnd(5));\n const module = chalk.magenta(entry.module);\n const reqId = entry.reqId ? chalk.dim(`[${entry.reqId}]`) + \" \" : \"\";\n const meta = entry.meta ? formatMeta(entry.meta) : \"\";\n\n process.stdout.write(`${time} ${level} ${module} ${reqId}- ${entry.msg}${meta}${EOL}`);\n};\n\nsetWriter(prettyWriter);\n","/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nexport default freeGlobal;\n","import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nexport default root;\n","import root from './_root.js';\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nexport default Symbol;\n","import Symbol from './_Symbol.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nexport default getRawTag;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nexport default objectToString;\n","import Symbol from './_Symbol.js';\nimport getRawTag from './_getRawTag.js';\nimport objectToString from './_objectToString.js';\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nexport default baseGetTag;\n","/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nexport default isObjectLike;\n","import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nexport default isSymbol;\n","/**\n * A specialized version of `_.map` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\nfunction arrayMap(array, iteratee) {\n var index = -1,\n length = array == null ? 0 : array.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iteratee(array[index], index, array);\n }\n return result;\n}\n\nexport default arrayMap;\n","/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\nexport default isArray;\n","import Symbol from './_Symbol.js';\nimport arrayMap from './_arrayMap.js';\nimport isArray from './isArray.js';\nimport isSymbol from './isSymbol.js';\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n/**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\nfunction baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isArray(value)) {\n // Recursively convert values (susceptible to call stack limits).\n return arrayMap(value, baseToString) + '';\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\nexport default baseToString;\n","/** Used to match a single whitespace character. */\nvar reWhitespace = /\\s/;\n\n/**\n * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace\n * character of `string`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {number} Returns the index of the last non-whitespace character.\n */\nfunction trimmedEndIndex(string) {\n var index = string.length;\n\n while (index-- && reWhitespace.test(string.charAt(index))) {}\n return index;\n}\n\nexport default trimmedEndIndex;\n","import trimmedEndIndex from './_trimmedEndIndex.js';\n\n/** Used to match leading whitespace. */\nvar reTrimStart = /^\\s+/;\n\n/**\n * The base implementation of `_.trim`.\n *\n * @private\n * @param {string} string The string to trim.\n * @returns {string} Returns the trimmed string.\n */\nfunction baseTrim(string) {\n return string\n ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')\n : string;\n}\n\nexport default baseTrim;\n","/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nexport default isObject;\n","import baseGetTag from './_baseGetTag.js';\nimport isObject from './isObject.js';\n\n/** `Object#toString` result references. */\nvar asyncTag = '[object AsyncFunction]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n proxyTag = '[object Proxy]';\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\n\nexport default isFunction;\n","import root from './_root.js';\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\nexport default coreJsData;\n","import coreJsData from './_coreJsData.js';\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\nexport default isMasked;\n","/** Used for built-in method references. */\nvar funcProto = Function.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\nexport default toSource;\n","import isFunction from './isFunction.js';\nimport isMasked from './_isMasked.js';\nimport isObject from './isObject.js';\nimport toSource from './_toSource.js';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\nexport default baseIsNative;\n","/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\nexport default getValue;\n","import baseIsNative from './_baseIsNative.js';\nimport getValue from './_getValue.js';\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\nexport default getNative;\n","/**\n * The base implementation of `_.findIndex` and `_.findLastIndex` without\n * support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} predicate The function invoked per iteration.\n * @param {number} fromIndex The index to search from.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction baseFindIndex(array, predicate, fromIndex, fromRight) {\n var length = array.length,\n index = fromIndex + (fromRight ? 1 : -1);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n}\n\nexport default baseFindIndex;\n","/**\n * The base implementation of `_.isNaN` without support for number objects.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.\n */\nfunction baseIsNaN(value) {\n return value !== value;\n}\n\nexport default baseIsNaN;\n","/**\n * A specialized version of `_.indexOf` which performs strict equality\n * comparisons of values, i.e. `===`.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction strictIndexOf(array, value, fromIndex) {\n var index = fromIndex - 1,\n length = array.length;\n\n while (++index < length) {\n if (array[index] === value) {\n return index;\n }\n }\n return -1;\n}\n\nexport default strictIndexOf;\n","import baseFindIndex from './_baseFindIndex.js';\nimport baseIsNaN from './_baseIsNaN.js';\nimport strictIndexOf from './_strictIndexOf.js';\n\n/**\n * The base implementation of `_.indexOf` without `fromIndex` bounds checks.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction baseIndexOf(array, value, fromIndex) {\n return value === value\n ? strictIndexOf(array, value, fromIndex)\n : baseFindIndex(array, baseIsNaN, fromIndex);\n}\n\nexport default baseIndexOf;\n","/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n var type = typeof value;\n length = length == null ? MAX_SAFE_INTEGER : length;\n\n return !!length &&\n (type == 'number' ||\n (type != 'symbol' && reIsUint.test(value))) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\nexport default isIndex;\n","/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\nexport default eq;\n","/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\nexport default isLength;\n","import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]';\n\n/**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\nfunction baseIsArguments(value) {\n return isObjectLike(value) && baseGetTag(value) == argsTag;\n}\n\nexport default baseIsArguments;\n","import baseIsArguments from './_baseIsArguments.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nvar isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&\n !propertyIsEnumerable.call(value, 'callee');\n};\n\nexport default isArguments;\n","import isArray from './isArray.js';\nimport isSymbol from './isSymbol.js';\n\n/** Used to match property names within property paths. */\nvar reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,\n reIsPlainProp = /^\\w*$/;\n\n/**\n * Checks if `value` is a property name and not a property path.\n *\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n */\nfunction isKey(value, object) {\n if (isArray(value)) {\n return false;\n }\n var type = typeof value;\n if (type == 'number' || type == 'symbol' || type == 'boolean' ||\n value == null || isSymbol(value)) {\n return true;\n }\n return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||\n (object != null && value in Object(object));\n}\n\nexport default isKey;\n","import getNative from './_getNative.js';\n\n/* Built-in method references that are verified to be native. */\nvar nativeCreate = getNative(Object, 'create');\n\nexport default nativeCreate;\n","import nativeCreate from './_nativeCreate.js';\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n}\n\nexport default hashClear;\n","/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n}\n\nexport default hashDelete;\n","import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\nexport default hashGet;\n","import nativeCreate from './_nativeCreate.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);\n}\n\nexport default hashHas;\n","import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\nexport default hashSet;\n","import hashClear from './_hashClear.js';\nimport hashDelete from './_hashDelete.js';\nimport hashGet from './_hashGet.js';\nimport hashHas from './_hashHas.js';\nimport hashSet from './_hashSet.js';\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\nexport default Hash;\n","/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n}\n\nexport default listCacheClear;\n","import eq from './eq.js';\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\nexport default assocIndexOf;\n","import assocIndexOf from './_assocIndexOf.js';\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype;\n\n/** Built-in value references. */\nvar splice = arrayProto.splice;\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n}\n\nexport default listCacheDelete;\n","import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\nexport default listCacheGet;\n","import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\nexport default listCacheHas;\n","import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\nexport default listCacheSet;\n","import listCacheClear from './_listCacheClear.js';\nimport listCacheDelete from './_listCacheDelete.js';\nimport listCacheGet from './_listCacheGet.js';\nimport listCacheHas from './_listCacheHas.js';\nimport listCacheSet from './_listCacheSet.js';\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\nexport default ListCache;\n","import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map');\n\nexport default Map;\n","import Hash from './_Hash.js';\nimport ListCache from './_ListCache.js';\nimport Map from './_Map.js';\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\nexport default mapCacheClear;\n","/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\nexport default isKeyable;\n","import isKeyable from './_isKeyable.js';\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\nexport default getMapData;\n","import getMapData from './_getMapData.js';\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n}\n\nexport default mapCacheDelete;\n","import getMapData from './_getMapData.js';\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\nexport default mapCacheGet;\n","import getMapData from './_getMapData.js';\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\nexport default mapCacheHas;\n","import getMapData from './_getMapData.js';\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n}\n\nexport default mapCacheSet;\n","import mapCacheClear from './_mapCacheClear.js';\nimport mapCacheDelete from './_mapCacheDelete.js';\nimport mapCacheGet from './_mapCacheGet.js';\nimport mapCacheHas from './_mapCacheHas.js';\nimport mapCacheSet from './_mapCacheSet.js';\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\nexport default MapCache;\n","import MapCache from './_MapCache.js';\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * **Note:** The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `_.memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `clear`, `delete`, `get`, `has`, and `set`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n * var other = { 'c': 3, 'd': 4 };\n *\n * var values = _.memoize(_.values);\n * values(object);\n * // => [1, 2]\n *\n * values(other);\n * // => [3, 4]\n *\n * object.a = 2;\n * values(object);\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b']);\n * values(object);\n * // => ['a', 'b']\n *\n * // Replace `_.memoize.Cache`.\n * _.memoize.Cache = WeakMap;\n */\nfunction memoize(func, resolver) {\n if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var memoized = function() {\n var args = arguments,\n key = resolver ? resolver.apply(this, args) : args[0],\n cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n var result = func.apply(this, args);\n memoized.cache = cache.set(key, result) || cache;\n return result;\n };\n memoized.cache = new (memoize.Cache || MapCache);\n return memoized;\n}\n\n// Expose `MapCache`.\nmemoize.Cache = MapCache;\n\nexport default memoize;\n","import memoize from './memoize.js';\n\n/** Used as the maximum memoize cache size. */\nvar MAX_MEMOIZE_SIZE = 500;\n\n/**\n * A specialized version of `_.memoize` which clears the memoized function's\n * cache when it exceeds `MAX_MEMOIZE_SIZE`.\n *\n * @private\n * @param {Function} func The function to have its output memoized.\n * @returns {Function} Returns the new memoized function.\n */\nfunction memoizeCapped(func) {\n var result = memoize(func, function(key) {\n if (cache.size === MAX_MEMOIZE_SIZE) {\n cache.clear();\n }\n return key;\n });\n\n var cache = result.cache;\n return result;\n}\n\nexport default memoizeCapped;\n","import memoizeCapped from './_memoizeCapped.js';\n\n/** Used to match property names within property paths. */\nvar rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g;\n\n/** Used to match backslashes in property paths. */\nvar reEscapeChar = /\\\\(\\\\)?/g;\n\n/**\n * Converts `string` to a property path array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\nvar stringToPath = memoizeCapped(function(string) {\n var result = [];\n if (string.charCodeAt(0) === 46 /* . */) {\n result.push('');\n }\n string.replace(rePropName, function(match, number, quote, subString) {\n result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));\n });\n return result;\n});\n\nexport default stringToPath;\n","import baseToString from './_baseToString.js';\n\n/**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\nfunction toString(value) {\n return value == null ? '' : baseToString(value);\n}\n\nexport default toString;\n","import isArray from './isArray.js';\nimport isKey from './_isKey.js';\nimport stringToPath from './_stringToPath.js';\nimport toString from './toString.js';\n\n/**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {Object} [object] The object to query keys on.\n * @returns {Array} Returns the cast property path array.\n */\nfunction castPath(value, object) {\n if (isArray(value)) {\n return value;\n }\n return isKey(value, object) ? [value] : stringToPath(toString(value));\n}\n\nexport default castPath;\n","import isSymbol from './isSymbol.js';\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n */\nfunction toKey(value) {\n if (typeof value == 'string' || isSymbol(value)) {\n return value;\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\nexport default toKey;\n","/**\n * The base implementation of `_.slice` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\nfunction baseSlice(array, start, end) {\n var index = -1,\n length = array.length;\n\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = end > length ? length : end;\n if (end < 0) {\n end += length;\n }\n length = start > end ? 0 : ((end - start) >>> 0);\n start >>>= 0;\n\n var result = Array(length);\n while (++index < length) {\n result[index] = array[index + start];\n }\n return result;\n}\n\nexport default baseSlice;\n","import baseSlice from './_baseSlice.js';\n\n/**\n * Casts `array` to a slice if it's needed.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {number} start The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the cast slice.\n */\nfunction castSlice(array, start, end) {\n var length = array.length;\n end = end === undefined ? length : end;\n return (!start && end >= length) ? array : baseSlice(array, start, end);\n}\n\nexport default castSlice;\n","/** Used to compose unicode character classes. */\nvar rsAstralRange = '\\\\ud800-\\\\udfff',\n rsComboMarksRange = '\\\\u0300-\\\\u036f',\n reComboHalfMarksRange = '\\\\ufe20-\\\\ufe2f',\n rsComboSymbolsRange = '\\\\u20d0-\\\\u20ff',\n rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,\n rsVarRange = '\\\\ufe0e\\\\ufe0f';\n\n/** Used to compose unicode capture groups. */\nvar rsZWJ = '\\\\u200d';\n\n/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */\nvar reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');\n\n/**\n * Checks if `string` contains Unicode symbols.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {boolean} Returns `true` if a symbol is found, else `false`.\n */\nfunction hasUnicode(string) {\n return reHasUnicode.test(string);\n}\n\nexport default hasUnicode;\n","/**\n * Converts an ASCII `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\nfunction asciiToArray(string) {\n return string.split('');\n}\n\nexport default asciiToArray;\n","/** Used to compose unicode character classes. */\nvar rsAstralRange = '\\\\ud800-\\\\udfff',\n rsComboMarksRange = '\\\\u0300-\\\\u036f',\n reComboHalfMarksRange = '\\\\ufe20-\\\\ufe2f',\n rsComboSymbolsRange = '\\\\u20d0-\\\\u20ff',\n rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,\n rsVarRange = '\\\\ufe0e\\\\ufe0f';\n\n/** Used to compose unicode capture groups. */\nvar rsAstral = '[' + rsAstralRange + ']',\n rsCombo = '[' + rsComboRange + ']',\n rsFitz = '\\\\ud83c[\\\\udffb-\\\\udfff]',\n rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',\n rsNonAstral = '[^' + rsAstralRange + ']',\n rsRegional = '(?:\\\\ud83c[\\\\udde6-\\\\uddff]){2}',\n rsSurrPair = '[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]',\n rsZWJ = '\\\\u200d';\n\n/** Used to compose unicode regexes. */\nvar reOptMod = rsModifier + '?',\n rsOptVar = '[' + rsVarRange + ']?',\n rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',\n rsSeq = rsOptVar + reOptMod + rsOptJoin,\n rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';\n\n/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */\nvar reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');\n\n/**\n * Converts a Unicode `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\nfunction unicodeToArray(string) {\n return string.match(reUnicode) || [];\n}\n\nexport default unicodeToArray;\n","import asciiToArray from './_asciiToArray.js';\nimport hasUnicode from './_hasUnicode.js';\nimport unicodeToArray from './_unicodeToArray.js';\n\n/**\n * Converts `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\nfunction stringToArray(string) {\n return hasUnicode(string)\n ? unicodeToArray(string)\n : asciiToArray(string);\n}\n\nexport default stringToArray;\n","import castPath from './_castPath.js';\nimport isArguments from './isArguments.js';\nimport isArray from './isArray.js';\nimport isIndex from './_isIndex.js';\nimport isLength from './isLength.js';\nimport toKey from './_toKey.js';\n\n/**\n * Checks if `path` exists on `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @param {Function} hasFunc The function to check properties.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n */\nfunction hasPath(object, path, hasFunc) {\n path = castPath(path, object);\n\n var index = -1,\n length = path.length,\n result = false;\n\n while (++index < length) {\n var key = toKey(path[index]);\n if (!(result = object != null && hasFunc(object, key))) {\n break;\n }\n object = object[key];\n }\n if (result || ++index != length) {\n return result;\n }\n length = object == null ? 0 : object.length;\n return !!length && isLength(length) && isIndex(key, length) &&\n (isArray(object) || isArguments(object));\n}\n\nexport default hasPath;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * The base implementation of `_.has` without support for deep paths.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {Array|string} key The key to check.\n * @returns {boolean} Returns `true` if `key` exists, else `false`.\n */\nfunction baseHas(object, key) {\n return object != null && hasOwnProperty.call(object, key);\n}\n\nexport default baseHas;\n","import baseHas from './_baseHas.js';\nimport hasPath from './_hasPath.js';\n\n/**\n * Checks if `path` is a direct property of `object`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n * @example\n *\n * var object = { 'a': { 'b': 2 } };\n * var other = _.create({ 'a': _.create({ 'b': 2 }) });\n *\n * _.has(object, 'a');\n * // => true\n *\n * _.has(object, 'a.b');\n * // => true\n *\n * _.has(object, ['a', 'b']);\n * // => true\n *\n * _.has(other, 'a');\n * // => false\n */\nfunction has(object, path) {\n return object != null && hasPath(object, path, baseHas);\n}\n\nexport default has;\n","import baseIndexOf from './_baseIndexOf.js';\n\n/**\n * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol\n * that is not found in the character symbols.\n *\n * @private\n * @param {Array} strSymbols The string symbols to inspect.\n * @param {Array} chrSymbols The character symbols to find.\n * @returns {number} Returns the index of the last unmatched string symbol.\n */\nfunction charsEndIndex(strSymbols, chrSymbols) {\n var index = strSymbols.length;\n\n while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}\n return index;\n}\n\nexport default charsEndIndex;\n","import baseIndexOf from './_baseIndexOf.js';\n\n/**\n * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol\n * that is not found in the character symbols.\n *\n * @private\n * @param {Array} strSymbols The string symbols to inspect.\n * @param {Array} chrSymbols The character symbols to find.\n * @returns {number} Returns the index of the first unmatched string symbol.\n */\nfunction charsStartIndex(strSymbols, chrSymbols) {\n var index = -1,\n length = strSymbols.length;\n\n while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}\n return index;\n}\n\nexport default charsStartIndex;\n","import baseToString from './_baseToString.js';\nimport baseTrim from './_baseTrim.js';\nimport castSlice from './_castSlice.js';\nimport charsEndIndex from './_charsEndIndex.js';\nimport charsStartIndex from './_charsStartIndex.js';\nimport stringToArray from './_stringToArray.js';\nimport toString from './toString.js';\n\n/**\n * Removes leading and trailing whitespace or specified characters from `string`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to trim.\n * @param {string} [chars=whitespace] The characters to trim.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {string} Returns the trimmed string.\n * @example\n *\n * _.trim(' abc ');\n * // => 'abc'\n *\n * _.trim('-_-abc-_-', '_-');\n * // => 'abc'\n *\n * _.map([' foo ', ' bar '], _.trim);\n * // => ['foo', 'bar']\n */\nfunction trim(string, chars, guard) {\n string = toString(string);\n if (string && (guard || chars === undefined)) {\n return baseTrim(string);\n }\n if (!string || !(chars = baseToString(chars))) {\n return string;\n }\n var strSymbols = stringToArray(string),\n chrSymbols = stringToArray(chars),\n start = charsStartIndex(strSymbols, chrSymbols),\n end = charsEndIndex(strSymbols, chrSymbols) + 1;\n\n return castSlice(strSymbols, start, end).join('');\n}\n\nexport default trim;\n","import { has, trim } from \"lodash-es\";\n\n//import dotenv from \"dotenv\";\n// if (__DEV__) {\n// dotenv.config({\n// path: __ENV_PATH__\n// })\n// }\n\n//function _env(key: keyof EnvKeys, defaultValue?: string): string;\nfunction _env(key: string, defaultValue?: string): string {\n return has(process.env, key)\n ? (process.env[key] ?? \"\")\n : (defaultValue ?? \"\");\n}\n\n//function int(key: keyof EnvKeys, defaultValue?: number): number;\nfunction int(key: string, defaultValue?: number): number {\n if (!has(process.env, key)) {\n return defaultValue ?? 0;\n }\n const value = process.env[key] ?? \"0\";\n return parseInt(value, 10);\n}\n\n//function float(key: keyof EnvKeys, defaultValue?: number): number;\nfunction float(key: string, defaultValue?: number): number {\n if (!has(process.env, key)) {\n return defaultValue ?? 0;\n }\n\n const value = process.env[key] ?? \"0\";\n return parseFloat(value);\n}\n\n//function bool(key: keyof EnvKeys, defaultValue?: boolean): boolean;\nfunction bool(key: string, defaultValue?: boolean): boolean {\n if (!has(process.env, key)) {\n return defaultValue ?? false;\n }\n\n const value = process.env[key];\n return value === 'true';\n}\n\n//function json<T = any>(key: keyof EnvKeys, defaultValue?: T): T\nfunction json<T = any>(key: string, defaultValue?: T) {\n if (!has(process.env, key)) {\n return defaultValue ?? {};\n }\n\n const value = process.env[key] ?? \"{}\";\n try {\n return JSON.parse(value);\n } catch (error: any) {\n throw new Error(`Invalid json environment variable ${key}: ${error.message}`);\n }\n}\n\n//function array(key: keyof EnvKeys, defaultValue?: []): string[];\nfunction array(key: string, defaultValue?: []): Array<any> {\n if (!has(process.env, key)) {\n return defaultValue ?? [];\n }\n\n let value = process.env[key] ?? \"\";\n\n if (value.startsWith('[') && value.endsWith(']')) {\n value = value.substring(1, value.length - 1);\n }\n\n return value.split(',').map((v) => {\n return trim(trim(v, ' '), '\"');\n });\n}\n\n//function date(key: keyof EnvKeys, defaultValue?: Date): Date;\nfunction date(key: string, defaultValue?: Date): Date {\n if (!has(process.env, key)) {\n return defaultValue ?? new Date();\n }\n\n const value = process.env[key] ?? Date()\n return new Date(value);\n}\n\nconst utils = {\n\n int,\n\n float,\n\n bool,\n\n json,\n\n array,\n\n date,\n\n /**\n * Gets a value from env that matches oneOf provided values\n * @param {string} key\n * @param {string[]} expectedValues\n * @param {string|undefined} defaultValue\n * @returns {string|undefined}\n */\n oneOf(key: string, expectedValues: string[], defaultValue?: string): string {\n if (!expectedValues) {\n throw new Error(`env.oneOf requires expectedValues`);\n }\n\n if (defaultValue && !expectedValues.includes(defaultValue)) {\n throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);\n }\n\n const rawValue = env(key as any, defaultValue);\n return expectedValues.includes(rawValue) ? rawValue : (defaultValue ?? \"\");\n },\n};\n\nexport const env = Object.assign(_env, utils);","export const logLevels = {\n fatal: -1,\n error: 0,\n warn: 1,\n info: 2,\n debug: 3,\n trace: 4,\n};\n\nexport type Logger = {\n level: string;\n fatal: (mergeObject: Record<string, any> | string, msg?: string) => void;\n error: (mergeObject: Record<string, any> | string, msg?: string) => void;\n warn: (mergeObject: Record<string, any> | string, msg?: string) => void;\n info: (mergeObject: Record<string, any> | string, msg?: string) => void;\n debug: (mergeObject: Record<string, any> | string, msg?: string) => void;\n trace: (mergeObject: Record<string, any> | string, msg?: string) => void;\n silent: (mergeObject: Record<string, any> | string, msg?: string) => void;\n child: (bindings: Record<string, string>) => Logger;\n}","const safeJsonStringify = (value: unknown): string => {\n const seen = new WeakSet<object>();\n\n return JSON.stringify(value, (key, currentValue: unknown) => {\n if (key === 'constructor') return undefined;\n\n if (typeof currentValue === 'object' && currentValue !== null) {\n if (seen.has(currentValue)) return '[Circular]';\n seen.add(currentValue);\n }\n\n return currentValue;\n });\n};\n\nconst hasOwnConstructorProp = (value: unknown): boolean => {\n if (typeof value !== 'object' || value === null) return false;\n\n return Object.prototype.hasOwnProperty.call(value, 'constructor');\n};\n\nexport const errorToString = (error: unknown): string => {\n // Handle null or undefined\n if (error === null) return 'Null error';\n if (error === undefined) return 'Undefined error';\n\n // Handle Error objects\n if (error instanceof Error) {\n return [\n `Name: ${error.name}`,\n `Message: ${error.message}`,\n `Stack: ${error.stack || 'No stack trace available'}`,\n // Handle additional properties that might exist on custom errors\n ...Object.entries(error)\n .filter(\n ([key, value]) =>\n !['name', 'message', 'stack'].includes(key) && !hasOwnConstructorProp(value)\n )\n .map(([key, value]) => `${key}: ${safeJsonStringify(value)}`)\n ].join('\\n');\n }\n\n // Handle strings\n if (typeof error === 'string') return error;\n\n // Handle objects\n if (typeof error === 'object') {\n try {\n return JSON.stringify(\n error,\n (key, value: unknown) => {\n if (key === 'constructor') return undefined;\n return value;\n },\n 2\n );\n } catch {\n return `[Object that cannot be stringified: ${Object.prototype.toString.call(error)}]`;\n }\n }\n\n // Handle other primitives\n return String(error);\n};\n","import { EOL } from \"os\";\n\nexport type LogEntry = {\n level: number;\n levelName: string;\n time: number;\n module: string;\n reqId: string;\n msg: string;\n meta?: Record<string, unknown>;\n};\n\nexport type LogWriter = (entry: LogEntry) => void;\n\nconst jsonWriter: LogWriter = (entry) => {\n process.stdout.write(JSON.stringify(entry) + EOL);\n};\n\nlet _writer: LogWriter = jsonWriter;\n\nexport function setWriter(writer: LogWriter): void {\n _writer = writer;\n}\n\nexport function getWriter(): LogWriter {\n return _writer;\n}\n","import { env } from \"../config\";\nimport { Logger, logLevels } from \"./types\";\nimport { errorToString } from \"./error-to-string\";\nimport { getWriter } from \"./writer\";\n\nexport { setWriter, getWriter } from \"./writer\";\nexport type { LogWriter, LogEntry } from \"./writer\";\n\nconst levelValues = {\n fatal: 70,\n error: 60,\n warn: 50,\n info: 40,\n debug: 30,\n trace: 20,\n} as const;\n\ntype LevelName = keyof typeof levelValues;\n\nlet currentLogLevel = 2;\nlet _module = \"default\";\nlet _requestId = \"\";\n\nexport function initializeLogger(moduleName: string, requestIdValue: string = \"\") {\n _module = moduleName;\n _requestId = requestIdValue;\n}\n\nfunction writeLine(level: LevelName, mergeObject: Record<string, any> | null, msg: string, bindings: Record<string, string>) {\n getWriter()({\n level: levelValues[level],\n levelName: level,\n time: Date.now(),\n module: bindings.module || _module,\n reqId: bindings.reqId || _requestId,\n msg: level === \"error\" || level === \"fatal\" ? errorToString(msg) : msg,\n ...(mergeObject ? { meta: mergeObject } : {}),\n });\n}\n\nfunction createLogger(bindings: Record<string, string> = {}): Logger & { child: (b: Record<string, string>) => ReturnType<typeof createLogger> } {\n const currentLogLevelName = (env(\"LOG_LEVEL\")?.toLowerCase() ?? \"info\") as keyof typeof logLevels;\n currentLogLevel = logLevels[currentLogLevelName] ?? logLevels.info;\n\n return {\n level: currentLogLevelName,\n fatal: (mergeObject: Record<string, any> | string, msg?: string) => {\n if (currentLogLevel >= logLevels.fatal) {\n typeof mergeObject === \"string\" || mergeObject instanceof Error\n ? writeLine(\"fatal\", null, mergeObject as any, bindings)\n : writeLine(\"fatal\", mergeObject, msg ?? \"\", bindings);\n }\n },\n error: (mergeObject: Record<string, any> | string, msg?: string) => {\n if (currentLogLevel >= logLevels.error) {\n typeof mergeObject === \"string\" || mergeObject instanceof Error\n ? writeLine(\"error\", null, mergeObject as any, bindings)\n : writeLine(\"error\", mergeObject, msg ?? \"\", bindings);\n }\n },\n warn: (mergeObject: Record<string, any> | string, msg?: string) => {\n if (currentLogLevel >= logLevels.warn) {\n typeof mergeObject === \"string\"\n ? writeLine(\"warn\", null, mergeObject, bindings)\n : writeLine(\"warn\", mergeObject, msg ?? \"\", bindings);\n }\n },\n info: (mergeObject: Record<string, any> | string, msg?: string) => {\n if (currentLogLevel >= logLevels.info) {\n typeof mergeObject === \"string\"\n ? writeLine(\"info\", null, mergeObject, bindings)\n : writeLine(\"info\", mergeObject, msg ?? \"\", bindings);\n }\n },\n debug: (mergeObject: Record<string, any> | string, msg?: string) => {\n if (currentLogLevel >= logLevels.debug) {\n typeof mergeObject === \"string\"\n ? writeLine(\"debug\", null, mergeObject, bindings)\n : writeLine(\"debug\", mergeObject, msg ?? \"\", bindings);\n }\n },\n trace: (mergeObject: Record<string, any> | string, msg?: string) => {\n if (currentLogLevel >= logLevels.trace) {\n typeof mergeObject === \"string\"\n ? writeLine(\"trace\", null, mergeObject, bindings)\n : writeLine(\"trace\", mergeObject, msg ?? \"\", bindings);\n }\n },\n silent: () => { },\n child: (childBindings: Record<string, string>) =>\n createLogger({ ...bindings, ...childBindings }),\n };\n}\n\nexport const logger = createLogger();\n","import path from \"path\";\nimport { FastifyInstance } from \"fastify\";\nimport fastifyStatic from \"@fastify/static\";\nimport fsPlugin from \"fastify-plugin\";\nimport { createRequire } from 'module';\nconst require = createRequire(import.meta.url);\n\nimport { setWriter, getWriter } from \"@cloudnux/utils\";\nimport type { LogEntry as UtilsLogEntry } from \"@cloudnux/utils\";\nimport { WebSocketConnectionGoneError } from \"@cloudnux/core-cloud-provider\";\n\nimport \"../queue-plugin\";\nimport \"../schedule-plugin\";\nimport \"../websocket-plugin\";\n\nimport { routeRegistry } from \"./route-registry\";\n\ninterface LogEntry {\n id: string;\n timestamp: Date;\n levelName: string;\n message: string;\n meta?: Record<string, unknown>;\n module: string;\n reqId: string;\n}\n\nclass LogStore {\n private logs: LogEntry[] = [];\n private maxLogs = 1000;\n private listeners: ((log: LogEntry) => void)[] = [];\n\n addLog(entry: LogEntry) {\n this.logs.unshift(entry);\n if (this.logs.length > this.maxLogs) {\n this.logs = this.logs.slice(0, this.maxLogs);\n }\n this.listeners.forEach(listener => listener(entry));\n }\n\n getLogs(limit = 100) {\n return this.logs.slice(0, limit);\n }\n\n clear() {\n this.logs = [];\n }\n\n subscribe(listener: (log: LogEntry) => void) {\n this.listeners.push(listener);\n return () => {\n this.listeners = this.listeners.filter(l => l !== listener);\n };\n }\n}\n\nconst logStore = new LogStore();\n\nexport interface DevConsolePluginOptions {\n prefix?: string;\n enableUI?: boolean;\n}\n\nasync function devConsolePluginFunction(\n fastify: FastifyInstance,\n options: DevConsolePluginOptions = {}\n) {\n const { prefix = 'console', enableUI = true } = options;\n\n // Chain into the utils logging pipeline — only when the plugin is actually registered.\n // pretty-writer.ts is already set (guaranteed by index.ts import order), so getWriter() returns it.\n const upstream = getWriter();\n setWriter((entry: UtilsLogEntry) => {\n logStore.addLog({\n id: Date.now().toString() + Math.random().toString(36).slice(2, 9),\n timestamp: new Date(entry.time),\n levelName: entry.levelName,\n message: entry.msg,\n meta: entry.meta,\n module: entry.module,\n reqId: entry.reqId,\n });\n upstream(entry);\n });\n\n // Restore upstream writer and clear log store on plugin teardown\n fastify.addHook('onClose', (_instance, done) => {\n setWriter(upstream);\n logStore.clear();\n done();\n });\n\n // Register route discovery hook for all routes\n fastify.addHook('onRoute', (routeOptions) => {\n if (routeOptions.prefix === \"/api\") {\n routeRegistry.register(routeOptions);\n }\n });\n\n // API endpoints\n fastify.get(`/${prefix}/routes`, async () => {\n return { routes: routeRegistry.getAll() };\n });\n\n fastify.get(`/${prefix}/routes/:method`, async (request) => {\n const { method } = request.params as { method: string };\n return { routes: routeRegistry.getByMethod(method) };\n });\n\n fastify.get(`/${prefix}/registry/stats`, async () => {\n return {\n totalRoutes: routeRegistry.count(),\n registeredAt: new Date()\n };\n });\n\n // Modules endpoints - group resources by module\n fastify.get(`/${prefix}/modules`, async (_, reply) => {\n const queueManager = fastify.queues;\n const schedulerManager = fastify.scheduler;\n const wsManager = fastify.websockets;\n\n if (!queueManager || !schedulerManager || !wsManager) {\n return reply.status(503).send({ error: 'Services not available' });\n }\n\n // Get all routes and filter HTTP routes by prefix\n const allRoutes = routeRegistry.getAll();\n const httpRoutes = allRoutes;\n\n // Get all modules from routes, queues, schedules, and websockets\n const moduleSet = new Set<string>();\n\n httpRoutes.forEach(route => {\n if (route.module) moduleSet.add(route.module);\n });\n\n const allQueueNames = queueManager.listQueues();\n const allJobNames = schedulerManager.listJobs();\n\n allQueueNames.forEach(queueName => {\n const queueStats = queueManager.getQueueStats(queueName);\n if (queueStats?.module) moduleSet.add(queueStats.module);\n });\n\n allJobNames.forEach(jobName => {\n const jobStats = schedulerManager.getJobStats(jobName);\n if (jobStats?.job.module) moduleSet.add(jobStats.job.module);\n });\n\n wsManager.getRegisteredPaths().forEach(p => {\n if (p.module) moduleSet.add(p.module);\n });\n\n // Create module objects\n const modules = Array.from(moduleSet).map(moduleName => {\n // Get routes for this module\n const moduleRoutes = httpRoutes.filter(route => route.module === moduleName);\n\n // Get queues for this module\n const moduleQueueNames = queueManager.listQueues(moduleName);\n const moduleQueues = moduleQueueNames.map(name => {\n const stats = queueManager.getQueueStats(name);\n return {\n name,\n stats: stats ? {\n incoming: stats.incoming.length,\n processing: stats.processing.length,\n dlq: stats.dlq.length\n } : null\n };\n });\n\n // Get schedules for this module\n const moduleJobNames = schedulerManager.listJobs(moduleName);\n const moduleSchedules = moduleJobNames.map(name => {\n const jobStats = schedulerManager.getJobStats(name);\n return {\n name,\n enabled: jobStats?.job.enabled || false,\n isRunning: jobStats?.isRunning || false,\n cronExpression: jobStats?.job.cronExpression,\n timezone: jobStats?.job.timezone\n };\n });\n\n // Get websockets for this module\n const moduleWebSockets = wsManager\n ? wsManager.getRegisteredPaths(moduleName).map(p => ({\n path: p.path,\n connectionCount: wsManager.getConnections(p.path).length\n }))\n : [];\n\n return {\n name: moduleName,\n routes: moduleRoutes,\n queues: moduleQueues,\n schedules: moduleSchedules,\n websockets: moduleWebSockets\n };\n });\n\n return { modules };\n });\n\n // Queues endpoints - access via decorator\n fastify.get(`/${prefix}/queues`, async (_, reply) => {\n const queueManager = fastify.queues;\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n const queueNames = queueManager.listQueues();\n const queues = queueNames.map(name => {\n const stats = queueManager.getQueueStats(name);\n return {\n name,\n stats: stats ? {\n incoming: stats.incoming.length,\n processing: stats.processing.length,\n dlq: stats.dlq.length\n } : null\n };\n });\n\n return { queues };\n });\n\n fastify.get(`/${prefix}/queues/:queueName`, async (request, reply) => {\n const { queueName } = request.params as { queueName: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n const queueStats = queueManager.getQueueStats(queueName);\n if (!queueStats) {\n return reply.status(404).send({ error: 'Queue not found' });\n }\n\n const config = queueManager.getConfig();\n\n return {\n name: queueName,\n stats: {\n incoming: queueStats.incoming.length,\n processing: queueStats.processing.length,\n dlq: queueStats.dlq.length,\n configuration: config\n },\n messages: {\n incoming: queueStats.incoming,\n processing: queueStats.processing,\n dlq: queueStats.dlq\n }\n };\n });\n\n // Queue action endpoints\n fastify.get(`/${prefix}/queues/:queueName/process-dlq`, async (request, reply) => {\n const { queueName } = request.params as { queueName: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n try {\n const result = await queueManager.processDlq(queueName);\n return reply.status(200).send(result);\n } catch (error) {\n return reply.status(500).send({\n message: 'Failed to process DLQ',\n error\n });\n }\n });\n\n fastify.get(`/${prefix}/queues/:queueName/purge-dlq`, async (request, reply) => {\n const { queueName } = request.params as { queueName: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n try {\n const result = await queueManager.purgeDlq(queueName);\n return reply.status(200).send(result);\n } catch (error) {\n return reply.status(500).send({\n message: 'Failed to purge DLQ',\n error\n });\n }\n });\n\n fastify.post(`/${prefix}/queues/:queueName/enqueue`, async (request, reply) => {\n const { queueName } = request.params as { queueName: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n try {\n const result = await queueManager.enqueueMessage(queueName, request.body, request.headers as Record<string, any>);\n return reply.status(200).send(result);\n } catch (error) {\n return reply.status(500).send({\n message: 'Failed to enqueue message',\n error\n });\n }\n });\n\n fastify.delete(`/${prefix}/queues/:queueName`, async (request, reply) => {\n const { queueName } = request.params as { queueName: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n try {\n await queueManager.removeQueue(queueName);\n return reply.status(200).send({\n status: 'success',\n message: `Queue ${queueName} removed successfully`\n });\n } catch (error) {\n return reply.status(500).send({\n message: 'Failed to remove queue',\n error\n });\n }\n });\n\n fastify.post(`/${prefix}/queues`, async (request, reply) => {\n const { queueName, module } = request.body as { queueName: string; module?: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n if (!queueName) {\n return reply.status(400).send({ error: 'Queue name is required' });\n }\n\n try {\n // Simple handler that logs messages\n const handler = async (message: any) => {\n console.log(`Processing message in ${queueName}:`, message);\n return undefined;\n };\n\n await queueManager.addQueue(queueName, handler, module);\n return reply.status(201).send({\n status: 'success',\n message: `Queue ${queueName} created successfully`,\n queueName\n });\n } catch (error) {\n return reply.status(500).send({\n message: 'Failed to create queue',\n error\n });\n }\n });\n\n // Schedules endpoints - access via decorator\n fastify.get(`/${prefix}/schedules`, async (_, reply) => {\n const schedulerManager = fastify.scheduler;\n if (!schedulerManager) {\n return reply.status(503).send({ error: 'Scheduler service not available' });\n }\n\n const jobNames = schedulerManager.listJobs();\n const jobs = jobNames.map(name => {\n const jobStats = schedulerManager.getJobStats(name);\n return {\n name,\n enabled: jobStats?.job.enabled || false,\n isRunning: jobStats?.isRunning || false,\n cronExpression: jobStats?.job.cronExpression,\n timezone: jobStats?.job.timezone\n };\n });\n\n return { schedules: jobs };\n });\n\n fastify.get(`/${prefix}/schedules/:jobName`, async (request, reply) => {\n const { jobName } = request.params as { jobName: string };\n const schedulerManager = (fastify as any).scheduler;\n\n if (!schedulerManager) {\n return reply.status(503).send({ error: 'Scheduler service not available' });\n }\n\n const jobStats = schedulerManager.getJobStats(jobName);\n if (!jobStats) {\n return reply.status(404).send({ error: 'Job not found' });\n }\n\n return {\n name: jobName,\n job: jobStats.job,\n isRunning: jobStats.isRunning,\n timerId: jobStats.timerId ? 'scheduled' : 'not_scheduled'\n };\n });\n\n // Schedule action endpoints - use decorators\n fastify.post(`/${prefix}/schedules/:jobName/trigger`, async (request, reply) => {\n const { jobName } = request.params as { jobName: string };\n const schedulerManager = fastify.scheduler;\n\n if (!schedulerManager) {\n return reply.status(503).send({ error: 'Scheduler service not available' });\n }\n\n try {\n await schedulerManager.triggerJob(jobName);\n return reply.status(200).send({\n status: 'success',\n message: `Schedule ${jobName} triggered successfully`\n });\n } catch {\n return reply.status(500).send({ error: 'Failed to trigger schedule' });\n }\n });\n\n fastify.put(`/${prefix}/schedules/:jobName/enable`, async (request, reply) => {\n const { jobName } = request.params as { jobName: string };\n const schedulerManager = fastify.scheduler;\n\n if (!schedulerManager) {\n return reply.status(503).send({ error: 'Scheduler service not available' });\n }\n\n try {\n await schedulerManager.enableJob(jobName);\n return reply.status(200).send({\n status: 'success',\n message: `Schedule ${jobName} enabled successfully`\n });\n } catch {\n return reply.status(500).send({ error: 'Failed to enable schedule' });\n }\n });\n\n fastify.put(`/${prefix}/schedules/:jobName/disable`, async (request, reply) => {\n const { jobName } = request.params as { jobName: string };\n const schedulerManager = fastify.scheduler;\n\n if (!schedulerManager) {\n return reply.status(503).send({ error: 'Scheduler service not available' });\n }\n\n try {\n await schedulerManager.disableJob(jobName);\n return reply.status(200).send({\n status: 'success',\n message: `Schedule ${jobName} disabled successfully`\n });\n } catch {\n return reply.status(500).send({ error: 'Failed to disable schedule' });\n }\n });\n\n // Logs endpoints\n fastify.get(`/${prefix}/logs`, async (request) => {\n const {\n limit = 100,\n level,\n module,\n reqId,\n } = request.query as {\n limit?: number;\n level?: string;\n module?: string;\n reqId?: string;\n };\n\n let logs = logStore.getLogs(Number(limit));\n\n if (level) {\n logs = logs.filter(log => log.levelName === level);\n }\n\n if (module) {\n logs = logs.filter(log => log.module === module);\n }\n\n if (reqId) {\n logs = logs.filter(log => log.reqId === reqId);\n }\n\n return { logs };\n });\n\n fastify.delete(`/${prefix}/logs`, async () => {\n logStore.clear();\n return { status: 'success', message: 'Logs cleared' };\n });\n\n // WebSocket endpoints\n fastify.get(`/${prefix}/websockets`, async (_, reply) => {\n const wsManager = fastify.websockets;\n if (!wsManager) {\n return reply.status(503).send({ error: 'WebSocket service not available' });\n }\n\n const connections = wsManager.getConnections();\n const pathSet = new Set(connections.map(c => c.path));\n const paths = Array.from(pathSet).map(p => ({\n path: p,\n connections: wsManager.getConnections(p).map(c => ({\n connectionId: c.connectionId,\n path: c.path,\n connectedAt: c.connectedAt,\n })),\n }));\n\n return { paths };\n });\n\n fastify.get(`/${prefix}/websockets/:path`, async (request, reply) => {\n const wsManager = fastify.websockets;\n if (!wsManager) {\n return reply.status(503).send({ error: 'WebSocket service not available' });\n }\n\n const { path: wsPath } = request.params as { path: string };\n const decodedPath = '/' + wsPath;\n const connections = wsManager.getConnections(decodedPath).map(c => ({\n connectionId: c.connectionId,\n path: c.path,\n connectedAt: c.connectedAt,\n }));\n\n return { path: decodedPath, connections };\n });\n\n fastify.post(`/${prefix}/websockets/:connectionId/send`, async (request, reply) => {\n const wsManager = fastify.websockets;\n if (!wsManager) {\n return reply.status(503).send({ error: 'WebSocket service not available' });\n }\n\n const { connectionId } = request.params as { connectionId: string };\n\n try {\n await wsManager.sendToClient(connectionId, request.body);\n return reply.status(200).send({ status: 'success', message: `Message sent to ${connectionId}` });\n } catch (error) {\n if (error instanceof WebSocketConnectionGoneError) {\n return reply.status(410).send({ error: error.message });\n }\n return reply.status(404).send({ error: (error as Error).message });\n }\n });\n\n // Server-Sent Events for real-time logs\n fastify.get(`/${prefix}/logs/stream`, async (request, reply) => {\n reply.type('text/event-stream');\n reply.header('Cache-Control', 'no-cache');\n reply.header('Connection', 'keep-alive');\n reply.header('Access-Control-Allow-Origin', '*');\n\n // Send initial logs\n const initialLogs = logStore.getLogs(50);\n reply.raw.write(`data: ${JSON.stringify({ type: 'initial', logs: initialLogs })}\\n\\n`);\n\n // Subscribe to new logs\n const unsubscribe = logStore.subscribe((log) => {\n reply.raw.write(`data: ${JSON.stringify({ type: 'log', log })}\\n\\n`);\n });\n\n // Cleanup on client disconnect\n request.raw.on('close', () => {\n unsubscribe();\n });\n });\n\n // Serve static UI files if enabled\n if (enableUI) {\n const devConsolePath = path.dirname(\n require.resolve('@cloudnux/dev-console/dist/index.html')\n );\n\n await fastify.register(fastifyStatic, {\n root: devConsolePath,\n decorateReply: true,\n prefix: `/${prefix}/`\n });\n\n // Serve dev-console SPA\n fastify.get(`/${prefix}`, async (_, reply) => {\n return reply.sendFile('index.html');\n });\n }\n}\n\nexport const devConsolePlugin = fsPlugin(devConsolePluginFunction, {\n name: 'dev-console-plugin'\n})","import { FastifyInstance, FastifyPluginAsync } from \"fastify\";\nimport fsPlugin from \"fastify-plugin\";\n\nimport { QueuePluginOptions, QueueService, SchedulerRef } from \"./types\";\n\nimport {\n DEFAULT_CONFIG,\n mergeConfig\n} from \"./core\";\n\nimport {\n createProcessMessageHandler,\n createBatchProcessor,\n createProcessingScheduler\n} from \"./processing\";\n\nimport {\n createPersistenceInitializer,\n createQueueStateSaver,\n createAllQueuesStateSaver,\n createDirtyQueuesStateSaver,\n createQueueStateLoader,\n createAllQueuesStateLoader\n} from \"./persistence\";\n\nimport { registerQueueRoutes } from \"./routes\";\nimport { createQueueManager, createQueueDecorator } from \"./decorator\";\n\nexport const queuesPlugin: FastifyPluginAsync<QueuePluginOptions> =\n fsPlugin(async (\n app: FastifyInstance,\n options: QueuePluginOptions\n ) => {\n // Configuration setup\n const config = mergeConfig(DEFAULT_CONFIG, options.config);\n\n // Initialize empty queues map\n const queues: Record<string, QueueService> = {};\n\n // Dirty tracking for debounced persistence\n const dirtyQueues = new Set<string>();\n const intervalIdHolder: { id?: NodeJS.Timeout } = {};\n\n // Create specialized functions using higher-order functions\n const processMessage = createProcessMessageHandler(config);\n\n const saveQueueState = config.persistence.enabled\n ? createQueueStateSaver(config)\n : undefined;\n\n const saveAllQueueStates = config.persistence.enabled && saveQueueState\n ? createAllQueuesStateSaver(config, saveQueueState)(queues)\n : async () => { };\n\n const saveDirtyQueueStates = config.persistence.enabled && saveQueueState\n ? createDirtyQueuesStateSaver(saveQueueState, dirtyQueues)(queues)\n : async () => { };\n\n const schedulerRef: SchedulerRef = {};\n\n const processBatch = createBatchProcessor(\n processMessage,\n config,\n config.persistence.enabled ? dirtyQueues : undefined,\n schedulerRef\n );\n\n const scheduleProcessing = createProcessingScheduler(processBatch, config);\n schedulerRef.current = scheduleProcessing;\n\n const loadQueueState = config.persistence.enabled\n ? createQueueStateLoader(\n config,\n scheduleProcessing,\n processMessage\n )(queues)\n : async () => { };\n\n const loadAllQueueStates = config.persistence.enabled\n ? createAllQueuesStateLoader(config, loadQueueState)\n : async () => { };\n\n const initializePersistence = config.persistence.enabled\n ? createPersistenceInitializer(config, loadAllQueueStates, saveDirtyQueueStates, saveAllQueueStates, intervalIdHolder)\n : async () => { };\n\n // Create and register queue manager decorator\n const queueManager = createQueueManager({\n config,\n queues,\n dirtyQueues,\n saveQueueState: saveQueueState ? (queueName: string) => saveQueueState(queueName, queues[queueName]) : undefined,\n loadQueueState,\n scheduleProcessing,\n processBatch,\n });\n const decorateQueues = createQueueDecorator(queueManager);\n decorateQueues(app);\n\n // Register all routes\n registerQueueRoutes(\n app,\n options.prefix\n );\n\n // Initialize persistence if enabled\n await initializePersistence();\n });\n","import { logger } from \"@cloudnux/utils\";\n\nimport { EventHandler, QueueConfig, QueueMessage, QueueService, QueueSummary } from \"./types\";\n\n// default config\nexport const DEFAULT_CONFIG: QueueConfig = {\n batchSize: 10,\n batchWindowMs: 500,\n maxRetries: 3,\n parallel: true,\n maxConcurrent: 5,\n retryBackoff: true,\n persistence: {\n enabled: true,\n directory: './.develop/queue-data',\n saveInterval: 60000,\n saveOnShutdown: false,\n loadOnStartup: true\n }\n};\n\n// Pure function to merge configs\nexport const mergeConfig = (defaultConfig: QueueConfig, userConfig?: Partial<QueueConfig>): QueueConfig => ({\n ...defaultConfig,\n ...userConfig,\n persistence: {\n ...defaultConfig.persistence,\n ...(userConfig?.persistence || {})\n }\n});\n\n// Pure function to create a new queue service\nexport const createQueueService = (handler: EventHandler, module?: string): QueueService => ({\n handler,\n incoming: [],\n processing: [],\n dlq: [],\n timeoutId: null,\n processingBatch: false,\n module\n});\n\n// Pure function to create a queue message\nexport const createQueueMessage = (body: any, headers: Record<string, any>): QueueMessage => {\n const id = Date.now().toString() + Math.random().toString(36).substring(2, 7);\n const message: QueueMessage = {\n id,\n timestamp: new Date(),\n attempts: 0,\n payload: body,\n attributes: headers,\n };\n\n const delaySeconds = Number(headers?.['x-delay-seconds']);\n if (delaySeconds > 0) {\n message.nextAttempt = new Date(Date.now() + delaySeconds * 1000);\n }\n\n return message;\n};\n\n// Pure function to check whether a message is ready to be processed\nexport const isMessageReady = (message: QueueMessage, now: number = Date.now()): boolean => {\n return !message.nextAttempt || message.nextAttempt.getTime() <= now;\n};\n\n// Pure function to move ready messages from incoming to processing, leaving delayed messages in place\nexport const moveToProcessing = (queueService: QueueService, batchSize: number): QueueMessage[] => {\n const now = Date.now();\n const ready: QueueMessage[] = [];\n const remaining: QueueMessage[] = [];\n\n for (const message of queueService.incoming) {\n if (ready.length < batchSize && isMessageReady(message, now)) {\n ready.push(message);\n } else {\n remaining.push(message);\n }\n }\n\n queueService.incoming = remaining;\n return ready;\n};\n\n// Pure function to compute the delay until the next delayed message in incoming becomes ready\nexport const getNextReadyDelay = (queueService: QueueService): number | null => {\n const nextAttempts = queueService.incoming\n .filter(message => message.nextAttempt)\n .map(message => message.nextAttempt!.getTime());\n\n if (nextAttempts.length === 0) return null;\n\n return Math.max(0, Math.min(...nextAttempts) - Date.now());\n};\n\n// Pure function to remove message from processing queue\nexport const removeFromProcessing = (queueService: QueueService, messageId: string): void => {\n queueService.processing = queueService.processing.filter(msg => msg.id !== messageId);\n};\n\n// Pure function to move message to DLQ\nexport const moveToDLQ = (queueService: QueueService, message: QueueMessage, error: string): void => {\n queueService.dlq.push({\n ...message,\n error,\n failedAt: new Date()\n });\n removeFromProcessing(queueService, message.id);\n};\n\n// Pure function to increment message attempts\nexport const incrementAttempts = (queueService: QueueService, messageId: string): QueueMessage | null => {\n const index = queueService.processing.findIndex(m => m.id === messageId);\n if (index >= 0) {\n queueService.processing[index].attempts += 1;\n return queueService.processing[index];\n }\n return null;\n};\n\n// Pure function to calculate backoff delay\nexport const calculateBackoffDelay = (attempts: number): number => {\n return Math.pow(2, attempts) * 100;\n};\n\n// Pure function to set next attempt time\nexport const setNextAttemptTime = (message: QueueMessage, delayMs: number): QueueMessage => ({\n ...message,\n nextAttempt: new Date(Date.now() + delayMs)\n});\n\n// Pure function to create queue summary\nexport const createQueueSummary = (queueService: QueueService, config: QueueConfig): QueueSummary => ({\n incoming: queueService.incoming.length,\n processing: queueService.processing.length,\n dlq: queueService.dlq.length,\n isProcessing: queueService.processingBatch,\n configuration: {\n batchSize: config.batchSize,\n batchWindowMs: config.batchWindowMs,\n parallel: config.parallel,\n maxConcurrent: config.maxConcurrent\n }\n});\n\n// Pure function to create dashboard summary\nexport const createDashboardSummary = (queues: Record<string, QueueService>, config: QueueConfig): Record<string, QueueSummary> => {\n return Object.entries(queues).reduce((summary, [queueName, queue]) => {\n summary[queueName] = createQueueSummary(queue, config);\n return summary;\n }, {} as Record<string, QueueSummary>);\n};\n\n// Pure function to move DLQ messages back to incoming\nexport const moveDLQToIncoming = (queueService: QueueService): number => {\n const dlqCount = queueService.dlq.length;\n\n if (dlqCount === 0) return 0;\n\n const movedMessages = queueService.dlq.map(message => ({\n ...message,\n attempts: 0,\n error: undefined,\n failedAt: undefined,\n reprocessed: true,\n originalId: message.id,\n id: Date.now().toString() + Math.random().toString(36).substring(2, 7)\n }));\n\n queueService.incoming.push(...movedMessages);\n queueService.dlq = [];\n\n return dlqCount;\n};\n\n// Pure function to purge DLQ\nexport const purgeDLQ = (queueService: QueueService): number => {\n const dlqCount = queueService.dlq.length;\n queueService.dlq = [];\n return dlqCount;\n};\n\n// Logging functions (side effects isolated)\nexport const logSuccess = (message: string, messageId: string, queueName: string): void => {\n logger.debug(`Success: ${message} ${messageId} in queue ${queueName}`);\n};\n\nexport const logError = (message: string, messageId: string, queueName: string, error: string): void => {\n logger.error(`Error: ${message} ${messageId} in queue ${queueName}: ${error}`);\n};\n\nexport const logRetryScheduled = (messageId: string, delayMs: number): void => {\n logger.debug(`Scheduling retry for message ${messageId} in ${delayMs}ms`);\n};\n\nexport const logDLQOperation = (operation: string, count: number, queueName: string): void => {\n logger.warn(`${operation} ${count} messages from DLQ for ${queueName}`);\n};","import { QueueConfig, QueueMessage, QueueService, SchedulerRef } from \"./types\";\nimport {\n moveToProcessing,\n removeFromProcessing,\n moveToDLQ,\n incrementAttempts,\n calculateBackoffDelay,\n setNextAttemptTime,\n getNextReadyDelay,\n logSuccess,\n logError,\n logRetryScheduled\n} from \"./core\";\n\n// Higher-order function for creating processing context\nexport const createProcessMessageHandler = (\n config: QueueConfig\n) => async (queueName: string, message: QueueMessage, queueService: QueueService): Promise<void> => {\n try {\n const result = await queueService.handler(message);\n\n if (result?.failureId) {\n await handleProcessingError(queueName, message, queueService, config);\n } else {\n removeFromProcessing(queueService, message.id);\n logSuccess('Successfully processed message', message.id, queueName);\n }\n } catch {\n await handleProcessingError(queueName, message, queueService, config);\n }\n};\n\n// Higher-order function for handling processing errors\nconst handleProcessingError = async (\n queueName: string,\n message: QueueMessage,\n queueService: QueueService,\n config: QueueConfig,\n): Promise<void> => {\n logError('Error processing message', message.id, queueName, 'handler returned failure');\n\n if (message.attempts >= config.maxRetries) {\n moveToDLQ(queueService, message, 'max retries exceeded');\n return;\n }\n\n const updatedMessage = incrementAttempts(queueService, message.id);\n if (!updatedMessage) return;\n\n if (config.retryBackoff) {\n const delayMs = calculateBackoffDelay(updatedMessage.attempts);\n const messageWithNextAttempt = setNextAttemptTime(updatedMessage, delayMs);\n\n logRetryScheduled(message.id, delayMs);\n\n setTimeout(() => {\n createProcessMessageHandler(config)(queueName, messageWithNextAttempt, queueService);\n }, delayMs);\n }\n};\n\n// Higher-order function for batch processing\nexport const createBatchProcessor = (\n processMessage: (queueName: string, message: QueueMessage, queueService: QueueService) => Promise<void>,\n config: QueueConfig,\n dirtyQueues?: Set<string>,\n schedulerRef?: SchedulerRef\n) => async (queueName: string, queueService: QueueService): Promise<void> => {\n // Clear timeout to prevent double processing\n if (queueService.timeoutId) {\n clearTimeout(queueService.timeoutId);\n queueService.timeoutId = null;\n }\n\n // If already processing, return early\n if (queueService.processingBatch) {\n return;\n }\n\n try {\n queueService.processingBatch = true;\n\n const messagesToProcess = moveToProcessing(queueService, config.batchSize);\n\n if (messagesToProcess.length > 0) {\n queueService.processing.push(...messagesToProcess);\n\n // Process messages in parallel\n await Promise.all(messagesToProcess.map(message => {\n return processMessage(queueName, message, queueService);\n }));\n\n // Mark queue as dirty for periodic persistence\n if (config.persistence.enabled && dirtyQueues) {\n dirtyQueues.add(queueName);\n }\n }\n } finally {\n queueService.processingBatch = false;\n\n // If delayed messages remain, schedule a wake-up for when the earliest one becomes ready\n const nextReadyDelay = getNextReadyDelay(queueService);\n if (nextReadyDelay !== null) {\n schedulerRef?.current?.(queueName, queueService, nextReadyDelay);\n }\n }\n};\n\n// Higher-order function for scheduling processing\nexport const createProcessingScheduler = (\n processBatch: (queueName: string, queueService: QueueService) => Promise<void>,\n config: QueueConfig\n) => (queueName: string, queueService: QueueService, overrideDelay: number | null = null): void => {\n if (!queueService.timeoutId) {\n const delay = overrideDelay ?? config.batchWindowMs;\n queueService.timeoutId = setTimeout(() => {\n processBatch(queueName, queueService);\n }, delay);\n }\n};\n\n// Function to handle immediate processing when batch size is reached\nexport const handleImmediateProcessing = (\n queueService: QueueService,\n config: QueueConfig,\n processBatch: (queueName: string, queueService: QueueService) => Promise<void>,\n queueName: string\n): void => {\n if (queueService.incoming.length >= config.batchSize) {\n if (queueService.timeoutId) {\n clearTimeout(queueService.timeoutId);\n queueService.timeoutId = null;\n }\n setImmediate(() => processBatch(queueName, queueService));\n }\n};","import * as fs from \"fs/promises\";\nimport * as path from \"path\";\n\nimport { logger } from \"@cloudnux/utils\";\n\nimport { QueueConfig, QueueService } from \"./types\";\n\n// Pure function to create queue data for persistence\nconst createQueueData = (queueService: QueueService) => ({\n incoming: queueService.incoming,\n processing: queueService.processing,\n dlq: queueService.dlq,\n savedAt: new Date()\n});\n\n// Pure function to restore date objects from JSON\nconst restoreDates = (messages: any[]): void => {\n messages.forEach((msg: any) => {\n msg.timestamp = new Date(msg.timestamp);\n if (msg.nextAttempt) msg.nextAttempt = new Date(msg.nextAttempt);\n if (msg.failedAt) msg.failedAt = new Date(msg.failedAt);\n });\n};\n\n// Higher-order function to create persistence initializer\nexport const createPersistenceInitializer = (\n config: QueueConfig,\n loadAllQueueStates: () => Promise<void>,\n saveDirtyQueueStates: () => Promise<void>,\n saveAllQueueStates: () => Promise<void>,\n intervalIdHolder: { id?: NodeJS.Timeout }\n) => async (): Promise<void> => {\n try {\n await fs.mkdir(config.persistence.directory, { recursive: true });\n\n if (config.persistence.loadOnStartup) {\n await loadAllQueueStates();\n }\n\n if (config.persistence.saveInterval && config.persistence.saveInterval > 0) {\n intervalIdHolder.id = setInterval(saveDirtyQueueStates, config.persistence.saveInterval);\n }\n\n if (config.persistence.saveOnShutdown) {\n const shutdownHandler = async () => {\n logger.debug('Saving queue state before shutdown...');\n if (intervalIdHolder.id) {\n clearInterval(intervalIdHolder.id);\n }\n await saveAllQueueStates();\n process.exit(0);\n };\n\n process.on('SIGINT', shutdownHandler);\n process.on('SIGTERM', shutdownHandler);\n }\n\n logger.debug(`Queue persistence initialized: ${config.persistence.directory}`);\n } catch (error: any) {\n logger.error(`Failed to initialize queue persistence: ${error?.message}`);\n }\n};\n\n// Higher-order function to create queue state saver\nexport const createQueueStateSaver = (config: QueueConfig) => async (queueName: string, queueService: QueueService): Promise<void> => {\n try {\n if (!queueService) return;\n\n const queueData = createQueueData(queueService);\n const now = Date.now();\n const queueFilePath = path.join(config.persistence.directory, `${queueName}.json`);\n const tempFilePath = path.join(config.persistence.directory, `${queueName}.${now}temp.json`);\n\n // Write to temporary file first\n await fs.writeFile(tempFilePath, JSON.stringify(queueData, null, 2), 'utf8');\n\n // Rename temporary file to the actual file (atomic operation)\n await fs.rename(tempFilePath, queueFilePath);\n\n logger.debug(`Queue state saved: ${queueName}`);\n } catch (error: any) {\n logger.error(`Failed to save queue state for ${queueName}:`, error?.message);\n }\n};\n\n// Higher-order function to create all queues state saver\nexport const createAllQueuesStateSaver = (\n config: QueueConfig,\n saveQueueState: (queueName: string, queueService: QueueService) => Promise<void>\n) => (queues: Record<string, QueueService>) => async (): Promise<void> => {\n try {\n for (const [queueName, queueService] of Object.entries(queues)) {\n await saveQueueState(queueName, queueService);\n }\n logger.debug(`All queue states saved to ${config.persistence.directory}`);\n } catch (error: any) {\n logger.error(`Failed to save all queue states: ${error?.message}`);\n }\n};\n\n// Higher-order function to create dirty queues state saver (only saves changed queues)\nexport const createDirtyQueuesStateSaver = (\n saveQueueState: (queueName: string, queueService: QueueService) => Promise<void>,\n dirtyQueues: Set<string>\n) => (queues: Record<string, QueueService>) => async (): Promise<void> => {\n if (dirtyQueues.size === 0) return;\n\n try {\n const queueNames = [...dirtyQueues];\n dirtyQueues.clear();\n\n for (const queueName of queueNames) {\n if (queues[queueName]) {\n await saveQueueState(queueName, queues[queueName]);\n }\n }\n } catch (error: any) {\n logger.error(`Failed to save dirty queue states: ${error?.message}`);\n }\n};\n\n// Higher-order function to create queue state loader\nexport const createQueueStateLoader = (\n config: QueueConfig,\n scheduleProcessing: (queueName: string, queueService: QueueService) => void,\n processMessage: (queueName: string, message: any, queueService: QueueService) => Promise<void>\n) => (queues: Record<string, QueueService>) => async (queueName: string): Promise<void> => {\n try {\n if (!queues[queueName]) {\n logger.warn(`Skipping load for non-existent queue: ${queueName}`);\n return;\n }\n\n const queueFilePath = path.join(config.persistence.directory, `${queueName}.json`);\n\n try {\n const data = await fs.readFile(queueFilePath, 'utf8');\n const queueData = JSON.parse(data);\n\n // Restore date objects\n restoreDates(queueData.incoming);\n restoreDates(queueData.processing);\n restoreDates(queueData.dlq);\n\n // Restore queue state\n queues[queueName].incoming = queueData.incoming;\n queues[queueName].processing = queueData.processing;\n queues[queueName].dlq = queueData.dlq;\n\n logger.debug(`Queue state loaded: ${queueName} (saved at ${queueData.savedAt})`);\n\n // Schedule processing for any messages that were in flight\n if (queues[queueName].incoming.length > 0) {\n scheduleProcessing(queueName, queues[queueName]);\n }\n\n // Re-process any messages that were in the processing queue\n if (queues[queueName].processing.length > 0) {\n for (const message of [...queues[queueName].processing]) {\n if (message.attempts >= config.maxRetries) continue;\n\n setTimeout(() => {\n processMessage(queueName, message, queues[queueName]);\n }, 100 * (Math.random() * 10));\n }\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n logger.debug(`No saved state found for queue: ${queueName}`);\n } else {\n throw error;\n }\n }\n } catch (error: any) {\n logger.error(`Failed to load queue state for ${queueName}:`, error?.message);\n }\n};\n\n// Higher-order function to create all queues state loader\nexport const createAllQueuesStateLoader = (\n config: QueueConfig,\n loadQueueState: (queueName: string) => Promise<void>\n) => async (): Promise<void> => {\n try {\n const files = await fs.readdir(config.persistence.directory);\n const queueFiles = files.filter(file => file.endsWith('.json') && !file.includes('.temp.'));\n\n for (const file of queueFiles) {\n const queueName = path.basename(file, '.json');\n await loadQueueState(queueName);\n }\n\n logger.debug('All queue states loaded');\n } catch (error: any) {\n logger.error('Failed to load queue states:', error?.message);\n }\n};","import { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\n\n// Function to register all routes\nexport const registerQueueRoutes = (\n app: FastifyInstance,\n prefix: string = \"\"\n): void => {\n app.get(`/${prefix}/dashboard`,\n async (_: FastifyRequest, reply: FastifyReply) => {\n const summary = app.queues.getDashboardSummary();\n return reply.status(200).send(summary);\n });\n\n app.get<{ Params: { queue: string } }>(`/${prefix}/:queue`,\n async (request: FastifyRequest<{ Params: { queue: string } }>, reply: FastifyReply) => {\n const queueName = request.params.queue;\n const summary = app.queues.getQueueSummary(queueName);\n if (summary === null) {\n return reply.status(404).send({ error: \"Queue not found\" });\n }\n return reply.status(200).send(summary);\n });\n\n app.post<{ Params: { queue: string }; Body: any }>(`/${prefix}/:queue`,\n async (request: FastifyRequest<{ Params: { queue: string }; Body: any }>, reply: FastifyReply) => {\n const queueName = request.params.queue;\n const result = await app.queues.enqueueMessage(queueName, request.body, request.headers as Record<string, any>);\n if (result === null) {\n return reply.status(404).send({ error: \"Queue not found\" });\n }\n return reply.status(200).send(result);\n });\n\n app.get<{ Params: { queue: string } }>(`/${prefix}/:queue/process-dlq`,\n async (request: FastifyRequest<{ Params: { queue: string } }>, reply: FastifyReply) => {\n const queueName = request.params.queue;\n const result = await app.queues.processDlq(queueName);\n if (result === null) {\n return reply.status(404).send(result);\n }\n return reply.status(200).send(result);\n });\n\n app.post<{ Params: { queue: string } }>(`/${prefix}/:queue/purge-dlq`,\n async (request: FastifyRequest<{ Params: { queue: string } }>, reply: FastifyReply) => {\n const queueName = request.params.queue;\n const result = await app.queues.purgeDlq(queueName);\n if (result === null) {\n return reply.status(404).send({ error: \"Queue not found\" });\n }\n return reply.status(200).send(result);\n });\n};","import { FastifyInstance } from \"fastify\";\n\nimport { logger } from \"@cloudnux/utils\";\n\nimport { QueueService, QueueManager, QueueDecoratorOptions, EventHandler } from \"./types\";\nimport {\n createQueueService,\n createQueueMessage,\n createDashboardSummary,\n createQueueSummary,\n moveDLQToIncoming,\n purgeDLQ,\n logDLQOperation\n} from \"./core\";\n\nimport { handleImmediateProcessing } from \"./processing\";\n\nconst isValidQueueName = (queueName: string): boolean => {\n return typeof queueName === 'string' && queueName.length > 0 && /^[a-zA-Z0-9_-]+$/.test(queueName);\n};\n\n// Higher-order function to create the queue manager\nexport const createQueueManager = ({\n config,\n queues,\n dirtyQueues,\n saveQueueState,\n loadQueueState,\n scheduleProcessing,\n processBatch\n}: QueueDecoratorOptions): QueueManager => {\n\n // Pure function to validate queue name\n const validateQueueName = (queueName: string): void => {\n if (!queueName || typeof queueName !== 'string') {\n throw new Error('Queue name must be a non-empty string');\n }\n\n if (!isValidQueueName(queueName)) {\n throw new Error('Queue name must contain only alphanumeric characters, hyphens, and underscores');\n }\n };\n\n // Pure function to validate handler\n const validateHandler = (handler: any): void => {\n if (typeof handler !== 'function') {\n throw new Error('Handler must be a function');\n }\n };\n\n const addQueue = async (queueName: string, handler: EventHandler, module?: string): Promise<void> => {\n try {\n validateQueueName(queueName);\n validateHandler(handler);\n\n //TODO: add queue filtering logic\n if (queues[queueName]) {\n logger.warn(`Queue already exists: ${queueName}.`);\n return;\n }\n\n // Create new queue service\n queues[queueName] = createQueueService(handler, module);\n\n // Load existing state if persistence is enabled\n if (config.persistence.enabled && loadQueueState) {\n await loadQueueState(queueName);\n }\n\n logger.info(`Queue added: ${queueName}`);\n } catch (error: any) {\n logger.error(`Failed to add queue ${queueName}: ${error.message}`);\n throw error;\n }\n };\n const removeQueue = async (queueName: string): Promise<void> => {\n try {\n validateQueueName(queueName);\n\n if (!queues[queueName]) {\n throw new Error(`Queue '${queueName}' does not exist`);\n }\n\n const queueService = queues[queueName];\n\n // Check if queue has pending messages\n const totalMessages = queueService.incoming.length + queueService.processing.length;\n if (totalMessages > 0) {\n logger.warn(`Removing queue with ${totalMessages} pending messages: ${queueName}`);\n }\n\n // Clear any scheduled processing\n if (queueService.timeoutId) {\n clearTimeout(queueService.timeoutId);\n }\n\n // Save final state if persistence is enabled\n if (config.persistence.enabled && saveQueueState) {\n await saveQueueState(queueName, queueService);\n }\n\n // Remove from queues map\n delete queues[queueName];\n\n logger.info(`Queue removed: ${queueName}`);\n } catch (error: any) {\n logger.error(`Failed to remove queue ${queueName}: ${error.message}`);\n throw error;\n }\n };\n const hasQueue = (queueName: string): boolean => {\n try {\n validateQueueName(queueName);\n return queueName in queues;\n } catch {\n return false;\n }\n };\n const listQueues = (module?: string): string[] => {\n return Object.keys(queues).filter(queueName => {\n const queueService = queues[queueName];\n return !module || queueService.module === module;\n }).sort();\n };\n const getQueueStats = (queueName: string): QueueService | null => {\n try {\n validateQueueName(queueName);\n return queues[queueName] || null;\n } catch {\n return null;\n }\n };\n const getQueuesMap = (): Record<string, QueueService> => {\n // Return a copy to prevent external modification\n return { ...queues };\n };\n const getConfig = () => config;\n //==========================================================\n const getDashboardSummary = () => createDashboardSummary(queues, config);\n const getQueueSummary = (queueName: string) => {\n if (!queues[queueName]) {\n return null;\n }\n\n const queue = queues[queueName];\n const stats = createQueueSummary(queue, config);\n\n return {\n stats,\n messages: {\n incoming: queue.incoming,\n processing: queue.processing,\n dlq: queue.dlq\n }\n };\n }\n const enqueueMessage = async (queueName: string, body: any, attributes: any) => {\n if (!queues[queueName]) {\n return null;\n }\n\n const message = createQueueMessage(body, attributes);\n queues[queueName].incoming.push(message);\n\n // Schedule processing if not already scheduled\n scheduleProcessing(queueName, queues[queueName]);\n\n // Handle immediate processing if batch size is reached\n handleImmediateProcessing(queues[queueName], config, processBatch, queueName);\n\n // Mark queue as dirty for periodic persistence\n if (config.persistence.enabled) {\n dirtyQueues.add(queueName);\n }\n\n return {\n id: message.id,\n queueName\n }\n }\n const processDlq = async (queueName: string) => {\n if (!queues[queueName]) {\n return null;\n }\n\n const processedCount = moveDLQToIncoming(queues[queueName]);\n\n if (processedCount === 0) {\n return {\n status: \"success\",\n message: \"No messages in DLQ to process\",\n processed: 0\n };\n }\n\n logDLQOperation('Moving', processedCount, queueName);\n\n // Schedule processing if not already scheduled\n scheduleProcessing(queueName, queues[queueName]);\n\n // Mark queue as dirty for periodic persistence\n if (config.persistence.enabled) {\n dirtyQueues.add(queueName);\n }\n\n return {\n status: \"success\",\n message: `Moved ${processedCount} messages from DLQ to processing queue`,\n processed: processedCount\n }\n }\n const purgeDlq = async (queueName: string) => {\n if (!queues[queueName]) {\n return null;\n }\n\n const purgedCount = purgeDLQ(queues[queueName]);\n\n if (purgedCount === 0) {\n return {\n status: \"success\",\n message: \"No messages in DLQ to purge\",\n purged: 0\n };\n }\n\n logDLQOperation('Purging', purgedCount, queueName);\n\n // Mark queue as dirty for periodic persistence\n if (config.persistence.enabled) {\n dirtyQueues.add(queueName);\n }\n\n return {\n status: \"success\",\n message: `Purged ${purgedCount} messages from DLQ`,\n purged: purgedCount\n };\n }\n\n return {\n addQueue,\n removeQueue,\n hasQueue,\n listQueues,\n getQueueStats,\n getQueuesMap,\n getConfig,\n\n getDashboardSummary,\n getQueueSummary,\n enqueueMessage,\n processDlq,\n purgeDlq\n };\n};\n\n// Higher-order function to create decorator registration function\nexport const createQueueDecorator = (queueManager: QueueManager) =>\n (app: FastifyInstance): void => {\n app.decorate('queues', queueManager);\n };","import { FastifyInstance, FastifyPluginAsync } from \"fastify\";\nimport fsPlugin from \"fastify-plugin\";\n\nimport { SchedulerPluginOptions } from \"./types\";\nimport {\n DEFAULT_CONFIG,\n mergeConfig,\n createInitialState,\n createSchedulerFunctions,\n initializeScheduler\n //setupSchedulerLifecycle\n} from \"./core\";\nimport { registerAllRoutes } from \"./routes\";\nimport { createSchedulerDecorator, createSchedulerManager } from \"./decorator\";\n\n\nexport const schedulerPlugin: FastifyPluginAsync<SchedulerPluginOptions> =\n fsPlugin(async (\n app: FastifyInstance,\n options: SchedulerPluginOptions\n ) => {\n const config = mergeConfig(DEFAULT_CONFIG, options.config);\n\n // Initialize scheduler state\n const state = createInitialState(config);\n\n // Create both functions together to avoid circular dependency\n const { executeJob, scheduleJobFn } = createSchedulerFunctions(state);\n\n // Initialize the scheduler\n await initializeScheduler(state, scheduleJobFn);\n\n // Setup lifecycle management\n //setupSchedulerLifecycle(state, app);\n\n // Create and register scheduler manager decorator\n const schedulerManager = createSchedulerManager({\n state,\n config,\n scheduleJobFn,\n executeJob\n });\n const decorateScheduler = createSchedulerDecorator(schedulerManager);\n decorateScheduler(app);\n\n // Register API routes\n registerAllRoutes(app, state, executeJob, scheduleJobFn);\n });","import * as fs from \"fs/promises\";\nimport { FastifyInstance } from \"fastify\";\n\nimport { logger } from \"@cloudnux/utils\";\n\n\nimport { SchedulerConfig, SchedulerState, SchedulerService } from \"./types\";\nimport {\n scheduleJob,\n canExecuteJob,\n createJobExecution,\n executeJobWithTimeout,\n updateJobAfterExecution,\n handleExecutionError,\n handleExecutionSuccess\n} from \"./execution\";\nimport { saveSchedulerState, loadSchedulerState } from \"./persistence\";\nimport { cleanupExecutionHistory, createShutdownHandler, setupGracefulShutdown } from \"./cleanup\";\n\n\nexport const DEFAULT_CONFIG: SchedulerConfig = {\n persistence: {\n enabled: true,\n directory: './.develop/scheduler-data',\n saveInterval: 30000, // 30 seconds\n },\n execution: {\n maxConcurrent: 5,\n defaultTimeout: 300000, // 5 minutes\n retryOnError: false,\n maxRetries: 3,\n },\n cleanup: {\n maxExecutionHistory: 1000,\n cleanupInterval: 600000, // 10 minutes\n },\n restartBehavior: {\n preserveNaturalTiming: true,\n skipMissedRuns: true,\n maxTimingDrift: 60000, // 1 minute\n rapidRestartThreshold: 10000, // 10 seconds\n },\n cron: {\n defaultTimezone: undefined, // Use system timezone\n logCronDetails: true,\n }\n};\n\nexport const mergeConfig = (defaultConfig: SchedulerConfig, userConfig?: Partial<SchedulerConfig>): SchedulerConfig => ({\n ...defaultConfig,\n ...userConfig,\n persistence: { ...defaultConfig.persistence, ...userConfig?.persistence },\n execution: { ...defaultConfig.execution, ...userConfig?.execution },\n cleanup: { ...defaultConfig.cleanup, ...userConfig?.cleanup },\n restartBehavior: { ...defaultConfig.restartBehavior, ...userConfig?.restartBehavior },\n cron: { ...defaultConfig.cron, ...userConfig?.cron },\n});\n\nexport const createInitialState = (\n config: SchedulerConfig\n): SchedulerState => {\n return {\n schedulers: {},\n executions: {},\n executionHistory: [],\n isShuttingDown: false,\n runningExecutions: 0,\n isDirty: false,\n lastCleanupTime: Date.now(),\n lastRestartTime: new Date(),\n config,\n };\n};\n\nexport const createSchedulerFunctions = (\n state: SchedulerState\n) => {\n const executeJob = async (scheduler: SchedulerService): Promise<void> => {\n\n const { canExecute, reason } = canExecuteJob(scheduler, state);\n\n if (!canExecute) {\n if (reason === 'Maximum concurrent executions reached') {\n logger.warn(`Delaying job ${scheduler.job.name} - ${reason}`);\n scheduler.job.nextRun = new Date(Date.now() + 30000);\n scheduleJobFn(scheduler);\n } else if (reason === 'Job reached maximum runs') {\n logger.info(`Job ${scheduler.job.name} reached max runs (${scheduler.job.maxRuns})`);\n }\n return;\n }\n\n const execution = createJobExecution(scheduler.job.id);\n\n state.executions[execution.id] = execution;\n state.executionHistory.push(execution);\n scheduler.isRunning = true;\n state.runningExecutions++;\n\n logger.info(`Executing job ${scheduler.job.name} (${execution.id})`);\n\n try {\n const result = await executeJobWithTimeout(\n scheduler.handler,\n scheduler.job,\n execution,\n state.config.execution.defaultTimeout\n );\n\n const completedExecution = handleExecutionSuccess(execution, result);\n state.executions[execution.id] = completedExecution;\n } catch (error: any) {\n const failedExecution = handleExecutionError(execution, error);\n state.executions[execution.id] = failedExecution;\n } finally {\n scheduler.isRunning = false;\n state.runningExecutions--;\n scheduler.job = updateJobAfterExecution(scheduler.job, execution, state.config);\n\n if (scheduler.job.enabled && !state.isShuttingDown) {\n scheduleJobFn(scheduler);\n }\n\n if (state.config.persistence.enabled) {\n state.isDirty = true;\n }\n }\n };\n\n const scheduleJobFn = (scheduler: SchedulerService): SchedulerService => {\n const updatedScheduler = scheduleJob(scheduler, state, executeJob);\n state.schedulers[scheduler.job.id] = updatedScheduler;\n return updatedScheduler;\n };\n\n return { executeJob, scheduleJobFn };\n};\n\nexport const initializeScheduler = async (\n state: SchedulerState,\n scheduleJobFn: (scheduler: SchedulerService) => SchedulerService\n): Promise<void> => {\n\n try {\n if (state.config.persistence.enabled) {\n await fs.mkdir(state.config.persistence.directory, { recursive: true });\n\n const { schedulers, executionHistory } = await loadSchedulerState(\n state.schedulers,\n state.config,\n state.lastRestartTime\n );\n\n state.schedulers = schedulers;\n state.executionHistory = executionHistory;\n\n }\n\n // Unified tick: handles both state persistence and cleanup\n const tickInterval = (state.config.persistence.saveInterval || 0) > 0\n ? state.config.persistence.saveInterval\n : state.config.cleanup.cleanupInterval;\n\n state.tickInterval = setInterval(async () => {\n // Save state only when dirty\n if (state.isDirty && state.config.persistence.enabled) {\n state.isDirty = false;\n await saveSchedulerState(state);\n }\n\n // Run cleanup when enough time has elapsed\n if (Date.now() - state.lastCleanupTime >= state.config.cleanup.cleanupInterval) {\n state.lastCleanupTime = Date.now();\n cleanupExecutionHistory(state);\n }\n }, tickInterval);\n\n // Schedule all enabled jobs\n for (const scheduler of Object.values(state.schedulers)) {\n if (scheduler.job.enabled) {\n scheduleJobFn(scheduler);\n }\n }\n\n logger.debug(`Scheduler initialized: ${Object.keys(state.schedulers).length} jobs loaded`);\n } catch (error: any) {\n logger.error(`Failed to initialize scheduler: ${error.message}`);\n throw error;\n }\n};\n\nexport const setupSchedulerLifecycle = (\n state: SchedulerState,\n app: FastifyInstance,\n): void => {\n const shutdownHandler = createShutdownHandler(\n state,\n () => saveSchedulerState(state)\n );\n\n setupGracefulShutdown(shutdownHandler, app);\n};","import { parseExpression } from 'cron-parser';\n\nimport { logger } from \"@cloudnux/utils\"\n\n/**\n * Professional cron parser using cron-parser library\n * \n * Installation:\n * npm install cron-parser\n * npm install -D @types/cron-parser\n */\n\ninterface CronParseOptions {\n preserveNaturalTiming?: boolean;\n timezone?: string;\n utc?: boolean;\n currentDate?: Date;\n endDate?: Date;\n iterator?: boolean;\n}\n\ninterface CronParseResult {\n nextRun: Date;\n isValid: boolean;\n error?: string;\n pattern?: string;\n description?: string;\n}\n\n/**\n * Parse cron expression and get next execution time\n */\nexport function parseCronExpression(\n cronExpression: string,\n lastRun?: Date,\n options: CronParseOptions = {}\n): CronParseResult {\n const {\n preserveNaturalTiming = true,\n timezone,\n utc = false,\n currentDate\n } = options;\n\n try {\n // Validate and normalize cron expression\n const normalizedCron = normalizeCronExpression(cronExpression);\n\n const parseOptions: any = {\n tz: timezone,\n utc: utc,\n currentDate: currentDate ?? new Date()\n };\n\n // Use lastRun for baseline if preserving natural timing\n if (preserveNaturalTiming && lastRun) {\n parseOptions.currentDate = lastRun;\n }\n\n const interval = parseExpression(normalizedCron, parseOptions);\n let nextRun = interval.next().toDate();\n\n // Ensure next run is in the future\n const now = new Date();\n while (nextRun <= now) {\n nextRun = interval.next().toDate();\n }\n\n return {\n nextRun,\n isValid: true,\n pattern: normalizedCron,\n description: describeCronExpression(normalizedCron)\n };\n\n } catch (error: any) {\n //BREAKPOINT: LOGGING\n logger.error(`Invalid cron expression: ${cronExpression} - ${error.message}`);\n\n // Fallback to a safe default (every hour)\n const fallbackTime = new Date();\n fallbackTime.setHours(fallbackTime.getHours() + 1);\n fallbackTime.setMinutes(0);\n fallbackTime.setSeconds(0);\n fallbackTime.setMilliseconds(0);\n\n return {\n nextRun: fallbackTime,\n isValid: false,\n error: error.message,\n pattern: cronExpression\n };\n }\n}\n\n/**\n * Get multiple next execution times\n */\nexport function getNextExecutions(\n cronExpression: string,\n count: number = 5,\n options: CronParseOptions = {}\n): Date[] {\n try {\n const normalizedCron = normalizeCronExpression(cronExpression);\n const parseOptions: any = {\n tz: options.timezone,\n utc: options.utc ?? false,\n currentDate: options.currentDate ?? new Date()\n };\n\n const interval = parseExpression(normalizedCron, parseOptions);\n const executions: Date[] = [];\n\n for (let i = 0; i < count; i++) {\n executions.push(interval.next().toDate());\n }\n\n return executions;\n } catch (error: any) {\n //BREAKPOINT: LOGGING\n logger.error(`Error getting next executions: ${error.message}`);\n return [];\n }\n}\n\n/**\n * Validate if a cron expression is valid\n */\nexport function validateCronExpression(cronExpression: string): boolean {\n try {\n const normalized = normalizeCronExpression(cronExpression);\n parseExpression(normalized);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Normalize cron expressions to handle different formats\n */\nfunction normalizeCronExpression(cronExpression: string): string {\n const parts = cronExpression.trim().split(/\\s+/);\n\n // Handle different cron formats\n if (parts.length === 5) {\n // Standard 5-field format: minute hour day month dayOfWeek\n return cronExpression;\n } else if (parts.length === 6) {\n // 6-field format with seconds: second minute hour day month dayOfWeek\n return cronExpression;\n } else if (parts.length === 7) {\n // 7-field format with year: second minute hour day month dayOfWeek year\n return cronExpression;\n } else {\n throw new Error(`Invalid cron format: expected 5, 6, or 7 fields, got ${parts.length}`);\n }\n}\n\n/**\n * Provide human-readable description of cron expression\n */\nfunction describeCronExpression(cronExpression: string): string {\n const parts = cronExpression.split(' ');\n\n // Handle common patterns\n const patterns: Record<string, string> = {\n '*/5 * * * *': 'Every 5 minutes',\n '0 * * * *': 'Every hour at minute 0',\n '0 */2 * * *': 'Every 2 hours',\n '0 0 * * *': 'Daily at midnight',\n '0 6 * * *': 'Daily at 6:00 AM',\n '0 0 * * 0': 'Weekly on Sunday at midnight',\n '0 0 1 * *': 'Monthly on the 1st at midnight',\n '0 0 1 1 *': 'Yearly on January 1st at midnight'\n };\n\n if (patterns[cronExpression]) {\n return patterns[cronExpression];\n }\n\n // Basic description for other patterns\n if (parts.length >= 5) {\n const [minute, hour, day, month, dayOfWeek] = parts;\n\n let description = 'Runs ';\n\n if (minute.includes('*/')) {\n const interval = minute.split('*/')[1];\n description += `every ${interval} minutes`;\n } else if (minute === '*') {\n description += 'every minute';\n } else {\n description += `at minute ${minute}`;\n }\n\n if (hour.includes('*/')) {\n const interval = hour.split('*/')[1];\n description += `, every ${interval} hours`;\n } else if (hour !== '*') {\n description += `, at hour ${hour}`;\n }\n\n if (day !== '*') {\n description += `, on day ${day}`;\n }\n\n if (month !== '*') {\n description += `, in month ${month}`;\n }\n\n if (dayOfWeek !== '*') {\n const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];\n const dayNames = dayOfWeek.split(',').map(d => days[parseInt(d)] || d).join(', ');\n description += `, on ${dayNames}`;\n }\n\n return description;\n }\n\n return 'Custom schedule';\n}\n\n/**\n * Calculate time until next execution\n */\nexport function timeUntilNextExecution(cronExpression: string, timezone?: string): number {\n const result = parseCronExpression(cronExpression, undefined, { timezone });\n if (!result.isValid) {\n return -1;\n }\n\n return result.nextRun.getTime() - Date.now();\n}\n\n/**\n * Check if a time matches a cron expression\n */\nexport function doesTimeMatchCron(cronExpression: string, date: Date, timezone?: string): boolean {\n try {\n const normalizedCron = normalizeCronExpression(cronExpression);\n const parseOptions: any = {\n tz: timezone,\n currentDate: date\n };\n\n const interval = parseExpression(normalizedCron, parseOptions);\n const nextExecution = interval.next().toDate();\n\n // Check if the date is very close to the next execution (within 1 minute)\n const timeDiff = Math.abs(nextExecution.getTime() - date.getTime());\n return timeDiff < 60000; // 1 minute tolerance\n } catch {\n return false;\n }\n}\n\n/**\n * Detect the type of scheduling expression\n */\nexport function detectExpressionType(expression: string | undefined): 'cron' | 'rate' | 'unknown' {\n if (!expression || typeof expression !== 'string') {\n return 'unknown';\n }\n const trimmedExpression = expression.trim();\n\n // Check for AWS rate expression pattern\n // Format: \"rate(value unit)\" where unit can be minute(s), hour(s), day(s)\n const ratePattern = /^rate\\(\\s*(\\d+)\\s+(minute|minutes|hour|hours|day|days)\\s*\\)$/i;\n if (ratePattern.test(trimmedExpression)) {\n return 'rate';\n }\n\n // Check for cron expression pattern\n // Should have 5, 6, or 7 space-separated fields\n const cronParts = trimmedExpression.split(/\\s+/);\n if (cronParts.length >= 5 && cronParts.length <= 7) {\n // Additional validation: check if parts contain valid cron characters\n const cronCharPattern = /^[\\d\\*\\-\\,\\/\\?\\#LW]+$/;\n const validCronParts = cronParts.every(part => cronCharPattern.test(part) || part === '*');\n\n if (validCronParts) {\n return 'cron';\n }\n }\n\n return 'unknown';\n}\n\n/**\n * Convert AWS rate expression to cron expression\n * \n * AWS Rate expressions format: rate(value unit)\n * Examples:\n * - rate(5 minutes) -> *\\/5 * * * *\n * - rate(1 hour) -> 0 * * * *\n * - rate(2 hours) -> 0 *\\/2 * * *\n * - rate(1 day) -> 0 0 * * *\n * - rate(7 days) -> 0 0 *\\/7 * *\n*/\nexport function convertRateToCron(rateExpression: string): {\n cronExpression: string;\n isValid: boolean;\n error?: string;\n originalRate: string;\n description: string;\n} {\n const trimmedExpression = rateExpression.trim();\n\n // Parse rate expression\n const ratePattern = /^rate\\(\\s*(\\d+)\\s+(minute|minutes|hour|hours|day|days)\\s*\\)$/i;\n const match = trimmedExpression.match(ratePattern);\n\n if (!match) {\n return {\n cronExpression: '',\n isValid: false,\n error: 'Invalid rate expression format. Expected: rate(value unit)',\n originalRate: rateExpression,\n description: ''\n };\n }\n\n const value = parseInt(match[1]);\n const unit = match[2].toLowerCase();\n\n // Validate value\n if (value <= 0) {\n return {\n cronExpression: '',\n isValid: false,\n error: 'Rate value must be greater than 0',\n originalRate: rateExpression,\n description: ''\n };\n }\n\n let cronExpression = '';\n let description = '';\n\n try {\n switch (unit) {\n case 'minute':\n case 'minutes':\n if (value > 59) {\n return {\n cronExpression: '',\n isValid: false,\n error: 'Minutes value cannot exceed 59. Use hours for longer intervals.',\n originalRate: rateExpression,\n description: ''\n };\n }\n\n if (value === 1) {\n cronExpression = '* * * * *';\n description = 'Every minute';\n } else {\n cronExpression = `*/${value} * * * *`;\n description = `Every ${value} minutes`;\n }\n break;\n\n case 'hour':\n case 'hours':\n if (value > 23) {\n // For hours > 23, convert to days if evenly divisible by 24\n if (value % 24 === 0) {\n const days = value / 24;\n cronExpression = `0 0 */${days} * *`;\n description = `Every ${days} day${days > 1 ? 's' : ''}`;\n } else {\n return {\n cronExpression: '',\n isValid: false,\n error: 'Hours value greater than 23 must be divisible by 24, or use days unit.',\n originalRate: rateExpression,\n description: ''\n };\n }\n } else if (value === 1) {\n cronExpression = '0 * * * *';\n description = 'Every hour';\n } else {\n cronExpression = `0 */${value} * * *`;\n description = `Every ${value} hours`;\n }\n break;\n\n case 'day':\n case 'days':\n if (value > 365) {\n return {\n cronExpression: '',\n isValid: false,\n error: 'Days value cannot exceed 365',\n originalRate: rateExpression,\n description: ''\n };\n }\n\n if (value === 1) {\n cronExpression = '0 0 * * *';\n description = 'Every day (daily)';\n } else if (value === 7) {\n cronExpression = '0 0 * * 0';\n description = 'Every 7 days (weekly)';\n } else if (value <= 31) {\n cronExpression = `0 0 */${value} * *`;\n description = `Every ${value} days`;\n } else {\n // For large day intervals, we need to be more careful\n // This is an approximation since months have different lengths\n cronExpression = `0 0 */${value} * *`;\n description = `Every ${value} days (approximate)`;\n }\n break;\n\n default:\n return {\n cronExpression: '',\n isValid: false,\n error: `Unsupported time unit: ${unit}. Use minute(s), hour(s), or day(s).`,\n originalRate: rateExpression,\n description: ''\n };\n }\n\n // Validate the generated cron expression\n if (!validateCronExpression(cronExpression)) {\n return {\n cronExpression: '',\n isValid: false,\n error: 'Generated cron expression is invalid',\n originalRate: rateExpression,\n description: ''\n };\n }\n\n return {\n cronExpression,\n isValid: true,\n originalRate: rateExpression,\n description\n };\n\n } catch (error: any) {\n return {\n cronExpression: '',\n isValid: false,\n error: `Conversion error: ${error.message}`,\n originalRate: rateExpression,\n description: ''\n };\n }\n}","import { ScheduledJob, SchedulerConfig } from \"./types\";\nimport { parseCronExpression } from \"./cron-utils\";\n\nexport const generateJobId = (): string =>\n `job_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\n\nexport const generateExecutionId = (): string =>\n `exec_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\n\nexport const calculateNextRun = (\n job: ScheduledJob,\n preserveNaturalTiming: boolean = true\n): Date => {\n const now = new Date();\n\n if (job.cronExpression) {\n const result = parseCronExpression(job.cronExpression, job.lastRun, {\n preserveNaturalTiming,\n timezone: job.timezone,\n currentDate: preserveNaturalTiming && job.lastRun ? job.lastRun : now\n });\n return result.nextRun;\n }\n\n if (job.intervalMs) {\n return new Date(now.getTime() + job.intervalMs);\n }\n\n if (job.delayMs) {\n return new Date(now.getTime() + job.delayMs);\n }\n\n // Default: 1 hour\n return new Date(now.getTime() + 3600000);\n};\n\nexport const calculateNextRunFromLastRun = (\n job: ScheduledJob,\n lastRun: Date | undefined,\n config: SchedulerConfig\n): Date => {\n const now = new Date();\n\n if (job.cronExpression) {\n const result = parseCronExpression(job.cronExpression, lastRun, {\n preserveNaturalTiming: config.restartBehavior.preserveNaturalTiming,\n timezone: job.timezone ?? config.cron.defaultTimezone\n });\n return result.nextRun;\n }\n\n if (job.intervalMs && lastRun) {\n let nextRun = new Date(lastRun.getTime() + job.intervalMs);\n\n if (config.restartBehavior.skipMissedRuns) {\n while (nextRun <= now) {\n nextRun = new Date(nextRun.getTime() + job.intervalMs);\n }\n } else {\n if (nextRun <= now) {\n nextRun = new Date(now.getTime() + job.intervalMs);\n }\n }\n\n return nextRun;\n }\n\n return calculateNextRun(job, config.restartBehavior.preserveNaturalTiming);\n};\n\nexport const hasJobDefinitionChanged = (currentJob: ScheduledJob, savedJob: any): boolean => (\n currentJob.cronExpression !== savedJob.cronExpression ||\n currentJob.intervalMs !== savedJob.intervalMs ||\n currentJob.delayMs !== savedJob.delayMs ||\n currentJob.maxRuns !== savedJob.maxRuns ||\n currentJob.timezone !== savedJob.timezone\n);\n\nexport const shouldSkipJob = (job: ScheduledJob): boolean => {\n if (!job.enabled) return true;\n if (job.maxRuns && job.runCount >= job.maxRuns) return true;\n return false;\n};\n\nexport const isJobReadyToRun = (job: ScheduledJob): boolean => {\n const now = new Date();\n return job.nextRun.getTime() <= now.getTime();\n};\n\nexport const getTimeUntilNextRun = (job: ScheduledJob): number =>\n Math.max(0, job.nextRun.getTime() - Date.now());","import { logger } from \"@cloudnux/utils\";\n\nimport { JobExecution, ScheduledJob, SchedulerConfig, SchedulerService, SchedulerState, JobHandler } from \"./types\";\nimport { generateExecutionId, calculateNextRunFromLastRun, shouldSkipJob, getTimeUntilNextRun } from \"./utils\";\n\nexport const createJobExecution = (jobId: string): JobExecution => ({\n id: generateExecutionId(),\n jobId,\n startTime: new Date(),\n status: 'running',\n});\n\nexport const completeExecution = (\n execution: JobExecution,\n result?: any,\n error?: string\n): JobExecution => ({\n ...execution,\n endTime: new Date(),\n status: error ? 'failed' : 'completed',\n result,\n error,\n});\n\nexport const canExecuteJob = (\n scheduler: SchedulerService,\n state: SchedulerState\n): { canExecute: boolean; reason?: string } => {\n if (state.isShuttingDown) {\n return { canExecute: false, reason: 'System is shutting down' };\n }\n\n if (scheduler.isRunning) {\n return { canExecute: false, reason: 'Job is already running' };\n }\n\n if (shouldSkipJob(scheduler.job)) {\n const reason = !scheduler.job.enabled\n ? 'Job is disabled'\n : 'Job reached maximum runs';\n return { canExecute: false, reason };\n }\n\n if (state.runningExecutions >= state.config.execution.maxConcurrent) {\n return { canExecute: false, reason: 'Maximum concurrent executions reached' };\n }\n\n return { canExecute: true };\n};\n\nexport const scheduleJob = (\n scheduler: SchedulerService,\n state: SchedulerState,\n executeJobFn: (scheduler: SchedulerService) => Promise<void>,\n): SchedulerService => {\n if (state.isShuttingDown) return scheduler;\n\n const timeUntilNextRun = getTimeUntilNextRun(scheduler.job);\n\n const updatedScheduler = { ...scheduler };\n\n if (timeUntilNextRun <= 0) {\n // Should run now\n setImmediate(() => executeJobFn(updatedScheduler));\n } else {\n // Schedule for future\n updatedScheduler.timerId = setTimeout(() => {\n executeJobFn(updatedScheduler);\n }, timeUntilNextRun);\n\n logger.debug(`Scheduled job ${scheduler.job.name} to run in ${Math.round(timeUntilNextRun / 1000)}s`);\n }\n\n return updatedScheduler;\n};\n\nexport const executeJobWithTimeout = async (\n handler: JobHandler,\n job: ScheduledJob,\n execution: JobExecution,\n timeoutMs: number\n): Promise<any> => {\n let timerId: NodeJS.Timeout;\n\n try {\n return await Promise.race([\n handler(job, execution),\n new Promise((_, reject) => {\n timerId = setTimeout(() => reject(new Error('Job execution timeout')), timeoutMs);\n })\n ]);\n } finally {\n clearTimeout(timerId!);\n }\n};\n\nexport const updateJobAfterExecution = (\n job: ScheduledJob,\n execution: JobExecution,\n config: SchedulerConfig\n): ScheduledJob => {\n const updatedJob = {\n ...job,\n lastRun: execution.startTime,\n runCount: job.runCount + 1,\n };\n\n if (job.enabled) {\n updatedJob.nextRun = calculateNextRunFromLastRun(updatedJob, updatedJob.lastRun, config);\n }\n\n return updatedJob;\n};\n\nexport const handleExecutionError = (\n execution: JobExecution,\n error: Error,\n): JobExecution => {\n logger.error(`Job failed ${execution.jobId}: ${error.message}`);\n\n return completeExecution(execution, undefined, error.message);\n};\n\nexport const handleExecutionSuccess = (\n execution: JobExecution,\n result: any,\n): JobExecution => {\n const duration = execution.endTime ? execution.endTime.getTime() - execution.startTime.getTime() : 0;\n\n logger.debug(`Job completed in ${duration}ms`);\n\n return completeExecution(execution, result);\n};","import * as fs from \"fs/promises\";\nimport * as path from \"path\";\n\nimport { logger } from \"@cloudnux/utils\";\n\nimport { SchedulerState, SchedulerService, JobExecution, ScheduledJob, SchedulerConfig } from \"./types\";\nimport { hasJobDefinitionChanged, calculateNextRunFromLastRun } from \"./utils\";\nimport { parseCronExpression } from \"./cron-utils\";\n\ninterface SchedulerStateData {\n jobs: ScheduledJob[];\n executions: JobExecution[];\n savedAt: Date;\n version: string;\n}\n\nexport const createStateFilePath = (\n directory: string\n): string => path.join(directory, 'scheduler-state.json');\n\nexport const createTempFilePath = (\n directory: string\n): string => path.join(directory, `scheduler-state.${Date.now()}.temp.json`);\n\nexport const serializeSchedulerState = (\n schedulers: Record<string, SchedulerService>,\n executionHistory: JobExecution[]\n): SchedulerStateData => ({\n jobs: Object.values(schedulers).map(s => s.job),\n executions: executionHistory.slice(-100),\n savedAt: new Date(),\n version: '1.0'\n});\n\nexport const saveSchedulerState = async (\n state: SchedulerState\n): Promise<void> => {\n\n try {\n const serializedState = serializeSchedulerState(state.schedulers, state.executionHistory);\n const stateFile = createStateFilePath(state.config.persistence.directory);\n const tempFile = createTempFilePath(state.config.persistence.directory);\n\n await fs.writeFile(tempFile, JSON.stringify(serializedState, null, 2), 'utf8');\n await fs.rename(tempFile, stateFile);\n\n logger.debug('Enhanced scheduler state saved');\n } catch (error: any) {\n logger.error('Failed to save scheduler state:', error);\n }\n};\n\nexport const loadSchedulerStateData = async (\n directory: string\n): Promise<SchedulerStateData | null> => {\n try {\n const stateFile = createStateFilePath(directory);\n const data = await fs.readFile(stateFile, 'utf8');\n return JSON.parse(data);\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n logger.debug('No previous scheduler state found - starting fresh');\n } else {\n logger.error('Failed to load scheduler state:', error);\n }\n return null;\n }\n};\n\nexport const validateAndAdjustNextRun = (\n job: ScheduledJob,\n savedNextRun: Date | undefined,\n lastRestartTime: Date,\n config: SchedulerConfig\n): Date => {\n const now = new Date();\n\n if (!savedNextRun) {\n return calculateNextRunFromLastRun(job, job.lastRun, config);\n }\n\n if (savedNextRun <= now) {\n logger.debug(`Saved next run is in the past for ${job.name} - recalculating`);\n return calculateNextRunFromLastRun(job, job.lastRun, config);\n }\n\n const timeSinceRestart = now.getTime() - lastRestartTime.getTime();\n const isRapidRestart = timeSinceRestart < config.restartBehavior.rapidRestartThreshold;\n\n if (isRapidRestart) {\n logger.debug(`Rapid restart detected for ${job.name} - preserving saved timing`);\n return savedNextRun;\n }\n\n if (job.cronExpression || job.intervalMs) {\n const expectedNextRun = calculateNextRunFromLastRun(job, job.lastRun, config);\n const timeDiff = Math.abs(savedNextRun.getTime() - expectedNextRun.getTime());\n\n if (timeDiff > config.restartBehavior.maxTimingDrift) {\n logger.debug(`Adjusting timing for ${job.name} - drift of ${Math.round(timeDiff / 1000)}s detected`);\n return expectedNextRun;\n }\n }\n\n return savedNextRun;\n};\n\nexport const restoreJobFromSavedData = (\n scheduler: SchedulerService,\n savedJob: ScheduledJob,\n config: SchedulerConfig,\n lastRestartTime: Date\n): SchedulerService => {\n const definitionChanged = hasJobDefinitionChanged(scheduler.job, savedJob);\n\n const updatedJob = {\n ...scheduler.job,\n runCount: savedJob.runCount,\n lastRun: savedJob.lastRun ? new Date(savedJob.lastRun) : undefined,\n };\n\n if (definitionChanged) {\n logger.debug(`Job definition changed: ${savedJob.name} - recalculating schedule`);\n updatedJob.nextRun = calculateNextRunFromLastRun(updatedJob, updatedJob.lastRun, config);\n } else {\n const savedNextRun = savedJob.nextRun ? new Date(savedJob.nextRun) : undefined;\n updatedJob.nextRun = validateAndAdjustNextRun(updatedJob, savedNextRun, lastRestartTime, config);\n }\n\n if (config.cron.logCronDetails && updatedJob.cronExpression) {\n const result = parseCronExpression(updatedJob.cronExpression, updatedJob.lastRun, {\n timezone: updatedJob.timezone\n });\n logger.debug(`Job restored: ${savedJob.name} - ${result.description} - next: ${updatedJob.nextRun.toLocaleString()}`);\n }\n\n return { ...scheduler, job: updatedJob };\n};\n\nexport const restoreExecutionHistory = (\n savedExecutions: any[]\n): JobExecution[] => {\n return savedExecutions.map((exec: any) => ({\n ...exec,\n startTime: new Date(exec.startTime),\n endTime: exec.endTime ? new Date(exec.endTime) : undefined,\n }));\n};\n\nexport const loadSchedulerState = async (\n schedulers: Record<string, SchedulerService>,\n config: SchedulerConfig,\n lastRestartTime: Date\n): Promise<{\n schedulers: Record<string, SchedulerService>;\n executionHistory: JobExecution[];\n}> => {\n const stateData = await loadSchedulerStateData(config.persistence.directory);\n\n if (!stateData) {\n return { schedulers, executionHistory: [] };\n }\n\n const restoredSchedulers = { ...schedulers };\n\n for (const savedJob of stateData.jobs) {\n const existingScheduler = Object.values(schedulers).find(s => s.job.name === savedJob.name);\n\n if (existingScheduler) {\n const restoredScheduler = restoreJobFromSavedData(\n existingScheduler,\n savedJob,\n config,\n lastRestartTime\n );\n restoredSchedulers[restoredScheduler.job.id] = restoredScheduler;\n }\n }\n\n const executionHistory = stateData.executions ? restoreExecutionHistory(stateData.executions) : [];\n\n logger.debug(`Enhanced scheduler state loaded (saved at ${stateData.savedAt})`);\n\n return { schedulers: restoredSchedulers, executionHistory };\n};","import { logger } from \"@cloudnux/utils\";\n\nimport { SchedulerState, JobExecution } from \"./types\";\n\nexport const cleanupExecutionHistory = (\n state: SchedulerState,\n): JobExecution[] => {\n if (state.executionHistory.length > state.config.cleanup.maxExecutionHistory) {\n const removed = state.executionHistory.splice(\n 0,\n state.executionHistory.length - state.config.cleanup.maxExecutionHistory\n );\n\n logger.debug(`Cleaned up ${removed.length} old execution records`);\n return removed;\n }\n\n return [];\n};\n\nexport const clearAllTimers = (schedulers: Record<string, any>): void => {\n for (const scheduler of Object.values(schedulers)) {\n if (scheduler.timerId) {\n clearTimeout(scheduler.timerId);\n scheduler.timerId = undefined;\n }\n }\n};\n\nexport const waitForRunningJobs = async (\n getRunningExecutions: () => number,\n maxWaitTime: number = 30000,\n): Promise<void> => {\n const startTime = Date.now();\n\n while (getRunningExecutions() > 0 && (Date.now() - startTime) < maxWaitTime) {\n logger.debug(`Waiting for ${getRunningExecutions()} running jobs to complete...`);\n await new Promise(resolve => setTimeout(resolve, 1000));\n }\n};\n\nexport const createShutdownHandler = (\n state: SchedulerState,\n saveStateFn: () => Promise<void>\n) => async (): Promise<void> => {\n logger.info(`Enhanced scheduler shutting down...`);\n\n // Mark as shutting down\n state.isShuttingDown = true;\n\n // Clear all timers\n clearAllTimers(state.schedulers);\n\n // Clear unified tick interval\n if (state.tickInterval) {\n clearInterval(state.tickInterval);\n }\n\n // Wait for running jobs\n await waitForRunningJobs(() => state.runningExecutions, 30000);\n\n // Save final state\n if (state.config.persistence.enabled) {\n await saveStateFn();\n }\n\n logger.debug(`Enhanced scheduler shutdown complete`);\n};\n\nexport const setupGracefulShutdown = (\n shutdownHandler: () => Promise<void>,\n app: any\n): void => {\n process.on('SIGINT', shutdownHandler);\n process.on('SIGTERM', shutdownHandler);\n app.addHook('onClose', async () => {\n await shutdownHandler();\n });\n};","import { logger } from \"@cloudnux/utils\";\n\nimport { JobDefinition, ScheduledJob, SchedulerService, SchedulerConfig } from \"./types\";\nimport { detectExpressionType, convertRateToCron, parseCronExpression, getNextExecutions } from \"./cron-utils\";\nimport { generateJobId, calculateNextRun } from \"./utils\";\n\nexport const validateJobDefinition = (\n jobDef: JobDefinition\n): void => {\n const expressionType = detectExpressionType(jobDef.cronExpression);\n if (expressionType === \"unknown\") {\n logger.error(`Invalid cron expression for job: ${jobDef.name}`);\n throw new Error(`Invalid cron expression for job: ${jobDef.name}`);\n }\n};\n\nexport const createJobFromDefinition = (\n jobDef: JobDefinition,\n config: SchedulerConfig\n): ScheduledJob => {\n validateJobDefinition(jobDef);\n\n const expressionType = detectExpressionType(jobDef.cronExpression);\n\n if (config.cron.logCronDetails && jobDef.cronExpression) {\n const cronExpression = expressionType === \"rate\"\n ? convertRateToCron(jobDef.cronExpression).cronExpression\n : jobDef.cronExpression;\n\n const result = parseCronExpression(cronExpression, undefined, {\n timezone: jobDef.timezone ?? config.cron.defaultTimezone\n });\n\n logger.debug(`Job ${jobDef.name}: ${result.description} - Next: ${result.nextRun.toLocaleString()}`);\n\n const upcoming = getNextExecutions(cronExpression, 3, {\n timezone: jobDef.timezone ?? config.cron.defaultTimezone\n });\n logger.debug(`Upcoming: ${upcoming.map(d => d.toLocaleTimeString()).join(', ')}`);\n }\n\n const job: ScheduledJob = {\n id: generateJobId(),\n name: jobDef.name,\n cronExpression: expressionType === \"rate\"\n ? convertRateToCron(jobDef.cronExpression!).cronExpression\n : jobDef.cronExpression,\n intervalMs: jobDef.intervalMs,\n delayMs: jobDef.delayMs,\n nextRun: new Date(),\n enabled: jobDef.enabled ?? true,\n runCount: 0,\n maxRuns: jobDef.maxRuns,\n metadata: jobDef.metadata,\n createdAt: new Date(),\n timezone: jobDef.timezone,\n module: jobDef.module\n };\n\n job.nextRun = calculateNextRun(job);\n return job;\n};\n\nexport const createSchedulerService = (\n job: ScheduledJob,\n handler: any\n): SchedulerService => ({\n job,\n handler,\n isRunning: false,\n});\n\nexport const enableJob = (scheduler: SchedulerService): SchedulerService => ({\n ...scheduler,\n job: {\n ...scheduler.job,\n enabled: true,\n nextRun: calculateNextRun(scheduler.job)\n }\n});\n\nexport const disableJob = (scheduler: SchedulerService): SchedulerService => {\n if (scheduler.timerId) {\n clearTimeout(scheduler.timerId);\n }\n\n return {\n ...scheduler,\n job: { ...scheduler.job, enabled: false },\n timerId: undefined\n };\n};","import { FastifyInstance } from \"fastify\";\n\nimport { SchedulerService, SchedulerState } from \"./types\";\nimport { getNextExecutions, parseCronExpression } from \"./cron-utils\";\nimport { enableJob, disableJob } from \"./jobs\";\nimport { getTimeUntilNextRun } from \"./utils\";\n\nexport const createDashboardData = (state: SchedulerState) => {\n const jobs = Object.values(state.schedulers).map(s => {\n const nextExecutions = s.job.cronExpression ?\n getNextExecutions(s.job.cronExpression, 3, { timezone: s.job.timezone }) : [];\n\n return {\n ...s.job,\n isRunning: s.isRunning,\n timeUntilNextRun: getTimeUntilNextRun(s.job),\n upcomingExecutions: nextExecutions,\n cronDescription: s.job.cronExpression ?\n parseCronExpression(s.job.cronExpression, undefined, { timezone: s.job.timezone }).description :\n undefined\n };\n });\n\n return { jobs, runningExecutions: state.runningExecutions };\n};\n\nexport const createExecutionsData = (state: SchedulerState) => ({\n executions: state.executionHistory.slice(-50), // Last 50 executions\n running: Object.values(state.executions).filter(e => e.status === 'running'),\n});\n\nexport const registerDashboardRoute = (\n app: FastifyInstance,\n state: SchedulerState\n): void => {\n app.get(\"/schedule/dashboard\", async function (_, reply) {\n const dashboardData = createDashboardData(state);\n return reply.status(200).send(dashboardData);\n });\n};\n\nexport const registerExecutionsRoute = (\n app: FastifyInstance,\n state: SchedulerState\n): void => {\n app.get(\"/schedule/executions\", async function (_, reply) {\n const executionsData = createExecutionsData(state);\n return reply.status(200).send(executionsData);\n });\n};\n\nexport const registerTriggerJobRoute = (\n app: FastifyInstance,\n state: SchedulerState,\n executeJobFn: (scheduler: any) => Promise<void>\n): void => {\n app.post<{ Params: { jobId: string } }>(\"/schedule/jobs/:jobId/trigger\", async function (request, reply) {\n const scheduler = state.schedulers[request.params.jobId];\n\n if (!scheduler) {\n return reply.status(404).send({ error: \"Job not found\" });\n }\n\n if (scheduler.isRunning) {\n return reply.status(409).send({ error: \"Job is already running\" });\n }\n\n // Trigger immediately\n setImmediate(() => executeJobFn(scheduler));\n\n return reply.status(200).send({ message: \"Job triggered successfully\" });\n });\n};\n\nexport const registerEnableJobRoute = (\n app: FastifyInstance,\n state: SchedulerState,\n scheduleJobFn: (scheduler: any) => void\n): void => {\n app.put<{ Params: { jobId: string } }>(\"/schedule/jobs/:jobId/enable\", async function (request, reply) {\n const scheduler = state.schedulers[request.params.jobId];\n\n if (!scheduler) {\n return reply.status(404).send({ error: \"Job not found\" });\n }\n\n const enabledScheduler = enableJob(scheduler);\n state.schedulers[request.params.jobId] = enabledScheduler;\n scheduleJobFn(enabledScheduler);\n\n return reply.status(200).send({ message: \"Job enabled successfully\" });\n });\n};\n\nexport const registerDisableJobRoute = (\n app: FastifyInstance,\n state: SchedulerState\n): void => {\n app.put<{ Params: { jobId: string } }>(\"/schedule/jobs/:jobId/disable\", async function (request, reply) {\n const scheduler = state.schedulers[request.params.jobId];\n\n if (!scheduler) {\n return reply.status(404).send({ error: \"Job not found\" });\n }\n\n const disabledScheduler = disableJob(scheduler);\n state.schedulers[request.params.jobId] = disabledScheduler;\n\n return reply.status(200).send({ message: \"Job disabled successfully\" });\n });\n};\n\nexport const registerAllRoutes = (\n app: FastifyInstance,\n state: SchedulerState,\n executeJobFn: (scheduler: SchedulerService) => Promise<void>,\n scheduleJobFn: (scheduler: SchedulerService) => SchedulerService\n): void => {\n registerDashboardRoute(app, state);\n registerExecutionsRoute(app, state);\n registerTriggerJobRoute(app, state, executeJobFn);\n registerEnableJobRoute(app, state, scheduleJobFn);\n registerDisableJobRoute(app, state);\n};","import { FastifyInstance } from \"fastify\";\n\nimport { logger } from \"@cloudnux/utils\";\n\nimport { SchedulerManager, SchedulerDecoratorOptions, JobDefinition, JobHandler } from \"./types\";\nimport { validateJobDefinition, createJobFromDefinition, createSchedulerService } from \"./jobs\";\n\nconst isValidJobName = (jobName: string): boolean => {\n return typeof jobName === 'string' && jobName.length > 0 && /^[a-zA-Z0-9_-]+$/.test(jobName);\n};\n\n// Higher-order function to create the scheduler manager\nexport const createSchedulerManager = ({\n state,\n scheduleJobFn,\n executeJob,\n config\n}: SchedulerDecoratorOptions): SchedulerManager => {\n\n // Pure function to validate job name\n const validateJobName = (jobName: string): void => {\n if (!jobName || typeof jobName !== 'string') {\n throw new Error('Job name must be a non-empty string');\n }\n\n if (!isValidJobName(jobName)) {\n throw new Error('Job name must contain only alphanumeric characters, hyphens, and underscores');\n }\n };\n\n // Pure function to validate handler\n const validateHandler = (handler: JobHandler): void => {\n if (typeof handler !== 'function') {\n throw new Error('Handler must be a function');\n }\n };\n\n const addJob = async (jobDefinition: JobDefinition): Promise<string> => {\n try {\n validateJobName(jobDefinition.name);\n validateHandler(jobDefinition.handler);\n\n // Validate job definition (cron expression, etc.)\n validateJobDefinition(jobDefinition);\n\n // Check if job already exists\n const existingJob = Object.values(state.schedulers).find(s => s.job.name === jobDefinition.name);\n if (existingJob) {\n logger.warn(`Job already exists: ${jobDefinition.name}.`);\n return existingJob.job.id;\n }\n\n // Create new job\n const job = createJobFromDefinition(jobDefinition, config);\n const scheduler = createSchedulerService(job, jobDefinition.handler);\n\n // Add to state\n state.schedulers[job.id] = scheduler;\n\n // Schedule if enabled\n if (job.enabled) {\n scheduleJobFn(scheduler);\n }\n\n logger.info(`Job added: ${jobDefinition.name} (${job.id})`);\n\n return job.id;\n } catch (error: any) {\n logger.error(`Failed to add job ${jobDefinition.name}: ${error.message}`);\n throw error;\n }\n };\n\n const removeJob = async (jobName: string): Promise<void> => {\n try {\n validateJobName(jobName);\n\n const scheduler = Object.values(state.schedulers).find(s => s.job.name === jobName);\n if (!scheduler) {\n throw new Error(`Job '${jobName}' does not exist`);\n }\n\n // Check if job is currently running\n if (scheduler.isRunning) {\n logger.warn(`Removing job that is currently running: ${jobName}`);\n }\n\n // Clear any scheduled timeout\n if (scheduler.timerId) {\n clearTimeout(scheduler.timerId);\n }\n\n // Remove from state\n delete state.schedulers[scheduler.job.id];\n\n logger.info(`Job removed: ${jobName}`);\n } catch (error: any) {\n logger.error(`Failed to remove job ${jobName}: ${error.message}`);\n throw error;\n }\n };\n\n const hasJob = (jobName: string): boolean => {\n try {\n validateJobName(jobName);\n return Object.values(state.schedulers).some(s => s.job.name === jobName);\n } catch {\n return false;\n }\n };\n\n const listJobs = (module?: string): string[] => {\n return Object.values(state.schedulers)\n .filter(s => !module || s.job.module === module)\n .map(s => s.job.name)\n .sort();\n };\n\n const getJobStats = (jobName: string) => {\n try {\n validateJobName(jobName);\n const scheduler = Object.values(state.schedulers).find(s => s.job.name === jobName);\n return scheduler || null;\n } catch {\n return null;\n }\n };\n\n const enableJob = async (jobName: string): Promise<void> => {\n try {\n validateJobName(jobName);\n\n const scheduler = Object.values(state.schedulers).find(s => s.job.name === jobName);\n if (!scheduler) {\n throw new Error(`Job '${jobName}' does not exist`);\n }\n\n if (scheduler.job.enabled) {\n logger.debug(`Job is already enabled: ${jobName}`);\n return;\n }\n\n // Enable the job\n scheduler.job.enabled = true;\n\n // Schedule it\n scheduleJobFn(scheduler);\n\n logger.info(`Job enabled: ${jobName}`);\n } catch (error: any) {\n logger.error(`Failed to enable job ${jobName}: ${error.message}`);\n throw error;\n }\n };\n\n const disableJob = async (jobName: string): Promise<void> => {\n try {\n validateJobName(jobName);\n\n const scheduler = Object.values(state.schedulers).find(s => s.job.name === jobName);\n if (!scheduler) {\n throw new Error(`Job '${jobName}' does not exist`);\n }\n\n if (!scheduler.job.enabled) {\n logger.debug(`Job is already disabled: ${jobName}`);\n return;\n }\n\n // Disable the job\n scheduler.job.enabled = false;\n\n // Clear timer if exists\n if (scheduler.timerId) {\n clearTimeout(scheduler.timerId);\n scheduler.timerId = undefined;\n }\n\n logger.info(`Job disabled: ${jobName}`);\n } catch (error: any) {\n logger.error(`Failed to disable job ${jobName}: ${error.message}`);\n throw error;\n }\n };\n\n const triggerJob = async (jobName: string): Promise<void> => {\n try {\n validateJobName(jobName);\n\n const scheduler = Object.values(state.schedulers).find(s => s.job.name === jobName);\n if (!scheduler) {\n throw new Error(`Job '${jobName}' does not exist`);\n }\n\n if (scheduler.isRunning) {\n throw new Error(`Job '${jobName}' is already running`);\n }\n\n // Trigger immediately\n setImmediate(() => executeJob(scheduler));\n\n logger.info(`Job triggered: ${jobName}`);\n } catch (error: any) {\n logger.error(`Failed to trigger job ${jobName}: ${error.message}`);\n throw error;\n }\n };\n\n const getJobsMap = () => {\n // Return a copy to prevent external modification\n return { ...state.schedulers };\n };\n\n return {\n addJob,\n removeJob,\n hasJob,\n listJobs,\n getJobStats,\n enableJob,\n disableJob,\n triggerJob,\n getJobsMap\n };\n};\n\n// Higher-order function to create decorator registration function\nexport const createSchedulerDecorator = (schedulerManager: SchedulerManager) =>\n (app: FastifyInstance): void => {\n app.decorate('scheduler', schedulerManager);\n };","import crypto from \"node:crypto\";\n\nimport { FastifyInstance, FastifyPluginAsync } from \"fastify\";\nimport fsPlugin from \"fastify-plugin\";\nimport websocketPlugin from \"@fastify/websocket\";\n\nimport { logger } from \"@cloudnux/utils\";\nimport { WebSocketConnectionGoneError } from \"@cloudnux/core-cloud-provider\";\n\n\nimport {\n WebSocketPluginOptions,\n WebSocketConfig,\n WebSocketConnection,\n WebSocketRouteHandler,\n RegisteredWebSocketPath,\n} from \"./types\";\n\nconst DEFAULT_CONFIG: WebSocketConfig = {\n routeKeyField: \"action\",\n};\n\nfunction mergeConfig(\n defaults: WebSocketConfig,\n overrides?: Partial<WebSocketConfig>\n): WebSocketConfig {\n return { ...defaults, ...overrides };\n}\n\nexport const websocketsPlugin: FastifyPluginAsync<WebSocketPluginOptions> =\n fsPlugin(async (\n app: FastifyInstance,\n options: WebSocketPluginOptions\n ) => {\n const config = mergeConfig(DEFAULT_CONFIG, options.config);\n const connections = new Map<string, WebSocketConnection>();\n const handlers: WebSocketRouteHandler[] = [];\n const registeredPaths = new Set<string>();\n const pathModuleMap = new Map<string, string | undefined>();\n\n // Register @fastify/websocket\n await app.register(websocketPlugin);\n\n // Register WebSocket route for a path when first handler uses it\n function ensureRouteForPath(path: string) {\n if (registeredPaths.has(path)) return;\n registeredPaths.add(path);\n\n app.get(path, {\n websocket: true,\n preHandler: async (request, reply) => {\n const connectionId = crypto.randomUUID();\n (request as any)._wsConnectionId = connectionId;\n\n const connectHandlers = handlers.filter(h => h.path === path && h.event === \"connect\");\n for (const h of connectHandlers) {\n await h.handler(connectionId, \"connect\", null, request, reply);\n }\n if (reply.statusCode !== 200)\n return reply; // Prevent WebSocket upgrade if preHandler set an error status\n },\n }, (socket, request) => {\n const connectionId = (request as any)._wsConnectionId ?? crypto.randomUUID();\n const connection: WebSocketConnection = {\n connectionId,\n socket,\n path,\n connectedAt: new Date(),\n };\n connections.set(connectionId, connection);\n\n // Filter handlers for this path at runtime so late-registered handlers are included\n const pathHandlers = () => handlers.filter(h => h.path === path);\n\n // Handle incoming messages\n socket.on(\"message\", (raw) => {\n const data = raw.toString();\n\n const currentHandlers = pathHandlers();\n\n // Try to parse and match a specific route handler\n let routeKey: string | undefined;\n try {\n const parsed = JSON.parse(data);\n routeKey = parsed?.[config.routeKeyField];\n } catch {\n // not JSON, no route key\n }\n\n let matched = false;\n if (routeKey) {\n const routeHandlers = currentHandlers.filter(\n h => h.event === \"message\" && h.route === routeKey\n );\n for (const h of routeHandlers) {\n matched = true;\n h.handler(connectionId, \"message\", data, request).catch((e) => { logger.error(e) });\n }\n }\n\n // Fall back to default message handlers (no route)\n if (!matched) {\n const defaultHandlers = currentHandlers.filter(\n h => h.event === \"message\" && !h.route\n );\n for (const h of defaultHandlers) {\n h.handler(connectionId, \"message\", data, request).catch((e) => { logger.error(e) });\n }\n }\n });\n\n // Handle disconnect\n socket.on(\"close\", () => {\n const disconnectHandlers = pathHandlers().filter(h => h.event === \"disconnect\");\n for (const h of disconnectHandlers) {\n h.handler(connectionId, \"disconnect\", null, request).catch((e) => { logger.error(e) });\n }\n connections.delete(connectionId);\n });\n });\n }\n\n // Create manager with eager route registration\n const manager = {\n registerHandler(handler: WebSocketRouteHandler) {\n handlers.push(handler);\n if (!pathModuleMap.has(handler.path)) {\n pathModuleMap.set(handler.path, handler.module);\n }\n ensureRouteForPath(handler.path);\n },\n getConnections(path?: string): WebSocketConnection[] {\n const allConnections = Array.from(connections.values());\n if (path) {\n return allConnections.filter(c => c.path === path);\n }\n return allConnections;\n },\n getRegisteredPaths(module?: string): RegisteredWebSocketPath[] {\n const all: RegisteredWebSocketPath[] = Array.from(pathModuleMap.entries()).map(([path, mod]) => ({ path, module: mod }));\n if (module) {\n return all.filter(p => p.module === module);\n }\n return all;\n },\n async sendToClient(connectionId: string, data: any): Promise<void> {\n const connection = connections.get(connectionId);\n if (!connection) {\n throw new WebSocketConnectionGoneError(connectionId);\n }\n const payload = typeof data === \"string\" ? data : JSON.stringify(data);\n connection.socket.send(payload);\n },\n async disconnect(connectionId: string): Promise<void> {\n const connection = connections.get(connectionId);\n if (!connection) {\n throw new WebSocketConnectionGoneError(connectionId);\n }\n connection.socket.close();\n },\n };\n\n app.decorate('websockets', manager);\n });\n","export interface RouteInfo {\n method: string | string[]\n url: string\n handler: string\n registeredAt: Date,\n module?: string\n}\n\nclass RouteRegistry {\n private routes: RouteInfo[] = []\n\n private static readonly IGNORED_METHODS = new Set(['OPTIONS', 'HEAD'])\n\n register(routeOptions: any): void {\n const methods: string[] = Array.isArray(routeOptions.method)\n ? routeOptions.method\n : [routeOptions.method]\n\n if (methods.every(m => RouteRegistry.IGNORED_METHODS.has(m.toUpperCase()))) {\n return\n }\n\n const routeInfo: RouteInfo = {\n method: routeOptions.method,\n url: routeOptions.url,\n handler: routeOptions.handler?.name || 'anonymous',\n registeredAt: new Date(),\n module: routeOptions.config?.module\n }\n\n this.routes.push(routeInfo)\n }\n\n getAll(): RouteInfo[] {\n return [...this.routes]\n }\n\n getByMethod(method: string): RouteInfo[] {\n return this.routes.filter(route => {\n if (Array.isArray(route.method)) {\n return route.method.includes(method.toUpperCase())\n }\n return route.method.toUpperCase() === method.toUpperCase()\n })\n }\n\n clear(): void {\n this.routes = []\n }\n\n count(): number {\n return this.routes.length\n }\n}\n\nexport const routeRegistry = new RouteRegistry()"],"mappings":";AAAA,OAAO,WAAW;AAClB,SAAS,OAAAA,YAAW;;;ACApB,IAAI,aAAa,OAAO,UAAU,YAAY,UAAU,OAAO,WAAW,UAAU;AAEpF,IAAO,qBAAQ;;;ACAf,IAAI,WAAW,OAAO,QAAQ,YAAY,QAAQ,KAAK,WAAW,UAAU;AAG5E,IAAI,OAAO,sBAAc,YAAY,SAAS,aAAa,EAAE;AAE7D,IAAO,eAAQ;;;ACLf,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AAC9C,YAAM,IAAI,MAAM,SAAS,KAAK,UAAU,EAAE,MAAM,OAAO,IAAI,CAAC,CAAC;AAAA;AAAA,CAAM;AAAA,IACrE,CAAC;AAGD,YAAQ,IAAI,GAAG,SAAS,MAAM;AAC5B,kBAAY;AAAA,IACd,CAAC;AAAA,EACH,CAAC;AAGD,MAAI,UAAU;AACZ,UAAM,iBAAiBC,MAAK;AAAA,MAC1BF,SAAQ,QAAQ,uCAAuC;AAAA,IACzD;AAEA,UAAM,QAAQ,SAAS,eAAe;AAAA,MACpC,MAAM;AAAA,MACN,eAAe;AAAA,MACf,QAAQ,IAAI,MAAM;AAAA,IACpB,CAAC;AAGD,YAAQ,IAAI,IAAI,MAAM,IAAI,OAAO,GAAG,UAAU;AAC5C,aAAO,MAAM,SAAS,YAAY;AAAA,IACpC,CAAC;AAAA,EACH;AACF;AAEO,IAAM,mBAAmBG,UAAS,0BAA0B;AAAA,EACjE,MAAM;AACR,CAAC;","names":["EOL","objectProto","nativeObjectToString","symToStringTag","array","funcProto","objectProto","funcToString","hasOwnProperty","array","array","array","MAX_SAFE_INTEGER","objectProto","hasOwnProperty","objectProto","hasOwnProperty","objectProto","hasOwnProperty","HASH_UNDEFINED","array","Map","INFINITY","array","array","rsAstralRange","rsComboMarksRange","reComboHalfMarksRange","rsComboSymbolsRange","rsComboRange","rsVarRange","rsZWJ","path","objectProto","hasOwnProperty","path","EOL","path","fsPlugin","WebSocketConnectionGoneError","fsPlugin","fs","fs","path","DEFAULT_CONFIG","mergeConfig","enableJob","disableJob","fsPlugin","mergeConfig","DEFAULT_CONFIG","fsPlugin","DEFAULT_CONFIG","mergeConfig","fsPlugin","path","require","WebSocketConnectionGoneError","path","fsPlugin"]}
|
|
1
|
+
{"version":3,"sources":["../../src/dev-console-plugin/plugin.ts","../../src/queue-plugin/plugin.ts","../../src/queue-plugin/core.ts","../../src/queue-plugin/persistence.ts","../../src/queue-plugin/processing.ts","../../src/queue-plugin/decorator.ts","../../src/queue-plugin/routes.ts","../../src/schedule-plugin/plugin.ts","../../src/schedule-plugin/cron-utils.ts","../../src/schedule-plugin/utils.ts","../../src/schedule-plugin/core.ts","../../src/schedule-plugin/jobs.ts","../../src/schedule-plugin/persistence.ts","../../src/schedule-plugin/processing.ts","../../src/schedule-plugin/decorator.ts","../../src/schedule-plugin/routes.ts","../../src/websocket-plugin/plugin.ts","../../src/dev-console-plugin/route-registry.ts"],"sourcesContent":["import path from \"path\";\nimport { FastifyInstance } from \"fastify\";\nimport fastifyStatic from \"@fastify/static\";\nimport fsPlugin from \"fastify-plugin\";\nimport { createRequire } from 'module';\nconst require = createRequire(import.meta.url);\n\nimport { WebSocketConnectionGoneError } from \"@cloudnux/core-cloud-provider\";\n\nimport \"../logger/types\";\n\nimport \"../queue-plugin\";\nimport \"../schedule-plugin\";\nimport \"../websocket-plugin\";\n\nimport { routeRegistry } from \"./route-registry\";\n\ninterface LogEntry {\n id: string;\n timestamp: Date;\n levelName: string;\n message: string;\n meta?: Record<string, unknown>;\n module: string;\n reqId: string;\n}\n\nclass LogStore {\n private logs: LogEntry[] = [];\n private maxLogs = 1000;\n private listeners: ((log: LogEntry) => void)[] = [];\n\n addLog(entry: LogEntry) {\n this.logs.unshift(entry);\n if (this.logs.length > this.maxLogs) {\n this.logs = this.logs.slice(0, this.maxLogs);\n }\n this.listeners.forEach(listener => listener(entry));\n }\n\n getLogs(limit = 100) {\n return this.logs.slice(0, limit);\n }\n\n clear() {\n this.logs = [];\n }\n\n subscribe(listener: (log: LogEntry) => void) {\n this.listeners.push(listener);\n return () => {\n this.listeners = this.listeners.filter(l => l !== listener);\n };\n }\n}\n\nconst logStore = new LogStore();\n\ninterface HttpHistoryEntry {\n id: string;\n method: string;\n routeUrl: string;\n url: string;\n statusCode: number;\n duration: number;\n reqId: string;\n requestHeaders: Record<string, unknown>;\n requestBody?: unknown;\n timestamp: Date;\n}\n\n// Records every real request that hits a module route (matched by url\n// prefix, same \"/api\" convention routeRegistry uses), not just the ones\n// fired from the console's own \"Test Route\" panel - so RouteDetailView can\n// show traffic that actually happened, keyed by the route's method+template\n// since that's all the frontend has to ask for.\nclass HttpHistoryStore {\n private entries: Map<string, HttpHistoryEntry[]> = new Map();\n private readonly maxPerRoute = 50;\n\n add(entry: HttpHistoryEntry) {\n const key = `${entry.method} ${entry.routeUrl}`;\n const existing = this.entries.get(key) ?? [];\n existing.unshift(entry);\n if (existing.length > this.maxPerRoute) {\n existing.length = this.maxPerRoute;\n }\n this.entries.set(key, existing);\n }\n\n get(method: string, routeUrl: string) {\n return this.entries.get(`${method.toUpperCase()} ${routeUrl}`) ?? [];\n }\n\n clear() {\n this.entries.clear();\n }\n}\n\nconst httpHistoryStore = new HttpHistoryStore();\n\nexport interface DevConsolePluginOptions {\n prefix?: string;\n enableUI?: boolean;\n}\n\nasync function devConsolePluginFunction(\n fastify: FastifyInstance,\n options: DevConsolePluginOptions = {}\n) {\n const { prefix = 'console', enableUI = true } = options;\n\n // Read off `fastify.logging` (decorated once by router/index.ts on the shared\n // FastifyInstance), not a direct `../logger` import - dev-console-plugin is its\n // own separately-bundled tsup entry, so a direct import would get its own\n // disconnected copy of the logger's listeners Set and never see logs published\n // from queue-plugin/schedule-plugin/websocket-plugin's bundles.\n const unsubscribe = fastify.logging.subscribeToLogs((entry) => {\n logStore.addLog({\n id: Date.now().toString() + Math.random().toString(36).slice(2, 9),\n timestamp: new Date(entry.time),\n levelName: entry.levelName,\n message: entry.msg,\n meta: entry.meta,\n module: entry.module,\n reqId: entry.reqId,\n });\n });\n\n // Unsubscribe and clear log store on plugin teardown\n fastify.addHook('onClose', (_instance, done) => {\n unsubscribe();\n logStore.clear();\n httpHistoryStore.clear();\n done();\n });\n\n // Register route discovery hook for all routes\n fastify.addHook('onRoute', (routeOptions) => {\n if (routeOptions.prefix === \"/api\") {\n routeRegistry.register(routeOptions);\n }\n });\n\n // Stamp a start time on every request so onResponse below can compute\n // duration - registered fastify-plugin-wide (like onRoute above), so it\n // sees traffic regardless of whether it was triggered from the console UI.\n fastify.addHook('onRequest', (request, _reply, done) => {\n (request as any)._historyStart = Date.now();\n done();\n });\n\n fastify.addHook('onResponse', (request, reply, done) => {\n const routeUrl = request.routeOptions.url;\n if (routeUrl?.startsWith('/api')) {\n const start = (request as any)._historyStart as number | undefined;\n httpHistoryStore.add({\n id: Date.now().toString() + Math.random().toString(36).slice(2, 9),\n method: request.method,\n routeUrl,\n url: request.url,\n statusCode: reply.statusCode,\n duration: start ? Date.now() - start : 0,\n reqId: request.id,\n requestHeaders: request.headers,\n requestBody: request.body,\n timestamp: new Date(),\n });\n }\n done();\n });\n\n // API endpoints\n fastify.get(`/${prefix}/routes`, async () => {\n return { routes: routeRegistry.getAll() };\n });\n\n fastify.get(`/${prefix}/routes/:method`, async (request) => {\n const { method } = request.params as { method: string };\n return { routes: routeRegistry.getByMethod(method) };\n });\n\n // Real requests that hit a given route (method + url template), captured\n // by the onResponse hook above - not just clicks from \"Test Route\".\n fastify.get(`/${prefix}/routes/history`, async (request, reply) => {\n const { method, url } = request.query as { method?: string; url?: string };\n\n if (!method || !url) {\n return reply.status(400).send({ error: 'method and url query params are required' });\n }\n\n return { history: httpHistoryStore.get(method, url) };\n });\n\n fastify.get(`/${prefix}/registry/stats`, async () => {\n return {\n totalRoutes: routeRegistry.count(),\n registeredAt: new Date()\n };\n });\n\n // Modules endpoints - group resources by module\n fastify.get(`/${prefix}/modules`, async (_, reply) => {\n const queueManager = fastify.queues;\n const schedulerManager = fastify.scheduler;\n const wsManager = fastify.websockets;\n\n if (!queueManager || !schedulerManager || !wsManager) {\n return reply.status(503).send({ error: 'Services not available' });\n }\n\n // Get all routes and filter HTTP routes by prefix\n const allRoutes = routeRegistry.getAll();\n const httpRoutes = allRoutes;\n\n // Get all modules from routes, queues, schedules, and websockets\n const moduleSet = new Set<string>();\n\n httpRoutes.forEach(route => {\n if (route.module) moduleSet.add(route.module);\n });\n\n const allQueueNames = queueManager.listQueues();\n const allJobNames = schedulerManager.listJobs();\n\n allQueueNames.forEach(queueName => {\n const queueStats = queueManager.getQueueStats(queueName);\n if (queueStats?.module) moduleSet.add(queueStats.module);\n });\n\n allJobNames.forEach(jobName => {\n const jobStats = schedulerManager.getJobStats(jobName);\n if (jobStats?.job.module) moduleSet.add(jobStats.job.module);\n });\n\n wsManager.getRegisteredPaths().forEach(p => {\n if (p.module) moduleSet.add(p.module);\n });\n\n // Create module objects\n const modules = Array.from(moduleSet).map(moduleName => {\n // Get routes for this module\n const moduleRoutes = httpRoutes.filter(route => route.module === moduleName);\n\n // Get queues for this module\n const moduleQueueNames = queueManager.listQueues(moduleName);\n const moduleQueues = moduleQueueNames.map(name => {\n const stats = queueManager.getQueueStats(name);\n return {\n name,\n stats: stats ? {\n incoming: stats.incoming.length,\n processing: stats.processing.length,\n dlq: stats.dlq.length\n } : null\n };\n });\n\n // Get schedules for this module\n const moduleJobNames = schedulerManager.listJobs(moduleName);\n const moduleSchedules = moduleJobNames.map(name => {\n const jobStats = schedulerManager.getJobStats(name);\n return {\n name,\n enabled: jobStats?.job.enabled || false,\n isRunning: jobStats?.isRunning || false,\n cronExpression: jobStats?.job.cronExpression,\n timezone: jobStats?.job.timezone\n };\n });\n\n // Get websockets for this module\n const moduleWebSockets = wsManager\n ? wsManager.getRegisteredPaths(moduleName).map(p => ({\n path: p.path,\n connectionCount: wsManager.getConnections(p.path).length\n }))\n : [];\n\n return {\n name: moduleName,\n routes: moduleRoutes,\n queues: moduleQueues,\n schedules: moduleSchedules,\n websockets: moduleWebSockets\n };\n });\n\n return { modules };\n });\n\n // Queues endpoints - access via decorator\n fastify.get(`/${prefix}/queues`, async (_, reply) => {\n const queueManager = fastify.queues;\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n const queueNames = queueManager.listQueues();\n const queues = queueNames.map(name => {\n const stats = queueManager.getQueueStats(name);\n return {\n name,\n stats: stats ? {\n incoming: stats.incoming.length,\n processing: stats.processing.length,\n dlq: stats.dlq.length\n } : null\n };\n });\n\n return { queues };\n });\n\n fastify.get(`/${prefix}/queues/:queueName`, async (request, reply) => {\n const { queueName } = request.params as { queueName: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n const queueStats = queueManager.getQueueStats(queueName);\n if (!queueStats) {\n return reply.status(404).send({ error: 'Queue not found' });\n }\n\n const config = queueManager.getConfig();\n\n return {\n name: queueName,\n stats: {\n incoming: queueStats.incoming.length,\n processing: queueStats.processing.length,\n dlq: queueStats.dlq.length,\n configuration: config\n },\n messages: {\n incoming: queueStats.incoming,\n processing: queueStats.processing,\n dlq: queueStats.dlq\n }\n };\n });\n\n // Messages that already finished processing (completed or DLQ'd) -\n // covers listener invocations triggered by real traffic, not just\n // messages enqueued from the console's own form.\n fastify.get(`/${prefix}/queues/:queueName/history`, async (request, reply) => {\n const { queueName } = request.params as { queueName: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n if (!queueManager.getQueueStats(queueName)) {\n return reply.status(404).send({ error: 'Queue not found' });\n }\n\n return { history: queueManager.getMessageHistory(queueName) };\n });\n\n // Queue action endpoints\n fastify.get(`/${prefix}/queues/:queueName/process-dlq`, async (request, reply) => {\n const { queueName } = request.params as { queueName: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n try {\n const result = await queueManager.processDlq(queueName);\n return reply.status(200).send(result);\n } catch (error) {\n return reply.status(500).send({\n message: 'Failed to process DLQ',\n error\n });\n }\n });\n\n fastify.get(`/${prefix}/queues/:queueName/purge-dlq`, async (request, reply) => {\n const { queueName } = request.params as { queueName: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n try {\n const result = await queueManager.purgeDlq(queueName);\n return reply.status(200).send(result);\n } catch (error) {\n return reply.status(500).send({\n message: 'Failed to purge DLQ',\n error\n });\n }\n });\n\n fastify.post(`/${prefix}/queues/:queueName/enqueue`, async (request, reply) => {\n const { queueName } = request.params as { queueName: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n try {\n const result = await queueManager.enqueueMessage(queueName, request.body, request.headers as Record<string, any>);\n return reply.status(200).send(result);\n } catch (error) {\n return reply.status(500).send({\n message: 'Failed to enqueue message',\n error\n });\n }\n });\n\n fastify.delete(`/${prefix}/queues/:queueName`, async (request, reply) => {\n const { queueName } = request.params as { queueName: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n try {\n await queueManager.removeQueue(queueName);\n return reply.status(200).send({\n status: 'success',\n message: `Queue ${queueName} removed successfully`\n });\n } catch (error) {\n return reply.status(500).send({\n message: 'Failed to remove queue',\n error\n });\n }\n });\n\n fastify.post(`/${prefix}/queues`, async (request, reply) => {\n const { queueName, module } = request.body as { queueName: string; module?: string };\n const queueManager = fastify.queues;\n\n if (!queueManager) {\n return reply.status(503).send({ error: 'Queue service not available' });\n }\n\n if (!queueName) {\n return reply.status(400).send({ error: 'Queue name is required' });\n }\n\n try {\n // Simple handler that logs messages\n const handler = async (message: any) => {\n console.log(`Processing message in ${queueName}:`, message);\n return undefined;\n };\n\n await queueManager.addQueue(queueName, handler, module);\n return reply.status(201).send({\n status: 'success',\n message: `Queue ${queueName} created successfully`,\n queueName\n });\n } catch (error) {\n return reply.status(500).send({\n message: 'Failed to create queue',\n error\n });\n }\n });\n\n // Schedules endpoints - access via decorator\n fastify.get(`/${prefix}/schedules`, async (_, reply) => {\n const schedulerManager = fastify.scheduler;\n if (!schedulerManager) {\n return reply.status(503).send({ error: 'Scheduler service not available' });\n }\n\n const jobNames = schedulerManager.listJobs();\n const jobs = jobNames.map(name => {\n const jobStats = schedulerManager.getJobStats(name);\n return {\n name,\n enabled: jobStats?.job.enabled || false,\n isRunning: jobStats?.isRunning || false,\n cronExpression: jobStats?.job.cronExpression,\n timezone: jobStats?.job.timezone\n };\n });\n\n return { schedules: jobs };\n });\n\n fastify.get(`/${prefix}/schedules/:jobName`, async (request, reply) => {\n const { jobName } = request.params as { jobName: string };\n const schedulerManager = (fastify as any).scheduler;\n\n if (!schedulerManager) {\n return reply.status(503).send({ error: 'Scheduler service not available' });\n }\n\n const jobStats = schedulerManager.getJobStats(jobName);\n if (!jobStats) {\n return reply.status(404).send({ error: 'Job not found' });\n }\n\n return {\n name: jobName,\n job: jobStats.job,\n isRunning: jobStats.isRunning,\n timerId: jobStats.timerId ? 'scheduled' : 'not_scheduled'\n };\n });\n\n // Every real execution of this job - tick-triggered or manually triggered,\n // from the console or otherwise - not just runs kicked off from this UI.\n fastify.get(`/${prefix}/schedules/:jobName/executions`, async (request, reply) => {\n const { jobName } = request.params as { jobName: string };\n const schedulerManager = fastify.scheduler;\n\n if (!schedulerManager) {\n return reply.status(503).send({ error: 'Scheduler service not available' });\n }\n\n if (!schedulerManager.getJobStats(jobName)) {\n return reply.status(404).send({ error: 'Job not found' });\n }\n\n return { executions: schedulerManager.getJobExecutionHistory(jobName) };\n });\n\n // Schedule action endpoints - use decorators\n fastify.post(`/${prefix}/schedules/:jobName/trigger`, async (request, reply) => {\n const { jobName } = request.params as { jobName: string };\n const schedulerManager = fastify.scheduler;\n\n if (!schedulerManager) {\n return reply.status(503).send({ error: 'Scheduler service not available' });\n }\n\n try {\n await schedulerManager.triggerJob(jobName);\n return reply.status(200).send({\n status: 'success',\n message: `Schedule ${jobName} triggered successfully`\n });\n } catch {\n return reply.status(500).send({ error: 'Failed to trigger schedule' });\n }\n });\n\n fastify.put(`/${prefix}/schedules/:jobName/enable`, async (request, reply) => {\n const { jobName } = request.params as { jobName: string };\n const schedulerManager = fastify.scheduler;\n\n if (!schedulerManager) {\n return reply.status(503).send({ error: 'Scheduler service not available' });\n }\n\n try {\n await schedulerManager.enableJob(jobName);\n return reply.status(200).send({\n status: 'success',\n message: `Schedule ${jobName} enabled successfully`\n });\n } catch {\n return reply.status(500).send({ error: 'Failed to enable schedule' });\n }\n });\n\n fastify.put(`/${prefix}/schedules/:jobName/disable`, async (request, reply) => {\n const { jobName } = request.params as { jobName: string };\n const schedulerManager = fastify.scheduler;\n\n if (!schedulerManager) {\n return reply.status(503).send({ error: 'Scheduler service not available' });\n }\n\n try {\n await schedulerManager.disableJob(jobName);\n return reply.status(200).send({\n status: 'success',\n message: `Schedule ${jobName} disabled successfully`\n });\n } catch {\n return reply.status(500).send({ error: 'Failed to disable schedule' });\n }\n });\n\n // Logs endpoints\n fastify.get(`/${prefix}/logs`, async (request) => {\n const {\n limit = 100,\n level,\n module,\n reqId,\n } = request.query as {\n limit?: number;\n level?: string;\n module?: string;\n reqId?: string;\n };\n\n let logs = logStore.getLogs(Number(limit));\n\n if (level) {\n logs = logs.filter(log => log.levelName === level);\n }\n\n if (module) {\n logs = logs.filter(log => log.module === module);\n }\n\n if (reqId) {\n logs = logs.filter(log => log.reqId === reqId);\n }\n\n return { logs };\n });\n\n fastify.delete(`/${prefix}/logs`, async () => {\n logStore.clear();\n return { status: 'success', message: 'Logs cleared' };\n });\n\n // WebSocket endpoints\n fastify.get(`/${prefix}/websockets`, async (_, reply) => {\n const wsManager = fastify.websockets;\n if (!wsManager) {\n return reply.status(503).send({ error: 'WebSocket service not available' });\n }\n\n const connections = wsManager.getConnections();\n const pathSet = new Set(connections.map(c => c.path));\n const paths = Array.from(pathSet).map(p => ({\n path: p,\n connections: wsManager.getConnections(p).map(c => ({\n connectionId: c.connectionId,\n path: c.path,\n connectedAt: c.connectedAt,\n })),\n }));\n\n return { paths };\n });\n\n fastify.get(`/${prefix}/websockets/:path`, async (request, reply) => {\n const wsManager = fastify.websockets;\n if (!wsManager) {\n return reply.status(503).send({ error: 'WebSocket service not available' });\n }\n\n const { path: wsPath } = request.params as { path: string };\n const decodedPath = '/' + wsPath;\n const connections = wsManager.getConnections(decodedPath).map(c => ({\n connectionId: c.connectionId,\n path: c.path,\n connectedAt: c.connectedAt,\n }));\n\n return { path: decodedPath, connections };\n });\n\n fastify.post(`/${prefix}/websockets/:connectionId/send`, async (request, reply) => {\n const wsManager = fastify.websockets;\n if (!wsManager) {\n return reply.status(503).send({ error: 'WebSocket service not available' });\n }\n\n const { connectionId } = request.params as { connectionId: string };\n\n try {\n await wsManager.sendToClient(connectionId, request.body);\n return reply.status(200).send({ status: 'success', message: `Message sent to ${connectionId}` });\n } catch (error) {\n if (error instanceof WebSocketConnectionGoneError) {\n return reply.status(410).send({ error: error.message });\n }\n return reply.status(404).send({ error: (error as Error).message });\n }\n });\n\n // Server-Sent Events for real-time logs\n fastify.get(`/${prefix}/logs/stream`, async (request, reply) => {\n const { level, module, reqId } = request.query as {\n level?: string;\n module?: string;\n reqId?: string;\n };\n\n // Mirror the same filters the REST /logs endpoint applies - otherwise a\n // client viewing a filtered (e.g. module-scoped) log list gets every\n // other module's activity pushed into it live, which looks exactly like\n // cleared logs reappearing.\n const matchesFilters = (log: LogEntry) => {\n if (level && log.levelName !== level) return false;\n if (module && log.module !== module) return false;\n if (reqId && log.reqId !== reqId) return false;\n return true;\n };\n\n reply.type('text/event-stream');\n reply.header('Cache-Control', 'no-cache');\n reply.header('Connection', 'keep-alive');\n reply.header('Access-Control-Allow-Origin', '*');\n\n // Send initial logs\n const initialLogs = logStore.getLogs(50).filter(matchesFilters);\n reply.raw.write(`data: ${JSON.stringify({ type: 'initial', logs: initialLogs })}\\n\\n`);\n\n // Subscribe to new logs\n const unsubscribe = logStore.subscribe((log) => {\n if (matchesFilters(log)) {\n reply.raw.write(`data: ${JSON.stringify({ type: 'log', log })}\\n\\n`);\n }\n });\n\n // Cleanup on client disconnect\n request.raw.on('close', () => {\n unsubscribe();\n });\n });\n\n // Serve static UI files if enabled\n if (enableUI) {\n const devConsolePath = path.dirname(\n require.resolve('@cloudnux/dev-console/dist/index.html')\n );\n\n await fastify.register(fastifyStatic, {\n root: devConsolePath,\n decorateReply: true,\n prefix: `/${prefix}/`\n });\n\n // Serve dev-console SPA\n fastify.get(`/${prefix}`, async (_, reply) => {\n return reply.sendFile('index.html');\n });\n }\n}\n\nexport const devConsolePlugin = fsPlugin(devConsolePluginFunction, {\n name: 'dev-console-plugin'\n})","import { FastifyInstance, FastifyPluginAsync } from \"fastify\";\nimport fsPlugin from \"fastify-plugin\";\n\nimport { QueuePluginOptions, QueueRuntime } from \"./types\";\nimport { DEFAULT_CONFIG, mergeConfig } from \"./core\";\nimport { tick } from \"./processing\";\nimport { initializePersistence } from \"./persistence\";\nimport { createQueueManager } from \"./decorator\";\nimport { registerQueueRoutes } from \"./routes\";\n\nexport const queuesPlugin: FastifyPluginAsync<QueuePluginOptions> =\n fsPlugin(async (\n app: FastifyInstance,\n options: QueuePluginOptions\n ) => {\n const runtime: QueueRuntime = {\n config: mergeConfig(DEFAULT_CONFIG, options.config),\n queues: {},\n dirtyQueues: new Set<string>(),\n lastSavedAt: Date.now(),\n messageHistory: [],\n logging: app.logging,\n };\n\n // One timer for the entire plugin: every tickIntervalMs, check every\n // queue for batches/retries that are due, and save persistence if\n // its interval has elapsed. See processing.ts:tick.\n const tickIntervalId = setInterval(() => tick(runtime), runtime.config.tickIntervalMs);\n app.addHook('onClose', async () => clearInterval(tickIntervalId));\n\n app.decorate('queues', createQueueManager(runtime));\n registerQueueRoutes(app, options.prefix);\n\n await initializePersistence(runtime);\n });","import { EventHandler, QueueConfig, QueueMessage, QueueMessageHistoryEntry, QueueService, QueueSummary } from \"./types\";\n\nconst MAX_MESSAGE_HISTORY = 500;\n\n// default config\nexport const DEFAULT_CONFIG: QueueConfig = {\n batchSize: 10,\n batchWindowMs: 500,\n maxRetries: 3,\n parallel: true,\n maxConcurrent: 5,\n retryBackoff: true,\n tickIntervalMs: 50,\n persistence: {\n enabled: true,\n directory: './.develop/queue-data',\n saveInterval: 60000,\n saveOnShutdown: false\n }\n};\n\n// Pure function to merge configs\nexport const mergeConfig = (defaultConfig: QueueConfig, userConfig?: Partial<QueueConfig>): QueueConfig => ({\n ...defaultConfig,\n ...userConfig,\n persistence: {\n ...defaultConfig.persistence,\n ...(userConfig?.persistence || {})\n }\n});\n\n// Pure function to create a new queue service\nexport const createQueueService = (handler: EventHandler, module?: string): QueueService => ({\n handler,\n incoming: [],\n processing: [],\n dlq: [],\n processingBatch: false,\n module\n});\n\n// Pure function to create a queue message\nexport const createQueueMessage = (body: any, headers: Record<string, any>): QueueMessage => {\n const id = Date.now().toString() + Math.random().toString(36).substring(2, 7);\n const message: QueueMessage = {\n id,\n timestamp: new Date(),\n attempts: 0,\n payload: body,\n attributes: headers,\n };\n\n const delaySeconds = Number(headers?.['x-delay-seconds']);\n if (delaySeconds > 0) {\n message.nextAttempt = new Date(Date.now() + delaySeconds * 1000);\n }\n\n return message;\n};\n\n// Pure function to schedule a retry for a message\n// Puts a failed message back into `incoming` to wait out its backoff delay,\n// same as any delayed message - so the next batch dispatch picks it up\n// mixed in with whatever else is ready, instead of retrying it alone.\nexport const scheduleRetry = (queueService: QueueService, message: QueueMessage, delayMs: number): void => {\n removeFromProcessing(queueService, message.id);\n message.attempts += 1;\n message.nextAttempt = new Date(Date.now() + delayMs);\n queueService.incoming.push(message);\n};\n\n\n// Pure function to check whether a message is ready to be processed\nexport const isMessageReady = (message: QueueMessage, now: number = Date.now()): boolean => {\n return !message.nextAttempt || message.nextAttempt.getTime() <= now;\n};\n\n// Pure function to move ready messages from incoming to processing, leaving delayed messages in place\nexport const moveToProcessing = (queueService: QueueService, batchSize: number): QueueMessage[] => {\n const now = Date.now();\n const ready: QueueMessage[] = [];\n const remaining: QueueMessage[] = [];\n\n for (const message of queueService.incoming) {\n if (ready.length < batchSize && isMessageReady(message, now)) {\n ready.push(message);\n } else {\n remaining.push(message);\n }\n }\n\n queueService.incoming = remaining;\n return ready;\n};\n\n// Pure function to remove message from processing queue\nexport const removeFromProcessing = (queueService: QueueService, messageId: string): void => {\n queueService.processing = queueService.processing.filter(msg => msg.id !== messageId);\n};\n\n// Pure function to move message to DLQ\nexport const moveToDLQ = (queueService: QueueService, message: QueueMessage, error: string): void => {\n queueService.dlq.push({\n ...message,\n error,\n failedAt: new Date()\n });\n removeFromProcessing(queueService, message.id);\n};\n\n// Pure function to calculate backoff delay\nexport const calculateBackoffDelay = (attempts: number): number => {\n return Math.pow(2, attempts) * 100;\n};\n\n// Pure function to create queue summary\nexport const createQueueSummary = (queueService: QueueService, config: QueueConfig): QueueSummary => ({\n incoming: queueService.incoming.length,\n processing: queueService.processing.length,\n dlq: queueService.dlq.length,\n isProcessing: queueService.processingBatch,\n configuration: {\n batchSize: config.batchSize,\n batchWindowMs: config.batchWindowMs,\n parallel: config.parallel,\n maxConcurrent: config.maxConcurrent\n }\n});\n\n// Pure function to create dashboard summary\nexport const createDashboardSummary = (queues: Record<string, QueueService>, config: QueueConfig): Record<string, QueueSummary> => {\n return Object.entries(queues).reduce((summary, [queueName, queue]) => {\n summary[queueName] = createQueueSummary(queue, config);\n return summary;\n }, {} as Record<string, QueueSummary>);\n};\n\n// Pure function to move DLQ messages back to incoming\nexport const moveDLQToIncoming = (queueService: QueueService): number => {\n const dlqCount = queueService.dlq.length;\n\n if (dlqCount === 0) return 0;\n\n const movedMessages = queueService.dlq.map(message => ({\n ...message,\n attempts: 0,\n error: undefined,\n failedAt: undefined,\n reprocessed: true,\n originalId: message.id,\n id: Date.now().toString() + Math.random().toString(36).substring(2, 7)\n }));\n\n queueService.incoming.push(...movedMessages);\n queueService.dlq = [];\n\n return dlqCount;\n};\n\n// Pure function to purge DLQ\nexport const purgeDLQ = (queueService: QueueService): number => {\n const dlqCount = queueService.dlq.length;\n queueService.dlq = [];\n return dlqCount;\n};\n\n// Pure function to build a message-history record for a completed or\n// terminally-failed message. This is what powers the dev console's\n// per-queue history view for messages that already left incoming/processing/dlq.\nexport const createHistoryEntry = (\n queueName: string,\n message: QueueMessage,\n status: 'completed' | 'failed',\n error?: string\n): QueueMessageHistoryEntry => ({\n id: message.id,\n queueName,\n status,\n timestamp: message.timestamp,\n completedAt: new Date(),\n attempts: message.attempts,\n payload: message.payload,\n attributes: message.attributes,\n error,\n});\n\n// Appends to the bounded history log in place, mirroring schedule-plugin's\n// executionHistory cap so long-running processes don't grow this unbounded.\nexport const recordMessageHistory = (\n history: QueueMessageHistoryEntry[],\n entry: QueueMessageHistoryEntry\n): void => {\n history.push(entry);\n if (history.length > MAX_MESSAGE_HISTORY) {\n history.splice(0, history.length - MAX_MESSAGE_HISTORY);\n }\n};","import * as fs from \"fs/promises\";\nimport * as path from \"path\";\n\nimport { QueueService, QueueRuntime, QueueMessage } from \"./types\";\n\nconst createQueueData = (queueService: QueueService) => ({\n incoming: queueService.incoming,\n processing: queueService.processing,\n dlq: queueService.dlq,\n savedAt: new Date()\n});\n\nconst restoreDates = (messages: QueueMessage[]): void => {\n messages.forEach((msg: QueueMessage) => {\n msg.timestamp = new Date(msg.timestamp);\n if (msg.nextAttempt) msg.nextAttempt = new Date(msg.nextAttempt);\n if (msg.failedAt) msg.failedAt = new Date(msg.failedAt);\n });\n};\n\nexport const saveQueueState = async (runtime: QueueRuntime, queueName: string, queueService: QueueService): Promise<void> => {\n try {\n const queueData = createQueueData(queueService);\n const now = Date.now();\n const queueFilePath = path.join(runtime.config.persistence.directory, `${queueName}.json`);\n const tempFilePath = path.join(runtime.config.persistence.directory, `${queueName}.${now}temp.json`);\n\n // Write to a temp file first, then rename - rename is atomic, so a\n // reader never sees a half-written file.\n await fs.writeFile(tempFilePath, JSON.stringify(queueData, null, 2), 'utf8');\n await fs.rename(tempFilePath, queueFilePath);\n\n runtime.logging.debug({ module: queueService.module }, `Queue state saved: ${queueName}`);\n } catch (error: any) {\n runtime.logging.error(\n { module: queueService.module, error: error?.message },\n `Failed to save queue state for ${queueName}`\n );\n }\n};\n\nexport const saveAllQueueStates = async (runtime: QueueRuntime): Promise<void> => {\n try {\n for (const [queueName, queueService] of Object.entries(runtime.queues)) {\n await saveQueueState(runtime, queueName, queueService);\n }\n runtime.logging.debug(`All queue states saved to ${runtime.config.persistence.directory}`);\n } catch (error: any) {\n runtime.logging.error({ error: error?.message }, `Failed to save all queue states`);\n }\n};\n\n// Only saves queues that changed since the last save (tracked via\n// runtime.dirtyQueues). Called from processing.ts's tick once\n// persistence.saveInterval has elapsed.\nexport const saveDirtyQueueStates = async (runtime: QueueRuntime): Promise<void> => {\n if (runtime.dirtyQueues.size === 0) return;\n\n try {\n const queueNames = [...runtime.dirtyQueues];\n runtime.dirtyQueues.clear();\n\n for (const queueName of queueNames) {\n if (runtime.queues[queueName]) {\n await saveQueueState(runtime, queueName, runtime.queues[queueName]);\n }\n }\n } catch (error: any) {\n runtime.logging.error({ error: error?.message }, `Failed to save dirty queue states`);\n }\n};\n\n// Called from addQueue, right after a queue is registered, to restore\n// whatever was on disk for it from a previous run.\nexport const loadQueueState = async (runtime: QueueRuntime, queueName: string): Promise<void> => {\n try {\n const queueService = runtime.queues[queueName];\n if (!queueService) {\n runtime.logging.warn(`Skipping load for non-existent queue: ${queueName}`);\n return;\n }\n\n const queueFilePath = path.join(runtime.config.persistence.directory, `${queueName}.json`);\n\n try {\n const data = await fs.readFile(queueFilePath, 'utf8');\n const queueData = JSON.parse(data);\n\n restoreDates(queueData.incoming);\n restoreDates(queueData.processing);\n restoreDates(queueData.dlq);\n\n queueService.incoming = queueData.incoming;\n queueService.dlq = queueData.dlq;\n queueService.processing = [];\n\n // Nothing is actually in flight right after a restart - anything\n // that was mid-handling goes back into the ready pool like any\n // other message (the tick's next batch picks it up), or straight\n // to the DLQ if it had already used up its retries before the\n // shutdown.\n for (const message of queueData.processing as QueueMessage[]) {\n if (message.attempts >= runtime.config.maxRetries) {\n queueService.dlq.push({ ...message, error: 'max retries exceeded before restart', failedAt: new Date() });\n } else {\n message.nextAttempt = new Date();\n queueService.incoming.push(message);\n }\n }\n\n runtime.logging.debug(\n { module: queueService.module },\n `Queue state loaded: ${queueName} (saved at ${queueData.savedAt})`\n );\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n runtime.logging.debug({ module: queueService.module }, `No saved state found for queue: ${queueName}`);\n } else {\n throw error;\n }\n }\n } catch (error: any) {\n runtime.logging.error({ error: error?.message }, `Failed to load queue state for ${queueName}`);\n }\n};\n\nexport const initializePersistence = async (runtime: QueueRuntime): Promise<void> => {\n try {\n await fs.mkdir(runtime.config.persistence.directory, { recursive: true });\n\n if (runtime.config.persistence.saveOnShutdown) {\n const shutdownHandler = async () => {\n runtime.logging.debug('Saving queue state before shutdown...');\n await saveAllQueueStates(runtime);\n process.exit(0);\n };\n\n process.on('SIGINT', shutdownHandler);\n process.on('SIGTERM', shutdownHandler);\n }\n\n runtime.logging.debug(`Queue persistence initialized: ${runtime.config.persistence.directory}`);\n } catch (error: any) {\n runtime.logging.error({ error: error?.message }, `Failed to initialize queue persistence`);\n }\n};","import { QueueMessage, QueueService, QueueRuntime } from \"./types\";\nimport {\n isMessageReady,\n moveToProcessing,\n removeFromProcessing,\n moveToDLQ,\n scheduleRetry,\n calculateBackoffDelay,\n createHistoryEntry,\n recordMessageHistory,\n} from \"./core\";\nimport { saveDirtyQueueStates } from \"./persistence\";\n\n// Sends one message through the user's handler. Success removes it from\n// `processing`; failure either schedules a retry or moves it to the DLQ.\n// Used for both freshly-batched messages and individually-retried ones.\n// Wrapped in runWithLogContext by processBatch, so every log call below\n// (and anything the user's handler itself logs) carries this message's\n// module/reqId without having to pass them through explicitly.\nconst processMessage = async (\n runtime: QueueRuntime,\n queueName: string,\n message: QueueMessage,\n queueService: QueueService\n): Promise<void> => {\n try {\n const result = await queueService.handler(message);\n if (result?.failureId) {\n handleFailure(runtime, queueName, message, queueService);\n } else {\n removeFromProcessing(queueService, message.id);\n recordMessageHistory(runtime.messageHistory, createHistoryEntry(queueName, message, 'completed'));\n runtime.logging.debug(`Successfully processed message ${message.id} in queue ${queueName}`);\n }\n } catch {\n handleFailure(runtime, queueName, message, queueService);\n }\n};\n\nconst handleFailure = (\n runtime: QueueRuntime,\n queueName: string,\n message: QueueMessage,\n queueService: QueueService\n): void => {\n runtime.logging.error(`Error processing message ${message.id} in queue ${queueName}: handler returned failure`);\n\n if (message.attempts >= runtime.config.maxRetries) {\n moveToDLQ(queueService, message, 'max retries exceeded');\n recordMessageHistory(runtime.messageHistory, createHistoryEntry(queueName, message, 'failed', 'max retries exceeded'));\n return;\n }\n\n const delayMs = runtime.config.retryBackoff ? calculateBackoffDelay(message.attempts + 1) : 0;\n scheduleRetry(queueService, message, delayMs);\n runtime.logging.debug(`Scheduling retry for message ${message.id} in ${delayMs}ms`);\n};\n\n// Pulls up to batchSize ready messages out of `incoming` and runs them\n// through processMessage concurrently. Guarded by `processingBatch` so the\n// tick never starts a second batch for a queue while one is still running.\nconst processBatch = async (\n runtime: QueueRuntime,\n queueName: string,\n queueService: QueueService\n): Promise<void> => {\n if (queueService.processingBatch) {\n return;\n }\n\n try {\n queueService.processingBatch = true;\n\n const messagesToProcess = moveToProcessing(queueService, runtime.config.batchSize);\n if (messagesToProcess.length === 0) {\n return;\n }\n\n queueService.processing.push(...messagesToProcess);\n\n await Promise.all(\n messagesToProcess.map(message => runtime.logging.runWithLogContext(\n { module: queueService.module, reqId: message.id },\n () => processMessage(runtime, queueName, message, queueService)\n ))\n );\n\n if (runtime.config.persistence.enabled) {\n runtime.dirtyQueues.add(queueName);\n }\n } finally {\n queueService.processingBatch = false;\n }\n};\n\nconst dispatchBatchIfDue = (\n runtime: QueueRuntime,\n queueName: string,\n queueService: QueueService,\n now: number\n): void => {\n if (queueService.processingBatch) {\n return;\n }\n const ready = queueService.incoming.filter(message => isMessageReady(message, now));\n if (ready.length === 0) {\n return;\n }\n\n const dueBySize = ready.length >= runtime.config.batchSize;\n const oldestReadyAge = now - Math.min(...ready.map(message => message.timestamp.getTime()));\n const dueByWindow = oldestReadyAge >= runtime.config.batchWindowMs;\n\n if (dueBySize || dueByWindow) {\n processBatch(runtime, queueName, queueService);\n }\n};\n\nconst maybeSavePersistence = (runtime: QueueRuntime, now: number): void => {\n if (!runtime.config.persistence.enabled) {\n return;\n }\n\n const saveInterval = runtime.config.persistence.saveInterval ?? 0;\n if (saveInterval > 0 && now - runtime.lastSavedAt >= saveInterval) {\n runtime.lastSavedAt = now;\n saveDirtyQueueStates(runtime);\n }\n};\n\n\n// The one timer for the whole plugin. Every tickIntervalMs: for every queue,\n// dispatch a batch if one is due (this is also how retried messages get\n// picked up - they wait in `incoming` like any delayed message); then save\n// persistence if its interval has elapsed.\nexport const tick = (runtime: QueueRuntime): void => {\n const now = Date.now();\n for (const [queueName, queueService] of Object.entries(runtime.queues)) {\n dispatchBatchIfDue(runtime, queueName, queueService, now);\n }\n maybeSavePersistence(runtime, now);\n};","import { QueueService, QueueManager, QueueRuntime, EventHandler } from \"./types\";\nimport {\n createQueueService,\n createQueueMessage,\n createDashboardSummary,\n createQueueSummary,\n moveDLQToIncoming,\n purgeDLQ,\n} from \"./core\";\nimport { loadQueueState, saveQueueState } from \"./persistence\";\n\nconst isValidQueueName = (queueName: string): boolean => {\n return typeof queueName === 'string' && queueName.length > 0 && /^[a-zA-Z0-9_-]+$/.test(queueName);\n};\n\nconst validateQueueName = (queueName: string): void => {\n if (!queueName || typeof queueName !== 'string') {\n throw new Error('Queue name must be a non-empty string');\n }\n\n if (!isValidQueueName(queueName)) {\n throw new Error('Queue name must contain only alphanumeric characters, hyphens, and underscores');\n }\n};\n\nconst validateHandler = (handler: any): void => {\n if (typeof handler !== 'function') {\n throw new Error('Handler must be a function');\n }\n};\n\nexport const addQueue = async (runtime: QueueRuntime, queueName: string, handler: EventHandler, module?: string): Promise<void> => {\n try {\n validateQueueName(queueName);\n validateHandler(handler);\n\n if (runtime.queues[queueName]) {\n runtime.logging.warn({ module }, `Queue already exists: ${queueName}.`);\n return;\n }\n\n runtime.queues[queueName] = createQueueService(handler, module);\n\n if (runtime.config.persistence.enabled) {\n await loadQueueState(runtime, queueName);\n }\n\n runtime.logging.info({ module }, `Queue added: ${queueName}`);\n } catch (error: any) {\n runtime.logging.error({ module, error: error.message }, `Failed to add queue ${queueName}`);\n throw error;\n }\n};\n\nexport const removeQueue = async (runtime: QueueRuntime, queueName: string): Promise<void> => {\n try {\n validateQueueName(queueName);\n\n const queueService = runtime.queues[queueName];\n if (!queueService) {\n throw new Error(`Queue '${queueName}' does not exist`);\n }\n\n const totalMessages = queueService.incoming.length + queueService.processing.length;\n if (totalMessages > 0) {\n runtime.logging.warn(\n { module: queueService.module },\n `Removing queue with ${totalMessages} pending messages: ${queueName}`\n );\n }\n\n if (runtime.config.persistence.enabled) {\n await saveQueueState(runtime, queueName, queueService);\n }\n\n delete runtime.queues[queueName];\n\n runtime.logging.info({ module: queueService.module }, `Queue removed: ${queueName}`);\n } catch (error: any) {\n runtime.logging.error({ error: error.message }, `Failed to remove queue ${queueName}`);\n throw error;\n }\n};\n\nexport const hasQueue = (runtime: QueueRuntime, queueName: string): boolean => {\n try {\n validateQueueName(queueName);\n return queueName in runtime.queues;\n } catch {\n return false;\n }\n};\n\nexport const listQueues = (runtime: QueueRuntime, module?: string): string[] => {\n return Object.keys(runtime.queues)\n .filter(queueName => !module || runtime.queues[queueName].module === module)\n .sort();\n};\n\nexport const getQueueStats = (runtime: QueueRuntime, queueName: string): QueueService | null => {\n try {\n validateQueueName(queueName);\n return runtime.queues[queueName] || null;\n } catch {\n return null;\n }\n};\n\nexport const getQueuesMap = (runtime: QueueRuntime): Record<string, QueueService> => {\n // Return a copy to prevent external modification\n return { ...runtime.queues };\n};\n\nexport const getDashboardSummary = (runtime: QueueRuntime) =>\n createDashboardSummary(runtime.queues, runtime.config);\n\nexport const getQueueSummary = (runtime: QueueRuntime, queueName: string) => {\n const queue = runtime.queues[queueName];\n if (!queue) {\n return null;\n }\n\n return {\n stats: createQueueSummary(queue, runtime.config),\n messages: {\n incoming: queue.incoming,\n processing: queue.processing,\n dlq: queue.dlq\n }\n };\n};\n\nexport const enqueueMessage = async (runtime: QueueRuntime, queueName: string, body: any, attributes: any) => {\n const queueService = runtime.queues[queueName];\n if (!queueService) {\n return null;\n }\n\n const message = createQueueMessage(body, attributes);\n queueService.incoming.push(message);\n\n if (runtime.config.persistence.enabled) {\n runtime.dirtyQueues.add(queueName);\n }\n\n return { id: message.id, queueName };\n};\n\nexport const processDlq = async (runtime: QueueRuntime, queueName: string) => {\n const queueService = runtime.queues[queueName];\n if (!queueService) {\n return null;\n }\n\n const processedCount = moveDLQToIncoming(queueService);\n if (processedCount === 0) {\n return { status: \"success\", message: \"No messages in DLQ to process\", processed: 0 };\n }\n\n runtime.logging.warn(\n { module: queueService.module },\n `Moving ${processedCount} messages from DLQ for ${queueName}`\n );\n\n if (runtime.config.persistence.enabled) {\n runtime.dirtyQueues.add(queueName);\n }\n\n return {\n status: \"success\",\n message: `Moved ${processedCount} messages from DLQ to processing queue`,\n processed: processedCount\n };\n};\n\nexport const purgeDlq = async (runtime: QueueRuntime, queueName: string) => {\n const queueService = runtime.queues[queueName];\n if (!queueService) {\n return null;\n }\n\n const purgedCount = purgeDLQ(queueService);\n if (purgedCount === 0) {\n return { status: \"success\", message: \"No messages in DLQ to purge\", purged: 0 };\n }\n\n runtime.logging.warn(\n { module: queueService.module },\n `Purging ${purgedCount} messages from DLQ for ${queueName}`\n );\n\n if (runtime.config.persistence.enabled) {\n runtime.dirtyQueues.add(queueName);\n }\n\n return {\n status: \"success\",\n message: `Purged ${purgedCount} messages from DLQ`,\n purged: purgedCount\n };\n};\n\nexport const getMessageHistory = (runtime: QueueRuntime, queueName: string, limit = 50) => {\n return runtime.messageHistory\n .filter(entry => entry.queueName === queueName)\n .slice(-limit)\n .reverse();\n};\n\n// The one place runtime gets bound into the public app.queues shape -\n// Fastify needs a plain object of methods with no runtime param, so this\n// wraps each plain function above with `runtime` pre-applied. Everything\n// above this line is a normal function you can call directly with an\n// explicit runtime, e.g. in tests.\nexport const createQueueManager = (runtime: QueueRuntime): QueueManager => ({\n addQueue: (queueName, handler, module) => addQueue(runtime, queueName, handler, module),\n removeQueue: (queueName) => removeQueue(runtime, queueName),\n hasQueue: (queueName) => hasQueue(runtime, queueName),\n listQueues: (module) => listQueues(runtime, module),\n getQueueStats: (queueName) => getQueueStats(runtime, queueName),\n getQueuesMap: () => getQueuesMap(runtime),\n getConfig: () => runtime.config,\n getDashboardSummary: () => getDashboardSummary(runtime),\n getQueueSummary: (queueName) => getQueueSummary(runtime, queueName),\n enqueueMessage: (queueName, body, attributes) => enqueueMessage(runtime, queueName, body, attributes),\n processDlq: (queueName) => processDlq(runtime, queueName),\n purgeDlq: (queueName) => purgeDlq(runtime, queueName),\n getMessageHistory: (queueName, limit) => getMessageHistory(runtime, queueName, limit),\n});","import { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\n\n// Function to register all routes\nexport const registerQueueRoutes = (\n app: FastifyInstance,\n prefix: string = \"\"\n): void => {\n app.get(`/${prefix}/dashboard`,\n async (_: FastifyRequest, reply: FastifyReply) => {\n const summary = app.queues.getDashboardSummary();\n return reply.status(200).send(summary);\n });\n\n app.get<{ Params: { queue: string } }>(`/${prefix}/:queue`,\n async (request: FastifyRequest<{ Params: { queue: string } }>, reply: FastifyReply) => {\n const queueName = request.params.queue;\n const summary = app.queues.getQueueSummary(queueName);\n if (summary === null) {\n return reply.status(404).send({ error: \"Queue not found\" });\n }\n return reply.status(200).send(summary);\n });\n\n app.post<{ Params: { queue: string }; Body: any }>(`/${prefix}/:queue`,\n async (request: FastifyRequest<{ Params: { queue: string }; Body: any }>, reply: FastifyReply) => {\n const queueName = request.params.queue;\n const result = await app.queues.enqueueMessage(queueName, request.body, request.headers as Record<string, any>);\n if (result === null) {\n return reply.status(404).send({ error: \"Queue not found\" });\n }\n return reply.status(200).send(result);\n });\n\n app.get<{ Params: { queue: string } }>(`/${prefix}/:queue/process-dlq`,\n async (request: FastifyRequest<{ Params: { queue: string } }>, reply: FastifyReply) => {\n const queueName = request.params.queue;\n const result = await app.queues.processDlq(queueName);\n if (result === null) {\n return reply.status(404).send(result);\n }\n return reply.status(200).send(result);\n });\n\n app.post<{ Params: { queue: string } }>(`/${prefix}/:queue/purge-dlq`,\n async (request: FastifyRequest<{ Params: { queue: string } }>, reply: FastifyReply) => {\n const queueName = request.params.queue;\n const result = await app.queues.purgeDlq(queueName);\n if (result === null) {\n return reply.status(404).send({ error: \"Queue not found\" });\n }\n return reply.status(200).send(result);\n });\n};","import { FastifyInstance, FastifyPluginAsync } from \"fastify\";\nimport fsPlugin from \"fastify-plugin\";\n\nimport { SchedulerPluginOptions, SchedulerRuntime } from \"./types\";\nimport { DEFAULT_CONFIG, mergeConfig } from \"./core\";\nimport { tick } from \"./processing\";\nimport { initializePersistence } from \"./persistence\";\nimport { createSchedulerManager } from \"./decorator\";\nimport { registerSchedulerRoutes } from \"./routes\";\n\nexport const schedulerPlugin: FastifyPluginAsync<SchedulerPluginOptions> =\n fsPlugin(async (\n app: FastifyInstance,\n options: SchedulerPluginOptions\n ) => {\n const runtime: SchedulerRuntime = {\n config: mergeConfig(DEFAULT_CONFIG, options.config),\n schedulers: {},\n executions: {},\n executionHistory: [],\n isShuttingDown: false,\n runningExecutions: 0,\n isDirty: false,\n lastCleanupTime: Date.now(),\n lastSavedAt: Date.now(),\n lastRestartTime: new Date(),\n logging: app.logging,\n };\n\n // One timer for the entire plugin: every tickIntervalMs, run any job\n // that's due, then clean up old execution history / save persistence\n // once their own intervals have elapsed. See processing.ts:tick.\n const tickIntervalId = setInterval(() => tick(runtime), runtime.config.tickIntervalMs);\n app.addHook('onClose', async () => {\n runtime.isShuttingDown = true;\n clearInterval(tickIntervalId);\n });\n\n app.decorate('scheduler', createSchedulerManager(runtime));\n registerSchedulerRoutes(app, options.prefix);\n\n if (runtime.config.persistence.enabled) {\n await initializePersistence(runtime);\n }\n });\n","import { parseExpression } from 'cron-parser';\n\n/**\n * Professional cron parser using cron-parser library\n * \n * Installation:\n * npm install cron-parser\n * npm install -D @types/cron-parser\n */\n\ninterface CronParseOptions {\n preserveNaturalTiming?: boolean;\n timezone?: string;\n utc?: boolean;\n currentDate?: Date;\n endDate?: Date;\n iterator?: boolean;\n}\n\ninterface CronParseResult {\n nextRun: Date;\n isValid: boolean;\n error?: string;\n pattern?: string;\n description?: string;\n}\n\n/**\n * Parse cron expression and get next execution time\n */\nexport function parseCronExpression(\n cronExpression: string,\n lastRun?: Date,\n options: CronParseOptions = {}\n): CronParseResult {\n const {\n preserveNaturalTiming = true,\n timezone,\n utc = false,\n currentDate\n } = options;\n\n try {\n // Validate and normalize cron expression\n const normalizedCron = normalizeCronExpression(cronExpression);\n\n const parseOptions: any = {\n tz: timezone,\n utc: utc,\n currentDate: currentDate ?? new Date()\n };\n\n // Use lastRun for baseline if preserving natural timing\n if (preserveNaturalTiming && lastRun) {\n parseOptions.currentDate = lastRun;\n }\n\n const interval = parseExpression(normalizedCron, parseOptions);\n let nextRun = interval.next().toDate();\n\n // Ensure next run is in the future\n const now = new Date();\n while (nextRun <= now) {\n nextRun = interval.next().toDate();\n }\n\n return {\n nextRun,\n isValid: true,\n pattern: normalizedCron,\n description: describeCronExpression(normalizedCron)\n };\n\n } catch (error: any) {\n // Fallback to a safe default (every hour) - the caller gets the\n // failure via `isValid`/`error` on the returned result, so it can\n // log with whatever module context it has; this module has none.\n const fallbackTime = new Date();\n fallbackTime.setHours(fallbackTime.getHours() + 1);\n fallbackTime.setMinutes(0);\n fallbackTime.setSeconds(0);\n fallbackTime.setMilliseconds(0);\n\n return {\n nextRun: fallbackTime,\n isValid: false,\n error: error.message,\n pattern: cronExpression\n };\n }\n}\n\n/**\n * Get multiple next execution times\n */\nexport function getNextExecutions(\n cronExpression: string,\n count: number = 5,\n options: CronParseOptions = {}\n): Date[] {\n try {\n const normalizedCron = normalizeCronExpression(cronExpression);\n const parseOptions: any = {\n tz: options.timezone,\n utc: options.utc ?? false,\n currentDate: options.currentDate ?? new Date()\n };\n\n const interval = parseExpression(normalizedCron, parseOptions);\n const executions: Date[] = [];\n\n for (let i = 0; i < count; i++) {\n executions.push(interval.next().toDate());\n }\n\n return executions;\n } catch {\n return [];\n }\n}\n\n/**\n * Validate if a cron expression is valid\n */\nexport function validateCronExpression(cronExpression: string): boolean {\n try {\n const normalized = normalizeCronExpression(cronExpression);\n parseExpression(normalized);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Normalize cron expressions to handle different formats\n */\nfunction normalizeCronExpression(cronExpression: string): string {\n const parts = cronExpression.trim().split(/\\s+/);\n\n // Handle different cron formats\n if (parts.length === 5) {\n // Standard 5-field format: minute hour day month dayOfWeek\n return cronExpression;\n } else if (parts.length === 6) {\n // 6-field format with seconds: second minute hour day month dayOfWeek\n return cronExpression;\n } else if (parts.length === 7) {\n // 7-field format with year: second minute hour day month dayOfWeek year\n return cronExpression;\n } else {\n throw new Error(`Invalid cron format: expected 5, 6, or 7 fields, got ${parts.length}`);\n }\n}\n\n/**\n * Provide human-readable description of cron expression\n */\nfunction describeCronExpression(cronExpression: string): string {\n const parts = cronExpression.split(' ');\n\n // Handle common patterns\n const patterns: Record<string, string> = {\n '*/5 * * * *': 'Every 5 minutes',\n '0 * * * *': 'Every hour at minute 0',\n '0 */2 * * *': 'Every 2 hours',\n '0 0 * * *': 'Daily at midnight',\n '0 6 * * *': 'Daily at 6:00 AM',\n '0 0 * * 0': 'Weekly on Sunday at midnight',\n '0 0 1 * *': 'Monthly on the 1st at midnight',\n '0 0 1 1 *': 'Yearly on January 1st at midnight'\n };\n\n if (patterns[cronExpression]) {\n return patterns[cronExpression];\n }\n\n // Basic description for other patterns\n if (parts.length >= 5) {\n const [minute, hour, day, month, dayOfWeek] = parts;\n\n let description = 'Runs ';\n\n if (minute.includes('*/')) {\n const interval = minute.split('*/')[1];\n description += `every ${interval} minutes`;\n } else if (minute === '*') {\n description += 'every minute';\n } else {\n description += `at minute ${minute}`;\n }\n\n if (hour.includes('*/')) {\n const interval = hour.split('*/')[1];\n description += `, every ${interval} hours`;\n } else if (hour !== '*') {\n description += `, at hour ${hour}`;\n }\n\n if (day !== '*') {\n description += `, on day ${day}`;\n }\n\n if (month !== '*') {\n description += `, in month ${month}`;\n }\n\n if (dayOfWeek !== '*') {\n const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];\n const dayNames = dayOfWeek.split(',').map(d => days[parseInt(d)] || d).join(', ');\n description += `, on ${dayNames}`;\n }\n\n return description;\n }\n\n return 'Custom schedule';\n}\n\n/**\n * Calculate time until next execution\n */\nexport function timeUntilNextExecution(cronExpression: string, timezone?: string): number {\n const result = parseCronExpression(cronExpression, undefined, { timezone });\n if (!result.isValid) {\n return -1;\n }\n\n return result.nextRun.getTime() - Date.now();\n}\n\n/**\n * Check if a time matches a cron expression\n */\nexport function doesTimeMatchCron(cronExpression: string, date: Date, timezone?: string): boolean {\n try {\n const normalizedCron = normalizeCronExpression(cronExpression);\n const parseOptions: any = {\n tz: timezone,\n currentDate: date\n };\n\n const interval = parseExpression(normalizedCron, parseOptions);\n const nextExecution = interval.next().toDate();\n\n // Check if the date is very close to the next execution (within 1 minute)\n const timeDiff = Math.abs(nextExecution.getTime() - date.getTime());\n return timeDiff < 60000; // 1 minute tolerance\n } catch {\n return false;\n }\n}\n\n/**\n * Detect the type of scheduling expression\n */\nexport function detectExpressionType(expression: string | undefined): 'cron' | 'rate' | 'unknown' {\n if (!expression || typeof expression !== 'string') {\n return 'unknown';\n }\n const trimmedExpression = expression.trim();\n\n // Check for AWS rate expression pattern\n // Format: \"rate(value unit)\" where unit can be minute(s), hour(s), day(s)\n const ratePattern = /^rate\\(\\s*(\\d+)\\s+(minute|minutes|hour|hours|day|days)\\s*\\)$/i;\n if (ratePattern.test(trimmedExpression)) {\n return 'rate';\n }\n\n // Check for cron expression pattern\n // Should have 5, 6, or 7 space-separated fields\n const cronParts = trimmedExpression.split(/\\s+/);\n if (cronParts.length >= 5 && cronParts.length <= 7) {\n // Additional validation: check if parts contain valid cron characters\n const cronCharPattern = /^[\\d\\*\\-\\,\\/\\?\\#LW]+$/;\n const validCronParts = cronParts.every(part => cronCharPattern.test(part) || part === '*');\n\n if (validCronParts) {\n return 'cron';\n }\n }\n\n return 'unknown';\n}\n\n/**\n * Convert AWS rate expression to cron expression\n * \n * AWS Rate expressions format: rate(value unit)\n * Examples:\n * - rate(5 minutes) -> *\\/5 * * * *\n * - rate(1 hour) -> 0 * * * *\n * - rate(2 hours) -> 0 *\\/2 * * *\n * - rate(1 day) -> 0 0 * * *\n * - rate(7 days) -> 0 0 *\\/7 * *\n*/\nexport function convertRateToCron(rateExpression: string): {\n cronExpression: string;\n isValid: boolean;\n error?: string;\n originalRate: string;\n description: string;\n} {\n const trimmedExpression = rateExpression.trim();\n\n // Parse rate expression\n const ratePattern = /^rate\\(\\s*(\\d+)\\s+(minute|minutes|hour|hours|day|days)\\s*\\)$/i;\n const match = trimmedExpression.match(ratePattern);\n\n if (!match) {\n return {\n cronExpression: '',\n isValid: false,\n error: 'Invalid rate expression format. Expected: rate(value unit)',\n originalRate: rateExpression,\n description: ''\n };\n }\n\n const value = parseInt(match[1]);\n const unit = match[2].toLowerCase();\n\n // Validate value\n if (value <= 0) {\n return {\n cronExpression: '',\n isValid: false,\n error: 'Rate value must be greater than 0',\n originalRate: rateExpression,\n description: ''\n };\n }\n\n let cronExpression = '';\n let description = '';\n\n try {\n switch (unit) {\n case 'minute':\n case 'minutes':\n if (value > 59) {\n return {\n cronExpression: '',\n isValid: false,\n error: 'Minutes value cannot exceed 59. Use hours for longer intervals.',\n originalRate: rateExpression,\n description: ''\n };\n }\n\n if (value === 1) {\n cronExpression = '* * * * *';\n description = 'Every minute';\n } else {\n cronExpression = `*/${value} * * * *`;\n description = `Every ${value} minutes`;\n }\n break;\n\n case 'hour':\n case 'hours':\n if (value > 23) {\n // For hours > 23, convert to days if evenly divisible by 24\n if (value % 24 === 0) {\n const days = value / 24;\n cronExpression = `0 0 */${days} * *`;\n description = `Every ${days} day${days > 1 ? 's' : ''}`;\n } else {\n return {\n cronExpression: '',\n isValid: false,\n error: 'Hours value greater than 23 must be divisible by 24, or use days unit.',\n originalRate: rateExpression,\n description: ''\n };\n }\n } else if (value === 1) {\n cronExpression = '0 * * * *';\n description = 'Every hour';\n } else {\n cronExpression = `0 */${value} * * *`;\n description = `Every ${value} hours`;\n }\n break;\n\n case 'day':\n case 'days':\n if (value > 365) {\n return {\n cronExpression: '',\n isValid: false,\n error: 'Days value cannot exceed 365',\n originalRate: rateExpression,\n description: ''\n };\n }\n\n if (value === 1) {\n cronExpression = '0 0 * * *';\n description = 'Every day (daily)';\n } else if (value === 7) {\n cronExpression = '0 0 * * 0';\n description = 'Every 7 days (weekly)';\n } else if (value <= 31) {\n cronExpression = `0 0 */${value} * *`;\n description = `Every ${value} days`;\n } else {\n // For large day intervals, we need to be more careful\n // This is an approximation since months have different lengths\n cronExpression = `0 0 */${value} * *`;\n description = `Every ${value} days (approximate)`;\n }\n break;\n\n default:\n return {\n cronExpression: '',\n isValid: false,\n error: `Unsupported time unit: ${unit}. Use minute(s), hour(s), or day(s).`,\n originalRate: rateExpression,\n description: ''\n };\n }\n\n // Validate the generated cron expression\n if (!validateCronExpression(cronExpression)) {\n return {\n cronExpression: '',\n isValid: false,\n error: 'Generated cron expression is invalid',\n originalRate: rateExpression,\n description: ''\n };\n }\n\n return {\n cronExpression,\n isValid: true,\n originalRate: rateExpression,\n description\n };\n\n } catch (error: any) {\n return {\n cronExpression: '',\n isValid: false,\n error: `Conversion error: ${error.message}`,\n originalRate: rateExpression,\n description: ''\n };\n }\n}","import { ScheduledJob, SchedulerConfig } from \"./types\";\nimport { parseCronExpression } from \"./cron-utils\";\n\nexport const generateJobId = (): string =>\n `job_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\n\nexport const generateExecutionId = (): string =>\n `exec_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\n\nexport const calculateNextRun = (\n job: ScheduledJob,\n preserveNaturalTiming: boolean = true\n): Date => {\n const now = new Date();\n\n if (job.cronExpression) {\n const result = parseCronExpression(job.cronExpression, job.lastRun, {\n preserveNaturalTiming,\n timezone: job.timezone,\n currentDate: preserveNaturalTiming && job.lastRun ? job.lastRun : now\n });\n return result.nextRun;\n }\n\n if (job.intervalMs) {\n return new Date(now.getTime() + job.intervalMs);\n }\n\n if (job.delayMs) {\n return new Date(now.getTime() + job.delayMs);\n }\n\n // Default: 1 hour\n return new Date(now.getTime() + 3600000);\n};\n\nexport const calculateNextRunFromLastRun = (\n job: ScheduledJob,\n lastRun: Date | undefined,\n config: SchedulerConfig\n): Date => {\n const now = new Date();\n\n if (job.cronExpression) {\n const result = parseCronExpression(job.cronExpression, lastRun, {\n preserveNaturalTiming: config.restartBehavior.preserveNaturalTiming,\n timezone: job.timezone ?? config.cron.defaultTimezone\n });\n return result.nextRun;\n }\n\n if (job.intervalMs && lastRun) {\n let nextRun = new Date(lastRun.getTime() + job.intervalMs);\n\n if (config.restartBehavior.skipMissedRuns) {\n while (nextRun <= now) {\n nextRun = new Date(nextRun.getTime() + job.intervalMs);\n }\n } else {\n if (nextRun <= now) {\n nextRun = new Date(now.getTime() + job.intervalMs);\n }\n }\n\n return nextRun;\n }\n\n return calculateNextRun(job, config.restartBehavior.preserveNaturalTiming);\n};\n\nexport const hasJobDefinitionChanged = (currentJob: ScheduledJob, savedJob: any): boolean => (\n currentJob.cronExpression !== savedJob.cronExpression ||\n currentJob.intervalMs !== savedJob.intervalMs ||\n currentJob.delayMs !== savedJob.delayMs ||\n currentJob.maxRuns !== savedJob.maxRuns ||\n currentJob.timezone !== savedJob.timezone\n);\n\nexport const shouldSkipJob = (job: ScheduledJob): boolean => {\n if (!job.enabled) return true;\n if (job.maxRuns && job.runCount >= job.maxRuns) return true;\n return false;\n};\n\nexport const isJobReadyToRun = (job: ScheduledJob): boolean => {\n const now = new Date();\n return job.nextRun.getTime() <= now.getTime();\n};\n\nexport const getTimeUntilNextRun = (job: ScheduledJob): number =>\n Math.max(0, job.nextRun.getTime() - Date.now());","import { SchedulerConfig, SchedulerDashboardJob, SchedulerRuntime } from \"./types\";\nimport { getNextExecutions, parseCronExpression } from \"./cron-utils\";\nimport { getTimeUntilNextRun } from \"./utils\";\n\n// default config\nexport const DEFAULT_CONFIG: SchedulerConfig = {\n tickIntervalMs: 1000,\n persistence: {\n enabled: true,\n directory: './.develop/scheduler-data',\n saveInterval: 30000, // 30 seconds\n saveOnShutdown: false,\n },\n execution: {\n maxConcurrent: 5,\n defaultTimeout: 300000, // 5 minutes\n },\n cleanup: {\n maxExecutionHistory: 1000,\n cleanupInterval: 600000, // 10 minutes\n },\n restartBehavior: {\n preserveNaturalTiming: true,\n skipMissedRuns: true,\n maxTimingDrift: 60000, // 1 minute\n rapidRestartThreshold: 10000, // 10 seconds\n },\n cron: {\n defaultTimezone: undefined, // Use system timezone\n logCronDetails: true,\n },\n};\n\n// Pure function to merge configs\nexport const mergeConfig = (defaultConfig: SchedulerConfig, userConfig?: Partial<SchedulerConfig>): SchedulerConfig => ({\n ...defaultConfig,\n ...userConfig,\n persistence: { ...defaultConfig.persistence, ...userConfig?.persistence },\n execution: { ...defaultConfig.execution, ...userConfig?.execution },\n cleanup: { ...defaultConfig.cleanup, ...userConfig?.cleanup },\n restartBehavior: { ...defaultConfig.restartBehavior, ...userConfig?.restartBehavior },\n cron: { ...defaultConfig.cron, ...userConfig?.cron },\n});\n\n// Pure function to build the dashboard view of every job\nexport const createDashboardSummary = (runtime: SchedulerRuntime): { jobs: SchedulerDashboardJob[]; runningExecutions: number } => {\n const jobs = Object.values(runtime.schedulers).map((scheduler): SchedulerDashboardJob => {\n const upcomingExecutions = scheduler.job.cronExpression\n ? getNextExecutions(scheduler.job.cronExpression, 3, { timezone: scheduler.job.timezone })\n : [];\n\n const cronDescription = scheduler.job.cronExpression\n ? parseCronExpression(scheduler.job.cronExpression, undefined, { timezone: scheduler.job.timezone }).description\n : undefined;\n\n return {\n ...scheduler.job,\n isRunning: scheduler.isRunning,\n timeUntilNextRun: getTimeUntilNextRun(scheduler.job),\n upcomingExecutions,\n cronDescription,\n };\n });\n\n return { jobs, runningExecutions: runtime.runningExecutions };\n};\n\n// Pure function to build the executions view\nexport const createExecutionsSummary = (runtime: SchedulerRuntime) => ({\n executions: runtime.executionHistory.slice(-50), // Last 50 executions\n running: Object.values(runtime.executions).filter(e => e.status === 'running'),\n});\n","import { JobDefinition, JobExecution, JobHandler, ScheduledJob, SchedulerConfig, SchedulerService } from \"./types\";\nimport { detectExpressionType, convertRateToCron } from \"./cron-utils\";\nimport { generateExecutionId, generateJobId, calculateNextRun, calculateNextRunFromLastRun } from \"./utils\";\n\n// Pure function to validate a job definition before it's turned into a job.\n// A job needs exactly one timing source; only validate the cron expression\n// itself when one was actually given (intervalMs/delayMs-only jobs have no\n// cron expression to check).\nexport const validateJobDefinition = (jobDef: JobDefinition): void => {\n if (!jobDef.cronExpression && !jobDef.intervalMs && !jobDef.delayMs) {\n throw new Error(`Job ${jobDef.name} must specify a cronExpression, intervalMs, or delayMs`);\n }\n\n if (jobDef.cronExpression && detectExpressionType(jobDef.cronExpression) === \"unknown\") {\n throw new Error(`Invalid cron expression for job: ${jobDef.name}`);\n }\n};\n\n// Pure function to turn a job definition into a scheduled job\nexport const createJobFromDefinition = (jobDef: JobDefinition, config: SchedulerConfig): ScheduledJob => {\n validateJobDefinition(jobDef);\n\n const expressionType = detectExpressionType(jobDef.cronExpression);\n const cronExpression = expressionType === \"rate\"\n ? convertRateToCron(jobDef.cronExpression!).cronExpression\n : jobDef.cronExpression;\n\n const job: ScheduledJob = {\n id: generateJobId(),\n name: jobDef.name,\n cronExpression,\n intervalMs: jobDef.intervalMs,\n delayMs: jobDef.delayMs,\n nextRun: new Date(),\n enabled: jobDef.enabled ?? true,\n runCount: 0,\n maxRuns: jobDef.maxRuns,\n metadata: jobDef.metadata,\n createdAt: new Date(),\n timezone: jobDef.timezone,\n module: jobDef.module,\n };\n\n job.nextRun = calculateNextRun(job, config.restartBehavior.preserveNaturalTiming);\n return job;\n};\n\n// Pure function to create a scheduler service for a job\nexport const createSchedulerService = (job: ScheduledJob, handler: JobHandler): SchedulerService => ({\n job,\n handler,\n isRunning: false,\n});\n\n// Pure function to create a job execution record\nexport const createJobExecution = (jobId: string): JobExecution => ({\n id: generateExecutionId(),\n jobId,\n startTime: new Date(),\n status: 'running',\n});\n\n// Pure function to mark an execution as finished\nexport const completeExecution = (\n execution: JobExecution,\n result?: any,\n error?: string\n): JobExecution => ({\n ...execution,\n endTime: new Date(),\n status: error ? 'failed' : 'completed',\n result,\n error,\n});\n\n// Pure function to advance a job's run count/timing after an execution\nexport const updateJobAfterExecution = (\n job: ScheduledJob,\n execution: JobExecution,\n config: SchedulerConfig\n): ScheduledJob => {\n const updatedJob: ScheduledJob = {\n ...job,\n lastRun: execution.startTime,\n runCount: job.runCount + 1,\n };\n\n if (updatedJob.enabled) {\n updatedJob.nextRun = calculateNextRunFromLastRun(updatedJob, updatedJob.lastRun, config);\n }\n\n return updatedJob;\n};\n\n// Pure function to enable a job and recompute its next run\nexport const enableJob = (scheduler: SchedulerService): SchedulerService => ({\n ...scheduler,\n job: {\n ...scheduler.job,\n enabled: true,\n nextRun: calculateNextRun(scheduler.job),\n },\n});\n\n// Pure function to disable a job\nexport const disableJob = (scheduler: SchedulerService): SchedulerService => ({\n ...scheduler,\n job: { ...scheduler.job, enabled: false },\n});\n","import * as fs from \"fs/promises\";\nimport * as path from \"path\";\n\nimport { JobExecution, ScheduledJob, SchedulerRuntime, SchedulerService } from \"./types\";\nimport { hasJobDefinitionChanged, calculateNextRunFromLastRun } from \"./utils\";\nimport { parseCronExpression } from \"./cron-utils\";\n\ninterface SchedulerStateData {\n jobs: ScheduledJob[];\n executions: JobExecution[];\n savedAt: Date;\n version: string;\n}\n\nconst stateFilePath = (directory: string): string => path.join(directory, 'scheduler-state.json');\n\nconst tempFilePath = (directory: string): string => path.join(directory, `scheduler-state.${Date.now()}.temp.json`);\n\nconst restoreExecutionHistory = (savedExecutions: JobExecution[]): JobExecution[] =>\n savedExecutions.map((exec) => ({\n ...exec,\n startTime: new Date(exec.startTime),\n endTime: exec.endTime ? new Date(exec.endTime) : undefined,\n }));\n\nconst readStateData = async (directory: string): Promise<SchedulerStateData | null> => {\n const data = await fs.readFile(stateFilePath(directory), 'utf8');\n return JSON.parse(data);\n};\n\nexport const saveSchedulerState = async (runtime: SchedulerRuntime): Promise<void> => {\n try {\n const stateData: SchedulerStateData = {\n jobs: Object.values(runtime.schedulers).map(s => s.job),\n executions: runtime.executionHistory.slice(-100),\n savedAt: new Date(),\n version: '1.0',\n };\n\n const file = stateFilePath(runtime.config.persistence.directory);\n const temp = tempFilePath(runtime.config.persistence.directory);\n\n // Write to a temp file first, then rename - rename is atomic, so a\n // reader never sees a half-written file.\n await fs.writeFile(temp, JSON.stringify(stateData, null, 2), 'utf8');\n await fs.rename(temp, file);\n\n runtime.logging.debug('Scheduler state saved');\n } catch (error: any) {\n runtime.logging.error({ error: error?.message }, 'Failed to save scheduler state');\n }\n};\n\n// Recalculates - or preserves - a restored job's nextRun depending on how\n// long ago the process restarted, so a quick redeploy doesn't lose timing\n// but a long outage doesn't fire a pile of catch-up runs.\nconst validateAndAdjustNextRun = (\n job: ScheduledJob,\n savedNextRun: Date | undefined,\n runtime: SchedulerRuntime\n): Date => {\n const { config, lastRestartTime, logging } = runtime;\n const now = new Date();\n\n if (!savedNextRun || savedNextRun <= now) {\n logging.debug({ module: job.module }, `Saved next run is in the past for ${job.name} - recalculating`);\n return calculateNextRunFromLastRun(job, job.lastRun, config);\n }\n\n const isRapidRestart = now.getTime() - lastRestartTime.getTime() < config.restartBehavior.rapidRestartThreshold;\n if (isRapidRestart) {\n logging.debug({ module: job.module }, `Rapid restart detected for ${job.name} - preserving saved timing`);\n return savedNextRun;\n }\n\n if (job.cronExpression || job.intervalMs) {\n const expectedNextRun = calculateNextRunFromLastRun(job, job.lastRun, config);\n const drift = Math.abs(savedNextRun.getTime() - expectedNextRun.getTime());\n if (drift > config.restartBehavior.maxTimingDrift) {\n logging.debug({ module: job.module }, `Adjusting timing for ${job.name} - drift of ${Math.round(drift / 1000)}s detected`);\n return expectedNextRun;\n }\n }\n\n return savedNextRun;\n};\n\n// Restores this job's saved run history (count, lastRun) and next-run\n// timing from the persisted state file. Mirrors queue-plugin's per-queue\n// loadQueueState: called from addJob right after the scheduler is\n// registered, not at plugin init - the saved file has nothing to match\n// against that early, since no jobs have been added yet.\nexport const loadJobState = async (runtime: SchedulerRuntime, scheduler: SchedulerService): Promise<SchedulerService> => {\n try {\n const stateData = await readStateData(runtime.config.persistence.directory);\n if (!stateData) {\n return scheduler;\n }\n\n const savedJob = stateData.jobs.find(job => job.name === scheduler.job.name);\n if (!savedJob) {\n return scheduler;\n }\n\n const definitionChanged = hasJobDefinitionChanged(scheduler.job, savedJob);\n const lastRun = savedJob.lastRun ? new Date(savedJob.lastRun) : undefined;\n\n const updatedJob: ScheduledJob = {\n ...scheduler.job,\n runCount: savedJob.runCount,\n lastRun,\n };\n\n if (definitionChanged) {\n runtime.logging.debug({ module: scheduler.job.module }, `Job definition changed: ${savedJob.name} - recalculating schedule`);\n updatedJob.nextRun = calculateNextRunFromLastRun(updatedJob, lastRun, runtime.config);\n } else {\n updatedJob.nextRun = validateAndAdjustNextRun(updatedJob, savedJob.nextRun ? new Date(savedJob.nextRun) : undefined, runtime);\n }\n\n if (runtime.config.cron.logCronDetails && updatedJob.cronExpression) {\n const result = parseCronExpression(updatedJob.cronExpression, updatedJob.lastRun, { timezone: updatedJob.timezone });\n runtime.logging.debug(\n { module: scheduler.job.module },\n `Job restored: ${savedJob.name} - ${result.description} - next: ${updatedJob.nextRun.toLocaleString()}`\n );\n } else {\n runtime.logging.debug({ module: scheduler.job.module }, `Job state restored: ${savedJob.name}`);\n }\n\n return { ...scheduler, job: updatedJob };\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n runtime.logging.debug('No saved scheduler state found - starting fresh');\n } else {\n runtime.logging.error({ error: error?.message }, `Failed to load job state for ${scheduler.job.name}`);\n }\n return scheduler;\n }\n};\n\n// Execution history isn't tied to any one job, so it's restored once at\n// plugin init (unlike per-job state, which loadJobState restores lazily as\n// each job is registered).\nexport const loadExecutionHistory = async (runtime: SchedulerRuntime): Promise<void> => {\n try {\n const stateData = await readStateData(runtime.config.persistence.directory);\n if (stateData?.executions) {\n runtime.executionHistory = restoreExecutionHistory(stateData.executions);\n }\n } catch (error: any) {\n if (error.code !== 'ENOENT') {\n runtime.logging.error({ error: error?.message }, 'Failed to load execution history');\n }\n }\n};\n\nexport const initializePersistence = async (runtime: SchedulerRuntime): Promise<void> => {\n try {\n await fs.mkdir(runtime.config.persistence.directory, { recursive: true });\n await loadExecutionHistory(runtime);\n\n if (runtime.config.persistence.saveOnShutdown) {\n const shutdownHandler = async () => {\n runtime.logging.debug('Saving scheduler state before shutdown...');\n await saveSchedulerState(runtime);\n process.exit(0);\n };\n\n process.on('SIGINT', shutdownHandler);\n process.on('SIGTERM', shutdownHandler);\n }\n\n runtime.logging.debug(`Scheduler persistence initialized: ${runtime.config.persistence.directory}`);\n } catch (error: any) {\n runtime.logging.error({ error: error?.message }, 'Failed to initialize scheduler persistence');\n }\n};\n","import { JobExecution, JobHandler, ScheduledJob, SchedulerRuntime, SchedulerService } from \"./types\";\nimport { completeExecution, createJobExecution, updateJobAfterExecution } from \"./jobs\";\nimport { isJobReadyToRun, shouldSkipJob } from \"./utils\";\nimport { saveSchedulerState } from \"./persistence\";\n\n// Pure function to check whether a job can run right now\nexport const canExecuteJob = (\n runtime: SchedulerRuntime,\n scheduler: SchedulerService\n): { canExecute: boolean; reason?: string } => {\n if (runtime.isShuttingDown) {\n return { canExecute: false, reason: 'System is shutting down' };\n }\n\n if (scheduler.isRunning) {\n return { canExecute: false, reason: 'Job is already running' };\n }\n\n if (shouldSkipJob(scheduler.job)) {\n const reason = !scheduler.job.enabled ? 'Job is disabled' : 'Job reached maximum runs';\n return { canExecute: false, reason };\n }\n\n if (runtime.runningExecutions >= runtime.config.execution.maxConcurrent) {\n return { canExecute: false, reason: 'Maximum concurrent executions reached' };\n }\n\n return { canExecute: true };\n};\n\nconst executeJobWithTimeout = async (\n handler: JobHandler,\n job: ScheduledJob,\n execution: JobExecution,\n timeoutMs: number\n): Promise<any> => {\n let timerId: NodeJS.Timeout;\n\n try {\n return await Promise.race([\n handler(job, execution),\n new Promise((_, reject) => {\n timerId = setTimeout(() => reject(new Error('Job execution timeout')), timeoutMs);\n }),\n ]);\n } finally {\n clearTimeout(timerId!);\n }\n};\n\n// Runs one job through its handler, recording the execution and advancing\n// its nextRun. Used by both the tick (once per due job) and triggerJob -\n// both go through the same path, wrapped in runWithLogContext by the\n// caller so every log call below carries the job's module/reqId.\nexport const executeJob = async (runtime: SchedulerRuntime, scheduler: SchedulerService): Promise<void> => {\n const execution = createJobExecution(scheduler.job.id);\n // Tracked in two places (the `executions` map and `executionHistory`)\n // but as a single shared reference - completeExecution below mutates\n // this same object via Object.assign so both views stay in sync,\n // instead of completeExecution's return value only updating one of them.\n runtime.executions[execution.id] = execution;\n runtime.executionHistory.push(execution);\n scheduler.isRunning = true;\n runtime.runningExecutions++;\n\n runtime.logging.info(`Executing job ${scheduler.job.name} (${execution.id})`);\n\n try {\n const result = await executeJobWithTimeout(\n scheduler.handler,\n scheduler.job,\n execution,\n runtime.config.execution.defaultTimeout\n );\n\n Object.assign(execution, completeExecution(execution, result));\n\n const duration = execution.endTime!.getTime() - execution.startTime.getTime();\n runtime.logging.debug(`Job completed in ${duration}ms`);\n } catch (error: any) {\n Object.assign(execution, completeExecution(execution, undefined, error.message));\n runtime.logging.error(`Job failed ${scheduler.job.name}: ${error.message}`);\n } finally {\n scheduler.isRunning = false;\n runtime.runningExecutions--;\n scheduler.job = updateJobAfterExecution(scheduler.job, execution, runtime.config);\n\n if (scheduler.job.maxRuns && scheduler.job.runCount >= scheduler.job.maxRuns) {\n runtime.logging.info(`Job ${scheduler.job.name} reached max runs (${scheduler.job.maxRuns})`);\n }\n\n if (runtime.config.persistence.enabled) {\n runtime.isDirty = true;\n }\n }\n};\n\nconst dispatchJobIfDue = (runtime: SchedulerRuntime, scheduler: SchedulerService): void => {\n if (!scheduler.job.enabled || !isJobReadyToRun(scheduler.job)) {\n return;\n }\n\n const { canExecute, reason } = canExecuteJob(runtime, scheduler);\n if (!canExecute) {\n // Not a permanent skip (except the maxRuns case, logged once above\n // instead) - e.g. at max concurrency, or another tick of the same\n // job already running. The job's nextRun hasn't moved, so the very\n // next tick simply tries again, instead of the old per-job timer\n // needing to be explicitly rescheduled with a delay. Logged at\n // debug to avoid spamming at tick frequency.\n if (reason === 'Maximum concurrent executions reached') {\n runtime.logging.debug({ module: scheduler.job.module }, `Delaying job ${scheduler.job.name} - ${reason}`);\n }\n return;\n }\n\n runtime.logging.runWithLogContext(\n { module: scheduler.job.module, reqId: scheduler.job.id },\n () => executeJob(runtime, scheduler)\n );\n};\n\nexport const cleanupExecutionHistory = (runtime: SchedulerRuntime): void => {\n const { maxExecutionHistory } = runtime.config.cleanup;\n if (runtime.executionHistory.length <= maxExecutionHistory) {\n return;\n }\n\n const removed = runtime.executionHistory.splice(0, runtime.executionHistory.length - maxExecutionHistory);\n runtime.logging.debug(`Cleaned up ${removed.length} old execution records`);\n};\n\nconst maybeCleanup = (runtime: SchedulerRuntime, now: number): void => {\n if (now - runtime.lastCleanupTime < runtime.config.cleanup.cleanupInterval) {\n return;\n }\n runtime.lastCleanupTime = now;\n cleanupExecutionHistory(runtime);\n};\n\nconst maybeSavePersistence = (runtime: SchedulerRuntime, now: number): void => {\n if (!runtime.config.persistence.enabled || !runtime.isDirty) {\n return;\n }\n\n const saveInterval = runtime.config.persistence.saveInterval ?? 0;\n if (saveInterval > 0 && now - runtime.lastSavedAt >= saveInterval) {\n runtime.lastSavedAt = now;\n runtime.isDirty = false;\n saveSchedulerState(runtime);\n }\n};\n\n// The one timer for the whole plugin. Every tickIntervalMs: run any job\n// whose nextRun has arrived (this is also how a manual triggerJob's\n// recurrence shows up - nothing schedules its own setTimeout anymore); then\n// clean up old execution history and save persistence if their intervals\n// have elapsed.\nexport const tick = (runtime: SchedulerRuntime): void => {\n const now = Date.now();\n for (const scheduler of Object.values(runtime.schedulers)) {\n dispatchJobIfDue(runtime, scheduler);\n }\n maybeCleanup(runtime, now);\n maybeSavePersistence(runtime, now);\n};\n","import { JobDefinition, JobHandler, SchedulerManager, SchedulerRuntime, SchedulerService } from \"./types\";\nimport { createJobFromDefinition, createSchedulerService, disableJob as disableJobData, enableJob as enableJobData } from \"./jobs\";\nimport { createDashboardSummary, createExecutionsSummary } from \"./core\";\nimport { getNextExecutions, parseCronExpression } from \"./cron-utils\";\nimport { loadJobState } from \"./persistence\";\nimport { executeJob } from \"./processing\";\n\nconst isValidJobName = (jobName: string): boolean => {\n return typeof jobName === 'string' && jobName.length > 0 && /^[a-zA-Z0-9_-]+$/.test(jobName);\n};\n\nconst validateJobName = (jobName: string): void => {\n if (!jobName || typeof jobName !== 'string') {\n throw new Error('Job name must be a non-empty string');\n }\n\n if (!isValidJobName(jobName)) {\n throw new Error('Job name must contain only alphanumeric characters, hyphens, and underscores');\n }\n};\n\nconst validateHandler = (handler: JobHandler): void => {\n if (typeof handler !== 'function') {\n throw new Error('Handler must be a function');\n }\n};\n\nconst findSchedulerByName = (runtime: SchedulerRuntime, jobName: string): SchedulerService | undefined =>\n Object.values(runtime.schedulers).find(scheduler => scheduler.job.name === jobName);\n\nexport const addJob = async (runtime: SchedulerRuntime, jobDefinition: JobDefinition): Promise<string> => {\n try {\n validateJobName(jobDefinition.name);\n validateHandler(jobDefinition.handler);\n\n const existing = findSchedulerByName(runtime, jobDefinition.name);\n if (existing) {\n runtime.logging.warn({ module: jobDefinition.module }, `Job already exists: ${jobDefinition.name}.`);\n return existing.job.id;\n }\n\n const job = createJobFromDefinition(jobDefinition, runtime.config);\n\n if (runtime.config.cron.logCronDetails && job.cronExpression) {\n const timezone = job.timezone ?? runtime.config.cron.defaultTimezone;\n const result = parseCronExpression(job.cronExpression, undefined, { timezone });\n runtime.logging.debug(\n { module: jobDefinition.module },\n `Job ${jobDefinition.name}: ${result.description} - Next: ${result.nextRun.toLocaleString()}`\n );\n\n const upcoming = getNextExecutions(job.cronExpression, 3, { timezone });\n runtime.logging.debug(\n { module: jobDefinition.module },\n `Upcoming: ${upcoming.map(d => d.toLocaleTimeString()).join(', ')}`\n );\n }\n\n let scheduler = createSchedulerService(job, jobDefinition.handler);\n\n if (runtime.config.persistence.enabled) {\n scheduler = await loadJobState(runtime, scheduler);\n }\n\n runtime.schedulers[scheduler.job.id] = scheduler;\n\n runtime.logging.info({ module: jobDefinition.module }, `Job added: ${jobDefinition.name} (${scheduler.job.id})`);\n\n return scheduler.job.id;\n } catch (error: any) {\n runtime.logging.error({ module: jobDefinition.module, error: error.message }, `Failed to add job ${jobDefinition.name}`);\n throw error;\n }\n};\n\nexport const removeJob = async (runtime: SchedulerRuntime, jobName: string): Promise<void> => {\n try {\n validateJobName(jobName);\n\n const scheduler = findSchedulerByName(runtime, jobName);\n if (!scheduler) {\n throw new Error(`Job '${jobName}' does not exist`);\n }\n\n if (scheduler.isRunning) {\n runtime.logging.warn({ module: scheduler.job.module }, `Removing job that is currently running: ${jobName}`);\n }\n\n delete runtime.schedulers[scheduler.job.id];\n\n runtime.logging.info({ module: scheduler.job.module }, `Job removed: ${jobName}`);\n } catch (error: any) {\n runtime.logging.error({ error: error.message }, `Failed to remove job ${jobName}`);\n throw error;\n }\n};\n\nexport const hasJob = (runtime: SchedulerRuntime, jobName: string): boolean => {\n try {\n validateJobName(jobName);\n return !!findSchedulerByName(runtime, jobName);\n } catch {\n return false;\n }\n};\n\nexport const listJobs = (runtime: SchedulerRuntime, module?: string): string[] => {\n return Object.values(runtime.schedulers)\n .filter(scheduler => !module || scheduler.job.module === module)\n .map(scheduler => scheduler.job.name)\n .sort();\n};\n\nexport const getJobStats = (runtime: SchedulerRuntime, jobName: string): SchedulerService | null => {\n try {\n validateJobName(jobName);\n return findSchedulerByName(runtime, jobName) ?? null;\n } catch {\n return null;\n }\n};\n\nexport const getJobsMap = (runtime: SchedulerRuntime): Record<string, SchedulerService> => {\n // Return a copy to prevent external modification\n return { ...runtime.schedulers };\n};\n\nexport const enableJob = async (runtime: SchedulerRuntime, jobName: string): Promise<void> => {\n try {\n validateJobName(jobName);\n\n const scheduler = findSchedulerByName(runtime, jobName);\n if (!scheduler) {\n throw new Error(`Job '${jobName}' does not exist`);\n }\n\n if (scheduler.job.enabled) {\n runtime.logging.debug({ module: scheduler.job.module }, `Job is already enabled: ${jobName}`);\n return;\n }\n\n runtime.schedulers[scheduler.job.id] = enableJobData(scheduler);\n runtime.logging.info({ module: scheduler.job.module }, `Job enabled: ${jobName}`);\n } catch (error: any) {\n runtime.logging.error({ error: error.message }, `Failed to enable job ${jobName}`);\n throw error;\n }\n};\n\nexport const disableJob = async (runtime: SchedulerRuntime, jobName: string): Promise<void> => {\n try {\n validateJobName(jobName);\n\n const scheduler = findSchedulerByName(runtime, jobName);\n if (!scheduler) {\n throw new Error(`Job '${jobName}' does not exist`);\n }\n\n if (!scheduler.job.enabled) {\n runtime.logging.debug({ module: scheduler.job.module }, `Job is already disabled: ${jobName}`);\n return;\n }\n\n runtime.schedulers[scheduler.job.id] = disableJobData(scheduler);\n runtime.logging.info({ module: scheduler.job.module }, `Job disabled: ${jobName}`);\n } catch (error: any) {\n runtime.logging.error({ error: error.message }, `Failed to disable job ${jobName}`);\n throw error;\n }\n};\n\nexport const triggerJob = async (runtime: SchedulerRuntime, jobName: string): Promise<void> => {\n try {\n validateJobName(jobName);\n\n const scheduler = findSchedulerByName(runtime, jobName);\n if (!scheduler) {\n throw new Error(`Job '${jobName}' does not exist`);\n }\n\n if (scheduler.isRunning) {\n throw new Error(`Job '${jobName}' is already running`);\n }\n\n runtime.logging.info({ module: scheduler.job.module }, `Job triggered: ${jobName}`);\n\n // Fire-and-forget, same as the tick's own dispatch - callers (e.g.\n // the trigger route) get an immediate response rather than waiting\n // out the job's full run.\n runtime.logging.runWithLogContext(\n { module: scheduler.job.module, reqId: scheduler.job.id },\n () => executeJob(runtime, scheduler)\n );\n } catch (error: any) {\n runtime.logging.error({ error: error.message }, `Failed to trigger job ${jobName}`);\n throw error;\n }\n};\n\nexport const getDashboardSummary = (runtime: SchedulerRuntime) => createDashboardSummary(runtime);\n\nexport const getExecutionsSummary = (runtime: SchedulerRuntime) => createExecutionsSummary(runtime);\n\n// Unlike getExecutionsSummary (last 50 across every job), this filters the\n// full executionHistory down to one job first - so a busy job elsewhere\n// can't push a quieter job's own runs out of view.\nexport const getJobExecutionHistory = (runtime: SchedulerRuntime, jobName: string, limit = 50) => {\n const scheduler = findSchedulerByName(runtime, jobName);\n if (!scheduler) {\n return [];\n }\n\n return runtime.executionHistory\n .filter(execution => execution.jobId === scheduler.job.id)\n .slice(-limit)\n .reverse();\n};\n\n// The one place runtime gets bound into the public app.scheduler shape -\n// Fastify needs a plain object of methods with no runtime param, so this\n// wraps each plain function above with `runtime` pre-applied. Everything\n// above this line is a normal function you can call directly with an\n// explicit runtime, e.g. in tests.\nexport const createSchedulerManager = (runtime: SchedulerRuntime): SchedulerManager => ({\n addJob: (jobDefinition) => addJob(runtime, jobDefinition),\n removeJob: (jobName) => removeJob(runtime, jobName),\n hasJob: (jobName) => hasJob(runtime, jobName),\n listJobs: (module) => listJobs(runtime, module),\n getJobStats: (jobName) => getJobStats(runtime, jobName),\n getJobsMap: () => getJobsMap(runtime),\n getConfig: () => runtime.config,\n enableJob: (jobName) => enableJob(runtime, jobName),\n disableJob: (jobName) => disableJob(runtime, jobName),\n triggerJob: (jobName) => triggerJob(runtime, jobName),\n getDashboardSummary: () => getDashboardSummary(runtime),\n getExecutionsSummary: () => getExecutionsSummary(runtime),\n getJobExecutionHistory: (jobName, limit) => getJobExecutionHistory(runtime, jobName, limit),\n});\n","import { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\n\n// Function to register all routes\nexport const registerSchedulerRoutes = (\n app: FastifyInstance,\n prefix: string = \"schedule\"\n): void => {\n app.get(`/${prefix}/dashboard`,\n async (_: FastifyRequest, reply: FastifyReply) => {\n return reply.status(200).send(app.scheduler.getDashboardSummary());\n });\n\n app.get(`/${prefix}/executions`,\n async (_: FastifyRequest, reply: FastifyReply) => {\n return reply.status(200).send(app.scheduler.getExecutionsSummary());\n });\n\n app.post<{ Params: { jobName: string } }>(`/${prefix}/jobs/:jobName/trigger`,\n async (request: FastifyRequest<{ Params: { jobName: string } }>, reply: FastifyReply) => {\n try {\n await app.scheduler.triggerJob(request.params.jobName);\n return reply.status(200).send({ message: \"Job triggered successfully\" });\n } catch (error: any) {\n return reply.status(404).send({ error: error.message });\n }\n });\n\n app.put<{ Params: { jobName: string } }>(`/${prefix}/jobs/:jobName/enable`,\n async (request: FastifyRequest<{ Params: { jobName: string } }>, reply: FastifyReply) => {\n try {\n await app.scheduler.enableJob(request.params.jobName);\n return reply.status(200).send({ message: \"Job enabled successfully\" });\n } catch (error: any) {\n return reply.status(404).send({ error: error.message });\n }\n });\n\n app.put<{ Params: { jobName: string } }>(`/${prefix}/jobs/:jobName/disable`,\n async (request: FastifyRequest<{ Params: { jobName: string } }>, reply: FastifyReply) => {\n try {\n await app.scheduler.disableJob(request.params.jobName);\n return reply.status(200).send({ message: \"Job disabled successfully\" });\n } catch (error: any) {\n return reply.status(404).send({ error: error.message });\n }\n });\n};\n","import crypto from \"node:crypto\";\n\nimport { FastifyInstance, FastifyPluginAsync } from \"fastify\";\nimport fsPlugin from \"fastify-plugin\";\nimport websocketPlugin from \"@fastify/websocket\";\n\nimport \"../logger/types\";\nimport { WebSocketConnectionGoneError } from \"@cloudnux/core-cloud-provider\";\n\n\nimport {\n WebSocketPluginOptions,\n WebSocketConfig,\n WebSocketConnection,\n WebSocketRouteHandler,\n RegisteredWebSocketPath,\n} from \"./types\";\n\nconst DEFAULT_CONFIG: WebSocketConfig = {\n routeKeyField: \"action\",\n};\n\nfunction mergeConfig(\n defaults: WebSocketConfig,\n overrides?: Partial<WebSocketConfig>\n): WebSocketConfig {\n return { ...defaults, ...overrides };\n}\n\nexport const websocketsPlugin: FastifyPluginAsync<WebSocketPluginOptions> =\n fsPlugin(async (\n app: FastifyInstance,\n options: WebSocketPluginOptions\n ) => {\n const config = mergeConfig(DEFAULT_CONFIG, options.config);\n const connections = new Map<string, WebSocketConnection>();\n const handlers: WebSocketRouteHandler[] = [];\n const registeredPaths = new Set<string>();\n const pathModuleMap = new Map<string, string | undefined>();\n\n // Register @fastify/websocket\n await app.register(websocketPlugin);\n\n // Register WebSocket route for a path when first handler uses it\n function ensureRouteForPath(path: string) {\n if (registeredPaths.has(path)) return;\n registeredPaths.add(path);\n\n app.get(path, {\n websocket: true,\n preHandler: async (request, reply) => {\n const connectionId = crypto.randomUUID();\n (request as any)._wsConnectionId = connectionId;\n const reqId = `${request.id}:${connectionId}`;\n\n const connectHandlers = handlers.filter(h => h.path === path && h.event === \"connect\");\n for (const h of connectHandlers) {\n await app.logging.runWithLogContext(\n { module: h.module, reqId },\n () => h.handler(connectionId, \"connect\", null, request, reply)\n );\n }\n if (reply.statusCode !== 200)\n return reply; // Prevent WebSocket upgrade if preHandler set an error status\n },\n }, (socket, request) => {\n const connectionId = (request as any)._wsConnectionId ?? crypto.randomUUID();\n const reqId = `${request.id}:${connectionId}`;\n const connection: WebSocketConnection = {\n connectionId,\n socket,\n path,\n connectedAt: new Date(),\n };\n connections.set(connectionId, connection);\n\n // Filter handlers for this path at runtime so late-registered handlers are included\n const pathHandlers = () => handlers.filter(h => h.path === path);\n\n // Handle incoming messages\n socket.on(\"message\", (raw) => {\n const data = raw.toString();\n\n const currentHandlers = pathHandlers();\n\n // Try to parse and match a specific route handler\n let routeKey: string | undefined;\n try {\n const parsed = JSON.parse(data);\n routeKey = parsed?.[config.routeKeyField];\n } catch {\n // not JSON, no route key\n }\n\n let matched = false;\n if (routeKey) {\n const routeHandlers = currentHandlers.filter(\n h => h.event === \"message\" && h.route === routeKey\n );\n for (const h of routeHandlers) {\n matched = true;\n app.logging.runWithLogContext(\n { module: h.module, reqId },\n () => h.handler(connectionId, \"message\", data, request).catch((e) => app.logging.error(e))\n );\n }\n }\n\n // Fall back to default message handlers (no route)\n if (!matched) {\n const defaultHandlers = currentHandlers.filter(\n h => h.event === \"message\" && !h.route\n );\n for (const h of defaultHandlers) {\n app.logging.runWithLogContext(\n { module: h.module, reqId },\n () => h.handler(connectionId, \"message\", data, request).catch((e) => app.logging.error(e))\n );\n }\n }\n });\n\n // Handle disconnect\n socket.on(\"close\", () => {\n const disconnectHandlers = pathHandlers().filter(h => h.event === \"disconnect\");\n for (const h of disconnectHandlers) {\n app.logging.runWithLogContext(\n { module: h.module, reqId },\n () => h.handler(connectionId, \"disconnect\", null, request).catch((e) => app.logging.error(e))\n );\n }\n connections.delete(connectionId);\n });\n });\n }\n\n // Create manager with eager route registration\n const manager = {\n registerHandler(handler: WebSocketRouteHandler) {\n handlers.push(handler);\n if (!pathModuleMap.has(handler.path)) {\n pathModuleMap.set(handler.path, handler.module);\n }\n ensureRouteForPath(handler.path);\n },\n getConnections(path?: string): WebSocketConnection[] {\n const allConnections = Array.from(connections.values());\n if (path) {\n return allConnections.filter(c => c.path === path);\n }\n return allConnections;\n },\n getRegisteredPaths(module?: string): RegisteredWebSocketPath[] {\n const all: RegisteredWebSocketPath[] = Array.from(pathModuleMap.entries()).map(([path, mod]) => ({ path, module: mod }));\n if (module) {\n return all.filter(p => p.module === module);\n }\n return all;\n },\n async sendToClient(connectionId: string, data: any): Promise<void> {\n const connection = connections.get(connectionId);\n if (!connection) {\n throw new WebSocketConnectionGoneError(connectionId);\n }\n const payload = typeof data === \"string\" ? data : JSON.stringify(data);\n connection.socket.send(payload);\n },\n async disconnect(connectionId: string): Promise<void> {\n const connection = connections.get(connectionId);\n if (!connection) {\n throw new WebSocketConnectionGoneError(connectionId);\n }\n connection.socket.close();\n },\n };\n\n app.decorate('websockets', manager);\n });\n","export interface RouteInfo {\n method: string | string[]\n url: string\n handler: string\n registeredAt: Date,\n module?: string\n}\n\nclass RouteRegistry {\n private routes: RouteInfo[] = []\n\n private static readonly IGNORED_METHODS = new Set(['OPTIONS', 'HEAD'])\n\n register(routeOptions: any): void {\n const methods: string[] = Array.isArray(routeOptions.method)\n ? routeOptions.method\n : [routeOptions.method]\n\n if (methods.every(m => RouteRegistry.IGNORED_METHODS.has(m.toUpperCase()))) {\n return\n }\n\n const routeInfo: RouteInfo = {\n method: routeOptions.method,\n url: routeOptions.url,\n handler: routeOptions.handler?.name || 'anonymous',\n registeredAt: new Date(),\n module: routeOptions.config?.module\n }\n\n this.routes.push(routeInfo)\n }\n\n getAll(): RouteInfo[] {\n return [...this.routes]\n }\n\n getByMethod(method: string): RouteInfo[] {\n return this.routes.filter(route => {\n if (Array.isArray(route.method)) {\n return route.method.includes(method.toUpperCase())\n }\n return route.method.toUpperCase() === method.toUpperCase()\n })\n }\n\n clear(): void {\n this.routes = []\n }\n\n count(): number {\n return this.routes.length\n }\n}\n\nexport const routeRegistry = new RouteRegistry()"],"mappings":";AAAA,OAAOA,WAAU;AAEjB,OAAO,mBAAmB;AAC1B,OAAOC,eAAc;AACrB,SAAS,qBAAqB;AAG9B,SAAS,gCAAAC,qCAAoC;;;ACN7C,OAAO,cAAc;;;ACCrB,IAAM,sBAAsB;AAGrB,IAAM,iBAA8B;AAAA,EACvC,WAAW;AAAA,EACX,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,eAAe;AAAA,EACf,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,aAAa;AAAA,IACT,SAAS;AAAA,IACT,WAAW;AAAA,IACX,cAAc;AAAA,IACd,gBAAgB;AAAA,EACpB;AACJ;AAGO,IAAM,cAAc,CAAC,eAA4B,gBAAoD;AAAA,EACxG,GAAG;AAAA,EACH,GAAG;AAAA,EACH,aAAa;AAAA,IACT,GAAG,cAAc;AAAA,IACjB,GAAI,YAAY,eAAe,CAAC;AAAA,EACpC;AACJ;AAGO,IAAM,qBAAqB,CAAC,SAAuB,YAAmC;AAAA,EACzF;AAAA,EACA,UAAU,CAAC;AAAA,EACX,YAAY,CAAC;AAAA,EACb,KAAK,CAAC;AAAA,EACN,iBAAiB;AAAA,EACjB;AACJ;AAGO,IAAM,qBAAqB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AAS,IAAI,UAAU,MAAO,QAAO;AACzC,aAAO;AAAA,IACT;AAEA,UAAM,KAAK,mBAAmB;AAC9B,UAAM,OAAO,iBAAiB,UAAU;AACxC,UAAM,OAAO,cAAc,YAAY;AACvC,UAAM,OAAO,+BAA+B,GAAG;AAG/C,UAAM,cAAc,SAAS,QAAQ,EAAE,EAAE,OAAO,cAAc;AAC9D,UAAM,IAAI,MAAM,SAAS,KAAK,UAAU,EAAE,MAAM,WAAW,MAAM,YAAY,CAAC,CAAC;AAAA;AAAA,CAAM;AAGrF,UAAMC,eAAc,SAAS,UAAU,CAAC,QAAQ;AAC9C,UAAI,eAAe,GAAG,GAAG;AACvB,cAAM,IAAI,MAAM,SAAS,KAAK,UAAU,EAAE,MAAM,OAAO,IAAI,CAAC,CAAC;AAAA;AAAA,CAAM;AAAA,MACrE;AAAA,IACF,CAAC;AAGD,YAAQ,IAAI,GAAG,SAAS,MAAM;AAC5B,MAAAA,aAAY;AAAA,IACd,CAAC;AAAA,EACH,CAAC;AAGD,MAAI,UAAU;AACZ,UAAM,iBAAiBC,MAAK;AAAA,MAC1BH,SAAQ,QAAQ,uCAAuC;AAAA,IACzD;AAEA,UAAM,QAAQ,SAAS,eAAe;AAAA,MACpC,MAAM;AAAA,MACN,eAAe;AAAA,MACf,QAAQ,IAAI,MAAM;AAAA,IACpB,CAAC;AAGD,YAAQ,IAAI,IAAI,MAAM,IAAI,OAAO,GAAG,UAAU;AAC5C,aAAO,MAAM,SAAS,YAAY;AAAA,IACpC,CAAC;AAAA,EACH;AACF;AAEO,IAAM,mBAAmBI,UAAS,0BAA0B;AAAA,EACjE,MAAM;AACR,CAAC;","names":["path","fsPlugin","WebSocketConnectionGoneError","tempFilePath","fsPlugin","DEFAULT_CONFIG","mergeConfig","createDashboardSummary","fs","path","initializePersistence","maybeSavePersistence","tick","validateHandler","enableJob","disableJob","getDashboardSummary","createDashboardSummary","fsPlugin","mergeConfig","DEFAULT_CONFIG","tick","initializePersistence","fsPlugin","DEFAULT_CONFIG","mergeConfig","fsPlugin","path","require","WebSocketConnectionGoneError","unsubscribe","path","fsPlugin"]}
|