diff --git a/admin-ui/package-lock.json b/admin-ui/package-lock.json index 683920e..b83d524 100644 --- a/admin-ui/package-lock.json +++ b/admin-ui/package-lock.json @@ -15,34 +15,337 @@ }, "devDependencies": { "@eslint/eslintrc": "^3.2.0", + "@testing-library/jest-dom": "^6.9.1", + "@testing-library/react": "^16.3.2", "@types/node": "^22.9.0", "@types/react": "19.2.14", "@types/react-dom": "19.2.3", + "@vitejs/plugin-react": "^6.0.1", + "@vitest/coverage-v8": "^4.1.5", "eslint": "^9.15.0", "eslint-config-next": "15.5.15", + "jsdom": "^29.1.0", "sass": "^1.81.0", - "typescript": "^5.6.3" + "typescript": "^5.6.3", + "vitest": "^4.1.5" }, "engines": { "node": ">=20" } }, + "node_modules/@adobe/css-tools": { + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.4.tgz", + "integrity": "sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@asamuzakjp/css-color": { + "version": "5.1.11", + "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-5.1.11.tgz", + "integrity": "sha512-KVw6qIiCTUQhByfTd78h2yD1/00waTmm9uy/R7Ck/ctUyAPj+AEDLkQIdJW0T8+qGgj3j5bpNKK7Q3G+LedJWg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/generational-cache": "^1.0.1", + "@csstools/css-calc": "^3.2.0", + "@csstools/css-color-parser": "^4.1.0", + "@csstools/css-parser-algorithms": "^4.0.0", + "@csstools/css-tokenizer": "^4.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/@asamuzakjp/dom-selector": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-7.1.1.tgz", + "integrity": "sha512-67RZDnYRc8H/8MLDgQCDE//zoqVFwajkepHZgmXrbwybzXOEwOWGPYGmALYl9J2DOLfFPPs6kKCqmbzV895hTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/generational-cache": "^1.0.1", + "@asamuzakjp/nwsapi": "^2.3.9", + "bidi-js": "^1.0.3", + "css-tree": "^3.2.1", + "is-potential-custom-element-name": "^1.0.1" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/@asamuzakjp/generational-cache": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@asamuzakjp/generational-cache/-/generational-cache-1.0.1.tgz", + "integrity": "sha512-wajfB8KqzMCN2KGNFdLkReeHncd0AslUSrvHVvvYWuU8ghncRJoA50kT3zP9MVL0+9g4/67H+cdvBskj9THPzg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/@asamuzakjp/nwsapi": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/@asamuzakjp/nwsapi/-/nwsapi-2.3.9.tgz", + "integrity": "sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@babel/code-frame": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.0.tgz", + "integrity": "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.28.5", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.2.tgz", + "integrity": "sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.0" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.29.2", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.2.tgz", + "integrity": "sha512-JiDShH45zKHWyGe4ZNVRrCjBz8Nh9TMmZG1kh4QTK8hCBTWBi8Da+i7s1fJw7/lYpM4ccepSNfqzZ/QvABBi5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz", + "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@bramus/specificity": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.2.tgz", + "integrity": "sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "css-tree": "^3.0.0" + }, + "bin": { + "specificity": "bin/cli.js" + } + }, + "node_modules/@csstools/color-helpers": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.0.2.tgz", + "integrity": "sha512-LMGQLS9EuADloEFkcTBR3BwV/CGHV7zyDxVRtVDTwdI2Ca4it0CCVTT9wCkxSgokjE5Ho41hEPgb8OEUwoXr6Q==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/@csstools/css-calc": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.2.0.tgz", + "integrity": "sha512-bR9e6o2BDB12jzN/gIbjHa5wLJ4UjD1CB9pM7ehlc0ddk6EBz+yYS1EV2MF55/HUxrHcB/hehAyt5vhsA3hx7w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^4.0.0", + "@csstools/css-tokenizer": "^4.0.0" + } + }, + "node_modules/@csstools/css-color-parser": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.1.0.tgz", + "integrity": "sha512-U0KhLYmy2GVj6q4T3WaAe6NPuFYCPQoE3b0dRGxejWDgcPp8TP7S5rVdM5ZrFaqu4N67X8YaPBw14dQSYx3IyQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/color-helpers": "^6.0.2", + "@csstools/css-calc": "^3.2.0" + }, + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^4.0.0", + "@csstools/css-tokenizer": "^4.0.0" + } + }, + "node_modules/@csstools/css-parser-algorithms": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.0.tgz", + "integrity": "sha512-+B87qS7fIG3L5h3qwJ/IFbjoVoOe/bpOdh9hAjXbvx0o8ImEmUsGXN0inFOnk2ChCFgqkkGFQ+TpM5rbhkKe4w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-tokenizer": "^4.0.0" + } + }, + "node_modules/@csstools/css-syntax-patches-for-csstree": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.3.tgz", + "integrity": "sha512-SH60bMfrRCJF3morcdk57WklujF4Jr/EsQUzqkarfHXEFcAR1gg7fS/chAE922Sehgzc1/+Tz5H3Ypa1HiEKrg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "peerDependencies": { + "css-tree": "^3.2.1" + }, + "peerDependenciesMeta": { + "css-tree": { + "optional": true + } + } + }, + "node_modules/@csstools/css-tokenizer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-4.0.0.tgz", + "integrity": "sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + } + }, "node_modules/@emnapi/core": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.9.1.tgz", - "integrity": "sha512-mukuNALVsoix/w1BJwFzwXBN/dHeejQtuVzcDsfOEsdpCumXb/E9j8w11h5S54tT1xhifGfbbSm/ICrObRb3KA==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz", + "integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==", "dev": true, "license": "MIT", "optional": true, "dependencies": { - "@emnapi/wasi-threads": "1.2.0", + "@emnapi/wasi-threads": "1.2.1", "tslib": "^2.4.0" } }, "node_modules/@emnapi/runtime": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.1.tgz", - "integrity": "sha512-VYi5+ZVLhpgK4hQ0TAjiQiZ6ol0oe4mBx7mVv7IflsiEp0OWoVsp/+f9Vc1hOhE0TtkORVrI1GvzyreqpgWtkA==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz", + "integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==", "license": "MIT", "optional": true, "dependencies": { @@ -50,9 +353,9 @@ } }, "node_modules/@emnapi/wasi-threads": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.0.tgz", - "integrity": "sha512-N10dEJNSsUx41Z6pZsXU8FjPjpBEplgH24sfkmITrBED1/U2Esum9F3lfLrMjKHHjmi557zQn7kR9R+XWXu5Rg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz", + "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==", "dev": true, "license": "MIT", "optional": true, @@ -204,6 +507,24 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@exodus/bytes": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.15.0.tgz", + "integrity": "sha512-UY0nlA+feH81UGSHv92sLEPLCeZFjXOuHhrIo0HQydScuQc8s0A7kL/UdgwgDq8g8ilksmuoF35YVTNphV2aBQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@noble/hashes": "^1.8.0 || ^2.0.0" + }, + "peerDependenciesMeta": { + "@noble/hashes": { + "optional": true + } + } + }, "node_modules/@humanfs/core": { "version": "0.19.1", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", @@ -722,6 +1043,34 @@ "url": "https://opencollective.com/libvips" } }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, "node_modules/@napi-rs/wasm-runtime": { "version": "0.2.12", "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-0.2.12.tgz", @@ -927,6 +1276,16 @@ "node": ">=12.4.0" } }, + "node_modules/@oxc-project/types": { + "version": "0.127.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.127.0.tgz", + "integrity": "sha512-aIYXQBo4lCbO4z0R3FHeucQHpF46l2LbMdxRvqvuRuW2OxdnSkcng5B8+K12spgLDj93rtN3+J2Vac/TIO+ciQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/Boshen" + } + }, "node_modules/@parcel/watcher": { "version": "2.5.6", "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.6.tgz", @@ -1262,6 +1621,289 @@ "url": "https://opencollective.com/popperjs" } }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-rc.17.tgz", + "integrity": "sha512-s70pVGhw4zqGeFnXWvAzJDlvxhlRollagdCCKRgOsgUOH3N1l0LIxf83AtGzmb5SiVM4Hjl5HyarMRfdfj3DaQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0-rc.17.tgz", + "integrity": "sha512-4ksWc9n0mhlZpZ9PMZgTGjeOPRu8MB1Z3Tz0Mo02eWfWCHMW1zN82Qz/pL/rC+yQa+8ZnutMF0JjJe7PjwasYw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0-rc.17.tgz", + "integrity": "sha512-SUSDOI6WwUVNcWxd02QEBjLdY1VPHvlEkw6T/8nYG322iYWCTxRb1vzk4E+mWWYehTp7ERibq54LSJGjmouOsw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0-rc.17.tgz", + "integrity": "sha512-hwnz3nw9dbJ05EDO/PvcjaaewqqDy7Y1rn1UO81l8iIK1GjenME75dl16ajbvSSMfv66WXSRCYKIqfgq2KCfxw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0-rc.17.tgz", + "integrity": "sha512-IS+W7epTcwANmFSQFrS1SivEXHtl1JtuQA9wlxrZTcNi6mx+FDOYrakGevvvTwgj2JvWiK8B29/qD9BELZPyXQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0-rc.17.tgz", + "integrity": "sha512-e6usGaHKW5BMNZOymS1UcEYGowQMWcgZ71Z17Sl/h2+ZziNJ1a9n3Zvcz6LdRyIW5572wBCTH/Z+bKuZouGk9Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0-rc.17.tgz", + "integrity": "sha512-b/CgbwAJpmrRLp02RPfhbudf5tZnN9nsPWK82znefso832etkem8H7FSZwxrOI9djcdTP7U6YfNhbRnh7djErg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.0-rc.17.tgz", + "integrity": "sha512-4EII1iNGRUN5WwGbF/kOh/EIkoDN9HsupgLQoXfY+D1oyJm7/F4t5PYU5n8SWZgG0FEwakyM8pGgwcBYruGTlA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.0-rc.17.tgz", + "integrity": "sha512-AH8oq3XqQo4IibpVXvPeLDI5pzkpYn0WiZAfT05kFzoJ6tQNzwRdDYQ45M8I/gslbodRZwW8uxLhbSBbkv96rA==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0-rc.17.tgz", + "integrity": "sha512-cLnjV3xfo7KslbU41Z7z8BH/E1y5mzUYzAqih1d1MDaIGZRCMqTijqLv76/P7fyHuvUcfGsIpqCdddbxLLK9rA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0-rc.17.tgz", + "integrity": "sha512-0phclDw1spsL7dUB37sIARuis2tAgomCJXAHZlpt8PXZ4Ba0dRP1e+66lsRqrfhISeN9bEGNjQs+T/Fbd7oYGw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0-rc.17.tgz", + "integrity": "sha512-0ag/hEgXOwgw4t8QyQvUCxvEg+V0KBcA6YuOx9g0r02MprutRF5dyljgm3EmR02O292UX7UeS6HzWHAl6KgyhA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0-rc.17.tgz", + "integrity": "sha512-LEXei6vo0E5wTGwpkJ4KoT3OZJRnglwldt5ziLzOlc6qqb55z4tWNq2A+PFqCJuvWWdP53CVhG1Z9NtToDPJrA==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "1.10.0", + "@emnapi/runtime": "1.10.0", + "@napi-rs/wasm-runtime": "^1.1.4" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi/node_modules/@napi-rs/wasm-runtime": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.4.tgz", + "integrity": "sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.1" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1", + "@emnapi/runtime": "^1.7.1" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0-rc.17.tgz", + "integrity": "sha512-gUmyzBl3SPMa6hrqFUth9sVfcLBlYsbMzBx5PlexMroZStgzGqlZ26pYG89rBb45Mnia+oil6YAIFeEWGWhoZA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-rc.17.tgz", + "integrity": "sha512-3hkiolcUAvPB9FLb3UZdfjVVNWherN1f/skkGWJP/fgSQhYUZpSIRr0/I8ZK9TkF3F7kxvJAk0+IcKvPHk9qQg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.0-rc.7", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.7.tgz", + "integrity": "sha512-qujRfC8sFVInYSPPMLQByRh7zhwkGFS4+tyMQ83srV1qrxL4g8E2tyxVVyxd0+8QeBM1mIk9KbWxkegRr76XzA==", + "dev": true, + "license": "MIT" + }, "node_modules/@rtsao/scc": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz", @@ -1276,6 +1918,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@standard-schema/spec": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", + "dev": true, + "license": "MIT" + }, "node_modules/@swc/helpers": { "version": "0.5.15", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz", @@ -1285,6 +1934,93 @@ "tslib": "^2.8.0" } }, + "node_modules/@testing-library/dom": { + "version": "10.4.1", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz", + "integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/code-frame": "^7.10.4", + "@babel/runtime": "^7.12.5", + "@types/aria-query": "^5.0.1", + "aria-query": "5.3.0", + "dom-accessibility-api": "^0.5.9", + "lz-string": "^1.5.0", + "picocolors": "1.1.1", + "pretty-format": "^27.0.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@testing-library/dom/node_modules/aria-query": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "dependencies": { + "dequal": "^2.0.3" + } + }, + "node_modules/@testing-library/jest-dom": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.9.1.tgz", + "integrity": "sha512-zIcONa+hVtVSSep9UT3jZ5rizo2BsxgyDYU7WFD5eICBE7no3881HGeb/QkGfsJs6JTkY1aQhT7rIPC7e+0nnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@adobe/css-tools": "^4.4.0", + "aria-query": "^5.0.0", + "css.escape": "^1.5.1", + "dom-accessibility-api": "^0.6.3", + "picocolors": "^1.1.1", + "redent": "^3.0.0" + }, + "engines": { + "node": ">=14", + "npm": ">=6", + "yarn": ">=1" + } + }, + "node_modules/@testing-library/jest-dom/node_modules/dom-accessibility-api": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.6.3.tgz", + "integrity": "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@testing-library/react": { + "version": "16.3.2", + "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.3.2.tgz", + "integrity": "sha512-XU5/SytQM+ykqMnAnvB2umaJNIOsLF3PVv//1Ew4CTcpz0/BRyy/af40qqrt7SjKpDdT1saBMc42CUok5gaw+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.12.5" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@testing-library/dom": "^10.0.0", + "@types/react": "^18.0.0 || ^19.0.0", + "@types/react-dom": "^18.0.0 || ^19.0.0", + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@tybys/wasm-util": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz", @@ -1296,6 +2032,32 @@ "tslib": "^2.4.0" } }, + "node_modules/@types/aria-query": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", + "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", @@ -1898,6 +2660,176 @@ "win32" ] }, + "node_modules/@vitejs/plugin-react": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.0.1.tgz", + "integrity": "sha512-l9X/E3cDb+xY3SWzlG1MOGt2usfEHGMNIaegaUGFsLkb3RCn/k8/TOXBcab+OndDI4TBtktT8/9BwwW8Vi9KUQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rolldown/pluginutils": "1.0.0-rc.7" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "peerDependencies": { + "@rolldown/plugin-babel": "^0.1.7 || ^0.2.0", + "babel-plugin-react-compiler": "^1.0.0", + "vite": "^8.0.0" + }, + "peerDependenciesMeta": { + "@rolldown/plugin-babel": { + "optional": true + }, + "babel-plugin-react-compiler": { + "optional": true + } + } + }, + "node_modules/@vitest/coverage-v8": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.5.tgz", + "integrity": "sha512-38C0/Ddb7HcRG0Z4/DUem8x57d2p9jYgp18mkaYswEOQBGsI1CG4f/hjm0ZCeaJfWhSZ4k7jgs29V1Zom7Ki9A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@bcoe/v8-coverage": "^1.0.2", + "@vitest/utils": "4.1.5", + "ast-v8-to-istanbul": "^1.0.0", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-report": "^3.0.1", + "istanbul-reports": "^3.2.0", + "magicast": "^0.5.2", + "obug": "^2.1.1", + "std-env": "^4.0.0-rc.1", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/browser": "4.1.5", + "vitest": "4.1.5" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + } + } + }, + "node_modules/@vitest/expect": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.5.tgz", + "integrity": "sha512-PWBaRY5JoKuRnHlUHfpV/KohFylaDZTupcXN1H9vYryNLOnitSw60Mw9IAE2r67NbwwzBw/Cc/8q9BK3kIX8Kw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.1.0", + "@types/chai": "^5.2.2", + "@vitest/spy": "4.1.5", + "@vitest/utils": "4.1.5", + "chai": "^6.2.2", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.5.tgz", + "integrity": "sha512-/x2EmFC4mT4NNzqvC3fmesuV97w5FC903KPmey4gsnJiMQ3Be1IlDKVaDaG8iqaLFHqJ2FVEkxZk5VmeLjIItw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "4.1.5", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.21" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.5.tgz", + "integrity": "sha512-7I3q6l5qr03dVfMX2wCo9FxwSJbPdwKjy2uu/YPpU3wfHvIL4QHwVRp57OfGrDFeUJ8/8QdfBKIV12FTtLn00g==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.5.tgz", + "integrity": "sha512-2D+o7Pr82IEO46YPpoA/YU0neeyr6FTerQb5Ro7BUnBuv6NQtT/kmVnczngiMEBhzgqz2UZYl5gArejsyERDSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "4.1.5", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.5.tgz", + "integrity": "sha512-zypXEt4KH/XgKGPUz4eC2AvErYx0My5hfL8oDb1HzGFpEk1P62bxSohdyOmvz+d9UJwanI68MKwr2EquOaOgMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.1.5", + "@vitest/utils": "4.1.5", + "magic-string": "^0.30.21", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.5.tgz", + "integrity": "sha512-2lNOsh6+R2Idnf1TCZqSwYlKN2E/iDlD8sgU59kYVl+OMDmvldO1VDk39smRfpUNwYpNRVn3w4YfuC7KfbBnkQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.5.tgz", + "integrity": "sha512-76wdkrmfXfqGjueGgnb45ITPyUi1ycZ4IHgC2bhPDUfWHklY/q3MdLOAB+TF1e6xfl8NxNY0ZYaPCFNWSsw3Ug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.1.5", + "convert-source-map": "^2.0.0", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "node_modules/acorn": { "version": "8.16.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", @@ -1938,6 +2870,17 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=8" + } + }, "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -2131,6 +3074,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, "node_modules/ast-types-flow": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.8.tgz", @@ -2138,6 +3091,25 @@ "dev": true, "license": "MIT" }, + "node_modules/ast-v8-to-istanbul": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.0.tgz", + "integrity": "sha512-1fSfIwuDICFA4LKkCzRPO7F0hzFf0B7+Xqrl27ynQaa+Rh0e1Es0v6kWHPott3lU10AyAr7oKHa65OppjLn3Rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.31", + "estree-walker": "^3.0.3", + "js-tokens": "^10.0.0" + } + }, + "node_modules/ast-v8-to-istanbul/node_modules/js-tokens": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-10.0.0.tgz", + "integrity": "sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==", + "dev": true, + "license": "MIT" + }, "node_modules/async-function": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/async-function/-/async-function-1.0.0.tgz", @@ -2191,6 +3163,16 @@ "dev": true, "license": "MIT" }, + "node_modules/bidi-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.0.3.tgz", + "integrity": "sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==", + "dev": true, + "license": "MIT", + "dependencies": { + "require-from-string": "^2.0.2" + } + }, "node_modules/bootstrap": { "version": "5.3.8", "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.8.tgz", @@ -2314,6 +3296,16 @@ ], "license": "CC-BY-4.0" }, + "node_modules/chai": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz", + "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -2380,6 +3372,13 @@ "dev": true, "license": "MIT" }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -2395,6 +3394,27 @@ "node": ">= 8" } }, + "node_modules/css-tree": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz", + "integrity": "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "mdn-data": "2.27.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + } + }, + "node_modules/css.escape": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", + "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==", + "dev": true, + "license": "MIT" + }, "node_modules/csstype": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", @@ -2409,6 +3429,20 @@ "dev": true, "license": "BSD-2-Clause" }, + "node_modules/data-urls": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-7.0.0.tgz", + "integrity": "sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^16.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, "node_modules/data-view-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz", @@ -2481,6 +3515,13 @@ } } }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "dev": true, + "license": "MIT" + }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -2524,12 +3565,23 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=6" + } + }, "node_modules/detect-libc": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "devOptional": true, "license": "Apache-2.0", - "optional": true, "engines": { "node": ">=8" } @@ -2547,6 +3599,14 @@ "node": ">=0.10.0" } }, + "node_modules/dom-accessibility-api": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", + "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", + "dev": true, + "license": "MIT", + "peer": true + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", @@ -2569,6 +3629,19 @@ "dev": true, "license": "MIT" }, + "node_modules/entities": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-8.0.0.tgz", + "integrity": "sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/es-abstract": { "version": "1.24.1", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.1.tgz", @@ -2687,6 +3760,13 @@ "node": ">= 0.4" } }, + "node_modules/es-module-lexer": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.1.0.tgz", + "integrity": "sha512-n27zTYMjYu1aj4MjCWzSP7G9r75utsaoc8m61weK+W8JMBGGQybd43GstCXZ3WNmSFtGT9wi59qQTW6mhTR5LQ==", + "dev": true, + "license": "MIT" + }, "node_modules/es-object-atoms": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", @@ -3181,6 +4261,16 @@ "node": ">=4.0" } }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -3191,6 +4281,16 @@ "node": ">=0.10.0" } }, + "node_modules/expect-type": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz", + "integrity": "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -3332,6 +4432,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -3603,6 +4718,26 @@ "node": ">= 0.4" } }, + "node_modules/html-encoding-sniffer": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-6.0.0.tgz", + "integrity": "sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.6.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -3647,6 +4782,16 @@ "node": ">=0.8.19" } }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/internal-slot": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz", @@ -3919,6 +5064,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "dev": true, + "license": "MIT" + }, "node_modules/is-regex": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", @@ -4078,6 +5230,45 @@ "dev": true, "license": "ISC" }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", + "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/iterator.prototype": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.5.tgz", @@ -4116,6 +5307,47 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/jsdom": { + "version": "29.1.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-29.1.0.tgz", + "integrity": "sha512-YNUc7fB9QuvSSQWfrH0xF+TyABkxUwx8sswgIDaCrw4Hol8BghdZDkITtZheRJeMtzWlnTfsM3bBBusRvpO1wg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/css-color": "^5.1.11", + "@asamuzakjp/dom-selector": "^7.1.1", + "@bramus/specificity": "^2.4.2", + "@csstools/css-syntax-patches-for-csstree": "^1.1.3", + "@exodus/bytes": "^1.15.0", + "css-tree": "^3.2.1", + "data-urls": "^7.0.0", + "decimal.js": "^10.6.0", + "html-encoding-sniffer": "^6.0.0", + "is-potential-custom-element-name": "^1.0.1", + "lru-cache": "^11.3.5", + "parse5": "^8.0.1", + "saxes": "^6.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^6.0.1", + "undici": "^7.25.0", + "w3c-xmlserializer": "^5.0.0", + "webidl-conversions": "^8.0.1", + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^16.0.1", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24.0.0" + }, + "peerDependencies": { + "canvas": "^3.0.0" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", @@ -4210,6 +5442,267 @@ "node": ">= 0.8.0" } }, + "node_modules/lightningcss": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", + "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.32.0", + "lightningcss-darwin-arm64": "1.32.0", + "lightningcss-darwin-x64": "1.32.0", + "lightningcss-freebsd-x64": "1.32.0", + "lightningcss-linux-arm-gnueabihf": "1.32.0", + "lightningcss-linux-arm64-gnu": "1.32.0", + "lightningcss-linux-arm64-musl": "1.32.0", + "lightningcss-linux-x64-gnu": "1.32.0", + "lightningcss-linux-x64-musl": "1.32.0", + "lightningcss-win32-arm64-msvc": "1.32.0", + "lightningcss-win32-x64-msvc": "1.32.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz", + "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz", + "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz", + "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz", + "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz", + "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz", + "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz", + "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz", + "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz", + "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz", + "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz", + "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -4246,6 +5739,65 @@ "loose-envify": "cli.js" } }, + "node_modules/lru-cache": { + "version": "11.3.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.3.5.tgz", + "integrity": "sha512-NxVFwLAnrd9i7KUBxC4DrUhmgjzOs+1Qm50D3oF1/oL+r1NpZ4gA7xvG0/zJ8evR7zIKn4vLf7qTNduWFtCrRw==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/lz-string": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", + "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", + "dev": true, + "license": "MIT", + "peer": true, + "bin": { + "lz-string": "bin/bin.js" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/magicast": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.2.tgz", + "integrity": "sha512-E3ZJh4J3S9KfwdjZhe2afj6R9lGIN5Pher1pF39UGrXRqq/VDaGVIGN13BjHd2u8B61hArAGOnso7nBOouW3TQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.0", + "@babel/types": "^7.29.0", + "source-map-js": "^1.2.1" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -4256,6 +5808,13 @@ "node": ">= 0.4" } }, + "node_modules/mdn-data": { + "version": "2.27.1", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.27.1.tgz", + "integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==", + "dev": true, + "license": "CC0-1.0" + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -4280,6 +5839,16 @@ "node": ">=8.6" } }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/minimatch": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", @@ -4563,6 +6132,17 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/obug": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz", + "integrity": "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT" + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", @@ -4644,6 +6224,19 @@ "node": ">=6" } }, + "node_modules/parse5": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.1.tgz", + "integrity": "sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^8.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -4671,6 +6264,13 @@ "dev": true, "license": "MIT" }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -4738,6 +6338,44 @@ "node": ">= 0.8.0" } }, + "node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/pretty-format/node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "dev": true, + "license": "MIT", + "peer": true + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -4823,6 +6461,20 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/redent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", + "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "indent-string": "^4.0.0", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/reflect.getprototypeof": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", @@ -4867,6 +6519,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/resolve": { "version": "1.22.11", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz", @@ -4919,6 +6581,47 @@ "node": ">=0.10.0" } }, + "node_modules/rolldown": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-rc.17.tgz", + "integrity": "sha512-ZrT53oAKrtA4+YtBWPQbtPOxIbVDbxT0orcYERKd63VJTF13zPcgXTvD4843L8pcsI7M6MErt8QtON6lrB9tyA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.127.0", + "@rolldown/pluginutils": "1.0.0-rc.17" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm64": "1.0.0-rc.17", + "@rolldown/binding-darwin-arm64": "1.0.0-rc.17", + "@rolldown/binding-darwin-x64": "1.0.0-rc.17", + "@rolldown/binding-freebsd-x64": "1.0.0-rc.17", + "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.17", + "@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.17", + "@rolldown/binding-linux-arm64-musl": "1.0.0-rc.17", + "@rolldown/binding-linux-ppc64-gnu": "1.0.0-rc.17", + "@rolldown/binding-linux-s390x-gnu": "1.0.0-rc.17", + "@rolldown/binding-linux-x64-gnu": "1.0.0-rc.17", + "@rolldown/binding-linux-x64-musl": "1.0.0-rc.17", + "@rolldown/binding-openharmony-arm64": "1.0.0-rc.17", + "@rolldown/binding-wasm32-wasi": "1.0.0-rc.17", + "@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.17", + "@rolldown/binding-win32-x64-msvc": "1.0.0-rc.17" + } + }, + "node_modules/rolldown/node_modules/@rolldown/pluginutils": { + "version": "1.0.0-rc.17", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.17.tgz", + "integrity": "sha512-n8iosDOt6Ig1UhJ2AYqoIhHWh/isz0xpicHTzpKBeotdVsTEcxsSA/i3EVM7gQAj0rU27OLAxCjzlj15IWY7bg==", + "dev": true, + "license": "MIT" + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -5019,6 +6722,19 @@ "@parcel/watcher": "^2.4.1" } }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dev": true, + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, "node_modules/scheduler": { "version": "0.27.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", @@ -5231,6 +6947,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -5247,6 +6970,20 @@ "dev": true, "license": "MIT" }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.1.0.tgz", + "integrity": "sha512-Rq7ybcX2RuC55r9oaPVEW7/xu3tj8u4GeBYHBWCychFtzMIr86A7e3PPEBPT37sHStKX3+TiX/Fr/ACmJLVlLQ==", + "dev": true, + "license": "MIT" + }, "node_modules/stop-iteration-iterator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz", @@ -5384,6 +7121,19 @@ "node": ">=4" } }, + "node_modules/strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "min-indent": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -5446,15 +7196,39 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.1.1.tgz", + "integrity": "sha512-VKS/ZaQhhkKFMANmAOhhXVoIfBXblQxGX1myCQ2faQrfmobMftXeJPcZGp0gS07ocvGJWDLZGyOZDadDBqYIJg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/tinyglobby": { - "version": "0.2.15", - "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", - "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "version": "0.2.16", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz", + "integrity": "sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==", "dev": true, "license": "MIT", "dependencies": { "fdir": "^6.5.0", - "picomatch": "^4.0.3" + "picomatch": "^4.0.4" }, "engines": { "node": ">=12.0.0" @@ -5482,9 +7256,9 @@ } }, "node_modules/tinyglobby/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "dev": true, "license": "MIT", "engines": { @@ -5494,6 +7268,36 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/tinyrainbow": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.0.tgz", + "integrity": "sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tldts": { + "version": "7.0.29", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.0.29.tgz", + "integrity": "sha512-JIXCerhudr/N6OWLwLF1HVsTTUo7ry6qHa5eWZEkiMuxsIiAACL55tGLfqfHfoH7QaMQUW8fngD7u7TxWexYQg==", + "dev": true, + "license": "MIT", + "dependencies": { + "tldts-core": "^7.0.29" + }, + "bin": { + "tldts": "bin/cli.js" + } + }, + "node_modules/tldts-core": { + "version": "7.0.29", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.0.29.tgz", + "integrity": "sha512-W99NuU7b1DcG3uJ3v9k9VztCH3WialNbBkBft5wCs8V8mexu0XQqaZEYb9l9RNNzK8+3EJ9PKWB0/RUtTQ/o+Q==", + "dev": true, + "license": "MIT" + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -5507,6 +7311,32 @@ "node": ">=8.0" } }, + "node_modules/tough-cookie": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.1.tgz", + "integrity": "sha512-LktZQb3IeoUWB9lqR5EWTHgW/VTITCXg4D21M+lvybRVdylLrRMnqaIONLVb5mav8vM19m44HIcGq4qASeu2Qw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tldts": "^7.0.5" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/tr46": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-6.0.0.tgz", + "integrity": "sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/ts-api-utils": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", @@ -5663,6 +7493,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici": { + "version": "7.25.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.25.0.tgz", + "integrity": "sha512-xXnp4kTyor2Zq+J1FfPI6Eq3ew5h6Vl0F/8d9XU5zZQf1tX9s2Su1/3PiMmUANFULpmksxkClamIZcaUqryHsQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, "node_modules/undici-types": { "version": "6.21.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", @@ -5715,6 +7555,277 @@ "punycode": "^2.1.0" } }, + "node_modules/vite": { + "version": "8.0.10", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.0.10.tgz", + "integrity": "sha512-rZuUu9j6J5uotLDs+cAA4O5H4K1SfPliUlQwqa6YEwSrWDZzP4rhm00oJR5snMewjxF5V/K3D4kctsUTsIU9Mw==", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.32.0", + "picomatch": "^4.0.4", + "postcss": "^8.5.10", + "rolldown": "1.0.0-rc.17", + "tinyglobby": "^0.2.16" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.1.0", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/picomatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/vite/node_modules/postcss": { + "version": "8.5.12", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.12.tgz", + "integrity": "sha512-W62t/Se6rA0Az3DfCL0AqJwXuKwBeYg6nOaIgzP+xZ7N5BFCI7DYi1qs6ygUYT6rvfi6t9k65UMLJC+PHZpDAA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/vitest": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.5.tgz", + "integrity": "sha512-9Xx1v3/ih3m9hN+SbfkUyy0JAs72ap3r7joc87XL6jwF0jGg6mFBvQ1SrwaX+h8BlkX6Hz9shdd1uo6AF+ZGpg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "4.1.5", + "@vitest/mocker": "4.1.5", + "@vitest/pretty-format": "4.1.5", + "@vitest/runner": "4.1.5", + "@vitest/snapshot": "4.1.5", + "@vitest/spy": "4.1.5", + "@vitest/utils": "4.1.5", + "es-module-lexer": "^2.0.0", + "expect-type": "^1.3.0", + "magic-string": "^0.30.21", + "obug": "^2.1.1", + "pathe": "^2.0.3", + "picomatch": "^4.0.3", + "std-env": "^4.0.0-rc.1", + "tinybench": "^2.9.0", + "tinyexec": "^1.0.2", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.1.0", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^20.0.0 || ^22.0.0 || >=24.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "4.1.5", + "@vitest/browser-preview": "4.1.5", + "@vitest/browser-webdriverio": "4.1.5", + "@vitest/coverage-istanbul": "4.1.5", + "@vitest/coverage-v8": "4.1.5", + "@vitest/ui": "4.1.5", + "happy-dom": "*", + "jsdom": "*", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@opentelemetry/api": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { + "optional": true + }, + "@vitest/coverage-istanbul": { + "optional": true + }, + "@vitest/coverage-v8": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "vite": { + "optional": false + } + } + }, + "node_modules/vitest/node_modules/picomatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/w3c-xmlserializer": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", + "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/webidl-conversions": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz", + "integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-mimetype": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz", + "integrity": "sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-url": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-16.0.1.tgz", + "integrity": "sha512-1to4zXBxmXHV3IiSSEInrreIlu02vUOvrhxJJH5vcxYTBDAx51cqZiKdyTxlecdKNSjj8EcxGBxNf6Vg+945gw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.11.0", + "tr46": "^6.0.0", + "webidl-conversions": "^8.0.1" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -5820,6 +7931,23 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", @@ -5830,6 +7958,23 @@ "node": ">=0.10.0" } }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true, + "license": "MIT" + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/admin-ui/package.json b/admin-ui/package.json index 119d335..ab14cd2 100644 --- a/admin-ui/package.json +++ b/admin-ui/package.json @@ -8,7 +8,10 @@ "build": "next build", "start": "next start -p 3040", "lint": "next lint", - "typecheck": "tsc --noEmit" + "typecheck": "tsc --noEmit", + "test": "vitest run", + "test:watch": "vitest", + "test:coverage": "vitest run --coverage" }, "dependencies": { "bootstrap": "^5.3.3", @@ -18,13 +21,19 @@ }, "devDependencies": { "@eslint/eslintrc": "^3.2.0", + "@testing-library/jest-dom": "^6.9.1", + "@testing-library/react": "^16.3.2", "@types/node": "^22.9.0", "@types/react": "19.2.14", "@types/react-dom": "19.2.3", + "@vitejs/plugin-react": "^6.0.1", + "@vitest/coverage-v8": "^4.1.5", "eslint": "^9.15.0", "eslint-config-next": "15.5.15", + "jsdom": "^29.1.0", "sass": "^1.81.0", - "typescript": "^5.6.3" + "typescript": "^5.6.3", + "vitest": "^4.1.5" }, "engines": { "node": ">=20" diff --git a/admin-ui/test/components/AppShell.test.tsx b/admin-ui/test/components/AppShell.test.tsx new file mode 100644 index 0000000..61dd90d --- /dev/null +++ b/admin-ui/test/components/AppShell.test.tsx @@ -0,0 +1,69 @@ +import { describe, it, expect, vi } from 'vitest'; +import { render, screen } from '@testing-library/react'; +import { AppShell } from '@/components/AppShell'; + +vi.mock('next/link', () => ({ + default: ({ href, children, className }: { href: string; children: React.ReactNode; className?: string }) => ( + {children} + ), +})); + +describe('AppShell', () => { + it('renders the page title', () => { + render(
content
); + expect(screen.getByRole('heading', { name: 'Dashboard' })).toBeInTheDocument(); + }); + + it('renders child content', () => { + render(

Hello content

); + expect(screen.getByText('Hello content')).toBeInTheDocument(); + }); + + it('renders the BitReport brand link', () => { + render(
); + expect(screen.getByText('BitReport')).toBeInTheDocument(); + }); + + it('renders nav links for Painel and Incidentes', () => { + render(
); + expect(screen.getByRole('link', { name: /Painel/i })).toBeInTheDocument(); + expect(screen.getByRole('link', { name: /Incidentes/i })).toBeInTheDocument(); + }); + + it('renders breadcrumb when provided', () => { + render( + +
+ + ); + expect(screen.getByRole('navigation', { name: 'breadcrumb' })).toBeInTheDocument(); + expect(screen.getByText('Home')).toBeInTheDocument(); + expect(screen.getByText('Current')).toBeInTheDocument(); + }); + + it('does not render breadcrumb nav when breadcrumb is empty', () => { + render(
); + expect(screen.queryByRole('navigation', { name: 'breadcrumb' })).toBeNull(); + }); + + it('does not render breadcrumb nav when breadcrumb is omitted', () => { + render(
); + expect(screen.queryByRole('navigation', { name: 'breadcrumb' })).toBeNull(); + }); + + it('breadcrumb item with href renders as a link', () => { + render( +
+ ); + const link = screen.getByText('Home').closest('a'); + expect(link).not.toBeNull(); + }); + + it('breadcrumb item without href has aria-current="page"', () => { + render( +
+ ); + const item = screen.getByText('Current page').closest('li'); + expect(item?.getAttribute('aria-current')).toBe('page'); + }); +}); diff --git a/admin-ui/test/components/DataAlert.test.tsx b/admin-ui/test/components/DataAlert.test.tsx new file mode 100644 index 0000000..26f52d0 --- /dev/null +++ b/admin-ui/test/components/DataAlert.test.tsx @@ -0,0 +1,41 @@ +import { describe, it, expect } from 'vitest'; +import { render, screen } from '@testing-library/react'; +import { DataAlert } from '@/components/DataAlert'; + +describe('DataAlert', () => { + it('renders the title', () => { + render(); + expect(screen.getByText('Aviso')).toBeInTheDocument(); + }); + + it('renders the body text', () => { + render(); + expect(screen.getByText('Nenhuma informação disponível.')).toBeInTheDocument(); + }); + + it('applies the correct alert variant class', () => { + const { container } = render(); + expect(container.querySelector('.alert-danger')).not.toBeNull(); + }); + + it('applies alert-warning class for warning variant', () => { + const { container } = render(); + expect(container.querySelector('.alert-warning')).not.toBeNull(); + }); + + it('applies alert-info class for info variant', () => { + const { container } = render(); + expect(container.querySelector('.alert-info')).not.toBeNull(); + }); + + it('has role="status" for accessibility', () => { + render(); + expect(screen.getByRole('status')).toBeInTheDocument(); + }); + + it('renders title in a strong element', () => { + render(); + const strong = screen.getByText('My Title'); + expect(strong.tagName).toBe('STRONG'); + }); +}); diff --git a/admin-ui/test/components/IncidentNotes.test.tsx b/admin-ui/test/components/IncidentNotes.test.tsx new file mode 100644 index 0000000..179c2eb --- /dev/null +++ b/admin-ui/test/components/IncidentNotes.test.tsx @@ -0,0 +1,51 @@ +import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { render, screen, fireEvent } from '@testing-library/react'; +import { IncidentNotes } from '@/components/IncidentNotes'; + +describe('IncidentNotes', () => { + beforeEach(() => { + sessionStorage.clear(); + }); + + it('renders the label', () => { + render(); + expect(screen.getByText('Notas do operador')).toBeInTheDocument(); + }); + + it('renders a textarea', () => { + render(); + expect(screen.getByRole('textbox')).toBeInTheDocument(); + }); + + it('starts with empty textarea when no stored value', () => { + render(); + const ta = screen.getByRole('textbox') as HTMLTextAreaElement; + expect(ta.value).toBe(''); + }); + + it('loads stored value from sessionStorage', () => { + sessionStorage.setItem('er-incident-notes:inc-42', 'saved note'); + render(); + const ta = screen.getByRole('textbox') as HTMLTextAreaElement; + expect(ta.value).toBe('saved note'); + }); + + it('saves to sessionStorage when user types', () => { + render(); + const ta = screen.getByRole('textbox'); + fireEvent.change(ta, { target: { value: 'new note text' } }); + expect(sessionStorage.getItem('er-incident-notes:inc-99')).toBe('new note text'); + }); + + it('shows the helper text about server persistence', () => { + render(); + expect(screen.getByText(/não são enviadas ao servidor/i)).toBeInTheDocument(); + }); + + it('textarea is linked to its label via htmlFor/id', () => { + render(); + const label = screen.getByText('Notas do operador'); + const ta = screen.getByRole('textbox'); + expect(label.getAttribute('for')).toBe(ta.getAttribute('id')); + }); +}); diff --git a/admin-ui/test/components/KpiCard.test.tsx b/admin-ui/test/components/KpiCard.test.tsx new file mode 100644 index 0000000..42584bf --- /dev/null +++ b/admin-ui/test/components/KpiCard.test.tsx @@ -0,0 +1,42 @@ +import { describe, it, expect } from 'vitest'; +import { render, screen } from '@testing-library/react'; +import { KpiCard } from '@/components/KpiCard'; + +describe('KpiCard', () => { + it('renders the label text', () => { + render(); + expect(screen.getByText('Total Errors')).toBeInTheDocument(); + }); + + it('renders the numeric value', () => { + render(); + expect(screen.getByText('7')).toBeInTheDocument(); + }); + + it('applies the correct border variant class', () => { + const { container } = render(); + expect(container.querySelector('.border-success')).not.toBeNull(); + }); + + it('applies the correct text variant class', () => { + render(); + const valueEl = screen.getByText('3'); + expect(valueEl.className).toContain('text-dark'); + }); + + it('renders value zero', () => { + render(); + expect(screen.getByText('0')).toBeInTheDocument(); + }); + + it('renders large numbers', () => { + render(); + expect(screen.getByText('99999')).toBeInTheDocument(); + }); + + it('applies card and col wrapper classes', () => { + const { container } = render(); + expect(container.querySelector('.card')).not.toBeNull(); + expect(container.querySelector('.card-body')).not.toBeNull(); + }); +}); diff --git a/admin-ui/test/components/SeverityBadge.test.tsx b/admin-ui/test/components/SeverityBadge.test.tsx new file mode 100644 index 0000000..93ed20c --- /dev/null +++ b/admin-ui/test/components/SeverityBadge.test.tsx @@ -0,0 +1,33 @@ +import { describe, it, expect } from 'vitest'; +import { render, screen } from '@testing-library/react'; +import { SeverityBadge } from '@/components/SeverityBadge'; +import type { Severity } from '@/lib/types'; + +describe('SeverityBadge', () => { + const cases: { severity: Severity; label: string; cssClass: string }[] = [ + { severity: 'critical', label: 'Crítico', cssClass: 'text-bg-dark' }, + { severity: 'high', label: 'Alto', cssClass: 'text-bg-danger' }, + { severity: 'medium', label: 'Médio', cssClass: 'text-bg-warning' }, + { severity: 'low', label: 'Baixo', cssClass: 'text-bg-info' }, + { severity: 'info', label: 'Info', cssClass: 'text-bg-light' }, + ]; + + cases.forEach(({ severity, label, cssClass }) => { + it(`renders "${label}" label for severity="${severity}"`, () => { + render(); + expect(screen.getByText(label)).toBeInTheDocument(); + }); + + it(`applies "${cssClass}" class for severity="${severity}"`, () => { + render(); + const badge = screen.getByText(label); + expect(badge.className).toContain(cssClass); + expect(badge.className).toContain('badge'); + }); + }); + + it('renders as a span element', () => { + render(); + expect(screen.getByText('Alto').tagName).toBe('SPAN'); + }); +}); diff --git a/admin-ui/test/components/StateBadge.test.tsx b/admin-ui/test/components/StateBadge.test.tsx new file mode 100644 index 0000000..99fe07d --- /dev/null +++ b/admin-ui/test/components/StateBadge.test.tsx @@ -0,0 +1,32 @@ +import { describe, it, expect } from 'vitest'; +import { render, screen } from '@testing-library/react'; +import { StateBadge } from '@/components/StateBadge'; +import type { IncidentState } from '@/lib/types'; + +describe('StateBadge', () => { + const cases: { state: IncidentState; label: string; cssClass: string }[] = [ + { state: 'open', label: 'Aberto', cssClass: 'text-bg-danger' }, + { state: 'investigating', label: 'Em investigação', cssClass: 'text-bg-warning' }, + { state: 'resolved', label: 'Resolvido', cssClass: 'text-bg-success' }, + { state: 'ignored', label: 'Ignorado', cssClass: 'text-bg-secondary' }, + ]; + + cases.forEach(({ state, label, cssClass }) => { + it(`renders "${label}" label for state="${state}"`, () => { + render(); + expect(screen.getByText(label)).toBeInTheDocument(); + }); + + it(`applies "${cssClass}" class for state="${state}"`, () => { + render(); + const badge = screen.getByText(label); + expect(badge.className).toContain(cssClass); + expect(badge.className).toContain('badge'); + }); + }); + + it('renders as a span element', () => { + render(); + expect(screen.getByText('Aberto').tagName).toBe('SPAN'); + }); +}); diff --git a/admin-ui/test/lib/demo-incidents.test.ts b/admin-ui/test/lib/demo-incidents.test.ts new file mode 100644 index 0000000..fe522f9 --- /dev/null +++ b/admin-ui/test/lib/demo-incidents.test.ts @@ -0,0 +1,54 @@ +import { describe, it, expect } from 'vitest'; +import { getDemoIncidentSummaries, getDemoIncidentDetail } from '@/lib/demo-incidents'; + +describe('getDemoIncidentSummaries', () => { + it('returns a non-empty array', () => { + const result = getDemoIncidentSummaries(); + expect(Array.isArray(result)).toBe(true); + expect(result.length).toBeGreaterThan(0); + }); + + it('each summary has required fields', () => { + const summaries = getDemoIncidentSummaries(); + for (const s of summaries) { + expect(typeof s.id).toBe('string'); + expect(typeof s.projectSlug).toBe('string'); + expect(typeof s.fingerprint).toBe('string'); + expect(typeof s.title).toBe('string'); + expect(['critical', 'high', 'medium', 'low', 'info']).toContain(s.severity); + expect(['open', 'investigating', 'resolved', 'ignored']).toContain(s.currentState); + expect(typeof s.occurrencesCount).toBe('number'); + } + }); + + it('returns a stable list on repeated calls', () => { + const first = getDemoIncidentSummaries(); + const second = getDemoIncidentSummaries(); + expect(first.length).toBe(second.length); + expect(first[0].id).toBe(second[0].id); + }); +}); + +describe('getDemoIncidentDetail', () => { + it('returns null for unknown id', () => { + expect(getDemoIncidentDetail('nonexistent-id')).toBeNull(); + }); + + it('returns a detail for a known demo id', () => { + const summaries = getDemoIncidentSummaries(); + const id = summaries[0].id; + const detail = getDemoIncidentDetail(id); + expect(detail).not.toBeNull(); + expect(detail?.id).toBe(id); + }); + + it('returned detail has occurrences array', () => { + const summaries = getDemoIncidentSummaries(); + const detail = getDemoIncidentDetail(summaries[0].id); + expect(Array.isArray(detail?.occurrences)).toBe(true); + }); + + it('returns null for empty string id', () => { + expect(getDemoIncidentDetail('')).toBeNull(); + }); +}); diff --git a/admin-ui/test/lib/format.test.ts b/admin-ui/test/lib/format.test.ts new file mode 100644 index 0000000..ede5b87 --- /dev/null +++ b/admin-ui/test/lib/format.test.ts @@ -0,0 +1,36 @@ +import { describe, it, expect } from 'vitest'; +import { formatDateTime } from '@/lib/format'; + +describe('formatDateTime', () => { + it('formats a valid ISO string', () => { + const result = formatDateTime('2024-01-15T10:30:00Z'); + expect(typeof result).toBe('string'); + expect(result.length).toBeGreaterThan(0); + expect(result).not.toBe('2024-01-15T10:30:00Z'); + }); + + it('returns the raw string for an invalid date', () => { + expect(formatDateTime('not-a-date')).toBe('not-a-date'); + }); + + it('returns the raw string for an empty string', () => { + expect(formatDateTime('')).toBe(''); + }); + + it('handles date-only ISO strings', () => { + const result = formatDateTime('2024-06-01'); + expect(typeof result).toBe('string'); + expect(result.length).toBeGreaterThan(0); + }); + + it('handles ISO strings with milliseconds', () => { + const result = formatDateTime('2024-03-20T14:22:33.456Z'); + expect(typeof result).toBe('string'); + expect(result).not.toBe('2024-03-20T14:22:33.456Z'); + }); + + it('returns consistent output for the same input', () => { + const iso = '2024-07-04T12:00:00Z'; + expect(formatDateTime(iso)).toBe(formatDateTime(iso)); + }); +}); diff --git a/admin-ui/test/lib/incidents-data-api.test.ts b/admin-ui/test/lib/incidents-data-api.test.ts new file mode 100644 index 0000000..4cc5dac --- /dev/null +++ b/admin-ui/test/lib/incidents-data-api.test.ts @@ -0,0 +1,190 @@ +/** + * Tests for fetchIncidentList and fetchIncidentDetail covering the API-backed paths. + */ +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { fetchIncidentList, fetchIncidentDetail } from '@/lib/incidents-data'; +import type { IncidentSummary } from '@/lib/types'; + +vi.mock('next/headers', () => ({ + cookies: vi.fn().mockResolvedValue({ get: vi.fn().mockReturnValue(undefined) }), +})); + +const PREV_API_BASE = process.env.ERROR_REPORTING_ADMIN_API_BASE; + +const mockIncident: IncidentSummary = { + id: 'inc-001', + projectSlug: 'wdmi-store', + fingerprint: 'fp-abc', + title: 'Uncaught TypeError', + severity: 'high', + currentState: 'open', + firstSeenAt: '2026-01-01T00:00:00Z', + lastSeenAt: '2026-01-02T00:00:00Z', + occurrencesCount: 5, +}; + +beforeEach(() => { + process.env.ERROR_REPORTING_ADMIN_API_BASE = 'http://test-api.local'; + delete process.env.ERROR_REPORTING_UI_DEMO; +}); + +afterEach(() => { + if (PREV_API_BASE === undefined) { + delete process.env.ERROR_REPORTING_ADMIN_API_BASE; + } else { + process.env.ERROR_REPORTING_ADMIN_API_BASE = PREV_API_BASE; + } + vi.restoreAllMocks(); +}); + +describe('fetchIncidentList — API mode', () => { + it('returns incidents from API on success', async () => { + global.fetch = vi.fn().mockResolvedValue({ + ok: true, + json: () => Promise.resolve({ incidents: [mockIncident] }), + }); + const result = await fetchIncidentList({}); + expect(result.ok).toBe(true); + if (result.ok) { + expect(result.incidents).toHaveLength(1); + expect(result.incidents[0].id).toBe('inc-001'); + expect(result.source).toBe('api'); + } + }); + + it('passes state/severity/project/q as query params', async () => { + global.fetch = vi.fn().mockResolvedValue({ + ok: true, + json: () => Promise.resolve({ incidents: [] }), + }); + await fetchIncidentList({ state: 'open', severity: 'high', project: 'wdmi', q: 'TypeError' }); + const calledUrl = (global.fetch as ReturnType).mock.calls[0][0] as string; + expect(calledUrl).toContain('state=open'); + expect(calledUrl).toContain('severity=high'); + expect(calledUrl).toContain('project=wdmi'); + expect(calledUrl).toContain('q=TypeError'); + }); + + it('omits empty params from query string', async () => { + global.fetch = vi.fn().mockResolvedValue({ + ok: true, + json: () => Promise.resolve({ incidents: [] }), + }); + await fetchIncidentList({}); + const calledUrl = (global.fetch as ReturnType).mock.calls[0][0] as string; + expect(calledUrl).not.toContain('state='); + expect(calledUrl).not.toContain('severity='); + }); + + it('returns unreachable error when fetch throws', async () => { + global.fetch = vi.fn().mockRejectedValue(new Error('ECONNREFUSED')); + const result = await fetchIncidentList({}); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error).toBe('unreachable'); + expect(result.message).toContain('ECONNREFUSED'); + } + }); + + it('returns unreachable error when API returns non-ok status', async () => { + global.fetch = vi.fn().mockResolvedValue({ + ok: false, + status: 503, + json: () => Promise.resolve({}), + }); + const result = await fetchIncidentList({}); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error).toBe('unreachable'); + } + }); + + it('returns empty incidents array when payload has no incidents field', async () => { + global.fetch = vi.fn().mockResolvedValue({ + ok: true, + json: () => Promise.resolve({}), + }); + const result = await fetchIncidentList({}); + expect(result.ok).toBe(true); + if (result.ok) { + expect(result.incidents).toHaveLength(0); + } + }); +}); + +describe('fetchIncidentDetail — API mode', () => { + const detailPayload = { + incident: { + id: 'inc-001', + projectSlug: 'wdmi-store', + fingerprint: 'fp-abc', + title: 'Uncaught TypeError', + severity: 'high', + currentState: 'open', + firstSeenAt: '2026-01-01T00:00:00Z', + lastSeenAt: '2026-01-02T00:00:00Z', + occurrencesCount: 5, + recentOccurrences: [], + stateHistory: [], + }, + }; + + it('returns incident detail on success', async () => { + global.fetch = vi.fn().mockResolvedValue({ + ok: true, + json: () => Promise.resolve(detailPayload), + }); + const result = await fetchIncidentDetail('inc-001'); + expect(result.ok).toBe(true); + if (result.ok) { + expect(result.incident.id).toBe('inc-001'); + expect(result.source).toBe('api'); + } + }); + + it('returns not_found on 404', async () => { + global.fetch = vi.fn().mockResolvedValue({ + ok: false, + status: 404, + json: () => Promise.resolve({}), + }); + const result = await fetchIncidentDetail('unknown-id'); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error).toBe('not_found'); + } + }); + + it('returns unreachable when API throws', async () => { + global.fetch = vi.fn().mockRejectedValue(new Error('timeout')); + const result = await fetchIncidentDetail('inc-001'); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error).toBe('unreachable'); + expect(result.message).toContain('timeout'); + } + }); + + it('returns unreachable on non-404 HTTP error', async () => { + global.fetch = vi.fn().mockResolvedValue({ + ok: false, + status: 500, + json: () => Promise.resolve({}), + }); + const result = await fetchIncidentDetail('inc-001'); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error).toBe('unreachable'); + } + }); + + it('URL-encodes the incident id', async () => { + global.fetch = vi.fn().mockResolvedValue({ + ok: true, + json: () => Promise.resolve(detailPayload), + }); + await fetchIncidentDetail('inc/with/slashes'); + const calledUrl = (global.fetch as ReturnType).mock.calls[0][0] as string; + expect(calledUrl).toContain('inc%2Fwith%2Fslashes'); + }); +}); diff --git a/admin-ui/test/lib/incidents-data.test.ts b/admin-ui/test/lib/incidents-data.test.ts new file mode 100644 index 0000000..a1aab3a --- /dev/null +++ b/admin-ui/test/lib/incidents-data.test.ts @@ -0,0 +1,176 @@ +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { computeKpis, fetchIncidentList, fetchIncidentDetail } from '@/lib/incidents-data'; +import { getDemoIncidentSummaries } from '@/lib/demo-incidents'; +import type { IncidentSummary } from '@/lib/types'; + +vi.mock('next/headers', () => ({ + cookies: vi.fn().mockResolvedValue({ get: vi.fn().mockReturnValue(undefined) }), +})); + +const makeIncident = (state: IncidentSummary['currentState']): IncidentSummary => ({ + id: Math.random().toString(), + projectSlug: 'test', + fingerprint: 'fp', + title: 'Error', + severity: 'high', + currentState: state, + firstSeenAt: '2024-01-01T00:00:00Z', + lastSeenAt: '2024-01-01T00:00:00Z', + occurrencesCount: 1, +}); + +describe('computeKpis', () => { + it('returns all zeros for empty list', () => { + const result = computeKpis([]); + expect(result).toEqual({ total: 0, open: 0, investigating: 0, resolved: 0, ignored: 0 }); + }); + + it('counts total correctly', () => { + const incidents = [makeIncident('open'), makeIncident('resolved'), makeIncident('ignored')]; + expect(computeKpis(incidents).total).toBe(3); + }); + + it('counts each state correctly', () => { + const incidents = [ + makeIncident('open'), + makeIncident('open'), + makeIncident('investigating'), + makeIncident('resolved'), + makeIncident('ignored'), + ]; + const result = computeKpis(incidents); + expect(result.open).toBe(2); + expect(result.investigating).toBe(1); + expect(result.resolved).toBe(1); + expect(result.ignored).toBe(1); + expect(result.total).toBe(5); + }); + + it('handles all incidents in a single state', () => { + const incidents = [makeIncident('resolved'), makeIncident('resolved')]; + const result = computeKpis(incidents); + expect(result.resolved).toBe(2); + expect(result.open).toBe(0); + }); +}); + +describe('fetchIncidentList — not_configured', () => { + beforeEach(() => { + delete process.env.ERROR_REPORTING_ADMIN_API_BASE; + delete process.env.ERROR_REPORTING_UI_DEMO; + }); + + it('returns not_configured when API base is missing and demo is off', async () => { + const result = await fetchIncidentList({}); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error).toBe('not_configured'); + } + }); +}); + +describe('fetchIncidentList — demo mode', () => { + beforeEach(() => { + delete process.env.ERROR_REPORTING_ADMIN_API_BASE; + process.env.ERROR_REPORTING_UI_DEMO = '1'; + }); + + afterEach(() => { + delete process.env.ERROR_REPORTING_UI_DEMO; + }); + + it('returns demo incidents when no API base is set', async () => { + const result = await fetchIncidentList({}); + expect(result.ok).toBe(true); + if (result.ok) { + expect(result.source).toBe('demo'); + expect(result.incidents.length).toBeGreaterThan(0); + } + }); + + it('filters demo incidents by state', async () => { + const allDemo = getDemoIncidentSummaries(); + const openCount = allDemo.filter((i) => i.currentState === 'open').length; + const result = await fetchIncidentList({ state: 'open' }); + if (result.ok) { + expect(result.incidents.every((i) => i.currentState === 'open')).toBe(true); + expect(result.incidents.length).toBe(openCount); + } + }); + + it('filters demo incidents by severity', async () => { + const result = await fetchIncidentList({ severity: 'high' }); + if (result.ok) { + expect(result.incidents.every((i) => i.severity === 'high')).toBe(true); + } + }); + + it('filters demo incidents by project slug', async () => { + const allDemo = getDemoIncidentSummaries(); + const firstSlug = allDemo[0].projectSlug; + const result = await fetchIncidentList({ project: firstSlug }); + if (result.ok) { + expect(result.incidents.every((i) => i.projectSlug === firstSlug)).toBe(true); + } + }); + + it('filters demo incidents by query string', async () => { + const allDemo = getDemoIncidentSummaries(); + const word = allDemo[0].title.split(' ')[0].toLowerCase(); + const result = await fetchIncidentList({ q: word }); + if (result.ok) { + expect(result.incidents.length).toBeGreaterThan(0); + } + }); + + it('returns empty list when no demo incidents match filter', async () => { + const result = await fetchIncidentList({ q: 'xyzzy_no_match_abc_999' }); + if (result.ok) { + expect(result.incidents).toHaveLength(0); + } + }); +}); + +describe('fetchIncidentDetail — demo mode', () => { + beforeEach(() => { + delete process.env.ERROR_REPORTING_ADMIN_API_BASE; + process.env.ERROR_REPORTING_UI_DEMO = '1'; + }); + + afterEach(() => { + delete process.env.ERROR_REPORTING_UI_DEMO; + }); + + it('returns detail for a known demo incident', async () => { + const demos = getDemoIncidentSummaries(); + const result = await fetchIncidentDetail(demos[0].id); + expect(result.ok).toBe(true); + if (result.ok) { + expect(result.incident.id).toBe(demos[0].id); + expect(result.source).toBe('demo'); + } + }); + + it('returns not_found for an unknown demo id', async () => { + const result = await fetchIncidentDetail('no-such-incident-id'); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error).toBe('not_found'); + } + }); +}); + +describe('fetchIncidentDetail — not_configured', () => { + beforeEach(() => { + delete process.env.ERROR_REPORTING_ADMIN_API_BASE; + delete process.env.ERROR_REPORTING_UI_DEMO; + }); + + it('returns not_configured when API is not set and demo is off', async () => { + const result = await fetchIncidentDetail('some-id'); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error).toBe('not_configured'); + } + }); +}); diff --git a/admin-ui/test/lib/stats-data-api.test.ts b/admin-ui/test/lib/stats-data-api.test.ts new file mode 100644 index 0000000..d240ff0 --- /dev/null +++ b/admin-ui/test/lib/stats-data-api.test.ts @@ -0,0 +1,146 @@ +/** + * Tests for fetchOperationalStats covering the API-backed success and error paths. + */ +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { fetchOperationalStats, type StatsSummaryPayload } from '@/lib/stats-data'; + +vi.mock('next/headers', () => ({ + cookies: vi.fn().mockResolvedValue({ get: vi.fn().mockReturnValue(undefined) }), +})); + +const PREV_API_BASE = process.env.ERROR_REPORTING_ADMIN_API_BASE; + +const mockSummary: StatsSummaryPayload = { + byProject: [ + { slug: 'wdmi', total: 5, open: 2, investigating: 1, resolved: 1, ignored: 1, critical: 0 }, + ], + bySeverity: { critical: 1, high: 2, medium: 1, low: 0, info: 0 }, + resolvedLast24h: 3, + totalLast24h: 10, +}; + +const mockTrendDay = { granularity: 'day', dates: ['2026-01-01'], series: { high: [1] } }; +const mockTrendHour = { granularity: 'hour', hours: ['2026-01-01 00:00:00'], series: { high: [1] } }; +const mockRecurrence = { windowDays: 7, rangeStart: '2026-01-01', rangeEndExclusive: '2026-01-08', top: [] }; + +function makeFetchMock(responses: Map) { + return vi.fn().mockImplementation((url: string) => { + for (const [key, value] of responses) { + if (url.includes(key)) { + return Promise.resolve({ + ok: true, + json: () => Promise.resolve(value), + }); + } + } + return Promise.resolve({ ok: false, status: 500, json: () => Promise.resolve({}) }); + }); +} + +beforeEach(() => { + process.env.ERROR_REPORTING_ADMIN_API_BASE = 'http://test-api.local'; +}); + +afterEach(() => { + if (PREV_API_BASE === undefined) { + delete process.env.ERROR_REPORTING_ADMIN_API_BASE; + } else { + process.env.ERROR_REPORTING_ADMIN_API_BASE = PREV_API_BASE; + } + vi.restoreAllMocks(); +}); + +describe('fetchOperationalStats — API mode', () => { + it('returns ok:true with all data when all fetches succeed', async () => { + global.fetch = makeFetchMock( + new Map([ + ['/v1/stats/summary', mockSummary], + ['/v1/stats/trend?granularity=day', mockTrendDay], + ['/v1/stats/trend?granularity=hour', mockTrendHour], + ['/v1/stats/recurrence', mockRecurrence], + ]), + ); + + const result = await fetchOperationalStats(); + expect(result.ok).toBe(true); + if (result.ok) { + expect(result.summary.byProject).toHaveLength(1); + expect(result.trendDay.granularity).toBe('day'); + expect(result.trendHour.granularity).toBe('hour'); + expect(result.recurrence.windowDays).toBe(7); + } + }); + + it('returns error when summary fetch throws', async () => { + global.fetch = vi.fn().mockRejectedValue(new Error('network error')); + const result = await fetchOperationalStats(); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.message).toContain('network error'); + } + }); + + it('returns error when summary returns non-ok HTTP status', async () => { + global.fetch = vi.fn().mockResolvedValue({ + ok: false, + status: 503, + json: () => Promise.resolve({}), + }); + const result = await fetchOperationalStats(); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.message).toContain('503'); + } + }); + + it('falls back to empty trendDay when trend day fetch fails', async () => { + let callCount = 0; + global.fetch = vi.fn().mockImplementation((url: string) => { + callCount++; + if (url.includes('/v1/stats/summary')) { + return Promise.resolve({ ok: true, json: () => Promise.resolve(mockSummary) }); + } + if (url.includes('granularity=day')) { + return Promise.reject(new Error('day trend unavailable')); + } + if (url.includes('granularity=hour')) { + return Promise.resolve({ ok: true, json: () => Promise.resolve(mockTrendHour) }); + } + if (url.includes('recurrence')) { + return Promise.resolve({ ok: true, json: () => Promise.resolve(mockRecurrence) }); + } + return Promise.resolve({ ok: false, status: 500, json: () => Promise.resolve({}) }); + }); + + const result = await fetchOperationalStats(); + expect(result.ok).toBe(true); + if (result.ok) { + expect(result.trendDay.dates).toHaveLength(0); + expect(result.trendHour.granularity).toBe('hour'); + } + }); + + it('falls back to empty recurrence when recurrence fetch fails', async () => { + global.fetch = vi.fn().mockImplementation((url: string) => { + if (url.includes('/v1/stats/summary')) { + return Promise.resolve({ ok: true, json: () => Promise.resolve(mockSummary) }); + } + if (url.includes('granularity=day')) { + return Promise.resolve({ ok: true, json: () => Promise.resolve(mockTrendDay) }); + } + if (url.includes('granularity=hour')) { + return Promise.resolve({ ok: true, json: () => Promise.resolve(mockTrendHour) }); + } + if (url.includes('recurrence')) { + return Promise.reject(new Error('recurrence unavailable')); + } + return Promise.resolve({ ok: false, status: 500, json: () => Promise.resolve({}) }); + }); + + const result = await fetchOperationalStats(); + expect(result.ok).toBe(true); + if (result.ok) { + expect(result.recurrence.top).toHaveLength(0); + } + }); +}); diff --git a/admin-ui/test/lib/stats-data.test.ts b/admin-ui/test/lib/stats-data.test.ts new file mode 100644 index 0000000..0876f5b --- /dev/null +++ b/admin-ui/test/lib/stats-data.test.ts @@ -0,0 +1,67 @@ +import { describe, it, expect, vi } from 'vitest'; +import { aggregateIncidentKpisFromSummary } from '@/lib/stats-data'; +import type { StatsSummaryPayload } from '@/lib/stats-data'; + +import { fetchOperationalStats } from '@/lib/stats-data'; + +vi.mock('next/headers', () => ({ + cookies: vi.fn().mockResolvedValue({ get: vi.fn().mockReturnValue(undefined) }), +})); + +describe('fetchOperationalStats — not_configured', () => { + it('returns error when API is not configured', async () => { + delete process.env.ERROR_REPORTING_ADMIN_API_BASE; + const result = await fetchOperationalStats(); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(typeof result.message).toBe('string'); + } + }); +}); + +describe('aggregateIncidentKpisFromSummary', () => { + it('returns zeros for empty byProject list', () => { + const summary: StatsSummaryPayload = { byProject: [] }; + const result = aggregateIncidentKpisFromSummary(summary); + expect(result).toEqual({ total: 0, open: 0, investigating: 0, resolved: 0, ignored: 0 }); + }); + + it('sums across a single project', () => { + const summary: StatsSummaryPayload = { + byProject: [ + { projectSlug: 'proj-a', total: 10, open: 3, investigating: 2, resolved: 4, ignored: 1 }, + ], + }; + const result = aggregateIncidentKpisFromSummary(summary); + expect(result.total).toBe(10); + expect(result.open).toBe(3); + expect(result.investigating).toBe(2); + expect(result.resolved).toBe(4); + expect(result.ignored).toBe(1); + }); + + it('sums across multiple projects', () => { + const summary: StatsSummaryPayload = { + byProject: [ + { projectSlug: 'proj-a', total: 5, open: 2, investigating: 1, resolved: 1, ignored: 1 }, + { projectSlug: 'proj-b', total: 8, open: 4, investigating: 2, resolved: 2, ignored: 0 }, + ], + }; + const result = aggregateIncidentKpisFromSummary(summary); + expect(result.total).toBe(13); + expect(result.open).toBe(6); + expect(result.investigating).toBe(3); + expect(result.resolved).toBe(3); + expect(result.ignored).toBe(1); + }); + + it('handles projects with all zeros', () => { + const summary: StatsSummaryPayload = { + byProject: [ + { projectSlug: 'empty', total: 0, open: 0, investigating: 0, resolved: 0, ignored: 0 }, + ], + }; + const result = aggregateIncidentKpisFromSummary(summary); + expect(result.total).toBe(0); + }); +}); diff --git a/admin-ui/test/setup.ts b/admin-ui/test/setup.ts new file mode 100644 index 0000000..7b0828b --- /dev/null +++ b/admin-ui/test/setup.ts @@ -0,0 +1 @@ +import '@testing-library/jest-dom'; diff --git a/admin-ui/vitest.config.ts b/admin-ui/vitest.config.ts new file mode 100644 index 0000000..5143489 --- /dev/null +++ b/admin-ui/vitest.config.ts @@ -0,0 +1,23 @@ +import { defineConfig } from 'vitest/config'; +import react from '@vitejs/plugin-react'; +import path from 'node:path'; + +export default defineConfig({ + plugins: [react()], + test: { + environment: 'jsdom', + setupFiles: ['./test/setup.ts'], + globals: true, + coverage: { + provider: 'v8', + reporter: ['text', 'json', 'html'], + include: ['components/**/*.{ts,tsx}', 'lib/**/*.{ts,tsx}'], + exclude: ['**/*.d.ts', 'test/**'], + }, + }, + resolve: { + alias: { + '@': path.resolve(__dirname, '.'), + }, + }, +}); diff --git a/api/package-lock.json b/api/package-lock.json index ee7f5d1..b842d35 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -24,11 +24,83 @@ "devDependencies": { "@types/bcrypt": "^5.0.2", "@types/node": "^20.14.0", + "@vitest/coverage-v8": "^1.6.1", "tsx": "^4.15.6", "typescript": "^5.4.5", "vitest": "^1.6.0" } }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.2.tgz", + "integrity": "sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.0" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz", + "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true, + "license": "MIT" + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.27.4", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.4.tgz", @@ -629,6 +701,16 @@ "node": ">=12" } }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz", + "integrity": "sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/@jest/schemas": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", @@ -642,6 +724,27 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", @@ -649,6 +752,17 @@ "dev": true, "license": "MIT" }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, "node_modules/@lukeed/ms": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@lukeed/ms/-/ms-2.0.2.tgz", @@ -1086,6 +1200,34 @@ "undici-types": "~6.21.0" } }, + "node_modules/@vitest/coverage-v8": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-1.6.1.tgz", + "integrity": "sha512-6YeRZwuO4oTGKxD3bijok756oktHSIm3eczVVzNe3scqzuhLwltIF3S9ZL/vwOVIpURmU6SnZhziXXAfw8/Qlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.2.1", + "@bcoe/v8-coverage": "^0.2.3", + "debug": "^4.3.4", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-report": "^3.0.1", + "istanbul-lib-source-maps": "^5.0.4", + "istanbul-reports": "^3.1.6", + "magic-string": "^0.30.5", + "magicast": "^0.3.3", + "picocolors": "^1.0.0", + "std-env": "^3.5.0", + "strip-literal": "^2.0.0", + "test-exclude": "^6.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "vitest": "1.6.1" + } + }, "node_modules/@vitest/expect": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-1.6.1.tgz", @@ -2091,6 +2233,16 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/has-unicode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", @@ -2106,6 +2258,13 @@ "node": ">=16.0.0" } }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -2221,6 +2380,76 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "license": "ISC" }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report/node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-5.0.6.tgz", + "integrity": "sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.23", + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", + "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/jackspeak": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", @@ -2350,6 +2579,18 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/magicast": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.3.5.tgz", + "integrity": "sha512-L0WhttDl+2BOsybvEOLK7fW3UA0OQ0IQ2d6Zl2x/a6vVRs3bAY0ECOSHHeL5jD+SbOpOCUEi0y1DgHEn9Qn1AQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.25.4", + "@babel/types": "^7.25.4", + "source-map-js": "^1.2.0" + } + }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -3450,6 +3691,19 @@ "url": "https://github.com/sponsors/antfu" } }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/tar": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", @@ -3486,6 +3740,67 @@ "bintrees": "1.0.2" } }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "license": "ISC", + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude/node_modules/brace-expansion": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz", + "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/test-exclude/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/test-exclude/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/thread-stream": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-3.1.0.tgz", diff --git a/api/package.json b/api/package.json index 137bf13..937988d 100644 --- a/api/package.json +++ b/api/package.json @@ -30,9 +30,9 @@ "devDependencies": { "@types/bcrypt": "^5.0.2", "@types/node": "^20.14.0", + "@vitest/coverage-v8": "^1.6.1", "tsx": "^4.15.6", "typescript": "^5.4.5", - "@vitest/coverage-v8": "^1.6.0", "vitest": "^1.6.0" } } diff --git a/api/src/routes/admin/auth.test.ts b/api/src/routes/admin/auth.test.ts new file mode 100644 index 0000000..a20452d --- /dev/null +++ b/api/src/routes/admin/auth.test.ts @@ -0,0 +1,257 @@ +/** + * Tests for admin auth routes. + * Exercises login, refresh, logout, and /me without a live database. + */ +import { describe, it, expect, vi, beforeEach } from 'vitest'; +import Fastify, { type FastifyInstance } from 'fastify'; +import cookie from '@fastify/cookie'; +import jwt from '@fastify/jwt'; +import type { RowDataPacket } from 'mysql2'; +import adminAuthRoutes from './auth.js'; + +vi.mock('bcrypt', () => ({ + default: { + compare: vi.fn().mockResolvedValue(false), + hash: vi.fn(), + }, +})); + +vi.mock('../../plugins/audit.js', () => ({ + auditLog: vi.fn().mockResolvedValue(undefined), +})); + +import bcrypt from 'bcrypt'; +const mockBcrypt = vi.mocked(bcrypt); + +function makePool(executeFn?: (...args: unknown[]) => Promise) { + return { + execute: executeFn ?? vi.fn().mockResolvedValue([[] as RowDataPacket[]]), + getConnection: vi.fn(), + }; +} + +async function buildApp(pool?: ReturnType): Promise { + const app = Fastify({ logger: false }); + await app.register(cookie, { secret: 'test-cookie-secret' }); + await app.register(jwt, { + secret: 'test-jwt-secret', + cookie: { cookieName: '__Host-access', signed: false }, + }); + + const p = pool ?? makePool(); + app.decorate('db', p as unknown as FastifyInstance['db']); + app.decorate('rateLimits', { + login: { max: 10, timeWindow: 300_000 }, + ingest: { max: 1000, timeWindow: 60_000 }, + global: { max: 500, timeWindow: 60_000 }, + mutation: { max: 100, timeWindow: 60_000 }, + }); + app.decorate('authenticate', async function (req: Parameters[0]) { + (req as { auth: unknown }).auth = { user_id: 'u1', email: 'admin@example.com', role: 'admin' }; + }); + + await app.register(adminAuthRoutes); + return app; +} + +describe('POST /admin/auth/login', () => { + beforeEach(() => { + vi.mocked(mockBcrypt.compare).mockResolvedValue(false as never); + }); + + it('returns 400 for missing email field', async () => { + const app = await buildApp(); + const res = await app.inject({ + method: 'POST', + url: '/admin/auth/login', + payload: { password: 'secret' }, + }); + expect(res.statusCode).toBe(400); + }); + + it('returns 400 for invalid email format', async () => { + const app = await buildApp(); + const res = await app.inject({ + method: 'POST', + url: '/admin/auth/login', + payload: { email: 'not-an-email', password: 'secret' }, + }); + expect(res.statusCode).toBe(400); + }); + + it('returns 401 when user not found', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ + method: 'POST', + url: '/admin/auth/login', + payload: { email: 'nobody@example.com', password: 'pass' }, + }); + expect(res.statusCode).toBe(401); + expect(res.json()).toMatchObject({ error: 'Invalid credentials' }); + }); + + it('returns 401 when password is wrong', async () => { + const rows = [{ id: 'u1', email: 'admin@example.com', role: 'admin', password_hash: '$2b$hash', is_active: 1 }]; + const pool = makePool(vi.fn().mockResolvedValue([rows as unknown as RowDataPacket[]])); + vi.mocked(mockBcrypt.compare).mockResolvedValue(false as never); + const app = await buildApp(pool); + const res = await app.inject({ + method: 'POST', + url: '/admin/auth/login', + payload: { email: 'admin@example.com', password: 'wrongpass' }, + }); + expect(res.statusCode).toBe(401); + }); + + it('returns 401 when user is inactive', async () => { + const rows = [{ id: 'u1', email: 'admin@example.com', role: 'admin', password_hash: '$2b$hash', is_active: 0 }]; + const pool = makePool(vi.fn().mockResolvedValue([rows as unknown as RowDataPacket[]])); + vi.mocked(mockBcrypt.compare).mockResolvedValue(true as never); + const app = await buildApp(pool); + const res = await app.inject({ + method: 'POST', + url: '/admin/auth/login', + payload: { email: 'admin@example.com', password: 'pass' }, + }); + expect(res.statusCode).toBe(401); + }); + + it('returns 200 with user info on successful login', async () => { + const rows = [{ id: 'u1', email: 'admin@example.com', role: 'admin', password_hash: '$2b$hash', is_active: 1 }]; + const pool = makePool(vi.fn().mockResolvedValue([rows as unknown as RowDataPacket[]])); + vi.mocked(mockBcrypt.compare).mockResolvedValue(true as never); + const app = await buildApp(pool); + const res = await app.inject({ + method: 'POST', + url: '/admin/auth/login', + payload: { email: 'admin@example.com', password: 'correct' }, + }); + expect(res.statusCode).toBe(200); + expect(res.json()).toMatchObject({ user: { id: 'u1', email: 'admin@example.com', role: 'admin' } }); + }); +}); + +describe('POST /admin/auth/refresh', () => { + it('returns 401 when no refresh token cookie present', async () => { + const app = await buildApp(); + const res = await app.inject({ method: 'POST', url: '/admin/auth/refresh' }); + expect(res.statusCode).toBe(401); + expect(res.json()).toMatchObject({ error: 'No refresh token' }); + }); + + it('returns 401 when token hash not found in db', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ + method: 'POST', + url: '/admin/auth/refresh', + headers: { cookie: '__Host-refresh=sometoken' }, + }); + expect(res.statusCode).toBe(401); + expect(res.json()).toMatchObject({ error: 'Refresh token invalid or expired' }); + }); + + it('returns 401 when token is revoked', async () => { + const tokenRow = [{ + id: 't1', + user_id: 'u1', + expires_at: new Date(Date.now() + 1_000_000), + revoked_at: new Date(), + }]; + const pool = makePool(vi.fn().mockResolvedValue([tokenRow as unknown as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ + method: 'POST', + url: '/admin/auth/refresh', + headers: { cookie: '__Host-refresh=sometoken' }, + }); + expect(res.statusCode).toBe(401); + }); + + it('returns 401 when token is expired', async () => { + const tokenRow = [{ + id: 't1', + user_id: 'u1', + expires_at: new Date(Date.now() - 1_000), + revoked_at: null, + }]; + const pool = makePool(vi.fn().mockResolvedValue([tokenRow as unknown as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ + method: 'POST', + url: '/admin/auth/refresh', + headers: { cookie: '__Host-refresh=sometoken' }, + }); + expect(res.statusCode).toBe(401); + }); + + it('returns 401 when user no longer active after valid token', async () => { + const tokenRow = [{ id: 't1', user_id: 'u1', expires_at: new Date(Date.now() + 1_000_000), revoked_at: null }]; + const user: RowDataPacket[] = []; + const execute = vi.fn() + .mockResolvedValueOnce([tokenRow]) + .mockResolvedValueOnce([[]]) + .mockResolvedValue([user]); + const pool = makePool(execute); + const app = await buildApp(pool); + const res = await app.inject({ + method: 'POST', + url: '/admin/auth/refresh', + headers: { cookie: '__Host-refresh=sometoken' }, + }); + expect(res.statusCode).toBe(401); + expect(res.json()).toMatchObject({ error: 'User no longer active' }); + }); + + it('returns 200 with ok:true on valid refresh', async () => { + const tokenRow = [{ id: 't1', user_id: 'u1', expires_at: new Date(Date.now() + 1_000_000), revoked_at: null }]; + const userRow = [{ id: 'u1', email: 'admin@example.com', role: 'admin', is_active: 1 }]; + const execute = vi.fn() + .mockResolvedValueOnce([tokenRow]) + .mockResolvedValueOnce([[]]) + .mockResolvedValueOnce([userRow]) + .mockResolvedValue([[]]); + const pool = makePool(execute); + const app = await buildApp(pool); + const res = await app.inject({ + method: 'POST', + url: '/admin/auth/refresh', + headers: { cookie: '__Host-refresh=sometoken' }, + }); + expect(res.statusCode).toBe(200); + expect(res.json()).toMatchObject({ ok: true }); + }); +}); + +describe('POST /admin/auth/logout', () => { + it('returns 200 and clears cookies', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ + method: 'POST', + url: '/admin/auth/logout', + headers: { cookie: '__Host-refresh=sometoken' }, + }); + expect(res.statusCode).toBe(200); + expect(res.json()).toMatchObject({ ok: true }); + }); + + it('returns 200 even without refresh cookie', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'POST', url: '/admin/auth/logout' }); + expect(res.statusCode).toBe(200); + }); +}); + +describe('GET /admin/auth/me', () => { + it('returns current user info from auth context', async () => { + const app = await buildApp(); + const res = await app.inject({ method: 'GET', url: '/admin/auth/me' }); + expect(res.statusCode).toBe(200); + expect(res.json()).toMatchObject({ + user: { id: 'u1', email: 'admin@example.com', role: 'admin' }, + }); + }); +}); diff --git a/api/src/routes/admin/incidents.test.ts b/api/src/routes/admin/incidents.test.ts new file mode 100644 index 0000000..247506d --- /dev/null +++ b/api/src/routes/admin/incidents.test.ts @@ -0,0 +1,192 @@ +/** + * Tests for admin incident routes. + * Uses mock DB and bypassed auth decorators — no live database required. + */ +import { describe, it, expect, vi } from 'vitest'; +import Fastify, { type FastifyInstance } from 'fastify'; +import type { RowDataPacket } from 'mysql2'; +import adminIncidentsRoutes from './incidents.js'; + +function makePool(executeFn?: (...args: unknown[]) => Promise) { + return { + execute: executeFn ?? vi.fn().mockResolvedValue([[] as RowDataPacket[]]), + getConnection: vi.fn(), + }; +} + +async function buildApp(pool?: ReturnType): Promise { + const app = Fastify({ logger: false }); + const p = pool ?? makePool(); + app.decorate('db', p as unknown as FastifyInstance['db']); + app.decorate('authenticate', async function (req: Parameters[0]) { + (req as { auth: unknown }).auth = { user_id: 'u1', email: 'admin@example.com', role: 'admin' }; + }); + app.decorate('requirePermission', (_perm: string) => async (_req: unknown, _reply: unknown) => { + // passthrough — permission already granted by mock authenticate + }); + await app.register(adminIncidentsRoutes); + return app; +} + +const baseIncident = { + id: '42', + projectSlug: 'wdmi-store', + fingerprint: 'abc123', + title: 'Test error', + severity: 'high', + currentState: 'open', + firstSeenAt: '2026-01-01T00:00:00.000Z', + lastSeenAt: '2026-01-02T00:00:00.000Z', + occurrencesCount: 5, +}; + +describe('GET /v1/incidents', () => { + it('returns empty list when no incidents', async () => { + const app = await buildApp(); + const res = await app.inject({ method: 'GET', url: '/v1/incidents' }); + expect(res.statusCode).toBe(200); + expect(res.json()).toMatchObject({ incidents: [] }); + }); + + it('returns mapped incident list', async () => { + const row = { + id: '42', + projectSlug: 'wdmi-store', + fingerprint: 'abc123', + title: 'Test error', + severity: 'high', + currentState: 'open', + firstSeenAt: '2026-01-01T00:00:00.000Z', + lastSeenAt: '2026-01-02T00:00:00.000Z', + occurrencesCount: 5, + }; + const pool = makePool(vi.fn().mockResolvedValue([[row as unknown as RowDataPacket]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/incidents' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { incidents: typeof baseIncident[] }; + expect(body.incidents).toHaveLength(1); + expect(body.incidents[0]).toMatchObject({ id: '42', severity: 'high', currentState: 'open' }); + }); + + it('accepts valid state filter', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/incidents?state=resolved' }); + expect(res.statusCode).toBe(200); + }); + + it('accepts valid severity filter', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/incidents?severity=critical' }); + expect(res.statusCode).toBe(200); + }); + + it('accepts project slug filter', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/incidents?project=myproject' }); + expect(res.statusCode).toBe(200); + }); + + it('accepts search query filter', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/incidents?q=TypeError' }); + expect(res.statusCode).toBe(200); + }); + + it('accepts combined filters', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/incidents?state=open&severity=high&project=proj&q=crash' }); + expect(res.statusCode).toBe(200); + expect(res.json()).toMatchObject({ incidents: [] }); + }); +}); + +describe('GET /v1/incidents/:id', () => { + it('returns 404 for non-numeric id', async () => { + const app = await buildApp(); + const res = await app.inject({ method: 'GET', url: '/v1/incidents/abc-not-numeric' }); + expect(res.statusCode).toBe(404); + }); + + it('returns 404 when incident not found in db', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/incidents/9999' }); + expect(res.statusCode).toBe(404); + }); + + it('returns incident with occurrences on found', async () => { + const incidentRow = { + id: '42', + projectSlug: 'wdmi-store', + fingerprint: 'abc123', + title: 'Test error', + severity: 'high', + currentState: 'open', + firstSeenAt: '2026-01-01T00:00:00.000Z', + lastSeenAt: '2026-01-02T00:00:00.000Z', + occurrencesCount: 1, + metadataJson: null, + ingestKeyLabel: 'prod-key', + }; + const occurrenceRow = { + id: '1', + occurredAt: '2026-01-01T00:00:00.000Z', + levelRaw: 'error', + severity: 'high', + message: 'Something failed', + stacktrace: null, + contextJson: '{"env":"production"}', + }; + const execute = vi.fn() + .mockResolvedValueOnce([[incidentRow as unknown as RowDataPacket]]) + .mockResolvedValue([[occurrenceRow as unknown as RowDataPacket]]); + const pool = makePool(execute); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/incidents/42' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { incident: { id: string; occurrences: unknown[] } }; + expect(body.incident.id).toBe('42'); + expect(body.incident.occurrences).toHaveLength(1); + }); + + it('handles occurrence with null stacktrace and contextJson', async () => { + const incidentRow = { + id: '1', + projectSlug: 'proj', + fingerprint: 'fp', + title: 'err', + severity: 'low', + currentState: 'open', + firstSeenAt: '2026-01-01T00:00:00.000Z', + lastSeenAt: '2026-01-01T00:00:00.000Z', + occurrencesCount: 1, + metadataJson: '{"key":"val"}', + ingestKeyLabel: null, + }; + const occurrenceRow = { + id: '2', + occurredAt: '2026-01-01T00:00:00.000Z', + levelRaw: 'warn', + severity: 'low', + message: 'warn', + stacktrace: null, + contextJson: null, + }; + const execute = vi.fn() + .mockResolvedValueOnce([[incidentRow as unknown as RowDataPacket]]) + .mockResolvedValue([[occurrenceRow as unknown as RowDataPacket]]); + const pool = makePool(execute); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/incidents/1' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { incident: { metadataJson: unknown; ingestKeyLabel: unknown } }; + expect(body.incident.metadataJson).toMatchObject({ key: 'val' }); + expect(body.incident.ingestKeyLabel).toBeNull(); + }); +}); diff --git a/api/src/routes/admin/stats.test.ts b/api/src/routes/admin/stats.test.ts new file mode 100644 index 0000000..0c20704 --- /dev/null +++ b/api/src/routes/admin/stats.test.ts @@ -0,0 +1,245 @@ +/** + * Tests for admin stats routes. + * Uses mock DB and bypassed auth decorators — no live database required. + */ +import { describe, it, expect, vi } from 'vitest'; +import Fastify, { type FastifyInstance } from 'fastify'; +import type { RowDataPacket } from 'mysql2'; +import adminStatsRoutes from './stats.js'; + +function makePool(executeFn?: (...args: unknown[]) => Promise) { + return { + execute: executeFn ?? vi.fn().mockResolvedValue([[] as RowDataPacket[]]), + getConnection: vi.fn(), + }; +} + +async function buildApp(pool?: ReturnType): Promise { + const app = Fastify({ logger: false }); + const p = pool ?? makePool(); + app.decorate('db', p as unknown as FastifyInstance['db']); + app.decorate('authenticate', async function (req: Parameters[0]) { + (req as { auth: unknown }).auth = { user_id: 'u1', email: 'admin@example.com', role: 'admin' }; + }); + app.decorate('requirePermission', (_perm: string) => async (_req: unknown, _reply: unknown) => { + // passthrough + }); + await app.register(adminStatsRoutes); + return app; +} + +describe('GET /v1/stats/trend', () => { + it('returns day granularity by default with empty series', async () => { + const app = await buildApp(); + const res = await app.inject({ method: 'GET', url: '/v1/stats/trend' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { granularity: string; dates: string[]; series: Record }; + expect(body.granularity).toBe('day'); + expect(Array.isArray(body.dates)).toBe(true); + expect(body.dates.length).toBeGreaterThan(0); + expect(body.series).toHaveProperty('critical'); + expect(body.series).toHaveProperty('high'); + expect(body.series).toHaveProperty('low'); + expect(body.series).toHaveProperty('info'); + }); + + it('returns hour granularity when requested', async () => { + const app = await buildApp(); + const res = await app.inject({ method: 'GET', url: '/v1/stats/trend?granularity=hour&hours=5' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { granularity: string; hours: string[] }; + expect(body.granularity).toBe('hour'); + expect(body.hours).toHaveLength(5); + }); + + it('returns 404 when project slug not found for day granularity', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/trend?project=nonexistent' }); + expect(res.statusCode).toBe(404); + }); + + it('returns 404 when project slug not found for hour granularity', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/trend?granularity=hour&project=nonexistent' }); + expect(res.statusCode).toBe(404); + }); + + it('maps DB aggregate rows into series data for day granularity', async () => { + const today = new Date(); + const dateStr = today.toISOString().slice(0, 10); + const aggRow = { d: dateStr, severity: 'critical', c: 7 }; + const pool = makePool(vi.fn().mockResolvedValue([[aggRow as unknown as RowDataPacket]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/trend?days=3' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { series: Record }; + const criticalSeries = body.series['critical'] ?? []; + expect(criticalSeries.some((v) => v === 7)).toBe(true); + }); + + it('maps DB aggregate rows into series data for hour granularity', async () => { + const now = new Date(); + now.setUTCMinutes(0, 0, 0); + now.setUTCMilliseconds(0); + const y = now.getUTCFullYear(); + const mo = String(now.getUTCMonth() + 1).padStart(2, '0'); + const day = String(now.getUTCDate()).padStart(2, '0'); + const h = String(now.getUTCHours()).padStart(2, '0'); + const bucketLabel = `${y}-${mo}-${day} ${h}:00:00`; + const aggRow = { b: bucketLabel, severity: 'high', c: 3 }; + const pool = makePool(vi.fn().mockResolvedValue([[aggRow as unknown as RowDataPacket]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/trend?granularity=hour&hours=3' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { series: Record }; + expect(body.series['high']?.some((v) => v === 3)).toBe(true); + }); + + it('ignores unknown severity in aggregate rows', async () => { + const aggRow = { d: new Date().toISOString().slice(0, 10), severity: 'unknown-severity', c: 10 }; + const pool = makePool(vi.fn().mockResolvedValue([[aggRow as unknown as RowDataPacket]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/trend?days=1' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { series: Record }; + expect(body.series['critical']?.every((v) => v === 0)).toBe(true); + }); + + it('accepts days parameter for day granularity', async () => { + const app = await buildApp(); + const res = await app.inject({ method: 'GET', url: '/v1/stats/trend?days=7' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { dates: string[] }; + expect(body.dates).toHaveLength(7); + }); +}); + +describe('GET /v1/stats/summary', () => { + const defaultExecute = vi.fn() + .mockResolvedValueOnce([[{ slug: 'proj', total_incidents: 5, open_cnt: 2, investigating_cnt: 0, resolved_cnt: 3, ignored_cnt: 0, critical_cnt: 1 } as unknown as RowDataPacket]]) + .mockResolvedValueOnce([[{ severity: 'critical', c: 1 } as unknown as RowDataPacket]]) + .mockResolvedValueOnce([[{ c: 2 } as unknown as RowDataPacket]]) + .mockResolvedValue([[{ c: 10 } as unknown as RowDataPacket]]); + + it('returns byProject, bySeverity, resolvedLast24h, totalLast24h', async () => { + const execute = vi.fn() + .mockResolvedValueOnce([[{ slug: 'proj', total_incidents: 5, open_cnt: 2, investigating_cnt: 0, resolved_cnt: 3, ignored_cnt: 0, critical_cnt: 1 } as unknown as RowDataPacket]]) + .mockResolvedValueOnce([[{ severity: 'high', c: 4 } as unknown as RowDataPacket]]) + .mockResolvedValueOnce([[{ c: 2 } as unknown as RowDataPacket]]) + .mockResolvedValue([[{ c: 10 } as unknown as RowDataPacket]]); + const pool = makePool(execute); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/summary' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { byProject: unknown[]; bySeverity: Record; resolvedLast24h: number; totalLast24h: number }; + expect(body.byProject).toHaveLength(1); + expect(body.bySeverity.high).toBe(4); + expect(body.resolvedLast24h).toBe(2); + expect(body.totalLast24h).toBe(10); + }); + + it('returns 404 when project slug not found', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/summary?project=nonexistent' }); + expect(res.statusCode).toBe(404); + }); + + it('handles empty results gracefully', async () => { + const execute = vi.fn().mockResolvedValue([[] as RowDataPacket[]]); + const pool = makePool(execute); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/summary' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { byProject: unknown[]; bySeverity: Record; resolvedLast24h: number; totalLast24h: number }; + expect(body.byProject).toHaveLength(0); + expect(body.resolvedLast24h).toBe(0); + expect(body.totalLast24h).toBe(0); + }); + + it('skips unknown severity values from summary rows', async () => { + const execute = vi.fn() + .mockResolvedValueOnce([[]]) + .mockResolvedValueOnce([[{ severity: 'badvalue', c: 99 } as unknown as RowDataPacket]]) + .mockResolvedValueOnce([[{ c: 0 } as unknown as RowDataPacket]]) + .mockResolvedValue([[{ c: 0 } as unknown as RowDataPacket]]); + const pool = makePool(execute); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/summary' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { bySeverity: Record }; + expect(body.bySeverity.critical).toBe(0); + }); + + it('accepts valid project filter when project exists', async () => { + const execute = vi.fn() + .mockResolvedValueOnce([[{ ok: 1 } as unknown as RowDataPacket]]) + .mockResolvedValueOnce([[]]) + .mockResolvedValueOnce([[]]) + .mockResolvedValueOnce([[{ c: 0 } as unknown as RowDataPacket]]) + .mockResolvedValue([[{ c: 0 } as unknown as RowDataPacket]]); + const pool = makePool(execute); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/summary?project=myproject' }); + expect(res.statusCode).toBe(200); + }); +}); + +describe('GET /v1/stats/recurrence', () => { + it('returns empty top list when no occurrences', async () => { + const app = await buildApp(); + const res = await app.inject({ method: 'GET', url: '/v1/stats/recurrence' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { top: unknown[]; windowDays: number }; + expect(body.top).toHaveLength(0); + expect(body.windowDays).toBe(7); + }); + + it('maps top incidents correctly', async () => { + const row = { + id: '1', + project_slug: 'proj', + fingerprint: 'fp1', + title: 'Crash in module', + severity: 'critical', + current_state: 'open', + hits_in_window: 42, + lifetime_occurrences: 100, + }; + const pool = makePool(vi.fn().mockResolvedValue([[row as unknown as RowDataPacket]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/recurrence?days=14&limit=5' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { top: Array<{ hitsInWindow: number; lifetimeOccurrences: number }> }; + expect(body.top[0]?.hitsInWindow).toBe(42); + expect(body.top[0]?.lifetimeOccurrences).toBe(100); + }); + + it('returns 404 when project slug not found', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/recurrence?project=nonexistent' }); + expect(res.statusCode).toBe(404); + }); + + it('accepts valid project when it exists', async () => { + const execute = vi.fn() + .mockResolvedValueOnce([[{ ok: 1 } as unknown as RowDataPacket]]) + .mockResolvedValue([[] as RowDataPacket[]]); + const pool = makePool(execute); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/recurrence?project=validproject' }); + expect(res.statusCode).toBe(200); + }); + + it('uses default days=7 and limit=15 when not specified', async () => { + const pool = makePool(vi.fn().mockResolvedValue([[] as RowDataPacket[]])); + const app = await buildApp(pool); + const res = await app.inject({ method: 'GET', url: '/v1/stats/recurrence' }); + expect(res.statusCode).toBe(200); + const body = res.json() as { windowDays: number }; + expect(body.windowDays).toBe(7); + }); +}); diff --git a/api/src/routes/public/errorMonitoringStats.test.ts b/api/src/routes/public/errorMonitoringStats.test.ts new file mode 100644 index 0000000..1f6b5d6 --- /dev/null +++ b/api/src/routes/public/errorMonitoringStats.test.ts @@ -0,0 +1,230 @@ +/** + * Tests for GET /api/error-monitoring/stats + * Uses the same in-process Fastify injection pattern as other route tests. + */ +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import Fastify, { type FastifyInstance } from 'fastify'; +import type { RowDataPacket } from 'mysql2'; +import errorMonitoringStatsRoutes from './errorMonitoringStats.js'; + +vi.mock('../../plugins/prometheus.js', () => ({ + metricsGauges: { + occurrences24hGauge: { set: vi.fn() }, + resolved24hGauge: { set: vi.fn() }, + incidentsBySeverityGauge: { labels: vi.fn().mockReturnValue({ set: vi.fn() }) }, + incidentsTotalGauge: { labels: vi.fn().mockReturnValue({ set: vi.fn() }) }, + projectIncidentsGauge: { + reset: vi.fn(), + labels: vi.fn().mockReturnValue({ set: vi.fn() }), + }, + projectResolutionRateGauge: { + reset: vi.fn(), + labels: vi.fn().mockReturnValue({ set: vi.fn() }), + }, + }, +})); + +function makeExecute(responses: unknown[][]) { + let call = 0; + return vi.fn().mockImplementation(() => Promise.resolve([responses[call++] ?? []])); +} + +async function buildApp(execute: ReturnType): Promise { + const app = Fastify({ logger: false }); + app.decorate('db', { execute } as unknown as FastifyInstance['db']); + await app.register(errorMonitoringStatsRoutes); + return app; +} + +const PREV_KEY = process.env.ERROR_RESOLVE_API_KEY; + +beforeEach(() => { + process.env.ERROR_RESOLVE_API_KEY = 'test-stats-key'; +}); + +afterEach(() => { + if (PREV_KEY === undefined) { + delete process.env.ERROR_RESOLVE_API_KEY; + } else { + process.env.ERROR_RESOLVE_API_KEY = PREV_KEY; + } +}); + +describe('GET /api/error-monitoring/stats', () => { + function makeDefaultExecute() { + return makeExecute([ + // sevRows + [ + { severity: 'critical', c: 5 } as RowDataPacket, + { severity: 'high', c: 10 } as RowDataPacket, + { severity: 'unknown_sev', c: 1 } as RowDataPacket, + ], + // stateRows + [ + { state: 'open', c: 8 } as RowDataPacket, + { state: 'resolved', c: 7 } as RowDataPacket, + ], + // vol24h + [{ c: 42 } as RowDataPacket], + // res24h + [{ c: 3 } as RowDataPacket], + // hourlyRows + [ + { hour_bucket: '2026-01-01 00:00:00', severity: 'high', cnt: 2 } as RowDataPacket, + { hour_bucket: '2026-01-01 00:00:00', severity: 'bad_sev', cnt: 1 } as RowDataPacket, + ], + // projRows + [ + { + slug: 'wdmi', + total: 10, + open_cnt: 3, + investigating_cnt: 2, + resolved_cnt: 4, + ignored_cnt: 1, + critical_cnt: 2, + } as RowDataPacket, + ], + ]); + } + + it('returns 401 without a valid api_key', async () => { + const execute = makeExecute([]); + const app = await buildApp(execute); + const res = await app.inject({ method: 'GET', url: '/api/error-monitoring/stats' }); + expect(res.statusCode).toBe(401); + }); + + it('returns 200 with api_key query param', async () => { + const execute = makeDefaultExecute(); + const app = await buildApp(execute); + const res = await app.inject({ + method: 'GET', + url: '/api/error-monitoring/stats?api_key=test-stats-key', + }); + expect(res.statusCode).toBe(200); + }); + + it('returns correct bySeverity counts', async () => { + const execute = makeDefaultExecute(); + const app = await buildApp(execute); + const res = await app.inject({ + method: 'GET', + url: '/api/error-monitoring/stats?api_key=test-stats-key', + }); + const body = res.json<{ bySeverity: Record }>(); + expect(body.bySeverity.critical).toBe(5); + expect(body.bySeverity.high).toBe(10); + expect(body.bySeverity.medium).toBe(0); + expect(body.bySeverity.low).toBe(0); + expect(body.bySeverity.info).toBe(0); + }); + + it('returns correct byState counts', async () => { + const execute = makeDefaultExecute(); + const app = await buildApp(execute); + const res = await app.inject({ + method: 'GET', + url: '/api/error-monitoring/stats?api_key=test-stats-key', + }); + const body = res.json<{ byState: Record }>(); + expect(body.byState.open).toBe(8); + expect(body.byState.resolved).toBe(7); + }); + + it('returns correct 24h ingestion volume', async () => { + const execute = makeDefaultExecute(); + const app = await buildApp(execute); + const res = await app.inject({ + method: 'GET', + url: '/api/error-monitoring/stats?api_key=test-stats-key', + }); + const body = res.json<{ ingestion: { last24h: number; resolvedLast24h: number } }>(); + expect(body.ingestion.last24h).toBe(42); + expect(body.ingestion.resolvedLast24h).toBe(3); + }); + + it('returns 24-entry hourlyTrend array (zero-filled)', async () => { + const execute = makeDefaultExecute(); + const app = await buildApp(execute); + const res = await app.inject({ + method: 'GET', + url: '/api/error-monitoring/stats?api_key=test-stats-key', + }); + const body = res.json<{ ingestion: { hourlyTrend: unknown[] } }>(); + expect(body.ingestion.hourlyTrend).toHaveLength(24); + }); + + it('returns correct per-project metrics with resolutionRate', async () => { + const execute = makeDefaultExecute(); + const app = await buildApp(execute); + const res = await app.inject({ + method: 'GET', + url: '/api/error-monitoring/stats?api_key=test-stats-key', + }); + const body = res.json<{ + projects: Array<{ slug: string; total: number; resolved: number; resolutionRate: number }>; + }>(); + expect(body.projects).toHaveLength(1); + const proj = body.projects[0]; + expect(proj.slug).toBe('wdmi'); + expect(proj.total).toBe(10); + expect(proj.resolved).toBe(4); + expect(proj.resolutionRate).toBe(0.4); + }); + + it('returns resolutionRate of 0 when total is 0', async () => { + const execute = makeExecute([ + [], + [], + [{ c: 0 } as RowDataPacket], + [{ c: 0 } as RowDataPacket], + [], + [ + { + slug: 'empty-proj', + total: 0, + open_cnt: 0, + investigating_cnt: 0, + resolved_cnt: 0, + ignored_cnt: 0, + critical_cnt: 0, + } as RowDataPacket, + ], + ]); + const app = await buildApp(execute); + const res = await app.inject({ + method: 'GET', + url: '/api/error-monitoring/stats?api_key=test-stats-key', + }); + const body = res.json<{ projects: Array<{ resolutionRate: number }> }>(); + expect(body.projects[0].resolutionRate).toBe(0); + }); + + it('returns 401 with wrong api_key', async () => { + const execute = makeExecute([]); + const app = await buildApp(execute); + const res = await app.inject({ + method: 'GET', + url: '/api/error-monitoring/stats?api_key=wrong-key', + }); + expect(res.statusCode).toBe(401); + }); + + it('accepts view_errors query param when DEBUG_VIEW_ERRORS_KEY is set', async () => { + const prevViewKey = process.env.DEBUG_VIEW_ERRORS_KEY; + process.env.DEBUG_VIEW_ERRORS_KEY = 'view-only-key'; + try { + const execute = makeDefaultExecute(); + const app = await buildApp(execute); + const res = await app.inject({ + method: 'GET', + url: '/api/error-monitoring/stats?view_errors=view-only-key', + }); + expect(res.statusCode).toBe(200); + } finally { + if (prevViewKey === undefined) delete process.env.DEBUG_VIEW_ERRORS_KEY; + else process.env.DEBUG_VIEW_ERRORS_KEY = prevViewKey; + } + }); +}); diff --git a/collector-worker/package-lock.json b/collector-worker/package-lock.json index 2c23969..1897579 100644 --- a/collector-worker/package-lock.json +++ b/collector-worker/package-lock.json @@ -13,6 +13,7 @@ }, "devDependencies": { "@types/node": "^22.9.0", + "@vitest/coverage-v8": "^2.1.9", "tsx": "^4.19.2", "typescript": "^5.6.3", "vitest": "^2.1.0" @@ -21,6 +22,77 @@ "node": ">=20" } }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.2.tgz", + "integrity": "sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.0" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz", + "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true, + "license": "MIT" + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.27.4", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.4.tgz", @@ -463,6 +535,55 @@ "node": ">=18" } }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz", + "integrity": "sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", @@ -470,6 +591,28 @@ "dev": true, "license": "MIT" }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.59.1", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.59.1.tgz", @@ -836,6 +979,39 @@ "undici-types": "~6.21.0" } }, + "node_modules/@vitest/coverage-v8": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-2.1.9.tgz", + "integrity": "sha512-Z2cOr0ksM00MpEfyVE8KXIYPEcBFxdbLSs56L8PO0QQMxt/6bDj45uQfxoc96v05KW3clk7vvgP0qfDit9DmfQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.3.0", + "@bcoe/v8-coverage": "^0.2.3", + "debug": "^4.3.7", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-report": "^3.0.1", + "istanbul-lib-source-maps": "^5.0.6", + "istanbul-reports": "^3.1.7", + "magic-string": "^0.30.12", + "magicast": "^0.3.5", + "std-env": "^3.8.0", + "test-exclude": "^7.0.1", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/browser": "2.1.9", + "vitest": "2.1.9" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + } + } + }, "node_modules/@vitest/expect": { "version": "2.1.9", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.9.tgz", @@ -949,6 +1125,32 @@ "url": "https://opencollective.com/vitest" } }, + "node_modules/ansi-regex": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", + "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/assertion-error": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", @@ -968,6 +1170,29 @@ "node": ">= 6.0.0" } }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/brace-expansion": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz", + "integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + } + }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -1005,6 +1230,41 @@ "node": ">= 16" } }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -1054,6 +1314,20 @@ "url": "https://dotenvx.com" } }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true, + "license": "MIT" + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true, + "license": "MIT" + }, "node_modules/es-module-lexer": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", @@ -1123,6 +1397,23 @@ "node": ">=12.0.0" } }, + "node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "dev": true, + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -1160,6 +1451,78 @@ "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" } }, + "node_modules/glob": { + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", + "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.0.tgz", + "integrity": "sha512-TN1kCZAgdgweJhWWpgKYrQaMNHcDULHkWwQIspdtjV4Y5aurRdZpjAqn6yX3FPqTA9ngHCc4hJxMAMgGfve85w==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", + "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.2" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, "node_modules/iconv-lite": { "version": "0.7.2", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", @@ -1176,12 +1539,99 @@ "url": "https://opencollective.com/express" } }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/is-property": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", "integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==", "license": "MIT" }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-5.0.6.tgz", + "integrity": "sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.23", + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", + "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, "node_modules/long": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz", @@ -1195,6 +1645,13 @@ "dev": true, "license": "MIT" }, + "node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, "node_modules/lru.min": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.4.tgz", @@ -1220,6 +1677,60 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/magicast": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.3.5.tgz", + "integrity": "sha512-L0WhttDl+2BOsybvEOLK7fW3UA0OQ0IQ2d6Zl2x/a6vVRs3bAY0ECOSHHeL5jD+SbOpOCUEi0y1DgHEn9Qn1AQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.25.4", + "@babel/types": "^7.25.4", + "source-map-js": "^1.2.0" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimatch": { + "version": "10.2.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", + "integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.5" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -1280,6 +1791,40 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/pathe": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", @@ -1394,6 +1939,42 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "license": "MIT" }, + "node_modules/semver": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/siginfo": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", @@ -1401,6 +1982,19 @@ "dev": true, "license": "ISC" }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -1440,6 +2034,138 @@ "dev": true, "license": "MIT" }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.2.tgz", + "integrity": "sha512-u9E6A+ZDYdp7a4WnarkXPZOx8Ilz46+kby6p1yZ8zsGTz9gYa6FIS7lj2oezzNKmtdyyJNNmmXDppga5GB7kSw==", + "dev": true, + "license": "ISC", + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^10.4.1", + "minimatch": "^10.2.2" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/tinybench": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", @@ -2103,6 +2829,22 @@ } } }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/why-is-node-running": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", @@ -2119,6 +2861,104 @@ "engines": { "node": ">=8" } + }, + "node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } } } } diff --git a/collector-worker/package.json b/collector-worker/package.json index 881298e..7531bee 100644 --- a/collector-worker/package.json +++ b/collector-worker/package.json @@ -19,9 +19,9 @@ }, "devDependencies": { "@types/node": "^22.9.0", + "@vitest/coverage-v8": "^2.1.9", "tsx": "^4.19.2", "typescript": "^5.6.3", - "@vitest/coverage-v8": "^2.1.0", "vitest": "^2.1.0" }, "engines": { diff --git a/collector-worker/src/db/collectorRunWriter.test.ts b/collector-worker/src/db/collectorRunWriter.test.ts new file mode 100644 index 0000000..b3c6ca8 --- /dev/null +++ b/collector-worker/src/db/collectorRunWriter.test.ts @@ -0,0 +1,139 @@ +/** + * Tests for collectorRunWriter DB helpers. + */ +import { describe, it, expect, vi } from 'vitest'; +import type { ResultSetHeader } from 'mysql2'; +import { + insertRunStarted, + finishRun, + markSourceSuccess, + markSourceFailure, +} from './collectorRunWriter.js'; + +function makeClient(insertId: number | bigint = 42, overrides: Partial<{ + execute: ReturnType; +}> = {}) { + return { + execute: overrides.execute ?? vi.fn().mockResolvedValue([{ insertId } as ResultSetHeader]), + }; +} + +function makePool() { + return { + execute: vi.fn().mockResolvedValue([{ affectedRows: 1 } as ResultSetHeader]), + }; +} + +describe('insertRunStarted', () => { + it('returns stringified insertId on success', async () => { + const client = makeClient(99); + const result = await insertRunStarted(client as never, { + collectorSourceId: 'src-1', + projectId: 'proj-1', + }); + expect(result).toBe('99'); + }); + + it('executes the INSERT statement with correct args', async () => { + const client = makeClient(1); + await insertRunStarted(client as never, { + collectorSourceId: 'src-abc', + projectId: 'proj-xyz', + }); + expect(client.execute).toHaveBeenCalledWith( + expect.stringContaining('INSERT INTO er_collector_runs'), + ['src-abc', 'proj-xyz'], + ); + }); + + it('throws when insertId is zero', async () => { + const client = makeClient(0); + await expect( + insertRunStarted(client as never, { collectorSourceId: 's', projectId: 'p' }), + ).rejects.toThrow('collector_run_insert_failed'); + }); + + it('throws when insertId is not a number', async () => { + const client = { + execute: vi.fn().mockResolvedValue([{ insertId: undefined }]), + }; + await expect( + insertRunStarted(client as never, { collectorSourceId: 's', projectId: 'p' }), + ).rejects.toThrow('collector_run_insert_failed'); + }); + + it('handles bigint insertId', async () => { + const client = makeClient(BigInt(123)); + const result = await insertRunStarted(client as never, { + collectorSourceId: 's', + projectId: 'p', + }); + expect(result).toBe('123'); + }); +}); + +describe('finishRun', () => { + it('executes UPDATE with all fields', async () => { + const client = { execute: vi.fn().mockResolvedValue([{}]) }; + await finishRun(client as never, { + runId: '42', + status: 'success', + fetchedCount: 10, + acceptedCount: 9, + deduplicatedCount: 1, + failedCount: 0, + errorSummary: null, + }); + expect(client.execute).toHaveBeenCalledWith( + expect.stringContaining('UPDATE er_collector_runs'), + ['success', 10, 9, 1, 0, null, '42'], + ); + }); + + it('accepts partial/failed status', async () => { + const client = { execute: vi.fn().mockResolvedValue([{}]) }; + await finishRun(client as never, { + runId: '7', + status: 'failed', + fetchedCount: 0, + acceptedCount: 0, + deduplicatedCount: 0, + failedCount: 3, + errorSummary: 'timeout', + }); + expect(client.execute).toHaveBeenCalledWith( + expect.any(String), + ['failed', 0, 0, 0, 3, 'timeout', '7'], + ); + }); +}); + +describe('markSourceSuccess', () => { + it('executes UPDATE on correct table', async () => { + const pool = makePool(); + await markSourceSuccess(pool as never, 'src-id-1'); + expect(pool.execute).toHaveBeenCalledWith( + expect.stringContaining('UPDATE er_collector_sources'), + ['src-id-1'], + ); + }); +}); + +describe('markSourceFailure', () => { + it('executes UPDATE with message and sourceId', async () => { + const pool = makePool(); + await markSourceFailure(pool as never, { sourceId: 'src-2', message: 'connection refused' }); + expect(pool.execute).toHaveBeenCalledWith( + expect.stringContaining('UPDATE er_collector_sources'), + ['connection refused', 'src-2'], + ); + }); + + it('truncates error message at 4000 chars', async () => { + const pool = makePool(); + const longMsg = 'x'.repeat(5000); + await markSourceFailure(pool as never, { sourceId: 's', message: longMsg }); + const callArgs = pool.execute.mock.calls[0] as [string, [string, string]]; + expect(callArgs[1][0]).toHaveLength(4000); + }); +}); diff --git a/collector-worker/src/db/loadActiveSources.test.ts b/collector-worker/src/db/loadActiveSources.test.ts new file mode 100644 index 0000000..cb99d24 --- /dev/null +++ b/collector-worker/src/db/loadActiveSources.test.ts @@ -0,0 +1,76 @@ +/** + * Tests for loadActiveSources — DB query and row mapping. + */ +import { describe, it, expect, vi } from 'vitest'; +import type { RowDataPacket } from 'mysql2'; +import { loadActiveSources } from './loadActiveSources.js'; + +function makePool(rows: RowDataPacket[]) { + return { + execute: vi.fn().mockResolvedValue([rows]), + }; +} + +const dbRow = (overrides: Partial = {}): RowDataPacket => + ({ + id: '1', + project_id: '42', + name: 'My Source', + source_type: 'http_poll', + endpoint_uri: 'https://example.com/events', + auth_secret_ref: 'secret/token', + poll_interval_seconds: '30', + ...overrides, + }) as RowDataPacket; + +describe('loadActiveSources', () => { + it('returns empty array when no rows', async () => { + const pool = makePool([]); + const result = await loadActiveSources(pool as never); + expect(result).toHaveLength(0); + }); + + it('maps DB row fields to CollectorSourceRow', async () => { + const pool = makePool([dbRow()]); + const [source] = await loadActiveSources(pool as never); + expect(source.id).toBe('1'); + expect(source.project_id).toBe('42'); + expect(source.name).toBe('My Source'); + expect(source.source_type).toBe('http_poll'); + expect(source.endpoint_uri).toBe('https://example.com/events'); + expect(source.auth_secret_ref).toBe('secret/token'); + expect(source.poll_interval_seconds).toBe(30); + }); + + it('parses poll_interval_seconds as integer', async () => { + const pool = makePool([dbRow({ poll_interval_seconds: '60' })]); + const [source] = await loadActiveSources(pool as never); + expect(source.poll_interval_seconds).toBe(60); + expect(typeof source.poll_interval_seconds).toBe('number'); + }); + + it('preserves null auth_secret_ref', async () => { + const pool = makePool([dbRow({ auth_secret_ref: null })]); + const [source] = await loadActiveSources(pool as never); + expect(source.auth_secret_ref).toBeNull(); + }); + + it('maps multiple rows', async () => { + const pool = makePool([ + dbRow({ id: '1', name: 'Source A' }), + dbRow({ id: '2', name: 'Source B' }), + ]); + const result = await loadActiveSources(pool as never); + expect(result).toHaveLength(2); + expect(result[0].name).toBe('Source A'); + expect(result[1].name).toBe('Source B'); + }); + + it('queries only active sources', async () => { + const pool = makePool([]); + await loadActiveSources(pool as never); + expect(pool.execute).toHaveBeenCalledWith( + expect.stringContaining('is_active = TRUE'), + ); + }); +}); diff --git a/collector-worker/src/scheduler/runHttpSourceOnce.test.ts b/collector-worker/src/scheduler/runHttpSourceOnce.test.ts new file mode 100644 index 0000000..3180c8c --- /dev/null +++ b/collector-worker/src/scheduler/runHttpSourceOnce.test.ts @@ -0,0 +1,223 @@ +/** + * Unit tests for runHttpSourceOnce — covers the main state machine paths + * without network or DB access. + */ +import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { runHttpSourceOnce } from './runHttpSourceOnce.js'; +import type { SourceRuntimeState } from './sourceState.js'; +import type { CollectorSourceRow } from '../types/ingest.js'; + +vi.mock('../auth/resolveSecret.js', () => ({ + resolveIngestToken: vi.fn(), +})); +vi.mock('../db/collectorRunWriter.js', () => ({ + insertRunStarted: vi.fn(), + finishRun: vi.fn(), + markSourceSuccess: vi.fn(), + markSourceFailure: vi.fn(), +})); +vi.mock('../poll/fetchHttpEvents.js', () => ({ + fetchHttpPollEvents: vi.fn(), +})); +vi.mock('../ingest/pushEvents.js', () => ({ + pushEventsToIngest: vi.fn(), +})); +vi.mock('../log/structuredLog.js', () => ({ + logInfo: vi.fn(), + logError: vi.fn(), +})); + +import { resolveIngestToken } from '../auth/resolveSecret.js'; +import { + insertRunStarted, + finishRun, + markSourceSuccess, + markSourceFailure, +} from '../db/collectorRunWriter.js'; +import { fetchHttpPollEvents } from '../poll/fetchHttpEvents.js'; +import { pushEventsToIngest } from '../ingest/pushEvents.js'; + +const mockInsertRunStarted = vi.mocked(insertRunStarted); +const mockFetchHttpPollEvents = vi.mocked(fetchHttpPollEvents); +const mockResolveIngestToken = vi.mocked(resolveIngestToken); +const mockPushEventsToIngest = vi.mocked(pushEventsToIngest); +const mockMarkSourceSuccess = vi.mocked(markSourceSuccess); +const mockMarkSourceFailure = vi.mocked(markSourceFailure); +const mockFinishRun = vi.mocked(finishRun); + +function makeClient() { + return { + beginTransaction: vi.fn().mockResolvedValue(undefined), + execute: vi.fn().mockResolvedValue([{ insertId: 1 }]), + commit: vi.fn().mockResolvedValue(undefined), + rollback: vi.fn().mockResolvedValue(undefined), + release: vi.fn(), + }; +} + +function makePool() { + const client = makeClient(); + return { + _client: client, + execute: vi.fn().mockResolvedValue([{ affectedRows: 1 }]), + getConnection: vi.fn().mockResolvedValue(client), + }; +} + +const baseEnv = { + HTTP_FETCH_TIMEOUT_MS: 10000, + INGEST_BASE_URL: 'http://ingest.local', + INGEST_PUSH_TIMEOUT_MS: 10000, + INGEST_PUSH_MAX_RETRIES: 2, + INGEST_PUSH_RETRY_BASE_MS: 100, + INGEST_PUSH_RETRY_MAX_JITTER_MS: 50, + MAX_BACKOFF_EXPONENT: 6, + INGEST_RATE_LIMIT_MAX: 500, + INGEST_RATE_LIMIT_WINDOW_MS: 60000, + INGEST_ANON_IP_MAX: 20, + INGEST_ANON_IP_WINDOW_MS: 60000, + NODE_ENV: 'test', +}; + +const baseSource: CollectorSourceRow = { + id: 'src-1', + project_id: 'proj-1', + name: 'Test Source', + source_type: 'http_poll', + endpoint_uri: 'https://example.com/events', + auth_secret_ref: 'secret/token', + poll_interval_seconds: 60, +}; + +function makeState(): SourceRuntimeState { + return { consecutiveFailures: 0, nextAtMs: 0 }; +} + +beforeEach(() => { + vi.clearAllMocks(); + mockInsertRunStarted.mockResolvedValue('run-42'); +}); + +describe('runHttpSourceOnce — run start failure', () => { + it('marks failure and increments consecutiveFailures when DB insert throws', async () => { + const pool = makePool(); + pool._client.commit.mockRejectedValue(new Error('DB down')); + mockInsertRunStarted.mockRejectedValue(new Error('DB down')); + + const state = makeState(); + await runHttpSourceOnce({ pool: pool as never, env: baseEnv as never, source: baseSource, state }); + + expect(state.consecutiveFailures).toBe(1); + expect(mockMarkSourceFailure).toHaveBeenCalledWith(pool, { + sourceId: 'src-1', + message: 'DB down', + }); + }); +}); + +describe('runHttpSourceOnce — fetch failure', () => { + it('increments failure count and marks source failure when HTTP fetch fails', async () => { + const pool = makePool(); + mockFetchHttpPollEvents.mockResolvedValue({ ok: false, error: 'connection refused' }); + + const state = makeState(); + await runHttpSourceOnce({ pool: pool as never, env: baseEnv as never, source: baseSource, state }); + + expect(state.consecutiveFailures).toBe(1); + expect(mockMarkSourceFailure).toHaveBeenCalledWith(pool, { + sourceId: 'src-1', + message: 'connection refused', + }); + }); +}); + +describe('runHttpSourceOnce — missing token', () => { + it('marks failure when ingest token cannot be resolved', async () => { + const pool = makePool(); + mockFetchHttpPollEvents.mockResolvedValue({ + ok: true, + events: [{ schema_version: 1, occurred_at: '2026-01-01T00:00:00Z', level: 'error', message: 'err' }], + }); + mockResolveIngestToken.mockReturnValue(null); + + const state = makeState(); + await runHttpSourceOnce({ pool: pool as never, env: baseEnv as never, source: baseSource, state }); + + expect(state.consecutiveFailures).toBe(1); + expect(mockMarkSourceFailure).toHaveBeenCalledWith(pool, { + sourceId: 'src-1', + message: 'missing_ingest_token', + }); + }); +}); + +describe('runHttpSourceOnce — empty events', () => { + it('marks success and resets consecutiveFailures when fetch returns 0 events', async () => { + const pool = makePool(); + mockFetchHttpPollEvents.mockResolvedValue({ ok: true, events: [] }); + mockResolveIngestToken.mockReturnValue('test-token'); + + const state = makeState(); + state.consecutiveFailures = 3; + + await runHttpSourceOnce({ pool: pool as never, env: baseEnv as never, source: baseSource, state }); + + expect(state.consecutiveFailures).toBe(0); + expect(mockMarkSourceSuccess).toHaveBeenCalledWith(pool, 'src-1'); + expect(mockFinishRun).toHaveBeenCalledWith( + expect.anything(), + expect.objectContaining({ status: 'success', fetchedCount: 0 }), + ); + }); +}); + +describe('runHttpSourceOnce — push failure', () => { + it('marks failure when push to ingest API fails', async () => { + const pool = makePool(); + const events = [ + { schema_version: 1, occurred_at: '2026-01-01T00:00:00Z', level: 'error', message: 'e1' }, + ]; + mockFetchHttpPollEvents.mockResolvedValue({ ok: true, events }); + mockResolveIngestToken.mockReturnValue('test-token'); + mockPushEventsToIngest.mockResolvedValue({ + ok: false, + error: 'HTTP 503', + status: 503, + attempts: 3, + }); + + const state = makeState(); + await runHttpSourceOnce({ pool: pool as never, env: baseEnv as never, source: baseSource, state }); + + expect(state.consecutiveFailures).toBe(1); + expect(mockMarkSourceFailure).toHaveBeenCalledWith(pool, { + sourceId: 'src-1', + message: 'HTTP 503', + }); + }); +}); + +describe('runHttpSourceOnce — success path', () => { + it('marks success and resets state when events are fetched and pushed', async () => { + const pool = makePool(); + const events = [ + { schema_version: 1, occurred_at: '2026-01-01T00:00:00Z', level: 'error', message: 'e1' }, + { schema_version: 1, occurred_at: '2026-01-01T01:00:00Z', level: 'warn', message: 'e2' }, + ]; + mockFetchHttpPollEvents.mockResolvedValue({ ok: true, events }); + mockResolveIngestToken.mockReturnValue('test-token'); + mockPushEventsToIngest.mockResolvedValue({ ok: true, accepted: 2, attempts: 1 }); + + const state = makeState(); + state.consecutiveFailures = 2; + + await runHttpSourceOnce({ pool: pool as never, env: baseEnv as never, source: baseSource, state }); + + expect(state.consecutiveFailures).toBe(0); + expect(mockMarkSourceSuccess).toHaveBeenCalledWith(pool, 'src-1'); + expect(mockFinishRun).toHaveBeenCalledWith( + expect.anything(), + expect.objectContaining({ status: 'success', fetchedCount: 2, acceptedCount: 2 }), + ); + }); +}); diff --git a/ingest-api/package-lock.json b/ingest-api/package-lock.json index 7520b59..ff52c1f 100644 --- a/ingest-api/package-lock.json +++ b/ingest-api/package-lock.json @@ -17,6 +17,7 @@ }, "devDependencies": { "@types/node": "^22.9.0", + "@vitest/coverage-v8": "^2.1.9", "ajv": "^8.18.0", "tsx": "^4.19.2", "typescript": "^5.6.3", @@ -26,6 +27,77 @@ "node": ">=20" } }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.2.tgz", + "integrity": "sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.0" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz", + "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true, + "license": "MIT" + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.27.4", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.4.tgz", @@ -582,6 +654,37 @@ "node": ">=12" } }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz", + "integrity": "sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", @@ -589,6 +692,17 @@ "dev": true, "license": "MIT" }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, "node_modules/@lukeed/ms": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@lukeed/ms/-/ms-2.0.2.tgz", @@ -989,6 +1103,39 @@ "undici-types": "~6.21.0" } }, + "node_modules/@vitest/coverage-v8": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-2.1.9.tgz", + "integrity": "sha512-Z2cOr0ksM00MpEfyVE8KXIYPEcBFxdbLSs56L8PO0QQMxt/6bDj45uQfxoc96v05KW3clk7vvgP0qfDit9DmfQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.3.0", + "@bcoe/v8-coverage": "^0.2.3", + "debug": "^4.3.7", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-report": "^3.0.1", + "istanbul-lib-source-maps": "^5.0.6", + "istanbul-reports": "^3.1.7", + "magic-string": "^0.30.12", + "magicast": "^0.3.5", + "std-env": "^3.8.0", + "test-exclude": "^7.0.1", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/browser": "2.1.9", + "vitest": "2.1.9" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + } + } + }, "node_modules/@vitest/expect": { "version": "2.1.9", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.9.tgz", @@ -1685,6 +1832,23 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -1753,6 +1917,60 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "license": "ISC" }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-5.0.6.tgz", + "integrity": "sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.23", + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", + "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/jackspeak": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", @@ -1855,6 +2073,34 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/magicast": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.3.5.tgz", + "integrity": "sha512-L0WhttDl+2BOsybvEOLK7fW3UA0OQ0IQ2d6Zl2x/a6vVRs3bAY0ECOSHHeL5jD+SbOpOCUEi0y1DgHEn9Qn1AQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.25.4", + "@babel/types": "^7.25.4", + "source-map-js": "^1.2.0" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/mime": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", @@ -2523,6 +2769,19 @@ "node": ">=8" } }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/tdigest": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/tdigest/-/tdigest-0.1.2.tgz", @@ -2532,6 +2791,60 @@ "bintrees": "1.0.2" } }, + "node_modules/test-exclude": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.2.tgz", + "integrity": "sha512-u9E6A+ZDYdp7a4WnarkXPZOx8Ilz46+kby6p1yZ8zsGTz9gYa6FIS7lj2oezzNKmtdyyJNNmmXDppga5GB7kSw==", + "dev": true, + "license": "ISC", + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^10.4.1", + "minimatch": "^10.2.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/test-exclude/node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/test-exclude/node_modules/brace-expansion": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz", + "integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/test-exclude/node_modules/minimatch": { + "version": "10.2.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", + "integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.5" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/thread-stream": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-3.1.0.tgz", diff --git a/ingest-api/package.json b/ingest-api/package.json index 79e6455..cd0b527 100644 --- a/ingest-api/package.json +++ b/ingest-api/package.json @@ -23,10 +23,10 @@ }, "devDependencies": { "@types/node": "^22.9.0", + "@vitest/coverage-v8": "^2.1.9", "ajv": "^8.18.0", "tsx": "^4.19.2", "typescript": "^5.6.3", - "@vitest/coverage-v8": "^2.1.0", "vitest": "^2.1.0" }, "engines": { diff --git a/ingest-api/src/buildApp.test.ts b/ingest-api/src/buildApp.test.ts new file mode 100644 index 0000000..17b11cb --- /dev/null +++ b/ingest-api/src/buildApp.test.ts @@ -0,0 +1,156 @@ +/** + * Integration tests for buildApp — exercises routes via Fastify inject, + * mocking DB pool and processIngestBatch so no real DB is needed. + */ +import { describe, it, expect, vi, beforeAll } from 'vitest'; +import type { FastifyInstance } from 'fastify'; +import type { RowDataPacket } from 'mysql2'; +import { buildApp } from './buildApp.js'; +import { sha256Hex } from './lib/hash.js'; + +vi.mock('./plugins/prometheus.js', () => ({ + default: async () => {}, + ingestEventsTotal: { inc: vi.fn() }, + ingestBatchSize: { observe: vi.fn() }, + errorHubLastEventTimestamp: { set: vi.fn() }, + errorHubIngestFailuresTotal: { inc: vi.fn() }, +})); + +vi.mock('./services/processIngestBatch.js', () => ({ + processIngestBatch: vi.fn().mockResolvedValue({ + status: 200, + body: { + fingerprint_policy_version: 1, + noise_ruleset_version: '1', + noise_filtered_count: 0, + results: [{ incident_id: 'inc-1', occurrence_id: 'occ-1', fingerprint: 'fp-1' }], + }, + }), + computeRequestBodyHash: vi.fn().mockReturnValue('hash-abc'), +})); + +const TOKEN = 'my-ingest-token'; +const TOKEN_HASH = sha256Hex(TOKEN); + +const validKeyRow: RowDataPacket = { + id: 'key-1', + project_id: 'proj-1', + project_slug: 'wdmi-store', + rate_limit_max: null, + rate_limit_window_ms: null, +} as unknown as RowDataPacket; + +const baseEnv = { + NODE_ENV: 'test', + PORT: 3000, + INGEST_BASE_URL: 'http://ingest.local', + INGEST_RATE_LIMIT_MAX: 500, + INGEST_RATE_LIMIT_WINDOW_MS: 60000, + INGEST_ANON_IP_MAX: 20, + INGEST_ANON_IP_WINDOW_MS: 60000, + INGEST_PUSH_TIMEOUT_MS: 10000, + INGEST_PUSH_MAX_RETRIES: 2, + INGEST_PUSH_RETRY_BASE_MS: 100, + INGEST_PUSH_RETRY_MAX_JITTER_MS: 50, + HTTP_FETCH_TIMEOUT_MS: 10000, + MAX_BACKOFF_EXPONENT: 6, +}; + +function makePool(keyRows: RowDataPacket[] = []) { + return { + execute: vi.fn().mockResolvedValue([keyRows]), + }; +} + +let app: FastifyInstance; + +beforeAll(async () => { + app = await buildApp({ env: baseEnv as never, pool: makePool([validKeyRow]) as never }); +}); + +describe('GET /health', () => { + it('returns 200 with status ok', async () => { + const res = await app.inject({ method: 'GET', url: '/health' }); + expect(res.statusCode).toBe(200); + expect(res.json()).toMatchObject({ status: 'ok' }); + }); +}); + +describe('POST /v1/ingest/events — auth rejection', () => { + it('returns 401 when no credentials provided', async () => { + const localPool = makePool([]); + const localApp = await buildApp({ env: baseEnv as never, pool: localPool as never }); + const res = await localApp.inject({ + method: 'POST', + url: '/v1/ingest/events', + payload: { + events: [ + { + schema_version: 1, + occurred_at: '2026-01-01T00:00:00Z', + level: 'error', + message: 'test error', + }, + ], + }, + }); + expect(res.statusCode).toBe(401); + }); + + it('returns 401 when API key is not found in DB', async () => { + const localPool = makePool([]); + const localApp = await buildApp({ env: baseEnv as never, pool: localPool as never }); + const res = await localApp.inject({ + method: 'POST', + url: '/v1/ingest/events', + headers: { Authorization: 'Bearer invalid-key' }, + payload: { + events: [ + { + schema_version: 1, + occurred_at: '2026-01-01T00:00:00Z', + level: 'error', + message: 'test error', + }, + ], + }, + }); + expect(res.statusCode).toBe(401); + }); +}); + +describe('POST /v1/ingest/events — successful ingest', () => { + it('returns 200 with ingest results on valid auth and payload', async () => { + const localPool = makePool([validKeyRow]); + const localApp = await buildApp({ env: baseEnv as never, pool: localPool as never }); + + const res = await localApp.inject({ + method: 'POST', + url: '/v1/ingest/events', + headers: { Authorization: `Bearer ${TOKEN}` }, + payload: { + events: [ + { + schema_version: 1, + occurred_at: '2026-01-01T00:00:00Z', + level: 'error', + message: 'Test error message', + }, + ], + }, + }); + expect(res.statusCode).toBe(200); + const body = res.json<{ results: unknown[] }>(); + expect(body.results).toHaveLength(1); + }); +}); + +describe('GET /v1/openapi.json', () => { + it('returns OpenAPI JSON spec', async () => { + const res = await app.inject({ method: 'GET', url: '/v1/openapi.json' }); + expect(res.statusCode).toBe(200); + const spec = res.json<{ openapi: string; info: { title: string } }>(); + expect(spec.openapi).toBe('3.1.0'); + expect(spec.info.title).toContain('ingest'); + }); +}); diff --git a/ingest-api/src/plugins/prometheus.test.ts b/ingest-api/src/plugins/prometheus.test.ts new file mode 100644 index 0000000..f8607d2 --- /dev/null +++ b/ingest-api/src/plugins/prometheus.test.ts @@ -0,0 +1,52 @@ +/** + * Tests for the Prometheus metrics plugin in ingest-api. + */ +import { describe, it, expect } from 'vitest'; +import Fastify from 'fastify'; +import prometheusPlugin from './prometheus.js'; + +async function buildTestApp() { + const app = Fastify({ logger: false }); + await app.register(prometheusPlugin); + return app; +} + +describe('prometheusPlugin', () => { + it('exposes GET /metrics returning Prometheus text format', async () => { + const app = await buildTestApp(); + const res = await app.inject({ method: 'GET', url: '/metrics' }); + expect(res.statusCode).toBe(200); + expect(res.headers['content-type']).toContain('text/plain'); + expect(res.payload).toContain('er_ingest_'); + }); + + it('increments active connections on request and decrements on response', async () => { + const app = await buildTestApp(); + // Fire a request — active connections hook runs around it + await app.inject({ method: 'GET', url: '/metrics' }); + // No assertion on exact gauge value since it resets per request, + // but confirm the metrics endpoint still returns data + const res = await app.inject({ method: 'GET', url: '/metrics' }); + expect(res.statusCode).toBe(200); + }); + + it('records ingest request duration for /v1/ingest paths', async () => { + const app = Fastify({ logger: false }); + await app.register(prometheusPlugin); + app.post('/v1/ingest/events', async (_req, reply) => reply.status(200).send({ ok: true })); + + await app.inject({ method: 'POST', url: '/v1/ingest/events', payload: {} }); + + const metricsRes = await app.inject({ method: 'GET', url: '/metrics' }); + expect(metricsRes.payload).toContain('er_ingest_request_duration_seconds'); + expect(metricsRes.payload).toContain('er_ingest_requests_total'); + }); + + it('does not track /metrics itself in SLO histogram', async () => { + const app = await buildTestApp(); + // Call metrics twice — the second call should not create a recursive entry + await app.inject({ method: 'GET', url: '/metrics' }); + const res = await app.inject({ method: 'GET', url: '/metrics' }); + expect(res.statusCode).toBe(200); + }); +}); diff --git a/ingest-api/src/services/ingestAuth.test.ts b/ingest-api/src/services/ingestAuth.test.ts new file mode 100644 index 0000000..f7341d8 --- /dev/null +++ b/ingest-api/src/services/ingestAuth.test.ts @@ -0,0 +1,167 @@ +/** + * Tests for attachIngestAuth — validates token extraction, DB lookup, and error paths. + */ +import { describe, it, expect, vi } from 'vitest'; +import type { FastifyReply, FastifyRequest } from 'fastify'; +import type { RowDataPacket } from 'mysql2'; +import { attachIngestAuth } from './ingestAuth.js'; +import { sha256Hex } from '../lib/hash.js'; + +function makeReply() { + const reply = { + statusCode: 200, + _body: null as unknown, + status: vi.fn().mockReturnThis() as ReturnType, + send: vi.fn().mockImplementation(function (this: unknown, body: unknown) { + (reply as { _body: unknown })._body = body; + return Promise.resolve(); + }), + }; + (reply.status as ReturnType).mockReturnValue(reply); + return reply; +} + +function makeRequest(overrides: { + authorization?: string; + 'x-api-key'?: string; +}): FastifyRequest { + return { + headers: overrides, + ingestAuth: undefined, + } as unknown as FastifyRequest; +} + +function makePool(rows: RowDataPacket[]) { + return { + execute: vi.fn().mockResolvedValue([rows]), + }; +} + +describe('attachIngestAuth', () => { + const TOKEN = 'my-secret-token'; + const TOKEN_HASH = sha256Hex(TOKEN); + + const validRow: RowDataPacket = { + id: 'key-id-123', + project_id: 'proj-id-456', + project_slug: 'wdmi-store', + rate_limit_max: 100, + rate_limit_window_ms: 60000, + } as unknown as RowDataPacket; + + it('returns 401 when no authorization header and no x-api-key', async () => { + const pool = makePool([]); + const request = makeRequest({}); + const reply = makeReply(); + await attachIngestAuth( + pool as never, + request, + reply as unknown as FastifyReply, + ); + expect(reply.status).toHaveBeenCalledWith(401); + expect(reply._body).toMatchObject({ error: 'unauthorized' }); + }); + + it('returns 401 when authorization header has no Bearer prefix', async () => { + const pool = makePool([]); + const request = makeRequest({ authorization: 'Basic abc123' }); + const reply = makeReply(); + await attachIngestAuth(pool as never, request, reply as unknown as FastifyReply); + expect(reply.status).toHaveBeenCalledWith(401); + }); + + it('returns 401 when token not found in DB (Bearer auth)', async () => { + const pool = makePool([]); + const request = makeRequest({ authorization: `Bearer ${TOKEN}` }); + const reply = makeReply(); + await attachIngestAuth(pool as never, request, reply as unknown as FastifyReply); + expect(reply.status).toHaveBeenCalledWith(401); + expect(reply._body).toMatchObject({ error: 'unauthorized', message: expect.stringContaining('Invalid') }); + }); + + it('attaches ingestAuth on valid Bearer token', async () => { + const pool = makePool([validRow]); + const request = makeRequest({ authorization: `Bearer ${TOKEN}` }); + const reply = makeReply(); + await attachIngestAuth(pool as never, request, reply as unknown as FastifyReply); + expect(reply.status).not.toHaveBeenCalled(); + expect(request.ingestAuth).toMatchObject({ + keyId: 'key-id-123', + projectId: 'proj-id-456', + projectSlug: 'wdmi-store', + rateLimitMax: 100, + rateLimitWindowMs: 60000, + }); + }); + + it('attaches ingestAuth via X-Api-Key header', async () => { + const pool = makePool([validRow]); + const request = makeRequest({ 'x-api-key': TOKEN }); + const reply = makeReply(); + await attachIngestAuth(pool as never, request, reply as unknown as FastifyReply); + expect(request.ingestAuth).toBeDefined(); + expect(request.ingestAuth?.projectSlug).toBe('wdmi-store'); + }); + + it('sends hashed token to DB query', async () => { + const pool = makePool([validRow]); + const request = makeRequest({ authorization: `Bearer ${TOKEN}` }); + const reply = makeReply(); + await attachIngestAuth(pool as never, request, reply as unknown as FastifyReply); + expect(pool.execute).toHaveBeenCalledWith( + expect.any(String), + [TOKEN_HASH], + ); + }); + + it('sets rateLimitMax to null when DB value is zero', async () => { + const rowWithZeroLimit: RowDataPacket = { + ...validRow, + rate_limit_max: 0, + rate_limit_window_ms: 0, + } as unknown as RowDataPacket; + const pool = makePool([rowWithZeroLimit]); + const request = makeRequest({ authorization: `Bearer ${TOKEN}` }); + const reply = makeReply(); + await attachIngestAuth(pool as never, request, reply as unknown as FastifyReply); + expect(request.ingestAuth?.rateLimitMax).toBeNull(); + expect(request.ingestAuth?.rateLimitWindowMs).toBeNull(); + }); + + it('sets rateLimitMax to null when DB value is null', async () => { + const rowWithNullLimit: RowDataPacket = { + ...validRow, + rate_limit_max: null, + rate_limit_window_ms: null, + } as unknown as RowDataPacket; + const pool = makePool([rowWithNullLimit]); + const request = makeRequest({ authorization: `Bearer ${TOKEN}` }); + const reply = makeReply(); + await attachIngestAuth(pool as never, request, reply as unknown as FastifyReply); + expect(request.ingestAuth?.rateLimitMax).toBeNull(); + expect(request.ingestAuth?.rateLimitWindowMs).toBeNull(); + }); + + it('prefers Authorization header over X-Api-Key', async () => { + const pool = makePool([validRow]); + const request = makeRequest({ + authorization: `Bearer ${TOKEN}`, + 'x-api-key': 'different-token', + }); + const reply = makeReply(); + await attachIngestAuth(pool as never, request, reply as unknown as FastifyReply); + expect(pool.execute).toHaveBeenCalledWith(expect.any(String), [TOKEN_HASH]); + }); + + it('lowercases projectSlug', async () => { + const rowUpperSlug: RowDataPacket = { + ...validRow, + project_slug: 'WDMI-Store', + } as unknown as RowDataPacket; + const pool = makePool([rowUpperSlug]); + const request = makeRequest({ authorization: `Bearer ${TOKEN}` }); + const reply = makeReply(); + await attachIngestAuth(pool as never, request, reply as unknown as FastifyReply); + expect(request.ingestAuth?.projectSlug).toBe('wdmi-store'); + }); +}); diff --git a/ingest-api/src/services/processIngestBatch.utils.test.ts b/ingest-api/src/services/processIngestBatch.utils.test.ts new file mode 100644 index 0000000..510b356 --- /dev/null +++ b/ingest-api/src/services/processIngestBatch.utils.test.ts @@ -0,0 +1,30 @@ +/** + * Tests for exported helpers from processIngestBatch. + */ +import { describe, it, expect } from 'vitest'; +import { computeRequestBodyHash } from './processIngestBatch.js'; + +describe('computeRequestBodyHash', () => { + it('returns a hex string', () => { + const hash = computeRequestBodyHash({ events: [] }); + expect(typeof hash).toBe('string'); + expect(hash).toMatch(/^[0-9a-f]{64}$/); + }); + + it('returns same hash for same input', () => { + const body = { events: [{ schema_version: 1, occurred_at: '2026-01-01T00:00:00Z', level: 'error', message: 'test' }] }; + expect(computeRequestBodyHash(body)).toBe(computeRequestBodyHash(body)); + }); + + it('returns different hash for different input', () => { + const a = computeRequestBodyHash({ events: [{ message: 'a' }] }); + const b = computeRequestBodyHash({ events: [{ message: 'b' }] }); + expect(a).not.toBe(b); + }); + + it('is order-independent for object keys', () => { + const a = computeRequestBodyHash({ a: 1, b: 2 }); + const b = computeRequestBodyHash({ b: 2, a: 1 }); + expect(a).toBe(b); + }); +});