diff --git a/backend/package-lock.json b/backend/package-lock.json index e977784..d5d060f 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -26,9 +26,12 @@ "@types/node": "^25.2.0", "@types/node-cron": "^3.0.11", "@types/nodemailer": "^7.0.9", + "@types/supertest": "^6.0.3", "nodemon": "^3.1.11", + "supertest": "^7.2.2", "tsx": "^4.21.0", - "typescript": "^5.9.3" + "typescript": "^5.9.3", + "vitest": "^4.0.18" } }, "node_modules/@colors/colors": { @@ -708,6 +711,13 @@ "node": "20 || >=22" } }, + "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/@lukeed/ms": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@lukeed/ms/-/ms-2.0.2.tgz", @@ -717,6 +727,29 @@ "node": ">=8" } }, + "node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@paralleldrive/cuid2": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@paralleldrive/cuid2/-/cuid2-2.3.1.tgz", + "integrity": "sha512-XO7cAxhnTZl0Yggq6jOgjiOHhbgcO4NqFqwSmQpjK3b6TEE6Uj/jfSk6wzYyemh3+I0sHirKSetjQwn5cZktFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@noble/hashes": "^1.1.5" + } + }, "node_modules/@pinojs/redact": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz", @@ -786,6 +819,356 @@ "@prisma/debug": "5.22.0" } }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.57.1.tgz", + "integrity": "sha512-A6ehUVSiSaaliTxai040ZpZ2zTevHYbvu/lDoeAteHI8QnaosIzm4qwtezfRg1jOYaUmnzLX1AOD6Z+UJjtifg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.57.1.tgz", + "integrity": "sha512-dQaAddCY9YgkFHZcFNS/606Exo8vcLHwArFZ7vxXq4rigo2bb494/xKMMwRRQW6ug7Js6yXmBZhSBRuBvCCQ3w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.57.1.tgz", + "integrity": "sha512-crNPrwJOrRxagUYeMn/DZwqN88SDmwaJ8Cvi/TN1HnWBU7GwknckyosC2gd0IqYRsHDEnXf328o9/HC6OkPgOg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.57.1.tgz", + "integrity": "sha512-Ji8g8ChVbKrhFtig5QBV7iMaJrGtpHelkB3lsaKzadFBe58gmjfGXAOfI5FV0lYMH8wiqsxKQ1C9B0YTRXVy4w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.57.1.tgz", + "integrity": "sha512-R+/WwhsjmwodAcz65guCGFRkMb4gKWTcIeLy60JJQbXrJ97BOXHxnkPFrP+YwFlaS0m+uWJTstrUA9o+UchFug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.57.1.tgz", + "integrity": "sha512-IEQTCHeiTOnAUC3IDQdzRAGj3jOAYNr9kBguI7MQAAZK3caezRrg0GxAb6Hchg4lxdZEI5Oq3iov/w/hnFWY9Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.57.1.tgz", + "integrity": "sha512-F8sWbhZ7tyuEfsmOxwc2giKDQzN3+kuBLPwwZGyVkLlKGdV1nvnNwYD0fKQ8+XS6hp9nY7B+ZeK01EBUE7aHaw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.57.1.tgz", + "integrity": "sha512-rGfNUfn0GIeXtBP1wL5MnzSj98+PZe/AXaGBCRmT0ts80lU5CATYGxXukeTX39XBKsxzFpEeK+Mrp9faXOlmrw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.57.1.tgz", + "integrity": "sha512-MMtej3YHWeg/0klK2Qodf3yrNzz6CGjo2UntLvk2RSPlhzgLvYEB3frRvbEF2wRKh1Z2fDIg9KRPe1fawv7C+g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.57.1.tgz", + "integrity": "sha512-1a/qhaaOXhqXGpMFMET9VqwZakkljWHLmZOX48R0I/YLbhdxr1m4gtG1Hq7++VhVUmf+L3sTAf9op4JlhQ5u1Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.57.1.tgz", + "integrity": "sha512-QWO6RQTZ/cqYtJMtxhkRkidoNGXc7ERPbZN7dVW5SdURuLeVU7lwKMpo18XdcmpWYd0qsP1bwKPf7DNSUinhvA==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.57.1.tgz", + "integrity": "sha512-xpObYIf+8gprgWaPP32xiN5RVTi/s5FCR+XMXSKmhfoJjrpRAjCuuqQXyxUa/eJTdAE6eJ+KDKaoEqjZQxh3Gw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.57.1.tgz", + "integrity": "sha512-4BrCgrpZo4hvzMDKRqEaW1zeecScDCR+2nZ86ATLhAoJ5FQ+lbHVD3ttKe74/c7tNT9c6F2viwB3ufwp01Oh2w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.57.1.tgz", + "integrity": "sha512-NOlUuzesGauESAyEYFSe3QTUguL+lvrN1HtwEEsU2rOwdUDeTMJdO5dUYl/2hKf9jWydJrO9OL/XSSf65R5+Xw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.57.1.tgz", + "integrity": "sha512-ptA88htVp0AwUUqhVghwDIKlvJMD/fmL/wrQj99PRHFRAG6Z5nbWoWG4o81Nt9FT+IuqUQi+L31ZKAFeJ5Is+A==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.57.1.tgz", + "integrity": "sha512-S51t7aMMTNdmAMPpBg7OOsTdn4tySRQvklmL3RpDRyknk87+Sp3xaumlatU+ppQ+5raY7sSTcC2beGgvhENfuw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.57.1.tgz", + "integrity": "sha512-Bl00OFnVFkL82FHbEqy3k5CUCKH6OEJL54KCyx2oqsmZnFTR8IoNqBF+mjQVcRCT5sB6yOvK8A37LNm/kPJiZg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.57.1.tgz", + "integrity": "sha512-ABca4ceT4N+Tv/GtotnWAeXZUZuM/9AQyCyKYyKnpk4yoA7QIAuBt6Hkgpw8kActYlew2mvckXkvx0FfoInnLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.57.1.tgz", + "integrity": "sha512-HFps0JeGtuOR2convgRRkHCekD7j+gdAuXM+/i6kGzQtFhlCtQkpwtNzkNj6QhCDp7DRJ7+qC/1Vg2jt5iSOFw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.57.1.tgz", + "integrity": "sha512-H+hXEv9gdVQuDTgnqD+SQffoWoc0Of59AStSzTEj/feWTBAnSfSD3+Dql1ZruJQxmykT/JVY0dE8Ka7z0DH1hw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.57.1.tgz", + "integrity": "sha512-4wYoDpNg6o/oPximyc/NG+mYUejZrCU2q+2w6YZqrAs2UcNUChIZXjtafAiiZSUc7On8v5NyNj34Kzj/Ltk6dQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.57.1.tgz", + "integrity": "sha512-O54mtsV/6LW3P8qdTcamQmuC990HDfR71lo44oZMZlXU4tzLrbvTii87Ni9opq60ds0YzuAlEr/GNwuNluZyMQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.57.1.tgz", + "integrity": "sha512-P3dLS+IerxCT/7D2q2FYcRdWRl22dNbrbBEtxdWhXrfIMPP9lQhb5h4Du04mdl5Woq05jVCDPCMF7Ub0NAjIew==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.57.1.tgz", + "integrity": "sha512-VMBH2eOOaKGtIJYleXsi2B8CPVADrh+TyNxJ4mWPnKfLB/DBUmzW+5m1xUrcwWoMfSLagIRpjUFeW5CO5hyciQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.57.1.tgz", + "integrity": "sha512-mxRFDdHIWRxg3UfIIAwCm6NzvxG0jDX/wBN6KsQFTvKFqqg9vTrWUE68qEjHt19A5wwx5X5aUi2zuZT7YR0jrA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@so-ric/colorspace": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/@so-ric/colorspace/-/colorspace-1.1.6.tgz", @@ -796,6 +1179,52 @@ "text-hex": "1.0.x" } }, + "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/@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/cookiejar": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.5.tgz", + "integrity": "sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==", + "dev": true, + "license": "MIT" + }, + "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", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/methods": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@types/methods/-/methods-1.1.4.tgz", + "integrity": "sha512-ymXWVrDiCxTBE3+RIrrP533E70eA+9qu7zdWoHuOmGujkYtzf4HQF96b8nwHLqhuf4ykX61IGRIB38CC6/sImQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/node": { "version": "25.2.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-25.2.0.tgz", @@ -823,12 +1252,147 @@ "@types/node": "*" } }, + "node_modules/@types/superagent": { + "version": "8.1.9", + "resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-8.1.9.tgz", + "integrity": "sha512-pTVjI73witn+9ILmoJdajHGW2jkSaOzhiFYF1Rd3EQ94kymLqB9PjD9ISg7WaALC7+dCHT0FGe9T2LktLq/3GQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/cookiejar": "^2.1.5", + "@types/methods": "^1.1.4", + "@types/node": "*", + "form-data": "^4.0.0" + } + }, + "node_modules/@types/supertest": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@types/supertest/-/supertest-6.0.3.tgz", + "integrity": "sha512-8WzXq62EXFhJ7QsH3Ocb/iKQ/Ty9ZVWnVzoTKc9tyyFRRF3a74Tk2+TLFgaFFw364Ere+npzHKEJ6ga2LzIL7w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/methods": "^1.1.4", + "@types/superagent": "^8.1.0" + } + }, "node_modules/@types/triple-beam": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz", "integrity": "sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==", "license": "MIT" }, + "node_modules/@vitest/expect": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.18.tgz", + "integrity": "sha512-8sCWUyckXXYvx4opfzVY03EOiYVxyNrHS5QxX3DAIi5dpJAAkyJezHCP77VMX4HKA2LDT/Jpfo8i2r5BE3GnQQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.0.0", + "@types/chai": "^5.2.2", + "@vitest/spy": "4.0.18", + "@vitest/utils": "4.0.18", + "chai": "^6.2.1", + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.18.tgz", + "integrity": "sha512-HhVd0MDnzzsgevnOWCBj5Otnzobjy5wLBe4EdeeFGv8luMsGcYqDuFRMcttKWZA5vVO8RFjexVovXvAM4JoJDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "4.0.18", + "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-0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.18.tgz", + "integrity": "sha512-P24GK3GulZWC5tz87ux0m8OADrQIUVDPIjjj65vBXYG17ZeU3qD7r+MNZ1RNv4l8CGU2vtTRqixrOi9fYk/yKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.18.tgz", + "integrity": "sha512-rpk9y12PGa22Jg6g5M3UVVnTS7+zycIGk9ZNGN+m6tZHKQb7jrP7/77WfZy13Y/EUDd52NDsLRQhYKtv7XfPQw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "4.0.18", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.18.tgz", + "integrity": "sha512-PCiV0rcl7jKQjbgYqjtakly6T1uwv/5BQ9SwBLekVg/EaYeQFPiXcgrC2Y7vDMA8dM1SUEAEV82kgSQIlXNMvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.0.18", + "magic-string": "^0.30.21", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.18.tgz", + "integrity": "sha512-cbQt3PTSD7P2OARdVW3qWER5EGq7PHlvE+QfzSC0lbwO+xnt7+XH06ZzFjFRgzUX//JmpxrCu92VdwvEPlWSNw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.18.tgz", + "integrity": "sha512-msMRKLMVLWygpK3u2Hybgi4MNjcYJvwTb0Ru09+fOyCXIgT5raYP041DRRdiJiI3k/2U6SEbAETB3YtBrUkCFA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.0.18", + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "node_modules/abstract-logging": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-2.0.1.tgz", @@ -882,12 +1446,36 @@ "node": ">= 8" } }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", + "dev": true, + "license": "MIT" + }, + "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/async": { "version": "3.2.6", "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", "license": "MIT" }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true, + "license": "MIT" + }, "node_modules/atomic-sleep": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", @@ -951,6 +1539,47 @@ "node": ">=8" } }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "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/chokidar": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", @@ -1022,6 +1651,29 @@ "node": ">=18" } }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/component-emitter": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.1.tgz", + "integrity": "sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1055,6 +1707,23 @@ "url": "https://opencollective.com/express" } }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/cookiejar": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", + "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==", + "dev": true, + "license": "MIT" + }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -1073,6 +1742,16 @@ } } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -1091,6 +1770,17 @@ "node": ">=6" } }, + "node_modules/dezalgo": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", + "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", + "dev": true, + "license": "ISC", + "dependencies": { + "asap": "^2.0.0", + "wrappy": "1" + } + }, "node_modules/dotenv": { "version": "17.2.3", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.3.tgz", @@ -1103,6 +1793,21 @@ "url": "https://dotenvx.com" } }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/enabled": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz", @@ -1118,6 +1823,62 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-module-lexer": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", + "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "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", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/esbuild": { "version": "0.27.2", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.2.tgz", @@ -1166,6 +1927,26 @@ "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", "license": "MIT" }, + "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/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-decode-uri-component": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/fast-decode-uri-component/-/fast-decode-uri-component-1.0.1.tgz", @@ -1211,6 +1992,13 @@ "fast-decode-uri-component": "^1.0.1" } }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "dev": true, + "license": "MIT" + }, "node_modules/fast-uri": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz", @@ -1324,6 +2112,41 @@ "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", "license": "MIT" }, + "node_modules/form-data": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", + "dev": true, + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/formidable": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-3.5.4.tgz", + "integrity": "sha512-YikH+7CUTOtP44ZTnUhR7Ic2UASBPOqmaRkRKxRbywPTe5VxF7RRCck4af9wutiZ/QKM5nME9Bie2fFaPz5Gug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@paralleldrive/cuid2": "^2.2.2", + "dezalgo": "^1.0.4", + "once": "^1.4.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "url": "https://ko-fi.com/tunnckoCore/commissions" + } + }, "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", @@ -1338,6 +2161,55 @@ "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", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/get-tsconfig": { "version": "4.13.1", "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.1.tgz", @@ -1381,6 +2253,19 @@ "node": ">= 6" } }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -1391,6 +2276,48 @@ "node": ">=4" } }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/http-errors": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", @@ -1585,6 +2512,36 @@ "node": "20 || >=22" } }, + "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/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/mime": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", @@ -1597,6 +2554,29 @@ "node": ">=10.0.0" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/minimatch": { "version": "10.1.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.1.tgz", @@ -1627,6 +2607,25 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "license": "MIT" }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/node-cron": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-4.2.1.tgz", @@ -1697,6 +2696,30 @@ "node": ">=0.10.0" } }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "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/on-exit-leak-free": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz", @@ -1706,6 +2729,16 @@ "node": ">=14.0.0" } }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/one-time": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz", @@ -1752,6 +2785,20 @@ "url": "https://github.com/sponsors/isaacs" } }, + "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", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -1832,6 +2879,35 @@ "node": ">=18" } }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "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/prisma": { "version": "5.22.0", "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.22.0.tgz", @@ -1889,6 +2965,22 @@ "dev": true, "license": "MIT" }, + "node_modules/qs": { + "version": "6.14.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz", + "integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/quick-format-unescaped": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", @@ -1975,6 +3067,51 @@ "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", "license": "MIT" }, + "node_modules/rollup": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.57.1.tgz", + "integrity": "sha512-oQL6lgK3e2QZeQ7gcgIkS2YZPg5slw37hYufJ3edKlfQSGGm8ICoxswK15ntSzF/a8+h7ekRy7k7oWc3BQ7y8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.57.1", + "@rollup/rollup-android-arm64": "4.57.1", + "@rollup/rollup-darwin-arm64": "4.57.1", + "@rollup/rollup-darwin-x64": "4.57.1", + "@rollup/rollup-freebsd-arm64": "4.57.1", + "@rollup/rollup-freebsd-x64": "4.57.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.57.1", + "@rollup/rollup-linux-arm-musleabihf": "4.57.1", + "@rollup/rollup-linux-arm64-gnu": "4.57.1", + "@rollup/rollup-linux-arm64-musl": "4.57.1", + "@rollup/rollup-linux-loong64-gnu": "4.57.1", + "@rollup/rollup-linux-loong64-musl": "4.57.1", + "@rollup/rollup-linux-ppc64-gnu": "4.57.1", + "@rollup/rollup-linux-ppc64-musl": "4.57.1", + "@rollup/rollup-linux-riscv64-gnu": "4.57.1", + "@rollup/rollup-linux-riscv64-musl": "4.57.1", + "@rollup/rollup-linux-s390x-gnu": "4.57.1", + "@rollup/rollup-linux-x64-gnu": "4.57.1", + "@rollup/rollup-linux-x64-musl": "4.57.1", + "@rollup/rollup-openbsd-x64": "4.57.1", + "@rollup/rollup-openharmony-arm64": "4.57.1", + "@rollup/rollup-win32-arm64-msvc": "4.57.1", + "@rollup/rollup-win32-ia32-msvc": "4.57.1", + "@rollup/rollup-win32-x64-gnu": "4.57.1", + "@rollup/rollup-win32-x64-msvc": "4.57.1", + "fsevents": "~2.3.2" + } + }, "node_modules/rss-parser": { "version": "3.13.0", "resolved": "https://registry.npmjs.org/rss-parser/-/rss-parser-3.13.0.tgz", @@ -2082,6 +3219,89 @@ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", "license": "ISC" }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "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/simple-update-notifier": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", @@ -2104,6 +3324,16 @@ "atomic-sleep": "^1.0.0" } }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/split2": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", @@ -2122,6 +3352,13 @@ "node": "*" } }, + "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/statuses": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", @@ -2131,6 +3368,13 @@ "node": ">= 0.8" } }, + "node_modules/std-env": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", + "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==", + "dev": true, + "license": "MIT" + }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -2140,6 +3384,55 @@ "safe-buffer": "~5.2.0" } }, + "node_modules/superagent": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-10.3.0.tgz", + "integrity": "sha512-B+4Ik7ROgVKrQsXTV0Jwp2u+PXYLSlqtDAhYnkkD+zn3yg8s/zjA2MeGayPoY/KICrbitwneDHrjSotxKL+0XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "component-emitter": "^1.3.1", + "cookiejar": "^2.1.4", + "debug": "^4.3.7", + "fast-safe-stringify": "^2.1.1", + "form-data": "^4.0.5", + "formidable": "^3.5.4", + "methods": "^1.1.2", + "mime": "2.6.0", + "qs": "^6.14.1" + }, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/superagent/node_modules/mime": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", + "dev": true, + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/supertest": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/supertest/-/supertest-7.2.2.tgz", + "integrity": "sha512-oK8WG9diS3DlhdUkcFn4tkNIiIbBx9lI2ClF8K+b2/m8Eyv47LSawxUzZQSNKUrVb2KsqeTDCcjAAVPYaSLVTA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cookie-signature": "^1.2.2", + "methods": "^1.1.2", + "superagent": "^10.3.0" + }, + "engines": { + "node": ">=14.18.0" + } + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -2171,6 +3464,82 @@ "node": ">=20" } }, + "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.0.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", + "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", + "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==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "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==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/tinyrainbow": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz", + "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -2290,6 +3659,236 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "license": "MIT" }, + "node_modules/vite": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.1.tgz", + "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.27.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "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", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.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 + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "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/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/vite/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/vite/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/vitest": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.18.tgz", + "integrity": "sha512-hOQuK7h0FGKgBAas7v0mSAsnvrIgAvWmRFjmzpJ7SwFHH3g1k2u37JtYwOwmEKhK6ZO3v9ggDBBm0La1LCK4uQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "4.0.18", + "@vitest/mocker": "4.0.18", + "@vitest/pretty-format": "4.0.18", + "@vitest/runner": "4.0.18", + "@vitest/snapshot": "4.0.18", + "@vitest/spy": "4.0.18", + "@vitest/utils": "4.0.18", + "es-module-lexer": "^1.7.0", + "expect-type": "^1.2.2", + "magic-string": "^0.30.21", + "obug": "^2.1.1", + "pathe": "^2.0.3", + "picomatch": "^4.0.3", + "std-env": "^3.10.0", + "tinybench": "^2.9.0", + "tinyexec": "^1.0.2", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.0.3", + "vite": "^6.0.0 || ^7.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.0.18", + "@vitest/browser-preview": "4.0.18", + "@vitest/browser-webdriverio": "4.0.18", + "@vitest/ui": "4.0.18", + "happy-dom": "*", + "jsdom": "*" + }, + "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/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "node_modules/vitest/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "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/winston": { "version": "3.19.0", "resolved": "https://registry.npmjs.org/winston/-/winston-3.19.0.tgz", @@ -2326,6 +3925,13 @@ "node": ">= 12.0.0" } }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true, + "license": "ISC" + }, "node_modules/xml2js": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz", diff --git a/backend/package.json b/backend/package.json index 3a4968c..b02e68c 100644 --- a/backend/package.json +++ b/backend/package.json @@ -7,6 +7,9 @@ "dev": "tsx watch src/app.ts", "build": "tsc", "start": "node dist/app.js", + "test": "vitest run", + "test:watch": "vitest", + "test:coverage": "vitest run --coverage", "prisma:generate": "prisma generate", "prisma:migrate": "prisma migrate dev", "prisma:studio": "prisma studio" @@ -33,8 +36,11 @@ "@types/node": "^25.2.0", "@types/node-cron": "^3.0.11", "@types/nodemailer": "^7.0.9", + "@types/supertest": "^6.0.3", "nodemon": "^3.1.11", + "supertest": "^7.2.2", "tsx": "^4.21.0", - "typescript": "^5.9.3" + "typescript": "^5.9.3", + "vitest": "^4.0.18" } } diff --git a/backend/src/web/routes/channels.ts b/backend/src/web/routes/channels.ts index 6e56100..b6f3a3d 100644 --- a/backend/src/web/routes/channels.ts +++ b/backend/src/web/routes/channels.ts @@ -70,9 +70,16 @@ export async function channelRoutes(app: FastifyInstance): Promise { throw new NotFoundError('推送渠道不存在'); } + // 构建更新数据对象,只包含提供的字段 + const updateData: any = {}; + if (name !== undefined) updateData.name = name; + if (type !== undefined) updateData.type = type; + if (config !== undefined) updateData.config = config; + if (enabled !== undefined) updateData.enabled = enabled; + const channel = await prisma.channel.update({ where: { id: parseInt(id) }, - data: { name, type, config, enabled }, + data: updateData, }); successResponse(reply, channel, '推送渠道更新成功'); diff --git a/backend/src/web/routes/llm-configs.ts b/backend/src/web/routes/llm-configs.ts index 0092d5d..f50ae69 100644 --- a/backend/src/web/routes/llm-configs.ts +++ b/backend/src/web/routes/llm-configs.ts @@ -63,9 +63,17 @@ export async function llmConfigRoutes(app: FastifyInstance): Promise { throw new NotFoundError('LLM 配置不存在'); } + // 构建更新数据对象,只包含提供的字段 + const updateData: any = {}; + if (name !== undefined) updateData.name = name; + if (baseUrl !== undefined) updateData.baseUrl = baseUrl; + if (model !== undefined) updateData.model = model; + if (apiKey !== undefined) updateData.apiKey = apiKey; + if (enabled !== undefined) updateData.enabled = enabled; + const config = await prisma.llmConfig.update({ where: { id: parseInt(id) }, - data: { name, baseUrl, model, apiKey, enabled }, + data: updateData, }); successResponse(reply, config, 'LLM 配置更新成功'); diff --git a/backend/src/web/routes/sources.ts b/backend/src/web/routes/sources.ts index 2ea8211..d599204 100644 --- a/backend/src/web/routes/sources.ts +++ b/backend/src/web/routes/sources.ts @@ -70,9 +70,17 @@ export async function sourceRoutes(app: FastifyInstance): Promise { throw new NotFoundError('数据源不存在'); } + // 构建更新数据对象,只包含提供的字段 + const updateData: any = {}; + if (name !== undefined) updateData.name = name; + if (type !== undefined) updateData.type = type; + if (config !== undefined) updateData.config = config; + if (cronExpression !== undefined) updateData.cronExpression = cronExpression; + if (enabled !== undefined) updateData.enabled = enabled; + const source = await prisma.source.update({ where: { id: parseInt(id) }, - data: { name, type, config, cronExpression, enabled }, + data: updateData, }); successResponse(reply, source, '数据源更新成功'); diff --git a/backend/src/web/routes/topics.ts b/backend/src/web/routes/topics.ts index afdefec..51bf6c6 100644 --- a/backend/src/web/routes/topics.ts +++ b/backend/src/web/routes/topics.ts @@ -118,9 +118,18 @@ export async function topicRoutes(app: FastifyInstance): Promise { throw new NotFoundError('主题不存在'); } + // 构建更新数据对象,只包含提供的字段 + const updateData: any = {}; + if (name !== undefined) updateData.name = name; + if (description !== undefined) updateData.description = description; + if (processMode !== undefined) updateData.processMode = processMode; + if (llmConfigId !== undefined) updateData.llmConfigId = llmConfigId; + if (scheduleConfig !== undefined) updateData.scheduleConfig = scheduleConfig; + if (enabled !== undefined) updateData.enabled = enabled; + const topic = await prisma.topic.update({ where: { id: parseInt(id) }, - data: { name, description, processMode, llmConfigId, scheduleConfig, enabled }, + data: updateData, }); // 更新数据源关联 diff --git a/backend/tests/articles.test.ts b/backend/tests/articles.test.ts new file mode 100644 index 0000000..5478a60 --- /dev/null +++ b/backend/tests/articles.test.ts @@ -0,0 +1,387 @@ +import { beforeAll, afterAll, beforeEach, describe, it, expect } from 'vitest'; +import { createTestApp } from './helpers/app'; +import { cleanupDatabase, prisma } from './setup'; + +describe('资讯 API', () => { + let app: Awaited>; + + beforeAll(async () => { + app = await createTestApp(); + }); + + beforeEach(async () => { + await cleanupDatabase(); + }); + + afterAll(async () => { + await app.close(); + await cleanupDatabase(); + }); + + describe('GET /api/v1/articles', () => { + it('应返回资讯列表', async () => { + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + await prisma.article.createMany({ + data: [ + { + sourceId: source.id, + collectedAt: new Date('2024-01-01T00:00:00Z'), + title: '文章 1', + url: 'https://example.com/1', + content: '内容 1', + publishedAt: new Date('2024-01-01'), + collectedAt: new Date('2024-01-01T00:00:00Z'), + }, + { + sourceId: source.id, + collectedAt: new Date('2024-01-01T00:00:00Z'), + title: '文章 2', + url: 'https://example.com/2', + content: '内容 2', + publishedAt: new Date('2024-01-02'), + collectedAt: new Date('2024-01-02T00:00:00Z'), + }, + ], + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/articles', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(2); + expect(body.pagination.total).toBe(2); + expect(body.data[0].source).toBeDefined(); + }); + + it('应支持按数据源筛选', async () => { + const source1 = await prisma.source.create({ + data: { + name: '源 1', + type: 'rss', + config: { url: 'https://example.com/rss1' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const source2 = await prisma.source.create({ + data: { + name: '源 2', + type: 'rss', + config: { url: 'https://example.com/rss2' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + await prisma.article.create({ + data: { + sourceId: source1.id, + title: '来自源 1', + url: 'https://example.com/1', + content: '内容', + collectedAt: new Date('2024-01-01T00:00:00Z'), + }, + }); + + await prisma.article.create({ + data: { + sourceId: source2.id, + title: '来自源 2', + url: 'https://example.com/2', + content: '内容', + collectedAt: new Date('2024-01-01T00:00:00Z'), + }, + }); + + const response = await app.inject({ + method: 'GET', + url: `/api/v1/articles?sourceId=${source1.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(1); + expect(body.data[0].sourceId).toBe(source1.id); + }); + + it('应支持按主题筛选(返回主题关联的所有数据源的文章)', async () => { + const source1 = await prisma.source.create({ + data: { + name: '源 1', + type: 'rss', + config: { url: 'https://example.com/rss1' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const source2 = await prisma.source.create({ + data: { + name: '源 2', + type: 'rss', + config: { url: 'https://example.com/rss2' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const source3 = await prisma.source.create({ + data: { + name: '源 3', + type: 'rss', + config: { url: 'https://example.com/rss3' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const topic = await prisma.topic.create({ + data: { + name: 'AI 资讯', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + }, + }); + + // 关联源 1 和源 2 到主题 + await prisma.topicSource.createMany({ + data: [ + { topicId: topic.id, sourceId: source1.id }, + { topicId: topic.id, sourceId: source2.id }, + ], + }); + + // 创建文章 + await prisma.article.create({ + data: { + sourceId: source1.id, + title: '文章 1', + url: 'https://example.com/1', + content: '内容', + collectedAt: new Date('2024-01-01T00:00:00Z'), + }, + }); + + await prisma.article.create({ + data: { + sourceId: source2.id, + title: '文章 2', + url: 'https://example.com/2', + content: '内容', + collectedAt: new Date('2024-01-01T00:00:00Z'), + }, + }); + + await prisma.article.create({ + data: { + sourceId: source3.id, + title: '文章 3', + url: 'https://example.com/3', + content: '内容', + collectedAt: new Date('2024-01-01T00:00:00Z'), + }, + }); + + const response = await app.inject({ + method: 'GET', + url: `/api/v1/articles?topicId=${topic.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + // 只返回源 1 和源 2 的文章 + expect(body.data).toHaveLength(2); + const sourceIds = body.data.map((item: any) => item.sourceId); + expect(sourceIds).toContain(source1.id); + expect(sourceIds).toContain(source2.id); + expect(sourceIds).not.toContain(source3.id); + }); + + it('应支持按日期范围筛选', async () => { + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + await prisma.article.create({ + data: { + sourceId: source.id, + collectedAt: new Date('2024-01-01T00:00:00Z'), + title: '旧文章', + url: 'https://example.com/old', + content: '内容', + publishedAt: new Date('2024-01-01'), + }, + }); + + await prisma.article.create({ + data: { + sourceId: source.id, + collectedAt: new Date('2024-01-01T00:00:00Z'), + title: '新文章', + url: 'https://example.com/new', + content: '内容', + publishedAt: new Date('2024-01-15'), + }, + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/articles?startDate=2024-01-10&endDate=2024-01-20', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(1); + expect(body.data[0].title).toBe('新文章'); + }); + + it('应支持分页', async () => { + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const data = Array.from({ length: 25 }, (_, i) => ({ + sourceId: source.id, + collectedAt: new Date('2024-01-01T00:00:00Z'), + title: `文章 ${i + 1}`, + url: `https://example.com/${i}`, + content: '内容', + })); + await prisma.article.createMany({ data }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/articles?page=2&limit=10', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(10); + expect(body.pagination.total).toBe(25); + expect(body.pagination.page).toBe(2); + }); + }); + + describe('GET /api/v1/articles/:id', () => { + it('应返回单篇资讯', async () => { + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const article = await prisma.article.create({ + data: { + sourceId: source.id, + collectedAt: new Date('2024-01-01T00:00:00Z'), + title: '测试文章', + url: 'https://example.com/test', + content: '这是文章内容', + summary: '摘要', + publishedAt: new Date('2024-01-01'), + }, + }); + + const response = await app.inject({ + method: 'GET', + url: `/api/v1/articles/${article.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data.id).toBe(article.id); + expect(body.data.title).toBe('测试文章'); + expect(body.data.source).toBeDefined(); + expect(body.data.source.name).toBe('测试源'); + }); + + it('资讯不存在时应返回 404', async () => { + const response = await app.inject({ + method: 'GET', + url: '/api/v1/articles/99999', + }); + + expect(response.statusCode).toBe(404); + const body = JSON.parse(response.body); + expect(body.success).toBe(false); + expect(body.error).toContain('资讯不存在'); + }); + }); + + describe('DELETE /api/v1/articles/:id', () => { + it('应成功删除资讯', async () => { + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const article = await prisma.article.create({ + data: { + sourceId: source.id, + collectedAt: new Date('2024-01-01T00:00:00Z'), + title: '待删除文章', + url: 'https://example.com/delete', + content: '内容', + }, + }); + + const response = await app.inject({ + method: 'DELETE', + url: `/api/v1/articles/${article.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.message).toBe('资讯删除成功'); + + const deleted = await prisma.article.findUnique({ + where: { id: article.id }, + }); + expect(deleted).toBeNull(); + }); + + it('删除不存在的资讯时应返回 404', async () => { + const response = await app.inject({ + method: 'DELETE', + url: '/api/v1/articles/99999', + }); + + expect(response.statusCode).toBe(404); + }); + }); +}); diff --git a/backend/tests/channels.test.ts b/backend/tests/channels.test.ts new file mode 100644 index 0000000..d9517aa --- /dev/null +++ b/backend/tests/channels.test.ts @@ -0,0 +1,341 @@ +import { beforeAll, afterAll, beforeEach, describe, it, expect } from 'vitest'; +import { createTestApp } from './helpers/app'; +import { cleanupDatabase, prisma } from './setup'; + +describe('推送渠道 API', () => { + let app: Awaited>; + + beforeAll(async () => { + app = await createTestApp(); + }); + + beforeEach(async () => { + await cleanupDatabase(); + }); + + afterAll(async () => { + await app.close(); + await cleanupDatabase(); + }); + + describe('POST /api/v1/channels', () => { + it('应成功创建邮件类型的推送渠道', async () => { + const payload = { + name: '邮件通知', + type: 'email', + config: { + to: 'test@example.com', + subject: '资讯周报', + }, + enabled: true, + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/channels', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.success).toBe(true); + expect(body.message).toBe('推送渠道创建成功'); + expect(body.data.name).toBe(payload.name); + expect(body.data.type).toBe('email'); + }); + + it('应成功创建 Slack 类型的推送渠道', async () => { + const payload = { + name: 'Slack 通知', + type: 'slack', + config: { + webhookUrl: 'https://hooks.slack.com/services/xxx', + }, + enabled: true, + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/channels', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.data.type).toBe('slack'); + }); + + it('应成功创建钉钉类型的推送渠道', async () => { + const payload = { + name: '钉钉通知', + type: 'dingtalk', + config: { + webhookUrl: 'https://oapi.dingtalk.com/robot/send', + secret: 'SEC123', + }, + enabled: true, + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/channels', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.data.type).toBe('dingtalk'); + }); + + it('应成功创建企业微信类型的推送渠道', async () => { + const payload = { + name: '企业微信通知', + type: 'wechat', + config: { + webhookUrl: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send', + }, + enabled: true, + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/channels', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.data.type).toBe('wechat'); + }); + + it('缺少必填字段时应返回 400 错误', async () => { + const payload = { + name: '不完整渠道', + type: 'email', + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/channels', + payload, + }); + + expect(response.statusCode).toBe(400); + const body = JSON.parse(response.body); + expect(body.success).toBe(false); + expect(body.error).toContain('缺少必填字段'); + }); + + it('enabled 默认值应为 true', async () => { + const payload = { + name: '测试渠道', + type: 'email', + config: { to: 'test@example.com' }, + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/channels', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.data.enabled).toBe(true); + }); + }); + + describe('GET /api/v1/channels', () => { + it('应返回推送渠道列表', async () => { + await prisma.channel.createMany({ + data: [ + { + name: '邮件渠道', + type: 'email', + config: { to: 'test@example.com' }, + enabled: true, + }, + { + name: 'Slack 渠道', + type: 'slack', + config: { webhookUrl: 'https://hooks.slack.com/xxx' }, + enabled: true, + }, + ], + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/channels', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(2); + expect(body.pagination.total).toBe(2); + }); + + it('应支持按类型筛选', async () => { + await prisma.channel.createMany({ + data: [ + { + name: '邮件渠道 1', + type: 'email', + config: { to: 'test1@example.com' }, + enabled: true, + }, + { + name: 'Slack 渠道 1', + type: 'slack', + config: { webhookUrl: 'https://hooks.slack.com/xxx' }, + enabled: true, + }, + ], + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/channels?type=email', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(1); + expect(body.data[0].type).toBe('email'); + }); + }); + + describe('GET /api/v1/channels/:id', () => { + it('应返回单个推送渠道及其关联的主题', async () => { + const channel = await prisma.channel.create({ + data: { + name: '测试渠道', + type: 'email', + config: { to: 'test@example.com' }, + enabled: true, + }, + }); + + const topic = await prisma.topic.create({ + data: { + name: '测试主题', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * *' }, + enabled: true, + }, + }); + + await prisma.topicChannel.create({ + data: { + topicId: topic.id, + channelId: channel.id, + }, + }); + + const response = await app.inject({ + method: 'GET', + url: `/api/v1/channels/${channel.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data.id).toBe(channel.id); + expect(body.data.topicChannels).toHaveLength(1); + expect(body.data.topicChannels[0].topic.name).toBe('测试主题'); + }); + + it('推送渠道不存在时应返回 404', async () => { + const response = await app.inject({ + method: 'GET', + url: '/api/v1/channels/99999', + }); + + expect(response.statusCode).toBe(404); + const body = JSON.parse(response.body); + expect(body.success).toBe(false); + expect(body.error).toContain('推送渠道不存在'); + }); + }); + + describe('PUT /api/v1/channels/:id', () => { + it('应成功更新推送渠道', async () => { + const channel = await prisma.channel.create({ + data: { + name: '原始渠道', + type: 'email', + config: { to: 'old@example.com' }, + enabled: true, + }, + }); + + const updateData = { + name: '更新后渠道', + config: { to: 'new@example.com' }, + enabled: false, + }; + + const response = await app.inject({ + method: 'PUT', + url: `/api/v1/channels/${channel.id}`, + payload: updateData, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data.name).toBe('更新后渠道'); + expect(body.data.config.to).toBe('new@example.com'); + expect(body.data.enabled).toBe(false); + expect(body.message).toBe('推送渠道更新成功'); + }); + + it('更新不存在的推送渠道时应返回 404', async () => { + const response = await app.inject({ + method: 'PUT', + url: '/api/v1/channels/99999', + payload: { + name: '更新', + type: 'email', + config: { to: 'test@example.com' }, + }, + }); + + expect(response.statusCode).toBe(404); + }); + }); + + describe('DELETE /api/v1/channels/:id', () => { + it('应成功删除推送渠道', async () => { + const channel = await prisma.channel.create({ + data: { + name: '待删除渠道', + type: 'email', + config: { to: 'test@example.com' }, + enabled: true, + }, + }); + + const response = await app.inject({ + method: 'DELETE', + url: `/api/v1/channels/${channel.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.message).toBe('推送渠道删除成功'); + + const deleted = await prisma.channel.findUnique({ + where: { id: channel.id }, + }); + expect(deleted).toBeNull(); + }); + + it('删除不存在的推送渠道时应返回 404', async () => { + const response = await app.inject({ + method: 'DELETE', + url: '/api/v1/channels/99999', + }); + + expect(response.statusCode).toBe(404); + }); + }); +}); diff --git a/backend/tests/collection-logs.test.ts b/backend/tests/collection-logs.test.ts new file mode 100644 index 0000000..660741b --- /dev/null +++ b/backend/tests/collection-logs.test.ts @@ -0,0 +1,363 @@ +import { beforeAll, afterAll, beforeEach, describe, it, expect } from 'vitest'; +import { createTestApp } from './helpers/app'; +import { cleanupDatabase, prisma } from './setup'; + +describe('采集日志 API', () => { + let app: Awaited>; + + beforeAll(async () => { + app = await createTestApp(); + }); + + beforeEach(async () => { + await cleanupDatabase(); + }); + + afterAll(async () => { + await app.close(); + await cleanupDatabase(); + }); + + describe('GET /api/v1/collection-logs', () => { + it('应返回采集日志列表', async () => { + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + await prisma.collectionLog.createMany({ + data: [ + { + sourceId: source.id, + status: 'success', + articlesCount: 5, + startedAt: new Date('2024-01-01T00:00:00Z'), + finishedAt: new Date('2024-01-01T00:01:00Z'), + }, + { + sourceId: source.id, + status: 'failed', + errorMessage: '连接超时', + startedAt: new Date('2024-01-02T00:00:00Z'), + finishedAt: new Date('2024-01-02T00:01:00Z'), + }, + ], + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/collection-logs', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(2); + expect(body.pagination.total).toBe(2); + expect(body.data[0].source).toBeDefined(); + }); + + it('应支持按数据源筛选', async () => { + const source1 = await prisma.source.create({ + data: { + name: '源 1', + type: 'rss', + config: { url: 'https://example.com/rss1' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const source2 = await prisma.source.create({ + data: { + name: '源 2', + type: 'rss', + config: { url: 'https://example.com/rss2' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + await prisma.collectionLog.create({ + data: { + sourceId: source1.id, + status: 'success', + articlesCount: 10, + startedAt: new Date('2024-01-01T00:00:00Z'), + finishedAt: new Date('2024-01-01T00:01:00Z'), + }, + }); + + await prisma.collectionLog.create({ + data: { + sourceId: source2.id, + status: 'success', + articlesCount: 5, + startedAt: new Date('2024-01-01T00:00:00Z'), + finishedAt: new Date('2024-01-01T00:01:00Z'), + }, + }); + + const response = await app.inject({ + method: 'GET', + url: `/api/v1/collection-logs?sourceId=${source1.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(1); + expect(body.data[0].sourceId).toBe(source1.id); + expect(body.data[0].articlesCount).toBe(10); + }); + + it('应支持按状态筛选', async () => { + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + await prisma.collectionLog.createMany({ + data: [ + { + sourceId: source.id, + status: 'success', + articlesCount: 10, + startedAt: new Date('2024-01-01T00:00:00Z'), + finishedAt: new Date('2024-01-01T00:01:00Z'), + }, + { + sourceId: source.id, + status: 'failed', + errorMessage: '错误', + startedAt: new Date('2024-01-02T00:00:00Z'), + finishedAt: new Date('2024-01-02T00:01:00Z'), + }, + { + sourceId: source.id, + status: 'running', + startedAt: new Date('2024-01-03T00:00:00Z'), + }, + ], + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/collection-logs?status=success', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(1); + expect(body.data[0].status).toBe('success'); + }); + + it('应支持分页', async () => { + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const data = Array.from({ length: 25 }, () => ({ + sourceId: source.id, + status: 'success' as const, + articlesCount: 5, + startedAt: new Date('2024-01-01T00:00:00Z'), + finishedAt: new Date('2024-01-01T00:01:00Z'), + })); + await prisma.collectionLog.createMany({ data }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/collection-logs?page=2&limit=10', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(10); + expect(body.pagination.total).toBe(25); + expect(body.pagination.page).toBe(2); + }); + + it('应按创建时间倒序排列', async () => { + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const log1 = await prisma.collectionLog.create({ + data: { + sourceId: source.id, + status: 'success', + articlesCount: 5, + startedAt: new Date('2024-01-01T00:00:00Z'), + finishedAt: new Date('2024-01-01T00:01:00Z'), + }, + }); + + // 等待确保时间差 + await new Promise((resolve) => setTimeout(resolve, 10)); + + const log2 = await prisma.collectionLog.create({ + data: { + sourceId: source.id, + status: 'success', + articlesCount: 3, + startedAt: new Date('2024-01-02T00:00:00Z'), + finishedAt: new Date('2024-01-02T00:01:00Z'), + }, + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/collection-logs', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data[0].id).toBe(log2.id); + expect(body.data[1].id).toBe(log1.id); + }); + }); + + describe('GET /api/v1/collection-logs/stats', () => { + it('应返回所有数据源的统计信息', async () => { + const source1 = await prisma.source.create({ + data: { + name: 'RSS 源 1', + type: 'rss', + config: { url: 'https://example.com/rss1' }, + cronExpression: '0 * * * *', + enabled: true, + lastCollectedAt: new Date('2024-01-15T10:00:00Z'), + }, + }); + + const source2 = await prisma.source.create({ + data: { + name: 'API 源 1', + type: 'api', + config: { url: 'https://api.example.com' }, + cronExpression: '0 * * * *', + enabled: false, + }, + }); + + // 为源 1 创建文章 + await prisma.article.createMany({ + data: [ + { + sourceId: source1.id, + title: '文章 1', + url: 'https://example.com/1', + content: '内容', + collectedAt: new Date('2024-01-01T00:00:00Z'), + }, + { + sourceId: source1.id, + title: '文章 2', + url: 'https://example.com/2', + content: '内容', + collectedAt: new Date('2024-01-01T00:00:00Z'), + }, + { + sourceId: source1.id, + title: '文章 3', + url: 'https://example.com/3', + content: '内容', + collectedAt: new Date('2024-01-01T00:00:00Z'), + }, + ], + }); + + // 为源 1 创建采集日志 + await prisma.collectionLog.createMany({ + data: [ + { + sourceId: source1.id, + status: 'success', + articlesCount: 3, + startedAt: new Date('2024-01-15T10:00:00Z'), + finishedAt: new Date('2024-01-15T10:01:00Z'), + }, + { + sourceId: source1.id, + status: 'failed', + errorMessage: '超时', + startedAt: new Date('2024-01-14T10:00:00Z'), + finishedAt: new Date('2024-01-14T10:01:00Z'), + }, + ], + }); + + // 为源 2 创建文章 + await prisma.article.create({ + data: { + sourceId: source2.id, + title: '文章 4', + url: 'https://example.com/4', + content: '内容', + collectedAt: new Date('2024-01-01T00:00:00Z'), + }, + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/collection-logs/stats', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(2); + + const stats1 = body.data.find((s: any) => s.id === source1.id); + expect(stats1).toBeDefined(); + expect(stats1.name).toBe('RSS 源 1'); + expect(stats1.type).toBe('rss'); + expect(stats1.enabled).toBe(true); + expect(stats1.totalArticles).toBe(3); + expect(stats1.totalCollections).toBe(2); + expect(stats1.lastCollectedAt).toBeDefined(); + expect(stats1.lastLog).toBeDefined(); + expect(stats1.lastLog.status).toBe('success'); + + const stats2 = body.data.find((s: any) => s.id === source2.id); + expect(stats2).toBeDefined(); + expect(stats2.name).toBe('API 源 1'); + expect(stats2.enabled).toBe(false); + expect(stats2.totalArticles).toBe(1); + expect(stats2.totalCollections).toBe(0); + expect(stats2.lastCollectedAt).toBeNull(); + expect(stats2.lastLog).toBeNull(); + }); + + it('应返回空数组当没有数据源时', async () => { + const response = await app.inject({ + method: 'GET', + url: '/api/v1/collection-logs/stats', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toEqual([]); + }); + }); +}); diff --git a/backend/tests/health.test.ts b/backend/tests/health.test.ts new file mode 100644 index 0000000..0681b6e --- /dev/null +++ b/backend/tests/health.test.ts @@ -0,0 +1,50 @@ +import { beforeAll, afterAll, describe, it, expect } from 'vitest'; +import { createTestApp } from './helpers/app'; +import { cleanupDatabase, prisma } from './setup'; + +describe('健康检查 API', () => { + let app: Awaited>; + + beforeAll(async () => { + app = await createTestApp(); + await cleanupDatabase(); + }); + + afterAll(async () => { + await app.close(); + await cleanupDatabase(); + }); + + describe('GET /api/v1/health', () => { + it('应返回健康状态', async () => { + const response = await app.inject({ + method: 'GET', + url: '/api/v1/health', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.success).toBe(true); + expect(body.data.status).toBe('ok'); + expect(body.data.timestamp).toBeDefined(); + expect(body.data.version).toBe('1.0.0'); + }); + }); + + describe('GET /api/v1/health/detailed', () => { + it('应返回详细的健康状态包括数据库检查', async () => { + const response = await app.inject({ + method: 'GET', + url: '/api/v1/health/detailed', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.success).toBe(true); + expect(body.data.status).toBe('ok'); + expect(body.data.checks).toBeDefined(); + expect(body.data.checks.server).toBe('ok'); + expect(body.data.checks.database).toBe('ok'); + }); + }); +}); diff --git a/backend/tests/helpers/app.ts b/backend/tests/helpers/app.ts new file mode 100644 index 0000000..4a502f1 --- /dev/null +++ b/backend/tests/helpers/app.ts @@ -0,0 +1,73 @@ +import Fastify from 'fastify'; +import cors from '@fastify/cors'; +import { healthRoutes } from '../../src/web/routes/health'; +import { llmConfigRoutes } from '../../src/web/routes/llm-configs'; +import { sourceRoutes } from '../../src/web/routes/sources'; +import { channelRoutes } from '../../src/web/routes/channels'; +import { topicRoutes } from '../../src/web/routes/topics'; +import { reportRoutes } from '../../src/web/routes/reports'; +import { articleRoutes } from '../../src/web/routes/articles'; +import { collectionLogRoutes } from '../../src/web/routes/collection-logs'; +import { AppError } from '../../src/utils/errors'; + +/** + * 创建用于测试的 Fastify 应用实例 + */ +export async function createTestApp() { + const app = Fastify({ + logger: false, + }); + + // 注册 CORS + await app.register(cors, { + origin: true, + credentials: true, + }); + + // 简单的错误处理器(复制自 error-handler.ts) + app.setErrorHandler(async (error, request, reply) => { + if (error instanceof AppError) { + return reply.status(error.statusCode).send({ + success: false, + error: error.message, + ...(error instanceof Error && process.env.NODE_ENV === 'development' && { + stack: error.stack, + }), + }); + } + + // 处理验证错误 + if (error.validation) { + return reply.status(400).send({ + success: false, + error: '请求参数验证失败', + details: error.validation, + }); + } + + // 未知错误 + reply.status(500).send({ + success: false, + error: '服务器内部错误', + }); + }); + + // 注册路由 + await app.register(healthRoutes, { prefix: '/api/v1' }); + await app.register(llmConfigRoutes, { prefix: '/api/v1/llm-configs' }); + await app.register(sourceRoutes, { prefix: '/api/v1/sources' }); + await app.register(channelRoutes, { prefix: '/api/v1/channels' }); + await app.register(topicRoutes, { prefix: '/api/v1/topics' }); + await app.register(reportRoutes, { prefix: '/api/v1/reports' }); + await app.register(articleRoutes, { prefix: '/api/v1/articles' }); + await app.register(collectionLogRoutes, { prefix: '/api/v1/collection-logs' }); + + return app; +} + +/** + * 等待一段时间(用于异步操作) + */ +export function wait(ms: number): Promise { + return new Promise((resolve) => setTimeout(resolve, ms)); +} diff --git a/backend/tests/llm-configs.test.ts b/backend/tests/llm-configs.test.ts new file mode 100644 index 0000000..35d63de --- /dev/null +++ b/backend/tests/llm-configs.test.ts @@ -0,0 +1,267 @@ +import { beforeAll, afterAll, beforeEach, describe, it, expect } from 'vitest'; +import { createTestApp } from './helpers/app'; +import { cleanupDatabase, prisma } from './setup'; + +describe('LLM 配置 API', () => { + let app: Awaited>; + + beforeAll(async () => { + app = await createTestApp(); + }); + + beforeEach(async () => { + await cleanupDatabase(); + }); + + afterAll(async () => { + await app.close(); + await cleanupDatabase(); + }); + + describe('POST /api/v1/llm-configs', () => { + it('应成功创建 LLM 配置', async () => { + const payload = { + name: 'OpenAI 测试配置', + baseUrl: 'https://api.openai.com/v1', + model: 'gpt-4', + apiKey: 'sk-test123', + enabled: true, + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/llm-configs', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.success).toBe(true); + expect(body.message).toBe('LLM 配置创建成功'); + expect(body.data.name).toBe(payload.name); + expect(body.data.baseUrl).toBe(payload.baseUrl); + expect(body.data.model).toBe(payload.model); + expect(body.data.apiKey).toBe(payload.apiKey); + expect(body.data.enabled).toBe(true); + expect(body.data.id).toBeDefined(); + }); + + it('缺少必填字段时应返回 400 错误', async () => { + const payload = { + name: '不完整配置', + baseUrl: 'https://api.openai.com/v1', + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/llm-configs', + payload, + }); + + expect(response.statusCode).toBe(400); + const body = JSON.parse(response.body); + expect(body.success).toBe(false); + expect(body.error).toContain('缺少必填字段'); + }); + + it('enabled 默认值应为 true', async () => { + const payload = { + name: 'OpenAI 测试配置', + baseUrl: 'https://api.openai.com/v1', + model: 'gpt-4', + apiKey: 'sk-test123', + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/llm-configs', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.data.enabled).toBe(true); + }); + }); + + describe('GET /api/v1/llm-configs', () => { + it('应返回配置列表', async () => { + // 创建测试数据 + await prisma.llmConfig.createMany({ + data: [ + { + name: '配置 1', + baseUrl: 'https://api.openai.com/v1', + model: 'gpt-4', + apiKey: 'sk-key1', + enabled: true, + }, + { + name: '配置 2', + baseUrl: 'https://api.anthropic.com/v1', + model: 'claude-3', + apiKey: 'sk-key2', + enabled: false, + }, + ], + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/llm-configs', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(2); + expect(body.pagination.total).toBe(2); + expect(body.pagination.page).toBe(1); + expect(body.pagination.limit).toBe(20); + }); + + it('应支持分页', async () => { + // 创建 25 条数据 + const data = Array.from({ length: 25 }, (_, i) => ({ + name: `配置 ${i + 1}`, + baseUrl: 'https://api.openai.com/v1', + model: 'gpt-4', + apiKey: `sk-key${i}`, + enabled: true, + })); + await prisma.llmConfig.createMany({ data }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/llm-configs?page=2&limit=10', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(10); + expect(body.pagination.total).toBe(25); + expect(body.pagination.page).toBe(2); + }); + }); + + describe('GET /api/v1/llm-configs/:id', () => { + it('应返回单个配置', async () => { + const config = await prisma.llmConfig.create({ + data: { + name: '测试配置', + baseUrl: 'https://api.openai.com/v1', + model: 'gpt-4', + apiKey: 'sk-test', + enabled: true, + }, + }); + + const response = await app.inject({ + method: 'GET', + url: `/api/v1/llm-configs/${config.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data.id).toBe(config.id); + expect(body.data.name).toBe('测试配置'); + }); + + it('配置不存在时应返回 404', async () => { + const response = await app.inject({ + method: 'GET', + url: '/api/v1/llm-configs/99999', + }); + + expect(response.statusCode).toBe(404); + const body = JSON.parse(response.body); + expect(body.success).toBe(false); + expect(body.error).toContain('LLM 配置不存在'); + }); + }); + + describe('PUT /api/v1/llm-configs/:id', () => { + it('应成功更新配置', async () => { + const config = await prisma.llmConfig.create({ + data: { + name: '原始配置', + baseUrl: 'https://api.openai.com/v1', + model: 'gpt-4', + apiKey: 'sk-test', + enabled: true, + }, + }); + + const updateData = { + name: '更新后配置', + model: 'gpt-4-turbo', + enabled: false, + }; + + const response = await app.inject({ + method: 'PUT', + url: `/api/v1/llm-configs/${config.id}`, + payload: updateData, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data.name).toBe('更新后配置'); + expect(body.data.model).toBe('gpt-4-turbo'); + expect(body.data.enabled).toBe(false); + expect(body.message).toBe('LLM 配置更新成功'); + }); + + it('更新不存在的配置时应返回 404', async () => { + const response = await app.inject({ + method: 'PUT', + url: '/api/v1/llm-configs/99999', + payload: { + name: '更新', + baseUrl: 'https://api.openai.com/v1', + model: 'gpt-4', + apiKey: 'sk-test', + }, + }); + + expect(response.statusCode).toBe(404); + }); + }); + + describe('DELETE /api/v1/llm-configs/:id', () => { + it('应成功删除配置', async () => { + const config = await prisma.llmConfig.create({ + data: { + name: '待删除配置', + baseUrl: 'https://api.openai.com/v1', + model: 'gpt-4', + apiKey: 'sk-test', + enabled: true, + }, + }); + + const response = await app.inject({ + method: 'DELETE', + url: `/api/v1/llm-configs/${config.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.message).toBe('LLM 配置删除成功'); + + // 验证已被删除 + const deleted = await prisma.llmConfig.findUnique({ + where: { id: config.id }, + }); + expect(deleted).toBeNull(); + }); + + it('删除不存在的配置时应返回 404', async () => { + const response = await app.inject({ + method: 'DELETE', + url: '/api/v1/llm-configs/99999', + }); + + expect(response.statusCode).toBe(404); + }); + }); +}); diff --git a/backend/tests/reports.test.ts b/backend/tests/reports.test.ts new file mode 100644 index 0000000..cd98f67 --- /dev/null +++ b/backend/tests/reports.test.ts @@ -0,0 +1,307 @@ +import { beforeAll, afterAll, beforeEach, describe, it, expect } from 'vitest'; +import { createTestApp } from './helpers/app'; +import { cleanupDatabase, prisma } from './setup'; + +describe('报告 API', () => { + let app: Awaited>; + + beforeAll(async () => { + app = await createTestApp(); + }); + + beforeEach(async () => { + await cleanupDatabase(); + }); + + afterAll(async () => { + await app.close(); + await cleanupDatabase(); + }); + + describe('GET /api/v1/reports', () => { + it('应返回报告列表', async () => { + const topic = await prisma.topic.create({ + data: { + name: 'AI 资讯', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + }, + }); + + await prisma.report.createMany({ + data: [ + { + title: '报告 1', + topicId: topic.id, + status: 'completed', + content: '报告内容 1', + periodStart: new Date('2024-01-01'), + periodEnd: new Date('2024-01-07'), + }, + { + title: '报告 2', + topicId: topic.id, + status: 'pending', + content: '', + periodStart: new Date('2024-01-08'), + periodEnd: new Date('2024-01-14'), + }, + ], + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/reports', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(2); + expect(body.pagination.total).toBe(2); + expect(body.data[0].topic).toBeDefined(); + }); + + it('应支持按主题 ID 筛选', async () => { + const topic1 = await prisma.topic.create({ + data: { + name: '主题 1', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + }, + }); + + const topic2 = await prisma.topic.create({ + data: { + name: '主题 2', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + }, + }); + + await prisma.report.create({ + data: { + title: '报告 1', + topicId: topic1.id, + status: 'completed', + content: '报告 1', + periodStart: new Date('2024-01-01'), + periodEnd: new Date('2024-01-07'), + }, + }); + + await prisma.report.create({ + data: { + title: '报告 2', + topicId: topic2.id, + status: 'completed', + content: '报告 2', + periodStart: new Date('2024-01-01'), + periodEnd: new Date('2024-01-07'), + }, + }); + + const response = await app.inject({ + method: 'GET', + url: `/api/v1/reports?topicId=${topic1.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(1); + expect(body.data[0].topicId).toBe(topic1.id); + }); + + it('应支持按状态筛选', async () => { + const topic = await prisma.topic.create({ + data: { + name: 'AI 资讯', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + }, + }); + + await prisma.report.createMany({ + data: [ + { + title: '完成报告', + topicId: topic.id, + status: 'completed', + content: '完成', + periodStart: new Date('2024-01-01'), + periodEnd: new Date('2024-01-07'), + }, + { + title: '待处理报告', + topicId: topic.id, + status: 'pending', + content: '', + periodStart: new Date('2024-01-08'), + periodEnd: new Date('2024-01-14'), + }, + { + title: '失败报告', + topicId: topic.id, + status: 'failed', + errorMessage: '失败', + content: '', + periodStart: new Date('2024-01-15'), + periodEnd: new Date('2024-01-21'), + }, + ], + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/reports?status=completed', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(1); + expect(body.data[0].status).toBe('completed'); + }); + + it('应支持分页', async () => { + const topic = await prisma.topic.create({ + data: { + name: 'AI 资讯', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + }, + }); + + const data = Array.from({ length: 25 }, (_, i) => ({ + title: `报告 ${i + 1}`, + topicId: topic.id, + status: 'completed' as const, + content: '报告内容', + periodStart: new Date('2024-01-01'), + periodEnd: new Date('2024-01-07'), + })); + await prisma.report.createMany({ data }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/reports?page=2&limit=10', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(10); + expect(body.pagination.total).toBe(25); + expect(body.pagination.page).toBe(2); + }); + }); + + describe('GET /api/v1/reports/:id', () => { + it('应返回单个报告及关联的主题数据', async () => { + const llmConfig = await prisma.llmConfig.create({ + data: { + name: 'OpenAI', + baseUrl: 'https://api.openai.com/v1', + model: 'gpt-4', + apiKey: 'sk-test', + enabled: true, + }, + }); + + const topic = await prisma.topic.create({ + data: { + name: 'AI 资讯', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + llmConfigId: llmConfig.id, + enabled: true, + }, + }); + + const report = await prisma.report.create({ + data: { + title: 'AI 资讯周报', + topicId: topic.id, + status: 'completed', + content: '这是 AI 资讯周报', + periodStart: new Date('2024-01-01'), + periodEnd: new Date('2024-01-07'), + }, + }); + + const response = await app.inject({ + method: 'GET', + url: `/api/v1/reports/${report.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data.id).toBe(report.id); + expect(body.data.content).toBe('这是 AI 资讯周报'); + expect(body.data.topic).toBeDefined(); + expect(body.data.topic.llmConfig).toBeDefined(); + expect(body.data.topic.llmConfig.name).toBe('OpenAI'); + }); + + it('报告不存在时应返回 404', async () => { + const response = await app.inject({ + method: 'GET', + url: '/api/v1/reports/99999', + }); + + expect(response.statusCode).toBe(404); + const body = JSON.parse(response.body); + expect(body.success).toBe(false); + expect(body.error).toContain('报告不存在'); + }); + }); + + describe('DELETE /api/v1/reports/:id', () => { + it('应成功删除报告', async () => { + const topic = await prisma.topic.create({ + data: { + name: 'AI 资讯', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + }, + }); + + const report = await prisma.report.create({ + data: { + title: '待删除报告', + topicId: topic.id, + status: 'completed', + content: '报告内容', + periodStart: new Date('2024-01-01'), + periodEnd: new Date('2024-01-07'), + }, + }); + + const response = await app.inject({ + method: 'DELETE', + url: `/api/v1/reports/${report.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.message).toBe('报告删除成功'); + + const deleted = await prisma.report.findUnique({ + where: { id: report.id }, + }); + expect(deleted).toBeNull(); + }); + + it('删除不存在的报告时应返回 404', async () => { + const response = await app.inject({ + method: 'DELETE', + url: '/api/v1/reports/99999', + }); + + expect(response.statusCode).toBe(404); + }); + }); +}); diff --git a/backend/tests/setup.ts b/backend/tests/setup.ts new file mode 100644 index 0000000..8556760 --- /dev/null +++ b/backend/tests/setup.ts @@ -0,0 +1,45 @@ +import { PrismaClient } from '@prisma/client'; + +// 使用单独的测试数据库 URL(如果配置了)或默认数据库 +const testDatabaseUrl = process.env.TEST_DATABASE_URL || process.env.DATABASE_URL; + +const prisma = new PrismaClient({ + datasources: { + db: { + url: testDatabaseUrl, + }, + }, +}); + +export async function setup() { + await prisma.$connect(); + console.log('测试数据库已连接'); +} + +export async function teardown() { + await prisma.$disconnect(); + console.log('测试数据库已断开'); +} + +// 清理数据库(按依赖关系顺序删除表以避免外键约束) +export async function cleanupDatabase() { + // 按依赖关系顺序删除(从最底层的依赖开始) + // 删除所有关联和日志表 + await prisma.pushLog.deleteMany({}); + await prisma.conversation.deleteMany({}); + await prisma.article.deleteMany({}); + await prisma.report.deleteMany({}); + await prisma.collectionLog.deleteMany({}); + + // 删除关联表(在删除主表之前) + await prisma.topicSource.deleteMany({}); + await prisma.topicChannel.deleteMany({}); + + // 删除主表 + await prisma.topic.deleteMany({}); + await prisma.channel.deleteMany({}); + await prisma.source.deleteMany({}); + await prisma.llmConfig.deleteMany({}); +} + +export { prisma }; diff --git a/backend/tests/sources.test.ts b/backend/tests/sources.test.ts new file mode 100644 index 0000000..c162c97 --- /dev/null +++ b/backend/tests/sources.test.ts @@ -0,0 +1,385 @@ +import { beforeAll, afterAll, beforeEach, describe, it, expect } from 'vitest'; +import { createTestApp } from './helpers/app'; +import { cleanupDatabase, prisma } from './setup'; + +describe('数据源 API', () => { + let app: Awaited>; + + beforeAll(async () => { + app = await createTestApp(); + }); + + beforeEach(async () => { + await cleanupDatabase(); + }); + + afterAll(async () => { + await app.close(); + await cleanupDatabase(); + }); + + describe('POST /api/v1/sources', () => { + it('应成功创建 RSS 类型的数据源', async () => { + const payload = { + name: '技术博客 RSS', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 */6 * * *', + enabled: true, + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/sources', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.success).toBe(true); + expect(body.message).toBe('数据源创建成功'); + expect(body.data.name).toBe(payload.name); + expect(body.data.type).toBe('rss'); + }); + + it('应成功创建 API 类型的数据源', async () => { + const payload = { + name: '新闻 API', + type: 'api', + config: { + url: 'https://api.example.com/news', + headers: { Authorization: 'Bearer token' }, + }, + cronExpression: '0 * * * *', + enabled: true, + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/sources', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.data.type).toBe('api'); + }); + + it('应成功创建 Playwright 类型的数据源', async () => { + const payload = { + name: '爬虫数据源', + type: 'playwright', + config: { + url: 'https://example.com', + selectors: { + title: '.title', + content: '.content', + }, + }, + cronExpression: '0 0 * * *', + enabled: true, + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/sources', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.data.type).toBe('playwright'); + }); + + it('缺少必填字段时应返回 400 错误', async () => { + const payload = { + name: '不完整数据源', + type: 'rss', + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/sources', + payload, + }); + + expect(response.statusCode).toBe(400); + const body = JSON.parse(response.body); + expect(body.success).toBe(false); + expect(body.error).toContain('缺少必填字段'); + }); + + it('enabled 默认值应为 true', async () => { + const payload = { + name: '测试数据源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/sources', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.data.enabled).toBe(true); + }); + }); + + describe('GET /api/v1/sources', () => { + it('应返回数据源列表', async () => { + await prisma.source.createMany({ + data: [ + { + name: 'RSS 源 1', + type: 'rss', + config: { url: 'https://example.com/rss1' }, + cronExpression: '0 * * * *', + enabled: true, + }, + { + name: 'API 源 1', + type: 'api', + config: { url: 'https://api.example.com' }, + cronExpression: '0 * * * *', + enabled: true, + }, + ], + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/sources', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(2); + expect(body.pagination.total).toBe(2); + }); + + it('应支持按类型筛选', async () => { + await prisma.source.createMany({ + data: [ + { + name: 'RSS 源 1', + type: 'rss', + config: { url: 'https://example.com/rss1' }, + cronExpression: '0 * * * *', + enabled: true, + }, + { + name: 'API 源 1', + type: 'api', + config: { url: 'https://api.example.com' }, + cronExpression: '0 * * * *', + enabled: true, + }, + ], + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/sources?type=rss', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(1); + expect(body.data[0].type).toBe('rss'); + }); + + it('应支持分页', async () => { + const data = Array.from({ length: 25 }, (_, i) => ({ + name: `源 ${i + 1}`, + type: 'rss' as const, + config: { url: `https://example.com/rss${i}` }, + cronExpression: '0 * * * *', + enabled: true, + })); + await prisma.source.createMany({ data }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/sources?page=2&limit=10', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(10); + expect(body.pagination.total).toBe(25); + expect(body.pagination.page).toBe(2); + }); + }); + + describe('GET /api/v1/sources/:id', () => { + it('应返回单个数据源及其关联的主题', async () => { + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const topic = await prisma.topic.create({ + data: { + name: '测试主题', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * *' }, + enabled: true, + }, + }); + + await prisma.topicSource.create({ + data: { + topicId: topic.id, + sourceId: source.id, + }, + }); + + const response = await app.inject({ + method: 'GET', + url: `/api/v1/sources/${source.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data.id).toBe(source.id); + expect(body.data.topicSources).toHaveLength(1); + expect(body.data.topicSources[0].topic.name).toBe('测试主题'); + }); + + it('数据源不存在时应返回 404', async () => { + const response = await app.inject({ + method: 'GET', + url: '/api/v1/sources/99999', + }); + + expect(response.statusCode).toBe(404); + const body = JSON.parse(response.body); + expect(body.success).toBe(false); + expect(body.error).toContain('数据源不存在'); + }); + }); + + describe('PUT /api/v1/sources/:id', () => { + it('应成功更新数据源', async () => { + const source = await prisma.source.create({ + data: { + name: '原始源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const updateData = { + name: '更新后源', + enabled: false, + }; + + const response = await app.inject({ + method: 'PUT', + url: `/api/v1/sources/${source.id}`, + payload: updateData, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data.name).toBe('更新后源'); + expect(body.data.enabled).toBe(false); + expect(body.message).toBe('数据源更新成功'); + }); + + it('更新不存在的数据源时应返回 404', async () => { + const response = await app.inject({ + method: 'PUT', + url: '/api/v1/sources/99999', + payload: { + name: '更新', + type: 'rss', + config: { url: 'https://example.com' }, + cronExpression: '0 * * * *', + }, + }); + + expect(response.statusCode).toBe(404); + }); + }); + + describe('DELETE /api/v1/sources/:id', () => { + it('应成功删除数据源', async () => { + const source = await prisma.source.create({ + data: { + name: '待删除源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const response = await app.inject({ + method: 'DELETE', + url: `/api/v1/sources/${source.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.message).toBe('数据源删除成功'); + + const deleted = await prisma.source.findUnique({ + where: { id: source.id }, + }); + expect(deleted).toBeNull(); + }); + + it('删除不存在的数据源时应返回 404', async () => { + const response = await app.inject({ + method: 'DELETE', + url: '/api/v1/sources/99999', + }); + + expect(response.statusCode).toBe(404); + }); + }); + + describe('POST /api/v1/sources/:id/collect', () => { + it('应触发采集任务', async () => { + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const response = await app.inject({ + method: 'POST', + url: `/api/v1/sources/${source.id}/collect`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.message).toBe('采集任务已触发'); + }); + + it('数据源不存在时应返回 404', async () => { + const response = await app.inject({ + method: 'POST', + url: '/api/v1/sources/99999/collect', + }); + + expect(response.statusCode).toBe(404); + }); + }); +}); diff --git a/backend/tests/topics.test.ts b/backend/tests/topics.test.ts new file mode 100644 index 0000000..974dc6a --- /dev/null +++ b/backend/tests/topics.test.ts @@ -0,0 +1,440 @@ +import { beforeAll, afterAll, beforeEach, describe, it, expect } from 'vitest'; +import { createTestApp } from './helpers/app'; +import { cleanupDatabase, prisma } from './setup'; + +describe('主题 API', () => { + let app: Awaited>; + + beforeAll(async () => { + app = await createTestApp(); + }); + + beforeEach(async () => { + await cleanupDatabase(); + }); + + afterAll(async () => { + await app.close(); + await cleanupDatabase(); + }); + + describe('POST /api/v1/topics', () => { + it('应成功创建主题', async () => { + const payload = { + name: 'AI 技术资讯', + description: '收集 AI 相关的技术文章', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/topics', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.success).toBe(true); + expect(body.message).toBe('主题创建成功'); + expect(body.data.name).toBe(payload.name); + expect(body.data.processMode).toBe('summary'); + }); + + it('应成功创建主题并关联数据源和推送渠道', async () => { + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const channel = await prisma.channel.create({ + data: { + name: '测试渠道', + type: 'email', + config: { to: 'test@example.com' }, + enabled: true, + }, + }); + + const payload = { + name: '完整配置主题', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + sourceIds: [source.id], + channelIds: [channel.id], + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/topics', + payload, + }); + + expect(response.statusCode).toBe(201); + + // 验证关联关系 + const topicSources = await prisma.topicSource.findMany({ + where: { sourceId: source.id }, + }); + expect(topicSources).toHaveLength(1); + + const topicChannels = await prisma.topicChannel.findMany({ + where: { channelId: channel.id }, + }); + expect(topicChannels).toHaveLength(1); + }); + + it('应支持关联 LLM 配置', async () => { + const llmConfig = await prisma.llmConfig.create({ + data: { + name: 'OpenAI', + baseUrl: 'https://api.openai.com/v1', + model: 'gpt-4', + apiKey: 'sk-test', + enabled: true, + }, + }); + + const payload = { + name: 'AI 资讯', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + llmConfigId: llmConfig.id, + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/topics', + payload, + }); + + expect(response.statusCode).toBe(201); + const body = JSON.parse(response.body); + expect(body.data.llmConfigId).toBe(llmConfig.id); + }); + + it('缺少必填字段时应返回 400 错误', async () => { + const payload = { + name: '不完整主题', + }; + + const response = await app.inject({ + method: 'POST', + url: '/api/v1/topics', + payload, + }); + + expect(response.statusCode).toBe(400); + const body = JSON.parse(response.body); + expect(body.success).toBe(false); + expect(body.error).toContain('缺少必填字段'); + }); + }); + + describe('GET /api/v1/topics', () => { + it('应返回主题列表及关联数据', async () => { + const llmConfig = await prisma.llmConfig.create({ + data: { + name: 'OpenAI', + baseUrl: 'https://api.openai.com/v1', + model: 'gpt-4', + apiKey: 'sk-test', + enabled: true, + }, + }); + + const topic = await prisma.topic.create({ + data: { + name: 'AI 资讯', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + llmConfigId: llmConfig.id, + enabled: true, + }, + }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/topics', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(1); + expect(body.data[0].llmConfig).toBeDefined(); + expect(body.data[0].llmConfig.name).toBe('OpenAI'); + }); + + it('应支持分页', async () => { + const data = Array.from({ length: 25 }, (_, i) => ({ + name: `主题 ${i + 1}`, + processMode: 'summary' as const, + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + })); + await prisma.topic.createMany({ data }); + + const response = await app.inject({ + method: 'GET', + url: '/api/v1/topics?page=2&limit=10', + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data).toHaveLength(10); + expect(body.pagination.total).toBe(25); + expect(body.pagination.page).toBe(2); + }); + }); + + describe('GET /api/v1/topics/:id', () => { + it('应返回单个主题及其完整关联数据', async () => { + const llmConfig = await prisma.llmConfig.create({ + data: { + name: 'OpenAI', + baseUrl: 'https://api.openai.com/v1', + model: 'gpt-4', + apiKey: 'sk-test', + enabled: true, + }, + }); + + const source = await prisma.source.create({ + data: { + name: '测试源', + type: 'rss', + config: { url: 'https://example.com/rss' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const channel = await prisma.channel.create({ + data: { + name: '测试渠道', + type: 'email', + config: { to: 'test@example.com' }, + enabled: true, + }, + }); + + const topic = await prisma.topic.create({ + data: { + name: 'AI 资讯', + description: 'AI 技术文章', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + llmConfigId: llmConfig.id, + enabled: true, + }, + }); + + await prisma.topicSource.create({ + data: { topicId: topic.id, sourceId: source.id }, + }); + + await prisma.topicChannel.create({ + data: { topicId: topic.id, channelId: channel.id }, + }); + + const response = await app.inject({ + method: 'GET', + url: `/api/v1/topics/${topic.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data.id).toBe(topic.id); + expect(body.data.llmConfig).toBeDefined(); + expect(body.data.topicSources).toHaveLength(1); + expect(body.data.topicSources[0].source.name).toBe('测试源'); + expect(body.data.topicChannels).toHaveLength(1); + expect(body.data.topicChannels[0].channel.name).toBe('测试渠道'); + }); + + it('主题不存在时应返回 404', async () => { + const response = await app.inject({ + method: 'GET', + url: '/api/v1/topics/99999', + }); + + expect(response.statusCode).toBe(404); + }); + }); + + describe('PUT /api/v1/topics/:id', () => { + it('应成功更新主题', async () => { + const topic = await prisma.topic.create({ + data: { + name: '原始主题', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + }, + }); + + const updateData = { + name: '更新后主题', + description: '新描述', + enabled: false, + }; + + const response = await app.inject({ + method: 'PUT', + url: `/api/v1/topics/${topic.id}`, + payload: updateData, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.data.name).toBe('更新后主题'); + expect(body.data.description).toBe('新描述'); + expect(body.data.enabled).toBe(false); + expect(body.message).toBe('主题更新成功'); + }); + + it('应更新数据源和渠道关联', async () => { + const source1 = await prisma.source.create({ + data: { + name: '源 1', + type: 'rss', + config: { url: 'https://example.com/rss1' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const source2 = await prisma.source.create({ + data: { + name: '源 2', + type: 'rss', + config: { url: 'https://example.com/rss2' }, + cronExpression: '0 * * * *', + enabled: true, + }, + }); + + const topic = await prisma.topic.create({ + data: { + name: '测试主题', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + }, + }); + + // 初始关联 + await prisma.topicSource.create({ + data: { topicId: topic.id, sourceId: source1.id }, + }); + + // 更新关联 + const response = await app.inject({ + method: 'PUT', + url: `/api/v1/topics/${topic.id}`, + payload: { + name: '测试主题', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + sourceIds: [source2.id], + }, + }); + + expect(response.statusCode).toBe(200); + + // 验证关联已更新 + const topicSources = await prisma.topicSource.findMany({ + where: { topicId: topic.id }, + }); + expect(topicSources).toHaveLength(1); + expect(topicSources[0].sourceId).toBe(source2.id); + }); + + it('更新不存在的主题时应返回 404', async () => { + const response = await app.inject({ + method: 'PUT', + url: '/api/v1/topics/99999', + payload: { + name: '更新', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + }, + }); + + expect(response.statusCode).toBe(404); + }); + }); + + describe('DELETE /api/v1/topics/:id', () => { + it('应成功删除主题', async () => { + const topic = await prisma.topic.create({ + data: { + name: '待删除主题', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + }, + }); + + const response = await app.inject({ + method: 'DELETE', + url: `/api/v1/topics/${topic.id}`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.message).toBe('主题删除成功'); + + const deleted = await prisma.topic.findUnique({ + where: { id: topic.id }, + }); + expect(deleted).toBeNull(); + }); + + it('删除不存在的主题时应返回 404', async () => { + const response = await app.inject({ + method: 'DELETE', + url: '/api/v1/topics/99999', + }); + + expect(response.statusCode).toBe(404); + }); + }); + + describe('POST /api/v1/topics/:id/generate-report', () => { + it('应触发报告生成任务', async () => { + const topic = await prisma.topic.create({ + data: { + name: 'AI 资讯', + processMode: 'summary', + scheduleConfig: { cron: '0 0 * * 0' }, + enabled: true, + }, + }); + + const response = await app.inject({ + method: 'POST', + url: `/api/v1/topics/${topic.id}/generate-report`, + }); + + expect(response.statusCode).toBe(200); + const body = JSON.parse(response.body); + expect(body.message).toBe('报告生成任务已触发'); + }); + + it('主题不存在时应返回 404', async () => { + const response = await app.inject({ + method: 'POST', + url: '/api/v1/topics/99999/generate-report', + }); + + expect(response.statusCode).toBe(404); + }); + }); +}); diff --git a/backend/tsconfig.json b/backend/tsconfig.json index f2a0442..9ebed6c 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -4,7 +4,7 @@ "module": "commonjs", "lib": ["ES2022"], "outDir": "./dist", - "rootDir": "./src", + "rootDir": "./", "strict": true, "esModuleInterop": true, "skipLibCheck": true, @@ -13,6 +13,6 @@ "moduleResolution": "node", "types": ["node"] }, - "include": ["src/**/*"], + "include": ["src/**/*", "tests/**/*"], "exclude": ["node_modules", "dist"] } diff --git a/backend/vitest.config.ts b/backend/vitest.config.ts new file mode 100644 index 0000000..07effd7 --- /dev/null +++ b/backend/vitest.config.ts @@ -0,0 +1,23 @@ +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + globals: true, + environment: 'node', + testTimeout: 30000, + hookTimeout: 30000, + include: ['tests/**/*.test.ts'], + setupFiles: ['tests/setup.ts'], + // 串行执行测试以避免数据库竞争 + fileParallelism: false, + maxConcurrency: 1, + alias: { + '@': new URL('./src', import.meta.url).pathname, + }, + }, + resolve: { + alias: { + '@': '/src', + }, + }, +});