From 50a35732ff202f2452b344c2df17aba677426ec3 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 1 Oct 2024 07:37:27 +0800 Subject: [PATCH] feat: add zeromq to make sure lighthouse can only run one at same time and add socketio notify to refresh list --- pnpm-lock.yaml | 392 ++++++++++++++++-- src/client/api/socketio.ts | 19 +- .../components/server/AddServerStep.tsx | 4 +- src/client/components/server/useServerMap.ts | 4 +- .../website/WebsiteLighthouseBtn.tsx | 11 + src/server/main.ts | 3 + src/server/mq/producer.ts | 21 + src/server/mq/shared.ts | 1 + src/server/mq/worker.ts | 85 ++++ src/server/package.json | 1 + src/server/trpc/routers/website.ts | 56 +-- src/server/ws/shared.ts | 1 + 12 files changed, 507 insertions(+), 91 deletions(-) create mode 100644 src/server/mq/producer.ts create mode 100644 src/server/mq/shared.ts create mode 100644 src/server/mq/worker.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7e6792c..7b9de42 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -138,7 +138,7 @@ importers: version: 3.3.4(react-hook-form@7.51.1(react@18.2.0)) '@i18next-toolkit/react': specifier: ^1.1.0 - version: 1.1.0(@types/react@18.2.78)(buffer@6.0.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 1.1.0(@types/react@18.2.78)(buffer@6.0.3)(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@loadable/component': specifier: ^5.16.3 version: 5.16.3(react@18.2.0) @@ -361,7 +361,7 @@ importers: version: 0.34.1(nodemailer@6.9.8) '@i18next-toolkit/cli': specifier: ^1.4.3 - version: 1.4.3(buffer@6.0.3)(openai@4.63.0(zod@3.22.2))(typescript@5.5.4) + version: 1.4.3(buffer@6.0.3)(encoding@0.1.13)(openai@4.63.0(encoding@0.1.13)(zod@3.22.2))(typescript@5.5.4) '@tanstack/router-vite-plugin': specifier: 1.20.5 version: 1.20.5 @@ -569,6 +569,9 @@ importers: yup: specifier: ^1.3.3 version: 1.3.3 + zeromq: + specifier: ^6.0.4 + version: 6.0.4 zod: specifier: ^3.22.2 version: 3.22.2 @@ -653,7 +656,7 @@ importers: version: 3.0.3(prisma@5.14.0)(typescript@5.5.4) prisma-zod-generator: specifier: 0.8.13 - version: 0.8.13(prisma@5.14.0) + version: 0.8.13(encoding@0.1.13)(prisma@5.14.0) supertest: specifier: ^6.3.4 version: 6.3.4 @@ -848,6 +851,10 @@ packages: '@amap/amap-jsapi-loader@1.0.1': resolution: {integrity: sha512-nPyLKt7Ow/ThHLkSvn2etQlUzqxmTVgK7bIgwdBRTg2HK5668oN7xVxkaiRe3YZEzGzfV2XgH5Jmu2T73ljejw==} + '@aminya/node-gyp-build@4.8.1-aminya.1': + resolution: {integrity: sha512-r5eD8cvhlXpr5H2TKKsDBlPUzmK8FaWQG4QQ0+AbHyGra2a1uZBa7r9DXCe4FSADw1sU9RAMRJH5/POm4lojFQ==} + hasBin: true + '@ampproject/remapping@2.2.1': resolution: {integrity: sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==} engines: {node: '>=6.0.0'} @@ -2543,6 +2550,14 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} + '@npmcli/agent@2.2.2': + resolution: {integrity: sha512-OrcNPXdpSl9UX7qPVRWbmWMCSXrcDa2M9DvrbOTj7ao1S4PlqVFYv9/yLKMkrJKZ/V5A/kDBC690or307i26Og==} + engines: {node: ^16.14.0 || >=18.0.0} + + '@npmcli/fs@3.1.1': + resolution: {integrity: sha512-q9CRWjpHCMIh5sVyefoD1cA7PkvILqCZsnSOEUUivORLjxCO/Irmue2DprETiNgEqktDBZaM1Bi+jrarx1XdCg==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + '@octokit/auth-token@4.0.0': resolution: {integrity: sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==} engines: {node: '>= 18'} @@ -4550,6 +4565,10 @@ packages: resolution: {integrity: sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==} hasBin: true + abbrev@2.0.0: + resolution: {integrity: sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + abort-controller@3.0.0: resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} engines: {node: '>=6.5'} @@ -4628,6 +4647,10 @@ packages: resolution: {integrity: sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==} engines: {node: '>= 14'} + agent-base@7.1.1: + resolution: {integrity: sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==} + engines: {node: '>= 14'} + agentkeepalive@4.5.0: resolution: {integrity: sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==} engines: {node: '>= 8.0.0'} @@ -5112,6 +5135,10 @@ packages: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} + cacache@18.0.4: + resolution: {integrity: sha512-B+L5iIa9mgcjLbliir2th36yEwPftrzteHYujzsx3dFP/31GCHcIeS8f5MGd80odLOjaOvSpU3EEAmRQptkxLQ==} + engines: {node: ^16.14.0 || >=18.0.0} + cache-manager@5.7.2: resolution: {integrity: sha512-YJ4YL4hCbn2P11vK85eo1W8nF1L9FBnRvqzRmGEy0qwNxojrsKe8U09zvRoQFo1hidbw4wfTsyce8HIo8Pvvyw==} engines: {node: '>= 18'} @@ -6363,6 +6390,9 @@ packages: resolution: {integrity: sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==} engines: {node: '>= 0.8'} + encoding@0.1.13: + resolution: {integrity: sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==} + end-of-stream@1.4.4: resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==} @@ -6408,6 +6438,9 @@ packages: eol@0.9.1: resolution: {integrity: sha512-Ds/TEoZjwggRoz/Q2O7SE3i4Jm66mqTDfmdHdq/7DKVk3bro9Q8h6WdXKdPqFLMoqxrDK5SVRzHVPOS6uuGtrg==} + err-code@2.0.3: + resolution: {integrity: sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==} + errno@0.1.8: resolution: {integrity: sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==} hasBin: true @@ -6577,6 +6610,9 @@ packages: resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} engines: {node: '>=6'} + exponential-backoff@3.1.1: + resolution: {integrity: sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==} + express-async-errors@3.1.1: resolution: {integrity: sha512-h6aK1da4tpqWSbyCa3FxB/V6Ehd4EEB15zyQq9qe75OZBp0krinNKuH4rAY+S/U/2I36vdLAUFSjQJ+TFmODng==} peerDependencies: @@ -6856,6 +6892,10 @@ packages: resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} engines: {node: '>= 8'} + fs-minipass@3.0.3: + resolution: {integrity: sha512-XUBA9XClHbnJWSfBzjkm6RvPsyg3sryZt06BEQoXcF7EK/xpGaQYJgQKDJSUH5SGZ76Y7pFx1QBnXz09rU5Fbw==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + fs-mkdirp-stream@1.0.0: resolution: {integrity: sha512-+vSd9frUnapVC2RZYfL3FCB2p3g4TBhaUmrsWlSudsGdnxIuUvBB2QM1VZeBtc49QFwrp+wQLrDs3+xxDgI5gQ==} engines: {node: '>= 0.10'} @@ -7531,6 +7571,10 @@ packages: inversify@5.1.1: resolution: {integrity: sha512-j8grHGDzv1v+8T1sAQ+3boTCntFPfvxLCkNcxB1J8qA0lUN+fAlSyYd+RXKvaPRL4AGyPxViutBEJHNXOyUdFQ==} + ip-address@9.0.5: + resolution: {integrity: sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==} + engines: {node: '>= 12'} + ip@1.1.8: resolution: {integrity: sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==} @@ -7673,6 +7717,9 @@ packages: resolution: {integrity: sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==} engines: {node: '>=12'} + is-lambda@1.0.1: + resolution: {integrity: sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==} + is-localhost-ip@2.0.0: resolution: {integrity: sha512-vlgs2cSgMOfnKU8c1ewgKPyum9rVrjjLLW2HBdL5i0iAJjOs8NY55ZBd/hqUTaYR0EO9CKZd3hVSC2HlIbygTQ==} engines: {node: '>=12'} @@ -7839,6 +7886,10 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + isexe@3.1.1: + resolution: {integrity: sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==} + engines: {node: '>=16'} + isobject@3.0.1: resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==} engines: {node: '>=0.10.0'} @@ -7920,6 +7971,9 @@ packages: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} hasBin: true + jsbn@1.1.0: + resolution: {integrity: sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==} + jsesc@0.5.0: resolution: {integrity: sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==} hasBin: true @@ -8312,6 +8366,10 @@ packages: make-error@1.3.6: resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} + make-fetch-happen@13.0.1: + resolution: {integrity: sha512-cKTUFc/rbKUd/9meOvgrpJ2WrNzymt6jfRDdwg5UCnVzv9dTpEj9JS5m3wtziXVCjluIXyL8pcaukYqezIzZQA==} + engines: {node: ^16.14.0 || >=18.0.0} + mana-common@0.3.2: resolution: {integrity: sha512-1oylLR9CcyshQcTiBdM96HxIoaA413eudpo1INiOCwyZE554TDJNUD0zrIjmeBvw8CBAjukzaAHn2gn0hZphIg==} @@ -8800,6 +8858,26 @@ packages: minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + minipass-collect@2.0.1: + resolution: {integrity: sha512-D7V8PO9oaz7PWGLbCACuI1qEOsq7UKfLotx/C0Aet43fCUB/wfQ7DYeq2oR/svFJGYDHPr38SHATeaj/ZoKHKw==} + engines: {node: '>=16 || 14 >=14.17'} + + minipass-fetch@3.0.5: + resolution: {integrity: sha512-2N8elDQAtSnFV0Dk7gt15KHsS0Fyz6CbYZ360h0WTYV1Ty46li3rAXVOQj1THMNLdmrD9Vt5pBPtWtVkpwGBqg==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + + minipass-flush@1.0.5: + resolution: {integrity: sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw==} + engines: {node: '>= 8'} + + minipass-pipeline@1.2.4: + resolution: {integrity: sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A==} + engines: {node: '>=8'} + + minipass-sized@1.0.3: + resolution: {integrity: sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g==} + engines: {node: '>=8'} + minipass@3.3.6: resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} engines: {node: '>=8'} @@ -9012,6 +9090,9 @@ packages: resolution: {integrity: sha512-JJ98b02z16ILv7859irtXn4oUaFWADtvkzy2c0IAatNVX2Mc9Yoh8z6hZInn3QwvMEYhHuQloYi+TTQy67SIdQ==} engines: {node: '>=10'} + node-addon-api@7.1.1: + resolution: {integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==} + node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} @@ -9056,6 +9137,11 @@ packages: resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==} engines: {node: '>= 6.13.0'} + node-gyp@10.2.0: + resolution: {integrity: sha512-sp3FonBAaFe4aYTcFdZUn2NYkbP7xroPGYvQmP4Nl5PxamznItBnNCgjrVTKrEfQynInMsJvZrdmqUnysCJ8rw==} + engines: {node: ^16.14.0 || >=18.0.0} + hasBin: true + node-mocks-http@1.13.0: resolution: {integrity: sha512-lArD6sJMPJ53WF50GX0nJ89B1nkV1TdMvNwq8WXXFrUXF80ujSyye1T30mgiHh4h2It0/svpF3C4kZ2OAONVlg==} engines: {node: '>=14'} @@ -9067,6 +9153,11 @@ packages: resolution: {integrity: sha512-cfrYUk16e67Ks051i4CntM9kshRYei1/o/Gi8K1d+R34OIs21xdFnW7Pt7EucmVKA0LKtqUGNcjMZ7ehjl49mQ==} engines: {node: '>=6.0.0'} + nopt@7.2.1: + resolution: {integrity: sha512-taM24ViiimT/XntxbPyJQzCG+p4EKOpgD3mxFwW38mGjVUrfERQOeY4EDHjdnptttfHuHQXFx+lTP08Q+mLa/w==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + hasBin: true + normalize-package-data@2.5.0: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} @@ -10036,6 +10127,10 @@ packages: probe.gl@3.6.0: resolution: {integrity: sha512-19JydJWI7+DtR4feV+pu4Mn1I5TAc0xojuxVgZdXIyfmTLfUaFnk4OloWK1bKbPtkgGKLr2lnbnCXmpZEcEp9g==} + proc-log@4.2.0: + resolution: {integrity: sha512-g8+OnU/L2v+wyiVK+D5fA34J7EH8jZ8DDlvwhRCMxmMj7UCBvxiO1mGeN+36JXIKF4zevU4kRBd8lVgG9vLelA==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} @@ -10051,6 +10146,10 @@ packages: resolution: {integrity: sha512-zLaJ9b8hnC564fnJH6NFSOGZYYdzrAJn2JUUIwzoQb32fG2QAakpDNM+CZo1km6keXkRXRM+hml1BFAPVnPkxg==} engines: {node: '>=16'} + promise-retry@2.0.1: + resolution: {integrity: sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==} + engines: {node: '>=10'} + promise.allsettled@1.0.7: resolution: {integrity: sha512-hezvKvQQmsFkOdrZfYxUxkyxl8mgFQeT259Ajj9PXdbg9VzBCWrItOev72JyWxkCD5VSSqAeHmlN3tWx4DlmsA==} engines: {node: '>= 0.4'} @@ -11088,6 +11187,10 @@ packages: resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + retry@0.12.0: + resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==} + engines: {node: '>= 4'} + retry@0.13.1: resolution: {integrity: sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==} engines: {node: '>= 4'} @@ -11435,10 +11538,18 @@ packages: resolution: {integrity: sha512-8zuqoLv1aP/66PHF5TqwJ7Czm3Yv32urJQHrVyhD7mmA6d61Zv8cIXQYPTWwmg6qlupnPvs/QKDmfa4P/qct2g==} engines: {node: '>= 14'} + socks-proxy-agent@8.0.4: + resolution: {integrity: sha512-GNAq/eg8Udq2x0eNiFkr9gRg5bA7PXEWagQdeRX4cPSG+X/8V38v637gim9bjFptMk1QWsCTr0ttrJEiXbNnRw==} + engines: {node: '>= 14'} + socks@2.7.1: resolution: {integrity: sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==} engines: {node: '>= 10.13.0', npm: '>= 3.0.0'} + socks@2.8.3: + resolution: {integrity: sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==} + engines: {node: '>= 10.0.0', npm: '>= 3.0.0'} + sonner@1.4.3: resolution: {integrity: sha512-SArYlHbkjqRuLiR0iGY2ZSr09oOrxw081ZZkQPfXrs8aZQLIBOLOdzTYxGJB5yIZ7qL56UEPmrX1YqbODwG0Lw==} peerDependencies: @@ -11546,6 +11657,9 @@ packages: sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} + sprintf-js@1.1.3: + resolution: {integrity: sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==} + srcset@1.0.0: resolution: {integrity: sha512-UH8e80l36aWnhACzjdtLspd4TAWldXJMa45NuOkTTU+stwekswObdqM63TtQixN4PPd/vO/kxLa6RD+tUPeFMg==} engines: {node: '>=0.10.0'} @@ -11554,6 +11668,10 @@ packages: resolution: {integrity: sha512-wvLeHgcVHKO8Sc/H/5lkGreJQVeYMm9rlmt8PuR1xE31rIuXhuzznUUqAt8MqLhB3MqJdFzlNAfpcWnxiFUcPw==} engines: {node: '>=12'} + ssri@10.0.6: + resolution: {integrity: sha512-MGrFH9Z4NP9Iyhqn16sDtBpRRNJ0Y2hNa6D65h736fVSaPCHr4DM4sWUNvVaSuC+0OBGhwsrydQwmgfg5LncqQ==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + stack-generator@2.0.10: resolution: {integrity: sha512-mwnua/hkqM6pF4k8SnmZ2zfETsRUpWXREfA/goT8SLCV4iOFa4bzOX2nDipWAZFPTjLvQB82f5yaodMVhK0yJQ==} @@ -12284,6 +12402,14 @@ packages: resolution: {integrity: sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==} engines: {node: '>=0.10.0'} + unique-filename@3.0.0: + resolution: {integrity: sha512-afXhuC55wkAmZ0P18QsVE6kp8JaxrEokN2HGIoIVv2ijHQd419H0+6EigAFcIzXeMIkcIkNBpB3L/DXB3cTS/g==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + + unique-slug@4.0.0: + resolution: {integrity: sha512-WrcA6AyEfqDX5bWige/4NQfPZMtASNVxdmWR76WESYQVAACSgWcR6e9i0mofqqBxYFtL4oAxPIptY73/0YE1DQ==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + unique-stream@2.3.1: resolution: {integrity: sha512-2nY4TnBE70yoxHkDli7DMazpWiP7xMdCYqU2nBRO0UB+ZpEkGsSija7MvmvnZFUeC+mrgiUfcHSr3LmRFIg4+A==} @@ -12735,6 +12861,11 @@ packages: engines: {node: '>= 8'} hasBin: true + which@4.0.0: + resolution: {integrity: sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==} + engines: {node: ^16.13.0 || >=18.0.0} + hasBin: true + why-is-node-running@2.2.2: resolution: {integrity: sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==} engines: {node: '>=8'} @@ -12912,6 +13043,10 @@ packages: yup@1.3.3: resolution: {integrity: sha512-v8QwZSsHH2K3/G9WSkp6mZKO+hugKT1EmnMqLNUcfu51HU9MDyhlETT/JgtzprnrnQHPWsjc6MUDMBp/l9fNnw==} + zeromq@6.0.4: + resolution: {integrity: sha512-VEkrYixtqrFmkV2YTJDUmOR3qNJoG/9U+ETxw4LcUNqoJ22AdIo/Wv5asgP1oaV1PIziimaOitVqWz4+j9YJsQ==} + engines: {node: '>= 10.2', pnpm: '>= 9'} + zip-stream@4.1.1: resolution: {integrity: sha512-9qv4rlDiopXg4E69k+vMHjNN63YFMe9sZMrdlvKnCjlCRWeCBswPPMPUfx+ipsAWq1LXHe70RcbaHdJJpS6hyQ==} engines: {node: '>= 10'} @@ -13063,6 +13198,8 @@ snapshots: '@amap/amap-jsapi-loader@1.0.1': {} + '@aminya/node-gyp-build@4.8.1-aminya.1': {} + '@ampproject/remapping@2.2.1': dependencies: '@jridgewell/gen-mapping': 0.3.5 @@ -15598,12 +15735,12 @@ snapshots: '@hutson/parse-repository-url@5.0.0': {} - '@i18next-toolkit/cli@1.4.3(buffer@6.0.3)(openai@4.63.0(zod@3.22.2))(typescript@5.5.4)': + '@i18next-toolkit/cli@1.4.3(buffer@6.0.3)(encoding@0.1.13)(openai@4.63.0(encoding@0.1.13)(zod@3.22.2))(typescript@5.5.4)': dependencies: '@i18next-toolkit/extractor': 1.1.0(buffer@6.0.3) '@i18next-toolkit/scanner': 1.0.0 - '@langchain/core': 0.2.27(openai@4.63.0(zod@3.22.2)) - '@langchain/openai': 0.2.7 + '@langchain/core': 0.2.27(openai@4.63.0(encoding@0.1.13)(zod@3.22.2)) + '@langchain/openai': 0.2.7(encoding@0.1.13) bing-translate-api: 4.0.2 cosmiconfig: 9.0.0(typescript@5.5.4) dotenv: 16.4.5 @@ -15630,12 +15767,12 @@ snapshots: transitivePeerDependencies: - buffer - '@i18next-toolkit/react@1.1.0(@types/react@18.2.78)(buffer@6.0.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + '@i18next-toolkit/react@1.1.0(@types/react@18.2.78)(buffer@6.0.3)(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@types/react': 18.2.78 crc: 4.3.2(buffer@6.0.3) i18next: 23.10.0 - i18next-http-backend: 2.4.3 + i18next-http-backend: 2.4.3(encoding@0.1.13) react: 18.2.0 react-i18next: 14.0.5(i18next@23.10.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) transitivePeerDependencies: @@ -15731,13 +15868,13 @@ snapshots: '@jsdevtools/ono@7.1.3': {} - '@langchain/core@0.2.27(openai@4.63.0(zod@3.22.2))': + '@langchain/core@0.2.27(openai@4.63.0(encoding@0.1.13)(zod@3.22.2))': dependencies: ansi-styles: 5.2.0 camelcase: 6.3.0 decamelize: 1.2.0 js-tiktoken: 1.0.14 - langsmith: 0.1.59(openai@4.63.0(zod@3.22.2)) + langsmith: 0.1.59(openai@4.63.0(encoding@0.1.13)(zod@3.22.2)) mustache: 4.2.0 p-queue: 6.6.2 p-retry: 4.6.2 @@ -15747,13 +15884,13 @@ snapshots: transitivePeerDependencies: - openai - '@langchain/core@0.2.27(openai@4.63.0(zod@3.23.8))': + '@langchain/core@0.2.27(openai@4.63.0(encoding@0.1.13)(zod@3.23.8))': dependencies: ansi-styles: 5.2.0 camelcase: 6.3.0 decamelize: 1.2.0 js-tiktoken: 1.0.14 - langsmith: 0.1.59(openai@4.63.0(zod@3.23.8)) + langsmith: 0.1.59(openai@4.63.0(encoding@0.1.13)(zod@3.23.8)) mustache: 4.2.0 p-queue: 6.6.2 p-retry: 4.6.2 @@ -15763,11 +15900,11 @@ snapshots: transitivePeerDependencies: - openai - '@langchain/openai@0.2.7': + '@langchain/openai@0.2.7(encoding@0.1.13)': dependencies: - '@langchain/core': 0.2.27(openai@4.63.0(zod@3.23.8)) + '@langchain/core': 0.2.27(openai@4.63.0(encoding@0.1.13)(zod@3.23.8)) js-tiktoken: 1.0.14 - openai: 4.63.0(zod@3.23.8) + openai: 4.63.0(encoding@0.1.13)(zod@3.23.8) zod: 3.23.8 zod-to-json-schema: 3.22.5(zod@3.23.8) transitivePeerDependencies: @@ -15942,6 +16079,20 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.15.0 + '@npmcli/agent@2.2.2': + dependencies: + agent-base: 7.1.0 + http-proxy-agent: 7.0.2 + https-proxy-agent: 7.0.5 + lru-cache: 10.4.3 + socks-proxy-agent: 8.0.4 + transitivePeerDependencies: + - supports-color + + '@npmcli/fs@3.1.1': + dependencies: + semver: 7.6.3 + '@octokit/auth-token@4.0.0': {} '@octokit/core@5.0.2': @@ -16090,7 +16241,7 @@ snapshots: '@prisma/fetch-engine': 5.14.0 '@prisma/get-platform': 5.14.0 - '@prisma/fetch-engine@4.16.2': + '@prisma/fetch-engine@4.16.2(encoding@0.1.13)': dependencies: '@prisma/debug': 4.16.2 '@prisma/get-platform': 4.16.2 @@ -16101,7 +16252,7 @@ snapshots: http-proxy-agent: 7.0.0 https-proxy-agent: 7.0.0 kleur: 4.1.5 - node-fetch: 2.6.11 + node-fetch: 2.6.11(encoding@0.1.13) p-filter: 2.1.0 p-map: 4.0.0 p-retry: 4.6.2 @@ -16163,19 +16314,19 @@ snapshots: dependencies: '@prisma/debug': 5.14.0 - '@prisma/internals@4.16.2': + '@prisma/internals@4.16.2(encoding@0.1.13)': dependencies: '@antfu/ni': 0.21.4 '@opentelemetry/api': 1.4.1 '@prisma/debug': 4.16.2 '@prisma/engines': 4.16.2 - '@prisma/fetch-engine': 4.16.2 + '@prisma/fetch-engine': 4.16.2(encoding@0.1.13) '@prisma/generator-helper': 4.16.2 '@prisma/get-platform': 4.16.2 '@prisma/prisma-fmt-wasm': 4.16.1-1.4bc8b6e1b66cb932731fb1bdbbc550d1e010de81 archiver: 5.3.1 arg: 5.0.2 - checkpoint-client: 1.1.24 + checkpoint-client: 1.1.24(encoding@0.1.13) cli-truncate: 2.1.0 dotenv: 16.0.3 escape-string-regexp: 4.0.0 @@ -16191,7 +16342,7 @@ snapshots: is-wsl: 2.2.0 kleur: 4.1.5 new-github-issue-url: 0.2.1 - node-fetch: 2.6.11 + node-fetch: 2.6.11(encoding@0.1.13) npm-packlist: 5.1.3 open: 7.4.2 p-map: 4.0.0 @@ -18727,6 +18878,8 @@ snapshots: jsonparse: 1.3.1 through: 2.3.8 + abbrev@2.0.0: {} + abort-controller@3.0.0: dependencies: event-target-shim: 5.0.1 @@ -18796,6 +18949,12 @@ snapshots: transitivePeerDependencies: - supports-color + agent-base@7.1.1: + dependencies: + debug: 4.3.7 + transitivePeerDependencies: + - supports-color + agentkeepalive@4.5.0: dependencies: humanize-ms: 1.2.1 @@ -19483,6 +19642,21 @@ snapshots: cac@6.7.14: {} + cacache@18.0.4: + dependencies: + '@npmcli/fs': 3.1.1 + fs-minipass: 3.0.3 + glob: 10.4.5 + lru-cache: 10.4.3 + minipass: 7.1.2 + minipass-collect: 2.0.1 + minipass-flush: 1.0.5 + minipass-pipeline: 1.2.4 + p-map: 4.0.0 + ssri: 10.0.6 + tar: 6.2.1 + unique-filename: 3.0.0 + cache-manager@5.7.2: dependencies: eventemitter3: 5.0.1 @@ -19625,14 +19799,14 @@ snapshots: dependencies: get-func-name: 2.0.2 - checkpoint-client@1.1.24: + checkpoint-client@1.1.24(encoding@0.1.13): dependencies: ci-info: 3.8.0 env-paths: 2.2.1 fast-write-atomic: 0.2.1 make-dir: 3.1.0 ms: 2.1.3 - node-fetch: 2.6.11 + node-fetch: 2.6.11(encoding@0.1.13) uuid: 9.0.0 transitivePeerDependencies: - encoding @@ -20183,9 +20357,9 @@ snapshots: dependencies: cross-spawn: 7.0.3 - cross-fetch@4.0.0: + cross-fetch@4.0.0(encoding@0.1.13): dependencies: - node-fetch: 2.7.0 + node-fetch: 2.7.0(encoding@0.1.13) transitivePeerDependencies: - encoding @@ -20911,6 +21085,11 @@ snapshots: encodeurl@1.0.2: {} + encoding@0.1.13: + dependencies: + iconv-lite: 0.6.3 + optional: true + end-of-stream@1.4.4: dependencies: once: 1.4.0 @@ -20970,6 +21149,8 @@ snapshots: eol@0.9.1: {} + err-code@2.0.3: {} + errno@0.1.8: dependencies: prr: 1.0.1 @@ -21215,6 +21396,8 @@ snapshots: expand-template@2.0.3: {} + exponential-backoff@3.1.1: {} + express-async-errors@3.1.1(express@4.18.2): dependencies: express: 4.18.2 @@ -21544,6 +21727,10 @@ snapshots: dependencies: minipass: 3.3.6 + fs-minipass@3.0.3: + dependencies: + minipass: 7.1.2 + fs-mkdirp-stream@1.0.0: dependencies: graceful-fs: 4.2.11 @@ -22326,9 +22513,9 @@ snapshots: hyphenate-style-name@1.0.4: {} - i18next-http-backend@2.4.3: + i18next-http-backend@2.4.3(encoding@0.1.13): dependencies: - cross-fetch: 4.0.0 + cross-fetch: 4.0.0(encoding@0.1.13) transitivePeerDependencies: - encoding @@ -22493,6 +22680,11 @@ snapshots: inversify@5.1.1: {} + ip-address@9.0.5: + dependencies: + jsbn: 1.1.0 + sprintf-js: 1.1.3 + ip@1.1.8: {} ip@2.0.0: {} @@ -22606,6 +22798,8 @@ snapshots: is-interactive@2.0.0: {} + is-lambda@1.0.1: {} + is-localhost-ip@2.0.0: {} is-map@2.0.2: {} @@ -22725,6 +22919,8 @@ snapshots: isexe@2.0.0: {} + isexe@3.1.1: {} + isobject@3.0.1: {} isolated-vm@4.7.2: @@ -22818,6 +23014,8 @@ snapshots: dependencies: argparse: 2.0.1 + jsbn@1.1.0: {} + jsesc@0.5.0: {} jsesc@2.5.2: {} @@ -22926,7 +23124,7 @@ snapshots: kuler@2.0.0: {} - langsmith@0.1.59(openai@4.63.0(zod@3.22.2)): + langsmith@0.1.59(openai@4.63.0(encoding@0.1.13)(zod@3.22.2)): dependencies: '@types/uuid': 10.0.0 commander: 10.0.1 @@ -22935,9 +23133,9 @@ snapshots: semver: 7.6.3 uuid: 10.0.0 optionalDependencies: - openai: 4.63.0(zod@3.22.2) + openai: 4.63.0(encoding@0.1.13)(zod@3.22.2) - langsmith@0.1.59(openai@4.63.0(zod@3.23.8)): + langsmith@0.1.59(openai@4.63.0(encoding@0.1.13)(zod@3.23.8)): dependencies: '@types/uuid': 10.0.0 commander: 10.0.1 @@ -22946,7 +23144,7 @@ snapshots: semver: 7.6.3 uuid: 10.0.0 optionalDependencies: - openai: 4.63.0(zod@3.23.8) + openai: 4.63.0(encoding@0.1.13)(zod@3.23.8) latest-version@7.0.0: dependencies: @@ -23217,6 +23415,23 @@ snapshots: make-error@1.3.6: {} + make-fetch-happen@13.0.1: + dependencies: + '@npmcli/agent': 2.2.2 + cacache: 18.0.4 + http-cache-semantics: 4.1.1 + is-lambda: 1.0.1 + minipass: 7.1.2 + minipass-fetch: 3.0.5 + minipass-flush: 1.0.5 + minipass-pipeline: 1.2.4 + negotiator: 0.6.3 + proc-log: 4.2.0 + promise-retry: 2.0.1 + ssri: 10.0.6 + transitivePeerDependencies: + - supports-color + mana-common@0.3.2: {} mana-syringe@0.2.2: @@ -24176,6 +24391,30 @@ snapshots: minimist@1.2.8: {} + minipass-collect@2.0.1: + dependencies: + minipass: 7.1.2 + + minipass-fetch@3.0.5: + dependencies: + minipass: 7.1.2 + minipass-sized: 1.0.3 + minizlib: 2.1.2 + optionalDependencies: + encoding: 0.1.13 + + minipass-flush@1.0.5: + dependencies: + minipass: 3.3.6 + + minipass-pipeline@1.2.4: + dependencies: + minipass: 3.3.6 + + minipass-sized@1.0.3: + dependencies: + minipass: 3.3.6 + minipass@3.3.6: dependencies: yallist: 4.0.0 @@ -24400,6 +24639,8 @@ snapshots: dependencies: semver: 7.6.3 + node-addon-api@7.1.1: {} + node-domexception@1.0.0: {} node-emoji@2.1.3: @@ -24417,13 +24658,17 @@ snapshots: node-fetch-native@1.6.4: {} - node-fetch@2.6.11: + node-fetch@2.6.11(encoding@0.1.13): dependencies: whatwg-url: 5.0.0 + optionalDependencies: + encoding: 0.1.13 - node-fetch@2.7.0: + node-fetch@2.7.0(encoding@0.1.13): dependencies: whatwg-url: 5.0.0 + optionalDependencies: + encoding: 0.1.13 node-fetch@3.3.2: dependencies: @@ -24433,6 +24678,21 @@ snapshots: node-forge@1.3.1: {} + node-gyp@10.2.0: + dependencies: + env-paths: 2.2.1 + exponential-backoff: 3.1.1 + glob: 10.4.5 + graceful-fs: 4.2.11 + make-fetch-happen: 13.0.1 + nopt: 7.2.1 + proc-log: 4.2.0 + semver: 7.6.3 + tar: 6.2.1 + which: 4.0.0 + transitivePeerDependencies: + - supports-color + node-mocks-http@1.13.0: dependencies: accepts: 1.3.8 @@ -24450,6 +24710,10 @@ snapshots: nodemailer@6.9.8: {} + nopt@7.2.1: + dependencies: + abbrev: 2.0.0 + normalize-package-data@2.5.0: dependencies: hosted-git-info: 2.8.9 @@ -24604,7 +24868,7 @@ snapshots: is-inside-container: 1.0.0 is-wsl: 2.2.0 - openai@4.63.0(zod@3.22.2): + openai@4.63.0(encoding@0.1.13)(zod@3.22.2): dependencies: '@types/node': 18.18.13 '@types/node-fetch': 2.6.11 @@ -24612,14 +24876,14 @@ snapshots: agentkeepalive: 4.5.0 form-data-encoder: 1.7.2 formdata-node: 4.4.1 - node-fetch: 2.7.0 + node-fetch: 2.7.0(encoding@0.1.13) optionalDependencies: zod: 3.22.2 transitivePeerDependencies: - encoding optional: true - openai@4.63.0(zod@3.23.8): + openai@4.63.0(encoding@0.1.13)(zod@3.23.8): dependencies: '@types/node': 18.18.13 '@types/node-fetch': 2.6.11 @@ -24627,7 +24891,7 @@ snapshots: agentkeepalive: 4.5.0 form-data-encoder: 1.7.2 formdata-node: 4.4.1 - node-fetch: 2.7.0 + node-fetch: 2.7.0(encoding@0.1.13) optionalDependencies: zod: 3.23.8 transitivePeerDependencies: @@ -25606,11 +25870,11 @@ snapshots: transitivePeerDependencies: - supports-color - prisma-zod-generator@0.8.13(prisma@5.14.0): + prisma-zod-generator@0.8.13(encoding@0.1.13)(prisma@5.14.0): dependencies: '@prisma/client': 4.16.2(prisma@5.14.0) '@prisma/generator-helper': 4.16.2 - '@prisma/internals': 4.16.2 + '@prisma/internals': 4.16.2(encoding@0.1.13) prettier: 2.8.8 tslib: 2.6.2 zod: 3.22.2 @@ -25632,6 +25896,8 @@ snapshots: '@probe.gl/log': 3.6.0 '@probe.gl/stats': 3.6.0 + proc-log@4.2.0: {} + process-nextick-args@2.0.1: {} process@0.11.10: {} @@ -25640,6 +25906,11 @@ snapshots: promise-coalesce@1.1.2: {} + promise-retry@2.0.1: + dependencies: + err-code: 2.0.3 + retry: 0.12.0 + promise.allsettled@1.0.7: dependencies: array.prototype.map: 1.0.6 @@ -27299,6 +27570,8 @@ snapshots: onetime: 5.1.2 signal-exit: 3.0.7 + retry@0.12.0: {} + retry@0.13.1: {} reusify@1.0.4: {} @@ -27761,11 +28034,24 @@ snapshots: transitivePeerDependencies: - supports-color + socks-proxy-agent@8.0.4: + dependencies: + agent-base: 7.1.1 + debug: 4.3.7 + socks: 2.8.3 + transitivePeerDependencies: + - supports-color + socks@2.7.1: dependencies: ip: 2.0.0 smart-buffer: 4.2.0 + socks@2.8.3: + dependencies: + ip-address: 9.0.5 + smart-buffer: 4.2.0 + sonner@1.4.3(react-dom@18.2.0(react@18.2.0))(react@18.2.0): dependencies: react: 18.2.0 @@ -27872,6 +28158,8 @@ snapshots: sprintf-js@1.0.3: {} + sprintf-js@1.1.3: {} + srcset@1.0.0: dependencies: array-uniq: 1.0.3 @@ -27879,6 +28167,10 @@ snapshots: srcset@4.0.0: {} + ssri@10.0.6: + dependencies: + minipass: 7.1.2 + stack-generator@2.0.10: dependencies: stackframe: 1.3.4 @@ -28770,6 +29062,14 @@ snapshots: is-extendable: 0.1.1 set-value: 2.0.1 + unique-filename@3.0.0: + dependencies: + unique-slug: 4.0.0 + + unique-slug@4.0.0: + dependencies: + imurmurhash: 0.1.4 + unique-stream@2.3.1: dependencies: json-stable-stringify-without-jsonify: 1.0.1 @@ -29442,6 +29742,10 @@ snapshots: dependencies: isexe: 2.0.0 + which@4.0.0: + dependencies: + isexe: 3.1.1 + why-is-node-running@2.2.2: dependencies: siginfo: 2.0.0 @@ -29604,6 +29908,16 @@ snapshots: toposort: 2.0.2 type-fest: 2.19.0 + zeromq@6.0.4: + dependencies: + '@aminya/node-gyp-build': 4.8.1-aminya.1 + cross-env: 7.0.3 + node-addon-api: 7.1.1 + node-gyp: 10.2.0 + shelljs: 0.8.5 + transitivePeerDependencies: + - supports-color + zip-stream@4.1.1: dependencies: archiver-utils: 3.0.4 diff --git a/src/client/api/socketio.ts b/src/client/api/socketio.ts index 53955a0..e5d50f5 100644 --- a/src/client/api/socketio.ts +++ b/src/client/api/socketio.ts @@ -109,7 +109,24 @@ export function useSocket() { return { socket, emit, subscribe }; } -export function useSocketSubscribe( +export function useSocketSubscribe( + name: K, + cb: (data: SubscribeEventData) => void +) { + const { subscribe } = useSocket(); + + const fn = useEvent(cb); + + useEffect(() => { + const unsubscribe = subscribe(name, fn); + + return () => { + unsubscribe(); + }; + }, [name]); +} + +export function useSocketSubscribeData( name: keyof SubscribeEventMap, defaultData: T ): T { diff --git a/src/client/components/server/AddServerStep.tsx b/src/client/components/server/AddServerStep.tsx index fc539d3..3de9be4 100644 --- a/src/client/components/server/AddServerStep.tsx +++ b/src/client/components/server/AddServerStep.tsx @@ -5,11 +5,11 @@ import { useWatch } from '../../hooks/useWatch'; import { Loading } from '../Loading'; import { without } from 'lodash-es'; import { useTranslation } from '@i18next-toolkit/react'; -import { useSocketSubscribe } from '@/api/socketio'; +import { useSocketSubscribeData } from '@/api/socketio'; import { ServerStatusInfo } from '../../../types'; function useServerMap(): Record { - const serverMap = useSocketSubscribe>( + const serverMap = useSocketSubscribeData>( 'onServerStatusUpdate', {} ); diff --git a/src/client/components/server/useServerMap.ts b/src/client/components/server/useServerMap.ts index 9442a2b..a2fc7b8 100644 --- a/src/client/components/server/useServerMap.ts +++ b/src/client/components/server/useServerMap.ts @@ -1,10 +1,10 @@ -import { useSocket, useSocketSubscribe } from '@/api/socketio'; +import { useSocket, useSocketSubscribeData } from '@/api/socketio'; import { ServerStatusInfo } from '../../../types'; import { useVisibilityChange } from '@/hooks/useVisibilityChange'; export function useServerMap(): Record { const { socket } = useSocket(); - const serverMap = useSocketSubscribe>( + const serverMap = useSocketSubscribeData>( 'onServerStatusUpdate', {} ); diff --git a/src/client/components/website/WebsiteLighthouseBtn.tsx b/src/client/components/website/WebsiteLighthouseBtn.tsx index e88e629..7844caa 100644 --- a/src/client/components/website/WebsiteLighthouseBtn.tsx +++ b/src/client/components/website/WebsiteLighthouseBtn.tsx @@ -28,6 +28,7 @@ import { useEvent } from '@/hooks/useEvent'; import { Badge } from '../ui/badge'; import { LuArrowRight, LuPlus } from 'react-icons/lu'; import { ROLES } from '@tianji/shared'; +import { useSocketSubscribe } from '@/api/socketio'; interface WebsiteLighthouseBtnProps { websiteId: string; @@ -55,6 +56,16 @@ export const WebsiteLighthouseBtn: React.FC = onError: defaultErrorHandler, }); + useSocketSubscribe('onLighthouseWorkCompleted', (data) => { + const { websiteId } = data; + if (websiteId !== props.websiteId) { + return; + } + + refetch(); + toast.info(t('Lighthouse report completed!')); + }); + const allData = useMemo(() => { if (!data) { return []; diff --git a/src/server/main.ts b/src/server/main.ts index 913adc6..82f5986 100644 --- a/src/server/main.ts +++ b/src/server/main.ts @@ -8,6 +8,7 @@ import { env } from './utils/env.js'; import { initCronjob } from './cronjob/index.js'; import { logger } from './utils/logger.js'; import { app } from './app.js'; +import { runMQWorker } from './mq/worker.js'; const port = env.port; @@ -19,6 +20,8 @@ initSocketio(httpServer); initCronjob(); +runMQWorker(); + monitorManager.startAll(); httpServer.listen(port, () => { diff --git a/src/server/mq/producer.ts b/src/server/mq/producer.ts new file mode 100644 index 0000000..01b390c --- /dev/null +++ b/src/server/mq/producer.ts @@ -0,0 +1,21 @@ +import zmq from 'zeromq'; +import { zmqUrl } from './shared.js'; +import { logger } from '../utils/logger.js'; + +const sock = new zmq.Push(); + +sock.bind(zmqUrl).then(() => { + logger.info('Producer bound to:', zmqUrl); +}); + +export async function sendBuildLighthouseMessageQueue( + workspaceId: string, + websiteId: string, + reportId: string, + url: string +) { + await sock.send([ + 'lighthouse', + JSON.stringify({ workspaceId, websiteId, reportId, url }), + ]); +} diff --git a/src/server/mq/shared.ts b/src/server/mq/shared.ts new file mode 100644 index 0000000..04879c6 --- /dev/null +++ b/src/server/mq/shared.ts @@ -0,0 +1 @@ +export const zmqUrl = 'tcp://127.0.0.1:12351'; diff --git a/src/server/mq/worker.ts b/src/server/mq/worker.ts new file mode 100644 index 0000000..31b0d05 --- /dev/null +++ b/src/server/mq/worker.ts @@ -0,0 +1,85 @@ +import zmq from 'zeromq'; +import { zmqUrl } from './shared.js'; +import { logger } from '../utils/logger.js'; +import { z } from 'zod'; +import { generateLighthouse } from '../utils/screenshot/lighthouse.js'; +import { get } from 'lodash-es'; +import { prisma } from '../model/_client.js'; +import { WebsiteLighthouseReportStatus } from '@prisma/client'; +import { subscribeEventBus } from '../ws/shared.js'; + +export async function runMQWorker() { + const sock = new zmq.Pull(); + sock.connect(zmqUrl); + + logger.info('Worker connected to:', zmqUrl); + + for await (const [_type, _msg] of sock) { + const type = String(_type); + const msg = String(_msg); + logger.info('Received message', type, msg); + + try { + if (type === 'lighthouse') { + await runLighthouseReportWorker(msg); + } + } catch (err) { + logger.error('MQ Worker throw error', { type, msg }, err); + } + } +} + +async function runLighthouseReportWorker(msg: string) { + const payload = z + .object({ + workspaceId: z.string(), + websiteId: z.string(), + reportId: z.string(), + url: z.string().url(), + }) + .parse(JSON.parse(msg)); + + try { + const result = await generateLighthouse(payload.url); + + logger.info('Successfully generated lighthouse report'); + + const performanceScore = + Number(get(result, ['categories', 'performance', 'score'], 0)) * 100; + const accessibilityScore = + Number(get(result, ['categories', 'accessibility', 'score'], 0)) * 100; + const bestPracticesScore = + Number(get(result, ['categories', 'best-practices', 'score'], 0)) * 100; + const seoScore = + Number(get(result, ['categories', 'seo', 'score'], 0)) * 100; + + await prisma.websiteLighthouseReport.update({ + where: { + id: payload.reportId, + }, + data: { + status: WebsiteLighthouseReportStatus.Success, + result: JSON.stringify(result), + performanceScore, + accessibilityScore, + bestPracticesScore, + seoScore, + }, + }); + } catch (err) { + logger.error('Failed to generate lighthouse report:', err); + await prisma.websiteLighthouseReport.update({ + where: { + id: payload.reportId, + }, + data: { + status: WebsiteLighthouseReportStatus.Failed, + errorMessage: String(err), + }, + }); + } finally { + subscribeEventBus.emit('onLighthouseWorkCompleted', payload.workspaceId, { + websiteId: payload.websiteId, + }); + } +} diff --git a/src/server/package.json b/src/server/package.json index 0947ff6..37b3838 100644 --- a/src/server/package.json +++ b/src/server/package.json @@ -70,6 +70,7 @@ "vite-express": "^0.13.0", "winston": "^3.11.0", "yup": "^1.3.3", + "zeromq": "^6.0.4", "zod": "^3.22.2", "zod-prisma": "0.5.4" }, diff --git a/src/server/trpc/routers/website.ts b/src/server/trpc/routers/website.ts index 57caf82..00858d5 100644 --- a/src/server/trpc/routers/website.ts +++ b/src/server/trpc/routers/website.ts @@ -34,11 +34,9 @@ import { import dayjs from 'dayjs'; import { fetchDataByCursor, WebsiteQueryFilters } from '../../utils/prisma.js'; import { WebsiteLighthouseReportStatus } from '@prisma/client'; -import { generateLighthouse } from '../../utils/screenshot/lighthouse.js'; import { WebsiteLighthouseReportModelSchema } from '../../prisma/zod/websitelighthousereport.js'; import { buildCursorResponseSchema } from '../../utils/schema.js'; -import { logger } from '../../utils/logger.js'; -import { get } from 'lodash-es'; +import { sendBuildLighthouseMessageQueue } from '../../mq/producer.js'; const websiteNameSchema = z.string().max(100); const websiteDomainSchema = z.union([ @@ -600,9 +598,9 @@ export const websiteRouter = router({ ) .output(z.string()) .mutation(async ({ input }) => { - const { websiteId, url } = input; + const { workspaceId, websiteId, url } = input; - const websiteInfo = await prisma.websiteLighthouseReport.create({ + const report = await prisma.websiteLighthouseReport.create({ data: { url, websiteId, @@ -611,48 +609,12 @@ export const websiteRouter = router({ }, }); - generateLighthouse(url) - .then(async (result) => { - logger.info('Successfully generated lighthouse report'); - - const performanceScore = - Number(get(result, ['categories', 'performance', 'score'], 0)) * - 100; - const accessibilityScore = - Number(get(result, ['categories', 'accessibility', 'score'], 0)) * - 100; - const bestPracticesScore = - Number(get(result, ['categories', 'best-practices', 'score'], 0)) * - 100; - const seoScore = - Number(get(result, ['categories', 'seo', 'score'], 0)) * 100; - - await prisma.websiteLighthouseReport.update({ - where: { - id: websiteInfo.id, - }, - data: { - status: WebsiteLighthouseReportStatus.Success, - result: JSON.stringify(result), - performanceScore, - accessibilityScore, - bestPracticesScore, - seoScore, - }, - }); - }) - .catch(async (err) => { - logger.error('Failed to generate lighthouse report:', err); - await prisma.websiteLighthouseReport.update({ - where: { - id: websiteInfo.id, - }, - data: { - status: WebsiteLighthouseReportStatus.Failed, - errorMessage: String(err), - }, - }); - }); + await sendBuildLighthouseMessageQueue( + workspaceId, + websiteId, + report.id, + url + ); return 'success'; }), diff --git a/src/server/ws/shared.ts b/src/server/ws/shared.ts index cdab798..bf22397 100644 --- a/src/server/ws/shared.ts +++ b/src/server/ws/shared.ts @@ -10,6 +10,7 @@ export interface SubscribeEventMap { onServerStatusUpdate: SubscribeEventFn>; onMonitorReceiveNewData: SubscribeEventFn; onReceiveFeedEvent: SubscribeEventFn>; + onLighthouseWorkCompleted: SubscribeEventFn<{ websiteId: string }>; } type SocketEventFn = (